aboutsummaryrefslogtreecommitdiff
path: root/src/core_write.cpp
diff options
context:
space:
mode:
authorjonnynewbs <jonnynewbs@gmail.com>2016-09-21 10:52:53 -0400
committerjnewbery <john@johnnewbery.com>2016-10-05 09:00:34 -0400
commit4408558843c6c2b7abeb4160f641dfdbf5be5eb4 (patch)
treef2619b1603e2ae5b81d314ee1cda3eaed6b0a114 /src/core_write.cpp
parenta7e5cbb209d4aeb8c2e4c58c92bf214759998056 (diff)
Update bitcoin-tx to output witness data.
Diffstat (limited to 'src/core_write.cpp')
-rw-r--r--src/core_write.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core_write.cpp b/src/core_write.cpp
index 6f9e2266a3..ea01ddc10d 100644
--- a/src/core_write.cpp
+++ b/src/core_write.cpp
@@ -151,11 +151,13 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey,
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry)
{
entry.pushKV("txid", tx.GetHash().GetHex());
+ entry.pushKV("hash", tx.GetWitnessHash().GetHex());
entry.pushKV("version", tx.nVersion);
entry.pushKV("locktime", (int64_t)tx.nLockTime);
UniValue vin(UniValue::VARR);
- BOOST_FOREACH(const CTxIn& txin, tx.vin) {
+ 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()));
@@ -166,6 +168,13 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry)
o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true));
o.pushKV("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
in.pushKV("scriptSig", o);
+ if (!tx.wit.IsNull() && i < tx.wit.vtxinwit.size() && !tx.wit.vtxinwit[i].IsNull()) {
+ UniValue txinwitness(UniValue::VARR);
+ for (const auto& item : tx.wit.vtxinwit[i].scriptWitness.stack) {
+ txinwitness.push_back(HexStr(item.begin(), item.end()));
+ }
+ in.pushKV("txinwitness", txinwitness);
+ }
}
in.pushKV("sequence", (int64_t)txin.nSequence);
vin.push_back(in);