Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e78c102
Add json API for struct route_exclusion
Lagrang3 Sep 23, 2024
6f087dd
askrene: add route_exclution array
Lagrang3 Sep 23, 2024
1c0132e
add askrene-disable-channel
Lagrang3 Sep 23, 2024
f9bc499
askrene: refactor disabled channels/nodes
Lagrang3 Sep 25, 2024
3071fba
renepay: call getroutes RPC instead of computing
Lagrang3 Sep 2, 2024
c3bbe07
renepay: add default knowledge layer
Lagrang3 Sep 12, 2024
b059dc7
renepay: use askrene-age to relax knowledge
Lagrang3 Sep 12, 2024
679c5f2
renepay: remove unused payment modifier
Lagrang3 Sep 12, 2024
bf53f94
renepay: pass routehints to askrene
Lagrang3 Sep 16, 2024
fdfa65d
renepay: remove unused parts of gossmap refresh
Lagrang3 Sep 17, 2024
f070ddf
renepay: apply channel filters through askrene
Lagrang3 Sep 17, 2024
9e46388
renepay: minor fixes
Lagrang3 Sep 17, 2024
58920e5
renepay: remove extra call to refreshgossmap
Lagrang3 Sep 17, 2024
94d4611
renepay: add json helper for route hops
Lagrang3 Sep 18, 2024
50bc782
renepay: resolve multiple RPC
Lagrang3 Sep 17, 2024
8468b54
renepay: refactor send routes
Lagrang3 Sep 19, 2024
316c34f
renepay: reserve liquidity in askrene
Lagrang3 Sep 20, 2024
b790b7b
renepay: remove unused get_routes func
Lagrang3 Sep 21, 2024
90cea4c
renepay: remove uncertainty tools
Lagrang3 Sep 21, 2024
57153b8
renepay: disable channels with askrene
Lagrang3 Sep 23, 2024
d50e839
renepay: remove unused struct flow
Lagrang3 Sep 23, 2024
7c3d010
renepay: remove unused struct chan_extra
Lagrang3 Sep 23, 2024
d47a6f8
renepay: remove unused internal errorcodes
Lagrang3 Sep 23, 2024
b3f4631
renepay: use askrene-disable-channel
Lagrang3 Sep 25, 2024
192932e
renepay: fix plugin bugs
Lagrang3 Sep 25, 2024
b115d8b
renepay: remove spurious "have_results" flag
Lagrang3 Sep 27, 2024
fc8788f
renepay: remove spurious payment->retry flag
Lagrang3 Sep 27, 2024
86dd2e2
renepay: simplify collect_results
Lagrang3 Sep 27, 2024
13a8e79
renepay: mark routes when reserved
Lagrang3 Sep 27, 2024
7faebad
renepay: refactor routefail and routetracker
Lagrang3 Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions common/json_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <common/json_parse.h>
#include <common/json_stream.h>
#include <common/node_id.h>
#include <common/route.h>
#include <common/wireaddr.h>
#include <inttypes.h>
#include <stdio.h>
Expand Down Expand Up @@ -494,6 +495,17 @@ void json_add_short_channel_id_dir(struct json_stream *response,
short_channel_id_outnum(scidd.scid), scidd.dir);
}

void json_add_route_exclusion(struct json_stream *response,
const char *fieldname,
const struct route_exclusion *ex)
{
if (ex->type == EXCLUDE_NODE)
json_add_node_id(response, fieldname, &ex->u.node_id);
else
json_add_short_channel_id_dir(response, fieldname,
ex->u.chan_id);
}

static void json_add_address_fields(struct json_stream *response,
const struct wireaddr *addr,
const char *typefield)
Expand Down
7 changes: 7 additions & 0 deletions common/json_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct wally_psbt;
struct lease_rates;
struct wireaddr;
struct wireaddr_internal;
struct route_exclusion;

struct json_stream {
struct json_out *jout;
Expand Down Expand Up @@ -301,6 +302,12 @@ void json_add_channel_id(struct json_stream *response,
const char *fieldname,
const struct channel_id *cid);

/* '"fieldname" : <value>' or "<value>" if fieldname is NULL, where <value> is
* either a node_id or a short_channel_id_dir. */
void json_add_route_exclusion(struct json_stream *response,
const char *fieldname,
const struct route_exclusion *ex);

/* '"fieldname" : <hexrev>' or "<hexrev>" if fieldname is NULL */
void json_add_txid(struct json_stream *result, const char *fieldname,
const struct bitcoin_txid *txid);
Expand Down
76 changes: 71 additions & 5 deletions contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,62 @@
"Main web site: <https://github.com/ElementsProject/lightning>"
]
},
"lightning-askrene-disable-channel.json": {
"$schema": "../rpc-schema-draft.json",
"type": "object",
"additionalProperties": false,
"rpc": "askrene-disable-channel",
"title": "Command to disable a channel in a layer (EXPERIMENTAL)",
"description": [
"WARNING: experimental, so API may change.",
"",
"The **askrene-disable-channel** RPC command tells askrene to disable a channel whenever the given layer is used. This is mainly useful to force the use of alternate paths."
],
"request": {
"required": [
"layer",
"short_channel_id"
],
"properties": {
"layer": {
"type": "string",
"description": [
"The name of the layer to apply this change to."
]
},
"short_channel_id": {
"type": "short_channel_id",
"description": [
"The channel to disable."
]
},
"direction": {
"type": "u32",
"description": [
"The direction of the channel. If the direction is not specified then both directions are disabled."
]
}
}
},
"response": {
"required": [],
"properties": {}
},
"see_also": [
"lightning-getroutes(7)",
"lightning-askrene-create-channel(7)",
"lightning-askrene-inform-channel(7)",
"lightning-askrene-disable-node(7)",
"lightning-askrene-listlayers(7)",
"lightning-askrene-age(7)"
],
"author": [
"Rusty Russell <<[email protected]>> is mainly responsible."
],
"resources": [
"Main web site: <https://github.com/ElementsProject/lightning>"
]
},
"lightning-askrene-disable-node.json": {
"$schema": "../rpc-schema-draft.json",
"type": "object",
Expand Down Expand Up @@ -555,7 +611,7 @@
"additionalProperties": false,
"required": [
"layer",
"disabled_nodes",
"disabled",
"created_channels",
"constraints"
],
Expand All @@ -566,12 +622,22 @@
"The name of the layer."
]
},
"disabled_nodes": {
"disabled": {
"type": "array",
"items": {
"type": "pubkey",
"description": [
"The id of the disabled node."
"oneOf": [
{
"type": "pubkey",
"description": [
"The id of the disabled node."
]
},
{
"type": "short_channel_id_dir",
"description": [
"The short channel id of the disabled channel."
]
}
]
}
},
Expand Down
1 change: 1 addition & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GENERATE_MARKDOWN := doc/lightning-addgossip.7 \
doc/lightning-addpsbtoutput.7 \
doc/lightning-askrene-create-channel.7 \
doc/lightning-askrene-disable-node.7 \
doc/lightning-askrene-disable-channel.7 \
doc/lightning-askrene-inform-channel.7 \
doc/lightning-askrene-listlayers.7 \
doc/lightning-askrene-reserve.7 \
Expand Down
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Core Lightning Documentation
lightning-addgossip <lightning-addgossip.7.md>
lightning-addpsbtoutput <lightning-addpsbtoutput.7.md>
lightning-askrene-create-channel <lightning-askrene-create-channel.7.md>
lightning-askrene-disable-channel <lightning-askrene-disable-channel.7.md>
lightning-askrene-disable-node <lightning-askrene-disable-node.7.md>
lightning-askrene-inform-channel <lightning-askrene-inform-channel.7.md>
lightning-askrene-listlayers <lightning-askrene-listlayers.7.md>
Expand Down
56 changes: 56 additions & 0 deletions doc/schemas/lightning-askrene-disable-channel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"$schema": "../rpc-schema-draft.json",
"type": "object",
"additionalProperties": false,
"rpc": "askrene-disable-channel",
"title": "Command to disable a channel in a layer (EXPERIMENTAL)",
"description": [
"WARNING: experimental, so API may change.",
"",
"The **askrene-disable-channel** RPC command tells askrene to disable a channel whenever the given layer is used. This is mainly useful to force the use of alternate paths."
],
"request": {
"required": [
"layer",
"short_channel_id"
],
"properties": {
"layer": {
"type": "string",
"description": [
"The name of the layer to apply this change to."
]
},
"short_channel_id": {
"type": "short_channel_id",
"description": [
"The channel to disable."
]
},
"direction": {
"type": "u32",
"description": [
"The direction of the channel. If the direction is not specified then both directions are disabled."
]
}
}
},
"response": {
"required": [],
"properties": {}
},
"see_also": [
"lightning-getroutes(7)",
"lightning-askrene-create-channel(7)",
"lightning-askrene-inform-channel(7)",
"lightning-askrene-disable-node(7)",
"lightning-askrene-listlayers(7)",
"lightning-askrene-age(7)"
],
"author": [
"Rusty Russell <<[email protected]>> is mainly responsible."
],
"resources": [
"Main web site: <https://github.com/ElementsProject/lightning>"
]
}
20 changes: 15 additions & 5 deletions doc/schemas/lightning-askrene-listlayers.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"additionalProperties": false,
"required": [
"layer",
"disabled_nodes",
"disabled",
"created_channels",
"constraints"
],
Expand All @@ -43,12 +43,22 @@
"The name of the layer."
]
},
"disabled_nodes": {
"disabled": {
"type": "array",
"items": {
"type": "pubkey",
"description": [
"The id of the disabled node."
"oneOf": [
{
"type": "pubkey",
"description": [
"The id of the disabled node."
]
},
{
"type": "short_channel_id_dir",
"description": [
"The short channel id of the disabled channel."
]
}
]
}
},
Expand Down
48 changes: 48 additions & 0 deletions plugins/askrene/askrene.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ static const char *get_routes(const tal_t *ctx,

gossmap_apply_localmods(askrene->gossmap, localmods);

rq->disabled = tal_get_disabled_bitmap(rq, rq);
if (!rq->disabled) {
ret = tal_fmt(ctx, "Failed creation of disabled bitmap.");
goto out;
}

srcnode = gossmap_find_node(askrene->gossmap, source);
if (!srcnode) {
ret = tal_fmt(ctx, "Unknown source node %s", fmt_node_id(tmpctx, source));
Expand Down Expand Up @@ -881,6 +887,44 @@ static struct command_result *json_askrene_inform_channel(struct command *cmd,
return command_finished(cmd, response);
}

static struct command_result *json_askrene_disable_channel(struct command *cmd,
const char *buffer,
const jsmntok_t *params)
{
struct short_channel_id *scid;
int *direction;
const char *layername;
struct layer *layer;
struct json_stream *response;
struct askrene *askrene = get_askrene(cmd->plugin);

if (!param(cmd, buffer, params,
p_req("layer", param_layername, &layername),
p_req("short_channel_id", param_short_channel_id, &scid),
p_opt("direction", param_zero_or_one, &direction),
NULL))
return command_param_failed();

layer = find_layer(askrene, layername);
if (!layer)
layer = new_layer(askrene, layername);

struct short_channel_id_dir scidd = {.scid = *scid};
if (direction) {
scidd.dir = *direction;
layer_add_disabled_channel(layer, &scidd);
} else {
/* If no direction is provided we disable both. */
scidd.dir = 0;
layer_add_disabled_channel(layer, &scidd);
scidd.dir = 1;
layer_add_disabled_channel(layer, &scidd);
}

response = jsonrpc_stream_success(cmd);
return command_finished(cmd, response);
}

static struct command_result *json_askrene_disable_node(struct command *cmd,
const char *buffer,
const jsmntok_t *params)
Expand Down Expand Up @@ -983,6 +1027,10 @@ static const struct plugin_command commands[] = {
"askrene-age",
json_askrene_age,
},
{
"askrene-disable-channel",
json_askrene_disable_channel,
},
};

static void askrene_markmem(struct plugin *plugin, struct htable *memtable)
Expand Down
5 changes: 5 additions & 0 deletions plugins/askrene/askrene.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define LIGHTNING_PLUGINS_ASKRENE_ASKRENE_H
#include "config.h"
#include <bitcoin/short_channel_id.h>
#include <ccan/bitmap/bitmap.h>
#include <ccan/htable/htable_type.h>
#include <ccan/list/list.h>
#include <common/amount.h>
Expand Down Expand Up @@ -41,6 +42,10 @@ struct route_query {
/* This is *not* updated during a query! Has all layers applied. */
const struct gossmap *gossmap;

/* Bit is set for [idx*2+dir] if that channel is disabled or if it
* belongs to a disabled node.. */
bitmap *disabled;

/* We need to take in-flight payments into account */
const struct reserve_htable *reserved;

Expand Down
Loading