Test
This commit is contained in:
@@ -988,7 +988,7 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue ValueFromAmount(const CAmount& amount);
|
void komodo_listunspent();
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -997,64 +997,8 @@ int32_t komodo_staked(uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep
|
|||||||
memset(utxotxidp,0,sizeof(*utxotxidp));
|
memset(utxotxidp,0,sizeof(*utxotxidp));
|
||||||
memset(utxovoutp,0,sizeof(*utxovoutp));
|
memset(utxovoutp,0,sizeof(*utxovoutp));
|
||||||
memset(utxosig,0,72);
|
memset(utxosig,0,72);
|
||||||
fprintf(stderr,"call listunspent\n");
|
fprintf(stderr,"start listunspent\n");
|
||||||
vector<COutput> vecOutputs;
|
komodo_listunspent();
|
||||||
assert(pwalletMain != NULL);
|
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
|
||||||
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",entry.get_str().c_str());
|
|
||||||
}
|
|
||||||
fprintf(stderr,"listunspent done\n");
|
fprintf(stderr,"listunspent done\n");
|
||||||
return(72);
|
return(72);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2691,6 +2691,68 @@ UniValue listunspent(const UniValue& params, bool fHelp)
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void komodo_listunspent()
|
||||||
|
{
|
||||||
|
fprintf(stderr,"call listunspent\n");
|
||||||
|
vector<COutput> vecOutputs;
|
||||||
|
assert(pwalletMain != NULL);
|
||||||
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
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",entry.get_str().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t komodo_interestsum()
|
uint64_t komodo_interestsum()
|
||||||
{
|
{
|
||||||
uint64_t interest,sum = 0;
|
uint64_t interest,sum = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user