Skip to content

Commit 4ac8a76

Browse files
authored
Merge pull request #4543 from TheBlueMatt/2026-04-flow-opts
Drop 353 resolution and fix block updating in `OffersMessageFlow`
2 parents 9dad193 + 5704e8e commit 4ac8a76

1 file changed

Lines changed: 5 additions & 66 deletions

File tree

lightning/src/offers/flow.rs

Lines changed: 5 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ use crate::types::payment::{PaymentHash, PaymentSecret};
6262
use crate::util::logger::Logger;
6363
use crate::util::ser::Writeable;
6464

65-
#[cfg(feature = "dnssec")]
66-
use {
67-
crate::blinded_path::message::DNSResolverContext,
68-
crate::onion_message::dns_resolution::{DNSResolverMessage, DNSSECQuery, OMNameResolver},
69-
};
70-
7165
/// A BOLT12 offers code and flow utility provider, which facilitates
7266
/// BOLT12 builder generation and onion message handling.
7367
///
@@ -94,11 +88,6 @@ pub struct OffersMessageFlow<MR: MessageRouter, L: Logger> {
9488
pending_async_payments_messages: Mutex<Vec<(AsyncPaymentsMessage, MessageSendInstructions)>>,
9589
async_receive_offer_cache: Mutex<AsyncReceiveOfferCache>,
9690

97-
#[cfg(feature = "dnssec")]
98-
pub(crate) hrn_resolver: OMNameResolver,
99-
#[cfg(feature = "dnssec")]
100-
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
101-
10291
logger: L,
10392
}
10493

@@ -126,11 +115,6 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
126115
pending_offers_messages: Mutex::new(Vec::new()),
127116
pending_async_payments_messages: Mutex::new(Vec::new()),
128117

129-
#[cfg(feature = "dnssec")]
130-
hrn_resolver: OMNameResolver::new(current_timestamp, best_block.height),
131-
#[cfg(feature = "dnssec")]
132-
pending_dns_onion_messages: Mutex::new(Vec::new()),
133-
134118
async_receive_offer_cache: Mutex::new(AsyncReceiveOfferCache::new()),
135119

136120
logger,
@@ -199,10 +183,14 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
199183
///
200184
/// Must be called whenever a new chain tip becomes available. May be skipped
201185
/// for intermediary blocks.
202-
pub fn best_block_updated(&self, header: &Header, _height: u32) {
186+
pub fn best_block_updated(&self, header: &Header, height: u32) {
203187
let timestamp = &self.highest_seen_timestamp;
204188
let block_time = header.time as usize;
205189

190+
// Note that we deliberately don't use `update_for_new_tip` as we dont rely on receiving
191+
// disconnection information instead expecting to simply "jump" to the new tip.
192+
*self.best_block.write().unwrap() = BestBlock::new(header.block_hash(), height);
193+
206194
loop {
207195
// Update timestamp to be the max of its current value and the block
208196
// timestamp. This should keep us close to the current time without relying on
@@ -220,12 +208,6 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
220208
break;
221209
}
222210
}
223-
224-
#[cfg(feature = "dnssec")]
225-
{
226-
let updated_time = timestamp.load(Ordering::Acquire) as u32;
227-
self.hrn_resolver.new_best_block(_height, updated_time);
228-
}
229211
}
230212
}
231213

@@ -1306,41 +1288,6 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
13061288
)
13071289
}
13081290

1309-
/// Enqueues the created [`DNSSECQuery`] to be sent to the counterparty.
1310-
///
1311-
/// # Peers
1312-
///
1313-
/// The user must provide a list of [`MessageForwardNode`] that will be used to generate
1314-
/// valid reply paths for the counterparty to send back the corresponding response for
1315-
/// the [`DNSSECQuery`] message.
1316-
///
1317-
/// [`supports_onion_messages`]: crate::types::features::Features::supports_onion_messages
1318-
#[cfg(feature = "dnssec")]
1319-
pub fn enqueue_dns_onion_message(
1320-
&self, message: DNSSECQuery, context: DNSResolverContext, dns_resolvers: Vec<Destination>,
1321-
peers: Vec<MessageForwardNode>,
1322-
) -> Result<(), Bolt12SemanticError> {
1323-
let reply_paths = self
1324-
.create_blinded_paths(peers, MessageContext::DNSResolver(context))
1325-
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
1326-
1327-
let message_params = dns_resolvers
1328-
.iter()
1329-
.flat_map(|destination| reply_paths.iter().map(move |path| (path, destination)))
1330-
.take(OFFERS_MESSAGE_REQUEST_LIMIT);
1331-
for (reply_path, destination) in message_params {
1332-
self.pending_dns_onion_messages.lock().unwrap().push((
1333-
DNSResolverMessage::DNSSECQuery(message.clone()),
1334-
MessageSendInstructions::WithSpecifiedReplyPath {
1335-
destination: destination.clone(),
1336-
reply_path: reply_path.clone(),
1337-
},
1338-
));
1339-
}
1340-
1341-
Ok(())
1342-
}
1343-
13441291
/// Gets the enqueued [`OffersMessage`] with their corresponding [`MessageSendInstructions`].
13451292
pub fn release_pending_offers_messages(&self) -> Vec<(OffersMessage, MessageSendInstructions)> {
13461293
core::mem::take(&mut self.pending_offers_messages.lock().unwrap())
@@ -1353,14 +1300,6 @@ impl<MR: MessageRouter, L: Logger> OffersMessageFlow<MR, L> {
13531300
core::mem::take(&mut self.pending_async_payments_messages.lock().unwrap())
13541301
}
13551302

1356-
/// Gets the enqueued [`DNSResolverMessage`] with their corresponding [`MessageSendInstructions`].
1357-
#[cfg(feature = "dnssec")]
1358-
pub fn release_pending_dns_messages(
1359-
&self,
1360-
) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
1361-
core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
1362-
}
1363-
13641303
/// Retrieve an [`Offer`] for receiving async payments as an often-offline recipient. Will only
13651304
/// return an offer if [`Self::set_paths_to_static_invoice_server`] was called and we succeeded in
13661305
/// interactively building a [`StaticInvoice`] with the static invoice server.

0 commit comments

Comments
 (0)