fix: CDarksendPool::IsSignatureValid has misleading name and suboptimal params (#1035)

This commit is contained in:
UdjinM6 2016-09-21 18:03:04 +04:00 committed by GitHub
parent c1b292be39
commit 2245d25497
2 changed files with 13 additions and 10 deletions

View File

@ -838,8 +838,8 @@ void CDarksendPool::CheckForCompleteQueue()
} }
} }
// check to see if the signature is valid // Check to make sure a given input matches an input in the pool and its scriptSig is valid
bool CDarksendPool::IsSignatureValid(const CScript& scriptSig, const CTxIn& txin) bool CDarksendPool::IsInputScriptSigValid(const CTxIn& txin)
{ {
CMutableTransaction txNew; CMutableTransaction txNew;
txNew.vin.clear(); txNew.vin.clear();
@ -866,15 +866,18 @@ bool CDarksendPool::IsSignatureValid(const CScript& scriptSig, const CTxIn& txin
} }
if(nTxInIndex >= 0) { //might have to do this one input at a time? if(nTxInIndex >= 0) { //might have to do this one input at a time?
txNew.vin[nTxInIndex].scriptSig = scriptSig; txNew.vin[nTxInIndex].scriptSig = txin.scriptSig;
LogPrint("privatesend", "CDarksendPool::IsSignatureValid -- Sign with sig %s\n", ScriptToAsmStr(scriptSig).substr(0,24)); LogPrint("privatesend", "CDarksendPool::IsInputScriptSigValid -- verifying scriptSig %s\n", ScriptToAsmStr(txin.scriptSig).substr(0,24));
if(!VerifyScript(txNew.vin[nTxInIndex].scriptSig, sigPubKey, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC, MutableTransactionSignatureChecker(&txNew, nTxInIndex))) { if(!VerifyScript(txNew.vin[nTxInIndex].scriptSig, sigPubKey, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC, MutableTransactionSignatureChecker(&txNew, nTxInIndex))) {
LogPrint("privatesend", "CDarksendPool::IsSignatureValid -- Signing -- Error signing input %d\n", nTxInIndex); LogPrint("privatesend", "CDarksendPool::IsInputScriptSigValid -- VerifyScript() failed on input %d\n", nTxInIndex);
return false; return false;
} }
} else {
LogPrint("privatesend", "CDarksendPool::IsInputScriptSigValid -- Failed to find matching input in pool, %s\n", txin.ToString());
return false;
} }
LogPrint("privatesend", "CDarksendPool::IsSignatureValid -- Signing -- Successfully validated input\n"); LogPrint("privatesend", "CDarksendPool::IsInputScriptSigValid -- Successfully validated input and scriptSig\n");
return true; return true;
} }
@ -999,8 +1002,8 @@ bool CDarksendPool::AddScriptSig(const CTxIn& txinNew)
} }
} }
if(!IsSignatureValid(txinNew.scriptSig, txinNew)) { if(!IsInputScriptSigValid(txinNew)) {
LogPrint("privatesend", "CDarksendPool::AddScriptSig -- Invalid Sig\n"); LogPrint("privatesend", "CDarksendPool::AddScriptSig -- Invalid scriptSig\n");
return false; return false;
} }

View File

@ -369,8 +369,8 @@ private:
bool IsCollateralValid(const CTransaction& txCollateral); bool IsCollateralValid(const CTransaction& txCollateral);
/// Check that all inputs are signed. (Are all inputs signed?) /// Check that all inputs are signed. (Are all inputs signed?)
bool IsSignaturesComplete(); bool IsSignaturesComplete();
/// Check to make sure a signature matches an input in the pool /// Check to make sure a given input matches an input in the pool and its scriptSig is valid
bool IsSignatureValid(const CScript& scriptSig, const CTxIn& txin); bool IsInputScriptSigValid(const CTxIn& txin);
bool IsDenomSkipped(CAmount nDenomValue) { bool IsDenomSkipped(CAmount nDenomValue) {
return std::find(vecDenominationsSkipped.begin(), vecDenominationsSkipped.end(), nDenomValue) != vecDenominationsSkipped.end(); return std::find(vecDenominationsSkipped.begin(), vecDenominationsSkipped.end(), nDenomValue) != vecDenominationsSkipped.end();