@@ -8,7 +8,7 @@ use crate::{setup, Call};
88
99use bitcoin:: { self , Address , Amount } ;
1010use elements:: hex:: ToHex ;
11- use elements:: encode:: { deserialize , serialize} ;
11+ use elements:: encode:: serialize;
1212use elements:: hashes:: Hash ;
1313use elements:: pset:: PartiallySignedTransaction ;
1414use elements:: { AssetId , ContractHash } ;
@@ -131,15 +131,16 @@ fn tx_pegin() {
131131}
132132
133133fn rtt ( base64 : & str ) -> String {
134- base64:: encode ( serialize ( & psbt_from_base64 ( & base64) ) )
134+ let pset: PartiallySignedTransaction = base64. parse ( ) . unwrap ( ) ;
135+ pset. to_string ( )
135136}
136137
137138fn psbt_rtt ( elementsd : & ElementsD , base64 : & str ) {
138139 let a = elementsd. decode_psbt ( & base64) . unwrap ( ) ;
139140
140- let b_psbt = psbt_from_base64 ( & base64) ;
141+ let b_psbt: PartiallySignedTransaction = base64. parse ( ) . unwrap ( ) ;
141142 let mut b_bytes = serialize ( & b_psbt) ;
142- let b_base64 = base64:: encode ( & b_bytes) ;
143+ let b_base64 = bitcoin :: base64:: encode ( & b_bytes) ;
143144 let b = elementsd. decode_psbt ( & b_base64) . unwrap ( ) ;
144145
145146 assert_eq ! ( a, b) ;
@@ -151,16 +152,10 @@ fn psbt_rtt(elementsd: &ElementsD, base64: &str) {
151152 // ensuring decode prints all data inside psbt, randomly changing a byte,
152153 // if the results is still decodable it should not be equal to initial value
153154 b_bytes[ i] = b_bytes[ i] . wrapping_add ( 1 ) ;
154- let base64 = base64:: encode ( & b_bytes) ;
155+ let base64 = bitcoin :: base64:: encode ( & b_bytes) ;
155156 if let Some ( decoded) = elementsd. decode_psbt ( & base64) {
156157 assert_ne ! ( a, decoded, "{} with changed byte {}" , b_bytes. to_hex( ) , i) ;
157158 }
158159 b_bytes[ i] = b_bytes[ i] . wrapping_sub ( 1 ) ;
159160 }
160161}
161-
162- fn psbt_from_base64 ( base64 : & str ) -> PartiallySignedTransaction {
163- let bytes = base64:: decode ( & base64) . unwrap ( ) ;
164- deserialize ( & bytes) . unwrap ( )
165- }
166-
0 commit comments