Skip to content

Commit f4e6487

Browse files
committed
src/arith_256.cpp: bigendian compatibility
1 parent aac3205 commit f4e6487

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/arith_uint256.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "uint256.h"
99
#include "utilstrencodings.h"
10+
#include "crypto/common.h"
1011

1112
#include <stdio.h>
1213
#include <string.h>
@@ -246,14 +247,14 @@ uint32_t arith_uint256::GetCompact(bool fNegative) const
246247
uint256 ArithToUint256(const arith_uint256 &a)
247248
{
248249
uint256 b;
249-
// TODO: needs bswap32 on big-endian
250-
memcpy(b.begin(), a.pn, a.size());
250+
for(int x=0; x<a.WIDTH; ++x)
251+
WriteLE32(b.begin() + x*4, a.pn[x]);
251252
return b;
252253
}
253254
arith_uint256 UintToArith256(const uint256 &a)
254255
{
255256
arith_uint256 b;
256-
// TODO: needs bswap32 on big-endian
257-
memcpy(b.pn, a.begin(), a.size());
257+
for(int x=0; x<b.WIDTH; ++x)
258+
b.pn[x] = ReadLE32(a.begin() + x*4);
258259
return b;
259260
}

0 commit comments

Comments
 (0)