global: remove unnecessary includes from headers.
What changed, and why it matters
This is a large but purely mechanical cleanup of C header file #include directives across the Core Lightning codebase. The goal is to make each header include only what it actually needs, and to add missing includes to the .c source files that now need them. It also deletes a tiny wrapper header that did nothing but include another generated header. There is no change to program logic, data handling, or security behavior.
No security action required. Treat as normal refactoring; verify the tree still compiles and passes existing tests.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes transitive/unneeded #include directives from ~212 headers and source files, moves required declarations into the .c files that use them, and deletes wire/onion_wire.h in favor of directly including wire/onion_wiregen.h. Several wire/*.csv files and wire/Makefile are updated so generated wire code emits the correct includes. No functional code, algorithms, parsing, cryptography, or protocol handling are modified.
Changed components
bitcoin/*.hchanneld/*.hchanneld/*.ccli/*.hcli/*.cclosingd/*.csvcommon/*.hcommon/*.cconnectd/*.hconnectd/*.cdb/*.hdb/*.cdevtools/*.cdevtools/*.hgossipd/*.hgossipd/*.chsmd/*.hhsmd/*.clightningd/*.hlightningd/*.conchaind/*.conchaind/*.csvopeningd/*.hopeningd/*.cplugins/**/*.cplugins/**/*.htests/fuzz/*.ctests/fuzz/*.htests/plugins/*.ctools/hsmtool.cwallet/*.cwallet/*.hwire/*.hwire/*.cwire/MakefileInspect captured patch +178 / −153
diff --git a/bitcoin/block.h b/bitcoin/block.h
index a2631b7..a3289ee 100644
--- a/bitcoin/block.h
+++ b/bitcoin/block.h
@@ -4,7 +4,6 @@
#include "bitcoin/shadouble.h"
#include <ccan/endian/endian.h>
#include <ccan/structeq/structeq.h>
-#include <ccan/tal/tal.h>
struct chainparams;
diff --git a/bitcoin/feerate.h b/bitcoin/feerate.h
index cab1e95..f4dbdbb 100644
--- a/bitcoin/feerate.h
+++ b/bitcoin/feerate.h
@@ -2,7 +2,6 @@
#define LIGHTNING_BITCOIN_FEERATE_H
#include "config.h"
#include <ccan/build_assert/build_assert.h>
-#include <ccan/short_types/short_types.h>
#include <common/amount.h>
/* bitcoind considers 250 satoshi per kw to be the minimum acceptable fee:
diff --git a/bitcoin/privkey.h b/bitcoin/privkey.h
index d592d46..b4ee358 100644
--- a/bitcoin/privkey.h
+++ b/bitcoin/privkey.h
@@ -2,7 +2,6 @@
#define LIGHTNING_BITCOIN_PRIVKEY_H
#include "config.h"
#include <ccan/short_types/short_types.h>
-#include <ccan/structeq/structeq.h>
#include <ccan/tal/tal.h>
#define PRIVKEY_LEN 32
diff --git a/bitcoin/script.c b/bitcoin/script.c
index 6397464..71e0dd0 100644
--- a/bitcoin/script.c
+++ b/bitcoin/script.c
@@ -9,6 +9,7 @@
#include <ccan/mem/mem.h>
#include <common/utils.h>
#include <sodium/randombytes.h>
+#include <wally_script.h>
/* To push 0-75 bytes onto stack. */
#define OP_PUSHBYTES(val) (val)
diff --git a/bitcoin/script.h b/bitcoin/script.h
index 5b96d69..ccbad3b 100644
--- a/bitcoin/script.h
+++ b/bitcoin/script.h
@@ -3,7 +3,6 @@
#include "config.h"
#include "signature.h"
#include "tx.h"
-#include <wally_script.h>
struct bitcoin_address;
struct preimage;
diff --git a/bitcoin/short_channel_id.h b/bitcoin/short_channel_id.h
index 1cd13f9..3c7cce9 100644
--- a/bitcoin/short_channel_id.h
+++ b/bitcoin/short_channel_id.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_BITCOIN_SHORT_CHANNEL_ID_H
#define LIGHTNING_BITCOIN_SHORT_CHANNEL_ID_H
#include "config.h"
-#include <ccan/compiler/compiler.h>
#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
#include <common/gossip_constants.h>
diff --git a/bitcoin/tx.h b/bitcoin/tx.h
index 2549cd5..4b7134e 100644
--- a/bitcoin/tx.h
+++ b/bitcoin/tx.h
@@ -2,11 +2,7 @@
#define LIGHTNING_BITCOIN_TX_H
#include "config.h"
#include <bitcoin/chainparams.h>
-#include <bitcoin/shadouble.h>
-#include <bitcoin/signature.h>
#include <bitcoin/varint.h>
-#include <ccan/structeq/structeq.h>
-#include <common/amount.h>
#include <wally_transaction.h>
#define BITCOIN_TX_DEFAULT_SEQUENCE 0xFFFFFFFF
diff --git a/channeld/channeld.c b/channeld/channeld.c
index eb1b7a5..dc8bdf2 100644
--- a/channeld/channeld.c
+++ b/channeld/channeld.c
@@ -42,10 +42,12 @@
#include <common/status.h>
#include <common/subdaemon.h>
#include <common/timeout.h>
+#include <common/utils.h>
#include <common/wire_error.h>
#include <errno.h>
#include <fcntl.h>
#include <hsmd/hsmd_wiregen.h>
+#include <inttypes.h>
#include <stdio.h>
#include <wally_bip32.h>
#include <wire/peer_wire.h>
diff --git a/channeld/channeld.h b/channeld/channeld.h
index a2b26b0..c57a290 100644
--- a/channeld/channeld.h
+++ b/channeld/channeld.h
@@ -2,7 +2,6 @@
#define LIGHTNING_CHANNELD_CHANNELD_H
#include "config.h"
#include <ccan/short_types/short_types.h>
-#include <ccan/take/take.h>
#include <ccan/tal/tal.h>
const u8 *hsm_req(const tal_t *ctx, const u8 *req TAKES);
diff --git a/channeld/channeld_htlc.h b/channeld/channeld_htlc.h
index 14d41f0..2bd7075 100644
--- a/channeld/channeld_htlc.h
+++ b/channeld/channeld_htlc.h
@@ -1,11 +1,8 @@
#ifndef LIGHTNING_CHANNELD_CHANNELD_HTLC_H
#define LIGHTNING_CHANNELD_CHANNELD_HTLC_H
#include "config.h"
-#include <ccan/crypto/siphash24/siphash24.h>
#include <common/htlc.h>
#include <common/pseudorand.h>
-#include <wire/onion_wire.h>
-#include <wire/tlvstream.h>
struct htlc {
/* What's the status. */
diff --git a/channeld/full_channel.c b/channeld/full_channel.c
index 699ccdf..9bf383d 100644
--- a/channeld/full_channel.c
+++ b/channeld/full_channel.c
@@ -13,6 +13,7 @@
#include <common/keyset.h>
#include <common/memleak.h>
#include <common/status.h>
+#include <inttypes.h>
#include <stdio.h>
/* Needs to be at end, since it doesn't include its own hdrs */
#include "full_channel_error_names_gen.h"
diff --git a/channeld/inflight.h b/channeld/inflight.h
index 7143e0a..025dc45 100644
--- a/channeld/inflight.h
+++ b/channeld/inflight.h
@@ -3,6 +3,7 @@
#include "config.h"
#include <bitcoin/pubkey.h>
+#include <bitcoin/signature.h>
#include <bitcoin/tx.h>
#include <common/amount.h>
diff --git a/channeld/test/run-commit_tx.c b/channeld/test/run-commit_tx.c
index f2e0c8d..b57e50a 100644
--- a/channeld/test/run-commit_tx.c
+++ b/channeld/test/run-commit_tx.c
@@ -9,6 +9,7 @@ static bool print_superverbose;
#define PRINT_ACTUAL_FEE
#include "../commit_tx.c"
#include <bitcoin/preimage.h>
+#include <bitcoin/privkey.h>
#include <ccan/array_size/array_size.h>
#include <ccan/err/err.h>
#include <ccan/str/hex/hex.h>
diff --git a/cli/config_cli.h b/cli/config_cli.h
index 6faeb36..5b0dcfd 100644
--- a/cli/config_cli.h
+++ b/cli/config_cli.h
@@ -2,7 +2,6 @@
#define LIGHTNING_CLI_CONFIG_CLI_H
#include "config.h"
-#include <stdio.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 10f8fff..8ebc254 100644
--- a/cli/lightning-cli.c
+++ b/cli/lightning-cli.c
@@ -17,6 +17,7 @@
#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>
diff --git a/closingd/closingd_wire.csv b/closingd/closingd_wire.csv
index 10a5d8c..55ca558 100644
--- a/closingd/closingd_wire.csv
+++ b/closingd/closingd_wire.csv
@@ -1,3 +1,4 @@
+#include <bitcoin/signature.h>
#include <bitcoin/tx.h>
#include <common/bip32.h>
#include <common/channel_id.h>
diff --git a/common/amount.h b/common/amount.h
index b1cdbac..11551b9 100644
--- a/common/amount.h
+++ b/common/amount.h
@@ -1,6 +1,7 @@
#ifndef LIGHTNING_COMMON_AMOUNT_H
#define LIGHTNING_COMMON_AMOUNT_H
#include "config.h"
+#include <ccan/build_assert/build_assert.h>
#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
diff --git a/common/autodata.h b/common/autodata.h
index 60c300b..6a18ffc 100644
--- a/common/autodata.h
+++ b/common/autodata.h
@@ -1,8 +1,6 @@
#ifndef LIGHTNING_COMMON_AUTODATA_H
#define LIGHTNING_COMMON_AUTODATA_H
#include "config.h"
-#include <ccan/compiler/compiler.h>
-#include <ccan/cppmagic/cppmagic.h>
#include <stddef.h>
#define AUTODATA_TYPE(name, type) \
diff --git a/common/blindedpath.c b/common/blindedpath.c
index c13b49d..0923c40 100644
--- a/common/blindedpath.c
+++ b/common/blindedpath.c
@@ -1,13 +1,15 @@
#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>
#include <common/hmac.h>
+#include <common/utils.h>
#include <secp256k1_ecdh.h>
#include <sodium.h>
-#include <wire/onion_wire.h>
+#include <wire/onion_wiregen.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
diff --git a/common/blindedpath.h b/common/blindedpath.h
index b848693..7a5238f 100644
--- a/common/blindedpath.h
+++ b/common/blindedpath.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_COMMON_BLINDEDPATH_H
#define LIGHTNING_COMMON_BLINDEDPATH_H
#include "config.h"
-#include <ccan/compiler/compiler.h>
#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
diff --git a/common/blindedpay.c b/common/blindedpay.c
index 9c3dec2..1dc6f74 100644
--- a/common/blindedpay.c
+++ b/common/blindedpay.c
@@ -3,6 +3,7 @@
#include <common/blindedpay.h>
#include <common/bolt12.h>
#include <common/onion_encode.h>
+#include <wire/onion_wiregen.h>
u8 **blinded_onion_hops(const tal_t *ctx,
struct amount_msat final_amount,
diff --git a/common/blindedpay.h b/common/blindedpay.h
index fa99483..b455e38 100644
--- a/common/blindedpay.h
+++ b/common/blindedpay.h
@@ -2,7 +2,6 @@
#ifndef LIGHTNING_COMMON_BLINDEDPAY_H
#define LIGHTNING_COMMON_BLINDEDPAY_H
#include "config.h"
-#include <ccan/tal/tal.h>
#include <common/amount.h>
struct blinded_path;
diff --git a/common/bolt12.c b/common/bolt12.c
index f3bcbcd..8716807 100644
--- a/common/bolt12.c
+++ b/common/bolt12.c
@@ -9,9 +9,11 @@
#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_merkle.c b/common/bolt12_merkle.c
index 6ca2189..7f4e185 100644
--- a/common/bolt12_merkle.c
+++ b/common/bolt12_merkle.c
@@ -5,6 +5,7 @@
#include <ccan/ilog/ilog.h>
#include <ccan/mem/mem.h>
#include <common/bolt12_merkle.h>
+#include <common/utils.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
diff --git a/common/channel_type.c b/common/channel_type.c
index 61302b4..bae0d6b 100644
--- a/common/channel_type.c
+++ b/common/channel_type.c
@@ -1,6 +1,7 @@
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <common/channel_type.h>
+#include <common/utils.h>
static struct channel_type *new_channel_type(const tal_t *ctx)
{
diff --git a/common/codex32.c b/common/codex32.c
index f74587a..6ccb0c4 100644
--- a/common/codex32.c
+++ b/common/codex32.c
@@ -33,6 +33,7 @@
#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>
diff --git a/common/coin_mvt.c b/common/coin_mvt.c
index 4e9ec87..e797758 100644
--- a/common/coin_mvt.c
+++ b/common/coin_mvt.c
@@ -6,6 +6,7 @@
#include <ccan/time/time.h>
#include <common/coin_mvt.h>
#include <common/node_id.h>
+#include <common/utils.h>
#include <wire/wire.h>
static const char *mvt_tags[] = {
diff --git a/common/coin_mvt.h b/common/coin_mvt.h
index e9a41b3..822e6e8 100644
--- a/common/coin_mvt.h
+++ b/common/coin_mvt.h
@@ -3,9 +3,7 @@
#include "config.h"
#include <bitcoin/tx.h>
-#include <common/amount.h>
#include <common/channel_id.h>
-#include <common/utils.h>
#define COIN_MVT_VERSION 2
#define ACCOUNT_NAME_WALLET "wallet"
diff --git a/common/cryptomsg.c b/common/cryptomsg.c
index f9ede99..4225fef 100644
--- a/common/cryptomsg.c
+++ b/common/cryptomsg.c
@@ -1,5 +1,6 @@
#include "config.h"
#include <assert.h>
+#include <ccan/build_assert/build_assert.h>
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
#include <ccan/mem/mem.h>
#include <common/cryptomsg.h>
diff --git a/common/cryptomsg.h b/common/cryptomsg.h
index 3da3387..d7c5634 100644
--- a/common/cryptomsg.h
+++ b/common/cryptomsg.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_COMMON_CRYPTOMSG_H
#define LIGHTNING_COMMON_CRYPTOMSG_H
#include "config.h"
-#include <ccan/tal/tal.h>
#include <common/crypto_state.h>
/* BOLT #8:
diff --git a/common/decode_array.c b/common/decode_array.c
index 0f9a831..83c7d77 100644
--- a/common/decode_array.c
+++ b/common/decode_array.c
@@ -1,6 +1,7 @@
#include "config.h"
#include <ccan/cast/cast.h>
#include <common/decode_array.h>
+#include <common/utils.h>
#include <wire/peer_wire.h>
struct short_channel_id *decode_short_ids(const tal_t *ctx, const u8 *encoded)
diff --git a/common/dijkstra.c b/common/dijkstra.c
index afdc4d7..d29173b 100644
--- a/common/dijkstra.c
+++ b/common/dijkstra.c
@@ -7,6 +7,7 @@
#include <common/dijkstra.h>
#include <common/gossmap.h>
#include <common/overflows.h>
+#include <common/utils.h>
#include <gheap.h>
/* Each node has this side-info. */
diff --git a/common/ecdh_hsmd.c b/common/ecdh_hsmd.c
index b8546ea..5e186d5 100644
--- a/common/ecdh_hsmd.c
+++ b/common/ecdh_hsmd.c
@@ -1,5 +1,7 @@
#include "config.h"
+#include <common/ecdh.h>
#include <common/ecdh_hsmd.h>
+#include <common/utils.h>
#include <hsmd/hsmd_wiregen.h>
#include <wire/wire_sync.h>
diff --git a/common/ecdh_hsmd.h b/common/ecdh_hsmd.h
index ca9288f..7c8aad5 100644
--- a/common/ecdh_hsmd.h
+++ b/common/ecdh_hsmd.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_COMMON_ECDH_HSMD_H
#define LIGHTNING_COMMON_ECDH_HSMD_H
#include "config.h"
-#include <common/ecdh.h>
#include <common/status_levels.h>
/* The via-the-hsmd implementation of ecdh(). */
diff --git a/common/errcode.h b/common/errcode.h
index 9fcf6fb..dc3560b 100644
--- a/common/errcode.h
+++ b/common/errcode.h
@@ -3,7 +3,6 @@
#include "config.h"
-#include <ccan/short_types/short_types.h>
// Setup errors
#define EXITCODE_SUBDAEMON_FAIL 10
diff --git a/common/features.c b/common/features.c
index 030068e..7573fea 100644
--- a/common/features.c
+++ b/common/features.c
@@ -3,6 +3,7 @@
#include <ccan/array_size/array_size.h>
#include <ccan/tal/str/str.h>
#include <common/features.h>
+#include <common/utils.h>
#include <wire/peer_wire.h>
enum feature_copy_style {
diff --git a/common/gossip_constants.h b/common/gossip_constants.h
index 53ed1cc..d5a7623 100644
--- a/common/gossip_constants.h
+++ b/common/gossip_constants.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_COMMON_GOSSIP_CONSTANTS_H
#define LIGHTNING_COMMON_GOSSIP_CONSTANTS_H
#include "config.h"
-#include <common/utils.h>
/* FIXME: This is a legacy concept, which should be eliminated now we have
* only onion tlv payloads. */
diff --git a/common/gossmap.c b/common/gossmap.c
index 1f3c5c0..a21a666 100644
--- a/common/gossmap.c
+++ b/common/gossmap.c
@@ -11,6 +11,7 @@
#include <common/gossmap.h>
#include <common/pseudorand.h>
#include <common/sciddir_or_pubkey.h>
+#include <common/utils.h>
#include <errno.h>
#include <fcntl.h>
#include <gossipd/gossip_store_wiregen.h>
diff --git a/common/gossmap.h b/common/gossmap.h
index ef3b71a..1b60a1f 100644
--- a/common/gossmap.h
+++ b/common/gossmap.h
@@ -2,9 +2,6 @@
#define LIGHTNING_COMMON_GOSSMAP_H
#include "config.h"
#include <bitcoin/short_channel_id.h>
-#include <ccan/take/take.h>
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <common/amount.h>
#include <common/fp16.h>
#include <common/status_levels.h>
diff --git a/common/gossmods_listpeerchannels.h b/common/gossmods_listpeerchannels.h
index f97694d..8a62e77 100644
--- a/common/gossmods_listpeerchannels.h
+++ b/common/gossmods_listpeerchannels.h
@@ -2,7 +2,6 @@
#define LIGHTNING_COMMON_GOSSMODS_LISTPEERCHANNELS_H
#include "config.h"
#include <bitcoin/short_channel_id.h>
-#include <ccan/typesafe_cb/typesafe_cb.h>
#include <common/amount.h>
#include <common/json_parse_simple.h>
diff --git a/common/hsm_capable.c b/common/hsm_capable.c
index a818768..5194ea1 100644
--- a/common/hsm_capable.c
+++ b/common/hsm_capable.c
@@ -1,4 +1,5 @@
#include "config.h"
+#include <ccan/tal/tal.h>
#include <common/hsm_capable.h>
/* Is this capability supported by the HSM? (So far, always a message
diff --git a/common/hsm_capable.h b/common/hsm_capable.h
index 82c9f00..d6d6ddb 100644
--- a/common/hsm_capable.h
+++ b/common/hsm_capable.h
@@ -2,7 +2,6 @@
#define LIGHTNING_COMMON_HSM_CAPABLE_H
#include "config.h"
#include <ccan/short_types/short_types.h>
-#include <ccan/tal/tal.h>
#include <stdbool.h>
/* Is this capability supported by the HSM? (So far, always a message
diff --git a/common/hsm_encryption.c b/common/hsm_encryption.c
index 33fc617..c8f316a 100644
--- a/common/hsm_encryption.c
+++ b/common/hsm_encryption.c
@@ -3,6 +3,7 @@
#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/hsm_encryption.h b/common/hsm_encryption.h
index 0f1b360..af67701 100644
--- a/common/hsm_encryption.h
+++ b/common/hsm_encryption.h
@@ -2,9 +2,7 @@
#define LIGHTNING_COMMON_HSM_ENCRYPTION_H
#include "config.h"
#include <bitcoin/privkey.h>
-#include <ccan/tal/tal.h>
#include <sodium.h>
-#include <sys/stat.h>
/* Length of the encrypted hsm secret header. */
#define HS_HEADER_LEN crypto_secretstream_xchacha20poly1305_HEADERBYTES
diff --git a/common/htlc.h b/common/htlc.h
index c300f0f..b933e07 100644
--- a/common/htlc.h
+++ b/common/htlc.h
@@ -3,7 +3,6 @@
#include "config.h"
#include "bitcoin/locktime.h"
#include "htlc_state.h"
-#include <assert.h>
#include <ccan/htable/htable_type.h>
#define NUM_SIDES (REMOTE + 1)
diff --git a/common/htlc_tx.h b/common/htlc_tx.h
index a08a90f..4e9f09a 100644
--- a/common/htlc_tx.h
+++ b/common/htlc_tx.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_COMMON_HTLC_TX_H
#define LIGHTNING_COMMON_HTLC_TX_H
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <bitcoin/tx.h>
#include <common/htlc.h>
#include <common/utils.h>
diff --git a/common/htlc_wire.c b/common/htlc_wire.c
index bb17e73..3d94471 100644
--- a/common/htlc_wire.c
+++ b/common/htlc_wire.c
@@ -4,6 +4,7 @@
#include <ccan/crypto/shachain/shachain.h>
#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,
diff --git a/common/initial_commit_tx.h b/common/initial_commit_tx.h
index 6e71583..7b61b7b 100644
--- a/common/initial_commit_tx.h
+++ b/common/initial_commit_tx.h
@@ -2,7 +2,6 @@
#ifndef LIGHTNING_COMMON_INITIAL_COMMIT_TX_H
#define LIGHTNING_COMMON_INITIAL_COMMIT_TX_H
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <bitcoin/pubkey.h>
#include <bitcoin/tx.h>
#include <common/htlc.h>
diff --git a/common/interactivetx.c b/common/interactivetx.c
index 6e1aa1c..2e9a659 100644
--- a/common/interactivetx.c
+++ b/common/interactivetx.c
@@ -21,7 +21,9 @@
#include <common/setup.h>
#include <common/status.h>
#include <common/subdaemon.h>
+#include <common/utils.h>
#include <common/wire_error.h>
+#include <inttypes.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
diff --git a/common/interactivetx.h b/common/interactivetx.h
index af17e14..967bb16 100644
--- a/common/interactivetx.h
+++ b/common/interactivetx.h
@@ -2,12 +2,8 @@
#define LIGHTNING_COMMON_INTERACTIVETX_H
#include "config.h"
-#include <ccan/short_types/short_types.h>
#include <common/channel_id.h>
-#include <common/per_peer_state.h>
#include <common/tx_roles.h>
-#include <common/utils.h>
-#include <wally_psbt.h>
/* Interactive tx handles the building and updating of a transaction between
* two peers. A PSBT is passed back and forth between two peers in steps. In
diff --git a/common/json_blinded_path.c b/common/json_blinded_path.c
index 78ef625..2df745e 100644
--- a/common/json_blinded_path.c
+++ b/common/json_blinded_path.c
@@ -1,7 +1,9 @@
#include "config.h"
+#include <bitcoin/pubkey.h>
#include <common/json_blinded_path.h>
#include <common/json_parse.h>
-#include <wire/onion_wire.h>
+#include <common/utils.h>
+#include <wire/onion_wiregen.h>
struct blinded_path *
json_to_blinded_path(const tal_t *ctx, const char *buffer, const jsmntok_t *tok)
diff --git a/common/json_command.h b/common/json_command.h
index d0c0667..7b77cc8 100644
--- a/common/json_command.h
+++ b/common/json_command.h
@@ -3,9 +3,7 @@
#ifndef LIGHTNING_COMMON_JSON_COMMAND_H
#define LIGHTNING_COMMON_JSON_COMMAND_H
#include "config.h"
-#include <ccan/compiler/compiler.h>
#include <common/json_parse.h>
-#include <common/jsonrpc_errors.h>
#include <common/status_levels.h>
struct command;
diff --git a/common/json_filter.h b/common/json_filter.h
index dee177a..3e9116d 100644
--- a/common/json_filter.h
+++ b/common/json_filter.h
@@ -4,9 +4,7 @@
#ifndef LIGHTNING_COMMON_JSON_FILTER_H
#define LIGHTNING_COMMON_JSON_FILTER_H
#include "config.h"
-#include <ccan/tal/tal.h>
#include <common/json_parse_simple.h>
-#include <stdbool.h>
struct command;
struct json_filter;
diff --git a/common/json_param.c b/common/json_param.c
index c92de19..9323b03 100644
--- a/common/json_param.c
+++ b/common/json_param.c
@@ -14,6 +14,7 @@
#include <common/json_command.h>
#include <common/json_param.h>
#include <common/route.h>
+#include <common/utils.h>
/* Overridden by run-param.c */
#ifndef paramcheck_assert
diff --git a/common/json_param.h b/common/json_param.h
index e41528a..a000c71 100644
--- a/common/json_param.h
+++ b/common/json_param.h
@@ -2,13 +2,10 @@
#ifndef LIGHTNING_COMMON_JSON_PARAM_H
#define LIGHTNING_COMMON_JSON_PARAM_H
#include "config.h"
-#include <ccan/short_types/short_types.h>
#include <common/bolt11.h>
#include <common/json_parse.h>
#include <common/lease_rates.h>
-#include <common/node_id.h>
#include <common/sphinx.h>
-#include <wire/wire.h>
/*~ Greetings adventurer!
*
diff --git a/common/json_parse.c b/common/json_parse.c
index 260e9e1..2e4bc9e 100644
--- a/common/json_parse.c
+++ b/common/json_parse.c
@@ -20,7 +20,6 @@
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
-#include <wire/onion_wire.h>
bool json_to_millionths(const char *buffer, const jsmntok_t *tok,
u64 *millionths)
diff --git a/common/json_parse.h b/common/json_parse.h
index 4bd23cb..8f3bcfc 100644
--- a/common/json_parse.h
+++ b/common/json_parse.h
@@ -2,9 +2,7 @@
#define LIGHTNING_COMMON_JSON_PARSE_H
#include "config.h"
#include <bitcoin/short_channel_id.h>
-#include <ccan/crypto/sha256/sha256.h>
#include <common/coin_mvt.h>
-#include <common/errcode.h>
/* Simple helpers are here: this file contains heavier ones */
#include <common/json_parse_simple.h>
#include <common/jsonrpc_errors.h>
diff --git a/common/json_parse_simple.c b/common/json_parse_simple.c
index e3b2cba..521b737 100644
--- a/common/json_parse_simple.c
+++ b/common/json_parse_simple.c
@@ -8,7 +8,6 @@
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
-#include <wire/onion_wire.h>
const char *json_tok_full(const char *buffer, const jsmntok_t *t)
{
diff --git a/common/json_stream.h b/common/json_stream.h
index bfbb5d0..da65761 100644
--- a/common/json_stream.h
+++ b/common/json_stream.h
@@ -9,8 +9,6 @@
# include <external/jsmn/jsmn.h>
#include <bitcoin/short_channel_id.h>
-#include <ccan/short_types/short_types.h>
-#include <ccan/tal/tal.h>
#include <ccan/time/time.h>
#include <common/amount.h>
#include <common/jsonrpc_errors.h>
diff --git a/common/jsonrpc_errors.h b/common/jsonrpc_errors.h
index da9e337..48ff078 100644
--- a/common/jsonrpc_errors.h
+++ b/common/jsonrpc_errors.h
@@ -6,7 +6,6 @@
#include "config.h"
-#include <common/errcode.h>
enum jsonrpc_errcode {
/* Standard errors defined by JSON-RPC 2.0 standard */
diff --git a/common/key_derive.h b/common/key_derive.h
index b078cc9..8ea5419 100644
--- a/common/key_derive.h
+++ b/common/key_derive.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_COMMON_KEY_DERIVE_H
#define LIGHTNING_COMMON_KEY_DERIVE_H
#include "config.h"
-#include <ccan/short_types/short_types.h>
#include <stdbool.h>
struct pubkey;
diff --git a/common/lease_rates.c b/common/lease_rates.c
index 403804e..7bcb3ce 100644
--- a/common/lease_rates.c
+++ b/common/lease_rates.c
@@ -2,6 +2,7 @@
#include <ccan/ccan/tal/str/str.h>
#include <common/lease_rates.h>
#include <common/overflows.h>
+#include <common/utils.h>
bool lease_rates_empty(const struct lease_rates *rates)
{
diff --git a/common/lease_rates.h b/common/lease_rates.h
index 0b87b38..3651f95 100644
--- a/common/lease_rates.h
+++ b/common/lease_rates.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_COMMON_LEASE_RATES_H
#define LIGHTNING_COMMON_LEASE_RATES_H
#include "config.h"
-#include <stdbool.h>
#include <wire/peer_wire.h>
struct amount_msat;
diff --git a/common/memleak.h b/common/memleak.h
index a15413b..0ff2dc5 100644
--- a/common/memleak.h
+++ b/common/memleak.h
@@ -3,8 +3,6 @@
#include "config.h"
#include <ccan/strmap/strmap.h>
#include <ccan/tal/tal.h>
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <inttypes.h>
struct htable;
struct list_head;
diff --git a/common/node_id.h b/common/node_id.h
index fa4779c..0f943a4 100644
--- a/common/node_id.h
+++ b/common/node_id.h
@@ -4,7 +4,6 @@
#include "config.h"
#include <bitcoin/pubkey.h>
#include <ccan/crypto/siphash24/siphash24.h>
-#include <ccan/htable/htable_type.h>
#include <common/pseudorand.h>
struct sha256_double;
diff --git a/common/onion_decode.c b/common/onion_decode.c
index d1bc9b0..e82b8a9 100644
--- a/common/onion_decode.c
+++ b/common/onion_decode.c
@@ -8,6 +8,7 @@
#include <common/ecdh.h>
#include <common/onion_decode.h>
#include <common/sphinx.h>
+#include <common/utils.h>
#include <inttypes.h>
#include <sodium/crypto_aead_chacha20poly1305.h>
diff --git a/common/onion_decode.h b/common/onion_decode.h
index c114997..f1d637f 100644
--- a/common/onion_decode.h
+++ b/common/onion_decode.h
@@ -1,8 +1,6 @@
#ifndef LIGHTNING_COMMON_ONION_DECODE_H
#define LIGHTNING_COMMON_ONION_DECODE_H
#include "config.h"
-#include <bitcoin/privkey.h>
-#include <common/amount.h>
#include <common/onion_encode.h>
/**
diff --git a/common/onion_encode.c b/common/onion_encode.c
index ee97471..e5ff5d9 100644
--- a/common/onion_encode.c
+++ b/common/onion_encode.c
@@ -7,6 +7,7 @@
#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 c781866..e887d42 100644
--- a/common/onion_message.c
+++ b/common/onion_message.c
@@ -7,7 +7,7 @@
#include <common/onion_message.h>
#include <common/sphinx.h>
#include <sodium.h>
-#include <wire/onion_wire.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.h b/common/onion_message.h
index 0313982..e5da47d 100644
--- a/common/onion_message.h
+++ b/common/onion_message.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_COMMON_ONION_MESSAGE_H
#define LIGHTNING_COMMON_ONION_MESSAGE_H
#include "config.h"
-#include <ccan/tal/tal.h>
#include <common/sciddir_or_pubkey.h>
#include <common/utils.h>
diff --git a/common/onion_message_parse.c b/common/onion_message_parse.c
index 9becf60..c2184db 100644
--- a/common/onion_message_parse.c
+++ b/common/onion_message_parse.c
@@ -8,7 +8,7 @@
#include <common/sphinx.h>
#include <common/status.h>
#include <common/utils.h>
-#include <wire/onion_wire.h>
+#include <wire/onion_wiregen.h>
#include <wire/peer_wire.h>
static bool decrypt_final_onionmsg(const tal_t *ctx,
diff --git a/common/onion_message_parse.h b/common/onion_message_parse.h
index af4c519..6cc1b12 100644
--- a/common/onion_message_parse.h
+++ b/common/onion_message_parse.h
@@ -2,7 +2,6 @@
#define LIGHTNING_COMMON_ONION_MESSAGE_PARSE_H
#include "config.h"
#include <bitcoin/privkey.h>
-#include <common/amount.h>
struct tlv_onionmsg_tlv;
struct sciddir_or_pubkey;
diff --git a/common/peer_failed.c b/common/peer_failed.c
index f21754e..e9864e3 100644
--- a/common/peer_failed.c
+++ b/common/peer_failed.c
@@ -8,6 +8,7 @@
#include <common/peer_status_wiregen.h>
#include <common/status.h>
#include <common/status_wiregen.h>
+#include <common/utils.h>
#include <common/wire_error.h>
/* Fatal error here, return peer control to lightningd */
diff --git a/common/per_peer_state.h b/common/per_peer_state.h
index 0561d8c..23dce68 100644
--- a/common/per_peer_state.h
+++ b/common/per_peer_state.h
@@ -2,8 +2,6 @@
#define LIGHTNING_COMMON_PER_PEER_STATE_H
#include "config.h"
-#include <ccan/tal/tal.h>
-#include <ccan/time/time.h>
#include <common/crypto_state.h>
/* Things we hand between daemons to talk to peers. */
diff --git a/common/psbt_internal.c b/common/psbt_internal.c
index 44501d6..55c50e5 100644
--- a/common/psbt_internal.c
+++ b/common/psbt_internal.c
@@ -5,6 +5,7 @@
#include <bitcoin/varint.h>
#include <common/psbt_internal.h>
#include <common/psbt_open.h>
+#include <common/utils.h>
#include <wire/peer_wire.h>
diff --git a/common/psbt_open.h b/common/psbt_open.h
index b3c74c9..da0d30d 100644
--- a/common/psbt_open.h
+++ b/common/psbt_open.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_COMMON_PSBT_OPEN_H
#define LIGHTNING_COMMON_PSBT_OPEN_H
#include "config.h"
-#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
#include <common/tx_roles.h>
#include <wally_psbt.h>
diff --git a/common/pseudorand.c b/common/pseudorand.c
index 831be2b..a9c5dfa 100644
--- a/common/pseudorand.c
+++ b/common/pseudorand.c
@@ -1,7 +1,6 @@
#include "config.h"
#include <assert.h>
#include <ccan/crypto/sha256/sha256.h>
-#include <ccan/crypto/siphash24/siphash24.h>
#include <ccan/isaac/isaac64.h>
#include <ccan/likely/likely.h>
#include <ccan/tal/tal.h>
diff --git a/common/pseudorand.h b/common/pseudorand.h
index a342200..ebe9e0b 100644
--- a/common/pseudorand.h
+++ b/common/pseudorand.h
@@ -1,6 +1,7 @@
#ifndef LIGHTNING_COMMON_PSEUDORAND_H
#define LIGHTNING_COMMON_PSEUDORAND_H
#include "config.h"
+#include <ccan/crypto/siphash24/siphash24.h>
#include <stdint.h>
#include <stdlib.h>
diff --git a/common/read_peer_msg.c b/common/read_peer_msg.c
index b10de75..a371cf9 100644
--- a/common/read_peer_msg.c
+++ b/common/read_peer_msg.c
@@ -7,6 +7,7 @@
#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>
diff --git a/common/scb_wire.csv b/common/scb_wire.csv
index f955b6b..537c564 100644
--- a/common/scb_wire.csv
+++ b/common/scb_wire.csv
@@ -7,6 +7,7 @@
#include <common/htlc_wire.h>
#include <common/node_id.h>
#include <common/wireaddr.h>
+#include <common/utils.h>
tlvtype,scb_tlvs,shachain,1,
tlvdata,scb_tlvs,shachain,their_shachain,shachain,
diff --git a/common/shutdown_scriptpubkey.c b/common/shutdown_scriptpubkey.c
index 05d7b22..6c82baf 100644
--- a/common/shutdown_scriptpubkey.c
+++ b/common/shutdown_scriptpubkey.c
@@ -1,6 +1,7 @@
#include "config.h"
#include <bitcoin/script.h>
#include <common/shutdown_scriptpubkey.h>
+#include <wally_script.h>
#include <wire/wire.h>
/* BOLT #2:
diff --git a/common/sphinx.c b/common/sphinx.c
index c254e63..e440550 100644
--- a/common/sphinx.c
+++ b/common/sphinx.c
@@ -7,7 +7,7 @@
#include <common/onionreply.h>
#include <common/overflows.h>
#include <common/sphinx.h>
-
+#include <common/utils.h>
#include <secp256k1_ecdh.h>
diff --git a/common/sphinx.h b/common/sphinx.h
index 933e826..b559d61 100644
--- a/common/sphinx.h
+++ b/common/sphinx.h
@@ -6,7 +6,7 @@
#include "bitcoin/pubkey.h"
#include <common/hmac.h>
-#include <wire/onion_wire.h>
+#include <wire/onion_wiregen.h>
struct node_id;
diff --git a/common/splice_script.h b/common/splice_script.h
index 17b3de2..fd2c9b0 100644
--- a/common/splice_script.h
+++ b/common/splice_script.h
@@ -2,7 +2,6 @@
#define LIGHTNING_COMMON_SPLICE_SCRIPT_H
#include "config.h"
-#include <ccan/tal/tal.h>
#include <common/channel_id.h>
#include <common/json_stream.h>
#include <common/node_id.h>
diff --git a/common/status.c b/common/status.c
index 87a5540..7de0ebd 100644
--- a/common/status.c
+++ b/common/status.c
@@ -7,6 +7,7 @@
#include <common/daemon_conn.h>
#include <common/status.h>
#include <common/status_wiregen.h>
+#include <common/utils.h>
#include <common/version.h>
#include <errno.h>
#include <wire/peer_wire.h>
diff --git a/common/test/run-bolt12-format-string-test.c b/common/test/run-bolt12-format-string-test.c
index dc83847..e120af6 100644
--- a/common/test/run-bolt12-format-string-test.c
+++ b/common/test/run-bolt12-format-string-test.c
@@ -9,6 +9,7 @@
#include <common/bolt12_merkle.h>
#include <common/features.h>
#include <common/setup.h>
+#include <common/utils.h>
/* AUTOGENERATED MOCKS START */
/* Generated stub for features_unsupported */
diff --git a/common/test/run-bolt12_merkle-json.c b/common/test/run-bolt12_merkle-json.c
index 4c0910d..dba66a2 100644
--- a/common/test/run-bolt12_merkle-json.c
+++ b/common/test/run-bolt12_merkle-json.c
@@ -8,6 +8,7 @@
#include "../../wire/fromwire.c"
#include "../../wire/peer_wiregen.c"
#include "../../wire/tlvstream.c"
+#include <ccan/array_size/array_size.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
#include <common/channel_type.h>
diff --git a/common/test/run-cryptomsg.c b/common/test/run-cryptomsg.c
index 42fa16e..9b7619d 100644
--- a/common/test/run-cryptomsg.c
+++ b/common/test/run-cryptomsg.c
@@ -2,6 +2,7 @@
#include <ccan/str/hex/hex.h>
#include <common/setup.h>
#include <common/status.h>
+#include <common/utils.h>
#include <stdio.h>
#include <wire/peer_wire.h>
diff --git a/common/test/run-json.c b/common/test/run-json.c
index b5fdecd..529d96c 100644
--- a/common/test/run-json.c
+++ b/common/test/run-json.c
@@ -5,6 +5,7 @@
#include <ccan/tal/str/str.h>
#include <common/channel_type.h>
#include <common/json_filter.h>
+#include <common/sciddir_or_pubkey.h>
#include <common/setup.h>
#include <inttypes.h>
#include <stdio.h>
diff --git a/common/trace.c b/common/trace.c
index eade317..a91adf2 100644
--- a/common/trace.c
+++ b/common/trace.c
@@ -11,6 +11,7 @@
#include <common/pseudorand.h>
#include <common/trace.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <stdio.h>
#include <unistd.h>
diff --git a/common/utils.h b/common/utils.h
index 26992fd..45b91f8 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_COMMON_UTILS_H
#define LIGHTNING_COMMON_UTILS_H
#include "config.h"
-#include <ccan/build_assert/build_assert.h>
#include <ccan/crypto/ripemd160/ripemd160.h>
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/short_types/short_types.h>
diff --git a/common/wire_error.c b/common/wire_error.c
index 512a1cf..bf82176 100644
--- a/common/wire_error.c
+++ b/common/wire_error.c
@@ -1,6 +1,7 @@
#include "config.h"
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
+#include <common/utils.h>
#include <common/wire_error.h>
#include <wire/peer_wire.h>
diff --git a/connectd/connectd.c b/connectd/connectd.c
index f04f2ca..17ec7d3 100644
--- a/connectd/connectd.c
+++ b/connectd/connectd.c
@@ -19,8 +19,10 @@
#include <ccan/tal/str/str.h>
#include <common/bech32.h>
#include <common/bech32_util.h>
+#include <common/cryptomsg.h>
#include <common/daemon_conn.h>
#include <common/dev_disconnect.h>
+#include <common/ecdh.h>
#include <common/ecdh_hsmd.h>
#include <common/gossip_store.h>
#include <common/gossmap.h>
@@ -29,6 +31,7 @@
#include <common/status.h>
#include <common/subdaemon.h>
#include <common/timeout.h>
+#include <common/utils.h>
#include <common/wire_error.h>
#include <connectd/connectd.h>
#include <connectd/connectd_gossipd_wiregen.h>
diff --git a/connectd/connectd.h b/connectd/connectd.h
index 5774c22..09778e2 100644
--- a/connectd/connectd.h
+++ b/connectd/connectd.h
@@ -1,16 +1,12 @@
#ifndef LIGHTNING_CONNECTD_CONNECTD_H
#define LIGHTNING_CONNECTD_CONNECTD_H
#include "config.h"
-#include <bitcoin/pubkey.h>
#include <bitcoin/short_channel_id.h>
-#include <ccan/crypto/siphash24/siphash24.h>
#include <ccan/htable/htable_type.h>
#include <ccan/timer/timer.h>
#include <common/bigsize.h>
-#include <common/channel_id.h>
#include <common/crypto_state.h>
#include <common/node_id.h>
-#include <common/pseudorand.h>
#include <common/wireaddr.h>
#include <connectd/handshake.h>
diff --git a/connectd/connectd_gossipd_wire.csv b/connectd/connectd_gossipd_wire.csv
index 195a734..d6be886 100644
--- a/connectd/connectd_gossipd_wire.csv
+++ b/connectd/connectd_gossipd_wire.csv
@@ -1,6 +1,4 @@
#include <common/node_id.h>
-#include <common/per_peer_state.h>
-#include <common/wireaddr.h>
# Communication between gossipd and connectd.
msgtype,gossipd_new_peer,4000
diff --git a/connectd/connectd_wire.csv b/connectd/connectd_wire.csv
index 23b7d37..78df85e 100644
--- a/connectd/connectd_wire.csv
+++ b/connectd/connectd_wire.csv
@@ -1,10 +1,8 @@
-#include <bitcoin/block.h>
#include <common/channel_id.h>
-#include <common/cryptomsg.h>
#include <common/features.h>
#include <common/node_id.h>
#include <common/wireaddr.h>
-#include <wire/onion_wire.h>
+#include <wire/onion_wiregen.h>
msgtype,connectd_init,2000
msgdata,connectd_init,chainparams,chainparams,
diff --git a/connectd/gossip_store.c b/connectd/gossip_store.c
index 7a6bb61..60da90f 100644
--- a/connectd/gossip_store.c
+++ b/connectd/gossip_store.c
@@ -1,6 +1,7 @@
#include "config.h"
#include <ccan/crc32c/crc32c.h>
#include <common/status.h>
+#include <common/utils.h>
#include <connectd/gossip_store.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/connectd/multiplex.c b/connectd/multiplex.c
index d2c7253..77cdfd5 100644
--- a/connectd/multiplex.c
+++ b/connectd/multiplex.c
@@ -29,6 +29,7 @@
#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>
diff --git a/connectd/onion_message.c b/connectd/onion_message.c
index 09940e8..1a9b42b 100644
--- a/connectd/onion_message.c
+++ b/connectd/onion_message.c
@@ -10,6 +10,7 @@
#include <common/onion_message_parse.h>
#include <common/sphinx.h>
#include <common/status.h>
+#include <common/utils.h>
#include <common/wire_error.h>
#include <connectd/connectd.h>
#include <connectd/connectd_wiregen.h>
diff --git a/connectd/peer_exchange_initmsg.c b/connectd/peer_exchange_initmsg.c
index b0a2954..de43633 100644
--- a/connectd/peer_exchange_initmsg.c
+++ b/connectd/peer_exchange_initmsg.c
@@ -1,9 +1,11 @@
#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>
#include <connectd/connectd.h>
#include <connectd/connectd_wiregen.h>
diff --git a/connectd/queries.c b/connectd/queries.c
index 3a680cb..351c469 100644
--- a/connectd/queries.c
+++ b/connectd/queries.c
@@ -8,6 +8,7 @@
#include <common/decode_array.h>
#include <common/gossmap.h>
#include <common/status.h>
+#include <common/utils.h>
#include <common/wire_error.h>
#include <connectd/connectd.h>
#include <connectd/connectd_wiregen.h>
diff --git a/db/common.h b/db/common.h
index 1ffd263..829a3d2 100644
--- a/db/common.h
+++ b/db/common.h
@@ -2,11 +2,8 @@
#define LIGHTNING_DB_COMMON_H
#include "config.h"
#include <ccan/list/list.h>
-#include <ccan/short_types/short_types.h>
-#include <ccan/strset/strset.h>
#include <common/autodata.h>
#include <common/utils.h>
-#include <stdarg.h>
/**
* Macro to annotate a named SQL query.
diff --git a/db/utils.c b/db/utils.c
index 155efbd..3b896f9 100644
--- a/db/utils.c
+++ b/db/utils.c
@@ -1,4 +1,5 @@
#include "config.h"
+#include <ccan/strset/strset.h>
#include <ccan/tal/str/str.h>
#include <common/trace.h>
#include <common/utils.h>
diff --git a/devtools/bolt11-cli.c b/devtools/bolt11-cli.c
index 5553822..02204fb 100644
--- a/devtools/bolt11-cli.c
+++ b/devtools/bolt11-cli.c
@@ -12,6 +12,7 @@
#include <common/bolt11.h>
#include <common/features.h>
#include <common/setup.h>
+#include <common/utils.h>
#include <common/version.h>
#include <inttypes.h>
#include <stdio.h>
diff --git a/devtools/bolt12-cli.c b/devtools/bolt12-cli.c
index 830d274..0aa6adc 100644
--- a/devtools/bolt12-cli.c
+++ b/devtools/bolt12-cli.c
@@ -11,6 +11,7 @@
#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>
diff --git a/devtools/checkchannels.c b/devtools/checkchannels.c
index bf7746d..235b110 100644
--- a/devtools/checkchannels.c
+++ b/devtools/checkchannels.c
@@ -11,6 +11,7 @@
#include <ccan/tal/path/path.h>
#include <common/configdir.h>
#include <common/node_id.h>
+#include <common/utils.h>
#include <inttypes.h>
#include <sqlite3.h>
diff --git a/devtools/convert-gossmap.c b/devtools/convert-gossmap.c
index dee2b1f..96ea795 100644
--- a/devtools/convert-gossmap.c
+++ b/devtools/convert-gossmap.c
@@ -5,6 +5,7 @@
#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>
diff --git a/devtools/create-gossipstore.c b/devtools/create-gossipstore.c
index b9376f4..320ad9f 100644
--- a/devtools/create-gossipstore.c
+++ b/devtools/create-gossipstore.c
@@ -4,6 +4,7 @@
#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 <inttypes.h>
diff --git a/devtools/decodemsg.c b/devtools/decodemsg.c
index 2a5d05c..390a409 100644
--- a/devtools/decodemsg.c
+++ b/devtools/decodemsg.c
@@ -3,6 +3,7 @@
#include <ccan/opt/opt.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <common/setup.h>
+#include <common/utils.h>
#include <unistd.h>
#include <wire/onion_printgen.h>
#include <wire/peer_printgen.h>
diff --git a/devtools/dump-gossipstore.c b/devtools/dump-gossipstore.c
index ced6a5a..2d69b06 100644
--- a/devtools/dump-gossipstore.c
+++ b/devtools/dump-gossipstore.c
@@ -3,6 +3,7 @@
#include <ccan/err/err.h>
#include <ccan/opt/opt.h>
#include <common/gossip_store.h>
+#include <common/utils.h>
#include <fcntl.h>
#include <gossipd/gossip_store_wiregen.h>
#include <stdio.h>
diff --git a/devtools/gossipwith.c b/devtools/gossipwith.c
index f506787..254e619 100644
--- a/devtools/gossipwith.c
+++ b/devtools/gossipwith.c
@@ -9,6 +9,7 @@
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
+#include <ccan/time/time.h>
#include <common/cryptomsg.h>
#include <common/features.h>
#include <common/peer_failed.h>
diff --git a/devtools/gossmap-compress.c b/devtools/gossmap-compress.c
index 0847fc1..58ef255 100644
--- a/devtools/gossmap-compress.c
+++ b/devtools/gossmap-compress.c
@@ -13,6 +13,7 @@
#include <common/gossip_store.h>
#include <common/gossmap.h>
#include <common/setup.h>
+#include <common/utils.h>
#include <errno.h>
#include <fcntl.h>
#include <gossipd/gossip_store_wiregen.h>
diff --git a/devtools/mkcommit.c b/devtools/mkcommit.c
index 069282b..3cfe80b 100644
--- a/devtools/mkcommit.c
+++ b/devtools/mkcommit.c
@@ -23,6 +23,7 @@
#include <common/htlc_wire.h>
#include <common/key_derive.h>
#include <common/status.h>
+#include <common/utils.h>
#include <common/version.h>
#include <inttypes.h>
#include <stdio.h>
diff --git a/devtools/mkencoded.c b/devtools/mkencoded.c
index 6ff556b..ba6f40d 100644
--- a/devtools/mkencoded.c
+++ b/devtools/mkencoded.c
@@ -4,6 +4,7 @@
#include <ccan/err/err.h>
#include <ccan/str/hex/hex.h>
#include <common/decode_array.h>
+#include <common/utils.h>
#include <stdio.h>
static NORETURN void usage(void)
diff --git a/devtools/mkgossip.c b/devtools/mkgossip.c
index 374b914..b68d8cf 100644
--- a/devtools/mkgossip.c
+++ b/devtools/mkgossip.c
@@ -8,11 +8,13 @@
*/
#include "config.h"
#include <assert.h>
+#include <bitcoin/signature.h>
#include <ccan/crc32c/crc32c.h>
#include <ccan/err/err.h>
#include <ccan/opt/opt.h>
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
+#include <common/utils.h>
#include <inttypes.h>
#include <stdio.h>
#include <wire/peer_wire.h>
diff --git a/devtools/mkquery.c b/devtools/mkquery.c
index 3bb4cef..9fe6e69 100644
--- a/devtools/mkquery.c
+++ b/devtools/mkquery.c
@@ -2,6 +2,7 @@
#include "config.h"
#include <ccan/err/err.h>
#include <ccan/str/hex/hex.h>
+#include <common/utils.h>
#include <stdio.h>
#include <wire/peer_wire.h>
diff --git a/devtools/onion.c b/devtools/onion.c
index ca723af..ee2f531 100644
--- a/devtools/onion.c
+++ b/devtools/onion.c
@@ -10,6 +10,7 @@
#include <common/onion_decode.h>
#include <common/onion_encode.h>
#include <common/sphinx.h>
+#include <common/utils.h>
#include <common/version.h>
#include <err.h>
diff --git a/devtools/print_wire.c b/devtools/print_wire.c
index 1566989..ba1285f 100644
--- a/devtools/print_wire.c
+++ b/devtools/print_wire.c
@@ -1,8 +1,13 @@
#include "config.h"
+#include <bitcoin/preimage.h>
+#include <bitcoin/signature.h>
+#include <bitcoin/tx.h>
#include <ccan/mem/mem.h>
#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>
#include <stdio.h>
diff --git a/devtools/print_wire.h b/devtools/print_wire.h
index 40c86d2..0a2a137 100644
--- a/devtools/print_wire.h
+++ b/devtools/print_wire.h
@@ -1,11 +1,7 @@
#ifndef LIGHTNING_DEVTOOLS_PRINT_WIRE_H
#define LIGHTNING_DEVTOOLS_PRINT_WIRE_H
#include "config.h"
-#include <bitcoin/preimage.h>
-#include <bitcoin/tx.h>
-#include <common/wireaddr.h>
-#include <wire/peer_wire.h>
-#include <wire/onion_wire.h>
+#include <wire/onion_wiregen.h>
struct tlv_print_record_type {
u64 type;
diff --git a/devtools/route.c b/devtools/route.c
index 684d04c..d13e3cf 100644
--- a/devtools/route.c
+++ b/devtools/route.c
@@ -6,6 +6,7 @@
#include <common/gossmap.h>
#include <common/route.h>
#include <common/setup.h>
+#include <common/utils.h>
#include <devtools/clean_topo.h>
#include <inttypes.h>
#include <stdio.h>
diff --git a/devtools/topology.c b/devtools/topology.c
index 649e669..181809d 100644
--- a/devtools/topology.c
+++ b/devtools/topology.c
@@ -6,6 +6,7 @@
#include <common/dijkstra.h>
#include <common/gossmap.h>
#include <common/route.h>
+#include <common/utils.h>
#include <devtools/clean_topo.h>
#include <inttypes.h>
#include <stdio.h>
diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c
index 15cae6b..4d49077 100644
--- a/gossipd/gossip_store.c
+++ b/gossipd/gossip_store.c
@@ -6,6 +6,7 @@
#include <ccan/tal/str/str.h>
#include <common/gossip_store.h>
#include <common/status.h>
+#include <common/utils.h>
#include <errno.h>
#include <fcntl.h>
#include <gossipd/gossip_store.h>
diff --git a/gossipd/gossip_store.h b/gossipd/gossip_store.h
index 96ff093..853b772 100644
--- a/gossipd/gossip_store.h
+++ b/gossipd/gossip_store.h
@@ -4,9 +4,6 @@
#include "config.h"
#include <bitcoin/short_channel_id.h>
-#include <ccan/list/list.h>
-#include <ccan/short_types/short_types.h>
-#include <ccan/tal/tal.h>
/**
* gossip_store -- On-disk storage related information
diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c
index 4180705..14b795f 100644
--- a/gossipd/gossipd.c
+++ b/gossipd/gossipd.c
@@ -21,6 +21,7 @@
#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>
diff --git a/gossipd/gossipd.h b/gossipd/gossipd.h
index 8318156..9ee193e 100644
--- a/gossipd/gossipd.h
+++ b/gossipd/gossipd.h
@@ -2,6 +2,7 @@
#define LIGHTNING_GOSSIPD_GOSSIPD_H
#include "config.h"
#include <ccan/ccan/opt/opt.h>
+#include <ccan/htable/htable_type.h>
#include <ccan/timer/timer.h>
#include <common/node_id.h>
#include <lightningd/options.h>
diff --git a/gossipd/gossipd_wire.csv b/gossipd/gossipd_wire.csv
index d8bee4b..c5868eb 100644
--- a/gossipd/gossipd_wire.csv
+++ b/gossipd/gossipd_wire.csv
@@ -2,7 +2,7 @@
#include <common/features.h>
#include <common/wireaddr.h>
#include <wire/peer_wire.h>
-#include <wire/onion_wire.h>
+#include <wire/onion_wiregen.h>
# Initialize the gossip daemon.
msgtype,gossipd_init,3000
diff --git a/gossipd/gossmap_manage.c b/gossipd/gossmap_manage.c
index 816c3f0..72c94f3 100644
--- a/gossipd/gossmap_manage.c
+++ b/gossipd/gossmap_manage.c
@@ -9,6 +9,7 @@
#include <common/memleak.h>
#include <common/status.h>
#include <common/timeout.h>
+#include <common/utils.h>
#include <common/wire_error.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/gossipd/queries.c b/gossipd/queries.c
index 707933f..8902a5f 100644
--- a/gossipd/queries.c
+++ b/gossipd/queries.c
@@ -8,6 +8,7 @@
#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>
diff --git a/gossipd/seeker.c b/gossipd/seeker.c
index 414aa3e..b822cb7 100644
--- a/gossipd/seeker.c
+++ b/gossipd/seeker.c
@@ -13,6 +13,7 @@
#include <common/random_select.h>
#include <common/status.h>
#include <common/timeout.h>
+#include <common/utils.h>
#include <gossipd/gossipd.h>
#include <gossipd/gossipd_wiregen.h>
#include <gossipd/gossmap_manage.h>
diff --git a/hsmd/hsm_utxo.h b/hsmd/hsm_utxo.h
index 62bea00..b7d8d71 100644
--- a/hsmd/hsm_utxo.h
+++ b/hsmd/hsm_utxo.h
@@ -1,8 +1,6 @@
#ifndef LIGHTNING_HSMD_HSM_UTXO_H
#define LIGHTNING_HSMD_HSM_UTXO_H
#include "config.h"
-#include <bitcoin/tx.h>
-#include <common/amount.h>
#include <common/utxo.h>
/* FIXME: If we make our static_remotekey a normal keypath key, we can
diff --git a/hsmd/hsmd.c b/hsmd/hsmd.c
index ff6d1e7..2d05e65 100644
--- a/hsmd/hsmd.c
+++ b/hsmd/hsmd.c
@@ -19,6 +19,7 @@
#include <common/status.h>
#include <common/status_wiregen.h>
#include <common/subdaemon.h>
+#include <common/utils.h>
#include <errno.h>
#include <fcntl.h>
/*~ _wiregen files are autogenerated by tools/generate-wire.py */
diff --git a/hsmd/hsmd_wire.csv b/hsmd/hsmd_wire.csv
index 4a8c7c7..4f4a40d 100644
--- a/hsmd/hsmd_wire.csv
+++ b/hsmd/hsmd_wire.csv
@@ -392,6 +392,7 @@ msgdata,hsmd_sign_bolt12,merkleroot,sha256,
msgdata,hsmd_sign_bolt12,publictweaklen,u16,
msgdata,hsmd_sign_bolt12,publictweak,u8,publictweaklen
+#include <bitcoin/signature.h>
msgtype,hsmd_sign_bolt12_reply,125
msgdata,hsmd_sign_bolt12_reply,sig,bip340sig,
diff --git a/hsmd/libhsmd.c b/hsmd/libhsmd.c
index 7e51fd8..f459f03 100644
--- a/hsmd/libhsmd.c
+++ b/hsmd/libhsmd.c
@@ -8,6 +8,7 @@
#include <common/hash_u5.h>
#include <common/key_derive.h>
#include <common/lease_rates.h>
+#include <common/utils.h>
#include <hsmd/libhsmd.h>
#include <hsmd/permissions.h>
#include <inttypes.h>
diff --git a/hsmd/libhsmd.h b/hsmd/libhsmd.h
index db92728..652340e 100644
--- a/hsmd/libhsmd.h
+++ b/hsmd/libhsmd.h
@@ -2,7 +2,6 @@
#define LIGHTNING_HSMD_LIBHSMD_H
#include "config.h"
-#include <common/node_id.h>
#include <common/status_levels.h>
#include <hsmd/hsmd_wiregen.h>
diff --git a/lightningd/bitcoind.h b/lightningd/bitcoind.h
index cf92e90..3daa509 100644
--- a/lightningd/bitcoind.h
+++ b/lightningd/bitcoind.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_LIGHTNINGD_BITCOIND_H
#define LIGHTNING_LIGHTNINGD_BITCOIND_H
#include "config.h"
-#include <bitcoin/chainparams.h>
#include <bitcoin/tx.h>
#include <ccan/list/list.h>
#include <ccan/strmap/strmap.h>
diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c
index 59f004f..1baab40 100644
--- a/lightningd/chaintopology.c
+++ b/lightningd/chaintopology.c
@@ -17,6 +17,7 @@
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/coin_mvts.h>
+#include <lightningd/feerate.h>
#include <lightningd/gossip_control.h>
#include <lightningd/invoice.h>
#include <lightningd/io_loop_with_timers.h>
diff --git a/lightningd/chaintopology.h b/lightningd/chaintopology.h
index 4f80d21..f6aa818 100644
--- a/lightningd/chaintopology.h
+++ b/lightningd/chaintopology.h
@@ -1,9 +1,6 @@
#ifndef LIGHTNING_LIGHTNINGD_CHAINTOPOLOGY_H
#define LIGHTNING_LIGHTNINGD_CHAINTOPOLOGY_H
#include "config.h"
-#include <bitcoin/block.h>
-#include <ccan/list/list.h>
-#include <lightningd/feerate.h>
#include <lightningd/watch.h>
struct bitcoin_tx;
diff --git a/lightningd/channel.h b/lightningd/channel.h
index fd8e031..3606d0f 100644
--- a/lightningd/channel.h
+++ b/lightningd/channel.h
@@ -1,6 +1,7 @@
#ifndef LIGHTNING_LIGHTNINGD_CHANNEL_H
#define LIGHTNING_LIGHTNINGD_CHANNEL_H
#include "config.h"
+#include <bitcoin/signature.h>
#include <ccan/htable/htable_type.h>
#include <common/channel_config.h>
#include <common/channel_id.h>
diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c
index a72f959..93d76a7 100644
--- a/lightningd/channel_control.c
+++ b/lightningd/channel_control.c
@@ -23,6 +23,7 @@
#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>
diff --git a/lightningd/channel_state.h b/lightningd/channel_state.h
index 26d12d8..9db105f 100644
--- a/lightningd/channel_state.h
+++ b/lightningd/channel_state.h
@@ -2,7 +2,6 @@
#define LIGHTNING_LIGHTNINGD_CHANNEL_STATE_H
#include "config.h"
-#include <ccan/time/time.h>
/* These are in the database, so don't renumber them! */
enum channel_state {
diff --git a/lightningd/closing_control.c b/lightningd/closing_control.c
index 36fe90f..dbf604b 100644
--- a/lightningd/closing_control.c
+++ b/lightningd/closing_control.c
@@ -27,6 +27,7 @@
#include <lightningd/closing_control.h>
#include <lightningd/connect_control.h>
#include <lightningd/dual_open_control.h>
+#include <lightningd/feerate.h>
#include <lightningd/hsm_control.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c
index 2cdeb61..437beaa 100644
--- a/lightningd/connect_control.c
+++ b/lightningd/connect_control.c
@@ -1,6 +1,7 @@
#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>
diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c
index ab84e3f..8e6a651 100644
--- a/lightningd/dual_open_control.c
+++ b/lightningd/dual_open_control.c
@@ -25,6 +25,7 @@
#include <lightningd/closing_control.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>
diff --git a/lightningd/forwards.h b/lightningd/forwards.h
index f65dd16..0436035 100644
--- a/lightningd/forwards.h
+++ b/lightningd/forwards.h
@@ -2,7 +2,8 @@
#ifndef LIGHTNING_LIGHTNINGD_FORWARDS_H
#define LIGHTNING_LIGHTNINGD_FORWARDS_H
#include "config.h"
-#include <wire/onion_wire.h>
+#include <ccan/time/time.h>
+#include <wire/onion_wiregen.h>
struct json_stream;
struct lightningd;
diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c
index 4e931a7..207e41b 100644
--- a/lightningd/gossip_control.c
+++ b/lightningd/gossip_control.c
@@ -1,5 +1,6 @@
#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>
diff --git a/lightningd/gossip_control.h b/lightningd/gossip_control.h
index 06a2487..49baa7f 100644
--- a/lightningd/gossip_control.h
+++ b/lightningd/gossip_control.h
@@ -2,8 +2,6 @@
#define LIGHTNING_LIGHTNINGD_GOSSIP_CONTROL_H
#include "config.h"
#include <bitcoin/short_channel_id.h>
-#include <ccan/short_types/short_types.h>
-#include <stdbool.h>
struct channel;
struct lightningd;
diff --git a/lightningd/htlc_end.c b/lightningd/htlc_end.c
index 91d66b0..b557808 100644
--- a/lightningd/htlc_end.c
+++ b/lightningd/htlc_end.c
@@ -5,6 +5,7 @@
#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>
diff --git a/lightningd/htlc_set.h b/lightningd/htlc_set.h
index c93ca15..bb0119d 100644
--- a/lightningd/htlc_set.h
+++ b/lightningd/htlc_set.h
@@ -7,7 +7,6 @@
#include <common/amount.h>
#include <common/pseudorand.h>
#include <common/utils.h>
-#include <wire/onion_wire.h>
struct lightningd;
struct logger;
diff --git a/lightningd/invoice.h b/lightningd/invoice.h
index 90c31cb..43e98b2 100644
--- a/lightningd/invoice.h
+++ b/lightningd/invoice.h
@@ -2,7 +2,6 @@
#define LIGHTNING_LIGHTNINGD_INVOICE_H
#include "config.h"
#include <wallet/wallet.h>
-#include <wire/onion_wire.h>
struct amount_msat;
struct htlc_set;
diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c
index 5a350da..7044d97 100644
--- a/lightningd/lightningd.c
+++ b/lightningd/lightningd.c
@@ -37,6 +37,7 @@
*/
#include <ccan/array_size/array_size.h>
#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>
@@ -51,6 +52,7 @@
#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>
diff --git a/lightningd/opening_common.h b/lightningd/opening_common.h
index 8b75b56..21ca822 100644
--- a/lightningd/opening_common.h
+++ b/lightningd/opening_common.h
@@ -1,8 +1,6 @@
#ifndef LIGHTNING_LIGHTNINGD_OPENING_COMMON_H
#define LIGHTNING_LIGHTNINGD_OPENING_COMMON_H
#include "config.h"
-#include <bitcoin/pubkey.h>
-#include <common/amount.h>
#include <common/channel_config.h>
#include <common/channel_id.h>
#include <common/derive_basepoints.h>
diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c
index 7c12a0f..ffd6cab 100644
--- a/lightningd/opening_control.c
+++ b/lightningd/opening_control.c
@@ -20,6 +20,7 @@
#include <lightningd/channel.h>
#include <lightningd/channel_control.h>
#include <lightningd/connect_control.h>
+#include <lightningd/feerate.h>
#include <lightningd/hsm_control.h>
#include <lightningd/notification.h>
#include <lightningd/opening_common.h>
diff --git a/lightningd/options.c b/lightningd/options.c
index e565c62..5f84b72 100644
--- a/lightningd/options.c
+++ b/lightningd/options.c
@@ -15,6 +15,7 @@
#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>
@@ -26,6 +27,7 @@
#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>
diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c
index fa458cb..98f596b 100644
--- a/lightningd/peer_control.c
+++ b/lightningd/peer_control.c
@@ -71,7 +71,6 @@
#include <stdlib.h>
#include <unistd.h>
#include <wally_bip32.h>
-#include <wire/onion_wire.h>
#include <wire/wire_sync.h>
/* FIXME: Reorder! */
diff --git a/lightningd/peer_fd.h b/lightningd/peer_fd.h
index a6e1f01..8904126 100644
--- a/lightningd/peer_fd.h
+++ b/lightningd/peer_fd.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_LIGHTNINGD_PEER_FD_H
#define LIGHTNING_LIGHTNINGD_PEER_FD_H
#include "config.h"
-#include <ccan/compiler/compiler.h>
#include <ccan/tal/tal.h>
/* Tal wrapper for fd connecting subd to connectd */
diff --git a/lightningd/runes.c b/lightningd/runes.c
index 77be7a3..9085497 100644
--- a/lightningd/runes.c
+++ b/lightningd/runes.c
@@ -14,6 +14,7 @@
#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>
diff --git a/lightningd/subd.c b/lightningd/subd.c
index 263ce03..c3f59f0 100644
--- a/lightningd/subd.c
+++ b/lightningd/subd.c
@@ -7,6 +7,7 @@
#include <ccan/tal/path/path.h>
#include <ccan/tal/str/str.h>
#include <common/memleak.h>
+#include <common/msg_queue.h>
#include <common/peer_status_wiregen.h>
#include <common/status_wiregen.h>
#include <common/version.h>
diff --git a/lightningd/subd.h b/lightningd/subd.h
index c572a77..8518b06 100644
--- a/lightningd/subd.h
+++ b/lightningd/subd.h
@@ -1,12 +1,7 @@
#ifndef LIGHTNING_LIGHTNINGD_SUBD_H
#define LIGHTNING_LIGHTNINGD_SUBD_H
#include "config.h"
-#include <ccan/endian/endian.h>
#include <ccan/list/list.h>
-#include <ccan/short_types/short_types.h>
-#include <ccan/tal/tal.h>
-#include <ccan/typesafe_cb/typesafe_cb.h>
-#include <common/msg_queue.h>
#include <wire/wire.h>
struct crypto_state;
diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c
index 0fbc866..024aaf4 100644
--- a/onchaind/onchaind.c
+++ b/onchaind/onchaind.c
@@ -17,6 +17,7 @@
#include <common/status.h>
#include <common/subdaemon.h>
#include <hsmd/hsmd_wiregen.h>
+#include <inttypes.h>
#include <onchaind/onchain_types.h>
#include <onchaind/onchaind_wiregen.h>
#include <unistd.h>
diff --git a/onchaind/onchaind_wire.csv b/onchaind/onchaind_wire.csv
index f8f5e8e..3c9c76b 100644
--- a/onchaind/onchaind_wire.csv
+++ b/onchaind/onchaind_wire.csv
@@ -1,3 +1,4 @@
+#include <bitcoin/signature.h>
#include <bitcoin/tx_parts.h>
#include <common/bip32.h>
#include <common/coin_mvt.h>
diff --git a/openingd/common.h b/openingd/common.h
index aab8bd8..3464494 100644
--- a/openingd/common.h
+++ b/openingd/common.h
@@ -2,6 +2,7 @@
#define LIGHTNING_OPENINGD_COMMON_H
#include "config.h"
+#include <common/utils.h>
struct amount_sat;
struct bitcoin_tx;
diff --git a/openingd/dualopend.c b/openingd/dualopend.c
index 8e902fa..eeca905 100644
--- a/openingd/dualopend.c
+++ b/openingd/dualopend.c
@@ -38,9 +38,11 @@
#include <common/wire_error.h>
#include <errno.h>
#include <hsmd/hsmd_wiregen.h>
+#include <inttypes.h>
#include <openingd/common.h>
#include <openingd/dualopend_wiregen.h>
#include <unistd.h>
+#include <wally_script.h>
#include <wire/wire_sync.h>
/* stdin == lightningd, 3 == peer, 4 = hsmd */
diff --git a/openingd/dualopend_wire.csv b/openingd/dualopend_wire.csv
index 3484139..d6b1574 100644
--- a/openingd/dualopend_wire.csv
+++ b/openingd/dualopend_wire.csv
@@ -1,5 +1,6 @@
#include <bitcoin/chainparams.h>
#include <bitcoin/psbt.h>
+#include <bitcoin/signature.h>
#include <common/cryptomsg.h>
#include <common/channel_config.h>
#include <common/channel_id.h>
diff --git a/openingd/openingd_wire.csv b/openingd/openingd_wire.csv
index c70de6c..f96c50b 100644
--- a/openingd/openingd_wire.csv
+++ b/openingd/openingd_wire.csv
@@ -1,4 +1,5 @@
#include <bitcoin/chainparams.h>
+#include <bitcoin/signature.h>
#include <common/cryptomsg.h>
#include <common/channel_config.h>
#include <common/channel_id.h>
diff --git a/plugins/askrene/askrene.c b/plugins/askrene/askrene.c
index 9664d24..fff49c0 100644
--- a/plugins/askrene/askrene.c
+++ b/plugins/askrene/askrene.c
@@ -17,6 +17,7 @@
#include <common/json_stream.h>
#include <common/route.h>
#include <errno.h>
+#include <inttypes.h>
#include <math.h>
#include <plugins/askrene/askrene.h>
#include <plugins/askrene/flow.h>
diff --git a/plugins/askrene/mcf.c b/plugins/askrene/mcf.c
index 4614fb4..8d69511 100644
--- a/plugins/askrene/mcf.c
+++ b/plugins/askrene/mcf.c
@@ -7,6 +7,7 @@
#include <ccan/tal/tal.h>
#include <common/utils.h>
#include <float.h>
+#include <inttypes.h>
#include <math.h>
#include <plugins/askrene/algorithm.h>
#include <plugins/askrene/askrene.h>
diff --git a/plugins/askrene/reserve.c b/plugins/askrene/reserve.c
index abec937..59457fc 100644
--- a/plugins/askrene/reserve.c
+++ b/plugins/askrene/reserve.c
@@ -5,6 +5,7 @@
#include <common/gossmap.h>
#include <common/json_stream.h>
#include <common/memleak.h>
+#include <inttypes.h>
#include <plugins/askrene/askrene.h>
#include <plugins/askrene/reserve.h>
diff --git a/plugins/autoclean.c b/plugins/autoclean.c
index bfd358c..8be8ce2 100644
--- a/plugins/autoclean.c
+++ b/plugins/autoclean.c
@@ -6,6 +6,7 @@
#include <common/json_param.h>
#include <common/json_stream.h>
#include <common/memleak.h>
+#include <inttypes.h>
#include <plugins/libplugin.h>
static u64 cycle_seconds = 3600;
diff --git a/plugins/bcli.c b/plugins/bcli.c
index fdd5a7c..b1e655b 100644
--- a/plugins/bcli.c
+++ b/plugins/bcli.c
@@ -11,6 +11,7 @@
#include <common/json_stream.h>
#include <common/memleak.h>
#include <errno.h>
+#include <inttypes.h>
#include <plugins/libplugin.h>
/* Bitcoind's web server has a default of 4 threads, with queue depth 16.
diff --git a/plugins/bkpr/bookkeeper.c b/plugins/bkpr/bookkeeper.c
index 75fb76a..93f44e5 100644
--- a/plugins/bkpr/bookkeeper.c
+++ b/plugins/bkpr/bookkeeper.c
@@ -15,6 +15,7 @@
#include <common/node_id.h>
#include <db/exec.h>
#include <errno.h>
+#include <inttypes.h>
#include <plugins/bkpr/account.h>
#include <plugins/bkpr/account_entry.h>
#include <plugins/bkpr/blockheights.h>
diff --git a/plugins/bkpr/rebalances.c b/plugins/bkpr/rebalances.c
index 38bbdcd..91d9dd6 100644
--- a/plugins/bkpr/rebalances.c
+++ b/plugins/bkpr/rebalances.c
@@ -8,6 +8,7 @@
#include <common/memleak.h>
#include <common/node_id.h>
#include <common/utils.h>
+#include <inttypes.h>
#include <plugins/bkpr/bookkeeper.h>
#include <plugins/bkpr/rebalances.h>
#include <plugins/libplugin.h>
diff --git a/plugins/chanbackup.c b/plugins/chanbackup.c
index 11091ed..034c3ec 100644
--- a/plugins/chanbackup.c
+++ b/plugins/chanbackup.c
@@ -16,6 +16,7 @@
#include <common/scb_wiregen.h>
#include <errno.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <plugins/libplugin.h>
#include <sodium.h>
#include <unistd.h>
diff --git a/plugins/channel_hint.c b/plugins/channel_hint.c
index 1db3779..cf431cb 100644
--- a/plugins/channel_hint.c
+++ b/plugins/channel_hint.c
@@ -1,4 +1,5 @@
#include "config.h"
+#include <common/json_stream.h>
#include <common/memleak.h>
#include <plugins/channel_hint.h>
diff --git a/plugins/channel_hint.h b/plugins/channel_hint.h
index 200458f..db94c5b 100644
--- a/plugins/channel_hint.h
+++ b/plugins/channel_hint.h
@@ -2,11 +2,6 @@
#define LIGHTNING_PLUGINS_CHANNEL_HINT_H
#include "config.h"
-#include <bitcoin/short_channel_id.h>
-#include <ccan/short_types/short_types.h>
-#include <ccan/time/time.h>
-#include <common/amount.h>
-#include <common/json_stream.h>
#include <plugins/libplugin.h>
/* Information about channels we inferred from a) looking at our channels, and
diff --git a/plugins/commando.c b/plugins/commando.c
index 608e8df..ae23d7a 100644
--- a/plugins/commando.c
+++ b/plugins/commando.c
@@ -13,6 +13,7 @@
#include <common/json_stream.h>
#include <common/memleak.h>
#include <common/pseudorand.h>
+#include <inttypes.h>
#include <plugins/libplugin.h>
/* We (as your local commando command) detected an error. */
diff --git a/plugins/establish_onion_path.c b/plugins/establish_onion_path.c
index bfef89c..c74bc44 100644
--- a/plugins/establish_onion_path.c
+++ b/plugins/establish_onion_path.c
@@ -1,6 +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>
diff --git a/plugins/establish_onion_path.h b/plugins/establish_onion_path.h
index bb9a055..19411fe 100644
--- a/plugins/establish_onion_path.h
+++ b/plugins/establish_onion_path.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_PLUGINS_ESTABLISH_ONION_PATH_H
#define LIGHTNING_PLUGINS_ESTABLISH_ONION_PATH_H
#include "config.h"
-#include <ccan/typesafe_cb/typesafe_cb.h>
#include <plugins/libplugin.h>
struct gossmap;
diff --git a/plugins/fetchinvoice.c b/plugins/fetchinvoice.c
index c7013e6..10362e8 100644
--- a/plugins/fetchinvoice.c
+++ b/plugins/fetchinvoice.c
@@ -10,6 +10,7 @@
#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>
@@ -20,6 +21,7 @@
#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>
diff --git a/plugins/funder.c b/plugins/funder.c
index cae9534..af2997b 100644
--- a/plugins/funder.c
+++ b/plugins/funder.c
@@ -16,6 +16,7 @@
#include <common/memleak.h>
#include <common/overflows.h>
#include <common/psbt_open.h>
+#include <inttypes.h>
#include <plugins/funder_policy.h>
#include <plugins/libplugin.h>
diff --git a/plugins/keysend.c b/plugins/keysend.c
index 6104bf6..79a6600 100644
--- a/plugins/keysend.c
+++ b/plugins/keysend.c
@@ -4,11 +4,14 @@
#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>
#include <sodium.h>
diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c
index 5409e00..9b3bd5f 100644
--- a/plugins/libplugin-pay.c
+++ b/plugins/libplugin-pay.c
@@ -3,17 +3,22 @@
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/blindedpay.h>
+#include <common/bolt11.h>
#include <common/daemon.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/memleak.h>
#include <common/pseudorand.h>
#include <common/random_select.h>
+#include <common/route.h>
#include <common/trace.h>
#include <errno.h>
+#include <inttypes.h>
#include <math.h>
+#include <plugins/channel_hint.h>
#include <plugins/libplugin-pay.h>
#include <stdio.h>
#include <sys/types.h>
diff --git a/plugins/libplugin-pay.h b/plugins/libplugin-pay.h
index bc1ec51..4df7d3f 100644
--- a/plugins/libplugin-pay.h
+++ b/plugins/libplugin-pay.h
@@ -3,11 +3,8 @@
#include "config.h"
#include <ccan/io/io.h>
-#include <common/bolt11.h>
-#include <common/route.h>
-#include <plugins/channel_hint.h>
#include <plugins/libplugin.h>
-#include <wire/onion_wire.h>
+#include <wire/onion_wiregen.h>
struct legacy_payload {
struct short_channel_id scid;
diff --git a/plugins/libplugin.c b/plugins/libplugin.c
index 167d136..6e74026 100644
--- a/plugins/libplugin.c
+++ b/plugins/libplugin.c
@@ -3,11 +3,13 @@
#include <bitcoin/privkey.h>
#include <ccan/io/io.h>
#include <ccan/json_out/json_out.h>
+#include <ccan/membuf/membuf.h>
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/tal/path/path.h>
#include <ccan/tal/str/str.h>
#include <common/daemon.h>
#include <common/deprecation.h>
+#include <common/features.h>
#include <common/json_filter.h>
#include <common/json_param.h>
#include <common/json_parse_simple.h>
@@ -17,6 +19,7 @@
#include <common/route.h>
#include <common/trace.h>
#include <errno.h>
+#include <inttypes.h>
#include <plugins/libplugin.h>
#include <stdio.h>
#include <sys/socket.h>
diff --git a/plugins/libplugin.h b/plugins/libplugin.h
index 5504299..cec028b 100644
--- a/plugins/libplugin.h
+++ b/plugins/libplugin.h
@@ -3,21 +3,11 @@
#define LIGHTNING_PLUGINS_LIBPLUGIN_H
#include "config.h"
-#include <bitcoin/tx.h>
-#include <ccan/intmap/intmap.h>
-#include <ccan/membuf/membuf.h>
-#include <ccan/strmap/strmap.h>
-#include <ccan/time/time.h>
#include <ccan/timer/timer.h>
-#include <common/errcode.h>
-#include <common/features.h>
#include <common/htlc.h>
#include <common/json_command.h>
-#include <common/jsonrpc_errors.h>
#include <common/node_id.h>
-#include <common/status_levels.h>
#include <common/utils.h>
-#include <stdarg.h>
struct json_out;
struct htable;
diff --git a/plugins/offers.c b/plugins/offers.c
index 575d7a8..5daf8b6 100644
--- a/plugins/offers.c
+++ b/plugins/offers.c
@@ -11,6 +11,7 @@
#include <common/bolt11_json.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_blinded_path.h>
@@ -19,6 +20,7 @@
#include <common/memleak.h>
#include <common/onion_message.h>
#include <errno.h>
+#include <inttypes.h>
#include <plugins/establish_onion_path.h>
#include <plugins/fetchinvoice.h>
#include <plugins/offers.h>
diff --git a/plugins/offers_inv_hook.c b/plugins/offers_inv_hook.c
index 07bc1a7..4772899 100644
--- a/plugins/offers_inv_hook.c
+++ b/plugins/offers_inv_hook.c
@@ -3,6 +3,7 @@
#include <ccan/tal/str/str.h>
#include <common/bolt12_id.h>
#include <common/bolt12_merkle.h>
+#include <common/features.h>
#include <common/json_stream.h>
#include <plugins/offers.h>
#include <plugins/offers_inv_hook.h>
diff --git a/plugins/offers_invreq_hook.c b/plugins/offers_invreq_hook.c
index 5c8cb14..3a7574f 100644
--- a/plugins/offers_invreq_hook.c
+++ b/plugins/offers_invreq_hook.c
@@ -8,6 +8,7 @@
#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>
@@ -15,6 +16,7 @@
#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>
diff --git a/plugins/offers_offer.c b/plugins/offers_offer.c
index e7c7ded..77eae2c 100644
--- a/plugins/offers_offer.c
+++ b/plugins/offers_offer.c
@@ -4,6 +4,7 @@
#include <ccan/tal/str/str.h>
#include <common/bolt12.h>
#include <common/bolt12_id.h>
+#include <common/features.h>
#include <common/gossmap.h>
#include <common/iso4217.h>
#include <common/json_param.h>
diff --git a/plugins/pay.c b/plugins/pay.c
index 7deaf85..20de6e1 100644
--- a/plugins/pay.c
+++ b/plugins/pay.c
@@ -9,6 +9,7 @@
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
#include <common/bolt12_merkle.h>
+#include <common/features.h>
#include <common/gossmap.h>
#include <common/json_param.h>
#include <common/json_stream.h>
diff --git a/plugins/renepay/disabledmap.c b/plugins/renepay/disabledmap.c
index 68492ec..badeac8 100644
--- a/plugins/renepay/disabledmap.c
+++ b/plugins/renepay/disabledmap.c
@@ -1,4 +1,5 @@
#include "config.h"
+#include <common/utils.h>
#include <plugins/renepay/disabledmap.h>
struct disabledmap *disabledmap_new(const tal_t *ctx)
diff --git a/plugins/renepay/main.c b/plugins/renepay/main.c
index 01b4d13..8d92ea7 100644
--- a/plugins/renepay/main.c
+++ b/plugins/renepay/main.c
@@ -5,6 +5,7 @@
#include <ccan/tal/str/str.h>
#include <common/bolt11.h>
#include <common/bolt12_merkle.h>
+#include <common/features.h>
#include <common/gossmap.h>
#include <common/gossmods_listpeerchannels.h>
#include <common/json_param.h>
diff --git a/plugins/spender/multifundchannel.c b/plugins/spender/multifundchannel.c
index 5fef052..af42573 100644
--- a/plugins/spender/multifundchannel.c
+++ b/plugins/spender/multifundchannel.c
@@ -11,6 +11,7 @@
#include <common/memleak.h>
#include <common/psbt_open.h>
#include <common/pseudorand.h>
+#include <inttypes.h>
#include <plugins/spender/multifundchannel.h>
#include <plugins/spender/openchannel.h>
diff --git a/plugins/spender/multiwithdraw.c b/plugins/spender/multiwithdraw.c
index c6f4481..7950d1d 100644
--- a/plugins/spender/multiwithdraw.c
+++ b/plugins/spender/multiwithdraw.c
@@ -9,6 +9,7 @@
#include <common/json_stream.h>
#include <common/psbt_open.h>
#include <common/pseudorand.h>
+#include <inttypes.h>
#include <plugins/spender/multiwithdraw.h>
#include <wally_psbt.h>
diff --git a/plugins/spender/openchannel.c b/plugins/spender/openchannel.c
index 90c5cdb..85d15b0 100644
--- a/plugins/spender/openchannel.c
+++ b/plugins/spender/openchannel.c
@@ -6,6 +6,7 @@
#include <common/json_stream.h>
#include <common/lease_rates.h>
#include <common/psbt_open.h>
+#include <inttypes.h>
#include <plugins/spender/multifundchannel.h>
#include <plugins/spender/openchannel.h>
diff --git a/plugins/spender/splice.c b/plugins/spender/splice.c
index 1c8ce72..35098c0 100644
--- a/plugins/spender/splice.c
+++ b/plugins/spender/splice.c
@@ -11,6 +11,7 @@
#include <common/json_stream.h>
#include <common/psbt_open.h>
#include <common/splice_script.h>
+#include <inttypes.h>
#include <plugins/spender/splice.h>
struct abort_pkg {
diff --git a/plugins/topology.c b/plugins/topology.c
index 4c84d02..4a44084 100644
--- a/plugins/topology.c
+++ b/plugins/topology.c
@@ -14,6 +14,7 @@
#include <common/route.h>
#include <common/wireaddr.h>
#include <errno.h>
+#include <inttypes.h>
#include <plugins/libplugin.h>
/* Access via get_gossmap() */
diff --git a/plugins/xpay/xpay.c b/plugins/xpay/xpay.c
index bf5f9cb..b4e2c41 100644
--- a/plugins/xpay/xpay.c
+++ b/plugins/xpay/xpay.c
@@ -9,6 +9,7 @@
#include <common/bolt12.h>
#include <common/daemon.h>
#include <common/dijkstra.h>
+#include <common/features.h>
#include <common/gossmap.h>
#include <common/gossmods_listpeerchannels.h>
#include <common/json_param.h>
@@ -20,6 +21,7 @@
#include <common/route.h>
#include <common/wireaddr.h>
#include <errno.h>
+#include <inttypes.h>
#include <plugins/libplugin.h>
#include <stdarg.h>
diff --git a/tests/fuzz/fuzz-bolt12-invrequest-decode.c b/tests/fuzz/fuzz-bolt12-invrequest-decode.c
index 5a3ba5d..159fb26 100644
--- a/tests/fuzz/fuzz-bolt12-invrequest-decode.c
+++ b/tests/fuzz/fuzz-bolt12-invrequest-decode.c
@@ -1,4 +1,5 @@
#include "config.h"
+#include <assert.h>
#include <ccan/mem/mem.h>
#include <common/bolt12.h>
#include <common/utils.h>
diff --git a/tests/fuzz/libfuzz.h b/tests/fuzz/libfuzz.h
index cd09503..332caa3 100644
--- a/tests/fuzz/libfuzz.h
+++ b/tests/fuzz/libfuzz.h
@@ -4,6 +4,7 @@
#include "config.h"
#include <ccan/ccan/short_types/short_types.h>
#include <ccan/ccan/tal/tal.h>
+#include <common/utils.h>
#include <stddef.h>
#include <stdint.h>
diff --git a/tests/plugins/channeld_fakenet.c b/tests/plugins/channeld_fakenet.c
index fc08d2b..d56c582 100644
--- a/tests/plugins/channeld_fakenet.c
+++ b/tests/plugins/channeld_fakenet.c
@@ -27,6 +27,7 @@
#include <common/status.h>
#include <common/subdaemon.h>
#include <common/timeout.h>
+#include <common/utils.h>
#include <common/wire_error.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/tools/hsmtool.c b/tools/hsmtool.c
index 7f2d30f..484ef2b 100644
--- a/tools/hsmtool.c
+++ b/tools/hsmtool.c
@@ -24,6 +24,7 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <wally_bip32.h>
#include <wally_bip39.h>
diff --git a/wallet/reservation.c b/wallet/reservation.c
index 9c100a0..23cdaad 100644
--- a/wallet/reservation.c
+++ b/wallet/reservation.c
@@ -11,6 +11,7 @@
#include <common/psbt_open.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
+#include <lightningd/feerate.h>
#include <lightningd/hsm_control.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c
index 0c29382..6371dfb 100644
--- a/wallet/test/run-wallet.c
+++ b/wallet/test/run-wallet.c
@@ -40,6 +40,7 @@ static void test_error(struct lightningd *ld, bool fatal, const char *fmt, va_li
#include <common/setup.h>
#include <common/utils.h>
#include <stdio.h>
+#include <wally_script.h>
/* AUTOGENERATED MOCKS START */
/* Generated stub for add_node_announcement_sig */
diff --git a/wallet/txfilter.c b/wallet/txfilter.c
index 10ef774..b962286 100644
--- a/wallet/txfilter.c
+++ b/wallet/txfilter.c
@@ -4,6 +4,7 @@
#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.h b/wallet/wallet.h
index f956196..7eb1a51 100644
--- a/wallet/wallet.h
+++ b/wallet/wallet.h
@@ -18,6 +18,7 @@
#include <lightningd/wait.h>
struct amount_msat;
+struct bitcoin_signature;
struct invoices;
struct channel;
struct channel_inflight;
diff --git a/wire/Makefile b/wire/Makefile
index d695f1a..6d10c3e 100644
--- a/wire/Makefile
+++ b/wire/Makefile
@@ -74,6 +74,8 @@ wire/peer_wiregen.h_args := --include='common/channel_id.h' --include='bitcoin/t
wire/peer_wiregen.c_args := -s --expose-tlv-type=tlv_n1 --expose-tlv-type=tlv_n2
+wire/peer_printgen.c_args := --include='wire/peer_wiregen.h'
+
# The payload isn't parsed in a fromwire, so we need to expose it.
wire/onion_wiregen.h_args := --include='bitcoin/short_channel_id.h' --include='bitcoin/privkey.h' --include='common/bigsize.h' --include='common/amount.h' --include='common/node_id.h' --include='bitcoin/block.h' --include='common/sciddir_or_pubkey.h' -s --expose-tlv-type=tlv_payload
@@ -86,8 +88,8 @@ wire/peer_exp_printgen.h_args := --include='wire/channel_type_printgen.h'
wire/onion_exp_wiregen.h_args := $(wire/onion_wiregen.h_args)
wire/onion_exp_wiregen.c_args := $(wire/onion_wiregen.c_args)
-wire/bolt12_wiregen.c_args := -s --expose-tlv-type=tlv_blinded_path --expose-tlv-type=tlv_invoice_request --expose-tlv-type=tlv_invoice
-wire/bolt12_wiregen.h_args := --include='bitcoin/short_channel_id.h' --include='bitcoin/signature.h' --include='bitcoin/privkey.h' --include='common/bigsize.h' --include='common/amount.h' --include='common/node_id.h' --include='bitcoin/block.h' --include='wire/onion_wire.h' $(wire/bolt12_wiregen.c_args)
+wire/bolt12_wiregen.c_args := -s --expose-tlv-type=tlv_blinded_path --expose-tlv-type=tlv_invoice_request --expose-tlv-type=tlv_invoice --include='wire/onion_wiregen.h'
+wire/bolt12_wiregen.h_args := --include='bitcoin/short_channel_id.h' --include='bitcoin/signature.h' --include='bitcoin/privkey.h' --include='common/bigsize.h' --include='common/amount.h' --include='common/node_id.h' --include='bitcoin/block.h' $(wire/bolt12_wiregen.c_args)
wire/bolt12_printgen.c_args := --expose-tlv-type=tlv_blinded_path --expose-tlv-type=tlv_invoice_request --include='wire/onion_wiregen.h' --include='wire/onion_printgen.h'
wire/bolt12_printgen.h_args := --include='wire/bolt12_wiregen.h' --expose-tlv-type=tlv_blinded_path --expose-tlv-type=tlv_invoice_request
diff --git a/wire/onion_defs.h b/wire/onion_defs.h
index cdfc0b3..312636f 100644
--- a/wire/onion_defs.h
+++ b/wire/onion_defs.h
@@ -2,7 +2,6 @@
#ifndef LIGHTNING_WIRE_ONION_DEFS_H
#define LIGHTNING_WIRE_ONION_DEFS_H
#include "config.h"
-#include <common/sciddir_or_pubkey.h>
/* BOLT #4:
*
diff --git a/wire/onion_wire.h b/wire/onion_wire.h
deleted file mode 100644
index 54947d4..0000000
--- a/wire/onion_wire.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef LIGHTNING_WIRE_ONION_WIRE_H
-#define LIGHTNING_WIRE_ONION_WIRE_H
-#include "config.h"
-#include <stdbool.h>
-
-#include <wire/onion_wiregen.h>
-
-#endif /* LIGHTNING_WIRE_ONION_WIRE_H */
diff --git a/wire/peer_wire.h b/wire/peer_wire.h
index 2097a3c..760e062 100644
--- a/wire/peer_wire.h
+++ b/wire/peer_wire.h
@@ -1,7 +1,6 @@
#ifndef LIGHTNING_WIRE_PEER_WIRE_H
#define LIGHTNING_WIRE_PEER_WIRE_H
#include "config.h"
-#include <stdbool.h>
#include <wire/peer_wiregen.h>
diff --git a/wire/tlvstream.c b/wire/tlvstream.c
index 9e1c774..8afb7f2 100644
--- a/wire/tlvstream.c
+++ b/wire/tlvstream.c
@@ -1,6 +1,7 @@
#include "config.h"
#include <ccan/asort/asort.h>
#include <common/bigsize.h>
+#include <common/utils.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
diff --git a/wire/tlvstream.h b/wire/tlvstream.h
index 090ba4e..a8a76e3 100644
--- a/wire/tlvstream.h
+++ b/wire/tlvstream.h
@@ -2,8 +2,6 @@
#define LIGHTNING_WIRE_TLVSTREAM_H
#include "config.h"
#include <bitcoin/short_channel_id.h>
-#include <ccan/short_types/short_types.h>
-#include <ccan/tal/tal.h>
struct tlv_record_type {
u64 type;
diff --git a/wire/wire.h b/wire/wire.h
index 548f5b0..8e8f12a 100644
--- a/wire/wire.h
+++ b/wire/wire.h
@@ -1,12 +1,9 @@
#ifndef LIGHTNING_WIRE_WIRE_H
#define LIGHTNING_WIRE_WIRE_H
#include "config.h"
-#include <ccan/short_types/short_types.h>
-#include <ccan/tal/tal.h>
#include <common/jsonrpc_errors.h>
#include <common/wireaddr.h>
#include <secp256k1_recovery.h>
-#include <stdlib.h>
struct ripemd160;
struct sha256;
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.