From bc441c935238c5fbc5150d7b42fac21104a34761 Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Sat, 7 May 2016 22:17:37 +0300 Subject: [PATCH] Fix sign comparison warning & replace unsigned int with uint32_t for nIn. --- src/main.cpp | 2 +- src/qt/multisigdialog.cpp | 2 +- src/rpcrawtransaction.cpp | 2 +- src/script.cpp | 11 +++++------ src/script.h | 8 ++++---- src/wallet.cpp | 4 ++-- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 87e216e..2a9eb29 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -359,7 +359,7 @@ bool CTransaction::AreInputsStandard(const MapPrevTx& mapInputs) const if (IsCoinBase()) return true; // Coinbases don't use vin normally - for (unsigned int i = 0; i < vin.size(); i++) + for (uint32_t i = 0; i < vin.size(); i++) { const CTxOut& prev = GetOutputFor(vin[i], mapInputs); diff --git a/src/qt/multisigdialog.cpp b/src/qt/multisigdialog.cpp index 5c50da5..6f0851c 100644 --- a/src/qt/multisigdialog.cpp +++ b/src/qt/multisigdialog.cpp @@ -466,7 +466,7 @@ void MultisigDialog::on_signTransactionButton_clicked() // Sign what we can bool fComplete = true; - for(unsigned int i = 0; i < mergedTx.vin.size(); i++) + for(uint32_t i = 0; i < mergedTx.vin.size(); i++) { CTxIn& txin = mergedTx.vin[i]; if(mapPrevOut.count(txin.prevout) == 0) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index e07d4c4..b3b3c31 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -542,7 +542,7 @@ Value signrawtransaction(const Array& params, bool fHelp) bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE); // Sign what we can: - for (unsigned int i = 0; i < mergedTx.vin.size(); i++) + for (uint32_t i = 0; i < mergedTx.vin.size(); i++) { auto& txin = mergedTx.vin[i]; if (mapPrevOut.count(txin.prevout) == 0) diff --git a/src/script.cpp b/src/script.cpp index 7e0cd36..bd58210 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -412,7 +412,7 @@ bool CheckSequence(const int64_t& nSequence, const CTransaction &txTo, unsigned return true; } -bool EvalScript(vector >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType) +bool EvalScript(vector >& stack, const CScript& script, const CTransaction& txTo, uint32_t nIn, unsigned int flags, int nHashType) { CAutoBN_CTX pctx; auto pc = script.begin(); @@ -1831,8 +1831,7 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto return true; } -bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, - unsigned int flags, int nHashType) +bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, uint32_t nIn, unsigned int flags, int nHashType) { vector > stack, stackCopy; if (!EvalScript(stack, scriptSig, txTo, nIn, flags, nHashType)) @@ -1872,7 +1871,7 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const C return true; } -bool SignSignature(const CKeyStore &keystore, const CScript& fromPubKey, CTransaction& txTo, unsigned int nIn, int nHashType) +bool SignSignature(const CKeyStore &keystore, const CScript& fromPubKey, CTransaction& txTo, uint32_t nIn, int nHashType) { assert(nIn < txTo.vin.size()); auto& txin = txTo.vin[nIn]; @@ -1906,7 +1905,7 @@ bool SignSignature(const CKeyStore &keystore, const CScript& fromPubKey, CTransa return VerifyScript(txin.scriptSig, fromPubKey, txTo, nIn, STRICT_FLAGS, 0); } -bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType) +bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CTransaction& txTo, uint32_t nIn, int nHashType) { assert(nIn < txTo.vin.size()); auto& txin = txTo.vin[nIn]; @@ -2027,7 +2026,7 @@ static CScript CombineSignatures(const CScript& scriptPubKey, const CTransaction return CScript(); } -CScript CombineSignatures(const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, +CScript CombineSignatures(const CScript& scriptPubKey, const CTransaction& txTo, uint32_t nIn, const CScript& scriptSig1, const CScript& scriptSig2) { txnouttype txType; diff --git a/src/script.h b/src/script.h index 0f72d7d..f2f9a08 100644 --- a/src/script.h +++ b/src/script.h @@ -382,7 +382,7 @@ bool IsCanonicalPubKey(const std::vector &vchPubKey, unsigned int bool IsDERSignature(const valtype &vchSig, bool fWithHashType=false, bool fCheckLow=false); bool IsCanonicalSignature(const std::vector &vchSig, unsigned int flags); -bool EvalScript(std::vector >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType); +bool EvalScript(std::vector >& stack, const CScript& script, const CTransaction& txTo, uint32_t nIn, unsigned int flags, int nHashType); bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector >& vSolutionsRet); int ScriptSigArgsExpected(txnouttype t, const std::vector >& vSolutions); bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType); @@ -393,9 +393,9 @@ void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet); bool ExtractAddress(const CKeyStore &keystore, const CScript& scriptPubKey, CBitcoinAddress& addressRet); bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector& addressRet, int& nRequiredRet); -bool SignSignature(const CKeyStore& keystore, const CScript& fromPubKey, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL); -bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL); -bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType); +bool SignSignature(const CKeyStore& keystore, const CScript& fromPubKey, CTransaction& txTo, uint32_t nIn, int nHashType=SIGHASH_ALL); +bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CTransaction& txTo, uint32_t nIn, int nHashType=SIGHASH_ALL); +bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, uint32_t nIn, unsigned int flags, int nHashType); // Given two sets of signatures for scriptPubKey, possibly with OP_0 placeholders, // combine them intelligently and return the result. diff --git a/src/wallet.cpp b/src/wallet.cpp index b87b9f8..9d0f666 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -2322,7 +2322,7 @@ bool CWallet::MergeCoins(const int64_t& nAmount, const int64_t& nMinValue, const if (wtxNew.vout[0].nValue <= 0) return false; - for (unsigned int i = 0; i < wtxNew.vin.size(); i++) { + for (uint32_t i = 0; i < wtxNew.vin.size(); i++) { const CWalletTx *txin = vwtxPrev[i]; // Sign all scripts again @@ -2507,7 +2507,7 @@ bool CWallet::CreateCoinStake(uint256 &hashTx, uint32_t nOut, uint32_t nGenerati } // Limit size - unsigned int nBytes = ::GetSerializeSize(txNew, SER_NETWORK, PROTOCOL_VERSION); + auto nBytes = ::GetSerializeSize(txNew, SER_NETWORK, PROTOCOL_VERSION); if (nBytes >= MAX_BLOCK_SIZE_GEN/5) return error("CreateCoinStake : exceeded coinstake size limit\n"); -- 1.7.1