55// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
66// accordance with one or both of these licenses.
77
8+ use crate :: ffi:: maybe_wrap;
89use crate :: types:: { CustomTlvRecord , DynStore , PaymentStore , Sweeper , Wallet } ;
910
1011use crate :: {
@@ -22,6 +23,7 @@ use crate::logger::Logger;
2223use crate :: payment:: store:: {
2324 PaymentDetails , PaymentDetailsUpdate , PaymentDirection , PaymentKind , PaymentStatus ,
2425} ;
26+ use crate :: payment:: PaymentPreimage ;
2527
2628use crate :: io:: {
2729 EVENT_QUEUE_PERSISTENCE_KEY , EVENT_QUEUE_PERSISTENCE_PRIMARY_NAMESPACE ,
@@ -39,7 +41,7 @@ use lightning::routing::gossip::NodeId;
3941use lightning:: util:: errors:: APIError ;
4042use lightning:: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
4143
42- use lightning_types:: payment:: { PaymentHash , PaymentPreimage } ;
44+ use lightning_types:: payment:: PaymentHash ;
4345
4446use lightning_liquidity:: lsps2:: utils:: compute_opening_fee;
4547
@@ -740,7 +742,7 @@ where
740742 let quantity = payment_context. invoice_request . quantity ;
741743 let kind = PaymentKind :: Bolt12Offer {
742744 hash : Some ( payment_hash) ,
743- preimage : payment_preimage,
745+ preimage : payment_preimage. map ( |preimage| maybe_wrap ( preimage ) ) ,
744746 secret : Some ( payment_secret) ,
745747 offer_id,
746748 payer_note,
@@ -785,7 +787,7 @@ where
785787 // Since it's spontaneous, we insert it now into our store.
786788 let kind = PaymentKind :: Spontaneous {
787789 hash : payment_hash,
788- preimage : Some ( preimage) ,
790+ preimage : Some ( maybe_wrap ( preimage) ) ,
789791 } ;
790792
791793 let payment = PaymentDetails :: new (
@@ -871,7 +873,7 @@ where
871873 payment_secret,
872874 ..
873875 } => PaymentDetailsUpdate {
874- preimage : Some ( payment_preimage) ,
876+ preimage : Some ( payment_preimage. map ( |preimage| maybe_wrap ( preimage ) ) ) ,
875877 secret : Some ( Some ( payment_secret) ) ,
876878 amount_msat : Some ( Some ( amount_msat) ) ,
877879 status : Some ( PaymentStatus :: Succeeded ) ,
@@ -880,7 +882,7 @@ where
880882 PaymentPurpose :: Bolt12OfferPayment {
881883 payment_preimage, payment_secret, ..
882884 } => PaymentDetailsUpdate {
883- preimage : Some ( payment_preimage) ,
885+ preimage : Some ( payment_preimage. map ( |preimage| maybe_wrap ( preimage ) ) ) ,
884886 secret : Some ( Some ( payment_secret) ) ,
885887 amount_msat : Some ( Some ( amount_msat) ) ,
886888 status : Some ( PaymentStatus :: Succeeded ) ,
@@ -891,14 +893,14 @@ where
891893 payment_secret,
892894 ..
893895 } => PaymentDetailsUpdate {
894- preimage : Some ( payment_preimage) ,
896+ preimage : Some ( payment_preimage. map ( |preimage| maybe_wrap ( preimage ) ) ) ,
895897 secret : Some ( Some ( payment_secret) ) ,
896898 amount_msat : Some ( Some ( amount_msat) ) ,
897899 status : Some ( PaymentStatus :: Succeeded ) ,
898900 ..PaymentDetailsUpdate :: new ( payment_id)
899901 } ,
900902 PaymentPurpose :: SpontaneousPayment ( preimage) => PaymentDetailsUpdate {
901- preimage : Some ( Some ( preimage) ) ,
903+ preimage : Some ( Some ( maybe_wrap ( preimage) ) ) ,
902904 amount_msat : Some ( Some ( amount_msat) ) ,
903905 status : Some ( PaymentStatus :: Succeeded ) ,
904906 ..PaymentDetailsUpdate :: new ( payment_id)
@@ -960,7 +962,7 @@ where
960962
961963 let update = PaymentDetailsUpdate {
962964 hash : Some ( Some ( payment_hash) ) ,
963- preimage : Some ( Some ( payment_preimage) ) ,
965+ preimage : Some ( Some ( maybe_wrap ( payment_preimage) ) ) ,
964966 fee_paid_msat : Some ( fee_paid_msat) ,
965967 status : Some ( PaymentStatus :: Succeeded ) ,
966968 ..PaymentDetailsUpdate :: new ( payment_id)
@@ -992,7 +994,7 @@ where
992994 let event = Event :: PaymentSuccessful {
993995 payment_id : Some ( payment_id) ,
994996 payment_hash,
995- payment_preimage : Some ( payment_preimage) ,
997+ payment_preimage : Some ( maybe_wrap ( payment_preimage) ) ,
996998 fee_paid_msat,
997999 } ;
9981000
0 commit comments