fix: get receiving address for Descriptor Wallets

Expected to use wallet's interface instead LegacyScriptPubKeyMan to get a new address
This commit is contained in:
Konstantin Akimov 2024-03-02 18:20:27 +07:00
parent bdbd0b14a7
commit 4064334732
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
2 changed files with 2 additions and 4 deletions

View File

@ -154,10 +154,7 @@ public:
std::string getWalletName() override { return m_wallet->GetName(); } std::string getWalletName() override { return m_wallet->GetName(); }
bool getNewDestination(const std::string label, CTxDestination& dest) override bool getNewDestination(const std::string label, CTxDestination& dest) override
{ {
auto spk_man = m_wallet->GetLegacyScriptPubKeyMan(); LOCK(m_wallet->cs_wallet);
if (!spk_man) {
return false;
}
std::string error; std::string error;
return m_wallet->GetNewDestination(label, dest, error); return m_wallet->GetNewDestination(label, dest, error);
} }

View File

@ -3820,6 +3820,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
LegacyScriptPubKeyMan* legacy_spk_man = pwallet->GetLegacyScriptPubKeyMan(); LegacyScriptPubKeyMan* legacy_spk_man = pwallet->GetLegacyScriptPubKeyMan();
if (legacy_spk_man != nullptr) { if (legacy_spk_man != nullptr) {
const PKHash *pkhash = std::get_if<PKHash>(&dest); const PKHash *pkhash = std::get_if<PKHash>(&dest);
// TODO: refactor to use hd_seed_id from `meta`
if (pkhash && legacy_spk_man->HaveHDKey(ToKeyID(*pkhash), hdChainCurrent)) { if (pkhash && legacy_spk_man->HaveHDKey(ToKeyID(*pkhash), hdChainCurrent)) {
ret.pushKV("hdchainid", hdChainCurrent.GetID().GetHex()); ret.pushKV("hdchainid", hdChainCurrent.GetID().GetHex());
} }