From: CryptoManiac Date: Tue, 15 Jul 2014 22:36:10 +0000 (+0400) Subject: Move VerifySignature to main X-Git-Tag: v0.4.4.6-nvc-update5^2~20 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=7a255170a850961f78c4011ddb63df50c5a40950 Move VerifySignature to main --- diff --git a/src/main.cpp b/src/main.cpp index bf8bc4b..4b7a1c1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1458,6 +1458,20 @@ unsigned int CTransaction::GetP2SHSigOpCount(const MapPrevTx& inputs) const return nSigOps; } +bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType) +{ + assert(nIn < txTo.vin.size()); + const CTxIn& txin = txTo.vin[nIn]; + if (txin.prevout.n >= txFrom.vout.size()) + return false; + const CTxOut& txout = txFrom.vout[txin.prevout.n]; + + if (txin.prevout.hash != txFrom.GetHash()) + return false; + + return VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, flags, nHashType); +} + bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs, map& mapTestPool, const CDiskTxPos& posThisTx, const CBlockIndex* pindexBlock, bool fBlock, bool fMiner, unsigned int flags) { diff --git a/src/main.h b/src/main.h index cac65cd..081661e 100644 --- a/src/main.h +++ b/src/main.h @@ -124,6 +124,7 @@ const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfSta void StakeMiner(CWallet *pwallet); void ResendWalletTransactions(); +bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType); diff --git a/src/script.cpp b/src/script.cpp index d0e0234..8a66750 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1661,20 +1661,6 @@ bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CTrans return SignSignature(keystore, txout.scriptPubKey, txTo, nIn, nHashType); } -bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType) -{ - assert(nIn < txTo.vin.size()); - const CTxIn& txin = txTo.vin[nIn]; - if (txin.prevout.n >= txFrom.vout.size()) - return false; - const CTxOut& txout = txFrom.vout[txin.prevout.n]; - - if (txin.prevout.hash != txFrom.GetHash()) - return false; - - return VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, flags, nHashType); -} - static CScript PushAll(const vector& values) { CScript result; diff --git a/src/script.h b/src/script.h index 7cc5f1d..dc98f9a 100644 --- a/src/script.h +++ b/src/script.h @@ -632,7 +632,6 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std:: 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 VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int 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.