@@ -1283,20 +1283,39 @@ fn test_duplicate_htlc_different_direction_onchain() {
1283
1283
// Check we only broadcast 1 timeout tx
1284
1284
let claim_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().clone();
1285
1285
assert_eq!(claim_txn.len(), 8);
1286
- assert_eq!(claim_txn[1], claim_txn[4]);
1287
- assert_eq!(claim_txn[2], claim_txn[5]);
1286
+
1287
+ check_spends!(claim_txn[0], remote_txn[0]);
1288
+
1288
1289
check_spends!(claim_txn[1], chan_1.3);
1289
1290
check_spends!(claim_txn[2], claim_txn[1]);
1290
- check_spends!(claim_txn[7], claim_txn[1]);
1291
+
1292
+ let bump_tx = if claim_txn[1] == claim_txn[4] {
1293
+ assert_eq!(claim_txn[1], claim_txn[4]);
1294
+ assert_eq!(claim_txn[2], claim_txn[5]);
1295
+
1296
+ check_spends!(claim_txn[7], claim_txn[1]);
1297
+
1298
+ check_spends!(claim_txn[3], remote_txn[0]);
1299
+ &claim_txn[3]
1300
+ } else {
1301
+ assert_eq!(claim_txn[1], claim_txn[3]);
1302
+ assert_eq!(claim_txn[2], claim_txn[4]);
1303
+
1304
+ check_spends!(claim_txn[5], claim_txn[1]);
1305
+
1306
+ check_spends!(claim_txn[7], remote_txn[0]);
1307
+
1308
+ &claim_txn[7]
1309
+ };
1291
1310
1292
1311
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);
1312
+ assert_eq!(bump_tx .input.len(), 1);
1313
+ assert_eq!(claim_txn[0].input[0].previous_output, bump_tx .input[0].previous_output);
1295
1314
1296
1315
assert_eq!(claim_txn[0].input.len(), 1);
1297
1316
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
1317
assert_eq!(remote_txn[0].output[claim_txn[0].input[0].previous_output.vout as usize].value, 800);
1318
+
1300
1319
assert_eq!(claim_txn[6].input.len(), 1);
1301
1320
assert_eq!(claim_txn[6].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT); // HTLC 0 <--> 1, timeout tx
1302
1321
check_spends!(claim_txn[6], remote_txn[0]);
@@ -2351,7 +2370,8 @@ fn test_justice_tx() {
2351
2370
chanmon_cfgs[1].keys_manager.disable_revocation_policy_check = true;
2352
2371
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
2353
2372
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &user_cfgs);
2354
- let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
2373
+ let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
2374
+ *nodes[0].connect_style.borrow_mut() = ConnectStyle::FullBlockViaListen;
2355
2375
// Create some new channels:
2356
2376
let chan_5 = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
2357
2377
@@ -2583,7 +2603,7 @@ fn claim_htlc_outputs_single_tx() {
2583
2603
expect_payment_failed!(nodes[1], payment_hash_2, true);
2584
2604
2585
2605
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
2586
- assert_eq !(node_txn.len(), 9 );
2606
+ assert !(node_txn.len() == 9 || node_txn.len() == 10 );
2587
2607
// ChannelMonitor: justice tx revoked offered htlc, justice tx revoked received htlc, justice tx revoked to_local (3)
2588
2608
// ChannelManager: local commmitment + local HTLC-timeout (2)
2589
2609
// 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)
@@ -5283,21 +5303,30 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
5283
5303
let htlc_timeout_tx;
5284
5304
{ // Extract one of the two HTLC-Timeout transaction
5285
5305
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 );
5306
+ // ChannelMonitor: timeout tx * 2-or- 3, ChannelManager: local commitment tx
5307
+ assert !(node_txn.len() == 4 || node_txn.len() == 3 );
5288
5308
check_spends!(node_txn[0], chan_2.3);
5289
5309
5290
5310
check_spends!(node_txn[1], commitment_txn[0]);
5291
5311
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);
5312
+
5313
+ if node_txn.len() > 3 {
5314
+ check_spends!(node_txn[2], commitment_txn[0]);
5315
+ assert_eq!(node_txn[2].input.len(), 1);
5316
+ assert_eq!(node_txn[1].input[0].previous_output, node_txn[2].input[0].previous_output);
5317
+
5318
+ check_spends!(node_txn[3], commitment_txn[0]);
5319
+ assert_ne!(node_txn[1].input[0].previous_output, node_txn[3].input[0].previous_output);
5320
+ } else {
5321
+ check_spends!(node_txn[2], commitment_txn[0]);
5322
+ assert_ne!(node_txn[1].input[0].previous_output, node_txn[2].input[0].previous_output);
5323
+ }
5297
5324
5298
5325
assert_eq!(node_txn[1].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
5299
5326
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);
5327
+ if node_txn.len() > 3 {
5328
+ assert_eq!(node_txn[3].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT);
5329
+ }
5301
5330
htlc_timeout_tx = node_txn[1].clone();
5302
5331
}
5303
5332
@@ -7957,13 +7986,24 @@ fn test_bump_penalty_txn_on_remote_commitment() {
7957
7986
assert_eq!(node_txn[6].input.len(), 1);
7958
7987
check_spends!(node_txn[0], remote_txn[0]);
7959
7988
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
7989
7963
7990
check_spends!(node_txn[1], chan.3);
7964
7991
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]);
7992
+
7993
+ if node_txn[0].input[0].previous_output == node_txn[3].input[0].previous_output {
7994
+ preimage_bump = node_txn[3].clone();
7995
+ check_spends!(node_txn[3], remote_txn[0]);
7996
+
7997
+ assert_eq!(node_txn[1], node_txn[4]);
7998
+ assert_eq!(node_txn[2], node_txn[5]);
7999
+ } else {
8000
+ preimage_bump = node_txn[7].clone();
8001
+ check_spends!(node_txn[7], remote_txn[0]);
8002
+ assert_eq!(node_txn[0].input[0].previous_output, node_txn[7].input[0].previous_output);
8003
+
8004
+ assert_eq!(node_txn[1], node_txn[3]);
8005
+ assert_eq!(node_txn[2], node_txn[4]);
8006
+ }
7967
8007
7968
8008
timeout = node_txn[6].txid();
7969
8009
let index = node_txn[6].input[0].previous_output.vout;
0 commit comments