Skip to content

Commit

Permalink
Updates for btcjson type changes.
Browse files Browse the repository at this point in the history
To increase compatibility with Bitcoin Core Wallet, additional fields
were added to and other fields made optional for the listtransactions
and gettransaction results structs.  For both, fee was changed to be
optional (including the zero value is allowed).
  • Loading branch information
jrick committed May 6, 2015
1 parent 8ce25ce commit 49f33ee
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 33 deletions.
46 changes: 25 additions & 21 deletions internal/rpchelp/helpdescs_en_US.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ var helpDescsEnUS = map[string]string{
"gettransactionresult-hex": "The transaction encoded as a hexadecimal string",

// GetTransactionDetailsResult help.
"gettransactiondetailsresult-account": "DEPRECATED -- Unset",
"gettransactiondetailsresult-address": "The address an output was paid to, or the empty string if the output is nonstandard or this detail is regarding a transaction input",
"gettransactiondetailsresult-category": `The kind of detail: "send" for sent transactions, "immature" for immature coinbase outputs, "generate" for mature coinbase outputs, or "recv" for all other received outputs`,
"gettransactiondetailsresult-amount": "The amount of a received output",
"gettransactiondetailsresult-fee": "The included fee for a sent transaction",
"gettransactiondetailsresult-account": "DEPRECATED -- Unset",
"gettransactiondetailsresult-address": "The address an output was paid to, or the empty string if the output is nonstandard or this detail is regarding a transaction input",
"gettransactiondetailsresult-category": `The kind of detail: "send" for sent transactions, "immature" for immature coinbase outputs, "generate" for mature coinbase outputs, or "recv" for all other received outputs`,
"gettransactiondetailsresult-amount": "The amount of a received output",
"gettransactiondetailsresult-fee": "The included fee for a sent transaction",
"gettransactiondetailsresult-vout": "The transaction output index",
"gettransactiondetailsresult-involveswatchonly": "Unset",

// ImportPrivKeyCmd help.
"importprivkey--synopsis": "Imports a WIF-encoded private key to the 'imported' account.",
Expand Down Expand Up @@ -208,22 +210,24 @@ var helpDescsEnUS = map[string]string{
"listsinceblockresult-lastblock": "Hash of the latest-synced block to be used in later calls to listsinceblock",

// ListTransactionsResult help.
"listtransactionsresult-account": "DEPRECATED -- Unset",
"listtransactionsresult-address": "Payment address for a transaction output",
"listtransactionsresult-category": `The kind of transaction: "send" for sent transactions, "immature" for immature coinbase outputs, "generate" for mature coinbase outputs, or "recv" for all other received outputs. Note: A single output may be included multiple times under different categories`,
"listtransactionsresult-amount": "The value of the transaction output valued in bitcoin",
"listtransactionsresult-fee": "The total input value minus the total output value for sent transactions",
"listtransactionsresult-confirmations": "The number of block confirmations of the transaction",
"listtransactionsresult-generated": "Whether the transaction output is a coinbase output",
"listtransactionsresult-blockhash": "The hash of the block this transaction is mined in, or the empty string if unmined",
"listtransactionsresult-blockindex": "Unset",
"listtransactionsresult-blocktime": "The Unix time of the block header this transaction is mined in, or 0 if unmined",
"listtransactionsresult-txid": "The hash of the transaction",
"listtransactionsresult-walletconflicts": "Unset",
"listtransactionsresult-time": "The earliest Unix time this transaction was known to exist",
"listtransactionsresult-timereceived": "The earliest Unix time this transaction was known to exist",
"listtransactionsresult-comment": "Unset",
"listtransactionsresult-otheraccount": "Unset",
"listtransactionsresult-account": "DEPRECATED -- Unset",
"listtransactionsresult-address": "Payment address for a transaction output",
"listtransactionsresult-category": `The kind of transaction: "send" for sent transactions, "immature" for immature coinbase outputs, "generate" for mature coinbase outputs, or "recv" for all other received outputs. Note: A single output may be included multiple times under different categories`,
"listtransactionsresult-amount": "The value of the transaction output valued in bitcoin",
"listtransactionsresult-fee": "The total input value minus the total output value for sent transactions",
"listtransactionsresult-confirmations": "The number of block confirmations of the transaction",
"listtransactionsresult-generated": "Whether the transaction output is a coinbase output",
"listtransactionsresult-blockhash": "The hash of the block this transaction is mined in, or the empty string if unmined",
"listtransactionsresult-blockindex": "Unset",
"listtransactionsresult-blocktime": "The Unix time of the block header this transaction is mined in, or 0 if unmined",
"listtransactionsresult-txid": "The hash of the transaction",
"listtransactionsresult-vout": "The transaction output index",
"listtransactionsresult-walletconflicts": "Unset",
"listtransactionsresult-time": "The earliest Unix time this transaction was known to exist",
"listtransactionsresult-timereceived": "The earliest Unix time this transaction was known to exist",
"listtransactionsresult-involveswatchonly": "Unset",
"listtransactionsresult-comment": "Unset",
"listtransactionsresult-otheraccount": "Unset",

// ListTransactionsCmd help.
"listtransactions--synopsis": "Returns a JSON array of objects containing verbose details for wallet transactions.",
Expand Down
20 changes: 18 additions & 2 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2089,9 +2089,20 @@ func GetTransaction(w *wallet.Wallet, chainSvr *chain.Client, icmd interface{})
ret.Details = make([]btcjson.GetTransactionDetailsResult, 1, len(details.Credits)+1)

ret.Details[0] = btcjson.GetTransactionDetailsResult{
// Fields left zeroed:
// InvolvesWatchOnly
// Account
// Address
// Vout
//
// TODO(jrick): Address and Vout should always be set,
// but we're doing the wrong thing here by not matching
// core. Instead, gettransaction should only be adding
// details for transaction outputs, just like
// listtransactions (but using the short result format).
Category: "send",
Amount: (-debitTotal).ToBTC(), // negative since it is a send
Fee: feeF64,
Fee: &feeF64,
}
ret.Fee = feeF64
}
Expand All @@ -2111,9 +2122,14 @@ func GetTransaction(w *wallet.Wallet, chainSvr *chain.Client, icmd interface{})
}

ret.Details = append(ret.Details, btcjson.GetTransactionDetailsResult{
// Fields left zeroed:
// InvolvesWatchOnly
// Account
// Fee
Address: addr,
Category: credCat,
Amount: cred.Amount.ToBTC(),
Address: addr,
Vout: cred.Index,
})
}

Expand Down
Loading

0 comments on commit 49f33ee

Please sign in to comment.