Make get_latest_local_commitment_txn public
[rust-lightning] / src / ln / channelmonitor.rs
index 5dddd1e1557db9e9300ba9cf8d65c086bf2702bc..18319633f3826f80e21e109c17a70c3875b3c418 100644 (file)
@@ -763,6 +763,9 @@ impl ChannelMonitor {
                }
        }
 
+       pub(super) fn provide_rescue_remote_commitment_tx_info(&mut self, their_revocation_point: PublicKey) {
+       }
+
        /// Informs this monitor of the latest local (ie broadcastable) commitment transaction. The
        /// monitor watches for timeouts and may broadcast it if we approach such a timeout. Thus, it
        /// is important that any clones of this channel monitor (including remote clones) by kept
@@ -1768,7 +1771,7 @@ impl ChannelMonitor {
                        None => return (None, None),
                        Some(their_delayed_payment_base_key) => ignore_error!(chan_utils::derive_public_key(&self.secp_ctx, &per_commitment_point, &their_delayed_payment_base_key)),
                };
-               let redeemscript = chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.their_to_self_delay.unwrap(), &delayed_key);
+               let redeemscript = chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.our_to_self_delay, &delayed_key);
                let revokeable_p2wsh = redeemscript.to_v0_p2wsh();
                let htlc_txid = tx.txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
 
@@ -2048,9 +2051,16 @@ impl ChannelMonitor {
                None
        }
 
-       /// Used by ChannelManager deserialization to broadcast the latest local state if it's copy of
-       /// the Channel was out-of-date.
-       pub(super) fn get_latest_local_commitment_txn(&self) -> Vec<Transaction> {
+       /// Used by ChannelManager deserialization to broadcast the latest local state if its copy of
+       /// the Channel was out-of-date. You may use it to get a broadcastable local toxic tx in case of
+       /// fallen-behind, i.e when receiving a channel_reestablish with a proof that our remote side knows
+       /// a higher revocation secret than the local commitment number we are aware of. Broadcasting these
+       /// transactions are UNSAFE, as they allow remote side to punish you. Nevertheless you may want to
+       /// broadcast them if remote don't close channel with his higher commitment transaction after a
+       /// substantial amount of time (a month or even a year) to get back funds. Best may be to contact
+       /// out-of-band the other node operator to coordinate with him if option is available to you.
+       /// In any-case, choice is up to the user.
+       pub fn get_latest_local_commitment_txn(&self) -> Vec<Transaction> {
                if let &Some(ref local_tx) = &self.current_local_signed_commitment_tx {
                        let mut res = vec![local_tx.tx.clone()];
                        match self.key_storage {