From cfb320c972e384c7202f2ec19c7b0e47132fed8b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 16 May 2020 10:59:05 +0930 Subject: [PATCH] wire: move remaining bitcoin functions out to bitcoin/ files. Signed-off-by: Rusty Russell --- bitcoin/block.c | 7 ++- bitcoin/chainparams.h | 6 +- bitcoin/privkey.c | 21 +++++++ bitcoin/privkey.h | 7 +++ bitcoin/pubkey.c | 30 ++++++++++ bitcoin/pubkey.h | 5 ++ bitcoin/shadouble.c | 12 ++++ bitcoin/shadouble.h | 6 ++ bitcoin/test/run-bitcoin_block_from_hex.c | 13 ++--- bitcoin/test/run-secret_eq_consttime.c | 6 ++ bitcoin/test/run-tx-encode.c | 13 ++--- bitcoin/tx.c | 1 + channeld/test/run-commit_tx.c | 18 ++++-- channeld/test/run-full_channel.c | 18 ++++-- cli/test/run-large-input.c | 19 +++++-- cli/test/run-remove-hint.c | 19 +++++-- closingd/Makefile | 1 + common/bigsize.c | 25 +++++++++ common/bigsize.h | 11 ++++ common/bip32.c | 13 +++++ common/bip32.h | 9 +++ common/features.c | 1 + common/fee_states.c | 1 + common/json_helpers.c | 1 + common/json_helpers.h | 4 +- common/node_id.c | 14 +++++ common/node_id.h | 3 + common/sphinx.h | 2 + common/status_wire.csv | 1 + common/test/run-amount.c | 13 ++--- common/test/run-bigsize.c | 14 ++--- common/test/run-bolt11.c | 6 -- common/test/run-cryptomsg.c | 13 ++--- common/test/run-derive_basepoints.c | 32 +++-------- common/test/run-features.c | 13 ++--- common/test/run-funding_tx.c | 19 ++----- common/test/run-gossip_rcvd_filter.c | 9 +-- common/test/run-ip_port_parsing.c | 14 ++--- common/test/run-json_remove.c | 14 ++--- common/test/run-key_derive.c | 14 ++--- common/test/run-lock.c | 14 ++--- common/test/run-softref.c | 14 ++--- common/test/run-sphinx.c | 9 ++- connectd/connect_gossip_wire.csv | 1 + connectd/peer_exchange_initmsg.c | 1 + connectd/test/run-initiator-success.c | 14 ++--- connectd/test/run-responder-success.c | 14 ++--- devtools/mkcommit.c | 2 + devtools/mkgossip.c | 1 + gossipd/gossip_peerd_wire.csv | 2 + gossipd/gossip_store.csv | 1 + gossipd/queries.c | 1 + gossipd/routing.c | 1 + gossipd/seeker.c | 2 + lightningd/test/run-find_my_abspath.c | 18 ++++-- lightningd/test/run-invoice-select-inchan.c | 18 ++++-- lightningd/test/run-jsonrpc.c | 18 ++++-- lightningd/test/run-log-pruning.c | 18 ++++-- onchaind/Makefile | 1 + onchaind/test/run-grind_feerate-bug.c | 13 ++--- onchaind/test/run-grind_feerate.c | 13 ++--- openingd/Makefile | 1 + openingd/opening_wire.csv | 1 + plugins/Makefile | 1 + plugins/keysend.c | 1 + plugins/pay.c | 1 + tests/plugins/test_libplugin.c | 1 + tools/test/Makefile | 2 +- tools/test/test_cases | 3 + wallet/test/run-db.c | 6 -- wallet/test/run-wallet.c | 3 - wire/Makefile | 4 +- wire/fromwire.c | 61 --------------------- wire/peer_wire.c | 1 + wire/test/Makefile | 3 +- wire/test/run-peer-wire.c | 2 + wire/test/run-tlvstream.c | 9 +-- wire/tlvstream.c | 1 + wire/towire.c | 49 ----------------- wire/wire.h | 37 +------------ 80 files changed, 434 insertions(+), 377 deletions(-) diff --git a/bitcoin/block.c b/bitcoin/block.c index 3306e25828da..1951b0b1e887 100644 --- a/bitcoin/block.c +++ b/bitcoin/block.c @@ -1,6 +1,7 @@ -#include "bitcoin/block.h" -#include "bitcoin/pullpush.h" -#include "bitcoin/tx.h" +#include +#include +#include +#include #include #include #include diff --git a/bitcoin/chainparams.h b/bitcoin/chainparams.h index e041a79a1f9d..40a6ea8fad7e 100644 --- a/bitcoin/chainparams.h +++ b/bitcoin/chainparams.h @@ -6,13 +6,9 @@ #include #include #include +#include #include -struct bip32_key_version { - u32 bip32_pubkey_version; - u32 bip32_privkey_version; -}; - struct chainparams { const char *network_name; const char *bip173_name; diff --git a/bitcoin/privkey.c b/bitcoin/privkey.c index db8e2987b187..bdd83b361c3f 100644 --- a/bitcoin/privkey.c +++ b/bitcoin/privkey.c @@ -3,6 +3,7 @@ #include #include #include +#include static char *privkey_to_hexstr(const tal_t *ctx, const struct privkey *secret) { @@ -22,3 +23,23 @@ bool secret_eq_consttime(const struct secret *a, const struct secret *b) result |= a->data[i] ^ b->data[i]; return result == 0; } + +void towire_privkey(u8 **pptr, const struct privkey *privkey) +{ + towire_secret(pptr, &privkey->secret); +} + +void towire_secret(u8 **pptr, const struct secret *secret) +{ + towire(pptr, secret->data, sizeof(secret->data)); +} + +void fromwire_secret(const u8 **cursor, size_t *max, struct secret *secret) +{ + fromwire(cursor, max, secret->data, sizeof(secret->data)); +} + +void fromwire_privkey(const u8 **cursor, size_t *max, struct privkey *privkey) +{ + fromwire_secret(cursor, max, &privkey->secret); +} diff --git a/bitcoin/privkey.h b/bitcoin/privkey.h index c9966f21b608..9bebf602d865 100644 --- a/bitcoin/privkey.h +++ b/bitcoin/privkey.h @@ -18,4 +18,11 @@ bool secret_eq_consttime(const struct secret *a, const struct secret *b); struct privkey { struct secret secret; }; + +/* marshal/unmarshal functions */ +void fromwire_secret(const u8 **cursor, size_t *max, struct secret *secret); +void fromwire_privkey(const u8 **cursor, size_t *max, struct privkey *privkey); +void towire_privkey(u8 **pptr, const struct privkey *privkey); +void towire_secret(u8 **pptr, const struct secret *secret); + #endif /* LIGHTNING_BITCOIN_PRIVKEY_H */ diff --git a/bitcoin/pubkey.c b/bitcoin/pubkey.c index 345e50e1a0a2..e92c8aab9f28 100644 --- a/bitcoin/pubkey.c +++ b/bitcoin/pubkey.c @@ -5,6 +5,11 @@ #include #include #include +#include + +#ifndef SUPERVERBOSE +#define SUPERVERBOSE(...) +#endif bool pubkey_from_der(const u8 *der, size_t len, struct pubkey *key) { @@ -95,3 +100,28 @@ void pubkey_to_hash160(const struct pubkey *pk, struct ripemd160 *hash) sha256(&h, der, sizeof(der)); ripemd160(hash, h.u.u8, sizeof(h)); } + +void fromwire_pubkey(const u8 **cursor, size_t *max, struct pubkey *pubkey) +{ + u8 der[PUBKEY_CMPR_LEN]; + + if (!fromwire(cursor, max, der, sizeof(der))) + return; + + if (!pubkey_from_der(der, sizeof(der), pubkey)) { + SUPERVERBOSE("not a valid point"); + fromwire_fail(cursor, max); + } +} + +void towire_pubkey(u8 **pptr, const struct pubkey *pubkey) +{ + u8 output[PUBKEY_CMPR_LEN]; + size_t outputlen = sizeof(output); + + secp256k1_ec_pubkey_serialize(secp256k1_ctx, output, &outputlen, + &pubkey->pubkey, + SECP256K1_EC_COMPRESSED); + + towire(pptr, output, outputlen); +} diff --git a/bitcoin/pubkey.h b/bitcoin/pubkey.h index 16f3f6693d29..7477d9f56da3 100644 --- a/bitcoin/pubkey.h +++ b/bitcoin/pubkey.h @@ -55,4 +55,9 @@ static inline int pubkey_idx(const struct pubkey *id1, const struct pubkey *id2) * pubkey_to_hash160 - Get the hash for p2pkh payments for a given pubkey */ void pubkey_to_hash160(const struct pubkey *pk, struct ripemd160 *hash); + +/* marshal/unmarshal functions */ +void towire_pubkey(u8 **pptr, const struct pubkey *pubkey); +void fromwire_pubkey(const u8 **cursor, size_t *max, struct pubkey *pubkey); + #endif /* LIGHTNING_BITCOIN_PUBKEY_H */ diff --git a/bitcoin/shadouble.c b/bitcoin/shadouble.c index 01b51a2db69d..775b893433e8 100644 --- a/bitcoin/shadouble.c +++ b/bitcoin/shadouble.c @@ -1,6 +1,7 @@ #include "shadouble.h" #include #include +#include void sha256_double(struct sha256_double *shadouble, const void *p, size_t len) { @@ -14,3 +15,14 @@ void sha256_double_done(struct sha256_ctx *shactx, struct sha256_double *res) sha256(&res->sha, &res->sha, sizeof(res->sha)); } REGISTER_TYPE_TO_HEXSTR(sha256_double); + +void towire_sha256_double(u8 **pptr, const struct sha256_double *sha256d) +{ + towire_sha256(pptr, &sha256d->sha); +} + +void fromwire_sha256_double(const u8 **cursor, size_t *max, + struct sha256_double *sha256d) +{ + fromwire_sha256(cursor, max, &sha256d->sha); +} diff --git a/bitcoin/shadouble.h b/bitcoin/shadouble.h index f447df7f19a0..c87e37ed1a19 100644 --- a/bitcoin/shadouble.h +++ b/bitcoin/shadouble.h @@ -2,6 +2,7 @@ #define LIGHTNING_BITCOIN_SHADOUBLE_H #include "config.h" #include +#include /* To explicitly distinguish between single sha and bitcoin's standard double */ struct sha256_double { @@ -11,4 +12,9 @@ struct sha256_double { void sha256_double(struct sha256_double *shadouble, const void *p, size_t len); void sha256_double_done(struct sha256_ctx *sha256, struct sha256_double *res); + +/* marshal/unmarshal functions */ +void fromwire_sha256_double(const u8 **cursor, size_t *max, + struct sha256_double *sha256d); +void towire_sha256_double(u8 **pptr, const struct sha256_double *sha256d); #endif /* LIGHTNING_BITCOIN_SHADOUBLE_H */ diff --git a/bitcoin/test/run-bitcoin_block_from_hex.c b/bitcoin/test/run-bitcoin_block_from_hex.c index 2d028f009a35..6b7401754083 100644 --- a/bitcoin/test/run-bitcoin_block_from_hex.c +++ b/bitcoin/test/run-bitcoin_block_from_hex.c @@ -31,10 +31,9 @@ struct amount_sat fromwire_amount_sat(const u8 **cursor UNNEEDED, size_t *max UN /* Generated stub for fromwire_fail */ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_fail called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -45,9 +44,9 @@ u16 fromwire_u16(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) /* Generated stub for towire_amount_sat */ void towire_amount_sat(u8 **pptr UNNEEDED, const struct amount_sat sat UNNEEDED) { fprintf(stderr, "towire_amount_sat called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/bitcoin/test/run-secret_eq_consttime.c b/bitcoin/test/run-secret_eq_consttime.c index 69590d013b86..f0cea7aae537 100644 --- a/bitcoin/test/run-secret_eq_consttime.c +++ b/bitcoin/test/run-secret_eq_consttime.c @@ -6,6 +6,12 @@ #include /* AUTOGENERATED MOCKS START */ +/* Generated stub for fromwire */ +const u8 *fromwire(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, void *copy UNNEEDED, size_t n UNNEEDED) +{ fprintf(stderr, "fromwire called!\n"); abort(); } +/* Generated stub for towire */ +void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "towire called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ static bool verbose = false; diff --git a/bitcoin/test/run-tx-encode.c b/bitcoin/test/run-tx-encode.c index 8f69a760a4eb..d11778a16239 100644 --- a/bitcoin/test/run-tx-encode.c +++ b/bitcoin/test/run-tx-encode.c @@ -32,10 +32,9 @@ struct amount_sat fromwire_amount_sat(const u8 **cursor UNNEEDED, size_t *max UN /* Generated stub for fromwire_fail */ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_fail called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -46,9 +45,9 @@ u16 fromwire_u16(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) /* Generated stub for towire_amount_sat */ void towire_amount_sat(u8 **pptr UNNEEDED, const struct amount_sat sat UNNEEDED) { fprintf(stderr, "towire_amount_sat called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/bitcoin/tx.c b/bitcoin/tx.c index e529326a142f..af281fdf2be3 100644 --- a/bitcoin/tx.c +++ b/bitcoin/tx.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/channeld/test/run-commit_tx.c b/channeld/test/run-commit_tx.c index b7505919d1fd..511ac8cc3715 100644 --- a/channeld/test/run-commit_tx.c +++ b/channeld/test/run-commit_tx.c @@ -21,25 +21,31 @@ static bool print_superverbose; /*#define DEBUG */ /* AUTOGENERATED MOCKS START */ -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } -/* Generated stub for bigsize_put */ -size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) -{ fprintf(stderr, "bigsize_put called!\n"); abort(); } +/* Generated stub for fromwire_bigsize */ +bigsize_t fromwire_bigsize(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) +{ fprintf(stderr, "fromwire_bigsize called!\n"); abort(); } /* Generated stub for fromwire_channel_id */ void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "fromwire_channel_id called!\n"); abort(); } +/* Generated stub for fromwire_node_id */ +void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED) +{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); } /* Generated stub for status_fmt */ void status_fmt(enum log_level level UNNEEDED, const struct node_id *peer UNNEEDED, const char *fmt UNNEEDED, ...) { fprintf(stderr, "status_fmt called!\n"); abort(); } +/* Generated stub for towire_bigsize */ +void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED) +{ fprintf(stderr, "towire_bigsize called!\n"); abort(); } /* Generated stub for towire_channel_id */ void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "towire_channel_id called!\n"); abort(); } +/* Generated stub for towire_node_id */ +void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) +{ fprintf(stderr, "towire_node_id called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ /* bitcoind loves its backwards txids! */ diff --git a/channeld/test/run-full_channel.c b/channeld/test/run-full_channel.c index e358f4e67074..50804646680d 100644 --- a/channeld/test/run-full_channel.c +++ b/channeld/test/run-full_channel.c @@ -16,16 +16,16 @@ #include /* AUTOGENERATED MOCKS START */ -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } -/* Generated stub for bigsize_put */ -size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) -{ fprintf(stderr, "bigsize_put called!\n"); abort(); } +/* Generated stub for fromwire_bigsize */ +bigsize_t fromwire_bigsize(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) +{ fprintf(stderr, "fromwire_bigsize called!\n"); abort(); } /* Generated stub for fromwire_channel_id */ void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "fromwire_channel_id called!\n"); abort(); } +/* Generated stub for fromwire_node_id */ +void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED) +{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); } /* Generated stub for memleak_add_helper_ */ void memleak_add_helper_(const tal_t *p UNNEEDED, void (*cb)(struct htable *memtable UNNEEDED, const tal_t *)){ } @@ -36,9 +36,15 @@ void memleak_remove_htable(struct htable *memtable UNNEEDED, const struct htable void status_failed(enum status_failreason code UNNEEDED, const char *fmt UNNEEDED, ...) { fprintf(stderr, "status_failed called!\n"); abort(); } +/* Generated stub for towire_bigsize */ +void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED) +{ fprintf(stderr, "towire_bigsize called!\n"); abort(); } /* Generated stub for towire_channel_id */ void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "towire_channel_id called!\n"); abort(); } +/* Generated stub for towire_node_id */ +void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) +{ fprintf(stderr, "towire_node_id called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ void status_fmt(enum log_level level UNUSED, diff --git a/cli/test/run-large-input.c b/cli/test/run-large-input.c index 91e7dec3e32a..cee090de43e7 100644 --- a/cli/test/run-large-input.c +++ b/cli/test/run-large-input.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -51,22 +52,22 @@ bool amount_sat_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED) struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED) { fprintf(stderr, "amount_sat_sub called!\n"); abort(); } -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } -/* Generated stub for bigsize_put */ -size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) -{ fprintf(stderr, "bigsize_put called!\n"); abort(); } /* Generated stub for fromwire_amount_msat */ struct amount_msat fromwire_amount_msat(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_amount_msat called!\n"); abort(); } /* Generated stub for fromwire_amount_sat */ struct amount_sat fromwire_amount_sat(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_amount_sat called!\n"); abort(); } +/* Generated stub for fromwire_bigsize */ +bigsize_t fromwire_bigsize(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) +{ fprintf(stderr, "fromwire_bigsize called!\n"); abort(); } /* Generated stub for fromwire_channel_id */ void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "fromwire_channel_id called!\n"); abort(); } +/* Generated stub for fromwire_node_id */ +void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED) +{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); } /* Generated stub for json_add_member */ void json_add_member(struct json_stream *js UNNEEDED, const char *fieldname UNNEEDED, @@ -95,9 +96,15 @@ void towire_amount_msat(u8 **pptr UNNEEDED, const struct amount_msat msat UNNEED /* Generated stub for towire_amount_sat */ void towire_amount_sat(u8 **pptr UNNEEDED, const struct amount_sat sat UNNEEDED) { fprintf(stderr, "towire_amount_sat called!\n"); abort(); } +/* Generated stub for towire_bigsize */ +void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED) +{ fprintf(stderr, "towire_bigsize called!\n"); abort(); } /* Generated stub for towire_channel_id */ void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "towire_channel_id called!\n"); abort(); } +/* Generated stub for towire_node_id */ +void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) +{ fprintf(stderr, "towire_node_id called!\n"); abort(); } /* Generated stub for version_and_exit */ char *version_and_exit(const void *unused UNNEEDED) { fprintf(stderr, "version_and_exit called!\n"); abort(); } diff --git a/cli/test/run-remove-hint.c b/cli/test/run-remove-hint.c index d7c1b02a96bd..f621fea31847 100644 --- a/cli/test/run-remove-hint.c +++ b/cli/test/run-remove-hint.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -54,22 +55,22 @@ bool amount_sat_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED) struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED) { fprintf(stderr, "amount_sat_sub called!\n"); abort(); } -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } -/* Generated stub for bigsize_put */ -size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) -{ fprintf(stderr, "bigsize_put called!\n"); abort(); } /* Generated stub for fromwire_amount_msat */ struct amount_msat fromwire_amount_msat(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_amount_msat called!\n"); abort(); } /* Generated stub for fromwire_amount_sat */ struct amount_sat fromwire_amount_sat(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_amount_sat called!\n"); abort(); } +/* Generated stub for fromwire_bigsize */ +bigsize_t fromwire_bigsize(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) +{ fprintf(stderr, "fromwire_bigsize called!\n"); abort(); } /* Generated stub for fromwire_channel_id */ void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "fromwire_channel_id called!\n"); abort(); } +/* Generated stub for fromwire_node_id */ +void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED) +{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); } /* Generated stub for json_add_member */ void json_add_member(struct json_stream *js UNNEEDED, const char *fieldname UNNEEDED, @@ -98,9 +99,15 @@ void towire_amount_msat(u8 **pptr UNNEEDED, const struct amount_msat msat UNNEED /* Generated stub for towire_amount_sat */ void towire_amount_sat(u8 **pptr UNNEEDED, const struct amount_sat sat UNNEEDED) { fprintf(stderr, "towire_amount_sat called!\n"); abort(); } +/* Generated stub for towire_bigsize */ +void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED) +{ fprintf(stderr, "towire_bigsize called!\n"); abort(); } /* Generated stub for towire_channel_id */ void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "towire_channel_id called!\n"); abort(); } +/* Generated stub for towire_node_id */ +void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) +{ fprintf(stderr, "towire_node_id called!\n"); abort(); } /* Generated stub for version_and_exit */ char *version_and_exit(const void *unused UNNEEDED) { fprintf(stderr, "version_and_exit called!\n"); abort(); } diff --git a/closingd/Makefile b/closingd/Makefile index 99a8e5f748d7..dd709a3551aa 100644 --- a/closingd/Makefile +++ b/closingd/Makefile @@ -63,6 +63,7 @@ CLOSINGD_COMMON_OBJS := \ common/key_derive.o \ common/memleak.o \ common/msg_queue.o \ + common/node_id.o \ common/onionreply.o \ common/peer_billboard.o \ common/peer_failed.o \ diff --git a/common/bigsize.c b/common/bigsize.c index 674fa8970b00..18be939d582b 100644 --- a/common/bigsize.c +++ b/common/bigsize.c @@ -1,4 +1,6 @@ +#include #include +#include #ifndef SUPERVERBOSE #define SUPERVERBOSE(...) @@ -97,3 +99,26 @@ size_t bigsize_get(const u8 *p, size_t max, bigsize_t *val) return 1; } } + +bigsize_t fromwire_bigsize(const u8 **cursor, size_t *max) +{ + bigsize_t v; + size_t len = bigsize_get(*cursor, *max, &v); + + if (len == 0) { + fromwire_fail(cursor, max); + return 0; + } + assert(len <= *max); + fromwire(cursor, max, NULL, len); + return v; +} + +void towire_bigsize(u8 **pptr, const bigsize_t val) +{ + u8 buf[BIGSIZE_MAX_LEN]; + size_t len; + + len = bigsize_put(buf, val); + towire(pptr, buf, len); +} diff --git a/common/bigsize.h b/common/bigsize.h index 1c582896faf4..fe2d2bc78b0f 100644 --- a/common/bigsize.h +++ b/common/bigsize.h @@ -18,4 +18,15 @@ size_t bigsize_get(const u8 *p, size_t max, bigsize_t *val); /* How many bytes does it take to encode v? */ size_t bigsize_len(bigsize_t v); +/* Used for wire generation */ +typedef bigsize_t bigsize; + +/* FIXME: Some versions of spec using 'varint' for bigsize' */ +typedef bigsize varint; +#define fromwire_varint fromwire_bigsize +#define towire_varint towire_bigsize + +/* marshal/unmarshal functions */ +void towire_bigsize(u8 **pptr, const bigsize_t val); +bigsize_t fromwire_bigsize(const u8 **cursor, size_t *max); #endif /* LIGHTNING_COMMON_BIGSIZE_H */ diff --git a/common/bip32.c b/common/bip32.c index f2c22870e72f..f4be88500dd7 100644 --- a/common/bip32.c +++ b/common/bip32.c @@ -23,3 +23,16 @@ void fromwire_ext_key(const u8 **cursor, size_t *max, struct ext_key *bip32) if (bip32_key_unserialize(in, BIP32_SERIALIZED_LEN, bip32) != WALLY_OK) fromwire_fail(cursor, max); } + +void fromwire_bip32_key_version(const u8** cursor, size_t *max, + struct bip32_key_version *version) +{ + version->bip32_pubkey_version = fromwire_u32(cursor, max); + version->bip32_privkey_version = fromwire_u32(cursor, max); +} + +void towire_bip32_key_version(u8 **pptr, const struct bip32_key_version *version) +{ + towire_u32(pptr, version->bip32_pubkey_version); + towire_u32(pptr, version->bip32_privkey_version); +} diff --git a/common/bip32.h b/common/bip32.h index 1b8bb3d6e747..f0895fadd2aa 100644 --- a/common/bip32.h +++ b/common/bip32.h @@ -9,4 +9,13 @@ struct ext_key; void towire_ext_key(u8 **pptr, const struct ext_key *bip32); void fromwire_ext_key(const u8 **cursor, size_t *max, struct ext_key *bip32); +struct bip32_key_version { + u32 bip32_pubkey_version; + u32 bip32_privkey_version; +}; + +void towire_bip32_key_version(u8 **cursor, const struct bip32_key_version *version); +void fromwire_bip32_key_version(const u8 **cursor, size_t *max, + struct bip32_key_version *version); + #endif /* LIGHTNING_COMMON_BIP32_H */ diff --git a/common/features.c b/common/features.c index 490cb18a94f8..efa1dfdbb0c2 100644 --- a/common/features.c +++ b/common/features.c @@ -1,6 +1,7 @@ #include "features.h" #include #include +#include #include #include #include diff --git a/common/fee_states.c b/common/fee_states.c index 591ac21327dd..59497d73861a 100644 --- a/common/fee_states.c +++ b/common/fee_states.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/common/json_helpers.c b/common/json_helpers.c index 44a0eb4d7e4c..a4daa12d5815 100644 --- a/common/json_helpers.c +++ b/common/json_helpers.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/common/json_helpers.h b/common/json_helpers.h index 2d422bbf0897..d5e1de92f154 100644 --- a/common/json_helpers.h +++ b/common/json_helpers.h @@ -9,8 +9,10 @@ struct amount_msat; struct amount_sat; struct channel_id; -struct pubkey; struct node_id; +struct preimage; +struct pubkey; +struct secret; struct short_channel_id; struct wireaddr; struct wireaddr_internal; diff --git a/common/node_id.c b/common/node_id.c index 4633c40ef766..82d66a34975b 100644 --- a/common/node_id.c +++ b/common/node_id.c @@ -1,9 +1,11 @@ +#include #include #include #include #include #include #include +#include /* Convert from pubkey to compressed pubkey. */ void node_id_from_pubkey(struct node_id *id, const struct pubkey *key) @@ -48,3 +50,15 @@ int node_id_cmp(const struct node_id *a, const struct node_id *b) { return memcmp(a->k, b->k, sizeof(a->k)); } + +void fromwire_node_id(const u8 **cursor, size_t *max, struct node_id *id) +{ + fromwire(cursor, max, &id->k, sizeof(id->k)); +} + +void towire_node_id(u8 **pptr, const struct node_id *id) +{ + /* Cheap sanity check */ + assert(id->k[0] == 0x2 || id->k[0] == 0x3); + towire(pptr, id->k, sizeof(id->k)); +} diff --git a/common/node_id.h b/common/node_id.h index 15144927c7ad..1f23c9d335fc 100644 --- a/common/node_id.h +++ b/common/node_id.h @@ -40,4 +40,7 @@ static inline int node_id_idx(const struct node_id *id1, return node_id_cmp(id1, id2) > 0; } +/* marshal/unmarshal functions */ +void towire_node_id(u8 **pptr, const struct node_id *id); +void fromwire_node_id(const u8 **cursor, size_t *max, struct node_id *id); #endif /* LIGHTNING_COMMON_NODE_ID_H */ diff --git a/common/sphinx.h b/common/sphinx.h index e9e5927b2d9a..e3a54f2a57a3 100644 --- a/common/sphinx.h +++ b/common/sphinx.h @@ -12,6 +12,8 @@ #include #include +struct node_id; + #define VERSION_SIZE 1 #define REALM_SIZE 1 #define HMAC_SIZE 32 diff --git a/common/status_wire.csv b/common/status_wire.csv index 739834f77d57..d427af9d2b6f 100644 --- a/common/status_wire.csv +++ b/common/status_wire.csv @@ -1,4 +1,5 @@ #include +#include #include msgtype,status_log,0xFFF0 diff --git a/common/test/run-amount.c b/common/test/run-amount.c index 10750395d3bc..13b8fcbcfb39 100644 --- a/common/test/run-amount.c +++ b/common/test/run-amount.c @@ -17,10 +17,9 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -44,9 +43,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-bigsize.c b/common/test/run-bigsize.c index 99456f8bed07..8129cee1aa58 100644 --- a/common/test/run-bigsize.c +++ b/common/test/run-bigsize.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -47,10 +48,9 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -99,9 +99,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-bolt11.c b/common/test/run-bolt11.c index 7ce3b17dff18..5068ab3bbde1 100644 --- a/common/test/run-bolt11.c +++ b/common/test/run-bolt11.c @@ -15,12 +15,6 @@ #include /* AUTOGENERATED MOCKS START */ -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } -/* Generated stub for bigsize_put */ -size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) -{ fprintf(stderr, "bigsize_put called!\n"); abort(); } /* Generated stub for type_to_string_ */ const char *type_to_string_(const tal_t *ctx UNNEEDED, const char *typename UNNEEDED, union printable_types u UNNEEDED) diff --git a/common/test/run-cryptomsg.c b/common/test/run-cryptomsg.c index 5b9e1c580907..a3446d91e96d 100644 --- a/common/test/run-cryptomsg.c +++ b/common/test/run-cryptomsg.c @@ -43,10 +43,9 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -73,9 +72,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-derive_basepoints.c b/common/test/run-derive_basepoints.c index ebf6b1731a07..83793bfca58a 100644 --- a/common/test/run-derive_basepoints.c +++ b/common/test/run-derive_basepoints.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -39,23 +40,13 @@ bool fromwire_bool(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) /* Generated stub for fromwire_fail */ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_fail called!\n"); abort(); } -/* Generated stub for fromwire_privkey */ -void fromwire_privkey(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct privkey *privkey UNNEEDED) -{ fprintf(stderr, "fromwire_privkey called!\n"); abort(); } -/* Generated stub for fromwire_pubkey */ -void fromwire_pubkey(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct pubkey *pubkey UNNEEDED) -{ fprintf(stderr, "fromwire_pubkey called!\n"); abort(); } /* Generated stub for fromwire_secp256k1_ecdsa_signature */ void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_secret */ -void fromwire_secret(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct secret *secret UNNEEDED) -{ fprintf(stderr, "fromwire_secret called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -78,22 +69,13 @@ void towire_amount_sat(u8 **pptr UNNEEDED, const struct amount_sat sat UNNEEDED) /* Generated stub for towire_bool */ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) { fprintf(stderr, "towire_bool called!\n"); abort(); } -/* Generated stub for towire_privkey */ -void towire_privkey(u8 **pptr UNNEEDED, const struct privkey *privkey UNNEEDED) -{ fprintf(stderr, "towire_privkey called!\n"); abort(); } -/* Generated stub for towire_pubkey */ -void towire_pubkey(u8 **pptr UNNEEDED, const struct pubkey *pubkey UNNEEDED) -{ fprintf(stderr, "towire_pubkey called!\n"); abort(); } /* Generated stub for towire_secp256k1_ecdsa_signature */ void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_secret */ -void towire_secret(u8 **pptr UNNEEDED, const struct secret *secret UNNEEDED) -{ fprintf(stderr, "towire_secret called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-features.c b/common/test/run-features.c index 6be58c70b0ed..5e0b39f7026a 100644 --- a/common/test/run-features.c +++ b/common/test/run-features.c @@ -43,10 +43,9 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -73,9 +72,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-funding_tx.c b/common/test/run-funding_tx.c index ec8f30d0a52b..cdb7378fd38e 100644 --- a/common/test/run-funding_tx.c +++ b/common/test/run-funding_tx.c @@ -30,17 +30,13 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) /* Generated stub for fromwire_node_id */ void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED) { fprintf(stderr, "fromwire_node_id called!\n"); abort(); } -/* Generated stub for fromwire_pubkey */ -void fromwire_pubkey(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct pubkey *pubkey UNNEEDED) -{ fprintf(stderr, "fromwire_pubkey called!\n"); abort(); } /* Generated stub for fromwire_secp256k1_ecdsa_signature */ void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -66,16 +62,13 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) /* Generated stub for towire_node_id */ void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) { fprintf(stderr, "towire_node_id called!\n"); abort(); } -/* Generated stub for towire_pubkey */ -void towire_pubkey(u8 **pptr UNNEEDED, const struct pubkey *pubkey UNNEEDED) -{ fprintf(stderr, "towire_pubkey called!\n"); abort(); } /* Generated stub for towire_secp256k1_ecdsa_signature */ void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-gossip_rcvd_filter.c b/common/test/run-gossip_rcvd_filter.c index 54a750f0a4e0..14d7f01ac5fd 100644 --- a/common/test/run-gossip_rcvd_filter.c +++ b/common/test/run-gossip_rcvd_filter.c @@ -24,9 +24,6 @@ bool amount_sat_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED) struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED) { fprintf(stderr, "amount_sat_sub called!\n"); abort(); } -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } /* Generated stub for fromwire_amount_sat */ struct amount_sat fromwire_amount_sat(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_amount_sat called!\n"); abort(); } @@ -46,9 +43,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-ip_port_parsing.c b/common/test/run-ip_port_parsing.c index dc10012bda87..3962ead86e9f 100644 --- a/common/test/run-ip_port_parsing.c +++ b/common/test/run-ip_port_parsing.c @@ -4,6 +4,7 @@ #include #include #include +#include /* AUTOGENERATED MOCKS START */ /* Generated stub for amount_asset_is_main */ @@ -41,10 +42,9 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -74,9 +74,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-json_remove.c b/common/test/run-json_remove.c index 69cf6178d120..fea1a4cda2c6 100644 --- a/common/test/run-json_remove.c +++ b/common/test/run-json_remove.c @@ -1,4 +1,5 @@ #include "config.h" +#include #include #include #include @@ -39,10 +40,9 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -91,9 +91,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-key_derive.c b/common/test/run-key_derive.c index a289805e3c60..79d9abd6a2df 100644 --- a/common/test/run-key_derive.c +++ b/common/test/run-key_derive.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -44,10 +45,9 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -74,9 +74,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-lock.c b/common/test/run-lock.c index 93b1c948129b..f676d621baa3 100644 --- a/common/test/run-lock.c +++ b/common/test/run-lock.c @@ -1,6 +1,7 @@ #include "../io_lock.c" #include #include +#include #include #include #include @@ -43,10 +44,9 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -73,9 +73,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-softref.c b/common/test/run-softref.c index a1bd3cda4843..81f89596ef7b 100644 --- a/common/test/run-softref.c +++ b/common/test/run-softref.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -40,10 +41,9 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -70,9 +70,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/common/test/run-sphinx.c b/common/test/run-sphinx.c index fe41a8096b83..bf4ea50015d0 100644 --- a/common/test/run-sphinx.c +++ b/common/test/run-sphinx.c @@ -41,9 +41,6 @@ bool amount_sat_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED) struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED) { fprintf(stderr, "amount_sat_sub called!\n"); abort(); } -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } /* Generated stub for bigsize_put */ size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) { fprintf(stderr, "bigsize_put called!\n"); abort(); } @@ -56,6 +53,9 @@ struct amount_msat fromwire_amount_msat(const u8 **cursor UNNEEDED, size_t *max /* Generated stub for fromwire_amount_sat */ struct amount_sat fromwire_amount_sat(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_amount_sat called!\n"); abort(); } +/* Generated stub for fromwire_bigsize */ +bigsize_t fromwire_bigsize(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) +{ fprintf(stderr, "fromwire_bigsize called!\n"); abort(); } /* Generated stub for pubkey_from_node_id */ bool pubkey_from_node_id(struct pubkey *key UNNEEDED, const struct node_id *id UNNEEDED) { fprintf(stderr, "pubkey_from_node_id called!\n"); abort(); } @@ -65,6 +65,9 @@ void towire_amount_msat(u8 **pptr UNNEEDED, const struct amount_msat msat UNNEED /* Generated stub for towire_amount_sat */ void towire_amount_sat(u8 **pptr UNNEEDED, const struct amount_sat sat UNNEEDED) { fprintf(stderr, "towire_amount_sat called!\n"); abort(); } +/* Generated stub for towire_bigsize */ +void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED) +{ fprintf(stderr, "towire_bigsize called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ extern secp256k1_context *secp256k1_ctx; diff --git a/connectd/connect_gossip_wire.csv b/connectd/connect_gossip_wire.csv index 4fdfeeea0445..9daf465397bf 100644 --- a/connectd/connect_gossip_wire.csv +++ b/connectd/connect_gossip_wire.csv @@ -1,3 +1,4 @@ +#include #include #include diff --git a/connectd/peer_exchange_initmsg.c b/connectd/peer_exchange_initmsg.c index 4dca9848c3e8..78114b1f3c37 100644 --- a/connectd/peer_exchange_initmsg.c +++ b/connectd/peer_exchange_initmsg.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/connectd/test/run-initiator-success.c b/connectd/test/run-initiator-success.c index 8855d7fb59a3..719949ecfc68 100644 --- a/connectd/test/run-initiator-success.c +++ b/connectd/test/run-initiator-success.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -46,10 +47,9 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -76,9 +76,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/connectd/test/run-responder-success.c b/connectd/test/run-responder-success.c index 52acffccfbe0..b0ef207bc92c 100644 --- a/connectd/test/run-responder-success.c +++ b/connectd/test/run-responder-success.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -46,10 +47,9 @@ const void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -76,9 +76,9 @@ void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED) void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/devtools/mkcommit.c b/devtools/mkcommit.c index 82a83af5d912..0279e225f6fe 100644 --- a/devtools/mkcommit.c +++ b/devtools/mkcommit.c @@ -8,12 +8,14 @@ 0000000000000000000000000000000000000000000000000000000000000020 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000021 0000000000000000000000000000000000000000000000000000000000000022 0000000000000000000000000000000000000000000000000000000000000023 0000000000000000000000000000000000000000000000000000000000000024 \ 0000000000000000000000000000000000000000000000000000000000000010 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 0000000000000000000000000000000000000000000000000000000000000011 0000000000000000000000000000000000000000000000000000000000000012 0000000000000000000000000000000000000000000000000000000000000013 0000000000000000000000000000000000000000000000000000000000000014 */ +#include #include #include #include #include #include #include +#include #include #include #include diff --git a/devtools/mkgossip.c b/devtools/mkgossip.c index d605cdbd2371..a365ce47dbe6 100644 --- a/devtools/mkgossip.c +++ b/devtools/mkgossip.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/gossipd/gossip_peerd_wire.csv b/gossipd/gossip_peerd_wire.csv index 99e1371be09a..dc44ceb5bfb8 100644 --- a/gossipd/gossip_peerd_wire.csv +++ b/gossipd/gossip_peerd_wire.csv @@ -1,5 +1,7 @@ # These must be distinct from WIRE_CHANNEL_ANNOUNCEMENT etc. gossip msgs! #include +#include +#include # Channel daemon can ask for updates for a specific channel, for sending # errors. diff --git a/gossipd/gossip_store.csv b/gossipd/gossip_store.csv index ea61dafdc59e..29006d09fbe9 100644 --- a/gossipd/gossip_store.csv +++ b/gossipd/gossip_store.csv @@ -1,6 +1,7 @@ # gossip_store messages: messages persisted in the gossip_store # We store raw messages here, so these numbers must not overlap with # 256/257/258 or gossipd_local_add_channel (3503) +#include # This always follows the channel_announce. msgtype,gossip_store_channel_amount,4101 diff --git a/gossipd/queries.c b/gossipd/queries.c index e1ceaa9dbab4..5efebe1e7da2 100644 --- a/gossipd/queries.c +++ b/gossipd/queries.c @@ -1,4 +1,5 @@ /* Routines to generate and handle gossip query messages */ +#include #include #include #include diff --git a/gossipd/routing.c b/gossipd/routing.c index c571f0ad366b..18c4ca64d18e 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -1,6 +1,7 @@ #include "routing.h" #include #include +#include #include #include #include diff --git a/gossipd/seeker.c b/gossipd/seeker.c index e1a0cad30b84..bf9be248800e 100644 --- a/gossipd/seeker.c +++ b/gossipd/seeker.c @@ -1,9 +1,11 @@ /* This contains the code which actively seeks out gossip from peers */ +#include #include #include #include #include #include +#include #include #include #include diff --git a/lightningd/test/run-find_my_abspath.c b/lightningd/test/run-find_my_abspath.c index 0c231c3bb314..241aa797a490 100644 --- a/lightningd/test/run-find_my_abspath.c +++ b/lightningd/test/run-find_my_abspath.c @@ -18,12 +18,6 @@ char *add_plugin_dir(struct plugins *plugins UNNEEDED, const char *dir UNNEEDED, /* Generated stub for begin_topology */ void begin_topology(struct chain_topology *topo UNNEEDED) { fprintf(stderr, "begin_topology called!\n"); abort(); } -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } -/* Generated stub for bigsize_put */ -size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) -{ fprintf(stderr, "bigsize_put called!\n"); abort(); } /* Generated stub for channel_notify_new_block */ void channel_notify_new_block(struct lightningd *ld UNNEEDED, u32 block_height UNNEEDED) @@ -81,10 +75,16 @@ void free_htlcs(struct lightningd *ld UNNEEDED, const struct channel *channel UN /* Generated stub for free_unreleased_txs */ void free_unreleased_txs(struct wallet *w UNNEEDED) { fprintf(stderr, "free_unreleased_txs called!\n"); abort(); } +/* Generated stub for fromwire_bigsize */ +bigsize_t fromwire_bigsize(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) +{ fprintf(stderr, "fromwire_bigsize called!\n"); abort(); } /* Generated stub for fromwire_channel_id */ void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "fromwire_channel_id called!\n"); abort(); } +/* Generated stub for fromwire_node_id */ +void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED) +{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); } /* Generated stub for fromwire_status_fail */ bool fromwire_status_fail(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, enum status_failreason *failreason UNNEEDED, wirestring **desc UNNEEDED) { fprintf(stderr, "fromwire_status_fail called!\n"); abort(); } @@ -217,9 +217,15 @@ void setup_topology(struct chain_topology *topology UNNEEDED, struct timers *tim /* Generated stub for timer_expired */ void timer_expired(tal_t *ctx UNNEEDED, struct timer *timer UNNEEDED) { fprintf(stderr, "timer_expired called!\n"); abort(); } +/* Generated stub for towire_bigsize */ +void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED) +{ fprintf(stderr, "towire_bigsize called!\n"); abort(); } /* Generated stub for towire_channel_id */ void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "towire_channel_id called!\n"); abort(); } +/* Generated stub for towire_node_id */ +void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) +{ fprintf(stderr, "towire_node_id called!\n"); abort(); } /* Generated stub for txfilter_add_derkey */ void txfilter_add_derkey(struct txfilter *filter UNNEEDED, const u8 derkey[PUBKEY_CMPR_LEN]) diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index 4ee749be3810..5ecdea4d6874 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -7,12 +7,6 @@ bool deprecated_apis = false; /* AUTOGENERATED MOCKS START */ -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } -/* Generated stub for bigsize_put */ -size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) -{ fprintf(stderr, "bigsize_put called!\n"); abort(); } /* Generated stub for bitcoind_getutxout_ */ void bitcoind_getutxout_(struct bitcoind *bitcoind UNNEEDED, const struct bitcoin_txid *txid UNNEEDED, const u32 outnum UNNEEDED, @@ -108,6 +102,9 @@ bool feature_is_set(const u8 *features UNNEEDED, size_t bit UNNEEDED) /* Generated stub for fixup_htlcs_out */ void fixup_htlcs_out(struct lightningd *ld UNNEEDED) { fprintf(stderr, "fixup_htlcs_out called!\n"); abort(); } +/* Generated stub for fromwire_bigsize */ +bigsize_t fromwire_bigsize(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) +{ fprintf(stderr, "fromwire_bigsize called!\n"); abort(); } /* Generated stub for fromwire_channel_dev_memleak_reply */ bool fromwire_channel_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED) { fprintf(stderr, "fromwire_channel_dev_memleak_reply called!\n"); abort(); } @@ -130,6 +127,9 @@ bool fromwire_hsm_sign_commitment_tx_reply(const void *p UNNEEDED, struct bitcoi /* Generated stub for fromwire_hsm_sign_invoice_reply */ bool fromwire_hsm_sign_invoice_reply(const void *p UNNEEDED, secp256k1_ecdsa_recoverable_signature *sig UNNEEDED) { fprintf(stderr, "fromwire_hsm_sign_invoice_reply called!\n"); abort(); } +/* Generated stub for fromwire_node_id */ +void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED) +{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); } /* Generated stub for fromwire_onchain_dev_memleak_reply */ bool fromwire_onchain_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED) { fprintf(stderr, "fromwire_onchain_dev_memleak_reply called!\n"); abort(); } @@ -456,6 +456,9 @@ void subd_req_(const tal_t *ctx UNNEEDED, /* Generated stub for subd_send_msg */ void subd_send_msg(struct subd *sd UNNEEDED, const u8 *msg_out UNNEEDED) { fprintf(stderr, "subd_send_msg called!\n"); abort(); } +/* Generated stub for towire_bigsize */ +void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED) +{ fprintf(stderr, "towire_bigsize called!\n"); abort(); } /* Generated stub for towire_channel_dev_memleak */ u8 *towire_channel_dev_memleak(const tal_t *ctx UNNEEDED) { fprintf(stderr, "towire_channel_dev_memleak called!\n"); abort(); } @@ -494,6 +497,9 @@ u8 *towire_hsm_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct node_i /* Generated stub for towire_hsm_sign_invoice */ u8 *towire_hsm_sign_invoice(const tal_t *ctx UNNEEDED, const u8 *u5bytes UNNEEDED, const u8 *hrp UNNEEDED) { fprintf(stderr, "towire_hsm_sign_invoice called!\n"); abort(); } +/* Generated stub for towire_node_id */ +void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) +{ fprintf(stderr, "towire_node_id called!\n"); abort(); } /* Generated stub for towire_onchain_dev_memleak */ u8 *towire_onchain_dev_memleak(const tal_t *ctx UNNEEDED) { fprintf(stderr, "towire_onchain_dev_memleak called!\n"); abort(); } diff --git a/lightningd/test/run-jsonrpc.c b/lightningd/test/run-jsonrpc.c index 2532cdb851e3..243f606de4ae 100644 --- a/lightningd/test/run-jsonrpc.c +++ b/lightningd/test/run-jsonrpc.c @@ -3,12 +3,6 @@ #include "../json.c" /* AUTOGENERATED MOCKS START */ -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } -/* Generated stub for bigsize_put */ -size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) -{ fprintf(stderr, "bigsize_put called!\n"); abort(); } /* Generated stub for db_begin_transaction_ */ void db_begin_transaction_(struct db *db UNNEEDED, const char *location UNNEEDED) { fprintf(stderr, "db_begin_transaction_ called!\n"); abort(); } @@ -24,10 +18,16 @@ u32 feerate_from_style(u32 feerate UNNEEDED, enum feerate_style style UNNEEDED) /* Generated stub for feerate_name */ const char *feerate_name(enum feerate feerate UNNEEDED) { fprintf(stderr, "feerate_name called!\n"); abort(); } +/* Generated stub for fromwire_bigsize */ +bigsize_t fromwire_bigsize(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) +{ fprintf(stderr, "fromwire_bigsize called!\n"); abort(); } /* Generated stub for fromwire_channel_id */ void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "fromwire_channel_id called!\n"); abort(); } +/* Generated stub for fromwire_node_id */ +void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED) +{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); } /* Generated stub for json_add_sha256 */ void json_add_sha256(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED, const struct sha256 *hash UNNEEDED) @@ -109,9 +109,15 @@ struct command_result *param_tok(struct command *cmd UNNEEDED, const char *name bool plugin_hook_call_(struct lightningd *ld UNNEEDED, const struct plugin_hook *hook UNNEEDED, tal_t *cb_arg STEALS UNNEEDED) { fprintf(stderr, "plugin_hook_call_ called!\n"); abort(); } +/* Generated stub for towire_bigsize */ +void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED) +{ fprintf(stderr, "towire_bigsize called!\n"); abort(); } /* Generated stub for towire_channel_id */ void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "towire_channel_id called!\n"); abort(); } +/* Generated stub for towire_node_id */ +void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) +{ fprintf(stderr, "towire_node_id called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ bool deprecated_apis; diff --git a/lightningd/test/run-log-pruning.c b/lightningd/test/run-log-pruning.c index a95d2ee5b419..f55266ab3003 100644 --- a/lightningd/test/run-log-pruning.c +++ b/lightningd/test/run-log-pruning.c @@ -2,12 +2,6 @@ #include /* AUTOGENERATED MOCKS START */ -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } -/* Generated stub for bigsize_put */ -size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) -{ fprintf(stderr, "bigsize_put called!\n"); abort(); } /* Generated stub for command_fail */ struct command_result *command_fail(struct command *cmd UNNEEDED, errcode_t code UNNEEDED, const char *fmt UNNEEDED, ...) @@ -22,10 +16,16 @@ struct command_result *command_success(struct command *cmd UNNEEDED, struct json_stream *response) { fprintf(stderr, "command_success called!\n"); abort(); } +/* Generated stub for fromwire_bigsize */ +bigsize_t fromwire_bigsize(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) +{ fprintf(stderr, "fromwire_bigsize called!\n"); abort(); } /* Generated stub for fromwire_channel_id */ void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "fromwire_channel_id called!\n"); abort(); } +/* Generated stub for fromwire_node_id */ +void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED) +{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); } /* Generated stub for json_add_member */ void json_add_member(struct json_stream *js UNNEEDED, const char *fieldname UNNEEDED, @@ -70,9 +70,15 @@ void notify_warning(struct lightningd *ld UNNEEDED, struct log_entry *l UNNEEDED bool param(struct command *cmd UNNEEDED, const char *buffer UNNEEDED, const jsmntok_t params[] UNNEEDED, ...) { fprintf(stderr, "param called!\n"); abort(); } +/* Generated stub for towire_bigsize */ +void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED) +{ fprintf(stderr, "towire_bigsize called!\n"); abort(); } /* Generated stub for towire_channel_id */ void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "towire_channel_id called!\n"); abort(); } +/* Generated stub for towire_node_id */ +void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED) +{ fprintf(stderr, "towire_node_id called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ int main(void) diff --git a/onchaind/Makefile b/onchaind/Makefile index 3e2ff59b104b..23f31a3503e3 100644 --- a/onchaind/Makefile +++ b/onchaind/Makefile @@ -64,6 +64,7 @@ ONCHAIND_COMMON_OBJS := \ common/key_derive.o \ common/memleak.o \ common/msg_queue.o \ + common/node_id.o \ common/onionreply.o \ common/peer_billboard.o \ common/permute_tx.o \ diff --git a/onchaind/test/run-grind_feerate-bug.c b/onchaind/test/run-grind_feerate-bug.c index 55455331704a..84c0c50bc45b 100644 --- a/onchaind/test/run-grind_feerate-bug.c +++ b/onchaind/test/run-grind_feerate-bug.c @@ -64,10 +64,9 @@ int fromwire_peektype(const u8 *cursor UNNEEDED) void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -266,9 +265,9 @@ u8 *towire_onchain_unwatch_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_tx void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/onchaind/test/run-grind_feerate.c b/onchaind/test/run-grind_feerate.c index fae29de9e3e3..164c4bc3cf7e 100644 --- a/onchaind/test/run-grind_feerate.c +++ b/onchaind/test/run-grind_feerate.c @@ -65,10 +65,9 @@ bool fromwire_onchain_spent(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, s void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "fromwire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for fromwire_sha256_double */ -void fromwire_sha256_double(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, - struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "fromwire_sha256_double called!\n"); abort(); } +/* Generated stub for fromwire_sha256 */ +void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "fromwire_sha256 called!\n"); abort(); } /* Generated stub for fromwire_tal_arrn */ u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED) @@ -284,9 +283,9 @@ u8 *towire_onchain_unwatch_tx(const tal_t *ctx UNNEEDED, const struct bitcoin_tx void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED, const secp256k1_ecdsa_signature *signature UNNEEDED) { fprintf(stderr, "towire_secp256k1_ecdsa_signature called!\n"); abort(); } -/* Generated stub for towire_sha256_double */ -void towire_sha256_double(u8 **pptr UNNEEDED, const struct sha256_double *sha256d UNNEEDED) -{ fprintf(stderr, "towire_sha256_double called!\n"); abort(); } +/* Generated stub for towire_sha256 */ +void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED) +{ fprintf(stderr, "towire_sha256 called!\n"); abort(); } /* Generated stub for towire_u16 */ void towire_u16(u8 **pptr UNNEEDED, u16 v UNNEEDED) { fprintf(stderr, "towire_u16 called!\n"); abort(); } diff --git a/openingd/Makefile b/openingd/Makefile index 65d49cfbe1ca..f209ab5232be 100644 --- a/openingd/Makefile +++ b/openingd/Makefile @@ -63,6 +63,7 @@ OPENINGD_COMMON_OBJS := \ common/keyset.o \ common/memleak.o \ common/msg_queue.o \ + common/node_id.o \ common/onionreply.o \ common/penalty_base.o \ common/per_peer_state.o \ diff --git a/openingd/opening_wire.csv b/openingd/opening_wire.csv index 95e531e6df7b..84b7033923d5 100644 --- a/openingd/opening_wire.csv +++ b/openingd/opening_wire.csv @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/plugins/Makefile b/plugins/Makefile index b3cb29d4d650..e4569e84b090 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -19,6 +19,7 @@ PLUGIN_LIB_OBJS := $(PLUGIN_LIB_SRC:.c=.o) PLUGIN_COMMON_OBJS := \ bitcoin/base58.o \ + bitcoin/privkey.o \ bitcoin/pubkey.o \ bitcoin/pullpush.o \ bitcoin/script.o \ diff --git a/plugins/keysend.c b/plugins/keysend.c index 4506d0742024..186ae269bc64 100644 --- a/plugins/keysend.c +++ b/plugins/keysend.c @@ -1,5 +1,6 @@ #include #include +#include #include #include diff --git a/plugins/pay.c b/plugins/pay.c index 3b6c506139d3..ec6d501dc5c0 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/tests/plugins/test_libplugin.c b/tests/plugins/test_libplugin.c index 7a6899ffaf41..bff60e89b6ef 100644 --- a/tests/plugins/test_libplugin.c +++ b/tests/plugins/test_libplugin.c @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/tools/test/Makefile b/tools/test/Makefile index 002b70f441fc..d3a51c114893 100644 --- a/tools/test/Makefile +++ b/tools/test/Makefile @@ -28,7 +28,7 @@ TOOLS_WIRE_DEPS := $(BOLT_DEPS) tools/test/test_cases $(wildcard tools/gen/*_tem $(TOOL_TEST_OBJS) $(TOOL_GEN_OBJS): $(TOOL_GEN_HEADER) $(TOOL_TEST_PROGRAMS): $(TOOL_TEST_COMMON_OBJS) $(TOOL_GEN_SRC:.c=.o) tools/test/enum.o -tools/test/gen_test.h: $(TOOLS_WIRE_DEPS) +tools/test/gen_test.h: $(TOOLS_WIRE_DEPS) tools/test/Makefile $(BOLT_GEN) --page header $@ test_type < tools/test/test_cases > $@ .INTERMEDIATE: tools/test/gen_test.c.tmp.c diff --git a/tools/test/test_cases b/tools/test/test_cases index ef085c85f7db..4854a1dbfa16 100644 --- a/tools/test/test_cases +++ b/tools/test/test_cases @@ -1,4 +1,7 @@ #include +#include +#include +#include #include "enum.h" # AUTOGENERATED MOCKS START # AUTOGENERATED MOCKS END diff --git a/wallet/test/run-db.c b/wallet/test/run-db.c index f45be567557d..5a75a5793fbb 100644 --- a/wallet/test/run-db.c +++ b/wallet/test/run-db.c @@ -18,12 +18,6 @@ static void db_log_(struct log *log UNUSED, enum log_level level UNUSED, const s #include /* AUTOGENERATED MOCKS START */ -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } -/* Generated stub for bigsize_put */ -size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) -{ fprintf(stderr, "bigsize_put called!\n"); abort(); } /* Generated stub for fatal */ void fatal(const char *fmt UNNEEDED, ...) { fprintf(stderr, "fatal called!\n"); abort(); } diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 4e22fd28de74..4b3e92df9ce8 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -31,9 +31,6 @@ static void db_log_(struct log *log UNUSED, enum log_level level UNUSED, const s bool deprecated_apis = true; /* AUTOGENERATED MOCKS START */ -/* Generated stub for bigsize_get */ -size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNNEEDED) -{ fprintf(stderr, "bigsize_get called!\n"); abort(); } /* Generated stub for bigsize_put */ size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) { fprintf(stderr, "bigsize_put called!\n"); abort(); } diff --git a/wire/Makefile b/wire/Makefile index 9625637c2636..dfb57f05b03c 100644 --- a/wire/Makefile +++ b/wire/Makefile @@ -74,14 +74,14 @@ wire/gen_peer_wire_csv wire/gen_onion_wire_csv: config.vars # for testing and to prevent compile error about them being unused. # This will be easier if test vectors are moved to separate files. wire/gen_peer_wire.h: wire/gen_peer_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile - $(BOLT_GEN) --include='common/channel_id.h' --include='bitcoin/tx.h' --include='bitcoin/preimage.h' --include='bitcoin/short_channel_id.h' -s --expose-tlv-type=n1 --expose-tlv-type=n2 --page header $@ wire_type < $< > $@ + $(BOLT_GEN) --include='common/channel_id.h' --include='bitcoin/tx.h' --include='bitcoin/preimage.h' --include='bitcoin/short_channel_id.h' --include='common/node_id.h' --include='common/bigsize.h' --include='bitcoin/block.h' --include='bitcoin/privkey.h' -s --expose-tlv-type=n1 --expose-tlv-type=n2 --page header $@ wire_type < $< > $@ wire/gen_peer_wire.c: wire/gen_peer_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile $(BOLT_GEN) -s --expose-tlv-type=n1 --expose-tlv-type=n2 --page impl ${@:.c=.h} wire_type < $< > $@ # The tlv_payload isn't parsed in a fromwire, so we need to expose it. wire/gen_onion_wire.h: wire/gen_onion_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile - $(BOLT_GEN) --include='bitcoin/short_channel_id.h' -s --expose-tlv-type=tlv_payload --page header $@ onion_type < $< > $@ + $(BOLT_GEN) --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' -s --expose-tlv-type=tlv_payload --page header $@ onion_type < $< > $@ wire/gen_onion_wire.c: wire/gen_onion_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile $(BOLT_GEN) -s --expose-tlv-type=tlv_payload --page impl ${@:.c=.h} onion_type < $< > $@ diff --git a/wire/fromwire.c b/wire/fromwire.c index 76fe20463ef2..a001339b1cf7 100644 --- a/wire/fromwire.c +++ b/wire/fromwire.c @@ -1,18 +1,11 @@ #include "wire.h" #include -#include -#include -#include -#include #include #include #include #include #include #include -#include -#include -#include #include #include @@ -170,48 +163,6 @@ errcode_t fromwire_errcode_t(const u8 **cursor, size_t *max) return ret; } -bigsize_t fromwire_bigsize(const u8 **cursor, size_t *max) -{ - bigsize_t v; - size_t len = bigsize_get(*cursor, *max, &v); - - if (len == 0) { - fromwire_fail(cursor, max); - return 0; - } - assert(len <= *max); - fromwire(cursor, max, NULL, len); - return v; -} - -void fromwire_pubkey(const u8 **cursor, size_t *max, struct pubkey *pubkey) -{ - u8 der[PUBKEY_CMPR_LEN]; - - if (!fromwire(cursor, max, der, sizeof(der))) - return; - - if (!pubkey_from_der(der, sizeof(der), pubkey)) { - SUPERVERBOSE("not a valid point"); - fromwire_fail(cursor, max); - } -} - -void fromwire_node_id(const u8 **cursor, size_t *max, struct node_id *id) -{ - fromwire(cursor, max, &id->k, sizeof(id->k)); -} - -void fromwire_secret(const u8 **cursor, size_t *max, struct secret *secret) -{ - fromwire(cursor, max, secret->data, sizeof(secret->data)); -} - -void fromwire_privkey(const u8 **cursor, size_t *max, struct privkey *privkey) -{ - fromwire_secret(cursor, max, &privkey->secret); -} - void fromwire_secp256k1_ecdsa_signature(const u8 **cursor, size_t *max, secp256k1_ecdsa_signature *sig) { @@ -246,12 +197,6 @@ void fromwire_sha256(const u8 **cursor, size_t *max, struct sha256 *sha256) fromwire(cursor, max, sha256, sizeof(*sha256)); } -void fromwire_sha256_double(const u8 **cursor, size_t *max, - struct sha256_double *sha256d) -{ - fromwire_sha256(cursor, max, &sha256d->sha); -} - void fromwire_ripemd160(const u8 **cursor, size_t *max, struct ripemd160 *ripemd) { fromwire(cursor, max, ripemd, sizeof(*ripemd)); @@ -307,9 +252,3 @@ void fromwire_siphash_seed(const u8 **cursor, size_t *max, fromwire(cursor, max, seed, sizeof(*seed)); } -void fromwire_bip32_key_version(const u8** cursor, size_t *max, - struct bip32_key_version *version) -{ - version->bip32_pubkey_version = fromwire_u32(cursor, max); - version->bip32_privkey_version = fromwire_u32(cursor, max); -} diff --git a/wire/peer_wire.c b/wire/peer_wire.c index 737e2fbb6caa..d9ef1db0c397 100644 --- a/wire/peer_wire.c +++ b/wire/peer_wire.c @@ -1,3 +1,4 @@ +#include #include static bool unknown_type(enum wire_type t) diff --git a/wire/test/Makefile b/wire/test/Makefile index d0a8f542d203..a7e3eeeac920 100644 --- a/wire/test/Makefile +++ b/wire/test/Makefile @@ -11,7 +11,8 @@ WIRE_TEST_COMMON_OBJS := \ update-mocks: $(WIRE_TEST_SRC:%=update-mocks/%) -$(WIRE_TEST_PROGRAMS): $(WIRE_TEST_COMMON_OBJS) $(BITCOIN_OBJS) +# run-tlvstream.c needs to reach into bitcoin/pubkey for SUPERVERBOSE +$(WIRE_TEST_PROGRAMS): $(WIRE_TEST_COMMON_OBJS) $(filter-out bitcoin/pubkey.o,$(BITCOIN_OBJS)) # Test objects require source to be generated, since they include .. $(WIRE_TEST_OBJS): $(WIRE_GEN_SRC) $(WIRE_SRC) $(WIRE_HEADERS) diff --git a/wire/test/run-peer-wire.c b/wire/test/run-peer-wire.c index 2a49f06a86d4..66bec3467c09 100644 --- a/wire/test/run-peer-wire.c +++ b/wire/test/run-peer-wire.c @@ -1,8 +1,10 @@ #include "../towire.c" #include "../fromwire.c" #include "../peer_wire.c" +#include "bitcoin/pubkey.c" #include "common/amount.c" #include "common/channel_id.c" +#include "common/node_id.c" #include #include diff --git a/wire/test/run-tlvstream.c b/wire/test/run-tlvstream.c index 3dde124f05b4..ff324807538e 100644 --- a/wire/test/run-tlvstream.c +++ b/wire/test/run-tlvstream.c @@ -4,14 +4,15 @@ #include #include -#include -#include -#include - static const char *reason; #undef SUPERVERBOSE #define SUPERVERBOSE(r) do { reason = (r); } while(0) +#include +#include +#include +#include + #include #include #include diff --git a/wire/tlvstream.c b/wire/tlvstream.c index 257b53f0c188..1a7d653c0d91 100644 --- a/wire/tlvstream.c +++ b/wire/tlvstream.c @@ -1,3 +1,4 @@ +#include #include #include diff --git a/wire/towire.c b/wire/towire.c index be0feb04ab04..fa26b10e15fb 100644 --- a/wire/towire.c +++ b/wire/towire.c @@ -84,44 +84,6 @@ void towire_errcode_t(u8 **pptr, errcode_t v) towire_u32(pptr, (u32)v); } -void towire_bigsize(u8 **pptr, const bigsize_t val) -{ - u8 buf[BIGSIZE_MAX_LEN]; - size_t len; - - len = bigsize_put(buf, val); - towire(pptr, buf, len); -} - -void towire_pubkey(u8 **pptr, const struct pubkey *pubkey) -{ - u8 output[PUBKEY_CMPR_LEN]; - size_t outputlen = sizeof(output); - - secp256k1_ec_pubkey_serialize(secp256k1_ctx, output, &outputlen, - &pubkey->pubkey, - SECP256K1_EC_COMPRESSED); - - towire(pptr, output, outputlen); -} - -void towire_node_id(u8 **pptr, const struct node_id *id) -{ - /* Cheap sanity check */ - assert(id->k[0] == 0x2 || id->k[0] == 0x3); - towire(pptr, id->k, sizeof(id->k)); -} - -void towire_secret(u8 **pptr, const struct secret *secret) -{ - towire(pptr, secret->data, sizeof(secret->data)); -} - -void towire_privkey(u8 **pptr, const struct privkey *privkey) -{ - towire_secret(pptr, &privkey->secret); -} - void towire_secp256k1_ecdsa_signature(u8 **pptr, const secp256k1_ecdsa_signature *sig) { @@ -151,11 +113,6 @@ void towire_sha256(u8 **pptr, const struct sha256 *sha256) towire(pptr, sha256, sizeof(*sha256)); } -void towire_sha256_double(u8 **pptr, const struct sha256_double *sha256d) -{ - towire_sha256(pptr, &sha256d->sha); -} - void towire_ripemd160(u8 **pptr, const struct ripemd160 *ripemd) { towire(pptr, ripemd, sizeof(*ripemd)); @@ -184,9 +141,3 @@ void towire_siphash_seed(u8 **pptr, const struct siphash_seed *seed) { towire(pptr, seed, sizeof(*seed)); } - -void towire_bip32_key_version(u8 **pptr, const struct bip32_key_version *version) -{ - towire_u32(pptr, version->bip32_pubkey_version); - towire_u32(pptr, version->bip32_privkey_version); -} diff --git a/wire/wire.h b/wire/wire.h index b8aca7f01fce..eb6ffd4e0229 100644 --- a/wire/wire.h +++ b/wire/wire.h @@ -1,50 +1,29 @@ #ifndef LIGHTNING_WIRE_WIRE_H #define LIGHTNING_WIRE_WIRE_H #include "config.h" -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include +#include #include -#include #include #include -struct preimage; struct ripemd160; +struct sha256; struct siphash_seed; /* Makes generate-wire.py work */ typedef char wirestring; -typedef bigsize_t bigsize; - -/* FIXME: Some versions of spec using 'varint' for bigsize' */ -typedef bigsize varint; -#define fromwire_varint fromwire_bigsize -#define towire_varint towire_bigsize /* Read the type; returns -1 if not long enough. cursor is a tal ptr. */ int fromwire_peektype(const u8 *cursor); const void *fromwire_fail(const u8 **cursor, size_t *max); void towire(u8 **pptr, const void *data, size_t len); -void towire_pubkey(u8 **pptr, const struct pubkey *pubkey); -void towire_node_id(u8 **pptr, const struct node_id *id); -void towire_privkey(u8 **pptr, const struct privkey *privkey); -void towire_secret(u8 **pptr, const struct secret *secret); void towire_secp256k1_ecdsa_signature(u8 **pptr, const secp256k1_ecdsa_signature *signature); void towire_secp256k1_ecdsa_recoverable_signature(u8 **pptr, const secp256k1_ecdsa_recoverable_signature *rsig); void towire_sha256(u8 **pptr, const struct sha256 *sha256); -void towire_sha256_double(u8 **pptr, const struct sha256_double *sha256d); void towire_ripemd160(u8 **pptr, const struct ripemd160 *ripemd); void towire_u8(u8 **pptr, u8 v); void towire_u16(u8 **pptr, u16 v); @@ -56,15 +35,12 @@ void towire_tu64(u8 **pptr, u64 v); void towire_pad(u8 **pptr, size_t num); void towire_bool(u8 **pptr, bool v); void towire_errcode_t(u8 **pptr, errcode_t v); -void towire_bigsize(u8 **pptr, const bigsize_t val); void towire_u8_array(u8 **pptr, const u8 *arr, size_t num); void towire_wirestring(u8 **pptr, const char *str); void towire_siphash_seed(u8 **cursor, const struct siphash_seed *seed); -void towire_bip32_key_version(u8 **cursor, const struct bip32_key_version *version); - const u8 *fromwire(const u8 **cursor, size_t *max, void *copy, size_t n); u8 fromwire_u8(const u8 **cursor, size_t *max); u16 fromwire_u16(const u8 **cursor, size_t *max); @@ -75,19 +51,12 @@ u32 fromwire_tu32(const u8 **cursor, size_t *max); u64 fromwire_tu64(const u8 **cursor, size_t *max); bool fromwire_bool(const u8 **cursor, size_t *max); errcode_t fromwire_errcode_t(const u8 **cursor, size_t *max); -bigsize_t fromwire_bigsize(const u8 **cursor, size_t *max); -void fromwire_secret(const u8 **cursor, size_t *max, struct secret *secret); -void fromwire_privkey(const u8 **cursor, size_t *max, struct privkey *privkey); -void fromwire_pubkey(const u8 **cursor, size_t *max, struct pubkey *pubkey); -void fromwire_node_id(const u8 **cursor, size_t *max, struct node_id *id); void fromwire_secp256k1_ecdsa_signature(const u8 **cursor, size_t *max, secp256k1_ecdsa_signature *signature); void fromwire_secp256k1_ecdsa_recoverable_signature(const u8 **cursor, size_t *max, secp256k1_ecdsa_recoverable_signature *rsig); void fromwire_sha256(const u8 **cursor, size_t *max, struct sha256 *sha256); -void fromwire_sha256_double(const u8 **cursor, size_t *max, - struct sha256_double *sha256d); void fromwire_ripemd160(const u8 **cursor, size_t *max, struct ripemd160 *ripemd); void fromwire_pad(const u8 **cursor, size_t *max, size_t num); @@ -97,8 +66,6 @@ u8 *fromwire_tal_arrn(const tal_t *ctx, char *fromwire_wirestring(const tal_t *ctx, const u8 **cursor, size_t *max); void fromwire_siphash_seed(const u8 **cursor, size_t *max, struct siphash_seed *seed); -void fromwire_bip32_key_version(const u8 **cursor, size_t *max, - struct bip32_key_version *version); #if !EXPERIMENTAL_FEATURES /* Stubs, as this subtype is only defined when EXPERIMENTAL_FEATURES */