Skip to content

Fix router-backtrack cases in last-hop hints #3586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
4 changes: 2 additions & 2 deletions fuzz/src/chanmon_consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use lightning::ln::channelmanager::{
use lightning::ln::functional_test_utils::*;
use lightning::ln::inbound_payment::ExpandedKey;
use lightning::ln::msgs::{
self, ChannelMessageHandler, CommitmentUpdate, DecodeError, Init, UpdateAddHTLC,
ChannelMessageHandler, CommitmentUpdate, DecodeError, Init, UpdateAddHTLC,
};
use lightning::ln::script::ShutdownScript;
use lightning::ln::types::ChannelId;
Expand Down Expand Up @@ -118,7 +118,7 @@ impl Router for FuzzRouter {
fn find_route(
&self, _payer: &PublicKey, _params: &RouteParameters,
_first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs,
) -> Result<Route, msgs::LightningError> {
) -> Result<Route, &'static str> {
unreachable!()
}

Expand Down
9 changes: 3 additions & 6 deletions fuzz/src/full_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use lightning::ln::channelmanager::{
};
use lightning::ln::functional_test_utils::*;
use lightning::ln::inbound_payment::ExpandedKey;
use lightning::ln::msgs::{self, DecodeError};
use lightning::ln::msgs::DecodeError;
use lightning::ln::peer_handler::{
IgnoringMessageHandler, MessageHandler, PeerManager, SocketDescriptor,
};
Expand Down Expand Up @@ -151,11 +151,8 @@ impl Router for FuzzRouter {
fn find_route(
&self, _payer: &PublicKey, _params: &RouteParameters,
_first_hops: Option<&[&ChannelDetails]>, _inflight_htlcs: InFlightHtlcs,
) -> Result<Route, msgs::LightningError> {
Err(msgs::LightningError {
err: String::from("Not implemented"),
action: msgs::ErrorAction::IgnoreError,
})
) -> Result<Route, &'static str> {
Err("Not implemented")
}

fn create_blinded_payment_paths<T: secp256k1::Signing + secp256k1::Verification>(
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/functional_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2169,7 +2169,7 @@ macro_rules! get_payment_preimage_hash {
}

/// Gets a route from the given sender to the node described in `payment_params`.
pub fn get_route(send_node: &Node, route_params: &RouteParameters) -> Result<Route, msgs::LightningError> {
pub fn get_route(send_node: &Node, route_params: &RouteParameters) -> Result<Route, &'static str> {
let scorer = TestScorer::new();
let keys_manager = TestKeysInterface::new(&[0u8; 32], Network::Testnet);
let random_seed_bytes = keys_manager.get_secure_random_bytes();
Expand All @@ -2181,7 +2181,7 @@ pub fn get_route(send_node: &Node, route_params: &RouteParameters) -> Result<Rou
}

/// Like `get_route` above, but adds a random CLTV offset to the final hop.
pub fn find_route(send_node: &Node, route_params: &RouteParameters) -> Result<Route, msgs::LightningError> {
pub fn find_route(send_node: &Node, route_params: &RouteParameters) -> Result<Route, &'static str> {
let scorer = TestScorer::new();
let keys_manager = TestKeysInterface::new(&[0u8; 32], Network::Testnet);
let random_seed_bytes = keys_manager.get_secure_random_bytes();
Expand Down
14 changes: 5 additions & 9 deletions lightning/src/ln/outbound_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,6 @@ mod tests {
use crate::ln::channelmanager::{PaymentId, RecipientOnionFields};
use crate::ln::inbound_payment::ExpandedKey;
use crate::types::features::{Bolt12InvoiceFeatures, ChannelFeatures, NodeFeatures};
use crate::ln::msgs::{ErrorAction, LightningError};
use crate::ln::outbound_payment::{Bolt12PaymentError, OutboundPayments, PendingOutboundPayment, Retry, RetryableSendFailure, StaleExpiration};
#[cfg(feature = "std")]
use crate::offers::invoice::DEFAULT_RELATIVE_EXPIRY;
Expand Down Expand Up @@ -2532,8 +2531,7 @@ mod tests {
let payment_params = PaymentParameters::from_node_id(
PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()), 0);
let route_params = RouteParameters::from_payment_params_and_value(payment_params, 0);
router.expect_find_route(route_params.clone(),
Err(LightningError { err: String::new(), action: ErrorAction::IgnoreError }));
router.expect_find_route(route_params.clone(), Err(""));

let pending_events = Mutex::new(VecDeque::new());
if on_retry {
Expand Down Expand Up @@ -2863,13 +2861,11 @@ mod tests {
);
assert!(outbound_payments.has_pending_payments());

router.expect_find_route(
RouteParameters::from_payment_params_and_value(
PaymentParameters::from_bolt12_invoice(&invoice),
invoice.amount_msats(),
),
Err(LightningError { err: String::new(), action: ErrorAction::IgnoreError }),
let route_params = RouteParameters::from_payment_params_and_value(
PaymentParameters::from_bolt12_invoice(&invoice),
invoice.amount_msats(),
);
router.expect_find_route(route_params, Err(""));

assert_eq!(
outbound_payments.send_payment_for_bolt12_invoice(
Expand Down
1 change: 1 addition & 0 deletions lightning/src/ln/reload_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ fn do_test_partial_claim_before_restart(persist_both_monitors: bool) {

// Ensure that the remaining channel is fully operation and not blocked (and that after a
// cycle of commitment updates the payment preimage is ultimately pruned).
nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
send_payment(&nodes[0], &[&nodes[2], &nodes[3]], 100_000);
assert!(!get_monitor!(nodes[3], chan_id_not_persisted).get_stored_preimages().contains_key(&payment_hash));
}
Expand Down
Loading
Loading