File tree Expand file tree Collapse file tree 2 files changed +22
-38
lines changed Expand file tree Collapse file tree 2 files changed +22
-38
lines changed Original file line number Diff line number Diff line change @@ -549,42 +549,7 @@ where
549
549
}
550
550
payment_preimage
551
551
} ,
552
- PaymentPurpose :: Bolt12RefundPayment {
553
- payment_preimage,
554
- payment_secret,
555
- ..
556
- } => {
557
- let payment = PaymentDetails {
558
- id : payment_id,
559
- kind : PaymentKind :: Bolt12Refund {
560
- hash : Some ( payment_hash) ,
561
- preimage : payment_preimage,
562
- secret : Some ( payment_secret) ,
563
- } ,
564
- amount_msat : Some ( amount_msat) ,
565
- direction : PaymentDirection :: Inbound ,
566
- status : PaymentStatus :: Pending ,
567
- } ;
568
- match self . payment_store . insert ( payment) {
569
- Ok ( false ) => ( ) ,
570
- Ok ( true ) => {
571
- log_error ! (
572
- self . logger,
573
- "Bolt12RefundPayment with ID {} was previously known" ,
574
- payment_id,
575
- ) ;
576
- debug_assert ! ( false ) ;
577
- } ,
578
- Err ( e) => {
579
- log_error ! (
580
- self . logger,
581
- "Failed to insert payment with ID {}: {}" ,
582
- payment_id,
583
- e
584
- ) ;
585
- debug_assert ! ( false ) ;
586
- } ,
587
- }
552
+ PaymentPurpose :: Bolt12RefundPayment { payment_preimage, .. } => {
588
553
payment_preimage
589
554
} ,
590
555
PaymentPurpose :: SpontaneousPayment ( preimage) => {
Original file line number Diff line number Diff line change @@ -273,10 +273,29 @@ impl Bolt12Payment {
273
273
/// The returned [`Bolt12Invoice`] is for informational purposes only (i.e., isn't needed to
274
274
/// retrieve the refund).
275
275
pub fn request_refund ( & self , refund : & Refund ) -> Result < Bolt12Invoice , Error > {
276
- self . channel_manager . request_refund_payment ( refund) . map_err ( |e| {
276
+ let invoice = self . channel_manager . request_refund_payment ( refund) . map_err ( |e| {
277
277
log_error ! ( self . logger, "Failed to request refund payment: {:?}" , e) ;
278
278
Error :: InvoiceRequestCreationFailed
279
- } )
279
+ } ) ?;
280
+
281
+ let payment_hash = invoice. payment_hash ( ) ;
282
+ let payment_id = PaymentId ( payment_hash. 0 ) ;
283
+
284
+ let payment = PaymentDetails {
285
+ id : payment_id,
286
+ kind : PaymentKind :: Bolt12Refund {
287
+ hash : Some ( payment_hash) ,
288
+ preimage : None ,
289
+ secret : None ,
290
+ } ,
291
+ amount_msat : Some ( refund. amount_msats ( ) ) ,
292
+ direction : PaymentDirection :: Inbound ,
293
+ status : PaymentStatus :: Pending ,
294
+ } ;
295
+
296
+ self . payment_store . insert ( payment) ?;
297
+
298
+ Ok ( invoice)
280
299
}
281
300
282
301
/// Returns a [`Refund`] that can be used to offer a refund payment of the amount given.
You can’t perform that action at this time.
0 commit comments