Skip to content

Do not record unilateral closes as payments#979

Open
tankyleo wants to merge 1 commit into
lightningdevkit:mainfrom
tankyleo:2026-07-filter-out-unilateralclose
Open

Do not record unilateral closes as payments#979
tankyleo wants to merge 1 commit into
lightningdevkit:mainfrom
tankyleo:2026-07-filter-out-unilateralclose

Conversation

@tankyleo

Copy link
Copy Markdown
Contributor

Unilateral closes are not onchain payments. The real on-chain credits to our onchain balance after a unilateral close happen on Sweep and Claim transactions.

Also, UnilateralClose payments currently never graduate from the Pending state, as no BDK events are emitted when these transactions confirm.

Co-Authored-By: HAL 9000

Unilateral closes are not onchain payments. The real on-chain credits to
our onchain balance after a unilateral close happen on `Sweep` and
`Claim` transactions.

Also, `UnilateralClose` payments currently never graduate from the `Pending`
state, as no BDK events are emitted when these transactions confirm.

AI-Assisted-By: OpenAI Codex
@ldk-reviews-bot

ldk-reviews-bot commented Jul 14, 2026

Copy link
Copy Markdown

👋 Thanks for assigning @jkczyz 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 July 14, 2026 06:18
@tankyleo

tankyleo commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Continued from #660

The original motivation for this change: commitment transactions in 0FC channels have zero-fees and zero-amount according to BDK (since they don't interact with the on-chain wallet), so these were not recorded in the payment store. I then failed the assertion in the channel_full_cycle test that asserts that UnilateralClose was present in the payment store.

Hmm, these don't directly interact with the onchain wallet, but wouldn't it still make sense to record them as otherwise users would have a 'gap' between channel funding and the resulting Sweep transaction? If we keep them that could allow them to track the funds end-to-end, on each step?

Would have to think more about the overall purpose of payment store, as a user I think I would find it quite confusing for there to be a zero-amount inbound payment, with a non-zero fee. In the case of zero-fee commitment channels, these would be inbound payment for zero-amount, zero-fee (but the entry could still allow us to track the movement of funds).

Also note that currently UnilteralClose only gets recorded for outbound channels, as BDK can tracks the funding output and assigns a non-zero fee only in this case. This makes sense as for inbound channels, the fee of the commitment transaction comes from the counterparty's balance, not our balance.

@tankyleo tankyleo requested a review from jkczyz July 14, 2026 06:23

@tnull tnull left a comment

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.

Yeah, makes sense to me, though I still think it somehow would be nice to show users the intermediate transaction state somehow. But you're probably right that the payment store is not the right place to do it.

Comment thread tests/common/mod.rs
"node_b should remain persisted in node_a peer store after locally-initiated force-close"
);
assert_any_node_has_onchain_tx_type(
assert_no_node_has_onchain_tx_type(

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: Can we just reuse assert_all_nodes_have_onchain_tx_type and invert the predicate?

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.

3 participants