diff --git a/bin/basicswap_prepare.py b/bin/basicswap_prepare.py index cecd735..b138d87 100755 --- a/bin/basicswap_prepare.py +++ b/bin/basicswap_prepare.py @@ -61,8 +61,13 @@ DASH_VERSION_TAG = os.getenv('DASH_VERSION_TAG', '') FIRO_VERSION = os.getenv('FIRO_VERSION', '0.14.99.1') FIRO_VERSION_TAG = os.getenv('FIRO_VERSION_TAG', '') +NAV_VERSION = os.getenv('NAV_VERSION', '7.0.3') +NAV_VERSION_TAG = os.getenv('NAV_VERSION', '') + GUIX_SSL_CERT_DIR = None +ADD_PUBKEY_URL = os.getenv('ADD_PUBKEY_URL', '') + known_coins = { 'particl': (PARTICL_VERSION, PARTICL_VERSION_TAG, ('tecnovert',)), @@ -74,6 +79,7 @@ known_coins = { 'dash': (DASH_VERSION, DASH_VERSION_TAG, ('pasta',)), # 'firo': (FIRO_VERSION, FIRO_VERSION_TAG, ('reuben',)), 'firo': (FIRO_VERSION, FIRO_VERSION_TAG, ('tecnovert',)), + 'navcoin': (NAV_VERSION, NAV_VERSION_TAG, ('nav_builder',)), } expected_key_ids = { @@ -86,6 +92,7 @@ expected_key_ids = { 'fuzzbawls': ('3BDCDA2D87A881D9',), 'pasta': ('52527BEDABE87984',), 'reuben': ('1290A1D0FA7EE109',), + 'nav_builder': ('2782262BF6E7FADB',), } USE_PLATFORM = os.getenv('USE_PLATFORM', platform.system()) @@ -159,6 +166,12 @@ FIRO_ONION_PORT = int(os.getenv('FIRO_ONION_PORT', 8168)) # nDefaultPort FIRO_RPC_USER = os.getenv('FIRO_RPC_USER', '') FIRO_RPC_PWD = os.getenv('FIRO_RPC_PWD', '') +NAV_RPC_HOST = os.getenv('NAV_RPC_HOST', '127.0.0.1') +NAV_RPC_PORT = int(os.getenv('NAV_RPC_PORT', 44444)) +NAV_ONION_PORT = int(os.getenv('NAV_ONION_PORT', 8334)) # TODO? +NAV_RPC_USER = os.getenv('NAV_RPC_USER', '') +NAV_RPC_PWD = os.getenv('NAV_RPC_PWD', '') + TOR_PROXY_HOST = os.getenv('TOR_PROXY_HOST', '127.0.0.1') TOR_PROXY_PORT = int(os.getenv('TOR_PROXY_PORT', 9050)) TOR_CONTROL_PORT = int(os.getenv('TOR_CONTROL_PORT', 9051)) @@ -612,8 +625,14 @@ def prepareCore(coin, version_data, settings, data_dir, extra_opts={}): release_filename = 'firo-0.14.99.1-x86_64-apple-darwin18.tar.gz' else: raise ValueError('Firo: Unknown architecture') - release_url = 'https://github.com/tecnovert/particl-core/releases/download/v{}/{}'.format(version + version_tag, release_filename) + release_url = 'https://github.com/tecnovert/particl-core/releases/download/{}/{}'.format(version + version_tag, release_filename) assert_url = 'https://github.com/tecnovert/particl-core/releases/download/v%s/SHA256SUMS.asc' % (version + version_tag) + elif coin == 'navcoin': + release_filename = '{}-{}-{}.{}'.format(coin, version, BIN_ARCH, FILE_EXT) + release_url = 'https://github.com/navcoin/navcoin-core/releases/download/{}/{}'.format(version + version_tag, release_filename) + assert_filename = 'SHA256SUM_7.0.3.asc' + assert_sig_filename = 'SHA256SUM_7.0.3.asc.sig' + assert_url = 'https://github.com/navcoin/navcoin-core/releases/download/{}/{}'.format(version + version_tag, assert_filename) else: raise ValueError('Unknown coin') @@ -629,7 +648,8 @@ def prepareCore(coin, version_data, settings, data_dir, extra_opts={}): if coin not in ('firo', ): assert_sig_url = assert_url + ('.asc' if major_version >= 22 else '.sig') - assert_sig_filename = '{}-{}-{}-build-{}.assert.sig'.format(coin, os_name, version, signing_key_name) + if coin not in ('nav', ): + assert_sig_filename = '{}-{}-{}-build-{}.assert.sig'.format(coin, os_name, version, signing_key_name) assert_sig_path = os.path.join(bin_dir, assert_sig_filename) if not os.path.exists(assert_sig_path): downloadFile(assert_sig_url, assert_sig_path) @@ -665,6 +685,8 @@ def prepareCore(coin, version_data, settings, data_dir, extra_opts={}): if coin in ('firo', ): pubkey_filename = '{}_{}.pgp'.format('particl', signing_key_name) + elif coin in ('navcoin', ): + pubkey_filename = '{}_builder.pgp'.format(coin) else: pubkey_filename = '{}_{}.pgp'.format(coin, signing_key_name) pubkeyurls = [ @@ -678,6 +700,9 @@ def prepareCore(coin, version_data, settings, data_dir, extra_opts={}): if coin == 'firo': pubkeyurls.append('https://firo.org/reuben.asc') + if ADD_PUBKEY_URL != '': + pubkeyurls.append(ADD_PUBKEY_URL + '/' + pubkey_filename) + if coin in ('monero', 'firo'): with open(assert_path, 'rb') as fp: verified = gpg.verify_file(fp) @@ -687,6 +712,21 @@ def prepareCore(coin, version_data, settings, data_dir, extra_opts={}): importPubkeyFromUrls(gpg, pubkeyurls) with open(assert_path, 'rb') as fp: verified = gpg.verify_file(fp) + elif coin in ('navcoin'): + with open(assert_sig_path, 'rb') as fp: + verified = gpg.verify_file(fp) + + if not isValidSignature(verified) and verified.username is None: + logger.warning('Signature made by unknown key.') + importPubkeyFromUrls(gpg, pubkeyurls) + with open(assert_sig_path, 'rb') as fp: + verified = gpg.verify_file(fp) + + # .sig file is not a detached signature, recheck release hash in decrypted data + logger.warning('Double checking Navcoin release hash.') + with open(assert_sig_path, 'rb') as fp: + decrypted = gpg.decrypt_file(fp) + assert (release_hash.hex() in str(decrypted)) else: with open(assert_sig_path, 'rb') as fp: verified = gpg.verify_file(fp, assert_path) @@ -793,8 +833,12 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}): exitWithError('{} exists'.format(core_conf_path)) with open(core_conf_path, 'w') as fp: if chain != 'mainnet': - fp.write(chain + '=1\n') - if coin != 'firo': + if coin in ('navcoin',): + chainname = 'devnet' if chain == 'regtest' else chain + fp.write(chainname + '=1\n') + else: + fp.write(chain + '=1\n') + if coin not in ('firo', 'navcoin'): if chain == 'testnet': fp.write('[test]\n\n') elif chain == 'regtest': @@ -856,6 +900,11 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}): fp.write('usehd=1\n') if FIRO_RPC_USER != '': fp.write('rpcauth={}:{}${}\n'.format(FIRO_RPC_USER, salt, password_to_hmac(salt, FIRO_RPC_PWD))) + elif coin == 'navcoin': + fp.write('prune=4000\n') + fp.write('fallbackfee=0.0002\n') + if NAV_RPC_USER != '': + fp.write('rpcauth={}:{}${}\n'.format(NAV_RPC_USER, salt, password_to_hmac(salt, NAV_RPC_PWD))) else: logger.warning('Unknown coin %s', coin) @@ -1519,6 +1568,21 @@ def main(): 'conf_target': 2, 'core_version_group': 18, 'chain_lookups': 'local', + }, + 'navcoin': { + 'connection_type': 'rpc' if 'navcoin' in with_coins else 'none', + 'manage_daemon': True if ('navcoin' in with_coins and NAV_RPC_HOST == '127.0.0.1') else False, + 'rpchost': NAV_RPC_HOST, + 'rpcport': NAV_RPC_PORT + port_offset, + 'onionport': NAV_ONION_PORT + port_offset, + 'datadir': os.getenv('NAV_DATA_DIR', os.path.join(data_dir, 'navcoin')), + 'bindir': os.path.join(bin_dir, 'navcoin'), + 'use_segwit': True, + 'use_csv': True, + 'blocks_confirmed': 1, + 'conf_target': 2, + 'core_version_group': 18, + 'chain_lookups': 'local', } } @@ -1543,6 +1607,9 @@ def main(): if FIRO_RPC_USER != '': chainclients['firo']['rpcuser'] = FIRO_RPC_USER chainclients['firo']['rpcpassword'] = FIRO_RPC_PWD + if NAV_RPC_USER != '': + chainclients['nav']['rpcuser'] = NAV_RPC_USER + chainclients['nav']['rpcpassword'] = NAV_RPC_PWD chainclients['monero']['walletsdir'] = os.getenv('XMR_WALLETS_DIR', chainclients['monero']['datadir']) diff --git a/pgp/keys/navcoin_builder.pgp b/pgp/keys/navcoin_builder.pgp new file mode 100644 index 0000000..361d13c --- /dev/null +++ b/pgp/keys/navcoin_builder.pgp @@ -0,0 +1,40 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +xsDNBF/8KgoBDADpq1pIJh2u7J6eX1u8awKFA/k0M826KejUFIMY/B25MlYaBaQm +DMy2aCX9NuLCXtnA+Ys5UGlHb70KrsGLmlvA6Jk+nQZhjCM9RXTJtbMOrq84uTYc +zRgWBfAkMU+HIj2svkdjrmDdCjdbip6myBbketgg9UP09G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9fKJPwYI5oUam5By3sYmTT +i0WBmStFWb3bvqfkdjbe86g7ilbbLIoAlUS03w== +=Y9TC +-----END PGP PUBLIC KEY BLOCK----- diff --git a/tests/basicswap/extended/test_nav.py b/tests/basicswap/extended/test_nav.py index 37114e8..a6e0627 100644 --- a/tests/basicswap/extended/test_nav.py +++ b/tests/basicswap/extended/test_nav.py @@ -69,7 +69,7 @@ from tests.basicswap.test_btc_xmr import TestFunctions logger = logging.getLogger() -NAV_BINDIR = os.path.expanduser(os.getenv('NAV_BINDIR', os.path.join(cfg.DEFAULT_TEST_BINDIR, 'nav'))) +NAV_BINDIR = os.path.expanduser(os.getenv('NAV_BINDIR', os.path.join(cfg.DEFAULT_TEST_BINDIR, 'navcoin'))) NAVD = os.getenv('NAVD', 'navcoind' + cfg.bin_suffix) NAV_CLI = os.getenv('NAV_CLI', 'navcoin-cli' + cfg.bin_suffix) NAV_TX = os.getenv('NAV_TX', 'navcoin-tx' + cfg.bin_suffix) diff --git a/tests/basicswap/test_btc_xmr.py b/tests/basicswap/test_btc_xmr.py index 3cac99f..3e8cc72 100644 --- a/tests/basicswap/test_btc_xmr.py +++ b/tests/basicswap/test_btc_xmr.py @@ -1083,8 +1083,12 @@ class TestBTC_PARTB(TestFunctions): self.do_test_01_full_swap(self.test_coin_from, self.test_coin_to) def test_01_b_full_swap_reverse(self): - self.prepare_balance(self.test_coin_to, 100.0, 1800, 1800) - self.do_test_01_full_swap(self.test_coin_to, self.test_coin_from) + self.extra_wait_time = 60 + try: + self.prepare_balance(self.test_coin_to, 100.0, 1800, 1800) + self.do_test_01_full_swap(self.test_coin_to, self.test_coin_from) + finally: + self.extra_wait_time = 0 def test_02_a_leader_recover_a_lock_tx(self): self.prepare_balance(self.test_coin_to, 100.0, 1801, 1800)