aboutsummaryrefslogtreecommitdiff
path: root/src/random.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2024-06-08 07:46:47 -0400
committerPieter Wuille <pieter@wuille.net>2024-07-01 10:26:46 -0400
commitb3b382dde202ad508baf553817c5b38fdd2d4a0c (patch)
treef16a8aa8b19dba63f3888b108276a1f946b9caa9 /src/random.h
parent493a2e024e845e623e202e3eefe1cc2010e9b514 (diff)
random: move rand256() and randbytes() to .h file
Diffstat (limited to 'src/random.h')
-rw-r--r--src/random.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/random.h b/src/random.h
index f7c20ee4b0..ab9686c5b9 100644
--- a/src/random.h
+++ b/src/random.h
@@ -213,7 +213,12 @@ public:
/** Generate random bytes. */
template <typename B = unsigned char>
- std::vector<B> randbytes(size_t len);
+ std::vector<B> randbytes(size_t len)
+ {
+ std::vector<B> ret(len);
+ fillrand(MakeWritableByteSpan(ret));
+ return ret;
+ }
/** Fill a byte Span with random bytes. */
void fillrand(Span<std::byte> output);
@@ -222,7 +227,12 @@ public:
uint32_t rand32() noexcept { return randbits(32); }
/** generate a random uint256. */
- uint256 rand256() noexcept;
+ uint256 rand256() noexcept
+ {
+ uint256 ret;
+ fillrand(MakeWritableByteSpan(ret));
+ return ret;
+ }
/** Generate a random boolean. */
bool randbool() noexcept { return randbits(1); }