Skip to content

Commit 3fa2fd3

Browse files
Store async payment data in PendingOutboundPayment.
1 parent bf77ff4 commit 3fa2fd3

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,
@@ -10981,6 +10984,7 @@ where
1098110984
}
1098210985
PendingOutboundPayment::AwaitingInvoice { .. } => {},
1098310986
PendingOutboundPayment::InvoiceReceived { .. } => {},
10987+
PendingOutboundPayment::StaticInvoiceReceived { .. } => {},
1098410988
PendingOutboundPayment::Fulfilled { .. } => {},
1098510989
PendingOutboundPayment::Abandoned { .. } => {},
1098610990
}

lightning/src/ln/outbound_payment.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ pub(crate) enum PendingOutboundPayment {
6262
// used anywhere.
6363
max_total_routing_fee_msat: Option<u64>,
6464
},
65+
StaticInvoiceReceived {
66+
payment_hash: PaymentHash,
67+
keysend_preimage: PaymentPreimage,
68+
retry_strategy: Retry,
69+
payment_release_secret: [u8; 32],
70+
route_params: RouteParameters,
71+
},
6572
Retryable {
6673
retry_strategy: Option<Retry>,
6774
attempts: PaymentAttempts,
@@ -168,6 +175,7 @@ impl PendingOutboundPayment {
168175
PendingOutboundPayment::Legacy { .. } => None,
169176
PendingOutboundPayment::AwaitingInvoice { .. } => None,
170177
PendingOutboundPayment::InvoiceReceived { payment_hash, .. } => Some(*payment_hash),
178+
PendingOutboundPayment::StaticInvoiceReceived { payment_hash, .. } => Some(*payment_hash),
171179
PendingOutboundPayment::Retryable { payment_hash, .. } => Some(*payment_hash),
172180
PendingOutboundPayment::Fulfilled { payment_hash, .. } => *payment_hash,
173181
PendingOutboundPayment::Abandoned { payment_hash, .. } => Some(*payment_hash),
@@ -182,7 +190,8 @@ impl PendingOutboundPayment {
182190
PendingOutboundPayment::Fulfilled { session_privs, .. } |
183191
PendingOutboundPayment::Abandoned { session_privs, .. } => session_privs,
184192
PendingOutboundPayment::AwaitingInvoice { .. } |
185-
PendingOutboundPayment::InvoiceReceived { .. } => { debug_assert!(false); return; },
193+
PendingOutboundPayment::InvoiceReceived { .. } |
194+
PendingOutboundPayment::StaticInvoiceReceived { .. } => { debug_assert!(false); return; },
186195
});
187196
let payment_hash = self.payment_hash();
188197
*self = PendingOutboundPayment::Fulfilled { session_privs, payment_hash, timer_ticks_without_htlcs: 0 };
@@ -216,7 +225,8 @@ impl PendingOutboundPayment {
216225
session_privs.remove(session_priv)
217226
},
218227
PendingOutboundPayment::AwaitingInvoice { .. } |
219-
PendingOutboundPayment::InvoiceReceived { .. } => { debug_assert!(false); false },
228+
PendingOutboundPayment::InvoiceReceived { .. } |
229+
PendingOutboundPayment::StaticInvoiceReceived { .. } => { debug_assert!(false); false },
220230
};
221231
if remove_res {
222232
if let PendingOutboundPayment::Retryable {
@@ -245,7 +255,8 @@ impl PendingOutboundPayment {
245255
session_privs.insert(session_priv)
246256
},
247257
PendingOutboundPayment::AwaitingInvoice { .. } |
248-
PendingOutboundPayment::InvoiceReceived { .. } => { debug_assert!(false); false },
258+
PendingOutboundPayment::InvoiceReceived { .. } |
259+
PendingOutboundPayment::StaticInvoiceReceived { .. } => { debug_assert!(false); false },
249260
PendingOutboundPayment::Fulfilled { .. } => false,
250261
PendingOutboundPayment::Abandoned { .. } => false,
251262
};
@@ -278,6 +289,7 @@ impl PendingOutboundPayment {
278289
},
279290
PendingOutboundPayment::AwaitingInvoice { .. } => 0,
280291
PendingOutboundPayment::InvoiceReceived { .. } => 0,
292+
PendingOutboundPayment::StaticInvoiceReceived { .. } => 0,
281293
}
282294
}
283295
}
@@ -1094,6 +1106,7 @@ impl OutboundPayments {
10941106
*payment.into_mut() = retryable_payment;
10951107
(total_amount, recipient_onion, None, onion_session_privs)
10961108
},
1109+
PendingOutboundPayment::StaticInvoiceReceived { .. } => todo!(),
10971110
PendingOutboundPayment::Fulfilled { .. } => {
10981111
log_error!(logger, "Payment already completed");
10991112
return
@@ -1865,6 +1878,13 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
18651878
(2, retry_strategy, required),
18661879
(4, max_total_routing_fee_msat, option),
18671880
},
1881+
(9, StaticInvoiceReceived) => {
1882+
(0, payment_hash, required),
1883+
(2, keysend_preimage, required),
1884+
(4, retry_strategy, required),
1885+
(6, payment_release_secret, required),
1886+
(8, route_params, required),
1887+
},
18681888
);
18691889

18701890
#[cfg(test)]

0 commit comments

Comments
 (0)