Ln use common (#751)

* chore: cdk-cln use common

* feat: lnd use common

* feat: lnbits use common
This commit is contained in:
thesimplekid
2025-05-14 17:29:58 +01:00
committed by GitHub
parent 65e785561c
commit 9ac387ae3d
9 changed files with 31 additions and 31 deletions

View File

@@ -13,7 +13,7 @@ readme = "README.md"
[dependencies]
async-trait.workspace = true
bitcoin.workspace = true
cdk = { workspace = true, features = ["mint"] }
cdk-common = { workspace = true, features = ["mint"] }
cln-rpc = "0.3.0"
futures.workspace = true
tokio.workspace = true

View File

@@ -25,10 +25,10 @@ pub enum Error {
ClnRpc(#[from] cln_rpc::RpcError),
/// Amount Error
#[error(transparent)]
Amount(#[from] cdk::amount::Error),
Amount(#[from] cdk_common::amount::Error),
}
impl From<Error> for cdk::cdk_payment::Error {
impl From<Error> for cdk_common::payment::Error {
fn from(e: Error) -> Self {
Self::Lightning(Box::new(e))
}

View File

@@ -12,15 +12,15 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use async_trait::async_trait;
use cdk::amount::{to_unit, Amount};
use cdk::cdk_payment::{
use cdk_common::amount::{to_unit, Amount};
use cdk_common::common::FeeReserve;
use cdk_common::nuts::{CurrencyUnit, MeltOptions, MeltQuoteState, MintQuoteState};
use cdk_common::payment::{
self, Bolt11Settings, CreateIncomingPaymentResponse, MakePaymentResponse, MintPayment,
PaymentQuoteResponse,
};
use cdk::nuts::{CurrencyUnit, MeltOptions, MeltQuoteState, MintQuoteState};
use cdk::types::FeeReserve;
use cdk::util::{hex, unix_time};
use cdk::{mint, Bolt11Invoice};
use cdk_common::util::{hex, unix_time};
use cdk_common::{mint, Bolt11Invoice};
use cln_rpc::model::requests::{
InvoiceRequest, ListinvoicesRequest, ListpaysRequest, PayRequest, WaitanyinvoiceRequest,
};
@@ -65,7 +65,7 @@ impl Cln {
#[async_trait]
impl MintPayment for Cln {
type Err = cdk_payment::Error;
type Err = payment::Error;
async fn get_settings(&self) -> Result<Value, Self::Err> {
Ok(serde_json::to_value(Bolt11Settings {

View File

@@ -15,7 +15,7 @@ async-trait.workspace = true
anyhow.workspace = true
axum.workspace = true
bitcoin.workspace = true
cdk = { workspace = true, features = ["mint"] }
cdk-common = { workspace = true, features = ["mint"] }
futures.workspace = true
tokio.workspace = true
tokio-util.workspace = true

View File

@@ -19,7 +19,7 @@ pub enum Error {
Anyhow(#[from] anyhow::Error),
}
impl From<Error> for cdk::cdk_payment::Error {
impl From<Error> for cdk_common::payment::Error {
fn from(e: Error) -> Self {
Self::Lightning(Box::new(e))
}

View File

@@ -13,15 +13,15 @@ use std::sync::Arc;
use anyhow::anyhow;
use async_trait::async_trait;
use axum::Router;
use cdk::amount::{to_unit, Amount, MSAT_IN_SAT};
use cdk::cdk_payment::{
use cdk_common::amount::{to_unit, Amount, MSAT_IN_SAT};
use cdk_common::common::FeeReserve;
use cdk_common::nuts::{CurrencyUnit, MeltOptions, MeltQuoteState, MintQuoteState};
use cdk_common::payment::{
self, Bolt11Settings, CreateIncomingPaymentResponse, MakePaymentResponse, MintPayment,
PaymentQuoteResponse,
};
use cdk::nuts::{CurrencyUnit, MeltOptions, MeltQuoteState, MintQuoteState};
use cdk::types::FeeReserve;
use cdk::util::unix_time;
use cdk::{mint, Bolt11Invoice};
use cdk_common::util::unix_time;
use cdk_common::{mint, Bolt11Invoice};
use error::Error;
use futures::stream::StreamExt;
use futures::Stream;
@@ -77,7 +77,7 @@ impl LNbits {
#[async_trait]
impl MintPayment for LNbits {
type Err = cdk_payment::Error;
type Err = payment::Error;
async fn get_settings(&self) -> Result<Value, Self::Err> {
Ok(serde_json::to_value(&self.settings)?)
@@ -166,7 +166,7 @@ impl MintPayment for LNbits {
let amount_msat = match options {
Some(amount) => {
if matches!(amount, MeltOptions::Mpp { mpp: _ }) {
return Err(cdk_payment::Error::UnsupportedPaymentOption);
return Err(payment::Error::UnsupportedPaymentOption);
}
amount.amount_msat()
}

View File

@@ -13,7 +13,7 @@ readme = "README.md"
[dependencies]
async-trait.workspace = true
anyhow.workspace = true
cdk = { workspace = true, features = ["mint"] }
cdk-common = { workspace = true, features = ["mint"] }
fedimint-tonic-lnd = "0.2.0"
futures.workspace = true
tokio.workspace = true

View File

@@ -38,7 +38,7 @@ pub enum Error {
InvalidConfig(String),
}
impl From<Error> for cdk::cdk_payment::Error {
impl From<Error> for cdk_common::payment::Error {
fn from(e: Error) -> Self {
Self::Lightning(Box::new(e))
}

View File

@@ -15,16 +15,16 @@ use std::sync::Arc;
use anyhow::anyhow;
use async_trait::async_trait;
use cdk::amount::{to_unit, Amount, MSAT_IN_SAT};
use cdk::cdk_payment::{
use cdk_common::amount::{to_unit, Amount, MSAT_IN_SAT};
use cdk_common::bitcoin::hashes::Hash;
use cdk_common::common::FeeReserve;
use cdk_common::nuts::{CurrencyUnit, MeltOptions, MeltQuoteState, MintQuoteState};
use cdk_common::payment::{
self, Bolt11Settings, CreateIncomingPaymentResponse, MakePaymentResponse, MintPayment,
PaymentQuoteResponse,
};
use cdk::nuts::{CurrencyUnit, MeltOptions, MeltQuoteState, MintQuoteState};
use cdk::secp256k1::hashes::Hash;
use cdk::types::FeeReserve;
use cdk::util::hex;
use cdk::{mint, Bolt11Invoice};
use cdk_common::util::hex;
use cdk_common::{mint, Bolt11Invoice};
use error::Error;
use fedimint_tonic_lnd::lnrpc::fee_limit::Limit;
use fedimint_tonic_lnd::lnrpc::payment::PaymentStatus;
@@ -113,7 +113,7 @@ impl Lnd {
#[async_trait]
impl MintPayment for Lnd {
type Err = cdk_payment::Error;
type Err = payment::Error;
#[instrument(skip_all)]
async fn get_settings(&self) -> Result<serde_json::Value, Self::Err> {
@@ -522,7 +522,7 @@ impl MintPayment for Lnd {
unit: self.settings.unit.clone(),
});
} else {
return Err(cdk_payment::Error::UnknownPaymentState);
return Err(payment::Error::UnknownPaymentState);
}
}
};