Expected behavior
Wallet created in testnet should neither be available in listwalletdir
nor allowed to be loaded in mainnet,regtest,signet etc. And in general we should not be able to open wallets of other chains/network mode.
Actual behavior
Wallet created in regtest, testnet etc. are available in listwalletdir
, bitcoin-qt -> open wallet and testnet wallet can be loaded in mainnet
To reproduce
-
Run
bitcoind -testnet=1
and create a wallet T1 -
Run
bitcoind -regtest=1
and create a wallet R1 -
Run
bitcoind
and create a wallet M1 -
Run
bitcoind -datadir=/home/satoshi
(Assuming user ‘satoshi’, OS: Ubuntu, real datadir: /home/satoshi/.bitcoin, if trying on Windows root directory can be used in -datadir. Example: “C:”) -
Check wallets with
listwalletdir
-
Try to load regtest and testnet wallets in mainnet. R1 will give the following error as expected:
0error code: -4 1error message: 2Wallet loading failed. Wallet files should not be reused across chains.
T1 will give error mentioned in https://github.com/bitcoin-core/gui/issues/369 so I tried unloading this wallet and load. This works although we should not be able to load wallets created in other chain/network mode. I have not tried experimenting more however more things may be possible.
0$ bitcoin-cli -datadir=/home/satoshi unloadwallet ".bitcoin/testnet3/wallets/T1" 1{ 2 "warning": "" 3} 4$ ./bitcoin-cli -datadir=/home/satoshi loadwallet ".bitcoin/testnet3/wallets/T1" 5{ 6 "name": ".bitcoin/testnet3/wallets/T1", 7 "warning": "" 8}
System information
Tried with Master Branch and PR#18554 Branch on Pop!_OS
This issue can result in vulnerabilities if ignored and things are not kept separate IMO. One interesting vulnerability that I remember: https://shiftcrypto.ch/blog/coldcard-isolation-bypass/