Skip to content

Commit 392815e

Browse files
Store async payment data in PendingOutboundPayment.
1 parent 246f12c commit 392815e

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
@@ -3133,6 +3133,9 @@ where
31333133
PendingOutboundPayment::InvoiceReceived { .. } => {
31343134
Some(RecentPaymentDetails::AwaitingInvoice { payment_id: *payment_id })
31353135
},
3136+
PendingOutboundPayment::StaticInvoiceReceived { .. } => {
3137+
Some(RecentPaymentDetails::AwaitingInvoice { payment_id: *payment_id })
3138+
},
31363139
PendingOutboundPayment::Retryable { payment_hash, total_msat, .. } => {
31373140
Some(RecentPaymentDetails::Pending {
31383141
payment_id: *payment_id,
@@ -11021,6 +11024,7 @@ where
1102111024
}
1102211025
PendingOutboundPayment::AwaitingInvoice { .. } => {},
1102311026
PendingOutboundPayment::InvoiceReceived { .. } => {},
11027+
PendingOutboundPayment::StaticInvoiceReceived { .. } => {},
1102411028
PendingOutboundPayment::Fulfilled { .. } => {},
1102511029
PendingOutboundPayment::Abandoned { .. } => {},
1102611030
}

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
}
@@ -1121,6 +1133,7 @@ impl OutboundPayments {
11211133
*payment.into_mut() = retryable_payment;
11221134
(total_amount, recipient_onion, None, onion_session_privs)
11231135
},
1136+
PendingOutboundPayment::StaticInvoiceReceived { .. } => todo!(),
11241137
PendingOutboundPayment::Fulfilled { .. } => {
11251138
log_error!(logger, "Payment already completed");
11261139
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)