@@ -174,7 +174,7 @@ struct ClaimableHTLC {
174
174
175
175
/// A payment identifier used to uniquely identify a payment to LDK.
176
176
#[ derive( Hash , Copy , Clone , PartialEq , Eq , Debug ) ]
177
- pub ( crate ) struct PaymentId ( pub [ u8 ; 32 ] ) ;
177
+ pub struct PaymentId ( pub [ u8 ; 32 ] ) ;
178
178
179
179
impl Writeable for PaymentId {
180
180
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
@@ -1997,11 +1997,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1997
1997
/// If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
1998
1998
/// bit set (either as required or as available). If multiple paths are present in the Route,
1999
1999
/// we assume the invoice had the basic_mpp feature set.
2000
- pub fn send_payment ( & self , route : & Route , payment_hash : PaymentHash , payment_secret : & Option < PaymentSecret > ) -> Result < ( ) , PaymentSendFailure > {
2000
+ pub fn send_payment ( & self , route : & Route , payment_hash : PaymentHash , payment_secret : & Option < PaymentSecret > ) -> Result < PaymentId , PaymentSendFailure > {
2001
2001
self . send_payment_internal ( route, payment_hash, payment_secret, None )
2002
2002
}
2003
2003
2004
- fn send_payment_internal ( & self , route : & Route , payment_hash : PaymentHash , payment_secret : & Option < PaymentSecret > , keysend_preimage : Option < PaymentPreimage > ) -> Result < ( ) , PaymentSendFailure > {
2004
+ fn send_payment_internal ( & self , route : & Route , payment_hash : PaymentHash , payment_secret : & Option < PaymentSecret > , keysend_preimage : Option < PaymentPreimage > ) -> Result < PaymentId , PaymentSendFailure > {
2005
2005
if route. paths . len ( ) < 1 {
2006
2006
return Err ( PaymentSendFailure :: ParameterError ( APIError :: RouteError { err : "There must be at least one path to send over" } ) ) ;
2007
2007
}
@@ -2059,7 +2059,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2059
2059
} else if has_err {
2060
2060
Err ( PaymentSendFailure :: AllFailedRetrySafe ( results. drain ( ..) . map ( |r| r. unwrap_err ( ) ) . collect ( ) ) )
2061
2061
} else {
2062
- Ok ( ( ) )
2062
+ Ok ( payment_id )
2063
2063
}
2064
2064
}
2065
2065
@@ -2077,14 +2077,14 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2077
2077
/// Note that `route` must have exactly one path.
2078
2078
///
2079
2079
/// [`send_payment`]: Self::send_payment
2080
- pub fn send_spontaneous_payment ( & self , route : & Route , payment_preimage : Option < PaymentPreimage > ) -> Result < PaymentHash , PaymentSendFailure > {
2080
+ pub fn send_spontaneous_payment ( & self , route : & Route , payment_preimage : Option < PaymentPreimage > ) -> Result < ( PaymentHash , PaymentId ) , PaymentSendFailure > {
2081
2081
let preimage = match payment_preimage {
2082
2082
Some ( p) => p,
2083
2083
None => PaymentPreimage ( self . keys_manager . get_secure_random_bytes ( ) ) ,
2084
2084
} ;
2085
2085
let payment_hash = PaymentHash ( Sha256 :: hash ( & preimage. 0 ) . into_inner ( ) ) ;
2086
2086
match self . send_payment_internal ( route, payment_hash, & None , Some ( preimage) ) {
2087
- Ok ( ( ) ) => Ok ( payment_hash) ,
2087
+ Ok ( payment_id ) => Ok ( ( payment_hash, payment_id ) ) ,
2088
2088
Err ( e) => Err ( e)
2089
2089
}
2090
2090
}
@@ -5877,7 +5877,7 @@ mod tests {
5877
5877
// To start (2), send a keysend payment but don't claim it.
5878
5878
let payment_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
5879
5879
let route = get_route ( & nodes[ 0 ] . node . get_our_node_id ( ) , & nodes[ 0 ] . net_graph_msg_handler . network_graph , & expected_route. last ( ) . unwrap ( ) . node . get_our_node_id ( ) , Some ( InvoiceFeatures :: known ( ) ) , None , & Vec :: new ( ) , 100_000 , TEST_FINAL_CLTV , & logger) . unwrap ( ) ;
5880
- let payment_hash = nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) ) . unwrap ( ) ;
5880
+ let ( payment_hash, _ ) = nodes[ 0 ] . node . send_spontaneous_payment ( & route, Some ( payment_preimage) ) . unwrap ( ) ;
5881
5881
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
5882
5882
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
5883
5883
assert_eq ! ( events. len( ) , 1 ) ;
0 commit comments