Skip to content

Java converter from legacy address to new bitcoincash format and vice versa

License

Notifications You must be signed in to change notification settings

sealedtx/bitcoin-cash-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bitcoin-cash-converter

Build Status

Simple address converter from legacy to new bitcoincash format and vice versa. It is fully covered by unit tests.

Usage

The class AddressConverter is the entrypoint to the bitcoin-cash-converter API, use it to convert addresses.

Legacy -> Bitcoincash

You can convert legacy address from a String to new bitcoincash format:

String bitcoincash_address = AddressConverter.toCashAddress(legacy_address);

Bitcoincash -> Legacy

You can convert bitcoincash address from a String with format "bitcoincash:${your_address}" to legacy fomat:

String legacy_address = AddressConverter.toLegacyAddress(bitcoincash_address);

Example:

String legacy_address = "18uzj5qpkmg88uF3R4jKTQRVV3NiQ5SBPf";
String bitcoincash_address = AddressConverter.toCashAddress(legacy_address);
System.out.println(bitcoincash_address); // output: bitcoincash:qptvav58e40tcrcwuvufr94u7enkjk6s2qlxy5uf9j

String cash_address = "bitcoincash:qptvav58e40tcrcwuvufr94u7enkjk6s2qlxy5uf9j";
String legacy_address = AddressConverter.toLegacyAddress(cash_address);
System.out.println(legacy_address); // output: 18uzj5qpkmg88uF3R4jKTQRVV3NiQ5SBPf

Include

Maven

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>
<dependency>
  <groupId>com.github.sealedtx</groupId>
  <artifactId>bitcoin-cash-converter</artifactId>
  <version>1.0</version>
</dependency>

Gradle

allprojects {
  repositories {
  ...
  maven { url 'https://jitpack.io' }
  }
}
  
dependencies {
  implementation 'com.github.sealedtx:bitcoin-cash-converter:1.0'
}

About

Java converter from legacy address to new bitcoincash format and vice versa

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages