Skip to content
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

wrong base58check to hex encoding #32

Closed
viktorheli opened this issue Mar 2, 2018 · 2 comments
Closed

wrong base58check to hex encoding #32

viktorheli opened this issue Mar 2, 2018 · 2 comments

Comments

@viktorheli
Copy link

viktorheli commented Mar 2, 2018

Hi. Bug:
This command line:
bitcoin-tool --input-type address --input-format base58check --output-type address --output-format hex --input 15cLKZtKbqeSVxXWjhi5i4DjeftC8ky3bo

Give me following hex digit:
00328f307df6191bacf2bfdccfed12246fc19debd2

Going to Online Address Validator and Base58 Encoder/Decoder
http://lenschulwitz.com/base58
paste hex and see this:
1hrXJp891VFJ8KLGRyszDoqLeJJV

Correct work, for example:
bx base58-decode 15cLKZtKbqeSVxXWjhi5i4DjeftC8ky3bo
00328f307df6191bacf2bfdccfed12246fc19debd24913a03a

http://lenschulwitz.com/base58 give:
15cLKZtKbqeSVxXWjhi5i4DjeftC8ky3bo

matja added a commit that referenced this issue Mar 3, 2018
The existing `--output-type address` emits the 1 prefix byte and
20 bytes of the RMD160 hash of the address, without the 4 byte
checksum (truncated SHA256 hash), as the base58check encoding
introduces the checksum during a seperate process.

The introduction of this output type allows the checksum bytes
of the base58check encoding to be output.

This should resolve issue #32
@matja
Copy link
Owner

matja commented Mar 3, 2018

For the first example, 00328f307df6191bacf2bfdccfed12246fc19debd2 is the prefix byte and 20-byte RMD160 hash (21 bytes in total), without the checksum (4 byte truncated SHA256 hash).
This patches the requested --output-type address as describe in the help page :

address : 21 byte Bitcoin address (prefix + hash)

The site you mention expects a hex string with the checksum to be appended, which is the reason for the different address which was output (which is invalid).

I agree you have a valid point and bitcoin-tool should output this, so I've added a new output-type called address-checksum (I didn't want to change existing behavior). You can pull the latest master branch to get this.

This will give you the output I believe you were expecting, when used like:
./bitcoin-tool --input-type address --input-format base58check --output-type address-checksum --output-format hex --input 15cLKZtKbqeSVxXWjhi5i4DjeftC8ky3bo

Output:
00328f307df6191bacf2bfdccfed12246fc19debd24913a03a

@viktorheli
Copy link
Author

viktorheli commented Mar 5, 2018

It works! Very BIG thanks!
./bitcoin-tool --input-type address --input-format base58check --output-type address-checksum --output-format hex --input 15cLKZtKbqeSVxXWjhi5i4DjeftC8ky3bo

00328f307df6191bacf2bfdccfed12246fc19debd24913a03a

bx base58-decode 15cLKZtKbqeSVxXWjhi5i4DjeftC8ky3bo
00328f307df6191bacf2bfdccfed12246fc19debd24913a03a

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

No branches or pull requests

2 participants