Skip to content

diverted funding vout bypass: test hook + fix - #50

Merged
zoedberg merged 2 commits into
rgbfrom
test/diverted-funding-vout-bypass
Nov 9, 2026
Merged

zoedberg merged 2 commits into
rgbfrom
test/diverted-funding-vout-bypass

Conversation

@zoedberg

@zoedberg zoedberg commented Nov 9, 2026

Copy link
Copy Markdown
Member

No description provided.

Add SKIP_COMMITMENT_COLORING_FOR_DIR (gated on _rln_test_hooks): a node
whose ldk_data_dir matches leaves its commitments uncolored instead of
coloring them. It models a malicious funder that does not honestly color
its commitment transactions, so it does not panic on a funding output it
deliberately left without the channel's assets. No-op unless the flag is
set, so other tests are unaffected.
_accept_transfer hardcoded funding_vout = 1, so the acceptor validated
the funding consignment against vout 1 whatever output the channel was
actually built on. An honest funding does put the funding output at
vout 1, after rgb-lib's OP_RETURN, but the funder builds the funding
transaction and so chooses: it could seal the channel's assets to its own
output at vout 1 and leave the real 2-of-2 elsewhere. The acceptor then
credited the channel with assets its funding output did not hold, and
panicked coloring its first commitment, which spends that output. The
panic needed nothing but a funding_created, so it landed before the
funding transaction was broadcast, and the credited amount was persisted
first, making it reachable again on restart.

Pass msg.funding_output_index through handle_funding instead, so the
assets are validated on the same outpoint the commitments spend. LDK
already checks, once the funding transaction confirms, that the output at
that index is the expected 2-of-2 for the expected value, and a channel
cannot become usable before then.
@zoedberg
zoedberg force-pushed the test/diverted-funding-vout-bypass branch from ee033d1 to 63864f8 Compare November 9, 2026 16:15
@zoedberg
zoedberg merged commit 63864f8 into rgb Nov 9, 2026
12 checks passed
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.

1 participant