From 4d16261fcf44e837817b8b862f019f582065c994 Mon Sep 17 00:00:00 2001 From: zhangchunlin Date: Sun, 5 Apr 2020 17:37:50 +0800 Subject: [PATCH] add code --- .../java/top/andnux/wallet/ExampleUnitTest.java | 17 +++++++++++++++-- .../wallet/bos/services/BosWalletService.kt | 2 +- .../wallet/eos/services/EosWalletService.kt | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/test/java/top/andnux/wallet/ExampleUnitTest.java b/app/src/test/java/top/andnux/wallet/ExampleUnitTest.java index 0228da2..b357a47 100644 --- a/app/src/test/java/top/andnux/wallet/ExampleUnitTest.java +++ b/app/src/test/java/top/andnux/wallet/ExampleUnitTest.java @@ -1,7 +1,14 @@ package top.andnux.wallet; +import com.google.gson.Gson; + import org.junit.Test; +import java.util.ServiceLoader; + +import top.andnux.wallet.base.WalletAccount; +import top.andnux.wallet.base.services.WalletService; + import static org.junit.Assert.*; /** @@ -11,7 +18,13 @@ */ public class ExampleUnitTest { @Test - public void addition_isCorrect() { - assertEquals(4, 2 + 2); + public void addition_isCorrect() throws Exception{ + ServiceLoader services = ServiceLoader.load(WalletService.class); + for (WalletService service : services) { + System.out.println(service.chainName()); + WalletAccount account = service.createAccount(); + String json = new Gson().toJson(account); + System.out.println(json); + } } } \ No newline at end of file diff --git a/bos/src/main/java/top/andnux/wallet/bos/services/BosWalletService.kt b/bos/src/main/java/top/andnux/wallet/bos/services/BosWalletService.kt index b11a59b..f9dff7e 100644 --- a/bos/src/main/java/top/andnux/wallet/bos/services/BosWalletService.kt +++ b/bos/src/main/java/top/andnux/wallet/bos/services/BosWalletService.kt @@ -19,7 +19,7 @@ class BosWalletService : WalletService { @Throws(Exception::class) override fun createAccount(): WalletAccount { val mnemonic = ChainUtil.genMnemonic(Words.TWELVE) - val privateKey = BosPrivateKey(ChainUtil.genECKey(mnemonic, "").privKeyBytes) + val privateKey = BosPrivateKey(ChainUtil.genECKey(mnemonic, "m/44'/194'/0'/0/0").privKeyBytes) return WalletAccount(privateKey = privateKey.toWif(), publicKey = privateKey.publicKey.toString(), mnemonic = mnemonic); diff --git a/eos/src/main/java/top/andnux/wallet/eos/services/EosWalletService.kt b/eos/src/main/java/top/andnux/wallet/eos/services/EosWalletService.kt index 3e32691..b59e13b 100644 --- a/eos/src/main/java/top/andnux/wallet/eos/services/EosWalletService.kt +++ b/eos/src/main/java/top/andnux/wallet/eos/services/EosWalletService.kt @@ -20,7 +20,7 @@ class EosWalletService : WalletService { @Throws(Exception::class) override fun createAccount(): WalletAccount { val mnemonic = ChainUtil.genMnemonic(Words.TWELVE) - val privateKey = EosPrivateKey(ChainUtil.genECKey(mnemonic, "").privKeyBytes) + val privateKey = EosPrivateKey(ChainUtil.genECKey(mnemonic, "m/44'/194'/0'/0/0").privKeyBytes) return WalletAccount(privateKey = privateKey.toWif(), publicKey = privateKey.publicKey.toString(), mnemonic = mnemonic);