bitcoin: have random_scid() function.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user