Skip to content

Commit 826233e

Browse files
author
Antoine Riard
committed
Add tracking of outputs from our local commitment tx to detect onchain
resolution of channel Modifiy in consequence test_txn_broadcast to still pass channel_monitor_network test
1 parent 84953fc commit 826233e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3809,7 +3809,7 @@ mod tests {
38093809
false
38103810
} else { true }
38113811
});
3812-
assert_eq!(res.len(), 2);
3812+
assert!(res.len() >= 2);
38133813
}
38143814

38153815
assert!(node_txn.is_empty());

src/ln/channelmonitor.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,19 +1136,19 @@ impl ChannelMonitor {
11361136
/// Attempts to claim any claimable HTLCs in a commitment transaction which was not (yet)
11371137
/// revoked using data in local_claimable_outpoints.
11381138
/// Should not be used if check_spend_revoked_transaction succeeds.
1139-
fn check_spend_local_transaction(&self, tx: &Transaction, _height: u32) -> Vec<Transaction> {
1139+
fn check_spend_local_transaction(&self, tx: &Transaction, _height: u32) -> (Vec<Transaction>, (Sha256dHash, Vec<TxOut>)) {
11401140
let commitment_txid = tx.txid();
11411141
if let &Some(ref local_tx) = &self.current_local_signed_commitment_tx {
11421142
if local_tx.txid == commitment_txid {
1143-
return self.broadcast_by_local_state(local_tx);
1143+
return (self.broadcast_by_local_state(local_tx), (commitment_txid, tx.output.clone()))
11441144
}
11451145
}
11461146
if let &Some(ref local_tx) = &self.prev_local_signed_commitment_tx {
11471147
if local_tx.txid == commitment_txid {
1148-
return self.broadcast_by_local_state(local_tx);
1148+
return (self.broadcast_by_local_state(local_tx), (commitment_txid, tx.output.clone()))
11491149
}
11501150
}
1151-
Vec::new()
1151+
(Vec::new(), (commitment_txid, Vec::new()))
11521152
}
11531153

11541154
fn block_connected(&self, txn_matched: &[&Transaction], height: u32, broadcaster: &BroadcasterInterface)-> Vec<(Sha256dHash, Vec<TxOut>)> {
@@ -1168,7 +1168,11 @@ impl ChannelMonitor {
11681168
watch_outputs.push(new_outputs);
11691169
}
11701170
if txn.is_empty() {
1171-
txn = self.check_spend_local_transaction(tx, height);
1171+
let (local_txn, new_outputs) = self.check_spend_local_transaction(tx, height);
1172+
txn = local_txn;
1173+
if !new_outputs.1.is_empty() {
1174+
watch_outputs.push(new_outputs);
1175+
}
11721176
}
11731177
} else {
11741178
let remote_commitment_txn_on_chain = self.remote_commitment_txn_on_chain.lock().unwrap();

0 commit comments

Comments
 (0)