@@ -7105,16 +7105,17 @@ where
7105
7105
}
7106
7106
7107
7107
/// Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the
7108
- /// [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the refund. The refund will
7109
- /// not have an expiration unless otherwise set on the builder.
7108
+ /// [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the refund. The builder will
7109
+ /// have an expiration set, if provided. Any changes to the expiration on the returned builder
7110
+ /// will not be honored by [`ChannelManager`].
7110
7111
///
7111
7112
/// The provided `payment_id` is used to ensure that only one invoice is paid for the refund.
7112
7113
///
7113
7114
/// [`Refund`]: crate::offers::refund::Refund
7114
7115
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
7115
7116
pub fn create_refund_builder(
7116
- &self, description: String, amount_msats: u64, payment_id: PaymentId, retry_strategy: Retry ,
7117
- max_total_routing_fee_msat: Option<u64>
7117
+ &self, description: String, amount_msats: u64, absolute_expiry: Option<Duration> ,
7118
+ payment_id: PaymentId, retry_strategy: Retry, max_total_routing_fee_msat: Option<u64>
7118
7119
) -> Result<RefundBuilder<secp256k1::All>, Bolt12SemanticError> {
7119
7120
let node_id = self.get_our_node_id();
7120
7121
let expanded_key = &self.inbound_payment_key;
@@ -7125,8 +7126,21 @@ where
7125
7126
let builder = RefundBuilder::deriving_payer_id(
7126
7127
description, node_id, expanded_key, entropy, secp_ctx, amount_msats, payment_id
7127
7128
)?.chain_hash(self.chain_hash);
7129
+
7130
+ let builder = match absolute_expiry {
7131
+ Some(absolute_expiry) => builder.absolute_expiry(absolute_expiry),
7132
+ None => builder,
7133
+ };
7134
+
7135
+ const SECONDS_PER_TIMER_TICK: u64 = 60;
7136
+ let timer_ticks_before_expiration =
7137
+ absolute_expiry.map(|expiry| expiry.as_secs() / SECONDS_PER_TIMER_TICK);
7138
+
7128
7139
self.pending_outbound_payments
7129
- .add_new_awaiting_invoice(payment_id, retry_strategy, max_total_routing_fee_msat)
7140
+ .add_new_awaiting_invoice_for_refund(
7141
+ payment_id, retry_strategy, max_total_routing_fee_msat,
7142
+ timer_ticks_before_expiration
7143
+ )
7130
7144
.map_err(|_| Bolt12SemanticError::DuplicatePaymentId)?;
7131
7145
7132
7146
Ok(builder)
0 commit comments