From 5b62f095e790a0d4e2a70ece89465b64fc68358a Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Wed, 10 Aug 2022 15:19:56 -0400 Subject: wallet: Refactor SetupDescSPKMs to take CExtKey Refactors SetupDescSPKMs so that the DescSPKM loops are in their own function. This allows us to call it later during migration with a key that was already generated. --- src/wallet/wallet.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 934811dee1..d1876dda70 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -907,6 +907,7 @@ public: void DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool internal); //! Create new DescriptorScriptPubKeyMans and add them to the wallet + void SetupDescriptorScriptPubKeyMans(const CExtKey& master_key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); //! Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet -- cgit v1.2.3 From e7b16f925ae5b117e8b74ce814b63e19b19b50f4 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Fri, 26 Aug 2022 13:18:04 -0400 Subject: Implement MigrateToSQLite --- src/wallet/wallet.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index d1876dda70..45391c20d7 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -316,7 +316,7 @@ private: std::string m_name; /** Internal database handle. */ - std::unique_ptr const m_database; + std::unique_ptr m_database; /** * The following is used to keep track of how far behind the wallet is @@ -920,6 +920,13 @@ public: //! Add a descriptor to the wallet, return a ScriptPubKeyMan & associated output type ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); + + /** Move all records from the BDB database to a new SQLite database for storage. + * The original BDB file will be deleted and replaced with a new SQLite file. + * A backup is not created. + * May crash if something unexpected happens in the filesystem. + */ + bool MigrateToSQLite(bilingual_str& error) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); }; /** -- cgit v1.2.3 From 0bf7b38bff422e7413bcd3dc0abe2568dd918ddc Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 13 Jul 2020 16:38:39 -0400 Subject: Implement MigrateLegacyToDescriptor --- src/wallet/wallet.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/wallet/wallet.h') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 45391c20d7..d8807dc02d 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -927,6 +927,13 @@ public: * May crash if something unexpected happens in the filesystem. */ bool MigrateToSQLite(bilingual_str& error) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); + + //! Get all of the descriptors from a legacy wallet + std::optional GetDescriptorsForLegacy(bilingual_str& error) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); + + //! Adds the ScriptPubKeyMans given in MigrationData to this wallet, removes LegacyScriptPubKeyMan, + //! and where needed, moves tx and address book entries to watchonly_wallet or solvable_wallet + bool ApplyMigrationData(MigrationData& data, bilingual_str& error) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); }; /** @@ -985,6 +992,16 @@ bool RemoveWalletSetting(interfaces::Chain& chain, const std::string& wallet_nam bool DummySignInput(const SigningProvider& provider, CTxIn &tx_in, const CTxOut &txout, const CCoinControl* coin_control = nullptr); bool FillInputToWeight(CTxIn& txin, int64_t target_weight); + +struct MigrationResult { + std::string wallet_name; + std::shared_ptr watchonly_wallet; + std::shared_ptr solvables_wallet; + fs::path backup_path; +}; + +//! Do all steps to migrate a legacy wallet to a descriptor wallet +util::Result MigrateLegacyToDescriptor(std::shared_ptr&& wallet, WalletContext& context); } // namespace wallet #endif // BITCOIN_WALLET_WALLET_H -- cgit v1.2.3