mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-06 23:54:22 +01:00
listchannels: allow source arg to list channels by their source node.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
de682f5806
commit
dc2ee9639b
@@ -43,6 +43,7 @@ gossip_getroute_reply,,hops,num_hops*struct route_hop
|
||||
|
||||
gossip_getchannels_request,3007
|
||||
gossip_getchannels_request,,short_channel_id,?struct short_channel_id
|
||||
gossip_getchannels_request,,source,?struct pubkey
|
||||
|
||||
gossip_getchannels_reply,3107
|
||||
gossip_getchannels_reply,,num_channels,u16
|
||||
|
||||
|
@@ -1971,9 +1971,10 @@ static struct io_plan *getchannels_req(struct io_conn *conn,
|
||||
struct gossip_getchannels_entry *entries;
|
||||
struct chan *chan;
|
||||
struct short_channel_id *scid;
|
||||
struct pubkey *source;
|
||||
|
||||
/* Note: scid is marked optional in gossip_wire.csv */
|
||||
if (!fromwire_gossip_getchannels_request(msg, msg, &scid))
|
||||
if (!fromwire_gossip_getchannels_request(msg, msg, &scid, &source))
|
||||
master_badmsg(WIRE_GOSSIP_GETCHANNELS_REQUEST, msg);
|
||||
|
||||
entries = tal_arr(tmpctx, struct gossip_getchannels_entry, 0);
|
||||
@@ -1982,6 +1983,15 @@ static struct io_plan *getchannels_req(struct io_conn *conn,
|
||||
chan = get_channel(daemon->rstate, scid);
|
||||
if (chan)
|
||||
append_channel(&entries, chan);
|
||||
} else if (source) {
|
||||
struct node *s = get_node(daemon->rstate, source);
|
||||
if (s) {
|
||||
for (size_t i = 0; i < tal_count(s->chans); i++)
|
||||
append_half_channel(&entries,
|
||||
s->chans[i],
|
||||
!half_chan_to(s,
|
||||
s->chans[i]));
|
||||
}
|
||||
} else {
|
||||
u64 idx;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user