Skip to content

Commit 2ea457e

Browse files
committed
f - pass absolute expiry to create_refund_builder
1 parent 86252ea commit 2ea457e

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7109,16 +7109,17 @@ where
71097109
}
71107110

71117111
/// Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the
7112-
/// [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the refund. The refund will
7113-
/// not have an expiration unless otherwise set on the builder.
7112+
/// [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the refund. The builder will
7113+
/// have an expiration set, if provided. Any changes to the expiration on the returned builder
7114+
/// will not be honored by [`ChannelManager`].
71147115
///
71157116
/// The provided `payment_id` is used to ensure that only one invoice is paid for the refund.
71167117
///
71177118
/// [`Refund`]: crate::offers::refund::Refund
71187119
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
71197120
pub fn create_refund_builder(
7120-
&self, description: String, amount_msats: u64, payment_id: PaymentId, retry_strategy: Retry,
7121-
max_total_routing_fee_msat: Option<u64>
7121+
&self, description: String, amount_msats: u64, absolute_expiry: Option<Duration>,
7122+
payment_id: PaymentId, retry_strategy: Retry, max_total_routing_fee_msat: Option<u64>
71227123
) -> Result<RefundBuilder<secp256k1::All>, Bolt12SemanticError> {
71237124
let node_id = self.get_our_node_id();
71247125
let expanded_key = &self.inbound_payment_key;
@@ -7129,8 +7130,21 @@ where
71297130
let builder = RefundBuilder::deriving_payer_id(
71307131
description, node_id, expanded_key, entropy, secp_ctx, amount_msats, payment_id
71317132
)?.chain_hash(self.chain_hash);
7133+
7134+
let builder = match absolute_expiry {
7135+
Some(absolute_expiry) => builder.absolute_expiry(absolute_expiry),
7136+
None => builder,
7137+
};
7138+
7139+
const SECONDS_PER_TIMER_TICK: u64 = 60;
7140+
let timer_ticks_before_expiration =
7141+
absolute_expiry.map(|expiry| expiry.as_secs() / SECONDS_PER_TIMER_TICK);
7142+
71327143
self.pending_outbound_payments
7133-
.add_new_awaiting_invoice(payment_id, retry_strategy, max_total_routing_fee_msat)
7144+
.add_new_awaiting_invoice_for_refund(
7145+
payment_id, retry_strategy, max_total_routing_fee_msat,
7146+
timer_ticks_before_expiration
7147+
)
71347148
.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
71357149

71367150
Ok(builder)

0 commit comments

Comments
 (0)