@@ -57,43 +57,29 @@ impl SpontaneousPayment {
5757 pub fn send (
5858 & self , amount_msat : u64 , node_id : PublicKey , sending_parameters : Option < SendingParameters > ,
5959 ) -> Result < PaymentId , Error > {
60- self . send_inner ( amount_msat, node_id, sending_parameters, None , None )
60+ self . send_inner ( amount_msat, node_id, sending_parameters, None )
6161 }
6262
6363 /// Send a spontaneous payment including a list of custom TLVs.
6464 pub fn send_with_custom_tlvs (
6565 & self , amount_msat : u64 , node_id : PublicKey , sending_parameters : Option < SendingParameters > ,
6666 custom_tlvs : Vec < CustomTlvRecord > ,
6767 ) -> Result < PaymentId , Error > {
68- self . send_inner ( amount_msat, node_id, sending_parameters, Some ( custom_tlvs) , None )
69- }
70-
71- /// Send a spontaneous with custom preimage
72- pub fn send_with_preimage (
73- & self , amount_msat : u64 , node_id : PublicKey , sending_parameters : Option < SendingParameters > ,
74- preimage : PaymentPreimage ,
75- ) -> Result < PaymentId , Error > {
76- self . send_inner ( amount_msat, node_id, sending_parameters, None , Some ( preimage) )
77- }
78-
79- /// Send a spontaneous payment with custom preimage including a list of custom TLVs.
80- pub fn send_with_preimage_and_custom_tlvs (
81- & self , amount_msat : u64 , node_id : PublicKey , sending_parameters : Option < SendingParameters > ,
82- custom_tlvs : Vec < CustomTlvRecord > , preimage : PaymentPreimage ,
83- ) -> Result < PaymentId , Error > {
84- self . send_inner ( amount_msat, node_id, sending_parameters, Some ( custom_tlvs) , Some ( preimage) )
68+ self . send_inner ( amount_msat, node_id, sending_parameters, Some ( custom_tlvs) )
8569 }
8670
8771 fn send_inner (
8872 & self , amount_msat : u64 , node_id : PublicKey , sending_parameters : Option < SendingParameters > ,
89- custom_tlvs : Option < Vec < CustomTlvRecord > > , preimage : Option < PaymentPreimage > ,
73+ custom_tlvs : Option < Vec < CustomTlvRecord > > ,
9074 ) -> Result < PaymentId , Error > {
9175 let rt_lock = self . runtime . read ( ) . unwrap ( ) ;
9276 if rt_lock. is_none ( ) {
9377 return Err ( Error :: NotRunning ) ;
9478 }
9579
96- let payment_preimage = preimage
80+ let payment_preimage = sending_parameters
81+ . as_ref ( )
82+ . and_then ( |sp| sp. preimage )
9783 . unwrap_or_else ( || PaymentPreimage ( self . keys_manager . get_secure_random_bytes ( ) ) ) ;
9884 let payment_hash = PaymentHash :: from ( payment_preimage) ;
9985 let payment_id = PaymentId ( payment_hash. 0 ) ;
0 commit comments