Skip to content

Commit

Permalink
add code
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchunlin committed Apr 5, 2020
1 parent 7ea02df commit 4d16261
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions app/src/test/java/top/andnux/wallet/ExampleUnitTest.java
Original file line number Diff line number Diff line change
@@ -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.*;

/**
Expand All @@ -11,7 +18,13 @@
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
public void addition_isCorrect() throws Exception{
ServiceLoader<WalletService> 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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4d16261

Please sign in to comment.