Skip to content

Commit a09e63f

Browse files
committed
Make OP_DETERMINISTICRANDOM endian-safe
Fixing a TODO from elements-0.14.1. Signed-off-by: Steven Roose <[email protected]>
1 parent 1967112 commit a09e63f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/script/interpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,8 +1374,8 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
13741374
hasher.Write(vchSeed.data(), vchSeed.size());
13751375
do {
13761376
if (nHashIndex >= 3) {
1377-
//TODO this isn't endian safe
1378-
CSHA256(hasher).Write((const unsigned char*)&nCounter, sizeof(nCounter)).Finalize(vchHash.data());
1377+
uint64_t le_counter = htole64(nCounter);
1378+
CSHA256(hasher).Write((const unsigned char*)&le_counter, sizeof(nCounter)).Finalize(vchHash.data());
13791379
nHashIndex = 0;
13801380
nCounter++;
13811381
}

0 commit comments

Comments
 (0)