Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support CLN (Core Lightning / c-lightning)? #67

Open
kristapsk opened this issue Nov 16, 2022 · 3 comments
Open

Support CLN (Core Lightning / c-lightning)? #67

kristapsk opened this issue Nov 16, 2022 · 3 comments

Comments

@kristapsk
Copy link

Haven't looked into details of architecture of nolooking, how easy it would be to add support for other Lightning Network node implementations, mainly CLN?

@Kixunil
Copy link
Contributor

Kixunil commented Nov 17, 2022

If CLN has a PSBT API reasonably similar to that of LND it should be possible. But also there would be need of having a Rust library for RPC and some abstraction to have a single node interface. Same for Eclair.

@kristapsk
Copy link
Author

Not familiar with LND API, but for CLN there is fundchannel_start and fundchannel_complete. I think they were first at both implementng such API for creating channels and also PSBTs.

@Kixunil
Copy link
Contributor

Kixunil commented Nov 18, 2022

From quick look the API looks usable (and much simpler than LNDs!), although it's not entirely clear to me whether it can be used for funding multiple channels in the same transaction (probably it can). Also IDK how CLN handles reserve for anchors.

So something like this should work:

trait LnNode {
    // async is just me being lazy, I'm not suggesting to use nightly. We would need to return boxed pinned future.
    // If there's not enough reserved sats for anchors returns a `TxOut` that needs to be funded. Amount may be raised.
    async fn get_anchor_reserve(&mut self, num_new_channels: usize) -> Result<Option<TxOut>>;

    // box makes it object-safe so that we can run-time select the impl without blowing up code size or even support multiple nodes
    // allocation cost should be dwarfed by communication overhead (including with peers)
    async fn init_open(&mut self, peer: NodeId, amount: Amount) -> Result<(TxOut, Box<dyn UnfundedChannel>)>;
}

trait UnfundedChannel {
    async fn submit_funding_psbt(self: Box<Self>, psbt: Psbt) -> Result<()>;
}

Then we call get_anchor_reserve, obtain TxOuts in a for loop while storing UnfundedChannel and submit PSBT to all at the end.

@DanGould DanGould changed the title Any plans to support CLN (Core Lightning / c-lightning)? Support CLN (Core Lightning / c-lightning)? Apr 2, 2023
@DanGould DanGould moved this to Todo in Payjoin Roadmap 📝 Apr 2, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants