Change the optional parameter for getrawtransaction from bool to int.
This matches bitcoind. ok oga@
This commit is contained in:
parent
6e2fa5aad7
commit
cbe4b140b9
16
jsoncmd.go
16
jsoncmd.go
|
@ -3105,15 +3105,15 @@ func (cmd *GetRawMempoolCmd) UnmarshalJSON(b []byte) error {
|
||||||
type GetRawTransactionCmd struct {
|
type GetRawTransactionCmd struct {
|
||||||
id interface{}
|
id interface{}
|
||||||
Txid string
|
Txid string
|
||||||
Verbose bool
|
Verbose int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enforce that GetRawTransactionCmd satisifies the Cmd interface.
|
// Enforce that GetRawTransactionCmd satisifies the Cmd interface.
|
||||||
var _ Cmd = &GetRawTransactionCmd{}
|
var _ Cmd = &GetRawTransactionCmd{}
|
||||||
|
|
||||||
// NewGetRawTransactionCmd creates a new GetRawTransactionCmd.
|
// NewGetRawTransactionCmd creates a new GetRawTransactionCmd.
|
||||||
func NewGetRawTransactionCmd(id interface{}, txid string, optArgs ...bool) (*GetRawTransactionCmd, error) {
|
func NewGetRawTransactionCmd(id interface{}, txid string, optArgs ...int) (*GetRawTransactionCmd, error) {
|
||||||
var verbose bool
|
var verbose int
|
||||||
if len(optArgs) > 0 {
|
if len(optArgs) > 0 {
|
||||||
if len(optArgs) > 1 {
|
if len(optArgs) > 1 {
|
||||||
return nil, ErrTooManyOptArgs
|
return nil, ErrTooManyOptArgs
|
||||||
|
@ -3155,7 +3155,7 @@ func (cmd *GetRawTransactionCmd) MarshalJSON() ([]byte, error) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Verbose {
|
if cmd.Verbose != 0 {
|
||||||
raw.Params = append(raw.Params, cmd.Verbose)
|
raw.Params = append(raw.Params, cmd.Verbose)
|
||||||
}
|
}
|
||||||
return json.Marshal(raw)
|
return json.Marshal(raw)
|
||||||
|
@ -3179,14 +3179,14 @@ func (cmd *GetRawTransactionCmd) UnmarshalJSON(b []byte) error {
|
||||||
return errors.New("first parameter txid must be a string")
|
return errors.New("first parameter txid must be a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
optArgs := make([]bool, 0, 1)
|
optArgs := make([]int, 0, 1)
|
||||||
if len(r.Params) == 2 {
|
if len(r.Params) == 2 {
|
||||||
verbose, ok := r.Params[1].(bool)
|
verbose, ok := r.Params[1].(float64)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("second optional parameter verbose must be a bool")
|
return errors.New("second optional parameter verbose must be a number")
|
||||||
}
|
}
|
||||||
|
|
||||||
optArgs = append(optArgs, verbose)
|
optArgs = append(optArgs, int(verbose))
|
||||||
}
|
}
|
||||||
|
|
||||||
newCmd, err := NewGetRawTransactionCmd(r.Id, txid, optArgs...)
|
newCmd, err := NewGetRawTransactionCmd(r.Id, txid, optArgs...)
|
||||||
|
|
|
@ -615,12 +615,12 @@ var jsoncmdtests = []struct {
|
||||||
f: func() (Cmd, error) {
|
f: func() (Cmd, error) {
|
||||||
return NewGetRawTransactionCmd(testId,
|
return NewGetRawTransactionCmd(testId,
|
||||||
"sometxid",
|
"sometxid",
|
||||||
true)
|
1)
|
||||||
},
|
},
|
||||||
result: &GetRawTransactionCmd{
|
result: &GetRawTransactionCmd{
|
||||||
id: testId,
|
id: testId,
|
||||||
Txid: "sometxid",
|
Txid: "sometxid",
|
||||||
Verbose: true,
|
Verbose: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue