@@ -1280,23 +1280,41 @@ fn test_duplicate_htlc_different_direction_onchain() {
1280
1280
check_closed_event!(nodes[0], 1, ClosureReason::CommitmentTxConfirmed);
1281
1281
connect_blocks(&nodes[0], TEST_FINAL_CLTV - 1); // Confirm blocks until the HTLC expires
1282
1282
1283
- // Check we only broadcast 1 timeout tx
1284
1283
let claim_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().clone();
1285
1284
assert_eq!(claim_txn.len(), 8);
1286
- assert_eq!(claim_txn[1], claim_txn[4]);
1287
- assert_eq!(claim_txn[2], claim_txn[5]);
1288
- check_spends!(claim_txn[1], chan_1.3);
1289
- check_spends!(claim_txn[2], claim_txn[1]);
1290
- check_spends!(claim_txn[7], claim_txn[1]);
1285
+
1286
+ check_spends!(claim_txn[0], remote_txn[0]); // Immediate HTLC claim with preimage
1287
+
1288
+ check_spends!(claim_txn[1], chan_1.3); // Alternative commitment tx
1289
+ check_spends!(claim_txn[2], claim_txn[1]); // HTLC spend in alternative commitment tx
1290
+
1291
+ let bump_tx = if claim_txn[1] == claim_txn[4] {
1292
+ assert_eq!(claim_txn[1], claim_txn[4]);
1293
+ assert_eq!(claim_txn[2], claim_txn[5]);
1294
+
1295
+ check_spends!(claim_txn[7], claim_txn[1]); // HTLC timeout on alternative commitment tx
1296
+
1297
+ check_spends!(claim_txn[3], remote_txn[0]); // HTLC timeout on broadcasted commitment tx
1298
+ &claim_txn[3]
1299
+ } else {
1300
+ assert_eq!(claim_txn[1], claim_txn[3]);
1301
+ assert_eq!(claim_txn[2], claim_txn[4]);
1302
+
1303
+ check_spends!(claim_txn[5], claim_txn[1]); // HTLC timeout on alternative commitment tx
1304
+
1305
+ check_spends!(claim_txn[7], remote_txn[0]); // HTLC timeout on broadcasted commitment tx
1306
+
1307
+ &claim_txn[7]
1308
+ };
1291
1309
1292
1310
assert_eq!(claim_txn[0].input.len(), 1);
1293
- assert_eq!(claim_txn[3] .input.len(), 1);
1294
- assert_eq!(claim_txn[0].input[0].previous_output, claim_txn[3] .input[0].previous_output);
1311
+ assert_eq!(bump_tx .input.len(), 1);
1312
+ assert_eq!(claim_txn[0].input[0].previous_output, bump_tx .input[0].previous_output);
1295
1313
1296
1314
assert_eq!(claim_txn[0].input.len(), 1);
1297
1315
assert_eq!(claim_txn[0].input[0].witness.last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT); // HTLC 1 <--> 0, preimage tx
1298
- check_spends!(claim_txn[0], remote_txn[0]);
1299
1316
assert_eq!(remote_txn[0].output[claim_txn[0].input[0].previous_output.vout as usize].value, 800);
1317
+
1300
1318
assert_eq!(claim_txn[6].input.len(), 1);
1301
1319
assert_eq!(claim_txn[6].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT); // HTLC 0 <--> 1, timeout tx
1302
1320
check_spends!(claim_txn[6], remote_txn[0]);
@@ -2351,7 +2369,8 @@ fn test_justice_tx() {
2351
2369
chanmon_cfgs[1].keys_manager.disable_revocation_policy_check = true;
2352
2370
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
2353
2371
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &user_cfgs);
2354
- let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
2372
+ let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
2373
+ *nodes[0].connect_style.borrow_mut() = ConnectStyle::FullBlockViaListen;
2355
2374
// Create some new channels:
2356
2375
let chan_5 = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
2357
2376
@@ -2583,11 +2602,7 @@ fn claim_htlc_outputs_single_tx() {
2583
2602
expect_payment_failed!(nodes[1], payment_hash_2, true);
2584
2603
2585
2604
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
2586
- assert_eq!(node_txn.len(), 9);
2587
- // ChannelMonitor: justice tx revoked offered htlc, justice tx revoked received htlc, justice tx revoked to_local (3)
2588
- // ChannelManager: local commmitment + local HTLC-timeout (2)
2589
- // ChannelMonitor: bumped justice tx, after one increase, bumps on HTLC aren't generated not being substantial anymore, bump on revoked to_local isn't generated due to more room for expiration (2)
2590
- // ChannelMonitor: local commitment + local HTLC-timeout (2)
2605
+ assert!(node_txn.len() == 9 || node_txn.len() == 10);
2591
2606
2592
2607
// Check the pair local commitment and HTLC-timeout broadcast due to HTLC expiration
2593
2608
assert_eq!(node_txn[0].input.len(), 1);
@@ -5283,21 +5298,30 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
5283
5298
let htlc_timeout_tx;
5284
5299
{ // Extract one of the two HTLC-Timeout transaction
5285
5300
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
5286
- // ChannelMonitor: timeout tx * 3, ChannelManager: local commitment tx
5287
- assert_eq !(node_txn.len(), 4 );
5301
+ // ChannelMonitor: timeout tx * 2-or- 3, ChannelManager: local commitment tx
5302
+ assert !(node_txn.len() == 4 || node_txn.len() == 3 );
5288
5303
check_spends!(node_txn[0], chan_2.3);
5289
5304
5290
5305
check_spends!(node_txn[1], commitment_txn[0]);
5291
5306
assert_eq!(node_txn[1].input.len(), 1);
5292
- check_spends!(node_txn[2], commitment_txn[0]);
5293
- assert_eq!(node_txn[2].input.len(), 1);
5294
- assert_eq!(node_txn[1].input[0].previous_output, node_txn[2].input[0].previous_output);
5295
- check_spends!(node_txn[3], commitment_txn[0]);
5296
- assert_ne!(node_txn[1].input[0].previous_output, node_txn[3].input[0].previous_output);
5307
+
5308
+ if node_txn.len() > 3 {
5309
+ check_spends!(node_txn[2], commitment_txn[0]);
5310
+ assert_eq!(node_txn[2].input.len(), 1);
5311
+ assert_eq!(node_txn[1].input[0].previous_output, node_txn[2].input[0].previous_output);
5312
+
5313
+ check_spends!(node_txn[3], commitment_txn[0]);
5314
+ assert_ne!(node_txn[1].input[0].previous_output, node_txn[3].input[0].previous_output);
5315
+ } else {
5316
+ check_spends!(node_txn[2], commitment_txn[0]);
5317
+ assert_ne!(node_txn[1].input[0].previous_output, node_txn[2].input[0].previous_output);
5318
+ }
5297
5319
5298
5320
assert_eq!(node_txn[1].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
5299
5321
assert_eq!(node_txn[2].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
5300
- assert_eq!(node_txn[3].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
5322
+ if node_txn.len() > 3 {
5323
+ assert_eq!(node_txn[3].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
5324
+ }
5301
5325
htlc_timeout_tx = node_txn[1].clone();
5302
5326
}
5303
5327
@@ -7957,13 +7981,24 @@ fn test_bump_penalty_txn_on_remote_commitment() {
7957
7981
assert_eq!(node_txn[6].input.len(), 1);
7958
7982
check_spends!(node_txn[0], remote_txn[0]);
7959
7983
check_spends!(node_txn[6], remote_txn[0]);
7960
- assert_eq!(node_txn[0].input[0].previous_output, node_txn[3].input[0].previous_output);
7961
- preimage_bump = node_txn[3].clone();
7962
7984
7963
7985
check_spends!(node_txn[1], chan.3);
7964
7986
check_spends!(node_txn[2], node_txn[1]);
7965
- assert_eq!(node_txn[1], node_txn[4]);
7966
- assert_eq!(node_txn[2], node_txn[5]);
7987
+
7988
+ if node_txn[0].input[0].previous_output == node_txn[3].input[0].previous_output {
7989
+ preimage_bump = node_txn[3].clone();
7990
+ check_spends!(node_txn[3], remote_txn[0]);
7991
+
7992
+ assert_eq!(node_txn[1], node_txn[4]);
7993
+ assert_eq!(node_txn[2], node_txn[5]);
7994
+ } else {
7995
+ preimage_bump = node_txn[7].clone();
7996
+ check_spends!(node_txn[7], remote_txn[0]);
7997
+ assert_eq!(node_txn[0].input[0].previous_output, node_txn[7].input[0].previous_output);
7998
+
7999
+ assert_eq!(node_txn[1], node_txn[3]);
8000
+ assert_eq!(node_txn[2], node_txn[4]);
8001
+ }
7967
8002
7968
8003
timeout = node_txn[6].txid();
7969
8004
let index = node_txn[6].input[0].previous_output.vout;
0 commit comments