mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
invoice: allow creation of giant invoices.
https://github.com/lightningnetwork/lightning-rfc/pull/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>
This commit is contained in:
@@ -834,6 +834,19 @@ invoice_complete(struct invoice_info *info,
|
|||||||
info->label->s);
|
info->label->s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If this requires a giant HTLC, most implementations cannot
|
||||||
|
* send that much; will need to split. */
|
||||||
|
/* BOLT #2:
|
||||||
|
* ### Adding an HTLC: `update_add_htlc`
|
||||||
|
*...
|
||||||
|
* - for channels with `chain_hash` identifying the Bitcoin blockchain:
|
||||||
|
* - MUST set the four most significant bytes of `amount_msat` to 0.
|
||||||
|
*/
|
||||||
|
if (info->b11->msat
|
||||||
|
&& amount_msat_greater(*info->b11->msat, chainparams->max_payment)) {
|
||||||
|
warning_mpp = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get details */
|
/* Get details */
|
||||||
details = wallet_invoice_details(info, wallet, invoice);
|
details = wallet_invoice_details(info, wallet, invoice);
|
||||||
|
|
||||||
@@ -1135,14 +1148,6 @@ static struct command_result *json_invoice(struct command *cmd,
|
|||||||
strlen(desc_val));
|
strlen(desc_val));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msatoshi_val
|
|
||||||
&& amount_msat_greater(*msatoshi_val, chainparams->max_payment)) {
|
|
||||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
|
||||||
"msatoshi cannot exceed %s",
|
|
||||||
type_to_string(tmpctx, struct amount_msat,
|
|
||||||
&chainparams->max_payment));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fallbacks) {
|
if (fallbacks) {
|
||||||
size_t i;
|
size_t i;
|
||||||
const jsmntok_t *t;
|
const jsmntok_t *t;
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ def test_invoice(node_factory, chainparams):
|
|||||||
assert 'routes' not in b11
|
assert 'routes' not in b11
|
||||||
assert 'warning_capacity' in inv
|
assert 'warning_capacity' in inv
|
||||||
|
|
||||||
# Make sure no wumbo invoices
|
# Make sure wumbo invoices warn about mpp being needed.
|
||||||
with pytest.raises(RpcError, match=r'msatoshi cannot exceed 4294967295msat'):
|
inv = l2.rpc.invoice(4294967295 + 1, 'inv4', '?')
|
||||||
l2.rpc.invoice(4294967295 + 1, 'inv3', '?')
|
assert 'warning_mpp' in inv
|
||||||
l2.rpc.invoice(4294967295, 'inv3', '?')
|
l2.rpc.invoice(4294967295, 'inv3', '?')
|
||||||
|
|
||||||
# Test cltv option.
|
# Test cltv option.
|
||||||
|
|||||||
Reference in New Issue
Block a user