use of org.bitcoinj.crypto.ChildNumber in project bitrafael_public by GENERALBYTESCOM.
the class MasterPrivateKeyBCH method serializePUB.
public static String serializePUB(DeterministicKey masterKey, int standard, int accountIndex, String cryptoCurrency) {
final DeterministicKey purposeKey = HDKeyDerivation.deriveChildKey(masterKey, new ChildNumber(standard, true));
final DeterministicKey coinKey = HDKeyDerivation.deriveChildKey(purposeKey, new ChildNumber(WalletTools.getCoinTypeByCryptoCurrency(cryptoCurrency), true));
final DeterministicKey accountKey = HDKeyDerivation.deriveChildKey(coinKey, new ChildNumber(accountIndex, true));
int header = 0x0488b21e;
switch(standard) {
case IWalletTools.STANDARD_BIP44:
// xpub
header = XPUB;
break;
}
ByteBuffer ser = ByteBuffer.allocate(78);
ser.putInt(header);
ser.put((byte) accountKey.getDepth());
ser.putInt(accountKey.getParentFingerprint());
ser.putInt(accountKey.getChildNumber().i());
ser.put(accountKey.getChainCode());
ser.put(accountKey.getPubKey());
checkState(ser.position() == 78);
return Base58.encode(addChecksum(ser.array()));
}
use of org.bitcoinj.crypto.ChildNumber in project bitrafael_public by GENERALBYTESCOM.
the class MasterPrivateKeyETH method serializePUB.
public static String serializePUB(DeterministicKey masterKey, int standard, int accountIndex, String cryptoCurrency) {
final DeterministicKey purposeKey = HDKeyDerivation.deriveChildKey(masterKey, new ChildNumber(standard, true));
final DeterministicKey coinKey = HDKeyDerivation.deriveChildKey(purposeKey, new ChildNumber(WalletTools.getCoinTypeByCryptoCurrency(cryptoCurrency), true));
final DeterministicKey accountKey = HDKeyDerivation.deriveChildKey(coinKey, new ChildNumber(accountIndex, true));
int header = 0x0488b21e;
switch(standard) {
case IWalletTools.STANDARD_BIP44:
// xpub
header = XPUB;
break;
}
ByteBuffer ser = ByteBuffer.allocate(78);
ser.putInt(header);
ser.put((byte) accountKey.getDepth());
ser.putInt(accountKey.getParentFingerprint());
ser.putInt(accountKey.getChildNumber().i());
ser.put(accountKey.getChainCode());
ser.put(accountKey.getPubKey());
checkState(ser.position() == 78);
return Base58.encode(addChecksum(ser.array()));
}
Aggregations