Update: HTLC - CSV / CLTV

This commit is contained in:
gerlofvanek
2026-05-29 22:01:32 +02:00
parent 283662e659
commit 0de77c8d97
+17 -4
View File
@@ -8230,6 +8230,19 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
return rv return rv
def _isScriptRefundMature(self, ci, offer, refund_tx_bytes, parent_tx) -> bool:
refund_tx = ci.loadTx(refund_tx_bytes)
if offer.lock_type in (TxLockTypes.ABS_LOCK_BLOCKS, TxLockTypes.ABS_LOCK_TIME):
return ci.isAbsLockTimeMature(refund_tx.nLockTime)
if parent_tx is None or parent_tx.block_height is None:
return False
return ci.isCsvLockMature(
offer.lock_type,
refund_tx.vin[0].nSequence,
parent_tx.block_height,
parent_tx.block_time,
)
def checkBidState(self, bid_id: bytes, bid, offer): def checkBidState(self, bid_id: bytes, bid, offer):
# assert (self.mxDB.locked()) # assert (self.mxDB.locked())
# Return True to remove bid from in-progress list # Return True to remove bid from in-progress list
@@ -8490,8 +8503,8 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
if ( if (
bid.getITxState() in (TxStates.TX_SENT, TxStates.TX_CONFIRMED) bid.getITxState() in (TxStates.TX_SENT, TxStates.TX_CONFIRMED)
and bid.initiate_txn_refund is not None and bid.initiate_txn_refund is not None
and ci_from.isAbsLockTimeMature( and self._isScriptRefundMature(
ci_from.loadTx(bid.initiate_txn_refund).nLockTime ci_from, offer, bid.initiate_txn_refund, bid.initiate_tx
) )
): ):
try: try:
@@ -8516,8 +8529,8 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
if ( if (
bid.getPTxState() in (TxStates.TX_SENT, TxStates.TX_CONFIRMED) bid.getPTxState() in (TxStates.TX_SENT, TxStates.TX_CONFIRMED)
and bid.participate_txn_refund is not None and bid.participate_txn_refund is not None
and ci_to.isAbsLockTimeMature( and self._isScriptRefundMature(
ci_to.loadTx(bid.participate_txn_refund).nLockTime ci_to, offer, bid.participate_txn_refund, bid.participate_tx
) )
): ):
try: try: