Skip to content

Commit

Permalink
Adding gettruboredemption and some useful RPC info
Browse files Browse the repository at this point in the history
  • Loading branch information
Grandpa-Jones committed Jun 27, 2015
1 parent 945b419 commit 3c2d471
Show file tree
Hide file tree
Showing 8 changed files with 326 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,11 @@ static const CRPCCommand vRPCCommands[] =
{ "getblockhash", &getblockhash, false, false },
{ "gettransaction", &gettransaction, false, false },
{ "listtransactions", &listtransactions, false, false },
{ "getfirstturboblock", &getfirstturboblock, false, false },
{ "getturbo", &getturbo, false, false },
{ "getmyturboaddresses", &getmyturboaddresses, false, false },
{ "getallturboaddresses", &getallturboaddresses, false, false },
{ "getturboredemption", &getturboredemption, false, false },
{ "listaddressgroupings", &listaddressgroupings, false, false },
{ "signmessage", &signmessage, false, false },
{ "verifymessage", &verifymessage, false, false },
Expand Down
2 changes: 2 additions & 0 deletions src/bitcoinrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,11 @@ extern json_spirit::Value listaddressgroupings(const json_spirit::Array& params,
extern json_spirit::Value listaccounts(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value listsinceblock(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value gettransaction(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getfirstturboblock(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getturbo(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getmyturboaddresses(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getallturboaddresses(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getturboredemption(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value backupwallet(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value keypoolrefill(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value walletpassphrase(const json_spirit::Array& params, bool fHelp);
Expand Down
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ int64_t nTurboDuration = 30 * 24 * 60 * 60; // TurboStake ends after 30 days
// hardcoded upon first update - Thu, 25 Jun 2015 06:03:07 GMT
int64_t nTurboEndTime = 1432620187 + nTurboDuration;

// block time of first stake (about 2 days 10 min after block 1 found)
int64_t nTurboStartTime = 1432793442;

// set when known
// int nLastTurboHeight = 0;
// set when known
Expand Down
1 change: 1 addition & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ extern std::set<CWallet*> setpwalletRegistered;
extern unsigned char pchMessageStart[4];
extern std::map<uint256, CBlock*> mapOrphanBlocks;

extern int64_t nTurboStartTime;
extern int64_t nTurboEndTime;
extern CBlockIndex *pindexLastTurbo;

Expand Down
4 changes: 0 additions & 4 deletions src/qt/turboaddresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class TurboAddressTablePriv

void refreshTurboAddressTable()
{
printf("TurboAddressTablePriv::refreshTurboAddressTable: called\n");
cachedTurboAddressTable.clear();

int rank = 0;
Expand All @@ -36,7 +35,6 @@ class TurboAddressTablePriv
++rank;
cachedTurboAddressTable.append(TurboAddressTableEntry(rank, QString::fromStdString(it->name_),
it->value_.get_int()));
printf("TurboAddressTablePriv::refreshTurboAddressTable: rank: %d\n", rank);
}

// qLowerBound() and qUpperBound() require
Expand Down Expand Up @@ -207,7 +205,6 @@ void TurboAddressTableModel::emitLayoutChanged()

void TurboAddressTableModel::setTurbos(json_spirit::Object allTurbos)
{
printf("TurboAddressTableModel::setTurbos: called\n");
emit beginResetModel();
priv->allTurbos = allTurbos;
priv->refreshTurboAddressTable();
Expand All @@ -224,7 +221,6 @@ void TurboAddressTableModel::update()

if (!IsInitialBlockDownload()) {
// [TODO] factor getallturboaddresses
printf("TurboAddressTableModel::update: called\n");
json_spirit::Object allTurbos = getallturboaddresses(json_spirit::Array(), false).get_obj();
this->setTurbos(allTurbos);
}
Expand Down
1 change: 1 addition & 0 deletions src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("blocktrust", leftTrim(blockindex->GetBlockTrust().GetHex(), '0')));
result.push_back(Pair("chaintrust", leftTrim(blockindex->nChainTrust.GetHex(), '0')));
result.push_back(Pair("money supply", ValueFromAmount(blockindex->nMoneySupply)));
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
if (blockindex->pnext)
Expand Down
41 changes: 41 additions & 0 deletions src/rpcrawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH

void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
{
CTxDB txdb("r");

entry.push_back(Pair("txid", tx.GetHash().GetHex()));
entry.push_back(Pair("version", tx.nVersion));
entry.push_back(Pair("time", (boost::int64_t)tx.nTime));
entry.push_back(Pair("locktime", (boost::int64_t)tx.nLockTime));
if (tx.nVersion > 1) {
entry.push_back(Pair("tx-comment", tx.strTxComment));
entry.push_back(Pair("product-id", (boost::int64_t)tx.nProdTypeID));
}
Array vin;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
Expand All @@ -66,6 +72,41 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
in.push_back(Pair("scriptSig", o));
}
in.push_back(Pair("sequence", (boost::int64_t)txin.nSequence));


// [TODO] Refactor this! See getturboredemption.
CTransaction txPrev;
CTxIndex txindex;
if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex))
{
if (fDebug)
{
printf("TxToJSON: could not read txin from disk\n");
}
continue; // previous transaction not in main chain?
}
CTxOut prevtxout = txPrev.vout[txin.prevout.n];

int nRequired;
txnouttype type;
vector<CTxDestination> addresses;
if (ExtractDestinations(prevtxout.scriptPubKey, type, addresses, nRequired))
{
in.push_back(Pair("value", ValueFromAmount(prevtxout.nValue)));
}
else
{
in.push_back(Pair("type", GetTxnOutputType(TX_NONSTANDARD)));
}

Array a;
BOOST_FOREACH(const CTxDestination& addr, addresses)
{
a.push_back(CBitcoinAddress(addr).ToString());
}

in.push_back(Pair("addresses", a));

vin.push_back(in);
}
entry.push_back(Pair("vin", vin));
Expand Down

0 comments on commit 3c2d471

Please sign in to comment.