The maximum size of a script depending on the context. */
| 282 | constexpr uint32_t MAX_TAPSCRIPT_SAT_SIZE{GetSizeOfCompactSize(MAX_STACK_SIZE) + (GetSizeOfCompactSize(MAX_TAPMINISCRIPT_STACK_ELEM_SIZE) + MAX_TAPMINISCRIPT_STACK_ELEM_SIZE) * MAX_STACK_SIZE + GetSizeOfCompactSize(TAPROOT_CONTROL_MAX_SIZE) + TAPROOT_CONTROL_MAX_SIZE}; |
| 283 | /** The maximum size of a script depending on the context. */ |
| 284 | constexpr uint32_t MaxScriptSize(MiniscriptContext ms_ctx) |
| 285 | { |
| 286 | if (IsTapscript(ms_ctx)) { |
| 287 | // Leaf scripts under Tapscript are not explicitly limited in size. They are only implicitly |
| 288 | // bounded by the maximum standard size of a spending transaction. Let the maximum script |
| 289 | // size conservatively be small enough such that even a maximum sized witness and a reasonably |
| 290 | // sized spending transaction can spend an output paying to this script without running into |
| 291 | // the maximum standard tx size limit. |
| 292 | constexpr auto max_size{MAX_STANDARD_TX_WEIGHT - TX_BODY_LEEWAY_WEIGHT - MAX_TAPSCRIPT_SAT_SIZE}; |
| 293 | return max_size - GetSizeOfCompactSize(max_size); |
| 294 | } |
| 295 | return MAX_STANDARD_P2WSH_SCRIPT_SIZE; |
| 296 | } |
| 297 | |
| 298 | //! Helper function for Node::CalcType. |
| 299 | Type ComputeType(Fragment fragment, Type x, Type y, Type z, const std::vector<Type>& sub_types, uint32_t k, size_t data_size, size_t n_subs, size_t n_keys, MiniscriptContext ms_ctx); |