aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-08-07 16:29:06 -0400
committerAva Chow <github@achow101.com>2024-08-08 12:47:22 -0400
commit1bbf46e2dae4599d04c79aaacf7c5db00b2e707f (patch)
tree67c7e7b72af0d742d5628cba43179d1be9a15ea4 /src/wallet/wallet.cpp
parent0d640c6f02bc20e5c1be773443dd74d8806d953b (diff)
downloadbitcoin-1bbf46e2dae4599d04c79aaacf7c5db00b2e707f.tar.xz
descriptors: Change Parse to return vector of descriptors
When given a descriptor which contins a multipath derivation specifier, a vector of descriptors will be returned.
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index d569c64b43..2ff5a52984 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3743,10 +3743,11 @@ void CWallet::SetupDescriptorScriptPubKeyMans()
const std::string& desc_str = desc_val.getValStr();
FlatSigningProvider keys;
std::string desc_error;
- std::unique_ptr<Descriptor> desc = Parse(desc_str, keys, desc_error, false);
- if (desc == nullptr) {
+ auto descs = Parse(desc_str, keys, desc_error, false);
+ if (descs.empty()) {
throw std::runtime_error(std::string(__func__) + ": Invalid descriptor \"" + desc_str + "\" (" + desc_error + ")");
}
+ auto& desc = descs.at(0);
if (!desc->GetOutputType()) {
continue;
}
@@ -4285,12 +4286,12 @@ bool DoMigration(CWallet& wallet, WalletContext& context, bilingual_str& error,
// Parse the descriptor
FlatSigningProvider keys;
std::string parse_err;
- std::unique_ptr<Descriptor> desc = Parse(desc_str, keys, parse_err, /* require_checksum */ true);
- assert(desc); // It shouldn't be possible to have the LegacyScriptPubKeyMan make an invalid descriptor
- assert(!desc->IsRange()); // It shouldn't be possible to have LegacyScriptPubKeyMan make a ranged watchonly descriptor
+ std::vector<std::unique_ptr<Descriptor>> descs = Parse(desc_str, keys, parse_err, /* require_checksum */ true);
+ assert(descs.size() == 1); // It shouldn't be possible to have the LegacyScriptPubKeyMan make an invalid descriptor or a multipath descriptors
+ assert(!descs.at(0)->IsRange()); // It shouldn't be possible to have LegacyScriptPubKeyMan make a ranged watchonly descriptor
// Add to the wallet
- WalletDescriptor w_desc(std::move(desc), creation_time, 0, 0, 0);
+ WalletDescriptor w_desc(std::move(descs.at(0)), creation_time, 0, 0, 0);
data->watchonly_wallet->AddWalletDescriptor(w_desc, keys, "", false);
}
@@ -4322,12 +4323,12 @@ bool DoMigration(CWallet& wallet, WalletContext& context, bilingual_str& error,
// Parse the descriptor
FlatSigningProvider keys;
std::string parse_err;
- std::unique_ptr<Descriptor> desc = Parse(desc_str, keys, parse_err, /* require_checksum */ true);
- assert(desc); // It shouldn't be possible to have the LegacyScriptPubKeyMan make an invalid descriptor
- assert(!desc->IsRange()); // It shouldn't be possible to have LegacyScriptPubKeyMan make a ranged watchonly descriptor
+ std::vector<std::unique_ptr<Descriptor>> descs = Parse(desc_str, keys, parse_err, /* require_checksum */ true);
+ assert(descs.size() == 1); // It shouldn't be possible to have the LegacyScriptPubKeyMan make an invalid descriptor or a multipath descriptors
+ assert(!descs.at(0)->IsRange()); // It shouldn't be possible to have LegacyScriptPubKeyMan make a ranged watchonly descriptor
// Add to the wallet
- WalletDescriptor w_desc(std::move(desc), creation_time, 0, 0, 0);
+ WalletDescriptor w_desc(std::move(descs.at(0)), creation_time, 0, 0, 0);
data->solvable_wallet->AddWalletDescriptor(w_desc, keys, "", false);
}