-
Notifications
You must be signed in to change notification settings - Fork 38.7k
wallet: ensure wallet files are not reused across chains #18554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wallet: ensure wallet files are not reused across chains #18554
Conversation
9b93678 to
e1dc5b4
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
src/wallet/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should be a debug option only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, debug options are for users who know what they are doing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. Should it also be in WALLET_DEBUG_TEST category?
3ce1335 to
0f02b2c
Compare
0f02b2c to
0ae2e5c
Compare
0ae2e5c to
36bb866
Compare
36bb866 to
5030801
Compare
|
Looks like the CI picked up a memory leak running |
51b4f8c to
2844377
Compare
2844377 to
4eb1434
Compare
50c8e2b to
d48ed7a
Compare
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to move it here, since putting this after line 2766 where I placed it originally results in memory leaks, as detected by the sanitizer.
3188695 to
ece5cd1
Compare
|
I tested this today and tried to reproduce the issue with the steps mentioned in this issue: #22792
|
If that is a descriptor wallet, then that would be because the sqlite implementation (only used for descriptor wallets) includes a crosschain protection mechanism already. However legacy wallets don't, and this PR would allow for that.
Indeed. The test is incorrect because all regtest chains use the same genesis even if the rest of the blockchain is different. @rodentrabies You will need to change the test to start a node in testnet or mainnet mode (without syncing of course) in order to test the crosschain protection.
I don't think that is related, you should double check your bitcoin.conf and make sure it does not specify a specific chain to use. |
I am not sure if there was some misunderstanding. Not able to reproduce issue in PR branch was a good thing but error was confusing. @rodentrabies its been couple of years and issue is still not fixed. There were some suggestions by @achow101 as well. You tried your best and I appreciate it however I think this can lead to some kind of vulnerability if not fixed soon. Last update was 3 months ago. Is it okay if someone else can work on this pull request? |
|
@prayank23 I'm sorry for the slow progress on this. I'll work on wrapping this up today, if you don't mind. In fact I've spent 2 hours this weekend trying to make the functional test start both regtest and testnet nodes for me by playing with |
d93f366 to
6c31b80
Compare
6c31b80 to
b933b80
Compare
|
Tried testing different things. Two tests worked as expected and 1 failed. ✅ Test 1 :
✅ Test 2:
❌ Test 3:
|
|
Just tried this (test 3) and got expected behavior: Perhaps EDIT: just tried the same without |
b933b80 to
5f21321
Compare
|
ACK 5f21321 |
Even I could not reproduce it and getting cross chain error now for a new wallet. Old wallet still loads in mainnet that was created on testnet. I have added the wallet files if that helps: https://github.com/prayank23/bitcoin/blob/test-wallets/T2.zip |
Are you sure you didn't just make a mistake when doing this test? The provided wallet file has a mainnet block locator record and it doesn't load in testnet with this PR. |
Right. Looks like I did something wrong. I think this PR fixes the issue and if I find anything else it can be done in a follow up PR. Its weird that this wallet T2 exists with other testnet wallets in testnet3 directory. |
ghost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 5f21321
|
Code Review ACK 5f21321 Apropos of nothing: @rodentrabies has quite the fortitude, carrying this PR since 2018 |
|
@dongcarl to be frank, I didn't do a very good job of carrying it. Had to be reminded several times to rebase/update it :) Great it's finally merged! |
…s chains 5f21321 tests: add tests for cross-chain wallet use prevention (Seibart Nedor) 9687659 wallet: ensure wallet files are not reused across chains (Seibart Nedor) Pull request description: This implements a proposal in bitcoin#12805 and is a rebase of bitcoin#14533. This seems to be a working approach, but I'm not sure why the `p2p_segwit.py` functional test needed a change, so I'll look into it more. ACKs for top commit: achow101: ACK 5f21321 dongcarl: Code Review ACK 5f21321 [deleted]: tACK bitcoin@5f21321 Tree-SHA512: 2c934300f113e772fc31c16ef5588526300bbc36e4dcef7d77bd0760c5c8f0ec77f766b1bed5503eb0157fa26dc900ed54d2ad1b41863c1f736ce5c1f3b67bec
This implements a proposal in #12805 and is a rebase of #14533.
This seems to be a working approach, but I'm not sure why the
p2p_segwit.pyfunctional test needed a change, so I'll look into it more.