doc: document error 313 where it can actually be returned - #9474
Open
nepet wants to merge 2 commits into
Open
Conversation
The three schemas which documented error 313 all read "The `min-emergency-msat` reserve not be preserved", which is missing a verb. Changelog-None
FUND_CANNOT_AFFORD_WITH_EMERGENCY is raised in exactly two places, `fundpsbt` and `utxopsbt` (wallet/reservation.c), when the node has an anchor channel and the transaction would not leave `min-emergency-msat` behind. Note that this does not require `opening_anchor_channel`: any existing anchor channel is enough. Every other command which can return it does so by forwarding one of those two errors verbatim, but only `withdraw`, `fundchannel` and `multifundchannel` documented it. Add it to the rest: - `fundpsbt` and `utxopsbt`, which raise it directly; - `txprepare` and `multiwithdraw`, which call them; - `upgradewallet`, which calls `utxopsbt` via txprepare_continue() and had no `errors` section at all, so document -1 and 301 there too. Changelog-None
nepet
force-pushed
the
fix-missing-cannot-afford-with-emergency
branch
from
September 3, 2026 08:55
9cd4f35 to
6f42233
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FUND_CANNOT_AFFORD_WITH_EMERGENCYis only raised in two places,json_fundpsbtandjson_utxopsbtin wallet/reservation.c. It fires when the node has an anchor channel and the transaction would not leavemin-emergency-msatbehind. You don't need to passopening_anchor_channelfor this, having an anchor channel already is enough.Every other command that can return it just forwards one of those two errors unchanged. But only
withdraw,fundchannelandmultifundchannelhad it in their schema.So this adds it to:
fundpsbtandutxopsbt, which raise ittxprepareandmultiwithdraw, which call themupgradewallet, which ends up inutxopsbtviatxprepare_continue(). Ithad no
errorssection at all, so -1 and 301 are documented there now as wellThe wider question
I doubt 313 is the only one like this. There are around 70
forward_errorcall sites, and all of them pass the inner error through unchanged. So a command that forwards should really document at least the codes of the command it forwards from. I don't think that holds across the tree.Two examples I ran into but left alone here to keep the scope:
fundpsbtraisesFUNDING_STILL_SYNCING_BITCOIN(304) and doesn't document it. Neither doesanything that calls it. Right now 304 is only documented on
openchannel_initandfundchannel_start, and neither of those raises it.txprepareandwithdrawboth documentFUND_OUTPUT_IS_DUST(302), but I can't find anything in plugins/txprepare.c that raises it.Is this worth fixing properly? I don't think we can work it out from the source.
multifundchannelalone is built from around 40 chained continuations wired up by function pointers, so there is no call graph to follow. Andsetconfigpasses through whatever integer a plugin hands back (lightningd/plugin.c:2265). The only thing I can see working is declaring the codes next to the command registration and checking the schemas against that. Happy to have a go at it if there is appetite, but it's a big change and I'd rather ask first if someone else has time to work on it.The "around 70" and "around 40" figures came from a survey rather than a hand count, so soften them to "most" and "many" if you'd rather not be held to numbers in review.
Important
26.09 FREEZE August 5th: Non-bugfix PRs not ready by this date will wait for 26.12.
RC1 is scheduled on August 17th
The final release is scheduled for September 7th.
Checklist
Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:
tools/lightning-downgrade