invoice: Consider aliases too when selecting routehints

This commit is contained in:
Christian Decker
2022-04-28 17:55:15 +02:00
parent 78c9c6a9e0
commit 1ae3dba529
7 changed files with 65 additions and 5 deletions

View File

@@ -1581,10 +1581,10 @@ static struct listpeers_channel *json_to_listpeers_channel(const tal_t *ctx,
*scidtok =
json_get_member(buffer, tok, "short_channel_id"),
*dirtok = json_get_member(buffer, tok, "direction"),
*tmsattok =
json_get_member(buffer, tok, "total_msat"),
*tmsattok = json_get_member(buffer, tok, "total_msat"),
*smsattok =
json_get_member(buffer, tok, "spendable_msat");
json_get_member(buffer, tok, "spendable_msat"),
*aliastok = json_get_member(buffer, tok, "alias");
if (privtok == NULL || privtok->type != JSMN_PRIMITIVE ||
statetok == NULL || statetok->type != JSMN_STRING ||
@@ -1611,6 +1611,25 @@ static struct listpeers_channel *json_to_listpeers_channel(const tal_t *ctx,
chan->scid = NULL;
chan->direction = NULL;
}
if (aliastok != NULL) {
const jsmntok_t *loctok =
json_get_member(buffer, aliastok, "local"),
*remtok =
json_get_member(buffer, aliastok, "remote");
if (loctok) {
chan->alias[LOCAL] = tal(chan, struct short_channel_id);
json_to_short_channel_id(buffer, loctok,
chan->alias[LOCAL]);
} else
chan->alias[LOCAL] = NULL;
if (remtok) {
chan->alias[REMOTE] = tal(chan, struct short_channel_id);
json_to_short_channel_id(buffer, loctok,
chan->alias[REMOTE]);
} else
chan->alias[REMOTE] = NULL;
}
json_to_msat(buffer, tmsattok, &chan->total_msat);
json_to_msat(buffer, smsattok, &chan->spendable_msat);