blockchain: use taproot script flags for validation after activation

This commit is contained in:
Olaoluwa Osuntokun 2022-03-08 18:24:45 -08:00
parent ba9fb8ece1
commit 23cf18b050
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -11,11 +11,11 @@ import (
"math/big"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcd/btcutil"
)
const (
@ -1218,6 +1218,18 @@ func (b *BlockChain) checkConnectBlock(node *blockNode, block *btcutil.Block, vi
scriptFlags |= txscript.ScriptStrictMultiSig
}
// Before we execute the main scripts, we'll also check to see if
// taproot is active or not.
taprootState, err := b.deploymentState(
node.parent, chaincfg.DeploymentTaproot,
)
if err != nil {
return err
}
if taprootState == ThresholdActive {
scriptFlags |= txscript.ScriptVerifyTaproot
}
// Now that the inexpensive checks are done and have passed, verify the
// transactions are actually allowed to spend the coins by running the
// expensive ECDSA signature check scripts. Doing this last helps