Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

apoelstra
Copy link
Member

It turns out we only ever use do decoding of fixed test vectors. It would be nice to have a hex! macro for this. Eventually.

In some cases we were able to use inherent methods on bitcoin types -- for example ScriptBuf::from_hex or deserialize_hex.

@apoelstra apoelstra marked this pull request as draft May 22, 2025 20:53
@apoelstra
Copy link
Member Author

Drafting. Might as well just wait for the real 1.0.

@apoelstra apoelstra force-pushed the push-ppmrkrkvqkzo branch 3 times, most recently from fb0adc3 to bea8cde Compare May 23, 2025 13:05
@apoelstra
Copy link
Member Author

Published :) will update this tonight or tomorrow morning.

@apoelstra apoelstra force-pushed the push-ppmrkrkvqkzo branch from bea8cde to 78e8f01 Compare July 15, 2025 14:16
Copy link
Member Author

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On bea8cde successfully ran local tests

@apoelstra apoelstra marked this pull request as ready for review July 15, 2025 14:56
Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 78e8f01

@tcharding
Copy link
Member

PR title and git log are both stale - they mention 'rc'.

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment on lines -74 to +73
let depo_tx: Transaction = deserialize(&Vec::<u8>::from_hex(hex_tx).unwrap()).unwrap();
let depo_tx: Transaction = deserialize_hex(hex_tx).unwrap();
Copy link
Member

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.

Copy link
Member Author

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.

Comment on lines -1658 to +1657
Vec::<u8>::from_hex("76a91479091972186c449eb1ded22b78e40d009bdf008988ac").unwrap()[..]
hex::decode_to_vec("76a91479091972186c449eb1ded22b78e40d009bdf008988ac").unwrap()[..]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest did you find yourself cursing the f***ing hex-conservative devs or were you happy enough during the upgrade?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was happy enough, but the lack of encoding support is idiotic.

@apoelstra apoelstra changed the title use hex-conservative 1.0 rc1 everywhere for decoding use hex-conservative 1.0 everywhere for decoding Jul 16, 2025
It turns out we only ever use do decoding of fixed test vectors. It
would be nice to have a hex! macro for this. Eventually.

In some cases we were able to use inherent methods on bitcoin types --
for example ScriptBuf::from_hex or deserialize_hex.
@apoelstra apoelstra force-pushed the push-ppmrkrkvqkzo branch from 78e8f01 to a1fa898 Compare July 16, 2025 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants