aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/walletdb.cpp
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2023-07-03 21:30:38 -0400
committerAndrew Chow <github@achow101.com>2023-07-03 21:42:01 -0400
commitf08d914a678f7ceb81e7584efe92d3840f3b9c95 (patch)
tree3dd7fbc8e3a1031a0ab5ff0d1970f1436ebdb638 /src/wallet/walletdb.cpp
parent600c595b8d2f4bf049b9182d4a0aa88e4b34458d (diff)
parent5df988b534df842ddb658ad2a7ff0f12996c8478 (diff)
downloadbitcoin-f08d914a678f7ceb81e7584efe92d3840f3b9c95.tar.xz
Merge bitcoin/bitcoin#27920: wallet: bugfix, always use apostrophe for spkm descriptor ID
5df988b534df842ddb658ad2a7ff0f12996c8478 test: add coverage for descriptor ID (furszy) 6a9510d2dabde1c9ee6c4226e3d16ca32eb48ac5 wallet: bugfix, always use apostrophe for spkm descriptor ID (furszy) 97a965d98f1582ea1b1377bd258c9088380e1b8b refactor: extract descriptor ID calculation from spkm GetID() (furszy) 1d207e3931cf076f69d4a8335cdd6c8ebb2a963f wallet: do not allow loading descriptor with an invalid ID (furszy) Pull request description: Aiming to fix #27915. As we re-write the descriptor's db record every time that the wallet is loaded (at `TopUp` time), if the spkm ID differs from the one in db, the wallet will enter in an unrecoverable corruption state (due to the storage of a descriptor with an ID that is not linked to any other descriptor record in DB), and no soft version will be able to open it anymore. Because we cannot change the past, to stay compatible between releases, we need to always use the apostrophe version for the spkm IDs. ACKs for top commit: achow101: ACK 5df988b534df842ddb658ad2a7ff0f12996c8478 Sjors: tACK 5df988b534df842ddb658ad2a7ff0f12996c8478 Tree-SHA512: f63fc4aac7d21a4e515657471758d28857575e751865bfa359298f8b89b2568970029ca487a873c1786a5716325f453f06cd417ed193f3366417f6e8c2987332
Diffstat (limited to 'src/wallet/walletdb.cpp')
-rw-r--r--src/wallet/walletdb.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index ff0b83dc38..ffe5fd4a18 100644
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -803,6 +803,12 @@ static DBErrors LoadDescriptorWalletRecords(CWallet* pwallet, DatabaseBatch& bat
}
pwallet->LoadDescriptorScriptPubKeyMan(id, desc);
+ // Prior to doing anything with this spkm, verify ID compatibility
+ if (id != pwallet->GetDescriptorScriptPubKeyMan(desc)->GetID()) {
+ strErr = "The descriptor ID calculated by the wallet differs from the one in DB";
+ return DBErrors::CORRUPT;
+ }
+
DescriptorCache cache;
// Get key cache for this descriptor