-
Notifications
You must be signed in to change notification settings - Fork 155
use hex-conservative 1.0 everywhere for decoding #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,27 +166,11 @@ fn main() { | |
|
||
#[cfg(test)] | ||
mod tests { | ||
fn extend_vec_from_hex(hex: &str, out: &mut Vec<u8>) { | ||
let mut b = 0; | ||
for (idx, c) in hex.as_bytes().iter().enumerate() { | ||
b <<= 4; | ||
match *c { | ||
b'A'..=b'F' => b |= c - b'A' + 10, | ||
b'a'..=b'f' => b |= c - b'a' + 10, | ||
b'0'..=b'9' => b |= c - b'0', | ||
_ => panic!("Bad hex"), | ||
} | ||
if (idx & 1) == 1 { | ||
out.push(b); | ||
b = 0; | ||
} | ||
} | ||
} | ||
use miniscript::hex; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
||
#[test] | ||
fn duplicate_crash() { | ||
let mut a = Vec::new(); | ||
extend_vec_from_hex("", &mut a); | ||
super::do_test(&a); | ||
let v = hex::decode_to_vec("abcd").unwrap(); | ||
super::do_test(&v); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1047,7 +1047,6 @@ mod tests { | |
use bitcoin::blockdata::opcodes::all::{OP_CLTV, OP_CSV}; | ||
use bitcoin::blockdata::script::Instruction; | ||
use bitcoin::blockdata::{opcodes, script}; | ||
use bitcoin::hashes::hex::FromHex; | ||
use bitcoin::hashes::Hash; | ||
use bitcoin::script::PushBytes; | ||
use bitcoin::sighash::EcdsaSighashType; | ||
|
@@ -1645,7 +1644,7 @@ mod tests { | |
.unwrap(); | ||
assert_eq!( | ||
*descriptor.script_code().unwrap().as_bytes(), | ||
Vec::<u8>::from_hex("76a9141d0f172a0ecb48aee1be1f2687d2963ae33f71a188ac").unwrap()[..] | ||
hex::decode_to_vec("76a9141d0f172a0ecb48aee1be1f2687d2963ae33f71a188ac").unwrap()[..] | ||
); | ||
|
||
// P2SH-P2WPKH (from bip143 test vectors) | ||
|
@@ -1655,7 +1654,7 @@ mod tests { | |
.unwrap(); | ||
assert_eq!( | ||
*descriptor.script_code().unwrap().as_bytes(), | ||
Vec::<u8>::from_hex("76a91479091972186c449eb1ded22b78e40d009bdf008988ac").unwrap()[..] | ||
hex::decode_to_vec("76a91479091972186c449eb1ded22b78e40d009bdf008988ac").unwrap()[..] | ||
Comment on lines
-1658
to
+1657
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of interest did you find yourself cursing the f***ing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was happy enough, but the lack of encoding support is idiotic. |
||
); | ||
|
||
// P2WSH (from bitcoind's `createmultisig`) | ||
|
@@ -1667,7 +1666,7 @@ mod tests { | |
*descriptor | ||
.script_code().unwrap() | ||
.as_bytes(), | ||
Vec::<u8>::from_hex("522103789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd2103dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a6162652ae").unwrap()[..] | ||
hex::decode_to_vec("522103789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd2103dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a6162652ae").unwrap()[..] | ||
); | ||
|
||
// P2SH-P2WSH (from bitcoind's `createmultisig`) | ||
|
@@ -1676,7 +1675,7 @@ mod tests { | |
*descriptor | ||
.script_code().unwrap() | ||
.as_bytes(), | ||
Vec::<u8>::from_hex("522103789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd2103dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a6162652ae") | ||
hex::decode_to_vec("522103789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd2103dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a6162652ae") | ||
.unwrap()[..] | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of an unrelated change, bad Andrew no biscuit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is it unrelated? We used to have a hex library that has
from_hex
and now we don't.