global: remove unnecessary includes from C files.
What changed, and why it matters
This commit is a routine code cleanup: it removes unused C-language #include directives from many source files and adds a few that were needed but previously inherited indirectly. The stated goal is faster build times, and the diff shows no functional code changes. There is no security-relevant behavior change.
No security action required. Treat as normal refactoring; verify CI still passes on all supported compilers/configurations.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch is a bulk include-reduction pass generated by devtools/reduce-includes.sh across 177 files. It deletes 682 include lines and adds 14, mostly removing headers that were not directly used in each translation unit. A few files gain explicit includes (e.g.,
Changed components
build system / compilation hygieneC source include directives across bitcoin/, channeld/, cli/, closingd/, common/, connectd/, db/, devtools/, gossipd/, hsmd/, lightningd/, onchaind/, openingd/, plugins/, tools/, wallet/, wire/Inspect captured patch +14 / −682
diff --git a/bitcoin/base58.c b/bitcoin/base58.c
index a3da473..f0dc2a7 100644
--- a/bitcoin/base58.c
+++ b/bitcoin/base58.c
@@ -6,9 +6,6 @@
#include "config.h"
#include <bitcoin/address.h>
#include <bitcoin/base58.h>
-#include <bitcoin/privkey.h>
-#include <bitcoin/pubkey.h>
-#include <bitcoin/shadouble.h>
#include <common/utils.h>
#include <wally_core.h>
diff --git a/bitcoin/block.c b/bitcoin/block.c
index 53fc6d9..5a36a7d 100644
--- a/bitcoin/block.c
+++ b/bitcoin/block.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <assert.h>
#include <bitcoin/block.h>
-#include <bitcoin/chainparams.h>
#include <bitcoin/tx.h>
#include <ccan/mem/mem.h>
#include <ccan/str/hex/hex.h>
diff --git a/bitcoin/chainparams.c b/bitcoin/chainparams.c
index 572f8b1..9d2883b 100644
--- a/bitcoin/chainparams.c
+++ b/bitcoin/chainparams.c
@@ -3,7 +3,6 @@
#include <bitcoin/chainparams.h>
#include <ccan/array_size/array_size.h>
#include <ccan/tal/str/str.h>
-#include <common/utils.h>
/* Version codes for BIP32 extended keys in libwally-core.
* Stolen from wally_bip32.h in libwally-core*/
diff --git a/bitcoin/locktime.c b/bitcoin/locktime.c
index f73559d..d45e8ca 100644
--- a/bitcoin/locktime.c
+++ b/bitcoin/locktime.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <assert.h>
#include <bitcoin/locktime.h>
-#include <ccan/tal/str/str.h>
#define SECONDS_POINT 500000000
diff --git a/bitcoin/psbt.c b/bitcoin/psbt.c
index dff12b0..ea4a6c2 100644
--- a/bitcoin/psbt.c
+++ b/bitcoin/psbt.c
@@ -1,13 +1,10 @@
#include "config.h"
#include <assert.h>
-#include <bitcoin/chainparams.h>
#include <bitcoin/psbt.h>
#include <bitcoin/pubkey.h>
#include <bitcoin/script.h>
-#include <bitcoin/varint.h>
#include <ccan/ccan/array_size/array_size.h>
#include <ccan/ccan/mem/mem.h>
-#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <wally_psbt.h>
#include <wire/wire.h>
diff --git a/bitcoin/script.c b/bitcoin/script.c
index 71e0dd0..73367f5 100644
--- a/bitcoin/script.c
+++ b/bitcoin/script.c
@@ -5,7 +5,6 @@
#include <bitcoin/preimage.h>
#include <bitcoin/pubkey.h>
#include <bitcoin/script.h>
-#include <ccan/endian/endian.h>
#include <ccan/mem/mem.h>
#include <common/utils.h>
#include <sodium/randombytes.h>
diff --git a/bitcoin/signature.c b/bitcoin/signature.c
index 82215cf..5ae7bd5 100644
--- a/bitcoin/signature.c
+++ b/bitcoin/signature.c
@@ -3,8 +3,6 @@
#include <bitcoin/privkey.h>
#include <bitcoin/psbt.h>
#include <bitcoin/pubkey.h>
-#include <bitcoin/script.h>
-#include <bitcoin/shadouble.h>
#include <bitcoin/signature.h>
#include <bitcoin/tx.h>
#include <ccan/mem/mem.h>
diff --git a/channeld/channeld.c b/channeld/channeld.c
index dc8bdf2..6489ba7 100644
--- a/channeld/channeld.c
+++ b/channeld/channeld.c
@@ -19,14 +19,10 @@
#include <channeld/channeld.h>
#include <channeld/channeld_wiregen.h>
#include <channeld/full_channel.h>
-#include <channeld/inflight.h>
#include <channeld/splice.h>
#include <channeld/watchtower.h>
#include <common/billboard.h>
#include <common/ecdh_hsmd.h>
-#include <common/gossip_store.h>
-#include <common/hsm_capable.h>
-#include <common/hsm_version.h>
#include <common/interactivetx.h>
#include <common/key_derive.h>
#include <common/memleak.h>
@@ -48,10 +44,6 @@
#include <fcntl.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
-#include <stdio.h>
-#include <wally_bip32.h>
-#include <wire/peer_wire.h>
-#include <wire/tlvstream.h>
#include <wire/wire_sync.h>
/* stdin == requests, 3 == peer, 4 = HSM */
diff --git a/channeld/inflight.c b/channeld/inflight.c
index db84e58..475e669 100644
--- a/channeld/inflight.c
+++ b/channeld/inflight.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <assert.h>
#include <bitcoin/psbt.h>
#include <bitcoin/short_channel_id.h>
#include <channeld/inflight.h>
diff --git a/channeld/splice.c b/channeld/splice.c
index e72b4af..6ebc73d 100644
--- a/channeld/splice.c
+++ b/channeld/splice.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <ccan/tal/tal.h>
#include <channeld/splice.h>
struct splice_state *splice_state_new(const tal_t *ctx)
diff --git a/channeld/watchtower.c b/channeld/watchtower.c
index 43a267e..285cdc4 100644
--- a/channeld/watchtower.c
+++ b/channeld/watchtower.c
@@ -3,13 +3,11 @@
#include <bitcoin/script.h>
#include <channeld/channeld.h>
#include <channeld/watchtower.h>
-#include <common/features.h>
#include <common/htlc_tx.h>
#include <common/keyset.h>
#include <common/psbt_keypath.h>
#include <common/status.h>
#include <hsmd/hsmd_wiregen.h>
-#include <wire/wire_sync.h>
static const u8 ONE = 0x1;
diff --git a/cli/config_cli.h b/cli/config_cli.h
index 5b0dcfd..7d1e9cc 100644
--- a/cli/config_cli.h
+++ b/cli/config_cli.h
@@ -2,6 +2,7 @@
#define LIGHTNING_CLI_CONFIG_CLI_H
#include "config.h"
+#include <unistd.h>
#ifndef CLN_TEST
/* Redefinition procedure is a very cool feature, but
diff --git a/cli/lightning-cli.c b/cli/lightning-cli.c
index 8ebc254..3aed536 100644
--- a/cli/lightning-cli.c
+++ b/cli/lightning-cli.c
@@ -13,15 +13,12 @@
#include <common/configdir.h>
#include <common/json_command.h>
#include <common/node_id.h>
-#include <common/status_levels.h>
#include <common/utils.h>
-#include <common/version.h>
#include <libgen.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/wait.h>
-#include <unistd.h>
#define NO_ERROR 0
#define ERROR_FROM_LIGHTNINGD 1
diff --git a/closingd/closingd.c b/closingd/closingd.c
index 5cf5f5b..a42bcf3 100644
--- a/closingd/closingd.c
+++ b/closingd/closingd.c
@@ -1,13 +1,10 @@
#include "config.h"
#include <bitcoin/script.h>
#include <ccan/cast/cast.h>
-#include <ccan/fdpass/fdpass.h>
#include <ccan/tal/str/str.h>
#include <closingd/closingd_wiregen.h>
#include <common/close_tx.h>
#include <common/closing_fee.h>
-#include <common/derive_basepoints.h>
-#include <common/htlc.h>
#include <common/memleak.h>
#include <common/peer_billboard.h>
#include <common/peer_failed.h>
@@ -17,14 +14,11 @@
#include <common/status.h>
#include <common/subdaemon.h>
#include <common/utils.h>
-#include <common/version.h>
-#include <common/wire_error.h>
#include <errno.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <stdio.h>
#include <unistd.h>
-#include <wally_bip32.h>
#include <wire/peer_wire.h>
#include <wire/wire_sync.h>
diff --git a/common/blindedpath.c b/common/blindedpath.c
index 0923c40..5d26c93 100644
--- a/common/blindedpath.c
+++ b/common/blindedpath.c
@@ -1,7 +1,5 @@
#include "config.h"
-#include <bitcoin/privkey.h>
#include <bitcoin/tx.h>
-#include <ccan/cast/cast.h>
#include <common/blindedpath.h>
#include <common/blinding.h>
#include <common/bolt11.h>
diff --git a/common/blindedpay.c b/common/blindedpay.c
index 1dc6f74..4d8c3c8 100644
--- a/common/blindedpay.c
+++ b/common/blindedpay.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <assert.h>
#include <common/blindedpay.h>
-#include <common/bolt12.h>
#include <common/onion_encode.h>
#include <wire/onion_wiregen.h>
diff --git a/common/bolt11.c b/common/bolt11.c
index bd51fb3..7698f49 100644
--- a/common/bolt11.c
+++ b/common/bolt11.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <assert.h>
#include <bitcoin/address.h>
#include <bitcoin/script.h>
#include <ccan/array_size/array_size.h>
diff --git a/common/bolt11_json.c b/common/bolt11_json.c
index c2e7f22..bdc91c1 100644
--- a/common/bolt11_json.c
+++ b/common/bolt11_json.c
@@ -1,6 +1,4 @@
#include "config.h"
-#include <bitcoin/address.h>
-#include <bitcoin/base58.h>
#include <bitcoin/script.h>
#include <ccan/tal/str/str.h>
#include <common/addr.h>
diff --git a/common/bolt12.c b/common/bolt12.c
index 8716807..1435b35 100644
--- a/common/bolt12.c
+++ b/common/bolt12.c
@@ -1,19 +1,14 @@
#include "config.h"
-#include <assert.h>
#include <bitcoin/chainparams.h>
#include <ccan/tal/str/str.h>
-#include <ccan/time/time.h>
#include <common/bech32_util.h>
#include <common/bolt12.h>
#include <common/bolt12_merkle.h>
-#include <common/configdir.h>
#include <common/features.h>
#include <common/overflows.h>
#include <common/utils.h>
#include <inttypes.h>
-#include <secp256k1_schnorrsig.h>
#include <time.h>
-#include <wire/onion_wiregen.h>
/* If chains is NULL, max_num_chains is ignored */
bool bolt12_chains_match(const struct bitcoin_blkid *chains,
diff --git a/common/bolt12_id.c b/common/bolt12_id.c
index 3348b99..7665229 100644
--- a/common/bolt12_id.c
+++ b/common/bolt12_id.c
@@ -1,6 +1,5 @@
#include "config.h"
#include <bitcoin/privkey.h>
-#include <ccan/crypto/sha256/sha256.h>
#include <common/bolt12_id.h>
#include <common/utils.h>
diff --git a/common/bolt12_merkle.c b/common/bolt12_merkle.c
index 7f4e185..dadd6de 100644
--- a/common/bolt12_merkle.c
+++ b/common/bolt12_merkle.c
@@ -3,7 +3,6 @@
#include <bitcoin/tx.h>
#include <ccan/cast/cast.h>
#include <ccan/ilog/ilog.h>
-#include <ccan/mem/mem.h>
#include <common/bolt12_merkle.h>
#include <common/utils.h>
diff --git a/common/close_tx.c b/common/close_tx.c
index e4ec998..ee54913 100644
--- a/common/close_tx.c
+++ b/common/close_tx.c
@@ -4,7 +4,6 @@
#include <common/close_tx.h>
#include <common/permute_tx.h>
#include <common/psbt_keypath.h>
-#include <common/utils.h>
struct bitcoin_tx *create_close_tx(const tal_t *ctx,
const struct chainparams *chainparams,
diff --git a/common/codex32.c b/common/codex32.c
index 6ccb0c4..39c9cc0 100644
--- a/common/codex32.c
+++ b/common/codex32.c
@@ -22,22 +22,11 @@
*/
#include "config.h"
#include <assert.h>
-#include <bitcoin/chainparams.h>
#include <ccan/array_size/array_size.h>
-#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/bech32.h>
-#include <common/bech32_util.h>
-#include <common/bolt12.h>
-#include <common/bolt12_merkle.h>
#include <common/codex32.h>
-#include <common/configdir.h>
-#include <common/features.h>
#include <common/utils.h>
-#include <math.h>
-#include <secp256k1_schnorrsig.h>
-#include <string.h>
-#include <time.h>
struct checksum_engine {
u8 generator[15];
diff --git a/common/configdir.c b/common/configdir.c
index 248c8e7..b4e401a 100644
--- a/common/configdir.c
+++ b/common/configdir.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <assert.h>
#include <bitcoin/chainparams.h>
-#include <ccan/cast/cast.h>
#include <ccan/err/err.h>
#include <ccan/opt/opt.h>
#include <ccan/opt/private.h>
diff --git a/common/configvar.c b/common/configvar.c
index 4a3dff3..1148f98 100644
--- a/common/configvar.c
+++ b/common/configvar.c
@@ -4,7 +4,6 @@
#include <ccan/tal/str/str.h>
#include <common/configvar.h>
#include <common/utils.h>
-#include <unistd.h>
struct configvar *configvar_new(const tal_t *ctx,
enum configvar_src src,
diff --git a/common/deprecation.c b/common/deprecation.c
index 6adabb7..3666e20 100644
--- a/common/deprecation.c
+++ b/common/deprecation.c
@@ -1,9 +1,7 @@
#include "config.h"
#include <assert.h>
-#include <ccan/str/str.h>
#include <ccan/tal/tal.h>
#include <common/deprecation.h>
-#include <stdlib.h>
#define MONTH_VAL (10)
#define YEAR_VAL (12 * MONTH_VAL)
diff --git a/common/dev_disconnect.c b/common/dev_disconnect.c
index 2feaf92..039897c 100644
--- a/common/dev_disconnect.c
+++ b/common/dev_disconnect.c
@@ -1,12 +1,9 @@
#include "config.h"
-#include <ccan/closefrom/closefrom.h>
#include <ccan/err/err.h>
#include <common/dev_disconnect.h>
#include <common/status.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <wire/peer_wire.h>
diff --git a/common/gossip_store.c b/common/gossip_store.c
index 10f4dab..3f10dd8 100644
--- a/common/gossip_store.c
+++ b/common/gossip_store.c
@@ -1,14 +1,7 @@
#include "config.h"
-#include <ccan/crc32c/crc32c.h>
#include <common/gossip_store.h>
-#include <common/per_peer_state.h>
-#include <common/status.h>
-#include <errno.h>
-#include <fcntl.h>
#include <gossipd/gossip_store_wiregen.h>
-#include <inttypes.h>
#include <unistd.h>
-#include <wire/peer_wire.h>
/* We cheat and read first two bytes of message too. */
struct hdr_and_type {
diff --git a/common/gossmap.c b/common/gossmap.c
index a21a666..948ed0b 100644
--- a/common/gossmap.c
+++ b/common/gossmap.c
@@ -1,7 +1,5 @@
#include "config.h"
-#include <assert.h>
#include <ccan/crc32c/crc32c.h>
-#include <ccan/crypto/siphash24/siphash24.h>
#include <ccan/err/err.h>
#include <ccan/htable/htable_type.h>
#include <ccan/ptrint/ptrint.h>
@@ -9,7 +7,6 @@
#include <common/features.h>
#include <common/gossip_store.h>
#include <common/gossmap.h>
-#include <common/pseudorand.h>
#include <common/sciddir_or_pubkey.h>
#include <common/utils.h>
#include <errno.h>
diff --git a/common/gossmods_listpeerchannels.c b/common/gossmods_listpeerchannels.c
index 59754d7..256bc30 100644
--- a/common/gossmods_listpeerchannels.c
+++ b/common/gossmods_listpeerchannels.c
@@ -2,7 +2,6 @@
#include <ccan/err/err.h>
#include <common/gossmap.h>
#include <common/gossmods_listpeerchannels.h>
-#include <common/node_id.h>
#include <plugins/libplugin.h>
void gossmod_add_localchan(struct gossmap_localmods *mods,
diff --git a/common/hsm_encryption.c b/common/hsm_encryption.c
index c8f316a..3486773 100644
--- a/common/hsm_encryption.c
+++ b/common/hsm_encryption.c
@@ -1,8 +1,6 @@
#include "config.h"
-#include <ccan/tal/str/str.h>
#include <common/errcode.h>
#include <common/hsm_encryption.h>
-#include <errno.h>
#include <sys/stat.h>
#include <termios.h>
#include <unistd.h>
diff --git a/common/htlc_wire.c b/common/htlc_wire.c
index 3d94471..5ccd757 100644
--- a/common/htlc_wire.c
+++ b/common/htlc_wire.c
@@ -5,7 +5,6 @@
#include <common/htlc_wire.h>
#include <common/onionreply.h>
#include <common/utils.h>
-#include <wire/tlvstream.h>
static struct failed_htlc *failed_htlc_dup(const tal_t *ctx,
const struct failed_htlc *f TAKES)
diff --git a/common/interactivetx.c b/common/interactivetx.c
index 2e9a659..87473ae 100644
--- a/common/interactivetx.c
+++ b/common/interactivetx.c
@@ -1,26 +1,13 @@
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <bitcoin/psbt.h>
#include <bitcoin/script.h>
-#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
-#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
-#include <common/billboard.h>
-#include <common/blockheight_states.h>
-#include <common/gossip_store.h>
-#include <common/initial_channel.h>
#include <common/interactivetx.h>
#include <common/lease_rates.h>
-#include <common/memleak.h>
-#include <common/peer_billboard.h>
-#include <common/peer_failed.h>
#include <common/peer_io.h>
-#include <common/psbt_internal.h>
#include <common/psbt_open.h>
-#include <common/setup.h>
#include <common/status.h>
-#include <common/subdaemon.h>
#include <common/utils.h>
#include <common/wire_error.h>
#include <inttypes.h>
diff --git a/common/json_blinded_path.c b/common/json_blinded_path.c
index 2df745e..bac2be4 100644
--- a/common/json_blinded_path.c
+++ b/common/json_blinded_path.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <bitcoin/pubkey.h>
#include <common/json_blinded_path.h>
#include <common/json_parse.h>
#include <common/utils.h>
diff --git a/common/json_channel_type.c b/common/json_channel_type.c
index bb175e8..91c6181 100644
--- a/common/json_channel_type.c
+++ b/common/json_channel_type.c
@@ -2,7 +2,6 @@
#include <common/channel_type.h>
#include <common/json_channel_type.h>
#include <common/json_command.h>
-#include <common/json_param.h>
#include <common/json_stream.h>
struct command_result *param_channel_type(struct command *cmd,
diff --git a/common/json_param.c b/common/json_param.c
index 9323b03..1b52970 100644
--- a/common/json_param.c
+++ b/common/json_param.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <bitcoin/address.h>
#include <bitcoin/base58.h>
-#include <bitcoin/feerate.h>
#include <bitcoin/psbt.h>
#include <bitcoin/script.h>
#include <ccan/asort/asort.h>
@@ -10,7 +9,6 @@
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
#include <common/bech32.h>
-#include <common/configdir.h>
#include <common/json_command.h>
#include <common/json_param.h>
#include <common/route.h>
diff --git a/common/json_parse.c b/common/json_parse.c
index 2e4bc9e..dc491b2 100644
--- a/common/json_parse.c
+++ b/common/json_parse.c
@@ -4,22 +4,14 @@
#include <bitcoin/preimage.h>
#include <bitcoin/privkey.h>
#include <bitcoin/psbt.h>
-#include <bitcoin/pubkey.h>
-#include <bitcoin/tx.h>
-#include <ccan/json_escape/json_escape.h>
#include <ccan/mem/mem.h>
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
-#include <ccan/time/time.h>
-#include <common/amount.h>
-#include <common/channel_id.h>
#include <common/json_parse.h>
#include <common/node_id.h>
#include <common/overflows.h>
#include <common/utils.h>
#include <errno.h>
-#include <inttypes.h>
-#include <stdio.h>
bool json_to_millionths(const char *buffer, const jsmntok_t *tok,
u64 *millionths)
diff --git a/common/json_parse_simple.c b/common/json_parse_simple.c
index 521b737..f3b3da8 100644
--- a/common/json_parse_simple.c
+++ b/common/json_parse_simple.c
@@ -6,8 +6,6 @@
#include <common/json_parse_simple.h>
#include <common/utils.h>
#include <errno.h>
-#include <inttypes.h>
-#include <stdio.h>
const char *json_tok_full(const char *buffer, const jsmntok_t *t)
{
diff --git a/common/json_stream.c b/common/json_stream.c
index 7d1cc92..582e5e7 100644
--- a/common/json_stream.c
+++ b/common/json_stream.c
@@ -1,25 +1,15 @@
#include "config.h"
#include <arpa/inet.h>
-#include <bitcoin/preimage.h>
-#include <bitcoin/privkey.h>
#include <bitcoin/psbt.h>
#include <bitcoin/signature.h>
-#include <bitcoin/tx.h>
#include <ccan/io/io.h>
/* To reach into io_plan: not a public header! */
#include <ccan/io/backend.h>
#include <ccan/json_escape/json_escape.h>
#include <ccan/json_out/json_out.h>
#include <ccan/str/hex/hex.h>
-#include <ccan/strmap/strmap.h>
-#include <ccan/tal/str/str.h>
-#include <common/channel_id.h>
-#include <common/configdir.h>
#include <common/json_filter.h>
-#include <common/json_parse.h>
#include <common/json_stream.h>
-#include <common/node_id.h>
-#include <common/wireaddr.h>
#include <inttypes.h>
#include <stdio.h>
#include <wire/peer_wire.h>
diff --git a/common/key_derive.c b/common/key_derive.c
index 07c7461..cc2a913 100644
--- a/common/key_derive.c
+++ b/common/key_derive.c
@@ -3,7 +3,6 @@
#include <bitcoin/pubkey.h>
#include <common/key_derive.h>
#include <common/utils.h>
-#include <wally_bip32.h>
/* BOLT #3:
*
diff --git a/common/msg_queue.c b/common/msg_queue.c
index ba702f3..566bb3b 100644
--- a/common/msg_queue.c
+++ b/common/msg_queue.c
@@ -1,10 +1,7 @@
#include "config.h"
-#include <assert.h>
-#include <ccan/cast/cast.h>
#include <ccan/membuf/membuf.h>
#include <common/daemon.h>
#include <common/msg_queue.h>
-#include <common/utils.h>
#include <wire/wire.h>
static bool warned_once;
diff --git a/common/onion_decode.c b/common/onion_decode.c
index e82b8a9..285c634 100644
--- a/common/onion_decode.c
+++ b/common/onion_decode.c
@@ -1,7 +1,4 @@
#include "config.h"
-#include <assert.h>
-#include <ccan/array_size/array_size.h>
-#include <ccan/cast/cast.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/blindedpath.h>
@@ -10,7 +7,6 @@
#include <common/sphinx.h>
#include <common/utils.h>
#include <inttypes.h>
-#include <sodium/crypto_aead_chacha20poly1305.h>
/* BOLT #4:
* - If `encrypted_recipient_data` is present:
diff --git a/common/onion_encode.c b/common/onion_encode.c
index e5ff5d9..2b817e1 100644
--- a/common/onion_encode.c
+++ b/common/onion_encode.c
@@ -1,14 +1,9 @@
#include "config.h"
#include <assert.h>
-#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
-#include <ccan/mem/mem.h>
-#include <common/blindedpath.h>
-#include <common/ecdh.h>
#include <common/onion_encode.h>
#include <common/sphinx.h>
#include <common/utils.h>
-#include <sodium/crypto_aead_chacha20poly1305.h>
/* BOLT #4:
*
diff --git a/common/onion_message.c b/common/onion_message.c
index e887d42..34faf00 100644
--- a/common/onion_message.c
+++ b/common/onion_message.c
@@ -1,13 +1,11 @@
#include "config.h"
#include <assert.h>
-#include <bitcoin/pubkey.h>
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
#include <common/blindedpath.h>
#include <common/onion_message.h>
#include <common/sphinx.h>
#include <sodium.h>
-#include <wire/onion_wiregen.h>
struct tlv_encrypted_data_tlv **new_encdata_tlvs(const tal_t *ctx,
const struct pubkey *ids,
diff --git a/common/onion_message_parse.c b/common/onion_message_parse.c
index c2184db..8668c85 100644
--- a/common/onion_message_parse.c
+++ b/common/onion_message_parse.c
@@ -6,9 +6,7 @@
#include <common/ecdh.h>
#include <common/onion_message_parse.h>
#include <common/sphinx.h>
-#include <common/status.h>
#include <common/utils.h>
-#include <wire/onion_wiregen.h>
#include <wire/peer_wire.h>
static bool decrypt_final_onionmsg(const tal_t *ctx,
diff --git a/common/onionreply.c b/common/onionreply.c
index 6a6e58f..74a20a5 100644
--- a/common/onionreply.c
+++ b/common/onionreply.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <ccan/cast/cast.h>
#include <common/onionreply.h>
-#include <common/utils.h>
#include <wire/wire.h>
void towire_onionreply(u8 **cursor, const struct onionreply *r)
diff --git a/common/peer_io.c b/common/peer_io.c
index 3f090a8..79812b7 100644
--- a/common/peer_io.c
+++ b/common/peer_io.c
@@ -1,17 +1,9 @@
#include "config.h"
-#include <ccan/read_write_all/read_write_all.h>
#include <common/cryptomsg.h>
#include <common/peer_failed.h>
#include <common/peer_io.h>
#include <common/per_peer_state.h>
#include <common/status.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <sys/socket.h>
-#include <wire/wire.h>
-#include <wire/wire_io.h>
#include <wire/wire_sync.h>
void peer_write(struct per_peer_state *pps, const void *msg TAKES)
diff --git a/common/per_peer_state.c b/common/per_peer_state.c
index 981e06c..ee93565 100644
--- a/common/per_peer_state.c
+++ b/common/per_peer_state.c
@@ -1,10 +1,8 @@
#include "config.h"
#include <assert.h>
#include <ccan/fdpass/fdpass.h>
-#include <common/gossip_constants.h>
#include <common/per_peer_state.h>
#include <unistd.h>
-#include <wire/wire.h>
bool dev_fast_gossip = false;
diff --git a/common/ping.c b/common/ping.c
index cfba85f..4c98f09 100644
--- a/common/ping.c
+++ b/common/ping.c
@@ -1,7 +1,5 @@
#include "config.h"
#include <common/ping.h>
-#include <common/status.h>
-#include <common/version.h>
#include <wire/peer_wire.h>
bool check_ping_make_pong(const tal_t *ctx, const u8 *ping, u8 **pong)
diff --git a/common/psbt_internal.c b/common/psbt_internal.c
index 55c50e5..22d4685 100644
--- a/common/psbt_internal.c
+++ b/common/psbt_internal.c
@@ -2,7 +2,6 @@
#include <assert.h>
#include <bitcoin/psbt.h>
#include <bitcoin/script.h>
-#include <bitcoin/varint.h>
#include <common/psbt_internal.h>
#include <common/psbt_open.h>
#include <common/utils.h>
diff --git a/common/psbt_keypath.c b/common/psbt_keypath.c
index dbc055f..dcd89a9 100644
--- a/common/psbt_keypath.c
+++ b/common/psbt_keypath.c
@@ -2,7 +2,6 @@
#include <bitcoin/tx.h>
#include <common/psbt_keypath.h>
#include <common/utils.h>
-#include <wally_bip32.h>
void psbt_output_set_keypath(u32 index, const struct ext_key *ext, bool is_taproot, struct wally_psbt_output *output) {
u8 fingerprint[BIP32_KEY_FINGERPRINT_LEN];
diff --git a/common/psbt_open.c b/common/psbt_open.c
index d589322..5cf83b5 100644
--- a/common/psbt_open.c
+++ b/common/psbt_open.c
@@ -2,8 +2,6 @@
#include <bitcoin/psbt.h>
#include <bitcoin/script.h>
#include <ccan/asort/asort.h>
-#include <ccan/ccan/endian/endian.h>
-#include <ccan/ccan/mem/mem.h>
#include <common/channel_id.h>
#include <common/psbt_open.h>
#include <common/pseudorand.h>
diff --git a/common/pseudorand.c b/common/pseudorand.c
index a9c5dfa..b29aeee 100644
--- a/common/pseudorand.c
+++ b/common/pseudorand.c
@@ -2,11 +2,9 @@
#include <assert.h>
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/isaac/isaac64.h>
-#include <ccan/likely/likely.h>
#include <ccan/tal/tal.h>
#include <common/pseudorand.h>
#include <sodium/randombytes.h>
-#include <string.h>
static struct isaac64_ctx isaac64;
static struct siphash_seed siphashseed;
diff --git a/common/read_peer_msg.c b/common/read_peer_msg.c
index a371cf9..292cc6e 100644
--- a/common/read_peer_msg.c
+++ b/common/read_peer_msg.c
@@ -1,17 +1,10 @@
#include "config.h"
-#include <assert.h>
#include <bitcoin/chainparams.h>
#include <common/peer_failed.h>
-#include <common/peer_io.h>
-#include <common/per_peer_state.h>
-#include <common/ping.h>
#include <common/read_peer_msg.h>
#include <common/status.h>
#include <common/utils.h>
#include <common/wire_error.h>
-#include <errno.h>
-#include <wire/peer_wire.h>
-#include <wire/wire_sync.h>
bool handle_peer_error_or_warning(struct per_peer_state *pps,
const u8 *msg TAKES)
diff --git a/common/route.c b/common/route.c
index b699742..534594e 100644
--- a/common/route.c
+++ b/common/route.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <assert.h>
#include <common/dijkstra.h>
-#include <common/features.h>
#include <common/gossmap.h>
#include <common/route.h>
diff --git a/common/sphinx.c b/common/sphinx.c
index e440550..dd405a0 100644
--- a/common/sphinx.c
+++ b/common/sphinx.c
@@ -3,7 +3,6 @@
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
-#include <common/onion_decode.h>
#include <common/onionreply.h>
#include <common/overflows.h>
#include <common/sphinx.h>
diff --git a/common/splice_script.c b/common/splice_script.c
index fd07c3e..0affda6 100644
--- a/common/splice_script.c
+++ b/common/splice_script.c
@@ -1,16 +1,12 @@
#include "config.h"
#include <assert.h>
#include <bitcoin/base58.h>
-#include <bitcoin/pubkey.h>
#include <ccan/mem/mem.h>
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
-#include <common/amount.h>
#include <common/bech32.h>
#include <common/json_parse.h>
-#include <common/json_parse_simple.h>
#include <common/splice_script.h>
-#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
diff --git a/common/test/run-bolt12_decode.c b/common/test/run-bolt12_decode.c
index 4702d23..6f0fa2a 100644
--- a/common/test/run-bolt12_decode.c
+++ b/common/test/run-bolt12_decode.c
@@ -5,6 +5,7 @@
#include "../json_parse.c"
#include "../json_parse_simple.c"
#include <ccan/array_size/array_size.h>
+#include <ccan/json_escape/json_escape.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
#include <common/setup.h>
diff --git a/common/test/run-codex32.c b/common/test/run-codex32.c
index 2aed323..3b32582 100644
--- a/common/test/run-codex32.c
+++ b/common/test/run-codex32.c
@@ -9,6 +9,7 @@
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
#include <common/setup.h>
+#include <wire/wire.h>
/* AUTOGENERATED MOCKS START */
/* Generated stub for amount_asset_is_main */
diff --git a/common/test/run-json_scan.c b/common/test/run-json_scan.c
index a80dad9..ab3e487 100644
--- a/common/test/run-json_scan.c
+++ b/common/test/run-json_scan.c
@@ -3,6 +3,7 @@
#include "../json_parse_simple.c"
#include <common/amount.h>
#include <common/setup.h>
+#include <stdio.h>
#include <wire/wire.h>
/* AUTOGENERATED MOCKS START */
diff --git a/common/trace.c b/common/trace.c
index a91adf2..7ffe7ea 100644
--- a/common/trace.c
+++ b/common/trace.c
@@ -4,13 +4,9 @@
#include <ccan/err/err.h>
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
-#include <ccan/tal/tal.h>
-#include <ccan/time/time.h>
#include <common/json_stream.h>
-#include <common/memleak.h>
#include <common/pseudorand.h>
#include <common/trace.h>
-#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <unistd.h>
diff --git a/common/utxo.c b/common/utxo.c
index 93ec50d..ca978c5 100644
--- a/common/utxo.c
+++ b/common/utxo.c
@@ -1,6 +1,5 @@
#include "config.h"
#include <common/utxo.h>
-#include <wire/wire.h>
size_t utxo_spend_weight(const struct utxo *utxo, size_t min_witness_weight)
{
diff --git a/common/version.c b/common/version.c
index 0840968..5e762e2 100644
--- a/common/version.c
+++ b/common/version.c
@@ -1,10 +1,7 @@
#include "config.h"
-#include <ccan/compiler/compiler.h>
#include <common/configvar.h>
#include <common/version.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
/* Only common/version.c can safely include this. */
# include "version_gen.h"
diff --git a/connectd/connectd.c b/connectd/connectd.c
index 17ec7d3..edbd51a 100644
--- a/connectd/connectd.c
+++ b/connectd/connectd.c
@@ -13,7 +13,6 @@
#include <ccan/array_size/array_size.h>
#include <ccan/asort/asort.h>
#include <ccan/closefrom/closefrom.h>
-#include <ccan/fdpass/fdpass.h>
#include <ccan/io/backend.h>
#include <ccan/noerr/noerr.h>
#include <ccan/tal/str/str.h>
@@ -24,9 +23,7 @@
#include <common/dev_disconnect.h>
#include <common/ecdh.h>
#include <common/ecdh_hsmd.h>
-#include <common/gossip_store.h>
#include <common/gossmap.h>
-#include <common/jsonrpc_errors.h>
#include <common/memleak.h>
#include <common/status.h>
#include <common/subdaemon.h>
@@ -52,10 +49,8 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <unistd.h>
#include <wire/peer_wire.h>
#include <wire/wire_io.h>
-#include <wire/wire_sync.h>
/*~ We are passed two file descriptors when exec'ed from `lightningd`: the
* first is a connection to `hsmd`, which we need for the cryptographic
diff --git a/connectd/gossip_rcvd_filter.c b/connectd/gossip_rcvd_filter.c
index c8097a4..5f628c1 100644
--- a/connectd/gossip_rcvd_filter.c
+++ b/connectd/gossip_rcvd_filter.c
@@ -1,9 +1,6 @@
#include "config.h"
-#include <ccan/crypto/siphash24/siphash24.h>
#include <ccan/htable/htable.h>
#include <ccan/ptrint/ptrint.h>
-#include <common/memleak.h>
-#include <common/pseudorand.h>
#include <connectd/gossip_rcvd_filter.h>
#include <wire/peer_wire.h>
diff --git a/connectd/multiplex.c b/connectd/multiplex.c
index 77cdfd5..b657a69 100644
--- a/connectd/multiplex.c
+++ b/connectd/multiplex.c
@@ -1,19 +1,12 @@
/*~ This contains all the code to shuffle data between socket to the peer
* itself, and the subdaemons. */
#include "config.h"
-#include <assert.h>
-#include <bitcoin/block.h>
-#include <bitcoin/chainparams.h>
-#include <ccan/io/io.h>
#include <ccan/tal/str/str.h>
#include <common/cryptomsg.h>
#include <common/daemon_conn.h>
#include <common/dev_disconnect.h>
-#include <common/features.h>
-#include <common/gossip_constants.h>
#include <common/gossmap.h>
#include <common/memleak.h>
-#include <common/per_peer_state.h>
#include <common/ping.h>
#include <common/status.h>
#include <common/timeout.h>
@@ -23,22 +16,15 @@
#include <connectd/connectd_gossipd_wiregen.h>
#include <connectd/connectd_wiregen.h>
#include <connectd/gossip_rcvd_filter.h>
-#include <connectd/gossip_store.h>
#include <connectd/multiplex.h>
#include <connectd/onion_message.h>
#include <connectd/queries.h>
#include <errno.h>
-#include <fcntl.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <wire/peer_wire.h>
-#include <wire/wire.h>
#include <wire/wire_io.h>
-#include <wire/wire_sync.h>
struct subd {
/* Owner: we are in peer->subds[] */
diff --git a/connectd/onion_message.c b/connectd/onion_message.c
index 1a9b42b..27718b7 100644
--- a/connectd/onion_message.c
+++ b/connectd/onion_message.c
@@ -1,14 +1,8 @@
/*~ This contains all the code to handle onion messages. */
#include "config.h"
-#include <ccan/cast/cast.h>
#include <ccan/tal/str/str.h>
-#include <common/blindedpath.h>
-#include <common/blinding.h>
#include <common/daemon_conn.h>
-#include <common/ecdh_hsmd.h>
-#include <common/features.h>
#include <common/onion_message_parse.h>
-#include <common/sphinx.h>
#include <common/status.h>
#include <common/utils.h>
#include <common/wire_error.h>
diff --git a/connectd/peer_exchange_initmsg.c b/connectd/peer_exchange_initmsg.c
index de43633..bbcb6b4 100644
--- a/connectd/peer_exchange_initmsg.c
+++ b/connectd/peer_exchange_initmsg.c
@@ -1,9 +1,7 @@
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <ccan/io/io.h>
#include <common/cryptomsg.h>
#include <common/dev_disconnect.h>
-#include <common/memleak.h>
#include <common/status.h>
#include <common/utils.h>
#include <common/wire_error.h>
diff --git a/connectd/queries.c b/connectd/queries.c
index 351c469..59f2bf5 100644
--- a/connectd/queries.c
+++ b/connectd/queries.c
@@ -1,10 +1,8 @@
/* Routines to handle gossip query messages */
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <ccan/array_size/array_size.h>
#include <ccan/asort/asort.h>
#include <ccan/crc32c/crc32c.h>
-#include <common/daemon_conn.h>
#include <common/decode_array.h>
#include <common/gossmap.h>
#include <common/status.h>
diff --git a/connectd/test/run-gossip_rcvd_filter.c b/connectd/test/run-gossip_rcvd_filter.c
index b46dc4c..3011917 100644
--- a/connectd/test/run-gossip_rcvd_filter.c
+++ b/connectd/test/run-gossip_rcvd_filter.c
@@ -8,12 +8,6 @@
/* AUTOGENERATED MOCKS START */
/* AUTOGENERATED MOCKS END */
-void memleak_add_helper_(const tal_t *p UNNEEDED,
- void (*cb)(struct htable *memtable,
- const tal_t *) UNNEEDED)
-{
-}
-
static u8 *mkgossip(const tal_t *ctx, const char *str)
{
return tal_hexdata(ctx, str, strlen(str));
diff --git a/connectd/websocketd.c b/connectd/websocketd.c
index 7825304..d139199 100644
--- a/connectd/websocketd.c
+++ b/connectd/websocketd.c
@@ -8,15 +8,10 @@
#include <ccan/io/io.h>
#include <ccan/mem/mem.h>
#include <ccan/read_write_all/read_write_all.h>
-#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
#include <common/setup.h>
#include <common/utils.h>
#include <connectd/sha1.h>
-#include <poll.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <unistd.h>
/*
0 1 2 3
diff --git a/db/bindings.c b/db/bindings.c
index ceb251f..8dac3ea 100644
--- a/db/bindings.c
+++ b/db/bindings.c
@@ -2,12 +2,9 @@
#include <bitcoin/privkey.h>
#include <bitcoin/psbt.h>
#include <ccan/mem/mem.h>
-#include <ccan/take/take.h>
#include <ccan/tal/str/str.h>
-#include <ccan/tal/tal.h>
#include <common/channel_id.h>
#include <common/channel_type.h>
-#include <common/htlc_state.h>
#include <common/node_id.h>
#include <common/onionreply.h>
#include <db/bindings.h>
diff --git a/db/db_sqlite3.c b/db/db_sqlite3.c
index c34acc5..5df248b 100644
--- a/db/db_sqlite3.c
+++ b/db/db_sqlite3.c
@@ -1,7 +1,5 @@
#include "config.h"
#include <ccan/ccan/tal/str/str.h>
-#include <common/utils.h>
-#include <db/bindings.h>
#include <db/common.h>
#include <db/exec.h>
#include <db/utils.h>
diff --git a/db/exec.c b/db/exec.c
index c6e6471..5ab6e9b 100644
--- a/db/exec.c
+++ b/db/exec.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <ccan/tal/tal.h>
#include <db/bindings.h>
#include <db/common.h>
#include <db/exec.h>
diff --git a/db/utils.c b/db/utils.c
index 3b896f9..25bce2f 100644
--- a/db/utils.c
+++ b/db/utils.c
@@ -2,7 +2,6 @@
#include <ccan/strset/strset.h>
#include <ccan/tal/str/str.h>
#include <common/trace.h>
-#include <common/utils.h>
#include <db/common.h>
#include <db/utils.h>
diff --git a/devtools/bip137-verifysignature.c b/devtools/bip137-verifysignature.c
index 48db7b9..761f6ce 100644
--- a/devtools/bip137-verifysignature.c
+++ b/devtools/bip137-verifysignature.c
@@ -1,8 +1,5 @@
#include "config.h"
-#include <assert.h>
-#include <bitcoin/base58.h>
#include <bitcoin/pubkey.h>
-#include <bitcoin/shadouble.h>
#include <bitcoin/varint.h>
#include <ccan/err/err.h>
#include <common/addr.h>
diff --git a/devtools/bolt12-cli.c b/devtools/bolt12-cli.c
index 0aa6adc..9d8e0b6 100644
--- a/devtools/bolt12-cli.c
+++ b/devtools/bolt12-cli.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <bitcoin/tx.h>
#include <ccan/array_size/array_size.h>
#include <ccan/err/err.h>
@@ -7,14 +6,12 @@
#include <ccan/tal/str/str.h>
#include <common/bech32_util.h>
#include <common/bolt12_merkle.h>
-#include <common/configdir.h>
#include <common/features.h>
#include <common/iso4217.h>
#include <common/setup.h>
#include <common/utils.h>
#include <common/version.h>
#include <inttypes.h>
-#include <secp256k1_schnorrsig.h>
#include <stdio.h>
#include <time.h>
diff --git a/devtools/checkchannels.c b/devtools/checkchannels.c
index 235b110..144646f 100644
--- a/devtools/checkchannels.c
+++ b/devtools/checkchannels.c
@@ -5,7 +5,6 @@
#include <bitcoin/short_channel_id.h>
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
#include <ccan/err/err.h>
-#include <ccan/mem/mem.h>
#include <ccan/opt/opt.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
diff --git a/devtools/convert-gossmap.c b/devtools/convert-gossmap.c
index 96ea795..c5ee23c 100644
--- a/devtools/convert-gossmap.c
+++ b/devtools/convert-gossmap.c
@@ -1,14 +1,10 @@
/* Tool we can use to convert our testing gossip_store files */
#include "config.h"
-#include <ccan/crc32c/crc32c.h>
#include <ccan/err/err.h>
-#include <ccan/opt/opt.h>
#include <ccan/read_write_all/read_write_all.h>
#include <common/gossip_store.h>
#include <common/utils.h>
-#include <fcntl.h>
#include <gossipd/gossip_store_wiregen.h>
-#include <stdio.h>
#include <unistd.h>
#include <wire/peer_wire.h>
diff --git a/devtools/fp16.c b/devtools/fp16.c
index abf1947..81791b3 100644
--- a/devtools/fp16.c
+++ b/devtools/fp16.c
@@ -1,6 +1,5 @@
/* Simple tool to convert to/from our internal fp16 representation */
#include "config.h"
-#include <ccan/err/err.h>
#include <ccan/opt/opt.h>
#include <common/fp16.h>
#include <common/setup.h>
diff --git a/devtools/gossipwith.c b/devtools/gossipwith.c
index 254e619..a0e55ab 100644
--- a/devtools/gossipwith.c
+++ b/devtools/gossipwith.c
@@ -1,7 +1,5 @@
/* Simple tool to route gossip from a peer. */
#include "config.h"
-#include <bitcoin/block.h>
-#include <bitcoin/chainparams.h>
#include <ccan/array_size/array_size.h>
#include <ccan/err/err.h>
#include <ccan/io/io.h>
@@ -12,14 +10,9 @@
#include <ccan/time/time.h>
#include <common/cryptomsg.h>
#include <common/features.h>
-#include <common/peer_failed.h>
-#include <common/per_peer_state.h>
#include <common/ping.h>
-#include <common/status.h>
#include <inttypes.h>
#include <netdb.h>
-#include <poll.h>
-#include <secp256k1_ecdh.h>
#include <stdio.h>
#include <wire/peer_wire.h>
diff --git a/devtools/gossmap-compress.c b/devtools/gossmap-compress.c
index 58ef255..ac995f9 100644
--- a/devtools/gossmap-compress.c
+++ b/devtools/gossmap-compress.c
@@ -1,15 +1,11 @@
#include "config.h"
-#include <bitcoin/privkey.h>
-#include <bitcoin/pubkey.h>
#include <ccan/asort/asort.h>
-#include <ccan/cast/cast.h>
#include <ccan/crc32c/crc32c.h>
#include <ccan/err/err.h>
#include <ccan/mem/mem.h>
#include <ccan/opt/opt.h>
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/tal/str/str.h>
-#include <common/bigsize.h>
#include <common/gossip_store.h>
#include <common/gossmap.h>
#include <common/setup.h>
diff --git a/devtools/mkcommit.c b/devtools/mkcommit.c
index 3cfe80b..48494ac 100644
--- a/devtools/mkcommit.c
+++ b/devtools/mkcommit.c
@@ -9,7 +9,6 @@
0000000000000000000000000000000000000000000000000000000000000010 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 0000000000000000000000000000000000000000000000000000000000000011 0000000000000000000000000000000000000000000000000000000000000012 0000000000000000000000000000000000000000000000000000000000000013 0000000000000000000000000000000000000000000000000000000000000014
*/
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <bitcoin/script.h>
#include <ccan/cast/cast.h>
#include <ccan/err/err.h>
diff --git a/devtools/onion.c b/devtools/onion.c
index ee2f531..461494a 100644
--- a/devtools/onion.c
+++ b/devtools/onion.c
@@ -7,7 +7,6 @@
#include <ccan/tal/str/str.h>
#include <common/ecdh.h>
#include <common/json_parse.h>
-#include <common/onion_decode.h>
#include <common/onion_encode.h>
#include <common/sphinx.h>
#include <common/utils.h>
diff --git a/devtools/print_wire.c b/devtools/print_wire.c
index ba1285f..a99a495 100644
--- a/devtools/print_wire.c
+++ b/devtools/print_wire.c
@@ -6,7 +6,6 @@
#include <ccan/utf8/utf8.h>
#include <common/channel_id.h>
#include <common/decode_array.h>
-#include <common/sciddir_or_pubkey.h>
#include <common/utils.h>
#include <devtools/print_wire.h>
#include <errno.h>
diff --git a/devtools/rune.c b/devtools/rune.c
index 37322e0..a534dec 100644
--- a/devtools/rune.c
+++ b/devtools/rune.c
@@ -1,11 +1,8 @@
/* Decodes a rune. */
#include "config.h"
-#include <ccan/err/err.h>
#include <ccan/opt/opt.h>
#include <ccan/rune/rune.h>
-#include <common/configdir.h>
#include <common/setup.h>
-#include <common/utils.h>
#include <common/version.h>
#include <stdio.h>
diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c
index 4d49077..2143625 100644
--- a/gossipd/gossip_store.c
+++ b/gossipd/gossip_store.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <ccan/array_size/array_size.h>
#include <ccan/crc32c/crc32c.h>
#include <ccan/noerr/noerr.h>
#include <ccan/read_write_all/read_write_all.h>
@@ -12,12 +11,9 @@
#include <gossipd/gossip_store.h>
#include <gossipd/gossip_store_wiregen.h>
#include <gossipd/gossipd.h>
-#include <gossipd/gossmap_manage.h>
#include <inttypes.h>
#include <sys/stat.h>
-#include <sys/uio.h>
#include <unistd.h>
-#include <wire/peer_wire.h>
/* Obsolete ZOMBIE bit */
#define GOSSIP_STORE_ZOMBIE_BIT_V13 0x1000U
diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c
index 14b795f..18166ad 100644
--- a/gossipd/gossipd.c
+++ b/gossipd/gossipd.c
@@ -11,29 +11,21 @@
* add complexity to this daemon.
*/
#include "config.h"
-#include <ccan/cast/cast.h>
#include <ccan/tal/str/str.h>
#include <common/daemon_conn.h>
#include <common/ecdh_hsmd.h>
-#include <common/lease_rates.h>
#include <common/memleak.h>
-#include <common/pseudorand.h>
#include <common/status.h>
#include <common/subdaemon.h>
#include <common/timeout.h>
#include <common/utils.h>
#include <common/wire_error.h>
-#include <common/wireaddr.h>
#include <connectd/connectd_gossipd_wiregen.h>
-#include <errno.h>
-#include <gossipd/gossip_store.h>
-#include <gossipd/gossip_store_wiregen.h>
#include <gossipd/gossipd.h>
#include <gossipd/gossipd_wiregen.h>
#include <gossipd/gossmap_manage.h>
#include <gossipd/queries.h>
#include <gossipd/seeker.h>
-#include <sodium/crypto_aead_chacha20poly1305.h>
const struct node_id *peer_node_id(const struct peer *peer)
{
diff --git a/gossipd/gossmap_manage.c b/gossipd/gossmap_manage.c
index 72c94f3..bf4faee 100644
--- a/gossipd/gossmap_manage.c
+++ b/gossipd/gossmap_manage.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <bitcoin/script.h>
#include <ccan/array_size/array_size.h>
-#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/daemon_conn.h>
#include <common/gossip_store.h>
@@ -11,8 +10,6 @@
#include <common/timeout.h>
#include <common/utils.h>
#include <common/wire_error.h>
-#include <errno.h>
-#include <fcntl.h>
#include <gossipd/gossip_store.h>
#include <gossipd/gossip_store_wiregen.h>
#include <gossipd/gossipd.h>
@@ -21,7 +18,6 @@
#include <gossipd/seeker.h>
#include <gossipd/sigcheck.h>
#include <gossipd/txout_failures.h>
-#include <string.h>
struct pending_cannounce {
const u8 *scriptpubkey;
diff --git a/gossipd/queries.c b/gossipd/queries.c
index 8902a5f..e106f47 100644
--- a/gossipd/queries.c
+++ b/gossipd/queries.c
@@ -1,19 +1,10 @@
/* Routines to generate gossip query messages */
#include "config.h"
-#include <bitcoin/chainparams.h>
-#include <ccan/array_size/array_size.h>
-#include <ccan/asort/asort.h>
-#include <ccan/crc32c/crc32c.h>
-#include <common/daemon_conn.h>
#include <common/decode_array.h>
-#include <common/gossmap.h>
#include <common/status.h>
#include <common/utils.h>
#include <common/wire_error.h>
-#include <gossipd/gossip_store.h>
#include <gossipd/gossipd.h>
-#include <gossipd/gossipd_wiregen.h>
-#include <gossipd/gossmap_manage.h>
#include <gossipd/queries.h>
/* BOLT #7:
diff --git a/gossipd/seeker.c b/gossipd/seeker.c
index b822cb7..4ba862e 100644
--- a/gossipd/seeker.c
+++ b/gossipd/seeker.c
@@ -1,7 +1,5 @@
/* This contains the code which actively seeks out gossip from peers */
#include "config.h"
-#include <bitcoin/chainparams.h>
-#include <ccan/array_size/array_size.h>
#include <ccan/asort/asort.h>
#include <ccan/intmap/intmap.h>
#include <ccan/tal/str/str.h>
@@ -9,8 +7,6 @@
#include <common/decode_array.h>
#include <common/gossmap.h>
#include <common/memleak.h>
-#include <common/pseudorand.h>
-#include <common/random_select.h>
#include <common/status.h>
#include <common/timeout.h>
#include <common/utils.h>
diff --git a/gossipd/sigcheck.c b/gossipd/sigcheck.c
index 8897586..9e729c1 100644
--- a/gossipd/sigcheck.c
+++ b/gossipd/sigcheck.c
@@ -3,7 +3,6 @@
#include <bitcoin/signature.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
-#include <common/wire_error.h>
#include <gossipd/sigcheck.h>
/* Verify the signature of a channel_update message */
diff --git a/gossipd/test/run-extended-info.c b/gossipd/test/run-extended-info.c
index 0fee410..417c0eb 100644
--- a/gossipd/test/run-extended-info.c
+++ b/gossipd/test/run-extended-info.c
@@ -1,6 +1,7 @@
#include "config.h"
#include "../queries.c"
+#include <ccan/array_size/array_size.h>
#include <ccan/str/hex/hex.h>
#include <common/blinding.h>
#include <common/channel_type.h>
diff --git a/hsmd/hsmd.c b/hsmd/hsmd.c
index 2d05e65..56f2283 100644
--- a/hsmd/hsmd.c
+++ b/hsmd/hsmd.c
@@ -25,7 +25,6 @@
/*~ _wiregen files are autogenerated by tools/generate-wire.py */
#include <hsmd/libhsmd.h>
#include <hsmd/permissions.h>
-#include <sys/socket.h>
#include <sys/stat.h>
#include <wire/wire_io.h>
diff --git a/lightningd/anchorspend.c b/lightningd/anchorspend.c
index 2dbe10b..a194702 100644
--- a/lightningd/anchorspend.c
+++ b/lightningd/anchorspend.c
@@ -1,23 +1,15 @@
#include "config.h"
-#include <bitcoin/psbt.h>
#include <bitcoin/script.h>
-#include <bitcoin/tx.h>
#include <ccan/asort/asort.h>
-#include <ccan/cast/cast.h>
#include <ccan/mem/mem.h>
-#include <ccan/tal/str/str.h>
#include <channeld/channeld_wiregen.h>
-#include <common/utils.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/anchorspend.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/hsm_control.h>
-#include <lightningd/htlc_end.h>
#include <lightningd/lightningd.h>
-#include <lightningd/log.h>
-#include <lightningd/peer_control.h>
#include <wally_psbt.h>
/* This is attached to each anchor tx retransmission */
diff --git a/lightningd/bitcoind.c b/lightningd/bitcoind.c
index 771ccf2..3e092a5 100644
--- a/lightningd/bitcoind.c
+++ b/lightningd/bitcoind.c
@@ -4,24 +4,15 @@
* standardized and you can use another plugin as the Bitcoin backend, or
* even make your own! */
#include "config.h"
-#include <bitcoin/base58.h>
-#include <bitcoin/block.h>
#include <bitcoin/feerate.h>
#include <bitcoin/script.h>
-#include <bitcoin/shadouble.h>
#include <ccan/array_size/array_size.h>
#include <ccan/io/io.h>
#include <ccan/tal/str/str.h>
-#include <common/configdir.h>
-#include <common/json_parse.h>
-#include <common/memleak.h>
#include <common/trace.h>
-#include <db/exec.h>
#include <lightningd/bitcoind.h>
#include <lightningd/chaintopology.h>
#include <lightningd/io_loop_with_timers.h>
-#include <lightningd/lightningd.h>
-#include <lightningd/log.h>
#include <lightningd/plugin.h>
/* The names of the requests we can make to our Bitcoin backend. */
diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c
index 1baab40..a35e4d0 100644
--- a/lightningd/chaintopology.c
+++ b/lightningd/chaintopology.c
@@ -1,19 +1,13 @@
#include "config.h"
-#include <bitcoin/feerate.h>
#include <bitcoin/script.h>
-#include <bitcoin/tx.h>
#include <ccan/array_size/array_size.h>
#include <ccan/io/io.h>
#include <ccan/tal/str/str.h>
-#include <common/configdir.h>
#include <common/htlc_tx.h>
-#include <common/json_command.h>
-#include <common/json_param.h>
#include <common/memleak.h>
#include <common/timeout.h>
#include <common/trace.h>
#include <db/exec.h>
-#include <lightningd/bitcoind.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/coin_mvts.h>
@@ -21,13 +15,9 @@
#include <lightningd/gossip_control.h>
#include <lightningd/invoice.h>
#include <lightningd/io_loop_with_timers.h>
-#include <lightningd/jsonrpc.h>
-#include <lightningd/lightningd.h>
-#include <lightningd/log.h>
#include <lightningd/notification.h>
#include <math.h>
#include <wallet/txfilter.h>
-#include <wallet/wallet.h>
/* Mutual recursion via timer. */
static void try_extend_tip(struct chain_topology *topo);
diff --git a/lightningd/channel.c b/lightningd/channel.c
index 1390a48..798c7ad 100644
--- a/lightningd/channel.c
+++ b/lightningd/channel.c
@@ -5,20 +5,16 @@
#include <common/fee_states.h>
#include <common/json_command.h>
#include <common/wire_error.h>
-#include <errno.h>
#include <hsmd/hsmd_wiregen.h>
#include <lightningd/channel.h>
#include <lightningd/channel_gossip.h>
#include <lightningd/channel_state_names_gen.h>
#include <lightningd/connect_control.h>
-#include <lightningd/gossip_control.h>
#include <lightningd/hsm_control.h>
#include <lightningd/notification.h>
#include <lightningd/opening_common.h>
-#include <lightningd/peer_control.h>
#include <lightningd/subd.h>
#include <wallet/txfilter.h>
-#include <wire/peer_wire.h>
void channel_set_owner(struct channel *channel, struct subd *owner)
{
diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c
index 93d76a7..a5fb7d4 100644
--- a/lightningd/channel_control.c
+++ b/lightningd/channel_control.c
@@ -1,37 +1,27 @@
#include "config.h"
#include <ccan/asort/asort.h>
#include <ccan/cast/cast.h>
-#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <channeld/channeld_wiregen.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/json_stream.h>
-#include <common/memleak.h>
#include <common/psbt_open.h>
#include <common/shutdown_scriptpubkey.h>
#include <common/wire_error.h>
#include <connectd/connectd_wiregen.h>
#include <errno.h>
-#include <fcntl.h>
#include <hsmd/permissions.h>
-#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/channel_control.h>
#include <lightningd/channel_gossip.h>
#include <lightningd/closing_control.h>
-#include <lightningd/coin_mvts.h>
#include <lightningd/connect_control.h>
#include <lightningd/dual_open_control.h>
#include <lightningd/feerate.h>
-#include <lightningd/gossip_control.h>
#include <lightningd/hsm_control.h>
#include <lightningd/notification.h>
-#include <lightningd/peer_control.h>
#include <lightningd/peer_fd.h>
#include <lightningd/peer_htlcs.h>
-#include <wally_bip32.h>
-#include <wally_psbt.h>
+#include <unistd.h>
struct stfu_result
{
diff --git a/lightningd/channel_gossip.c b/lightningd/channel_gossip.c
index d4153b2..79b12ff 100644
--- a/lightningd/channel_gossip.c
+++ b/lightningd/channel_gossip.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
-#include <ccan/mem/mem.h>
#include <common/memleak.h>
#include <common/timeout.h>
#include <common/wire_error.h>
@@ -13,7 +12,6 @@
#include <lightningd/gossip_generation.h>
#include <lightningd/hsm_control.h>
#include <lightningd/lightningd.h>
-#include <lightningd/peer_control.h>
#include <lightningd/subd.h>
enum channel_gossip_state {
diff --git a/lightningd/closed_channel.c b/lightningd/closed_channel.c
index dd85f4f..73b572f 100644
--- a/lightningd/closed_channel.c
+++ b/lightningd/closed_channel.c
@@ -1,14 +1,9 @@
#include "config.h"
#include <common/json_channel_type.h>
-#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/json_stream.h>
#include <lightningd/channel.h>
#include <lightningd/closed_channel.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
-#include <lightningd/peer_control.h>
-#include <wallet/wallet.h>
size_t hash_cid(const struct channel_id *cid)
{
diff --git a/lightningd/closing_control.c b/lightningd/closing_control.c
index dbf604b..c3f2d7b 100644
--- a/lightningd/closing_control.c
+++ b/lightningd/closing_control.c
@@ -1,27 +1,15 @@
#include "config.h"
-#include <bitcoin/feerate.h>
#include <bitcoin/script.h>
-#include <ccan/cast/cast.h>
-#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <channeld/channeld_wiregen.h>
#include <closingd/closingd_wiregen.h>
-#include <common/close_tx.h>
#include <common/closing_fee.h>
-#include <common/configdir.h>
-#include <common/fee_states.h>
-#include <common/initial_commit_tx.h>
#include <common/json_command.h>
-#include <common/json_param.h>
#include <common/shutdown_scriptpubkey.h>
#include <common/timeout.h>
-#include <common/utils.h>
-#include <connectd/connectd_wiregen.h>
#include <errno.h>
-#include <gossipd/gossipd_wiregen.h>
#include <hsmd/permissions.h>
#include <inttypes.h>
-#include <lightningd/bitcoind.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/closing_control.h>
@@ -31,14 +19,9 @@
#include <lightningd/hsm_control.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
-#include <lightningd/log.h>
#include <lightningd/opening_common.h>
-#include <lightningd/options.h>
-#include <lightningd/peer_control.h>
#include <lightningd/peer_fd.h>
-#include <lightningd/subd.h>
#include <openingd/dualopend_wiregen.h>
-#include <wally_bip32.h>
struct close_command {
/* Inside struct lightningd close_commands. */
diff --git a/lightningd/coin_mvts.c b/lightningd/coin_mvts.c
index cc206b6..dcbc305 100644
--- a/lightningd/coin_mvts.c
+++ b/lightningd/coin_mvts.c
@@ -1,11 +1,9 @@
#include "config.h"
-#include <ccan/array_size/array_size.h>
#include <ccan/tal/str/str.h>
#include <common/json_command.h>
#include <lightningd/channel.h>
#include <lightningd/coin_mvts.h>
#include <lightningd/notification.h>
-#include <lightningd/peer_control.h>
struct channel_coin_mvt *new_channel_mvt_invoice_hin(const tal_t *ctx,
diff --git a/lightningd/configs.c b/lightningd/configs.c
index 0585717..553daff 100644
--- a/lightningd/configs.c
+++ b/lightningd/configs.c
@@ -10,12 +10,8 @@
#include <common/configdir.h>
#include <common/configvar.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/version.h>
#include <errno.h>
#include <fcntl.h>
-#include <lightningd/jsonrpc.h>
-#include <lightningd/options.h>
#include <lightningd/plugin.h>
#include <unistd.h>
diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c
index 437beaa..d426811 100644
--- a/lightningd/connect_control.c
+++ b/lightningd/connect_control.c
@@ -1,27 +1,17 @@
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <ccan/err/err.h>
#include <ccan/io/io.h>
#include <ccan/tal/str/str.h>
-#include <common/configdir.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/memleak.h>
-#include <common/timeout.h>
#include <connectd/connectd_wiregen.h>
-#include <gossipd/gossipd_wiregen.h>
#include <hsmd/permissions.h>
#include <lightningd/channel.h>
-#include <lightningd/channel_gossip.h>
#include <lightningd/connect_control.h>
#include <lightningd/dual_open_control.h>
#include <lightningd/hsm_control.h>
-#include <lightningd/lightningd.h>
#include <lightningd/notification.h>
#include <lightningd/onion_message.h>
#include <lightningd/opening_common.h>
-#include <lightningd/opening_control.h>
-#include <lightningd/peer_control.h>
#include <lightningd/ping.h>
#include <lightningd/plugin_hook.h>
diff --git a/lightningd/datastore.c b/lightningd/datastore.c
index f3ecfc6..8ccb533 100644
--- a/lightningd/datastore.c
+++ b/lightningd/datastore.c
@@ -1,8 +1,6 @@
#include "config.h"
#include <ccan/tal/str/str.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/json_stream.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c
index 8e6a651..1dc4c6a 100644
--- a/lightningd/dual_open_control.c
+++ b/lightningd/dual_open_control.c
@@ -3,7 +3,6 @@
* saves and funding tx watching for a channel open */
#include "config.h"
-#include <bitcoin/short_channel_id.h>
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
#include <ccan/mem/mem.h>
@@ -11,14 +10,12 @@
#include <common/blockheight_states.h>
#include <common/json_channel_type.h>
#include <common/json_command.h>
-#include <common/json_param.h>
#include <common/psbt_open.h>
#include <common/shutdown_scriptpubkey.h>
#include <common/wire_error.h>
#include <connectd/connectd_wiregen.h>
#include <errno.h>
#include <hsmd/permissions.h>
-#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/channel_control.h>
#include <lightningd/channel_gossip.h>
@@ -26,14 +23,13 @@
#include <lightningd/connect_control.h>
#include <lightningd/dual_open_control.h>
#include <lightningd/feerate.h>
-#include <lightningd/gossip_control.h>
#include <lightningd/hsm_control.h>
#include <lightningd/notification.h>
#include <lightningd/opening_common.h>
-#include <lightningd/peer_control.h>
#include <lightningd/peer_fd.h>
#include <lightningd/plugin_hook.h>
#include <openingd/dualopend_wiregen.h>
+#include <unistd.h>
struct commit_rcvd {
struct channel *channel;
diff --git a/lightningd/feerate.c b/lightningd/feerate.c
index 56b0e82..78027a5 100644
--- a/lightningd/feerate.c
+++ b/lightningd/feerate.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <common/configdir.h>
#include <common/json_command.h>
#include <lightningd/chaintopology.h>
#include <lightningd/feerate.h>
diff --git a/lightningd/forwards.c b/lightningd/forwards.c
index ecb1409..6c86d50 100644
--- a/lightningd/forwards.c
+++ b/lightningd/forwards.c
@@ -2,14 +2,10 @@
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/json_stream.h>
#include <inttypes.h>
#include <lightningd/forwards.h>
-#include <lightningd/htlc_end.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
-#include <wallet/wallet.h>
static u64 forward_index_inc(struct lightningd *ld,
enum forward_status status,
diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c
index 207e41b..6b484a7 100644
--- a/lightningd/gossip_control.c
+++ b/lightningd/gossip_control.c
@@ -1,29 +1,17 @@
#include "config.h"
#include <ccan/err/err.h>
#include <ccan/io/io.h>
-#include <ccan/mem/mem.h>
#include <ccan/ptrint/ptrint.h>
-#include <channeld/channeld_wiregen.h>
-#include <common/daemon.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/json_stream.h>
-#include <common/node_id.h>
-#include <common/timeout.h>
#include <connectd/connectd_wiregen.h>
-#include <gossipd/gossipd_wiregen.h>
-#include <hsmd/hsmd_wiregen.h>
#include <hsmd/permissions.h>
-#include <lightningd/bitcoind.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
-#include <lightningd/channel_control.h>
#include <lightningd/channel_gossip.h>
#include <lightningd/gossip_control.h>
#include <lightningd/hsm_control.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
-#include <lightningd/peer_control.h>
#include <lightningd/subd.h>
static void got_txout(struct bitcoind *bitcoind,
diff --git a/lightningd/gossip_generation.c b/lightningd/gossip_generation.c
index 22877c9..7a59f0e 100644
--- a/lightningd/gossip_generation.c
+++ b/lightningd/gossip_generation.c
@@ -1,14 +1,9 @@
#include "config.h"
#include <ccan/cast/cast.h>
#include <ccan/mem/mem.h>
-#include <common/features.h>
-#include <common/htlc.h>
-#include <common/node_id.h>
#include <lightningd/channel.h>
#include <lightningd/gossip_generation.h>
#include <lightningd/lightningd.h>
-#include <lightningd/peer_control.h>
-#include <wire/peer_wire.h>
/* Once we know which way nodes go, it's easy to construct */
static u8 *create_channel_announcement_dir(const tal_t *ctx,
diff --git a/lightningd/hsm_control.c b/lightningd/hsm_control.c
index 7c0c658..599ef40 100644
--- a/lightningd/hsm_control.c
+++ b/lightningd/hsm_control.c
@@ -2,22 +2,17 @@
#include <ccan/err/err.h>
#include <ccan/fdpass/fdpass.h>
#include <common/bolt12_id.h>
-#include <common/ecdh.h>
#include <common/errcode.h>
#include <common/hsm_capable.h>
#include <common/hsm_encryption.h>
#include <common/hsm_version.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/jsonrpc_errors.h>
#include <errno.h>
#include <hsmd/hsmd_wiregen.h>
#include <lightningd/hsm_control.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
#include <lightningd/subd.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
#include <wally_bip32.h>
#include <wire/wire_sync.h>
diff --git a/lightningd/htlc_end.c b/lightningd/htlc_end.c
index b557808..e2a0617 100644
--- a/lightningd/htlc_end.c
+++ b/lightningd/htlc_end.c
@@ -1,14 +1,10 @@
#include "config.h"
#include <ccan/cast/cast.h>
-#include <ccan/crypto/siphash24/siphash24.h>
#include <ccan/tal/str/str.h>
-#include <common/htlc.h>
#include <common/htlc_wire.h>
-#include <common/pseudorand.h>
#include <common/utils.h>
#include <lightningd/htlc_end.h>
#include <lightningd/log.h>
-#include <wire/tlvstream.h>
size_t hash_htlc_key(const struct htlc_key *k)
{
diff --git a/lightningd/htlc_set.c b/lightningd/htlc_set.c
index 4767767..5d2531f 100644
--- a/lightningd/htlc_set.c
+++ b/lightningd/htlc_set.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <common/features.h>
#include <common/timeout.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
diff --git a/lightningd/invoice.c b/lightningd/invoice.c
index 31362ab..dfdf633 100644
--- a/lightningd/invoice.c
+++ b/lightningd/invoice.c
@@ -2,7 +2,6 @@
#include <bitcoin/script.h>
#include <ccan/array_size/array_size.h>
#include <ccan/asort/asort.h>
-#include <ccan/cast/cast.h>
#include <ccan/json_escape/json_escape.h>
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
@@ -10,14 +9,9 @@
#include <common/bolt11_json.h>
#include <common/bolt12_id.h>
#include <common/bolt12_merkle.h>
-#include <common/configdir.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/overflows.h>
#include <common/random_select.h>
#include <common/timeout.h>
-#include <db/exec.h>
-#include <errno.h>
#include <hsmd/hsmd_wiregen.h>
#include <lightningd/channel.h>
#include <lightningd/hsm_control.h>
@@ -27,10 +21,8 @@
#include <lightningd/plugin_hook.h>
#include <lightningd/routehint.h>
#include <sodium/randombytes.h>
-#include <stdio.h>
#include <wallet/invoices.h>
#include <wallet/walletrpc.h>
-#include <wire/wire_sync.h>
const char *invoice_status_str(enum invoice_status state)
{
diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c
index 7370ad7..95d32cb 100644
--- a/lightningd/jsonrpc.c
+++ b/lightningd/jsonrpc.c
@@ -23,11 +23,8 @@
#include <ccan/tal/path/path.h>
#include <ccan/tal/str/str.h>
#include <common/codex32.h>
-#include <common/configdir.h>
-#include <common/deprecation.h>
#include <common/json_command.h>
#include <common/json_filter.h>
-#include <common/json_param.h>
#include <common/memleak.h>
#include <common/timeout.h>
#include <common/trace.h>
@@ -36,11 +33,7 @@
#include <errno.h>
#include <fcntl.h>
#include <lightningd/jsonrpc.h>
-#include <lightningd/options.h>
#include <lightningd/plugin_hook.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/un.h>
/* Dummy structure. */
diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c
index 7044d97..8eb3acc 100644
--- a/lightningd/lightningd.c
+++ b/lightningd/lightningd.c
@@ -39,7 +39,6 @@
#include <ccan/closefrom/closefrom.h>
#include <ccan/io/io.h>
#include <ccan/json_escape/json_escape.h>
-#include <ccan/opt/opt.h>
#include <ccan/pipecmd/pipecmd.h>
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/tal/grab_file/grab_file.h>
@@ -48,13 +47,11 @@
/*~ This is common code: routines shared by one or more executables
* (separate daemons, or the lightning-cli program). */
-#include <common/configdir.h>
#include <common/daemon.h>
#include <common/deprecation.h>
#include <common/ecdh_hsmd.h>
#include <common/errcode.h>
#include <common/hsm_encryption.h>
-#include <common/json_stream.h>
#include <common/memleak.h>
#include <common/timeout.h>
#include <common/trace.h>
@@ -64,13 +61,11 @@
#include <errno.h>
#include <fcntl.h>
#include <header_versions_gen.h>
-#include <hsmd/hsmd_wiregen.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/channel_control.h>
#include <lightningd/channel_gossip.h>
#include <lightningd/closed_channel.h>
-#include <lightningd/coin_mvts.h>
#include <lightningd/connect_control.h>
#include <lightningd/gossip_control.h>
#include <lightningd/hsm_control.h>
@@ -78,7 +73,6 @@
#include <lightningd/lightningd.h>
#include <lightningd/onchain_control.h>
#include <lightningd/peer_htlcs.h>
-#include <lightningd/plugin.h>
#include <lightningd/plugin_hook.h>
#include <lightningd/runes.h>
#include <lightningd/subd.h>
diff --git a/lightningd/log.c b/lightningd/log.c
index 9775e79..5b5bcd5 100644
--- a/lightningd/log.c
+++ b/lightningd/log.c
@@ -7,13 +7,11 @@
#include <ccan/tal/str/str.h>
#include <common/configvar.h>
#include <common/json_command.h>
-#include <common/json_param.h>
#include <common/memleak.h>
#include <errno.h>
#include <fcntl.h>
#include <lightningd/log.h>
#include <lightningd/notification.h>
-#include <signal.h>
#include <stdio.h>
/* What logging level to use if they didn't specify */
diff --git a/lightningd/memdump.c b/lightningd/memdump.c
index b2f32a1..2372ab0 100644
--- a/lightningd/memdump.c
+++ b/lightningd/memdump.c
@@ -3,12 +3,9 @@
#include <backtrace.h>
#include <ccan/tal/str/str.h>
#include <common/json_command.h>
-#include <common/json_param.h>
#include <common/memleak.h>
#include <common/timeout.h>
#include <connectd/connectd_wiregen.h>
-#include <errno.h>
-#include <gossipd/gossipd_wiregen.h>
#include <hsmd/hsmd_wiregen.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
@@ -17,8 +14,6 @@
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
#include <lightningd/memdump.h>
-#include <lightningd/opening_common.h>
-#include <lightningd/peer_control.h>
#include <lightningd/subd.h>
static void json_add_ptr(struct json_stream *response, const char *name,
diff --git a/lightningd/notification.c b/lightningd/notification.c
index 75134ec..73a689b 100644
--- a/lightningd/notification.c
+++ b/lightningd/notification.c
@@ -1,9 +1,7 @@
#include "config.h"
#include <ccan/cast/cast.h>
-#include <common/configdir.h>
#include <lightningd/channel.h>
#include <lightningd/coin_mvts.h>
-#include <lightningd/log.h>
#include <lightningd/notification.h>
bool notifications_topic_is_native(const char *topic)
diff --git a/lightningd/offer.c b/lightningd/offer.c
index 9b26d75..dd8871c 100644
--- a/lightningd/offer.c
+++ b/lightningd/offer.c
@@ -1,20 +1,13 @@
#include "config.h"
#include <ccan/cast/cast.h>
-#include <ccan/json_escape/json_escape.h>
-#include <ccan/take/take.h>
#include <common/bolt12_id.h>
#include <common/bolt12_merkle.h>
-#include <common/configdir.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/json_stream.h>
-#include <errno.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/hsm_control.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
-#include <secp256k1_schnorrsig.h>
static void json_populate_offer(struct json_stream *response,
const struct sha256 *offer_id,
diff --git a/lightningd/onchain_control.c b/lightningd/onchain_control.c
index b82523a..09d5d89 100644
--- a/lightningd/onchain_control.c
+++ b/lightningd/onchain_control.c
@@ -4,7 +4,6 @@
#include <ccan/cast/cast.h>
#include <ccan/tal/str/str.h>
#include <common/htlc_tx.h>
-#include <common/key_derive.h>
#include <common/memleak.h>
#include <common/psbt_keypath.h>
#include <db/exec.h>
@@ -18,15 +17,10 @@
#include <lightningd/coin_mvts.h>
#include <lightningd/hsm_control.h>
#include <lightningd/onchain_control.h>
-#include <lightningd/peer_control.h>
#include <lightningd/peer_htlcs.h>
#include <lightningd/subd.h>
#include <onchaind/onchaind_wiregen.h>
#include <wallet/txfilter.h>
-#include <wallet/wallet.h>
-#include <wally_bip32.h>
-#include <wally_psbt.h>
-#include <wire/wire_sync.h>
/* If we're restarting, we keep a per-channel copy of watches, and replay */
struct replay_tx {
diff --git a/lightningd/onion_message.c b/lightningd/onion_message.c
index 6c09498..70efb66 100644
--- a/lightningd/onion_message.c
+++ b/lightningd/onion_message.c
@@ -1,18 +1,12 @@
#include "config.h"
-#include <ccan/mem/mem.h>
#include <common/blindedpath.h>
#include <common/blinding.h>
-#include <common/configdir.h>
#include <common/ecdh.h>
#include <common/json_command.h>
-#include <common/json_param.h>
#include <connectd/connectd_wiregen.h>
-#include <lightningd/channel.h>
#include <lightningd/onion_message.h>
-#include <lightningd/peer_control.h>
#include <lightningd/plugin_hook.h>
#include <lightningd/subd.h>
-#include <sodium/randombytes.h>
struct onion_message_hook_payload {
/* Optional */
diff --git a/lightningd/opening_common.c b/lightningd/opening_common.c
index 79f7867..5b03d2a 100644
--- a/lightningd/opening_common.c
+++ b/lightningd/opening_common.c
@@ -1,19 +1,12 @@
#include "config.h"
#include <ccan/ccan/tal/str/str.h>
#include <common/json_command.h>
-#include <common/wire_error.h>
-#include <errno.h>
#include <hsmd/hsmd_wiregen.h>
#include <lightningd/channel.h>
-#include <lightningd/channel_control.h>
-#include <lightningd/connect_control.h>
#include <lightningd/hsm_control.h>
#include <lightningd/notification.h>
#include <lightningd/opening_common.h>
-#include <lightningd/peer_control.h>
-#include <lightningd/peer_fd.h>
#include <lightningd/subd.h>
-#include <openingd/openingd_wiregen.h>
static void destroy_uncommitted_channel(struct uncommitted_channel *uc)
{
diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c
index ffd6cab..8570160 100644
--- a/lightningd/opening_control.c
+++ b/lightningd/opening_control.c
@@ -1,22 +1,17 @@
#include "config.h"
-#include <bitcoin/feerate.h>
#include <bitcoin/psbt.h>
#include <ccan/cast/cast.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/addr.h>
#include <common/blockheight_states.h>
-#include <common/configdir.h>
#include <common/fee_states.h>
#include <common/json_channel_type.h>
#include <common/json_command.h>
-#include <common/json_param.h>
#include <common/memleak.h>
-#include <common/scb_wiregen.h>
#include <connectd/connectd_wiregen.h>
#include <errno.h>
#include <hsmd/permissions.h>
-#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/channel_control.h>
#include <lightningd/connect_control.h>
@@ -29,6 +24,7 @@
#include <lightningd/plugin_hook.h>
#include <lightningd/subd.h>
#include <openingd/openingd_wiregen.h>
+#include <unistd.h>
#include <wally_psbt.h>
void json_add_uncommitted_channel(struct command *cmd,
diff --git a/lightningd/options.c b/lightningd/options.c
index 5f84b72..1ef5d1f 100644
--- a/lightningd/options.c
+++ b/lightningd/options.c
@@ -2,38 +2,29 @@
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
#include <ccan/err/err.h>
-#include <ccan/json_escape/json_escape.h>
-#include <ccan/mem/mem.h>
#include <ccan/noerr/noerr.h>
#include <ccan/opt/opt.h>
-#include <ccan/opt/private.h>
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/str/hex/hex.h>
-#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
#include <ccan/tal/str/str.h>
#include <common/codex32.h>
#include <common/configdir.h>
#include <common/configvar.h>
#include <common/errcode.h>
-#include <common/features.h>
#include <common/hsm_encryption.h>
-#include <common/json_command.h>
-#include <common/json_param.h>
#include <common/version.h>
-#include <common/wireaddr.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <hsmd/hsmd_wiregen.h>
#include <lightningd/chaintopology.h>
#include <lightningd/feerate.h>
-#include <lightningd/hsm_control.h>
#include <lightningd/options.h>
#include <lightningd/plugin.h>
#include <lightningd/subd.h>
-#include <sys/stat.h>
#include <sys/wait.h>
+#include <unistd.h>
/* FIXME: Put into ccan/time. */
#define TIME_FROM_SEC(sec) { { .tv_nsec = 0, .tv_sec = sec } }
diff --git a/lightningd/pay.c b/lightningd/pay.c
index bd85e73..c1b2771 100644
--- a/lightningd/pay.c
+++ b/lightningd/pay.c
@@ -4,19 +4,15 @@
#include <ccan/tal/str/str.h>
#include <common/blinding.h>
#include <common/bolt12_merkle.h>
-#include <common/configdir.h>
#include <common/json_command.h>
-#include <common/json_param.h>
#include <common/onion_decode.h>
#include <common/onionreply.h>
#include <common/route.h>
#include <common/timeout.h>
-#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/invoice.h>
#include <lightningd/notification.h>
#include <lightningd/pay.h>
-#include <lightningd/peer_control.h>
#include <lightningd/peer_htlcs.h>
#include <wallet/invoices.h>
diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c
index 98f596b..7ecd01a 100644
--- a/lightningd/peer_control.c
+++ b/lightningd/peer_control.c
@@ -1,46 +1,22 @@
#include "config.h"
-#include <arpa/inet.h>
#include <bitcoin/feerate.h>
#include <bitcoin/script.h>
-#include <bitcoin/tx.h>
#include <ccan/array_size/array_size.h>
#include <ccan/asort/asort.h>
-#include <ccan/cast/cast.h>
-#include <ccan/io/io.h>
-#include <ccan/mem/mem.h>
-#include <ccan/noerr/noerr.h>
-#include <ccan/str/str.h>
-#include <ccan/take/take.h>
#include <ccan/tal/str/str.h>
#include <channeld/channeld_wiregen.h>
#include <common/addr.h>
-#include <common/closing_fee.h>
-#include <common/configdir.h>
-#include <common/dev_disconnect.h>
-#include <common/features.h>
#include <common/htlc_trim.h>
#include <common/initial_commit_tx.h>
#include <common/json_channel_type.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/jsonrpc_errors.h>
-#include <common/key_derive.h>
-#include <common/scb_wiregen.h>
-#include <common/shutdown_scriptpubkey.h>
-#include <common/status.h>
#include <common/timeout.h>
-#include <common/utils.h>
#include <common/version.h>
#include <common/wire_error.h>
#include <connectd/connectd_wiregen.h>
#include <errno.h>
-#include <fcntl.h>
-#include <gossipd/gossipd_wiregen.h>
#include <hsmd/hsmd_wiregen.h>
-#include <inttypes.h>
#include <lightningd/anchorspend.h>
-#include <lightningd/bitcoind.h>
-#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/channel_control.h>
#include <lightningd/channel_gossip.h>
@@ -48,30 +24,20 @@
#include <lightningd/closing_control.h>
#include <lightningd/connect_control.h>
#include <lightningd/dual_open_control.h>
-#include <lightningd/gossip_control.h>
#include <lightningd/hsm_control.h>
-#include <lightningd/jsonrpc.h>
-#include <lightningd/lightningd.h>
-#include <lightningd/log.h>
#include <lightningd/memdump.h>
#include <lightningd/notification.h>
#include <lightningd/onchain_control.h>
#include <lightningd/opening_common.h>
#include <lightningd/opening_control.h>
-#include <lightningd/options.h>
#include <lightningd/peer_control.h>
#include <lightningd/peer_fd.h>
#include <lightningd/peer_htlcs.h>
#include <lightningd/plugin_hook.h>
-#include <lightningd/subd.h>
-#include <limits.h>
#include <onchaind/onchaind_wiregen.h>
#include <openingd/dualopend_wiregen.h>
#include <openingd/openingd_wiregen.h>
-#include <stdlib.h>
#include <unistd.h>
-#include <wally_bip32.h>
-#include <wire/wire_sync.h>
/* FIXME: Reorder! */
static void peer_disconnected(struct lightningd *ld,
diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c
index da93db8..6dea601 100644
--- a/lightningd/peer_htlcs.c
+++ b/lightningd/peer_htlcs.c
@@ -3,32 +3,20 @@
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <channeld/channeld_wiregen.h>
-#include <common/bigsize.h>
#include <common/blinding.h>
-#include <common/configdir.h>
#include <common/ecdh.h>
#include <common/json_command.h>
-#include <common/json_param.h>
#include <common/onion_decode.h>
#include <common/onionreply.h>
#include <common/timeout.h>
-#include <connectd/connectd_wiregen.h>
#include <db/exec.h>
-#include <gossipd/gossipd_wiregen.h>
-#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/coin_mvts.h>
#include <lightningd/notification.h>
-#include <lightningd/pay.h>
-#include <lightningd/peer_control.h>
#include <lightningd/peer_htlcs.h>
#include <lightningd/plugin_hook.h>
#include <lightningd/subd.h>
#include <onchaind/onchaind_wiregen.h>
-#include <stdio.h>
-#include <wire/onion_wiregen.h>
-#include <wire/peer_wiregen.h>
-#include <wire/tlvstream.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
diff --git a/lightningd/ping.c b/lightningd/ping.c
index 45ceb33..b348eec 100644
--- a/lightningd/ping.c
+++ b/lightningd/ping.c
@@ -1,12 +1,9 @@
#include "config.h"
#include <common/json_command.h>
-#include <common/json_param.h>
#include <connectd/connectd_wiregen.h>
#include <inttypes.h>
-#include <lightningd/channel.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
-#include <lightningd/peer_control.h>
#include <lightningd/ping.h>
#include <lightningd/subd.h>
diff --git a/lightningd/plugin.c b/lightningd/plugin.c
index 42718c2..cb38c84 100644
--- a/lightningd/plugin.c
+++ b/lightningd/plugin.c
@@ -5,17 +5,13 @@
#include <ccan/io/io.h>
#include <ccan/json_escape/json_escape.h>
#include <ccan/json_out/json_out.h>
-#include <ccan/mem/mem.h>
-#include <ccan/opt/opt.h>
#include <ccan/pipecmd/pipecmd.h>
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/tal/path/path.h>
#include <ccan/tal/str/str.h>
#include <ccan/utf8/utf8.h>
-#include <common/configdir.h>
#include <common/configvar.h>
#include <common/deprecation.h>
-#include <common/features.h>
#include <common/json_command.h>
#include <common/memleak.h>
#include <common/plugin.h>
@@ -32,7 +28,6 @@
#include <lightningd/plugin_control.h>
#include <lightningd/plugin_hook.h>
#include <lightningd/subd.h>
-#include <sys/stat.h>
/* Only this file can include this generated header! */
# include <plugins/list_of_builtin_plugins_gen.h>
diff --git a/lightningd/plugin_control.c b/lightningd/plugin_control.c
index 2f8bb4e..89073f9 100644
--- a/lightningd/plugin_control.c
+++ b/lightningd/plugin_control.c
@@ -2,7 +2,6 @@
#include <ccan/tal/path/path.h>
#include <ccan/tal/str/str.h>
#include <common/json_command.h>
-#include <common/json_param.h>
#include <common/memleak.h>
#include <common/timeout.h>
#include <errno.h>
diff --git a/lightningd/plugin_hook.c b/lightningd/plugin_hook.c
index cd69b79..934fa16 100644
--- a/lightningd/plugin_hook.c
+++ b/lightningd/plugin_hook.c
@@ -1,7 +1,5 @@
#include "config.h"
#include <ccan/io/io.h>
-#include <ccan/tal/str/str.h>
-#include <common/json_parse.h>
#include <common/memleak.h>
#include <db/exec.h>
#include <db/utils.h>
diff --git a/lightningd/routehint.c b/lightningd/routehint.c
index 5c0d80a..27264f6 100644
--- a/lightningd/routehint.c
+++ b/lightningd/routehint.c
@@ -1,10 +1,6 @@
#include "config.h"
-#include <common/bolt11.h>
-#include <common/json_parse.h>
-#include <gossipd/gossipd_wiregen.h>
#include <lightningd/channel.h>
#include <lightningd/lightningd.h>
-#include <lightningd/peer_control.h>
#include <lightningd/routehint.h>
static bool scid_in_arr(const struct short_channel_id *scidarr,
diff --git a/lightningd/runes.c b/lightningd/runes.c
index 9085497..70821bc 100644
--- a/lightningd/runes.c
+++ b/lightningd/runes.c
@@ -2,24 +2,16 @@
#include <ccan/array_size/array_size.h>
#include <ccan/bitmap/bitmap.h>
#include <ccan/json_escape/json_escape.h>
-#include <ccan/rune/rune.h>
#include <ccan/tal/str/str.h>
#include <common/bolt12.h>
-#include <common/configdir.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/json_stream.h>
-#include <common/memleak.h>
#include <common/overflows.h>
-#include <common/timeout.h>
-#include <db/exec.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/hsm_control.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
#include <lightningd/runes.h>
-#include <wallet/wallet.h>
/* "640k should be enough for anybody!" */
#define MAX_BLACKLIST_NUM 100000000
diff --git a/lightningd/signmessage.c b/lightningd/signmessage.c
index 7ecc842..b13e4f8 100644
--- a/lightningd/signmessage.c
+++ b/lightningd/signmessage.c
@@ -1,9 +1,6 @@
#include "config.h"
#include <common/bech32.h>
-#include <common/configdir.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <errno.h>
#include <hsmd/hsmd_wiregen.h>
#include <lightningd/hsm_control.h>
#include <lightningd/plugin.h>
diff --git a/lightningd/subd.c b/lightningd/subd.c
index c3f59f0..744d615 100644
--- a/lightningd/subd.c
+++ b/lightningd/subd.c
@@ -18,7 +18,6 @@
#include <lightningd/log_status.h>
#include <lightningd/peer_fd.h>
#include <lightningd/subd.h>
-#include <sys/socket.h>
#include <sys/wait.h>
#include <wire/wire_io.h>
diff --git a/lightningd/test/run-find_my_abspath.c b/lightningd/test/run-find_my_abspath.c
index 1d7067c..7f15dc1 100644
--- a/lightningd/test/run-find_my_abspath.c
+++ b/lightningd/test/run-find_my_abspath.c
@@ -6,6 +6,7 @@ int unused_main(int argc, char *argv[]);
#include "../subd.c"
#include <common/json_command.h>
#include <common/setup.h>
+#include <hsmd/hsmd_wiregen.h>
/* AUTOGENERATED MOCKS START */
/* Generated stub for begin_topology */
diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c
index 024aaf4..5f2ad78 100644
--- a/onchaind/onchaind.c
+++ b/onchaind/onchaind.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <bitcoin/feerate.h>
#include <bitcoin/script.h>
#include <ccan/array_size/array_size.h>
#include <ccan/asort/asort.h>
@@ -11,9 +10,7 @@
#include <common/keyset.h>
#include <common/lease_rates.h>
#include <common/memleak.h>
-#include <common/overflows.h>
#include <common/peer_billboard.h>
-#include <common/psbt_keypath.h>
#include <common/status.h>
#include <common/subdaemon.h>
#include <hsmd/hsmd_wiregen.h>
@@ -21,7 +18,6 @@
#include <onchaind/onchain_types.h>
#include <onchaind/onchaind_wiregen.h>
#include <unistd.h>
-#include <wally_bip32.h>
#include <wire/wire_sync.h>
#include "onchain_types_names_gen.h"
diff --git a/openingd/common.c b/openingd/common.c
index 78c72f9..d57bd83 100644
--- a/openingd/common.c
+++ b/openingd/common.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <ccan/ccan/tal/str/str.h>
#include <common/channel_config.h>
-#include <common/features.h>
#include <common/initial_commit_tx.h>
#include <common/shutdown_scriptpubkey.h>
#include <common/status.h>
diff --git a/openingd/dualopend.c b/openingd/dualopend.c
index eeca905..9ac43d8 100644
--- a/openingd/dualopend.c
+++ b/openingd/dualopend.c
@@ -19,15 +19,12 @@
#include <ccan/tal/str/str.h>
#include <common/billboard.h>
#include <common/blockheight_states.h>
-#include <common/channel_type.h>
-#include <common/gossip_store.h>
#include <common/initial_channel.h>
#include <common/lease_rates.h>
#include <common/memleak.h>
#include <common/peer_billboard.h>
#include <common/peer_failed.h>
#include <common/peer_io.h>
-#include <common/peer_status_wiregen.h>
#include <common/per_peer_state.h>
#include <common/psbt_internal.h>
#include <common/psbt_open.h>
diff --git a/openingd/openingd.c b/openingd/openingd.c
index 23331fa..7a86218 100644
--- a/openingd/openingd.c
+++ b/openingd/openingd.c
@@ -12,9 +12,7 @@
#include <ccan/array_size/array_size.h>
#include <ccan/breakpoint/breakpoint.h>
#include <ccan/tal/str/str.h>
-#include <common/channel_type.h>
#include <common/fee_states.h>
-#include <common/gossip_store.h>
#include <common/initial_channel.h>
#include <common/memleak.h>
#include <common/peer_billboard.h>
@@ -25,7 +23,6 @@
#include <common/status.h>
#include <common/subdaemon.h>
#include <common/wire_error.h>
-#include <errno.h>
#include <hsmd/hsmd_wiregen.h>
#include <openingd/common.h>
#include <openingd/openingd_wiregen.h>
diff --git a/plugins/autoclean.c b/plugins/autoclean.c
index 8be8ce2..f156125 100644
--- a/plugins/autoclean.c
+++ b/plugins/autoclean.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
-#include <ccan/ptrint/ptrint.h>
#include <ccan/tal/str/str.h>
#include <common/json_param.h>
#include <common/json_stream.h>
diff --git a/plugins/bcli.c b/plugins/bcli.c
index b1e655b..656df9f 100644
--- a/plugins/bcli.c
+++ b/plugins/bcli.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <bitcoin/base58.h>
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
#include <ccan/io/io.h>
diff --git a/plugins/chanbackup.c b/plugins/chanbackup.c
index 034c3ec..de298ec 100644
--- a/plugins/chanbackup.c
+++ b/plugins/chanbackup.c
@@ -1,15 +1,11 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
-#include <ccan/err/err.h>
#include <ccan/json_out/json_out.h>
#include <ccan/noerr/noerr.h>
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/str/str.h>
-#include <ccan/time/time.h>
-#include <common/features.h>
-#include <common/hsm_encryption.h>
#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
diff --git a/plugins/commando.c b/plugins/commando.c
index ae23d7a..f5022be 100644
--- a/plugins/commando.c
+++ b/plugins/commando.c
@@ -1,18 +1,13 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
-#include <ccan/crypto/siphash24/siphash24.h>
-#include <ccan/htable/htable_type.h>
-#include <ccan/json_escape/json_escape.h>
#include <ccan/json_out/json_out.h>
#include <ccan/mem/mem.h>
#include <ccan/rune/rune.h>
#include <ccan/tal/str/str.h>
-#include <ccan/time/time.h>
#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
-#include <common/pseudorand.h>
#include <inttypes.h>
#include <plugins/libplugin.h>
diff --git a/plugins/establish_onion_path.c b/plugins/establish_onion_path.c
index c74bc44..f3213bd 100644
--- a/plugins/establish_onion_path.c
+++ b/plugins/establish_onion_path.c
@@ -1,9 +1,7 @@
#include "config.h"
-#include <ccan/tal/str/str.h>
#include <common/dijkstra.h>
#include <common/features.h>
#include <common/gossmap.h>
-#include <common/gossmods_listpeerchannels.h>
#include <common/json_stream.h>
#include <common/route.h>
#include <plugins/establish_onion_path.h>
diff --git a/plugins/exposesecret.c b/plugins/exposesecret.c
index ea50fa0..ed944cd 100644
--- a/plugins/exposesecret.c
+++ b/plugins/exposesecret.c
@@ -1,8 +1,6 @@
#include "config.h"
-#include <bitcoin/privkey.h>
#include <ccan/array_size/array_size.h>
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
-#include <ccan/crypto/sha256/sha256.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/str/str.h>
#include <common/bech32.h>
diff --git a/plugins/fetchinvoice.c b/plugins/fetchinvoice.c
index 10362e8..a18b82e 100644
--- a/plugins/fetchinvoice.c
+++ b/plugins/fetchinvoice.c
@@ -1,32 +1,20 @@
#include "config.h"
-#include <bitcoin/chainparams.h>
-#include <ccan/array_size/array_size.h>
-#include <ccan/cast/cast.h>
#include <ccan/json_out/json_out.h>
#include <ccan/mem/mem.h>
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
-#include <common/blindedpath.h>
#include <common/bolt12_id.h>
#include <common/bolt12_merkle.h>
-#include <common/dijkstra.h>
#include <common/features.h>
#include <common/gossmap.h>
-#include <common/gossmods_listpeerchannels.h>
#include <common/json_param.h>
#include <common/json_stream.h>
-#include <common/memleak.h>
#include <common/onion_message.h>
#include <common/overflows.h>
-#include <common/route.h>
-#include <common/utils.h>
-#include <errno.h>
#include <inttypes.h>
#include <plugins/establish_onion_path.h>
#include <plugins/fetchinvoice.h>
-#include <plugins/libplugin.h>
#include <plugins/offers.h>
-#include <secp256k1_schnorrsig.h>
#include <sodium.h>
static LIST_HEAD(sent_list);
diff --git a/plugins/funder.c b/plugins/funder.c
index af2997b..15ab3f1 100644
--- a/plugins/funder.c
+++ b/plugins/funder.c
@@ -12,7 +12,6 @@
#include <ccan/tal/str/str.h>
#include <common/json_param.h>
#include <common/json_stream.h>
-#include <common/lease_rates.h>
#include <common/memleak.h>
#include <common/overflows.h>
#include <common/psbt_open.h>
diff --git a/plugins/funder_policy.c b/plugins/funder_policy.c
index 1ce2cef..fc84e8f 100644
--- a/plugins/funder_policy.c
+++ b/plugins/funder_policy.c
@@ -4,7 +4,6 @@
#include <ccan/tal/str/str.h>
#include <common/json_stream.h>
#include <common/lease_rates.h>
-#include <common/pseudorand.h>
#include <inttypes.h>
#include <plugins/funder_policy.h>
diff --git a/plugins/keysend.c b/plugins/keysend.c
index 79a6600..aed5511 100644
--- a/plugins/keysend.c
+++ b/plugins/keysend.c
@@ -1,15 +1,12 @@
#include "config.h"
-#include <bitcoin/preimage.h>
#include <ccan/array_size/array_size.h>
#include <ccan/asort/asort.h>
#include <ccan/cast/cast.h>
#include <ccan/tal/str/str.h>
#include <common/features.h>
-#include <common/gossmap.h>
#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
-#include <errno.h>
#include <inttypes.h>
#include <plugins/channel_hint.h>
#include <plugins/libplugin-pay.h>
diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c
index 9b3bd5f..919ca7d 100644
--- a/plugins/libplugin-pay.c
+++ b/plugins/libplugin-pay.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/blindedpay.h>
@@ -11,7 +10,6 @@
#include <common/gossmods_listpeerchannels.h>
#include <common/json_stream.h>
#include <common/memleak.h>
-#include <common/pseudorand.h>
#include <common/random_select.h>
#include <common/route.h>
#include <common/trace.h>
@@ -20,8 +18,6 @@
#include <math.h>
#include <plugins/channel_hint.h>
#include <plugins/libplugin-pay.h>
-#include <stdio.h>
-#include <sys/types.h>
#include <wire/peer_wire.h>
static struct gossmap *global_gossmap;
diff --git a/plugins/libplugin.c b/plugins/libplugin.c
index 6e74026..3d35700 100644
--- a/plugins/libplugin.c
+++ b/plugins/libplugin.c
@@ -1,6 +1,4 @@
#include "config.h"
-#include <bitcoin/chainparams.h>
-#include <bitcoin/privkey.h>
#include <ccan/io/io.h>
#include <ccan/json_out/json_out.h>
#include <ccan/membuf/membuf.h>
@@ -12,7 +10,6 @@
#include <common/features.h>
#include <common/json_filter.h>
#include <common/json_param.h>
-#include <common/json_parse_simple.h>
#include <common/json_stream.h>
#include <common/memleak.h>
#include <common/plugin.h>
@@ -22,8 +19,7 @@
#include <inttypes.h>
#include <plugins/libplugin.h>
#include <stdio.h>
-#include <sys/socket.h>
-#include <sys/un.h>
+#include <unistd.h>
#define READ_CHUNKSIZE 4096
diff --git a/plugins/offers.c b/plugins/offers.c
index 5daf8b6..383beff 100644
--- a/plugins/offers.c
+++ b/plugins/offers.c
@@ -1,13 +1,10 @@
/* This plugin covers both sending and receiving offers */
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <ccan/array_size/array_size.h>
-#include <ccan/cast/cast.h>
#include <ccan/rune/rune.h>
#include <ccan/tal/str/str.h>
#include <common/bech32.h>
#include <common/bech32_util.h>
-#include <common/bolt11.h>
#include <common/bolt11_json.h>
#include <common/bolt12_id.h>
#include <common/bolt12_merkle.h>
diff --git a/plugins/offers_inv_hook.c b/plugins/offers_inv_hook.c
index 4772899..3e72fae 100644
--- a/plugins/offers_inv_hook.c
+++ b/plugins/offers_inv_hook.c
@@ -7,7 +7,6 @@
#include <common/json_stream.h>
#include <plugins/offers.h>
#include <plugins/offers_inv_hook.h>
-#include <secp256k1_schnorrsig.h>
/* We need to keep the reply path around so we can reply if error */
struct inv {
diff --git a/plugins/offers_invreq_hook.c b/plugins/offers_invreq_hook.c
index 3a7574f..153def6 100644
--- a/plugins/offers_invreq_hook.c
+++ b/plugins/offers_invreq_hook.c
@@ -1,25 +1,19 @@
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <bitcoin/preimage.h>
#include <ccan/cast/cast.h>
-#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/bech32_util.h>
-#include <common/blindedpath.h>
#include <common/bolt12_id.h>
#include <common/bolt12_merkle.h>
#include <common/features.h>
#include <common/gossmap.h>
#include <common/iso4217.h>
#include <common/json_stream.h>
-#include <common/memleak.h>
#include <common/onion_message.h>
#include <common/overflows.h>
-#include <errno.h>
#include <inttypes.h>
#include <plugins/offers.h>
#include <plugins/offers_invreq_hook.h>
-#include <secp256k1_schnorrsig.h>
#include <sodium.h>
/* We need to keep the reply path around so we can reply with invoice */
diff --git a/plugins/offers_offer.c b/plugins/offers_offer.c
index 77eae2c..34b6844 100644
--- a/plugins/offers_offer.c
+++ b/plugins/offers_offer.c
@@ -1,7 +1,5 @@
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <ccan/array_size/array_size.h>
-#include <ccan/tal/str/str.h>
#include <common/bolt12.h>
#include <common/bolt12_id.h>
#include <common/features.h>
diff --git a/plugins/pay.c b/plugins/pay.c
index 20de6e1..ba1353a 100644
--- a/plugins/pay.c
+++ b/plugins/pay.c
@@ -1,12 +1,6 @@
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <ccan/array_size/array_size.h>
-#include <ccan/asort/asort.h>
#include <ccan/cast/cast.h>
-#include <ccan/crypto/siphash24/siphash24.h>
-#include <ccan/htable/htable_type.h>
-#include <ccan/json_out/json_out.h>
-#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
#include <common/bolt12_merkle.h>
#include <common/features.h>
@@ -14,10 +8,8 @@
#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
-#include <common/pseudorand.h>
#include <plugins/channel_hint.h>
#include <plugins/libplugin-pay.h>
-#include <plugins/libplugin.h>
#include <stdio.h>
/* Public key of this node. */
diff --git a/plugins/recklessrpc.c b/plugins/recklessrpc.c
index 3c86a08..510a3e5 100644
--- a/plugins/recklessrpc.c
+++ b/plugins/recklessrpc.c
@@ -5,15 +5,14 @@
#include <ccan/array_size/array_size.h>
#include <ccan/io/io.h>
#include <ccan/pipecmd/pipecmd.h>
-#include <ccan/str/str.h>
#include <ccan/tal/str/str.h>
#include <common/json_param.h>
-#include <common/json_parse_simple.h>
#include <common/json_stream.h>
#include <common/memleak.h>
#include <errno.h>
#include <plugins/libplugin.h>
#include <signal.h>
+#include <unistd.h>
static struct plugin *plugin;
diff --git a/plugins/recover.c b/plugins/recover.c
index fcc7b74..850f85d 100644
--- a/plugins/recover.c
+++ b/plugins/recover.c
@@ -1,14 +1,10 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
-#include <common/features.h>
#include <common/gossmap.h>
-#include <common/hsm_encryption.h>
-#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
#include <errno.h>
#include <plugins/libplugin.h>
-#include <unistd.h>
/* How long to wait after startup before starting the timer loop */
#define STARTUP_TIME 2
diff --git a/plugins/sql.c b/plugins/sql.c
index a1c361d..ca622c0 100644
--- a/plugins/sql.c
+++ b/plugins/sql.c
@@ -2,7 +2,6 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <ccan/err/err.h>
-#include <ccan/strmap/strmap.h>
#include <ccan/tal/str/str.h>
#include <common/deprecation.h>
#include <common/gossip_store.h>
@@ -16,8 +15,6 @@
#include <plugins/libplugin.h>
#include <sqlite3.h>
#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <unistd.h>
/* Minimized schemas. C23 #embed, Where Art Thou? */
diff --git a/plugins/test/run-route-calc.c b/plugins/test/run-route-calc.c
index 025c984..de62e98 100644
--- a/plugins/test/run-route-calc.c
+++ b/plugins/test/run-route-calc.c
@@ -4,6 +4,7 @@
#include "../../common/dijkstra.c"
#include "../libplugin-pay.c"
#include <bitcoin/chainparams.h>
+#include <ccan/array_size/array_size.h>
#include <ccan/crc32c/crc32c.h>
#include <common/gossip_store.h>
#include <common/setup.h>
diff --git a/plugins/topology.c b/plugins/topology.c
index 4a44084..944180d 100644
--- a/plugins/topology.c
+++ b/plugins/topology.c
@@ -1,7 +1,5 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
-#include <ccan/crypto/siphash24/siphash24.h>
-#include <ccan/htable/htable_type.h>
#include <ccan/json_escape/json_escape.h>
#include <ccan/tal/str/str.h>
#include <common/dijkstra.h>
@@ -10,9 +8,7 @@
#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
-#include <common/pseudorand.h>
#include <common/route.h>
-#include <common/wireaddr.h>
#include <errno.h>
#include <inttypes.h>
#include <plugins/libplugin.h>
diff --git a/plugins/txprepare.c b/plugins/txprepare.c
index a0cbd1b..d1be784 100644
--- a/plugins/txprepare.c
+++ b/plugins/txprepare.c
@@ -1,15 +1,11 @@
#include "config.h"
#include <bitcoin/psbt.h>
-#include <bitcoin/script.h>
#include <ccan/array_size/array_size.h>
-#include <common/addr.h>
#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
#include <common/psbt_open.h>
-#include <common/pseudorand.h>
#include <plugins/libplugin.h>
-#include <wally_psbt.h>
struct tx_output {
struct amount_sat amount;
diff --git a/tools/hsmtool.c b/tools/hsmtool.c
index 484ef2b..1352bd8 100644
--- a/tools/hsmtool.c
+++ b/tools/hsmtool.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <bitcoin/tx.h>
#include <ccan/array_size/array_size.h>
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
#include <ccan/err/err.h>
@@ -12,13 +11,11 @@
#include <common/bech32.h>
#include <common/bech32_util.h>
#include <common/codex32.h>
-#include <common/configdir.h>
#include <common/derive_basepoints.h>
#include <common/descriptor_checksum.h>
#include <common/errcode.h>
#include <common/hsm_encryption.h>
#include <common/key_derive.h>
-#include <common/node_id.h>
#include <common/utils.h>
#include <common/utxo.h>
#include <errno.h>
diff --git a/wallet/account_migration.c b/wallet/account_migration.c
index e26d521..b1de096 100644
--- a/wallet/account_migration.c
+++ b/wallet/account_migration.c
@@ -11,7 +11,6 @@
#include <lightningd/lightningd.h>
#include <unistd.h>
#include <wallet/account_migration.h>
-#include <wallet/wallet.h>
/* These functions and definitions copied almost exactly from old
* plugins/bkpr/{recorder.c,chain_event.h,channel_event.h}
diff --git a/wallet/db.c b/wallet/db.c
index eb0ae7b..2457349 100644
--- a/wallet/db.c
+++ b/wallet/db.c
@@ -1,11 +1,7 @@
#include "config.h"
#include <bitcoin/script.h>
#include <ccan/array_size/array_size.h>
-#include <ccan/build_assert/build_assert.h>
-#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
-#include <common/bolt11.h>
-#include <common/key_derive.h>
#include <common/version.h>
#include <db/bindings.h>
#include <db/common.h>
@@ -16,12 +12,9 @@
#include <lightningd/channel.h>
#include <lightningd/hsm_control.h>
#include <lightningd/plugin_hook.h>
-#include <sodium/randombytes.h>
-#include <stddef.h>
#include <wallet/account_migration.h>
#include <wallet/db.h>
#include <wallet/psbt_fixup.h>
-#include <wire/peer_wire.h>
#include <wire/wire_sync.h>
struct migration {
diff --git a/wallet/invoices.c b/wallet/invoices.c
index 1655c8f..0376f17 100644
--- a/wallet/invoices.c
+++ b/wallet/invoices.c
@@ -7,7 +7,6 @@
#include <db/utils.h>
#include <lightningd/invoice.h>
#include <lightningd/lightningd.h>
-#include <lightningd/wait.h>
#include <wallet/invoices.h>
struct invoice_waiter {
diff --git a/wallet/psbt_fixup.c b/wallet/psbt_fixup.c
index b550963..1c15946 100644
--- a/wallet/psbt_fixup.c
+++ b/wallet/psbt_fixup.c
@@ -6,11 +6,8 @@
* As of libwally 0.88 (and perhaps 0.87?) it will refuse to load them.
*/
#include "config.h"
-#include <bitcoin/pubkey.h>
#include <bitcoin/signature.h>
-#include <ccan/array_size/array_size.h>
#include <ccan/endian/endian.h>
-#include <ccan/mem/mem.h>
#include <common/utils.h>
#include <wallet/psbt_fixup.h>
#include <wire/wire.h>
diff --git a/wallet/reservation.c b/wallet/reservation.c
index 23cdaad..dd1bebb 100644
--- a/wallet/reservation.c
+++ b/wallet/reservation.c
@@ -3,11 +3,7 @@
#include <bitcoin/psbt.h>
#include <bitcoin/script.h>
#include <ccan/cast/cast.h>
-#include <ccan/mem/mem.h>
-#include <common/configdir.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/key_derive.h>
#include <common/psbt_open.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
@@ -16,7 +12,6 @@
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
#include <wallet/txfilter.h>
-#include <wally_psbt.h>
/* 12 hours is usually enough reservation time */
#define RESERVATION_DEFAULT (6 * 12)
diff --git a/wallet/test/run-psbt_fixup.c b/wallet/test/run-psbt_fixup.c
index ac63f25..5af0ad5 100644
--- a/wallet/test/run-psbt_fixup.c
+++ b/wallet/test/run-psbt_fixup.c
@@ -3,6 +3,7 @@
#include <assert.h>
#include <bitcoin/chainparams.h>
#include <bitcoin/psbt.h>
+#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
#include <common/setup.h>
#include <stdio.h>
diff --git a/wallet/txfilter.c b/wallet/txfilter.c
index b962286..a8b32db 100644
--- a/wallet/txfilter.c
+++ b/wallet/txfilter.c
@@ -1,9 +1,6 @@
#include "config.h"
#include <bitcoin/script.h>
-#include <ccan/crypto/siphash24/siphash24.h>
-#include <ccan/mem/mem.h>
#include <common/memleak.h>
-#include <common/pseudorand.h>
#include <common/utils.h>
#include <wallet/txfilter.h>
#include <wallet/wallet.h>
diff --git a/wallet/wallet.c b/wallet/wallet.c
index 599e2f9..d2dc7d0 100644
--- a/wallet/wallet.c
+++ b/wallet/wallet.c
@@ -5,8 +5,6 @@
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <channeld/channeld_wiregen.h>
-#include <common/blockheight_states.h>
-#include <common/fee_states.h>
#include <common/memleak.h>
#include <common/onionreply.h>
#include <common/trace.h>
@@ -14,20 +12,17 @@
#include <db/common.h>
#include <db/exec.h>
#include <db/utils.h>
-#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/channel_gossip.h>
#include <lightningd/closed_channel.h>
#include <lightningd/coin_mvts.h>
#include <lightningd/notification.h>
-#include <lightningd/peer_control.h>
#include <lightningd/peer_htlcs.h>
#include <lightningd/runes.h>
#include <onchaind/onchaind_wiregen.h>
#include <wallet/invoices.h>
#include <wallet/txfilter.h>
#include <wallet/wallet.h>
-#include <wally_bip32.h>
#define SQLITE_MAX_UINT 0x7FFFFFFFFFFFFFFF
#define DIRECTION_INCOMING 0
diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c
index 677db8b..6155c89 100644
--- a/wallet/walletrpc.c
+++ b/wallet/walletrpc.c
@@ -1,30 +1,19 @@
#include "config.h"
-#include <bitcoin/base58.h>
#include <bitcoin/script.h>
-#include <ccan/array_size/array_size.h>
-#include <ccan/cast/cast.h>
#include <common/addr.h>
#include <common/base64.h>
#include <common/bech32.h>
-#include <common/configdir.h>
#include <common/json_command.h>
-#include <common/json_param.h>
-#include <common/key_derive.h>
#include <common/psbt_keypath.h>
#include <common/psbt_open.h>
#include <db/exec.h>
#include <errno.h>
#include <hsmd/hsmd_wiregen.h>
-#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/hsm_control.h>
-#include <lightningd/jsonrpc.h>
-#include <lightningd/lightningd.h>
#include <lightningd/notification.h>
-#include <lightningd/peer_control.h>
#include <wallet/txfilter.h>
#include <wallet/walletrpc.h>
-#include <wally_psbt.h>
#include <wire/wire_sync.h>
/* May return NULL if encoding error occurs. */
diff --git a/wire/towire.c b/wire/towire.c
index f275367..b90c7e3 100644
--- a/wire/towire.c
+++ b/wire/towire.c
@@ -2,7 +2,6 @@
#include "wire.h"
#include <assert.h>
#include <ccan/crypto/siphash24/siphash24.h>
-#include <ccan/endian/endian.h>
#include <ccan/mem/mem.h>
#include <channeld/inflight.h>
#include <common/utils.h>
diff --git a/wire/wire_io.c b/wire/wire_io.c
index 26051c8..7cbdde3 100644
--- a/wire/wire_io.c
+++ b/wire/wire_io.c
@@ -3,7 +3,6 @@
#include <unistd.h>
#include <ccan/io/io_plan.h>
#include <ccan/mem/mem.h>
-#include <common/utils.h>
#include <errno.h>
#include <wire/wire_io.h>
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.