Skip to content

docs: document missing and fix erroneous JSON-RPC error codes - #9496

Open
daywalker90 wants to merge 1 commit into
ElementsProject:masterfrom
daywalker90:fix-wrong-missing-error-codes
Open

docs: document missing and fix erroneous JSON-RPC error codes#9496
daywalker90 wants to merge 1 commit into
ElementsProject:masterfrom
daywalker90:fix-wrong-missing-error-codes

Conversation

@daywalker90

Copy link
Copy Markdown
Collaborator

Audit the errors sections of the RPC schemas against the error codes the handlers actually raise, and fix the discrepancies.

FUNDING_STILL_SYNCING_BITCOIN (304) is only raised by fundpsbt and utxopsbt (wallet/reservation.c), and is forwarded verbatim by every other command which can return it. Document it on fundpsbt, utxopsbt, txprepare, withdraw, multiwithdraw, upgradewallet, fundchannel and multifundchannel. Conversely, fundchannel_start and openchannel_init do not call either: when the node is not synced they delay via topology_add_sync_waiter() and retry, so drop their stale 304.

Also fix the remaining discrepancies:

  • delpay documented 211 for a status mismatch, but that path returns 208 (PAY_NO_SUCH_PAYMENT); 211 is never raised by delpay, so replace it;
  • document missing codes: createinvoice 907 (INVOICE_OFFER_INACTIVE), enableoffer 1007 (OFFER_USED_SINGLE_USE), getroutes 217 (PAY_USER_ERROR) and addpsbtoutput 302/309;
  • add errors sections to splice_init, splice_update and splice_signed (351-356), disableoffer and disableinvoicerequest (1001), preapproveinvoice (213), preapprovekeysend (214) and recover (1600).

Changelog-None

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:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.
  • Important All PRs must consider how to reverse any persistent changes for tools/lightning-downgrade

@Andezion Andezion 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.

The three splice commands (splice_init, splice_update, splice_signed) got the most extensive new errors sections in this pr (351-356). Did the audit include the async failure paths in lightningd/channel_control.c, or only the synchronous raises in param_channel_for_splice? i ask because i found several more splice-specific codes that appear to reach the pending rpc command via splice_command_for_chan():

  • SPLICE_BROADCAST_FAIL = 350 (check_utxo_block, line 564)
  • SPLICE_FUNDING_LOW = 357 (handle_splice_funding_error, line 245)
  • SPLICE_STATE_ERROR = 358 (handle_splice_state_error, line 275)
  • SPLICE_LOW_FEE/SPLICE_HIGH_FEE = 359/360 (handle_splice_feerate_error, line 305)
  • SPLICE_ABORT = 362 (handle_splice_abort, line 364)
  • SPLICE_CHANNEL_ERROR = 363 (channel_control_errmsg, line 1740)

Audit the `errors` sections of the RPC schemas against the error codes
the handlers actually raise, and fix the discrepancies.

FUNDING_STILL_SYNCING_BITCOIN (304) is only raised by `fundpsbt` and
`utxopsbt` (wallet/reservation.c), and is forwarded verbatim by every
other command which can return it.  Document it on `fundpsbt`,
`utxopsbt`, `txprepare`, `withdraw`, `multiwithdraw`, `upgradewallet`,
`fundchannel` and `multifundchannel`.  Conversely, `fundchannel_start`
and `openchannel_init` do not call either: when the node is not synced
they delay via topology_add_sync_waiter() and retry, so drop their
stale 304.

Also fix the remaining discrepancies:

- `delpay` documented 211 for a status mismatch, but that path returns
  208 (PAY_NO_SUCH_PAYMENT); 211 is never raised by `delpay`, so replace
  it;
- document missing codes: `createinvoice` 907 (INVOICE_OFFER_INACTIVE),
  `enableoffer` 1007 (OFFER_USED_SINGLE_USE), `getroutes` 217
  (PAY_USER_ERROR) and `addpsbtoutput` 302/309;
- add `errors` sections to `splice_init`, `splice_update` and
  `splice_signed` (351-356), `disableoffer` and `disableinvoicerequest`
  (1001), `preapproveinvoice` (213), `preapprovekeysend` (214) and
  `recover` (1600).

The splice commands can also fail asynchronously, after the command has
gone pending, through the channeld message handlers in channel_control.c
which resolve the pending command via splice_command_for_chan().
Document those codes too: 350 (SPLICE_BROADCAST_FAIL) on `splice_signed`;
357/359/360 (SPLICE_FUNDING_LOW/SPLICE_LOW_FEE/SPLICE_HIGH_FEE) on
`splice_update`; and 358/362/363 (SPLICE_STATE_ERROR/SPLICE_ABORT/
SPLICE_CHANNEL_ERROR) on all three.

Changelog-None
@daywalker90
daywalker90 force-pushed the fix-wrong-missing-error-codes branch from 94096ff to 3f359c0 Compare September 11, 2026 11:53
@daywalker90

Copy link
Copy Markdown
Collaborator Author

Good catch. I added those as well.

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.

2 participants