From a9bad5a3004be82ed2578b9b738ff913795e56b8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 May 2018 15:47:18 +0300 Subject: [PATCH] test --- src/coins.cpp | 1 + src/komodo_gateway.h | 13 ++++++++++--- src/main.cpp | 3 ++- src/miner.cpp | 2 +- src/wallet/rpcwallet.cpp | 15 ++++++++------- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index bb40af9cc..ba55d174e 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -462,6 +462,7 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const const COutPoint &prevout = tx.vin[i].prevout; const CCoins* coins = AccessCoins(prevout.hash); if (!coins || !coins->IsAvailable(prevout.n)) { + fprintf(stderr,"HaveInputs missing input %s/v%d\n",prevout.hash.ToString().c_str()); return false; } } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7eb5d9ab8..dcb5d2483 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -683,18 +683,21 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } } n = block.vtx[0].vout.size(); - script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); + //script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); //if ( n <= 2 || script[0] != 0x6a ) { - int64_t val,prevtotal = 0; int32_t overflow = 0; + int64_t val,strangeout=0,prevtotal = 0; int32_t overflow = 0; total = 0; for (i=1; i= MAX_MONEY ) { overflow = 1; break; } + if ( script[0] != 0x6a && val == 0 ) + strangeout++; total += val; if ( total < prevtotal || (val != 0 && total == prevtotal) ) { @@ -719,10 +722,14 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim if ( height > KOMODO_NOTARIES_HEIGHT1 ) return(-1); } + if ( height > 800000 && strangeout != 0 ) + { + fprintf(stderr,"ht.%d strangout.%d\n",height,strangeout); + } } else { - if ( overflow != 0 || total > 0 ) + if ( overflow != 0 || total > 0 || strangeout != 0 ) return(-1); } return(0); diff --git a/src/main.cpp b/src/main.cpp index 511a7413c..cdb0b3f3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2684,9 +2684,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (!tx.IsCoinBase()) { if (!view.HaveInputs(tx)) + { return state.DoS(100, error("ConnectBlock(): inputs missing/spent"), REJECT_INVALID, "bad-txns-inputs-missingorspent"); - + } // are the JoinSplit's requirements met? if (!view.HaveJoinSplitRequirements(tx)) return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"), diff --git a/src/miner.cpp b/src/miner.cpp index e113571dd..f8414cb19 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -491,7 +491,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxFees.push_back(txfees); pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary)); nFees += txfees; - fprintf(stderr,"add notaryvin\n"); + //fprintf(stderr,"add notaryvin\n"); } else fprintf(stderr,"error adding notaryvin\n"); } else diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 499484b01..673cca17a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4505,10 +4505,11 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) continue; } utxovalue = (uint64_t)nValue; - decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + //decode_hex((uint8_t *)&utxotxid,32,(char *)out.tx->GetHash().GetHex().c_str()); + utxotxid = out.tx->GetHash(); utxovout = out.i; best_scriptPubKey = out.tx->vout[out.i].scriptPubKey; - fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); + //fprintf(stderr,"check %s/v%d %llu\n",(char *)out.tx->GetHash().GetHex().c_str(),utxovout,(long long)utxovalue); bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr; uint256 revtxid,utxotxid; auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); @@ -4516,9 +4517,9 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) txNew.vin.resize(1); txNew.vout.resize(1); txfee = utxovalue / 2;; - for (i=0; i<32; i++) - ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; - txNew.vin[0].prevout.hash = revtxid; + //for (i=0; i<32; i++) + // ((uint8_t *)&revtxid)[i] = ((uint8_t *)&utxotxid)[31 - i]; + txNew.vin[0].prevout.hash = utxotxid; //revtxid; txNew.vin[0].prevout.n = utxovout; txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; txNew.vout[0].nValue = utxovalue - txfee; @@ -4532,8 +4533,8 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33) ptr = (uint8_t *)sigdata.scriptSig.data(); siglen = sigdata.scriptSig.size(); for (i=0; i