mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
wallet: Construct ExternalSignerSPKM with the new descriptor
Instead of constructing then setting the descriptor with SetupDescriptor, just pass in that descriptor to the constructor.
This commit is contained in:
parent
dc4c61f7ec
commit
39db554fe0
3 changed files with 8 additions and 14 deletions
|
@ -21,7 +21,8 @@
|
||||||
using common::PSBTError;
|
using common::PSBTError;
|
||||||
|
|
||||||
namespace wallet {
|
namespace wallet {
|
||||||
bool ExternalSignerScriptPubKeyMan::SetupDescriptor(WalletBatch& batch, std::unique_ptr<Descriptor> desc)
|
ExternalSignerScriptPubKeyMan::ExternalSignerScriptPubKeyMan(WalletStorage& storage, WalletBatch& batch, int64_t keypool_size, std::unique_ptr<Descriptor> desc)
|
||||||
|
: DescriptorScriptPubKeyMan(storage, keypool_size)
|
||||||
{
|
{
|
||||||
LOCK(cs_desc_man);
|
LOCK(cs_desc_man);
|
||||||
assert(m_storage.IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
|
assert(m_storage.IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
|
||||||
|
@ -42,7 +43,6 @@ bool ExternalSignerScriptPubKeyMan::SetupDescriptor(WalletBatch& batch, std::uni
|
||||||
TopUpWithDB(batch);
|
TopUpWithDB(batch);
|
||||||
|
|
||||||
m_storage.UnsetBlankWalletFlag(batch);
|
m_storage.UnsetBlankWalletFlag(batch);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalSigner ExternalSignerScriptPubKeyMan::GetExternalSigner() {
|
ExternalSigner ExternalSignerScriptPubKeyMan::GetExternalSigner() {
|
||||||
|
|
|
@ -14,18 +14,13 @@ struct bilingual_str;
|
||||||
namespace wallet {
|
namespace wallet {
|
||||||
class ExternalSignerScriptPubKeyMan : public DescriptorScriptPubKeyMan
|
class ExternalSignerScriptPubKeyMan : public DescriptorScriptPubKeyMan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExternalSignerScriptPubKeyMan(WalletStorage& storage, const uint256& id, WalletDescriptor& descriptor, int64_t keypool_size, const KeyMap& keys, const CryptedKeyMap& ckeys)
|
//! Create an ExternalSPKM from existing wallet data
|
||||||
|
ExternalSignerScriptPubKeyMan(WalletStorage& storage, const uint256& id, WalletDescriptor& descriptor, int64_t keypool_size, const KeyMap& keys, const CryptedKeyMap& ckeys)
|
||||||
: DescriptorScriptPubKeyMan(storage, id, descriptor, keypool_size, keys, ckeys)
|
: DescriptorScriptPubKeyMan(storage, id, descriptor, keypool_size, keys, ckeys)
|
||||||
{}
|
{}
|
||||||
ExternalSignerScriptPubKeyMan(WalletStorage& storage, int64_t keypool_size)
|
//! Create a new ExternalSPKM from just a descriptor
|
||||||
: DescriptorScriptPubKeyMan(storage, keypool_size)
|
ExternalSignerScriptPubKeyMan(WalletStorage& storage, WalletBatch& batch, int64_t keypool_size, std::unique_ptr<Descriptor> desc);
|
||||||
{}
|
|
||||||
|
|
||||||
/** Provide a descriptor at setup time
|
|
||||||
* Returns false if already setup or setup fails, true if setup is successful
|
|
||||||
*/
|
|
||||||
bool SetupDescriptor(WalletBatch& batch, std::unique_ptr<Descriptor>desc);
|
|
||||||
|
|
||||||
static ExternalSigner GetExternalSigner();
|
static ExternalSigner GetExternalSigner();
|
||||||
|
|
||||||
|
|
|
@ -3800,8 +3800,7 @@ void CWallet::SetupDescriptorScriptPubKeyMans()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
OutputType t = *desc->GetOutputType();
|
OutputType t = *desc->GetOutputType();
|
||||||
auto spk_manager = std::unique_ptr<ExternalSignerScriptPubKeyMan>(new ExternalSignerScriptPubKeyMan(*this, m_keypool_size));
|
auto spk_manager = std::unique_ptr<ExternalSignerScriptPubKeyMan>(new ExternalSignerScriptPubKeyMan(*this, batch, m_keypool_size, std::move(desc)));
|
||||||
spk_manager->SetupDescriptor(batch, std::move(desc));
|
|
||||||
uint256 id = spk_manager->GetID();
|
uint256 id = spk_manager->GetID();
|
||||||
AddScriptPubKeyMan(id, std::move(spk_manager));
|
AddScriptPubKeyMan(id, std::move(spk_manager));
|
||||||
AddActiveScriptPubKeyManWithDb(batch, id, t, internal);
|
AddActiveScriptPubKeyManWithDb(batch, id, t, internal);
|
||||||
|
|
Loading…
Add table
Reference in a new issue