diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 27919a75a..66eaed5f8 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -1338,3 +1337,16 @@ void opening_dev_memleak(struct command *cmd) opening_memleak_req_next(cmd, NULL); } #endif /* DEVELOPER */ + +struct subd *peer_get_owning_subd(struct peer *peer) +{ + struct channel *channel; + channel = peer_active_channel(peer); + + if (channel != NULL) { + return channel->owner; + } else if (peer->uncommitted_channel != NULL) { + return peer->uncommitted_channel->openingd; + } + return NULL; +} diff --git a/lightningd/opening_control.h b/lightningd/opening_control.h index 23df19eb3..fbf8ce715 100644 --- a/lightningd/opening_control.h +++ b/lightningd/opening_control.h @@ -2,6 +2,7 @@ #define LIGHTNING_LIGHTNINGD_OPENING_CONTROL_H #include "config.h" #include +#include struct channel_id; struct crypto_state; @@ -26,4 +27,6 @@ struct command; void opening_dev_memleak(struct command *cmd); #endif +struct subd *peer_get_owning_subd(struct peer *peer); + #endif /* LIGHTNING_LIGHTNINGD_OPENING_CONTROL_H */