Skip to content

Commit

Permalink
signer: Add invoices extracted from SendPay calls
Browse files Browse the repository at this point in the history
They are part of the authenticated payload coming from the client, and
as such they are safe to be considered when sending a payment.
  • Loading branch information
cdecker committed Nov 9, 2023
1 parent 48d88d9 commit 36ccdb6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions libs/gl-client/src/signer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,23 @@ fn update_state_from_request(
request: &model::Request,
node: &lightning_signer::node::Node,
) -> Result<(), Error> {
use lightning_signer::invoice::Invoice;
use std::str::FromStr;
match request {
model::Request::SendPay(model::cln::SendpayRequest {
bolt11: Some(inv), ..
}) => {
let invoice = Invoice::from_str(inv).unwrap();
log::debug!(
"Adding invoice {:?} as side-effect of this sendpay {:?}",
invoice,
request
);
node.add_invoice(invoice).unwrap();
}
_ => {}
}

Ok(())
}

Expand Down

0 comments on commit 36ccdb6

Please sign in to comment.