| 56 | static constexpr decltype(CTransaction::version) DEFAULT_RAWTX_VERSION{CTransaction::CURRENT_VERSION}; |
| 57 | |
| 58 | static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry, |
| 59 | Chainstate& active_chainstate, const CTxUndo* txundo = nullptr, |
| 60 | TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS) |
| 61 | { |
| 62 | CHECK_NONFATAL(verbosity >= TxVerbosity::SHOW_DETAILS); |
| 63 | // Call into TxToUniv() in bitcoin-common to decode the transaction hex. |
| 64 | // |
| 65 | // Blockchain contextual information (confirmations and blocktime) is not |
| 66 | // available to code in bitcoin-common, so we query them here and push the |
| 67 | // data into the returned UniValue. |
| 68 | TxToUniv(tx, /*block_hash=*/uint256(), entry, /*include_hex=*/true, txundo, verbosity); |
| 69 | |
| 70 | if (!hashBlock.IsNull()) { |
| 71 | LOCK(cs_main); |
| 72 | |
| 73 | entry.pushKV("blockhash", hashBlock.GetHex()); |
| 74 | const CBlockIndex* pindex = active_chainstate.m_blockman.LookupBlockIndex(hashBlock); |
| 75 | if (pindex) { |
| 76 | if (active_chainstate.m_chain.Contains(*pindex)) { |
| 77 | entry.pushKV("confirmations", 1 + active_chainstate.m_chain.Height() - pindex->nHeight); |
| 78 | entry.pushKV("time", pindex->GetBlockTime()); |
| 79 | entry.pushKV("blocktime", pindex->GetBlockTime()); |
| 80 | } |
| 81 | else |
| 82 | entry.pushKV("confirmations", 0); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | static std::vector<RPCArg> CreateTxDoc() |
| 88 | { |
no test coverage detected