@@ -53,6 +53,9 @@ pub(crate) enum PendingOutboundPayment {
5353 AwaitingInvoice {
5454 timer_ticks_without_response : u8 ,
5555 } ,
56+ InvoiceReceived {
57+ payment_hash : PaymentHash ,
58+ } ,
5659 Retryable {
5760 retry_strategy : Option < Retry > ,
5861 attempts : PaymentAttempts ,
@@ -152,6 +155,7 @@ impl PendingOutboundPayment {
152155 match self {
153156 PendingOutboundPayment :: Legacy { .. } => None ,
154157 PendingOutboundPayment :: AwaitingInvoice { .. } => None ,
158+ PendingOutboundPayment :: InvoiceReceived { payment_hash } => Some ( * payment_hash) ,
155159 PendingOutboundPayment :: Retryable { payment_hash, .. } => Some ( * payment_hash) ,
156160 PendingOutboundPayment :: Fulfilled { payment_hash, .. } => * payment_hash,
157161 PendingOutboundPayment :: Abandoned { payment_hash, .. } => Some ( * payment_hash) ,
@@ -165,10 +169,8 @@ impl PendingOutboundPayment {
165169 PendingOutboundPayment :: Retryable { session_privs, .. } |
166170 PendingOutboundPayment :: Fulfilled { session_privs, .. } |
167171 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 ; } ,
172174 } ) ;
173175 let payment_hash = self . payment_hash ( ) ;
174176 * self = PendingOutboundPayment :: Fulfilled { session_privs, payment_hash, timer_ticks_without_htlcs : 0 } ;
@@ -183,6 +185,12 @@ impl PendingOutboundPayment {
183185 payment_hash : * payment_hash,
184186 reason : Some ( reason)
185187 } ;
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+ } ;
186194 }
187195 }
188196
@@ -195,10 +203,8 @@ impl PendingOutboundPayment {
195203 PendingOutboundPayment :: Abandoned { session_privs, .. } => {
196204 session_privs. remove ( session_priv)
197205 } ,
198- PendingOutboundPayment :: AwaitingInvoice { .. } => {
199- debug_assert ! ( false ) ;
200- false
201- } ,
206+ PendingOutboundPayment :: AwaitingInvoice { .. } |
207+ PendingOutboundPayment :: InvoiceReceived { .. } => { debug_assert ! ( false ) ; false } ,
202208 } ;
203209 if remove_res {
204210 if let PendingOutboundPayment :: Retryable { ref mut pending_amt_msat, ref mut pending_fee_msat, .. } = self {
@@ -217,11 +223,9 @@ impl PendingOutboundPayment {
217223 PendingOutboundPayment :: Legacy { session_privs } |
218224 PendingOutboundPayment :: Retryable { session_privs, .. } => {
219225 session_privs. insert ( session_priv)
220- }
221- PendingOutboundPayment :: AwaitingInvoice { .. } => {
222- debug_assert ! ( false ) ;
223- false
224- } ,
226+ } ,
227+ PendingOutboundPayment :: AwaitingInvoice { .. } |
228+ PendingOutboundPayment :: InvoiceReceived { .. } => { debug_assert ! ( false ) ; false } ,
225229 PendingOutboundPayment :: Fulfilled { .. } => false ,
226230 PendingOutboundPayment :: Abandoned { .. } => false ,
227231 } ;
@@ -245,6 +249,7 @@ impl PendingOutboundPayment {
245249 session_privs. len ( )
246250 } ,
247251 PendingOutboundPayment :: AwaitingInvoice { .. } => 0 ,
252+ PendingOutboundPayment :: InvoiceReceived { .. } => 0 ,
248253 }
249254 }
250255}
@@ -880,7 +885,9 @@ impl OutboundPayments {
880885 log_error ! ( logger, "Unable to retry payments that were initially sent on LDK versions prior to 0.0.102" ) ;
881886 return
882887 } ,
883- PendingOutboundPayment :: AwaitingInvoice { .. } => {
888+ PendingOutboundPayment :: AwaitingInvoice { .. } |
889+ PendingOutboundPayment :: InvoiceReceived { .. } =>
890+ {
884891 log_error ! ( logger, "Payment not yet sent" ) ;
885892 return
886893 } ,
@@ -1573,6 +1580,9 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
15731580 ( 5 , AwaitingInvoice ) => {
15741581 ( 0 , timer_ticks_without_response, required) ,
15751582 } ,
1583+ ( 7 , InvoiceReceived ) => {
1584+ ( 0 , payment_hash, required) ,
1585+ } ,
15761586) ;
15771587
15781588#[ cfg( test) ]
0 commit comments