Disable v23 descriptor wallets.
Missing sethdseed, signmessage doesn't work and dumprivkey is missing (preventing a workaround).
This commit is contained in:
parent
093a36c8d2
commit
bbe7556d18
@ -723,6 +723,10 @@ class BasicSwap(BaseApp):
|
||||
yield c
|
||||
|
||||
def changeWalletPasswords(self, old_password, new_password):
|
||||
|
||||
if len(self.swaps_in_progress) > 0:
|
||||
raise ValueError('Can\'t change passwords while swaps are in progress')
|
||||
|
||||
# Unlock all wallets to ensure they all have the same password.
|
||||
for c in self.activeCoins():
|
||||
ci = self.ci(c)
|
||||
|
@ -1261,6 +1261,7 @@ class BTCInterface(CoinInterface):
|
||||
ensure(sign_for_addr is not None, 'Could not find address with enough funds for proof')
|
||||
|
||||
self._log.debug('sign_for_addr %s', sign_for_addr)
|
||||
|
||||
if self._use_segwit: # TODO: Use isSegwitAddress when scantxoutset can use combo
|
||||
# 'Address does not refer to key' for non p2pkh
|
||||
pkh = self.decodeAddress(sign_for_addr)
|
||||
@ -1291,6 +1292,7 @@ class BTCInterface(CoinInterface):
|
||||
return False
|
||||
|
||||
def changeWalletPassword(self, old_password, new_password):
|
||||
self._log.info('changeWalletPassword - {}'.format(self.ticker()))
|
||||
if old_password == '':
|
||||
return self.rpc_callback('encryptwallet', [new_password])
|
||||
self.rpc_callback('walletpassphrasechange', [old_password, new_password])
|
||||
@ -1298,10 +1300,12 @@ class BTCInterface(CoinInterface):
|
||||
def unlockWallet(self, password):
|
||||
if password == '':
|
||||
return
|
||||
self._log.info('unlockWallet - {}'.format(self.ticker()))
|
||||
# Max timeout value, ~3 years
|
||||
self.rpc_callback('walletpassphrase', [password, 100000000])
|
||||
|
||||
def lockWallet(self):
|
||||
self._log.info('lockWallet - {}'.format(self.ticker()))
|
||||
self.rpc_callback('walletlock')
|
||||
|
||||
|
||||
|
@ -295,7 +295,6 @@ class XMRInterface(CoinInterface):
|
||||
}
|
||||
|
||||
try:
|
||||
rv = self.rpc_wallet_cb('open_wallet', {'filename': address_b58})
|
||||
self.openWallet(address_b58)
|
||||
except Exception as e:
|
||||
self.createWallet(params)
|
||||
@ -520,6 +519,7 @@ class XMRInterface(CoinInterface):
|
||||
return balance_info['unlocked_balance']
|
||||
|
||||
def changeWalletPassword(self, old_password, new_password):
|
||||
self._log.info('changeWalletPassword - {}'.format(self.ticker()))
|
||||
orig_password = self._wallet_password
|
||||
if old_password != '':
|
||||
self._wallet_password = old_password
|
||||
@ -531,7 +531,9 @@ class XMRInterface(CoinInterface):
|
||||
raise e
|
||||
|
||||
def unlockWallet(self, password):
|
||||
self._log.info('unlockWallet - {}'.format(self.ticker()))
|
||||
self._wallet_password = password
|
||||
|
||||
def lockWallet(self):
|
||||
self._log.info('lockWallet - {}'.format(self.ticker()))
|
||||
self._wallet_password = None
|
||||
|
@ -973,7 +973,12 @@ def initialise_wallets(particl_wallet_mnemonic, with_coins, data_dir, settings,
|
||||
wallets = swap_client.callcoinrpc(c, 'listwallets')
|
||||
if len(wallets) < 1:
|
||||
logger.info('Creating wallet.dat for {}.'.format(getCoinName(c)))
|
||||
swap_client.callcoinrpc(c, 'createwallet', ['wallet.dat'])
|
||||
|
||||
if c == Coins.BTC:
|
||||
# wallet_name, wallet_name, blank, passphrase, avoid_reuse, descriptors
|
||||
swap_client.callcoinrpc(c, 'createwallet', ['wallet.dat', False, True, '', False, False])
|
||||
else:
|
||||
swap_client.callcoinrpc(c, 'createwallet', ['wallet.dat'])
|
||||
|
||||
if 'particl' in with_coins and c == Coins.PART:
|
||||
logger.info('Loading Particl mnemonic')
|
||||
|
@ -93,12 +93,15 @@ def prepareDataDir(datadir, node_id, conf_file, dir_prefix, base_p2p_port=BASE_P
|
||||
|
||||
|
||||
def checkForks(ro):
|
||||
if 'bip9_softforks' in ro:
|
||||
assert (ro['bip9_softforks']['csv']['status'] == 'active')
|
||||
assert (ro['bip9_softforks']['segwit']['status'] == 'active')
|
||||
else:
|
||||
assert (ro['softforks']['csv']['active'])
|
||||
assert (ro['softforks']['segwit']['active'])
|
||||
try:
|
||||
if 'bip9_softforks' in ro:
|
||||
assert (ro['bip9_softforks']['csv']['status'] == 'active')
|
||||
assert (ro['bip9_softforks']['segwit']['status'] == 'active')
|
||||
else:
|
||||
assert (ro['softforks']['csv']['active'])
|
||||
assert (ro['softforks']['segwit']['active'])
|
||||
except Exception as e:
|
||||
logging.warning('Could not parse deployment info')
|
||||
|
||||
|
||||
def stopDaemons(daemons):
|
||||
|
@ -273,7 +273,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
btc_data_dir = os.path.join(cfg.TEST_DATADIRS, str(BTC_NODE))
|
||||
if os.path.exists(os.path.join(cfg.BITCOIN_BINDIR, 'bitcoin-wallet')):
|
||||
callrpc_cli(cfg.BITCOIN_BINDIR, btc_data_dir, 'regtest', '-wallet=wallet.dat create', 'bitcoin-wallet')
|
||||
callrpc_cli(cfg.BITCOIN_BINDIR, btc_data_dir, 'regtest', '-wallet=wallet.dat -legacy create', 'bitcoin-wallet')
|
||||
cls.daemons.append(startDaemon(btc_data_dir, cfg.BITCOIN_BINDIR, cfg.BITCOIND))
|
||||
logging.info('Started %s %d', cfg.BITCOIND, cls.daemons[-1].pid)
|
||||
cls.daemons.append(startDaemon(os.path.join(cfg.TEST_DATADIRS, str(DASH_NODE)), cfg.DASH_BINDIR, cfg.DASHD))
|
||||
@ -282,7 +282,7 @@ class Test(unittest.TestCase):
|
||||
for i in range(NUM_NODES):
|
||||
data_dir = os.path.join(cfg.TEST_DATADIRS, str(i))
|
||||
if os.path.exists(os.path.join(cfg.PARTICL_BINDIR, 'particl-wallet')):
|
||||
callrpc_cli(cfg.PARTICL_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat create', 'particl-wallet')
|
||||
callrpc_cli(cfg.PARTICL_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat -legacy create', 'particl-wallet')
|
||||
cls.daemons.append(startDaemon(data_dir, cfg.PARTICL_BINDIR, cfg.PARTICLD))
|
||||
logging.info('Started %s %d', cfg.PARTICLD, cls.daemons[-1].pid)
|
||||
|
||||
@ -334,7 +334,7 @@ class Test(unittest.TestCase):
|
||||
logging.info('Mining %d Bitcoin blocks to %s', num_blocks, cls.btc_addr)
|
||||
btcRpc('generatetoaddress {} {}'.format(num_blocks, cls.btc_addr))
|
||||
|
||||
ro = btcRpc('getblockchaininfo')
|
||||
ro = btcRpc('getdeploymentinfo')
|
||||
checkForks(ro)
|
||||
|
||||
ro = dashRpc('getwalletinfo')
|
||||
|
@ -200,7 +200,7 @@ class Test(unittest.TestCase):
|
||||
for i in range(NUM_NODES):
|
||||
data_dir = prepareDataDir(TEST_DIR, i, 'particl.conf', 'part_')
|
||||
if os.path.exists(os.path.join(cfg.PARTICL_BINDIR, 'particl-wallet')):
|
||||
callrpc_cli(cfg.PARTICL_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat create', 'particl-wallet')
|
||||
callrpc_cli(cfg.PARTICL_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat -legacy create', 'particl-wallet')
|
||||
|
||||
cls.part_daemons.append(startDaemon(os.path.join(TEST_DIR, 'part_' + str(i)), cfg.PARTICL_BINDIR, cfg.PARTICLD))
|
||||
logging.info('Started %s %d', cfg.PARTICLD, cls.part_daemons[-1].pid)
|
||||
@ -223,7 +223,7 @@ class Test(unittest.TestCase):
|
||||
for i in range(NUM_BTC_NODES):
|
||||
data_dir = prepareDataDir(TEST_DIR, i, 'bitcoin.conf', 'btc_', base_p2p_port=BTC_BASE_PORT, base_rpc_port=BTC_BASE_RPC_PORT)
|
||||
if os.path.exists(os.path.join(cfg.BITCOIN_BINDIR, 'bitcoin-wallet')):
|
||||
callrpc_cli(cfg.BITCOIN_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat create', 'bitcoin-wallet')
|
||||
callrpc_cli(cfg.BITCOIN_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat -legacy create', 'bitcoin-wallet')
|
||||
|
||||
cls.btc_daemons.append(startDaemon(os.path.join(TEST_DIR, 'btc_' + str(i)), cfg.BITCOIN_BINDIR, cfg.BITCOIND))
|
||||
logging.info('Started %s %d', cfg.BITCOIND, cls.part_daemons[-1].pid)
|
||||
|
@ -271,7 +271,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
btc_data_dir = os.path.join(cfg.TEST_DATADIRS, str(BTC_NODE))
|
||||
if os.path.exists(os.path.join(cfg.BITCOIN_BINDIR, 'bitcoin-wallet')):
|
||||
callrpc_cli(cfg.BITCOIN_BINDIR, btc_data_dir, 'regtest', '-wallet=wallet.dat create', 'bitcoin-wallet')
|
||||
callrpc_cli(cfg.BITCOIN_BINDIR, btc_data_dir, 'regtest', '-wallet=wallet.dat -legacy create', 'bitcoin-wallet')
|
||||
cls.daemons.append(startDaemon(btc_data_dir, cfg.BITCOIN_BINDIR, cfg.BITCOIND))
|
||||
logging.info('Started %s %d', cfg.BITCOIND, cls.daemons[-1].pid)
|
||||
cls.daemons.append(startDaemon(os.path.join(cfg.TEST_DATADIRS, str(NMC_NODE)), cfg.NAMECOIN_BINDIR, cfg.NAMECOIND))
|
||||
@ -280,7 +280,7 @@ class Test(unittest.TestCase):
|
||||
for i in range(NUM_NODES):
|
||||
data_dir = os.path.join(cfg.TEST_DATADIRS, str(i))
|
||||
if os.path.exists(os.path.join(cfg.PARTICL_BINDIR, 'particl-wallet')):
|
||||
callrpc_cli(cfg.PARTICL_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat create', 'particl-wallet')
|
||||
callrpc_cli(cfg.PARTICL_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat -legacy create', 'particl-wallet')
|
||||
cls.daemons.append(startDaemon(data_dir, cfg.PARTICL_BINDIR, cfg.PARTICLD))
|
||||
logging.info('Started %s %d', cfg.PARTICLD, cls.daemons[-1].pid)
|
||||
|
||||
@ -332,7 +332,7 @@ class Test(unittest.TestCase):
|
||||
logging.info('Mining %d Bitcoin blocks to %s', num_blocks, cls.btc_addr)
|
||||
btcRpc('generatetoaddress {} {}'.format(num_blocks, cls.btc_addr))
|
||||
|
||||
ro = btcRpc('getblockchaininfo')
|
||||
ro = btcRpc('getdeploymentinfo')
|
||||
checkForks(ro)
|
||||
|
||||
ro = nmcRpc('getwalletinfo')
|
||||
|
@ -285,7 +285,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
btc_data_dir = os.path.join(cfg.TEST_DATADIRS, str(BTC_NODE))
|
||||
if os.path.exists(os.path.join(cfg.BITCOIN_BINDIR, 'bitcoin-wallet')):
|
||||
callrpc_cli(cfg.BITCOIN_BINDIR, btc_data_dir, 'regtest', '-wallet=wallet.dat create', 'bitcoin-wallet')
|
||||
callrpc_cli(cfg.BITCOIN_BINDIR, btc_data_dir, 'regtest', '-wallet=wallet.dat -legacy create', 'bitcoin-wallet')
|
||||
cls.daemons.append(startDaemon(btc_data_dir, cfg.BITCOIN_BINDIR, cfg.BITCOIND))
|
||||
logging.info('Started %s %d', cfg.BITCOIND, cls.daemons[-1].pid)
|
||||
cls.daemons.append(startDaemon(os.path.join(cfg.TEST_DATADIRS, str(PIVX_NODE)), cfg.PIVX_BINDIR, cfg.PIVXD))
|
||||
@ -294,7 +294,7 @@ class Test(unittest.TestCase):
|
||||
for i in range(NUM_NODES):
|
||||
data_dir = os.path.join(cfg.TEST_DATADIRS, str(i))
|
||||
if os.path.exists(os.path.join(cfg.PARTICL_BINDIR, 'particl-wallet')):
|
||||
callrpc_cli(cfg.PARTICL_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat create', 'particl-wallet')
|
||||
callrpc_cli(cfg.PARTICL_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat -legacy create', 'particl-wallet')
|
||||
cls.daemons.append(startDaemon(data_dir, cfg.PARTICL_BINDIR, cfg.PARTICLD))
|
||||
logging.info('Started %s %d', cfg.PARTICLD, cls.daemons[-1].pid)
|
||||
|
||||
@ -346,7 +346,7 @@ class Test(unittest.TestCase):
|
||||
logging.info('Mining %d Bitcoin blocks to %s', num_blocks, cls.btc_addr)
|
||||
btcRpc('generatetoaddress {} {}'.format(num_blocks, cls.btc_addr))
|
||||
|
||||
ro = btcRpc('getblockchaininfo')
|
||||
ro = btcRpc('getdeploymentinfo')
|
||||
checkForks(ro)
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
@ -243,7 +243,8 @@ class BasicSwapTest(BaseTest):
|
||||
test_seed = '8e54a313e6df8918df6d758fafdbf127a115175fdd2238d0e908dd8093c9ac3b'
|
||||
test_wif = self.swap_clients[0].ci(self.test_coin_from).encodeKey(bytes.fromhex(test_seed))
|
||||
new_wallet_name = random.randbytes(10).hex()
|
||||
self.callnoderpc('createwallet', [new_wallet_name])
|
||||
# wallet_name, wallet_name, blank, passphrase, avoid_reuse, descriptors
|
||||
self.callnoderpc('createwallet', [new_wallet_name, False, True, '', False, False])
|
||||
self.callnoderpc('sethdseed', [True, test_wif], wallet=new_wallet_name)
|
||||
addr = self.callnoderpc('getnewaddress', wallet=new_wallet_name)
|
||||
self.callnoderpc('unloadwallet', [new_wallet_name])
|
||||
@ -432,7 +433,7 @@ class TestBTC(BasicSwapTest):
|
||||
assert (jsw['encrypted'] is False)
|
||||
assert (jsw['locked'] is False)
|
||||
|
||||
rv = read_json_api(1800, 'setpassword', {'oldpassword': '', 'newpassword': 'notapassword123'})
|
||||
read_json_api(1800, 'setpassword', {'oldpassword': '', 'newpassword': 'notapassword123'})
|
||||
|
||||
# Entire system is locked with Particl wallet
|
||||
jsw = read_json_api(1800, 'wallets/btc')
|
||||
@ -450,7 +451,6 @@ class TestBTC(BasicSwapTest):
|
||||
assert ('Coin must be unlocked' in jsw['error'])
|
||||
|
||||
read_json_api(1800, 'setpassword', {'oldpassword': 'notapassword123', 'newpassword': 'notapassword456'})
|
||||
|
||||
read_json_api(1800, 'unlock', {'password': 'notapassword456'})
|
||||
|
||||
for coin in ('part', 'btc', 'xmr'):
|
||||
@ -458,6 +458,17 @@ class TestBTC(BasicSwapTest):
|
||||
assert (jsw['encrypted'] is True)
|
||||
assert (jsw['locked'] is False)
|
||||
|
||||
def test_01_full_swap(self):
|
||||
js_0 = read_json_api(1800, 'wallets')
|
||||
if not js_0['PART']['encrypted']:
|
||||
read_json_api(1800, 'setpassword', {'oldpassword': '', 'newpassword': 'notapassword123'})
|
||||
read_json_api(1800, 'unlock', {'password': 'notapassword123'})
|
||||
js_0 = read_json_api(1800, 'wallets')
|
||||
assert (js_0['PART']['encrypted'] is True)
|
||||
assert (js_0['PART']['locked'] is False)
|
||||
|
||||
super().test_01_full_swap()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -143,6 +143,7 @@ def startXmrWalletRPC(node_dir, bin_dir, wallet_bin, node_id, opts=[]):
|
||||
args += ['--log-file={}'.format(os.path.join(data_dir, 'wallet.log'))]
|
||||
args += ['--rpc-login=test{0}:test_pass{0}'.format(node_id)]
|
||||
args += ['--shared-ringdb-dir={}'.format(os.path.join(data_dir, 'shared-ringdb'))]
|
||||
args += ['--allow-mismatched-daemon-version']
|
||||
|
||||
args += opts
|
||||
logging.info('Starting daemon {} --wallet-dir={}'.format(daemon_bin, node_dir))
|
||||
@ -366,7 +367,7 @@ class BaseTest(unittest.TestCase):
|
||||
if not cls.restore_instance:
|
||||
data_dir = prepareDataDir(TEST_DIR, i, 'particl.conf', 'part_')
|
||||
if os.path.exists(os.path.join(cfg.PARTICL_BINDIR, 'particl-wallet')):
|
||||
callrpc_cli(cfg.PARTICL_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat create', 'particl-wallet')
|
||||
callrpc_cli(cfg.PARTICL_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat -legacy create', 'particl-wallet')
|
||||
|
||||
cls.part_daemons.append(startDaemon(os.path.join(TEST_DIR, 'part_' + str(i)), cfg.PARTICL_BINDIR, cfg.PARTICLD))
|
||||
logging.info('Started %s %d', cfg.PARTICLD, cls.part_daemons[-1].pid)
|
||||
@ -391,7 +392,7 @@ class BaseTest(unittest.TestCase):
|
||||
if not cls.restore_instance:
|
||||
data_dir = prepareDataDir(TEST_DIR, i, 'bitcoin.conf', 'btc_', base_p2p_port=BTC_BASE_PORT, base_rpc_port=BTC_BASE_RPC_PORT)
|
||||
if os.path.exists(os.path.join(cfg.BITCOIN_BINDIR, 'bitcoin-wallet')):
|
||||
callrpc_cli(cfg.BITCOIN_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat create', 'bitcoin-wallet')
|
||||
callrpc_cli(cfg.BITCOIN_BINDIR, data_dir, 'regtest', '-wallet=wallet.dat -legacy create', 'bitcoin-wallet')
|
||||
|
||||
cls.btc_daemons.append(startDaemon(os.path.join(TEST_DIR, 'btc_' + str(i)), cfg.BITCOIN_BINDIR, cfg.BITCOIND))
|
||||
logging.info('Started %s %d', cfg.BITCOIND, cls.part_daemons[-1].pid)
|
||||
@ -500,7 +501,7 @@ class BaseTest(unittest.TestCase):
|
||||
logging.info('Mining %d Bitcoin blocks to %s', num_blocks, cls.btc_addr)
|
||||
callnoderpc(0, 'generatetoaddress', [num_blocks, cls.btc_addr], base_rpc_port=BTC_BASE_RPC_PORT)
|
||||
|
||||
checkForks(callnoderpc(0, 'getblockchaininfo', base_rpc_port=BTC_BASE_RPC_PORT))
|
||||
checkForks(callnoderpc(0, 'getdeploymentinfo', base_rpc_port=BTC_BASE_RPC_PORT))
|
||||
|
||||
if cls.start_ltc_nodes:
|
||||
num_blocks = 400
|
||||
|
Loading…
Reference in New Issue
Block a user