From b64437db8489189706ad8bac5a6855212038260c Mon Sep 17 00:00:00 2001 From: tecnovert Date: Thu, 16 Jun 2022 15:37:32 +0200 Subject: [PATCH] coins: Raise Litecoin version to 0.21.2 --- basicswap/basicswap.py | 7 +++++++ basicswap/chainparams.py | 9 ++++++--- bin/basicswap_prepare.py | 7 ++++--- tests/basicswap/test_other.py | 5 +++++ tests/basicswap/test_xmr.py | 11 ++++++++++- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index e955033..1dead1f 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -496,6 +496,7 @@ class BasicSwap(BaseApp): pidfilename = cc['name'] if cc['name'] == 'bitcoin' or cc['name'] == 'litecoin' or cc['name'] == 'namecoin': pidfilename += 'd' + pidfilepath = os.path.join(self.getChainDatadirPath(coin), pidfilename + '.pid') self.log.debug('Reading %s rpc credentials from auth cookie %s', coin, authcookiepath) # Wait for daemon to start @@ -503,6 +504,12 @@ class BasicSwap(BaseApp): datadir_pid = -1 for i in range(20): try: + # Workaround for mismatched pid file name in litecoin 0.21.2 + # TODO: Remove + if cc['name'] == 'litecoin' and not os.path.exists(pidfilepath) and \ + os.path.exists(os.path.join(self.getChainDatadirPath(coin), 'bitcoind.pid')): + pidfilepath = os.path.join(self.getChainDatadirPath(coin), 'bitcoind.pid') + with open(pidfilepath, 'rb') as fp: datadir_pid = int(fp.read().decode('utf-8')) assert(datadir_pid == cc['pid']), 'Mismatched pid' diff --git a/basicswap/chainparams.py b/basicswap/chainparams.py index d600b26..a26de43 100644 --- a/basicswap/chainparams.py +++ b/basicswap/chainparams.py @@ -116,7 +116,8 @@ chainparams = { 'mainnet': { 'rpcport': 9332, 'pubkey_address': 48, - 'script_address': 50, + 'script_address': 5, + 'script_address2': 50, 'key_prefix': 176, 'hrp': 'ltc', 'bip44': 2, @@ -126,7 +127,8 @@ chainparams = { 'testnet': { 'rpcport': 19332, 'pubkey_address': 111, - 'script_address': 58, + 'script_address': 196, + 'script_address2': 58, 'key_prefix': 239, 'hrp': 'tltc', 'bip44': 1, @@ -137,7 +139,8 @@ chainparams = { 'regtest': { 'rpcport': 19443, 'pubkey_address': 111, - 'script_address': 58, + 'script_address': 196, + 'script_address2': 58, 'key_prefix': 239, 'hrp': 'rltc', 'bip44': 1, diff --git a/bin/basicswap_prepare.py b/bin/basicswap_prepare.py index 4e81cca..8240487 100755 --- a/bin/basicswap_prepare.py +++ b/bin/basicswap_prepare.py @@ -40,7 +40,7 @@ PARTICL_VERSION = os.getenv('PARTICL_VERSION', '0.21.2.9') PARTICL_VERSION_TAG = os.getenv('PARTICL_VERSION_TAG', '') PARTICL_LINUX_EXTRA = os.getenv('PARTICL_LINUX_EXTRA', '_nousb') -LITECOIN_VERSION = os.getenv('LITECOIN_VERSION', '0.18.1') +LITECOIN_VERSION = os.getenv('LITECOIN_VERSION', '0.21.2') LITECOIN_VERSION_TAG = os.getenv('LITECOIN_VERSION_TAG', '') BITCOIN_VERSION = os.getenv('BITCOIN_VERSION', '22.0') @@ -52,7 +52,7 @@ MONERO_VERSION_TAG = os.getenv('MONERO_VERSION_TAG', '') # version, version tag eg. "rc1", signers known_coins = { 'particl': (PARTICL_VERSION, PARTICL_VERSION_TAG, ('tecnovert',)), - 'litecoin': (LITECOIN_VERSION, LITECOIN_VERSION_TAG, ('thrasher',)), + 'litecoin': (LITECOIN_VERSION, LITECOIN_VERSION_TAG, ('davidburkett38',)), 'bitcoin': (BITCOIN_VERSION, BITCOIN_VERSION_TAG, ('laanwj',)), 'namecoin': ('0.18.0', '', ('JeremyRand',)), 'monero': (MONERO_VERSION, MONERO_VERSION_TAG, ('binaryfate',)), @@ -64,6 +64,7 @@ expected_key_ids = { 'laanwj': ('1E4AED62986CD25D',), 'JeremyRand': ('2DBE339E29F6294C',), 'binaryfate': ('F0AF4D462A0BDF92',), + 'davidburkett38': ('3620E9D387E55666',), } if platform.system() == 'Darwin': @@ -327,7 +328,7 @@ def prepareCore(coin, version_data, settings, data_dir, extra_opts={}): assert_url = 'https://raw.githubusercontent.com/particl/gitian.sigs/master/%s-%s/%s/%s' % (version + version_tag, os_dir_name, signing_key_name, assert_filename) elif coin == 'litecoin': release_url = 'https://download.litecoin.org/litecoin-{}/{}/{}'.format(version, os_name, release_filename) - assert_filename = '{}-{}-{}-build.assert'.format(coin, os_name, version.rsplit('.', 1)[0]) + assert_filename = '{}-core-{}-{}-build.assert'.format(coin, os_name, version.rsplit('.', 1)[0]) assert_url = 'https://raw.githubusercontent.com/litecoin-project/gitian.sigs.ltc/master/%s-%s/%s/%s' % (version, os_dir_name, signing_key_name, assert_filename) elif coin == 'bitcoin': release_url = 'https://bitcoincore.org/bin/bitcoin-core-{}/{}'.format(version, release_filename) diff --git a/tests/basicswap/test_other.py b/tests/basicswap/test_other.py index 00c1e88..12336bf 100644 --- a/tests/basicswap/test_other.py +++ b/tests/basicswap/test_other.py @@ -22,6 +22,7 @@ from coincurve.keys import ( PrivateKey) from basicswap.util import i2b, h2b +from basicswap.util.crypto import ripemd160 from basicswap.util.rfc2440 import rfc2440_hash_password from basicswap.interface_btc import BTCInterface from basicswap.interface_xmr import XMRInterface @@ -287,6 +288,10 @@ class Test(unittest.TestCase): assert(password_hash == '16:B7A94A7E4988630E6095334BA67F06FBA509B2A7136A04C9C1B430F539') + def test_ripemd160(self): + input_data = b'hash this' + assert(ripemd160(input_data).hex() == 'd5443a154f167e2c1332f6de72cfb4c6ab9c8c17') + if __name__ == '__main__': unittest.main() diff --git a/tests/basicswap/test_xmr.py b/tests/basicswap/test_xmr.py index 3906efd..be073d7 100644 --- a/tests/basicswap/test_xmr.py +++ b/tests/basicswap/test_xmr.py @@ -456,11 +456,20 @@ class BaseTest(unittest.TestCase): logging.info('Mining %d Litecoin blocks to %s', num_blocks, cls.ltc_addr) callnoderpc(0, 'generatetoaddress', [num_blocks, cls.ltc_addr], base_rpc_port=LTC_BASE_RPC_PORT) - num_blocks = 100 + num_blocks = 31 cls.ltc_addr = cls.swap_clients[0].ci(Coins.LTC).pubkey_to_address(void_block_rewards_pubkey) logging.info('Mining %d Litecoin blocks to %s', num_blocks, cls.ltc_addr) callnoderpc(0, 'generatetoaddress', [num_blocks, cls.ltc_addr], base_rpc_port=LTC_BASE_RPC_PORT) + # https://github.com/litecoin-project/litecoin/issues/807 + # Block 432 is when MWEB activates. It requires a peg-in. You'll need to generate an mweb address and send some coins to it. Then it will allow you to mine the next block. + mweb_addr = callnoderpc(2, 'getnewaddress', ['mweb_addr', 'mweb'], base_rpc_port=LTC_BASE_RPC_PORT) + callnoderpc(0, 'sendtoaddress', [mweb_addr, 1], base_rpc_port=LTC_BASE_RPC_PORT) + + num_blocks = 69 + cls.ltc_addr = cls.swap_clients[0].ci(Coins.LTC).pubkey_to_address(void_block_rewards_pubkey) + callnoderpc(0, 'generatetoaddress', [num_blocks, cls.ltc_addr], base_rpc_port=LTC_BASE_RPC_PORT) + checkForks(callnoderpc(0, 'getblockchaininfo', base_rpc_port=LTC_BASE_RPC_PORT)) num_blocks = 100