aboutsummaryrefslogtreecommitdiff
path: root/src/script/script.h
diff options
context:
space:
mode:
authorJohnson Lau <jl2012@xbt.hk>2020-09-11 14:34:02 -0700
committerPieter Wuille <pieter@wuille.net>2020-10-12 17:18:24 -0700
commit72422ce396b8eba7b1a72c171c2f07dae691d1b5 (patch)
treed2aa2a75ed54579ed6ddac8f858cf3ca67605b48 /src/script/script.h
parent330de894a9a48515d9a473448b6c67adc3d188be (diff)
Implement Tapscript script validation rules (BIP 342)
This adds a new `SigVersion::TAPSCRIPT`, makes the necessary interpreter changes to make it implement BIP342, and uses them for leaf version 0xc0 in Taproot script path spends.
Diffstat (limited to 'src/script/script.h')
-rw-r--r--src/script/script.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/script/script.h b/src/script/script.h
index fcf3e29362..974cde4984 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -49,6 +49,12 @@ static const uint32_t LOCKTIME_MAX = 0xFFFFFFFFU;
// has meanings independent of the script
static constexpr unsigned int ANNEX_TAG = 0x50;
+// Validation weight per passing signature (Tapscript only, see BIP 342).
+static constexpr uint64_t VALIDATION_WEIGHT_PER_SIGOP_PASSED = 50;
+
+// How much weight budget is added to the witness size (Tapscript only, see BIP 342).
+static constexpr uint64_t VALIDATION_WEIGHT_OFFSET = 50;
+
template <typename T>
std::vector<unsigned char> ToByteVector(const T& in)
{
@@ -192,6 +198,9 @@ enum opcodetype
OP_NOP9 = 0xb8,
OP_NOP10 = 0xb9,
+ // Opcode added by BIP 342 (Tapscript)
+ OP_CHECKSIGADD = 0xba,
+
OP_INVALIDOPCODE = 0xff,
};
@@ -560,4 +569,7 @@ struct CScriptWitness
std::string ToString() const;
};
+/** Test for OP_SUCCESSx opcodes as defined by BIP342. */
+bool IsOpSuccess(const opcodetype& opcode);
+
#endif // BITCOIN_SCRIPT_SCRIPT_H