mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-06 02:38:11 +01:00
tests: Manual recovery of xmrswap chain B lock tx
This commit is contained in:
@@ -122,6 +122,7 @@ from .basicswap_util import (
|
||||
getOfferProofOfFundsHash,
|
||||
getLastBidState,
|
||||
isActiveBidState)
|
||||
from .protocols.xmr_swap_1 import recoverNoScriptTxnWithKey
|
||||
|
||||
non_script_type_coins = (Coins.XMR, Coins.PART_ANON)
|
||||
|
||||
@@ -4927,40 +4928,6 @@ class BasicSwap(BaseApp):
|
||||
finally:
|
||||
self.mxDB.release()
|
||||
|
||||
def recoverNoScriptTxnWithKey(self, bid_id, encoded_key):
|
||||
# Manually recover txn if other key is known
|
||||
session = scoped_session(self.session_factory)
|
||||
try:
|
||||
bid, xmr_swap = self.getXmrBidFromSession(session, bid_id)
|
||||
ensure(bid, 'Bid not found: {}.'.format(bid_id.hex()))
|
||||
ensure(xmr_swap, 'XMR swap not found: {}.'.format(bid_id.hex()))
|
||||
offer, xmr_offer = self.getXmrOfferFromSession(session, bid.offer_id, sent=False)
|
||||
ensure(offer, 'Offer not found: {}.'.format(bid.offer_id.hex()))
|
||||
ensure(xmr_offer, 'XMR offer not found: {}.'.format(bid.offer_id.hex()))
|
||||
ci_to = self.ci(offer.coin_to)
|
||||
|
||||
for_ed25519 = True if Coins(offer.coin_to) == Coins.XMR else False
|
||||
if bid.was_sent:
|
||||
kbsl = ci_to.decodeKey(encoded_key)
|
||||
kbsf = self.getPathKey(offer.coin_from, offer.coin_to, bid.created_at, xmr_swap.contract_count, KeyTypes.KBSF, for_ed25519)
|
||||
else:
|
||||
kbsl = self.getPathKey(offer.coin_from, offer.coin_to, bid.created_at, xmr_swap.contract_count, KeyTypes.KBSL, for_ed25519)
|
||||
kbsf = ci_to.decodeKey(encoded_key)
|
||||
ensure(ci_to.verifyKey(kbsl), 'Invalid kbsl')
|
||||
ensure(ci_to.verifyKey(kbsf), 'Invalid kbsf')
|
||||
vkbs = ci_to.sumKeys(kbsl, kbsf)
|
||||
|
||||
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, 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, txid.hex(), session)
|
||||
session.commit()
|
||||
|
||||
return txid.hex()
|
||||
finally:
|
||||
session.close()
|
||||
session.remove()
|
||||
|
||||
def manualBidUpdate(self, bid_id, data):
|
||||
self.log.info('Manually updating bid %s', bid_id.hex())
|
||||
self.mxDB.acquire()
|
||||
@@ -4984,7 +4951,7 @@ class BasicSwap(BaseApp):
|
||||
has_changed = True
|
||||
|
||||
if data['kbs_other'] is not None:
|
||||
return self.recoverNoScriptTxnWithKey(bid_id, data['kbs_other'])
|
||||
return recoverNoScriptTxnWithKey(self, bid_id, data['kbs_other'])
|
||||
|
||||
if has_changed:
|
||||
session = scoped_session(self.session_factory)
|
||||
|
||||
Reference in New Issue
Block a user