mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
invoice: Consider aliases too when selecting routehints
This commit is contained in:
@@ -3228,9 +3228,17 @@ static struct command_result *direct_pay_listpeers(struct command *cmd,
|
||||
if (!streq(chan->state, "CHANNELD_NORMAL"))
|
||||
continue;
|
||||
|
||||
/* Must have either a local alias for zeroconf
|
||||
* channels or a final scid. */
|
||||
assert(chan->alias[LOCAL] || chan->scid);
|
||||
d->chan = tal(d, struct short_channel_id_dir);
|
||||
d->chan->scid = *chan->scid;
|
||||
d->chan->dir = *chan->direction;
|
||||
if (chan->scid) {
|
||||
d->chan->scid = *chan->scid;
|
||||
d->chan->dir = *chan->direction;
|
||||
} else {
|
||||
d->chan->scid = *chan->alias[LOCAL];
|
||||
d->chan->dir = 0; /* Don't care. */
|
||||
}
|
||||
}
|
||||
}
|
||||
cont:
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <ccan/timer/timer.h>
|
||||
#include <common/errcode.h>
|
||||
#include <common/features.h>
|
||||
#include <common/htlc.h>
|
||||
#include <common/json.h>
|
||||
#include <common/json_command.h>
|
||||
#include <common/json_helpers.h>
|
||||
@@ -318,6 +319,7 @@ struct listpeers_channel {
|
||||
bool private;
|
||||
struct bitcoin_txid funding_txid;
|
||||
const char *state;
|
||||
struct short_channel_id *alias[NUM_SIDES];
|
||||
struct short_channel_id *scid;
|
||||
int *direction;
|
||||
struct amount_msat total_msat;
|
||||
|
||||
Reference in New Issue
Block a user