Merge pull request #1129 from gracenoah/fix-rescan
fix NewImportAddressCmd rescan wrong parameters
This commit is contained in:
commit
d2b1a06d93
3 changed files with 15 additions and 12 deletions
|
@ -36,14 +36,16 @@ func NewDumpWalletCmd(filename string) *DumpWalletCmd {
|
|||
// ImportAddressCmd defines the importaddress JSON-RPC command.
|
||||
type ImportAddressCmd struct {
|
||||
Address string
|
||||
Account string
|
||||
Rescan *bool `jsonrpcdefault:"true"`
|
||||
}
|
||||
|
||||
// NewImportAddressCmd returns a new instance which can be used to issue an
|
||||
// importaddress JSON-RPC command.
|
||||
func NewImportAddressCmd(address string, rescan *bool) *ImportAddressCmd {
|
||||
func NewImportAddressCmd(address string, account string, rescan *bool) *ImportAddressCmd {
|
||||
return &ImportAddressCmd{
|
||||
Address: address,
|
||||
Account: account,
|
||||
Rescan: rescan,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,12 +58,12 @@ func TestBtcWalletExtCmds(t *testing.T) {
|
|||
{
|
||||
name: "importaddress",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("importaddress", "1Address")
|
||||
return btcjson.NewCmd("importaddress", "1Address", "")
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewImportAddressCmd("1Address", nil)
|
||||
return btcjson.NewImportAddressCmd("1Address", "", nil)
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"importaddress","params":["1Address"],"id":1}`,
|
||||
marshalled: `{"jsonrpc":"1.0","method":"importaddress","params":["1Address",""],"id":1}`,
|
||||
unmarshalled: &btcjson.ImportAddressCmd{
|
||||
Address: "1Address",
|
||||
Rescan: btcjson.Bool(true),
|
||||
|
@ -72,14 +72,15 @@ func TestBtcWalletExtCmds(t *testing.T) {
|
|||
{
|
||||
name: "importaddress optional",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("importaddress", "1Address", false)
|
||||
return btcjson.NewCmd("importaddress", "1Address", "acct", false)
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewImportAddressCmd("1Address", btcjson.Bool(false))
|
||||
return btcjson.NewImportAddressCmd("1Address", "acct", btcjson.Bool(false))
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"importaddress","params":["1Address",false],"id":1}`,
|
||||
marshalled: `{"jsonrpc":"1.0","method":"importaddress","params":["1Address","acct",false],"id":1}`,
|
||||
unmarshalled: &btcjson.ImportAddressCmd{
|
||||
Address: "1Address",
|
||||
Account: "acct",
|
||||
Rescan: btcjson.Bool(false),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -2078,7 +2078,7 @@ func (r FutureImportAddressResult) Receive() error {
|
|||
//
|
||||
// See ImportAddress for the blocking version and more details.
|
||||
func (c *Client) ImportAddressAsync(address string) FutureImportAddressResult {
|
||||
cmd := btcjson.NewImportAddressCmd(address, nil)
|
||||
cmd := btcjson.NewImportAddressCmd(address, "", nil)
|
||||
return c.sendCmd(cmd)
|
||||
}
|
||||
|
||||
|
@ -2092,15 +2092,15 @@ func (c *Client) ImportAddress(address string) error {
|
|||
// returned instance.
|
||||
//
|
||||
// See ImportAddress for the blocking version and more details.
|
||||
func (c *Client) ImportAddressRescanAsync(address string, rescan bool) FutureImportAddressResult {
|
||||
cmd := btcjson.NewImportAddressCmd(address, &rescan)
|
||||
func (c *Client) ImportAddressRescanAsync(address string, account string, rescan bool) FutureImportAddressResult {
|
||||
cmd := btcjson.NewImportAddressCmd(address, account, &rescan)
|
||||
return c.sendCmd(cmd)
|
||||
}
|
||||
|
||||
// ImportAddressRescan imports the passed public address. When rescan is true,
|
||||
// the block history is scanned for transactions addressed to provided address.
|
||||
func (c *Client) ImportAddressRescan(address string, rescan bool) error {
|
||||
return c.ImportAddressRescanAsync(address, rescan).Receive()
|
||||
func (c *Client) ImportAddressRescan(address string, account string, rescan bool) error {
|
||||
return c.ImportAddressRescanAsync(address, account, rescan).Receive()
|
||||
}
|
||||
|
||||
// FutureImportPrivKeyResult is a future promise to deliver the result of an
|
||||
|
|
Loading…
Reference in a new issue