Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
BlockMechanic committed Jul 23, 2022
1 parent 9d9a52f commit ec99954
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
19 changes: 8 additions & 11 deletions src/masternode/masternode-budget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,15 @@ int GetNextSuperblock(int height)
bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, std::string& strError, int64_t& nTime, int& nConf)
{
uint256 nBlockHash;
CTransactionRef txCollateral = GetTransaction(nullptr, nullptr, nTxCollateralHash, Params().GetConsensus(), nBlockHash);
CBlockIndex* blockindex = nullptr;

CTransactionRef txCollateral = GetTransaction(blockindex, g_mempool, nTxCollateralHash, Params().GetConsensus(), nBlockHash);

if(!txCollateral){
strError = strprintf("Can't find collateral tx %s", nTxCollateralHash.ToString());
LogPrintf ("CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError);
return false;
}
if(txCollateral->nVersion >= TX_ELE_VERSION)
if(txCollateral->vpout.size() < 1) return false;
else
if(txCollateral->vout.size() < 1) return false;

if(txCollateral->nLockTime != 0) return false;

CScript findScript;
findScript << OP_RETURN << ToByteVector(nExpectedHash);
Expand All @@ -138,7 +134,8 @@ bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, s
LogPrintf ("CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError);
return false;
}
if(o.scriptPubKey == findScript && o.nValue >= BUDGET_FEE_TX) foundOpReturn = true;

if(o.scriptPubKey[0] == OP_RETURN && o.nValue >= BUDGET_FEE_TX) foundOpReturn = true;

}
if(!foundOpReturn){
Expand Down Expand Up @@ -307,8 +304,8 @@ void CBudgetManager::SubmitBudgetDraft()

int conf = GetIXConfirmations(tx->GetHash());
uint256 nBlockHash;

CTransactionRef txCollateral = GetTransaction(nullptr, nullptr, txidCollateral, Params().GetConsensus(), nBlockHash);
CBlockIndex* blockindex = nullptr;
CTransactionRef txCollateral = GetTransaction(blockindex, nullptr, txidCollateral, Params().GetConsensus(), nBlockHash);

if(!txCollateral) {
LogPrintf ("CBudgetManager::SubmitBudgetDraft - Can't find collateral tx %s", txidCollateral.ToString());
Expand Down Expand Up @@ -464,7 +461,7 @@ void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees) c
txNew.vpout[0].nValue = GetBlockSubsidy(pindexPrev->nHeight, Params().GetConsensus());
else
txNew.vout[0].nValue = GetBlockSubsidy(pindexPrev->nHeight, Params().GetConsensus());


// Find finalized budgets with the most votes

Expand Down
3 changes: 2 additions & 1 deletion src/masternode/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,8 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS) const
// verify that sig time is legit in past
// should be at least not earlier than block when 10000 CRW tx got MASTERNODE_MIN_CONFIRMATIONS
uint256 hashBlock = uint256();
CTransactionRef tx2 = GetTransaction(nullptr, nullptr, vin.prevout.hash, Params().GetConsensus(), hashBlock);
CBlockIndex* blockindex = nullptr;
CTransactionRef tx2 = GetTransaction(blockindex, nullptr, vin.prevout.hash, Params().GetConsensus(), hashBlock);
BlockMap::iterator mi = g_chainman.m_blockman.m_block_index.find(hashBlock);
if (mi != g_chainman.m_blockman.m_block_index.end() && (*mi).second)
{
Expand Down
3 changes: 2 additions & 1 deletion src/systemnode/systemnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ bool CSystemnodeBroadcast::CheckInputsAndAdd(int& nDoS) const
// verify that sig time is legit in past
// should be at least not earlier than block when 10000 CRW tx got SYSTEMNODE_MIN_CONFIRMATIONS
uint256 hashBlock = uint256();
CTransactionRef tx2 = GetTransaction(nullptr, nullptr, vin.prevout.hash, Params().GetConsensus(), hashBlock);;
CBlockIndex* blockindex = nullptr;
CTransactionRef tx2 = GetTransaction(blockindex, nullptr, vin.prevout.hash, Params().GetConsensus(), hashBlock);;
BlockMap::iterator mi = g_chainman.m_blockman.m_block_index.find(hashBlock);
if (mi != g_chainman.m_blockman.m_block_index.end() && (*mi).second)
{
Expand Down
8 changes: 4 additions & 4 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2754,22 +2754,22 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
//Asset DB
{
for(unsigned int i = 0; i < block.vtx.size(); i++){
LogPrintf("TRANSACTION: \n %s\n", block.vtx[i]->ToString());
//LogPrintf("TRANSACTION: \n %s\n", block.vtx[i]->ToString());
if(block.vtx[i]->nVersion >= TX_ELE_VERSION ){
for(unsigned int j = 0; j < block.vtx[i]->vpout.size(); j++){
CAsset out = block.vtx[i]->vpout[j].nAsset;

bool exists = false;
LogPrintf("%s: FOUND ASSET %s \n", __func__, out.ToString());
//LogPrintf("%s: FOUND ASSET %s \n", __func__, out.ToString());

for(auto const& x : passetsCache->GetItemsMap()){
CAsset checkasset = x.second->second.asset;
if(iequals(out.getAssetName(), checkasset.getAssetName()) || iequals(out.getAssetName(), checkasset.getShortName()))
exists = true;
}

if (exists)
LogPrintf("%s: EXISTS ASSET %s.\n", __func__, out.getAssetName());
//if (exists)
// LogPrintf("%s: EXISTS ASSET %s.\n", __func__, out.getAssetName());

if (!exists && !passetsCache->Exists(out.getAssetName())){
if(!fJustCheck){
Expand Down

0 comments on commit ec99954

Please sign in to comment.