Skip to content

Commit d1ff8eb

Browse files
author
Antoine Riard
committed
Add is_resolving_output in ChannelMonitor
Called in ChannelMonitor to block_connected, returning pending_htlc_updated upstream
1 parent 98d964c commit d1ff8eb

File tree

5 files changed

+328
-68
lines changed

5 files changed

+328
-68
lines changed

src/ln/channel.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ impl Channel {
18561856
/// waiting on this revoke_and_ack. The generation of this new commitment_signed may also fail,
18571857
/// generating an appropriate error *after* the channel state has been updated based on the
18581858
/// revoke_and_ack message.
1859-
pub fn revoke_and_ack(&mut self, msg: &msgs::RevokeAndACK, fee_estimator: &FeeEstimator) -> Result<(Option<msgs::CommitmentUpdate>, Vec<(PendingForwardHTLCInfo, u64)>, Vec<(HTLCSource, [u8; 32], HTLCFailReason)>, Option<msgs::ClosingSigned>, ChannelMonitor), HandleError> {
1859+
pub fn revoke_and_ack(&mut self, msg: &msgs::RevokeAndACK, fee_estimator: &FeeEstimator) -> Result<(Option<msgs::CommitmentUpdate>, Vec<(PendingForwardHTLCInfo, u64)>, Vec<(HTLCSource, [u8; 32], HTLCFailReason)>, Option<msgs::ClosingSigned>, ChannelMonitor, OutPoint), HandleError> {
18601860
if (self.channel_state & (ChannelState::ChannelFunded as u32)) != (ChannelState::ChannelFunded as u32) {
18611861
return Err(HandleError{err: "Got revoke/ACK message when channel was not in an operational state", action: None});
18621862
}
@@ -1895,6 +1895,7 @@ impl Channel {
18951895
let mut update_fail_malformed_htlcs = Vec::new();
18961896
let mut require_commitment = false;
18971897
let mut value_to_self_msat_diff: i64 = 0;
1898+
let funding_txo = self.channel_monitor.get_funding_txo().unwrap();
18981899
// We really shouldnt have two passes here, but retain gives a non-mutable ref (Rust bug)
18991900
self.pending_inbound_htlcs.retain(|htlc| {
19001901
if let &InboundHTLCState::LocalRemoved(ref reason) = &htlc.state {
@@ -1987,7 +1988,7 @@ impl Channel {
19871988
}
19881989
self.monitor_pending_forwards.append(&mut to_forward_infos);
19891990
self.monitor_pending_failures.append(&mut revoked_htlcs);
1990-
return Ok((None, Vec::new(), Vec::new(), None, self.channel_monitor.clone()));
1991+
return Ok((None, Vec::new(), Vec::new(), None, self.channel_monitor.clone(), funding_txo));
19911992
}
19921993

19931994
match self.free_holding_cell_htlcs()? {
@@ -2000,7 +2001,7 @@ impl Channel {
20002001
for fail_msg in update_fail_malformed_htlcs.drain(..) {
20012002
commitment_update.0.update_fail_malformed_htlcs.push(fail_msg);
20022003
}
2003-
Ok((Some(commitment_update.0), to_forward_infos, revoked_htlcs, None, commitment_update.1))
2004+
Ok((Some(commitment_update.0), to_forward_infos, revoked_htlcs, None, commitment_update.1, funding_txo))
20042005
},
20052006
None => {
20062007
if require_commitment {
@@ -2012,9 +2013,9 @@ impl Channel {
20122013
update_fail_malformed_htlcs,
20132014
update_fee: None,
20142015
commitment_signed
2015-
}), to_forward_infos, revoked_htlcs, None, monitor_update))
2016+
}), to_forward_infos, revoked_htlcs, None, monitor_update, funding_txo))
20162017
} else {
2017-
Ok((None, to_forward_infos, revoked_htlcs, self.maybe_propose_first_closing_signed(fee_estimator), self.channel_monitor.clone()))
2018+
Ok((None, to_forward_infos, revoked_htlcs, self.maybe_propose_first_closing_signed(fee_estimator), self.channel_monitor.clone(), funding_txo))
20182019
}
20192020
}
20202021
}

0 commit comments

Comments
 (0)