mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 19:37:27 -03:00
migration: Skip descriptors which do not parse
InferDescriptors can sometimes make descriptors which are actually invalid and cannot be parsed. Detect and skip such descriptors by doing a Parse() check before adding the descriptor to the wallet.
This commit is contained in:
parent
cb98957dd5
commit
0f0ce579ff
1 changed files with 13 additions and 0 deletions
|
@ -1925,6 +1925,19 @@ std::optional<MigrationData> LegacyDataSPKM::MigrateToDescriptor()
|
|||
|
||||
// InferDescriptor as that will get us all the solving info if it is there
|
||||
std::unique_ptr<Descriptor> desc = InferDescriptor(spk, *GetSolvingProvider(spk));
|
||||
|
||||
// Past bugs in InferDescriptor has caused it to create descriptors which cannot be re-parsed
|
||||
// Re-parse the descriptors to detect that, and skip any that do not parse.
|
||||
{
|
||||
std::string desc_str = desc->ToString();
|
||||
FlatSigningProvider parsed_keys;
|
||||
std::string parse_error;
|
||||
std::vector<std::unique_ptr<Descriptor>> parsed_descs = Parse(desc_str, parsed_keys, parse_error, false);
|
||||
if (parsed_descs.empty()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the private keys for this descriptor
|
||||
std::vector<CScript> scripts;
|
||||
FlatSigningProvider keys;
|
||||
|
|
Loading…
Reference in a new issue