java-faker icon indicating copy to clipboard operation
java-faker copied to clipboard

Add Fake Bitcoin Address and Transaction Hash Generation

Open grossiwm opened this issue 1 year ago • 0 comments

Add Fake Bitcoin Address and Transaction Hash Generation

Description

This pull request adds support for generating fake Bitcoin addresses and transaction hashes within the Java Faker library. It includes:

  • Bitcoin Address Generation:

    • Implemented methods to generate fake Bitcoin addresses for the main network (address()) and the test network (testnetAddress()).
    • Addresses are generated using Base58Check encoding with network-specific version bytes (0 for mainnet, 111 for testnet), following Bitcoin's address format conventions.
    • For more details on these version bytes and their corresponding address prefixes, refer to the Bitcoin Wiki - List of address prefixes.
  • Transaction Hash Generation:

    • Added a method (generateTransactionHash()) to create random 64-character hexadecimal strings simulating Bitcoin transaction hashes.
    • The method uses SHA-256 hashing for generating the transaction hash format.

Motivation

This addition allows Java Faker to generate realistic data related to Bitcoin transactions, enhancing the library’s utility for testing cryptocurrency-related applications.

Testing

  • Added unit tests to verify:
    • Correct format and prefix of mainnet and testnet addresses.
    • Address length within the expected range (26 to 35 characters).
    • Validity of generated transaction hashes as 64-character hexadecimal strings.

Notes

Please let me know if any adjustments are needed, or if further tests and documentation updates are required.

grossiwm avatar Oct 20 '24 05:10 grossiwm