@@ -280,7 +280,7 @@ constexpr uint32_t MaxScriptSize(MiniscriptContext ms_ctx)
280
280
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);
281
281
282
282
// ! Helper function for Node::CalcScriptLen.
283
- size_t ComputeScriptLen (Fragment fragment, Type sub0typ, size_t subsize, uint32_t k, size_t n_subs, size_t n_keys);
283
+ size_t ComputeScriptLen (Fragment fragment, Type sub0typ, size_t subsize, uint32_t k, size_t n_subs, size_t n_keys, MiniscriptContext ms_ctx );
284
284
285
285
// ! A helper sanitizer/checker for the output of CalcType.
286
286
Type SanitizeType (Type x);
@@ -437,7 +437,7 @@ struct Node {
437
437
subsize += sub->ScriptSize ();
438
438
}
439
439
Type sub0type = subs.size () > 0 ? subs[0 ]->GetType () : " " _mst;
440
- return internal::ComputeScriptLen (fragment, sub0type, subsize, k, subs.size (), keys.size ());
440
+ return internal::ComputeScriptLen (fragment, sub0type, subsize, k, subs.size (), keys.size (), m_script_ctx );
441
441
}
442
442
443
443
/* Apply a recursive algorithm to a Miniscript tree, without actual recursive calls.
@@ -1698,7 +1698,7 @@ inline NodeRef<Key> Parse(Span<const char> in, const Ctx& ctx)
1698
1698
auto & [key, key_size] = *res;
1699
1699
constructed.push_back (MakeNodeRef<Key>(internal::NoDupCheck{}, ctx.MsContext (), Fragment::WRAP_C, Vector (MakeNodeRef<Key>(internal::NoDupCheck{}, ctx.MsContext (), Fragment::PK_K, Vector (std::move (key))))));
1700
1700
in = in.subspan (key_size + 1 );
1701
- script_size += 34 ;
1701
+ script_size += IsTapscript (ctx. MsContext ()) ? 33 : 34 ;
1702
1702
} else if (Const (" pkh(" , in)) {
1703
1703
auto res = ParseKeyEnd<Key>(in, ctx);
1704
1704
if (!res) return {};
@@ -1712,7 +1712,7 @@ inline NodeRef<Key> Parse(Span<const char> in, const Ctx& ctx)
1712
1712
auto & [key, key_size] = *res;
1713
1713
constructed.push_back (MakeNodeRef<Key>(internal::NoDupCheck{}, ctx.MsContext (), Fragment::PK_K, Vector (std::move (key))));
1714
1714
in = in.subspan (key_size + 1 );
1715
- script_size += 33 ;
1715
+ script_size += IsTapscript (ctx. MsContext ()) ? 32 : 33 ;
1716
1716
} else if (Const (" pk_h(" , in)) {
1717
1717
auto res = ParseKeyEnd<Key>(in, ctx);
1718
1718
if (!res) return {};
@@ -2058,7 +2058,7 @@ inline NodeRef<Key> DecodeScript(I& in, I last, const Ctx& ctx)
2058
2058
break ;
2059
2059
}
2060
2060
// Public keys
2061
- if (in[0 ].second .size () == 33 ) {
2061
+ if (in[0 ].second .size () == 33 || in[ 0 ]. second . size () == 32 ) {
2062
2062
auto key = ctx.FromPKBytes (in[0 ].second .begin (), in[0 ].second .end ());
2063
2063
if (!key) return {};
2064
2064
++in;
0 commit comments