Use txscript.StandardVerifyFlags

By using txscript.StandardVerifyFlags when creating and validating
transactions, we can ensure the transactions successfully created
won't be rejected due to script policy.
This commit is contained in:
David Hill 2015-02-26 18:31:52 -05:00
parent dcf64e2957
commit f704c58114
2 changed files with 3 additions and 9 deletions

View file

@ -415,14 +415,10 @@ func signMsgTx(msgtx *wire.MsgTx, prevOutputs []txstore.Credit, store *keystore.
}
func validateMsgTx(msgtx *wire.MsgTx, prevOutputs []txstore.Credit) error {
flags := txscript.ScriptVerifyDERSignatures | txscript.ScriptStrictMultiSig
bip16 := time.Now().After(txscript.Bip16Activation)
if bip16 {
flags |= txscript.ScriptBip16
}
for i, txin := range msgtx.TxIn {
engine, err := txscript.NewScript(
txin.SignatureScript, prevOutputs[i].TxOut().PkScript, i, msgtx, flags)
txin.SignatureScript, prevOutputs[i].TxOut().PkScript,
i, msgtx, txscript.StandardVerifyFlags)
if err != nil {
return fmt.Errorf("cannot create script engine: %s", err)
}

View file

@ -2841,10 +2841,8 @@ func SignRawTransaction(w *Wallet, chainSvr *chain.Client, icmd btcjson.Cmd) (in
// Either it was already signed or we just signed it.
// Find out if it is completely satisfied or still needs more.
flags := txscript.ScriptBip16 | txscript.ScriptVerifyDERSignatures |
txscript.ScriptStrictMultiSig
engine, err := txscript.NewScript(txIn.SignatureScript, input,
i, msgTx, flags)
i, msgTx, txscript.StandardVerifyFlags)
if err != nil || engine.Execute() != nil {
complete = false
}