wallet.lib

wallet library

License

License

GroupId

GroupId

org.elastos
ArtifactId

ArtifactId

wallet.lib
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

wallet.lib
wallet library
Project URL

Project URL

http://www.elastos.org
Source Code Management

Source Code Management

http://github.com/elastos/Elastos.ORG.Wallet.Lib.Java/tree/master

Download wallet.lib

How to add to project

<!-- https://jarcasting.com/artifacts/org.elastos/wallet.lib/ -->
<dependency>
    <groupId>org.elastos</groupId>
    <artifactId>wallet.lib</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.elastos/wallet.lib/
implementation 'org.elastos:wallet.lib:0.1.1'
// https://jarcasting.com/artifacts/org.elastos/wallet.lib/
implementation ("org.elastos:wallet.lib:0.1.1")
'org.elastos:wallet.lib:jar:0.1.1'
<dependency org="org.elastos" name="wallet.lib" rev="0.1.1">
  <artifact name="wallet.lib" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.elastos', module='wallet.lib', version='0.1.1')
)
libraryDependencies += "org.elastos" % "wallet.lib" % "0.1.1"
[org.elastos/wallet.lib "0.1.1"]

Dependencies

compile (6)

Group / Artifact Type Version
org.elastos.ela : ela_tool jar 0.1.1
com.google.code.gson : gson jar 2.8.5
org.bitcoinj : bitcoinj-core jar 0.14.7
org.web3j : core jar 3.5.0
commons-codec : commons-codec jar 1.10
com.madgag.spongycastle : core jar 1.58.0.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

Quick Start

Run with Maven

Create a basic Maven project

<dependency>
    <groupId>org.elastos</groupId>
    <artifactId>wallet.lib</artifactId>
    <version>0.0.2</version>
</dependency>

or Gradle:

compile 'org.elastos:wallet.lib:0.0.2'

Sample of how to use some of these api:

  • generate mnemonic phrase
String mnemonic = ElaHdSupport.generateMnemonic(MnemonicType.ENGLISH); 
  • get single wallet of specific mnemonic index
String mnemonic = "purchase fantasy quit cement cruise hobby poem obvious warm climb amateur merit"; 
String singleAddress = ElaHdSupport.generate(mnemonic,1); 
  • generate raw transaction
String data = "{\"Transactions\":[{\"UTXOInputs\":[{\"privateKey\":\"C6B0CA5B61984E2FCACCB255D4A57AB3F6A2B7AB753999CC593B0DEF64FCE7A8\",\"address\":\"EeJ6yExPneTvMXuEXhnwbWL3Mx2Spb55BY\",\"txid\":\"4ee71e4c2b72b628d837fd7a0ff5a44db3d80805f5d644a8628f3a3996c74c01\",\"index\":0},{\"privateKey\":\"C6B0CA5B61984E2FCACCB255D4A57AB3F6A2B7AB753999CC593B0DEF64FCE7A8\",\"address\":\"EeJ6yExPneTvMXuEXhnwbWL3Mx2Spb55BY\",\"txid\":\"c456a8619d4b8d3e1f185fe6799a9dcae57135f9a895f73572d5256e5e32417f\",\"index\":0},{\"privateKey\":\"C6B0CA5B61984E2FCACCB255D4A57AB3F6A2B7AB753999CC593B0DEF64FCE7A8\",\"address\":\"EeJ6yExPneTvMXuEXhnwbWL3Mx2Spb55BY\",\"txid\":\"14c9754270e39b61c9a8c6925ab2f6d6763483c0ec2ba954074ef320a8e6cc70\",\"index\":0},{\"privateKey\":\"C6B0CA5B61984E2FCACCB255D4A57AB3F6A2B7AB753999CC593B0DEF64FCE7A8\",\"address\":\"EeJ6yExPneTvMXuEXhnwbWL3Mx2Spb55BY\",\"txid\":\"0ac2cb3f4aeb9d424635ead84bd83983000e1cd5b96327d0569c5327cadf6917\",\"index\":10530}],\"Outputs\":[{\"amount\":10,\"address\":\"EdyqqiJcdkTDtfkvxVbTuNXGMdB3FEcpXA\"},{\"amount\":9452322,\"address\":\"EeJ6yExPneTvMXuEXhnwbWL3Mx2Spb55BY\"}],\"Memo\":\"type:text,msg:hello123\"}]}\n";
JSONObject req = JSONObject.fromObject(data);
String rawTx = ElaKit.genRawTransaction(req);
  • generate did from public key
String did = ElaKit.getIdentityFromPublicKey("03BA05B26686DE8C7154C660B2B67B48561A423D1ABA532D514571AA9D821101F9");
  • sign message using private key
byte[] msg  = "abc".getBytes("utf-8");
byte[] priv = DatatypeConverter.parseHexBinary("A6911F5E9410AE84FB262E6346F39565520A29B67EDC7C7B925BBF13BDCA9DB4");
byte[] sig  = ElaSignTool.doSign(msg,priv);
  • verify message using public key
byte[] pub  = DatatypeConverter.parseHexBinary("03BA05B26686DE8C7154C660B2B67B48561A423D1ABA532D514571AA9D821101F9");
boolean ok = ElaSignTool.verify(msg,sig,pub);
  • check if an ela address is valid
boolean isValid = ElaKit.checkAddress("ELw1tzBuursLo9LnWeCATWv35hCD1kYygt");
org.elastos

Elastos Foundation

Blockchain Powered Internet

Versions

Version
0.1.1
0.1.0
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.2
0.0.1