From: svost Date: Sun, 11 Sep 2016 14:04:38 +0000 (+0300) Subject: One type for all nIn vars X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=89932a0e73c93441f075b19dea460973731c4680 One type for all nIn vars --- diff --git a/src/main.cpp b/src/main.cpp index 98c2105..90460db 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1405,7 +1405,7 @@ bool CScriptCheck::operator()() const { return true; } -bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType) +bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, uint32_t nIn, unsigned int flags, int nHashType) { return CScriptCheck(txFrom, txTo, nIn, flags, nHashType)(); } diff --git a/src/main.h b/src/main.h index d42c6b4..a937030 100644 --- a/src/main.h +++ b/src/main.h @@ -139,7 +139,7 @@ uint256 WantedByOrphan(const CBlock* pblockOrphan); const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfStake); void ResendWalletTransactions(bool fForceResend=false); -bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType); +bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, uint32_t nIn, unsigned int flags, int nHashType); @@ -210,7 +210,7 @@ public: uint32_t n; CInPoint() { SetNull(); } - CInPoint(CTransaction* ptxIn, unsigned int nIn) { ptx = ptxIn; n = nIn; } + CInPoint(CTransaction* ptxIn, uint32_t nIn) { ptx = ptxIn; n = nIn; } void SetNull() { ptx = NULL; n = numeric_limits::max(); } bool IsNull() const { return (ptx == NULL && n == numeric_limits::max()); } }; @@ -225,7 +225,7 @@ public: uint32_t n; COutPoint() { SetNull(); } - COutPoint(uint256 hashIn, unsigned int nIn) { hash = hashIn; n = nIn; } + COutPoint(uint256 hashIn, uint32_t nIn) { hash = hashIn; n = nIn; } IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); ) void SetNull() { hash = 0; n = numeric_limits::max(); } bool IsNull() const { return (hash == 0 && n == numeric_limits::max()); } @@ -734,13 +734,13 @@ class CScriptCheck private: CScript scriptPubKey; const CTransaction *ptxTo = nullptr; - unsigned int nIn = 0; + uint32_t nIn = 0; unsigned int nFlags = 0; int nHashType = 0; public: CScriptCheck() {} - CScriptCheck(const CTransaction& txFromIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, int nHashTypeIn) : + CScriptCheck(const CTransaction& txFromIn, const CTransaction& txToIn, uint32_t nInIn, unsigned int nFlagsIn, int nHashTypeIn) : scriptPubKey(txFromIn.vout[txToIn.vin[nInIn].prevout.n].scriptPubKey), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), nHashType(nHashTypeIn) { } diff --git a/src/script.cpp b/src/script.cpp index e12a936..b18d4fe 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -13,7 +13,7 @@ using namespace std; -bool CheckSig(vector vchSig, const vector &vchPubKey, const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType, int flags); +bool CheckSig(vector vchSig, const vector &vchPubKey, const CScript &scriptCode, const CTransaction& txTo, uint32_t nIn, int nHashType, int flags); static const valtype vchFalse(0); static const valtype vchZero(0); @@ -341,7 +341,7 @@ bool IsCanonicalSignature(const valtype &vchSig, unsigned int flags) { return IsDERSignature(vchSig, true, (flags & SCRIPT_VERIFY_LOW_S) != 0); } -bool CheckLockTime(const int64_t& nLockTime, const CTransaction &txTo, unsigned int nIn) +bool CheckLockTime(const int64_t& nLockTime, const CTransaction &txTo, uint32_t nIn) { // There are two kinds of nLockTime: lock-by-blockheight // and lock-by-blocktime, distinguished by whether @@ -377,7 +377,7 @@ bool CheckLockTime(const int64_t& nLockTime, const CTransaction &txTo, unsigned return true; } -bool CheckSequence(const int64_t& nSequence, const CTransaction &txTo, unsigned int nIn) +bool CheckSequence(const int64_t& nSequence, const CTransaction &txTo, uint32_t nIn) { // Relative lock times are supported by comparing the passed // in operand to the sequence number of the input. @@ -1282,7 +1282,7 @@ public: }; bool CheckSig(vector vchSig, const vector &vchPubKey, const CScript &scriptCode, - const CTransaction& txTo, unsigned int nIn, int nHashType, int flags) + const CTransaction& txTo, uint32_t nIn, int nHashType, int flags) { static CSignatureCache signatureCache; @@ -1930,7 +1930,7 @@ static CScript PushAll(const vector& values) return result; } -static CScript CombineMultisig(const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, +static CScript CombineMultisig(const CScript& scriptPubKey, const CTransaction& txTo, uint32_t nIn, const vector& vSolutions, vector& sigs1, vector& sigs2) { @@ -1986,7 +1986,7 @@ static CScript CombineMultisig(const CScript& scriptPubKey, const CTransaction& return result; } -static CScript CombineSignatures(const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, +static CScript CombineSignatures(const CScript& scriptPubKey, const CTransaction& txTo, uint32_t nIn, const txnouttype txType, const vector& vSolutions, vector& sigs1, vector& sigs2) { diff --git a/src/script.h b/src/script.h index 85fcf94..28def01 100644 --- a/src/script.h +++ b/src/script.h @@ -399,6 +399,6 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const C // Given two sets of signatures for scriptPubKey, possibly with OP_0 placeholders, // combine them intelligently and return the result. -CScript CombineSignatures(const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, const CScript& scriptSig1, const CScript& scriptSig2); +CScript CombineSignatures(const CScript& scriptPubKey, const CTransaction& txTo, uint32_t nIn, const CScript& scriptSig1, const CScript& scriptSig2); #endif diff --git a/src/wallet.cpp b/src/wallet.cpp index 033c391..b160e64 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -2167,7 +2167,7 @@ bool CWallet::CreateTransaction(const vector >& vecSend, wtxNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second)); // Sign - int nIn = 0; + uint32_t nIn = 0; for(const auto& coin : setCoins) if (!SignSignature(*this, *coin.first, wtxNew, nIn++)) return false; @@ -2504,7 +2504,7 @@ bool CWallet::CreateCoinStake(uint256 &hashTx, uint32_t nOut, uint32_t nGenerati } // Sign - int nIn = 0; + uint32_t nIn = 0; for(const CWalletTx* pcoin : vwtxPrev) { if (!SignSignature(*this, *pcoin, txNew, nIn++))