Skip to content

Enable 0conf and 0reserve on channels with trusted peers#853

Open
tankyleo wants to merge 1 commit intolightningdevkit:mainfrom
tankyleo:2026-03-zero-reserve
Open

Enable 0conf and 0reserve on channels with trusted peers#853
tankyleo wants to merge 1 commit intolightningdevkit:mainfrom
tankyleo:2026-03-zero-reserve

Conversation

@tankyleo
Copy link
Copy Markdown
Contributor

No description provided.

@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Mar 30, 2026

👋 Thanks for assigning @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@tankyleo tankyleo requested a review from tnull March 30, 2026 03:40
@tankyleo
Copy link
Copy Markdown
Contributor Author

tankyleo commented Mar 30, 2026

  • For now, we restrict the API to a single list of "trusted peers", and for all the peers on that list, we'll accept 0-conf and 0-reserve channels from them, and open 0-reserve channels to them (for outbound channels the 0-conf decision rests with the accepter of the channel).
  • I would rather make these restrictions for now; and if there is user-demand later, we can add greater flexibility.
  • We already have 4 similar fn open_channel calls (given the "fund_with_all", and "announced" bits), I did not want to multiply the number of such calls by two just for 0-reserve channels. So I read what peers to set 0-reserve for outbound channels from the same list that determines 0-conf, 0-reserve for inbound channels, though I grant that this could be a source of confusion.

prost = { version = "0.11.6", default-features = false}
#bitcoin-payment-instructions = { version = "0.6" }
bitcoin-payment-instructions = { git = "https://github.com/joostjager/bitcoin-payment-instructions", branch = "ldk-dcf0c203e166da2348bef12b2e5eff4a250cdec7" }
bitcoin-payment-instructions = { git = "https://github.com/tankyleo/bitcoin-payment-instructions", branch = "ldk-688544da72cb348e4405d39a75e4d81102c1278a" }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use rev here? Seems otherwise the revision could move if the branch is updated.

///
/// **Note:** Allowing payments via zero-confirmation channels is potentially insecure if
/// the funding transaction never gets confirmed on-chain. Zero-reserve channels
/// allow the counterparty to make cheating attempts with no financial penalty.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// allow the counterparty to make cheating attempts with no financial penalty.
/// allow the counterparty to attempt cheating with no financial penalty.

/// funding transaction ends up never being confirmed on-chain. Zero-confirmation channels
/// should therefore only be accepted from trusted peers.
pub trusted_peers_0conf: Vec<PublicKey>,
/// A list of peers that we trust. If a peer on this list opens a channel to us, we will
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Please expand the first sentence slightly and give it its own paragraph.

},
let is_trusted_peer = self.config.trusted_peers_0conf_0reserve.contains(&node_id);
if is_trusted_peer {
match self.channel_manager.create_channel_to_trusted_peer_0reserve(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm a bit dubious if we indeed should always opt for 0reserve if the peer is marked trusted?

/// allow them to spend their entire balance (zero-reserve). If we open a channel to a peer
/// on this list, we will allow them to spend their entire channel balance (note that for
/// channels *we* open, the decision of whether to accept HTLC forwards with no
/// confirmations of the funding transaction is *the peer's* decision).
Copy link
Copy Markdown
Collaborator

@tnull tnull Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, to be honest this is what makes it a bit weird to mix the concepts: yes, both require trust in the counterparty, but the AFAIU the use case is entirely opposite:

  • We usually opt into 0conf if we are the client and want to allow the LSP to open 0conf channels
  • If we are the client, there is little incentive to allow the LSP to not keep any reserve? So setting 0 reserve only makes sense if we are the LSP and want to allow the client to spend their full channel funds, no?

So, rather than also setting 0reserve if we are a LSPS client (see above), shouldn't we only set that if we are the LSP? Or maybe I'm missing something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are the client, there is little incentive to allow the LSP to not keep any reserve? So setting 0 reserve only makes sense if we are the LSP and want to allow the client to spend their full channel funds, no?

Thanks for the review will mull on this more, a quick reaction to this point: the LSP might want 0-reserve on their side of the channel for greater capital efficiency, ie dedicate as much of their capital as possible towards allowing clients to receive payments. If they get caught making even a single cheating attempt, their entire reputation is burned, and their business goes to 0 (hopefully !) so the incentives are aligned. 1000sats (the min reserve) * x users quickly becomes a lot of dead capital.

So, rather than also setting 0reserve if we are a LSPS client (see above), shouldn't we only set that if we are the LSP? Or maybe I'm missing something?

I see your point yes. Do you have in mind to not offer any public API for setting 0-reserve on outbound channels (assuming the client is usually the opener of the channel, and not the LSP) ?

If we were to offer a completely separate API we have these options:

  • Standalone function calls; this would at least require two more open_channel functions, one with max funding, and one with a parameterized amount.
  • A separate list, similar to what we currently have for inbound channels.
  • Some kind of boolean / enum flag on the existing open_channel functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants