From 23cf18b0505fe123d8ea89de9b98cdc73aa447f2 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 8 Mar 2022 18:24:45 -0800 Subject: [PATCH] blockchain: use taproot script flags for validation after activation --- blockchain/validate.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/blockchain/validate.go b/blockchain/validate.go index 575861e2..89971e7f 100644 --- a/blockchain/validate.go +++ b/blockchain/validate.go @@ -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