Skip to content

Commit 48825e0

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 92ff499 commit 48825e0

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
@@ -3193,7 +3193,7 @@ mod tests {
31933193
false
31943194
} else { true }
31953195
});
3196-
assert_eq!(res.len(), 2);
3196+
assert!(res.len() >= 2);
31973197
}
31983198

31993199
assert!(node_txn.is_empty());

src/ln/channelmonitor.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,19 +1124,19 @@ impl ChannelMonitor {
11241124
/// Attempts to claim any claimable HTLCs in a commitment transaction which was not (yet)
11251125
/// revoked using data in local_claimable_outpoints.
11261126
/// Should not be used if check_spend_revoked_transaction succeeds.
1127-
fn check_spend_local_transaction(&self, tx: &Transaction, _height: u32) -> Vec<Transaction> {
1127+
fn check_spend_local_transaction(&self, tx: &Transaction, _height: u32) -> (Vec<Transaction>, (Sha256dHash, Vec<TxOut>)) {
11281128
let commitment_txid = tx.txid();
11291129
if let &Some(ref local_tx) = &self.current_local_signed_commitment_tx {
11301130
if local_tx.txid == commitment_txid {
1131-
return self.broadcast_by_local_state(local_tx);
1131+
return (self.broadcast_by_local_state(local_tx), (commitment_txid, tx.output.clone()))
11321132
}
11331133
}
11341134
if let &Some(ref local_tx) = &self.prev_local_signed_commitment_tx {
11351135
if local_tx.txid == commitment_txid {
1136-
return self.broadcast_by_local_state(local_tx);
1136+
return (self.broadcast_by_local_state(local_tx), (commitment_txid, tx.output.clone()))
11371137
}
11381138
}
1139-
Vec::new()
1139+
(Vec::new(), (commitment_txid, Vec::new()))
11401140
}
11411141

11421142
fn block_connected(&self, txn_matched: &[&Transaction], height: u32, broadcaster: &BroadcasterInterface)-> Vec<(Sha256dHash, Vec<TxOut>)> {
@@ -1156,7 +1156,11 @@ impl ChannelMonitor {
11561156
watch_outputs.push(new_outputs);
11571157
}
11581158
if txn.is_empty() {
1159-
txn = self.check_spend_local_transaction(tx, height);
1159+
let (local_txn, new_outputs) = self.check_spend_local_transaction(tx, height);
1160+
txn = local_txn;
1161+
if !new_outputs.1.is_empty() {
1162+
watch_outputs.push(new_outputs);
1163+
}
11601164
}
11611165
} else {
11621166
let remote_commitment_txn_on_chain = self.remote_commitment_txn_on_chain.lock().unwrap();

0 commit comments

Comments
 (0)