mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-02-05 11:24:19 +00:00
remove stuff, improve TxToJSON
This commit is contained in:
parent
a6ff5511fa
commit
2fa9731108
@ -239,7 +239,6 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "verifymessage", &verifymessage, false, false },
|
{ "verifymessage", &verifymessage, false, false },
|
||||||
{ "getwork", &getwork, true, false },
|
{ "getwork", &getwork, true, false },
|
||||||
{ "listaccounts", &listaccounts, false, false },
|
{ "listaccounts", &listaccounts, false, false },
|
||||||
{ "settxfee", &settxfee, false, false },
|
|
||||||
{ "getblocktemplate", &getblocktemplate, true, false },
|
{ "getblocktemplate", &getblocktemplate, true, false },
|
||||||
{ "submitblock", &submitblock, false, false },
|
{ "submitblock", &submitblock, false, false },
|
||||||
{ "listsinceblock", &listsinceblock, false, false },
|
{ "listsinceblock", &listsinceblock, false, false },
|
||||||
@ -247,13 +246,11 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "dumpwallet", &dumpwallet, true, false },
|
{ "dumpwallet", &dumpwallet, true, false },
|
||||||
{ "importprivkey", &importprivkey, false, false },
|
{ "importprivkey", &importprivkey, false, false },
|
||||||
{ "importwallet", &importwallet, false, false },
|
{ "importwallet", &importwallet, false, false },
|
||||||
{ "listunspent", &listunspent, false, false },
|
|
||||||
{ "getrawtransaction", &getrawtransaction, false, false },
|
{ "getrawtransaction", &getrawtransaction, false, false },
|
||||||
{ "createrawtransaction", &createrawtransaction, false, false },
|
{ "createrawtransaction", &createrawtransaction, false, false },
|
||||||
{ "decoderawtransaction", &decoderawtransaction, false, false },
|
{ "decoderawtransaction", &decoderawtransaction, false, false },
|
||||||
{ "signrawtransaction", &signrawtransaction, false, false },
|
{ "signrawtransaction", &signrawtransaction, false, false },
|
||||||
{ "sendrawtransaction", &sendrawtransaction, false, false },
|
{ "sendrawtransaction", &sendrawtransaction, false, false },
|
||||||
{ "gettxoutsetinfo", &gettxoutsetinfo, true, false },
|
|
||||||
{ "gettxout", &gettxout, true, false },
|
{ "gettxout", &gettxout, true, false },
|
||||||
{ "lockunspent", &lockunspent, false, false },
|
{ "lockunspent", &lockunspent, false, false },
|
||||||
{ "listlockunspent", &listlockunspent, false, false },
|
{ "listlockunspent", &listlockunspent, false, false },
|
||||||
|
@ -116,22 +116,6 @@ Value getdifficulty(const Array& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Value settxfee(const Array& params, bool fHelp)
|
|
||||||
{
|
|
||||||
if (fHelp || params.size() < 1 || params.size() > 1)
|
|
||||||
throw runtime_error(
|
|
||||||
"settxfee <amount>\n"
|
|
||||||
"<amount> is a real and is rounded to the nearest 0.00000001");
|
|
||||||
|
|
||||||
// Amount
|
|
||||||
int64 nAmount = 0;
|
|
||||||
if (params[0].get_real() != 0.0)
|
|
||||||
nAmount = AmountFromValue(params[0]); // rejects 0.0 amounts
|
|
||||||
|
|
||||||
nTransactionFee = nAmount;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Value getrawmempool(const Array& params, bool fHelp)
|
Value getrawmempool(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
@ -139,7 +123,6 @@ Value getrawmempool(const Array& params, bool fHelp)
|
|||||||
"getrawmempool\n"
|
"getrawmempool\n"
|
||||||
"Returns all transaction ids in memory pool.");
|
"Returns all transaction ids in memory pool.");
|
||||||
|
|
||||||
// [MF] check: hashes are now userhash
|
|
||||||
vector<uint256> vtxid;
|
vector<uint256> vtxid;
|
||||||
mempool.queryHashes(vtxid);
|
mempool.queryHashes(vtxid);
|
||||||
|
|
||||||
@ -199,28 +182,6 @@ Value getblock(const Array& params, bool fHelp)
|
|||||||
return blockToJSON(block, pblockindex);
|
return blockToJSON(block, pblockindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value gettxoutsetinfo(const Array& params, bool fHelp)
|
|
||||||
{
|
|
||||||
if (fHelp || params.size() != 0)
|
|
||||||
throw runtime_error(
|
|
||||||
"gettxoutsetinfo\n"
|
|
||||||
"Returns statistics about the unspent transaction output set.");
|
|
||||||
|
|
||||||
Object ret;
|
|
||||||
|
|
||||||
CCoinsStats stats;
|
|
||||||
if (pcoinsTip->GetStats(stats)) {
|
|
||||||
ret.push_back(Pair("height", (boost::int64_t)stats.nHeight));
|
|
||||||
ret.push_back(Pair("bestblock", stats.hashBlock.GetHex()));
|
|
||||||
ret.push_back(Pair("transactions", (boost::int64_t)stats.nTransactions));
|
|
||||||
ret.push_back(Pair("txouts", (boost::int64_t)stats.nTransactionOutputs));
|
|
||||||
ret.push_back(Pair("bytes_serialized", (boost::int64_t)stats.nSerializedSize));
|
|
||||||
ret.push_back(Pair("hash_serialized", stats.hashSerialized.GetHex()));
|
|
||||||
ret.push_back(Pair("total_amount", ValueFromAmount(stats.nTotalAmount)));
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
Value gettxout(const Array& params, bool fHelp)
|
Value gettxout(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 2 || params.size() > 3)
|
if (fHelp || params.size() < 2 || params.size() > 3)
|
||||||
|
@ -78,43 +78,17 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
|
|||||||
{
|
{
|
||||||
entry.push_back(Pair("txid", tx.GetUsernameHash().GetHex()));
|
entry.push_back(Pair("txid", tx.GetUsernameHash().GetHex()));
|
||||||
entry.push_back(Pair("version", tx.nVersion));
|
entry.push_back(Pair("version", tx.nVersion));
|
||||||
//entry.push_back(Pair("locktime", (boost::int64_t)tx.nLockTime));
|
entry.push_back(Pair("message", tx.message.ExtractPushDataString(0)));
|
||||||
Array vin;
|
entry.push_back(Pair("username", tx.userName.ExtractPushDataString(0)));
|
||||||
/* [MF]
|
std::vector< std::vector<unsigned char> > vData;
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
if( tx.pubKey.ExtractPushData(vData) ) {
|
||||||
{
|
Array o;
|
||||||
Object in;
|
BOOST_FOREACH(std::vector<unsigned char> vch, vData) {
|
||||||
if (tx.IsCoinBase())
|
o.push_back(HexStr(vch));
|
||||||
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", (boost::int64_t)txin.prevout.n));
|
|
||||||
Object o;
|
|
||||||
o.push_back(Pair("asm", txin.scriptSig.ToString()));
|
|
||||||
o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())));
|
|
||||||
in.push_back(Pair("scriptSig", o));
|
|
||||||
}
|
}
|
||||||
in.push_back(Pair("sequence", (boost::int64_t)txin.nSequence));
|
entry.push_back(Pair("pubKey", o));
|
||||||
vin.push_back(in);
|
|
||||||
}
|
}
|
||||||
*/
|
entry.push_back(Pair("nonce", (int) tx.nNonce));
|
||||||
entry.push_back(Pair("vin", vin));
|
|
||||||
Array vout;
|
|
||||||
/*
|
|
||||||
for (unsigned int i = 0; i < tx.vout.size(); i++)
|
|
||||||
{
|
|
||||||
const CTxOut& txout = tx.vout[i];
|
|
||||||
Object out;
|
|
||||||
out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
|
|
||||||
out.push_back(Pair("n", (boost::int64_t)i));
|
|
||||||
Object o;
|
|
||||||
ScriptPubKeyToJSON(txout.scriptPubKey, o);
|
|
||||||
out.push_back(Pair("scriptPubKey", o));
|
|
||||||
vout.push_back(out);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
entry.push_back(Pair("vout", vout));
|
|
||||||
|
|
||||||
if (hashBlock != 0)
|
if (hashBlock != 0)
|
||||||
{
|
{
|
||||||
@ -169,94 +143,6 @@ Value getrawtransaction(const Array& params, bool fHelp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value listunspent(const Array& params, bool fHelp)
|
|
||||||
{
|
|
||||||
if (fHelp || params.size() > 3)
|
|
||||||
throw runtime_error(
|
|
||||||
"listunspent [minconf=1] [maxconf=9999999] [\"address\",...]\n"
|
|
||||||
"Returns array of unspent transaction outputs\n"
|
|
||||||
"with between minconf and maxconf (inclusive) confirmations.\n"
|
|
||||||
"Optionally filtered to only include txouts paid to specified addresses.\n"
|
|
||||||
"Results are an array of Objects, each of which has:\n"
|
|
||||||
"{txid, vout, scriptPubKey, amount, confirmations}");
|
|
||||||
|
|
||||||
RPCTypeCheck(params, list_of(int_type)(int_type)(array_type));
|
|
||||||
|
|
||||||
int nMinDepth = 1;
|
|
||||||
if (params.size() > 0)
|
|
||||||
nMinDepth = params[0].get_int();
|
|
||||||
|
|
||||||
int nMaxDepth = 9999999;
|
|
||||||
if (params.size() > 1)
|
|
||||||
nMaxDepth = params[1].get_int();
|
|
||||||
|
|
||||||
set<CBitcoinAddress> setAddress;
|
|
||||||
if (params.size() > 2)
|
|
||||||
{
|
|
||||||
Array inputs = params[2].get_array();
|
|
||||||
BOOST_FOREACH(Value& input, inputs)
|
|
||||||
{
|
|
||||||
CBitcoinAddress address(input.get_str());
|
|
||||||
if (!address.IsValid())
|
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Bitcoin address: ")+input.get_str());
|
|
||||||
if (setAddress.count(address))
|
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+input.get_str());
|
|
||||||
setAddress.insert(address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Array results;
|
|
||||||
vector<COutput> vecOutputs;
|
|
||||||
pwalletMain->AvailableCoins(vecOutputs, false);
|
|
||||||
BOOST_FOREACH(const COutput& out, vecOutputs)
|
|
||||||
{
|
|
||||||
if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (setAddress.size())
|
|
||||||
{
|
|
||||||
CTxDestination address;
|
|
||||||
/*
|
|
||||||
if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
|
|
||||||
continue;
|
|
||||||
*/
|
|
||||||
if (!setAddress.count(address))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
int64 nValue = out.tx->vout[out.i].nValue;
|
|
||||||
const CScript& pk = out.tx->vout[out.i].scriptPubKey;
|
|
||||||
Object entry;
|
|
||||||
entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
|
|
||||||
entry.push_back(Pair("vout", out.i));
|
|
||||||
CTxDestination address;
|
|
||||||
if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
|
|
||||||
{
|
|
||||||
entry.push_back(Pair("address", CBitcoinAddress(address).ToString()));
|
|
||||||
if (pwalletMain->mapAddressBook.count(address))
|
|
||||||
entry.push_back(Pair("account", pwalletMain->mapAddressBook[address]));
|
|
||||||
}
|
|
||||||
entry.push_back(Pair("scriptPubKey", HexStr(pk.begin(), pk.end())));
|
|
||||||
if (pk.IsPayToScriptHash())
|
|
||||||
{
|
|
||||||
CTxDestination address;
|
|
||||||
if (ExtractDestination(pk, address))
|
|
||||||
{
|
|
||||||
const CScriptID& hash = boost::get<const CScriptID&>(address);
|
|
||||||
CScript redeemScript;
|
|
||||||
if (pwalletMain->GetCScript(hash, redeemScript))
|
|
||||||
entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry.push_back(Pair("amount",ValueFromAmount(nValue)));
|
|
||||||
entry.push_back(Pair("confirmations",out.nDepth));
|
|
||||||
results.push_back(entry);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
Value createrawtransaction(const Array& params, bool fHelp)
|
Value createrawtransaction(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 2)
|
if (fHelp || params.size() != 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user