Skip to content

Commit 897a1ab

Browse files
committed
ChannelMonitor::get_funding_txo returns both the txid and scriptPK
... instead of only the txid. This is another instance of it not being possible to fully re-implement SimpleManyChannelMonitor using only public methods. In this case you couldn't properly register outpoints for monitoring so that the funding transaction would be matched.
1 parent 9be497c commit 897a1ab

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
22742274
};
22752275
// Because we have exclusive ownership of the channel here we can release the channel_state
22762276
// lock before add_monitor
2277-
if let Err(e) = self.monitor.add_monitor(monitor_update.get_funding_txo(), monitor_update) {
2277+
if let Err(e) = self.monitor.add_monitor(monitor_update.get_funding_txo().0, monitor_update) {
22782278
match e {
22792279
ChannelMonitorUpdateErr::PermanentFailure => {
22802280
// Note that we reply with the new channel_id in error messages if we gave up on the

lightning/src/ln/channelmonitor.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,15 @@ impl<Key : Send + cmp::Eq + hash::Hash + 'static, ChanSigner: ChannelKeys, T: De
235235
hash_map::Entry::Occupied(_) => return Err(MonitorUpdateError("Channel monitor for given key is already present")),
236236
hash_map::Entry::Vacant(e) => e,
237237
};
238-
log_trace!(self.logger, "Got new Channel Monitor for channel {}", log_bytes!(monitor.funding_info.0.to_channel_id()[..]));
239-
self.chain_monitor.install_watch_tx(&monitor.funding_info.0.txid, &monitor.funding_info.1);
240-
self.chain_monitor.install_watch_outpoint((monitor.funding_info.0.txid, monitor.funding_info.0.index as u32), &monitor.funding_info.1);
241-
for (txid, outputs) in monitor.get_outputs_to_watch().iter() {
242-
for (idx, script) in outputs.iter().enumerate() {
243-
self.chain_monitor.install_watch_outpoint((*txid, idx as u32), script);
238+
{
239+
let funding_txo = monitor.get_funding_txo();
240+
log_trace!(self.logger, "Got new Channel Monitor for channel {}", log_bytes!(funding_txo.0.to_channel_id()[..]));
241+
self.chain_monitor.install_watch_tx(&funding_txo.0.txid, &funding_txo.1);
242+
self.chain_monitor.install_watch_outpoint((funding_txo.0.txid, funding_txo.0.index as u32), &funding_txo.1);
243+
for (txid, outputs) in monitor.get_outputs_to_watch().iter() {
244+
for (idx, script) in outputs.iter().enumerate() {
245+
self.chain_monitor.install_watch_outpoint((*txid, idx as u32), script);
246+
}
244247
}
245248
}
246249
entry.insert(monitor);
@@ -1408,8 +1411,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
14081411
}
14091412

14101413
/// Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
1411-
pub fn get_funding_txo(&self) -> OutPoint {
1412-
self.funding_info.0
1414+
pub fn get_funding_txo(&self) -> &(OutPoint, Script) {
1415+
&self.funding_info
14131416
}
14141417

14151418
/// Gets a list of txids, with their output scripts (in the order they appear in the

0 commit comments

Comments
 (0)