diff --git a/doc/lightning-fetchinvoice.7.md b/doc/lightning-fetchinvoice.7.md index 799bde5f6..a0d5235e9 100644 --- a/doc/lightning-fetchinvoice.7.md +++ b/doc/lightning-fetchinvoice.7.md @@ -56,7 +56,7 @@ On success, an object is returned, containing: - **description** (string, optional): a completely replaced *description* field - **vendor_removed** (string, optional): The *vendor* from the offer, which is missing in the invoice - **vendor** (string, optional): a completely replaced *vendor* field - - **msat** (msat, optional): the amount, if different from the offer amount multiplied by any *quantity* (or the offer had no amount, or was not in BTC). + - **amount_msat** (msat, optional): the amount, if different from the offer amount multiplied by any *quantity* (or the offer had no amount, or was not in BTC). - **next_period** (object, optional): Only for recurring invoices if the next period is under the *recurrence_limit*: - **counter** (u64): the index of the next period to fetchinvoice - **starttime** (u64): UNIX timestamp that the next period starts @@ -88,4 +88,4 @@ RESOURCES Main web site: -[comment]: # ( SHA256STAMP:e0033e40d86355e51abb48472f802a9a713ed5b2725828467515f9541207dac5) +[comment]: # ( SHA256STAMP:fa4e9733716ba263e8288613633ec7e0e466c13fc8067b11588bfd3c88901672) diff --git a/doc/schemas/fetchinvoice.schema.json b/doc/schemas/fetchinvoice.schema.json index 951dcd19d..8c6d23655 100644 --- a/doc/schemas/fetchinvoice.schema.json +++ b/doc/schemas/fetchinvoice.schema.json @@ -33,7 +33,7 @@ "type": "string", "description": "a completely replaced *vendor* field" }, - "msat": { + "amount_msat": { "type": "msat", "description": "the amount, if different from the offer amount multiplied by any *quantity* (or the offer had no amount, or was not in BTC)." } diff --git a/plugins/fetchinvoice.c b/plugins/fetchinvoice.c index cca83e0c2..088affb61 100644 --- a/plugins/fetchinvoice.c +++ b/plugins/fetchinvoice.c @@ -345,9 +345,13 @@ static struct command_result *handle_invreq_response(struct command *cmd, */ /* We always tell them this unless it's trivial to calc and * exactly as expected. */ - if (!expected_amount || *inv->amount != *expected_amount) - json_add_amount_msat_only(out, "msat", + if (!expected_amount || *inv->amount != *expected_amount) { + if (deprecated_apis) + json_add_amount_msat_only(out, "msat", + amount_msat(*inv->amount)); + json_add_amount_msat_only(out, "amount_msat", amount_msat(*inv->amount)); + } json_object_end(out); /* We tell them about next period at this point, if any. */ diff --git a/tests/test_pay.py b/tests/test_pay.py index 67704fe59..cb1e068b0 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -4708,7 +4708,7 @@ def test_fetchinvoice(node_factory, bitcoind): 'description': 'USD test'})['bolt12'] inv = l1.rpc.call('fetchinvoice', {'offer': offerusd}) - assert inv['changes']['msat'] == Millisatoshi(int(10.05 * 5000)) + assert inv['changes']['amount_msat'] == Millisatoshi(int(10.05 * 5000)) # If we remove plugin, it can no longer give us an invoice. l3.rpc.plugin_stop(plugin)