Add support for GetTransactionResult.

ok @jcvernaleo
This commit is contained in:
David Hill 2014-04-11 09:39:08 -04:00
parent d211c4c6c8
commit 75a237bc0d
3 changed files with 36 additions and 3 deletions

View file

@ -113,6 +113,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"`
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"`
@ -1027,6 +1052,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

View file

@ -342,6 +342,8 @@ var resulttests = []struct {
{"getinfo", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false},
{"getblock", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false},
{"getblock", []byte(`{"result":{"hash":"000000","confirmations":16007,"size":325648},"error":null,"id":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},
{"getrawtransaction", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false},
{"getrawtransaction", []byte(`{"error":null,"id":1,"result":{"hex":"somejunk","version":1}}`), false, true},
{"decoderawtransaction", []byte(`{"error":null,"id":1,"result":[{"a":"b"}]}`), false, false},

View file

@ -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/jsonapi.go ReadResultCmd 58.73% (74/126)
github.com/conformal/btcjson/jsoncmd.go LockUnspentCmd.UnmarshalJSON 57.89% (11/19)
github.com/conformal/btcjson/jsonapi.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)
@ -461,5 +461,5 @@ github.com/conformal/btcjson/jsonapi.go TlsRpcCommand 0.00% (0/1)
github.com/conformal/btcjson/jsoncmd.go unparsableCmd.Method 0.00% (0/1)
github.com/conformal/btcjson/jsoncmd.go unparsableCmd.Id 0.00% (0/1)
github.com/conformal/btcjson/jsoncmd.go newUnparsableCmd 0.00% (0/1)
github.com/conformal/btcjson --------------------------------------- 78.71% (2333/2964)
github.com/conformal/btcjson --------------------------------------- 78.75% (2338/2969)