[lbry] blockchain, mempool: validate txscripts
This commit is contained in:
parent
9b1c4fbc04
commit
fc77c6db6a
3 changed files with 22 additions and 3 deletions
|
@ -291,6 +291,16 @@ func CheckTransactionSanity(tx *btcutil.Tx) error {
|
|||
btcutil.MaxSatoshi)
|
||||
return ruleError(ErrBadTxOutValue, str)
|
||||
}
|
||||
if txscript.ClaimScriptSize(txOut.PkScript) > txscript.MaxClaimScriptSize {
|
||||
str := fmt.Sprintf("claimscript exceeds max size of %v",
|
||||
txscript.MaxClaimScriptSize)
|
||||
return ruleError(ErrBadTxOutValue, str)
|
||||
}
|
||||
if txscript.ClaimNameSize(txOut.PkScript) > txscript.MaxClaimNameSize {
|
||||
str := fmt.Sprintf("claim name exceeds max size of %v",
|
||||
txscript.MaxClaimNameSize)
|
||||
return ruleError(ErrBadTxOutValue, str)
|
||||
}
|
||||
}
|
||||
|
||||
// Check for duplicate transaction inputs.
|
||||
|
|
|
@ -1155,6 +1155,14 @@ func (mp *TxPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit, rejec
|
|||
return nil, nil, txRuleError(wire.RejectInsufficientFee, str)
|
||||
}
|
||||
|
||||
minFee = txscript.CalcMinClaimTrieFee(tx.MsgTx(), txscript.MinFeePerNameclaimChar)
|
||||
if txFee < minFee {
|
||||
str := fmt.Sprintf("transaction %v has %d fees which is under "+
|
||||
"the required amount of %d for Claims", txHash, txFee,
|
||||
minFee)
|
||||
return nil, nil, txRuleError(wire.RejectInsufficientFee, str)
|
||||
}
|
||||
|
||||
// Require that free transactions have sufficient priority to be mined
|
||||
// in the next block. Transactions which are being added back to the
|
||||
// memory pool from blocks that have been disconnected during a reorg
|
||||
|
|
|
@ -99,7 +99,7 @@ func checkInputsStandard(tx *btcutil.Tx, utxoView *blockchain.UtxoViewpoint) err
|
|||
// they have already been checked prior to calling this
|
||||
// function.
|
||||
entry := utxoView.LookupEntry(txIn.PreviousOutPoint)
|
||||
originPkScript := entry.PkScript()
|
||||
originPkScript := txscript.StripClaimScriptPrefix(entry.PkScript())
|
||||
switch txscript.GetScriptClass(originPkScript) {
|
||||
case txscript.ScriptHashTy:
|
||||
numSigOps := txscript.GetPreciseSigOpCount(
|
||||
|
@ -332,8 +332,9 @@ func checkTransactionStandard(tx *btcutil.Tx, height int32,
|
|||
// be "dust" (except when the script is a null data script).
|
||||
numNullDataOutputs := 0
|
||||
for i, txOut := range msgTx.TxOut {
|
||||
scriptClass := txscript.GetScriptClass(txOut.PkScript)
|
||||
err := checkPkScriptStandard(txOut.PkScript, scriptClass)
|
||||
pkScript := txscript.StripClaimScriptPrefix(txOut.PkScript)
|
||||
scriptClass := txscript.GetScriptClass(pkScript)
|
||||
err := checkPkScriptStandard(pkScript, scriptClass)
|
||||
if err != nil {
|
||||
// Attempt to extract a reject code from the error so
|
||||
// it can be retained. When not possible, fall back to
|
||||
|
|
Loading…
Add table
Reference in a new issue