Skip to content
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

On start up wait invoice returns all paid invoices #430

Open
Tracked by #404
thesimplekid opened this issue Oct 30, 2024 · 1 comment
Open
Tracked by #404

On start up wait invoice returns all paid invoices #430

thesimplekid opened this issue Oct 30, 2024 · 1 comment
Assignees

Comments

@thesimplekid
Copy link
Collaborator

On start up since we do not pass the wait index to start at wait_any_invoice returns all the invoices that have been paid on the node. We should try and avoid this. And with the addition of bolt 12 we need to make sure we are not adding to the amount thats been paid more then once per real payment.

// Clippy thinks select is not stable but it compiles fine on MSRV (1.63.0)
async fn wait_any_invoice(
&self,
) -> Result<Pin<Box<dyn Stream<Item = String> + Send>>, Self::Err> {
let last_pay_index = self.get_last_pay_index().await?;
let cln_client = cln_rpc::ClnRpc::new(&self.rpc_socket).await?;
let stream = futures::stream::unfold(
(
cln_client,
last_pay_index,
self.wait_invoice_cancel_token.clone(),
Arc::clone(&self.wait_invoice_is_active),
),
|(mut cln_client, mut last_pay_idx, cancel_token, is_active)| async move {
// Set the stream as active
is_active.store(true, Ordering::SeqCst);

@mubarak23
Copy link
Contributor

so, on startup, we return only unpaid invoice @thesimplekid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants