@@ -33,7 +33,7 @@ use bitcoin::secp256k1::Secp256k1;
33
33
use bitcoin::{secp256k1, Sequence, Weight};
34
34
35
35
use crate::events::FundingInfo;
36
- use crate::blinded_path::message::{AsyncPaymentsContext, MessageForwardNode} ;
36
+ use crate::blinded_path::message::MessageForwardNode;
37
37
use crate::blinded_path::NodeIdLookUp;
38
38
use crate::blinded_path::payment::{BlindedPaymentPath, PaymentConstraints, PaymentContext, UnauthenticatedReceiveTlvs};
39
39
use crate::chain;
@@ -68,8 +68,7 @@ use crate::offers::invoice::Bolt12Invoice;
68
68
use crate::offers::invoice::UnsignedBolt12Invoice;
69
69
use crate::offers::nonce::Nonce;
70
70
use 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;
73
72
use crate::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
74
73
use crate::sign::ecdsa::EcdsaChannelSigner;
75
74
use crate::util::config::{UserConfig, ChannelConfig, ChannelConfigUpdate};
@@ -88,7 +87,6 @@ use crate::onion_message::dns_resolution::OMNameResolver;
88
87
use {
89
88
crate::blinded_path::message::{BlindedMessagePath, MessageContext},
90
89
crate::offers::static_invoice::StaticInvoice,
91
- crate::onion_message::messenger::Destination,
92
90
};
93
91
94
92
#[cfg(not(c_bindings))]
@@ -2418,8 +2416,6 @@ where
2418
2416
event_persist_notifier: Notifier,
2419
2417
needs_persist_flag: AtomicBool,
2420
2418
2421
- pending_async_payments_messages: Mutex<Vec<(AsyncPaymentsMessage, MessageSendInstructions)>>,
2422
-
2423
2419
/// Tracks the message events that are to be broadcasted when we are connected to some peer.
2424
2420
pending_broadcast_messages: Mutex<Vec<MessageSendEvent>>,
2425
2421
@@ -3339,7 +3335,6 @@ where
3339
3335
needs_persist_flag: AtomicBool::new(false),
3340
3336
funding_batch_states: Mutex::new(BTreeMap::new()),
3341
3337
3342
- pending_async_payments_messages: Mutex::new(Vec::new()),
3343
3338
pending_broadcast_messages: Mutex::new(Vec::new()),
3344
3339
3345
3340
last_days_feerates: Mutex::new(VecDeque::new()),
@@ -4508,45 +4503,6 @@ where
4508
4503
res
4509
4504
}
4510
4505
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
-
4550
4506
#[cfg(async_payments)]
4551
4507
fn send_payment_for_static_invoice(
4552
4508
&self, payment_id: PaymentId
@@ -9528,13 +9484,6 @@ where
9528
9484
Duration::from_secs(self.highest_seen_timestamp.load(Ordering::Acquire) as u64)
9529
9485
}
9530
9486
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
-
9538
9487
fn get_chain_hash(&self) -> ChainHash {
9539
9488
self.chain_hash
9540
9489
}
@@ -9568,6 +9517,20 @@ where
9568
9517
) -> Result<(), ()> {
9569
9518
self.pending_outbound_payments.received_offer(payment_id, retryable_invoice_request)
9570
9519
}
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
+ }
9571
9534
}
9572
9535
9573
9536
impl<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
11141
11104
}
11142
11105
}
11143
11106
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
-
11186
11107
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref>
11187
11108
NodeIdLookUp for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
11188
11109
where
@@ -13102,8 +13023,6 @@ where
13102
13023
13103
13024
funding_batch_states: Mutex::new(BTreeMap::new()),
13104
13025
13105
- pending_async_payments_messages: Mutex::new(Vec::new()),
13106
-
13107
13026
pending_broadcast_messages: Mutex::new(Vec::new()),
13108
13027
13109
13028
entropy_source: args.entropy_source,
0 commit comments