Skip to content

Commit 6115218

Browse files
committed
wallet: Add a deprecation warning for newly created legacy wallets
1 parent 64a4483 commit 6115218

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/wallet/rpc/wallet.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,9 @@ static RPCHelpMan createwallet()
315315
{"blank", RPCArg::Type::BOOL, RPCArg::Default{false}, "Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed."},
316316
{"passphrase", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "Encrypt the wallet with this passphrase."},
317317
{"avoid_reuse", RPCArg::Type::BOOL, RPCArg::Default{false}, "Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind."},
318-
{"descriptors", RPCArg::Type::BOOL, RPCArg::Default{true}, "Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation"},
318+
{"descriptors", RPCArg::Type::BOOL, RPCArg::Default{true}, "Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation."
319+
" Setting to \"false\" will create a legacy wallet; however, the legacy wallet type is being deprecated and"
320+
" support for creating and opening legacy wallets will be removed in the future."},
319321
{"load_on_startup", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED_NAMED_ARG, "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
320322
{"external_signer", RPCArg::Type::BOOL, RPCArg::Default{false}, "Use an external signer such as a hardware wallet. Requires -signer to be configured. Wallet creation will fail if keys cannot be fetched. Requires disable_private_keys and descriptors set to true."},
321323
},

src/wallet/wallet.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
354354
// Write the wallet settings
355355
UpdateWalletSetting(*context.chain, name, load_on_start, warnings);
356356

357+
// Legacy wallets are being deprecated, warn if a newly created wallet is legacy
358+
if (!(wallet_creation_flags & WALLET_FLAG_DESCRIPTORS)) {
359+
warnings.push_back(_("Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future."));
360+
}
361+
357362
status = DatabaseStatus::SUCCESS;
358363
return wallet;
359364
}

test/functional/wallet_createwallet.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,10 @@ def run_test(self):
164164
self.log.info('Using a passphrase with private keys disabled returns error')
165165
assert_raises_rpc_error(-4, 'Passphrase provided but private keys are disabled. A passphrase is only used to encrypt private keys, so cannot be used for wallets with private keys disabled.', self.nodes[0].createwallet, wallet_name='w9', disable_private_keys=True, passphrase='thisisapassphrase')
166166

167+
if self.is_bdb_compiled():
168+
self.log.info("Test legacy wallet deprecation")
169+
res = self.nodes[0].createwallet(wallet_name="legacy_w0", descriptors=False, passphrase=None)
170+
assert_equal(res["warning"], "Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future.")
171+
167172
if __name__ == '__main__':
168173
CreateWalletTest().main()

0 commit comments

Comments
 (0)