Skip to content

Commit aeabd67

Browse files
author
Antoine Riard
committed
Track HTLC-failure trigger tx until anti-reorg delay reached
Broadcasting a commitment tx means that we have to fail inbound HTLC in backward channel. Doing it prematurely would put us at risk in case of reorg. So we delay passing failure update upstream until solving tx mature to HTLC_FAIL_ANTI_ REORG_DELAY. Requirements differ if HTLC is a revoked/non-revoked dust/ non-revoked non-dust one. Add connect_blocks in test_utils to fix broken tests due to anti-reorg delay enforcement
1 parent 5764634 commit aeabd67

File tree

3 files changed

+89
-32
lines changed

3 files changed

+89
-32
lines changed

src/ln/channelmonitor.rs

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ impl<Key : Send + cmp::Eq + hash::Hash> ChainListener for SimpleManyChannelMonit
172172
// In case of reorg we may have htlc outputs solved in a different way so
173173
// we prefer to keep claims but don't store duplicate updates for a given
174174
// (payment_hash, HTLCSource) pair.
175-
// TODO: Note that we currently don't really use this as ChannelManager
176-
// will fail/claim backwards after the first block. We really should delay
177-
// a few blocks before failing backwards (but can claim backwards
178-
// immediately) as long as we have a few blocks of headroom.
179175
let mut existing_claim = false;
180176
e.get_mut().retain(|htlc_data| {
181177
if htlc.0 == htlc_data.0 {
@@ -299,7 +295,6 @@ pub(crate) const HTLC_FAIL_TIMEOUT_BLOCKS: u32 = 3;
299295
/// Number of blocks we wait on seeing a confirmed HTLC-Timeout or previous revoked commitment
300296
/// transaction before we fail corresponding inbound HTLCs. This prevents us from failing backwards
301297
/// and then getting a reorg resulting in us losing money.
302-
//TODO: We currently don't actually use this...we should
303298
pub(crate) const HTLC_FAIL_ANTI_REORG_DELAY: u32 = 6;
304299

305300
#[derive(Clone, PartialEq)]
@@ -385,6 +380,8 @@ pub struct ChannelMonitor {
385380

386381
destination_script: Script,
387382

383+
htlc_updated_waiting_threshold_conf: HashMap<u32, Vec<(HTLCSource, Option<PaymentPreimage>, PaymentHash)>>,
384+
388385
// We simply modify last_block_hash in Channel's block_connected so that serialization is
389386
// consistent but hopefully the users' copy handles block_connected in a consistent way.
390387
// (we do *not*, however, update them in insert_combine to ensure any local user copies keep
@@ -414,7 +411,8 @@ impl PartialEq for ChannelMonitor {
414411
self.current_remote_commitment_number != other.current_remote_commitment_number ||
415412
self.current_local_signed_commitment_tx != other.current_local_signed_commitment_tx ||
416413
self.payment_preimages != other.payment_preimages ||
417-
self.destination_script != other.destination_script
414+
self.destination_script != other.destination_script ||
415+
self.htlc_updated_waiting_threshold_conf != other.htlc_updated_waiting_threshold_conf
418416
{
419417
false
420418
} else {
@@ -464,6 +462,8 @@ impl ChannelMonitor {
464462
payment_preimages: HashMap::new(),
465463
destination_script: destination_script,
466464

465+
htlc_updated_waiting_threshold_conf: HashMap::new(),
466+
467467
last_block_hash: Default::default(),
468468
secp_ctx: Secp256k1::new(),
469469
logger,
@@ -951,6 +951,17 @@ impl ChannelMonitor {
951951
self.last_block_hash.write(writer)?;
952952
self.destination_script.write(writer)?;
953953

954+
writer.write_all(&byte_utils::be64_to_array(self.htlc_updated_waiting_threshold_conf.len() as u64))?;
955+
for (ref target, ref updates) in self.htlc_updated_waiting_threshold_conf.iter() {
956+
writer.write_all(&byte_utils::be32_to_array(**target))?;
957+
writer.write_all(&byte_utils::be64_to_array(updates.len() as u64))?;
958+
for ref update in updates.iter() {
959+
update.0.write(writer)?;
960+
update.1.write(writer)?;
961+
update.2.write(writer)?;
962+
}
963+
}
964+
954965
Ok(())
955966
}
956967

@@ -1014,13 +1025,12 @@ impl ChannelMonitor {
10141025
/// HTLC-Success/HTLC-Timeout transactions.
10151026
/// Return updates for HTLC pending in the channel and failed automatically by the broadcast of
10161027
/// revoked remote commitment tx
1017-
fn check_spend_remote_transaction(&mut self, tx: &Transaction, height: u32) -> (Vec<Transaction>, (Sha256dHash, Vec<TxOut>), Vec<SpendableOutputDescriptor>, Vec<(HTLCSource, Option<PaymentPreimage>, PaymentHash)>) {
1028+
fn check_spend_remote_transaction(&mut self, tx: &Transaction, height: u32) -> (Vec<Transaction>, (Sha256dHash, Vec<TxOut>), Vec<SpendableOutputDescriptor>) {
10181029
// Most secp and related errors trying to create keys means we have no hope of constructing
10191030
// a spend transaction...so we return no transactions to broadcast
10201031
let mut txn_to_broadcast = Vec::new();
10211032
let mut watch_outputs = Vec::new();
10221033
let mut spendable_outputs = Vec::new();
1023-
let mut htlc_updated = Vec::new();
10241034

10251035
let commitment_txid = tx.txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
10261036
let per_commitment_option = self.remote_claimable_outpoints.get(&commitment_txid);
@@ -1029,7 +1039,7 @@ impl ChannelMonitor {
10291039
( $thing : expr ) => {
10301040
match $thing {
10311041
Ok(a) => a,
1032-
Err(_) => return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs, htlc_updated)
1042+
Err(_) => return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs)
10331043
}
10341044
};
10351045
}
@@ -1054,7 +1064,7 @@ impl ChannelMonitor {
10541064
};
10551065
let delayed_key = ignore_error!(chan_utils::derive_public_key(&self.secp_ctx, &PublicKey::from_secret_key(&self.secp_ctx, &per_commitment_key), &self.their_delayed_payment_base_key.unwrap()));
10561066
let a_htlc_key = match self.their_htlc_base_key {
1057-
None => return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs, htlc_updated),
1067+
None => return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs),
10581068
Some(their_htlc_base_key) => ignore_error!(chan_utils::derive_public_key(&self.secp_ctx, &PublicKey::from_secret_key(&self.secp_ctx, &per_commitment_key), &their_htlc_base_key)),
10591069
};
10601070

@@ -1134,7 +1144,7 @@ impl ChannelMonitor {
11341144
if transaction_output_index as usize >= tx.output.len() ||
11351145
tx.output[transaction_output_index as usize].value != htlc.amount_msat / 1000 ||
11361146
tx.output[transaction_output_index as usize].script_pubkey != expected_script.to_v0_p2wsh() {
1137-
return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs, htlc_updated); // Corrupted per_commitment_data, fuck this user
1147+
return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs); // Corrupted per_commitment_data, fuck this user
11381148
}
11391149
let input = TxIn {
11401150
previous_output: BitcoinOutPoint {
@@ -1174,16 +1184,20 @@ impl ChannelMonitor {
11741184
watch_outputs.append(&mut tx.output.clone());
11751185
self.remote_commitment_txn_on_chain.insert(commitment_txid, (commitment_number, tx.output.iter().map(|output| { output.script_pubkey.clone() }).collect()));
11761186

1177-
// TODO: We really should only fail backwards after our revocation claims have been
1178-
// confirmed, but we also need to do more other tracking of in-flight pre-confirm
1179-
// on-chain claims, so we can do that at the same time.
11801187
macro_rules! check_htlc_fails {
11811188
($txid: expr, $commitment_tx: expr) => {
11821189
if let Some(ref outpoints) = self.remote_claimable_outpoints.get(&$txid) {
11831190
for &(ref htlc, ref source_option) in outpoints.iter() {
11841191
if let &Some(ref source) = source_option {
1185-
log_trace!(self, "Failing HTLC with payment_hash {} from {} remote commitment tx due to broadcast of revoked remote commitment transaction", log_bytes!(htlc.payment_hash.0), $commitment_tx);
1186-
htlc_updated.push(((**source).clone(), None, htlc.payment_hash.clone()));
1192+
log_trace!(self, "Failing HTLC with payment_hash {} from {} remote commitment tx due to broadcast of revoked remote commitment transaction, waiting confirmation until {} height", log_bytes!(htlc.payment_hash.0), $commitment_tx, height + HTLC_FAIL_ANTI_REORG_DELAY - 1);
1193+
match self.htlc_updated_waiting_threshold_conf.entry(height + HTLC_FAIL_ANTI_REORG_DELAY - 1) {
1194+
hash_map::Entry::Occupied(mut entry) => {
1195+
entry.get_mut().push(((**source).clone(), None, htlc.payment_hash.clone()));
1196+
}
1197+
hash_map::Entry::Vacant(entry) => {
1198+
entry.insert(vec![((**source).clone(), None, htlc.payment_hash.clone())]);
1199+
}
1200+
}
11871201
}
11881202
}
11891203
}
@@ -1199,7 +1213,7 @@ impl ChannelMonitor {
11991213
}
12001214
// No need to check local commitment txn, symmetric HTLCSource must be present as per-htlc data on remote commitment tx
12011215
}
1202-
if inputs.is_empty() { return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs, htlc_updated); } // Nothing to be done...probably a false positive/local tx
1216+
if inputs.is_empty() { return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs); } // Nothing to be done...probably a false positive/local tx
12031217

12041218
let outputs = vec!(TxOut {
12051219
script_pubkey: self.destination_script.clone(),
@@ -1238,9 +1252,6 @@ impl ChannelMonitor {
12381252

12391253
log_trace!(self, "Got broadcast of non-revoked remote commitment transaction {}", commitment_txid);
12401254

1241-
// TODO: We really should only fail backwards after our revocation claims have been
1242-
// confirmed, but we also need to do more other tracking of in-flight pre-confirm
1243-
// on-chain claims, so we can do that at the same time.
12441255
macro_rules! check_htlc_fails {
12451256
($txid: expr, $commitment_tx: expr, $id: tt) => {
12461257
if let Some(ref latest_outpoints) = self.remote_claimable_outpoints.get(&$txid) {
@@ -1261,7 +1272,14 @@ impl ChannelMonitor {
12611272
}
12621273
}
12631274
log_trace!(self, "Failing HTLC with payment_hash {} from {} remote commitment tx due to broadcast of remote commitment transaction", log_bytes!(htlc.payment_hash.0), $commitment_tx);
1264-
htlc_updated.push(((**source).clone(), None, htlc.payment_hash.clone()));
1275+
match self.htlc_updated_waiting_threshold_conf.entry(height + HTLC_FAIL_ANTI_REORG_DELAY - 1) {
1276+
hash_map::Entry::Occupied(mut entry) => {
1277+
entry.get_mut().push(((**source).clone(), None, htlc.payment_hash.clone()));
1278+
}
1279+
hash_map::Entry::Vacant(entry) => {
1280+
entry.insert(vec![((**source).clone(), None, htlc.payment_hash.clone())]);
1281+
}
1282+
}
12651283
}
12661284
}
12671285
}
@@ -1294,7 +1312,7 @@ impl ChannelMonitor {
12941312
},
12951313
};
12961314
let a_htlc_key = match self.their_htlc_base_key {
1297-
None => return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs, htlc_updated),
1315+
None => return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs),
12981316
Some(their_htlc_base_key) => ignore_error!(chan_utils::derive_public_key(&self.secp_ctx, revocation_point, &their_htlc_base_key)),
12991317
};
13001318

@@ -1349,7 +1367,7 @@ impl ChannelMonitor {
13491367
if transaction_output_index as usize >= tx.output.len() ||
13501368
tx.output[transaction_output_index as usize].value != htlc.amount_msat / 1000 ||
13511369
tx.output[transaction_output_index as usize].script_pubkey != expected_script.to_v0_p2wsh() {
1352-
return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs, htlc_updated); // Corrupted per_commitment_data, fuck this user
1370+
return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs); // Corrupted per_commitment_data, fuck this user
13531371
}
13541372
if let Some(payment_preimage) = self.payment_preimages.get(&htlc.payment_hash) {
13551373
let input = TxIn {
@@ -1412,7 +1430,7 @@ impl ChannelMonitor {
14121430
}
14131431
}
14141432

1415-
if inputs.is_empty() { return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs, htlc_updated); } // Nothing to be done...probably a false positive/local tx
1433+
if inputs.is_empty() { return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs); } // Nothing to be done...probably a false positive/local tx
14161434

14171435
let outputs = vec!(TxOut {
14181436
script_pubkey: self.destination_script.clone(),
@@ -1442,7 +1460,7 @@ impl ChannelMonitor {
14421460
}
14431461
}
14441462

1445-
(txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs, htlc_updated)
1463+
(txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs)
14461464
}
14471465

14481466
/// Attempts to claim a remote HTLC-Success/HTLC-Timeout's outputs using the revocation key
@@ -1714,7 +1732,7 @@ impl ChannelMonitor {
17141732
}
17151733
};
17161734
if funding_txo.is_none() || (prevout.txid == funding_txo.as_ref().unwrap().0.txid && prevout.vout == funding_txo.as_ref().unwrap().0.index as u32) {
1717-
let (remote_txn, new_outputs, mut spendable_output, mut updated) = self.check_spend_remote_transaction(tx, height);
1735+
let (remote_txn, new_outputs, mut spendable_output) = self.check_spend_remote_transaction(tx, height);
17181736
txn = remote_txn;
17191737
spendable_outputs.append(&mut spendable_output);
17201738
if !new_outputs.1.is_empty() {
@@ -1733,9 +1751,6 @@ impl ChannelMonitor {
17331751
spendable_outputs.push(spendable_output);
17341752
}
17351753
}
1736-
if updated.len() > 0 {
1737-
htlc_updated.append(&mut updated);
1738-
}
17391754
} else {
17401755
if let Some(&(commitment_number, _)) = self.remote_commitment_txn_on_chain.get(&prevout.txid) {
17411756
let (tx, spendable_output) = self.check_spend_remote_htlc(tx, commitment_number);
@@ -1786,6 +1801,12 @@ impl ChannelMonitor {
17861801
}
17871802
}
17881803
}
1804+
if let Some(updates) = self.htlc_updated_waiting_threshold_conf.remove(&height) {
1805+
for update in updates {
1806+
log_trace!(self, "HTLC {} failure update has get enough confirmation to be pass upstream", log_bytes!((update.2).0));
1807+
htlc_updated.push(update);
1808+
}
1809+
}
17891810
self.last_block_hash = block_hash.clone();
17901811
(watch_outputs, spendable_outputs, htlc_updated)
17911812
}
@@ -2159,6 +2180,21 @@ impl<R: ::std::io::Read> ReadableArgs<R, Arc<Logger>> for (Sha256dHash, ChannelM
21592180
let last_block_hash: Sha256dHash = Readable::read(reader)?;
21602181
let destination_script = Readable::read(reader)?;
21612182

2183+
let waiting_threshold_conf_len: u64 = Readable::read(reader)?;
2184+
let mut htlc_updated_waiting_threshold_conf = HashMap::with_capacity(cmp::min(waiting_threshold_conf_len as usize, MAX_ALLOC_SIZE / 128));
2185+
for _ in 0..waiting_threshold_conf_len {
2186+
let height_target = Readable::read(reader)?;
2187+
let updates_len: u64 = Readable::read(reader)?;
2188+
let mut updates = Vec::with_capacity(cmp::min(updates_len as usize, MAX_ALLOC_SIZE / 128));
2189+
for _ in 0..updates_len {
2190+
let htlc_source = Readable::read(reader)?;
2191+
let preimage = Readable::read(reader)?;
2192+
let hash = Readable::read(reader)?;
2193+
updates.push((htlc_source, preimage, hash));
2194+
}
2195+
htlc_updated_waiting_threshold_conf.insert(height_target, updates);
2196+
}
2197+
21622198
Ok((last_block_hash.clone(), ChannelMonitor {
21632199
commitment_transaction_number_obscure_factor,
21642200

@@ -2182,6 +2218,9 @@ impl<R: ::std::io::Read> ReadableArgs<R, Arc<Logger>> for (Sha256dHash, ChannelM
21822218
payment_preimages,
21832219

21842220
destination_script,
2221+
2222+
htlc_updated_waiting_threshold_conf,
2223+
21852224
last_block_hash,
21862225
secp_ctx,
21872226
logger,

src/ln/functional_test_utils.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use util::errors::APIError;
1414
use util::logger::Logger;
1515
use util::config::UserConfig;
1616

17-
use bitcoin::util::hash::BitcoinHash;
17+
use bitcoin::util::hash::{BitcoinHash, Sha256dHash};
1818
use bitcoin::blockdata::block::BlockHeader;
1919
use bitcoin::blockdata::transaction::{Transaction, TxOut};
2020
use bitcoin::network::constants::Network;
@@ -46,6 +46,15 @@ pub fn confirm_transaction(chain: &chaininterface::ChainWatchInterfaceUtil, tx:
4646
}
4747
}
4848

49+
pub fn connect_blocks(chain: &chaininterface::ChainWatchInterfaceUtil, depth: u32, height: u32, parent: bool, prev_blockhash: Sha256dHash) {
50+
let mut header = BlockHeader { version: 0x2000000, prev_blockhash: if parent { prev_blockhash } else { Default::default() }, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
51+
chain.block_connected_checked(&header, height + 1, &Vec::new(), &Vec::new());
52+
for i in 2..depth {
53+
header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
54+
chain.block_connected_checked(&header, height + i, &Vec::new(), &Vec::new());
55+
}
56+
}
57+
4958
pub struct Node {
5059
pub chain_monitor: Arc<chaininterface::ChainWatchInterfaceUtil>,
5160
pub tx_broadcaster: Arc<test_utils::TestBroadcaster>,

src/ln/functional_tests.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use chain::keysinterface::{KeysInterface, SpendableOutputDescriptor};
88
use chain::keysinterface;
99
use ln::channel::{COMMITMENT_TX_BASE_WEIGHT, COMMITMENT_TX_WEIGHT_PER_HTLC, BREAKDOWN_TIMEOUT};
1010
use ln::channelmanager::{ChannelManager,ChannelManagerReadArgs,HTLCForwardInfo,RAACommitmentOrder, PaymentPreimage, PaymentHash};
11-
use ln::channelmonitor::{ChannelMonitor, CLTV_CLAIM_BUFFER, HTLC_FAIL_TIMEOUT_BLOCKS, ManyChannelMonitor};
11+
use ln::channelmonitor::{ChannelMonitor, CLTV_CLAIM_BUFFER, HTLC_FAIL_TIMEOUT_BLOCKS, ManyChannelMonitor, HTLC_FAIL_ANTI_REORG_DELAY};
1212
use ln::channel::{ACCEPTED_HTLC_SCRIPT_WEIGHT, OFFERED_HTLC_SCRIPT_WEIGHT};
1313
use ln::onion_utils;
1414
use ln::router::{Route, RouteHop};
@@ -1723,6 +1723,7 @@ fn claim_htlc_outputs_shared_tx() {
17231723
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
17241724
nodes[0].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
17251725
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
1726+
connect_blocks(&nodes[1].chain_monitor, HTLC_FAIL_ANTI_REORG_DELAY, 1, true, header.bitcoin_hash());
17261727

17271728
let events = nodes[1].node.get_and_clear_pending_events();
17281729
assert_eq!(events.len(), 1);
@@ -1790,6 +1791,7 @@ fn claim_htlc_outputs_single_tx() {
17901791
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
17911792
nodes[0].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 200);
17921793
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 200);
1794+
connect_blocks(&nodes[1].chain_monitor, HTLC_FAIL_ANTI_REORG_DELAY, 200, true, header.bitcoin_hash());
17931795

17941796
let events = nodes[1].node.get_and_clear_pending_events();
17951797
assert_eq!(events.len(), 1);
@@ -1801,7 +1803,7 @@ fn claim_htlc_outputs_single_tx() {
18011803
}
18021804

18031805
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
1804-
assert_eq!(node_txn.len(), 12); // ChannelManager : 2, ChannelMontitor: 8 (1 standard revoked output, 2 revocation htlc tx, 1 local commitment tx + 1 htlc timeout tx) * 2 (block-rescan)
1806+
assert_eq!(node_txn.len(), 22); // ChannelManager : 2, ChannelMontitor: 8 (1 standard revoked output, 2 revocation htlc tx, 1 local commitment tx + 1 htlc timeout tx) * 2 (block-rescan) + 5 * (1 local commitment tx + 1 htlc timeout tx)
18051807

18061808
assert_eq!(node_txn[0], node_txn[7]);
18071809
assert_eq!(node_txn[1], node_txn[8]);
@@ -1811,6 +1813,10 @@ fn claim_htlc_outputs_single_tx() {
18111813
assert_eq!(node_txn[3], node_txn[5]); //local commitment tx + htlc timeout tx broadcasted by ChannelManger
18121814
assert_eq!(node_txn[4], node_txn[6]);
18131815

1816+
for i in 12..22 {
1817+
if i % 2 == 0 { assert_eq!(node_txn[3], node_txn[i]); } else { assert_eq!(node_txn[4], node_txn[i]); }
1818+
}
1819+
18141820
assert_eq!(node_txn[0].input.len(), 1);
18151821
assert_eq!(node_txn[1].input.len(), 1);
18161822
assert_eq!(node_txn[2].input.len(), 1);
@@ -2145,6 +2151,7 @@ fn test_simple_commitment_revoked_fail_backward() {
21452151

21462152
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42};
21472153
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
2154+
connect_blocks(&nodes[1].chain_monitor, HTLC_FAIL_ANTI_REORG_DELAY, 1, true, header.bitcoin_hash());
21482155
check_added_monitors!(nodes[1], 0);
21492156
check_closed_broadcast!(nodes[1]);
21502157

@@ -2297,6 +2304,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive(deliver_bs_raa: bool, use
22972304

22982305
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42};
22992306
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
2307+
connect_blocks(&nodes[1].chain_monitor, HTLC_FAIL_ANTI_REORG_DELAY, 1, true, header.bitcoin_hash());
23002308

23012309
let events = nodes[1].node.get_and_clear_pending_events();
23022310
assert_eq!(events.len(), if deliver_bs_raa { 1 } else { 2 });
@@ -3958,6 +3966,7 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno
39583966
} else {
39593967
nodes[2].chain_monitor.block_connected_checked(&header, 1, &[&ds_prev_commitment_tx[0]], &[1; 1]);
39603968
}
3969+
connect_blocks(&nodes[2].chain_monitor, HTLC_FAIL_ANTI_REORG_DELAY, 1, true, header.bitcoin_hash());
39613970
check_closed_broadcast!(nodes[2]);
39623971
expect_pending_htlcs_forwardable!(nodes[2]);
39633972
check_added_monitors!(nodes[2], 2);

0 commit comments

Comments
 (0)