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

is it possible to add --input-format int ? #20

Closed
ghost opened this issue Aug 20, 2017 · 6 comments
Closed

is it possible to add --input-format int ? #20

ghost opened this issue Aug 20, 2017 · 6 comments

Comments

@ghost
Copy link

ghost commented Aug 20, 2017

which will take int and convert it to hex

thanks

@matja
Copy link
Owner

matja commented Oct 21, 2017

To clarify, do you mean a decimal representation of a number?

Is there a common use-case for accepting decimal inputs? I haven't come across any need to use decimal input yet. Regardless, it is a simple change and I'll look into it - thanks for the suggestion.

@ghost
Copy link
Author

ghost commented Oct 21, 2017

please ignore my last message.
as i had just started to learn about it.

but as i learn more., and i feel there is this app or script missing.,
which will take bitcoin address and convert it to hash160 format and other way around.
it would be great if this could be implemented.
input file with addresses and output file with hash160
or other way around.

thanks

@matja
Copy link
Owner

matja commented Oct 21, 2017

Conversion between address and hash160 format is possible with this tool. It is actually one of the tests in tests.sh : 11 - convert 'Hash 160' to address

The 'Hash 160' format is called public-key-rmd (rmd = RIPEMD160) in this tool.

Example to convert from address to public-key-rmd :

./bitcoin-tool \
--input-type address \
--output-type public-key-rmd \
--input-format base58check \
--network bitcoin \
--output-format hex \
--input 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX

output: 119b098e2e980a229e139a9ed01a469e518e6f26

Example to convert from public-key-rmd to address :

./bitcoin-tool \
--input-type public-key-rmd \
--output-type address \
--input-format hex \
--network bitcoin \
--output-format base58check \
--input 119b098e2e980a229e139a9ed01a469e518e6f26

output: 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX

Example to convert a file containing addresses to public-key-rmd :
(I created 4 random addresses using the instructions at "Generate address from random private key" in README.md)

cat > addrs << EOF
1ArxEhBam1ThtTKC1oZMCSsouQZRW5W9r
14H8y3nHnRUTw63C28FzYSria7B4n6n4eW
1N8BuoWoWSWPa6h4yVo3xiKQJmYE3iu7aV
1wZWNAyjQc5xUBGEPFfwbhcRo2DCMhcNZ
EOF

./bitcoin-tool \
--batch \
--input-type address \
--output-type public-key-rmd \
--input-format base58check \
--network bitcoin \
--output-format hex \
--input-file addrs

output:

01dd7118282788012ded71f41b50419d3e724eea
23f5aec6038c5a52d1459b255ea37d2f05bcd956
e7b6a924c50d8a18d439f504e764cb4ca3cb092d
0a5198c976edf3994bfd95f04bb0b58e91062d33

I think that accomplishes what you describe, please tell me if you believe otherwise.

@ghost
Copy link
Author

ghost commented Oct 21, 2017

this is it, my quest is over.
this is what i have been looking for, from last few days.
thanks

@agoora
Copy link

agoora commented Jan 8, 2018

Hi matja,

From input-file btcaddress.txt, I have this error message :
"Failed to decode Base58Check input (checksum failure)."
Please help me.
Thanks.

@matja
Copy link
Owner

matja commented Jan 8, 2018

Does btcaddress.txt end with a newline character? For example, if you cat the file is the address output on its own line? If so, that is by design, to be strict about input decoding, although the error message could be better.
Try adding --batch to the options, then the newline will be ignored, and used to delimit inputs instead.

@matja matja closed this as completed Jan 8, 2018
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