Skip to content

Commit

Permalink
getweight RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
presstab committed Jan 28, 2015
1 parent 8f657b8 commit 1be9d61
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ static const CRPCCommand vRPCCommands[] =
{ "cccustomchange", &cccustomchange, false, false },
{ "ccreset", &ccreset, false, false },
{ "ccsend", &ccsend, false, false },
{ "getweight", &getweight, false, false },
};

CRPCTable::CRPCTable()
Expand Down
1 change: 1 addition & 0 deletions src/bitcoinrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ extern json_spirit::Value ccreturnchange(const json_spirit::Array& params, bool
extern json_spirit::Value cccustomchange(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value ccreset(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value ccsend(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getweight(const json_spirit::Array& params, bool fHelp);

extern json_spirit::Value getrawtransaction(const json_spirit::Array& params, bool fHelp); // in rcprawtransaction.cpp
extern json_spirit::Value listunspent(const json_spirit::Array& params, bool fHelp);
Expand Down
21 changes: 21 additions & 0 deletions src/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,27 @@ Value getstaketx(const Array& params, bool fHelp)
return entry;
}

//presstab HyperStake
Value getweight(const Array& params, bool fHelp)
{
std::vector<COutput> vCoins;
pwalletMain->AvailableCoins(vCoins);

uint64 nWeightSum = 0;
BOOST_FOREACH(const COutput& out, vCoins)
{
int64 nHeight = nBestHeight - out.nDepth;
CBlockIndex* pindex = FindBlockByHeight(nHeight);
uint64 nWeight = 0;
pwalletMain->GetStakeWeightFromValue(out.tx->GetTxTime(), out.tx->vout[out.i].nValue, nWeight);
double dAge = double(GetTime() - pindex->nTime) / (60*60*24);
if(dAge < 8.8)
nWeight = 0;
nWeightSum += nWeight;
}
return (double)nWeightSum;
}

// presstab HyperStake
Value setstakesplitthreshold(const Array& params, bool fHelp)
{
Expand Down

0 comments on commit 1be9d61

Please sign in to comment.