I have been working on converting some crypto pool software over to work with an incompatible coin. I believe I have it all about done. But this error keeps popping up and I just can't seem to figure out what the problem is. Here is my code:
type GetBalanceReply struct {
Unspent string `json:"unspent"`
}
type SendTransactionReply struct {
Hash string `json:"hash"`
}
type RPCClient struct {
sync.RWMutex
Url string
Name string
Account string
Password string
sick bool
sickRate int
successRate int
client *http.Client
}
type GetBlockReply struct {
Difficulty string `json:"bits"`
Hash string `json:"hash"`
MerkleTreeHash string `json:"merkle_tree_hash"`
Nonce string `json:"nonce"`
PrevHash string `json:"previous_block_hash"`
TimeStamp string `json:"time_stamp"`
Version string `json:"version"`
Mixhash string `json:"mixhash"`
Number string `json:"number"`
TransactionCount string `json:"transaction_count"`
}
type GetBlockReplyPart struct {
Number string `json:"number"`
Difficulty string `json:"bits"`
}
type TxReceipt struct {
TxHash string `json:"hash"`
}
type Tx struct {
Gas string `json:"gas"`
GasPrice string `json:"gasPrice"`
Hash string `json:"hash"`
}
type JSONRpcResp struct {
Id *json.RawMessage `json:"id"`
Result *json.RawMessage `json:"result"`
Balance *json.RawMessage `json:"balance"`
Transaction *json.RawMessage `json:"transaction"`
Error map[string]interface{} `json:"error"`
}
func (r *RPCClient) GetPendingBlock() (*GetBlockReplyPart, error) {
rpcResp, err := r.doPost(r.Url, "fetchheaderext", []interface{}{r.Account, r.Password, "pending"})
if err != nil {
return nil, err
}
if rpcResp.Result != nil {
var reply *GetBlockReplyPart
err = json.Unmarshal(*rpcResp.Result, &reply)
return reply, err
}
return nil, nil
}
func (r *RPCClient) GetBlockByHeight(height int64) (*GetBlockReply, error) {
//params := []interface{}{fmt.Sprintf("0x%x", height), true}
params := []interface{}{"-t", height}
return r.getBlockBy("fetch-header", params)
}
Whenever I run that manually in the wallet it displays:
"result": {
"bits": "7326472509313",
"hash": "060d0f6157d08bb294ad30f97a2c15c821ff46236281f118d65576b9e4a0ba27",
"merkle_tree_hash": "36936f36718e134e1eecaef05e66ebc4079811d8ee5a543f36d370335adc0801",
"nonce": "0",
"previous_block_hash": "10f4da59558fe41bab50a15864d1394462cd90836aecf52524f4cbce02a74a27",
"time_stamp": "1520718416",
"version": "1",
"mixhash": "0",
"number": "1011160",
"transaction_count": "1"
}'
But, the code errors out with "json: cannot unmarshal string into Go value of type map[string]interface {}"
Can anyone help me figure this one out? I've been hours on trying to figure it out on my own.