bitcoin: have random_scid() function.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-08-14 12:40:11 +09:30
parent ab80345754
commit 639452ac77
5 changed files with 18 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
#include "config.h"
#include <bitcoin/short_channel_id.h>
#include <ccan/tal/str/str.h>
#include <sodium/randombytes.h>
#include <stdio.h>
#include <wire/wire.h>
@@ -99,3 +100,10 @@ struct short_channel_id fromwire_short_channel_id(const u8 **cursor, size_t *max
scid.u64 = fromwire_u64(cursor, max);
return scid;
}
struct short_channel_id random_scid(void)
{
struct short_channel_id scid;
randombytes_buf(&scid, sizeof(scid));
return scid;
}

View File

@@ -98,4 +98,6 @@ void towire_short_channel_id(u8 **pptr,
struct short_channel_id short_channel_id);
struct short_channel_id fromwire_short_channel_id(const u8 **cursor, size_t *max);
/* Set to random bytes */
struct short_channel_id random_scid(void);
#endif /* LIGHTNING_BITCOIN_SHORT_CHANNEL_ID_H */