Skip to content

Commit

Permalink
Merge pull request #1050 from breez/savage-list-pays-fix
Browse files Browse the repository at this point in the history
Fix failed payment response of completed payment
  • Loading branch information
dangeross authored Jul 19, 2024
2 parents 0092c09 + f5d464a commit 1174bf3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions libs/sdk-core/src/greenlight/node_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use gl_client::pb::cln::listpays_pays::ListpaysPaysStatus;
use gl_client::pb::cln::listpeerchannels_channels::ListpeerchannelsChannelsState::*;
use gl_client::pb::cln::{
self, Amount, GetrouteRequest, GetrouteRoute, ListchannelsRequest,
ListclosedchannelsClosedchannels, ListpeerchannelsChannels, PreapproveinvoiceRequest,
SendpayRequest, SendpayRoute, WaitsendpayRequest,
ListclosedchannelsClosedchannels, ListpaysPays, ListpeerchannelsChannels,
PreapproveinvoiceRequest, SendpayRequest, SendpayRoute, WaitsendpayRequest,
};
use gl_client::pb::scheduler::scheduler_client::SchedulerClient;
use gl_client::pb::scheduler::{NodeInfoRequest, UpgradeRequest};
Expand Down Expand Up @@ -435,10 +435,18 @@ impl Greenlight {
retry += 1;
}

if response.pays.is_empty() {
// CLN also returns failed ListpaysPays along with the complete one
debug!("list_pays: {:?}", response.pays);
let pays: Vec<ListpaysPays> = response
.pays
.into_iter()
.filter(|pay| pay.status() == cln::listpays_pays::ListpaysPaysStatus::Complete)
.collect();

if pays.is_empty() {
return Err(anyhow!("Payment not found"));
}
Ok(response.pays[0].clone())
Ok(pays[0].clone())
}

async fn fetch_channels_and_balance_with_retry(
Expand Down

0 comments on commit 1174bf3

Please sign in to comment.