MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / MaxScriptSize

Function MaxScriptSize

src/script/miniscript.h:284–296  ·  view source on GitHub ↗

The maximum size of a script depending on the context. */

Source from the content-addressed store, hash-verified

282constexpr 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. */
284constexpr 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.
299Type 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);

Callers 4

IsValidMethod · 0.85
ParseFunction · 0.85
FromScriptFunction · 0.85
GenNodeFunction · 0.85

Calls 2

IsTapscriptFunction · 0.85
GetSizeOfCompactSizeFunction · 0.85

Tested by 1

GenNodeFunction · 0.68