Skip to content

Commit 76a5152

Browse files
authored
Merge pull request #3701 from TheBlueMatt/2025-04-liquidity-bindings-tweaks
Minor tweaks to `lightning-liquidity` to get it building in bindings
2 parents f9b8d63 + c3a1ffb commit 76a5152

17 files changed

+68
-46
lines changed

lightning-liquidity/src/events.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
use crate::lsps0;
1919
use crate::lsps1;
2020
use crate::lsps2;
21-
use crate::prelude::{Vec, VecDeque};
2221
use crate::sync::{Arc, Mutex};
2322

23+
use alloc::collections::VecDeque;
24+
use alloc::vec::Vec;
25+
2426
use core::future::Future;
2527
use core::task::{Poll, Waker};
2628

lightning-liquidity/src/lib.rs

-6
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@
5252
extern crate alloc;
5353

5454
mod prelude {
55-
#![allow(unused_imports)]
56-
pub use alloc::{boxed::Box, collections::VecDeque, string::String, vec, vec::Vec};
57-
58-
pub use alloc::borrow::ToOwned;
59-
pub use alloc::string::ToString;
60-
6155
pub(crate) use lightning::util::hash_tables::*;
6256
}
6357

lightning-liquidity/src/lsps0/event.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
//! Contains bLIP-50 / LSPS0 event types.
1111
12-
use crate::prelude::Vec;
12+
use alloc::vec::Vec;
13+
1314
use bitcoin::secp256k1::PublicKey;
1415

1516
/// An event which an bLIP-50 / LSPS0 client may want to take some action in response to.

lightning-liquidity/src/lsps0/msgs.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! Message, request, and other primitive types used to implement LSPS0.
22
3+
use alloc::vec::Vec;
4+
use core::convert::TryFrom;
5+
36
use crate::lsps0::ser::{LSPSMessage, LSPSRequestId, LSPSResponseError};
4-
use crate::prelude::Vec;
57

68
use serde::{Deserialize, Serialize};
79

8-
use core::convert::TryFrom;
9-
1010
pub(crate) const LSPS0_LISTPROTOCOLS_METHOD_NAME: &str = "lsps0.list_protocols";
1111

1212
/// A `list_protocols` request.
@@ -99,7 +99,8 @@ mod tests {
9999

100100
use super::*;
101101
use crate::lsps0::ser::LSPSMethod;
102-
use crate::prelude::ToString;
102+
103+
use alloc::string::ToString;
103104

104105
#[test]
105106
fn deserializes_request() {

lightning-liquidity/src/lsps0/ser.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
//! specification](https://github.com/lightning/blips/blob/master/blip-0050.md) for more
55
//! information.
66
7+
use alloc::string::String;
8+
9+
use core::fmt::{self, Display};
10+
use core::str::FromStr;
11+
712
use crate::lsps0::msgs::{
813
LSPS0ListProtocolsRequest, LSPS0Message, LSPS0Request, LSPS0Response,
914
LSPS0_LISTPROTOCOLS_METHOD_NAME,
@@ -16,17 +21,14 @@ use crate::lsps1::msgs::{
1621
use crate::lsps2::msgs::{
1722
LSPS2Message, LSPS2Request, LSPS2Response, LSPS2_BUY_METHOD_NAME, LSPS2_GET_INFO_METHOD_NAME,
1823
};
19-
use crate::prelude::{HashMap, String};
24+
use crate::prelude::HashMap;
2025

2126
use lightning::ln::msgs::{DecodeError, LightningError};
2227
use lightning::ln::wire;
2328
use lightning::util::ser::{LengthLimitedRead, LengthReadable, WithoutLength};
2429

2530
use bitcoin::secp256k1::PublicKey;
2631

27-
use core::fmt::{self, Display};
28-
use core::str::FromStr;
29-
3032
#[cfg(feature = "std")]
3133
use std::time::{SystemTime, UNIX_EPOCH};
3234

@@ -625,7 +627,7 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
625627
}
626628

627629
pub(crate) mod string_amount {
628-
use crate::prelude::{String, ToString};
630+
use alloc::string::{String, ToString};
629631
use core::str::FromStr;
630632
use serde::de::Unexpected;
631633
use serde::{Deserialize, Deserializer, Serializer};
@@ -650,7 +652,7 @@ pub(crate) mod string_amount {
650652
}
651653

652654
pub(crate) mod string_amount_option {
653-
use crate::prelude::{String, ToString};
655+
use alloc::string::{String, ToString};
654656
use core::str::FromStr;
655657
use serde::de::Unexpected;
656658
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@@ -679,7 +681,7 @@ pub(crate) mod string_amount_option {
679681
}
680682

681683
pub(crate) mod string_offer {
682-
use crate::prelude::{String, ToString};
684+
use alloc::string::{String, ToString};
683685
use core::str::FromStr;
684686
use lightning::offers::offer::Offer;
685687
use serde::de::Unexpected;
@@ -705,7 +707,7 @@ pub(crate) mod string_offer {
705707
}
706708

707709
pub(crate) mod unchecked_address {
708-
use crate::prelude::{String, ToString};
710+
use alloc::string::{String, ToString};
709711
use bitcoin::Address;
710712
use core::str::FromStr;
711713
use serde::de::Unexpected;
@@ -732,7 +734,7 @@ pub(crate) mod unchecked_address {
732734
}
733735

734736
pub(crate) mod unchecked_address_option {
735-
use crate::prelude::{String, ToString};
737+
use alloc::string::{String, ToString};
736738
use bitcoin::Address;
737739
use core::str::FromStr;
738740
use serde::de::Unexpected;

lightning-liquidity/src/lsps0/service.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
//! specifcation](https://github.com/lightning/blips/blob/master/blip-0050.md) for more
1414
//! information.
1515
16+
use alloc::vec::Vec;
17+
1618
use crate::lsps0::msgs::{LSPS0ListProtocolsResponse, LSPS0Message, LSPS0Request, LSPS0Response};
1719
use crate::lsps0::ser::{LSPSProtocolMessageHandler, LSPSRequestId};
1820
use crate::message_queue::MessageQueue;
19-
use crate::prelude::Vec;
2021
use crate::sync::Arc;
2122

2223
use lightning::ln::msgs::{ErrorAction, LightningError};

lightning-liquidity/src/lsps1/msgs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
//! Message, request, and other primitive types used to implement bLIP-51 / LSPS1.
22
3+
use alloc::string::String;
4+
5+
use core::convert::TryFrom;
6+
37
use crate::lsps0::ser::{
48
string_amount, string_offer, u32_fee_rate, unchecked_address, unchecked_address_option,
59
LSPSDateTime, LSPSMessage, LSPSRequestId, LSPSResponseError,
610
};
711

8-
use crate::prelude::String;
9-
1012
use bitcoin::{Address, FeeRate, OutPoint};
1113

1214
use lightning::offers::offer::Offer;
1315
use lightning_invoice::Bolt11Invoice;
1416

1517
use serde::{Deserialize, Serialize};
1618

17-
use core::convert::TryFrom;
18-
1919
pub(crate) const LSPS1_GET_INFO_METHOD_NAME: &str = "lsps1.get_info";
2020
pub(crate) const LSPS1_CREATE_ORDER_METHOD_NAME: &str = "lsps1.create_order";
2121
pub(crate) const LSPS1_GET_ORDER_METHOD_NAME: &str = "lsps1.get_order";

lightning-liquidity/src/lsps1/service.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
//! Contains the main bLIP-51 / LSPS1 server object, [`LSPS1ServiceHandler`].
1111
12+
use alloc::string::String;
13+
14+
use core::ops::Deref;
15+
1216
use super::event::LSPS1ServiceEvent;
1317
use super::msgs::{
1418
LSPS1ChannelInfo, LSPS1CreateOrderRequest, LSPS1CreateOrderResponse, LSPS1GetInfoResponse,
@@ -22,7 +26,7 @@ use crate::events::EventQueue;
2226
use crate::lsps0::ser::{
2327
LSPSDateTime, LSPSProtocolMessageHandler, LSPSRequestId, LSPSResponseError,
2428
};
25-
use crate::prelude::{new_hash_map, HashMap, String};
29+
use crate::prelude::{new_hash_map, HashMap};
2630
use crate::sync::{Arc, Mutex, RwLock};
2731
use crate::utils;
2832

@@ -36,7 +40,6 @@ use lightning::util::logger::Level;
3640
use bitcoin::secp256k1::PublicKey;
3741

3842
use chrono::Utc;
39-
use core::ops::Deref;
4043

4144
/// Server-side configuration options for bLIP-51 / LSPS1 channel requests.
4245
#[derive(Clone, Debug)]

lightning-liquidity/src/lsps2/client.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88

99
//! Contains the main bLIP-52 / LSPS2 client object, [`LSPS2ClientHandler`].
1010
11+
use alloc::string::{String, ToString};
12+
13+
use core::default::Default;
14+
use core::ops::Deref;
15+
1116
use crate::events::EventQueue;
1217
use crate::lsps0::ser::{LSPSProtocolMessageHandler, LSPSRequestId, LSPSResponseError};
1318
use crate::lsps2::event::LSPS2ClientEvent;
1419
use crate::message_queue::MessageQueue;
15-
use crate::prelude::{new_hash_map, new_hash_set, HashMap, HashSet, String, ToString};
20+
use crate::prelude::{new_hash_map, new_hash_set, HashMap, HashSet};
1621
use crate::sync::{Arc, Mutex, RwLock};
1722

1823
use lightning::ln::msgs::{ErrorAction, LightningError};
@@ -22,9 +27,6 @@ use lightning::util::logger::Level;
2227

2328
use bitcoin::secp256k1::PublicKey;
2429

25-
use core::default::Default;
26-
use core::ops::Deref;
27-
2830
use crate::lsps2::msgs::{
2931
LSPS2BuyRequest, LSPS2BuyResponse, LSPS2GetInfoRequest, LSPS2GetInfoResponse, LSPS2Message,
3032
LSPS2OpeningFeeParams, LSPS2Request, LSPS2Response,

lightning-liquidity/src/lsps2/event.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
1212
use super::msgs::LSPS2OpeningFeeParams;
1313
use crate::lsps0::ser::LSPSRequestId;
14-
use crate::prelude::{String, Vec};
14+
use alloc::string::String;
15+
use alloc::vec::Vec;
1516

1617
use bitcoin::secp256k1::PublicKey;
1718

lightning-liquidity/src/lsps2/msgs.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! Message, request, and other primitive types used to implement bLIP-52 / LSPS2.
22
3+
use alloc::string::String;
4+
use alloc::vec::Vec;
5+
36
use core::convert::TryFrom;
47

58
use bitcoin::hashes::hmac::{Hmac, HmacEngine};
@@ -13,7 +16,6 @@ use crate::lsps0::ser::{
1316
string_amount, string_amount_option, LSPSDateTime, LSPSMessage, LSPSRequestId,
1417
LSPSResponseError,
1518
};
16-
use crate::prelude::{String, Vec};
1719
use crate::utils;
1820

1921
pub(crate) const LSPS2_GET_INFO_METHOD_NAME: &str = "lsps2.get_info";

lightning-liquidity/src/lsps2/payment_queue.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use crate::prelude::Vec;
1+
use alloc::vec::Vec;
2+
23
use lightning::ln::channelmanager::InterceptId;
34
use lightning_types::payment::PaymentHash;
45

lightning-liquidity/src/lsps2/service.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
//! Contains the main bLIP-52 / LSPS2 server-side object, [`LSPS2ServiceHandler`].
1111
12+
use alloc::string::{String, ToString};
13+
use alloc::vec::Vec;
14+
15+
use core::ops::Deref;
16+
use core::sync::atomic::{AtomicUsize, Ordering};
17+
1218
use crate::events::EventQueue;
1319
use crate::lsps0::ser::{
1420
LSPSMessage, LSPSProtocolMessageHandler, LSPSRequestId, LSPSResponseError,
@@ -22,7 +28,7 @@ use crate::lsps2::utils::{
2228
};
2329
use crate::message_queue::MessageQueue;
2430
use crate::prelude::hash_map::Entry;
25-
use crate::prelude::{new_hash_map, HashMap, String, ToString, Vec};
31+
use crate::prelude::{new_hash_map, HashMap};
2632
use crate::sync::{Arc, Mutex, MutexGuard, RwLock};
2733

2834
use lightning::events::HTLCDestination;
@@ -36,9 +42,6 @@ use lightning_types::payment::PaymentHash;
3642

3743
use bitcoin::secp256k1::PublicKey;
3844

39-
use core::ops::Deref;
40-
use core::sync::atomic::{AtomicUsize, Ordering};
41-
4245
use crate::lsps2::msgs::{
4346
LSPS2BuyRequest, LSPS2BuyResponse, LSPS2GetInfoRequest, LSPS2GetInfoResponse, LSPS2Message,
4447
LSPS2OpeningFeeParams, LSPS2RawOpeningFeeParams, LSPS2Request, LSPS2Response,
@@ -551,7 +554,7 @@ macro_rules! get_or_insert_peer_state_entry {
551554
}
552555

553556
/// The main object allowing to send and receive bLIP-52 / LSPS2 messages.
554-
pub struct LSPS2ServiceHandler<CM: Deref + Clone>
557+
pub struct LSPS2ServiceHandler<CM: Deref>
555558
where
556559
CM::Target: AChannelManager,
557560
{
@@ -565,7 +568,7 @@ where
565568
config: LSPS2ServiceConfig,
566569
}
567570

568-
impl<CM: Deref + Clone> LSPS2ServiceHandler<CM>
571+
impl<CM: Deref> LSPS2ServiceHandler<CM>
569572
where
570573
CM::Target: AChannelManager,
571574
{
@@ -1352,7 +1355,7 @@ where
13521355
}
13531356
}
13541357

1355-
impl<CM: Deref + Clone> LSPSProtocolMessageHandler for LSPS2ServiceHandler<CM>
1358+
impl<CM: Deref> LSPSProtocolMessageHandler for LSPS2ServiceHandler<CM>
13561359
where
13571360
CM::Target: AChannelManager,
13581361
{

lightning-liquidity/src/manager.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
use alloc::boxed::Box;
2+
use alloc::string::ToString;
3+
use alloc::vec::Vec;
4+
15
use crate::events::{EventQueue, LiquidityEvent};
26
use crate::lsps0::client::LSPS0ClientHandler;
37
use crate::lsps0::msgs::LSPS0Message;
@@ -17,7 +21,7 @@ use crate::lsps1::service::{LSPS1ServiceConfig, LSPS1ServiceHandler};
1721
use crate::lsps2::client::{LSPS2ClientConfig, LSPS2ClientHandler};
1822
use crate::lsps2::msgs::LSPS2Message;
1923
use crate::lsps2::service::{LSPS2ServiceConfig, LSPS2ServiceHandler};
20-
use crate::prelude::{new_hash_map, new_hash_set, Box, HashMap, HashSet, ToString, Vec};
24+
use crate::prelude::{new_hash_map, new_hash_set, HashMap, HashSet};
2125
use crate::sync::{Arc, Mutex, RwLock};
2226

2327
use lightning::chain::{self, BestBlock, Confirm, Filter, Listen};

lightning-liquidity/src/message_queue.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
//! Holds types and traits used to implement message queues for [`LSPSMessage`]s.
22
3+
use alloc::boxed::Box;
4+
use alloc::collections::VecDeque;
5+
use alloc::vec::Vec;
6+
37
use crate::lsps0::ser::LSPSMessage;
4-
use crate::prelude::{Box, Vec, VecDeque};
58
use crate::sync::{Mutex, RwLock};
69

710
use bitcoin::secp256k1::PublicKey;

lightning-liquidity/src/tests/utils.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use crate::prelude::Vec;
1+
use alloc::vec::Vec;
2+
23
use bitcoin::secp256k1::PublicKey;
34
use lightning::io;
45
use lightning::sign::EntropySource;

lightning-liquidity/src/utils.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
use alloc::string::String;
12
use core::{fmt::Write, ops::Deref};
3+
24
use lightning::sign::EntropySource;
35

46
use crate::lsps0::ser::LSPSRequestId;
5-
use crate::prelude::String;
67

78
pub fn scid_from_human_readable_string(human_readable_scid: &str) -> Result<u64, ()> {
89
let mut parts = human_readable_scid.split('x');

0 commit comments

Comments
 (0)