From 71f8ba68a09524f8984aed5d6a2711164ad5adca Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Thu, 25 Aug 2022 22:28:06 -0700 Subject: [PATCH] multi-account: update getaccountaddress --- rpc/legacyrpc/methods.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/rpc/legacyrpc/methods.go b/rpc/legacyrpc/methods.go index 3f587f8..a187dab 100644 --- a/rpc/legacyrpc/methods.go +++ b/rpc/legacyrpc/methods.go @@ -715,16 +715,22 @@ func getAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error) { func getAccountAddress(icmd interface{}, w *wallet.Wallet) (interface{}, error) { cmd := icmd.(*btcjson.GetAccountAddressCmd) - account, err := w.AccountNumber(waddrmgr.KeyScopeBIP0044, cmd.Account) - if err != nil { - return nil, err - } - addr, err := w.CurrentAddress(account, waddrmgr.KeyScopeBIP0044) + account, err := w.AccountNumber(*cmd.Account) if err != nil { return nil, err } - return addr.EncodeAddress(), err + scope, err := lookupKeyScope(cmd.AddressType) + if err != nil { + return nil, err + } + + addr, err := w.CurrentAddress(account, *scope) + if err != nil { + return nil, err + } + + return addr.EncodeAddress(), nil } // getUnconfirmedBalance handles a getunconfirmedbalance extension request