btcjson: Add more fields to ListTransactionsResult

These include Abandoned, BIP125Replaceable, and Trusted.
This commit is contained in:
David Hill 2017-01-23 15:03:54 -05:00
parent 07f8c84fb1
commit e8b9147ba2
2 changed files with 35 additions and 26 deletions

View file

@ -58,9 +58,11 @@ type InfoWalletResult struct {
// ListTransactionsResult models the data from the listtransactions command. // ListTransactionsResult models the data from the listtransactions command.
type ListTransactionsResult struct { type ListTransactionsResult struct {
Abandoned bool `json:"abandoned"`
Account string `json:"account"` Account string `json:"account"`
Address string `json:"address,omitempty"` Address string `json:"address,omitempty"`
Amount float64 `json:"amount"` Amount float64 `json:"amount"`
BIP125Replaceable string `json:"bip125-replaceable,omitempty"`
BlockHash string `json:"blockhash,omitempty"` BlockHash string `json:"blockhash,omitempty"`
BlockIndex *int64 `json:"blockindex,omitempty"` BlockIndex *int64 `json:"blockindex,omitempty"`
BlockTime int64 `json:"blocktime,omitempty"` BlockTime int64 `json:"blocktime,omitempty"`
@ -71,6 +73,7 @@ type ListTransactionsResult struct {
InvolvesWatchOnly bool `json:"involveswatchonly,omitempty"` InvolvesWatchOnly bool `json:"involveswatchonly,omitempty"`
Time int64 `json:"time"` Time int64 `json:"time"`
TimeReceived int64 `json:"timereceived"` TimeReceived int64 `json:"timereceived"`
Trusted bool `json:"trusted"`
TxID string `json:"txid"` TxID string `json:"txid"`
Vout uint32 `json:"vout"` Vout uint32 `json:"vout"`
WalletConflicts []string `json:"walletconflicts"` WalletConflicts []string `json:"walletconflicts"`

View file

@ -72,41 +72,47 @@ func TestWalletSvrWsNtfns(t *testing.T) {
{ {
name: "newtx", name: "newtx",
newNtfn: func() (interface{}, error) { newNtfn: func() (interface{}, error) {
return btcjson.NewCmd("newtx", "acct", `{"account":"acct","address":"1Address","category":"send","amount":1.5,"fee":0.0001,"confirmations":1,"txid":"456","walletconflicts":[],"time":12345678,"timereceived":12345876,"vout":789,"otheraccount":"otheracct"}`) return btcjson.NewCmd("newtx", "acct", `{"account":"acct","address":"1Address","category":"send","amount":1.5,"bip125-replaceable":"unknown","fee":0.0001,"confirmations":1,"trusted":true,"txid":"456","walletconflicts":[],"time":12345678,"timereceived":12345876,"vout":789,"otheraccount":"otheracct"}`)
}, },
staticNtfn: func() interface{} { staticNtfn: func() interface{} {
result := btcjson.ListTransactionsResult{ result := btcjson.ListTransactionsResult{
Account: "acct", Abandoned: false,
Address: "1Address", Account: "acct",
Category: "send", Address: "1Address",
Amount: 1.5, BIP125Replaceable: "unknown",
Fee: btcjson.Float64(0.0001), Category: "send",
Confirmations: 1, Amount: 1.5,
TxID: "456", Fee: btcjson.Float64(0.0001),
WalletConflicts: []string{}, Confirmations: 1,
Time: 12345678, TxID: "456",
TimeReceived: 12345876, WalletConflicts: []string{},
Vout: 789, Time: 12345678,
OtherAccount: "otheracct", TimeReceived: 12345876,
Trusted: true,
Vout: 789,
OtherAccount: "otheracct",
} }
return btcjson.NewNewTxNtfn("acct", result) return btcjson.NewNewTxNtfn("acct", result)
}, },
marshalled: `{"jsonrpc":"1.0","method":"newtx","params":["acct",{"account":"acct","address":"1Address","amount":1.5,"category":"send","confirmations":1,"fee":0.0001,"time":12345678,"timereceived":12345876,"txid":"456","vout":789,"walletconflicts":[],"otheraccount":"otheracct"}],"id":null}`, marshalled: `{"jsonrpc":"1.0","method":"newtx","params":["acct",{"abandoned":false,"account":"acct","address":"1Address","amount":1.5,"bip125-replaceable":"unknown","category":"send","confirmations":1,"fee":0.0001,"time":12345678,"timereceived":12345876,"trusted":true,"txid":"456","vout":789,"walletconflicts":[],"otheraccount":"otheracct"}],"id":null}`,
unmarshalled: &btcjson.NewTxNtfn{ unmarshalled: &btcjson.NewTxNtfn{
Account: "acct", Account: "acct",
Details: btcjson.ListTransactionsResult{ Details: btcjson.ListTransactionsResult{
Account: "acct", Abandoned: false,
Address: "1Address", Account: "acct",
Category: "send", Address: "1Address",
Amount: 1.5, BIP125Replaceable: "unknown",
Fee: btcjson.Float64(0.0001), Category: "send",
Confirmations: 1, Amount: 1.5,
TxID: "456", Fee: btcjson.Float64(0.0001),
WalletConflicts: []string{}, Confirmations: 1,
Time: 12345678, TxID: "456",
TimeReceived: 12345876, WalletConflicts: []string{},
Vout: 789, Time: 12345678,
OtherAccount: "otheracct", TimeReceived: 12345876,
Trusted: true,
Vout: 789,
OtherAccount: "otheracct",
}, },
}, },
}, },