Skip to content

Commit 50ebdfb

Browse files
committed
invoice: allow creation of giant invoices.
lightning/bolts#877 talks about removing this restriction (only Electrum actually enforced it on receive), so start by allowing creation of giant invoices, though we mark them as requiring mpp. Changelog-Changed: JSON-RPC: `invoice` now allows creation of giant invoices (>= 2^32 msat) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 1643a61 commit 50ebdfb

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

lightningd/invoice.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,19 @@ invoice_complete(struct invoice_info *info,
834834
info->label->s);
835835
}
836836

837+
/* If this requires a giant HTLC, most implementations cannot
838+
* send that much; will need to split. */
839+
/* BOLT #2:
840+
* ### Adding an HTLC: `update_add_htlc`
841+
*...
842+
* - for channels with `chain_hash` identifying the Bitcoin blockchain:
843+
* - MUST set the four most significant bytes of `amount_msat` to 0.
844+
*/
845+
if (info->b11->msat
846+
&& amount_msat_greater(*info->b11->msat, chainparams->max_payment)) {
847+
warning_mpp = true;
848+
}
849+
837850
/* Get details */
838851
details = wallet_invoice_details(info, wallet, invoice);
839852

@@ -1135,14 +1148,6 @@ static struct command_result *json_invoice(struct command *cmd,
11351148
strlen(desc_val));
11361149
}
11371150

1138-
if (msatoshi_val
1139-
&& amount_msat_greater(*msatoshi_val, chainparams->max_payment)) {
1140-
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1141-
"msatoshi cannot exceed %s",
1142-
type_to_string(tmpctx, struct amount_msat,
1143-
&chainparams->max_payment));
1144-
}
1145-
11461151
if (fallbacks) {
11471152
size_t i;
11481153
const jsmntok_t *t;

tests/test_invoices.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def test_invoice(node_factory, chainparams):
5454
assert 'routes' not in b11
5555
assert 'warning_capacity' in inv
5656

57-
# Make sure no wumbo invoices
58-
with pytest.raises(RpcError, match=r'msatoshi cannot exceed 4294967295msat'):
59-
l2.rpc.invoice(4294967295 + 1, 'inv3', '?')
57+
# Make sure wumbo invoices warn about mpp being needed.
58+
inv = l2.rpc.invoice(4294967295 + 1, 'inv4', '?')
59+
assert 'warning_mpp' in inv
6060
l2.rpc.invoice(4294967295, 'inv3', '?')
6161

6262
# Test cltv option.

0 commit comments

Comments
 (0)