lightningdevkit / rust-lightning

A highly modular Bitcoin Lightning library written in Rust. It's rust-lightning, not Rusty's Lightning!
Other
1.15k stars 364 forks source link

add #[derive(Serialize, Deserialize)] to struct's #1871

Closed Ashleyhen closed 1 year ago

Ashleyhen commented 1 year ago

It would be nice to easily be able to serialize and deserialize structs to json such as OpenChannel or lnrpcChannelCloseSummary

https://serde.rs/

TheBlueMatt commented 1 year ago

In general, we've avoided taking a serde (or any, really) dependency unless we have a good reason to. We could feature-gate it like rust-bitcoin, but first I'm curious what your use case is here - if you're trying to get something that is human-readable, you can use the Debug impl, if you're trying to access some fields after sending the object over the wire somewhere, why not access those fields natively in Rust and then pass them somewhere?

The OpenChannel message is kinda a strange one to want to access fields in, though, you should generally just use the LDK creation/sending of that message, I think. Not sure what lnrpcChannelCloseSummary is, we don't have that struct anywhere.

Ashleyhen commented 1 year ago

https://api.lightning.community/#v1-channels Yeah so my use case is I'd like to use that struct to make a rpc call to lnd to make a openChannel request

TheBlueMatt commented 1 year ago

LDK is not related to LND, and the struct in question in LDK is a network-level message that lightning peers send each other, not a struct to make RPC calls to LND.

Ashleyhen commented 1 year ago

But LDK should be able to communicate with a LND node right. I'd assume that's done through some RPC call, right? @TheBlueMatt

TheBlueMatt commented 1 year ago

LDK is a full lightning node. It does not remote-control some other lightning node (like LND/CLN/etc). It speaks to other lightning nodes using the standard lightning P2P protocol, opening channels directly with the other node.

Ashleyhen commented 1 year ago

How is that done? how does it interact with the endpoints?

Ashleyhen commented 1 year ago

https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message If LDK doesn't use RPC then how does it send a openchannel message to another node

@TheBlueMatt

TheBlueMatt commented 1 year ago

It's a different protocol from the LND RPC. See the BOLT doc on the P2P protocol.

Ashleyhen commented 1 year ago

image I captured some packets between LND and eclair I think they do use RPC @TheBlueMatt

TheBlueMatt commented 1 year ago

That's your local RPC client. They do not.