Skip to content

ln_init: use rpc prioritizetransaction to fix channel open order in blocks - #825

Merged
pinheadmz merged 3 commits into
mainfrom
ln-prioritize-ch-opens
Nov 6, 2026
Merged

pinheadmz merged 3 commits into
mainfrom
ln-prioritize-ch-opens

Conversation

@pinheadmz

Copy link
Copy Markdown
Contributor

this is much more precise than expecting all LN implementations to get their fee rates exactly right

pinheadmz and others added 3 commits November 6, 2026 15:32
ln_init places each channel at its id.index in the block by giving the
funding transactions decreasing fee rates, which only works if every
implementation pays exactly the rate it's asked for. They don't: CLN
over-estimates the size of its funding transaction (in a mixed network
a CLN funding tx asked for 7846 s/vB was mined ahead of an lnd one asked
for 7966), and with 200 channels per block the step between neighbours
is only 0.5%.

Once all funding transactions of a block are in the miner's mempool,
use prioritisetransaction so the miner ranks each one at exactly its
requested fee rate, independent of what it actually paid. Also wait
for those exact transactions in the mining tank's mempool instead of
counting transactions in tank 0's, which is not the miner when
--miner is used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Now that ln_init orders funding transactions in their block with
prioritisetransaction on the miner, the fee they actually pay no longer
determines their position. Open every channel at 10 s/vB instead of a
decreasing schedule starting at 80006 s/vB, which burned ~0.1 BTC per
channel. An explicit rate is still passed because a new regtest chain
has no fee estimates. Ranking uses (channels in block - index + 1) *
1000 s/vB, which is strictly decreasing and well above anything else
in the mempool.

CLN interprets a feerate without a unit suffix as sat/kvB, so it paid
1000x less than asked. That was harmless at 80006 s/vB but would be
0.01 s/vB now, below the relay minimum, so pass the rate in perkb.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
push_msat is in millisatoshis, but was given the channel's push amount,
which is in satoshis, so CLN pushed 1000x less than intended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pinheadmz
pinheadmz merged commit 190353c into main Nov 6, 2026
48 of 51 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