@@ -75,7 +75,7 @@ use crate::offers::signer;
75
75
use crate::offers::static_invoice::StaticInvoice;
76
76
use crate::onion_message::async_payments::{AsyncPaymentsMessage, HeldHtlcAvailable, ReleaseHeldHtlc, AsyncPaymentsMessageHandler};
77
77
use crate::onion_message::dns_resolution::HumanReadableName;
78
- use crate::onion_message::messenger::{Destination, MessageRouter, Responder, ResponseInstruction, MessageSendInstructions };
78
+ use crate::onion_message::messenger::{DefaultMessageRouter, Destination, MessageRouter, MessageSendInstructions, Responder, ResponseInstruction };
79
79
use crate::onion_message::offers::OffersMessage;
80
80
use crate::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
81
81
use crate::sign::ecdsa::EcdsaChannelSigner;
@@ -88,13 +88,10 @@ use crate::util::logger::{Level, Logger, WithContext};
88
88
use crate::util::errors::APIError;
89
89
90
90
#[cfg(feature = "dnssec")]
91
- use crate::blinded_path::message::DNSResolverContext;
92
- #[cfg(feature = "dnssec")]
93
- use crate::onion_message::dns_resolution::{DNSResolverMessage, DNSResolverMessageHandler, DNSSECQuery, DNSSECProof, OMNameResolver};
91
+ use crate::onion_message::dns_resolution::{DNSResolverMessage, OMNameResolver};
94
92
95
93
#[cfg(not(c_bindings))]
96
94
use {
97
- crate::onion_message::messenger::DefaultMessageRouter,
98
95
crate::routing::router::DefaultRouter,
99
96
crate::routing::gossip::NetworkGraph,
100
97
crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters},
@@ -2390,14 +2387,6 @@ where
2390
2387
#[cfg(feature = "dnssec")]
2391
2388
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
2392
2389
2393
- #[cfg(feature = "_test_utils")]
2394
- /// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
2395
- /// offer generated in the test.
2396
- ///
2397
- /// This allows for doing so, validating proofs as normal, but, if they pass, replacing the
2398
- /// offer they resolve to to the given one.
2399
- pub testing_dnssec_proof_offer_resolution_override: Mutex<HashMap<HumanReadableName, Offer>>,
2400
-
2401
2390
entropy_source: ES,
2402
2391
node_signer: NS,
2403
2392
signer_provider: SP,
@@ -3267,9 +3256,6 @@ where
3267
3256
hrn_resolver: OMNameResolver::new(current_timestamp, params.best_block.height),
3268
3257
#[cfg(feature = "dnssec")]
3269
3258
pending_dns_onion_messages: Mutex::new(Vec::new()),
3270
-
3271
- #[cfg(feature = "_test_utils")]
3272
- testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
3273
3259
}
3274
3260
}
3275
3261
@@ -9203,6 +9189,7 @@ pub trait OffersMessageCommons {
9203
9189
/// Get pending offers messages
9204
9190
fn get_pending_offers_messages(&self) -> MutexGuard<'_, Vec<(OffersMessage, MessageSendInstructions)>>;
9205
9191
9192
+ #[cfg(feature = "dnssec")]
9206
9193
/// Get pending DNS onion messages
9207
9194
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>>;
9208
9195
@@ -9335,6 +9322,16 @@ pub trait OffersMessageCommons {
9335
9322
payer_note: Option<String>, payment_id: PaymentId,
9336
9323
human_readable_name: Option<HumanReadableName>, create_pending_payment: CPP,
9337
9324
) -> Result<(), Bolt12SemanticError>;
9325
+
9326
+ #[cfg(feature = "dnssec")]
9327
+ /// Amount for payment awaiting offer
9328
+ fn amt_msats_for_payment_awaiting_offer(&self, payment_id: PaymentId) -> Result<u64, ()>;
9329
+
9330
+ #[cfg(feature = "dnssec")]
9331
+ /// Received Offer
9332
+ fn received_offer(
9333
+ &self, payment_id: PaymentId, retryable_invoice_request: Option<RetryableInvoiceRequest>,
9334
+ ) -> Result<(), ()>;
9338
9335
}
9339
9336
9340
9337
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref> OffersMessageCommons for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
@@ -9353,6 +9350,7 @@ where
9353
9350
self.pending_offers_messages.lock().expect("Mutex is locked by other thread.")
9354
9351
}
9355
9352
9353
+ #[cfg(feature = "dnssec")]
9356
9354
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> {
9357
9355
self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.")
9358
9356
}
@@ -9586,6 +9584,18 @@ where
9586
9584
9587
9585
self.enqueue_invoice_request(invoice_request, reply_paths)
9588
9586
}
9587
+
9588
+ #[cfg(feature = "dnssec")]
9589
+ fn amt_msats_for_payment_awaiting_offer(&self, payment_id: PaymentId) -> Result<u64, ()> {
9590
+ self.pending_outbound_payments.amt_msats_for_payment_awaiting_offer(payment_id)
9591
+ }
9592
+
9593
+ #[cfg(feature = "dnssec")]
9594
+ fn received_offer(
9595
+ &self, payment_id: PaymentId, retryable_invoice_request: Option<RetryableInvoiceRequest>,
9596
+ ) -> Result<(), ()> {
9597
+ self.pending_outbound_payments.received_offer(payment_id, retryable_invoice_request)
9598
+ }
9589
9599
}
9590
9600
9591
9601
/// Defines the maximum number of [`OffersMessage`] including different reply paths to be sent
@@ -11119,69 +11129,6 @@ where
11119
11129
}
11120
11130
}
11121
11131
11122
- #[cfg(feature = "dnssec")]
11123
- impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref>
11124
- DNSResolverMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
11125
- where
11126
- M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
11127
- T::Target: BroadcasterInterface,
11128
- ES::Target: EntropySource,
11129
- NS::Target: NodeSigner,
11130
- SP::Target: SignerProvider,
11131
- F::Target: FeeEstimator,
11132
- R::Target: Router,
11133
- MR::Target: MessageRouter,
11134
- L::Target: Logger,
11135
- {
11136
- fn handle_dnssec_query(
11137
- &self, _message: DNSSECQuery, _responder: Option<Responder>,
11138
- ) -> Option<(DNSResolverMessage, ResponseInstruction)> {
11139
- None
11140
- }
11141
-
11142
- fn handle_dnssec_proof(&self, message: DNSSECProof, context: DNSResolverContext) {
11143
- let offer_opt = self.hrn_resolver.handle_dnssec_proof_for_offer(message, context);
11144
- #[cfg_attr(not(feature = "_test_utils"), allow(unused_mut))]
11145
- if let Some((completed_requests, mut offer)) = offer_opt {
11146
- for (name, payment_id) in completed_requests {
11147
- #[cfg(feature = "_test_utils")]
11148
- if let Some(replacement_offer) = self.testing_dnssec_proof_offer_resolution_override.lock().unwrap().remove(&name) {
11149
- // If we have multiple pending requests we may end up over-using the override
11150
- // offer, but tests can deal with that.
11151
- offer = replacement_offer;
11152
- }
11153
- if let Ok(amt_msats) = self.pending_outbound_payments.amt_msats_for_payment_awaiting_offer(payment_id) {
11154
- let offer_pay_res =
11155
- self.pay_for_offer_intern(&offer, None, Some(amt_msats), None, payment_id, Some(name),
11156
- |invoice_request, nonce| {
11157
- let retryable_invoice_request = RetryableInvoiceRequest {
11158
- invoice_request: invoice_request.clone(),
11159
- nonce,
11160
- };
11161
- self.pending_outbound_payments
11162
- .received_offer(payment_id, Some(retryable_invoice_request))
11163
- .map_err(|_| Bolt12SemanticError::DuplicatePaymentId)
11164
- });
11165
- if offer_pay_res.is_err() {
11166
- // The offer we tried to pay is the canonical current offer for the name we
11167
- // wanted to pay. If we can't pay it, there's no way to recover so fail the
11168
- // payment.
11169
- // Note that the PaymentFailureReason should be ignored for an
11170
- // AwaitingInvoice payment.
11171
- self.pending_outbound_payments.abandon_payment(
11172
- payment_id, PaymentFailureReason::RouteNotFound, &self.pending_events,
11173
- );
11174
- }
11175
- }
11176
- }
11177
- }
11178
- }
11179
-
11180
- fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
11181
- core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
11182
- }
11183
- }
11184
-
11185
11132
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref>
11186
11133
NodeIdLookUp for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
11187
11134
where
@@ -13033,9 +12980,6 @@ where
13033
12980
hrn_resolver: OMNameResolver::new(highest_seen_timestamp, best_block_height),
13034
12981
#[cfg(feature = "dnssec")]
13035
12982
pending_dns_onion_messages: Mutex::new(Vec::new()),
13036
-
13037
- #[cfg(feature = "_test_utils")]
13038
- testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
13039
12983
};
13040
12984
13041
12985
for (_, monitor) in args.channel_monitors.iter() {
0 commit comments