wallet: use intermediate hash cache during validateMsgTx

This commit is contained in:
Olaoluwa Osuntokun 2016-05-02 23:31:23 -07:00
parent 7cb1b47140
commit 6dfc793ad3

View file

@ -230,9 +230,10 @@ func (w *Wallet) findEligibleOutputs(account uint32, minconf int32, bs *waddrmgr
// scripts from outputs redeemed by the transaction, in the same order they are // scripts from outputs redeemed by the transaction, in the same order they are
// spent, must be passed in the prevScripts slice. // spent, must be passed in the prevScripts slice.
func validateMsgTx(tx *wire.MsgTx, prevScripts [][]byte, inputValues []btcutil.Amount) error { func validateMsgTx(tx *wire.MsgTx, prevScripts [][]byte, inputValues []btcutil.Amount) error {
hashCache := txscript.NewTxSigHashes(tx)
for i, prevScript := range prevScripts { for i, prevScript := range prevScripts {
vm, err := txscript.NewEngine(prevScript, tx, i, vm, err := txscript.NewEngine(prevScript, tx, i,
txscript.StandardVerifyFlags, nil, nil, int64(inputValues[i])) txscript.StandardVerifyFlags, nil, hashCache, int64(inputValues[i]))
if err != nil { if err != nil {
return fmt.Errorf("cannot create script engine: %s", err) return fmt.Errorf("cannot create script engine: %s", err)
} }