From f4f978d38ee4920c5cd0de5d93b407ec37bfd9c0 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Wed, 25 Jan 2023 14:31:05 +0100 Subject: [PATCH] miniscript: adapt resources checks depending on context Under Tapscript, there is: - No limit on the number of OPs - No limit on the script size, it's implicitly limited by the maximum (standard) transaction size. - No standardness limit on the number of stack items, it's limited by the consensus MAX_STACK_SIZE. This requires tracking the maximum stack size at all times during script execution, which will be tackled in its own commit. In order to avoid any Miniscript that would not be spendable by a standard transaction because of the size of the witness, we limit the script size under Tapscript to the maximum standard transaction size minus the maximum possible witness and Taproot control block sizes. Note this is a conservative limit but it still allows for scripts more than a hundred times larger than under P2WSH. --- src/script/miniscript.cpp | 2 +- src/script/miniscript.h | 43 +++++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/script/miniscript.cpp b/src/script/miniscript.cpp index c133f88709..03158c5d8a 100644 --- a/src/script/miniscript.cpp +++ b/src/script/miniscript.cpp @@ -6,11 +6,11 @@ #include #include