You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
594 B
27 lines
594 B
10 years ago
|
/**
|
||
|
* 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);
|
||
|
}
|