coins: Raise Bitcoin version to 22.0

2024-05-20_merge
tecnovert 3 years ago
parent 6b063d0582
commit 12bae95e7d
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
  1. 2
      basicswap/__init__.py
  2. 9
      basicswap/contrib/test_framework/util.py
  3. 9
      basicswap/interface_btc.py
  4. 46
      bin/basicswap_prepare.py
  5. 6
      doc/release-notes.md
  6. 13
      doc/tor.md

@ -1,3 +1,3 @@
name = "basicswap" name = "basicswap"
__version__ = "0.0.31" __version__ = "0.0.32"

@ -614,6 +614,11 @@ def find_vout_for_address(node, txid, addr):
""" """
tx = node.getrawtransaction(txid, True) tx = node.getrawtransaction(txid, True)
for i in range(len(tx["vout"])): for i in range(len(tx["vout"])):
if any([addr == a for a in tx["vout"][i]["scriptPubKey"]["addresses"]]): scriptPubKey = tx["vout"][i]["scriptPubKey"]
return i 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)) raise RuntimeError("Vout not found for address: txid=%s, addr=%s" % (txid, addr))

@ -97,8 +97,13 @@ def find_vout_for_address_from_txobj(tx_obj, addr):
given address. Raises runtime error exception if not found. given address. Raises runtime error exception if not found.
""" """
for i in range(len(tx_obj["vout"])): for i in range(len(tx_obj["vout"])):
if any([addr == a for a in tx_obj["vout"][i]["scriptPubKey"]["addresses"]]): scriptPubKey = tx_obj["vout"][i]["scriptPubKey"]
return i 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)) raise RuntimeError("Vout not found for address: txid={}, addr={}".format(tx_obj['txid'], addr))

@ -37,6 +37,15 @@ from basicswap.contrib.rpcauth import generate_salt, password_to_hmac
from bin.basicswap_run import startDaemon, startXmrWalletDaemon 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': if platform.system() == 'Darwin':
BIN_ARCH = 'osx64' BIN_ARCH = 'osx64'
FILE_EXT = 'tar.gz' FILE_EXT = 'tar.gz'
@ -47,14 +56,6 @@ else:
BIN_ARCH = 'x86_64-linux-gnu' BIN_ARCH = 'x86_64-linux-gnu'
FILE_EXT = 'tar.gz' 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 = logging.getLogger()
logger.level = logging.DEBUG logger.level = logging.DEBUG
if not len(logger.handlers): if not len(logger.handlers):
@ -186,8 +187,8 @@ def testOnionLink():
logger.info('Onion links work.') logger.info('Onion links work.')
def extractCore(coin, version_pair, settings, bin_dir, release_path): def extractCore(coin, version_data, settings, bin_dir, release_path):
version, version_tag = version_pair version, version_tag, signers = version_data
logger.info('extractCore %s v%s%s', coin, version, version_tag) logger.info('extractCore %s v%s%s', coin, version, version_tag)
if coin == 'monero': if coin == 'monero':
@ -220,7 +221,7 @@ def extractCore(coin, version_pair, settings, bin_dir, release_path):
bins = [coin + 'd', coin + '-cli', coin + '-tx'] bins = [coin + 'd', coin + '-cli', coin + '-tx']
versions = version.split('.') versions = version.split('.')
if int(versions[1]) >= 19: if int(versions[0]) >= 22 or int(versions[1]) >= 19:
bins.append(coin + '-wallet') bins.append(coin + '-wallet')
if 'win32' in BIN_ARCH or 'win64' in BIN_ARCH: if 'win32' in BIN_ARCH or 'win64' in BIN_ARCH:
with zipfile.ZipFile(release_path) as fz: 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) logging.warning('Unable to set file permissions: %s, for %s', str(e), out_path)
def prepareCore(coin, version_pair, settings, data_dir): def prepareCore(coin, version_data, settings, data_dir):
version, version_tag = version_pair version, version_tag, signers = version_data
logger.info('prepareCore %s v%s%s', coin, version, version_tag) logger.info('prepareCore %s v%s%s', coin, version, version_tag)
bin_dir = os.path.expanduser(settings['chainclients'][coin]['bindir']) 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): if not os.path.exists(assert_path):
downloadFile(assert_url, assert_path) downloadFile(assert_url, assert_path)
else: else:
major_version = int(version.split('.')[0])
signing_key_name = signers[0]
release_filename = '{}-{}-{}.{}'.format(coin, version + version_tag, BIN_ARCH, FILE_EXT) release_filename = '{}-{}-{}.{}'.format(coin, version + version_tag, BIN_ARCH, FILE_EXT)
if coin == 'particl': if coin == 'particl':
signing_key_name = 'tecnovert'
release_url = 'https://github.com/particl/particl-core/releases/download/v{}/{}'.format(version + version_tag, release_filename) 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_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) 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': elif coin == 'litecoin':
signing_key_name = 'thrasher'
release_url = 'https://download.litecoin.org/litecoin-{}/{}/{}'.format(version, os_name, release_filename) 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 = '{}-{}-{}-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) 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': elif coin == 'bitcoin':
signing_key_name = 'laanwj'
release_url = 'https://bitcoincore.org/bin/bitcoin-core-{}/{}'.format(version, release_filename) 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_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': elif coin == 'namecoin':
signing_key_name = 'JeremyRand'
release_url = 'https://beta.namecoin.org/files/namecoin-core/namecoin-core-{}/{}'.format(version, release_filename) 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_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) 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') raise ValueError('Unknown coin')
assert_sig_filename = assert_filename + '.sig' 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) release_path = os.path.join(bin_dir, release_filename)
if not os.path.exists(release_path): if not os.path.exists(release_path):
downloadFile(release_url, release_path) downloadFile(release_url, release_path)
# Rename assert files with full version # 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) assert_path = os.path.join(bin_dir, assert_filename)
if not os.path.exists(assert_path): if not os.path.exists(assert_path):
downloadFile(assert_url, 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) assert_sig_path = os.path.join(bin_dir, assert_sig_filename)
if not os.path.exists(assert_sig_path): if not os.path.exists(assert_sig_path):
downloadFile(assert_sig_url, 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'): and not (verified.status == 'signature valid' and verified.key_status == 'signing key has expired'):
raise ValueError('Signature verification failed.') 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): def writeTorSettings(fp, coin, coin_settings, tor_control_password):

@ -3,6 +3,12 @@
============== ==============
0.0.32
==============
- Experimental tor integration
0.0.31 0.0.31
============== ==============

@ -2,6 +2,9 @@
Basicswap can be configured to route all traffic through a tor proxy. 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 ### 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. 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 \ 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 \ 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 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 \ docker compose -f docker-compose_with_tor.yml run --rm swapclient \
basicswap-prepare --datadir=/coindata --disabletor 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

Loading…
Cancel
Save