Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | void ScriptPubKeyToJSON(const Config &config, const CScript &scriptPubKey, | ||||
out.push_back(Pair("addresses", a)); | out.push_back(Pair("addresses", a)); | ||||
} | } | ||||
void TxToJSON(const Config &config, const CTransaction &tx, | void TxToJSON(const Config &config, const CTransaction &tx, | ||||
const uint256 hashBlock, UniValue &entry) { | const uint256 hashBlock, UniValue &entry) { | ||||
entry.push_back(Pair("txid", tx.GetId().GetHex())); | entry.push_back(Pair("txid", tx.GetId().GetHex())); | ||||
entry.push_back(Pair("hash", tx.GetHash().GetHex())); | entry.push_back(Pair("hash", tx.GetHash().GetHex())); | ||||
entry.push_back(Pair( | entry.push_back(Pair( | ||||
"size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION))); | "size", int(::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION)))); | ||||
entry.push_back(Pair("version", tx.nVersion)); | entry.push_back(Pair("version", tx.nVersion)); | ||||
entry.push_back(Pair("locktime", (int64_t)tx.nLockTime)); | entry.push_back(Pair("locktime", int64_t(tx.nLockTime))); | ||||
UniValue vin(UniValue::VARR); | UniValue vin(UniValue::VARR); | ||||
for (unsigned int i = 0; i < tx.vin.size(); i++) { | for (unsigned int i = 0; i < tx.vin.size(); i++) { | ||||
const CTxIn &txin = tx.vin[i]; | const CTxIn &txin = tx.vin[i]; | ||||
UniValue in(UniValue::VOBJ); | UniValue in(UniValue::VOBJ); | ||||
if (tx.IsCoinBase()) { | if (tx.IsCoinBase()) { | ||||
in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), | in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), | ||||
txin.scriptSig.end()))); | txin.scriptSig.end()))); | ||||
} else { | } else { | ||||
in.push_back(Pair("txid", txin.prevout.GetTxId().GetHex())); | in.push_back(Pair("txid", txin.prevout.GetTxId().GetHex())); | ||||
in.push_back(Pair("vout", int64_t(txin.prevout.GetN()))); | in.push_back(Pair("vout", int64_t(txin.prevout.GetN()))); | ||||
UniValue o(UniValue::VOBJ); | UniValue o(UniValue::VOBJ); | ||||
o.push_back(Pair("asm", ScriptToAsmStr(txin.scriptSig, true))); | o.push_back(Pair("asm", ScriptToAsmStr(txin.scriptSig, true))); | ||||
o.push_back(Pair( | o.push_back(Pair( | ||||
"hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); | "hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); | ||||
in.push_back(Pair("scriptSig", o)); | in.push_back(Pair("scriptSig", o)); | ||||
} | } | ||||
in.push_back(Pair("sequence", (int64_t)txin.nSequence)); | in.push_back(Pair("sequence", int64_t(txin.nSequence))); | ||||
vin.push_back(in); | vin.push_back(in); | ||||
} | } | ||||
entry.push_back(Pair("vin", vin)); | entry.push_back(Pair("vin", vin)); | ||||
UniValue vout(UniValue::VARR); | UniValue vout(UniValue::VARR); | ||||
for (unsigned int i = 0; i < tx.vout.size(); i++) { | for (unsigned int i = 0; i < tx.vout.size(); i++) { | ||||
const CTxOut &txout = tx.vout[i]; | const CTxOut &txout = tx.vout[i]; | ||||
UniValue out(UniValue::VOBJ); | UniValue out(UniValue::VOBJ); | ||||
out.push_back(Pair("value", ValueFromAmount(txout.nValue))); | out.push_back(Pair("value", ValueFromAmount(txout.nValue))); | ||||
out.push_back(Pair("n", (int64_t)i)); | out.push_back(Pair("n", int64_t(i))); | ||||
UniValue o(UniValue::VOBJ); | UniValue o(UniValue::VOBJ); | ||||
ScriptPubKeyToJSON(config, txout.scriptPubKey, o, true); | ScriptPubKeyToJSON(config, txout.scriptPubKey, o, true); | ||||
out.push_back(Pair("scriptPubKey", o)); | out.push_back(Pair("scriptPubKey", o)); | ||||
vout.push_back(out); | vout.push_back(out); | ||||
} | } | ||||
entry.push_back(Pair("vout", vout)); | entry.push_back(Pair("vout", vout)); | ||||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | static UniValue gettxoutproof(const Config &config, | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
CBlockIndex *pblockindex = nullptr; | CBlockIndex *pblockindex = nullptr; | ||||
uint256 hashBlock; | uint256 hashBlock; | ||||
if (request.params.size() > 1) { | if (request.params.size() > 1) { | ||||
hashBlock = uint256S(request.params[1].get_str()); | hashBlock = uint256S(request.params[1].get_str()); | ||||
if (!mapBlockIndex.count(hashBlock)) | if (!mapBlockIndex.count(hashBlock)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | |||||
pblockindex = mapBlockIndex[hashBlock]; | pblockindex = mapBlockIndex[hashBlock]; | ||||
} else { | } else { | ||||
// Loop through txids and try to find which block they're in. Exit loop | // Loop through txids and try to find which block they're in. Exit loop | ||||
// once a block is found. | // once a block is found. | ||||
for (const auto &txid : setTxIds) { | for (const auto &txid : setTxIds) { | ||||
const Coin &coin = AccessByTxid(*pcoinsTip, txid); | const Coin &coin = AccessByTxid(*pcoinsTip, txid); | ||||
if (!coin.IsSpent()) { | if (!coin.IsSpent()) { | ||||
pblockindex = chainActive[coin.GetHeight()]; | pblockindex = chainActive[coin.GetHeight()]; | ||||
▲ Show 20 Lines • Show All 874 Lines • Show Last 20 Lines |