项目作者: sealedtx

项目描述 :
Java converter from legacy address to new bitcoincash format and vice versa
高级语言: Java
项目地址: git://github.com/sealedtx/bitcoin-cash-converter.git
创建时间: 2018-07-12T19:18:09Z
项目社区:https://github.com/sealedtx/bitcoin-cash-converter

开源协议:Apache License 2.0

下载


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:

  1. 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:

  1. String legacy_address = AddressConverter.toLegacyAddress(bitcoincash_address);

Example:

  1. String legacy_address = "18uzj5qpkmg88uF3R4jKTQRVV3NiQ5SBPf";
  2. String bitcoincash_address = AddressConverter.toCashAddress(legacy_address);
  3. System.out.println(bitcoincash_address); // output: bitcoincash:qptvav58e40tcrcwuvufr94u7enkjk6s2qlxy5uf9j
  4. String cash_address = "bitcoincash:qptvav58e40tcrcwuvufr94u7enkjk6s2qlxy5uf9j";
  5. String legacy_address = AddressConverter.toLegacyAddress(cash_address);
  6. System.out.println(legacy_address); // output: 18uzj5qpkmg88uF3R4jKTQRVV3NiQ5SBPf

Include

Maven

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

Gradle

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }
  7. dependencies {
  8. implementation 'com.github.sealedtx:bitcoin-cash-converter:1.0'
  9. }