Skip to content

Fix panic when calling batch_funding_transaction_generated early #4015

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

TheBlueMatt
Copy link
Collaborator

If a user calls `batch_funding_transaction_generated` before a
channel is ready to fund its possible to hit an `unwrap` when the
transaction-scanning logic attempts to fetch the channel's expected
output `scriptPubKey`.

While users shouldn't be doing this, we should also avoid the
panic, so here check the channel state first.

Found by the `full_stack_target` fuzzer.

`functional_tests.rs` is a rather large beast, but with this move
we take it down to under 10k LoC.
If a user calls `batch_funding_transaction_generated` before a
channel is ready to fund its possible to hit an `unwrap` when the
transaction-scanning logic attempts to fetch the channel's expected
output `scriptPubKey`.

While users shouldn't be doing this, we should also avoid the
panic, so here check the channel state first.

Found by the `full_stack_target` fuzzer.
When a channel gets replaced before we can fund it, its possible
now (due to RNG output repetition) to hit the "trying to fund
channel before its ready to be funded" error in the
`full_stack_target` fuzzer.

Thus, we now simply ignore errors when funding.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Aug 16, 2025

👋 I see @joostjager was un-assigned.
If you'd like another reviewer assignment, please click here.

@tnull tnull requested review from tnull and removed request for joostjager August 18, 2025 07:28
Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Seems this needs a rebase

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

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