@@ -33,7 +33,7 @@ use bitcoin::secp256k1::Secp256k1;
3333use bitcoin::{secp256k1, Sequence, Weight};
3434
3535use crate::events::FundingInfo;
36- use crate::blinded_path::message::{AsyncPaymentsContext, MessageForwardNode} ;
36+ use crate::blinded_path::message::MessageForwardNode;
3737use crate::blinded_path::NodeIdLookUp;
3838use crate::blinded_path::payment::{BlindedPaymentPath, PaymentConstraints, PaymentContext, UnauthenticatedReceiveTlvs};
3939use crate::chain;
@@ -68,8 +68,7 @@ use crate::offers::invoice::Bolt12Invoice;
6868use crate::offers::invoice::UnsignedBolt12Invoice;
6969use crate::offers::nonce::Nonce;
7070use crate::offers::signer;
71- use crate::onion_message::async_payments::{AsyncPaymentsMessage, HeldHtlcAvailable, ReleaseHeldHtlc, AsyncPaymentsMessageHandler};
72- use crate::onion_message::messenger::{MessageRouter, MessageSendInstructions, Responder, ResponseInstruction};
71+ use crate::onion_message::messenger::MessageRouter;
7372use crate::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
7473use crate::sign::ecdsa::EcdsaChannelSigner;
7574use crate::util::config::{UserConfig, ChannelConfig, ChannelConfigUpdate};
@@ -88,7 +87,6 @@ use crate::onion_message::dns_resolution::OMNameResolver;
8887use {
8988 crate::blinded_path::message::{BlindedMessagePath, MessageContext},
9089 crate::offers::static_invoice::StaticInvoice,
91- crate::onion_message::messenger::Destination,
9290};
9391
9492#[cfg(not(c_bindings))]
@@ -2418,8 +2416,6 @@ where
24182416 event_persist_notifier: Notifier,
24192417 needs_persist_flag: AtomicBool,
24202418
2421- pending_async_payments_messages: Mutex<Vec<(AsyncPaymentsMessage, MessageSendInstructions)>>,
2422-
24232419 /// Tracks the message events that are to be broadcasted when we are connected to some peer.
24242420 pending_broadcast_messages: Mutex<Vec<MessageSendEvent>>,
24252421
@@ -3339,7 +3335,6 @@ where
33393335 needs_persist_flag: AtomicBool::new(false),
33403336 funding_batch_states: Mutex::new(BTreeMap::new()),
33413337
3342- pending_async_payments_messages: Mutex::new(Vec::new()),
33433338 pending_broadcast_messages: Mutex::new(Vec::new()),
33443339
33453340 last_days_feerates: Mutex::new(VecDeque::new()),
@@ -4508,45 +4503,6 @@ where
45084503 res
45094504 }
45104505
4511- #[cfg(async_payments)]
4512- fn initiate_async_payment(
4513- &self, invoice: &StaticInvoice, payment_id: PaymentId
4514- ) -> Result<(), Bolt12PaymentError> {
4515-
4516- self.handle_static_invoice_received(invoice, payment_id)?;
4517-
4518- let nonce = Nonce::from_entropy_source(&*self.entropy_source);
4519- let hmac = payment_id.hmac_for_async_payment(nonce, &self.inbound_payment_key);
4520- let reply_paths = match self.create_blinded_paths(
4521- MessageContext::AsyncPayments(
4522- AsyncPaymentsContext::OutboundPayment { payment_id, nonce, hmac }
4523- )
4524- ) {
4525- Ok(paths) => paths,
4526- Err(()) => {
4527- self.abandon_payment_with_reason(payment_id, PaymentFailureReason::BlindedPathCreationFailed);
4528- return Err(Bolt12PaymentError::BlindedPathCreationFailed);
4529- }
4530- };
4531-
4532- let mut pending_async_payments_messages = self.pending_async_payments_messages.lock().unwrap();
4533- const HTLC_AVAILABLE_LIMIT: usize = 10;
4534- reply_paths
4535- .iter()
4536- .flat_map(|reply_path| invoice.message_paths().iter().map(move |invoice_path| (invoice_path, reply_path)))
4537- .take(HTLC_AVAILABLE_LIMIT)
4538- .for_each(|(invoice_path, reply_path)| {
4539- let instructions = MessageSendInstructions::WithSpecifiedReplyPath {
4540- destination: Destination::BlindedPath(invoice_path.clone()),
4541- reply_path: reply_path.clone(),
4542- };
4543- let message = AsyncPaymentsMessage::HeldHtlcAvailable(HeldHtlcAvailable {});
4544- pending_async_payments_messages.push((message, instructions));
4545- });
4546-
4547- Ok(())
4548- }
4549-
45504506 #[cfg(async_payments)]
45514507 fn send_payment_for_static_invoice(
45524508 &self, payment_id: PaymentId
@@ -9528,13 +9484,6 @@ where
95289484 Duration::from_secs(self.highest_seen_timestamp.load(Ordering::Acquire) as u64)
95299485 }
95309486
9531- #[cfg(async_payments)]
9532- fn initiate_async_payment(
9533- &self, invoice: &StaticInvoice, payment_id: PaymentId
9534- ) -> Result<(), Bolt12PaymentError> {
9535- self.initiate_async_payment(invoice, payment_id)
9536- }
9537-
95389487 fn get_chain_hash(&self) -> ChainHash {
95399488 self.chain_hash
95409489 }
@@ -9568,6 +9517,20 @@ where
95689517 ) -> Result<(), ()> {
95699518 self.pending_outbound_payments.received_offer(payment_id, retryable_invoice_request)
95709519 }
9520+
9521+ #[cfg(async_payments)]
9522+ fn handle_static_invoice_received(
9523+ &self, invoice: &StaticInvoice, payment_id: PaymentId
9524+ ) -> Result<(), Bolt12PaymentError> {
9525+ self.handle_static_invoice_received(invoice, payment_id)
9526+ }
9527+
9528+ #[cfg(async_payments)]
9529+ fn send_payment_for_static_invoice(
9530+ &self, payment_id: PaymentId
9531+ ) -> Result<(), Bolt12PaymentError> {
9532+ self.send_payment_for_static_invoice(payment_id)
9533+ }
95719534}
95729535
95739536impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref> ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
@@ -11141,48 +11104,6 @@ where
1114111104 }
1114211105}
1114311106
11144- impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref>
11145- AsyncPaymentsMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
11146- where
11147- M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
11148- T::Target: BroadcasterInterface,
11149- ES::Target: EntropySource,
11150- NS::Target: NodeSigner,
11151- SP::Target: SignerProvider,
11152- F::Target: FeeEstimator,
11153- R::Target: Router,
11154- MR::Target: MessageRouter,
11155- L::Target: Logger,
11156- {
11157- fn handle_held_htlc_available(
11158- &self, _message: HeldHtlcAvailable, _context: AsyncPaymentsContext,
11159- _responder: Option<Responder>
11160- ) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> {
11161- None
11162- }
11163-
11164- fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {
11165- #[cfg(async_payments)] {
11166- let (payment_id, nonce, hmac) = match _context {
11167- AsyncPaymentsContext::OutboundPayment { payment_id, hmac, nonce } => {
11168- (payment_id, nonce, hmac)
11169- },
11170- _ => return
11171- };
11172- if payment_id.verify_for_async_payment(hmac, nonce, &self.inbound_payment_key).is_err() { return }
11173- if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
11174- log_trace!(
11175- self.logger, "Failed to release held HTLC with payment id {}: {:?}", payment_id, e
11176- );
11177- }
11178- }
11179- }
11180-
11181- fn release_pending_messages(&self) -> Vec<(AsyncPaymentsMessage, MessageSendInstructions)> {
11182- core::mem::take(&mut self.pending_async_payments_messages.lock().unwrap())
11183- }
11184- }
11185-
1118611107impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref>
1118711108NodeIdLookUp for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
1118811109where
@@ -13102,8 +13023,6 @@ where
1310213023
1310313024 funding_batch_states: Mutex::new(BTreeMap::new()),
1310413025
13105- pending_async_payments_messages: Mutex::new(Vec::new()),
13106-
1310713026 pending_broadcast_messages: Mutex::new(Vec::new()),
1310813027
1310913028 entropy_source: args.entropy_source,
0 commit comments