0

I want to create a address bitcoin.

I have a payload with version like this:

0050d512c984b1656ef47c145c8fd5d5262d3904b1

where 00 in my version prefix, and 50d512c984b1656ef47c145c8fd5d5262d3904b1 is my payload.

Now I Want to add checksum, with sha256 twice, the result is

4550e2041dd936f17fd8a0d60f17c69faea8ef0e7d3ee82383153d93c2e837a8

where the first 4 bytes is checksum 4550e204

Now I can convert to base58

0050d512c984b1656ef47c145c8fd5d5262d3904b1**4550e204**

And I Get the right address.

I can read that

These four bytes serve as the error-checking code, or checksum. The checksum is concatenated (appended) to the end.

How Can I check if my checksum (4550e204) is correct before base58 ?

  • Sorry I don't understand your question. You have described the derivation for the checksum given version&payload. Given a base58 address, you decode the address for the version+payload+checksum. From that you can verify the version+payload. What other scenario do you mean? – James C. Jan 22 at 12:33
0

One way to check is to use a tool like https://github.com/keis/base58 that implements base58check (-c) encoding and decoding (-d) with checksum verification to try to decode the final address:

$ printf "0050d512c984b1656ef47c145c8fd5d5262d3904b14550e204" | xxd -r -p | base58
18NQJwokxLGA7KsHJdQWh6ANB46K6nP7Hm
$ printf "18NQJwokxLGA7KsHJdQWh6ANB46K6nP7Hm" | base58 -c -d | xxd -p
0050d512c984b1656ef47c145c8fd5d5262d3904b1

Now, change the checksum and see if it is able to decode:

$ printf "0050d512c984b1656ef47c145c8fd5d5262d3904b14550e203" | xxd -r -p | base58
18NQJwokxLGA7KsHJdQWh6ANB46K6nP7Hk
Jordans-MacBook-Pro:~ Jbaczuk$ printf "18NQJwokxLGA7KsHJdQWh6ANB46K6nP7Hk" | base58 -c -d | xxd -p
Invalid checksum
  • thanks, for do checksum the operation is decode base58 -and reply printf 0050d512c984b1656ef47c145c8fd5d5262d3904b1 |xxd -r -p | sha256sum -b | xxd -r -p | sha256sum -b | head -c 8and Check the output with last 4 bytes ? – monkeyUser Jan 22 at 15:46
  • 1
    Yes, the first four bytes of the HASH256 is the checksum, which is appended to the end of the value to encode. – JBaczuk Jan 22 at 15:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.