X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Foutbound_payment.rs;h=d6e32ed2519e030e49ebd2a3c6d909c500a344b1;hb=5ce4bfc1f6369cde16a88f2d2af416fc32f71082;hp=8867b2e96ae14c3e75bb960d5dd9fa97ed10d746;hpb=6d819796f2efedb924601c3e3bbbb23b2aefb131;p=rust-lightning diff --git a/lightning/src/ln/outbound_payment.rs b/lightning/src/ln/outbound_payment.rs index 8867b2e9..d6e32ed2 100644 --- a/lightning/src/ln/outbound_payment.rs +++ b/lightning/src/ln/outbound_payment.rs @@ -789,7 +789,9 @@ impl OutboundPayments { Some(RouteParameters { payment_params: payment_params.clone(), final_value_msat: pending_amt_unsent, - final_cltv_expiry_delta: max_unsent_cltv_delta, + final_cltv_expiry_delta: + if let Some(delta) = payment_params.final_cltv_expiry_delta { delta } + else { max_unsent_cltv_delta }, }) } else { None } } else { None }, @@ -987,7 +989,9 @@ impl OutboundPayments { Some(RouteParameters { payment_params: payment_params_data.clone(), final_value_msat: path_last_hop.fee_msat, - final_cltv_expiry_delta: path_last_hop.cltv_expiry_delta, + final_cltv_expiry_delta: + if let Some(delta) = payment_params_data.final_cltv_expiry_delta { delta } + else { path_last_hop.cltv_expiry_delta }, }) } else { None }; log_trace!(logger, "Failing outbound payment HTLC with payment_hash {}", log_bytes!(payment_hash.0)); @@ -1149,8 +1153,9 @@ mod tests { let past_expiry_time = std::time::SystemTime::UNIX_EPOCH.elapsed().unwrap().as_secs() - 2; let payment_params = PaymentParameters::from_node_id( - PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap())) - .with_expiry_time(past_expiry_time); + PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()), + 0 + ).with_expiry_time(past_expiry_time); let expired_route_params = RouteParameters { payment_params, final_value_msat: 0, @@ -1184,15 +1189,16 @@ mod tests { let secp_ctx = Secp256k1::new(); let keys_manager = test_utils::TestKeysInterface::new(&[0; 32], Network::Testnet); - router.expect_find_route(Err(LightningError { err: String::new(), action: ErrorAction::IgnoreError })); - let payment_params = PaymentParameters::from_node_id( - PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap())); + PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()), 0); let route_params = RouteParameters { payment_params, final_value_msat: 0, final_cltv_expiry_delta: 0, }; + router.expect_find_route(route_params.clone(), + Err(LightningError { err: String::new(), action: ErrorAction::IgnoreError })); + let err = if on_retry { outbound_payments.add_new_pending_payment(PaymentHash([0; 32]), None, PaymentId([0; 32]), &Route { paths: vec![], payment_params: None }, Retry::Attempts(1), Some(route_params.clone()),