Skip to content

Commit

Permalink
rpc/client/dcrwallet: accountunlocked/lockaccount/unlockaccount
Browse files Browse the repository at this point in the history
  • Loading branch information
chappjc committed Mar 24, 2021
1 parent 358ca96 commit 873c564
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmd/movefunds/movefunds
cmd/sweepaccount/sweepaccount
dcrwallet
cmd/repaircfilters/repaircfilters
cmd/treasurykey/treasurykey
/dcrwallet
vendor
*~
.vscode
Expand Down
24 changes: 23 additions & 1 deletion rpc/client/dcrwallet/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,28 @@ func (c *Client) ListReceivedByAddressIncludeEmpty(ctx context.Context, minConfi
return res, err
}

// AccountUnlocked indicates the encryption and locked status of an account. The
// Unlocked field of AccountUnlockedResult is only non-nil if Encrypted is true.
func (c *Client) AccountUnlocked(ctx context.Context, account string) (*types.AccountUnlockedResult, error) {
res := new(types.AccountUnlockedResult)
err := c.Call(ctx, "accountunlocked", res, account)
return res, err
}

// LockAccount locks an individually-encrypted account. It is an error if the
// account is not encrypted. It is also an error if the account is already
// locked, coded by dcrjson.ErrRPCWalletUnlockNeeded.
func (c *Client) LockAccount(ctx context.Context, account string) error {
return c.Call(ctx, "lockaccount", nil, account)
}

// UnlockAccount unlocks an individually-encrypted account using the passphrase.
// It is an error if the account is not encrypted. It is not an error if the
// account is already unlocked.
func (c *Client) UnlockAccount(ctx context.Context, account string, passphrase string) error {
return c.Call(ctx, "unlockaccount", nil, account, passphrase)
}

// WalletLock locks the wallet by removing the encryption key from memory.
//
// After calling this function, the WalletPassphrase function must be used to
Expand All @@ -557,7 +579,7 @@ func (c *Client) WalletLock(ctx context.Context) error {

// WalletPassphrase unlocks the wallet by using the passphrase to derive the
// decryption key which is then stored in memory for the specified timeout
// (in seconds).
// (in seconds). A timeout of 0 unlocks the wallet without a time limit.
func (c *Client) WalletPassphrase(ctx context.Context, passphrase string, timeoutSecs int64) error {
return c.Call(ctx, "walletpassphrase", nil, passphrase, timeoutSecs)
}
Expand Down

0 comments on commit 873c564

Please sign in to comment.