File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=" true" type =" JAVA_MODULE" version =" 4" >
3+ <component name =" NewModuleRootManager" LANGUAGE_LEVEL =" JDK_1_8" >
4+ <output url =" file://$MODULE_DIR$/target/classes" />
5+ <output-test url =" file://$MODULE_DIR$/target/test-classes" />
6+ <content url =" file://$MODULE_DIR$" >
7+ <sourceFolder url =" file://$MODULE_DIR$/src/main/java" isTestSource =" false" />
8+ <sourceFolder url =" file://$MODULE_DIR$/src/test/java" isTestSource =" true" />
9+ <excludeFolder url =" file://$MODULE_DIR$/target" />
10+ </content >
11+ <orderEntry type =" inheritedJdk" />
12+ <orderEntry type =" sourceFolder" forTests =" false" />
13+ <orderEntry type =" library" name =" Maven: com.google.code.gson:gson:2.8.0" level =" project" />
14+ </component >
15+ </module >
Original file line number Diff line number Diff line change 1313import multichain .command .builders .QueryBuilderAddress ;
1414import multichain .object .Address ;
1515import multichain .object .BalanceAsset ;
16+ import multichain .object .KeyPair ;
1617import multichain .object .MultiBalance ;
1718import multichain .object .formatters .AddressFormatter ;
1819import multichain .object .formatters .BalanceFormatter ;
@@ -335,5 +336,14 @@ public final static Address validateAddress(String stringAddress) throws Multich
335336 return address ;
336337 }
337338
339+ /**
340+ * Generate blockchian address and corresponding public and private key. Used for external key management.
341+ * @return KeyPair object with data
342+ * @throws MultichainException
343+ */
344+ public static KeyPair createKeyPairs () throws MultichainException {
345+ String keyPair = executeCreateKeyPairs ();
346+ return AddressFormatter .formatKeyPair (keyPair );
347+ }
338348
339349}
Original file line number Diff line number Diff line change @@ -247,6 +247,17 @@ protected static String executeValidateAddress(String address) throws Multichain
247247 return execute (CommandEnum .VALIDATEADDRESS , address );
248248 }
249249
250-
250+ /**
251+ * Generates a blockchain address, corresponding public and private keys
252+ * @return [{
253+ * address:
254+ * pubkey:
255+ * privkey:
256+ * }]
257+ * @throws MultichainException
258+ */
259+ protected static String executeCreateKeyPairs () throws MultichainException {
260+ return execute (CommandEnum .CREATEKEYPAIRS );
261+ }
251262
252263}
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ protected enum CommandEnum {
3939 COMBINEUNPSENT ,
4040 CREATE ,
4141 CREATEFROM ,
42+ CREATEKEYPAIRS ,
4243 CREATEMULTISIG ,
4344 CREATERAWEXCHANGE ,
4445 CREATERAWTRANSACTION ,
Original file line number Diff line number Diff line change 1+ package multichain .object ;
2+
3+ import com .google .gson .Gson ;
4+ import com .google .gson .GsonBuilder ;
5+
6+ public class KeyPair {
7+ String address ;
8+ String pubkey ;
9+ String privkey ;
10+
11+ public String getAddress () {
12+ return address ;
13+ }
14+
15+ public void setAddress (String address ) {
16+ this .address = address ;
17+ }
18+
19+ public String getPubkey () {
20+ return pubkey ;
21+ }
22+
23+ public void setPubkey (String pubkey ) {
24+ this .pubkey = pubkey ;
25+ }
26+
27+ public String getPrivkey () {
28+ return privkey ;
29+ }
30+
31+ public void setPrivkey (String privkey ) {
32+ this .privkey = privkey ;
33+ }
34+
35+ @ Override
36+ public String toString () {
37+ Gson gson = new GsonBuilder ().setPrettyPrinting ().create ();
38+ return gson .toJson (this , this .getClass ());
39+ }
40+ }
Original file line number Diff line number Diff line change 1515import com .google .gson .Gson ;
1616import com .google .gson .GsonBuilder ;
1717import com .google .gson .reflect .TypeToken ;
18+ import multichain .object .KeyPair ;
1819
1920/**
2021 * @author Ub - H. MARTEAU
@@ -46,4 +47,9 @@ public final static List<Address> formatAddressesList(String stringAddresses) {
4647
4748 return addresses ;
4849 }
50+
51+ public final static KeyPair formatKeyPair (String keyPair ) {
52+ final Gson gson = new GsonBuilder ().create ();
53+ return gson .fromJson (keyPair , KeyPair .class );
54+ }
4955}
You can’t perform that action at this time.
0 commit comments