@@ -718,6 +718,8 @@ class DescriptorImpl : public Descriptor
718
718
virtual std::optional<int64_t > MaxSatSize (bool use_max_sig) const { return {}; }
719
719
720
720
std::optional<int64_t > MaxSatisfactionWeight (bool ) const override { return {}; }
721
+
722
+ std::optional<int64_t > MaxSatisfactionElems () const override { return {}; }
721
723
};
722
724
723
725
/* * A parsed addr(A) descriptor. */
@@ -795,6 +797,8 @@ class PKDescriptor final : public DescriptorImpl
795
797
std::optional<int64_t > MaxSatisfactionWeight (bool use_max_sig) const override {
796
798
return *MaxSatSize (use_max_sig) * WITNESS_SCALE_FACTOR;
797
799
}
800
+
801
+ std::optional<int64_t > MaxSatisfactionElems () const override { return 1 ; }
798
802
};
799
803
800
804
/* * A parsed pkh(P) descriptor. */
@@ -822,6 +826,8 @@ class PKHDescriptor final : public DescriptorImpl
822
826
std::optional<int64_t > MaxSatisfactionWeight (bool use_max_sig) const override {
823
827
return *MaxSatSize (use_max_sig) * WITNESS_SCALE_FACTOR;
824
828
}
829
+
830
+ std::optional<int64_t > MaxSatisfactionElems () const override { return 2 ; }
825
831
};
826
832
827
833
/* * A parsed wpkh(P) descriptor. */
@@ -849,6 +855,8 @@ class WPKHDescriptor final : public DescriptorImpl
849
855
std::optional<int64_t > MaxSatisfactionWeight (bool use_max_sig) const override {
850
856
return MaxSatSize (use_max_sig);
851
857
}
858
+
859
+ std::optional<int64_t > MaxSatisfactionElems () const override { return 2 ; }
852
860
};
853
861
854
862
/* * A parsed combo(P) descriptor. */
@@ -909,6 +917,8 @@ class MultisigDescriptor final : public DescriptorImpl
909
917
std::optional<int64_t > MaxSatisfactionWeight (bool use_max_sig) const override {
910
918
return *MaxSatSize (use_max_sig) * WITNESS_SCALE_FACTOR;
911
919
}
920
+
921
+ std::optional<int64_t > MaxSatisfactionElems () const override { return 1 + m_threshold; }
912
922
};
913
923
914
924
/* * A parsed (sorted)multi_a(...) descriptor. Always uses x-only pubkeys. */
@@ -943,6 +953,8 @@ class MultiADescriptor final : public DescriptorImpl
943
953
std::optional<int64_t > MaxSatSize (bool use_max_sig) const override {
944
954
return (1 + 65 ) * m_threshold + (m_pubkey_args.size () - m_threshold);
945
955
}
956
+
957
+ std::optional<int64_t > MaxSatisfactionElems () const override { return m_pubkey_args.size (); }
946
958
};
947
959
948
960
/* * A parsed sh(...) descriptor. */
@@ -983,6 +995,11 @@ class SHDescriptor final : public DescriptorImpl
983
995
}
984
996
return {};
985
997
}
998
+
999
+ std::optional<int64_t > MaxSatisfactionElems () const override {
1000
+ if (const auto sub_elems = m_subdescriptor_args[0 ]->MaxSatisfactionElems ()) return 1 + *sub_elems;
1001
+ return {};
1002
+ }
986
1003
};
987
1004
988
1005
/* * A parsed wsh(...) descriptor. */
@@ -1014,6 +1031,11 @@ class WSHDescriptor final : public DescriptorImpl
1014
1031
std::optional<int64_t > MaxSatisfactionWeight (bool use_max_sig) const override {
1015
1032
return MaxSatSize (use_max_sig);
1016
1033
}
1034
+
1035
+ std::optional<int64_t > MaxSatisfactionElems () const override {
1036
+ if (const auto sub_elems = m_subdescriptor_args[0 ]->MaxSatisfactionElems ()) return 1 + *sub_elems;
1037
+ return {};
1038
+ }
1017
1039
};
1018
1040
1019
1041
/* * A parsed tr(...) descriptor. */
@@ -1074,6 +1096,11 @@ class TRDescriptor final : public DescriptorImpl
1074
1096
// FIXME: We assume keypath spend, which can lead to very large underestimations.
1075
1097
return 1 + 65 ;
1076
1098
}
1099
+
1100
+ std::optional<int64_t > MaxSatisfactionElems () const override {
1101
+ // FIXME: See above, we assume keypath spend.
1102
+ return 1 ;
1103
+ }
1077
1104
};
1078
1105
1079
1106
/* We instantiate Miniscript here with a simple integer as key type.
@@ -1164,6 +1191,10 @@ class MiniscriptDescriptor final : public DescriptorImpl
1164
1191
// For Miniscript we always assume high-R ECDSA signatures.
1165
1192
return m_node->GetWitnessSize ();
1166
1193
}
1194
+
1195
+ std::optional<int64_t > MaxSatisfactionElems () const override {
1196
+ return m_node->GetStackSize ();
1197
+ }
1167
1198
};
1168
1199
1169
1200
/* * A parsed rawtr(...) descriptor. */
@@ -1189,6 +1220,11 @@ class RawTRDescriptor final : public DescriptorImpl
1189
1220
// We can't know whether there is a script path, so assume key path spend.
1190
1221
return 1 + 65 ;
1191
1222
}
1223
+
1224
+ std::optional<int64_t > MaxSatisfactionElems () const override {
1225
+ // See above, we assume keypath spend.
1226
+ return 1 ;
1227
+ }
1192
1228
};
1193
1229
1194
1230
// //////////////////////////////////////////////////////////////////////////
0 commit comments