aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpcwallet.cpp
diff options
context:
space:
mode:
authorS3RK <1466284+S3RK@users.noreply.github.com>2021-10-05 09:45:45 +0200
committerS3RK <1466284+S3RK@users.noreply.github.com>2021-10-05 09:50:38 +0200
commit456e350926adde5dabdbc85fc0f017fb29bdadb3 (patch)
treef0fc56857c3ada5f2dc08f680567fe7b94a23604 /src/wallet/rpcwallet.cpp
parent69a66dcd0dacda54d813a61e9d4f61085c2268b2 (diff)
wallet: resolve ambiguity of two ScriptPubKey managers providing same script
Diffstat (limited to 'src/wallet/rpcwallet.cpp')
-rw-r--r--src/wallet/rpcwallet.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 7bc2dc7b21..1a872323be 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -3982,8 +3982,12 @@ RPCHelpMan getaddressinfo()
ret.pushKV("solvable", false);
}
+ const auto& spk_mans = pwallet->GetScriptPubKeyMans(scriptPubKey);
+ // In most cases there is only one matching ScriptPubKey manager and we can't resolve ambiguity in a better way
+ ScriptPubKeyMan* spk_man{nullptr};
+ if (spk_mans.size()) spk_man = *spk_mans.begin();
- DescriptorScriptPubKeyMan* desc_spk_man = dynamic_cast<DescriptorScriptPubKeyMan*>(pwallet->GetScriptPubKeyMan(scriptPubKey));
+ DescriptorScriptPubKeyMan* desc_spk_man = dynamic_cast<DescriptorScriptPubKeyMan*>(spk_man);
if (desc_spk_man) {
std::string desc_str;
if (desc_spk_man->GetDescriptorString(desc_str, /* priv */ false)) {
@@ -3998,7 +4002,6 @@ RPCHelpMan getaddressinfo()
ret.pushKV("ischange", ScriptIsChange(*pwallet, scriptPubKey));
- ScriptPubKeyMan* spk_man = pwallet->GetScriptPubKeyMan(scriptPubKey);
if (spk_man) {
if (const std::unique_ptr<CKeyMetadata> meta = spk_man->GetMetadata(dest)) {
ret.pushKV("timestamp", meta->nCreateTime);