global: replace randombytes_buf() with randbytes() wrapper.

This allows us to override it for deterministic results.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-11-13 15:39:31 +10:30
parent 2086699b70
commit f8fd97fb5d
69 changed files with 112 additions and 45 deletions

View File

@@ -9,9 +9,9 @@
#include <common/json_stream.h>
#include <common/onion_message.h>
#include <common/overflows.h>
#include <common/randbytes.h>
#include <plugins/offers.h>
#include <plugins/offers_offer.h>
#include <sodium/randombytes.h>
static bool msat_or_any(const char *buffer,
const jsmntok_t *tok,
@@ -706,8 +706,8 @@ struct command_result *json_invoicerequest(struct command *cmd,
* - MUST set `invreq_metadata` to an unpredictable series of bytes.
*/
invreq->invreq_metadata = tal_arr(invreq, u8, 16);
randombytes_buf(invreq->invreq_metadata,
tal_bytelen(invreq->invreq_metadata));
randbytes(invreq->invreq_metadata,
tal_bytelen(invreq->invreq_metadata));
/* BOLT #12:
* - otherwise (not responding to an offer):