Getbalance64
This commit is contained in:
@@ -383,6 +383,7 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "wallet", "getaccount", &getaccount, true },
|
{ "wallet", "getaccount", &getaccount, true },
|
||||||
{ "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true },
|
{ "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true },
|
||||||
{ "wallet", "getbalance", &getbalance, false },
|
{ "wallet", "getbalance", &getbalance, false },
|
||||||
|
{ "wallet", "getbalance64", &getbalance64, false },
|
||||||
{ "wallet", "getnewaddress", &getnewaddress, true },
|
{ "wallet", "getnewaddress", &getnewaddress, true },
|
||||||
{ "wallet", "getrawchangeaddress", &getrawchangeaddress, true },
|
{ "wallet", "getrawchangeaddress", &getrawchangeaddress, true },
|
||||||
{ "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false },
|
{ "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false },
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ extern UniValue verifymessage(const UniValue& params, bool fHelp);
|
|||||||
extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp);
|
extern UniValue getreceivedbyaddress(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp);
|
extern UniValue getreceivedbyaccount(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getbalance(const UniValue& params, bool fHelp);
|
extern UniValue getbalance(const UniValue& params, bool fHelp);
|
||||||
|
extern UniValue getbalance64(const UniValue& params, bool fHelp);
|
||||||
extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp);
|
extern UniValue getunconfirmedbalance(const UniValue& params, bool fHelp);
|
||||||
extern UniValue movecmd(const UniValue& params, bool fHelp);
|
extern UniValue movecmd(const UniValue& params, bool fHelp);
|
||||||
extern UniValue sendfrom(const UniValue& params, bool fHelp);
|
extern UniValue sendfrom(const UniValue& params, bool fHelp);
|
||||||
|
|||||||
@@ -4673,3 +4673,48 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
} else fprintf(stderr,"no earliest utxo for staking\n");
|
} else fprintf(stderr,"no earliest utxo for staking\n");
|
||||||
return(siglen);
|
return(siglen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue getbalance64(const UniValue& params, bool fHelp)
|
||||||
|
{
|
||||||
|
set<CBitcoinAddress> setAddress; vector<COutput> vecOutputs;
|
||||||
|
UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR),b(UniValue::VARR);
|
||||||
|
const CKeyStore& keystore = *pwalletMain;
|
||||||
|
CAmount nValues[64],nValues2[64],nValue,total,total2; int32_t i,segid;
|
||||||
|
assert(pwalletMain != NULL);
|
||||||
|
if (fHelp || params.size() > 0)
|
||||||
|
throw runtime_error("getbalance64\n");
|
||||||
|
total = total2 = 0;
|
||||||
|
memset(nValues,0,sizeof(nValues));
|
||||||
|
memset(nValues2,0,sizeof(nValues2));
|
||||||
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true);
|
||||||
|
BOOST_FOREACH(const COutput& out, vecOutputs)
|
||||||
|
{
|
||||||
|
nValue = out.tx->vout[out.i].nValue;
|
||||||
|
if ( setAddress.size() )
|
||||||
|
{
|
||||||
|
CTxDestination address;
|
||||||
|
if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
|
||||||
|
continue;
|
||||||
|
if (!setAddress.count(address))
|
||||||
|
continue;
|
||||||
|
segid = komodo_segid((char *)CBitcoinAddress(address).ToString().c_str());
|
||||||
|
if ( out.nDepth < 100 )
|
||||||
|
nValues2[segid] += nValue, total2 += nValue;
|
||||||
|
else nValues[segid] += nValue, total += nValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret.push_back(Pair("staking",(double)total/COIN));
|
||||||
|
ret.push_back(Pair("immature",(double)total2/COIN));
|
||||||
|
for (i=0; i<64; i++)
|
||||||
|
{
|
||||||
|
UniValue item(UniValue::VOBJ);
|
||||||
|
item.push_back(double)nValues[i] / COIN);
|
||||||
|
a.push_back(item);
|
||||||
|
item.push_back(double)nValues2[i] / COIN);
|
||||||
|
b.push_back(item);
|
||||||
|
}
|
||||||
|
ret.push_back(Pair("staking", a));
|
||||||
|
ret.push_back(Pair("immature", b));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user