agent-pay 0.1.0

L402 + DID-signed invoices: agent-to-agent Lightning payments (Rust port of @p-vbordei/agent-pay)
Documentation
//! Lightning node abstraction.

use async_trait::async_trait;

use crate::error::Error;

#[derive(Debug, Clone)]
pub struct InvoiceCreateRequest {
    pub amount_msat: u64,
    pub memo: Option<String>,
    pub expiry_seconds: Option<u64>,
}

#[derive(Debug, Clone)]
pub struct Invoice {
    pub bolt11: String,
    pub payment_hash: String,
}

#[derive(Debug, Clone)]
pub struct InvoiceLookup {
    pub settled: bool,
    pub amount_msat: u64,
    pub preimage: Option<Vec<u8>>,
}

#[derive(Debug, Clone)]
pub struct PaymentResult {
    pub preimage: Vec<u8>,
    pub fee_msat: u64,
}

#[async_trait]
pub trait LightningNode: Send + Sync {
    async fn create_invoice(&self, req: InvoiceCreateRequest) -> Result<Invoice, Error>;
    async fn lookup_invoice(&self, payment_hash: &str) -> Result<InvoiceLookup, Error>;
    async fn pay_invoice(&self, bolt11: &str) -> Result<PaymentResult, Error>;
}