diff --git a/basicswap/base.py b/basicswap/base.py index c2e93f8..3552d60 100644 --- a/basicswap/base.py +++ b/basicswap/base.py @@ -135,6 +135,6 @@ class BaseApp: raise ValueError('CLI error ' + str(out[1])) return out[0].decode('utf-8').strip() - def is_transient_error(ex): - str_error = str(ex).tolower() + def is_transient_error(self, ex): + str_error = str(ex).lower() return 'read timed out' in str_error or 'no connection to daemon' in str_error diff --git a/basicswap/http_server.py b/basicswap/http_server.py index beb4d60..9f07f65 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -810,6 +810,7 @@ class HttpHandler(BaseHTTPRequestHandler): messages = [] show_txns = False + show_lock_transfers = False edit_bid = False view_tx_ind = None form_data = self.checkForm(post_string, 'bid', messages) @@ -842,11 +843,14 @@ class HttpHandler(BaseHTTPRequestHandler): elif b'view_tx_submit' in form_data: show_txns = True view_tx_ind = form_data[b'view_tx'][0].decode('utf-8') + elif b'view_lock_transfers' in form_data: + show_txns = True + show_lock_transfers = True bid, xmr_swap, offer, xmr_offer, events = swap_client.getXmrBidAndOffer(bid_id) assert(bid), 'Unknown bid ID' - data = describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, events, edit_bid, show_txns, view_tx_ind) + data = describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, events, edit_bid, show_txns, view_tx_ind, show_lock_transfers=show_lock_transfers) if bid.debug_ind is not None and bid.debug_ind > 0: messages.append('Debug flag set: {}'.format(bid.debug_ind)) diff --git a/basicswap/interface_btc.py b/basicswap/interface_btc.py index b101c54..b3737a6 100644 --- a/basicswap/interface_btc.py +++ b/basicswap/interface_btc.py @@ -249,7 +249,7 @@ class BTCInterface(CoinInterface): bech32_prefix = chainparams[self.coin_type()][self._network]['hrp'] version = 0 pkh = hash160(pk) - return encode_segwit_address(bech32_prefix, version, pkh) + return segwit_addr.encode(bech32_prefix, version, pkh) def getNewSecretKey(self): return getSecretInt() @@ -952,6 +952,9 @@ class BTCInterface(CoinInterface): return True if address_hash == pubkey_hash else False + def showLockTransfers(self, Kbv, Kbs): + return 'Unimplemented' + def testBTCInterface(): print('testBTCInterface') diff --git a/basicswap/interface_xmr.py b/basicswap/interface_xmr.py index 5410627..7375f52 100644 --- a/basicswap/interface_xmr.py +++ b/basicswap/interface_xmr.py @@ -435,3 +435,22 @@ class XMRInterface(CoinInterface): params['priority'] = self._fee_priority rv = self.rpc_wallet_cb('transfer', params) return rv['tx_hash'] + + def showLockTransfers(self, Kbv, Kbs): + with self._mx_wallet: + try: + address_b58 = xmr_util.encode_address(Kbv, Kbs) + wallet_file = address_b58 + '_spend' + try: + self.rpc_wallet_cb('open_wallet', {'filename': wallet_file}) + except Exception: + wallet_file = address_b58 + self.rpc_wallet_cb('open_wallet', {'filename': wallet_file}) + + self.rpc_wallet_cb('refresh') + + rv = self.rpc_wallet_cb('get_transfers', {'in': True, 'out': True, 'pending': True, 'failed': True}) + rv['filename'] = wallet_file + return rv + except Exception as e: + return {'error': str(e)} diff --git a/basicswap/templates/bid_xmr.html b/basicswap/templates/bid_xmr.html index 0d34704..50df7ab 100644 --- a/basicswap/templates/bid_xmr.html +++ b/basicswap/templates/bid_xmr.html @@ -79,10 +79,20 @@ + {% if data.view_tx_hex %}

{{ data.view_tx_hex }}

{% endif %} + +{% if data.lock_transfers %} +

+
+ +

+{% endif %} {% endif %} diff --git a/basicswap/ui.py b/basicswap/ui.py index e81f4d0..24d0208 100644 --- a/basicswap/ui.py +++ b/basicswap/ui.py @@ -4,6 +4,7 @@ # Distributed under the MIT software license, see the accompanying # file LICENSE or http://www.opensource.org/licenses/mit-license.php. +import json from .util import ( make_int, format_timestamp, @@ -127,7 +128,7 @@ def listBidStates(): return rv -def describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, bid_events, edit_bid, show_txns, view_tx_ind=None, for_api=False): +def describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, bid_events, edit_bid, show_txns, view_tx_ind=None, for_api=False, show_lock_transfers=False): ci_from = swap_client.ci(Coins(offer.coin_from)) ci_to = swap_client.ci(Coins(offer.coin_to)) ticker_from = ci_from.ticker() @@ -221,6 +222,12 @@ def describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, bid_events, edit_b data['txns'] = txns data['xmr_b_shared_address'] = ci_to.encodeSharedAddress(xmr_swap.pkbv, xmr_swap.pkbs) if xmr_swap.pkbs else None + + if show_lock_transfers: + if xmr_swap.pkbs: + data['lock_transfers'] = json.dumps(ci_to.showLockTransfers(xmr_swap.pkbv, xmr_swap.pkbs), indent=4) + else: + data['lock_transfers'] = 'Shared address not yet known.' else: data['initiate_tx_refund'] = 'None' if not bid.initiate_txn_refund else bid.initiate_txn_refund.hex() data['participate_tx_refund'] = 'None' if not bid.participate_txn_refund else bid.participate_txn_refund.hex() diff --git a/doc/release-notes.md b/doc/release-notes.md index 9d8a2df..9b25e33 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -2,6 +2,7 @@ ============== - Raised Particl and Monero daemon versions. - Display shared address on bid page if show more info is enabled. +- Added View Lock Wallet Transfers button to bid page. 0.0.6