diff --git a/.travis.yml b/.travis.yml index c1c2f5f..6b29c61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ stages: env: global: - TEST_DIR=~/test_basicswap2/ - - PARTICL_BINDIR=/opt/binaries/particl-0.18.0.12/bin/ + - PARTICL_BINDIR=/opt/binaries/particl-0.18.1.1/bin/ - BITCOIN_BINDIR=/opt/binaries/bitcoin-0.18.0/bin/ - LITECOIN_BINDIR=/opt/binaries/litecoin-0.17.1/bin/ before_install: @@ -16,10 +16,10 @@ before_script: - if [ ! -d "/opt/binaries" ]; then mkdir -p "/opt/binaries" ; fi - if [ ! -d "$BITCOIN_BINDIR" ]; then cd "/opt/binaries" && wget https://bitcoincore.org/bin/bitcoin-core-0.18.0/bitcoin-0.18.0-x86_64-linux-gnu.tar.gz && tar xvf bitcoin-0.18.0-x86_64-linux-gnu.tar.gz ; fi - if [ ! -d "$LITECOIN_BINDIR" ]; then cd "/opt/binaries" && wget https://download.litecoin.org/litecoin-0.17.1/linux/litecoin-0.17.1-x86_64-linux-gnu.tar.gz && tar xvf litecoin-0.17.1-x86_64-linux-gnu.tar.gz ; fi - - if [ ! -d "$PARTICL_BINDIR" ]; then cd "/opt/binaries" && wget https://github.com/particl/particl-core/releases/download/v0.18.0.12/particl-0.18.0.12-x86_64-linux-gnu_nousb.tar.gz && tar xvf particl-0.18.0.12-x86_64-linux-gnu_nousb.tar.gz ; fi + - if [ ! -d "$PARTICL_BINDIR" ]; then cd "/opt/binaries" && wget https://github.com/particl/particl-core/releases/download/v0.18.1.1/particl-0.18.1.1-x86_64-linux-gnu_nousb.tar.gz && tar xvf particl-0.18.1.1-x86_64-linux-gnu_nousb.tar.gz ; fi script: - cd $TRAVIS_BUILD_DIR - - export PARTICL_BINDIR=/opt/binaries/particl-0.18.0.12/bin/ + - export PARTICL_BINDIR=/opt/binaries/particl-0.18.1.1/bin/ - export BITCOIN_BINDIR=/opt/binaries/bitcoin-0.18.0/bin/ - export LITECOIN_BINDIR=/opt/binaries/litecoin-0.17.1/bin/ - export DATADIRS=~/test_basicswap2/ diff --git a/basicswap/__init__.py b/basicswap/__init__.py index b9c4099..40ef697 100644 --- a/basicswap/__init__.py +++ b/basicswap/__init__.py @@ -1,3 +1,3 @@ name = "basicswap" -__version__ = "0.0.3" +__version__ = "0.0.4" diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 661c35e..21b1a81 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -61,7 +61,6 @@ import basicswap.segwit_addr as segwit_addr DEBUG = True -SMSG_SECONDS_IN_DAY = 86400 MIN_OFFER_VALID_TIME = 60 * 10 @@ -316,7 +315,11 @@ class BasicSwap(): self.swaps_in_progress = dict() if self.chain == 'regtest': - SMSG_SECONDS_IN_DAY = 600 + self.SMSG_SECONDS_IN_DAY = 600 + self.SMSG_SECONDS_IN_HOUR = 60 * 2 + else: + self.SMSG_SECONDS_IN_DAY = 86400 + self.SMSG_SECONDS_IN_HOUR = 60 * 60 self.prepareLogging() self.log.info('Network: {}'.format(self.chain)) @@ -445,6 +448,7 @@ class BasicSwap(): 'use_csv': chain_client_settings.get('use_csv', True), 'core_version_group': chain_client_settings.get('core_version_group', 0), 'pid': None, + 'core_version': None, 'explorers': [], } @@ -504,6 +508,7 @@ class BasicSwap(): self.waitForDaemonRPC(c) core_version = self.callcoinrpc(c, 'getnetworkinfo')['version'] self.log.info('%s Core version %d', chainparams[c]['name'].capitalize(), core_version) + self.coin_clients[c]['core_version'] = core_version # Sanity checks if c == Coins.PART: @@ -724,7 +729,9 @@ class BasicSwap(): else: offer_addr = addr_send_from self.callrpc('smsgaddlocaladdress', [offer_addr]) # Enable receiving smsg - ro = self.callrpc('smsgsend', [offer_addr, self.network_addr, payload_hex, False, 1, False, False, True]) + options = {'decodehex': True, 'ttl_is_seconds': True} + msg_valid = self.SMSG_SECONDS_IN_HOUR * 1 + ro = self.callrpc('smsgsend', [offer_addr, self.network_addr, payload_hex, False, msg_valid, False, options]) msg_id = ro['msgid'] offer_id = bytes.fromhex(msg_id) @@ -1035,7 +1042,9 @@ class BasicSwap(): else: bid_addr = addr_send_from self.callrpc('smsgaddlocaladdress', [bid_addr]) # Enable receiving smsg - ro = self.callrpc('smsgsend', [bid_addr, offer.addr_from, payload_hex, False, 1, False, False, True]) + options = {'decodehex': True, 'ttl_is_seconds': True} + msg_valid = self.SMSG_SECONDS_IN_HOUR * 1 + ro = self.callrpc('smsgsend', [bid_addr, offer.addr_from, payload_hex, False, msg_valid, False, options]) msg_id = ro['msgid'] bid_id = bytes.fromhex(msg_id) @@ -1177,7 +1186,10 @@ class BasicSwap(): bid_bytes = msg_buf.SerializeToString() payload_hex = str.format('{:02x}', MessageTypes.BID_ACCEPT) + bid_bytes.hex() - ro = self.callrpc('smsgsend', [offer.addr_from, bid.bid_addr, payload_hex, False, 1, False, False, True]) + options = {'decodehex': True, 'ttl_is_seconds': True} + # TODO: set msg_valid based on bid / offer parameters + msg_valid = self.SMSG_SECONDS_IN_HOUR * 48 + ro = self.callrpc('smsgsend', [offer.addr_from, bid.bid_addr, payload_hex, False, msg_valid, False, options]) msg_id = ro['msgid'] accept_msg_id = bytes.fromhex(msg_id) @@ -2004,7 +2016,7 @@ class BasicSwap(): options = {'encoding': 'none'} ro = self.callrpc('smsginbox', ['all', '', options]) for msg in ro['messages']: - expire_at = msg['sent'] + msg['daysretention'] * SMSG_SECONDS_IN_DAY + expire_at = msg['sent'] + msg['daysretention'] * self.SMSG_SECONDS_IN_DAY if expire_at < now: options = {'encoding': 'none', 'delete': True} del_msg = self.callrpc('smsg', [msg['msgid'], options]) @@ -2351,6 +2363,7 @@ class BasicSwap(): blockchaininfo = self.callcoinrpc(coin, 'getblockchaininfo') walletinfo = self.callcoinrpc(coin, 'getwalletinfo') rv = { + 'version': self.coin_clients[coin]['core_version'], 'deposit_address': self.getCachedAddressForCoin(coin), 'name': chainparams[coin]['name'].capitalize(), 'blocks': blockchaininfo['blocks'], diff --git a/basicswap/http_server.py b/basicswap/http_server.py index aa3a853..4f9ab8d 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -232,6 +232,7 @@ class HttpHandler(BaseHTTPRequestHandler): est_fee = (fee_rate * tx_vsize) / 1000 wallets_formatted.append({ 'name': w['name'], + 'version': w['version'], 'cid': str(int(k)), 'fee_rate': format8(fee_rate * COIN), 'est_fee': format8(est_fee * COIN), diff --git a/basicswap/templates/wallets.html b/basicswap/templates/wallets.html index 9840fa7..ee12cd3 100644 --- a/basicswap/templates/wallets.html +++ b/basicswap/templates/wallets.html @@ -13,7 +13,7 @@ {% for w in wallets %} -

{{ w.name }}

+

{{ w.name }} {{ w.version }}

{% if w.error %}

Error: {{ w.error }}

{% else %} diff --git a/bin/basicswap_prepare.py b/bin/basicswap_prepare.py index 35d445e..3c4de09 100644 --- a/bin/basicswap_prepare.py +++ b/bin/basicswap_prepare.py @@ -40,7 +40,7 @@ else: BIN_ARCH = 'x86_64-linux-gnu.tar.gz' known_coins = { - 'particl': '0.18.1.0', + 'particl': '0.18.1.1', 'litecoin': '0.17.1', 'bitcoin': '0.18.0', 'namecoin': '0.18.0', @@ -470,7 +470,7 @@ def main(): return 0 logger.info('With coins: %s', ', '.join(with_coins)) - if os.path.exists(config_path): + if os.path.exists(config_path) and not prepare_bin_only: exitWithError('{} exists'.format(config_path)) for c in with_coins: diff --git a/doc/upgrade.md b/doc/upgrade.md new file mode 100644 index 0000000..5bf90df --- /dev/null +++ b/doc/upgrade.md @@ -0,0 +1,13 @@ + +## Update basicswap version + +If installed through pip: + + cd basicswap + git pull + pip3 install . + + +## Update core versions + + basicswap-prepare -preparebinonly \ No newline at end of file diff --git a/tests/basicswap/test_reload.py b/tests/basicswap/test_reload.py index a07d142..bb581bc 100644 --- a/tests/basicswap/test_reload.py +++ b/tests/basicswap/test_reload.py @@ -8,7 +8,7 @@ """ mkdir -p /tmp/test_basicswap/bin/{particl,bitcoin} -cp ~/tmp/particl-0.18.1.0-x86_64-linux-gnu.tar.gz /tmp/test_basicswap/bin/particl +cp ~/tmp/particl-0.18.1.1-x86_64-linux-gnu.tar.gz /tmp/test_basicswap/bin/particl cp ~/tmp/bitcoin-0.18.0-x86_64-linux-gnu.tar.gz /tmp/test_basicswap/bin/bitcoin