upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/selftest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/selftest.cpp')
-rw-r--r--src/selftest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/selftest.cpp b/src/selftest.cpp
index cca5335..bcbf9d3 100644
--- a/src/selftest.cpp
+++ b/src/selftest.cpp
@@ -586,6 +586,34 @@ static int RunWalletHDSelfTest()
586 "the recovery audit finds wallet.dat-only immature mining rewards") ? 0 : 1; 586 "the recovery audit finds wallet.dat-only immature mining rewards") ? 0 : 1;
587 nFail += Check(audit.nLegacyImmatureTx == 1, 587 nFail += Check(audit.nLegacyImmatureTx == 1,
588 "the recovery audit counts wallet.dat-only immature mining rewards") ? 0 : 1; 588 "the recovery audit counts wallet.dat-only immature mining rewards") ? 0 : 1;
589
590 CKey keyLegacyHD11;
591 nSchemaForLegacyAudit = nHDKeySchema;
592 nHDKeySchema = HD_SCHEMA_LEGACY;
593 if (!DeriveHDKey(11, keyLegacyHD11, strError))
594 throw std::runtime_error("legacy compatibility index 11 derivation failed: " + strError);
595 nHDKeySchema = nSchemaForLegacyAudit;
596 if (!AddKey(keyLegacyHD11))
597 throw std::runtime_error("could not store the legacy compatibility index 11 key");
598
599 std::map<unsigned int, std::vector<unsigned char> > mapLegacyProbe;
600 mapLegacyProbe[0] = keyAuditLegacyHD.GetPubKey();
601 mapLegacyProbe[11] = keyLegacyHD11.GetPubKey();
602
603 CWalletTx wtxLegacyHD11;
604 wtxLegacyHD11.vout.push_back(CTxOut(19 * COIN, CScript() << keyLegacyHD11.GetPubKey() << OP_CHECKSIG));
605 CRITICAL_BLOCK(cs_mapWallet)
606 {
607 mapWallet.clear();
608 mapWallet[wtxLegacyHD11.GetHash()] = wtxLegacyHD11;
609 }
610 nFail += Check(WalletLastUsedPubKeyIndexNext(mapLegacyProbe) == 12,
611 "restore collapses legacy hdnext to the last used compatibility index plus one") ? 0 : 1;
612
613 CRITICAL_BLOCK(cs_mapWallet)
614 mapWallet.clear();
615 nFail += Check(WalletLastUsedPubKeyIndexNext(mapLegacyProbe) == 0,
616 "restore does not persist legacy hdnext at the scan depth when no compatibility key was used") ? 0 : 1;
589 } 617 }
590 catch (const std::exception& e) 618 catch (const std::exception& e)
591 { 619 {