From a40058cd0e6ae7b7486c6f0f95b183113bdce2e7 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 5 May 2015 19:35:25 -0500 Subject: [PATCH] rpcserver: Omit empty getrawtransaction->confirmations. This commit omits the confirmations field from the getrawtransactions RPC result when it's 0. Closes #420. --- btcjson/chainsvrresults.go | 2 +- btcjson/chainsvrwsntfns_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/btcjson/chainsvrresults.go b/btcjson/chainsvrresults.go index afe518aa..168d0034 100644 --- a/btcjson/chainsvrresults.go +++ b/btcjson/chainsvrresults.go @@ -318,7 +318,7 @@ type TxRawResult struct { Vin []Vin `json:"vin"` Vout []Vout `json:"vout"` BlockHash string `json:"blockhash,omitempty"` - Confirmations uint64 `json:"confirmations"` + Confirmations uint64 `json:"confirmations,omitempty"` Time int64 `json:"time,omitempty"` Blocktime int64 `json:"blocktime,omitempty"` } diff --git a/btcjson/chainsvrwsntfns_test.go b/btcjson/chainsvrwsntfns_test.go index cf76c01c..f09c0d06 100644 --- a/btcjson/chainsvrwsntfns_test.go +++ b/btcjson/chainsvrwsntfns_test.go @@ -167,7 +167,7 @@ func TestChainSvrWsNtfns(t *testing.T) { } return btcjson.NewTxAcceptedVerboseNtfn(txResult) }, - marshalled: `{"jsonrpc":"1.0","method":"txacceptedverbose","params":[{"hex":"001122","txid":"123","version":1,"locktime":4294967295,"vin":null,"vout":null,"confirmations":0}],"id":null}`, + marshalled: `{"jsonrpc":"1.0","method":"txacceptedverbose","params":[{"hex":"001122","txid":"123","version":1,"locktime":4294967295,"vin":null,"vout":null}],"id":null}`, unmarshalled: &btcjson.TxAcceptedVerboseNtfn{ RawTx: btcjson.TxRawResult{ Hex: "001122",