mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
pay: Populate the channel hints with either the scid or the alias
We'll use one of the two, and we reuse the `scid` field, since we don't really care that much which one it is.
This commit is contained in:
parent
0ce68b26c6
commit
7930e34da3
2 changed files with 21 additions and 4 deletions
|
@ -2293,7 +2293,7 @@ local_channel_hints_listpeers(struct command *cmd, const char *buffer,
|
||||||
const jsmntok_t *toks, struct payment *p)
|
const jsmntok_t *toks, struct payment *p)
|
||||||
{
|
{
|
||||||
const jsmntok_t *peers, *peer, *channels, *channel, *spendsats, *scid,
|
const jsmntok_t *peers, *peer, *channels, *channel, *spendsats, *scid,
|
||||||
*dir, *connected, *max_htlc, *htlcs, *state;
|
*dir, *connected, *max_htlc, *htlcs, *state, *alias, *alias_local;
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
peers = json_get_member(buffer, toks, "peers");
|
peers = json_get_member(buffer, toks, "peers");
|
||||||
|
|
||||||
|
@ -2311,12 +2311,20 @@ local_channel_hints_listpeers(struct command *cmd, const char *buffer,
|
||||||
struct channel_hint h;
|
struct channel_hint h;
|
||||||
spendsats = json_get_member(buffer, channel, "spendable_msat");
|
spendsats = json_get_member(buffer, channel, "spendable_msat");
|
||||||
scid = json_get_member(buffer, channel, "short_channel_id");
|
scid = json_get_member(buffer, channel, "short_channel_id");
|
||||||
|
|
||||||
|
alias = json_get_member(buffer, channel, "alias");
|
||||||
|
if (alias != NULL)
|
||||||
|
alias_local = json_get_member(buffer, alias, "local");
|
||||||
|
else
|
||||||
|
alias_local = NULL;
|
||||||
|
|
||||||
dir = json_get_member(buffer, channel, "direction");
|
dir = json_get_member(buffer, channel, "direction");
|
||||||
max_htlc = json_get_member(buffer, channel, "max_accepted_htlcs");
|
max_htlc = json_get_member(buffer, channel, "max_accepted_htlcs");
|
||||||
htlcs = json_get_member(buffer, channel, "htlcs");
|
htlcs = json_get_member(buffer, channel, "htlcs");
|
||||||
state = json_get_member(buffer, channel, "state");
|
state = json_get_member(buffer, channel, "state");
|
||||||
if (spendsats == NULL || scid == NULL || dir == NULL ||
|
if (spendsats == NULL ||
|
||||||
max_htlc == NULL || state == NULL ||
|
(scid == NULL && alias_local == NULL) ||
|
||||||
|
dir == NULL || max_htlc == NULL || state == NULL ||
|
||||||
max_htlc->type != JSMN_PRIMITIVE || htlcs == NULL ||
|
max_htlc->type != JSMN_PRIMITIVE || htlcs == NULL ||
|
||||||
htlcs->type != JSMN_ARRAY)
|
htlcs->type != JSMN_ARRAY)
|
||||||
continue;
|
continue;
|
||||||
|
@ -2327,7 +2335,11 @@ local_channel_hints_listpeers(struct command *cmd, const char *buffer,
|
||||||
json_to_bool(buffer, connected, &h.enabled);
|
json_to_bool(buffer, connected, &h.enabled);
|
||||||
h.enabled &= json_tok_streq(buffer, state, "CHANNELD_NORMAL");
|
h.enabled &= json_tok_streq(buffer, state, "CHANNELD_NORMAL");
|
||||||
|
|
||||||
json_to_short_channel_id(buffer, scid, &h.scid.scid);
|
if (scid != NULL)
|
||||||
|
json_to_short_channel_id(buffer, scid, &h.scid.scid);
|
||||||
|
else
|
||||||
|
json_to_short_channel_id(buffer, alias_local, &h.scid.scid);
|
||||||
|
|
||||||
json_to_int(buffer, dir, &h.scid.dir);
|
json_to_int(buffer, dir, &h.scid.dir);
|
||||||
|
|
||||||
json_to_msat(buffer, spendsats, &h.estimated_capacity);
|
json_to_msat(buffer, spendsats, &h.estimated_capacity);
|
||||||
|
|
|
@ -60,6 +60,11 @@ struct payment_result {
|
||||||
* get remove on failure. Success keeps the capacities, since the capacities
|
* get remove on failure. Success keeps the capacities, since the capacities
|
||||||
* changed due to the successful HTLCs. */
|
* changed due to the successful HTLCs. */
|
||||||
struct channel_hint {
|
struct channel_hint {
|
||||||
|
/* The short_channel_id we're going to use when referring to
|
||||||
|
* this channel. This can either be the real scid, or the
|
||||||
|
* local alias. The `pay` algorithm doesn't really care which
|
||||||
|
* one it is, but we'll prefer the scid as that's likely more
|
||||||
|
* readable than the alias. */
|
||||||
struct short_channel_id_dir scid;
|
struct short_channel_id_dir scid;
|
||||||
|
|
||||||
/* Upper bound on remove channels inferred from payment failures. */
|
/* Upper bound on remove channels inferred from payment failures. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue