Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/payment/bolt11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ impl Bolt11Payment {
log_error!(self.logger, "Failed to send payment: {:?}", e);
match e {
RetryableSendFailure::DuplicatePayment => Err(Error::DuplicatePayment),
RetryableSendFailure::RouteNotFound => Err(Error::PaymentSendingFailed),
_ => {
let kind = PaymentKind::Bolt11 {
hash: payment_hash,
Expand Down Expand Up @@ -422,6 +423,7 @@ impl Bolt11Payment {
log_error!(self.logger, "Failed to send payment: {:?}", e);
match e {
RetryableSendFailure::DuplicatePayment => Err(Error::DuplicatePayment),
RetryableSendFailure::RouteNotFound => Err(Error::PaymentSendingFailed),
_ => {
let kind = PaymentKind::Bolt11 {
hash: payment_hash,
Expand Down
1 change: 1 addition & 0 deletions src/payment/spontaneous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ impl SpontaneousPayment {

match e {
RetryableSendFailure::DuplicatePayment => Err(Error::DuplicatePayment),
RetryableSendFailure::RouteNotFound => Err(Error::PaymentSendingFailed),
_ => {
let kind = PaymentKind::Spontaneous {
hash: payment_hash,
Expand Down
29 changes: 29 additions & 0 deletions tests/integration_tests_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2957,3 +2957,32 @@ async fn splice_in_with_all_balance() {
node_a.stop().unwrap();
node_b.stop().unwrap();
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn test_retry_on_routing_failure() {
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd();
let chain_source = random_chain_source(&bitcoind, &electrsd);
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, true);

let invoice_description =
Bolt11InvoiceDescription::Direct(Description::new(String::from("test-retry")).unwrap());
let invoice = node_b
.bolt11_payment()
.receive(100_000, &invoice_description.clone().into(), 3600)
.unwrap();

let first_attempt = node_a.bolt11_payment().send(&invoice, None);
assert!(first_attempt.is_err(), "expecting error at first attempt");
assert_eq!(first_attempt.unwrap_err(), NodeError::PaymentSendingFailed);

let second_attempt = node_a.bolt11_payment().send(&invoice, None);

assert_ne!(
second_attempt.unwrap_err(),
NodeError::DuplicatePayment,
"The invoice hash was incorrectly locked in the payment store after a routing failure!"
);

node_a.stop().unwrap();
node_b.stop().unwrap();
}
Loading