mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
wallet: disallow migration of invalid or not-watched scripts
The legacy wallet allowed to import any raw script, without checking if it was valid or not. Appending it to the watch-only set. This causes a crash in the migration process because we are only expecting to find valid scripts inside the legacy spkm. These stored scripts internally map to `ISMINE_NO` (same as if they weren't stored at all..). So we need to check for these special case, and take into account that the legacy spkm could be storing invalid not watched scripts. Which, in code words, means IsMineInner() returning IsMineResult::INVALID for them.
This commit is contained in:
@@ -523,6 +523,12 @@ public:
|
||||
std::set<CKeyID> GetKeys() const override;
|
||||
std::unordered_set<CScript, SaltedSipHasher> GetScriptPubKeys() const override;
|
||||
|
||||
/**
|
||||
* Retrieves scripts that were imported by bugs into the legacy spkm and are
|
||||
* simply invalid, such as a sh(sh(pkh())) script, or not watched.
|
||||
*/
|
||||
std::unordered_set<CScript, SaltedSipHasher> GetNotMineScriptPubKeys() const;
|
||||
|
||||
/** Get the DescriptorScriptPubKeyMans (with private keys) that have the same scriptPubKeys as this LegacyScriptPubKeyMan.
|
||||
* Does not modify this ScriptPubKeyMan. */
|
||||
std::optional<MigrationData> MigrateToDescriptor();
|
||||
|
||||
Reference in New Issue
Block a user