Add support for GetTransactionResult.
ok @jcvernaleo
This commit is contained in:
parent
c6149949a2
commit
c2dd398b1e
3 changed files with 36 additions and 3 deletions
|
@ -95,6 +95,31 @@ type GetRawMempoolResult struct {
|
|||
Depends []string `json:"depends"`
|
||||
}
|
||||
|
||||
// GetTransactionDetailsResult models the details data from the gettransaction command.
|
||||
type GetTransactionDetailsResult struct {
|
||||
Account string `json:"account"`
|
||||
Address string `json:"address,omitempty"`
|
||||
Category string `json:"category"`
|
||||
Amount float64 `json:"amount"`
|
||||
Fee float64 `json:"fee,omitempty"`
|
||||
}
|
||||
|
||||
// GetTransactionResult models the data from the gettransaction command.
|
||||
type GetTransactionResult struct {
|
||||
Amount float64 `json:"amount"`
|
||||
Fee float64 `json:"fee,omitempty"`
|
||||
Confirmations int64 `json:"confirmations"`
|
||||
BlockHash string `json:"blockhash"`
|
||||
BlockIndex int64 `json:"blockindex"`
|
||||
BlockTime int64 `json:"blocktime"`
|
||||
TxID string `json:"txid"`
|
||||
WalletConflicts []string `json:"walletconflicts"`
|
||||
Time int64 `json:"time"`
|
||||
TimeReceived int64 `json:"timereceived"`
|
||||
Details []GetTransactionDetailsResult `json:"details"`
|
||||
Hex string `json:"hex"`
|
||||
}
|
||||
|
||||
// ListTransactionsResult models the data from the listtransactions command.
|
||||
type ListTransactionsResult struct {
|
||||
Account string `json:"account"`
|
||||
|
@ -428,6 +453,12 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
|
|||
result.Result = res
|
||||
}
|
||||
}
|
||||
case "gettransaction":
|
||||
var res GetTransactionResult
|
||||
err = json.Unmarshal(objmap["result"], &res)
|
||||
if err == nil {
|
||||
result.Result = res
|
||||
}
|
||||
case "getwork":
|
||||
// getwork can either return a JSON object or a boolean
|
||||
// depending on whether or not data was provided. Choose the
|
||||
|
|
|
@ -35,6 +35,8 @@ var resulttests = []struct {
|
|||
{"getblock", []byte(`{"result":{"hash":"000000","confirmations":16007,"size":325648},"error":null,"id":1}`), false, true},
|
||||
{"getrawtransaction", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false},
|
||||
{"getrawtransaction", []byte(`{"error":null,"id":1,"result":{"hex":"somejunk","version":1}}`), false, true},
|
||||
{"gettransaction", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false},
|
||||
{"gettransaction", []byte(`{"error":null,"id":1,"result":{"Amount":0.0}}`), false, true},
|
||||
{"decoderawtransaction", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false},
|
||||
{"decoderawtransaction", []byte(`{"error":null,"id":1,"result":{"Txid":"something"}}`), false, true},
|
||||
{"getaddressesbyaccount", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false},
|
||||
|
|
|
@ -436,12 +436,12 @@ github.com/conformal/btcjson/jsoncmd.go VerifyMessageCmd.UnmarshalJSON 68.42
|
|||
github.com/conformal/btcjson/jsoncmd.go SignRawTransactionCmd.MarshalJSON 66.67% (8/12)
|
||||
github.com/conformal/btcjson/jsoncmd.go NewLockUnspentCmd 66.67% (4/6)
|
||||
github.com/conformal/btcjson/jsoncmd.go NewAddNodeCmd 66.67% (2/3)
|
||||
github.com/conformal/btcjson/jsoncmd.go GetBlockCmd.MarshalJSON 63.64% (7/11)
|
||||
github.com/conformal/btcjson/jsonfxns.go jsonRpcSend 62.50% (10/16)
|
||||
github.com/conformal/btcjson/jsonapi.go rpcCommand 61.54% (8/13)
|
||||
github.com/conformal/btcjson/jsoncmd.go GetBlockCmd.MarshalJSON 60.00% (6/10)
|
||||
github.com/conformal/btcjson/jsoncmd.go GetTxOutCmd.UnmarshalJSON 59.09% (13/22)
|
||||
github.com/conformal/btcjson/jsonresults.go ReadResultCmd 58.73% (74/126)
|
||||
github.com/conformal/btcjson/jsoncmd.go LockUnspentCmd.UnmarshalJSON 57.89% (11/19)
|
||||
github.com/conformal/btcjson/jsonresults.go ReadResultCmd 57.38% (70/122)
|
||||
github.com/conformal/btcjson/jsonapi.go rpcRawCommand 53.33% (8/15)
|
||||
github.com/conformal/btcjson/jsoncmd.go GetBlockCmd.UnmarshalJSON 50.00% (12/24)
|
||||
github.com/conformal/btcjson/cmdhelp.go GetHelpString 50.00% (3/6)
|
||||
|
@ -462,5 +462,5 @@ github.com/conformal/btcjson/jsoncmd.go unparsableCmd.Method 0.00% (0/1)
|
|||
github.com/conformal/btcjson/jsonapi.go TlsRpcRawCommand 0.00% (0/1)
|
||||
github.com/conformal/btcjson/jsonapi.go RpcRawCommand 0.00% (0/1)
|
||||
github.com/conformal/btcjson/jsonresults.go Vin.IsCoinBase 0.00% (0/1)
|
||||
github.com/conformal/btcjson --------------------------------------- 78.58% (2333/2969)
|
||||
github.com/conformal/btcjson --------------------------------------- 78.61% (2338/2974)
|
||||
|
||||
|
|
Loading…
Reference in a new issue