wallet: plumb the mnemonic entropy through CWallet
Wires the key store secret to the database records: load and store paths on CWallet, the two ReadKeyValue arms, and the export path. GetMnemonicPhrase now prefers the entropy record and verifies it before printing: a phrase is only returned if expanding it reproduces the seed derivation actually uses. It falls back to the existing fMnemonicSeed path, so wallets that store the entropy AS the seed keep working unchanged. IsMnemonicSeed() now means "a phrase is available" rather than "the seed is the entropy", which is what every caller actually wants. Still a no-op on every existing wallet: nothing creates an entropy record yet, so GetMnemonicEntropy returns false and the old code path is taken. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+21
-2
@@ -1345,6 +1345,14 @@ public:
|
||||
|
||||
bool SetHDSeed(const HDSeed& seed);
|
||||
bool SetCryptedHDSeed(const uint256& seedFp, const std::vector<unsigned char> &vchCryptedSecret);
|
||||
/* Record this wallet's BIP39 entropy so its seed phrase can be reprinted.
|
||||
Display-only: derivation never reads it (the HD seed holds the bytes that
|
||||
are actually derived from). Refuses to replace an existing record.
|
||||
SetCryptedMnemonicEntropy overrides the CCryptoKeyStore virtual so the
|
||||
record reaches disk; SetMnemonicEntropy merely hides the base version,
|
||||
which is safe because no call site holds a base pointer. */
|
||||
bool SetMnemonicEntropy(const RawHDSeed& entropy);
|
||||
bool SetCryptedMnemonicEntropy(const uint256& entropyFp, const std::vector<unsigned char> &vchCryptedSecret);
|
||||
|
||||
/* Restore a wallet's HD seed from a hex string (as exported in the
|
||||
z_exportwallet "# HDSeed=" comment): 32 bytes for a legacy raw seed, or
|
||||
@@ -1363,8 +1371,14 @@ public:
|
||||
wallet and the seed is available (unlocked). Returns false otherwise. */
|
||||
bool GetMnemonicPhrase(std::string& phraseOut) const;
|
||||
|
||||
/* True if the HD seed was derived from a BIP39 mnemonic (stored as entropy). */
|
||||
bool IsMnemonicSeed() const { return hdChain.fMnemonicSeed; }
|
||||
/* True if this wallet has a BIP39 seed phrase available. Two storage forms
|
||||
qualify:
|
||||
- current: the HD seed is the EXPANDED 64-byte BIP39 seed and the
|
||||
entropy lives in its own record (HaveMnemonicEntropy());
|
||||
- legacy: hdChain.fMnemonicSeed, where the stored HD seed IS the
|
||||
32-byte entropy and is expanded on every derivation.
|
||||
Gates z_exportmnemonic (rpcdump.cpp). */
|
||||
bool IsMnemonicSeed() const { return hdChain.fMnemonicSeed || HaveMnemonicEntropy(); }
|
||||
|
||||
/* Return the seed to feed into HD derivation. For mnemonic wallets this
|
||||
expands the stored 32-byte entropy into the 64-byte BIP39 seed; for legacy
|
||||
@@ -1396,6 +1410,11 @@ public:
|
||||
|
||||
/* Set the current encrypted HD seed, without saving it to disk (used by LoadWallet) */
|
||||
bool LoadCryptedHDSeed(const uint256& seedFp, const std::vector<unsigned char>& seed);
|
||||
/* Set the mnemonic entropy, without saving it to disk (used by LoadWallet) */
|
||||
bool LoadMnemonicEntropy(const RawHDSeed& entropy);
|
||||
|
||||
/* Set the encrypted mnemonic entropy, without saving it to disk (used by LoadWallet) */
|
||||
bool LoadCryptedMnemonicEntropy(const uint256& entropyFp, const std::vector<unsigned char>& vchCryptedSecret);
|
||||
|
||||
/* Find notes filtered by payment address, min depth, ability to spend */
|
||||
void GetFilteredNotes(std::vector<SaplingNoteEntry>& saplingEntries,
|
||||
|
||||
Reference in New Issue
Block a user