2121
2222public class Test implements KeystoreStorage {
2323
24- static String path = "/temp " ;
24+ static String path = "/tmp " ;
2525
2626 @ Override
2727 public File getKeystoreDir () {
2828 return new File (path );
2929 }
3030
31- static {
31+ static public void init () {
3232 try {
3333 Files .createDirectories (Paths .get (path + "/wallets" ));
3434 } catch (Throwable ignored ) {
@@ -50,7 +50,8 @@ public File getKeystoreDir() {
5050 }
5151
5252
53- static public void genWallet () {
53+ static public void genBitcoinWallet () {
54+ init ();
5455 Identity identity = Identity .getCurrentIdentity ();
5556 String password = "123456" ;
5657 Wallet wallet = identity .deriveWalletByMnemonics (
@@ -61,7 +62,22 @@ static public void genWallet() {
6162 System .out .println (wallet .getAddress ());
6263 }
6364
65+ static public void genFilecoinWallet () {
66+ init ();
67+ Identity identity = Identity .getCurrentIdentity ();
68+ String password = "123456" ;
69+ Wallet wallet = identity .deriveWalletByMnemonics (
70+ ChainType .FILECOIN ,
71+ password ,
72+ MnemonicUtil .randomMnemonicCodes ()
73+ );
74+ System .out .println (wallet .getAddress ());
75+ String privateKey =wallet .exportPrivateKey ("123456" );
76+ System .out .println (privateKey );
77+ }
78+
6479 static public void signBitcoinTx () {
80+ init ();
6581 String password = "123456" ;
6682 String toAddress = "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9" ;
6783 int changeIdx = 0 ;
@@ -86,6 +102,7 @@ static public void signBitcoinTx() {
86102 }
87103
88104 static public void signTrxTx () {
105+ init ();
89106 String from = "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8" ;
90107 String to = "TF17BgPaZYbz8oxbjhriubPDsA7ArKoLX3" ;
91108 long amount = 1 ;
@@ -99,4 +116,11 @@ static public void signTrxTx() {
99116 }
100117
101118
119+
120+ public static void main (String [] args ) {
121+ genFilecoinWallet ();
122+ }
123+
124+
125+
102126}
0 commit comments