mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-28 16:01:27 +00:00
Added async version for CreateNewAccount, RenameAccount
This commit is contained in:
parent
bc36ac6d52
commit
20ff0689d8
1 changed files with 50 additions and 10 deletions
60
wallet.go
60
wallet.go
|
@ -960,17 +960,37 @@ func (c *Client) CreateMultisig(requiredSigs int, addresses []btcutil.Address) (
|
||||||
return c.CreateMultisigAsync(requiredSigs, addresses).Receive()
|
return c.CreateMultisigAsync(requiredSigs, addresses).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateNewAccount creates a new wallet account.
|
// FutureCreateNewAccountResult is a future promise to deliver the result of a
|
||||||
func (c *Client) CreateNewAccount(account string) error {
|
// CreateNewAccountAsync RPC invocation (or an applicable error).
|
||||||
id := c.NextID()
|
type FutureCreateNewAccountResult chan *response
|
||||||
cmd := btcws.NewCreateNewAccountCmd(id, account)
|
|
||||||
_, err := c.sendCmdAndWait(cmd)
|
// Receive waits for the response promised by the future and returns the
|
||||||
|
// result of creating new account.
|
||||||
|
func (r FutureCreateNewAccountResult) Receive() error {
|
||||||
|
_, err := receiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateNewAccountAsync returns an instance of a type that can be used to get the
|
||||||
|
// result of the RPC at some future time by invoking the Receive function on the
|
||||||
|
// returned instance.
|
||||||
|
//
|
||||||
|
// See CreateNewAccount for the blocking version and more details.
|
||||||
|
func (c *Client) CreateNewAccountAsync(account string) FutureCreateNewAccountResult {
|
||||||
|
id := c.NextID()
|
||||||
|
cmd := btcws.NewCreateNewAccountCmd(id, account)
|
||||||
|
return c.sendCmd(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateNewAccount creates a new wallet account.
|
||||||
|
func (c *Client) CreateNewAccount(account string) error {
|
||||||
|
return c.CreateNewAccountAsync(account).Receive()
|
||||||
|
}
|
||||||
|
|
||||||
// FutureGetNewAddressResult is a future promise to deliver the result of a
|
// FutureGetNewAddressResult is a future promise to deliver the result of a
|
||||||
// GetNewAddressAsync RPC invocation (or an applicable error).
|
// GetNewAddressAsync RPC invocation (or an applicable error).
|
||||||
type FutureGetNewAddressResult chan *response
|
type FutureGetNewAddressResult chan *response
|
||||||
|
@ -1337,17 +1357,37 @@ func (c *Client) MoveComment(fromAccount, toAccount string, amount btcutil.Amoun
|
||||||
comment).Receive()
|
comment).Receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenameAccount renames a wallet account.
|
// FutureRenameAccountResult is a future promise to deliver the result of a
|
||||||
func (c *Client) RenameAccount(oldaccount, newaccount string) error {
|
// RenameAccountAsync RPC invocation (or an applicable error).
|
||||||
id := c.NextID()
|
type FutureRenameAccountResult chan *response
|
||||||
cmd := btcws.NewRenameAccountCmd(id, oldaccount, newaccount)
|
|
||||||
_, err := c.sendCmdAndWait(cmd)
|
// Receive waits for the response promised by the future and returns the
|
||||||
|
// result of creating new account.
|
||||||
|
func (r FutureRenameAccountResult) Receive() error {
|
||||||
|
_, err := receiveFuture(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RenameAccountAsync returns an instance of a type that can be used to get the
|
||||||
|
// result of the RPC at some future time by invoking the Receive function on the
|
||||||
|
// returned instance.
|
||||||
|
//
|
||||||
|
// See RenameAccount for the blocking version and more details.
|
||||||
|
func (c *Client) RenameAccountAsync(oldaccount, newaccount string) FutureRenameAccountResult {
|
||||||
|
id := c.NextID()
|
||||||
|
cmd := btcws.NewRenameAccountCmd(id, oldaccount, newaccount)
|
||||||
|
return c.sendCmd(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RenameAccount creates a new wallet account.
|
||||||
|
func (c *Client) RenameAccount(oldaccount, newaccount string) error {
|
||||||
|
return c.RenameAccountAsync(oldaccount, newaccount).Receive()
|
||||||
|
}
|
||||||
|
|
||||||
// FutureValidateAddressResult is a future promise to deliver the result of a
|
// FutureValidateAddressResult is a future promise to deliver the result of a
|
||||||
// ValidateAddressAsync RPC invocation (or an applicable error).
|
// ValidateAddressAsync RPC invocation (or an applicable error).
|
||||||
type FutureValidateAddressResult chan *response
|
type FutureValidateAddressResult chan *response
|
||||||
|
|
Loading…
Add table
Reference in a new issue