Skip to content

Commit

Permalink
multi-scope: update renameaccount
Browse files Browse the repository at this point in the history
  • Loading branch information
roylee17 committed Sep 26, 2022
1 parent b888268 commit 78584be
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions rpc/legacyrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ func createNewAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
// renameAccount handles a renameaccount request by renaming an account.
// If the account does not exist an appropriate error will be returned.
func renameAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error) {

cmd := icmd.(*btcjson.RenameAccountCmd)

// The wildcard * is reserved by the rpc server with the special meaning
Expand All @@ -829,11 +830,18 @@ func renameAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
}

// Check that given account exists
account, err := w.AccountNumber(waddrmgr.KeyScopeBIP0044, cmd.OldAccount)
account, err := w.AccountNumber(cmd.OldAccount)
if err != nil {
return nil, err
}
return nil, w.RenameAccount(waddrmgr.KeyScopeBIP0044, account, cmd.NewAccount)

// Interate over all key scopes and rename the account.
fn := func(scope waddrmgr.KeyScope) error {
return w.RenameAccount(scope, account, cmd.NewAccount)
}
err = forEachKeyScope(fn)

return nil, err
}

func lookupKeyScope(kind *string) (*waddrmgr.KeyScope, error) {
Expand Down

0 comments on commit 78584be

Please sign in to comment.