本文整理汇总了C++中CTransaction::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ CTransaction::GetId方法的具体用法?C++ CTransaction::GetId怎么用?C++ CTransaction::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTransaction
的用法示例。
在下文中一共展示了CTransaction::GetId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TxToUniv
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock,
UniValue &entry) {
entry.pushKV("txid", tx.GetId().GetHex());
entry.pushKV("hash", tx.GetHash().GetHex());
entry.pushKV("version", tx.nVersion);
entry.pushKV("locktime", (int64_t)tx.nLockTime);
UniValue vin(UniValue::VARR);
for (unsigned int i = 0; i < tx.vin.size(); i++) {
const CTxIn &txin = tx.vin[i];
UniValue in(UniValue::VOBJ);
if (tx.IsCoinBase()) {
in.pushKV("coinbase",
HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
} else {
in.pushKV("txid", txin.prevout.hash.GetHex());
in.pushKV("vout", (int64_t)txin.prevout.n);
UniValue o(UniValue::VOBJ);
o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true));
o.pushKV("hex",
HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
in.pushKV("scriptSig", o);
}
in.pushKV("sequence", (int64_t)txin.nSequence);
vin.push_back(in);
}
entry.pushKV("vin", vin);
UniValue vout(UniValue::VARR);
for (unsigned int i = 0; i < tx.vout.size(); i++) {
const CTxOut &txout = tx.vout[i];
UniValue out(UniValue::VOBJ);
UniValue outValue(UniValue::VNUM,
FormatMoney(txout.nValue.GetSatoshis()));
out.pushKV("value", outValue);
out.pushKV("n", (int64_t)i);
UniValue o(UniValue::VOBJ);
ScriptPubKeyToUniv(txout.scriptPubKey, o, true);
out.pushKV("scriptPubKey", o);
vout.push_back(out);
}
entry.pushKV("vout", vout);
if (!hashBlock.IsNull()) {
entry.pushKV("blockhash", hashBlock.GetHex());
}
// the hex-encoded transaction. used the name "hex" to be consistent with
// the verbose output of "getrawtransaction".
entry.pushKV("hex", EncodeHexTx(tx));
}