Skip to content

Latest commit

 

History

History
76 lines (56 loc) · 2.01 KB

README.md

File metadata and controls

76 lines (56 loc) · 2.01 KB

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'
}