diff --git a/README.md b/README.md index 96034f3..02d4fb3 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ # tokencore介绍 -##### 区块链钱包后台核心组件,支持BTC,OMNI,ETH,ERC20,TRX,TRC20,BCH,BSV,DOGE,DASH,LTC +##### 区块链钱包后台核心组件,支持BTC,OMNI,ETH,ERC20,TRX,TRC20,BCH,BSV,DOGE,DASH,LTC,FILECOIN # tokencore使用方式 diff --git a/README_en.md b/README_en.md index 8a2f760..7b1156e 100644 --- a/README_en.md +++ b/README_en.md @@ -38,7 +38,7 @@ If you need the [java-wallet](https://github.com/paipaipaipai/java-wallet) walle # tokencore introduction -##### The core components of the blockchain wallet backend, support BTC, OMNI, ETH, ERC20, TRX, TRC20, BCH, BSV, DOGE, DASH, LTC +##### The core components of the blockchain wallet backend, support BTC, OMNI, ETH, ERC20, TRX, TRC20, BCH, BSV, DOGE, DASH, LTC,FILECOIN # tokencore usage diff --git a/build.gradle b/build.gradle index f21bf63..6d43a18 100644 --- a/build.gradle +++ b/build.gradle @@ -37,8 +37,7 @@ dependencies { // compile group: 'com.google.protobuf', name: 'protobuf-lite', version: '3.0.1' // compile 'com.google.protobuf:protobuf-java:3.5.1' compile 'org.json:json:20170516' - annotationProcessor 'org.projectlombok:lombok:1.18.2' - compileOnly 'org.projectlombok:lombok:1.18.2' + compile 'org.slf4j:slf4j-simple:1.6.6' compile 'com.github.paipaipaipai:FilecoinJ:0.0.1' compile 'com.google.protobuf:protobuf-java:3.11.0' @@ -48,6 +47,8 @@ dependencies { compile 'com.google.guava:guava:28.0-jre' +// compile 'com.madgag.spongycastle:core:1.58.0.0' + compile 'io.grpc:grpc-stub:1.36.0' } diff --git a/src/main/java/org/consenlabs/tokencore/wallet/Identity.java b/src/main/java/org/consenlabs/tokencore/wallet/Identity.java index 7a21219..4fab14c 100755 --- a/src/main/java/org/consenlabs/tokencore/wallet/Identity.java +++ b/src/main/java/org/consenlabs/tokencore/wallet/Identity.java @@ -195,7 +195,7 @@ public List deriveWalletsByMnemonics(List chainTypes, String pas wallet = deriveTronWallet(mnemonics, password); break; case ChainType.FILECOIN: - wallet = deriveTronWallet(mnemonics, password); + wallet = deriveFilecoinWallet(mnemonics, password); break; default: throw new TokenException(String.format("Doesn't support deriving %s wallet", chainType)); diff --git a/src/main/java/org/consenlabs/tokencore/wallet/address/FilecoinAddressCreator.java b/src/main/java/org/consenlabs/tokencore/wallet/address/FilecoinAddressCreator.java index 06fd548..4b3527f 100644 --- a/src/main/java/org/consenlabs/tokencore/wallet/address/FilecoinAddressCreator.java +++ b/src/main/java/org/consenlabs/tokencore/wallet/address/FilecoinAddressCreator.java @@ -2,7 +2,7 @@ import cn.hutool.core.codec.Base32; import cn.hutool.core.util.HexUtil; -import org.bitcoinj.core.ECKey; +import com.filecoinj.crypto.ECKey; import org.consenlabs.tokencore.foundation.utils.NumericUtil; import ove.crypto.digest.Blake2b; @@ -29,13 +29,13 @@ private String fromECKey(ECKey key) { @Override public String fromPrivateKey(String prvKeyHex) { - ECKey key = ECKey.fromPrivate(NumericUtil.hexToBytes(prvKeyHex), false); + ECKey key = ECKey.fromPrivate(NumericUtil.hexToBytes(prvKeyHex)); return fromECKey(key); } @Override public String fromPrivateKey(byte[] prvKeyBytes) { - ECKey key = ECKey.fromPrivate(prvKeyBytes, false); + ECKey key = ECKey.fromPrivate(prvKeyBytes); return fromECKey(key); } } diff --git a/src/test/java/org/consenlabs/tokencore/Test.java b/src/test/java/org/consenlabs/tokencore/Test.java index c7cc2c2..bd882f7 100644 --- a/src/test/java/org/consenlabs/tokencore/Test.java +++ b/src/test/java/org/consenlabs/tokencore/Test.java @@ -21,14 +21,14 @@ public class Test implements KeystoreStorage { - static String path = "/temp"; + static String path = "/tmp"; @Override public File getKeystoreDir() { return new File(path); } - static { + static public void init() { try { Files.createDirectories(Paths.get(path + "/wallets")); } catch (Throwable ignored) { @@ -50,7 +50,8 @@ public File getKeystoreDir() { } - static public void genWallet() { + static public void genBitcoinWallet() { + init(); Identity identity = Identity.getCurrentIdentity(); String password = "123456"; Wallet wallet = identity.deriveWalletByMnemonics( @@ -61,7 +62,22 @@ static public void genWallet() { System.out.println(wallet.getAddress()); } + static public void genFilecoinWallet() { + init(); + Identity identity = Identity.getCurrentIdentity(); + String password = "123456"; + Wallet wallet = identity.deriveWalletByMnemonics( + ChainType.FILECOIN, + password, + MnemonicUtil.randomMnemonicCodes() + ); + System.out.println(wallet.getAddress()); + String privateKey=wallet.exportPrivateKey("123456"); + System.out.println(privateKey); + } + static public void signBitcoinTx() { + init(); String password = "123456"; String toAddress = "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9"; int changeIdx = 0; @@ -86,6 +102,7 @@ static public void signBitcoinTx() { } static public void signTrxTx() { + init(); String from = "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8"; String to = "TF17BgPaZYbz8oxbjhriubPDsA7ArKoLX3"; long amount = 1; @@ -99,4 +116,11 @@ static public void signTrxTx() { } + + public static void main(String[] args) { + genFilecoinWallet(); + } + + + }