diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 74517a6..003f6e0 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -7964,11 +7964,14 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp): "", cursor, ) + refund_vout: int = ci_from.getLockRefundVout( + xmr_swap.a_lock_refund_tx, xmr_swap.vkbv + ) bid.txns[TxTypes.XMR_SWAP_A_LOCK_REFUND] = SwapTx( bid_id=bid_id, tx_type=TxTypes.XMR_SWAP_A_LOCK_REFUND, txid=bytes.fromhex(txid), - vout=0, + vout=refund_vout, ) self.saveBidInSession(bid_id, bid, cursor, xmr_swap) self.commitDB() @@ -7980,11 +7983,14 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp): ) txid = ci_from.getTxid(xmr_swap.a_lock_refund_tx) if TxTypes.XMR_SWAP_A_LOCK_REFUND not in bid.txns: + refund_vout: int = ci_from.getLockRefundVout( + xmr_swap.a_lock_refund_tx, xmr_swap.vkbv + ) bid.txns[TxTypes.XMR_SWAP_A_LOCK_REFUND] = SwapTx( bid_id=bid_id, tx_type=TxTypes.XMR_SWAP_A_LOCK_REFUND, txid=txid, - vout=0, + vout=refund_vout, ) self.saveBidInSession(bid_id, bid, cursor, xmr_swap) self.commitDB() @@ -9058,11 +9064,14 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp): ) if TxTypes.XMR_SWAP_A_LOCK_REFUND not in bid.txns: + refund_vout: int = ci_from.getLockRefundVout( + bytes.fromhex(spend_txn_hex), xmr_swap.vkbv + ) bid.txns[TxTypes.XMR_SWAP_A_LOCK_REFUND] = SwapTx( bid_id=bid.bid_id, tx_type=TxTypes.XMR_SWAP_A_LOCK_REFUND, txid=xmr_swap.a_lock_refund_tx_id, - vout=0, + vout=refund_vout, ) else: self.setBidError( diff --git a/basicswap/interface/base.py b/basicswap/interface/base.py index 0879a9d..26747aa 100644 --- a/basicswap/interface/base.py +++ b/basicswap/interface/base.py @@ -192,6 +192,9 @@ class AdaptorSigInterface: def getScriptLockRefundSwipeTxDummyWitness(self, script: bytes) -> List[bytes]: return [bytes(72), b"", bytes(len(script))] + def getLockRefundVout(self, lock_refund_tx_data: bytes, vbkv: bytes): + return 0 + class Secp256k1Interface(CoinInterface, AdaptorSigInterface): def __init__(self, **kwargs): diff --git a/basicswap/interface/part.py b/basicswap/interface/part.py index ea8c650..a5ba8f9 100644 --- a/basicswap/interface/part.py +++ b/basicswap/interface/part.py @@ -1299,6 +1299,17 @@ class PARTInterfaceBlind(PARTInterface): "fundrawtransactionfrom", ["blind", tx_hex, {}, outputs_info, options] )["hex"] + def getLockRefundVout(self, lock_refund_tx_data: bytes, vkbv: bytes): + lock_refund_tx_obj = self.rpc( + "decoderawtransaction", [lock_refund_tx_data.hex()] + ) + # Nonce is derived from vkbv + nonce = self.getScriptLockRefundTxNonce(vkbv) + + # Find the output of the lock refund tx to spend + spend_n, input_blinded_info = self.findOutputByNonce(lock_refund_tx_obj, nonce) + return spend_n + class PARTInterfaceAnon(PARTInterface):