mirror of
https://github.com/daywalker90/cln-nip47.git
synced 2026-08-13 12:33:43 +02:00
use cln-rpc structs for notification deserialization
This commit is contained in:
parent
e175198c45
commit
582100d398
1 changed files with 7 additions and 16 deletions
|
|
@ -14,6 +14,7 @@ use cln_rpc::{
|
|||
ListpaysPaysStatus,
|
||||
},
|
||||
},
|
||||
notifications::{InvoicePaymentNotification, SendPaySuccessNotification},
|
||||
primitives::Sha256,
|
||||
};
|
||||
use nostr::{
|
||||
|
|
@ -40,13 +41,8 @@ pub async fn payment_received_handler(
|
|||
if !plugin.option(&OPT_NOTIFICATIONS).unwrap() {
|
||||
return Ok(());
|
||||
}
|
||||
let label = args
|
||||
.get("invoice_payment")
|
||||
.ok_or_else(|| anyhow!("Malformed invoice_payment notification: missing invoice_payment"))?
|
||||
.get("label")
|
||||
.ok_or_else(|| anyhow!("Malformed invoice_payment notification: missing label"))?
|
||||
.as_str()
|
||||
.ok_or_else(|| anyhow!("label not a string"))?;
|
||||
|
||||
let notif: InvoicePaymentNotification = serde_json::from_value(args)?;
|
||||
|
||||
let mut rpc = plugin.state().rpc_lock.lock().await;
|
||||
|
||||
|
|
@ -54,7 +50,7 @@ pub async fn payment_received_handler(
|
|||
.call_typed(&ListinvoicesRequest {
|
||||
index: None,
|
||||
invstring: None,
|
||||
label: Some(label.to_owned()),
|
||||
label: Some(notif.label),
|
||||
limit: None,
|
||||
offer_id: None,
|
||||
payment_hash: None,
|
||||
|
|
@ -191,14 +187,9 @@ pub async fn payment_sent_handler(
|
|||
if !plugin.option(&OPT_NOTIFICATIONS).unwrap() {
|
||||
return Ok(());
|
||||
}
|
||||
let payment_hash = args
|
||||
.get("sendpay_success")
|
||||
.ok_or_else(|| anyhow!("Malformed sendpay_success notification: missing sendpay_success"))?
|
||||
.get("payment_hash")
|
||||
.ok_or_else(|| anyhow!("Malformed sendpay_success notification: missing payment_hash"))?
|
||||
.as_str()
|
||||
.ok_or_else(|| anyhow!("payment_hash not a string"))?
|
||||
.to_owned();
|
||||
|
||||
let notif: SendPaySuccessNotification = serde_json::from_value(args)?;
|
||||
let payment_hash = hex::encode(notif.payment_hash);
|
||||
|
||||
let mut rpc = plugin.state().rpc_lock.lock().await;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue