Skip to content

Commit 7e815f3

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 5fa9445 commit 7e815f3

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
@@ -1303,66 +1303,8 @@ pub struct LSPS1OrderStatus {
13031303
#[cfg(not(feature = "uniffi"))]
13041304
type LSPS1PaymentInfo = lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo;
13051305

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

13671309
#[derive(Debug, Clone)]
13681310
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)