Add View Lock Wallet Transfers button to bid page.

This commit is contained in:
tecnovert 2021-09-05 17:36:27 +02:00
parent e69409514c
commit 4475e5b643
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
7 changed files with 49 additions and 5 deletions

View file

@ -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

View file

@ -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))

View file

@ -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')

View file

@ -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)}

View file

@ -79,10 +79,20 @@
</select></td></tr>
</table>
<input name="view_tx_submit" type="submit" value="View Tx">
<input name="view_lock_transfers" type="submit" value="View Lock Wallet Transfers">
{% if data.view_tx_hex %}
<p>{{ data.view_tx_hex }}</p>
{% endif %}
{% if data.lock_transfers %}
<p>
<label for="transfers_view">Lock wallet transfers:</label><br/>
<textarea id="transfers_view" rows="10" cols="150" readonly>
{{ data.lock_transfers }}
</textarea>
</p>
{% endif %}
{% endif %}
</form>

View file

@ -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()

View file

@ -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