Remove address indexes
This commit is contained in:
@@ -63,91 +63,9 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fInclud
|
||||
out.push_back(Pair("addresses", a));
|
||||
}
|
||||
|
||||
void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& entry,
|
||||
int nHeight = 0, int nConfirmations = 0, int nBlockTime = 0)
|
||||
{
|
||||
|
||||
uint256 txid = tx.GetHash();
|
||||
entry.push_back(Pair("txid", txid.GetHex()));
|
||||
entry.push_back(Pair("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION)));
|
||||
entry.push_back(Pair("version", tx.nVersion));
|
||||
entry.push_back(Pair("locktime", (int64_t)tx.nLockTime));
|
||||
UniValue vin(UniValue::VARR);
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
||||
UniValue in(UniValue::VOBJ);
|
||||
if (tx.IsCoinBase())
|
||||
in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
|
||||
else {
|
||||
in.push_back(Pair("txid", txin.prevout.hash.GetHex()));
|
||||
in.push_back(Pair("vout", (int64_t)txin.prevout.n));
|
||||
UniValue o(UniValue::VOBJ);
|
||||
o.push_back(Pair("asm", ScriptToAsmStr(txin.scriptSig, true)));
|
||||
o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
|
||||
in.push_back(Pair("scriptSig", o));
|
||||
|
||||
// Add address and value info if spentindex enabled
|
||||
CSpentIndexValue spentInfo;
|
||||
CSpentIndexKey spentKey(txin.prevout.hash, txin.prevout.n);
|
||||
if (GetSpentIndex(spentKey, spentInfo)) {
|
||||
in.push_back(Pair("value", ValueFromAmount(spentInfo.satoshis)));
|
||||
in.push_back(Pair("valueSat", spentInfo.satoshis));
|
||||
if (spentInfo.addressType == 1) {
|
||||
in.push_back(Pair("address", EncodeDestination(CKeyID(spentInfo.addressHash))));
|
||||
} else if (spentInfo.addressType == 2) {
|
||||
in.push_back(Pair("address", EncodeDestination(CScriptID(spentInfo.addressHash))));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
in.push_back(Pair("sequence", (int64_t)txin.nSequence));
|
||||
vin.push_back(in);
|
||||
}
|
||||
entry.push_back(Pair("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);
|
||||
out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
|
||||
out.push_back(Pair("valueSat", txout.nValue));
|
||||
out.push_back(Pair("n", (int64_t)i));
|
||||
UniValue o(UniValue::VOBJ);
|
||||
ScriptPubKeyToJSON(txout.scriptPubKey, o, true);
|
||||
out.push_back(Pair("scriptPubKey", o));
|
||||
|
||||
// Add spent information if spentindex is enabled
|
||||
CSpentIndexValue spentInfo;
|
||||
CSpentIndexKey spentKey(txid, i);
|
||||
if (GetSpentIndex(spentKey, spentInfo)) {
|
||||
out.push_back(Pair("spentTxId", spentInfo.txid.GetHex()));
|
||||
out.push_back(Pair("spentIndex", (int)spentInfo.inputIndex));
|
||||
out.push_back(Pair("spentHeight", spentInfo.blockHeight));
|
||||
}
|
||||
|
||||
vout.push_back(out);
|
||||
}
|
||||
entry.push_back(Pair("vout", vout));
|
||||
|
||||
if (!hashBlock.IsNull()) {
|
||||
entry.push_back(Pair("blockhash", hashBlock.GetHex()));
|
||||
|
||||
if (nConfirmations > 0) {
|
||||
entry.push_back(Pair("height", nHeight));
|
||||
entry.push_back(Pair("confirmations", nConfirmations));
|
||||
entry.push_back(Pair("time", nBlockTime));
|
||||
entry.push_back(Pair("blocktime", nBlockTime));
|
||||
} else {
|
||||
entry.push_back(Pair("height", -1));
|
||||
entry.push_back(Pair("confirmations", 0));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
|
||||
{
|
||||
|
||||
uint256 txid = tx.GetHash();
|
||||
entry.push_back(Pair("txid", txid.GetHex()));
|
||||
entry.push_back(Pair("txid", tx.GetHash().GetHex()));
|
||||
entry.push_back(Pair("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION)));
|
||||
entry.push_back(Pair("version", tx.nVersion));
|
||||
entry.push_back(Pair("locktime", (int64_t)tx.nLockTime));
|
||||
@@ -175,7 +93,6 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
|
||||
const CTxOut& txout = tx.vout[i];
|
||||
UniValue out(UniValue::VOBJ);
|
||||
out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
|
||||
out.push_back(Pair("valueSat", txout.nValue));
|
||||
out.push_back(Pair("n", (int64_t)i));
|
||||
UniValue o(UniValue::VOBJ);
|
||||
ScriptPubKeyToJSON(txout.scriptPubKey, o, true);
|
||||
@@ -190,14 +107,12 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
|
||||
if (mi != mapBlockIndex.end() && (*mi).second) {
|
||||
CBlockIndex* pindex = (*mi).second;
|
||||
if (chainActive.Contains(pindex)) {
|
||||
entry.push_back(Pair("height", pindex->nHeight));
|
||||
entry.push_back(Pair("confirmations", 1 + chainActive.Height() - pindex->nHeight));
|
||||
entry.push_back(Pair("time", pindex->GetBlockTime()));
|
||||
entry.push_back(Pair("blocktime", pindex->GetBlockTime()));
|
||||
} else {
|
||||
entry.push_back(Pair("height", -1));
|
||||
entry.push_back(Pair("confirmations", 0));
|
||||
}
|
||||
else
|
||||
entry.push_back(Pair("confirmations", 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,6 +184,8 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp)
|
||||
+ HelpExampleRpc("getrawtransaction", "\"mytxid\", 1")
|
||||
);
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
uint256 hash = ParseHashV(params[0], "parameter 1");
|
||||
|
||||
bool fVerbose = false;
|
||||
@@ -276,31 +193,9 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp)
|
||||
fVerbose = (params[1].get_int() != 0);
|
||||
|
||||
CTransaction tx;
|
||||
|
||||
uint256 hashBlock;
|
||||
int nHeight = 0;
|
||||
int nConfirmations = 0;
|
||||
int nBlockTime = 0;
|
||||
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true))
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
|
||||
|
||||
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
|
||||
if (mi != mapBlockIndex.end() && (*mi).second) {
|
||||
CBlockIndex* pindex = (*mi).second;
|
||||
if (chainActive.Contains(pindex)) {
|
||||
nHeight = pindex->nHeight;
|
||||
nConfirmations = 1 + chainActive.Height() - pindex->nHeight;
|
||||
nBlockTime = pindex->GetBlockTime();
|
||||
} else {
|
||||
nHeight = -1;
|
||||
nConfirmations = 0;
|
||||
nBlockTime = pindex->GetBlockTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true))
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
|
||||
|
||||
string strHex = EncodeHexTx(tx);
|
||||
|
||||
@@ -309,8 +204,7 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp)
|
||||
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.push_back(Pair("hex", strHex));
|
||||
TxToJSONExpanded(tx, hashBlock, result, nHeight, nConfirmations, nBlockTime);
|
||||
|
||||
TxToJSON(tx, hashBlock, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user