Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fake Bitcoin Address and Transaction Hash Generation #782

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

grossiwm
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant