diff --git a/lightningd/channel.c b/lightningd/channel.c index c25a163d5..e0535212b 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -678,6 +678,29 @@ struct channel *channel_by_cid(struct lightningd *ld, return NULL; } +struct channel *find_channel_by_id(const struct peer *peer, + const struct channel_id *cid) +{ + struct channel *c; + + list_for_each(&peer->channels, c, list) { + if (channel_id_eq(&c->cid, cid)) + return c; + } + return NULL; +} + +struct channel *find_channel_by_scid(const struct peer *peer, + const struct short_channel_id *scid) +{ + struct channel *c; + + list_for_each(&peer->channels, c, list) { + if (c->scid && short_channel_id_eq(c->scid, scid)) + return c; + } + return NULL; +} void channel_set_last_tx(struct channel *channel, struct bitcoin_tx *tx, diff --git a/lightningd/channel.h b/lightningd/channel.h index 676b14a75..2583070c1 100644 --- a/lightningd/channel.h +++ b/lightningd/channel.h @@ -418,6 +418,10 @@ struct channel *channel_by_cid(struct lightningd *ld, struct channel *find_channel_by_id(const struct peer *peer, const struct channel_id *cid); +/* Find this channel within peer */ +struct channel *find_channel_by_scid(const struct peer *peer, + const struct short_channel_id *scid); + void channel_set_last_tx(struct channel *channel, struct bitcoin_tx *tx, const struct bitcoin_signature *sig, diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index a16d6ee57..c3721ef10 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -907,18 +907,6 @@ void channel_notify_new_block(struct lightningd *ld, tal_free(to_forget); } -struct channel *find_channel_by_id(const struct peer *peer, - const struct channel_id *cid) -{ - struct channel *c; - - list_for_each(&peer->channels, c, list) { - if (channel_id_eq(&c->cid, cid)) - return c; - } - return NULL; -} - /* Since this could vanish while we're checking with bitcoind, we need to save * the details and re-lookup. * diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index c067c987d..1f8b36176 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -133,10 +133,6 @@ char *encode_scriptpubkey_to_addr(const tal_t *ctx UNNEEDED, /* Generated stub for fatal */ void fatal(const char *fmt UNNEEDED, ...) { fprintf(stderr, "fatal called!\n"); abort(); } -/* Generated stub for find_channel_by_id */ -struct channel *find_channel_by_id(const struct peer *peer UNNEEDED, - const struct channel_id *cid UNNEEDED) -{ fprintf(stderr, "find_channel_by_id called!\n"); abort(); } /* Generated stub for fromwire_channeld_dev_memleak_reply */ bool fromwire_channeld_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED) { fprintf(stderr, "fromwire_channeld_dev_memleak_reply called!\n"); abort(); }