diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 239109a..f8622c5 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -4136,13 +4136,13 @@ class BasicSwap(BaseApp): ensure(script_lock_value == expect_sequence, 'sequence mismatch') else: if offer.lock_type == TxLockTypes.ABS_LOCK_BLOCKS: - block_header_from = ci_from.getBlockHeaderAt(bid.created_at) + block_header_from = ci_from.getBlockHeaderAt(now) chain_height_at_bid_creation = block_header_from['height'] ensure(script_lock_value <= chain_height_at_bid_creation + offer.lock_value + atomic_swap_1.ABS_LOCK_BLOCKS_LEEWAY, 'script lock height too high') ensure(script_lock_value >= chain_height_at_bid_creation + offer.lock_value - atomic_swap_1.ABS_LOCK_BLOCKS_LEEWAY, 'script lock height too low') else: - ensure(script_lock_value <= bid.created_at + offer.lock_value + atomic_swap_1.INITIATE_TX_TIMEOUT, 'script lock time too high') - ensure(script_lock_value >= bid.created_at + offer.lock_value, 'script lock time too low') + ensure(script_lock_value <= now + offer.lock_value + atomic_swap_1.INITIATE_TX_TIMEOUT, 'script lock time too high') + ensure(script_lock_value >= now + offer.lock_value - atomic_swap_1.ABS_LOCK_TIME_LEEWAY, 'script lock time too low') ensure(len(scriptvalues[3]) == 40, 'pkhash_refund bad length') diff --git a/basicswap/protocols/atomic_swap_1.py b/basicswap/protocols/atomic_swap_1.py index 8d9c0a7..62774ae 100644 --- a/basicswap/protocols/atomic_swap_1.py +++ b/basicswap/protocols/atomic_swap_1.py @@ -12,6 +12,7 @@ from basicswap.script import ( ) INITIATE_TX_TIMEOUT = 40 * 60 # TODO: make variable per coin +ABS_LOCK_TIME_LEEWAY = 10 * 60 def buildContractScript(lock_val, secret_hash, pkh_redeem, pkh_refund, op_lock=OpCodes.OP_CHECKSEQUENCEVERIFY):