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

Function WalletTxToJSON

src/wallet/rpcwallet.cpp:92–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92static void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
93{
94 int confirms = wtx.GetDepthInMainChain();
95 entry.pushKV("confirmations", confirms);
96 if (wtx.IsCoinBase())
97 entry.pushKV("generated", true);
98 if (confirms > 0)
99 {
100 entry.pushKV("blockhash", wtx.hashBlock.GetHex());
101 entry.pushKV("blockindex", wtx.nIndex);
102 entry.pushKV("blocktime", LookupBlockIndex(wtx.hashBlock)->GetBlockTime());
103 } else {
104 entry.pushKV("trusted", wtx.IsTrusted());
105 }
106 uint256 hash = wtx.GetHash();
107 entry.pushKV("txid", hash.GetHex());
108 UniValue conflicts(UniValue::VARR);
109 for (const uint256& conflict : wtx.GetConflicts())
110 conflicts.push_back(conflict.GetHex());
111 entry.pushKV("walletconflicts", conflicts);
112 entry.pushKV("time", wtx.GetTxTime());
113 entry.pushKV("timereceived", (int64_t)wtx.nTimeReceived);
114
115 // Add opt-in RBF status
116 std::string rbfStatus = "no";
117 if (confirms <= 0) {
118 LOCK(mempool.cs);
119 RBFTransactionState rbfState = IsRBFOptIn(*wtx.tx, mempool);
120 if (rbfState == RBFTransactionState::UNKNOWN)
121 rbfStatus = "unknown";
122 else if (rbfState == RBFTransactionState::REPLACEABLE_BIP125)
123 rbfStatus = "yes";
124 }
125 entry.pushKV("bip125-replaceable", rbfStatus);
126
127 for (const std::pair<const std::string, std::string>& item : wtx.mapValue)
128 entry.pushKV(item.first, item.second);
129}
130
131static std::string LabelFromValue(const UniValue& value)
132{

Callers 2

ListTransactionsFunction · 0.85
gettransactionFunction · 0.85

Calls 12

LookupBlockIndexFunction · 0.85
IsRBFOptInFunction · 0.85
GetDepthInMainChainMethod · 0.80
IsTrustedMethod · 0.80
GetConflictsMethod · 0.80
GetTxTimeMethod · 0.80
pushKVMethod · 0.45
IsCoinBaseMethod · 0.45
GetHexMethod · 0.45
GetBlockTimeMethod · 0.45
GetHashMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected