@@ -165,11 +165,11 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, targ
165
165
// TODO: Obviously *only* using total fee cost sucks. We should consider weighting by
166
166
// uptime/success in using a node in the past.
167
167
if * target == * our_node_id {
168
- return Err ( LightningError { err : "Cannot generate a route to ourselves" , action : ErrorAction :: IgnoreError } ) ;
168
+ return Err ( LightningError { err : "Cannot generate a route to ourselves" . to_owned ( ) , action : ErrorAction :: IgnoreError } ) ;
169
169
}
170
170
171
171
if final_value_msat > 21_000_000 * 1_0000_0000 * 1000 {
172
- return Err ( LightningError { err : "Cannot generate a route of more value than all existing satoshis" , action : ErrorAction :: IgnoreError } ) ;
172
+ return Err ( LightningError { err : "Cannot generate a route of more value than all existing satoshis" . to_owned ( ) , action : ErrorAction :: IgnoreError } ) ;
173
173
}
174
174
175
175
// We do a dest-to-source Dijkstra's sorting by each node's distance from the destination
@@ -209,7 +209,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, targ
209
209
first_hop_targets. insert ( chan. remote_network_id , ( short_channel_id, chan. counterparty_features . clone ( ) ) ) ;
210
210
}
211
211
if first_hop_targets. is_empty ( ) {
212
- return Err ( LightningError { err : "Cannot route when there are no outbound routes away from us" , action : ErrorAction :: IgnoreError } ) ;
212
+ return Err ( LightningError { err : "Cannot route when there are no outbound routes away from us" . to_owned ( ) , action : ErrorAction :: IgnoreError } ) ;
213
213
}
214
214
}
215
215
@@ -374,7 +374,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, targ
374
374
375
375
let new_entry = match dist. remove ( & res. last ( ) . unwrap ( ) . pubkey ) {
376
376
Some ( hop) => hop. 3 ,
377
- None => return Err ( LightningError { err : "Failed to find a non-fee-overflowing path to the given destination" , action : ErrorAction :: IgnoreError } ) ,
377
+ None => return Err ( LightningError { err : "Failed to find a non-fee-overflowing path to the given destination" . to_owned ( ) , action : ErrorAction :: IgnoreError } ) ,
378
378
} ;
379
379
res. last_mut ( ) . unwrap ( ) . fee_msat = new_entry. fee_msat ;
380
380
res. last_mut ( ) . unwrap ( ) . cltv_expiry_delta = new_entry. cltv_expiry_delta ;
@@ -395,7 +395,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, targ
395
395
}
396
396
}
397
397
398
- Err ( LightningError { err : "Failed to find a path to the given destination" , action : ErrorAction :: IgnoreError } )
398
+ Err ( LightningError { err : "Failed to find a path to the given destination" . to_owned ( ) , action : ErrorAction :: IgnoreError } )
399
399
}
400
400
401
401
#[ cfg( test) ]
@@ -881,7 +881,7 @@ mod tests {
881
881
assert_eq ! ( route. paths[ 0 ] [ 0 ] . fee_msat, 200 ) ;
882
882
assert_eq ! ( route. paths[ 0 ] [ 0 ] . cltv_expiry_delta, ( 13 << 8 ) | 1 ) ;
883
883
assert_eq ! ( route. paths[ 0 ] [ 0 ] . node_features. le_flags( ) , & vec![ 0b11 ] ) ; // it should also override our view of their features
884
- assert_eq ! ( route. paths[ 0 ] [ 0 ] . channel_features. le_flags( ) , & Vec :: new( ) ) ; // No feature flags will meet the relevant-to-channel conversion
884
+ assert_eq ! ( route. paths[ 0 ] [ 0 ] . channel_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // No feature flags will meet the relevant-to-channel conversion
885
885
886
886
assert_eq ! ( route. paths[ 0 ] [ 1 ] . pubkey, node3) ;
887
887
assert_eq ! ( route. paths[ 0 ] [ 1 ] . short_channel_id, 13 ) ;
@@ -945,7 +945,7 @@ mod tests {
945
945
assert_eq ! ( route. paths[ 0 ] [ 0 ] . fee_msat, 200 ) ;
946
946
assert_eq ! ( route. paths[ 0 ] [ 0 ] . cltv_expiry_delta, ( 13 << 8 ) | 1 ) ;
947
947
assert_eq ! ( route. paths[ 0 ] [ 0 ] . node_features. le_flags( ) , & vec![ 0b11 ] ) ; // it should also override our view of their features
948
- assert_eq ! ( route. paths[ 0 ] [ 0 ] . channel_features. le_flags( ) , & Vec :: new( ) ) ; // No feature flags will meet the relevant-to-channel conversion
948
+ assert_eq ! ( route. paths[ 0 ] [ 0 ] . channel_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // No feature flags will meet the relevant-to-channel conversion
949
949
950
950
assert_eq ! ( route. paths[ 0 ] [ 1 ] . pubkey, node3) ;
951
951
assert_eq ! ( route. paths[ 0 ] [ 1 ] . short_channel_id, 13 ) ;
@@ -1008,7 +1008,7 @@ mod tests {
1008
1008
assert_eq ! ( route. paths[ 0 ] [ 0 ] . fee_msat, 200 ) ;
1009
1009
assert_eq ! ( route. paths[ 0 ] [ 0 ] . cltv_expiry_delta, ( 13 << 8 ) | 1 ) ;
1010
1010
assert_eq ! ( route. paths[ 0 ] [ 0 ] . node_features. le_flags( ) , & vec![ 0b11 ] ) ;
1011
- assert_eq ! ( route. paths[ 0 ] [ 0 ] . channel_features. le_flags( ) , & Vec :: new( ) ) ; // No feature flags will meet the relevant-to-channel conversion
1011
+ assert_eq ! ( route. paths[ 0 ] [ 0 ] . channel_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // No feature flags will meet the relevant-to-channel conversion
1012
1012
1013
1013
assert_eq ! ( route. paths[ 0 ] [ 1 ] . pubkey, node3) ;
1014
1014
assert_eq ! ( route. paths[ 0 ] [ 1 ] . short_channel_id, 13 ) ;
@@ -1082,8 +1082,8 @@ mod tests {
1082
1082
assert_eq ! ( route. paths[ 0 ] [ 4 ] . short_channel_id, 8 ) ;
1083
1083
assert_eq ! ( route. paths[ 0 ] [ 4 ] . fee_msat, 100 ) ;
1084
1084
assert_eq ! ( route. paths[ 0 ] [ 4 ] . cltv_expiry_delta, 42 ) ;
1085
- assert_eq ! ( route. paths[ 0 ] [ 4 ] . node_features. le_flags( ) , & Vec :: new( ) ) ; // We dont pass flags in from invoices yet
1086
- assert_eq ! ( route. paths[ 0 ] [ 4 ] . channel_features. le_flags( ) , & Vec :: new( ) ) ; // We can't learn any flags from invoices, sadly
1085
+ assert_eq ! ( route. paths[ 0 ] [ 4 ] . node_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // We dont pass flags in from invoices yet
1086
+ assert_eq ! ( route. paths[ 0 ] [ 4 ] . channel_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // We can't learn any flags from invoices, sadly
1087
1087
1088
1088
// Simple test with outbound channel to 4 to test that last_hops and first_hops connect
1089
1089
let our_chans = vec ! [ channelmanager:: ChannelDetails {
@@ -1105,14 +1105,14 @@ mod tests {
1105
1105
assert_eq ! ( route. paths[ 0 ] [ 0 ] . fee_msat, 0 ) ;
1106
1106
assert_eq ! ( route. paths[ 0 ] [ 0 ] . cltv_expiry_delta, ( 8 << 8 ) | 1 ) ;
1107
1107
assert_eq ! ( route. paths[ 0 ] [ 0 ] . node_features. le_flags( ) , & vec![ 0b11 ] ) ;
1108
- assert_eq ! ( route. paths[ 0 ] [ 0 ] . channel_features. le_flags( ) , & Vec :: new( ) ) ; // No feature flags will meet the relevant-to-channel conversion
1108
+ assert_eq ! ( route. paths[ 0 ] [ 0 ] . channel_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // No feature flags will meet the relevant-to-channel conversion
1109
1109
1110
1110
assert_eq ! ( route. paths[ 0 ] [ 1 ] . pubkey, node7) ;
1111
1111
assert_eq ! ( route. paths[ 0 ] [ 1 ] . short_channel_id, 8 ) ;
1112
1112
assert_eq ! ( route. paths[ 0 ] [ 1 ] . fee_msat, 100 ) ;
1113
1113
assert_eq ! ( route. paths[ 0 ] [ 1 ] . cltv_expiry_delta, 42 ) ;
1114
- assert_eq ! ( route. paths[ 0 ] [ 1 ] . node_features. le_flags( ) , & Vec :: new( ) ) ; // We dont pass flags in from invoices yet
1115
- assert_eq ! ( route. paths[ 0 ] [ 1 ] . channel_features. le_flags( ) , & Vec :: new( ) ) ; // We can't learn any flags from invoices, sadly
1114
+ assert_eq ! ( route. paths[ 0 ] [ 1 ] . node_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // We dont pass flags in from invoices yet
1115
+ assert_eq ! ( route. paths[ 0 ] [ 1 ] . channel_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // We can't learn any flags from invoices, sadly
1116
1116
1117
1117
last_hops[ 0 ] . fees . base_msat = 1000 ;
1118
1118
@@ -1147,8 +1147,8 @@ mod tests {
1147
1147
assert_eq ! ( route. paths[ 0 ] [ 3 ] . short_channel_id, 10 ) ;
1148
1148
assert_eq ! ( route. paths[ 0 ] [ 3 ] . fee_msat, 100 ) ;
1149
1149
assert_eq ! ( route. paths[ 0 ] [ 3 ] . cltv_expiry_delta, 42 ) ;
1150
- assert_eq ! ( route. paths[ 0 ] [ 3 ] . node_features. le_flags( ) , & Vec :: new( ) ) ; // We dont pass flags in from invoices yet
1151
- assert_eq ! ( route. paths[ 0 ] [ 3 ] . channel_features. le_flags( ) , & Vec :: new( ) ) ; // We can't learn any flags from invoices, sadly
1150
+ assert_eq ! ( route. paths[ 0 ] [ 3 ] . node_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // We dont pass flags in from invoices yet
1151
+ assert_eq ! ( route. paths[ 0 ] [ 3 ] . channel_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // We can't learn any flags from invoices, sadly
1152
1152
1153
1153
// ...but still use 8 for larger payments as 6 has a variable feerate
1154
1154
let route = get_route ( & our_id, & net_graph_msg_handler. network_graph . read ( ) . unwrap ( ) , & node7, None , & last_hops, 2000 , 42 , Arc :: clone ( & logger) ) . unwrap ( ) ;
@@ -1188,7 +1188,7 @@ mod tests {
1188
1188
assert_eq ! ( route. paths[ 0 ] [ 4 ] . short_channel_id, 8 ) ;
1189
1189
assert_eq ! ( route. paths[ 0 ] [ 4 ] . fee_msat, 2000 ) ;
1190
1190
assert_eq ! ( route. paths[ 0 ] [ 4 ] . cltv_expiry_delta, 42 ) ;
1191
- assert_eq ! ( route. paths[ 0 ] [ 4 ] . node_features. le_flags( ) , & Vec :: new( ) ) ; // We dont pass flags in from invoices yet
1192
- assert_eq ! ( route. paths[ 0 ] [ 4 ] . channel_features. le_flags( ) , & Vec :: new( ) ) ; // We can't learn any flags from invoices, sadly
1191
+ assert_eq ! ( route. paths[ 0 ] [ 4 ] . node_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // We dont pass flags in from invoices yet
1192
+ assert_eq ! ( route. paths[ 0 ] [ 4 ] . channel_features. le_flags( ) , & Vec :: < u8 > :: new( ) ) ; // We can't learn any flags from invoices, sadly
1193
1193
}
1194
1194
}
0 commit comments