From 29c9bc27c85d10d8ff048c08055404ef8cfbec24 Mon Sep 17 00:00:00 2001 From: Donald Adu-Poku Date: Wed, 20 Jun 2018 19:32:36 +0000 Subject: [PATCH] blockchain: remove impossible to hit ErrInvalidSSRtxInput. ErrInvalidSSRtxInput's triggering condition is a subset of the checks IsSSRtx performs on a transaction. Since IsSSRtx is the first to evaluate a tx in CheckTransactionInputs that should be enough. --- blockchain/error.go | 5 ----- blockchain/error_test.go | 1 - blockchain/validate.go | 21 --------------------- 3 files changed, 27 deletions(-) diff --git a/blockchain/error.go b/blockchain/error.go index ff7d050697..b86d7ddd87 100644 --- a/blockchain/error.go +++ b/blockchain/error.go @@ -348,10 +348,6 @@ const ( // be OP_SS* tagged, but it must be P2PKH or P2SH. ErrSStxInScrType - // ErrInvalidSSRtxInput indicates that the input for the SSRtx was not from - // an SStx. - ErrInvalidSSRtxInput - // ErrSSRtxPayeesMismatch means that the number of payees in an SSRtx was // not the same as the number of payees in the outputs of the input SStx. ErrSSRtxPayeesMismatch @@ -532,7 +528,6 @@ var errorCodeStrings = map[ErrorCode]string{ ErrSSGenSubsidy: "ErrSSGenSubsidy", ErrSStxInImmature: "ErrSStxInImmature", ErrSStxInScrType: "ErrSStxInScrType", - ErrInvalidSSRtxInput: "ErrInvalidSSRtxInput", ErrSSRtxPayeesMismatch: "ErrSSRtxPayeesMismatch", ErrSSRtxPayees: "ErrSSRtxPayees", ErrTxSStxOutSpend: "ErrTxSStxOutSpend", diff --git a/blockchain/error_test.go b/blockchain/error_test.go index 266e52f29b..82953f5917 100644 --- a/blockchain/error_test.go +++ b/blockchain/error_test.go @@ -84,7 +84,6 @@ func TestErrorCodeStringer(t *testing.T) { {ErrSSGenSubsidy, "ErrSSGenSubsidy"}, {ErrSStxInImmature, "ErrSStxInImmature"}, {ErrSStxInScrType, "ErrSStxInScrType"}, - {ErrInvalidSSRtxInput, "ErrInvalidSSRtxInput"}, {ErrSSRtxPayeesMismatch, "ErrSSRtxPayeesMismatch"}, {ErrSSRtxPayees, "ErrSSRtxPayees"}, {ErrTxSStxOutSpend, "ErrTxSStxOutSpend"}, diff --git a/blockchain/validate.go b/blockchain/validate.go index 6b80142cec..936a4ea19f 100644 --- a/blockchain/validate.go +++ b/blockchain/validate.go @@ -1529,15 +1529,6 @@ func CheckTransactionInputs(subsidyCache *SubsidyCache, tx *dcrutil.Tx, txHeight return 0, ruleError(ErrMissingTxOut, str) } - // While we're here, double check to make sure that the input - // is from an SStx. By doing so, you also ensure the first - // output is OP_SSTX tagged. - if utxoEntrySstx.TransactionType() != stake.TxTypeSStx { - errStr := fmt.Sprintf("Input transaction %v for SSRtx"+ - " %v was not an SStx tx", txHash, sstxHash) - return 0, ruleError(ErrInvalidSSRtxInput, errStr) - } - minOutsSStx := ConvertUtxosToMinimalOutputs(utxoEntrySstx) sstxPayTypes, sstxPkhs, sstxAmts, _, sstxRules, sstxLimits := stake.SStxStakeOutputInfo(minOutsSStx) @@ -1581,18 +1572,6 @@ func CheckTransactionInputs(subsidyCache *SubsidyCache, tx *dcrutil.Tx, txHeight return 0, ruleError(ErrSSRtxPayees, errStr) } - // 2. Check to make sure that the second input was an OP_SSTX - // tagged output from the referenced SStx. - if txscript.GetScriptClass(utxoEntrySstx.ScriptVersionByIndex(0), - utxoEntrySstx.PkScriptByIndex(0)) != - txscript.StakeSubmissionTy { - errStr := fmt.Sprintf("First SStx output in SStx %v "+ - "referenced by SSGen %v should have been "+ - "OP_SSTX tagged, but it was not", sstxHash, - txHash) - return 0, ruleError(ErrInvalidSSRtxInput, errStr) - } - // 3. Check to ensure that ticket maturity number of blocks // have passed between the block the SSRtx plans to go into // and the block in which the SStx was originally found in.