matja / bitcoin-tool

Tool for converting Bitcoin keys and addresses
206 stars 116 forks source link

Can --batch mode return both address and private key pair? #19

Open xavier4040 opened 7 years ago

xavier4040 commented 7 years ago

Hi

I am currently testing bitcoin-tool for a project.

I have 2 questions :

Thanks Xavier

matja commented 7 years ago

Your first question is possible with --output-type all, for example:

./bitcoin-tool \
  --input $(openssl rand 32 -hex) \
  --input-type private-key \
  --input-format hex \
  --network bitcoin \
  --public-key-compression compressed \
  --output-type all

Will output in the following format:

address.hex:00854bb7dfddbfccb8282e802836c20207156a8f0d
address.base58:12ri4erZg1Ke7DrSSS7Pm4VYUBB3J
address.base58check:1D9oaWbrJ2bRn5a7XkexLTFge7Ua8iLkEJ
public-key-ripemd160.hex:854bb7dfddbfccb8282e802836c20207156a8f0d
public-key-ripemd160.base58:2ri4erZg1Ke7DrSSS7Pm4VYUBB3J
public-key-ripemd160.base58check:D9oaWbrJ2bRn5a7XkexLTFge7Ua3nTTS6
public-key-sha256.hex:2f3c72bb7c9d3ffbea38fee39a3402788dff44739b71ad3ad8df3fc4f9f734d3
public-key-sha256.base58:4BPd6yXb9h4do5Bng72KAjJhUVfsjvhkA4Nd5i6xFsWz
public-key-sha256.base58check:MoaqfkLHYDMp62Bs1N2LNgMSzmB5MTPGSUsiuHnzmeggVE8Ur
public-key.hex:024e0ba141873f80b0e9da24aa6b3255d85c9d75a71e5cd67aea5bc8717b69e177
public-key.base58:giHpynvuRLpTCCmVqagoHLSwPKwpM2naekSR1Mt6sQKg
public-key.base58check:5UrvH4VvFVnaZvUNpxuVwYfcRugJ8VWzzmZzzTCzLjf8kXEEZ5
private-key-wif.hex:8014b26e95a6e4833ed5ba40de7841c35d92a813b4a7c26e15e9746a35133fe6ee01
private-key-wif.base58:3twH6dVBXqoiKjXMc6FG2xvqno58qxdu4V8Q2JVZqx2xdT6
private-key-wif.base58check:KwuwezTsotYEjgfSX7Q9UpLPNHyLJPedER88PNp1QFtBsfqGbxmP
private-key.hex:14b26e95a6e4833ed5ba40de7841c35d92a813b4a7c26e15e9746a35133fe6ee
private-key.base58:2Pnxgm3Mic55wMU7HScz9GsTibiqLtnp94fdDRZfF1LH
private-key.base58check:A7gGiB4StaJmrRBWswWMDUJbisrMNt4pfck6mcF3p9M1bpypm

This does not currently work for --batch mode, as I think it'd be more sense to output selected items on the same row, rather than consecutive rows, which makes parsing harder. Shouldn't be too hard to change that behaviour, and I'd welcome any suggestions on the design.

xavier4040 commented 7 years ago

Hi

Thanks for your reply.

Yes I saw the --output-type all option, which returns a lot of informations.

From my point of view, the two main components of a "bitcoin identity" are the address and the private key (WIF). This is what is used by end users.

The workaround I found to the --batch operation is to run 2 bitcoin-tool commands, one for returning addresses, the other for returning private keys (both from same hex numbers file), and then merge/join the two files. So if bitcoin-tool could return both values on the same line, that would be perfect.

I agree with you with returning the selected items on the same row. It would make it a lot easier to handle. I think that CSV style is the most common and easy to use format/design. For example [Address;PrivateKey].

So for your example, each line could return something like this (if semicolon is used as delimiter): 1D9oaWbrJ2bRn5a7XkexLTFge7Ua8iLkEJ;KwuwezTsotYEjgfSX7Q9UpLPNHyLJPedER88PNp1QFtBsfqGbxmP

The idea is to just keep it simple. Xavier