@ -0,0 +1,360 @@ |
|||
{ |
|||
"formatVersion": 1, |
|||
"database": { |
|||
"version": 3, |
|||
"identityHash": "227b9fc6314e81dc9cb31e45d4d443b1", |
|||
"entities": [ |
|||
{ |
|||
"tableName": "coins", |
|||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `coinId` TEXT, `name` TEXT, `iconResId` INTEGER NOT NULL, `show` INTEGER NOT NULL, `addressCount` INTEGER NOT NULL, `coinCode` TEXT, `exPub` TEXT, `belongTo` TEXT, `index` INTEGER NOT NULL)", |
|||
"fields": [ |
|||
{ |
|||
"fieldPath": "id", |
|||
"columnName": "id", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "coinId", |
|||
"columnName": "coinId", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "name", |
|||
"columnName": "name", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "iconResId", |
|||
"columnName": "iconResId", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "show", |
|||
"columnName": "show", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "addressCount", |
|||
"columnName": "addressCount", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "coinCode", |
|||
"columnName": "coinCode", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "exPub", |
|||
"columnName": "exPub", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "belongTo", |
|||
"columnName": "belongTo", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "index", |
|||
"columnName": "index", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
} |
|||
], |
|||
"primaryKey": { |
|||
"columnNames": [ |
|||
"id" |
|||
], |
|||
"autoGenerate": true |
|||
}, |
|||
"indices": [ |
|||
{ |
|||
"name": "index_coins_id", |
|||
"unique": false, |
|||
"columnNames": [ |
|||
"id" |
|||
], |
|||
"createSql": "CREATE INDEX `index_coins_id` ON `${TABLE_NAME}` (`id`)" |
|||
} |
|||
], |
|||
"foreignKeys": [] |
|||
}, |
|||
{ |
|||
"tableName": "addresses", |
|||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `path` TEXT, `coinId` TEXT, `addressString` TEXT, `name` TEXT, `index` INTEGER NOT NULL, `belongTo` TEXT)", |
|||
"fields": [ |
|||
{ |
|||
"fieldPath": "id", |
|||
"columnName": "id", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "path", |
|||
"columnName": "path", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "coinId", |
|||
"columnName": "coinId", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "addressString", |
|||
"columnName": "addressString", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "name", |
|||
"columnName": "name", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "index", |
|||
"columnName": "index", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "belongTo", |
|||
"columnName": "belongTo", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
} |
|||
], |
|||
"primaryKey": { |
|||
"columnNames": [ |
|||
"id" |
|||
], |
|||
"autoGenerate": true |
|||
}, |
|||
"indices": [], |
|||
"foreignKeys": [] |
|||
}, |
|||
{ |
|||
"tableName": "txs", |
|||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`txId` TEXT NOT NULL, `coinId` TEXT, `coinCode` TEXT, `amount` TEXT, `from` TEXT, `to` TEXT, `fee` TEXT, `signedHex` TEXT, `timeStamp` INTEGER NOT NULL, `memo` TEXT, `signId` TEXT, `belongTo` TEXT, PRIMARY KEY(`txId`))", |
|||
"fields": [ |
|||
{ |
|||
"fieldPath": "txId", |
|||
"columnName": "txId", |
|||
"affinity": "TEXT", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "coinId", |
|||
"columnName": "coinId", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "coinCode", |
|||
"columnName": "coinCode", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "amount", |
|||
"columnName": "amount", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "from", |
|||
"columnName": "from", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "to", |
|||
"columnName": "to", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "fee", |
|||
"columnName": "fee", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "signedHex", |
|||
"columnName": "signedHex", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "timeStamp", |
|||
"columnName": "timeStamp", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "memo", |
|||
"columnName": "memo", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "signId", |
|||
"columnName": "signId", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "belongTo", |
|||
"columnName": "belongTo", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
} |
|||
], |
|||
"primaryKey": { |
|||
"columnNames": [ |
|||
"txId" |
|||
], |
|||
"autoGenerate": false |
|||
}, |
|||
"indices": [ |
|||
{ |
|||
"name": "index_txs_txId", |
|||
"unique": false, |
|||
"columnNames": [ |
|||
"txId" |
|||
], |
|||
"createSql": "CREATE INDEX `index_txs_txId` ON `${TABLE_NAME}` (`txId`)" |
|||
} |
|||
], |
|||
"foreignKeys": [] |
|||
}, |
|||
{ |
|||
"tableName": "white_list", |
|||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `addr` TEXT, `addrName` TEXT, `coinCode` TEXT, `memo` TEXT, `belongTo` TEXT)", |
|||
"fields": [ |
|||
{ |
|||
"fieldPath": "id", |
|||
"columnName": "id", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "addr", |
|||
"columnName": "addr", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "addrName", |
|||
"columnName": "addrName", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "coinCode", |
|||
"columnName": "coinCode", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "memo", |
|||
"columnName": "memo", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "belongTo", |
|||
"columnName": "belongTo", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
} |
|||
], |
|||
"primaryKey": { |
|||
"columnNames": [ |
|||
"id" |
|||
], |
|||
"autoGenerate": true |
|||
}, |
|||
"indices": [], |
|||
"foreignKeys": [] |
|||
}, |
|||
{ |
|||
"tableName": "accounts", |
|||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `hdPath` TEXT, `exPub` TEXT, `addressLength` INTEGER NOT NULL, `isMultiSign` INTEGER NOT NULL, `coinId` INTEGER NOT NULL, FOREIGN KEY(`coinId`) REFERENCES `coins`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", |
|||
"fields": [ |
|||
{ |
|||
"fieldPath": "id", |
|||
"columnName": "id", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "hdPath", |
|||
"columnName": "hdPath", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "exPub", |
|||
"columnName": "exPub", |
|||
"affinity": "TEXT", |
|||
"notNull": false |
|||
}, |
|||
{ |
|||
"fieldPath": "addressLength", |
|||
"columnName": "addressLength", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "isMultiSign", |
|||
"columnName": "isMultiSign", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
}, |
|||
{ |
|||
"fieldPath": "coinId", |
|||
"columnName": "coinId", |
|||
"affinity": "INTEGER", |
|||
"notNull": true |
|||
} |
|||
], |
|||
"primaryKey": { |
|||
"columnNames": [ |
|||
"id" |
|||
], |
|||
"autoGenerate": true |
|||
}, |
|||
"indices": [], |
|||
"foreignKeys": [ |
|||
{ |
|||
"table": "coins", |
|||
"onDelete": "CASCADE", |
|||
"onUpdate": "NO ACTION", |
|||
"columns": [ |
|||
"coinId" |
|||
], |
|||
"referencedColumns": [ |
|||
"id" |
|||
] |
|||
} |
|||
] |
|||
} |
|||
], |
|||
"views": [], |
|||
"setupQueries": [ |
|||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", |
|||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '227b9fc6314e81dc9cb31e45d4d443b1')" |
|||
] |
|||
} |
|||
} |
@ -1,14 +1,3 @@ |
|||
{ |
|||
"BTC": "BTC.bundle_94e3c1790748ac7fc876.js", |
|||
"BCH": "BCH.bundle.js", |
|||
"ETH": "ETH.bundle_b0d7ccb0dc5138935dc7.js", |
|||
"ETC": "ETC.bundle_b0d7ccb0dc5138935dc7.js", |
|||
"DASH": "DASH.bundle.js", |
|||
"LTC": "LTC.bundle.js", |
|||
"XRP": "XRP.bundle.js", |
|||
"XZC": "XZC.bundle.js", |
|||
"DCR": "DCR.bundle.js", |
|||
"EOS": "EOS.bundle_d0f384b2cc63ac78f25e.js", |
|||
"IOST": "IOST.bundle_010b6f92f916b495faad.js", |
|||
"TRON": "TRON.bundle.js" |
|||
"BTC": "BTC.bundle_94e3c1790748ac7fc876.js" |
|||
} |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 840 B |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 813 B |
@ -1,81 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coins.BCH; |
|||
|
|||
import com.cobo.coinlib.coins.AbsDeriver; |
|||
import com.cobo.coinlib.coins.BTC.Btc; |
|||
import com.cobo.coinlib.exception.InvalidTransactionException; |
|||
import com.cobo.coinlib.interfaces.Coin; |
|||
|
|||
import org.bitcoinj.core.LegacyAddress; |
|||
import org.bitcoinj.crypto.DeterministicKey; |
|||
import org.json.JSONArray; |
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
|
|||
public class Bch extends Btc { |
|||
public Bch(Coin impl) { |
|||
super(impl); |
|||
} |
|||
|
|||
@Override |
|||
public String coinCode() { |
|||
return "BCH"; |
|||
} |
|||
|
|||
public static class Tx extends Btc.Tx { |
|||
public Tx(JSONObject metaData, String coinCode) |
|||
throws JSONException, InvalidTransactionException { |
|||
super(metaData, coinCode); |
|||
} |
|||
|
|||
@Override |
|||
protected void parseInput() throws JSONException, InvalidTransactionException { |
|||
JSONArray inputs = metaData.getJSONArray("inputs"); |
|||
StringBuilder paths = new StringBuilder(); |
|||
for (int i = 0; i < inputs.length(); i++) { |
|||
JSONObject input = inputs.getJSONObject(i); |
|||
String path = input.getString("ownerKeyPath"); |
|||
checkHdPath(path, false); |
|||
paths.append(path).append(SEPARATOR); |
|||
int index = input.optInt("index"); |
|||
if (index == 0) { |
|||
input.put("index", 0); |
|||
} |
|||
inputAmount += input.getLong("value"); |
|||
} |
|||
hdPath = paths.deleteCharAt(paths.length() - 1).toString(); |
|||
} |
|||
} |
|||
|
|||
public static class Deriver extends AbsDeriver { |
|||
|
|||
@Override |
|||
public String derive(String xPubKey, int changeIndex, int addrIndex) { |
|||
DeterministicKey address = getAddrDeterministicKey(xPubKey, changeIndex, addrIndex); |
|||
LegacyAddress addr = LegacyAddress.fromPubKeyHash(MAINNET, address.getPubKeyHash()); |
|||
return addr.toBase58(); |
|||
} |
|||
|
|||
@Override |
|||
public String derive(String xPubKey) { |
|||
return LegacyAddress.fromPubKeyHash(MAINNET, |
|||
getDeterministicKey(xPubKey).getPubKeyHash()).toBase58(); |
|||
} |
|||
} |
|||
} |
@ -1,80 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coins.DASH; |
|||
|
|||
import com.cobo.coinlib.coins.AbsDeriver; |
|||
import com.cobo.coinlib.coins.BTC.Btc; |
|||
import com.cobo.coinlib.exception.InvalidTransactionException; |
|||
import com.cobo.coinlib.interfaces.Coin; |
|||
import com.cobo.coinlib.utils.Coins; |
|||
|
|||
import org.bitcoinj.core.Base58; |
|||
import org.bitcoinj.crypto.DeterministicKey; |
|||
import org.json.JSONArray; |
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
|
|||
public class Dash extends Btc { |
|||
public Dash(Coin impl) { |
|||
super(impl); |
|||
} |
|||
|
|||
@Override |
|||
public String coinCode() { |
|||
return Coins.DASH.coinCode(); |
|||
} |
|||
|
|||
public static class Tx extends Btc.Tx { |
|||
|
|||
public Tx(JSONObject metaData, String coinCode) throws JSONException, InvalidTransactionException { |
|||
super(metaData, coinCode); |
|||
} |
|||
|
|||
@Override |
|||
protected void parseInput() throws JSONException, InvalidTransactionException { |
|||
JSONArray inputs = metaData.getJSONArray("inputs"); |
|||
StringBuilder paths = new StringBuilder(); |
|||
for (int i = 0; i < inputs.length(); i++) { |
|||
JSONObject input = inputs.getJSONObject(i); |
|||
String path = input.getString("ownerKeyPath"); |
|||
checkHdPath(path, false); |
|||
paths.append(path).append(SEPARATOR); |
|||
int index = input.optInt("index"); |
|||
if (index == 0) { |
|||
input.put("index", 0); |
|||
} |
|||
inputAmount += input.getLong("value"); |
|||
} |
|||
hdPath = paths.deleteCharAt(paths.length() - 1).toString(); |
|||
} |
|||
} |
|||
|
|||
public static class Deriver extends AbsDeriver { |
|||
|
|||
@Override |
|||
public String derive(String xPubKey, int changeIndex, int addrIndex) { |
|||
DeterministicKey address = getAddrDeterministicKey(xPubKey, changeIndex, addrIndex); |
|||
return Base58.encodeChecked(0x4c, address.getPubKeyHash()); |
|||
} |
|||
|
|||
@Override |
|||
public String derive(String xPubKey) { |
|||
return Base58.encodeChecked(0x4c, getDeterministicKey(xPubKey).getPubKeyHash()); |
|||
} |
|||
} |
|||
} |
@ -1,121 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coins.DCR; |
|||
|
|||
import com.cobo.coinlib.coins.AbsCoin; |
|||
import com.cobo.coinlib.coins.AbsDeriver; |
|||
import com.cobo.coinlib.coins.AbsTx; |
|||
import com.cobo.coinlib.exception.InvalidTransactionException; |
|||
import com.cobo.coinlib.interfaces.Coin; |
|||
import com.cobo.coinlib.utils.Coins; |
|||
|
|||
import org.bitcoinj.crypto.DeterministicKey; |
|||
import org.json.JSONArray; |
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
|
|||
import fr.cryptohash.BLAKE256; |
|||
import fr.cryptohash.Digest; |
|||
import fr.cryptohash.RIPEMD160; |
|||
|
|||
|
|||
public class Dcr extends AbsCoin implements Coin { |
|||
public Dcr(Coin impl) { |
|||
super(impl); |
|||
} |
|||
|
|||
@Override |
|||
public String coinCode() { |
|||
return Coins.DCR.coinCode(); |
|||
} |
|||
|
|||
public static class Tx extends AbsTx { |
|||
|
|||
public Tx(JSONObject object, String coinCode) throws JSONException, InvalidTransactionException { |
|||
super(object, coinCode); |
|||
} |
|||
|
|||
@Override |
|||
protected void parseMetaData() throws JSONException { |
|||
parseInput(); |
|||
to = metaData.getString("to"); |
|||
amount = metaData.getLong("amount") / Math.pow(10, decimal); |
|||
memo = metaData.optString("memo"); |
|||
fee = metaData.getLong("fee") / Math.pow(10, decimal); |
|||
} |
|||
|
|||
private void parseInput() throws JSONException { |
|||
JSONArray inputs = metaData.getJSONArray("inputs"); |
|||
for (int i = 0; i < inputs.length(); i++) { |
|||
JSONObject input = inputs.getJSONObject(i); |
|||
int index = input.optInt("outputIndex"); |
|||
if (index == 0) { |
|||
input.put("outputIndex", 0); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static class Deriver extends AbsDeriver { |
|||
|
|||
@Override |
|||
public String derive(String xPubKey, int changeIndex, int addrIndex) { |
|||
DeterministicKey address = getAddrDeterministicKey(xPubKey, changeIndex, addrIndex); |
|||
byte[] hash = blake256Ripemd160(address.getPubKey()); |
|||
return encodeChecked(hash); |
|||
} |
|||
|
|||
@Override |
|||
public String derive(String xPubKey) { |
|||
return encodeChecked(blake256Ripemd160(getDeterministicKey(xPubKey).getPubKey())); |
|||
} |
|||
|
|||
|
|||
private byte[] blake256Ripemd160(byte[] publicKey) { |
|||
Digest digestBlake256 = new BLAKE256().copy(); |
|||
digestBlake256.update(publicKey); |
|||
byte[] hash1 = digestBlake256.digest(); |
|||
|
|||
Digest digest160 = new RIPEMD160().copy(); |
|||
digest160.update(hash1); |
|||
return digest160.digest(); |
|||
} |
|||
|
|||
private String encodeChecked(byte[] payload) { |
|||
// A stringified buffer is:
|
|||
// 2 byte version + data bytes + 4 bytes check code (a truncated hash)
|
|||
|
|||
byte[] versionBytes = new byte[]{0x07, 0x3f}; |
|||
byte[] addressBytes = new byte[2 + payload.length + 4]; |
|||
addressBytes[0] = versionBytes[0]; |
|||
addressBytes[1] = versionBytes[1]; |
|||
System.arraycopy(payload, 0, addressBytes, 2, payload.length); |
|||
byte[] checksum = doubleBlake256(addressBytes, 0, payload.length + 2); |
|||
System.arraycopy(checksum, 0, addressBytes, payload.length + 2, 4); |
|||
return org.bitcoinj.core.Base58.encode(addressBytes); |
|||
} |
|||
|
|||
private byte[] doubleBlake256(byte[] data, int offset, int length) { |
|||
Digest digest = new BLAKE256().copy(); |
|||
digest.update(data, offset, length); |
|||
return digest.digest(digest.digest()); |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
@ -1,116 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coins.EOS; |
|||
|
|||
import android.text.TextUtils; |
|||
|
|||
import com.cobo.coinlib.coins.AbsCoin; |
|||
import com.cobo.coinlib.coins.AbsDeriver; |
|||
import com.cobo.coinlib.coins.AbsTx; |
|||
import com.cobo.coinlib.exception.InvalidTransactionException; |
|||
import com.cobo.coinlib.interfaces.Coin; |
|||
|
|||
import org.bitcoinj.core.Base58; |
|||
import org.bitcoinj.crypto.DeterministicKey; |
|||
import org.bouncycastle.crypto.digests.RIPEMD160Digest; |
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
|
|||
import static com.cobo.coinlib.Util.concat; |
|||
|
|||
public class Eos extends AbsCoin { |
|||
public Eos(Coin impl) { |
|||
super(impl); |
|||
} |
|||
|
|||
@Override |
|||
public String coinCode() { |
|||
return "EOS"; |
|||
} |
|||
|
|||
public static class Tx extends AbsTx { |
|||
|
|||
public Tx(JSONObject object, String coinCode) throws JSONException, InvalidTransactionException { |
|||
super(object, coinCode); |
|||
} |
|||
|
|||
@Override |
|||
protected void parseMetaData() throws JSONException { |
|||
JSONObject data = metaData.getJSONObject("data"); |
|||
to = data.getString("to"); |
|||
from = data.getString("from"); |
|||
memo = data.optString("memo"); |
|||
int decimal = data.optInt("decimal"); |
|||
if (decimal == 0) { |
|||
data.put("decimal", this.decimal); |
|||
decimal = this.decimal; |
|||
} |
|||
amount = (double) data.getLong("amount") / Math.pow(10, decimal); |
|||
fee = (double) data.optLong("fee") / Math.pow(10, decimal); |
|||
String symbol = data.optString("symbol"); |
|||
if (!TextUtils.isEmpty(symbol) && !"EOS".equals(symbol)) { |
|||
isToken = true; |
|||
tokenName = symbol; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static class Deriver extends AbsDeriver { |
|||
|
|||
@Override |
|||
public String derive(String accountXpub, int changeIndex, int addressIndex) { |
|||
DeterministicKey address = getAddrDeterministicKey(accountXpub, 0, 0); |
|||
|
|||
return getEosPubKey(address); |
|||
} |
|||
|
|||
@Override |
|||
public String derive(String xPubKey) { |
|||
return getEosPubKey(getDeterministicKey(xPubKey)); |
|||
} |
|||
|
|||
private String getEosPubKey(DeterministicKey address) { |
|||
byte[] pubkeyByte = address.getPubKey(); |
|||
byte[] csum = ripeMD160Hash(pubkeyByte); |
|||
csum = copy(csum, 0, 4); |
|||
|
|||
byte[] addy = concat(pubkeyByte, csum); |
|||
return "EOS" + Base58.encode(addy); |
|||
} |
|||
|
|||
static byte[] ripeMD160Hash(byte[] pubKey) { |
|||
RIPEMD160Digest ripemd160 = new RIPEMD160Digest(); |
|||
ripemd160.update(pubKey, 0, pubKey.length); |
|||
byte[] output = new byte[ripemd160.getDigestSize()]; |
|||
ripemd160.doFinal(output, 0); |
|||
return output; |
|||
} |
|||
|
|||
public static byte[] copy(byte[] src, int start, int length) { |
|||
byte[] c = new byte[length]; |
|||
System.arraycopy(src, start, c, 0, length); |
|||
return c; |
|||
} |
|||
|
|||
|
|||
public static byte[] copy(byte[] src, int start, byte[] dest, int dstart, int length) { |
|||
System.arraycopy(src, start, dest, dstart, length); |
|||
return dest; |
|||
} |
|||
} |
|||
} |
@ -1,47 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coins.ETC; |
|||
|
|||
import com.cobo.coinlib.coins.ETH.Eth; |
|||
import com.cobo.coinlib.exception.InvalidTransactionException; |
|||
import com.cobo.coinlib.interfaces.Coin; |
|||
import com.cobo.coinlib.utils.Coins; |
|||
|
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
|
|||
public class Etc extends Eth { |
|||
|
|||
public Etc(Coin impl) { |
|||
super(impl); |
|||
} |
|||
|
|||
@Override |
|||
public String coinCode() { |
|||
return Coins.ETC.coinCode(); |
|||
} |
|||
|
|||
public static class Tx extends Eth.Tx { |
|||
public Tx(JSONObject metaData, String coinCode) throws JSONException, InvalidTransactionException { |
|||
super(metaData, coinCode); |
|||
} |
|||
} |
|||
|
|||
public static class Deriver extends Eth.Deriver { |
|||
} |
|||
} |
@ -1,172 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coins.ETH; |
|||
|
|||
import android.text.TextUtils; |
|||
|
|||
import com.cobo.coinlib.coins.AbsCoin; |
|||
import com.cobo.coinlib.coins.AbsDeriver; |
|||
import com.cobo.coinlib.coins.AbsTx; |
|||
import com.cobo.coinlib.exception.InvalidTransactionException; |
|||
import com.cobo.coinlib.interfaces.Coin; |
|||
import com.cobo.coinlib.utils.Coins; |
|||
|
|||
import org.bitcoinj.core.ECKey; |
|||
import org.bitcoinj.crypto.DeterministicKey; |
|||
import org.bouncycastle.jcajce.provider.digest.Keccak; |
|||
import org.bouncycastle.util.encoders.Hex; |
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Arrays; |
|||
|
|||
import static com.cobo.coinlib.Util.cleanHexPrefix; |
|||
import static com.cobo.coinlib.Util.sha3String; |
|||
|
|||
public class Eth extends AbsCoin implements Coin { |
|||
|
|||
public Eth(Coin impl) { |
|||
super(impl); |
|||
} |
|||
|
|||
@Override |
|||
public String coinCode() { |
|||
return Coins.ETH.coinCode(); |
|||
} |
|||
|
|||
public static class Tx extends AbsTx { |
|||
|
|||
public Tx(JSONObject metaData, String coinCode) throws JSONException, InvalidTransactionException { |
|||
super(metaData, coinCode); |
|||
} |
|||
|
|||
private int tokenDecimal; |
|||
|
|||
@Override |
|||
protected void parseMetaData() throws InvalidTransactionException { |
|||
try { |
|||
fee = calculateDisplayFee(); |
|||
if (metaData.has("override")) { |
|||
JSONObject override = metaData.getJSONObject("override"); |
|||
tokenDecimal = override.optInt("decimals", decimal); |
|||
isToken = true; |
|||
tokenName = override.optString("tokenShortName", |
|||
metaData.optString("tokenFullName", coinCode)); |
|||
String contractAddress = override.optString("contractAddress"); |
|||
if (TextUtils.isEmpty(contractAddress)) { |
|||
throw new InvalidTransactionException("invalid contractAddress"); |
|||
} |
|||
metaData.put("contractAddress", contractAddress); |
|||
} |
|||
to = metaData.getString("to"); |
|||
amount = calculateDisplayAmount(); |
|||
memo = metaData.optString("memo"); |
|||
boolean enableMemo = false; |
|||
if (!TextUtils.isEmpty(memo) && !enableMemo) { |
|||
metaData.put("memo", ""); |
|||
} |
|||
} catch (JSONException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public double getAmount() { |
|||
if (isToken) { |
|||
return getAmountWithoutFee(); |
|||
} else { |
|||
return super.getAmount(); |
|||
} |
|||
} |
|||
|
|||
private double calculateDisplayFee() throws JSONException { |
|||
BigDecimal gasPrice = new BigDecimal(metaData.getString("gasPrice")); |
|||
BigDecimal gasLimit = new BigDecimal(metaData.getString("gasLimit")); |
|||
|
|||
return gasLimit.multiply(gasPrice) |
|||
.divide(BigDecimal.TEN.pow(decimal), Math.min(decimal, 8), BigDecimal.ROUND_HALF_UP).doubleValue(); |
|||
} |
|||
|
|||
private double calculateDisplayAmount() throws JSONException { |
|||
|
|||
int decimal = isToken ? tokenDecimal : this.decimal; |
|||
String amount = metaData.getString("value"); |
|||
BigDecimal value = new BigDecimal(amount); |
|||
return value.divide(BigDecimal.TEN.pow(decimal), Math.min(decimal, 8), BigDecimal.ROUND_HALF_UP).doubleValue(); |
|||
} |
|||
|
|||
} |
|||
|
|||
public static class Deriver extends AbsDeriver { |
|||
@Override |
|||
public String derive(String accountXpub, int changeIndex, int addrIndex) { |
|||
DeterministicKey address = getAddrDeterministicKey(accountXpub, changeIndex, addrIndex); |
|||
//decompress
|
|||
ECKey eckey = ECKey.fromPublicOnly(address.getPubKeyPoint()); |
|||
byte[] pubKey = eckey.decompress().getPubKey(); |
|||
byte[] hash = new byte[pubKey.length - 1]; |
|||
System.arraycopy(pubKey, 1, hash, 0, hash.length); |
|||
|
|||
String s = Hex.toHexString(getAddress(hash)); |
|||
|
|||
//checksum
|
|||
return toChecksumAddress(s); |
|||
} |
|||
|
|||
@Override |
|||
public String derive(String xPubKey) { |
|||
DeterministicKey key = getDeterministicKey(xPubKey); |
|||
//decompress
|
|||
ECKey eckey = ECKey.fromPublicOnly(key.getPubKey()); |
|||
|
|||
byte[] pubKey = eckey.decompress().getPubKey(); |
|||
byte[] hash = new byte[pubKey.length - 1]; |
|||
System.arraycopy(pubKey, 1, hash, 0, hash.length); |
|||
|
|||
String s = Hex.toHexString(getAddress(hash)); |
|||
|
|||
//checksum
|
|||
return toChecksumAddress(s); |
|||
} |
|||
|
|||
public static byte[] getAddress(byte[] publicKey) { |
|||
byte[] hash = new Keccak.Digest256().digest(publicKey); |
|||
return Arrays.copyOfRange(hash, hash.length - 20, hash.length); // right most 160 bits
|
|||
} |
|||
|
|||
public static String toChecksumAddress(String address) { |
|||
String lowercaseAddress = cleanHexPrefix(address).toLowerCase(); |
|||
String addressHash = cleanHexPrefix(sha3String(lowercaseAddress)); |
|||
|
|||
StringBuilder result = new StringBuilder(lowercaseAddress.length() + 2); |
|||
|
|||
result.append("0x"); |
|||
|
|||
for (int i = 0; i < lowercaseAddress.length(); i++) { |
|||
if (Integer.parseInt(String.valueOf(addressHash.charAt(i)), 16) >= 8) { |
|||
result.append(String.valueOf(lowercaseAddress.charAt(i)).toUpperCase()); |
|||
} else { |
|||
result.append(lowercaseAddress.charAt(i)); |
|||
} |
|||
} |
|||
|
|||
return result.toString(); |
|||
} |
|||
} |
|||
} |
@ -1,83 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coins.IOST; |
|||
|
|||
import com.cobo.coinlib.Util; |
|||
import com.cobo.coinlib.coins.AbsCoin; |
|||
import com.cobo.coinlib.coins.AbsDeriver; |
|||
import com.cobo.coinlib.coins.AbsTx; |
|||
import com.cobo.coinlib.exception.InvalidTransactionException; |
|||
import com.cobo.coinlib.interfaces.Coin; |
|||
import com.cobo.coinlib.utils.B58; |
|||
import com.cobo.coinlib.utils.Coins; |
|||
|
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
import org.spongycastle.util.encoders.Hex; |
|||
|
|||
public class Iost extends AbsCoin { |
|||
|
|||
public Iost(Coin impl) { |
|||
super(impl); |
|||
} |
|||
|
|||
@Override |
|||
public String coinCode() { |
|||
return Coins.IOST.coinCode(); |
|||
} |
|||
|
|||
public static class Tx extends AbsTx { |
|||
|
|||
public Tx(JSONObject object, String coinCode) throws JSONException, InvalidTransactionException { |
|||
super(object, coinCode); |
|||
} |
|||
|
|||
@Override |
|||
protected void parseMetaData() throws JSONException { |
|||
from = metaData.getString("from"); |
|||
to = metaData.getString("to"); |
|||
amount = Double.parseDouble(metaData.getString("amount")); |
|||
memo = metaData.optString("memo"); |
|||
fee = Double.parseDouble(metaData.optString("fee", "0")); |
|||
tokenName = metaData.optString("tokenName", "iost").toUpperCase(); |
|||
if (!"IOST".equals(tokenName)) { |
|||
isToken = true; |
|||
} |
|||
|
|||
} |
|||
|
|||
@Override |
|||
protected void checkHdPath() throws InvalidTransactionException { |
|||
checkHdPath(hdPath, true); |
|||
} |
|||
} |
|||
|
|||
public static class Deriver extends AbsDeriver { |
|||
@Override |
|||
public String derive(String xPubKey, int changeIndex, int addrIndex) { |
|||
String pubKeyHex = Util.pubKeyFromExtentPubKey(xPubKey).substring(2); |
|||
return new B58().encodeToString(Hex.decode(pubKeyHex)); |
|||
} |
|||
|
|||
@Override |
|||
public String derive(String xPubKey) { |
|||
String pubKeyHex = Util.pubKeyFromExtentPubKey(xPubKey).substring(2); |
|||
return new B58().encodeToString(Hex.decode(pubKeyHex)); |
|||
} |
|||
} |
|||
} |
@ -1,75 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coins.LTC; |
|||
|
|||
import com.cobo.coinlib.coins.BTC.Btc; |
|||
import com.cobo.coinlib.exception.InvalidTransactionException; |
|||
import com.cobo.coinlib.interfaces.Coin; |
|||
import com.cobo.coinlib.utils.Coins; |
|||
|
|||
import org.bitcoinj.core.Base58; |
|||
import org.bitcoinj.core.LegacyAddress; |
|||
import org.bitcoinj.crypto.DeterministicKey; |
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
|
|||
public class Ltc extends Btc { |
|||
public Ltc(Coin impl) { |
|||
super(impl); |
|||
} |
|||
|
|||
@Override |
|||
public String coinCode() { |
|||
return Coins.LTC.coinCode(); |
|||
} |
|||
|
|||
public static class Tx extends Btc.Tx { |
|||
|
|||
public Tx(JSONObject metaData, String coinCode) throws JSONException, InvalidTransactionException { |
|||
super(metaData, coinCode); |
|||
} |
|||
} |
|||
|
|||
public static class Deriver extends Btc.Deriver { |
|||
|
|||
static final boolean legacyAddress = true; |
|||
|
|||
@Override |
|||
public String derive(String xPubKey, int changeIndex, int addrIndex) { |
|||
|
|||
if (legacyAddress) { |
|||
return super.derive(xPubKey, changeIndex, addrIndex); |
|||
} |
|||
DeterministicKey address = getAddrDeterministicKey(xPubKey, changeIndex, addrIndex); |
|||
|
|||
LegacyAddress addr = LegacyAddress.fromScriptHash(MAINNET, |
|||
segWitOutputScript(address.getPubKeyHash()).getPubKeyHash()); |
|||
return Base58.encodeChecked(0x32, addr.getHash()); |
|||
} |
|||
|
|||
@Override |
|||
public String derive(String xPubKey) { |
|||
if (legacyAddress) { |
|||
return super.derive(xPubKey); |
|||
} |
|||
LegacyAddress addr = LegacyAddress.fromScriptHash(MAINNET, |
|||
segWitOutputScript(getDeterministicKey(xPubKey).getPubKeyHash()).getPubKeyHash()); |
|||
return Base58.encodeChecked(0x32, addr.getHash()); |
|||
} |
|||
} |
|||
} |
@ -1,107 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coins.TRON; |
|||
|
|||
import com.cobo.coinlib.coins.AbsCoin; |
|||
import com.cobo.coinlib.coins.AbsDeriver; |
|||
import com.cobo.coinlib.coins.AbsTx; |
|||
import com.cobo.coinlib.exception.InvalidTransactionException; |
|||
import com.cobo.coinlib.interfaces.Coin; |
|||
import com.cobo.coinlib.utils.Coins; |
|||
|
|||
import org.bitcoinj.core.Base58; |
|||
import org.bitcoinj.core.ECKey; |
|||
import org.bitcoinj.crypto.DeterministicKey; |
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
|
|||
import static com.cobo.coinlib.coins.ETH.Eth.Deriver.getAddress; |
|||
|
|||
public class Tron extends AbsCoin { |
|||
public Tron(Coin impl) { |
|||
super(impl); |
|||
} |
|||
|
|||
@Override |
|||
public String coinCode() { |
|||
return Coins.TRON.coinCode(); |
|||
} |
|||
|
|||
public static class Tx extends AbsTx { |
|||
|
|||
public Tx(JSONObject object, String coinCode) throws JSONException, InvalidTransactionException { |
|||
super(object, coinCode); |
|||
} |
|||
|
|||
@Override |
|||
protected void parseMetaData() throws JSONException { |
|||
from = metaData.getString("from"); |
|||
to = metaData.getString("to"); |
|||
fee = metaData.getInt("fee") / Math.pow(10, decimal); |
|||
amount = metaData.getLong("value") / Math.pow(10, decimal); |
|||
memo = metaData.optString("memo"); |
|||
if ((metaData.has("token") || metaData.has("contractAddress")) |
|||
&& metaData.has("override")) { |
|||
isToken = true; |
|||
JSONObject override = metaData.getJSONObject("override"); |
|||
tokenName = override.optString("tokenShortName", |
|||
metaData.optString("tokenFullName", coinCode)); |
|||
int tokenDecimals = override.optInt("decimals"); |
|||
amount = metaData.getLong("value") / Math.pow(10, tokenDecimals); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public double getAmount() { |
|||
if (isToken) { |
|||
return getAmountWithoutFee(); |
|||
} else { |
|||
return super.getAmount(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static class Deriver extends AbsDeriver { |
|||
@Override |
|||
public String derive(String accountXpub, int changeIndex, int addrIndex) { |
|||
|
|||
DeterministicKey address = getAddrDeterministicKey(accountXpub, changeIndex, addrIndex); |
|||
|
|||
ECKey eckey = ECKey.fromPublicOnly(address.getPubKeyPoint()); |
|||
byte[] pubKey = eckey.decompress().getPubKey(); |
|||
byte[] hash = new byte[pubKey.length - 1]; |
|||
System.arraycopy(pubKey, 1, hash, 0, hash.length); |
|||
|
|||
byte[] addr = getAddress(hash); |
|||
|
|||
return Base58.encodeChecked(0x41, addr); |
|||
} |
|||
|
|||
@Override |
|||
public String derive(String xPubKey) { |
|||
ECKey eckey = ECKey.fromPublicOnly(getDeterministicKey(xPubKey).getPubKeyPoint()); |
|||
byte[] pubKey = eckey.decompress().getPubKey(); |
|||
byte[] hash = new byte[pubKey.length - 1]; |
|||
System.arraycopy(pubKey, 1, hash, 0, hash.length); |
|||
|
|||
byte[] addr = getAddress(hash); |
|||
|
|||
return Base58.encodeChecked(0x41, addr); |
|||
} |
|||
} |
|||
} |
@ -1,75 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coins.XRP; |
|||
|
|||
import com.cobo.coinlib.coins.AbsCoin; |
|||
import com.cobo.coinlib.coins.AbsDeriver; |
|||
import com.cobo.coinlib.coins.AbsTx; |
|||
import com.cobo.coinlib.exception.InvalidTransactionException; |
|||
import com.cobo.coinlib.interfaces.Coin; |
|||
import com.cobo.coinlib.utils.B58; |
|||
import com.cobo.coinlib.utils.Coins; |
|||
|
|||
import org.bitcoinj.crypto.DeterministicKey; |
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
|
|||
public class Xrp extends AbsCoin implements Coin { |
|||
public static final String DEFAULT_ALPHABET = "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"; |
|||
|
|||
public Xrp(Coin impl) { |
|||
super(impl); |
|||
} |
|||
|
|||
@Override |
|||
public String coinCode() { |
|||
return Coins.XRP.coinCode(); |
|||
} |
|||
|
|||
public static class Tx extends AbsTx { |
|||
|
|||
public Tx(JSONObject object, String coinCode) throws JSONException, InvalidTransactionException { |
|||
super(object, coinCode); |
|||
} |
|||
|
|||
@Override |
|||
protected void parseMetaData() throws JSONException { |
|||
to = metaData.getString("to"); |
|||
amount = metaData.getLong("amount") / Math.pow(10, decimal); |
|||
memo = metaData.optString("memo"); |
|||
fee = metaData.getLong("fee") / Math.pow(10, decimal); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
public static class Deriver extends AbsDeriver { |
|||
|
|||
@Override |
|||
public String derive(String xPubKey, int changeIndex, int addrIndex) { |
|||
DeterministicKey address = getAddrDeterministicKey(xPubKey, changeIndex, addrIndex); |
|||
return new B58(DEFAULT_ALPHABET).encodeToStringChecked(address.getPubKeyHash(), 0); |
|||
} |
|||
|
|||
@Override |
|||
public String derive(String xPubKey) { |
|||
return new B58(DEFAULT_ALPHABET) |
|||
.encodeToStringChecked(getDeterministicKey(xPubKey).getPubKeyHash(), 0); |
|||
} |
|||
} |
|||
} |
@ -1,83 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coins.XZC; |
|||
|
|||
import com.cobo.coinlib.coins.AbsCoin; |
|||
import com.cobo.coinlib.coins.AbsDeriver; |
|||
import com.cobo.coinlib.coins.AbsTx; |
|||
import com.cobo.coinlib.exception.InvalidTransactionException; |
|||
import com.cobo.coinlib.interfaces.Coin; |
|||
import com.cobo.coinlib.utils.Coins; |
|||
|
|||
import org.bitcoinj.core.Base58; |
|||
import org.bitcoinj.crypto.DeterministicKey; |
|||
import org.json.JSONArray; |
|||
import org.json.JSONException; |
|||
import org.json.JSONObject; |
|||
|
|||
public class Xzc extends AbsCoin implements Coin { |
|||
public Xzc(Coin impl) { |
|||
super(impl); |
|||
} |
|||
|
|||
@Override |
|||
public String coinCode() { |
|||
return Coins.XZC.coinCode(); |
|||
} |
|||
|
|||
public static class Tx extends AbsTx { |
|||
|
|||
public Tx(JSONObject object, String coinCode) throws JSONException, InvalidTransactionException { |
|||
super(object, coinCode); |
|||
} |
|||
|
|||
@Override |
|||
protected void parseMetaData() throws JSONException { |
|||
parseInput(); |
|||
to = metaData.getString("to"); |
|||
amount = metaData.getLong("amount") / Math.pow(10, decimal); |
|||
memo = metaData.optString("memo"); |
|||
fee = metaData.getLong("fee") / Math.pow(10, decimal); |
|||
} |
|||
|
|||
private void parseInput() throws JSONException { |
|||
JSONArray inputs = metaData.getJSONArray("inputs"); |
|||
for (int i = 0; i < inputs.length(); i++) { |
|||
JSONObject input = inputs.getJSONObject(i); |
|||
int index = input.optInt("outputIndex"); |
|||
if (index == 0) { |
|||
input.put("outputIndex", 0); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static class Deriver extends AbsDeriver { |
|||
|
|||
@Override |
|||
public String derive(String xPubKey, int changeIndex, int addrIndex) { |
|||
DeterministicKey address = getAddrDeterministicKey(xPubKey, changeIndex, addrIndex); |
|||
return Base58.encodeChecked(0x52, address.getPubKeyHash()); |
|||
} |
|||
|
|||
@Override |
|||
public String derive(String xPubKey) { |
|||
return Base58.encodeChecked(0x52, getDeterministicKey(xPubKey).getPubKeyHash()); |
|||
} |
|||
} |
|||
} |
@ -1,50 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coin; |
|||
|
|||
import com.cobo.coinlib.coins.BCH.Bch; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
@SuppressWarnings("ALL") |
|||
public class BchTest { |
|||
@Test |
|||
public void deriveAddress() { |
|||
String[] addr = new String[] { |
|||
"1HXQeKa8YSg1bEoToLqxXcHfm4Wrt4qk3V", |
|||
"18ZyEqa4ioSiTztN5zHRNoQCr5ZYtMNTjJ", |
|||
"18xv4x9EJzCQ8JGQWdBELL8tJUD7BHNYkf", |
|||
"1CGn89GG6o6aLSotHc1YZWoJ6jnKaCiWcH", |
|||
"16ruo7A9NGzqwpdatMMKaE1yWA6cfKXmrU", |
|||
"1C5QXNRmNVdEyh91nSrKp66TS1tkaFn5Jy", |
|||
"1Nk2jDqbMbxQNUcgRw17eiByUBw7s1VbC2", |
|||
"1NYx23tK96Utp75rXZGbY3YJfAGqjBdVhn", |
|||
"1EVdGw9JLbSFLaRHrWrQp7ULWM4px51725", |
|||
"19emQ5tpdoYDKd3aia7wo9PQtwej88bpsz", |
|||
"1JBKtGPGXPFb3pDeK1cF8czdgvYMzaxyE5" |
|||
}; |
|||
String pubKey = "xpub6CjD9XYc1hEKcAMsSasAA87Mw8bSUr6WQKrJ1ErLofJPP9sxeZ3sh1dH2S5ywQTRNrXsfXzT686jJNdX2m9KhvMDh4eQM9AdSkkQLLMbDG6"; |
|||
for (int i = 0 ; i < addr.length; i++) { |
|||
String address = new Bch.Deriver().derive(pubKey,0,i); |
|||
assertEquals(address,addr[i]); |
|||
} |
|||
} |
|||
|
|||
} |
@ -1,60 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coin; |
|||
|
|||
import com.cobo.coinlib.coins.DASH.Dash; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
@SuppressWarnings("ALL") |
|||
public class DashTest { |
|||
@Test |
|||
public void deriveAddress() { |
|||
String[] addr = new String[] { |
|||
"XciiKrSHgdFkuL9FTT31qRfTPNUVxX4sPc", |
|||
"XgTmuNhRLoj4F75TqboUgZQVQ37HCgW9Hf", |
|||
"Xpj2zS65KN6r792TQKuAMeJpLMdknrjo1y", |
|||
"Xb9LAffWjcxTCN5GMj5kbZiqN5g7nnkgrv", |
|||
"XyAT2tRaXhdZ4JvvB44Jy9S4qd6JurzaVo", |
|||
"XntqLKJvZbkauFvGLWHsGNMh51K5eiHvHT", |
|||
"XuMqWDM3eabLrze4hnLDtwvzBfQVSNjdqk", |
|||
"Xj3Q7zDq3BYmiPNHrwMgtPNgSKYQyQTs97", |
|||
"XmWeKAdw3DPcFvRFhro8brzhpqPoxvGdny", |
|||
"XfYy4fYEXa6ikpfzsSZS537yjoN3Mhstsv", |
|||
"XyuGNJoxmUiA1unZ7JKiG2g5WS69sDKFBP", |
|||
}; |
|||
String pubKey = "xpub6DTnbXgbPo6mrRhgim9sg7Jp571onenuioxgfSDJEREH7wudyDQMDSoTdLQiYq3tbvZVkzcPe7nMgL7mbSixQQcShekfhKt3Wdx6dE8MHCk"; |
|||
for (int i = 0 ; i < addr.length; i++) { |
|||
String address = new Dash.Deriver().derive(pubKey,0,i); |
|||
assertEquals(address,addr[i]); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -1,60 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coin; |
|||
|
|||
import com.cobo.coinlib.coins.DCR.Dcr; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
@SuppressWarnings("ALL") |
|||
public class DcrTest { |
|||
@Test |
|||
public void deriveAddress() { |
|||
String[] addr = new String[] { |
|||
"DsYvV7Q6ymU2WFzBFdVzNyUk7UXAE2dVyYd", |
|||
"DsbTLcGY9NHNqVvQZrJyXLcLN76SVrzBodq", |
|||
"DsTznosWuFjz94pjTKoAaEWd8LUVdCYfBfc", |
|||
"DsWzdC3CtWPy5ZqY7pTQH35Gm5JhH9mMe2c", |
|||
"DsbWz3eYSPRJk8DnehixbaDAXcVhUdz4p9u", |
|||
"DsmpowTXxpUxYwtwHgSHoixsCBcJ4gZZCZ7", |
|||
"Dsf2hAR1ZainZdRFY4fWi1ZM6vPJevsuXfn", |
|||
"DsSHLUANtfo82zVyLiTgi6SWQZdgSXAYrAc", |
|||
"Dsa76GyVEETpToSvWATPUtiXSpPbNmQHwg1", |
|||
"DsiC8hxMC2ApnouYUwMK1L4c3wbHezq5Gwb", |
|||
"DsgKnFzMq6kz4JWYWfaywo3LNhMBhJZZsDS", |
|||
}; |
|||
String pubKey = "xpub6BmQYH48mM1hm8B2TDXg7oDfa7dZfHVgi7pWFMsmSuJ3rVwi2YEgjZMN1cBFQtieHPgmoY3YQx5G85XyxMvppPxJToxmWjo64gaNutTn6iw"; |
|||
for (int i = 0 ; i < addr.length; i++) { |
|||
String address = new Dcr.Deriver().derive(pubKey,0,i); |
|||
assertEquals(address,addr[i]); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -1,46 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coin; |
|||
|
|||
import com.cobo.coinlib.coins.EOS.Eos; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
@SuppressWarnings("ALL") |
|||
public class EosTest { |
|||
@Test |
|||
public void deriveAddress() { |
|||
String pubKey = "xpub6BffWuUvhRpycrEq9H2gQDNT1xtzu2pfNvaf2j6JMxErTFbwAX7yaL5hCocYJwaKxmYgpNuoXkGFKHQv2brE1XEmX1aneH3AHtUrR8tMV6H"; |
|||
String address = new Eos.Deriver().derive(pubKey,0,0); |
|||
|
|||
assertEquals(address,"EOS86B1XBB2B7u3QcdM5tuuTdRMLFfVDzsTcjHvDqcFq78MSstUxp"); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -1,60 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coin; |
|||
|
|||
import com.cobo.coinlib.coins.ETC.Etc; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
@SuppressWarnings("ALL") |
|||
public class EtcTest { |
|||
@Test |
|||
public void deriveAddress() { |
|||
String[] addr = new String[] { |
|||
"0xff1e8f0F67b9C9DEA103ca988831DD9C54acA876", |
|||
"0x95662DfB520aaBE3B3E550675F90Ea05d52ecB5D", |
|||
"0x50a577fdd4ac9d2e2711C0b9887E518FfE1879d5", |
|||
"0xf00A5c61d7411D1Cb8231e9618b7851B4243092c", |
|||
"0x4a9B9e31EFbBade790725CE31F257f0d7D7b2f2c", |
|||
"0xaEE81b0b6b7c409dbB3cA2839f91C172E75Ab781", |
|||
"0xD697eC336A037B047c397464C354982b16fa784B", |
|||
"0x2046CfE33bb5B65A183414FCCB9CB9022dff9dA1", |
|||
"0xF8F353e88F761faa2a5f721A5eCF71Dcd180c93f", |
|||
"0x5c03CC3a68be5e41c7ceBEf47939b6d387E4c5E6", |
|||
"0x95554E6679EA8E8681ceB539C733dEa9F28db119", |
|||
}; |
|||
String pubKey = "xpub6BoGYciy75JfrWWm1yJJctrCnEft6RtyECCjHDuhACfmShsSbcSp5ceAZzx1YpMtLfWHCbG6bKqEH9uoUCbvMWAkjSMkMeVuYYf23nWd76X"; |
|||
for (int i = 0 ; i < addr.length; i++) { |
|||
String address = new Etc.Deriver().derive(pubKey,0,i); |
|||
assertEquals(address,addr[i]); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -1,60 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coin; |
|||
|
|||
import com.cobo.coinlib.coins.ETH.Eth; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
@SuppressWarnings("ALL") |
|||
public class EthTest { |
|||
@Test |
|||
public void deriveAddress() { |
|||
String[] addr = new String[] { |
|||
"0xE410157345be56688F43FF0D9e4B2B38Ea8F7828", |
|||
"0xEEACb7a5e53600c144C0b9839A834bb4b39E540c", |
|||
"0xA116800A72e56f91cF1677D40C9984f9C9f4B2c7", |
|||
"0x4826BadaBC9894B3513e23Be408605611b236C0f", |
|||
"0x8a1503beb17Ef02cC4Ff288b0A73583c4ce547c7", |
|||
"0x996c7a5c9001da0401B61aD68EFd2424633F728E", |
|||
"0xcAC3561d0b4Bec860ADCEBD70f8E6a8A5D45D752", |
|||
"0x7173684414e3a9d5347e5d73b1E8718f3020A296", |
|||
"0x4AAb5aD4FF70D7388182068a0B74BEEBA28B5068", |
|||
"0x824C70B0000Abf51F6db46284dC217579f53f86a", |
|||
"0x56FA9453B22867E0292301b68C2A737D8879441B", |
|||
}; |
|||
String pubKey = "xpub6CNhtuXAHDs84AhZj5ALZB6ii4sP5LnDXaKDSjiy6kcBbiysq89cDrLG29poKvZtX9z4FchZKTjTyiPuDeiFMUd1H4g5zViQxt4tpkronJr"; |
|||
for (int i = 0 ; i < addr.length; i++) { |
|||
String address = new Eth.Deriver().derive(pubKey,0,i); |
|||
assertEquals(address,addr[i]); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -1,46 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coin; |
|||
|
|||
import com.cobo.coinlib.coins.IOST.Iost; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
@SuppressWarnings("ALL") |
|||
public class IostTest { |
|||
@Test |
|||
public void deriveAddress() { |
|||
String pubKey = "xpub6GhXKqoStzyfom3kNWLzMFhLzir4GgPXnzwYMwurCWizsq2yXvZRHJJBny1hzA1YsepvGC9L3dSYPDY3wkuahqDsbK36cHKY4LMtV8DnARm"; |
|||
String address = new Iost.Deriver().derive(pubKey); |
|||
|
|||
assertEquals(address,"4guFd1weqq2Nvfxt6EDSfztUjp44trRzfJMqXumJ3qRt"); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -1,50 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coin; |
|||
|
|||
import com.cobo.coinlib.coins.LTC.Ltc; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
@SuppressWarnings("ALL") |
|||
public class LtcTest { |
|||
@Test |
|||
public void deriveAddress() { |
|||
String[] addr = new String[] { |
|||
"3DYRx8E2vK8KaXA9LJ21vV4wGL4hmRYmCL", |
|||
"3Qg4Jb6GJM2vk4eDwiyouPQRAukVa5Mbk7", |
|||
"3FnRAxvQm2qbAYSWoQnv2Jb1jqruYtFhMr", |
|||
"3NAwgFJy5nuMpguT4RM1t2niQe4GDLbU1r", |
|||
"3AQR2S4tpfDMPQzj44WC6rcHh5ZbYdBcWt", |
|||
"3QkyucsqatrXJHgLoYK7WiHu8BQeBhjuXT", |
|||
"3KngFdv9BNwYoAY7uawRs49R1dWwhJM5mD", |
|||
"3PgjwKnwxgPzbPbTarLpxCx6WzYufC5DEB", |
|||
"3PHP2LRaPoiJYkWt9q6Zf2KJZdonarZVzv", |
|||
"3LARJepdkdgcByt7FrKyzBovraY8GHeXht", |
|||
"3CAzK2RGXrCMoerQ1UFdmUHDyw5t4QcR33" |
|||
}; |
|||
String pubKey = "xpub6CKt97v4gEsG4FG9E4hEotEUtjmW8rAvVcUJ4jsmdrB437WBZnK8gs8ktzaFQHe9i7NqzcAUkc5SeNXsVoYfVNxd1AwDgbw2up8UdMWq91B"; |
|||
for (int i = 0 ; i < addr.length; i++) { |
|||
String address = new Ltc.Deriver().derive(pubKey,0,i); |
|||
assertEquals(address,addr[i]); |
|||
} |
|||
} |
|||
|
|||
} |
@ -1,60 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coin; |
|||
|
|||
import com.cobo.coinlib.coins.TRON.Tron; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
@SuppressWarnings("ALL") |
|||
public class TronTest { |
|||
@Test |
|||
public void deriveAddress() { |
|||
String[] addr = new String[] { |
|||
"TYgXziK4zH4T5dchXFBseTFUpZ8kty6oQy", |
|||
"TTgPTW6oaxmRnKz1xFT2qSHx3QNEpP2jZ6", |
|||
"TWD5uP9gDo9QJcYhvoN4u4jS4b9pHV25ow", |
|||
"TTrMEb1R2iUba67yygVVzu8ny6F1R3NbaE", |
|||
"TAGkxJfAd5Xy4D6PL76HAH4WM9W7VVpCDf", |
|||
"TGAnfDpv8GhTmi2WXbvQG7LPGguX5cuMcG", |
|||
"TXSEwZGP5JDZmU9z75SHBMY1GsB7HCjWyD", |
|||
"TB2ibqfKPNxHEqQHHmVUPfVgNGEtXkJ8NL", |
|||
"TSbt9gkbJriTUXmUxgVBLxNFwWwx6e4qTw", |
|||
"TNLvDnx9jECDPTRq31KaxPkMX4zaMLQeVC", |
|||
"TSzi8byHgnEbiHo8h4X5rkcmFXxM3wpZqH", |
|||
}; |
|||
String pubKey = "xpub6BmQYH48mM1hm8B2TDXg7oDfa7dZfHVgi7pWFMsmSuJ3rVwi2YEgjZMN1cBFQtieHPgmoY3YQx5G85XyxMvppPxJToxmWjo64gaNutTn6iw"; |
|||
for (int i = 0 ; i < addr.length; i++) { |
|||
String address = new Tron.Deriver().derive(pubKey,0,i); |
|||
assertEquals(address,addr[i]); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -1,60 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coin; |
|||
|
|||
import com.cobo.coinlib.coins.XRP.Xrp; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
@SuppressWarnings("ALL") |
|||
public class XrpTest { |
|||
@Test |
|||
public void deriveAddress() { |
|||
String[] addr = new String[] { |
|||
"rndm7RphBZG6CpZvKcG9AjoFbSvcKhwLCx", |
|||
"rrBD4sBsxrpzbohAEYWH4moPSsoxupWLA", |
|||
"rsc38kSbRZ74VjiNa8CG8xtkdqw2AWaXBb", |
|||
"r4Mh3Hdvk1UJJSs8tjkz9qnbxNyMD5qhYz", |
|||
"rsR6GtwgEtcJRaMrW2cNx8nwNqFovnJ32C", |
|||
"rhzrij6yt1wCwRAFgQK5VqxyxyhbNw7QR9", |
|||
"rNLCXobmiL4LbQkbjFJCWSW6XQm8XDLoCq", |
|||
"rKaNnXijwXQhyWegPkmUYchJzAxgKQjry9", |
|||
"rJ1gcRd2w38wwFNdSiqqVEuf4jYHU1fpP1", |
|||
"rE8fnyfbtdwkbumCm3aRR5dWcTHvS6pnWt", |
|||
"rLJYeuBpLdo6CY3xhc3SWt7hzYS6votewa", |
|||
}; |
|||
String pubKey = "xpub6C438jHkPCDoEy5jAH4a9hBtYrcprSwGvEA8L5HNhqDyJa1WZPpZXj9DNNtsRjcHxzsuZJq18sMSkbmqYKqpDacP8aMSK63ExzX2bPoMdAo"; |
|||
for (int i = 0 ; i < addr.length; i++) { |
|||
String address = new Xrp.Deriver().derive(pubKey,0,i); |
|||
assertEquals(address,addr[i]); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -1,60 +0,0 @@ |
|||
/* |
|||
* Copyright (c) 2020 Cobo |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.cobo.coinlib.coin; |
|||
|
|||
import com.cobo.coinlib.coins.XZC.Xzc; |
|||
|
|||
import org.junit.Test; |
|||
|
|||
import static org.junit.Assert.assertEquals; |
|||
|
|||
@SuppressWarnings("ALL") |
|||
public class XzcTest { |
|||
@Test |
|||
public void deriveAddress() { |
|||
String[] addr = new String[] { |
|||
"aJtu4Ztv64yCUZYm9YzQ7b3Hyrii2foaj8", |
|||
"aJJvE5kRvBJXJWeBcxScAf2ABr4vZVCotp", |
|||
"aGQC2rasPV2tiJnFJTqbevAniozqZDPpcA", |
|||
"a6pzbbDbqgCbKupySGuVWX2QewCGcSNFac", |
|||
"a3fY53SF4CdKeWAwMcUMQMjf7Y9b9tcxqS", |
|||
"aAFzem9L6FTT6peetFMoinJVeaCE2YZWDR", |
|||
"aNZUbMNuKEKxNSKvXCdNHt8kUTZoRQ8PM2", |
|||
"a6sFxJEsvwFvKCdaxhjGf1LSWYHTAfBwEE", |
|||
"aGcTa2jiSkyFLVGsLjtJZG5kCYxtWbbUhB", |
|||
"a2gcBybNBzDqsbAU5S78ug8GUKrnm1STwS", |
|||
"aBCFtxBN915aLPYbCADQULzUv4qYiXNW3X", |
|||
}; |
|||
String pubKey = "xpub6CKMZBhyfgYMeK7UuVCwF56BXsm1kVbUQwmB7bDU2i2cGx2VXNwR7Z5tnGsuZbjc35LQvhyZJasrX12adMdAqtFno9fLJJxSksPDU7W3SEk"; |
|||
for (int i = 0 ; i < addr.length; i++) { |
|||
String address = new Xzc.Deriver().derive(pubKey,0,i); |
|||
assertEquals(address,addr[i]); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|