mirror of
https://github.com/basicswap/basicswap.git
synced 2026-06-08 04:01:41 +02:00
Update: HTLC - CSV / CLTV
This commit is contained in:
+17
-4
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user