Open hamnaz opened 3 years ago
Used the tools i have.
On Fri, Jan 29, 2021, 00:47 hamnaz notifications@github.com wrote:
i have address bc1qsssfz2x83e8mlhwl52n7y5p8c3rj5r4yk0744y i want convert to hash160 (20byte) could you guide what command you saying to work i tried all way its return always error thankx for update me
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/matja/bitcoin-tool/issues/52, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBR6UGCI7FFC6DND65DMHDS4GPJVANCNFSM4WXOZRRQ .
Since the --batch option dont work, I've made following shell script to make the conversion, I hope this help you guys:
while read value do random=$(./bitcoin-tool --input-type address --input-format base58check --input $value --output-type public-key-rmd --output-format hex) echo $random done < FILEWITHBASE58ADDRESSES.txt
@voltaxvoltax why do you say batch option does not work? Please give me an example.
@streamofstars
@voltaxvoltax why do you say batch option does not work? Please give me an example.
running the command : ./bitcoin-tool --batch --input-type address --output-type public-key-rmd --input-format base58check --network bitcoin --output-format hex --input-file FILE.txt Gives the following error, even using the fix, it still dont work :
Failed to decode Base58Check input (checksum failure). You can use the --fix-base58check option to change the input string until the checksum is valid, but this may return a false positive match.
@voltaxvoltax ok, you are right, seems like a bug. I just tested on some addresses I took from the newest block and the tool behaves unpredictably. It throws errors on some addresses when a file is provided as an input but is able to convert them separately. Also, if the problematic address is at the first or second line of an input file then it works but if it is at the third line it does not. Weird. @matja FYI
Thanks for the report, I believe I have found the cause of this.
When using --batch
, does the failing address start with 1 and follows an address starting with 3?
Pushed 439aaaaf9f9cedda28a7acc37bb8402ace9a6ab5 to fix batch mode decoding of some addresses. Still need to check bech32 addresses.
Minimal test case:
cat > fail.txt << EOF
3R2cuenjG5nFubqX9Wzuukdin2YfBbQ6Kw
1111111111111111111114oLvT2
EOF
./bitcoin-tool \
--batch \
--network bitcoin \
--input-type address \
--input-format base58check \
--input-file fail.txt \
--output-type public-key-rmd \
--output-format hex
expected:
ffffffffffffffffffffffffffffffffffffffff
0000000000000000000000000000000000000000
actual:
ffffffffffffffffffffffffffffffffffffffff
Failed to decode Base58Check input (checksum failure).
You can use the --fix-base58check option to change the input string until the checksum is valid, but this may return a false positive match.
This happens because the leading zeros in the output buffer is not initialized at: https://github.com/matja/bitcoin-tool/blob/89fc01d8b034cc1db1c9bece8e008540aedb3d11/base58.c#L192
So the 0x05 address prefix (P2SH), which is not part of the rmd160 hash, is not overwritten by the 0x00 address prefix (P2PKH) of the leading zeros in the second address.
Added test to catch this:
Test failure (old code):
failed test 17 - 0-padded base58 decoding prefix initialization
Test pass (new code):
pass 17 - 0-padded base58 decoding prefix initialization
...
all tests passed
i have address bc1qsssfz2x83e8mlhwl52n7y5p8c3rj5r4yk0744y i want convert to hash160 (20byte) could you guide what command you saying to work i tried all way its return always error thankx for update me