MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / TxToJSON

Function TxToJSON

src/rpc/rawtransaction.cpp:40–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39
40static 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
66static UniValue getrawtransaction(const JSONRPCRequest& request)
67{

Callers 1

getrawtransactionFunction · 0.85

Calls 10

TxToUnivFunction · 0.85
RPCSerializationFlagsFunction · 0.85
LookupBlockIndexFunction · 0.85
HeightMethod · 0.80
uint256Class · 0.50
IsNullMethod · 0.45
pushKVMethod · 0.45
GetHexMethod · 0.45
ContainsMethod · 0.45
GetBlockTimeMethod · 0.45

Tested by

no test coverage detected