From e568d698670d9d73c74b895859e6dc7bf585eabb Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Mon, 25 Nov 2024 21:39:34 -0800 Subject: [PATCH] doc: Lock askrene example values --- contrib/msggen/msggen/schema.json | 448 ++++++++++++++++++ doc/schemas/lightning-askrene-age.json | 16 + .../lightning-askrene-bias-channel.json | 44 ++ .../lightning-askrene-create-channel.json | 16 + .../lightning-askrene-create-layer.json | 24 + .../lightning-askrene-disable-node.json | 13 + .../lightning-askrene-inform-channel.json | 24 + doc/schemas/lightning-askrene-listlayers.json | 113 +++++ .../lightning-askrene-listreservations.json | 37 ++ .../lightning-askrene-remove-layer.json | 12 + doc/schemas/lightning-askrene-reserve.json | 40 ++ doc/schemas/lightning-askrene-unreserve.json | 40 ++ .../lightning-askrene-update-channel.json | 29 ++ doc/schemas/lightning-getroutes.json | 40 ++ tests/autogenerate-rpc-examples.py | 51 +- 15 files changed, 946 insertions(+), 1 deletion(-) diff --git a/contrib/msggen/msggen/schema.json b/contrib/msggen/msggen/schema.json index ebbcbc867..46656268a 100644 --- a/contrib/msggen/msggen/schema.json +++ b/contrib/msggen/msggen/schema.json @@ -256,6 +256,22 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-age#1", + "method": "askrene-age", + "params": { + "layer": "test_layers", + "cutoff": 1738000000 + } + }, + "response": { + "layer": "test_layers", + "num_removed": 1 + } + } ] }, "lightning-askrene-bias-channel.json": { @@ -359,6 +375,50 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-bias-channel#1", + "method": "askrene-bias-channel", + "params": { + "layer": "test_layers", + "short_channel_id_dir": "109x1x1/1", + "bias": 1 + } + }, + "response": { + "biases": [ + { + "layer": "test_layers", + "short_channel_id_dir": "109x1x1/1", + "bias": 1 + } + ] + } + }, + { + "request": { + "id": "example:askrene-bias-channel#2", + "method": "askrene-bias-channel", + "params": [ + "test_layers", + "109x1x1/1", + -5, + "bigger bias" + ] + }, + "response": { + "biases": [ + { + "layer": "test_layers", + "short_channel_id_dir": "109x1x1/1", + "description": "bigger bias", + "bias": -5 + } + ] + } + } ] }, "lightning-askrene-create-channel.json": { @@ -431,6 +491,22 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-create-channel#1", + "method": "askrene-create-channel", + "params": { + "layer": "test_layers", + "source": "nodeid030303030303030303030303030303030303030303030303030303030303", + "destination": "nodeid010101010101010101010101010101010101010101010101010101010101", + "short_channel_id": "0x0x1", + "capacity_msat": "1000000sat" + } + }, + "response": {} + } ] }, "lightning-askrene-create-layer.json": { @@ -680,6 +756,30 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-create-layer#1", + "method": "askrene-create-layer", + "params": { + "layer": "test_layers" + } + }, + "response": { + "layers": [ + { + "layer": "test_layers", + "persistent": false, + "disabled_nodes": [], + "created_channels": [], + "channel_updates": [], + "constraints": [], + "biases": [] + } + ] + } + } ] }, "lightning-askrene-disable-node.json": { @@ -729,6 +829,19 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-disable-node#1", + "method": "askrene-disable-node", + "params": { + "layer": "test_layers", + "node": "nodeid010101010101010101010101010101010101010101010101010101010101" + } + }, + "response": {} + } ] }, "lightning-askrene-inform-channel.json": { @@ -844,6 +957,30 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-inform-channel#1", + "method": "askrene-inform-channel", + "params": { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/1", + "amount_msat": 100000, + "inform": "unconstrained" + } + }, + "response": { + "constraints": [ + { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ] + } + } ] }, "lightning-askrene-listlayers.json": { @@ -1095,6 +1232,119 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-listlayers#1", + "method": "askrene-listlayers", + "params": [ + "test_layers" + ] + }, + "response": { + "layers": [ + { + "layer": "test_layers", + "persistent": false, + "disabled_nodes": [ + "nodeid010101010101010101010101010101010101010101010101010101010101" + ], + "created_channels": [ + { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "short_channel_id": "0x0x1", + "capacity_msat": 1000000000 + } + ], + "channel_updates": [ + { + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + ], + "constraints": [ + { + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ], + "biases": [ + { + "short_channel_id_dir": "109x1x1/1", + "description": "bigger bias", + "bias": -5 + } + ] + } + ] + } + }, + { + "request": { + "id": "example:askrene-listlayers#2", + "method": "askrene-listlayers", + "params": {} + }, + "response": { + "layers": [ + { + "layer": "test_layers", + "persistent": false, + "disabled_nodes": [ + "nodeid010101010101010101010101010101010101010101010101010101010101" + ], + "created_channels": [ + { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "short_channel_id": "0x0x1", + "capacity_msat": 1000000000 + } + ], + "channel_updates": [ + { + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + ], + "constraints": [ + { + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ], + "biases": [ + { + "short_channel_id_dir": "109x1x1/1", + "description": "bigger bias", + "bias": -5 + } + ] + }, + { + "layer": "xpay", + "persistent": true, + "disabled_nodes": [], + "created_channels": [], + "channel_updates": [], + "constraints": [], + "biases": [] + } + ] + } + } ] }, "lightning-askrene-listreservations.json": { @@ -1167,6 +1417,43 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-listreservations#1", + "method": "askrene-listreservations", + "params": {} + }, + "response": { + "reservations": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#62/cln:askrene-reserve#122\"" + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#62/cln:askrene-reserve#122\"" + }, + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#66/cln:askrene-reserve#126\"" + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#66/cln:askrene-reserve#126\"" + } + ] + } + } ] }, "lightning-askrene-remove-layer.json": { @@ -1206,6 +1493,18 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-remove-layer#1", + "method": "askrene-remove-layer", + "params": { + "layer": "test_layers" + } + }, + "response": {} + } ] }, "lightning-askrene-reserve.json": { @@ -1267,6 +1566,46 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-reserve#1", + "method": "askrene-reserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001 + } + ] + } + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-reserve#2", + "method": "askrene-reserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000 + } + ] + } + }, + "response": {} + } ] }, "lightning-askrene-unreserve.json": { @@ -1328,6 +1667,46 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-unreserve#1", + "method": "askrene-unreserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001 + } + ] + } + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-unreserve#2", + "method": "askrene-unreserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000 + } + ] + } + }, + "response": {} + } ] }, "lightning-askrene-update-channel.json": { @@ -1410,6 +1789,35 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-update-channel#1", + "method": "askrene-update-channel", + "params": [ + "test_layers", + "0x0x1/0" + ] + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-update-channel#2", + "method": "askrene-update-channel", + "params": { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + }, + "response": {} + } ] }, "lightning-autoclean-once.json": { @@ -15549,6 +15957,46 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:getroutes#1", + "method": "getroutes", + "params": { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "amount_msat": 1250000, + "layers": [], + "maxfee_msat": 125000, + "final_cltv": 0 + } + }, + "response": { + "probability_ppm": 997501, + "routes": [ + { + "probability_ppm": 997501, + "amount_msat": 1250000, + "final_cltv": 0, + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "next_node_id": "nodeid020202020202020202020202020202020202020202020202020202020202", + "amount_msat": 1250026, + "delay": 12 + }, + { + "short_channel_id_dir": "123x1x1/0", + "next_node_id": "nodeid030303030303030303030303030303030303030303030303030303030303", + "amount_msat": 1250013, + "delay": 6 + } + ] + } + ] + } + } ] }, "lightning-help.json": { diff --git a/doc/schemas/lightning-askrene-age.json b/doc/schemas/lightning-askrene-age.json index dec6074d8..a274673c4 100644 --- a/doc/schemas/lightning-askrene-age.json +++ b/doc/schemas/lightning-askrene-age.json @@ -59,5 +59,21 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-age#1", + "method": "askrene-age", + "params": { + "layer": "test_layers", + "cutoff": 1738000000 + } + }, + "response": { + "layer": "test_layers", + "num_removed": 1 + } + } ] } diff --git a/doc/schemas/lightning-askrene-bias-channel.json b/doc/schemas/lightning-askrene-bias-channel.json index 448251bc3..2389d026c 100644 --- a/doc/schemas/lightning-askrene-bias-channel.json +++ b/doc/schemas/lightning-askrene-bias-channel.json @@ -99,5 +99,49 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-bias-channel#1", + "method": "askrene-bias-channel", + "params": { + "layer": "test_layers", + "short_channel_id_dir": "109x1x1/1", + "bias": 1 + } + }, + "response": { + "biases": [ + { + "layer": "test_layers", + "short_channel_id_dir": "109x1x1/1", + "bias": 1 + } + ] + } + }, + { + "request": { + "id": "example:askrene-bias-channel#2", + "method": "askrene-bias-channel", + "params": [ + "test_layers", + "109x1x1/1", + -5, + "bigger bias" + ] + }, + "response": { + "biases": [ + { + "layer": "test_layers", + "short_channel_id_dir": "109x1x1/1", + "description": "bigger bias", + "bias": -5 + } + ] + } + } ] } diff --git a/doc/schemas/lightning-askrene-create-channel.json b/doc/schemas/lightning-askrene-create-channel.json index 7843b197d..deb137636 100644 --- a/doc/schemas/lightning-askrene-create-channel.json +++ b/doc/schemas/lightning-askrene-create-channel.json @@ -68,5 +68,21 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-create-channel#1", + "method": "askrene-create-channel", + "params": { + "layer": "test_layers", + "source": "nodeid030303030303030303030303030303030303030303030303030303030303", + "destination": "nodeid010101010101010101010101010101010101010101010101010101010101", + "short_channel_id": "0x0x1", + "capacity_msat": "1000000sat" + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-askrene-create-layer.json b/doc/schemas/lightning-askrene-create-layer.json index ec1099887..d0b650d5f 100644 --- a/doc/schemas/lightning-askrene-create-layer.json +++ b/doc/schemas/lightning-askrene-create-layer.json @@ -245,5 +245,29 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-create-layer#1", + "method": "askrene-create-layer", + "params": { + "layer": "test_layers" + } + }, + "response": { + "layers": [ + { + "layer": "test_layers", + "persistent": false, + "disabled_nodes": [], + "created_channels": [], + "channel_updates": [], + "constraints": [], + "biases": [] + } + ] + } + } ] } diff --git a/doc/schemas/lightning-askrene-disable-node.json b/doc/schemas/lightning-askrene-disable-node.json index 479109ea9..2dc13f06a 100644 --- a/doc/schemas/lightning-askrene-disable-node.json +++ b/doc/schemas/lightning-askrene-disable-node.json @@ -45,5 +45,18 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-disable-node#1", + "method": "askrene-disable-node", + "params": { + "layer": "test_layers", + "node": "nodeid010101010101010101010101010101010101010101010101010101010101" + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-askrene-inform-channel.json b/doc/schemas/lightning-askrene-inform-channel.json index 6ebc0122f..41ac17a07 100644 --- a/doc/schemas/lightning-askrene-inform-channel.json +++ b/doc/schemas/lightning-askrene-inform-channel.json @@ -111,5 +111,29 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-inform-channel#1", + "method": "askrene-inform-channel", + "params": { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/1", + "amount_msat": 100000, + "inform": "unconstrained" + } + }, + "response": { + "constraints": [ + { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ] + } + } ] } diff --git a/doc/schemas/lightning-askrene-listlayers.json b/doc/schemas/lightning-askrene-listlayers.json index 4bc796e3e..98d3ee39b 100644 --- a/doc/schemas/lightning-askrene-listlayers.json +++ b/doc/schemas/lightning-askrene-listlayers.json @@ -247,5 +247,118 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-listlayers#1", + "method": "askrene-listlayers", + "params": [ + "test_layers" + ] + }, + "response": { + "layers": [ + { + "layer": "test_layers", + "persistent": false, + "disabled_nodes": [ + "nodeid010101010101010101010101010101010101010101010101010101010101" + ], + "created_channels": [ + { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "short_channel_id": "0x0x1", + "capacity_msat": 1000000000 + } + ], + "channel_updates": [ + { + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + ], + "constraints": [ + { + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ], + "biases": [ + { + "short_channel_id_dir": "109x1x1/1", + "description": "bigger bias", + "bias": -5 + } + ] + } + ] + } + }, + { + "request": { + "id": "example:askrene-listlayers#2", + "method": "askrene-listlayers", + "params": {} + }, + "response": { + "layers": [ + { + "layer": "test_layers", + "persistent": false, + "disabled_nodes": [ + "nodeid010101010101010101010101010101010101010101010101010101010101" + ], + "created_channels": [ + { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "short_channel_id": "0x0x1", + "capacity_msat": 1000000000 + } + ], + "channel_updates": [ + { + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + ], + "constraints": [ + { + "short_channel_id_dir": "0x0x1/1", + "timestamp": 1738000000, + "minimum_msat": 100000 + } + ], + "biases": [ + { + "short_channel_id_dir": "109x1x1/1", + "description": "bigger bias", + "bias": -5 + } + ] + }, + { + "layer": "xpay", + "persistent": true, + "disabled_nodes": [], + "created_channels": [], + "channel_updates": [], + "constraints": [], + "biases": [] + } + ] + } + } ] } diff --git a/doc/schemas/lightning-askrene-listreservations.json b/doc/schemas/lightning-askrene-listreservations.json index 38153aece..f72a1ee8e 100644 --- a/doc/schemas/lightning-askrene-listreservations.json +++ b/doc/schemas/lightning-askrene-listreservations.json @@ -68,5 +68,42 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-listreservations#1", + "method": "askrene-listreservations", + "params": {} + }, + "response": { + "reservations": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#62/cln:askrene-reserve#122\"" + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#62/cln:askrene-reserve#122\"" + }, + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#66/cln:askrene-reserve#126\"" + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000, + "age_in_seconds": 2, + "command_id": "\"-c:askrene-reserve#66/cln:askrene-reserve#126\"" + } + ] + } + } ] } diff --git a/doc/schemas/lightning-askrene-remove-layer.json b/doc/schemas/lightning-askrene-remove-layer.json index 6f6a02225..aa7ae1f73 100644 --- a/doc/schemas/lightning-askrene-remove-layer.json +++ b/doc/schemas/lightning-askrene-remove-layer.json @@ -35,5 +35,17 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-remove-layer#1", + "method": "askrene-remove-layer", + "params": { + "layer": "test_layers" + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-askrene-reserve.json b/doc/schemas/lightning-askrene-reserve.json index 92c9cbf02..f73e41867 100644 --- a/doc/schemas/lightning-askrene-reserve.json +++ b/doc/schemas/lightning-askrene-reserve.json @@ -57,5 +57,45 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-reserve#1", + "method": "askrene-reserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001 + } + ] + } + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-reserve#2", + "method": "askrene-reserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000 + } + ] + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-askrene-unreserve.json b/doc/schemas/lightning-askrene-unreserve.json index c99495376..982db753f 100644 --- a/doc/schemas/lightning-askrene-unreserve.json +++ b/doc/schemas/lightning-askrene-unreserve.json @@ -57,5 +57,45 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-unreserve#1", + "method": "askrene-unreserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250001 + } + ] + } + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-unreserve#2", + "method": "askrene-unreserve", + "params": { + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "amount_msat": 1250000000000 + }, + { + "short_channel_id_dir": "123x1x1/0", + "amount_msat": 1250000000000 + } + ] + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-askrene-update-channel.json b/doc/schemas/lightning-askrene-update-channel.json index 8088d59db..edc05bccb 100644 --- a/doc/schemas/lightning-askrene-update-channel.json +++ b/doc/schemas/lightning-askrene-update-channel.json @@ -78,5 +78,34 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:askrene-update-channel#1", + "method": "askrene-update-channel", + "params": [ + "test_layers", + "0x0x1/0" + ] + }, + "response": {} + }, + { + "request": { + "id": "example:askrene-update-channel#2", + "method": "askrene-update-channel", + "params": { + "layer": "test_layers", + "short_channel_id_dir": "0x0x1/0", + "htlc_minimum_msat": 100, + "htlc_maximum_msat": 900000000, + "fee_base_msat": 1, + "fee_proportional_millionths": 2, + "cltv_expiry_delta": 18 + } + }, + "response": {} + } ] } diff --git a/doc/schemas/lightning-getroutes.json b/doc/schemas/lightning-getroutes.json index 8911b3e4a..be0b85b01 100644 --- a/doc/schemas/lightning-getroutes.json +++ b/doc/schemas/lightning-getroutes.json @@ -172,5 +172,45 @@ ], "resources": [ "Main web site: " + ], + "examples": [ + { + "request": { + "id": "example:getroutes#1", + "method": "getroutes", + "params": { + "source": "nodeid010101010101010101010101010101010101010101010101010101010101", + "destination": "nodeid030303030303030303030303030303030303030303030303030303030303", + "amount_msat": 1250000, + "layers": [], + "maxfee_msat": 125000, + "final_cltv": 0 + } + }, + "response": { + "probability_ppm": 997501, + "routes": [ + { + "probability_ppm": 997501, + "amount_msat": 1250000, + "final_cltv": 0, + "path": [ + { + "short_channel_id_dir": "109x1x1/1", + "next_node_id": "nodeid020202020202020202020202020202020202020202020202020202020202", + "amount_msat": 1250026, + "delay": 12 + }, + { + "short_channel_id_dir": "123x1x1/0", + "next_node_id": "nodeid030303030303030303030303030303030303030303030303030303030303", + "amount_msat": 1250013, + "delay": 6 + } + ] + } + ] + } + } ] } diff --git a/tests/autogenerate-rpc-examples.py b/tests/autogenerate-rpc-examples.py index 17b8c618f..314402e3f 100644 --- a/tests/autogenerate-rpc-examples.py +++ b/tests/autogenerate-rpc-examples.py @@ -29,7 +29,7 @@ ALL_RPC_EXAMPLES = {} EXAMPLES_JSON = {} LOG_FILE = './tests/autogenerate-examples-status.log' TEMP_EXAMPLES_FILE = './tests/autogenerate-examples.json' -IGNORE_RPCS_LIST = ['dev-splice', 'reckless', 'sql-template', 'askrene-listreservations', 'askrene-remove-layer', 'askrene-create-channel', 'askrene-create-layer', 'askrene-bias-channel', 'askrene-reserve', 'askrene-listlayers', 'askrene-age', 'askrene-inform-channel', 'askrene-update-channel', 'getroutes', 'askrene-disable-node', 'askrene-unreserve'] +IGNORE_RPCS_LIST = ['dev-splice', 'reckless', 'sql-template'] # Constants for replacing values in examples NEW_VALUES_LIST = { @@ -1024,6 +1024,54 @@ def generate_offers_renepay_examples(l1, l2, inv_l21, inv_l34): raise +def generate_askrene_examples(l1, l2, l3, c12, c23_2): + """Generates askrene related examples""" + try: + logger.info('Askrene Start...') + + def direction(src, dst): + if src < dst: + return 0 + return 1 + + direction12 = direction(l1.info['id'], l2.info['id']) + direction23 = direction(l2.info['id'], l3.info['id']) + scid12dir = f'{c12}/{direction12}' + scid23dir = f'{c23_2}/{direction23}' + update_example(node=l2, method='askrene-create-layer', params={'layer': 'test_layers'}) + update_example(node=l2, method='askrene-disable-node', params={'layer': 'test_layers', 'node': l1.info['id']}) + update_example(node=l2, method='askrene-update-channel', params=['test_layers', '0x0x1/0']) + update_example(node=l2, method='askrene-create-channel', params={'layer': 'test_layers', 'source': l3.info['id'], 'destination': l1.info['id'], 'short_channel_id': '0x0x1', 'capacity_msat': '1000000sat'}) + update_example(node=l2, method='askrene-update-channel', params={'layer': 'test_layers', 'short_channel_id_dir': '0x0x1/0', 'htlc_minimum_msat': 100, 'htlc_maximum_msat': 900000000, 'fee_base_msat': 1, 'fee_proportional_millionths': 2, 'cltv_expiry_delta': 18}) + askrene_inform_channel_res1 = update_example(node=l2, method='askrene-inform-channel', params={'layer': 'test_layers', 'short_channel_id_dir': '0x0x1/1', 'amount_msat': 100000, 'inform': 'unconstrained'}) + update_example(node=l2, method='askrene-bias-channel', params={'layer': 'test_layers', 'short_channel_id_dir': scid12dir, 'bias': 1}) + update_example(node=l2, method='askrene-bias-channel', params=['test_layers', scid12dir, -5, 'bigger bias']) + askrene_listlayers_res1 = update_example(node=l2, method='askrene-listlayers', params=['test_layers']) + update_example(node=l2, method='askrene-listlayers', params={}) + ts1 = only_one(only_one(askrene_listlayers_res1['layers'])['constraints'])['timestamp'] + update_example(node=l2, method='askrene-age', params={'layer': 'test_layers', 'cutoff': ts1 + 1}) + update_example(node=l2, method='askrene-remove-layer', params={'layer': 'test_layers'}) + update_example(node=l1, method='getroutes', params={'source': l1.info['id'], 'destination': l3.info['id'], 'amount_msat': 1250000, 'layers': [], 'maxfee_msat': 125000, 'final_cltv': 0}) + update_example(node=l1, method='askrene-reserve', params={'path': [{'short_channel_id_dir': scid12dir, 'amount_msat': 1250_000}, {'short_channel_id_dir': scid23dir, 'amount_msat': 1250_001}]}) + update_example(node=l1, method='askrene-reserve', params={'path': [{'short_channel_id_dir': scid12dir, 'amount_msat': 1250_000_000_000}, {'short_channel_id_dir': scid23dir, 'amount_msat': 1250_000_000_000}]}) + time.sleep(2) + askrene_listreservations_res1 = l1.rpc.askrene_listreservations() + askrene_listreservations_res1 = update_list_responses(askrene_listreservations_res1, list_key='reservations', slice_upto=5, update_func=lambda x, i: REPLACE_RESPONSE_VALUES.extend([{'data_keys': ['command_id'], 'original_value': x['command_id'], 'new_value': f'\"-c:askrene-reserve#6{(i + 1) * 2}/cln:askrene-reserve#12{(i + 1) * 2}\"'}]), sort=True, sort_key='amount_msat') + update_example(node=l1, method='askrene-listreservations', params={}, response=askrene_listreservations_res1) + update_example(node=l1, method='askrene-unreserve', params={'path': [{'short_channel_id_dir': scid12dir, 'amount_msat': 1250_000}, {'short_channel_id_dir': scid23dir, 'amount_msat': 1250_001}]}) + update_example(node=l1, method='askrene-unreserve', params={'path': [{'short_channel_id_dir': scid12dir, 'amount_msat': 1250_000_000_000}, {'short_channel_id_dir': scid23dir, 'amount_msat': 1250_000_000_000}]}) + REPLACE_RESPONSE_VALUES.extend([ + {'data_keys': ['any', 'short_channel_id_dir'], 'original_value': scid12dir, 'new_value': f"{NEW_VALUES_LIST['c12']}/{direction12}"}, + {'data_keys': ['short_channel_id_dir'], 'original_value': scid23dir, 'new_value': f"{NEW_VALUES_LIST['c23_2']}/{direction23}"}, + {'data_keys': ['cutoff'], 'original_value': ts1 + 1, 'new_value': NEW_VALUES_LIST['time_at_800']}, + {'data_keys': ['timestamp'], 'original_value': askrene_inform_channel_res1['constraints'][0]['timestamp'], 'new_value': NEW_VALUES_LIST['time_at_800']}, + ]) + logger.info('Askrene Done!') + except Exception as e: + logger.error(f'Error in generating askrene examples: {e}') + raise + + def generate_wait_examples(l1, l2, bitcoind, executor): """Generates wait examples""" try: @@ -2043,6 +2091,7 @@ def test_generate_examples(node_factory, bitcoind, executor): generate_datastore_examples(l2) generate_bookkeeper_examples(l2, l3, c23res2['channel_id']) offer_l23, inv_req_l1_l22 = generate_offers_renepay_examples(l1, l2, inv_l21, inv_l34) + generate_askrene_examples(l1, l2, l3, c12, c23_2) generate_wait_examples(l1, l2, bitcoind, executor) address_l22 = generate_utils_examples(l1, l2, l3, l4, l5, l6, c23_2, c34_2, inv_l11, inv_l22, rune_l21, bitcoind) generate_splice_examples(node_factory, bitcoind)