fix: webhook
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-03-20 09:36:38 +00:00
parent be4a981bea
commit 3527742992

View File

@ -66,13 +66,14 @@ impl LightningNode for BitvoraNode {
if r.endpoint != "/api/v1/webhook/bitvora" { if r.endpoint != "/api/v1/webhook/bitvora" {
return InvoiceUpdate::Unknown; return InvoiceUpdate::Unknown;
} }
let body: BitvoraWebhookPayload<BitvoraWebhook> = let r_body = r.body.as_slice();
match serde_json::from_slice(r.body.as_slice()) { info!("Received webhook {}", String::from_utf8_lossy(r_body));
let body: BitvoraWebhook =
match serde_json::from_slice(r_body) {
Ok(b) => b, Ok(b) => b,
Err(e) => return InvoiceUpdate::Error(e.to_string()), Err(e) => return InvoiceUpdate::Error(e.to_string()),
}; };
info!("Received webhook {:?}", body);
let body = body.payload;
if let Err(e) = verify_webhook(&secret, &r) { if let Err(e) = verify_webhook(&secret, &r) {
return InvoiceUpdate::Error(e.to_string()); return InvoiceUpdate::Error(e.to_string());
} }
@ -122,11 +123,6 @@ struct CreateInvoiceResponse {
pub payment_request: String, pub payment_request: String,
} }
#[derive(Deserialize, Debug, Clone)]
struct BitvoraWebhookPayload<T> {
pub payload: T,
}
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
struct BitvoraWebhook { struct BitvoraWebhook {
pub event: BitvoraWebhookEvent, pub event: BitvoraWebhookEvent,