-snip- Maybe you know how to do it in Java in this case?
Try to incorporate Electrum's derivation path to the code that you're probably using (
This code?: /index.php?topic=5360581.msg57965406#msg57965406).
I'm not a Java programmer but based from what I understand, these few edits should derive the correct keys/addresses of Electrum's
P2WPKH:
From:
How can I integrate m / 84 '/ 0' / 0 '/ 0/0 into my code? I just need to get the first 5 addresses. I looked at your program, but there is a whole class forming a complex configuration. Too difficult for a beginner. How can I just hardcode the derivation path into my method?
-snip-
DeterministicKey deterministicKey = createMasterPrivateKey(seed, createHmacSha512Digest());
deterministicKey = HDKeyDerivation.deriveChildKey(deterministicKey, new ChildNumber(84, true));
deterministicKey = HDKeyDerivation.deriveChildKey(deterministicKey, new ChildNumber(0, true));
deterministicKey = HDKeyDerivation.deriveChildKey(deterministicKey, new ChildNumber(0, true));
deterministicKey = HDKeyDerivation.deriveChildKey(deterministicKey, new ChildNumber(0, false));
for (int i = 0; i <= 5; i++) {
System.out.println(Address.fromKey(MainNetParams.get(), HDKeyDerivation.deriveChildKey(deterministicKey, new ChildNumber(i, false)), Script.ScriptType.P2WPKH));
}
-snip-
Into:
-snip-
DeterministicKey deterministicKey = createMasterPrivateKey(seed, createHmacSha512Digest());
deterministicKey = HDKeyDerivation.deriveChildKey(deterministicKey, new ChildNumber(0, true));
deterministicKey = HDKeyDerivation.deriveChildKey(deterministicKey, new ChildNumber(0, false));
for (int i = 0; i <= 5; i++) {
System.out.println(Address.fromKey(MainNetParams.get(), HDKeyDerivation.deriveChildKey(deterministicKey, new ChildNumber(i, false)), Script.ScriptType.P2WPKH));
}
-snip-
The path in the code is
m/0'/0 (from
m/84'/0'/0'/0), the extra child key is for the 'external chain' (
receiving addresses), change to '1' for internal (
change addresses).
But then again, I'm not a Java programmer so the part that I've edited could be wrong :-\
For the derivation path,
You can actually directly see it in the wallet menu (
Wallet->Information):
Refer to these images:
| P2WPKH (Native Segwit): m/0' | | | P2PKH (Legacy): m |
| | | |