@@ -53,6 +53,9 @@ pub(crate) enum PendingOutboundPayment {
53
53
AwaitingInvoice {
54
54
timer_ticks_without_response : u8 ,
55
55
} ,
56
+ InvoiceReceived {
57
+ payment_hash : PaymentHash ,
58
+ } ,
56
59
Retryable {
57
60
retry_strategy : Option < Retry > ,
58
61
attempts : PaymentAttempts ,
@@ -152,6 +155,7 @@ impl PendingOutboundPayment {
152
155
match self {
153
156
PendingOutboundPayment :: Legacy { .. } => None ,
154
157
PendingOutboundPayment :: AwaitingInvoice { .. } => None ,
158
+ PendingOutboundPayment :: InvoiceReceived { payment_hash } => Some ( * payment_hash) ,
155
159
PendingOutboundPayment :: Retryable { payment_hash, .. } => Some ( * payment_hash) ,
156
160
PendingOutboundPayment :: Fulfilled { payment_hash, .. } => * payment_hash,
157
161
PendingOutboundPayment :: Abandoned { payment_hash, .. } => Some ( * payment_hash) ,
@@ -165,10 +169,8 @@ impl PendingOutboundPayment {
165
169
PendingOutboundPayment :: Retryable { session_privs, .. } |
166
170
PendingOutboundPayment :: Fulfilled { session_privs, .. } |
167
171
PendingOutboundPayment :: Abandoned { session_privs, .. } => session_privs,
168
- PendingOutboundPayment :: AwaitingInvoice { .. } => {
169
- debug_assert ! ( false ) ;
170
- return ;
171
- } ,
172
+ PendingOutboundPayment :: AwaitingInvoice { .. } |
173
+ PendingOutboundPayment :: InvoiceReceived { .. } => { debug_assert ! ( false ) ; return ; } ,
172
174
} ) ;
173
175
let payment_hash = self . payment_hash ( ) ;
174
176
* self = PendingOutboundPayment :: Fulfilled { session_privs, payment_hash, timer_ticks_without_htlcs : 0 } ;
@@ -183,6 +185,12 @@ impl PendingOutboundPayment {
183
185
payment_hash : * payment_hash,
184
186
reason : Some ( reason)
185
187
} ;
188
+ } else if let PendingOutboundPayment :: InvoiceReceived { payment_hash } = self {
189
+ * self = PendingOutboundPayment :: Abandoned {
190
+ session_privs : HashSet :: new ( ) ,
191
+ payment_hash : * payment_hash,
192
+ reason : Some ( reason)
193
+ } ;
186
194
}
187
195
}
188
196
@@ -196,6 +204,7 @@ impl PendingOutboundPayment {
196
204
session_privs. remove ( session_priv)
197
205
} ,
198
206
PendingOutboundPayment :: AwaitingInvoice { .. } => false ,
207
+ PendingOutboundPayment :: InvoiceReceived { .. } => false ,
199
208
} ;
200
209
if remove_res {
201
210
if let PendingOutboundPayment :: Retryable { ref mut pending_amt_msat, ref mut pending_fee_msat, .. } = self {
@@ -216,6 +225,7 @@ impl PendingOutboundPayment {
216
225
session_privs. insert ( session_priv)
217
226
}
218
227
PendingOutboundPayment :: AwaitingInvoice { .. } => false ,
228
+ PendingOutboundPayment :: InvoiceReceived { .. } => false ,
219
229
PendingOutboundPayment :: Fulfilled { .. } => false ,
220
230
PendingOutboundPayment :: Abandoned { .. } => false ,
221
231
} ;
@@ -239,6 +249,7 @@ impl PendingOutboundPayment {
239
249
session_privs. len ( )
240
250
} ,
241
251
PendingOutboundPayment :: AwaitingInvoice { .. } => 0 ,
252
+ PendingOutboundPayment :: InvoiceReceived { .. } => 0 ,
242
253
}
243
254
}
244
255
}
@@ -874,7 +885,9 @@ impl OutboundPayments {
874
885
log_error ! ( logger, "Unable to retry payments that were initially sent on LDK versions prior to 0.0.102" ) ;
875
886
return
876
887
} ,
877
- PendingOutboundPayment :: AwaitingInvoice { .. } => {
888
+ PendingOutboundPayment :: AwaitingInvoice { .. } |
889
+ PendingOutboundPayment :: InvoiceReceived { .. } =>
890
+ {
878
891
log_error ! ( logger, "Payment not yet sent" ) ;
879
892
return
880
893
} ,
@@ -1567,6 +1580,9 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
1567
1580
( 5 , AwaitingInvoice ) => {
1568
1581
( 0 , timer_ticks_without_response, required) ,
1569
1582
} ,
1583
+ ( 7 , InvoiceReceived ) => {
1584
+ ( 0 , payment_hash, required) ,
1585
+ } ,
1570
1586
) ;
1571
1587
1572
1588
#[ cfg( test) ]
0 commit comments