Skip to content

Commit e8cc3f5

Browse files
Store async payment data in PendingOutboundPayment.
1 parent 4a62589 commit e8cc3f5

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,6 +3217,9 @@ where
32173217
PendingOutboundPayment::InvoiceReceived { .. } => {
32183218
Some(RecentPaymentDetails::AwaitingInvoice { payment_id: *payment_id })
32193219
},
3220+
PendingOutboundPayment::StaticInvoiceReceived { .. } => {
3221+
Some(RecentPaymentDetails::AwaitingInvoice { payment_id: *payment_id })
3222+
},
32203223
PendingOutboundPayment::Retryable { payment_hash, total_msat, .. } => {
32213224
Some(RecentPaymentDetails::Pending {
32223225
payment_id: *payment_id,
@@ -11313,6 +11316,7 @@ where
1131311316
}
1131411317
PendingOutboundPayment::AwaitingInvoice { .. } => {},
1131511318
PendingOutboundPayment::InvoiceReceived { .. } => {},
11319+
PendingOutboundPayment::StaticInvoiceReceived { .. } => {},
1131611320
PendingOutboundPayment::Fulfilled { .. } => {},
1131711321
PendingOutboundPayment::Abandoned { .. } => {},
1131811322
}

lightning/src/ln/outbound_payment.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ pub(crate) enum PendingOutboundPayment {
6464
// used anywhere.
6565
max_total_routing_fee_msat: Option<u64>,
6666
},
67+
StaticInvoiceReceived {
68+
payment_hash: PaymentHash,
69+
keysend_preimage: PaymentPreimage,
70+
retry_strategy: Retry,
71+
payment_release_secret: [u8; 32],
72+
route_params: RouteParameters,
73+
},
6774
Retryable {
6875
retry_strategy: Option<Retry>,
6976
attempts: PaymentAttempts,
@@ -170,6 +177,7 @@ impl PendingOutboundPayment {
170177
PendingOutboundPayment::Legacy { .. } => None,
171178
PendingOutboundPayment::AwaitingInvoice { .. } => None,
172179
PendingOutboundPayment::InvoiceReceived { payment_hash, .. } => Some(*payment_hash),
180+
PendingOutboundPayment::StaticInvoiceReceived { payment_hash, .. } => Some(*payment_hash),
173181
PendingOutboundPayment::Retryable { payment_hash, .. } => Some(*payment_hash),
174182
PendingOutboundPayment::Fulfilled { payment_hash, .. } => *payment_hash,
175183
PendingOutboundPayment::Abandoned { payment_hash, .. } => Some(*payment_hash),
@@ -184,7 +192,8 @@ impl PendingOutboundPayment {
184192
PendingOutboundPayment::Fulfilled { session_privs, .. } |
185193
PendingOutboundPayment::Abandoned { session_privs, .. } => session_privs,
186194
PendingOutboundPayment::AwaitingInvoice { .. } |
187-
PendingOutboundPayment::InvoiceReceived { .. } => { debug_assert!(false); return; },
195+
PendingOutboundPayment::InvoiceReceived { .. } |
196+
PendingOutboundPayment::StaticInvoiceReceived { .. } => { debug_assert!(false); return; },
188197
});
189198
let payment_hash = self.payment_hash();
190199
*self = PendingOutboundPayment::Fulfilled { session_privs, payment_hash, timer_ticks_without_htlcs: 0 };
@@ -218,7 +227,8 @@ impl PendingOutboundPayment {
218227
session_privs.remove(session_priv)
219228
},
220229
PendingOutboundPayment::AwaitingInvoice { .. } |
221-
PendingOutboundPayment::InvoiceReceived { .. } => { debug_assert!(false); false },
230+
PendingOutboundPayment::InvoiceReceived { .. } |
231+
PendingOutboundPayment::StaticInvoiceReceived { .. } => { debug_assert!(false); false },
222232
};
223233
if remove_res {
224234
if let PendingOutboundPayment::Retryable {
@@ -247,7 +257,8 @@ impl PendingOutboundPayment {
247257
session_privs.insert(session_priv)
248258
},
249259
PendingOutboundPayment::AwaitingInvoice { .. } |
250-
PendingOutboundPayment::InvoiceReceived { .. } => { debug_assert!(false); false },
260+
PendingOutboundPayment::InvoiceReceived { .. } |
261+
PendingOutboundPayment::StaticInvoiceReceived { .. } => { debug_assert!(false); false },
251262
PendingOutboundPayment::Fulfilled { .. } => false,
252263
PendingOutboundPayment::Abandoned { .. } => false,
253264
};
@@ -280,6 +291,7 @@ impl PendingOutboundPayment {
280291
},
281292
PendingOutboundPayment::AwaitingInvoice { .. } => 0,
282293
PendingOutboundPayment::InvoiceReceived { .. } => 0,
294+
PendingOutboundPayment::StaticInvoiceReceived { .. } => 0,
283295
}
284296
}
285297
}
@@ -1135,6 +1147,7 @@ impl OutboundPayments {
11351147
*payment.into_mut() = retryable_payment;
11361148
(total_amount, recipient_onion, None, onion_session_privs)
11371149
},
1150+
PendingOutboundPayment::StaticInvoiceReceived { .. } => todo!(),
11381151
PendingOutboundPayment::Fulfilled { .. } => {
11391152
log_error!(logger, "Payment already completed");
11401153
return
@@ -1892,6 +1905,13 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
18921905
(2, retry_strategy, required),
18931906
(4, max_total_routing_fee_msat, option),
18941907
},
1908+
(9, StaticInvoiceReceived) => {
1909+
(0, payment_hash, required),
1910+
(2, keysend_preimage, required),
1911+
(4, retry_strategy, required),
1912+
(6, payment_release_secret, required),
1913+
(8, route_params, required),
1914+
},
18951915
);
18961916

18971917
#[cfg(test)]

0 commit comments

Comments
 (0)