Skip to content

Commit 75719bd

Browse files
committed
f Move uniffi LSPS1PaymentInfo types next to the pre-existing ones
.. as having them in two places doesn't make sense
1 parent 7eca470 commit 75719bd

File tree

2 files changed

+59
-62
lines changed

2 files changed

+59
-62
lines changed

src/liquidity.rs

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,66 +1307,8 @@ pub struct LSPS1OrderStatus {
13071307
#[cfg(not(feature = "uniffi"))]
13081308
type LSPS1PaymentInfo = lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo;
13091309

1310-
/// Details regarding how to pay for an order.
13111310
#[cfg(feature = "uniffi")]
1312-
#[derive(Clone, Debug, PartialEq, Eq)]
1313-
pub struct LSPS1PaymentInfo {
1314-
/// A Lightning payment using BOLT 11.
1315-
pub bolt11: Option<crate::uniffi_types::LSPS1Bolt11PaymentInfo>,
1316-
/// An onchain payment.
1317-
pub onchain: Option<LSPS1OnchainPaymentInfo>,
1318-
}
1319-
1320-
#[cfg(feature = "uniffi")]
1321-
impl From<lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo> for LSPS1PaymentInfo {
1322-
fn from(value: lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo) -> Self {
1323-
LSPS1PaymentInfo {
1324-
bolt11: value.bolt11.map(|b| b.into()),
1325-
onchain: value.onchain.map(|o| o.into()),
1326-
}
1327-
}
1328-
}
1329-
1330-
/// An onchain payment.
1331-
#[cfg(feature = "uniffi")]
1332-
#[derive(Clone, Debug, PartialEq, Eq)]
1333-
pub struct LSPS1OnchainPaymentInfo {
1334-
/// Indicates the current state of the payment.
1335-
pub state: lightning_liquidity::lsps1::msgs::LSPS1PaymentState,
1336-
/// The datetime when the payment option expires.
1337-
pub expires_at: LSPSDateTime,
1338-
/// The total fee the LSP will charge to open this channel in satoshi.
1339-
pub fee_total_sat: u64,
1340-
/// The amount the client needs to pay to have the requested channel openend.
1341-
pub order_total_sat: u64,
1342-
/// An on-chain address the client can send [`Self::order_total_sat`] to to have the channel
1343-
/// opened.
1344-
pub address: bitcoin::Address,
1345-
/// The minimum number of block confirmations that are required for the on-chain payment to be
1346-
/// considered confirmed.
1347-
pub min_onchain_payment_confirmations: Option<u16>,
1348-
/// The minimum fee rate for the on-chain payment in case the client wants the payment to be
1349-
/// confirmed without a confirmation.
1350-
pub min_fee_for_0conf: Arc<bitcoin::FeeRate>,
1351-
/// The address where the LSP will send the funds if the order fails.
1352-
pub refund_onchain_address: Option<bitcoin::Address>,
1353-
}
1354-
1355-
#[cfg(feature = "uniffi")]
1356-
impl From<lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo> for LSPS1OnchainPaymentInfo {
1357-
fn from(value: lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo) -> Self {
1358-
Self {
1359-
state: value.state,
1360-
expires_at: value.expires_at,
1361-
fee_total_sat: value.fee_total_sat,
1362-
order_total_sat: value.order_total_sat,
1363-
address: value.address,
1364-
min_onchain_payment_confirmations: value.min_onchain_payment_confirmations,
1365-
min_fee_for_0conf: Arc::new(value.min_fee_for_0conf),
1366-
refund_onchain_address: value.refund_onchain_address,
1367-
}
1368-
}
1369-
}
1311+
type LSPS1PaymentInfo = crate::uniffi_types::LSPS1PaymentInfo;
13701312

13711313
#[derive(Debug, Clone)]
13721314
pub(crate) struct LSPS2FeeResponse {

src/uniffi_types.rs

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ pub use crate::config::{
1515
EsploraSyncConfig, MaxDustHTLCExposure,
1616
};
1717
pub use crate::graph::{ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo};
18-
pub use crate::liquidity::{
19-
LSPS1OnchainPaymentInfo, LSPS1OrderStatus, LSPS1PaymentInfo, LSPS2ServiceConfig,
20-
};
18+
pub use crate::liquidity::{LSPS1OrderStatus, LSPS2ServiceConfig};
2119
pub use crate::logger::{LogLevel, LogRecord, LogWriter};
2220
pub use crate::payment::store::{
2321
ConfirmationStatus, LSPFeeLimits, PaymentDirection, PaymentKind, PaymentStatus,
@@ -607,6 +605,24 @@ impl std::fmt::Display for Bolt11Invoice {
607605
}
608606
}
609607

608+
/// Details regarding how to pay for an order.
609+
#[derive(Clone, Debug, PartialEq, Eq)]
610+
pub struct LSPS1PaymentInfo {
611+
/// A Lightning payment using BOLT 11.
612+
pub bolt11: Option<crate::uniffi_types::LSPS1Bolt11PaymentInfo>,
613+
/// An onchain payment.
614+
pub onchain: Option<LSPS1OnchainPaymentInfo>,
615+
}
616+
617+
impl From<lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo> for LSPS1PaymentInfo {
618+
fn from(value: lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo) -> Self {
619+
LSPS1PaymentInfo {
620+
bolt11: value.bolt11.map(|b| b.into()),
621+
onchain: value.onchain.map(|o| o.into()),
622+
}
623+
}
624+
}
625+
610626
/// A Lightning payment using BOLT 11.
611627
#[derive(Clone, Debug, PartialEq, Eq)]
612628
pub struct LSPS1Bolt11PaymentInfo {
@@ -634,6 +650,45 @@ impl From<lightning_liquidity::lsps1::msgs::LSPS1Bolt11PaymentInfo> for LSPS1Bol
634650
}
635651
}
636652

653+
/// An onchain payment.
654+
#[derive(Clone, Debug, PartialEq, Eq)]
655+
pub struct LSPS1OnchainPaymentInfo {
656+
/// Indicates the current state of the payment.
657+
pub state: lightning_liquidity::lsps1::msgs::LSPS1PaymentState,
658+
/// The datetime when the payment option expires.
659+
pub expires_at: LSPSDateTime,
660+
/// The total fee the LSP will charge to open this channel in satoshi.
661+
pub fee_total_sat: u64,
662+
/// The amount the client needs to pay to have the requested channel openend.
663+
pub order_total_sat: u64,
664+
/// An on-chain address the client can send [`Self::order_total_sat`] to to have the channel
665+
/// opened.
666+
pub address: bitcoin::Address,
667+
/// The minimum number of block confirmations that are required for the on-chain payment to be
668+
/// considered confirmed.
669+
pub min_onchain_payment_confirmations: Option<u16>,
670+
/// The minimum fee rate for the on-chain payment in case the client wants the payment to be
671+
/// confirmed without a confirmation.
672+
pub min_fee_for_0conf: Arc<bitcoin::FeeRate>,
673+
/// The address where the LSP will send the funds if the order fails.
674+
pub refund_onchain_address: Option<bitcoin::Address>,
675+
}
676+
677+
impl From<lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo> for LSPS1OnchainPaymentInfo {
678+
fn from(value: lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo) -> Self {
679+
Self {
680+
state: value.state,
681+
expires_at: value.expires_at,
682+
fee_total_sat: value.fee_total_sat,
683+
order_total_sat: value.order_total_sat,
684+
address: value.address,
685+
min_onchain_payment_confirmations: value.min_onchain_payment_confirmations,
686+
min_fee_for_0conf: Arc::new(value.min_fee_for_0conf),
687+
refund_onchain_address: value.refund_onchain_address,
688+
}
689+
}
690+
}
691+
637692
impl UniffiCustomTypeConverter for LSPS1OrderId {
638693
type Builtin = String;
639694

0 commit comments

Comments
 (0)