| 38 | |
| 39 | |
| 40 | static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) |
| 41 | { |
| 42 | // Call into TxToUniv() in bitcoin-common to decode the transaction hex. |
| 43 | // |
| 44 | // Blockchain contextual information (confirmations and blocktime) is not |
| 45 | // available to code in bitcoin-common, so we query them here and push the |
| 46 | // data into the returned UniValue. |
| 47 | TxToUniv(tx, uint256(), entry, true, RPCSerializationFlags()); |
| 48 | |
| 49 | if (!hashBlock.IsNull()) { |
| 50 | LOCK(cs_main); |
| 51 | |
| 52 | entry.pushKV("blockhash", hashBlock.GetHex()); |
| 53 | CBlockIndex* pindex = LookupBlockIndex(hashBlock); |
| 54 | if (pindex) { |
| 55 | if (chainActive.Contains(pindex)) { |
| 56 | entry.pushKV("confirmations", 1 + chainActive.Height() - pindex->nHeight); |
| 57 | entry.pushKV("time", pindex->GetBlockTime()); |
| 58 | entry.pushKV("blocktime", pindex->GetBlockTime()); |
| 59 | } |
| 60 | else |
| 61 | entry.pushKV("confirmations", 0); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | static UniValue getrawtransaction(const JSONRPCRequest& request) |
| 67 | { |
no test coverage detected