Test
This commit is contained in:
@@ -992,7 +992,7 @@ UniValue listunspent(const UniValue& params, bool fHelp);
|
|||||||
|
|
||||||
int32_t komodo_staked(uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig)
|
int32_t komodo_staked(uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig)
|
||||||
{
|
{
|
||||||
UniValue params = NullUniValue;
|
int32_t nMinDepth = 1,nMaxDepth = 9999999;
|
||||||
*utxovaluep = 0;
|
*utxovaluep = 0;
|
||||||
memset(utxotxidp,0,sizeof(*utxotxidp));
|
memset(utxotxidp,0,sizeof(*utxotxidp));
|
||||||
memset(utxovoutp,0,sizeof(*utxovoutp));
|
memset(utxovoutp,0,sizeof(*utxovoutp));
|
||||||
@@ -1002,6 +1002,59 @@ int32_t komodo_staked(uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep
|
|||||||
assert(pwalletMain != NULL);
|
assert(pwalletMain != NULL);
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true);
|
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||||
|
const CScript& pk = out.tx->vout[out.i].scriptPubKey;
|
||||||
|
UniValue entry(UniValue::VOBJ);
|
||||||
|
entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
|
||||||
|
entry.push_back(Pair("vout", out.i));
|
||||||
|
entry.push_back(Pair("generated", out.tx->IsCoinBase()));
|
||||||
|
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].name));
|
||||||
|
}
|
||||||
|
entry.push_back(Pair("scriptPubKey", HexStr(pk.begin(), pk.end())));
|
||||||
|
if (pk.IsPayToScriptHash())
|
||||||
|
{
|
||||||
|
CTxDestination address;
|
||||||
|
if (ExtractDestination(pk, address)) {
|
||||||
|
const CScriptID& hash = boost::get<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)));
|
||||||
|
if ( out.tx->nLockTime != 0 )
|
||||||
|
{
|
||||||
|
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
|
||||||
|
CBlockIndex *tipindex,*pindex = it->second;
|
||||||
|
uint64_t interest; uint32_t locktime; int32_t txheight;
|
||||||
|
if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 )
|
||||||
|
{
|
||||||
|
komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue,(int32_t)tipindex->nHeight);
|
||||||
|
interest = komodo_interest(txheight,nValue,out.tx->nLockTime,tipindex->nTime);
|
||||||
|
entry.push_back(Pair("interest",ValueFromAmount(interest)));
|
||||||
|
}
|
||||||
|
//fprintf(stderr,"nValue %.8f pindex.%p tipindex.%p locktime.%u txheight.%d pindexht.%d\n",(double)nValue/COIN,pindex,chainActive.Tip(),locktime,txheight,pindex->nHeight);
|
||||||
|
}
|
||||||
|
entry.push_back(Pair("confirmations",out.nDepth));
|
||||||
|
entry.push_back(Pair("spendable", out.fSpendable));
|
||||||
|
fprintf(stderr,"%s\n",results.get_str().c_str());
|
||||||
|
}
|
||||||
fprintf(stderr,"listunspent done\n");
|
fprintf(stderr,"listunspent done\n");
|
||||||
return(72);
|
return(72);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user