mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
wallet: Fix segmentation fault in CreateWalletFromFile
This commit is contained in:
parent
fab3c34412
commit
fa734603b7
5 changed files with 26 additions and 1 deletions
|
@ -4243,7 +4243,7 @@ bool CWallet::Verify(interfaces::Chain& chain, const WalletLocation& location, b
|
|||
|
||||
std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain, const WalletLocation& location, uint64_t wallet_creation_flags)
|
||||
{
|
||||
const std::string& walletFile = WalletDataFilePath(location.GetPath()).string();
|
||||
const std::string walletFile = WalletDataFilePath(location.GetPath()).string();
|
||||
|
||||
// needed to restore wallet transaction meta data after -zapwallettxes
|
||||
std::vector<CWalletTx> vWtx;
|
||||
|
|
0
test/functional/data/wallets/high_minversion/.walletlock
Normal file
0
test/functional/data/wallets/high_minversion/.walletlock
Normal file
0
test/functional/data/wallets/high_minversion/db.log
Normal file
0
test/functional/data/wallets/high_minversion/db.log
Normal file
BIN
test/functional/data/wallets/high_minversion/wallet.dat
Normal file
BIN
test/functional/data/wallets/high_minversion/wallet.dat
Normal file
Binary file not shown.
|
@ -17,6 +17,8 @@ from test_framework.util import (
|
|||
assert_raises_rpc_error,
|
||||
)
|
||||
|
||||
FEATURE_LATEST = 169900
|
||||
|
||||
|
||||
class MultiWalletTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
|
@ -27,6 +29,13 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||
def skip_test_if_missing_module(self):
|
||||
self.skip_if_no_wallet()
|
||||
|
||||
def add_options(self, parser):
|
||||
parser.add_argument(
|
||||
'--data_wallets_dir',
|
||||
default=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/wallets/'),
|
||||
help='Test data with wallet directories (default: %(default)s)',
|
||||
)
|
||||
|
||||
def run_test(self):
|
||||
node = self.nodes[0]
|
||||
|
||||
|
@ -323,6 +332,22 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||
self.nodes[0].unloadwallet(wallet)
|
||||
self.nodes[1].loadwallet(wallet)
|
||||
|
||||
# Fail to load if wallet is downgraded
|
||||
shutil.copytree(os.path.join(self.options.data_wallets_dir, 'high_minversion'), wallet_dir('high_minversion'))
|
||||
self.restart_node(0, extra_args=['-upgradewallet={}'.format(FEATURE_LATEST)])
|
||||
assert {'name': 'high_minversion'} in self.nodes[0].listwalletdir()['wallets']
|
||||
self.log.info("Fail -upgradewallet that results in downgrade")
|
||||
assert_raises_rpc_error(
|
||||
-4,
|
||||
"Wallet loading failed.",
|
||||
lambda: self.nodes[0].loadwallet(filename='high_minversion'),
|
||||
)
|
||||
self.stop_node(
|
||||
i=0,
|
||||
expected_stderr='Error: Error loading {}: Wallet requires newer version of Bitcoin Core'.format(
|
||||
wallet_dir('high_minversion', 'wallet.dat')),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
MultiWalletTest().main()
|
||||
|
|
Loading…
Reference in a new issue