ui: Reseed wallet must trigger update

This commit is contained in:
tecnovert 2021-10-18 22:28:42 +02:00
parent bf00f80b4d
commit 4ce8c58872
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
4 changed files with 25 additions and 6 deletions

View file

@ -115,7 +115,8 @@ from .basicswap_util import (
getVoutByP2WSH,
replaceAddrPrefix,
getOfferProofOfFundsHash,
getLastBidState)
getLastBidState,
isActiveBidState)
def threadPollChainState(swap_client, coin_type):
@ -4244,9 +4245,8 @@ class BasicSwap(BaseApp):
kbsl = self.getPathKey(coin_from, coin_to, bid.created_at, xmr_swap.contract_count, 2, for_ed25519)
vkbs = ci_to.sumKeys(kbsl, kbsf)
address_to = ci_to.getMainWalletAddress()
try:
address_to = ci_to.getMainWalletAddress() # TODO: cache main wallet address to reduce network traffic
txid = ci_to.spendBLockTx(address_to, xmr_swap.vkbv, vkbs, bid.amount_to, xmr_offer.b_fee_rate, xmr_swap.b_restore_height)
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)
@ -4653,7 +4653,7 @@ class BasicSwap(BaseApp):
else:
self.log.debug('TODO - determine in-progress for manualBidUpdate')
if offer.swap_type == SwapTypes.XMR_SWAP:
if bid.state and bid.state in (BidStates.XMR_SWAP_HAVE_SCRIPT_COIN_SPEND_TX, BidStates.XMR_SWAP_SCRIPT_COIN_LOCKED, BidStates.XMR_SWAP_NOSCRIPT_COIN_LOCKED, BidStates.XMR_SWAP_LOCK_RELEASED, BidStates.XMR_SWAP_NOSCRIPT_TX_REDEEMED):
if bid.state and isActiveBidState(bid.state):
activate_bid = True
if activate_bid:

View file

@ -336,3 +336,19 @@ def getLastBidState(packed_states):
return struct.unpack_from('<i', packed_states[(num_states - 2) * 12:])[0]
except Exception:
return BidStates.BID_STATE_UNKNOWN
def isActiveBidState(state):
if state == BidStates.XMR_SWAP_HAVE_SCRIPT_COIN_SPEND_TX:
return True
if state == BidStates.XMR_SWAP_SCRIPT_COIN_LOCKED:
return True
if state == BidStates.XMR_SWAP_NOSCRIPT_COIN_LOCKED:
return True
if state == BidStates.XMR_SWAP_LOCK_RELEASED:
return True
if state == BidStates.XMR_SWAP_NOSCRIPT_TX_REDEEMED:
return True
if state == BidStates.XMR_SWAP_SCRIPT_TX_REDEEMED:
return True
return False

View file

@ -240,6 +240,7 @@ class HttpHandler(BaseHTTPRequestHandler):
messages.append('Reseed complete ' + str(c))
except Exception as ex:
messages.append('Reseed failed ' + str(ex))
swap_client.updateWalletsInfo(True, c)
elif bytes('withdraw_' + cid, 'utf-8') in form_data:
try:
value = form_data[bytes('amt_' + cid, 'utf-8')][0].decode('utf-8')

View file

@ -164,6 +164,8 @@ def describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, bid_events, edit_b
elif bid.state == BidStates.BID_ERROR:
state_description = bid.state_note
elif offer.swap_type == SwapTypes.XMR_SWAP:
if bid.state == BidStates.BID_SENT:
tate_description = 'Waiting for offerer to accept'
if bid.state == BidStates.BID_RECEIVING:
# Offerer receiving bid from bidder
state_description = 'Waiting for bid to be fully received'
@ -188,9 +190,9 @@ def describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, bid_events, edit_b
else:
state_description = 'Delaying before automated action'
elif bid.state == BidStates.XMR_SWAP_HAVE_SCRIPT_COIN_SPEND_TX:
state_description = f'Waiting for {ticker_from} lock tx to confirm in chain'
state_description = f'Waiting for {ticker_from} lock tx to confirm in chain ({ci_from.blocks_confirmed} blocks)'
elif bid.state == BidStates.XMR_SWAP_SCRIPT_COIN_LOCKED:
state_description = f'Waiting for {ticker_to} lock tx to confirm in chain'
state_description = f'Waiting for {ticker_to} lock tx to confirm in chain ({ci_to.blocks_confirmed} blocks)'
elif bid.state == BidStates.XMR_SWAP_NOSCRIPT_COIN_LOCKED:
state_description = f'Waiting for offerer to unlock {ticker_from} lock tx'
elif bid.state == BidStates.XMR_SWAP_LOCK_RELEASED: