From ea04898994e5dc2cea02db1932393887debabe39 Mon Sep 17 00:00:00 2001 From: Peter Neuroth Date: Wed, 2 Sep 2026 16:28:48 +0200 Subject: [PATCH 1/2] doc: fix wording of the min-emergency-msat error description The three schemas which documented error 313 all read "The `min-emergency-msat` reserve not be preserved", which is missing a verb. Changelog-None --- contrib/msggen/msggen/schema.json | 6 +++--- doc/schemas/fundchannel.json | 2 +- doc/schemas/multifundchannel.json | 2 +- doc/schemas/withdraw.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/msggen/msggen/schema.json b/contrib/msggen/msggen/schema.json index 32111a6396c7..22d6b3c7e03b 100644 --- a/contrib/msggen/msggen/schema.json +++ b/contrib/msggen/msggen/schema.json @@ -15008,7 +15008,7 @@ "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", "- 302: The output amount is too small, and would be considered dust.", "- 303: Broadcasting of the funding transaction failed, the internal call to bitcoin-cli returned with an error.", - "- 313: The `min-emergency-msat` reserve not be preserved (and we have or are opening anchor channels).", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have or are opening anchor channels).", "", "Failure may also occur if **lightningd** and the peer cannot agree on channel parameters (funding limits, channel reserves, fees, etc.)." ], @@ -30692,7 +30692,7 @@ "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", "- 302: The output amount is too small, and would be considered dust.", "- 303: Broadcasting of the funding transaction failed, the internal call to bitcoin-cli returned with an error.", - "- 313: The `min-emergency-msat` reserve not be preserved (and we have or are opening anchor channels).", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have or are opening anchor channels).", "", "Failure may also occur if **lightningd** and the peer cannot agree on channel parameters (funding limits, channel reserves, fees, etc.). See lightning-fundchannel_start(7) and lightning-fundchannel_complete(7).", "", @@ -40958,7 +40958,7 @@ "- -1: Catchall nonspecific error.", "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", "- 302: The dust limit is not met.", - "- 313: The `min-emergency-msat` reserve not be preserved (and we have anchor channels)." + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have anchor channels)." ], "author": [ "Felix [fixone@gmail.com](mailto:fixone@gmail.com) is mainly responsible." diff --git a/doc/schemas/fundchannel.json b/doc/schemas/fundchannel.json index 0aaa6c5f6d95..6f7cfacf77f9 100644 --- a/doc/schemas/fundchannel.json +++ b/doc/schemas/fundchannel.json @@ -223,7 +223,7 @@ "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", "- 302: The output amount is too small, and would be considered dust.", "- 303: Broadcasting of the funding transaction failed, the internal call to bitcoin-cli returned with an error.", - "- 313: The `min-emergency-msat` reserve not be preserved (and we have or are opening anchor channels).", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have or are opening anchor channels).", "", "Failure may also occur if **lightningd** and the peer cannot agree on channel parameters (funding limits, channel reserves, fees, etc.)." ], diff --git a/doc/schemas/multifundchannel.json b/doc/schemas/multifundchannel.json index 415b89d30aa5..8307b259844d 100644 --- a/doc/schemas/multifundchannel.json +++ b/doc/schemas/multifundchannel.json @@ -313,7 +313,7 @@ "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", "- 302: The output amount is too small, and would be considered dust.", "- 303: Broadcasting of the funding transaction failed, the internal call to bitcoin-cli returned with an error.", - "- 313: The `min-emergency-msat` reserve not be preserved (and we have or are opening anchor channels).", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have or are opening anchor channels).", "", "Failure may also occur if **lightningd** and the peer cannot agree on channel parameters (funding limits, channel reserves, fees, etc.). See lightning-fundchannel_start(7) and lightning-fundchannel_complete(7).", "", diff --git a/doc/schemas/withdraw.json b/doc/schemas/withdraw.json index 2e0290df4b4a..84e0fcfe2212 100644 --- a/doc/schemas/withdraw.json +++ b/doc/schemas/withdraw.json @@ -84,7 +84,7 @@ "- -1: Catchall nonspecific error.", "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", "- 302: The dust limit is not met.", - "- 313: The `min-emergency-msat` reserve not be preserved (and we have anchor channels)." + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have anchor channels)." ], "author": [ "Felix [fixone@gmail.com](mailto:fixone@gmail.com) is mainly responsible." From 6f422336c11ed751ebdc927baa1015940464b9b1 Mon Sep 17 00:00:00 2001 From: Peter Neuroth Date: Wed, 2 Sep 2026 16:28:57 +0200 Subject: [PATCH 2/2] doc: document error 313 on every command which can return it 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 --- contrib/msggen/msggen/schema.json | 19 +++++++++++++++---- doc/schemas/fundpsbt.json | 3 ++- doc/schemas/multiwithdraw.json | 3 ++- doc/schemas/txprepare.json | 3 ++- doc/schemas/upgradewallet.json | 7 +++++++ doc/schemas/utxopsbt.json | 3 ++- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/contrib/msggen/msggen/schema.json b/contrib/msggen/msggen/schema.json index 22d6b3c7e03b..e631dd9bb572 100644 --- a/contrib/msggen/msggen/schema.json +++ b/contrib/msggen/msggen/schema.json @@ -16087,7 +16087,8 @@ "", "- -32602: If the given parameters are wrong.", "- -1: Catchall nonspecific error.", - "- 301: Insufficient UTXOs to meet *satoshi* value." + "- 301: Insufficient UTXOs to meet *satoshi* value.", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have or are opening anchor channels)." ], "author": [ "Rusty Russell [rusty@rustcorp.com.au](mailto:rusty@rustcorp.com.au) is mainly responsible." @@ -30937,7 +30938,8 @@ "", "- -1: Catchall nonspecific error.", "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", - "- 302: The dust limit is not met." + "- 302: The dust limit is not met.", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have anchor channels)." ], "author": [ "ZmnSCPxj [ZmnSCPxj@protonmail.com](mailto:ZmnSCPxj@protonmail.com) is mainly responsible." @@ -38460,7 +38462,8 @@ "", "- -1: Catchall nonspecific error.", "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", - "- 302: The dust limit is not met." + "- 302: The dust limit is not met.", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have anchor channels)." ], "author": [ "Rusty Russell [rusty@rustcorp.com.au](mailto:rusty@rustcorp.com.au) is mainly responsible." @@ -38832,6 +38835,13 @@ } } }, + "errors": [ + "On failure, an error is reported and no transaction is created.", + "", + "- -1: Catchall nonspecific error.", + "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have anchor channels)." + ], "usage": [ "The caller is trying to buy a liquidity ad but the command keeps failing. They have funds in their wallet, but they're all P2SH-wrapped outputs.", "", @@ -39067,7 +39077,8 @@ "", "- -32602: If the given parameters are wrong.", "- -1: Catchall nonspecific error.", - "- 301: Insufficient UTXOs to meet *satoshi* value." + "- 301: Insufficient UTXOs to meet *satoshi* value.", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have or are opening anchor channels)." ], "author": [ "Rusty Russell [rusty@rustcorp.com.au](mailto:rusty@rustcorp.com.au) is mainly responsible." diff --git a/doc/schemas/fundpsbt.json b/doc/schemas/fundpsbt.json index 68354ef79c1a..4dc53b1f1960 100644 --- a/doc/schemas/fundpsbt.json +++ b/doc/schemas/fundpsbt.json @@ -194,7 +194,8 @@ "", "- -32602: If the given parameters are wrong.", "- -1: Catchall nonspecific error.", - "- 301: Insufficient UTXOs to meet *satoshi* value." + "- 301: Insufficient UTXOs to meet *satoshi* value.", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have or are opening anchor channels)." ], "author": [ "Rusty Russell [rusty@rustcorp.com.au](mailto:rusty@rustcorp.com.au) is mainly responsible." diff --git a/doc/schemas/multiwithdraw.json b/doc/schemas/multiwithdraw.json index f2884beea852..e7185a7e7da4 100644 --- a/doc/schemas/multiwithdraw.json +++ b/doc/schemas/multiwithdraw.json @@ -72,7 +72,8 @@ "", "- -1: Catchall nonspecific error.", "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", - "- 302: The dust limit is not met." + "- 302: The dust limit is not met.", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have anchor channels)." ], "author": [ "ZmnSCPxj [ZmnSCPxj@protonmail.com](mailto:ZmnSCPxj@protonmail.com) is mainly responsible." diff --git a/doc/schemas/txprepare.json b/doc/schemas/txprepare.json index bca25b089d57..ef7f162ae7c7 100644 --- a/doc/schemas/txprepare.json +++ b/doc/schemas/txprepare.json @@ -81,7 +81,8 @@ "", "- -1: Catchall nonspecific error.", "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", - "- 302: The dust limit is not met." + "- 302: The dust limit is not met.", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have anchor channels)." ], "author": [ "Rusty Russell [rusty@rustcorp.com.au](mailto:rusty@rustcorp.com.au) is mainly responsible." diff --git a/doc/schemas/upgradewallet.json b/doc/schemas/upgradewallet.json index 02e1ba6602cd..98fbcf44edb2 100644 --- a/doc/schemas/upgradewallet.json +++ b/doc/schemas/upgradewallet.json @@ -63,6 +63,13 @@ } } }, + "errors": [ + "On failure, an error is reported and no transaction is created.", + "", + "- -1: Catchall nonspecific error.", + "- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have anchor channels)." + ], "usage": [ "The caller is trying to buy a liquidity ad but the command keeps failing. They have funds in their wallet, but they're all P2SH-wrapped outputs.", "", diff --git a/doc/schemas/utxopsbt.json b/doc/schemas/utxopsbt.json index c27458b1e558..31d052f43691 100644 --- a/doc/schemas/utxopsbt.json +++ b/doc/schemas/utxopsbt.json @@ -191,7 +191,8 @@ "", "- -32602: If the given parameters are wrong.", "- -1: Catchall nonspecific error.", - "- 301: Insufficient UTXOs to meet *satoshi* value." + "- 301: Insufficient UTXOs to meet *satoshi* value.", + "- 313: The `min-emergency-msat` reserve could not be preserved (and we have or are opening anchor channels)." ], "author": [ "Rusty Russell [rusty@rustcorp.com.au](mailto:rusty@rustcorp.com.au) is mainly responsible."