use of com.sparrowwallet.drongo.bip47.PaymentAddress in project drongo by sparrowwallet.
the class Keystore method getKey.
public ECKey getKey(WalletNode walletNode) throws MnemonicException {
if (source == KeystoreSource.SW_PAYMENT_CODE) {
try {
if (walletNode.getKeyPurpose() != KeyPurpose.RECEIVE) {
throw new IllegalArgumentException("Cannot get private key for non-receive chain");
}
PaymentAddress paymentAddress = getPaymentAddress(walletNode.getKeyPurpose(), walletNode.getIndex());
return paymentAddress.getReceiveECKey();
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid payment code " + externalPaymentCode, e);
} catch (Exception e) {
log.error("Cannot get receive private key at index " + walletNode.getIndex() + " for payment code " + externalPaymentCode, e);
}
}
ExtendedKey extendedPrivateKey = getExtendedPrivateKey();
List<ChildNumber> derivation = new ArrayList<>();
derivation.add(extendedPrivateKey.getKeyChildNumber());
derivation.addAll(walletNode.getDerivation());
return extendedPrivateKey.getKey(derivation);
}
use of com.sparrowwallet.drongo.bip47.PaymentAddress in project drongo by sparrowwallet.
the class Keystore method getPubKey.
public ECKey getPubKey(WalletNode walletNode) {
if (source == KeystoreSource.SW_PAYMENT_CODE) {
try {
PaymentAddress paymentAddress = getPaymentAddress(walletNode.getKeyPurpose(), walletNode.getIndex());
return walletNode.getKeyPurpose() == KeyPurpose.RECEIVE ? ECKey.fromPublicOnly(paymentAddress.getReceiveECKey()) : paymentAddress.getSendECKey();
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid payment code " + externalPaymentCode, e);
} catch (Exception e) {
log.error("Cannot get receive private key at index " + walletNode.getIndex() + " for payment code " + externalPaymentCode, e);
}
}
List<ChildNumber> derivation = new ArrayList<>();
derivation.add(extendedPublicKey.getKeyChildNumber());
derivation.addAll(walletNode.getDerivation());
return extendedPublicKey.getKey(derivation);
}
Aggregations