Skip to content

Commit ce42c66

Browse files
committed
Merge rust-bitcoin#781: feat: optimize pushbytes by removing unreachable minimal check
84d1ad5 feat: optimize pushbytes by removing unreachable minimal check (ChrisCho-H) Pull request description: In [rust-bitcoin](https://github.com/rust-bitcoin/rust-bitcoin/blob/aa25adfc64ea0d742ca202991140f280024aba1b/bitcoin/src/blockdata/script/push_bytes.rs#L312), `read_scriptint` checks `NonMinimalPush`, which makes an additional minimal check needless and `PushBytes` inefficient. ACKs for top commit: apoelstra: ACK 84d1ad5; successfully ran local tests; yep, I think you are right Tree-SHA512: d16a199fd5caef13b4fa78584d61c7feb843accb2097b29ca7ccdabfd1cae3e5af9d54d70dc7b7b93f50809c2719f70a87cf4dbba9da53ed55d427568de9eed2
2 parents 733bedd + 84d1ad5 commit ce42c66

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/miniscript/lex.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,9 @@ pub fn lex(script: &'_ script::Script) -> Result<Vec<Token<'_>>, Error> {
213213
33 => ret.push(Token::Bytes33(bytes.as_bytes())),
214214
65 => ret.push(Token::Bytes65(bytes.as_bytes())),
215215
_ => {
216+
// check minimality of the number
216217
match script::read_scriptint(bytes.as_bytes()) {
217218
Ok(v) if v >= 0 => {
218-
// check minimality of the number
219-
if script::Builder::new().push_int(v).into_script()[1..].as_bytes()
220-
!= bytes.as_bytes()
221-
{
222-
return Err(Error::InvalidPush(bytes.to_owned().into()));
223-
}
224219
ret.push(Token::Num(v as u32));
225220
}
226221
Ok(_) => return Err(Error::InvalidPush(bytes.to_owned().into())),

0 commit comments

Comments
 (0)