use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.
the class PayNymService method getSignature.
public String getSignature(Wallet wallet, String authToken) {
Wallet masterWallet = wallet.isMasterWallet() ? wallet : wallet.getMasterWallet();
Keystore keystore = masterWallet.getKeystores().get(0);
List<ChildNumber> derivation = keystore.getKeyDerivation().getDerivation();
ChildNumber derivationStart = derivation.isEmpty() ? ChildNumber.ZERO_HARDENED : derivation.get(derivation.size() - 1);
ECKey notificationPrivKey = keystore.getBip47ExtendedPrivateKey().getKey(List.of(derivationStart, new ChildNumber(0)));
return notificationPrivKey.signMessage(authToken, ScriptType.P2PKH);
}
use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.
the class KeystoreImportDialog method getWatchOnlyKeystore.
private Keystore getWatchOnlyKeystore() {
this.keystore = new Keystore();
keystore.setSource(KeystoreSource.SW_WATCH);
keystore.setWalletModel(WalletModel.SPARROW);
keystore.setKeyDerivation(new KeyDerivation("", ""));
return keystore;
}
use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.
the class Soroban method setHDWallet.
public void setHDWallet(Wallet wallet) {
if (wallet.isEncrypted()) {
throw new IllegalStateException("Wallet cannot be encrypted");
}
try {
Keystore keystore = wallet.getKeystores().get(0);
ScriptType scriptType = wallet.getScriptType();
int purpose = scriptType.getDefaultDerivation().get(0).num();
List<String> words = keystore.getSeed().getMnemonicCode();
String passphrase = keystore.getSeed().getPassphrase().asString();
byte[] seed = hdWalletFactory.computeSeedFromWords(words);
hdWallet = new HD_Wallet(purpose, new ArrayList<>(words), sorobanServer.getParams(), seed, passphrase);
bip47Account = wallet.isMasterWallet() ? wallet.getAccountIndex() : wallet.getMasterWallet().getAccountIndex();
} catch (Exception e) {
throw new IllegalStateException("Could not create Soroban HD wallet ", e);
}
}
use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.
the class SettingsWalletForm method isAddressChange.
private boolean isAddressChange(Wallet original, Wallet changed) {
if (original.getPolicyType() != changed.getPolicyType()) {
return true;
}
if (original.getScriptType() != changed.getScriptType()) {
return true;
}
if (!Objects.equals(getNumSignaturesRequired(original.getDefaultPolicy()), getNumSignaturesRequired(changed.getDefaultPolicy()))) {
return true;
}
if (original.getKeystores().size() != changed.getKeystores().size()) {
return true;
}
for (int i = 0; i < original.getKeystores().size(); i++) {
Keystore originalKeystore = original.getKeystores().get(i);
Keystore changedKeystore = changed.getKeystores().get(i);
if (!Objects.equals(originalKeystore.getKeyDerivation(), changedKeystore.getKeyDerivation())) {
return true;
}
if (!Objects.equals(originalKeystore.getExtendedPublicKey(), changedKeystore.getExtendedPublicKey())) {
return true;
}
}
return false;
}
use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.
the class InputController method initializeView.
public void initializeView() {
TransactionInput txInput = inputForm.getTransactionInput();
PSBTInput psbtInput = inputForm.getPsbtInput();
inputForm.signingWalletProperty().addListener((observable, oldValue, signingWallet) -> {
updateInputLegendFromWallet(txInput, signingWallet);
});
updateInputLegendFromWallet(txInput, inputForm.getSigningWallet());
initializeInputFields(txInput, psbtInput);
initializeScriptFields(txInput, psbtInput);
initializeStatusFields(txInput, psbtInput);
initializeLocktimeFields(txInput);
if (psbtInput != null) {
inputForm.getSignatureKeystoreMap().addListener((MapChangeListener<TransactionSignature, Keystore>) c -> {
updateSignatures(inputForm.getPsbtInput());
});
}
}
Aggregations