@@ -57,43 +57,29 @@ impl SpontaneousPayment {
57
57
pub fn send (
58
58
& self , amount_msat : u64 , node_id : PublicKey , sending_parameters : Option < SendingParameters > ,
59
59
) -> 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 )
61
61
}
62
62
63
63
/// Send a spontaneous payment including a list of custom TLVs.
64
64
pub fn send_with_custom_tlvs (
65
65
& self , amount_msat : u64 , node_id : PublicKey , sending_parameters : Option < SendingParameters > ,
66
66
custom_tlvs : Vec < CustomTlvRecord > ,
67
67
) -> 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) )
85
69
}
86
70
87
71
fn send_inner (
88
72
& 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 > > ,
90
74
) -> Result < PaymentId , Error > {
91
75
let rt_lock = self . runtime . read ( ) . unwrap ( ) ;
92
76
if rt_lock. is_none ( ) {
93
77
return Err ( Error :: NotRunning ) ;
94
78
}
95
79
96
- let payment_preimage = preimage
80
+ let payment_preimage = sending_parameters
81
+ . as_ref ( )
82
+ . and_then ( |sp| sp. preimage )
97
83
. unwrap_or_else ( || PaymentPreimage ( self . keys_manager . get_secure_random_bytes ( ) ) ) ;
98
84
let payment_hash = PaymentHash :: from ( payment_preimage) ;
99
85
let payment_id = PaymentId ( payment_hash. 0 ) ;
0 commit comments