lightningdevkit / ldk-node

A ready-to-go node implementation built using LDK.
Other
140 stars 72 forks source link

Remove `counterparty_node_id` argument from `Node::close_channel()` #284

Closed tvolk131 closed 4 months ago

tvolk131 commented 5 months ago

I need to be able to close a channel solely by its channel ID. Currently I call Node::list_channels(), filter by channel ID, then get the ChannelDetails.counterparty_node_id for the channel. Could we bake this behavior into Node::close_channel()?

TheBlueMatt commented 4 months ago

You can have two channels from two different nodes with the same channel id (before the funding step completes), so this isn't generally safe, sadly.

tnull commented 4 months ago

I need to be able to close a channel solely by its channel ID. Currently I call Node::list_channels(), filter by channel ID, then get the ChannelDetails.counterparty_node_id for the channel. Could we bake this behavior into Node::close_channel()?

Note that we recently changed the signature to take a UserChannelId rather than the channel ID (besides others also for the reasons Matt mentioned). Since this is expected to be a unique identifier, I guess we could technically drop the counterparty_node_id now. However, from the perspective of providing a failsafe API I generally like that we require the user to provide the counterparty also.

@tvolk131 Would you benefit from dropping counterparty_node_id at all now that we require a UserChannelId, or would you'd have to look up the latter from the channel id anyways?

tvolk131 commented 4 months ago

Thanks for the explanation! I actually no longer need to be able to close a channel solely by its channel ID. The API currently provided will work just fine for my use-case. I'll go ahead and close this out.