Prepare script extracts monero binaries.

2024-05-20_merge
tecnovert 4 years ago
parent 7f4be161d7
commit 0823e79e4d
  1. 6
      basicswap/basicswap.py
  2. 1
      basicswap/network.py
  3. 58
      bin/basicswap_prepare.py
  4. 1
      tests/basicswap/test_xmr.py

@ -1683,7 +1683,6 @@ class BasicSwap(BaseApp):
session.close() session.close()
session.remove() session.remove()
#self.swaps_in_progress[bid_id] = (bid, offer)
# Add to swaps_in_progress only when waiting on txns # Add to swaps_in_progress only when waiting on txns
self.log.info('Sent XMR_BID_ACCEPT_LF %s', bid_id.hex()) self.log.info('Sent XMR_BID_ACCEPT_LF %s', bid_id.hex())
return bid_id return bid_id
@ -2319,7 +2318,6 @@ class BasicSwap(BaseApp):
return rv return rv
state = BidStates(bid.state) state = BidStates(bid.state)
#rv = True # Remove from swaps_in_progress
if state == BidStates.SWAP_COMPLETED: if state == BidStates.SWAP_COMPLETED:
rv = True # Remove from swaps_in_progress rv = True # Remove from swaps_in_progress
elif state == BidStates.XMR_SWAP_FAILED_REFUNDED: elif state == BidStates.XMR_SWAP_FAILED_REFUNDED:
@ -2370,7 +2368,6 @@ class BasicSwap(BaseApp):
txid=b_lock_tx_id, txid=b_lock_tx_id,
) )
#bid.txns[TxTypes.XMR_SWAP_B_LOCK].setState(TxStates.TX_CONFIRMED)
bid.xmr_b_lock_tx.setState(TxStates.TX_CONFIRMED) bid.xmr_b_lock_tx.setState(TxStates.TX_CONFIRMED)
bid.setState(BidStates.XMR_SWAP_NOSCRIPT_COIN_LOCKED) bid.setState(BidStates.XMR_SWAP_NOSCRIPT_COIN_LOCKED)
@ -2382,9 +2379,6 @@ class BasicSwap(BaseApp):
self.createEventInSession(delay, EventTypes.SEND_XMR_SECRET, bid_id, session) self.createEventInSession(delay, EventTypes.SEND_XMR_SECRET, bid_id, session)
session.commit() session.commit()
# Waiting for initiate txn to be confirmed in 'from' chain
#initiate_txnid_hex = bid.initiate_tx.txid.hex()
#p2sh = self.getScriptAddress(coin_from, bid.initiate_tx.script)
elif state == BidStates.XMR_SWAP_SECRET_SHARED: elif state == BidStates.XMR_SWAP_SECRET_SHARED:
# Wait for script spend tx to confirm # Wait for script spend tx to confirm
# TODO: Use explorer to get tx / block hash for getrawtransaction # TODO: Use explorer to get tx / block hash for getrawtransaction

@ -9,5 +9,6 @@
TODO: TODO:
''' '''
class Peer: class Peer:
pass pass

@ -46,7 +46,7 @@ known_coins = {
'litecoin': '0.18.1', 'litecoin': '0.18.1',
'bitcoin': '0.20.1', 'bitcoin': '0.20.1',
'namecoin': '0.18.0', 'namecoin': '0.18.0',
'monero': '0.17.0.1', 'monero': '0.17.1.5',
} }
logger = logging.getLogger() logger = logging.getLogger()
@ -86,6 +86,22 @@ def extractCore(coin, version, settings, bin_dir, release_path):
bins = [coin + 'd', coin + '-cli', coin + '-tx'] bins = [coin + 'd', coin + '-cli', coin + '-tx']
if coin == 'monero':
with tarfile.open(release_path) as ft:
for member in ft.getmembers():
if member.isdir():
continue
out_path = os.path.join(bin_dir, os.path.basename(member.name))
fi = ft.extractfile(member)
with open(out_path, 'wb') as fout:
fout.write(fi.read())
fi.close()
os.chmod(out_path, stat.S_IRWXU | stat.S_IXGRP | stat.S_IXOTH)
print('member', member)
return
bins = [coin + 'd', coin + '-cli', coin + '-tx']
versions = version.split('.') versions = version.split('.')
if coin == 'particl' and int(versions[1]) >= 19: if coin == 'particl' and int(versions[1]) >= 19:
bins.append(coin + '-wallet') bins.append(coin + '-wallet')
@ -125,17 +141,21 @@ def prepareCore(coin, version, settings, data_dir):
os_dir_name = 'linux' os_dir_name = 'linux'
os_name = 'linux' os_name = 'linux'
release_filename = '{}-{}-{}'.format(coin, version, BIN_ARCH)
if coin == 'monero': if coin == 'monero':
url = 'https://downloads.getmonero.org/cli/monero-linux-x64-v${}.tar.bz2'.format(version) release_url = 'https://downloads.getmonero.org/cli/monero-linux-x64-v{}.tar.bz2'.format(version)
# TODO
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)
raise ValueError('TODO') # TODO: How to get version specific hashes
assert_filename = 'monero-{}-hashes.txt'.format(version)
assert_url = 'https://www.getmonero.org/downloads/hashes.txt'
assert_path = os.path.join(bin_dir, assert_filename)
if not os.path.exists(assert_path):
downloadFile(assert_url, assert_path)
else:
release_filename = '{}-{}-{}'.format(coin, version, BIN_ARCH) release_filename = '{}-{}-{}'.format(coin, version, BIN_ARCH)
if coin == 'particl': if coin == 'particl':
signing_key_name = 'tecnovert' signing_key_name = 'tecnovert'
@ -197,6 +217,21 @@ def prepareCore(coin, version, settings, data_dir):
""" """
gpg = gnupg.GPG() gpg = gnupg.GPG()
if coin == 'monero':
with open(assert_path, 'rb') as fp:
verified = gpg.verify_file(fp)
if verified.username is None:
logger.warning('Signature not verified.')
pubkeyurl = 'https://raw.githubusercontent.com/monero-project/monero/master/utils/gpg_keys/binaryfate.asc'
logger.info('Importing public key from url: ' + pubkeyurl)
rv = gpg.import_keys(urllib.request.urlopen(pubkeyurl).read())
assert('F0AF4D462A0BDF92' in rv)
print('import_keys', rv)
with open(assert_path, 'rb') as fp:
verified = gpg.verify_file(fp)
else:
with open(assert_sig_path, 'rb') as fp: with open(assert_sig_path, 'rb') as fp:
verified = gpg.verify_file(fp, assert_path) verified = gpg.verify_file(fp, assert_path)
@ -449,6 +484,17 @@ def main():
'conf_target': 2, 'conf_target': 2,
'core_version_group': 18, 'core_version_group': 18,
'chain_lookups': 'local', 'chain_lookups': 'local',
},
'monero': {
'connection_type': 'rpc' if 'monero' in with_coins else 'none',
'manage_daemon': True if 'monero' in with_coins else False,
'rpcport': 29798 + port_offset,
'walletrpcport': 29799 + port_offset,
#'walletrpcuser': 'test' + str(node_id),
#'walletrpcpassword': 'test_pass' + str(node_id),
'walletfile': 'basicswap',
'datadir': os.path.join(data_dir, 'monero'),
'bindir': os.path.join(bin_dir, 'monero'),
} }
} }

@ -701,6 +701,5 @@ class Test(unittest.TestCase):
self.wait_for_bid(swap_clients[1], bid2_id, BidStates.SWAP_COMPLETED, sent=True) self.wait_for_bid(swap_clients[1], bid2_id, BidStates.SWAP_COMPLETED, sent=True)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

Loading…
Cancel
Save