@@ -172,20 +172,20 @@ struct ClaimableHTLC {
172
172
onion_payload : OnionPayload ,
173
173
}
174
174
175
- /// A payment identifier used to correlate an MPP payment's per-path HTLC sources internally .
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 MppId ( pub [ u8 ; 32 ] ) ;
177
+ pub ( crate ) struct PaymentId ( pub [ u8 ; 32 ] ) ;
178
178
179
- impl Writeable for MppId {
179
+ impl Writeable for PaymentId {
180
180
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
181
181
self . 0 . write ( w)
182
182
}
183
183
}
184
184
185
- impl Readable for MppId {
185
+ impl Readable for PaymentId {
186
186
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
187
187
let buf: [ u8 ; 32 ] = Readable :: read ( r) ?;
188
- Ok ( MppId ( buf) )
188
+ Ok ( PaymentId ( buf) )
189
189
}
190
190
}
191
191
/// Tracks the inbound corresponding to an outbound HTLC
@@ -198,7 +198,7 @@ pub(crate) enum HTLCSource {
198
198
/// Technically we can recalculate this from the route, but we cache it here to avoid
199
199
/// doing a double-pass on route when we get a failure back
200
200
first_hop_htlc_msat : u64 ,
201
- mpp_id : MppId ,
201
+ payment_id : PaymentId ,
202
202
} ,
203
203
}
204
204
#[ cfg( test) ]
@@ -208,7 +208,7 @@ impl HTLCSource {
208
208
path : Vec :: new ( ) ,
209
209
session_priv : SecretKey :: from_slice ( & [ 1 ; 32 ] ) . unwrap ( ) ,
210
210
first_hop_htlc_msat : 0 ,
211
- mpp_id : MppId ( [ 2 ; 32 ] ) ,
211
+ payment_id : PaymentId ( [ 2 ; 32 ] ) ,
212
212
}
213
213
}
214
214
}
@@ -499,7 +499,7 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
499
499
/// payments over a single path).
500
500
///
501
501
/// Locked *after* channel_state.
502
- pending_outbound_payments : Mutex < HashMap < MppId , HashSet < [ u8 ; 32 ] > > > ,
502
+ pending_outbound_payments : Mutex < HashMap < PaymentId , HashSet < [ u8 ; 32 ] > > > ,
503
503
504
504
our_network_key : SecretKey ,
505
505
our_network_pubkey : PublicKey ,
@@ -1878,7 +1878,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1878
1878
}
1879
1879
1880
1880
// Only public for testing, this should otherwise never be called direcly
1881
- pub ( crate ) fn send_payment_along_path ( & self , path : & Vec < RouteHop > , payment_hash : & PaymentHash , payment_secret : & Option < PaymentSecret > , total_value : u64 , cur_height : u32 , mpp_id : MppId , keysend_preimage : & Option < PaymentPreimage > ) -> Result < ( ) , APIError > {
1881
+ pub ( crate ) fn send_payment_along_path ( & self , path : & Vec < RouteHop > , payment_hash : & PaymentHash , payment_secret : & Option < PaymentSecret > , total_value : u64 , cur_height : u32 , payment_id : PaymentId , keysend_preimage : & Option < PaymentPreimage > ) -> Result < ( ) , APIError > {
1882
1882
log_trace ! ( self . logger, "Attempting to send payment for path with next hop {}" , path. first( ) . unwrap( ) . short_channel_id) ;
1883
1883
let prng_seed = self . keys_manager . get_secure_random_bytes ( ) ;
1884
1884
let session_priv_bytes = self . keys_manager . get_secure_random_bytes ( ) ;
@@ -1894,7 +1894,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1894
1894
1895
1895
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
1896
1896
let mut pending_outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
1897
- let sessions = pending_outbounds. entry ( mpp_id ) . or_insert ( HashSet :: new ( ) ) ;
1897
+ let sessions = pending_outbounds. entry ( payment_id ) . or_insert ( HashSet :: new ( ) ) ;
1898
1898
assert ! ( sessions. insert( session_priv_bytes) ) ;
1899
1899
1900
1900
let err: Result < ( ) , _ > = loop {
@@ -1917,7 +1917,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1917
1917
path: path. clone( ) ,
1918
1918
session_priv: session_priv. clone( ) ,
1919
1919
first_hop_htlc_msat: htlc_msat,
1920
- mpp_id ,
1920
+ payment_id ,
1921
1921
} , onion_packet, & self . logger) , channel_state, chan)
1922
1922
} {
1923
1923
Some ( ( update_add, commitment_signed, monitor_update) ) => {
@@ -2017,7 +2017,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2017
2017
let mut total_value = 0 ;
2018
2018
let our_node_id = self . get_our_node_id ( ) ;
2019
2019
let mut path_errs = Vec :: with_capacity ( route. paths . len ( ) ) ;
2020
- let mpp_id = MppId ( self . keys_manager . get_secure_random_bytes ( ) ) ;
2020
+ let payment_id = PaymentId ( self . keys_manager . get_secure_random_bytes ( ) ) ;
2021
2021
' path_check: for path in route. paths . iter ( ) {
2022
2022
if path. len ( ) < 1 || path. len ( ) > 20 {
2023
2023
path_errs. push ( Err ( APIError :: RouteError { err : "Path didn't go anywhere/had bogus size" } ) ) ;
@@ -2039,7 +2039,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2039
2039
let cur_height = self . best_block . read ( ) . unwrap ( ) . height ( ) + 1 ;
2040
2040
let mut results = Vec :: new ( ) ;
2041
2041
for path in route. paths . iter ( ) {
2042
- results. push ( self . send_payment_along_path ( & path, & payment_hash, payment_secret, total_value, cur_height, mpp_id , & keysend_preimage) ) ;
2042
+ results. push ( self . send_payment_along_path ( & path, & payment_hash, payment_secret, total_value, cur_height, payment_id , & keysend_preimage) ) ;
2043
2043
}
2044
2044
let mut has_ok = false ;
2045
2045
let mut has_err = false ;
@@ -2875,11 +2875,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2875
2875
self . fail_htlc_backwards_internal ( channel_state,
2876
2876
htlc_src, & payment_hash, HTLCFailReason :: Reason { failure_code, data : onion_failure_data} ) ;
2877
2877
} ,
2878
- HTLCSource :: OutboundRoute { session_priv, mpp_id , path, .. } => {
2878
+ HTLCSource :: OutboundRoute { session_priv, payment_id , path, .. } => {
2879
2879
let mut session_priv_bytes = [ 0 ; 32 ] ;
2880
2880
session_priv_bytes. copy_from_slice ( & session_priv[ ..] ) ;
2881
2881
let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
2882
- if let hash_map:: Entry :: Occupied ( mut sessions) = outbounds. entry ( mpp_id ) {
2882
+ if let hash_map:: Entry :: Occupied ( mut sessions) = outbounds. entry ( payment_id ) {
2883
2883
if sessions. get_mut ( ) . remove ( & session_priv_bytes) {
2884
2884
self . pending_events . lock ( ) . unwrap ( ) . push (
2885
2885
events:: Event :: PaymentPathFailed {
@@ -2922,12 +2922,12 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2922
2922
// from block_connected which may run during initialization prior to the chain_monitor
2923
2923
// being fully configured. See the docs for `ChannelManagerReadArgs` for more.
2924
2924
match source {
2925
- HTLCSource :: OutboundRoute { ref path, session_priv, mpp_id , .. } => {
2925
+ HTLCSource :: OutboundRoute { ref path, session_priv, payment_id , .. } => {
2926
2926
let mut session_priv_bytes = [ 0 ; 32 ] ;
2927
2927
session_priv_bytes. copy_from_slice ( & session_priv[ ..] ) ;
2928
2928
let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
2929
2929
let mut all_paths_failed = false ;
2930
- if let hash_map:: Entry :: Occupied ( mut sessions) = outbounds. entry ( mpp_id ) {
2930
+ if let hash_map:: Entry :: Occupied ( mut sessions) = outbounds. entry ( payment_id ) {
2931
2931
if !sessions. get_mut ( ) . remove ( & session_priv_bytes) {
2932
2932
log_trace ! ( self . logger, "Received duplicative fail for HTLC with payment_hash {}" , log_bytes!( payment_hash. 0 ) ) ;
2933
2933
return ;
@@ -3181,12 +3181,12 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3181
3181
3182
3182
fn claim_funds_internal ( & self , mut channel_state_lock : MutexGuard < ChannelHolder < Signer > > , source : HTLCSource , payment_preimage : PaymentPreimage , forwarded_htlc_value_msat : Option < u64 > , from_onchain : bool ) {
3183
3183
match source {
3184
- HTLCSource :: OutboundRoute { session_priv, mpp_id , .. } => {
3184
+ HTLCSource :: OutboundRoute { session_priv, payment_id , .. } => {
3185
3185
mem:: drop ( channel_state_lock) ;
3186
3186
let mut session_priv_bytes = [ 0 ; 32 ] ;
3187
3187
session_priv_bytes. copy_from_slice ( & session_priv[ ..] ) ;
3188
3188
let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
3189
- let found_payment = if let Some ( mut sessions) = outbounds. remove ( & mpp_id ) {
3189
+ let found_payment = if let Some ( mut sessions) = outbounds. remove ( & payment_id ) {
3190
3190
sessions. remove ( & session_priv_bytes)
3191
3191
} else { false } ;
3192
3192
if found_payment {
@@ -5079,23 +5079,23 @@ impl Readable for HTLCSource {
5079
5079
let mut session_priv: :: util:: ser:: OptionDeserWrapper < SecretKey > = :: util:: ser:: OptionDeserWrapper ( None ) ;
5080
5080
let mut first_hop_htlc_msat: u64 = 0 ;
5081
5081
let mut path = Some ( Vec :: new ( ) ) ;
5082
- let mut mpp_id = None ;
5082
+ let mut payment_id = None ;
5083
5083
read_tlv_fields ! ( reader, {
5084
5084
( 0 , session_priv, required) ,
5085
- ( 1 , mpp_id , option) ,
5085
+ ( 1 , payment_id , option) ,
5086
5086
( 2 , first_hop_htlc_msat, required) ,
5087
5087
( 4 , path, vec_type) ,
5088
5088
} ) ;
5089
- if mpp_id . is_none ( ) {
5090
- // For backwards compat, if there was no mpp_id written, use the session_priv bytes
5089
+ if payment_id . is_none ( ) {
5090
+ // For backwards compat, if there was no payment_id written, use the session_priv bytes
5091
5091
// instead.
5092
- mpp_id = Some ( MppId ( * session_priv. 0 . unwrap ( ) . as_ref ( ) ) ) ;
5092
+ payment_id = Some ( PaymentId ( * session_priv. 0 . unwrap ( ) . as_ref ( ) ) ) ;
5093
5093
}
5094
5094
Ok ( HTLCSource :: OutboundRoute {
5095
5095
session_priv : session_priv. 0 . unwrap ( ) ,
5096
5096
first_hop_htlc_msat : first_hop_htlc_msat,
5097
5097
path : path. unwrap ( ) ,
5098
- mpp_id : mpp_id . unwrap ( ) ,
5098
+ payment_id : payment_id . unwrap ( ) ,
5099
5099
} )
5100
5100
}
5101
5101
1 => Ok ( HTLCSource :: PreviousHopData ( Readable :: read ( reader) ?) ) ,
@@ -5107,12 +5107,12 @@ impl Readable for HTLCSource {
5107
5107
impl Writeable for HTLCSource {
5108
5108
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: io:: Error > {
5109
5109
match self {
5110
- HTLCSource :: OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, mpp_id } => {
5110
+ HTLCSource :: OutboundRoute { ref session_priv, ref first_hop_htlc_msat, ref path, payment_id } => {
5111
5111
0u8 . write ( writer) ?;
5112
- let mpp_id_opt = Some ( mpp_id ) ;
5112
+ let payment_id_opt = Some ( payment_id ) ;
5113
5113
write_tlv_fields ! ( writer, {
5114
5114
( 0 , session_priv, required) ,
5115
- ( 1 , mpp_id_opt , option) ,
5115
+ ( 1 , payment_id_opt , option) ,
5116
5116
( 2 , first_hop_htlc_msat, required) ,
5117
5117
( 4 , path, vec_type) ,
5118
5118
} ) ;
@@ -5518,11 +5518,11 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
5518
5518
}
5519
5519
5520
5520
let pending_outbound_payments_count_compat: u64 = Readable :: read ( reader) ?;
5521
- let mut pending_outbound_payments_compat: HashMap < MppId , HashSet < [ u8 ; 32 ] > > =
5521
+ let mut pending_outbound_payments_compat: HashMap < PaymentId , HashSet < [ u8 ; 32 ] > > =
5522
5522
HashMap :: with_capacity ( cmp:: min ( pending_outbound_payments_count_compat as usize , MAX_ALLOC_SIZE /32 ) ) ;
5523
5523
for _ in 0 ..pending_outbound_payments_count_compat {
5524
5524
let session_priv = Readable :: read ( reader) ?;
5525
- if pending_outbound_payments_compat. insert ( MppId ( session_priv) , [ session_priv] . iter ( ) . cloned ( ) . collect ( ) ) . is_some ( ) {
5525
+ if pending_outbound_payments_compat. insert ( PaymentId ( session_priv) , [ session_priv] . iter ( ) . cloned ( ) . collect ( ) ) . is_some ( ) {
5526
5526
return Err ( DecodeError :: InvalidValue )
5527
5527
} ;
5528
5528
}
@@ -5596,7 +5596,7 @@ mod tests {
5596
5596
use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
5597
5597
use core:: time:: Duration ;
5598
5598
use ln:: { PaymentPreimage , PaymentHash , PaymentSecret } ;
5599
- use ln:: channelmanager:: { MppId , PaymentSendFailure } ;
5599
+ use ln:: channelmanager:: { PaymentId , PaymentSendFailure } ;
5600
5600
use ln:: features:: { InitFeatures , InvoiceFeatures } ;
5601
5601
use ln:: functional_test_utils:: * ;
5602
5602
use ln:: msgs;
@@ -5747,11 +5747,11 @@ mod tests {
5747
5747
let net_graph_msg_handler = & nodes[ 0 ] . net_graph_msg_handler ;
5748
5748
let route = get_route ( & nodes[ 0 ] . node . get_our_node_id ( ) , & net_graph_msg_handler. network_graph , & nodes[ 1 ] . node . get_our_node_id ( ) , Some ( InvoiceFeatures :: known ( ) ) , None , & Vec :: new ( ) , 100_000 , TEST_FINAL_CLTV , & logger) . unwrap ( ) ;
5749
5749
let ( payment_preimage, our_payment_hash, payment_secret) = get_payment_preimage_hash ! ( & nodes[ 1 ] ) ;
5750
- let mpp_id = MppId ( [ 42 ; 32 ] ) ;
5750
+ let payment_id = PaymentId ( [ 42 ; 32 ] ) ;
5751
5751
// Use the utility function send_payment_along_path to send the payment with MPP data which
5752
5752
// indicates there are more HTLCs coming.
5753
5753
let cur_height = CHAN_CONFIRM_DEPTH + 1 ; // route_payment calls send_payment, which adds 1 to the current height. So we do the same here to match.
5754
- nodes[ 0 ] . node . send_payment_along_path ( & route. paths [ 0 ] , & our_payment_hash, & Some ( payment_secret) , 200_000 , cur_height, mpp_id , & None ) . unwrap ( ) ;
5754
+ nodes[ 0 ] . node . send_payment_along_path ( & route. paths [ 0 ] , & our_payment_hash, & Some ( payment_secret) , 200_000 , cur_height, payment_id , & None ) . unwrap ( ) ;
5755
5755
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
5756
5756
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
5757
5757
assert_eq ! ( events. len( ) , 1 ) ;
@@ -5781,7 +5781,7 @@ mod tests {
5781
5781
expect_payment_failed ! ( nodes[ 0 ] , our_payment_hash, true ) ;
5782
5782
5783
5783
// Send the second half of the original MPP payment.
5784
- nodes[ 0 ] . node . send_payment_along_path ( & route. paths [ 0 ] , & our_payment_hash, & Some ( payment_secret) , 200_000 , cur_height, mpp_id , & None ) . unwrap ( ) ;
5784
+ nodes[ 0 ] . node . send_payment_along_path ( & route. paths [ 0 ] , & our_payment_hash, & Some ( payment_secret) , 200_000 , cur_height, payment_id , & None ) . unwrap ( ) ;
5785
5785
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
5786
5786
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
5787
5787
assert_eq ! ( events. len( ) , 1 ) ;
0 commit comments