@@ -6,6 +6,7 @@ use miniscript::limits::{
66} ;
77
88use super :: { Error , ErrorKind , Property , ScriptContext } ;
9+ use miniscript:: context:: SigType ;
910use script_num_size;
1011use std:: cmp;
1112use std:: iter:: once;
@@ -177,24 +178,30 @@ impl Property for ExtData {
177178 }
178179 }
179180
180- fn from_pk_k ( ) -> Self {
181+ fn from_pk_k < Ctx : ScriptContext > ( ) -> Self {
181182 ExtData {
182- pk_cost : 34 ,
183+ pk_cost : match Ctx :: sig_type ( ) {
184+ SigType :: Ecdsa => 34 ,
185+ SigType :: Schnorr => 33 ,
186+ } ,
183187 has_free_verify : false ,
184188 ops_count_static : 0 ,
185189 ops_count_sat : Some ( 0 ) ,
186190 ops_count_nsat : Some ( 0 ) ,
187191 stack_elem_count_sat : Some ( 1 ) ,
188192 stack_elem_count_dissat : Some ( 1 ) ,
189- max_sat_size : Some ( ( 73 , 73 ) ) ,
193+ max_sat_size : match Ctx :: sig_type ( ) {
194+ SigType :: Ecdsa => Some ( ( 73 , 73 ) ) ,
195+ SigType :: Schnorr => Some ( ( 66 , 66 ) ) ,
196+ } ,
190197 max_dissat_size : Some ( ( 1 , 1 ) ) ,
191198 timelock_info : TimeLockInfo :: default ( ) ,
192199 exec_stack_elem_count_sat : Some ( 1 ) , // pushes the pk
193200 exec_stack_elem_count_dissat : Some ( 1 ) ,
194201 }
195202 }
196203
197- fn from_pk_h ( ) -> Self {
204+ fn from_pk_h < Ctx : ScriptContext > ( ) -> Self {
198205 ExtData {
199206 pk_cost : 24 ,
200207 has_free_verify : false ,
@@ -203,8 +210,14 @@ impl Property for ExtData {
203210 ops_count_nsat : Some ( 3 ) ,
204211 stack_elem_count_sat : Some ( 2 ) ,
205212 stack_elem_count_dissat : Some ( 2 ) ,
206- max_sat_size : Some ( ( 34 + 73 , 34 + 73 ) ) ,
207- max_dissat_size : Some ( ( 35 , 35 ) ) ,
213+ max_sat_size : match Ctx :: sig_type ( ) {
214+ SigType :: Ecdsa => Some ( ( 34 + 73 , 34 + 73 ) ) ,
215+ SigType :: Schnorr => Some ( ( 66 + 33 , 33 + 66 ) ) ,
216+ } ,
217+ max_dissat_size : match Ctx :: sig_type ( ) {
218+ SigType :: Ecdsa => Some ( ( 35 , 35 ) ) ,
219+ SigType :: Schnorr => Some ( ( 34 , 34 ) ) ,
220+ } ,
208221 timelock_info : TimeLockInfo :: default ( ) ,
209222 exec_stack_elem_count_sat : Some ( 2 ) , // dup and hash push
210223 exec_stack_elem_count_dissat : Some ( 2 ) ,
@@ -242,7 +255,7 @@ impl Property for ExtData {
242255 ( false , false ) => 2 ,
243256 } ;
244257 ExtData {
245- pk_cost : num_cost + 33 * n /*pks*/ + ( n- 1 ) /*checksigadds*/ + 1 ,
258+ pk_cost : num_cost + 33 * n /*pks*/ + ( n - 1 ) /*checksigadds*/ + 1 ,
246259 has_free_verify : true ,
247260 ops_count_static : 1 , // We don't care about opcounts in tapscript
248261 ops_count_sat : Some ( n + 1 ) ,
@@ -1011,8 +1024,8 @@ impl Property for ExtData {
10111024 let ret = match * fragment {
10121025 Terminal :: True => Ok ( Self :: from_true ( ) ) ,
10131026 Terminal :: False => Ok ( Self :: from_false ( ) ) ,
1014- Terminal :: PkK ( ..) => Ok ( Self :: from_pk_k ( ) ) ,
1015- Terminal :: PkH ( ..) => Ok ( Self :: from_pk_h ( ) ) ,
1027+ Terminal :: PkK ( ..) => Ok ( Self :: from_pk_k :: < Ctx > ( ) ) ,
1028+ Terminal :: PkH ( ..) => Ok ( Self :: from_pk_h :: < Ctx > ( ) ) ,
10161029 Terminal :: Multi ( k, ref pks) | Terminal :: MultiA ( k, ref pks) => {
10171030 if k == 0 {
10181031 return Err ( Error {
0 commit comments