mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
listincoming: add htlc_min_msat, public and peer_features fields.
This is needed for offers to generate blinded paths. No documentation changes since listincoming is an undocumented internal hack interface which topology presents for production of routehints. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
c6f50220e1
commit
4bc10579e6
@@ -1289,3 +1289,22 @@ int gossmap_node_get_feature(const struct gossmap *map,
|
||||
return map_feature_test(map, COMPULSORY_FEATURE(fbit),
|
||||
n->nann_off + feature_len_off + 2, feature_len);
|
||||
}
|
||||
|
||||
u8 *gossmap_node_get_features(const tal_t *ctx,
|
||||
const struct gossmap *map,
|
||||
const struct gossmap_node *n)
|
||||
{
|
||||
u8 *ret;
|
||||
/* Note that first two bytes are message type */
|
||||
const size_t feature_len_off = 2 + 64;
|
||||
size_t feature_len;
|
||||
|
||||
if (n->nann_off == 0)
|
||||
return NULL;
|
||||
|
||||
feature_len = map_be16(map, n->nann_off + feature_len_off);
|
||||
ret = tal_arr(ctx, u8, feature_len);
|
||||
|
||||
map_copy(map, n->nann_off + feature_len_off + 2, ret, feature_len);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -134,21 +134,26 @@ u8 *gossmap_node_get_announce(const tal_t *ctx,
|
||||
const struct gossmap *map,
|
||||
const struct gossmap_node *n);
|
||||
|
||||
/* Return the feature bit (odd or even), or -1 if neither. */
|
||||
/* Return the channel feature bit (odd or even), or -1 if neither. */
|
||||
int gossmap_chan_get_feature(const struct gossmap *map,
|
||||
const struct gossmap_chan *c,
|
||||
int fbit);
|
||||
|
||||
/* Return the feature bitmap */
|
||||
/* Return the channel feature bitmap */
|
||||
u8 *gossmap_chan_get_features(const tal_t *ctx,
|
||||
const struct gossmap *map,
|
||||
const struct gossmap_chan *c);
|
||||
|
||||
/* Return the feature bit (odd or even), or -1 if neither (or no announcement) */
|
||||
/* Return the node feature bit (odd or even), or -1 if neither (or no announcement) */
|
||||
int gossmap_node_get_feature(const struct gossmap *map,
|
||||
const struct gossmap_node *n,
|
||||
int fbit);
|
||||
|
||||
/* Return the node feature bitmap: NULL if no announcement. */
|
||||
u8 *gossmap_node_get_features(const tal_t *ctx,
|
||||
const struct gossmap *map,
|
||||
const struct gossmap_node *n);
|
||||
|
||||
/* Returns details from channel_update (must be gossmap_chan_set, and
|
||||
* does not work for local_updatechan! */
|
||||
void gossmap_chan_get_update_details(const struct gossmap *map,
|
||||
|
||||
@@ -577,6 +577,7 @@ static struct command_result *json_listincoming(struct command *cmd,
|
||||
struct gossmap_chan *ourchan;
|
||||
struct gossmap_node *peer;
|
||||
struct short_channel_id scid;
|
||||
const u8 *peer_features;
|
||||
|
||||
ourchan = gossmap_nth_chan(gossmap, me, i, &dir);
|
||||
/* If its half is disabled, ignore. */
|
||||
@@ -593,6 +594,9 @@ static struct command_result *json_listincoming(struct command *cmd,
|
||||
json_add_amount_msat_only(js, "fee_base_msat",
|
||||
amount_msat(ourchan->half[!dir]
|
||||
.base_fee));
|
||||
json_add_amount_msat_only(js, "htlc_min_msat",
|
||||
amount_msat(fp16_to_u64(ourchan->half[!dir]
|
||||
.htlc_min)));
|
||||
json_add_amount_msat_only(js, "htlc_max_msat",
|
||||
amount_msat(fp16_to_u64(ourchan->half[!dir]
|
||||
.htlc_max)));
|
||||
@@ -602,6 +606,10 @@ static struct command_result *json_listincoming(struct command *cmd,
|
||||
json_add_amount_msat_only(js, "incoming_capacity_msat",
|
||||
peer_capacity(gossmap,
|
||||
me, peer, ourchan));
|
||||
json_add_bool(js, "public", !ourchan->private);
|
||||
peer_features = gossmap_node_get_features(tmpctx, gossmap, peer);
|
||||
if (peer_features)
|
||||
json_add_hex_talarr(js, "peer_features", peer_features);
|
||||
json_object_end(js);
|
||||
}
|
||||
done:
|
||||
|
||||
Reference in New Issue
Block a user