Skip to content

Commit 7c067a7

Browse files
committed
Take all PublicKey and SocketAddr by value
They are copied/defereneced in most cases anyways, and this makes the interface a bit more uniform.
1 parent c64c3ce commit 7c067a7

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

bindings/ldk_node.udl

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ interface Node {
3838
[Throws=NodeError]
3939
void connect(PublicKey node_id, SocketAddr address, boolean permanently);
4040
[Throws=NodeError]
41-
void disconnect([ByRef]PublicKey node_id);
41+
void disconnect(PublicKey node_id);
4242
[Throws=NodeError]
4343
void connect_open_channel(PublicKey node_id, SocketAddr address, u64 channel_amount_sats, u64? push_to_counterparty_msat, boolean announce_channel);
4444
[Throws=NodeError]
45-
void close_channel([ByRef]ChannelId channel_id, [ByRef]PublicKey counterparty_node_id);
45+
void close_channel([ByRef]ChannelId channel_id, PublicKey counterparty_node_id);
4646
[Throws=NodeError]
4747
void sync_wallets();
4848
[Throws=NodeError]
4949
PaymentHash send_payment([ByRef]Invoice invoice);
5050
[Throws=NodeError]
5151
PaymentHash send_payment_using_amount([ByRef]Invoice invoice, u64 amount_msat);
5252
[Throws=NodeError]
53-
PaymentHash send_spontaneous_payment(u64 amount_msat, [ByRef]PublicKey node_id);
53+
PaymentHash send_spontaneous_payment(u64 amount_msat, PublicKey node_id);
5454
[Throws=NodeError]
5555
Invoice receive_payment(u64 amount_msat, [ByRef]string description, u32 expiry_secs);
5656
[Throws=NodeError]

src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ impl Node {
953953
///
954954
/// Will also remove the peer from the peer store, i.e., after this has been called we won't
955955
/// try to reconnect on restart.
956-
pub fn disconnect(&self, counterparty_node_id: &PublicKey) -> Result<(), Error> {
956+
pub fn disconnect(&self, counterparty_node_id: PublicKey) -> Result<(), Error> {
957957
let rt_lock = self.runtime.read().unwrap();
958958
if rt_lock.is_none() {
959959
return Err(Error::NotRunning);
@@ -968,7 +968,7 @@ impl Node {
968968
}
969969
}
970970

971-
self.peer_manager.disconnect_by_node_id(*counterparty_node_id);
971+
self.peer_manager.disconnect_by_node_id(counterparty_node_id);
972972
Ok(())
973973
}
974974

@@ -1126,10 +1126,10 @@ impl Node {
11261126

11271127
/// Close a previously opened channel.
11281128
pub fn close_channel(
1129-
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey,
1129+
&self, channel_id: &ChannelId, counterparty_node_id: PublicKey,
11301130
) -> Result<(), Error> {
1131-
self.peer_store.remove_peer(counterparty_node_id)?;
1132-
match self.channel_manager.close_channel(&channel_id.0, counterparty_node_id) {
1131+
self.peer_store.remove_peer(&counterparty_node_id)?;
1132+
match self.channel_manager.close_channel(&channel_id.0, &counterparty_node_id) {
11331133
Ok(_) => Ok(()),
11341134
Err(_) => Err(Error::ChannelClosingFailed),
11351135
}
@@ -1291,7 +1291,7 @@ impl Node {
12911291

12921292
/// Send a spontaneous, aka. "keysend", payment
12931293
pub fn send_spontaneous_payment(
1294-
&self, amount_msat: u64, node_id: &PublicKey,
1294+
&self, amount_msat: u64, node_id: PublicKey,
12951295
) -> Result<PaymentHash, Error> {
12961296
let rt_lock = self.runtime.read().unwrap();
12971297
if rt_lock.is_none() {
@@ -1303,7 +1303,7 @@ impl Node {
13031303

13041304
let route_params = RouteParameters {
13051305
payment_params: PaymentParameters::from_node_id(
1306-
*node_id,
1306+
node_id,
13071307
self.config.default_cltv_expiry_delta,
13081308
),
13091309
final_value_msat: amount_msat,

src/test/functional_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn channel_full_cycle() {
181181
assert_eq!(node_b.payment(&payment_hash).unwrap().direction, PaymentDirection::Inbound);
182182
assert_eq!(node_b.payment(&payment_hash).unwrap().amount_msat, Some(determined_amount_msat));
183183

184-
node_b.close_channel(&channel_id, &node_a.node_id()).unwrap();
184+
node_b.close_channel(&channel_id, node_a.node_id()).unwrap();
185185
expect_event!(node_a, ChannelClosed);
186186
expect_event!(node_b, ChannelClosed);
187187

0 commit comments

Comments
 (0)