+ // TODO: Event release to users and serialization is currently race-y: its very easy for a
+ // user to serialize a ChannelManager with pending events in it and lose those events on
+ // restart. This is doubly true for the fail/fulfill-backs from monitor events!
+ {
+ //TODO: This behavior should be documented.
+ for htlc_update in self.monitor.fetch_pending_htlc_updated() {
+ if let Some(preimage) = htlc_update.payment_preimage {
+ self.claim_funds_internal(self.channel_state.lock().unwrap(), htlc_update.source, preimage);
+ } else {
+ self.fail_htlc_backwards_internal(self.channel_state.lock().unwrap(), htlc_update.source, &htlc_update.payment_hash, HTLCFailReason::Reason { failure_code: 0x4000 | 10, data: Vec::new() });
+ }
+ }
+ }
+