diff options
author | Pieter Wuille <pieter@wuille.net> | 2024-06-08 07:46:47 -0400 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2024-07-01 10:26:46 -0400 |
commit | b3b382dde202ad508baf553817c5b38fdd2d4a0c (patch) | |
tree | f16a8aa8b19dba63f3888b108276a1f946b9caa9 /src/random.h | |
parent | 493a2e024e845e623e202e3eefe1cc2010e9b514 (diff) |
random: move rand256() and randbytes() to .h file
Diffstat (limited to 'src/random.h')
-rw-r--r-- | src/random.h | 14 |
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); } |