mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
wallet: decouple default descriptors creation from external signer setup
This will be useful in the following-up commit to batch the entire wallet migration process.
This commit is contained in:
parent
f2541d09e1
commit
6052c7891d
2 changed files with 21 additions and 11 deletions
|
@ -3754,21 +3754,28 @@ void CWallet::SetupDescriptorScriptPubKeyMans(const CExtKey& master_key)
|
||||||
if (!batch.TxnCommit()) throw std::runtime_error("Error: cannot commit db transaction for descriptors setup");
|
if (!batch.TxnCommit()) throw std::runtime_error("Error: cannot commit db transaction for descriptors setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWallet::SetupOwnDescriptorScriptPubKeyMans()
|
||||||
|
{
|
||||||
|
AssertLockHeld(cs_wallet);
|
||||||
|
assert(!IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER));
|
||||||
|
// Make a seed
|
||||||
|
CKey seed_key = GenerateRandomKey();
|
||||||
|
CPubKey seed = seed_key.GetPubKey();
|
||||||
|
assert(seed_key.VerifyPubKey(seed));
|
||||||
|
|
||||||
|
// Get the extended key
|
||||||
|
CExtKey master_key;
|
||||||
|
master_key.SetSeed(seed_key);
|
||||||
|
|
||||||
|
SetupDescriptorScriptPubKeyMans(master_key);
|
||||||
|
}
|
||||||
|
|
||||||
void CWallet::SetupDescriptorScriptPubKeyMans()
|
void CWallet::SetupDescriptorScriptPubKeyMans()
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
|
|
||||||
if (!IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER)) {
|
if (!IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER)) {
|
||||||
// Make a seed
|
SetupOwnDescriptorScriptPubKeyMans();
|
||||||
CKey seed_key = GenerateRandomKey();
|
|
||||||
CPubKey seed = seed_key.GetPubKey();
|
|
||||||
assert(seed_key.VerifyPubKey(seed));
|
|
||||||
|
|
||||||
// Get the extended key
|
|
||||||
CExtKey master_key;
|
|
||||||
master_key.SetSeed(seed_key);
|
|
||||||
|
|
||||||
SetupDescriptorScriptPubKeyMans(master_key);
|
|
||||||
} else {
|
} else {
|
||||||
ExternalSigner signer = ExternalSignerScriptPubKeyMan::GetExternalSigner();
|
ExternalSigner signer = ExternalSignerScriptPubKeyMan::GetExternalSigner();
|
||||||
|
|
||||||
|
@ -4102,7 +4109,7 @@ bool CWallet::ApplyMigrationData(MigrationData& data, bilingual_str& error)
|
||||||
SetupDescriptorScriptPubKeyMans(data.master_key);
|
SetupDescriptorScriptPubKeyMans(data.master_key);
|
||||||
} else {
|
} else {
|
||||||
// Setup with a new seed if we don't.
|
// Setup with a new seed if we don't.
|
||||||
SetupDescriptorScriptPubKeyMans();
|
SetupOwnDescriptorScriptPubKeyMans();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1021,6 +1021,9 @@ public:
|
||||||
void SetupDescriptorScriptPubKeyMans(const CExtKey& master_key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
void SetupDescriptorScriptPubKeyMans(const CExtKey& master_key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
|
//! Create new seed and default DescriptorScriptPubKeyMans for this wallet
|
||||||
|
void SetupOwnDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
//! Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet
|
//! Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet
|
||||||
DescriptorScriptPubKeyMan* GetDescriptorScriptPubKeyMan(const WalletDescriptor& desc) const;
|
DescriptorScriptPubKeyMan* GetDescriptorScriptPubKeyMan(const WalletDescriptor& desc) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue