mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[DEV-130] convert searchrawtransaction ints to bools (#61)
This commit is contained in:
parent
d739bf5034
commit
e5545e2ee6
@ -593,10 +593,10 @@ func NewReconsiderBlockCmd(blockHash string) *ReconsiderBlockCmd {
|
||||
// SearchRawTransactionsCmd defines the searchrawtransactions JSON-RPC command.
|
||||
type SearchRawTransactionsCmd struct {
|
||||
Address string
|
||||
Verbose *int `jsonrpcdefault:"1"`
|
||||
Verbose *bool `jsonrpcdefault:"true"`
|
||||
Skip *int `jsonrpcdefault:"0"`
|
||||
Count *int `jsonrpcdefault:"100"`
|
||||
VinExtra *int `jsonrpcdefault:"0"`
|
||||
VinExtra *bool `jsonrpcdefault:"false"`
|
||||
Reverse *bool `jsonrpcdefault:"false"`
|
||||
FilterAddrs *[]string
|
||||
}
|
||||
@ -606,7 +606,7 @@ type SearchRawTransactionsCmd struct {
|
||||
//
|
||||
// The parameters which are pointers indicate they are optional. Passing nil
|
||||
// for optional parameters will use the default value.
|
||||
func NewSearchRawTransactionsCmd(address string, verbose, skip, count *int, vinExtra *int, reverse *bool, filterAddrs *[]string) *SearchRawTransactionsCmd {
|
||||
func NewSearchRawTransactionsCmd(address string, verbose *bool, skip, count *int, vinExtra, reverse *bool, filterAddrs *[]string) *SearchRawTransactionsCmd {
|
||||
return &SearchRawTransactionsCmd{
|
||||
Address: address,
|
||||
Verbose: verbose,
|
||||
|
@ -738,10 +738,10 @@ func TestDAGSvrCmds(t *testing.T) {
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address"],"id":1}`,
|
||||
unmarshalled: &btcjson.SearchRawTransactionsCmd{
|
||||
Address: "1Address",
|
||||
Verbose: btcjson.Int(1),
|
||||
Verbose: btcjson.Bool(true),
|
||||
Skip: btcjson.Int(0),
|
||||
Count: btcjson.Int(100),
|
||||
VinExtra: btcjson.Int(0),
|
||||
VinExtra: btcjson.Bool(false),
|
||||
Reverse: btcjson.Bool(false),
|
||||
FilterAddrs: nil,
|
||||
},
|
||||
@ -749,19 +749,19 @@ func TestDAGSvrCmds(t *testing.T) {
|
||||
{
|
||||
name: "searchrawtransactions",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", 0)
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", false)
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewSearchRawTransactionsCmd("1Address",
|
||||
btcjson.Int(0), nil, nil, nil, nil, nil)
|
||||
btcjson.Bool(false), nil, nil, nil, nil, nil)
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",0],"id":1}`,
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",false],"id":1}`,
|
||||
unmarshalled: &btcjson.SearchRawTransactionsCmd{
|
||||
Address: "1Address",
|
||||
Verbose: btcjson.Int(0),
|
||||
Verbose: btcjson.Bool(false),
|
||||
Skip: btcjson.Int(0),
|
||||
Count: btcjson.Int(100),
|
||||
VinExtra: btcjson.Int(0),
|
||||
VinExtra: btcjson.Bool(false),
|
||||
Reverse: btcjson.Bool(false),
|
||||
FilterAddrs: nil,
|
||||
},
|
||||
@ -769,19 +769,19 @@ func TestDAGSvrCmds(t *testing.T) {
|
||||
{
|
||||
name: "searchrawtransactions",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", 0, 5)
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", false, 5)
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewSearchRawTransactionsCmd("1Address",
|
||||
btcjson.Int(0), btcjson.Int(5), nil, nil, nil, nil)
|
||||
btcjson.Bool(false), btcjson.Int(5), nil, nil, nil, nil)
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",0,5],"id":1}`,
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",false,5],"id":1}`,
|
||||
unmarshalled: &btcjson.SearchRawTransactionsCmd{
|
||||
Address: "1Address",
|
||||
Verbose: btcjson.Int(0),
|
||||
Verbose: btcjson.Bool(false),
|
||||
Skip: btcjson.Int(5),
|
||||
Count: btcjson.Int(100),
|
||||
VinExtra: btcjson.Int(0),
|
||||
VinExtra: btcjson.Bool(false),
|
||||
Reverse: btcjson.Bool(false),
|
||||
FilterAddrs: nil,
|
||||
},
|
||||
@ -789,19 +789,19 @@ func TestDAGSvrCmds(t *testing.T) {
|
||||
{
|
||||
name: "searchrawtransactions",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", 0, 5, 10)
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", false, 5, 10)
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewSearchRawTransactionsCmd("1Address",
|
||||
btcjson.Int(0), btcjson.Int(5), btcjson.Int(10), nil, nil, nil)
|
||||
btcjson.Bool(false), btcjson.Int(5), btcjson.Int(10), nil, nil, nil)
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",0,5,10],"id":1}`,
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",false,5,10],"id":1}`,
|
||||
unmarshalled: &btcjson.SearchRawTransactionsCmd{
|
||||
Address: "1Address",
|
||||
Verbose: btcjson.Int(0),
|
||||
Verbose: btcjson.Bool(false),
|
||||
Skip: btcjson.Int(5),
|
||||
Count: btcjson.Int(10),
|
||||
VinExtra: btcjson.Int(0),
|
||||
VinExtra: btcjson.Bool(false),
|
||||
Reverse: btcjson.Bool(false),
|
||||
FilterAddrs: nil,
|
||||
},
|
||||
@ -809,19 +809,19 @@ func TestDAGSvrCmds(t *testing.T) {
|
||||
{
|
||||
name: "searchrawtransactions",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", 0, 5, 10, 1)
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", false, 5, 10, true)
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewSearchRawTransactionsCmd("1Address",
|
||||
btcjson.Int(0), btcjson.Int(5), btcjson.Int(10), btcjson.Int(1), nil, nil)
|
||||
btcjson.Bool(false), btcjson.Int(5), btcjson.Int(10), btcjson.Bool(true), nil, nil)
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",0,5,10,1],"id":1}`,
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",false,5,10,true],"id":1}`,
|
||||
unmarshalled: &btcjson.SearchRawTransactionsCmd{
|
||||
Address: "1Address",
|
||||
Verbose: btcjson.Int(0),
|
||||
Verbose: btcjson.Bool(false),
|
||||
Skip: btcjson.Int(5),
|
||||
Count: btcjson.Int(10),
|
||||
VinExtra: btcjson.Int(1),
|
||||
VinExtra: btcjson.Bool(true),
|
||||
Reverse: btcjson.Bool(false),
|
||||
FilterAddrs: nil,
|
||||
},
|
||||
@ -829,19 +829,19 @@ func TestDAGSvrCmds(t *testing.T) {
|
||||
{
|
||||
name: "searchrawtransactions",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", 0, 5, 10, 1, true)
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", false, 5, 10, true, true)
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewSearchRawTransactionsCmd("1Address",
|
||||
btcjson.Int(0), btcjson.Int(5), btcjson.Int(10), btcjson.Int(1), btcjson.Bool(true), nil)
|
||||
btcjson.Bool(false), btcjson.Int(5), btcjson.Int(10), btcjson.Bool(true), btcjson.Bool(true), nil)
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",0,5,10,1,true],"id":1}`,
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",false,5,10,true,true],"id":1}`,
|
||||
unmarshalled: &btcjson.SearchRawTransactionsCmd{
|
||||
Address: "1Address",
|
||||
Verbose: btcjson.Int(0),
|
||||
Verbose: btcjson.Bool(false),
|
||||
Skip: btcjson.Int(5),
|
||||
Count: btcjson.Int(10),
|
||||
VinExtra: btcjson.Int(1),
|
||||
VinExtra: btcjson.Bool(true),
|
||||
Reverse: btcjson.Bool(true),
|
||||
FilterAddrs: nil,
|
||||
},
|
||||
@ -849,19 +849,19 @@ func TestDAGSvrCmds(t *testing.T) {
|
||||
{
|
||||
name: "searchrawtransactions",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", 0, 5, 10, 1, true, []string{"1Address"})
|
||||
return btcjson.NewCmd("searchrawtransactions", "1Address", false, 5, 10, true, true, []string{"1Address"})
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewSearchRawTransactionsCmd("1Address",
|
||||
btcjson.Int(0), btcjson.Int(5), btcjson.Int(10), btcjson.Int(1), btcjson.Bool(true), &[]string{"1Address"})
|
||||
btcjson.Bool(false), btcjson.Int(5), btcjson.Int(10), btcjson.Bool(true), btcjson.Bool(true), &[]string{"1Address"})
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",0,5,10,1,true,["1Address"]],"id":1}`,
|
||||
marshalled: `{"jsonrpc":"1.0","method":"searchrawtransactions","params":["1Address",false,5,10,true,true,["1Address"]],"id":1}`,
|
||||
unmarshalled: &btcjson.SearchRawTransactionsCmd{
|
||||
Address: "1Address",
|
||||
Verbose: btcjson.Int(0),
|
||||
Verbose: btcjson.Bool(false),
|
||||
Skip: btcjson.Int(5),
|
||||
Count: btcjson.Int(10),
|
||||
VinExtra: btcjson.Int(1),
|
||||
VinExtra: btcjson.Bool(true),
|
||||
Reverse: btcjson.Bool(true),
|
||||
FilterAddrs: &[]string{"1Address"},
|
||||
},
|
||||
|
@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/daglabs/btcd/btcjson"
|
||||
"github.com/daglabs/btcd/dagconfig/daghash"
|
||||
"github.com/daglabs/btcd/wire"
|
||||
"github.com/daglabs/btcd/util"
|
||||
"github.com/daglabs/btcd/wire"
|
||||
)
|
||||
|
||||
// SigHashType enumerates the available signature hashing types that the
|
||||
@ -552,7 +552,7 @@ func (r FutureSearchRawTransactionsResult) Receive() ([]*wire.MsgTx, error) {
|
||||
// See SearchRawTransactions for the blocking version and more details.
|
||||
func (c *Client) SearchRawTransactionsAsync(address util.Address, skip, count int, reverse bool, filterAddrs []string) FutureSearchRawTransactionsResult {
|
||||
addr := address.EncodeAddress()
|
||||
verbose := btcjson.Int(0)
|
||||
verbose := btcjson.Bool(false)
|
||||
cmd := btcjson.NewSearchRawTransactionsCmd(addr, verbose, &skip, &count,
|
||||
nil, &reverse, &filterAddrs)
|
||||
return c.sendCmd(cmd)
|
||||
@ -601,10 +601,10 @@ func (c *Client) SearchRawTransactionsVerboseAsync(address util.Address, skip,
|
||||
count int, includePrevOut, reverse bool, filterAddrs *[]string) FutureSearchRawTransactionsVerboseResult {
|
||||
|
||||
addr := address.EncodeAddress()
|
||||
verbose := btcjson.Int(1)
|
||||
var prevOut *int
|
||||
verbose := btcjson.Bool(true)
|
||||
var prevOut *bool
|
||||
if includePrevOut {
|
||||
prevOut = btcjson.Int(1)
|
||||
prevOut = btcjson.Bool(true)
|
||||
}
|
||||
cmd := btcjson.NewSearchRawTransactionsCmd(addr, verbose, &skip, &count,
|
||||
prevOut, &reverse, filterAddrs)
|
||||
|
@ -2897,7 +2897,7 @@ func handleSearchRawTransactions(s *Server, cmd interface{}, closeChan <-chan st
|
||||
c := cmd.(*btcjson.SearchRawTransactionsCmd)
|
||||
vinExtra := false
|
||||
if c.VinExtra != nil {
|
||||
vinExtra = *c.VinExtra != 0
|
||||
vinExtra = *c.VinExtra
|
||||
}
|
||||
|
||||
// Including the extra previous output information requires the
|
||||
@ -3054,7 +3054,7 @@ func handleSearchRawTransactions(s *Server, cmd interface{}, closeChan <-chan st
|
||||
}
|
||||
|
||||
// When not in verbose mode, simply return a list of serialized txns.
|
||||
if c.Verbose != nil && *c.Verbose == 0 {
|
||||
if c.Verbose != nil && !*c.Verbose {
|
||||
return hexTxns, nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user