File tree 1 file changed +11
-0
lines changed
src/main/java/org/consenlabs/tokencore/wallet
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 1
1
package org .consenlabs .tokencore .wallet ;
2
2
3
3
import com .fasterxml .jackson .databind .ObjectMapper ;
4
+ import org .bitcoinj .crypto .ChildNumber ;
5
+ import org .bitcoinj .crypto .DeterministicKey ;
6
+ import org .bitcoinj .crypto .HDKeyDerivation ;
7
+ import org .consenlabs .tokencore .foundation .utils .MetaUtil ;
4
8
import org .consenlabs .tokencore .foundation .utils .NumericUtil ;
5
9
import org .consenlabs .tokencore .wallet .keystore .*;
6
10
import org .consenlabs .tokencore .wallet .model .*;
7
11
12
+ import java .nio .charset .Charset ;
8
13
import java .util .Collections ;
9
14
import java .util .List ;
10
15
@@ -79,6 +84,12 @@ public String exportPrivateKey(String password) {
79
84
} else {
80
85
return NumericUtil .bytesToHex (decrypted );
81
86
}
87
+ }else if (keystore instanceof HDMnemonicKeystore ){
88
+ String xprv = new String (decryptMainKey (password ), Charset .forName ("UTF-8" ));
89
+ DeterministicKey xprvKey = DeterministicKey .deserializeB58 (xprv , MetaUtil .getNetWork (keystore .getMetadata ()));
90
+ DeterministicKey accountKey = HDKeyDerivation .deriveChildKey (xprvKey , new ChildNumber (0 , false ));
91
+ DeterministicKey externalChangeKey = HDKeyDerivation .deriveChildKey (accountKey , new ChildNumber (1 , false ));
92
+ return NumericUtil .bigIntegerToHex (externalChangeKey .getPrivKey ());
82
93
}
83
94
throw new TokenException (Messages .ILLEGAL_OPERATION );
84
95
}
You can’t perform that action at this time.
0 commit comments