| 21 | void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex); |
| 22 | |
| 23 | double GetDifficulty(const CBlockIndex* blockindex) |
| 24 | { |
| 25 | // Floating point number that is a multiple of the minimum difficulty, |
| 26 | // minimum difficulty = 1.0. |
| 27 | if (blockindex == NULL) |
| 28 | { |
| 29 | if (chainActive.Tip() == NULL) |
| 30 | return 1.0; |
| 31 | else |
| 32 | blockindex = chainActive.Tip(); |
| 33 | } |
| 34 | |
| 35 | int nShift = (blockindex->nBits >> 24) & 0xff; |
| 36 | |
| 37 | double dDiff = |
| 38 | (double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff); |
| 39 | |
| 40 | while (nShift < 29) |
| 41 | { |
| 42 | dDiff *= 256.0; |
| 43 | nShift++; |
| 44 | } |
| 45 | while (nShift > 29) |
| 46 | { |
| 47 | dDiff /= 256.0; |
| 48 | nShift--; |
| 49 | } |
| 50 | |
| 51 | return dDiff; |
| 52 | } |
| 53 | |
| 54 | UniValue blockheaderToJSON(const CBlockIndex* blockindex) |
| 55 | { |
no test coverage detected