aboutsummaryrefslogtreecommitdiff
path: root/src/script/interpreter.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2020-09-11 14:33:45 -0700
committerPieter Wuille <pieter@wuille.net>2020-10-12 17:17:56 -0700
commit8bbed4b7acf4c76eaea8c0e10f3cbf6ba4e53809 (patch)
tree32afa457bf2ead02197781c43087b5f83f499d15 /src/script/interpreter.h
parent0664f5fe1f77f08d235aa3750b59428257b0b91d (diff)
downloadbitcoin-8bbed4b7acf4c76eaea8c0e10f3cbf6ba4e53809.tar.xz
Implement Taproot validation (BIP 341)
This includes key path spending and script path spending, but not the Tapscript execution implementation (leaf 0xc0 remains unemcumbered in this commit). Includes constants for various aspects of the consensus rules suggested by Jeremy Rubin.
Diffstat (limited to 'src/script/interpreter.h')
-rw-r--r--src/script/interpreter.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/script/interpreter.h b/src/script/interpreter.h
index e54243c8f0..2ffe18dd92 100644
--- a/src/script/interpreter.h
+++ b/src/script/interpreter.h
@@ -121,6 +121,14 @@ enum
// Making OP_CODESEPARATOR and FindAndDelete fail any non-segwit scripts
//
SCRIPT_VERIFY_CONST_SCRIPTCODE = (1U << 16),
+
+ // Taproot validation (BIP 341)
+ //
+ SCRIPT_VERIFY_TAPROOT = (1U << 17),
+
+ // Making unknown Taproot leaf versions non-standard
+ //
+ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_TAPROOT_VERSION = (1U << 18),
};
bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror);
@@ -167,6 +175,12 @@ static constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE = 32;
static constexpr size_t WITNESS_V0_KEYHASH_SIZE = 20;
static constexpr size_t WITNESS_V1_TAPROOT_SIZE = 32;
+static constexpr uint8_t TAPROOT_LEAF_MASK = 0xfe;
+static constexpr size_t TAPROOT_CONTROL_BASE_SIZE = 33;
+static constexpr size_t TAPROOT_CONTROL_NODE_SIZE = 32;
+static constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT = 128;
+static constexpr size_t TAPROOT_CONTROL_MAX_SIZE = TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * TAPROOT_CONTROL_MAX_NODE_COUNT;
+
template <class T>
uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn, int nHashType, const CAmount& amount, SigVersion sigversion, const PrecomputedTransactionData* cache = nullptr);