@@ -48,6 +48,7 @@ pub(crate) enum PendingOutboundPayment {
48
48
session_privs : HashSet < [ u8 ; 32 ] > ,
49
49
payment_hash : PaymentHash ,
50
50
payment_secret : Option < PaymentSecret > ,
51
+ keysend_preimage : Option < PaymentPreimage > ,
51
52
pending_amt_msat : u64 ,
52
53
/// Used to track the fee paid. Only present if the payment was serialized on 0.0.103+.
53
54
pending_fee_msat : Option < u64 > ,
@@ -432,7 +433,7 @@ impl OutboundPayments {
432
433
F : Fn ( & Vec < RouteHop > , & Option < PaymentParameters > , & PaymentHash , & Option < PaymentSecret > , u64 ,
433
434
u32 , PaymentId , & Option < PaymentPreimage > , [ u8 ; 32 ] ) -> Result < ( ) , APIError >
434
435
{
435
- let onion_session_privs = self . add_new_pending_payment ( payment_hash, * payment_secret, payment_id, route, None , None , entropy_source, best_block_height) ?;
436
+ let onion_session_privs = self . add_new_pending_payment ( payment_hash, * payment_secret, payment_id, None , route, None , None , entropy_source, best_block_height) ?;
436
437
self . pay_route_internal ( route, payment_hash, payment_secret, None , payment_id, None ,
437
438
onion_session_privs, node_signer, best_block_height, & send_payment_along_path)
438
439
. map_err ( |e| { self . remove_outbound_if_all_failed ( payment_id, & e) ; e } )
@@ -453,7 +454,7 @@ impl OutboundPayments {
453
454
None => PaymentPreimage ( entropy_source. get_secure_random_bytes ( ) ) ,
454
455
} ;
455
456
let payment_hash = PaymentHash ( Sha256 :: hash ( & preimage. 0 ) . into_inner ( ) ) ;
456
- let onion_session_privs = self . add_new_pending_payment ( payment_hash, None , payment_id, & route, None , None , entropy_source, best_block_height) ?;
457
+ let onion_session_privs = self . add_new_pending_payment ( payment_hash, None , payment_id, Some ( preimage ) , & route, None , None , entropy_source, best_block_height) ?;
457
458
458
459
match self . pay_route_internal ( route, payment_hash, & None , Some ( preimage) , payment_id, None , onion_session_privs, node_signer, best_block_height, & send_payment_along_path) {
459
460
Ok ( ( ) ) => Ok ( payment_hash) ,
@@ -540,7 +541,7 @@ impl OutboundPayments {
540
541
} ) ) ?;
541
542
542
543
let res = if let Some ( ( payment_hash, payment_secret, retry_strategy) ) = initial_send_info {
543
- let onion_session_privs = self . add_new_pending_payment ( payment_hash, * payment_secret, payment_id, & route, Some ( retry_strategy) , Some ( route_params. payment_params . clone ( ) ) , entropy_source, best_block_height) ?;
544
+ let onion_session_privs = self . add_new_pending_payment ( payment_hash, * payment_secret, payment_id, None , & route, Some ( retry_strategy) , Some ( route_params. payment_params . clone ( ) ) , entropy_source, best_block_height) ?;
544
545
self . pay_route_internal ( & route, payment_hash, payment_secret, None , payment_id, None , onion_session_privs, node_signer, best_block_height, send_payment_along_path)
545
546
} else {
546
547
self . retry_payment_with_route ( & route, payment_id, entropy_source, node_signer, best_block_height, send_payment_along_path)
@@ -669,7 +670,7 @@ impl OutboundPayments {
669
670
}
670
671
671
672
let route = Route { paths : vec ! [ hops] , payment_params : None } ;
672
- let onion_session_privs = self . add_new_pending_payment ( payment_hash, None , payment_id, & route, None , None , entropy_source, best_block_height) ?;
673
+ let onion_session_privs = self . add_new_pending_payment ( payment_hash, None , payment_id, None , & route, None , None , entropy_source, best_block_height) ?;
673
674
674
675
match self . pay_route_internal ( & route, payment_hash, & None , None , payment_id, None , onion_session_privs, node_signer, best_block_height, & send_payment_along_path) {
675
676
Ok ( ( ) ) => Ok ( ( payment_hash, payment_id) ) ,
@@ -685,13 +686,13 @@ impl OutboundPayments {
685
686
& self , payment_hash : PaymentHash , payment_secret : Option < PaymentSecret > , payment_id : PaymentId ,
686
687
route : & Route , retry_strategy : Option < Retry > , entropy_source : & ES , best_block_height : u32
687
688
) -> Result < Vec < [ u8 ; 32 ] > , PaymentSendFailure > where ES :: Target : EntropySource {
688
- self . add_new_pending_payment ( payment_hash, payment_secret, payment_id, route, retry_strategy, None , entropy_source, best_block_height)
689
+ self . add_new_pending_payment ( payment_hash, payment_secret, payment_id, None , route, retry_strategy, None , entropy_source, best_block_height)
689
690
}
690
691
691
692
pub ( super ) fn add_new_pending_payment < ES : Deref > (
692
693
& self , payment_hash : PaymentHash , payment_secret : Option < PaymentSecret > , payment_id : PaymentId ,
693
- route : & Route , retry_strategy : Option < Retry > , payment_params : Option < PaymentParameters > ,
694
- entropy_source : & ES , best_block_height : u32
694
+ keysend_preimage : Option < PaymentPreimage > , route : & Route , retry_strategy : Option < Retry > ,
695
+ payment_params : Option < PaymentParameters > , entropy_source : & ES , best_block_height : u32
695
696
) -> Result < Vec < [ u8 ; 32 ] > , PaymentSendFailure > where ES :: Target : EntropySource {
696
697
let mut onion_session_privs = Vec :: with_capacity ( route. paths . len ( ) ) ;
697
698
for _ in 0 ..route. paths . len ( ) {
@@ -711,6 +712,7 @@ impl OutboundPayments {
711
712
pending_fee_msat : Some ( 0 ) ,
712
713
payment_hash,
713
714
payment_secret,
715
+ keysend_preimage,
714
716
starting_block_height : best_block_height,
715
717
total_msat : route. get_total_amount ( ) ,
716
718
} ) ;
@@ -1158,6 +1160,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
1158
1160
( 10 , starting_block_height, required) ,
1159
1161
( not_written, retry_strategy, ( static_value, None ) ) ,
1160
1162
( not_written, attempts, ( static_value, PaymentAttempts :: new( ) ) ) ,
1163
+ ( not_written, keysend_preimage, ( static_value, None ) ) ,
1161
1164
} ,
1162
1165
( 3 , Abandoned ) => {
1163
1166
( 0 , session_privs, required) ,
@@ -1247,9 +1250,9 @@ mod tests {
1247
1250
Err ( LightningError { err : String :: new ( ) , action : ErrorAction :: IgnoreError } ) ) ;
1248
1251
1249
1252
let err = if on_retry {
1250
- outbound_payments. add_new_pending_payment ( PaymentHash ( [ 0 ; 32 ] ) , None , PaymentId ( [ 0 ; 32 ] ) ,
1251
- & Route { paths : vec ! [ ] , payment_params : None } , Some ( Retry :: Attempts ( 1 ) ) , Some ( route_params . payment_params . clone ( ) ) ,
1252
- & & keys_manager, 0 ) . unwrap ( ) ;
1253
+ outbound_payments. add_new_pending_payment ( PaymentHash ( [ 0 ; 32 ] ) , None , PaymentId ( [ 0 ; 32 ] ) , None ,
1254
+ & Route { paths : vec ! [ ] , payment_params : None } , Some ( Retry :: Attempts ( 1 ) ) ,
1255
+ Some ( route_params . payment_params . clone ( ) ) , & & keys_manager, 0 ) . unwrap ( ) ;
1253
1256
outbound_payments. pay_internal (
1254
1257
PaymentId ( [ 0 ; 32 ] ) , None , route_params, & & router, vec ! [ ] , InFlightHtlcs :: new ( ) ,
1255
1258
& & keys_manager, & & keys_manager, 0 , & & logger, & |_, _, _, _, _, _, _, _, _| Ok ( ( ) ) ) . unwrap_err ( )
0 commit comments