diff --git a/basicswap/__init__.py b/basicswap/__init__.py index 40f1c8e..4fb23cb 100644 --- a/basicswap/__init__.py +++ b/basicswap/__init__.py @@ -1,3 +1,3 @@ name = "basicswap" -__version__ = "0.0.25" +__version__ = "0.0.26" diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index cd92685..11fa63d 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -584,6 +584,12 @@ class BasicSwap(BaseApp): session.execute('ALTER TABLE offers ADD COLUMN addr_to VARCHAR') session.execute(f'UPDATE offers SET addr_to = "{self.network_addr}"') db_version += 1 + elif current_version == 11: + session.execute('ALTER TABLE bids ADD COLUMN chain_a_height_start INTEGER') + session.execute('ALTER TABLE bids ADD COLUMN chain_b_height_start INTEGER') + session.execute('ALTER TABLE bids ADD COLUMN protocol_version INTEGER') + session.execute('ALTER TABLE offers ADD COLUMN protocol_version INTEGER') + db_version += 1 if current_version != db_version: self.db_version = db_version @@ -919,6 +925,7 @@ class BasicSwap(BaseApp): msg_buf = OfferMessage() + msg_buf.protocol_version = 1 msg_buf.coin_from = int(coin_from) msg_buf.coin_to = int(coin_to) msg_buf.amount_from = int(amount) @@ -989,6 +996,7 @@ class BasicSwap(BaseApp): offer = Offer( offer_id=offer_id, active_ind=1, + protocol_version=msg_buf.protocol_version, coin_from=msg_buf.coin_from, coin_to=msg_buf.coin_to, @@ -1516,12 +1524,15 @@ class BasicSwap(BaseApp): self.mxDB.acquire() try: msg_buf = BidMessage() + msg_buf.protocol_version = 1 msg_buf.offer_msg_id = offer_id msg_buf.time_valid = valid_for_seconds msg_buf.amount = int(amount) # amount of coin_from coin_from = Coins(offer.coin_from) coin_to = Coins(offer.coin_to) + ci_from = self.ci(coin_from) + ci_to = self.ci(coin_to) self.checkSynced(coin_from, coin_to) @@ -1554,6 +1565,7 @@ class BasicSwap(BaseApp): bid_id = bytes.fromhex(msg_id) bid = Bid( + protocol_version=msg_buf.protocol_version, active_ind=1, bid_id=bid_id, offer_id=offer_id, @@ -1567,6 +1579,8 @@ class BasicSwap(BaseApp): expire_at=now + msg_buf.time_valid, bid_addr=bid_addr, was_sent=True, + chain_a_height_start=ci_from.getChainHeight(), + chain_b_height_start=ci_to.getChainHeight(), ) bid.setState(BidStates.BID_SENT) @@ -1842,6 +1856,7 @@ class BasicSwap(BaseApp): self.checkSynced(coin_from, coin_to) msg_buf = XmrBidMessage() + msg_buf.protocol_version = 1 msg_buf.offer_msg_id = offer_id msg_buf.time_valid = valid_for_seconds msg_buf.amount = int(amount) # Amount of coin_from @@ -1861,13 +1876,6 @@ class BasicSwap(BaseApp): xmr_swap = XmrSwap() xmr_swap.contract_count = self.getNewContractId() xmr_swap.dest_af = msg_buf.dest_af - xmr_swap.start_chain_a_height = ci_from.getChainHeight() - xmr_swap.b_restore_height = ci_to.getChainHeight() - - wallet_restore_height = self.getWalletRestoreHeight(ci_to) - if xmr_swap.b_restore_height < wallet_restore_height: - xmr_swap.b_restore_height = wallet_restore_height - self.log.warning('XMR swap restore height clamped to {}'.format(wallet_restore_height)) for_ed25519 = True if coin_to == Coins.XMR else False kbvf = self.getPathKey(coin_from, coin_to, bid_created_at, xmr_swap.contract_count, 1, for_ed25519) @@ -1932,6 +1940,7 @@ class BasicSwap(BaseApp): xmr_swap.bid_msg_id3 = bytes.fromhex(ro['msgid']) bid = Bid( + protocol_version=msg_buf.protocol_version, active_ind=1, bid_id=xmr_swap.bid_id, offer_id=offer_id, @@ -1943,6 +1952,15 @@ class BasicSwap(BaseApp): bid_addr=bid_addr, was_sent=True, ) + + bid.chain_a_height_start = ci_from.getChainHeight() + bid.chain_b_height_start = ci_to.getChainHeight() + + wallet_restore_height = self.getWalletRestoreHeight(ci_to) + if bid.chain_b_height_start < wallet_restore_height: + bid.chain_b_height_start = wallet_restore_height + self.log.warning('XMR swap restore height clamped to {}'.format(wallet_restore_height)) + bid.setState(BidStates.BID_SENT) try: @@ -2786,7 +2804,8 @@ class BasicSwap(BaseApp): a_lock_tx_dest = ci_from.getScriptDest(xmr_swap.a_lock_tx_script) # Changed from ci_from.getOutput(bid.xmr_a_lock_tx.txid, a_lock_tx_dest, bid.amount, xmr_swap) - lock_tx_chain_info = ci_from.getLockTxHeight(bid.xmr_a_lock_tx.txid, a_lock_tx_dest, bid.amount, xmr_swap) + p2wsh_addr = ci_from.encode_p2wsh(a_lock_tx_dest) + lock_tx_chain_info = ci_from.getLockTxHeight(bid.xmr_a_lock_tx.txid, p2wsh_addr, bid.amount, bid.chain_a_height_start) if lock_tx_chain_info is None: return rv @@ -2827,7 +2846,7 @@ class BasicSwap(BaseApp): bid_changed = False # Have to use findTxB instead of relying on the first seen height to detect chain reorgs - found_tx = ci_to.findTxB(xmr_swap.vkbv, xmr_swap.pkbs, bid.amount_to, ci_to.blocks_confirmed, xmr_swap.b_restore_height, bid.was_sent) + found_tx = ci_to.findTxB(xmr_swap.vkbv, xmr_swap.pkbs, bid.amount_to, ci_to.blocks_confirmed, bid.chain_b_height_start, bid.was_sent) if isinstance(found_tx, int) and found_tx == -1: if self.countBidEvents(bid, EventLogTypes.LOCK_TX_B_INVALID, session) < 1: @@ -2945,9 +2964,11 @@ class BasicSwap(BaseApp): addr = self.encodeSegwitP2WSH(coin_from, getP2WSH(bid.initiate_tx.script)) else: addr = p2sh - found = self.lookupUnspentByAddress(coin_from, addr, assert_amount=bid.amount, assert_txid=initiate_txnid_hex) + + ci_from = self.ci(coin_from) + found = ci_from.getLockTxHeight(bytes.fromhex(initiate_txnid_hex), addr, bid.amount, bid.chain_a_height_start, find_index=True) if found: - bid.initiate_tx.conf = found['n_conf'] + bid.initiate_tx.conf = found['depth'] index = found['index'] tx_height = found['height'] @@ -2984,11 +3005,12 @@ class BasicSwap(BaseApp): else: addr = self.getScriptAddress(coin_to, bid.participate_tx.script) - found = self.lookupUnspentByAddress(coin_to, addr, assert_amount=bid.amount_to) + ci_to = self.ci(coin_to) + found = ci_to.getLockTxHeight(None, addr, bid.amount_to, bid.chain_b_height_start, find_index=True) if found: - if bid.participate_tx.conf != found['n_conf']: + if bid.participate_tx.conf != found['depth']: save_bid = True - bid.participate_tx.conf = found['n_conf'] + bid.participate_tx.conf = found['depth'] index = found['index'] if bid.participate_tx is None or bid.participate_tx.txid is None: self.log.debug('Found bid %s participate txn %s in chain %s', bid_id.hex(), found['txid'], coin_to) @@ -3506,6 +3528,7 @@ class BasicSwap(BaseApp): offer_id=offer_id, active_ind=1, + protocol_version=offer_data.protocol_version, coin_from=offer_data.coin_from, coin_to=offer_data.coin_to, amount_from=offer_data.amount_from, @@ -3613,8 +3636,10 @@ class BasicSwap(BaseApp): # assert(bid_data.rate != offer['data'].rate), 'Bid rate mismatch' coin_to = Coins(offer.coin_to) + ci_from = self.ci(offer.coin_from) + ci_to = self.ci(coin_to) - amount_to = int((bid_data.amount * offer.rate) // self.ci(offer.coin_from).COIN()) + amount_to = int((bid_data.amount * offer.rate) // ci_from.COIN()) swap_type = offer.swap_type if swap_type == SwapTypes.SELLER_FIRST: ensure(len(bid_data.pkhash_buyer) == 20, 'Bad pkhash_buyer length') @@ -3647,6 +3672,7 @@ class BasicSwap(BaseApp): active_ind=1, bid_id=bid_id, offer_id=offer_id, + protocol_version=bid_data.protocol_version, amount=bid_data.amount, pkhash_buyer=bid_data.pkhash_buyer, @@ -3655,6 +3681,8 @@ class BasicSwap(BaseApp): expire_at=msg['sent'] + bid_data.time_valid, bid_addr=msg['from'], was_received=True, + chain_a_height_start=ci_from.getChainHeight(), + chain_b_height_start=ci_to.getChainHeight(), ) else: ensure(bid.state == BidStates.BID_SENT, 'Wrong bid state: {}'.format(str(BidStates(bid.state)))) @@ -3903,12 +3931,15 @@ class BasicSwap(BaseApp): active_ind=1, bid_id=bid_id, offer_id=offer_id, + protocol_version=bid_data.protocol_version, amount=bid_data.amount, created_at=msg['sent'], amount_to=(bid_data.amount * offer.rate) // ci_from.COIN(), expire_at=msg['sent'] + bid_data.time_valid, bid_addr=msg['from'], was_received=True, + chain_a_height_start=ci_from.getChainHeight(), + chain_b_height_start=ci_to.getChainHeight(), ) xmr_swap = XmrSwap( @@ -3918,12 +3949,10 @@ class BasicSwap(BaseApp): vkbvf=bid_data.kbvf, pkbvf=ci_to.getPubkey(bid_data.kbvf), kbsf_dleag=bid_data.kbsf_dleag, - b_restore_height=ci_to.getChainHeight(), - start_chain_a_height=ci_from.getChainHeight(), ) wallet_restore_height = self.getWalletRestoreHeight(ci_to) - if xmr_swap.b_restore_height < wallet_restore_height: - xmr_swap.b_restore_height = wallet_restore_height + if bid.chain_b_height_start < wallet_restore_height: + bid.chain_b_height_start = wallet_restore_height self.log.warning('XMR swap restore height clamped to {}'.format(wallet_restore_height)) else: ensure(bid.state == BidStates.BID_SENT, 'Wrong bid state: {}'.format(str(BidStates(bid.state)))) @@ -4035,7 +4064,7 @@ class BasicSwap(BaseApp): self.swaps_in_progress[bid.bid_id] = (bid, offer) coin_from = Coins(offer.coin_from) - self.setLastHeightChecked(coin_from, xmr_swap.start_chain_a_height) + self.setLastHeightChecked(coin_from, bid.chain_a_height_start) self.addWatchedOutput(coin_from, bid.bid_id, bid.xmr_a_lock_tx.txid.hex(), bid.xmr_a_lock_tx.vout, TxTypes.XMR_SWAP_A_LOCK, SwapTypes.XMR_SWAP) lock_refund_vout = self.ci(coin_from).getLockRefundTxSwapOutput(xmr_swap) @@ -4340,7 +4369,7 @@ class BasicSwap(BaseApp): address_to = self.getCachedMainWalletAddress(ci_to) else: address_to = self.getCachedStealthAddressForCoin(coin_to) - txid = ci_to.spendBLockTx(xmr_swap.b_lock_tx_id, address_to, xmr_swap.vkbv, vkbs, bid.amount_to, xmr_offer.b_fee_rate, xmr_swap.b_restore_height) + txid = ci_to.spendBLockTx(xmr_swap.b_lock_tx_id, address_to, xmr_swap.vkbv, vkbs, bid.amount_to, xmr_offer.b_fee_rate, bid.chain_b_height_start) self.log.debug('Submitted lock B spend txn %s to %s chain for bid %s', txid.hex(), ci_to.coin_name(), bid_id.hex()) self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_B_SPEND_TX_PUBLISHED, '', session) except Exception as ex: @@ -4395,7 +4424,7 @@ class BasicSwap(BaseApp): try: address_to = self.getCachedMainWalletAddress(ci_to) - txid = ci_to.spendBLockTx(xmr_swap.b_lock_tx_id, address_to, xmr_swap.vkbv, vkbs, bid.amount_to, xmr_offer.b_fee_rate, xmr_swap.b_restore_height) + txid = ci_to.spendBLockTx(xmr_swap.b_lock_tx_id, address_to, xmr_swap.vkbv, vkbs, bid.amount_to, xmr_offer.b_fee_rate, bid.chain_b_height_start) self.log.debug('Submitted lock B refund txn %s to %s chain for bid %s', txid.hex(), ci_to.coin_name(), bid_id.hex()) self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_B_REFUND_TX_PUBLISHED, '', session) except Exception as ex: diff --git a/basicswap/db.py b/basicswap/db.py index 46e5199..e0ef6dc 100644 --- a/basicswap/db.py +++ b/basicswap/db.py @@ -12,7 +12,7 @@ from enum import IntEnum, auto from sqlalchemy.ext.declarative import declarative_base -CURRENT_DB_VERSION = 11 +CURRENT_DB_VERSION = 12 Base = declarative_base() @@ -41,6 +41,7 @@ class Offer(Base): offer_id = sa.Column(sa.LargeBinary, primary_key=True) active_ind = sa.Column(sa.Integer) + protocol_version = sa.Column(sa.Integer) coin_from = sa.Column(sa.Integer) coin_to = sa.Column(sa.Integer) amount_from = sa.Column(sa.BigInteger) @@ -89,6 +90,7 @@ class Bid(Base): offer_id = sa.Column(sa.LargeBinary, sa.ForeignKey('offers.offer_id')) active_ind = sa.Column(sa.Integer) + protocol_version = sa.Column(sa.Integer) was_sent = sa.Column(sa.Boolean) was_received = sa.Column(sa.Boolean) contract_count = sa.Column(sa.Integer) @@ -123,6 +125,9 @@ class Bid(Base): debug_ind = sa.Column(sa.Integer) security_token = sa.Column(sa.LargeBinary) + chain_a_height_start = sa.Column(sa.Integer) # Height of script chain before the swap + chain_b_height_start = sa.Column(sa.Integer) # Height of scriptless chain before the swap + initiate_tx = None participate_tx = None xmr_a_lock_tx = None @@ -332,9 +337,6 @@ class XmrSwap(Base): b_lock_tx_id = sa.Column(sa.LargeBinary) - start_chain_a_height = sa.Column(sa.Integer) # Height of script chain before the swap - b_restore_height = sa.Column(sa.Integer) # Height of scriptless chain before the swap - class XmrSplitData(Base): __tablename__ = 'xmr_split_data' diff --git a/basicswap/interface_btc.py b/basicswap/interface_btc.py index 7e52a88..54a0da5 100644 --- a/basicswap/interface_btc.py +++ b/basicswap/interface_btc.py @@ -85,6 +85,17 @@ def findOutput(tx, script_pk): return None +def find_vout_for_address_from_txobj(tx_obj, addr): + """ + Locate the vout index of the given transaction sending to the + 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 + raise RuntimeError("Vout not found for address: txid=%s, addr=%s" % (txid, addr)) + + class BTCInterface(CoinInterface): @staticmethod def coin_type(): @@ -911,16 +922,30 @@ class BTCInterface(CoinInterface): def spendBLockTx(self, chain_b_lock_txid, address_to, kbv, kbs, cb_swap_value, b_fee, restore_height): raise ValueError('TODO') - def getLockTxHeight(self, txid, dest_script, bid_amount, xmr_swap): - rv = None - p2wsh_addr = self.encode_p2wsh(dest_script) - - addr_info = self.rpc_callback('getaddressinfo', [p2wsh_addr]) + def getLockTxHeight(self, txid, dest_address, bid_amount, rescan_from, find_index=False): + # Add watchonly address and rescan if required + addr_info = self.rpc_callback('getaddressinfo', [dest_address]) if not addr_info['iswatchonly']: - ro = self.rpc_callback('importaddress', [p2wsh_addr, 'bid', False]) - self._log.info('Imported watch-only addr: {}'.format(p2wsh_addr)) - self._log.info('Rescanning chain from height: {}'.format(xmr_swap.start_chain_a_height)) - self.rpc_callback('rescanblockchain', [xmr_swap.start_chain_a_height]) + ro = self.rpc_callback('importaddress', [dest_address, 'bid', False]) + self._log.info('Imported watch-only addr: {}'.format(dest_address)) + self._log.info('Rescanning chain from height: {}'.format(rescan_from)) + self.rpc_callback('rescanblockchain', [rescan_from]) + + return_txid = True if txid is None else False + if txid is None: + txns = self.rpc_callback('listunspent', [0, 9999999, [dest_address, ]]) + import json + print('txns', json.dumps(txns, indent=4)) + + for tx in txns: + print('bid_amount', bid_amount) + print('self.make_int(tx[amount])', self.make_int(tx['amount'])) + if self.make_int(tx['amount']) == bid_amount: + txid = bytes.fromhex(tx['txid']) + break + + if txid is None: + return None try: tx = self.rpc_callback('gettransaction', [txid.hex()]) @@ -933,8 +958,16 @@ class BTCInterface(CoinInterface): rv = { 'depth': 0 if 'confirmations' not in tx else tx['confirmations'], 'height': block_height} + except Exception as e: - pass + return None + + if find_index: + tx_obj = self.rpc_callback('decoderawtransaction', [tx['hex']]) + rv['index'] = find_vout_for_address_from_txobj(tx_obj, dest_address) + + if return_txid: + rv['txid'] = txid.hex() return rv diff --git a/basicswap/interface_nmc.py b/basicswap/interface_nmc.py index 2378ab3..ec81393 100644 --- a/basicswap/interface_nmc.py +++ b/basicswap/interface_nmc.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (c) 2020 tecnovert +# Copyright (c) 2020-2021 tecnovert # Distributed under the MIT software license, see the accompanying # file LICENSE or http://www.opensource.org/licenses/mit-license.php. @@ -13,3 +13,6 @@ class NMCInterface(BTCInterface): @staticmethod def coin_type(): return Coins.NMC + + def getLockTxHeight(self, txid, dest_address, bid_amount, rescan_from, find_index=False): + raise ValueError('TODO: Use scantxoutset') diff --git a/basicswap/messages.proto b/basicswap/messages.proto index 105549a..0a1ba4f 100644 --- a/basicswap/messages.proto +++ b/basicswap/messages.proto @@ -29,6 +29,8 @@ message OfferMessage { uint64 fee_rate_from = 14; uint64 fee_rate_to = 15; + + uint32 protocol_version = 16; } /* Step 2, buyer -> seller */ @@ -41,6 +43,8 @@ message BidMessage { bytes pkhash_buyer = 4; /* buyer's address to receive amount_from */ string proof_address = 5; string proof_signature = 6; + + uint32 protocol_version = 7; } /* Step 3, seller -> buyer */ @@ -67,6 +71,8 @@ message XmrBidMessage { bytes kbsf_dleag = 6; bytes dest_af = 7; + + uint32 protocol_version = 8; } message XmrSplitMessage { diff --git a/basicswap/messages_pb2.py b/basicswap/messages_pb2.py index e306fe5..5a5e317 100644 --- a/basicswap/messages_pb2.py +++ b/basicswap/messages_pb2.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: messages.proto - +"""Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection @@ -19,7 +19,7 @@ DESCRIPTOR = _descriptor.FileDescriptor( syntax='proto3', serialized_options=None, create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x0emessages.proto\x12\tbasicswap\"\xd8\x03\n\x0cOfferMessage\x12\x11\n\tcoin_from\x18\x01 \x01(\r\x12\x0f\n\x07\x63oin_to\x18\x02 \x01(\r\x12\x13\n\x0b\x61mount_from\x18\x03 \x01(\x04\x12\x0c\n\x04rate\x18\x04 \x01(\x04\x12\x16\n\x0emin_bid_amount\x18\x05 \x01(\x04\x12\x12\n\ntime_valid\x18\x06 \x01(\x04\x12\x33\n\tlock_type\x18\x07 \x01(\x0e\x32 .basicswap.OfferMessage.LockType\x12\x12\n\nlock_value\x18\x08 \x01(\r\x12\x11\n\tswap_type\x18\t \x01(\r\x12\x15\n\rproof_address\x18\n \x01(\t\x12\x17\n\x0fproof_signature\x18\x0b \x01(\t\x12\x15\n\rpkhash_seller\x18\x0c \x01(\x0c\x12\x13\n\x0bsecret_hash\x18\r \x01(\x0c\x12\x15\n\rfee_rate_from\x18\x0e \x01(\x04\x12\x13\n\x0b\x66\x65\x65_rate_to\x18\x0f \x01(\x04\"q\n\x08LockType\x12\x0b\n\x07NOT_SET\x10\x00\x12\x18\n\x14SEQUENCE_LOCK_BLOCKS\x10\x01\x12\x16\n\x12SEQUENCE_LOCK_TIME\x10\x02\x12\x13\n\x0f\x41\x42S_LOCK_BLOCKS\x10\x03\x12\x11\n\rABS_LOCK_TIME\x10\x04\"\x8c\x01\n\nBidMessage\x12\x14\n\x0coffer_msg_id\x18\x01 \x01(\x0c\x12\x12\n\ntime_valid\x18\x02 \x01(\x04\x12\x0e\n\x06\x61mount\x18\x03 \x01(\x04\x12\x14\n\x0cpkhash_buyer\x18\x04 \x01(\x0c\x12\x15\n\rproof_address\x18\x05 \x01(\t\x12\x17\n\x0fproof_signature\x18\x06 \x01(\t\"V\n\x10\x42idAcceptMessage\x12\x12\n\nbid_msg_id\x18\x01 \x01(\x0c\x12\x15\n\rinitiate_txid\x18\x02 \x01(\x0c\x12\x17\n\x0f\x63ontract_script\x18\x03 \x01(\x0c\"=\n\x12OfferRevokeMessage\x12\x14\n\x0coffer_msg_id\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\"\x8a\x01\n\rXmrBidMessage\x12\x14\n\x0coffer_msg_id\x18\x01 \x01(\x0c\x12\x12\n\ntime_valid\x18\x02 \x01(\x04\x12\x0e\n\x06\x61mount\x18\x03 \x01(\x04\x12\x0c\n\x04pkaf\x18\x04 \x01(\x0c\x12\x0c\n\x04kbvf\x18\x05 \x01(\x0c\x12\x12\n\nkbsf_dleag\x18\x06 \x01(\x0c\x12\x0f\n\x07\x64\x65st_af\x18\x07 \x01(\x0c\"T\n\x0fXmrSplitMessage\x12\x0e\n\x06msg_id\x18\x01 \x01(\x0c\x12\x10\n\x08msg_type\x18\x02 \x01(\r\x12\x10\n\x08sequence\x18\x03 \x01(\r\x12\r\n\x05\x64leag\x18\x04 \x01(\x0c\"\x80\x02\n\x13XmrBidAcceptMessage\x12\x12\n\nbid_msg_id\x18\x01 \x01(\x0c\x12\x0c\n\x04pkal\x18\x03 \x01(\x0c\x12\x0c\n\x04kbvl\x18\x04 \x01(\x0c\x12\x12\n\nkbsl_dleag\x18\x05 \x01(\x0c\x12\x11\n\ta_lock_tx\x18\x06 \x01(\x0c\x12\x18\n\x10\x61_lock_tx_script\x18\x07 \x01(\x0c\x12\x18\n\x10\x61_lock_refund_tx\x18\x08 \x01(\x0c\x12\x1f\n\x17\x61_lock_refund_tx_script\x18\t \x01(\x0c\x12\x1e\n\x16\x61_lock_refund_spend_tx\x18\n \x01(\x0c\x12\x1d\n\x15\x61l_lock_refund_tx_sig\x18\x0b \x01(\x0c\"r\n\x17XmrBidLockTxSigsMessage\x12\x12\n\nbid_msg_id\x18\x01 \x01(\x0c\x12$\n\x1c\x61\x66_lock_refund_spend_tx_esig\x18\x02 \x01(\x0c\x12\x1d\n\x15\x61\x66_lock_refund_tx_sig\x18\x03 \x01(\x0c\"X\n\x18XmrBidLockSpendTxMessage\x12\x12\n\nbid_msg_id\x18\x01 \x01(\x0c\x12\x17\n\x0f\x61_lock_spend_tx\x18\x02 \x01(\x0c\x12\x0f\n\x07kal_sig\x18\x03 \x01(\x0c\"M\n\x18XmrBidLockReleaseMessage\x12\x12\n\nbid_msg_id\x18\x01 \x01(\x0c\x12\x1d\n\x15\x61l_lock_spend_tx_esig\x18\x02 \x01(\x0c\x62\x06proto3' + serialized_pb=b'\n\x0emessages.proto\x12\tbasicswap\"\xf2\x03\n\x0cOfferMessage\x12\x11\n\tcoin_from\x18\x01 \x01(\r\x12\x0f\n\x07\x63oin_to\x18\x02 \x01(\r\x12\x13\n\x0b\x61mount_from\x18\x03 \x01(\x04\x12\x0c\n\x04rate\x18\x04 \x01(\x04\x12\x16\n\x0emin_bid_amount\x18\x05 \x01(\x04\x12\x12\n\ntime_valid\x18\x06 \x01(\x04\x12\x33\n\tlock_type\x18\x07 \x01(\x0e\x32 .basicswap.OfferMessage.LockType\x12\x12\n\nlock_value\x18\x08 \x01(\r\x12\x11\n\tswap_type\x18\t \x01(\r\x12\x15\n\rproof_address\x18\n \x01(\t\x12\x17\n\x0fproof_signature\x18\x0b \x01(\t\x12\x15\n\rpkhash_seller\x18\x0c \x01(\x0c\x12\x13\n\x0bsecret_hash\x18\r \x01(\x0c\x12\x15\n\rfee_rate_from\x18\x0e \x01(\x04\x12\x13\n\x0b\x66\x65\x65_rate_to\x18\x0f \x01(\x04\x12\x18\n\x10protocol_version\x18\x10 \x01(\r\"q\n\x08LockType\x12\x0b\n\x07NOT_SET\x10\x00\x12\x18\n\x14SEQUENCE_LOCK_BLOCKS\x10\x01\x12\x16\n\x12SEQUENCE_LOCK_TIME\x10\x02\x12\x13\n\x0f\x41\x42S_LOCK_BLOCKS\x10\x03\x12\x11\n\rABS_LOCK_TIME\x10\x04\"\xa6\x01\n\nBidMessage\x12\x14\n\x0coffer_msg_id\x18\x01 \x01(\x0c\x12\x12\n\ntime_valid\x18\x02 \x01(\x04\x12\x0e\n\x06\x61mount\x18\x03 \x01(\x04\x12\x14\n\x0cpkhash_buyer\x18\x04 \x01(\x0c\x12\x15\n\rproof_address\x18\x05 \x01(\t\x12\x17\n\x0fproof_signature\x18\x06 \x01(\t\x12\x18\n\x10protocol_version\x18\x07 \x01(\r\"V\n\x10\x42idAcceptMessage\x12\x12\n\nbid_msg_id\x18\x01 \x01(\x0c\x12\x15\n\rinitiate_txid\x18\x02 \x01(\x0c\x12\x17\n\x0f\x63ontract_script\x18\x03 \x01(\x0c\"=\n\x12OfferRevokeMessage\x12\x14\n\x0coffer_msg_id\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\"\xa4\x01\n\rXmrBidMessage\x12\x14\n\x0coffer_msg_id\x18\x01 \x01(\x0c\x12\x12\n\ntime_valid\x18\x02 \x01(\x04\x12\x0e\n\x06\x61mount\x18\x03 \x01(\x04\x12\x0c\n\x04pkaf\x18\x04 \x01(\x0c\x12\x0c\n\x04kbvf\x18\x05 \x01(\x0c\x12\x12\n\nkbsf_dleag\x18\x06 \x01(\x0c\x12\x0f\n\x07\x64\x65st_af\x18\x07 \x01(\x0c\x12\x18\n\x10protocol_version\x18\x08 \x01(\r\"T\n\x0fXmrSplitMessage\x12\x0e\n\x06msg_id\x18\x01 \x01(\x0c\x12\x10\n\x08msg_type\x18\x02 \x01(\r\x12\x10\n\x08sequence\x18\x03 \x01(\r\x12\r\n\x05\x64leag\x18\x04 \x01(\x0c\"\x80\x02\n\x13XmrBidAcceptMessage\x12\x12\n\nbid_msg_id\x18\x01 \x01(\x0c\x12\x0c\n\x04pkal\x18\x03 \x01(\x0c\x12\x0c\n\x04kbvl\x18\x04 \x01(\x0c\x12\x12\n\nkbsl_dleag\x18\x05 \x01(\x0c\x12\x11\n\ta_lock_tx\x18\x06 \x01(\x0c\x12\x18\n\x10\x61_lock_tx_script\x18\x07 \x01(\x0c\x12\x18\n\x10\x61_lock_refund_tx\x18\x08 \x01(\x0c\x12\x1f\n\x17\x61_lock_refund_tx_script\x18\t \x01(\x0c\x12\x1e\n\x16\x61_lock_refund_spend_tx\x18\n \x01(\x0c\x12\x1d\n\x15\x61l_lock_refund_tx_sig\x18\x0b \x01(\x0c\"r\n\x17XmrBidLockTxSigsMessage\x12\x12\n\nbid_msg_id\x18\x01 \x01(\x0c\x12$\n\x1c\x61\x66_lock_refund_spend_tx_esig\x18\x02 \x01(\x0c\x12\x1d\n\x15\x61\x66_lock_refund_tx_sig\x18\x03 \x01(\x0c\"X\n\x18XmrBidLockSpendTxMessage\x12\x12\n\nbid_msg_id\x18\x01 \x01(\x0c\x12\x17\n\x0f\x61_lock_spend_tx\x18\x02 \x01(\x0c\x12\x0f\n\x07kal_sig\x18\x03 \x01(\x0c\"M\n\x18XmrBidLockReleaseMessage\x12\x12\n\nbid_msg_id\x18\x01 \x01(\x0c\x12\x1d\n\x15\x61l_lock_spend_tx_esig\x18\x02 \x01(\x0c\x62\x06proto3' ) @@ -59,8 +59,8 @@ _OFFERMESSAGE_LOCKTYPE = _descriptor.EnumDescriptor( ], containing_type=None, serialized_options=None, - serialized_start=389, - serialized_end=502, + serialized_start=415, + serialized_end=528, ) _sym_db.RegisterEnumDescriptor(_OFFERMESSAGE_LOCKTYPE) @@ -178,6 +178,13 @@ _OFFERMESSAGE = _descriptor.Descriptor( message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='protocol_version', full_name='basicswap.OfferMessage.protocol_version', index=15, + number=16, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), ], extensions=[ ], @@ -192,7 +199,7 @@ _OFFERMESSAGE = _descriptor.Descriptor( oneofs=[ ], serialized_start=30, - serialized_end=502, + serialized_end=528, ) @@ -246,6 +253,13 @@ _BIDMESSAGE = _descriptor.Descriptor( message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='protocol_version', full_name='basicswap.BidMessage.protocol_version', index=6, + number=7, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), ], extensions=[ ], @@ -258,8 +272,8 @@ _BIDMESSAGE = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=505, - serialized_end=645, + serialized_start=531, + serialized_end=697, ) @@ -304,8 +318,8 @@ _BIDACCEPTMESSAGE = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=647, - serialized_end=733, + serialized_start=699, + serialized_end=785, ) @@ -343,8 +357,8 @@ _OFFERREVOKEMESSAGE = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=735, - serialized_end=796, + serialized_start=787, + serialized_end=848, ) @@ -405,6 +419,13 @@ _XMRBIDMESSAGE = _descriptor.Descriptor( message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='protocol_version', full_name='basicswap.XmrBidMessage.protocol_version', index=7, + number=8, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), ], extensions=[ ], @@ -417,8 +438,8 @@ _XMRBIDMESSAGE = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=799, - serialized_end=937, + serialized_start=851, + serialized_end=1015, ) @@ -470,8 +491,8 @@ _XMRSPLITMESSAGE = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=939, - serialized_end=1023, + serialized_start=1017, + serialized_end=1101, ) @@ -565,8 +586,8 @@ _XMRBIDACCEPTMESSAGE = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=1026, - serialized_end=1282, + serialized_start=1104, + serialized_end=1360, ) @@ -611,8 +632,8 @@ _XMRBIDLOCKTXSIGSMESSAGE = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=1284, - serialized_end=1398, + serialized_start=1362, + serialized_end=1476, ) @@ -657,8 +678,8 @@ _XMRBIDLOCKSPENDTXMESSAGE = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=1400, - serialized_end=1488, + serialized_start=1478, + serialized_end=1566, ) @@ -696,8 +717,8 @@ _XMRBIDLOCKRELEASEMESSAGE = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=1490, - serialized_end=1567, + serialized_start=1568, + serialized_end=1645, ) _OFFERMESSAGE.fields_by_name['lock_type'].enum_type = _OFFERMESSAGE_LOCKTYPE diff --git a/doc/release-notes.md b/doc/release-notes.md index 245605b..52f7bf0 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -1,4 +1,12 @@ +0.0.26 +============== + +- Added protocol version to order and bid messages +- Moved chain start heights to bid. +- Avoid scantxoutset for decred style swaps + + 0.0.25 ==============