bitcoin: hoist script_with_len out of wallet/ into here.
What changed, and why it matters
This commit is a routine code cleanup: it moves a small helper structure and its hash/equality functions from the wallet module to the more general Bitcoin module so other code can reuse them. It also updates many test files to provide a stub for a hash-seed function and removes an unused header include. There is no security fix or vulnerability here.
No security action required; treat as normal refactoring. Reviewers may verify that the moved hash/equality functions are behavior-preserving and that fuzz targets still build.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change hoists struct script_with_len, script_with_len_hash(), and script_with_len_eq() from wallet/wallet.c into bitcoin/script.{c,h}. Because bitcoin/script.c now calls siphash_seed(), many unit-test files gain an aborting stub for that symbol, and some replace <common/randbytes.h> with <common/pseudorand.h> or drop it. The fuzzing harness is adjusted so a single shared siphash_seed() mock is enabled only when fuzz_allow_siphash_seed is set. This is a refactoring/build-hygiene patch with no behavioral security change.
Changed components
bitcoin/script.cbitcoin/script.hwallet/wallet.ctests/fuzz/libfuzz.ctests/fuzz/libfuzz.hcommon/ unit-test filesInspect captured patch +187 / −70
diff --git a/bitcoin/script.c b/bitcoin/script.c
index 2422f61..30cc089 100644
--- a/bitcoin/script.c
+++ b/bitcoin/script.c
@@ -6,6 +6,7 @@
#include <bitcoin/pubkey.h>
#include <bitcoin/script.h>
#include <ccan/mem/mem.h>
+#include <common/pseudorand.h>
#include <common/randbytes.h>
#include <common/utils.h>
#include <wally_script.h>
@@ -13,6 +14,18 @@
/* To push 0-75 bytes onto stack. */
#define OP_PUSHBYTES(val) (val)
+size_t script_with_len_hash(const struct script_with_len *swl)
+{
+ return siphash24(siphash_seed(), swl->script, swl->len);
+}
+
+bool script_with_len_eq(const struct script_with_len *a,
+ const struct script_with_len *b)
+{
+ return memeq(a->script, a->len, b->script, b->len);
+}
+
+
/* Bitcoin's OP_HASH160 is RIPEMD(SHA256()) */
static void hash160(struct ripemd160 *redeemhash, const void *mem, size_t len)
{
diff --git a/bitcoin/script.h b/bitcoin/script.h
index 52be662..0c37c64 100644
--- a/bitcoin/script.h
+++ b/bitcoin/script.h
@@ -12,6 +12,16 @@ struct ripemd160;
struct rel_locktime;
struct abs_locktime;
+/* libwally uses pointer/size pairs */
+struct script_with_len {
+ const u8 *script;
+ size_t len;
+};
+
+size_t script_with_len_hash(const struct script_with_len *swl);
+bool script_with_len_eq(const struct script_with_len *a,
+ const struct script_with_len *b);
+
/* tal_count() gives the length of the script. */
u8 *bitcoin_redeem_2of2(const tal_t *ctx,
const struct pubkey *key1,
diff --git a/common/test/run-amount.c b/common/test/run-amount.c
index 751ff6c..e7d5cfb 100644
--- a/common/test/run-amount.c
+++ b/common/test/run-amount.c
@@ -1,6 +1,6 @@
#include "config.h"
#include "../amount.c"
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
#include <stdio.h>
@@ -37,6 +37,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-base64.c b/common/test/run-base64.c
index e71371c..f4df43b 100644
--- a/common/test/run-base64.c
+++ b/common/test/run-base64.c
@@ -1,9 +1,10 @@
#include "config.h"
#include "../base64.c"
#include <assert.h>
+#include <bitcoin/script.h>
#include <ccan/base64/base64.h>
#include <common/amount.h>
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
#include <common/utils.h>
#include <sodium/utils.h>
@@ -77,6 +78,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-bigsize.c b/common/test/run-bigsize.c
index 1e167fd..6ee860a 100644
--- a/common/test/run-bigsize.c
+++ b/common/test/run-bigsize.c
@@ -4,7 +4,6 @@
#include <common/amount.h>
#include <common/json_parse.c>
#include <common/json_parse_simple.c>
-#include <common/randbytes.h>
#include <common/setup.h>
static const char *reason;
@@ -91,6 +90,9 @@ bool parse_amount_msat(struct amount_msat *msat UNNEEDED, const char *s UNNEEDED
/* Generated stub for parse_amount_sat */
bool parse_amount_sat(struct amount_sat *sat UNNEEDED, const char *s UNNEEDED, size_t slen UNNEEDED)
{ fprintf(stderr, "parse_amount_sat called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-blindedpath_enctlv.c b/common/test/run-blindedpath_enctlv.c
index d2552ad..cc67bb2 100644
--- a/common/test/run-blindedpath_enctlv.c
+++ b/common/test/run-blindedpath_enctlv.c
@@ -3,7 +3,6 @@
#include "../blinding.c"
#include "../hmac.c"
#include <common/channel_id.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
@@ -63,6 +62,9 @@ void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct n
void fromwire_sciddir_or_pubkey(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct sciddir_or_pubkey *sciddpk UNNEEDED)
{ fprintf(stderr, "fromwire_sciddir_or_pubkey called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for towire_amount_msat */
void towire_amount_msat(u8 **pptr UNNEEDED, const struct amount_msat msat UNNEEDED)
{ fprintf(stderr, "towire_amount_msat called!\n"); abort(); }
diff --git a/common/test/run-blindedpath_onion.c b/common/test/run-blindedpath_onion.c
index fc6d015..f52fa65 100644
--- a/common/test/run-blindedpath_onion.c
+++ b/common/test/run-blindedpath_onion.c
@@ -81,6 +81,9 @@ struct onionreply *new_onionreply(const tal_t *ctx UNNEEDED, const u8 *contents
/* 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(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for towire_amount_msat */
void towire_amount_msat(u8 **pptr UNNEEDED, const struct amount_msat msat UNNEEDED)
{ fprintf(stderr, "towire_amount_msat called!\n"); abort(); }
diff --git a/common/test/run-bolt11.c b/common/test/run-bolt11.c
index bd8c2c6..fe2b3e2 100644
--- a/common/test/run-bolt11.c
+++ b/common/test/run-bolt11.c
@@ -9,11 +9,13 @@
#include "../wire/fromwire.c"
#include "../wire/towire.c"
#include <ccan/err/err.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
/* AUTOGENERATED MOCKS START */
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
static struct privkey privkey;
diff --git a/common/test/run-bolt12-encode-test.c b/common/test/run-bolt12-encode-test.c
index 5ca641f..911ce00 100644
--- a/common/test/run-bolt12-encode-test.c
+++ b/common/test/run-bolt12-encode-test.c
@@ -12,7 +12,6 @@
#include <common/bolt12.c>
#include <common/bolt12_merkle.h>
#include <common/features.c>
-#include <common/randbytes.h>
#include <common/sciddir_or_pubkey.c>
#include <common/setup.h>
#include <inttypes.h>
@@ -72,6 +71,9 @@ void sighash_from_merkle(const char *messagename UNNEEDED,
const struct sha256 *merkle UNNEEDED,
struct sha256 *sighash UNNEEDED)
{ fprintf(stderr, "sighash_from_merkle called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for towire_amount_msat */
void towire_amount_msat(u8 **pptr UNNEEDED, const struct amount_msat msat UNNEEDED)
{ fprintf(stderr, "towire_amount_msat called!\n"); abort(); }
diff --git a/common/test/run-bolt12-format-string-test.c b/common/test/run-bolt12-format-string-test.c
index f2a5e11..d517a60 100644
--- a/common/test/run-bolt12-format-string-test.c
+++ b/common/test/run-bolt12-format-string-test.c
@@ -8,7 +8,6 @@
#include <common/bolt12.h>
#include <common/bolt12_merkle.h>
#include <common/features.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <common/utils.h>
@@ -77,6 +76,9 @@ void sighash_from_merkle(const char *messagename UNNEEDED,
const struct sha256 *merkle UNNEEDED,
struct sha256 *sighash UNNEEDED)
{ fprintf(stderr, "sighash_from_merkle called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for towire_blinded_path */
void towire_blinded_path(u8 **p UNNEEDED, const struct blinded_path *blinded_path UNNEEDED)
{ fprintf(stderr, "towire_blinded_path called!\n"); abort(); }
diff --git a/common/test/run-bolt12-offer-decode.c b/common/test/run-bolt12-offer-decode.c
index 329a139..5c2a73d 100644
--- a/common/test/run-bolt12-offer-decode.c
+++ b/common/test/run-bolt12-offer-decode.c
@@ -14,7 +14,6 @@
#include <ccan/array_size/array_size.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
-#include <common/randbytes.h>
#include <common/setup.h>
/* AUTOGENERATED MOCKS START */
@@ -79,6 +78,9 @@ void sighash_from_merkle(const char *messagename UNNEEDED,
const struct sha256 *merkle UNNEEDED,
struct sha256 *sighash UNNEEDED)
{ fprintf(stderr, "sighash_from_merkle called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-bolt12_decode.c b/common/test/run-bolt12_decode.c
index e4473ad..f27f873 100644
--- a/common/test/run-bolt12_decode.c
+++ b/common/test/run-bolt12_decode.c
@@ -8,7 +8,6 @@
#include <ccan/json_escape/json_escape.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
-#include <common/randbytes.h>
#include <common/setup.h>
/* AUTOGENERATED MOCKS START */
@@ -122,6 +121,9 @@ void sighash_from_merkle(const char *messagename UNNEEDED,
const struct sha256 *merkle UNNEEDED,
struct sha256 *sighash UNNEEDED)
{ fprintf(stderr, "sighash_from_merkle called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-bolt12_merkle-json.c b/common/test/run-bolt12_merkle-json.c
index fefac76..b414fe7 100644
--- a/common/test/run-bolt12_merkle-json.c
+++ b/common/test/run-bolt12_merkle-json.c
@@ -12,7 +12,6 @@
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
#include <common/channel_type.h>
-#include <common/randbytes.h>
#include <common/setup.h>
/* AUTOGENERATED MOCKS START */
@@ -32,6 +31,9 @@ bool mvt_tag_parse(const char *buf UNNEEDED, size_t len UNNEEDED, enum mvt_tag *
/* Generated stub for node_id_from_hexstr */
bool node_id_from_hexstr(const char *str UNNEEDED, size_t slen UNNEEDED, struct node_id *id UNNEEDED)
{ fprintf(stderr, "node_id_from_hexstr called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-bolt12_merkle.c b/common/test/run-bolt12_merkle.c
index 4d2f0bc..abc5468 100644
--- a/common/test/run-bolt12_merkle.c
+++ b/common/test/run-bolt12_merkle.c
@@ -7,7 +7,6 @@
#include <ccan/array_size/array_size.h>
#include <common/channel_type.h>
#include <common/features.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <secp256k1_schnorrsig.h>
@@ -27,6 +26,9 @@ struct blinded_path *fromwire_blinded_path(const tal_t *ctx UNNEEDED, const u8 *
bool 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 siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for towire_blinded_path */
void towire_blinded_path(u8 **p UNNEEDED, const struct blinded_path *blinded_path UNNEEDED)
{ fprintf(stderr, "towire_blinded_path called!\n"); abort(); }
diff --git a/common/test/run-bolt12_period.c b/common/test/run-bolt12_period.c
index 6b92f9c..4152f13 100644
--- a/common/test/run-bolt12_period.c
+++ b/common/test/run-bolt12_period.c
@@ -5,7 +5,6 @@
#include <ccan/array_size/array_size.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
-#include <common/randbytes.h>
#include <common/setup.h>
/* AUTOGENERATED MOCKS START */
@@ -124,6 +123,9 @@ void sighash_from_merkle(const char *messagename UNNEEDED,
const struct sha256 *merkle UNNEEDED,
struct sha256 *sighash UNNEEDED)
{ fprintf(stderr, "sighash_from_merkle called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for to_bech32_charset */
char *to_bech32_charset(const tal_t *ctx UNNEEDED,
const char *hrp UNNEEDED, const u8 *data UNNEEDED)
diff --git a/common/test/run-channel_type.c b/common/test/run-channel_type.c
index 2cac84a..495f695 100644
--- a/common/test/run-channel_type.c
+++ b/common/test/run-channel_type.c
@@ -2,7 +2,6 @@
#include "../channel_type.c"
#include "../features.c"
#include <ccan/tal/str/str.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
#include <lightningd/channel_state.h>
@@ -77,6 +76,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-codex32.c b/common/test/run-codex32.c
index 276bd02..79aafbf 100644
--- a/common/test/run-codex32.c
+++ b/common/test/run-codex32.c
@@ -8,7 +8,6 @@
#include <common/codex32.h>
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/tal/path/path.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <wire/wire.h>
@@ -91,6 +90,9 @@ bool parse_amount_msat(struct amount_msat *msat UNNEEDED, const char *s UNNEEDED
/* Generated stub for parse_amount_sat */
bool parse_amount_sat(struct amount_sat *sat UNNEEDED, const char *s UNNEEDED, size_t slen UNNEEDED)
{ fprintf(stderr, "parse_amount_sat called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-coin_mvt.c b/common/test/run-coin_mvt.c
index 99651cc..b499bdf 100644
--- a/common/test/run-coin_mvt.c
+++ b/common/test/run-coin_mvt.c
@@ -1,7 +1,6 @@
#include "config.h"
#include "../coin_mvt.c"
#include <ccan/tal/str/str.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
@@ -91,6 +90,9 @@ void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr
/* Generated stub for fromwire_wirestring */
char *fromwire_wirestring(const tal_t *ctx UNNEEDED, const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_wirestring called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-cryptomsg.c b/common/test/run-cryptomsg.c
index 0284f9d..3c1c77d 100644
--- a/common/test/run-cryptomsg.c
+++ b/common/test/run-cryptomsg.c
@@ -1,6 +1,5 @@
#include "config.h"
#include <ccan/str/hex/hex.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <common/status.h>
#include <common/utils.h>
@@ -74,6 +73,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-deprecation.c b/common/test/run-deprecation.c
index fa1378c..01d5552 100644
--- a/common/test/run-deprecation.c
+++ b/common/test/run-deprecation.c
@@ -6,7 +6,7 @@ static const char *test_next_version;
#include "../deprecation.c"
#include <common/amount.h>
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
#include <stdio.h>
#include <wire/wire.h>
@@ -78,6 +78,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-derive_basepoints.c b/common/test/run-derive_basepoints.c
index cb896ad..9119382 100644
--- a/common/test/run-derive_basepoints.c
+++ b/common/test/run-derive_basepoints.c
@@ -5,7 +5,7 @@
#include <ccan/str/hex/hex.h>
#include <ccan/structeq/structeq.h>
#include <common/amount.h>
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
#include <common/utils.h>
#include <stdio.h>
@@ -79,6 +79,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-features.c b/common/test/run-features.c
index efbea7f..37c0ddd 100644
--- a/common/test/run-features.c
+++ b/common/test/run-features.c
@@ -3,7 +3,6 @@
#include "../memleak.c"
#include <bitcoin/script.h>
#include <ccan/mem/mem.h>
-#include <common/randbytes.h>
#include <common/setup.h>
/* AUTOGENERATED MOCKS START */
@@ -76,6 +75,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-gossmap-fp16.c b/common/test/run-gossmap-fp16.c
index 539b129..2b08524 100644
--- a/common/test/run-gossmap-fp16.c
+++ b/common/test/run-gossmap-fp16.c
@@ -1,6 +1,6 @@
#include "config.h"
#include "../fp16.c"
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
#include <stdio.h>
#include <wire/wire.h>
@@ -72,6 +72,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-htable.c b/common/test/run-htable.c
index 75164ce..267ad8c 100644
--- a/common/test/run-htable.c
+++ b/common/test/run-htable.c
@@ -8,7 +8,6 @@
#include <common/amount.h>
#include <common/memleak.h>
#include <common/pseudorand.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <common/utils.h>
#include <inttypes.h>
diff --git a/common/test/run-ip_port_parsing.c b/common/test/run-ip_port_parsing.c
index c7c5ba2..13d3495 100644
--- a/common/test/run-ip_port_parsing.c
+++ b/common/test/run-ip_port_parsing.c
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <common/amount.h>
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
/* AUTOGENERATED MOCKS START */
@@ -77,6 +77,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-json.c b/common/test/run-json.c
index 18130c2..1fc42a2 100644
--- a/common/test/run-json.c
+++ b/common/test/run-json.c
@@ -6,7 +6,6 @@
#include <common/channel_type.h>
#include <common/clock_time.h>
#include <common/json_filter.h>
-#include <common/randbytes.h>
#include <common/sciddir_or_pubkey.h>
#include <common/setup.h>
#include <inttypes.h>
diff --git a/common/test/run-json_filter.c b/common/test/run-json_filter.c
index d682b82..015ff35 100644
--- a/common/test/run-json_filter.c
+++ b/common/test/run-json_filter.c
@@ -6,7 +6,6 @@
#include "../json_stream.c"
#include <ccan/json_out/json_out.h>
#include <common/json_command.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
@@ -149,6 +148,9 @@ int segwit_addr_decode(
const char* addr
)
{ fprintf(stderr, "segwit_addr_decode called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for to_canonical_invstr */
const char *to_canonical_invstr(const tal_t *ctx UNNEEDED, const char *invstring UNNEEDED)
{ fprintf(stderr, "to_canonical_invstr called!\n"); abort(); }
diff --git a/common/test/run-json_remove.c b/common/test/run-json_remove.c
index 8a15653..880e9f8 100644
--- a/common/test/run-json_remove.c
+++ b/common/test/run-json_remove.c
@@ -2,7 +2,6 @@
#include <common/amount.h>
#include <common/json_param.c>
#include <common/json_parse_simple.c>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
#include <wire/wire.h>
@@ -181,6 +180,9 @@ int segwit_addr_decode(
const char* addr
)
{ fprintf(stderr, "segwit_addr_decode called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for to_canonical_invstr */
const char *to_canonical_invstr(const tal_t *ctx UNNEEDED, const char *invstring UNNEEDED)
{ fprintf(stderr, "to_canonical_invstr called!\n"); abort(); }
diff --git a/common/test/run-json_scan.c b/common/test/run-json_scan.c
index 877bce6..6519129 100644
--- a/common/test/run-json_scan.c
+++ b/common/test/run-json_scan.c
@@ -2,7 +2,6 @@
#include "../json_parse.c"
#include "../json_parse_simple.c"
#include <common/amount.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
#include <wire/wire.h>
@@ -86,6 +85,9 @@ bool parse_amount_msat(struct amount_msat *msat UNNEEDED, const char *s UNNEEDED
/* Generated stub for parse_amount_sat */
bool parse_amount_sat(struct amount_sat *sat UNNEEDED, const char *s UNNEEDED, size_t slen UNNEEDED)
{ fprintf(stderr, "parse_amount_sat called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-json_stream-filter.c b/common/test/run-json_stream-filter.c
index 6f6fe06..3f40141 100644
--- a/common/test/run-json_stream-filter.c
+++ b/common/test/run-json_stream-filter.c
@@ -4,7 +4,6 @@
#include <assert.h>
#include <ccan/tal/str/str.h>
#include <common/channel_type.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <inttypes.h>
#include <stdio.h>
@@ -111,6 +110,9 @@ const char *json_tok_full(const char *buffer UNNEEDED, const jsmntok_t *t UNNEED
/* Generated stub for json_tok_full_len */
int json_tok_full_len(const jsmntok_t *t UNNEEDED)
{ fprintf(stderr, "json_tok_full_len called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-jsonrpc_io.c b/common/test/run-jsonrpc_io.c
index d0f75ff..007132a 100644
--- a/common/test/run-jsonrpc_io.c
+++ b/common/test/run-jsonrpc_io.c
@@ -4,7 +4,7 @@
#include <ccan/io/io.h>
#include <common/amount.h>
#include <common/bigsize.h>
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
#include <stdio.h>
#include <wire/wire.h>
@@ -92,6 +92,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-key_derive.c b/common/test/run-key_derive.c
index 6b158f7..9dc6f4b 100644
--- a/common/test/run-key_derive.c
+++ b/common/test/run-key_derive.c
@@ -4,7 +4,7 @@
#include <assert.h>
#include <ccan/str/hex/hex.h>
#include <common/amount.h>
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
#include <stdio.h>
#include <wire/wire.h>
@@ -77,6 +77,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-lease_rates.c b/common/test/run-lease_rates.c
index f995eb8..5bf13c6 100644
--- a/common/test/run-lease_rates.c
+++ b/common/test/run-lease_rates.c
@@ -1,7 +1,6 @@
#include "config.h"
#include "../amount.c"
#include "../lease_rates.c"
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
@@ -41,6 +40,9 @@ u8 fromwire_u8(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_u8_array */
void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_u8_array called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-marginal_feerate.c b/common/test/run-marginal_feerate.c
index 097852c..e0d0ebd 100644
--- a/common/test/run-marginal_feerate.c
+++ b/common/test/run-marginal_feerate.c
@@ -2,7 +2,7 @@
#include <assert.h>
#include <bitcoin/chainparams.h>
#include <common/amount.h>
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
#include <stdio.h>
#include "../fee_states.c"
@@ -80,6 +80,9 @@ int htlc_state_flags(enum htlc_state state UNNEEDED)
/* Generated stub for htlc_state_name */
const char *htlc_state_name(enum htlc_state s UNNEEDED)
{ fprintf(stderr, "htlc_state_name called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-onion-message-test.c b/common/test/run-onion-message-test.c
index 7dba2c5..299a0c5 100644
--- a/common/test/run-onion-message-test.c
+++ b/common/test/run-onion-message-test.c
@@ -36,6 +36,9 @@ struct onionreply *new_onionreply(const tal_t *ctx UNNEEDED, const u8 *contents
/* 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(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-onion-test-vector.c b/common/test/run-onion-test-vector.c
index 842c96c..12986ad 100644
--- a/common/test/run-onion-test-vector.c
+++ b/common/test/run-onion-test-vector.c
@@ -100,6 +100,9 @@ bool parse_amount_sat(struct amount_sat *sat UNNEEDED, const char *s UNNEEDED, s
/* 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(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for tlv_field_offset */
size_t tlv_field_offset(const u8 *tlvstream UNNEEDED, size_t tlvlen UNNEEDED, u64 fieldtype UNNEEDED)
{ fprintf(stderr, "tlv_field_offset called!\n"); abort(); }
diff --git a/common/test/run-param.c b/common/test/run-param.c
index 3287eb2..5b7d295 100644
--- a/common/test/run-param.c
+++ b/common/test/run-param.c
@@ -9,7 +9,6 @@
#include <common/channel_type.h>
#include <common/clock_time.h>
#include <common/memleak.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
diff --git a/common/test/run-psbt_diff.c b/common/test/run-psbt_diff.c
index 1c10785..bb18358 100644
--- a/common/test/run-psbt_diff.c
+++ b/common/test/run-psbt_diff.c
@@ -1,5 +1,4 @@
#include "config.h"
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
#include "../amount.c"
@@ -41,6 +40,9 @@ void fromwire_u8_array(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, u8 *arr
/* Generated stub for pseudorand_u64_ */
uint64_t pseudorand_u64_(uint64_t *offset UNNEEDED)
{ fprintf(stderr, "pseudorand_u64_ called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-route-infloop.c b/common/test/run-route-infloop.c
index b52921e..7556fd2 100644
--- a/common/test/run-route-infloop.c
+++ b/common/test/run-route-infloop.c
@@ -8,7 +8,6 @@
#include <common/gossmap.h>
#include <common/gossip_store.h>
#include <common/memleak.h>
-#include <common/randbytes.h>
#include <common/route.h>
#include <common/sciddir_or_pubkey.h>
#include <common/setup.h>
diff --git a/common/test/run-route-specific.c b/common/test/run-route-specific.c
index 74653e2..09f20d8 100644
--- a/common/test/run-route-specific.c
+++ b/common/test/run-route-specific.c
@@ -15,7 +15,6 @@
#include <common/gossip_store_wiregen.h>
#include <common/gossmap.h>
#include <common/memleak.h>
-#include <common/randbytes.h>
#include <common/route.h>
#include <common/sciddir_or_pubkey.h>
#include <common/setup.h>
diff --git a/common/test/run-route.c b/common/test/run-route.c
index 50f3f3b..59cede0 100644
--- a/common/test/run-route.c
+++ b/common/test/run-route.c
@@ -8,7 +8,6 @@
#include <common/gossip_store_wiregen.h>
#include <common/gossmap.h>
#include <common/memleak.h>
-#include <common/randbytes.h>
#include <common/route.h>
#include <common/sciddir_or_pubkey.h>
#include <common/setup.h>
diff --git a/common/test/run-route_blinding_onion_test.c b/common/test/run-route_blinding_onion_test.c
index d3b26db..378087d 100644
--- a/common/test/run-route_blinding_onion_test.c
+++ b/common/test/run-route_blinding_onion_test.c
@@ -41,6 +41,9 @@ bool node_id_from_hexstr(const char *str UNNEEDED, size_t slen UNNEEDED, struct
/* 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(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for towire_sciddir_or_pubkey */
void towire_sciddir_or_pubkey(u8 **pptr UNNEEDED,
const struct sciddir_or_pubkey *sciddpk UNNEEDED)
diff --git a/common/test/run-route_blinding_test.c b/common/test/run-route_blinding_test.c
index cbd30ad..27c740a 100644
--- a/common/test/run-route_blinding_test.c
+++ b/common/test/run-route_blinding_test.c
@@ -13,7 +13,6 @@
#include <common/clock_time.h>
#include <common/json_parse.h>
#include <common/json_stream.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <common/wireaddr.h>
#include <stdio.h>
@@ -36,6 +35,9 @@ void fromwire_sciddir_or_pubkey(const u8 **cursor UNNEEDED, size_t *max UNNEEDED
/* Generated stub for node_id_from_hexstr */
bool node_id_from_hexstr(const char *str UNNEEDED, size_t slen UNNEEDED, struct node_id *id UNNEEDED)
{ fprintf(stderr, "node_id_from_hexstr called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed 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(); }
diff --git a/common/test/run-shutdown_scriptpubkey.c b/common/test/run-shutdown_scriptpubkey.c
index c98610d..0054836 100644
--- a/common/test/run-shutdown_scriptpubkey.c
+++ b/common/test/run-shutdown_scriptpubkey.c
@@ -4,7 +4,7 @@
#include <ccan/array_size/array_size.h>
#include <ccan/err/err.h>
#include <common/amount.h>
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
#include <common/utils.h>
#include <stdio.h>
@@ -45,6 +45,9 @@ struct amount_asset amount_sat_to_asset(struct amount_sat *sat UNNEEDED, const u
/* Generated stub for amount_tx_fee */
struct amount_sat amount_tx_fee(u32 fee_per_kw UNNEEDED, size_t weight UNNEEDED)
{ fprintf(stderr, "amount_tx_fee called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
/* Thanks ChatGPT! */
diff --git a/common/test/run-sphinx-xor_cipher_stream.c b/common/test/run-sphinx-xor_cipher_stream.c
index 0e33ace..9c3ab2f 100644
--- a/common/test/run-sphinx-xor_cipher_stream.c
+++ b/common/test/run-sphinx-xor_cipher_stream.c
@@ -1,5 +1,6 @@
#include "config.h"
#include "../sphinx.c"
+#include <bitcoin/tx.h>
#include <common/setup.h>
#include <stdio.h>
@@ -103,6 +104,9 @@ struct onionreply *new_onionreply(const tal_t *ctx UNNEEDED, const u8 *contents
/* 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(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for subkey_from_hmac */
void subkey_from_hmac(const char *prefix UNNEEDED,
const struct secret *base UNNEEDED,
diff --git a/common/test/run-sphinx.c b/common/test/run-sphinx.c
index b44101f..e9b26d6 100644
--- a/common/test/run-sphinx.c
+++ b/common/test/run-sphinx.c
@@ -89,6 +89,9 @@ bool fromwire_tlv(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
/* 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(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for tlv_field_offset */
size_t tlv_field_offset(const u8 *tlvstream UNNEEDED, size_t tlvlen UNNEEDED, u64 fieldtype UNNEEDED)
{ fprintf(stderr, "tlv_field_offset called!\n"); abort(); }
diff --git a/common/test/run-splice_script.c b/common/test/run-splice_script.c
index 082f46c..58157e0 100644
--- a/common/test/run-splice_script.c
+++ b/common/test/run-splice_script.c
@@ -6,7 +6,6 @@
#include "../json_stream.c"
#include "../json_parse_simple.c"
#include <bitcoin/chainparams.h>
-#include <common/randbytes.h>
#include <common/setup.h>
#include <common/splice_script.h>
#include <assert.h>
@@ -39,6 +38,9 @@ void command_log(struct command *cmd UNNEEDED, enum log_level level UNNEEDED,
/* Generated stub for mvt_tag_parse */
bool mvt_tag_parse(const char *buf UNNEEDED, size_t len UNNEEDED, enum mvt_tag *tag UNNEEDED)
{ fprintf(stderr, "mvt_tag_parse called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
static void set_node_id(struct splice_script_chan *chan, const char *hexstr)
diff --git a/common/test/run-tlv_span.c b/common/test/run-tlv_span.c
index eb3ede4..8a6156e 100644
--- a/common/test/run-tlv_span.c
+++ b/common/test/run-tlv_span.c
@@ -2,7 +2,6 @@
#include "../bolt12.c"
#include "../bigsize.c"
#include "../../wire/fromwire.c"
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
@@ -72,6 +71,9 @@ void sighash_from_merkle(const char *messagename UNNEEDED,
const struct sha256 *merkle UNNEEDED,
struct sha256 *sighash UNNEEDED)
{ fprintf(stderr, "sighash_from_merkle called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for to_bech32_charset */
char *to_bech32_charset(const tal_t *ctx UNNEEDED,
const char *hrp UNNEEDED, const u8 *data UNNEEDED)
diff --git a/common/test/run-tlv_unknown.c b/common/test/run-tlv_unknown.c
index 071b104..966f53b 100644
--- a/common/test/run-tlv_unknown.c
+++ b/common/test/run-tlv_unknown.c
@@ -5,7 +5,6 @@
#include "../../wire/towire.c"
#include "../bigsize.c"
#include "../bolt12.c"
-#include <common/randbytes.h>
#include <common/setup.h>
#include <stdio.h>
@@ -88,6 +87,9 @@ void sighash_from_merkle(const char *messagename UNNEEDED,
const struct sha256 *merkle UNNEEDED,
struct sha256 *sighash UNNEEDED)
{ fprintf(stderr, "sighash_from_merkle called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* Generated stub for to_bech32_charset */
char *to_bech32_charset(const tal_t *ctx UNNEEDED,
const char *hrp UNNEEDED, const u8 *data UNNEEDED)
diff --git a/common/test/run-version.c b/common/test/run-version.c
index 3b46f56..4bed5a3 100644
--- a/common/test/run-version.c
+++ b/common/test/run-version.c
@@ -1,11 +1,14 @@
#include "config.h"
#include "../version.c"
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
#include <assert.h>
#include <stdio.h>
/* AUTOGENERATED MOCKS START */
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
int main(int argc, char *argv[])
diff --git a/common/test/run-wireaddr.c b/common/test/run-wireaddr.c
index f5dd2ff..6e8ccda 100644
--- a/common/test/run-wireaddr.c
+++ b/common/test/run-wireaddr.c
@@ -1,7 +1,7 @@
#include "config.h"
#include <bitcoin/chainparams.h>
#include <common/amount.h>
-#include <common/randbytes.h>
+#include <common/pseudorand.h>
#include <common/setup.h>
#include <stdio.h>
@@ -59,6 +59,9 @@ u8 *b32_decode(const tal_t *ctx UNNEEDED, const char *str UNNEEDED, size_t len U
/* Generated stub for b32_encode */
char *b32_encode(const tal_t *ctx UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED)
{ fprintf(stderr, "b32_encode called!\n"); abort(); }
+/* Generated stub for siphash_seed */
+const struct siphash_seed *siphash_seed(void)
+{ fprintf(stderr, "siphash_seed called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
int main(int argc, char *argv[])
diff --git a/tests/fuzz/fuzz-full_channel.c b/tests/fuzz/fuzz-full_channel.c
index c907f45..977b736 100644
--- a/tests/fuzz/fuzz-full_channel.c
+++ b/tests/fuzz/fuzz-full_channel.c
@@ -14,15 +14,6 @@
#include <fcntl.h>
#include <tests/fuzz/libfuzz.h>
-/* MOCKS START */
-const struct siphash_seed *siphash_seed(void)
-{
- struct siphash_seed *siphashseed = tal(tmpctx, struct siphash_seed);
- memset(siphashseed, 1, sizeof(*siphashseed));
- return siphashseed;
-}
-/* MOCKS END */
-
#define MAX_SATS ((u64)WALLY_SATOSHI_PER_BTC * WALLY_BTC_MAX)
#define MAX_MSATS (MAX_SATS * 1000)
#define MAX_HTLCS 1000000
@@ -243,6 +234,7 @@ void init(int *argc, char ***argv)
chainparams = chainparams_for_network("bitcoin");
int devnull = open("/dev/null", O_WRONLY);
status_setup_sync(devnull);
+ fuzz_allow_siphash_seed = true;
}
struct pending_htlc {
diff --git a/tests/fuzz/fuzz-handle_onion_message.c b/tests/fuzz/fuzz-handle_onion_message.c
index d4a902d..0e96d03 100644
--- a/tests/fuzz/fuzz-handle_onion_message.c
+++ b/tests/fuzz/fuzz-handle_onion_message.c
@@ -16,7 +16,6 @@
static int lightningd_fd;
static struct privkey priv;
-static struct siphash_seed siphashseed;
jmp_buf fuzz_env;
/* MOCKS START */
@@ -27,9 +26,6 @@ u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ longjmp(fuzz_env, 1); }
-
-const struct siphash_seed *siphash_seed(void)
-{ return &siphashseed; }
/* MOCKS END */
void ecdh(const struct pubkey *point, struct secret *ss)
@@ -68,9 +64,9 @@ void init(int *argc, char ***argv)
lightningd_fd = open("/dev/null", O_WRONLY);
status_setup_sync(lightningd_fd);
chainparams = chainparams_for_network("bitcoin");
+ fuzz_allow_siphash_seed = true;
memset(&priv, 'b', sizeof(priv));
- memset(&siphashseed, 1, sizeof(siphashseed));
}
void run(const uint8_t *data, size_t size)
diff --git a/tests/fuzz/libfuzz.c b/tests/fuzz/libfuzz.c
index 8f8dc43..5d6f27a 100644
--- a/tests/fuzz/libfuzz.c
+++ b/tests/fuzz/libfuzz.c
@@ -22,6 +22,20 @@ int LLVMFuzzerInitialize(int *argc, char ***argv);
/* Provide a non-random pseudo-random function to speed fuzzing. */
static isaac64_ctx isaac64;
+/* Most tests should not be calling this */
+bool fuzz_allow_siphash_seed = false;
+
+/* Define this so we don't try to link against common/pseudorand.o! */
+const struct siphash_seed *siphash_seed(void)
+{
+ if (!fuzz_allow_siphash_seed)
+ abort();
+
+ struct siphash_seed *siphashseed = tal(tmpctx, struct siphash_seed);
+ memset(siphashseed, 1, sizeof(*siphashseed));
+ return siphashseed;
+}
+
uint64_t pseudorand_(uint64_t max, uint64_t *offset)
{
assert(max);
diff --git a/tests/fuzz/libfuzz.h b/tests/fuzz/libfuzz.h
index 332caa3..00547e8 100644
--- a/tests/fuzz/libfuzz.h
+++ b/tests/fuzz/libfuzz.h
@@ -12,6 +12,9 @@
* environment. */
void init(int *argc, char ***argv);
+/* Set if you want siphash_seed() to work */
+extern bool fuzz_allow_siphash_seed;
+
/* The actual target called multiple times with mutated data. */
void run(const uint8_t *data, size_t size);
diff --git a/wallet/wallet.c b/wallet/wallet.c
index b1dea4c..47bf6e0 100644
--- a/wallet/wallet.c
+++ b/wallet/wallet.c
@@ -68,12 +68,6 @@ static enum state_change state_change_in_db(enum state_change s)
fatal("%s: %u is invalid", __func__, s);
}
-/* libwally uses pointer/size pairs */
-struct script_with_len {
- const u8 *script;
- size_t len;
-};
-
/* We keep a hash of these, for fast lookup */
struct wallet_address {
u32 index;
@@ -81,20 +75,15 @@ struct wallet_address {
struct script_with_len swl;
};
-static size_t script_with_len_hash(const struct script_with_len *swl)
-{
- return siphash24(siphash_seed(), swl->script, swl->len);
-}
-
static const struct script_with_len *wallet_address_keyof(const struct wallet_address *waddr)
{
return &waddr->swl;
}
static bool wallet_address_eq_scriptpubkey(const struct wallet_address *waddr,
- const struct script_with_len *script)
+ const struct script_with_len *swl)
{
- return memeq(waddr->swl.script, waddr->swl.len, script->script, script->len);
+ return script_with_len_eq(&waddr->swl, swl);
}
HTABLE_DEFINE_NODUPS_TYPE(struct wallet_address,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.