File tree Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,24 @@ impl MyValue {
7575 _ => Err ( ScriptError :: UnexpectedArgument ) ,
7676 }
7777 }
78+
79+ pub fn from_pkh ( pkh : & PublicKeyHash ) -> Self {
80+ let pkh_bytes = pkh. as_ref ( ) ;
81+
82+ MyValue :: Bytes ( pkh_bytes. to_vec ( ) )
83+ }
84+
85+ pub fn to_pkh ( & self ) -> Result < PublicKeyHash , ScriptError > {
86+ match self {
87+ MyValue :: Bytes ( bytes) => {
88+ let pkh: PublicKeyHash = PublicKeyHash :: from_bytes ( bytes)
89+ . map_err ( |_e| ScriptError :: InvalidPublicKeyHash ) ?;
90+
91+ Ok ( pkh)
92+ }
93+ _ => Err ( ScriptError :: UnexpectedArgument ) ,
94+ }
95+ }
7896}
7997
8098fn equal_operator ( stack : & mut Stack < MyValue > ) -> Result < ( ) , ScriptError > {
@@ -199,16 +217,8 @@ fn check_multi_sig(
199217
200218 let mut pkhs = vec ! [ ] ;
201219 for bytes_pkh in bytes_pkhs {
202- match bytes_pkh {
203- MyValue :: Bytes ( bytes) => {
204- let pkh: PublicKeyHash = PublicKeyHash :: from_bytes ( & bytes)
205- . map_err ( |_e| ScriptError :: InvalidPublicKeyHash ) ?;
206- pkhs. push ( pkh) ;
207- }
208- _ => {
209- return Err ( ScriptError :: UnexpectedArgument ) ;
210- }
211- }
220+ let pkh = bytes_pkh. to_pkh ( ) ?;
221+ pkhs. push ( pkh) ;
212222 }
213223
214224 for sign_pkh in signed_pkhs {
You can’t perform that action at this time.
0 commit comments