MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / TxToUniv

Function TxToUniv

src/core_write.cpp:165–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry)
166{
167 entry.pushKV("txid", tx.GetHash().GetHex());
168 entry.pushKV("version", tx.nVersion);
169 entry.pushKV("locktime", (int64_t)tx.nLockTime);
170
171 UniValue vin(UniValue::VARR);
172 BOOST_FOREACH(const CTxIn& txin, tx.vin) {
173 UniValue in(UniValue::VOBJ);
174 if (tx.IsCoinBase())
175 in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
176 else {
177 in.pushKV("txid", txin.prevout.hash.GetHex());
178 in.pushKV("vout", (int64_t)txin.prevout.n);
179 UniValue o(UniValue::VOBJ);
180 o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true));
181 o.pushKV("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
182 in.pushKV("scriptSig", o);
183 }
184 in.pushKV("sequence", (int64_t)txin.nSequence);
185 vin.push_back(in);
186 }
187 entry.pushKV("vin", vin);
188
189 UniValue vout(UniValue::VARR);
190 for (unsigned int i = 0; i < tx.vout.size(); i++) {
191 const CTxOut& txout = tx.vout[i];
192
193 UniValue out(UniValue::VOBJ);
194
195 UniValue outValue(UniValue::VNUM, FormatMoney(txout.nValue));
196 out.pushKV("value", outValue);
197 out.pushKV("n", (int64_t)i);
198
199 UniValue o(UniValue::VOBJ);
200 ScriptPubKeyToUniv(txout.scriptPubKey, o, true);
201 out.pushKV("scriptPubKey", o);
202 vout.push_back(out);
203 }
204 entry.pushKV("vout", vout);
205
206 if (!hashBlock.IsNull())
207 entry.pushKV("blockhash", hashBlock.GetHex());
208
209 entry.pushKV("hex", EncodeHexTx(tx)); // the hex-encoded transaction. used the name "hex" to be consistent with the verbose output of "getrawtransaction".
210}

Callers 1

OutputTxJSONFunction · 0.85

Calls 9

FormatMoneyFunction · 0.85
ScriptPubKeyToUnivFunction · 0.85
EncodeHexTxFunction · 0.85
pushKVMethod · 0.45
GetHexMethod · 0.45
GetHashMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected