@@ -41,6 +41,9 @@ pub(crate) enum PendingOutboundPayment {
41
41
AwaitingInvoice {
42
42
timer_ticks_without_response : u8 ,
43
43
} ,
44
+ InvoiceReceived {
45
+ payment_hash : PaymentHash ,
46
+ } ,
44
47
Retryable {
45
48
retry_strategy : Option < Retry > ,
46
49
attempts : PaymentAttempts ,
@@ -140,6 +143,7 @@ impl PendingOutboundPayment {
140
143
match self {
141
144
PendingOutboundPayment :: Legacy { .. } => None ,
142
145
PendingOutboundPayment :: AwaitingInvoice { .. } => None ,
146
+ PendingOutboundPayment :: InvoiceReceived { payment_hash } => Some ( * payment_hash) ,
143
147
PendingOutboundPayment :: Retryable { payment_hash, .. } => Some ( * payment_hash) ,
144
148
PendingOutboundPayment :: Fulfilled { payment_hash, .. } => * payment_hash,
145
149
PendingOutboundPayment :: Abandoned { payment_hash, .. } => Some ( * payment_hash) ,
@@ -153,10 +157,8 @@ impl PendingOutboundPayment {
153
157
PendingOutboundPayment :: Retryable { session_privs, .. } |
154
158
PendingOutboundPayment :: Fulfilled { session_privs, .. } |
155
159
PendingOutboundPayment :: Abandoned { session_privs, .. } => session_privs,
156
- PendingOutboundPayment :: AwaitingInvoice { .. } => {
157
- debug_assert ! ( false ) ;
158
- return ;
159
- } ,
160
+ PendingOutboundPayment :: AwaitingInvoice { .. } |
161
+ PendingOutboundPayment :: InvoiceReceived { .. } => { debug_assert ! ( false ) ; return ; } ,
160
162
} ) ;
161
163
let payment_hash = self . payment_hash ( ) ;
162
164
* self = PendingOutboundPayment :: Fulfilled { session_privs, payment_hash, timer_ticks_without_htlcs : 0 } ;
@@ -171,6 +173,12 @@ impl PendingOutboundPayment {
171
173
payment_hash : * payment_hash,
172
174
reason : Some ( reason)
173
175
} ;
176
+ } else if let PendingOutboundPayment :: InvoiceReceived { payment_hash } = self {
177
+ * self = PendingOutboundPayment :: Abandoned {
178
+ session_privs : HashSet :: new ( ) ,
179
+ payment_hash : * payment_hash,
180
+ reason : Some ( reason)
181
+ } ;
174
182
}
175
183
}
176
184
@@ -184,6 +192,7 @@ impl PendingOutboundPayment {
184
192
session_privs. remove ( session_priv)
185
193
} ,
186
194
PendingOutboundPayment :: AwaitingInvoice { .. } => false ,
195
+ PendingOutboundPayment :: InvoiceReceived { .. } => false ,
187
196
} ;
188
197
if remove_res {
189
198
if let PendingOutboundPayment :: Retryable { ref mut pending_amt_msat, ref mut pending_fee_msat, .. } = self {
@@ -204,6 +213,7 @@ impl PendingOutboundPayment {
204
213
session_privs. insert ( session_priv)
205
214
}
206
215
PendingOutboundPayment :: AwaitingInvoice { .. } => false ,
216
+ PendingOutboundPayment :: InvoiceReceived { .. } => false ,
207
217
PendingOutboundPayment :: Fulfilled { .. } => false ,
208
218
PendingOutboundPayment :: Abandoned { .. } => false ,
209
219
} ;
@@ -227,6 +237,7 @@ impl PendingOutboundPayment {
227
237
session_privs. len ( )
228
238
} ,
229
239
PendingOutboundPayment :: AwaitingInvoice { .. } => 0 ,
240
+ PendingOutboundPayment :: InvoiceReceived { .. } => 0 ,
230
241
}
231
242
}
232
243
}
@@ -862,7 +873,9 @@ impl OutboundPayments {
862
873
log_error ! ( logger, "Unable to retry payments that were initially sent on LDK versions prior to 0.0.102" ) ;
863
874
return
864
875
} ,
865
- PendingOutboundPayment :: AwaitingInvoice { .. } => {
876
+ PendingOutboundPayment :: AwaitingInvoice { .. } |
877
+ PendingOutboundPayment :: InvoiceReceived { .. } =>
878
+ {
866
879
log_error ! ( logger, "Payment not yet sent" ) ;
867
880
return
868
881
} ,
@@ -1550,6 +1563,9 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
1550
1563
( 5 , AwaitingInvoice ) => {
1551
1564
( 0 , timer_ticks_without_response, required) ,
1552
1565
} ,
1566
+ ( 7 , InvoiceReceived ) => {
1567
+ ( 0 , payment_hash, required) ,
1568
+ } ,
1553
1569
) ;
1554
1570
1555
1571
#[ cfg( test) ]
0 commit comments