Skip to content

Commit c90750c

Browse files
authored
Merge pull request #4186 from TheBlueMatt/2025-10-first-bindings-pass
Small API tweaks to make bindings easier
2 parents 2849ae2 + e4512d1 commit c90750c

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

lightning-liquidity/src/lsps5/event.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use alloc::vec::Vec;
1515
use bitcoin::secp256k1::PublicKey;
1616

1717
use lightning::impl_writeable_tlv_based_enum;
18-
use lightning::util::hash_tables::HashMap;
1918

2019
use super::msgs::LSPS5AppName;
2120
use super::msgs::LSPS5Error;
@@ -70,7 +69,7 @@ pub enum LSPS5ServiceEvent {
7069
/// - `"x-lsps5-timestamp"`: with the timestamp in RFC3339 format (`"YYYY-MM-DDThh:mm:ss.uuuZ"`).
7170
/// - `"x-lsps5-signature"`: with the signature of the notification payload, signed using the LSP's node ID.
7271
/// Other custom headers may also be included as needed.
73-
headers: HashMap<String, String>,
72+
headers: Vec<(String, String)>,
7473
},
7574
}
7675

lightning-liquidity/src/lsps5/msgs.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -541,34 +541,29 @@ pub struct WebhookNotification {
541541
}
542542

543543
impl WebhookNotification {
544-
/// Create a new webhook notification.
545-
pub fn new(method: WebhookNotificationMethod) -> Self {
546-
Self { method }
547-
}
548-
549544
/// Create a webhook_registered notification.
550545
pub fn webhook_registered() -> Self {
551-
Self::new(WebhookNotificationMethod::LSPS5WebhookRegistered)
546+
Self { method: WebhookNotificationMethod::LSPS5WebhookRegistered }
552547
}
553548

554549
/// Create a payment_incoming notification.
555550
pub fn payment_incoming() -> Self {
556-
Self::new(WebhookNotificationMethod::LSPS5PaymentIncoming)
551+
Self { method: WebhookNotificationMethod::LSPS5PaymentIncoming }
557552
}
558553

559554
/// Create an expiry_soon notification.
560555
pub fn expiry_soon(timeout: u32) -> Self {
561-
Self::new(WebhookNotificationMethod::LSPS5ExpirySoon { timeout })
556+
Self { method: WebhookNotificationMethod::LSPS5ExpirySoon { timeout } }
562557
}
563558

564559
/// Create a liquidity_management_request notification.
565560
pub fn liquidity_management_request() -> Self {
566-
Self::new(WebhookNotificationMethod::LSPS5LiquidityManagementRequest)
561+
Self { method: WebhookNotificationMethod::LSPS5LiquidityManagementRequest }
567562
}
568563

569564
/// Create an onion_message_incoming notification.
570565
pub fn onion_message_incoming() -> Self {
571-
Self::new(WebhookNotificationMethod::LSPS5OnionMessageIncoming)
566+
Self { method: WebhookNotificationMethod::LSPS5OnionMessageIncoming }
572567
}
573568
}
574569

lightning-liquidity/src/lsps5/service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,12 +630,12 @@ where
630630

631631
let signature_hex = self.sign_notification(&notification, &timestamp)?;
632632

633-
let mut headers: HashMap<String, String> = [("Content-Type", "application/json")]
633+
let mut headers: Vec<(String, String)> = [("Content-Type", "application/json")]
634634
.into_iter()
635635
.map(|(k, v)| (k.to_string(), v.to_string()))
636636
.collect();
637-
headers.insert("x-lsps5-timestamp".into(), timestamp.to_rfc3339());
638-
headers.insert("x-lsps5-signature".into(), signature_hex);
637+
headers.push(("x-lsps5-timestamp".into(), timestamp.to_rfc3339()));
638+
headers.push(("x-lsps5-signature".into(), signature_hex));
639639

640640
event_queue_notifier.enqueue(LSPS5ServiceEvent::SendWebhookNotification {
641641
counterparty_node_id,

lightning-liquidity/tests/lsps5_integration_tests.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use lightning::ln::functional_test_utils::{
1717
};
1818
use lightning::ln::msgs::Init;
1919
use lightning::ln::peer_handler::CustomMessageHandler;
20-
use lightning::util::hash_tables::{HashMap, HashSet};
20+
use lightning::util::hash_tables::HashSet;
2121
use lightning::util::test_utils::TestStore;
2222
use lightning_liquidity::events::LiquidityEvent;
2323
use lightning_liquidity::lsps0::ser::LSPSDateTime;
@@ -288,15 +288,20 @@ impl TimeProvider for MockTimeProvider {
288288
}
289289
}
290290

291-
fn extract_ts_sig(headers: &HashMap<String, String>) -> (LSPSDateTime, String) {
291+
fn extract_ts_sig(headers: &Vec<(String, String)>) -> (LSPSDateTime, String) {
292292
let timestamp = headers
293-
.get("x-lsps5-timestamp")
293+
.iter()
294+
.find_map(|(key, value)| (key == "x-lsps5-timestamp").then(|| value))
294295
.expect("missing x-lsps5-timestamp header")
295296
.parse::<LSPSDateTime>()
296297
.expect("failed to parse x-lsps5-timestamp header");
297298

298-
let signature =
299-
headers.get("x-lsps5-signature").expect("missing x-lsps5-signature header").to_owned();
299+
let signature = headers
300+
.iter()
301+
.find(|(key, _)| key == "x-lsps5-signature")
302+
.expect("missing x-lsps5-signature header")
303+
.1
304+
.clone();
300305
(timestamp, signature)
301306
}
302307

lightning/src/util/anchor_channel_reserves.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ pub fn can_support_additional_anchor_channel<
290290
>,
291291
>,
292292
>(
293-
context: &AnchorChannelReserveContext, utxos: &[Utxo], a_channel_manager: &AChannelManagerRef,
294-
chain_monitor: &ChainMonitorRef,
293+
context: &AnchorChannelReserveContext, utxos: &[Utxo], a_channel_manager: AChannelManagerRef,
294+
chain_monitor: ChainMonitorRef,
295295
) -> bool
296296
where
297297
AChannelManagerRef::Target: AChannelManager,

0 commit comments

Comments
 (0)