Convert inability to find input tx to a RuleError.
This commit modifies the errors that result from missing expected input transactions to a RuleError. This allows the caller to detect a block was rejected due to a rule violation as opposed to an unexpected error.
This commit is contained in:
parent
e5ba199eed
commit
9a29855c16
1 changed files with 6 additions and 3 deletions
|
@ -347,18 +347,20 @@ func countP2SHSigOps(msgTx *btcwire.MsgTx, isCoinBaseTx bool, txStore TxStore) (
|
||||||
txInHash := &txIn.PreviousOutpoint.Hash
|
txInHash := &txIn.PreviousOutpoint.Hash
|
||||||
originTx, exists := txStore[*txInHash]
|
originTx, exists := txStore[*txInHash]
|
||||||
if !exists || originTx.Err != nil || originTx.Tx == nil {
|
if !exists || originTx.Err != nil || originTx.Tx == nil {
|
||||||
return 0, fmt.Errorf("unable to find input transaction "+
|
str := fmt.Sprintf("unable to find input transaction "+
|
||||||
"%v referenced from transaction %v", txInHash,
|
"%v referenced from transaction %v", txInHash,
|
||||||
txHash)
|
txHash)
|
||||||
|
return 0, RuleError(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the output index in the referenced transaction is
|
// Ensure the output index in the referenced transaction is
|
||||||
// available.
|
// available.
|
||||||
originTxIndex := txIn.PreviousOutpoint.Index
|
originTxIndex := txIn.PreviousOutpoint.Index
|
||||||
if originTxIndex >= uint32(len(originTx.Tx.TxOut)) {
|
if originTxIndex >= uint32(len(originTx.Tx.TxOut)) {
|
||||||
return 0, fmt.Errorf("out of bounds input index %d in "+
|
str := fmt.Sprintf("out of bounds input index %d in "+
|
||||||
"transaction %v referenced from transaction %v",
|
"transaction %v referenced from transaction %v",
|
||||||
originTxIndex, txInHash, txHash)
|
originTxIndex, txInHash, txHash)
|
||||||
|
return 0, RuleError(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We're only interested in pay-to-script-hash types, so skip
|
// We're only interested in pay-to-script-hash types, so skip
|
||||||
|
@ -379,10 +381,11 @@ func countP2SHSigOps(msgTx *btcwire.MsgTx, isCoinBaseTx bool, txStore TxStore) (
|
||||||
lastSigOps := totalSigOps
|
lastSigOps := totalSigOps
|
||||||
totalSigOps += numSigOps
|
totalSigOps += numSigOps
|
||||||
if totalSigOps < lastSigOps {
|
if totalSigOps < lastSigOps {
|
||||||
return 0, fmt.Errorf("the public key script from "+
|
str := fmt.Sprintf("the public key script from "+
|
||||||
"output index %d in transaction %v contains "+
|
"output index %d in transaction %v contains "+
|
||||||
"too many signature operations - overflow",
|
"too many signature operations - overflow",
|
||||||
originTxIndex, txInHash)
|
originTxIndex, txInHash)
|
||||||
|
return 0, RuleError(str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue