diff --git a/basicswap/__init__.py b/basicswap/__init__.py index 1bf9331..d91aff3 100644 --- a/basicswap/__init__.py +++ b/basicswap/__init__.py @@ -1,3 +1,3 @@ name = "basicswap" -__version__ = "0.0.31" +__version__ = "0.0.32" diff --git a/basicswap/contrib/test_framework/util.py b/basicswap/contrib/test_framework/util.py index c9f55e8..3c1d035 100644 --- a/basicswap/contrib/test_framework/util.py +++ b/basicswap/contrib/test_framework/util.py @@ -614,6 +614,11 @@ def find_vout_for_address(node, txid, addr): """ tx = node.getrawtransaction(txid, True) for i in range(len(tx["vout"])): - if any([addr == a for a in tx["vout"][i]["scriptPubKey"]["addresses"]]): - return i + scriptPubKey = tx["vout"][i]["scriptPubKey"] + if "addresses" in scriptPubKey: + if any([addr == a for a in scriptPubKey["addresses"]]): + return i + elif "address" in scriptPubKey: + if addr == scriptPubKey["address"]: + return i raise RuntimeError("Vout not found for address: txid=%s, addr=%s" % (txid, addr)) diff --git a/basicswap/interface_btc.py b/basicswap/interface_btc.py index db9fba6..1c25e0f 100644 --- a/basicswap/interface_btc.py +++ b/basicswap/interface_btc.py @@ -97,8 +97,13 @@ def find_vout_for_address_from_txobj(tx_obj, addr): given address. Raises runtime error exception if not found. """ for i in range(len(tx_obj["vout"])): - if any([addr == a for a in tx_obj["vout"][i]["scriptPubKey"]["addresses"]]): - return i + scriptPubKey = tx_obj["vout"][i]["scriptPubKey"] + if "addresses" in scriptPubKey: + if any([addr == a for a in scriptPubKey["addresses"]]): + return i + elif "address" in scriptPubKey: + if addr == scriptPubKey["address"]: + return i raise RuntimeError("Vout not found for address: txid={}, addr={}".format(tx_obj['txid'], addr)) diff --git a/bin/basicswap_prepare.py b/bin/basicswap_prepare.py index c19e06a..9863f9b 100755 --- a/bin/basicswap_prepare.py +++ b/bin/basicswap_prepare.py @@ -37,6 +37,15 @@ from basicswap.contrib.rpcauth import generate_salt, password_to_hmac from bin.basicswap_run import startDaemon, startXmrWalletDaemon +# version, version tag eg. "rc1", signers +known_coins = { + 'particl': ('0.21.2.7', '', ('tecnovert',)), + 'litecoin': ('0.18.1', '', ('thrasher',)), + 'bitcoin': ('22.0', '', ('laanwj',)), + 'namecoin': ('0.18.0', '', ('JeremyRand',)), + 'monero': ('0.17.3.0', '', ('',)), +} + if platform.system() == 'Darwin': BIN_ARCH = 'osx64' FILE_EXT = 'tar.gz' @@ -47,14 +56,6 @@ else: BIN_ARCH = 'x86_64-linux-gnu' FILE_EXT = 'tar.gz' -known_coins = { - 'particl': ('0.21.2.7', ''), - 'litecoin': ('0.18.1', ''), - 'bitcoin': ('0.21.1', ''), - 'namecoin': ('0.18.0', ''), - 'monero': ('0.17.3.0', ''), -} - logger = logging.getLogger() logger.level = logging.DEBUG if not len(logger.handlers): @@ -186,8 +187,8 @@ def testOnionLink(): logger.info('Onion links work.') -def extractCore(coin, version_pair, settings, bin_dir, release_path): - version, version_tag = version_pair +def extractCore(coin, version_data, settings, bin_dir, release_path): + version, version_tag, signers = version_data logger.info('extractCore %s v%s%s', coin, version, version_tag) if coin == 'monero': @@ -220,7 +221,7 @@ def extractCore(coin, version_pair, settings, bin_dir, release_path): bins = [coin + 'd', coin + '-cli', coin + '-tx'] versions = version.split('.') - if int(versions[1]) >= 19: + if int(versions[0]) >= 22 or int(versions[1]) >= 19: bins.append(coin + '-wallet') if 'win32' in BIN_ARCH or 'win64' in BIN_ARCH: with zipfile.ZipFile(release_path) as fz: @@ -247,8 +248,8 @@ def extractCore(coin, version_pair, settings, bin_dir, release_path): logging.warning('Unable to set file permissions: %s, for %s', str(e), out_path) -def prepareCore(coin, version_pair, settings, data_dir): - version, version_tag = version_pair +def prepareCore(coin, version_data, settings, data_dir): + version, version_tag, signers = version_data logger.info('prepareCore %s v%s%s', coin, version, version_tag) bin_dir = os.path.expanduser(settings['chainclients'][coin]['bindir']) @@ -282,24 +283,25 @@ def prepareCore(coin, version_pair, settings, data_dir): if not os.path.exists(assert_path): downloadFile(assert_url, assert_path) else: + major_version = int(version.split('.')[0]) + signing_key_name = signers[0] release_filename = '{}-{}-{}.{}'.format(coin, version + version_tag, BIN_ARCH, FILE_EXT) if coin == 'particl': - signing_key_name = 'tecnovert' release_url = 'https://github.com/particl/particl-core/releases/download/v{}/{}'.format(version + version_tag, release_filename) assert_filename = '{}-{}-{}-build.assert'.format(coin, os_name, version) 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': - signing_key_name = 'thrasher' 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_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': - signing_key_name = 'laanwj' release_url = 'https://bitcoincore.org/bin/bitcoin-core-{}/{}'.format(version, release_filename) assert_filename = '{}-core-{}-{}-build.assert'.format(coin, os_name, '.'.join(version.split('.')[:2])) - assert_url = 'https://raw.githubusercontent.com/bitcoin-core/gitian.sigs/master/%s-%s/%s/%s' % (version, os_dir_name, signing_key_name, assert_filename) + if major_version >= 22: + assert_url = f'https://raw.githubusercontent.com/bitcoin-core/guix.sigs/main/{version}/{signing_key_name}/all.SHA256SUMS' + else: + assert_url = 'https://raw.githubusercontent.com/bitcoin-core/gitian.sigs/master/%s-%s/%s/%s' % (version, os_dir_name, signing_key_name, assert_filename) elif coin == 'namecoin': - signing_key_name = 'JeremyRand' release_url = 'https://beta.namecoin.org/files/namecoin-core/namecoin-core-{}/{}'.format(version, release_filename) assert_filename = '{}-{}-{}-build.assert'.format(coin, os_name, version.rsplit('.', 1)[0]) assert_url = 'https://raw.githubusercontent.com/namecoin/gitian.sigs/master/%s-%s/%s/%s' % (version, os_dir_name, signing_key_name, assert_filename) @@ -307,19 +309,19 @@ def prepareCore(coin, version_pair, settings, data_dir): raise ValueError('Unknown coin') assert_sig_filename = assert_filename + '.sig' - assert_sig_url = assert_url + '.sig' + assert_sig_url = assert_url + ('.asc' if major_version >= 22 else '.sig') release_path = os.path.join(bin_dir, release_filename) if not os.path.exists(release_path): downloadFile(release_url, release_path) # Rename assert files with full version - assert_filename = '{}-{}-{}-build.assert'.format(coin, os_name, version) + assert_filename = '{}-{}-{}-build-{}.assert'.format(coin, os_name, version, signing_key_name) assert_path = os.path.join(bin_dir, assert_filename) if not os.path.exists(assert_path): downloadFile(assert_url, assert_path) - assert_sig_filename = '{}-{}-{}-build.assert.sig'.format(coin, os_name, version) + 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) @@ -380,7 +382,7 @@ def prepareCore(coin, version_pair, settings, data_dir): and not (verified.status == 'signature valid' and verified.key_status == 'signing key has expired'): raise ValueError('Signature verification failed.') - extractCore(coin, version_pair, settings, bin_dir, release_path) + extractCore(coin, version_data, settings, bin_dir, release_path) def writeTorSettings(fp, coin, coin_settings, tor_control_password): diff --git a/doc/release-notes.md b/doc/release-notes.md index 9aa581a..b48903f 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -3,6 +3,12 @@ ============== +0.0.32 +============== + +- Experimental tor integration + + 0.0.31 ============== diff --git a/doc/tor.md b/doc/tor.md index 20780fd..d9a50d8 100644 --- a/doc/tor.md +++ b/doc/tor.md @@ -2,6 +2,9 @@ Basicswap can be configured to route all traffic through a tor proxy. +Note that TOR integration is experimental and should not yet be relied upon. + + ### basicswap-prepare @@ -22,7 +25,7 @@ Note that some download links, notably for Litecoin, are unreachable when using If running through docker start the tor container with the following command as the torrc configuration file won't exist yet. docker compose -f docker-compose_with_tor.yml run --name tor --rm tor \ - tor --allow-missing-torrc --SocksPort 0.0.0.0:9050 + tor --allow-missing-torrc --SocksPort 0.0.0.0:9050 docker compose -f docker-compose_with_tor.yml run -e TOR_PROXY_HOST=172.16.238.200 --rm swapclient \ basicswap-prepare --usetorproxy --datadir=/coindata --withcoins=monero,particl @@ -41,3 +44,11 @@ Start Basicswap with: docker compose -f docker-compose_with_tor.yml run --rm swapclient \ basicswap-prepare --datadir=/coindata --disabletor + + +#### Update coin release + + docker compose -f docker-compose_with_tor.yml up -d tor + docker compose -f docker-compose_with_tor.yml run -e TOR_PROXY_HOST=172.16.238.200 --rm swapclient \ + basicswap-prepare --usetorproxy --datadir=/coindata --preparebinonly --withcoins=bitcoin + docker compose -f docker-compose_with_tor.yml stop