File tree Expand file tree Collapse file tree 3 files changed +7
-15
lines changed Expand file tree Collapse file tree 3 files changed +7
-15
lines changed Original file line number Diff line number Diff line change 88use core:: fmt;
99use core:: iter:: FromIterator ;
1010
11+ use bitcoin_miniscript:: expression:: check_valid_chars;
12+
1113use crate :: Error ;
1214
1315const INPUT_CHARSET : & str = "0123456789()[],'/*abcdefgh@:$%{}IJKLMNOPQRSTUVWXYZ&+-.;<=>?!^_|~ijklmnopqrstuvwxyzABCDEFGH`#\" \\ " ;
@@ -51,11 +53,7 @@ pub fn desc_checksum(desc: &str) -> Result<String, Error> {
5153/// if it is present and returns the descriptor string
5254/// without the checksum
5355pub ( crate ) fn verify_checksum ( s : & str ) -> Result < & str , Error > {
54- for ch in s. as_bytes ( ) {
55- if * ch < 20 || * ch > 127 {
56- return Err ( Error :: Unprintable ( * ch) ) ;
57- }
58- }
56+ check_valid_chars ( s) ?;
5957
6058 let mut parts = s. splitn ( 2 , '#' ) ;
6159 let desc_str = parts. next ( ) . unwrap ( ) ;
Original file line number Diff line number Diff line change 77use std:: collections:: HashSet ;
88use std:: { error, fmt, str} ;
99
10+ use bitcoin_miniscript:: expression:: check_valid_chars;
1011use elements:: { LockTime , Sequence } ;
1112#[ cfg( feature = "compiler" ) ]
1213use {
@@ -1098,11 +1099,7 @@ impl_from_str!(
10981099 Policy <Pk >,
10991100 type Err = Error ; ,
11001101 fn from_str( s: & str ) -> Result <Policy <Pk >, Error > {
1101- for ch in s. as_bytes( ) {
1102- if * ch < 20 || * ch > 127 {
1103- return Err ( Error :: Unprintable ( * ch) ) ;
1104- }
1105- }
1102+ check_valid_chars( s) ?;
11061103
11071104 let tree = expression:: Tree :: from_str( s) ?;
11081105 let policy: Policy <Pk > = FromTree :: from_tree( & tree) ?;
Original file line number Diff line number Diff line change 66use std:: str:: FromStr ;
77use std:: { fmt, str} ;
88
9+ use bitcoin_miniscript:: expression:: check_valid_chars;
910use elements:: { LockTime , Sequence } ;
1011
1112use super :: concrete:: PolicyError ;
@@ -287,11 +288,7 @@ impl_from_str!(
287288 Policy <Pk >,
288289 type Err = Error ; ,
289290 fn from_str( s: & str ) -> Result <Policy <Pk >, Error > {
290- for ch in s. as_bytes( ) {
291- if * ch < 20 || * ch > 127 {
292- return Err ( Error :: Unprintable ( * ch) ) ;
293- }
294- }
291+ check_valid_chars( s) ?;
295292
296293 let tree = expression:: Tree :: from_str( s) ?;
297294 expression:: FromTree :: from_tree( & tree)
You can’t perform that action at this time.
0 commit comments