forked from tpruvot/ccminer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
diff: import bitcoin bignum class for conversions
BIGNUM is defined in OpenSSL...
- Loading branch information
Showing
7 changed files
with
1,491 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Wrapper to OpenSSL BIGNUM used by net diff (nBits) | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "uint256.h" | ||
#include "bignum.hpp" | ||
|
||
#include "miner.h" // hex2bin | ||
|
||
extern "C" double bn_convert_nbits(const uint32_t nBits) | ||
{ | ||
uint256 bn = CBigNum().SetCompact(nBits).getuint256(); | ||
return bn.getdouble(); | ||
} | ||
|
||
// copy the big number to 32-bytes uchar | ||
extern "C" void bn_nbits_to_uchar(const uint32_t nBits, unsigned char *target) | ||
{ | ||
char buff[65]; | ||
uint256 bn = CBigNum().SetCompact(nBits).getuint256(); | ||
|
||
snprintf(buff, 65, "%s\n", bn.ToString().c_str()); buff[64] = '\0'; | ||
hex2bin(target, buff, 32); | ||
} |
Oops, something went wrong.