Skip to content

Commit 1e5c4a1

Browse files
author
Jurvis Tan
committed
Expose list_peers to bindings
1 parent a491ede commit 1e5c4a1

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

bindings/ldk_node.udl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ interface Node {
5151
[Throws=NodeError]
5252
Invoice receive_variable_amount_payment([ByRef]string description, u32 expiry_secs);
5353
PaymentInfo? payment_info([ByRef]PaymentHash payment_hash);
54+
sequence<PublicKey> list_peers();
5455
};
5556

5657
[Error]

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,11 @@ impl Node {
13411341
pub fn payment_info(&self, payment_hash: &PaymentHash) -> Option<PaymentInfo> {
13421342
self.payment_store.get(payment_hash)
13431343
}
1344+
1345+
/// List node's connected peers.
1346+
pub fn list_peers(&self) -> Vec<PublicKey> {
1347+
self.peer_manager.get_peer_node_ids().iter().map(|(pubkey, _)| *pubkey).collect::<Vec<_>>()
1348+
}
13441349
}
13451350

13461351
async fn connect_peer_if_necessary(

src/test/functional_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ fn channel_full_cycle() {
3737
.connect_open_channel(&node_b.node_id(), &node_b.listening_address().unwrap(), 50000, true)
3838
.unwrap();
3939

40+
assert_eq!(node_a.list_peers(), [node_b.node_id()]);
41+
4042
let funding_txo = loop {
4143
let details = node_a.list_channels();
4244

0 commit comments

Comments
 (0)