Skip to content

wallet: Disable creating and loading legacy wallets - #31250

Merged
fanquake merged 12 commits into
bitcoin:masterfrom
achow101:disable-legacy-wallets
Apr 25, 2025
Merged

wallet: Disable creating and loading legacy wallets#31250
fanquake merged 12 commits into
bitcoin:masterfrom
achow101:disable-legacy-wallets

Conversation

@achow101

@achow101 achow101 commented Nov 7, 2024

Copy link
Copy Markdown
Member

To prepare for the deletion of legacy wallet code, disable creating or loading new legacy wallets.

Tests for the legacy wallet specifically are deleted.

Split from #28710

@DrahtBot

DrahtBot commented Nov 7, 2024

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31250.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK Sjors, pablomartin4btc, laanwj
Concept ACK rkrux
Stale ACK maflcko, brunoerg

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #32290 (test: allow all functional tests to be run or skipped with --usecli by mzumsande)
  • #32273 (wallet: Fix relative path backup during migration. by davidgumberg)
  • #32174 (test: Verify that a message is not in rpc errors raised (follow-up 31451) by pablomartin4btc)
  • #32123 (wallet: make coinbase that will mature on the next block available for selection by luisschwab)
  • #31936 (rpc: Support v3 raw transactions creation by Bue-von-hon)
  • #31723 (qa debug: Add --debug_runs/-waitfordebugger [DRAFT] by hodlinator)
  • #31668 (Added rescan option for import descriptors by saikiran57)
  • #31423 (wallet: migration, don't create spendable wallet from a watch-only legacy wallet by furszy)
  • #29770 (index: Check all necessary block data is available before starting to sync by fjahr)
  • #29124 (test: Test that migration automatically repairs corrupted metadata with doubled derivation path by achow101)
  • #28944 (wallet, rpc: add anti-fee-sniping to send and sendall by ishaanam)
  • #28802 (ArgsManager: support subcommand-specific options by ajtowns)
  • #28710 (Remove the legacy wallet and BDB dependency by achow101)
  • #28333 (wallet: Construct ScriptPubKeyMans with all data rather than loaded progressively by achow101)
  • #27865 (wallet: Track no-longer-spendable TXOs separately by achow101)
  • #27286 (wallet: Keep track of the wallet's own transaction outputs in memory by achow101)
  • #27052 (test: rpc: add last block announcement time to getpeerinfo result by LarryRuane)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@DrahtBot DrahtBot added the Wallet label Nov 7, 2024
@achow101
achow101 force-pushed the disable-legacy-wallets branch from 4fcb431 to 47ac41b Compare November 7, 2024 18:54
This was referenced Nov 8, 2024
@achow101
achow101 force-pushed the disable-legacy-wallets branch from 47ac41b to 4f0e11b Compare November 12, 2024 15:49
Remove the option to set descriptors=False when creating a wallet, and
enforce this in RPC and in CreateWallet
Legacy wallets do not have the descriptors flag set. Don't load wallets
without the descriptors flag.

At the same time, we will no longer load BDB databases since they are
only used for legacy wallets.
@Sjors

Sjors commented Apr 24, 2025

Copy link
Copy Markdown
Member

re-ACK 17bb63f

@pablomartin4btc pablomartin4btc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 17bb63f

Since my last review:

  • Added a commit to disable legacy wallet creation from the wallet tool.

  • Addresed @davidgumberg's feedback.

@laanwj laanwj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 17bb63f
git range-diff b2bb27f..e39118ab0bf08fdaf68b16c86ad304b9133b43c7 9a4c92e..17bb63f

  • test: wallet_transactiontime_rescan importdescriptors always rescans: commit removed (test change not necessary here)
  • test: Remove legacy wallet tests from wallet_backwards_compatibility.py: comment change typo reverted
  • wallet: Disallow legacy wallet creation from the wallet tool, wallet: Disallow creating legacy wallets: add newlines to tfm::formats
    • (ideally these would both be in the first commit as that's where they're introduced, maybe if you need to re-touch anyway)

@pablomartin4btc

Copy link
Copy Markdown
Member

If a user tries to restore a legacy wallet (using RPC or QT) setting "load_on_startup" (can't be done on QT but it's being set in the wallet interface code), next time the node or QT starts it will be closed with the error "... Failed to open database path ... The wallet appears to be a Legacy wallet, please use the wallet migration tool... ". That case shouldn't be handled here? We shouldn't allow load_on_startup on legacy...

(Currently this situation is not happening as a side effect of #31451).

@achow101

Copy link
Copy Markdown
Member Author

If a user tries to restore a legacy wallet (using RPC or QT) setting "load_on_startup" (can't be done on QT but it's being set in the wallet interface code), next time the node or QT starts it will be closed with the error "... Failed to open database path ... The wallet appears to be a Legacy wallet, please use the wallet migration tool... ". That case shouldn't be handled here? We shouldn't allow load_on_startup on legacy...

(Currently this situation is not happening as a side effect of #31451).

I don't quite follow what you're saying. I tried to restore a legacy wallet with this PR and it doesn't do it, nor are there any issues with startup the next time.

Do you mean there is a possibility here if the interface is used incorrectly internally? In that case, I think it can be handled in a followup/if it becomes a reachable problem.

@pablomartin4btc

Copy link
Copy Markdown
Member

I tried to restore a legacy wallet with this PR and it doesn't do it, nor are there any issues...

Ok, I thought the restore would allow to do it and then the load_on_startup would fail but the restore fail on the wallet file verification, so all good.

Tested restorewallet creating a legacy on master, backed it up there and trying to restore it on this PR's branch.

./build_31250/bin/bitcoin-cli -regtest -datadir=/tmp/btc-wallet restorewallet "restored_legacy_master" /tmp/btc-wallet/regtest/wallets/backup_legacy_master.dat true
error code: -18
error message:
Wallet file verification failed. Failed to open database path '/tmp/btc-wallet/regtest/wallets/restored_legacy_master'. The wallet appears to be a Legacy wallet, please use the wallet migration tool (migratewallet RPC).

@pablomartin4btc

Copy link
Copy Markdown
Member

Do you mean there is a possibility here if the interface is used incorrectly internally?

I've tested it with this branch's QT and same failure on wallet file verifitcation while trying to restore a legacy backup using the GUI. All good.

@maflcko

maflcko commented Apr 25, 2025

Copy link
Copy Markdown
Member

(fresh CI)

Comment thread test/functional/test_framework/test_framework.py
Comment thread test/functional/rpc_createmultisig.py
Comment thread test/functional/rpc_createmultisig.py
Comment thread test/functional/rpc_rawtransaction.py

class RPCOverloadWrapper():
def __init__(self, rpc, cli=False, descriptors=False):
def __init__(self, rpc, cli=False):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated in c847dee: However, while touching, it could make sense to force named args for literal args, especially integral (boolean) ones:

    def __init__(self, rpc, *, cli=False):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let the next person to touch it to change this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the cli field can be removed. Done in #32360

Comment thread test/functional/test_runner.py

def importprivkey(self, privkey, label=None, rescan=None):
wallet_info = self.getwalletinfo()
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to remove this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The importprivkey overload was kept because several tests still use it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):. However, I see that it may be used by tests using previous releases.

Comment thread test/functional/wallet_createwallet.py
@fanquake

Copy link
Copy Markdown
Member

Looks like is_bdb_compiled & skip_if_no_bdb should have been dropped.

Comment thread test/functional/feature_bip68_sequence.py
@pablomartin4btc

Copy link
Copy Markdown
Member

Looks like is_bdb_compiled & skip_if_no_bdb should have been dropped.

That's done in #28710 (commit: "build, wallet, doc: Remove BDB").

@amtriorix

This comment was marked as abuse.

@davidgumberg

Copy link
Copy Markdown
Contributor

Backwards compatibility is needed for wallet.dat

Bitcoin Core will still be able to migrate wallets that are in the legacy format to the new format. See the migratewallet rpc command: https://bitcoincore.org/en/doc/29.0.0/rpc/wallet/migratewallet/ and the legacy wallet deprecation tracking issue (#20160) for more context.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.