mirror of
https://github.com/basicswap/basicswap.git
synced 2025-01-09 12:19:29 +00:00
Add View Lock Wallet Transfers button to bid page.
This commit is contained in:
parent
e69409514c
commit
4475e5b643
7 changed files with 49 additions and 5 deletions
|
@ -135,6 +135,6 @@ class BaseApp:
|
||||||
raise ValueError('CLI error ' + str(out[1]))
|
raise ValueError('CLI error ' + str(out[1]))
|
||||||
return out[0].decode('utf-8').strip()
|
return out[0].decode('utf-8').strip()
|
||||||
|
|
||||||
def is_transient_error(ex):
|
def is_transient_error(self, ex):
|
||||||
str_error = str(ex).tolower()
|
str_error = str(ex).lower()
|
||||||
return 'read timed out' in str_error or 'no connection to daemon' in str_error
|
return 'read timed out' in str_error or 'no connection to daemon' in str_error
|
||||||
|
|
|
@ -810,6 +810,7 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
show_txns = False
|
show_txns = False
|
||||||
|
show_lock_transfers = False
|
||||||
edit_bid = False
|
edit_bid = False
|
||||||
view_tx_ind = None
|
view_tx_ind = None
|
||||||
form_data = self.checkForm(post_string, 'bid', messages)
|
form_data = self.checkForm(post_string, 'bid', messages)
|
||||||
|
@ -842,11 +843,14 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||||
elif b'view_tx_submit' in form_data:
|
elif b'view_tx_submit' in form_data:
|
||||||
show_txns = True
|
show_txns = True
|
||||||
view_tx_ind = form_data[b'view_tx'][0].decode('utf-8')
|
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)
|
bid, xmr_swap, offer, xmr_offer, events = swap_client.getXmrBidAndOffer(bid_id)
|
||||||
assert(bid), 'Unknown 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:
|
if bid.debug_ind is not None and bid.debug_ind > 0:
|
||||||
messages.append('Debug flag set: {}'.format(bid.debug_ind))
|
messages.append('Debug flag set: {}'.format(bid.debug_ind))
|
||||||
|
|
|
@ -249,7 +249,7 @@ class BTCInterface(CoinInterface):
|
||||||
bech32_prefix = chainparams[self.coin_type()][self._network]['hrp']
|
bech32_prefix = chainparams[self.coin_type()][self._network]['hrp']
|
||||||
version = 0
|
version = 0
|
||||||
pkh = hash160(pk)
|
pkh = hash160(pk)
|
||||||
return encode_segwit_address(bech32_prefix, version, pkh)
|
return segwit_addr.encode(bech32_prefix, version, pkh)
|
||||||
|
|
||||||
def getNewSecretKey(self):
|
def getNewSecretKey(self):
|
||||||
return getSecretInt()
|
return getSecretInt()
|
||||||
|
@ -952,6 +952,9 @@ class BTCInterface(CoinInterface):
|
||||||
|
|
||||||
return True if address_hash == pubkey_hash else False
|
return True if address_hash == pubkey_hash else False
|
||||||
|
|
||||||
|
def showLockTransfers(self, Kbv, Kbs):
|
||||||
|
return 'Unimplemented'
|
||||||
|
|
||||||
|
|
||||||
def testBTCInterface():
|
def testBTCInterface():
|
||||||
print('testBTCInterface')
|
print('testBTCInterface')
|
||||||
|
|
|
@ -435,3 +435,22 @@ class XMRInterface(CoinInterface):
|
||||||
params['priority'] = self._fee_priority
|
params['priority'] = self._fee_priority
|
||||||
rv = self.rpc_wallet_cb('transfer', params)
|
rv = self.rpc_wallet_cb('transfer', params)
|
||||||
return rv['tx_hash']
|
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)}
|
||||||
|
|
|
@ -79,10 +79,20 @@
|
||||||
</select></td></tr>
|
</select></td></tr>
|
||||||
</table>
|
</table>
|
||||||
<input name="view_tx_submit" type="submit" value="View Tx">
|
<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 %}
|
{% if data.view_tx_hex %}
|
||||||
<p>{{ data.view_tx_hex }}</p>
|
<p>{{ data.view_tx_hex }}</p>
|
||||||
{% endif %}
|
{% 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 %}
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
import json
|
||||||
from .util import (
|
from .util import (
|
||||||
make_int,
|
make_int,
|
||||||
format_timestamp,
|
format_timestamp,
|
||||||
|
@ -127,7 +128,7 @@ def listBidStates():
|
||||||
return rv
|
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_from = swap_client.ci(Coins(offer.coin_from))
|
||||||
ci_to = swap_client.ci(Coins(offer.coin_to))
|
ci_to = swap_client.ci(Coins(offer.coin_to))
|
||||||
ticker_from = ci_from.ticker()
|
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['txns'] = txns
|
||||||
|
|
||||||
data['xmr_b_shared_address'] = ci_to.encodeSharedAddress(xmr_swap.pkbv, xmr_swap.pkbs) if xmr_swap.pkbs else None
|
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:
|
else:
|
||||||
data['initiate_tx_refund'] = 'None' if not bid.initiate_txn_refund else bid.initiate_txn_refund.hex()
|
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()
|
data['participate_tx_refund'] = 'None' if not bid.participate_txn_refund else bid.participate_txn_refund.hex()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
==============
|
==============
|
||||||
- Raised Particl and Monero daemon versions.
|
- Raised Particl and Monero daemon versions.
|
||||||
- Display shared address on bid page if show more info is enabled.
|
- Display shared address on bid page if show more info is enabled.
|
||||||
|
- Added View Lock Wallet Transfers button to bid page.
|
||||||
|
|
||||||
|
|
||||||
0.0.6
|
0.0.6
|
||||||
|
|
Loading…
Reference in a new issue