Skip to content

Commit 5fa9445

Browse files
committed
f Account for renamed lightning-liquidity types
1 parent e65d837 commit 5fa9445

File tree

3 files changed

+81
-79
lines changed

3 files changed

+81
-79
lines changed

bindings/ldk_node.udl

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ interface Node {
160160

161161
[Enum]
162162
interface Bolt11InvoiceDescription {
163-
Hash(string hash);
164-
Direct(string description);
163+
Hash(string hash);
164+
Direct(string description);
165165
};
166166

167167
interface Bolt11Payment {
@@ -245,7 +245,7 @@ interface LSPS1Liquidity {
245245
[Throws=NodeError]
246246
LSPS1OrderStatus request_channel(u64 lsp_balance_sat, u64 client_balance_sat, u32 channel_expiry_blocks, boolean announce_channel);
247247
[Throws=NodeError]
248-
LSPS1OrderStatus check_order_status(OrderId order_id);
248+
LSPS1OrderStatus check_order_status(LSPS1OrderId order_id);
249249
};
250250

251251
[Error]
@@ -459,13 +459,13 @@ dictionary CustomTlvRecord {
459459
};
460460

461461
dictionary LSPS1OrderStatus {
462-
OrderId order_id;
463-
OrderParameters order_params;
464-
PaymentInfo payment_options;
465-
ChannelOrderInfo? channel_state;
462+
LSPS1OrderId order_id;
463+
LSPS1OrderParams order_params;
464+
LSPS1PaymentInfo payment_options;
465+
LSPS1ChannelInfo? channel_state;
466466
};
467467

468-
dictionary OrderParameters {
468+
dictionary LSPS1OrderParams {
469469
u64 lsp_balance_sat;
470470
u64 client_balance_sat;
471471
u16 required_channel_confirmations;
@@ -475,22 +475,22 @@ dictionary OrderParameters {
475475
boolean announce_channel;
476476
};
477477

478-
dictionary PaymentInfo {
479-
Bolt11PaymentInfo? bolt11;
480-
OnchainPaymentInfo? onchain;
478+
dictionary LSPS1PaymentInfo {
479+
LSPS1Bolt11PaymentInfo? bolt11;
480+
LSPS1OnchainPaymentInfo? onchain;
481481
};
482482

483-
dictionary Bolt11PaymentInfo {
484-
PaymentState state;
485-
DateTime expires_at;
483+
dictionary LSPS1Bolt11PaymentInfo {
484+
LSPS1PaymentState state;
485+
LSPSDateTime expires_at;
486486
u64 fee_total_sat;
487487
u64 order_total_sat;
488488
Bolt11Invoice invoice;
489489
};
490490

491-
dictionary OnchainPaymentInfo {
492-
PaymentState state;
493-
DateTime expires_at;
491+
dictionary LSPS1OnchainPaymentInfo {
492+
LSPS1PaymentState state;
493+
LSPSDateTime expires_at;
494494
u64 fee_total_sat;
495495
u64 order_total_sat;
496496
Address address;
@@ -499,13 +499,13 @@ dictionary OnchainPaymentInfo {
499499
Address? refund_onchain_address;
500500
};
501501

502-
dictionary ChannelOrderInfo {
503-
DateTime funded_at;
502+
dictionary LSPS1ChannelInfo {
503+
LSPSDateTime funded_at;
504504
OutPoint funding_outpoint;
505-
DateTime expires_at;
505+
LSPSDateTime expires_at;
506506
};
507507

508-
enum PaymentState {
508+
enum LSPS1PaymentState {
509509
"ExpectPayment",
510510
"Paid",
511511
"Refunded",
@@ -794,7 +794,7 @@ typedef string UntrustedString;
794794
typedef string NodeAlias;
795795

796796
[Custom]
797-
typedef string OrderId;
797+
typedef string LSPS1OrderId;
798798

799799
[Custom]
800-
typedef string DateTime;
800+
typedef string LSPSDateTime;

src/liquidity.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ use lightning::routing::router::{RouteHint, RouteHintHop};
2121

2222
use lightning_invoice::{Bolt11Invoice, Bolt11InvoiceDescription, InvoiceBuilder, RoutingFees};
2323

24-
use lightning_liquidity::events::Event;
25-
use lightning_liquidity::lsps0::ser::RequestId;
24+
use lightning_liquidity::events::LiquidityEvent;
25+
use lightning_liquidity::lsps0::ser::{LSPSDateTime, LSPSRequestId};
2626
use lightning_liquidity::lsps1::client::LSPS1ClientConfig as LdkLSPS1ClientConfig;
2727
use lightning_liquidity::lsps1::event::LSPS1ClientEvent;
28-
use lightning_liquidity::lsps1::msgs::{ChannelInfo, LSPS1Options, OrderId, OrderParameters};
28+
use lightning_liquidity::lsps1::msgs::{
29+
LSPS1ChannelInfo, LSPS1Options, LSPS1OrderId, LSPS1OrderParams,
30+
};
2931
use lightning_liquidity::lsps2::client::LSPS2ClientConfig as LdkLSPS2ClientConfig;
3032
use lightning_liquidity::lsps2::event::{LSPS2ClientEvent, LSPS2ServiceEvent};
31-
use lightning_liquidity::lsps2::msgs::{OpeningFeeParams, RawOpeningFeeParams};
33+
use lightning_liquidity::lsps2::msgs::{LSPS2OpeningFeeParams, LSPS2RawOpeningFeeParams};
3234
use lightning_liquidity::lsps2::service::LSPS2ServiceConfig as LdkLSPS2ServiceConfig;
3335
use lightning_liquidity::lsps2::utils::compute_opening_fee;
3436
use lightning_liquidity::{LiquidityClientConfig, LiquidityServiceConfig};
@@ -40,7 +42,7 @@ use bitcoin::secp256k1::{PublicKey, Secp256k1};
4042

4143
use tokio::sync::oneshot;
4244

43-
use chrono::{DateTime, Utc};
45+
use chrono::Utc;
4446

4547
use rand::Rng;
4648

@@ -61,10 +63,10 @@ struct LSPS1Client {
6163
token: Option<String>,
6264
ldk_client_config: LdkLSPS1ClientConfig,
6365
pending_opening_params_requests:
64-
Mutex<HashMap<RequestId, oneshot::Sender<LSPS1OpeningParamsResponse>>>,
65-
pending_create_order_requests: Mutex<HashMap<RequestId, oneshot::Sender<LSPS1OrderStatus>>>,
66+
Mutex<HashMap<LSPSRequestId, oneshot::Sender<LSPS1OpeningParamsResponse>>>,
67+
pending_create_order_requests: Mutex<HashMap<LSPSRequestId, oneshot::Sender<LSPS1OrderStatus>>>,
6668
pending_check_order_status_requests:
67-
Mutex<HashMap<RequestId, oneshot::Sender<LSPS1OrderStatus>>>,
69+
Mutex<HashMap<LSPSRequestId, oneshot::Sender<LSPS1OrderStatus>>>,
6870
}
6971

7072
#[derive(Debug, Clone)]
@@ -79,8 +81,8 @@ struct LSPS2Client {
7981
lsp_address: SocketAddress,
8082
token: Option<String>,
8183
ldk_client_config: LdkLSPS2ClientConfig,
82-
pending_fee_requests: Mutex<HashMap<RequestId, oneshot::Sender<LSPS2FeeResponse>>>,
83-
pending_buy_requests: Mutex<HashMap<RequestId, oneshot::Sender<LSPS2BuyResponse>>>,
84+
pending_fee_requests: Mutex<HashMap<LSPSRequestId, oneshot::Sender<LSPS2FeeResponse>>>,
85+
pending_buy_requests: Mutex<HashMap<LSPSRequestId, oneshot::Sender<LSPS2BuyResponse>>>,
8486
}
8587

8688
#[derive(Debug, Clone)]
@@ -293,7 +295,7 @@ where
293295

294296
pub(crate) async fn handle_next_event(&self) {
295297
match self.liquidity_manager.next_event_async().await {
296-
Event::LSPS1Client(LSPS1ClientEvent::SupportedOptionsReady {
298+
LiquidityEvent::LSPS1Client(LSPS1ClientEvent::SupportedOptionsReady {
297299
request_id,
298300
counterparty_node_id,
299301
supported_options,
@@ -346,7 +348,7 @@ where
346348
);
347349
}
348350
},
349-
Event::LSPS1Client(LSPS1ClientEvent::OrderCreated {
351+
LiquidityEvent::LSPS1Client(LSPS1ClientEvent::OrderCreated {
350352
request_id,
351353
counterparty_node_id,
352354
order_id,
@@ -404,7 +406,7 @@ where
404406
log_error!(self.logger, "Received unexpected LSPS1Client::OrderCreated event!");
405407
}
406408
},
407-
Event::LSPS1Client(LSPS1ClientEvent::OrderStatus {
409+
LiquidityEvent::LSPS1Client(LSPS1ClientEvent::OrderStatus {
408410
request_id,
409411
counterparty_node_id,
410412
order_id,
@@ -462,7 +464,7 @@ where
462464
log_error!(self.logger, "Received unexpected LSPS1Client::OrderStatus event!");
463465
}
464466
},
465-
Event::LSPS2Service(LSPS2ServiceEvent::GetInfo {
467+
LiquidityEvent::LSPS2Service(LSPS2ServiceEvent::GetInfo {
466468
request_id,
467469
counterparty_node_id,
468470
token,
@@ -501,10 +503,8 @@ where
501503
}
502504
}
503505

504-
let mut valid_until: DateTime<Utc> = Utc::now();
505-
valid_until += LSPS2_GETINFO_REQUEST_EXPIRY;
506-
507-
let opening_fee_params = RawOpeningFeeParams {
506+
let valid_until = LSPSDateTime(Utc::now() + LSPS2_GETINFO_REQUEST_EXPIRY);
507+
let opening_fee_params = LSPS2RawOpeningFeeParams {
508508
min_fee_msat: service_config.min_channel_opening_fee_msat,
509509
proportional: service_config.channel_opening_fee_ppm,
510510
valid_until,
@@ -532,7 +532,7 @@ where
532532
return;
533533
}
534534
},
535-
Event::LSPS2Service(LSPS2ServiceEvent::BuyRequest {
535+
LiquidityEvent::LSPS2Service(LSPS2ServiceEvent::BuyRequest {
536536
request_id,
537537
counterparty_node_id,
538538
opening_fee_params: _,
@@ -599,7 +599,7 @@ where
599599
return;
600600
}
601601
},
602-
Event::LSPS2Service(LSPS2ServiceEvent::OpenChannel {
602+
LiquidityEvent::LSPS2Service(LSPS2ServiceEvent::OpenChannel {
603603
their_network_key,
604604
amt_to_forward_msat,
605605
opening_fee_msat: _,
@@ -713,7 +713,7 @@ where
713713
},
714714
}
715715
},
716-
Event::LSPS2Client(LSPS2ClientEvent::OpeningParametersReady {
716+
LiquidityEvent::LSPS2Client(LSPS2ClientEvent::OpeningParametersReady {
717717
request_id,
718718
counterparty_node_id,
719719
opening_fee_params_menu,
@@ -763,7 +763,7 @@ where
763763
);
764764
}
765765
},
766-
Event::LSPS2Client(LSPS2ClientEvent::InvoiceParametersReady {
766+
LiquidityEvent::LSPS2Client(LSPS2ClientEvent::InvoiceParametersReady {
767767
request_id,
768768
counterparty_node_id,
769769
intercept_scid,
@@ -903,7 +903,7 @@ where
903903
return Err(Error::LiquidityRequestFailed);
904904
}
905905

906-
let order_params = OrderParameters {
906+
let order_params = LSPS1OrderParams {
907907
lsp_balance_sat,
908908
client_balance_sat,
909909
required_channel_confirmations: lsp_limits.min_required_channel_confirmations,
@@ -952,7 +952,7 @@ where
952952
}
953953

954954
pub(crate) async fn lsps1_check_order_status(
955-
&self, order_id: OrderId,
955+
&self, order_id: LSPS1OrderId,
956956
) -> Result<LSPS1OrderStatus, Error> {
957957
let lsps1_client = self.lsps1_client.as_ref().ok_or(Error::LiquiditySourceUnavailable)?;
958958
let client_handler = self.liquidity_manager.lsps1_client_handler().ok_or_else(|| {
@@ -1120,7 +1120,7 @@ where
11201120
}
11211121

11221122
async fn lsps2_send_buy_request(
1123-
&self, amount_msat: Option<u64>, opening_fee_params: OpeningFeeParams,
1123+
&self, amount_msat: Option<u64>, opening_fee_params: LSPS2OpeningFeeParams,
11241124
) -> Result<LSPS2BuyResponse, Error> {
11251125
let lsps2_client = self.lsps2_client.as_ref().ok_or(Error::LiquiditySourceUnavailable)?;
11261126

@@ -1291,32 +1291,32 @@ pub(crate) struct LSPS1OpeningParamsResponse {
12911291
#[derive(Debug, Clone)]
12921292
pub struct LSPS1OrderStatus {
12931293
/// The id of the channel order.
1294-
pub order_id: OrderId,
1294+
pub order_id: LSPS1OrderId,
12951295
/// The parameters of channel order.
1296-
pub order_params: OrderParameters,
1296+
pub order_params: LSPS1OrderParams,
12971297
/// Contains details about how to pay for the order.
1298-
pub payment_options: PaymentInfo,
1298+
pub payment_options: LSPS1PaymentInfo,
12991299
/// Contains information about the channel state.
1300-
pub channel_state: Option<ChannelInfo>,
1300+
pub channel_state: Option<LSPS1ChannelInfo>,
13011301
}
13021302

13031303
#[cfg(not(feature = "uniffi"))]
1304-
type PaymentInfo = lightning_liquidity::lsps1::msgs::PaymentInfo;
1304+
type LSPS1PaymentInfo = lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo;
13051305

13061306
/// Details regarding how to pay for an order.
13071307
#[cfg(feature = "uniffi")]
13081308
#[derive(Clone, Debug, PartialEq, Eq)]
1309-
pub struct PaymentInfo {
1309+
pub struct LSPS1PaymentInfo {
13101310
/// A Lightning payment using BOLT 11.
1311-
pub bolt11: Option<crate::uniffi_types::Bolt11PaymentInfo>,
1311+
pub bolt11: Option<crate::uniffi_types::LSPS1Bolt11PaymentInfo>,
13121312
/// An onchain payment.
1313-
pub onchain: Option<OnchainPaymentInfo>,
1313+
pub onchain: Option<LSPS1OnchainPaymentInfo>,
13141314
}
13151315

13161316
#[cfg(feature = "uniffi")]
1317-
impl From<lightning_liquidity::lsps1::msgs::PaymentInfo> for PaymentInfo {
1318-
fn from(value: lightning_liquidity::lsps1::msgs::PaymentInfo) -> Self {
1319-
PaymentInfo {
1317+
impl From<lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo> for LSPS1PaymentInfo {
1318+
fn from(value: lightning_liquidity::lsps1::msgs::LSPS1PaymentInfo) -> Self {
1319+
LSPS1PaymentInfo {
13201320
bolt11: value.bolt11.map(|b| b.into()),
13211321
onchain: value.onchain.map(|o| o.into()),
13221322
}
@@ -1326,11 +1326,11 @@ impl From<lightning_liquidity::lsps1::msgs::PaymentInfo> for PaymentInfo {
13261326
/// An onchain payment.
13271327
#[cfg(feature = "uniffi")]
13281328
#[derive(Clone, Debug, PartialEq, Eq)]
1329-
pub struct OnchainPaymentInfo {
1329+
pub struct LSPS1OnchainPaymentInfo {
13301330
/// Indicates the current state of the payment.
1331-
pub state: lightning_liquidity::lsps1::msgs::PaymentState,
1331+
pub state: lightning_liquidity::lsps1::msgs::LSPS1PaymentState,
13321332
/// The datetime when the payment option expires.
1333-
pub expires_at: chrono::DateTime<chrono::Utc>,
1333+
pub expires_at: LSPSDateTime,
13341334
/// The total fee the LSP will charge to open this channel in satoshi.
13351335
pub fee_total_sat: u64,
13361336
/// The amount the client needs to pay to have the requested channel openend.
@@ -1349,8 +1349,8 @@ pub struct OnchainPaymentInfo {
13491349
}
13501350

13511351
#[cfg(feature = "uniffi")]
1352-
impl From<lightning_liquidity::lsps1::msgs::OnchainPaymentInfo> for OnchainPaymentInfo {
1353-
fn from(value: lightning_liquidity::lsps1::msgs::OnchainPaymentInfo) -> Self {
1352+
impl From<lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo> for LSPS1OnchainPaymentInfo {
1353+
fn from(value: lightning_liquidity::lsps1::msgs::LSPS1OnchainPaymentInfo) -> Self {
13541354
Self {
13551355
state: value.state,
13561356
expires_at: value.expires_at,
@@ -1366,7 +1366,7 @@ impl From<lightning_liquidity::lsps1::msgs::OnchainPaymentInfo> for OnchainPayme
13661366

13671367
#[derive(Debug, Clone)]
13681368
pub(crate) struct LSPS2FeeResponse {
1369-
opening_fee_params_menu: Vec<OpeningFeeParams>,
1369+
opening_fee_params_menu: Vec<LSPS2OpeningFeeParams>,
13701370
}
13711371

13721372
#[derive(Debug, Clone)]
@@ -1456,7 +1456,7 @@ impl LSPS1Liquidity {
14561456
}
14571457

14581458
/// Connects to the configured LSP and checks for the status of a previously-placed order.
1459-
pub fn check_order_status(&self, order_id: OrderId) -> Result<LSPS1OrderStatus, Error> {
1459+
pub fn check_order_status(&self, order_id: LSPS1OrderId) -> Result<LSPS1OrderStatus, Error> {
14601460
let liquidity_source =
14611461
self.liquidity_source.as_ref().ok_or(Error::LiquiditySourceUnavailable)?;
14621462

0 commit comments

Comments
 (0)