(
p: cln_plugin::Plugin<State>,
v: serde_json::Value,
)
| 508 | } |
| 509 | |
| 510 | async fn on_invoice_payment( |
| 511 | p: cln_plugin::Plugin<State>, |
| 512 | v: serde_json::Value, |
| 513 | ) -> Result<serde_json::Value, anyhow::Error> { |
| 514 | let req: InvoicePaymentRequest = ok_or_continue!( |
| 515 | serde_json::from_value(v).context("failed to deserialize htlc_accepted request JSON") |
| 516 | ); |
| 517 | let preimage = ok_or_continue!( |
| 518 | <[u8; 32]>::from_hex(&req.payment.preimage).context("invalid preimage hex") |
| 519 | ); |
| 520 | let hash = payment_hash(&preimage); |
| 521 | |
| 522 | // Delete DS-entries. |
| 523 | let dir = p.configuration().lightning_dir; |
| 524 | let rpc_path = Path::new(&dir).join(&p.configuration().rpc_file); |
| 525 | let mut cln_client = ok_or_continue!( |
| 526 | cln_rpc::ClnRpc::new(rpc_path.clone()) |
| 527 | .await |
| 528 | .context("failed to connect to core-lightning") |
| 529 | ); |
| 530 | ok_or_continue!( |
| 531 | cln_client |
| 532 | .call_typed(&DeldatastoreRequest { |
| 533 | key: vec!["lsps".to_string(), "invoice".to_string(), hash.to_string()], |
| 534 | generation: None, |
| 535 | }) |
| 536 | .await |
| 537 | .context("failed to delete datastore record") |
| 538 | ); |
| 539 | |
| 540 | Ok(serde_json::json!({"result": "continue"})) |
| 541 | } |
| 542 | |
| 543 | async fn on_htlc_accepted( |
| 544 | p: cln_plugin::Plugin<State>, |
nothing calls this directly
no test coverage detected