@@ -1284,7 +1284,7 @@ fn test_duplicate_htlc_different_direction_onchain() {
1284
1284
mine_transaction(&nodes[0], &remote_txn[0]);
1285
1285
check_added_monitors!(nodes[0], 1);
1286
1286
check_closed_event!(nodes[0], 1, ClosureReason::CommitmentTxConfirmed);
1287
- connect_blocks(&nodes[0], TEST_FINAL_CLTV - 1 ); // Confirm blocks until the HTLC expires
1287
+ connect_blocks(&nodes[0], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
1288
1288
1289
1289
let claim_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().clone();
1290
1290
assert_eq!(claim_txn.len(), 3);
@@ -2438,7 +2438,7 @@ fn test_justice_tx_htlc_timeout() {
2438
2438
test_txn_broadcast(&nodes[1], &chan_5, Some(revoked_local_txn[0].clone()), HTLCType::NONE);
2439
2439
2440
2440
mine_transaction(&nodes[0], &revoked_local_txn[0]);
2441
- connect_blocks(&nodes[0], TEST_FINAL_CLTV - 1 ); // Confirm blocks until the HTLC expires
2441
+ connect_blocks(&nodes[0], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
2442
2442
// Verify broadcast of revoked HTLC-timeout
2443
2443
let node_txn = test_txn_broadcast(&nodes[0], &chan_5, Some(revoked_local_txn[0].clone()), HTLCType::TIMEOUT);
2444
2444
check_added_monitors!(nodes[0], 1);
@@ -2765,7 +2765,7 @@ fn test_htlc_on_chain_success() {
2765
2765
// Verify that B's ChannelManager is able to extract preimage from HTLC Success tx and pass it backward
2766
2766
let header = BlockHeader { version: 0x20000000, prev_blockhash: nodes[1].best_block_hash(), merkle_root: TxMerkleNode::all_zeros(), time: 42, bits: 42, nonce: 42};
2767
2767
connect_block(&nodes[1], &Block { header, txdata: vec![commitment_tx[0].clone(), node_txn[0].clone(), node_txn[1].clone()]});
2768
- connect_blocks(&nodes[1], TEST_FINAL_CLTV - 1 ); // Confirm blocks until the HTLC expires
2768
+ connect_blocks(&nodes[1], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
2769
2769
{
2770
2770
let mut added_monitors = nodes[1].chain_monitor.added_monitors.lock().unwrap();
2771
2771
assert_eq!(added_monitors.len(), 1);
@@ -2894,15 +2894,15 @@ fn test_htlc_on_chain_success() {
2894
2894
assert_eq!(commitment_spend.input.len(), 2);
2895
2895
assert_eq!(commitment_spend.input[0].witness.last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT);
2896
2896
assert_eq!(commitment_spend.input[1].witness.last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT);
2897
- assert_eq!(commitment_spend.lock_time.0, nodes[1].best_block_info().1 + 1 );
2897
+ assert_eq!(commitment_spend.lock_time.0, nodes[1].best_block_info().1);
2898
2898
assert!(commitment_spend.output[0].script_pubkey.is_v0_p2wpkh()); // direct payment
2899
2899
// We don't bother to check that B can claim the HTLC output on its commitment tx here as
2900
2900
// we already checked the same situation with A.
2901
2901
2902
2902
// Verify that A's ChannelManager is able to extract preimage from preimage tx and generate PaymentSent
2903
2903
let mut header = BlockHeader { version: 0x20000000, prev_blockhash: nodes[0].best_block_hash(), merkle_root: TxMerkleNode::all_zeros(), time: 42, bits: 42, nonce: 42};
2904
2904
connect_block(&nodes[0], &Block { header, txdata: vec![node_a_commitment_tx[0].clone(), commitment_spend.clone()] });
2905
- connect_blocks(&nodes[0], TEST_FINAL_CLTV + MIN_CLTV_EXPIRY_DELTA as u32 - 1 ); // Confirm blocks until the HTLC expires
2905
+ connect_blocks(&nodes[0], TEST_FINAL_CLTV + MIN_CLTV_EXPIRY_DELTA as u32); // Confirm blocks until the HTLC expires
2906
2906
check_closed_broadcast!(nodes[0], true);
2907
2907
check_added_monitors!(nodes[0], 1);
2908
2908
let events = nodes[0].node.get_and_clear_pending_events();
@@ -3024,7 +3024,7 @@ fn do_test_htlc_on_chain_timeout(connect_style: ConnectStyle) {
3024
3024
check_spends!(commitment_tx[0], chan_1.3);
3025
3025
3026
3026
mine_transaction(&nodes[0], &commitment_tx[0]);
3027
- connect_blocks(&nodes[0], TEST_FINAL_CLTV + MIN_CLTV_EXPIRY_DELTA as u32 - 1 ); // Confirm blocks until the HTLC expires
3027
+ connect_blocks(&nodes[0], TEST_FINAL_CLTV + MIN_CLTV_EXPIRY_DELTA as u32); // Confirm blocks until the HTLC expires
3028
3028
3029
3029
check_closed_broadcast!(nodes[0], true);
3030
3030
check_added_monitors!(nodes[0], 1);
@@ -4446,7 +4446,7 @@ fn test_static_spendable_outputs_timeout_tx() {
4446
4446
MessageSendEvent::BroadcastChannelUpdate { .. } => {},
4447
4447
_ => panic!("Unexpected event"),
4448
4448
}
4449
- connect_blocks(&nodes[1], TEST_FINAL_CLTV - 1 ); // Confirm blocks until the HTLC expires
4449
+ connect_blocks(&nodes[1], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
4450
4450
4451
4451
// Check B's monitor was able to send back output descriptor event for timeout tx on A's commitment tx
4452
4452
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
@@ -4524,7 +4524,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx() {
4524
4524
check_closed_broadcast!(nodes[0], true);
4525
4525
check_added_monitors!(nodes[0], 1);
4526
4526
check_closed_event!(nodes[0], 1, ClosureReason::CommitmentTxConfirmed);
4527
- connect_blocks(&nodes[0], TEST_FINAL_CLTV - 1 ); // Confirm blocks until the HTLC expires
4527
+ connect_blocks(&nodes[0], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
4528
4528
4529
4529
let revoked_htlc_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
4530
4530
assert_eq!(revoked_htlc_txn.len(), 1);
@@ -4756,7 +4756,7 @@ fn test_onchain_to_onchain_claim() {
4756
4756
check_spends!(b_txn[0], commitment_tx[0]);
4757
4757
assert_eq!(b_txn[0].input[0].witness.clone().last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT);
4758
4758
assert!(b_txn[0].output[0].script_pubkey.is_v0_p2wpkh()); // direct payment
4759
- assert_eq!(b_txn[0].lock_time.0, nodes[1].best_block_info().1 + 1 ); // Success tx
4759
+ assert_eq!(b_txn[0].lock_time.0, nodes[1].best_block_info().1); // Success tx
4760
4760
4761
4761
check_closed_broadcast!(nodes[1], true);
4762
4762
check_added_monitors!(nodes[1], 1);
@@ -4807,7 +4807,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
4807
4807
check_closed_broadcast!(nodes[1], true);
4808
4808
check_added_monitors!(nodes[1], 1);
4809
4809
check_closed_event!(nodes[1], 1, ClosureReason::CommitmentTxConfirmed);
4810
- connect_blocks(&nodes[1], TEST_FINAL_CLTV - 40 + MIN_CLTV_EXPIRY_DELTA as u32 - 1 ); // Confirm blocks until the HTLC expires
4810
+ connect_blocks(&nodes[1], TEST_FINAL_CLTV - 40 + MIN_CLTV_EXPIRY_DELTA as u32); // Confirm blocks until the HTLC expires
4811
4811
4812
4812
let htlc_timeout_tx;
4813
4813
{ // Extract one of the two HTLC-Timeout transaction
@@ -5287,7 +5287,7 @@ fn test_dynamic_spendable_outputs_local_htlc_timeout_tx() {
5287
5287
check_closed_broadcast!(nodes[0], true);
5288
5288
check_added_monitors!(nodes[0], 1);
5289
5289
check_closed_event!(nodes[0], 1, ClosureReason::CommitmentTxConfirmed);
5290
- connect_blocks(&nodes[0], TEST_FINAL_CLTV - 1 ); // Confirm blocks until the HTLC expires
5290
+ connect_blocks(&nodes[0], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
5291
5291
5292
5292
let htlc_timeout = {
5293
5293
let node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap();
@@ -5370,7 +5370,7 @@ fn test_key_derivation_params() {
5370
5370
5371
5371
// Timeout HTLC on A's chain and so it can generate a HTLC-Timeout tx
5372
5372
mine_transaction(&nodes[0], &local_txn_1[0]);
5373
- connect_blocks(&nodes[0], TEST_FINAL_CLTV - 1 ); // Confirm blocks until the HTLC expires
5373
+ connect_blocks(&nodes[0], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
5374
5374
check_closed_broadcast!(nodes[0], true);
5375
5375
check_added_monitors!(nodes[0], 1);
5376
5376
check_closed_event!(nodes[0], 1, ClosureReason::CommitmentTxConfirmed);
@@ -6927,7 +6927,7 @@ fn do_test_sweep_outbound_htlc_failure_update(revoked: bool, local: bool) {
6927
6927
check_closed_event!(nodes[0], 1, ClosureReason::CommitmentTxConfirmed);
6928
6928
assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0);
6929
6929
6930
- connect_blocks(&nodes[0], TEST_FINAL_CLTV - 1 ); // Confirm blocks until the HTLC expires
6930
+ connect_blocks(&nodes[0], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
6931
6931
timeout_tx = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().drain(..)
6932
6932
.filter(|tx| tx.input[0].previous_output.txid == bs_commitment_tx[0].txid()).collect();
6933
6933
check_spends!(timeout_tx[0], bs_commitment_tx[0]);
@@ -6938,7 +6938,7 @@ fn do_test_sweep_outbound_htlc_failure_update(revoked: bool, local: bool) {
6938
6938
if !revoked {
6939
6939
assert_eq!(timeout_tx[0].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
6940
6940
} else {
6941
- assert_eq!(timeout_tx[0].lock_time.0, 12 );
6941
+ assert_eq!(timeout_tx[0].lock_time.0, 11 );
6942
6942
}
6943
6943
// We fail non-dust-HTLC 2 by broadcast of local timeout/revocation-claim tx
6944
6944
mine_transaction(&nodes[0], &timeout_tx[0]);
@@ -7318,7 +7318,7 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
7318
7318
check_closed_broadcast!(nodes[1], true);
7319
7319
check_added_monitors!(nodes[1], 1);
7320
7320
check_closed_event!(nodes[1], 1, ClosureReason::CommitmentTxConfirmed);
7321
- connect_blocks(&nodes[1], 49 ); // Confirm blocks until the HTLC expires (note CLTV was explicitly 50 above)
7321
+ connect_blocks(&nodes[1], 50 ); // Confirm blocks until the HTLC expires (note CLTV was explicitly 50 above)
7322
7322
7323
7323
let revoked_htlc_txn = {
7324
7324
let txn = nodes[1].tx_broadcaster.unique_txn_broadcast();
@@ -7464,7 +7464,7 @@ fn test_bump_penalty_txn_on_remote_commitment() {
7464
7464
expect_payment_claimed!(nodes[1], payment_hash, 3_000_000);
7465
7465
mine_transaction(&nodes[1], &remote_txn[0]);
7466
7466
check_added_monitors!(nodes[1], 2);
7467
- connect_blocks(&nodes[1], TEST_FINAL_CLTV - 1 ); // Confirm blocks until the HTLC expires
7467
+ connect_blocks(&nodes[1], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
7468
7468
7469
7469
// One or more claim tx should have been broadcast, check it
7470
7470
let timeout;
@@ -8660,7 +8660,7 @@ fn test_htlc_no_detection() {
8660
8660
check_closed_broadcast!(nodes[0], true);
8661
8661
check_added_monitors!(nodes[0], 1);
8662
8662
check_closed_event!(nodes[0], 1, ClosureReason::CommitmentTxConfirmed);
8663
- connect_blocks(&nodes[0], TEST_FINAL_CLTV - 1 );
8663
+ connect_blocks(&nodes[0], TEST_FINAL_CLTV);
8664
8664
8665
8665
let htlc_timeout = {
8666
8666
let node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap();
@@ -9836,8 +9836,8 @@ fn test_non_final_funding_tx() {
9836
9836
assert_eq!(events.len(), 1);
9837
9837
let mut tx = match events[0] {
9838
9838
Event::FundingGenerationReady { ref channel_value_satoshis, ref output_script, .. } => {
9839
- // Timelock the transaction _beyond_ the best client height + 2 .
9840
- Transaction { version: chan_id as i32, lock_time: PackedLockTime(best_height + 3 ), input: vec![input], output: vec![TxOut {
9839
+ // Timelock the transaction _beyond_ the best client height + 1 .
9840
+ Transaction { version: chan_id as i32, lock_time: PackedLockTime(best_height + 2 ), input: vec![input], output: vec![TxOut {
9841
9841
value: *channel_value_satoshis, script_pubkey: output_script.clone(),
9842
9842
}]}
9843
9843
},
@@ -9851,7 +9851,7 @@ fn test_non_final_funding_tx() {
9851
9851
_ => panic!()
9852
9852
}
9853
9853
9854
- // However, transaction should be accepted if it's in a +2 headroom from best block.
9854
+ // However, transaction should be accepted if it's in a +1 headroom from best block.
9855
9855
tx.lock_time = PackedLockTime(tx.lock_time.0 - 1);
9856
9856
assert!(nodes[0].node.funding_transaction_generated(&temp_channel_id, &nodes[1].node.get_our_node_id(), tx.clone()).is_ok());
9857
9857
get_event_msg!(nodes[0], MessageSendEvent::SendFundingCreated, nodes[1].node.get_our_node_id());
0 commit comments