Make get_latest_local_commitment_txn public
authorAntoine Riard <ariard@student.42.fr>
Thu, 1 Aug 2019 14:54:02 +0000 (10:54 -0400)
committerAntoine Riard <ariard@student.42.fr>
Mon, 5 Aug 2019 19:47:37 +0000 (15:47 -0400)
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.

Also, log toxic commitment tx id in channel_reestablish sending back
ChannelError::CloseDelayBroadcast

src/ln/channelmanager.rs
src/ln/channelmonitor.rs

index 2b22cbd89d0ec060d95f9d1a15793e2c733f607a..a957a96df73be073d6b4e9fd32aabdd8f80b2b74 100644 (file)
@@ -494,7 +494,10 @@ macro_rules! try_chan_entry {
                                                }
                                        }
                                }
-                               let mut shutdown_res = chan.force_shutdown(); // We drop closing transactions as they are toxic datas and MUST NOT be broadcast
+                               let mut shutdown_res = chan.force_shutdown();
+                               if shutdown_res.0.len() >= 1 {
+                                       log_error!($self, "You have a toxic local commitment transaction {} avaible in channel monitor, read comment in ChannelMonitor::get_latest_local_commitment_txn to be informed of manual action to take", shutdown_res.0[0].txid());
+                               }
                                shutdown_res.0.clear();
                                return Err(MsgHandleErrInternal::from_finish_shutdown(msg, channel_id, shutdown_res, $self.get_channel_update(&chan).ok()))
                        }
index e0ffe809845917499655da749da7d2a1086b6c85..18319633f3826f80e21e109c17a70c3875b3c418 100644 (file)
@@ -2051,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 {