Ensure all HTLCs for a claimed payment are claimed on startup
[rust-lightning] / lightning / src / chain / channelmonitor.rs
index 738fff3837ca045f5c8c9e3e93e588bb88974191..fd66e585208b6b580e6f981d633fa8c0d94c028e 100644 (file)
@@ -1085,7 +1085,8 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
                self.inner.lock().unwrap().provide_latest_holder_commitment_tx(holder_commitment_tx, htlc_outputs).map_err(|_| ())
        }
 
-       #[cfg(test)]
+       /// This is used to provide payment preimage(s) out-of-band during startup without updating the
+       /// off-chain state with a new commitment transaction.
        pub(crate) fn provide_payment_preimage<B: Deref, F: Deref, L: Deref>(
                &self,
                payment_hash: &PaymentHash,
@@ -1631,6 +1632,10 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
 
                res
        }
+
+       pub(crate) fn get_stored_preimages(&self) -> HashMap<PaymentHash, PaymentPreimage> {
+               self.inner.lock().unwrap().payment_preimages.clone()
+       }
 }
 
 /// Compares a broadcasted commitment transaction's HTLCs with those in the latest state,