-
Notifications
You must be signed in to change notification settings - Fork 404
Introduce RouteParametersConfig #3342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8da348e
4c6074f
cd7227c
50644df
78f6ccb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ use crate::types::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelType | |
use crate::types::features::Bolt11InvoiceFeatures; | ||
#[cfg(trampoline)] | ||
use crate::routing::gossip::NodeId; | ||
use crate::routing::router::{BlindedTail, FixedRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router}; | ||
use crate::routing::router::{BlindedTail, FixedRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, RouteParametersConfig, Router}; | ||
use crate::ln::onion_payment::{check_incoming_htlc_cltv, create_recv_pending_htlc_info, create_fwd_pending_htlc_info, decode_incoming_update_add_htlc_onion, InboundHTLCErr, NextPacketDetails}; | ||
use crate::ln::msgs; | ||
use crate::ln::onion_utils; | ||
|
@@ -2096,6 +2096,7 @@ where | |
/// # use lightning::events::{Event, EventsProvider, PaymentPurpose}; | ||
/// # use lightning::ln::channelmanager::AChannelManager; | ||
/// # use lightning::offers::parse::Bolt12SemanticError; | ||
/// # use lightning::routing::router::RouteParametersConfig; | ||
/// # | ||
/// # fn example<T: AChannelManager>(channel_manager: T) -> Result<(), Bolt12SemanticError> { | ||
/// # let channel_manager = channel_manager.get_cm(); | ||
|
@@ -2143,15 +2144,16 @@ where | |
/// # use lightning::events::{Event, EventsProvider}; | ||
/// # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry}; | ||
/// # use lightning::offers::offer::Offer; | ||
/// # use lightning::routing::router::RouteParametersConfig; | ||
/// # | ||
/// # fn example<T: AChannelManager>( | ||
/// # channel_manager: T, offer: &Offer, quantity: Option<u64>, amount_msats: Option<u64>, | ||
/// # payer_note: Option<String>, retry: Retry, max_total_routing_fee_msat: Option<u64> | ||
/// # payer_note: Option<String>, retry: Retry, route_params_config: RouteParametersConfig | ||
/// # ) { | ||
/// # let channel_manager = channel_manager.get_cm(); | ||
/// let payment_id = PaymentId([42; 32]); | ||
/// match channel_manager.pay_for_offer( | ||
/// offer, quantity, amount_msats, payer_note, payment_id, retry, max_total_routing_fee_msat | ||
/// offer, quantity, amount_msats, payer_note, payment_id, retry, route_params_config | ||
/// ) { | ||
/// Ok(()) => println!("Requesting invoice for offer"), | ||
/// Err(e) => println!("Unable to request invoice for offer: {:?}", e), | ||
|
@@ -2199,16 +2201,17 @@ where | |
/// # use lightning::events::{Event, EventsProvider}; | ||
/// # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry}; | ||
/// # use lightning::offers::parse::Bolt12SemanticError; | ||
/// # use lightning::routing::router::RouteParametersConfig; | ||
/// # | ||
/// # fn example<T: AChannelManager>( | ||
/// # channel_manager: T, amount_msats: u64, absolute_expiry: Duration, retry: Retry, | ||
/// # max_total_routing_fee_msat: Option<u64> | ||
/// # route_params_config: RouteParametersConfig | ||
/// # ) -> Result<(), Bolt12SemanticError> { | ||
/// # let channel_manager = channel_manager.get_cm(); | ||
/// let payment_id = PaymentId([42; 32]); | ||
/// let refund = channel_manager | ||
/// .create_refund_builder( | ||
/// amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat | ||
/// amount_msats, absolute_expiry, payment_id, retry, route_params_config | ||
/// )? | ||
/// # ; | ||
/// # // Needed for compiling for c_bindings | ||
|
@@ -9983,7 +9986,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => { | |
/// [Avoiding Duplicate Payments]: #avoiding-duplicate-payments | ||
pub fn create_refund_builder( | ||
&$self, amount_msats: u64, absolute_expiry: Duration, payment_id: PaymentId, | ||
retry_strategy: Retry, max_total_routing_fee_msat: Option<u64> | ||
retry_strategy: Retry, route_params_config: RouteParametersConfig | ||
) -> Result<$builder, Bolt12SemanticError> { | ||
let node_id = $self.get_our_node_id(); | ||
let expanded_key = &$self.inbound_payment_key; | ||
|
@@ -10008,7 +10011,7 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => { | |
let expiration = StaleExpiration::AbsoluteTimeout(absolute_expiry); | ||
$self.pending_outbound_payments | ||
.add_new_awaiting_invoice( | ||
payment_id, expiration, retry_strategy, max_total_routing_fee_msat, None, | ||
payment_id, expiration, retry_strategy, route_params_config, None, | ||
) | ||
.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?; | ||
|
||
|
@@ -10184,7 +10187,7 @@ where | |
pub fn pay_for_offer( | ||
&self, offer: &Offer, quantity: Option<u64>, amount_msats: Option<u64>, | ||
payer_note: Option<String>, payment_id: PaymentId, retry_strategy: Retry, | ||
max_total_routing_fee_msat: Option<u64> | ||
route_params_config: RouteParametersConfig | ||
) -> Result<(), Bolt12SemanticError> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK no needed option here but: what do you think about having the function call like struct OfferParams {
quantity: Option<u64>,
amount_msats: Option<u64>,
manual_routing_params: Option<ManualRoutingParameters>,
} I think is a lot of more verbose in this way, but I also this that this will be a lot of cleaner. Now I do not think this will fit well in this PR maybe can be a followup one, but with this patter, it is possible to hide future updates to offers (e.g: recurrence or market place feature) without breaking too much the code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a great improvement! It will help keep the function signature cleaner while remaining maintainable for future parameter increases. Maybe we can take this in a follow-up. @TheBlueMatt, what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No strong opinions. |
||
self.pay_for_offer_intern(offer, quantity, amount_msats, payer_note, payment_id, None, |invoice_request, nonce| { | ||
let expiration = StaleExpiration::TimerTicks(1); | ||
|
@@ -10195,7 +10198,7 @@ where | |
}; | ||
self.pending_outbound_payments | ||
.add_new_awaiting_invoice( | ||
payment_id, expiration, retry_strategy, max_total_routing_fee_msat, | ||
payment_id, expiration, retry_strategy, route_params_config, | ||
Some(retryable_invoice_request) | ||
) | ||
.map_err(|_| Bolt12SemanticError::DuplicatePaymentId) | ||
|
@@ -10428,14 +10431,14 @@ where | |
#[cfg(feature = "dnssec")] | ||
pub fn pay_for_offer_from_human_readable_name( | ||
&self, name: HumanReadableName, amount_msats: u64, payment_id: PaymentId, | ||
retry_strategy: Retry, max_total_routing_fee_msat: Option<u64>, | ||
retry_strategy: Retry, route_params_config: RouteParametersConfig, | ||
dns_resolvers: Vec<Destination>, | ||
) -> Result<(), ()> { | ||
let (onion_message, context) = | ||
self.hrn_resolver.resolve_name(payment_id, name, &*self.entropy_source)?; | ||
let reply_paths = self.create_blinded_paths(MessageContext::DNSResolver(context))?; | ||
let expiration = StaleExpiration::TimerTicks(1); | ||
self.pending_outbound_payments.add_new_awaiting_offer(payment_id, expiration, retry_strategy, max_total_routing_fee_msat, amount_msats)?; | ||
self.pending_outbound_payments.add_new_awaiting_offer(payment_id, expiration, retry_strategy, route_params_config, amount_msats)?; | ||
let message_params = dns_resolvers | ||
.iter() | ||
.flat_map(|destination| reply_paths.iter().map(move |path| (path, destination))) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: For stuff like this where rustfmt requires we blow up our code to cover 20 lines we should really create intermediate variables to see if we can avoid it.