Skip to content

Commit e30f9f7

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 e1a514b commit e30f9f7

File tree

2 files changed

+60
-62
lines changed

2 files changed

+60
-62
lines changed

src/ffi/types.rs

Lines changed: 59 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,
@@ -1068,6 +1066,64 @@ impl std::fmt::Display for Bolt11Invoice {
10681066
}
10691067
}
10701068

1069+
#[derive(Clone, Debug, PartialEq, Eq)]
1070+
pub struct LSPS1PaymentInfo {
1071+
/// A Lightning payment using BOLT 11.
1072+
pub bolt11: Option<crate::ffi::LSPS1Bolt11PaymentInfo>,
1073+
/// An onchain payment.
1074+
pub onchain: Option<LSPS1OnchainPaymentInfo>,
1075+
}
1076+
1077+
#[cfg(feature = "uniffi")]
1078+
impl From<lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo> for LSPS1PaymentInfo {
1079+
fn from(value: lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo) -> Self {
1080+
LSPS1PaymentInfo {
1081+
bolt11: value.bolt11.map(|b| b.into()),
1082+
onchain: value.onchain.map(|o| o.into()),
1083+
}
1084+
}
1085+
}
1086+
1087+
/// An onchain payment.
1088+
#[cfg(feature = "uniffi")]
1089+
#[derive(Clone, Debug, PartialEq, Eq)]
1090+
pub struct LSPS1OnchainPaymentInfo {
1091+
/// Indicates the current state of the payment.
1092+
pub state: lightning_liquidity::lsps1::msgs::LSPS1PaymentState,
1093+
/// The datetime when the payment option expires.
1094+
pub expires_at: LSPSDateTime,
1095+
/// The total fee the LSP will charge to open this channel in satoshi.
1096+
pub fee_total_sat: u64,
1097+
/// The amount the client needs to pay to have the requested channel openend.
1098+
pub order_total_sat: u64,
1099+
/// An on-chain address the client can send [`Self::order_total_sat`] to to have the channel
1100+
/// opened.
1101+
pub address: bitcoin::Address,
1102+
/// The minimum number of block confirmations that are required for the on-chain payment to be
1103+
/// considered confirmed.
1104+
pub min_onchain_payment_confirmations: Option<u16>,
1105+
/// The minimum fee rate for the on-chain payment in case the client wants the payment to be
1106+
/// confirmed without a confirmation.
1107+
pub min_fee_for_0conf: Arc<bitcoin::FeeRate>,
1108+
/// The address where the LSP will send the funds if the order fails.
1109+
pub refund_onchain_address: Option<bitcoin::Address>,
1110+
}
1111+
1112+
#[cfg(feature = "uniffi")]
1113+
impl From<lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo> for LSPS1OnchainPaymentInfo {
1114+
fn from(value: lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo) -> Self {
1115+
Self {
1116+
state: value.state,
1117+
expires_at: value.expires_at,
1118+
fee_total_sat: value.fee_total_sat,
1119+
order_total_sat: value.order_total_sat,
1120+
address: value.address,
1121+
min_onchain_payment_confirmations: value.min_onchain_payment_confirmations,
1122+
min_fee_for_0conf: Arc::new(value.min_fee_for_0conf),
1123+
refund_onchain_address: value.refund_onchain_address,
1124+
}
1125+
}
1126+
}
10711127
/// A Lightning payment using BOLT 11.
10721128
#[derive(Clone, Debug, PartialEq, Eq)]
10731129
pub struct LSPS1Bolt11PaymentInfo {

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::ffi::LSPSBolt11PaymentInfo>,
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::ffi::LSPS1PaymentInfo;
13661308

13671309
#[derive(Debug, Clone)]
13681310
pub(crate) struct LSPS2FeeResponse {

0 commit comments

Comments
 (0)