Skip to content

Commit 28a7b19

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 8861c0d commit 28a7b19

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

1331-
/// Details regarding how to pay for an order.
13321331
#[cfg(feature = "uniffi")]
1333-
#[derive(Clone, Debug, PartialEq, Eq)]
1334-
pub struct LSPS1PaymentInfo {
1335-
/// A Lightning payment using BOLT 11.
1336-
pub bolt11: Option<crate::ffi::LSPSBolt11PaymentInfo>,
1337-
/// An onchain payment.
1338-
pub onchain: Option<LSPS1OnchainPaymentInfo>,
1339-
}
1340-
1341-
#[cfg(feature = "uniffi")]
1342-
impl From<lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo> for LSPS1PaymentInfo {
1343-
fn from(value: lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo) -> Self {
1344-
LSPS1PaymentInfo {
1345-
bolt11: value.bolt11.map(|b| b.into()),
1346-
onchain: value.onchain.map(|o| o.into()),
1347-
}
1348-
}
1349-
}
1350-
1351-
/// An onchain payment.
1352-
#[cfg(feature = "uniffi")]
1353-
#[derive(Clone, Debug, PartialEq, Eq)]
1354-
pub struct LSPS1OnchainPaymentInfo {
1355-
/// Indicates the current state of the payment.
1356-
pub state: lightning_liquidity::lsps1::msgs::LSPS1PaymentState,
1357-
/// The datetime when the payment option expires.
1358-
pub expires_at: LSPSDateTime,
1359-
/// The total fee the LSP will charge to open this channel in satoshi.
1360-
pub fee_total_sat: u64,
1361-
/// The amount the client needs to pay to have the requested channel openend.
1362-
pub order_total_sat: u64,
1363-
/// An on-chain address the client can send [`Self::order_total_sat`] to to have the channel
1364-
/// opened.
1365-
pub address: bitcoin::Address,
1366-
/// The minimum number of block confirmations that are required for the on-chain payment to be
1367-
/// considered confirmed.
1368-
pub min_onchain_payment_confirmations: Option<u16>,
1369-
/// The minimum fee rate for the on-chain payment in case the client wants the payment to be
1370-
/// confirmed without a confirmation.
1371-
pub min_fee_for_0conf: Arc<bitcoin::FeeRate>,
1372-
/// The address where the LSP will send the funds if the order fails.
1373-
pub refund_onchain_address: Option<bitcoin::Address>,
1374-
}
1375-
1376-
#[cfg(feature = "uniffi")]
1377-
impl From<lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo> for LSPS1OnchainPaymentInfo {
1378-
fn from(value: lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo) -> Self {
1379-
Self {
1380-
state: value.state,
1381-
expires_at: value.expires_at,
1382-
fee_total_sat: value.fee_total_sat,
1383-
order_total_sat: value.order_total_sat,
1384-
address: value.address,
1385-
min_onchain_payment_confirmations: value.min_onchain_payment_confirmations,
1386-
min_fee_for_0conf: Arc::new(value.min_fee_for_0conf),
1387-
refund_onchain_address: value.refund_onchain_address,
1388-
}
1389-
}
1390-
}
1332+
type LSPS1PaymentInfo = crate::ffi::LSPS1PaymentInfo;
13911333

13921334
#[derive(Debug, Clone)]
13931335
pub(crate) struct LSPS2FeeResponse {

0 commit comments

Comments
 (0)