From: Jeffrey Czyz Date: Thu, 14 Sep 2023 19:50:56 +0000 (-0500) Subject: Store OffersMessages for later sending X-Git-Tag: v0.0.118~6^2~17 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=ddfeb3f642c7d3f0e4a627dcf552e2a1c2b1e04a;p=rust-lightning Store OffersMessages for later sending Upcoming commits will add utilities for sending an InvoiceRequest for an Offer and an Invoice for a Refund. These messages need to be enqueued so that they can be released in ChannelManager's implementation of OffersMessageHandler to OnionMessenger for sending. These messages do not need to be serialized as they must be resent upon restart. --- diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index d29790094..ffe8ba2b1 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -59,6 +59,7 @@ use crate::ln::wire::Encode; use crate::offers::offer::{DerivedMetadata, OfferBuilder}; use crate::offers::parse::Bolt12SemanticError; use crate::offers::refund::RefundBuilder; +use crate::onion_message::{OffersMessage, PendingOnionMessage}; use crate::sign::{EntropySource, KeysManager, NodeSigner, Recipient, SignerProvider, WriteableEcdsaChannelSigner}; use crate::util::config::{UserConfig, ChannelConfig, ChannelConfigUpdate}; use crate::util::wakers::{Future, Notifier}; @@ -1008,6 +1009,8 @@ where // // Lock order tree: // +// `pending_offers_messages` +// // `total_consistency_lock` // | // |__`forward_htlcs` @@ -1015,26 +1018,26 @@ where // | |__`pending_intercepted_htlcs` // | // |__`per_peer_state` -// | | -// | |__`pending_inbound_payments` -// | | -// | |__`claimable_payments` -// | | -// | |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds -// | | -// | |__`peer_state` -// | | -// | |__`id_to_peer` -// | | -// | |__`short_to_chan_info` -// | | -// | |__`outbound_scid_aliases` -// | | -// | |__`best_block` -// | | -// | |__`pending_events` -// | | -// | |__`pending_background_events` +// | +// |__`pending_inbound_payments` +// | +// |__`claimable_payments` +// | +// |__`pending_outbound_payments` // This field's struct contains a map of pending outbounds +// | +// |__`peer_state` +// | +// |__`id_to_peer` +// | +// |__`short_to_chan_info` +// | +// |__`outbound_scid_aliases` +// | +// |__`best_block` +// | +// |__`pending_events` +// | +// |__`pending_background_events` // pub struct ChannelManager where @@ -1246,6 +1249,8 @@ where event_persist_notifier: Notifier, needs_persist_flag: AtomicBool, + pending_offers_messages: Mutex>>, + entropy_source: ES, node_signer: NS, signer_provider: SP, @@ -2326,6 +2331,8 @@ where needs_persist_flag: AtomicBool::new(false), funding_batch_states: Mutex::new(BTreeMap::new()), + pending_offers_messages: Mutex::new(Vec::new()), + entropy_source, node_signer, signer_provider, @@ -10329,6 +10336,8 @@ where funding_batch_states: Mutex::new(BTreeMap::new()), + pending_offers_messages: Mutex::new(Vec::new()), + entropy_source: args.entropy_source, node_signer: args.node_signer, signer_provider: args.signer_provider,