From 78584be07ee4c95cdfdef46754a94a07c6f95ea5 Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Mon, 22 Aug 2022 13:48:12 -0700 Subject: [PATCH] multi-scope: update renameaccount --- rpc/legacyrpc/methods.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rpc/legacyrpc/methods.go b/rpc/legacyrpc/methods.go index c1cbefc158..f0dd4df577 100644 --- a/rpc/legacyrpc/methods.go +++ b/rpc/legacyrpc/methods.go @@ -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 @@ -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) {