Skip to content

Commit

Permalink
btcjson+rpcclient: restore bitcoind compatibility
Browse files Browse the repository at this point in the history
The PR #1594 introduced a change that made the order of parameters
relevant, if one of them is nil. This makes it harder to be backward
compatible with the same JSON message if an existing parameter in
bitcoind was re-purposed to have a different meaning.
  • Loading branch information
guggero committed Nov 12, 2020
1 parent 65d2b7a commit c9c84ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions btcjson/chainsvrcmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,12 @@ func NewSearchRawTransactionsCmd(address string, verbose, skip, count *int, vinE
type SendRawTransactionCmd struct {
HexTx string
AllowHighFees *bool `jsonrpcdefault:"false"`
}

// SendRawTransactionBitcoindCmd defines the sendrawtransaction JSON-RPC command
// that is used for bitcoind post 0.19.0.
type SendRawTransactionBitcoindCmd struct {
HexTx string
MaxFeeRate *int32
}

Expand All @@ -842,8 +848,8 @@ func NewSendRawTransactionCmd(hexTx string, allowHighFees *bool) *SendRawTransac
// sendrawtransaction JSON-RPC command to a bitcoind node.
//
// A 0 maxFeeRate indicates that a maximum fee rate won't be enforced.
func NewBitcoindSendRawTransactionCmd(hexTx string, maxFeeRate int32) *SendRawTransactionCmd {
return &SendRawTransactionCmd{
func NewBitcoindSendRawTransactionCmd(hexTx string, maxFeeRate int32) *SendRawTransactionBitcoindCmd {
return &SendRawTransactionBitcoindCmd{
HexTx: hexTx,
MaxFeeRate: &maxFeeRate,
}
Expand Down
2 changes: 1 addition & 1 deletion rpcclient/rawtransactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (c *Client) SendRawTransactionAsync(tx *wire.MsgTx, allowHighFees bool) Fut
return newFutureError(err)
}

var cmd *btcjson.SendRawTransactionCmd
var cmd interface{}
switch version {
// Starting from bitcoind v0.19.0, the MaxFeeRate field should be used.
case BitcoindPost19:
Expand Down

0 comments on commit c9c84ed

Please sign in to comment.