Delete Verus junk, which breaks ARMv8/aarch64 builds

This commit is contained in:
Duke Leto
2019-11-04 08:17:27 -05:00
parent a918948401
commit f39cd2a473
19 changed files with 43 additions and 1261 deletions

View File

@@ -1338,120 +1338,6 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list<CAccountingEntry>& acentries,
return txOrdered;
}
// looks through all wallet UTXOs and checks to see if any qualify to stake the block at the current height. it always returns the qualified
// UTXO with the smallest coin age if there is more than one, as larger coin age will win more often and is worth saving
// each attempt consists of taking a VerusHash of the following values:
// ASSETCHAINS_MAGIC, nHeight, txid, voutNum
bool CWallet::VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult, CTransaction &stakeSource, int32_t &voutNum, int32_t nHeight, uint32_t &bnTarget) const
{
arith_uint256 target;
arith_uint256 curHash;
vector<COutput> vecOutputs;
COutput *pwinner = NULL;
CBlockIndex *pastBlockIndex;
txnouttype whichType;
std:vector<std::vector<unsigned char>> vSolutions;
pBlock->nNonce.SetPOSTarget(bnTarget);
target.SetCompact(bnTarget);
pwalletMain->AvailableCoins(vecOutputs, true, NULL, false, false);
if (pastBlockIndex = komodo_chainactive(nHeight - 100))
{
CBlockHeader bh = pastBlockIndex->GetBlockHeader();
uint256 pastHash = bh.GetVerusEntropyHash(nHeight - 100);
CPOSNonce curNonce;
BOOST_FOREACH(COutput &txout, vecOutputs)
{
if (txout.fSpendable && (UintToArith256(txout.tx->GetVerusPOSHash(&(pBlock->nNonce), txout.i, nHeight, pastHash)) <= target) && (txout.nDepth >= VERUS_MIN_STAKEAGE))
{
if ((!pwinner || UintToArith256(curNonce) > UintToArith256(pBlock->nNonce)) &&
(Solver(txout.tx->vout[txout.i].scriptPubKey, whichType, vSolutions) && (whichType == TX_PUBKEY || whichType == TX_PUBKEYHASH)))
{
//printf("Found PoS block\nnNonce: %s\n", pBlock->nNonce.GetHex().c_str());
pwinner = &txout;
curNonce = pBlock->nNonce;
}
}
}
if (pwinner)
{
stakeSource = *(pwinner->tx);
voutNum = pwinner->i;
pBlock->nNonce = curNonce;
return true;
}
}
return false;
}
int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &bnTarget, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey pk) const
{
CTransaction stakeSource;
int32_t voutNum, siglen = 0;
int64_t nValue;
txnouttype whichType;
std::vector<std::vector<unsigned char>> vSolutions;
CBlockIndex *tipindex = chainActive.LastTip();
uint32_t stakeHeight = tipindex->GetHeight() + 1;
pk = CPubKey();
bnTarget = lwmaGetNextPOSRequired(tipindex, Params().GetConsensus());
if (!VerusSelectStakeOutput(pBlock, hashResult, stakeSource, voutNum, tipindex->GetHeight() + 1, bnTarget) ||
!Solver(stakeSource.vout[voutNum].scriptPubKey, whichType, vSolutions))
{
LogPrintf("Searched for eligible staking transactions, no winners found\n");
return 0;
}
bool signSuccess;
SignatureData sigdata;
uint64_t txfee;
auto consensusBranchId = CurrentEpochBranchId(stakeHeight, Params().GetConsensus());
const CKeyStore& keystore = *pwalletMain;
txNew.vin.resize(1);
txNew.vout.resize(1);
txfee = 0;
txNew.vin[0].prevout.hash = stakeSource.GetHash();
txNew.vin[0].prevout.n = voutNum;
if (whichType == TX_PUBKEY)
{
txNew.vout[0].scriptPubKey << ToByteVector(vSolutions[0]) << OP_CHECKSIG;
if (!pk.IsValid())
pk = CPubKey(vSolutions[0]);
}
else if (whichType == TX_PUBKEYHASH)
{
txNew.vout[0].scriptPubKey << OP_DUP << OP_HASH160 << ToByteVector(vSolutions[0]) << OP_EQUALVERIFY << OP_CHECKSIG;
}
else
return 0;
nValue = txNew.vout[0].nValue = stakeSource.vout[voutNum].nValue - txfee;
txNew.nLockTime = 0;
CTransaction txNewConst(txNew);
signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, nValue, SIGHASH_ALL), stakeSource.vout[voutNum].scriptPubKey, sigdata, consensusBranchId);
if (!signSuccess)
fprintf(stderr,"failed to create signature\n");
else
{
uint8_t *ptr;
UpdateTransaction(txNew,0,sigdata);
ptr = (uint8_t *)&sigdata.scriptSig[0];
siglen = sigdata.scriptSig.size();
for (int i=0; i<siglen; i++)
utxosig[i] = ptr[i];//, fprintf(stderr,"%02x",ptr[i]);
}
return(siglen);
}
void CWallet::MarkDirty()
{