mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
htlc: Allow for exactly min_final_cltv_expiry cltv delta
We are announcing that we are willing to accept incoming payments with current_height + min_final_cltv_expiry + slack, assuming that the sender adds some slack. In particular we'd reject the payment if slack=0 which is allowed by the spec. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
d6af14a869
commit
07e5a9ef9f
@ -359,9 +359,9 @@ static void handle_localpay(struct htlc_in *hin,
|
|||||||
* If the `cltv_expiry` is too low, the final node MUST fail the HTLC:
|
* If the `cltv_expiry` is too low, the final node MUST fail the HTLC:
|
||||||
*/
|
*/
|
||||||
if (get_block_height(ld->topology) + ld->config.cltv_final
|
if (get_block_height(ld->topology) + ld->config.cltv_final
|
||||||
>= cltv_expiry) {
|
> cltv_expiry) {
|
||||||
log_debug(hin->key.peer->log,
|
log_debug(hin->key.peer->log,
|
||||||
"Expiry cltv %u too close to current %u + %u",
|
"Expiry cltv too soon %u < %u + %u",
|
||||||
cltv_expiry,
|
cltv_expiry,
|
||||||
get_block_height(ld->topology),
|
get_block_height(ld->topology),
|
||||||
ld->config.cltv_final);
|
ld->config.cltv_final);
|
||||||
|
@ -1631,9 +1631,9 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
# Takes 6 blocks to timeout (cltv-final + 1), but we also give grace period of 1 block.
|
# Takes 6 blocks to timeout (cltv-final + 1), but we also give grace period of 1 block.
|
||||||
bitcoind.rpc.generate(5 + 1)
|
bitcoind.rpc.generate(5 + 1)
|
||||||
assert not l1.daemon.is_in_log('hit deadline')
|
assert not l1.daemon.is_in_log('hit deadline')
|
||||||
bitcoind.rpc.generate(1)
|
bitcoind.rpc.generate(2)
|
||||||
|
|
||||||
l1.daemon.wait_for_log('Offered HTLC 0 SENT_ADD_ACK_REVOCATION cltv {} hit deadline'.format(bitcoind.rpc.getblockcount()-1))
|
l1.daemon.wait_for_log('Offered HTLC 0 SENT_ADD_ACK_REVOCATION cltv .* hit deadline')
|
||||||
l1.daemon.wait_for_log('sendrawtx exit 0')
|
l1.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
l1.bitcoin.rpc.generate(1)
|
l1.bitcoin.rpc.generate(1)
|
||||||
l1.daemon.wait_for_log('-> ONCHAIND_OUR_UNILATERAL')
|
l1.daemon.wait_for_log('-> ONCHAIND_OUR_UNILATERAL')
|
||||||
@ -1668,12 +1668,12 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
# l1 will drop to chain, not reconnect.
|
# l1 will drop to chain, not reconnect.
|
||||||
l1.daemon.wait_for_log('dev_disconnect: -WIRE_REVOKE_AND_ACK')
|
l1.daemon.wait_for_log('dev_disconnect: -WIRE_REVOKE_AND_ACK')
|
||||||
|
|
||||||
# Deadline HTLC expity minus 1/2 cltv-expiry delta (rounded up) (== cltv - 3). ctlv is 5+1.
|
# Deadline HTLC expiry minus 1/2 cltv-expiry delta (rounded up) (== cltv - 3). ctlv is 5+1.
|
||||||
bitcoind.rpc.generate(2)
|
bitcoind.rpc.generate(2)
|
||||||
assert not l2.daemon.is_in_log('hit deadline')
|
assert not l2.daemon.is_in_log('hit deadline')
|
||||||
bitcoind.rpc.generate(1)
|
bitcoind.rpc.generate(2)
|
||||||
|
|
||||||
l2.daemon.wait_for_log('Fulfilled HTLC 0 SENT_REMOVE_COMMIT cltv {} hit deadline'.format(bitcoind.rpc.getblockcount()+3))
|
l2.daemon.wait_for_log('Fulfilled HTLC 0 SENT_REMOVE_COMMIT cltv .* hit deadline')
|
||||||
l2.daemon.wait_for_log('sendrawtx exit 0')
|
l2.daemon.wait_for_log('sendrawtx exit 0')
|
||||||
l2.bitcoin.rpc.generate(1)
|
l2.bitcoin.rpc.generate(1)
|
||||||
l2.daemon.wait_for_log('-> ONCHAIND_OUR_UNILATERAL')
|
l2.daemon.wait_for_log('-> ONCHAIND_OUR_UNILATERAL')
|
||||||
|
Loading…
Reference in New Issue
Block a user