Skip to content

Commit 82e1811

Browse files
authored
Update readme.md
1 parent 885cbeb commit 82e1811

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

readme.md

+10
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@ This is a demo, it uses Legacy Bitcoin addresses, which start with a 1 for P2PKH
1717
Example: 1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs.
1818
Encoding: Base58Check encoding.
1919
Type: P2PKH (Pay-to-Public-Key-Hash).
20+
21+
This code generates a legacy Bitcoin address from a given public key in hexadecimal format. It performs the following steps:
22+
23+
1. **Hex to Bytes**: Converts the input hexadecimal string into a byte array.
24+
2. **SHA-256 Hashing**: Computes the SHA-256 hash of the public key bytes.
25+
3. **RIPEMD-160 Hashing**: Hashes the SHA-256 result using the RIPEMD-160 algorithm.
26+
4. **Version Byte**: Prepends a version byte (0x00) to the RIPEMD-160 hash, indicating it's for the main Bitcoin network.
27+
5. **Checksum Calculation**: Computes the SHA-256 hash of the versioned hash, then performs SHA-256 again to derive a checksum.
28+
6. **Checksum Append**: Appends the first four bytes of the checksum to the versioned hash.
29+
7. **Base58 Encoding**: Converts the final byte array into a Base58 string, resulting in the Bitcoin address.

0 commit comments

Comments
 (0)