Search in sources :

Example 11 with Keystore

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);
}
Also used : Keystore(com.sparrowwallet.drongo.wallet.Keystore) Wallet(com.sparrowwallet.drongo.wallet.Wallet) ECKey(com.sparrowwallet.drongo.crypto.ECKey) ChildNumber(com.sparrowwallet.drongo.crypto.ChildNumber)

Example 12 with Keystore

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;
}
Also used : Keystore(com.sparrowwallet.drongo.wallet.Keystore) KeyDerivation(com.sparrowwallet.drongo.KeyDerivation)

Example 13 with 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);
    }
}
Also used : Keystore(com.sparrowwallet.drongo.wallet.Keystore) ScriptType(com.sparrowwallet.drongo.protocol.ScriptType) HD_Wallet(com.samourai.wallet.hd.HD_Wallet)

Example 14 with Keystore

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;
}
Also used : Keystore(com.sparrowwallet.drongo.wallet.Keystore)

Example 15 with Keystore

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());
        });
    }
}
Also used : Keystore(com.sparrowwallet.drongo.wallet.Keystore) Address(com.sparrowwallet.drongo.address.Address) Initializable(javafx.fxml.Initializable) Wallet(com.sparrowwallet.drongo.wallet.Wallet) javafx.scene.control(javafx.scene.control) URL(java.net.URL) LocalDateTime(java.time.LocalDateTime) ResourceBundle(java.util.ResourceBundle) PSBTInput(com.sparrowwallet.drongo.psbt.PSBTInput) Duration(java.time.Duration) Map(java.util.Map) com.sparrowwallet.drongo.protocol(com.sparrowwallet.drongo.protocol) KeyDerivation(com.sparrowwallet.drongo.KeyDerivation) Subscribe(com.google.common.eventbus.Subscribe) Field(tornadofx.control.Field) MapChangeListener(javafx.collections.MapChangeListener) com.sparrowwallet.sparrow.event(com.sparrowwallet.sparrow.event) CodeArea(org.fxmisc.richtext.CodeArea) Instant(java.time.Instant) Fieldset(tornadofx.control.Fieldset) ZoneId(java.time.ZoneId) FXML(javafx.fxml.FXML) BlockTransaction(com.sparrowwallet.drongo.wallet.BlockTransaction) VirtualizedScrollPane(org.fxmisc.flowless.VirtualizedScrollPane) DateTimeFormatter(java.time.format.DateTimeFormatter) EventManager(com.sparrowwallet.sparrow.EventManager) ECKey(com.sparrowwallet.drongo.crypto.ECKey) ToggleSwitch(org.controlsfx.control.ToggleSwitch) Keystore(com.sparrowwallet.drongo.wallet.Keystore) com.sparrowwallet.sparrow.control(com.sparrowwallet.sparrow.control) PSBTInput(com.sparrowwallet.drongo.psbt.PSBTInput)

Aggregations

Keystore (com.sparrowwallet.drongo.wallet.Keystore)47 Wallet (com.sparrowwallet.drongo.wallet.Wallet)14 Test (org.junit.Test)12 KeyDerivation (com.sparrowwallet.drongo.KeyDerivation)5 ScriptType (com.sparrowwallet.drongo.protocol.ScriptType)5 ImportException (com.sparrowwallet.sparrow.io.ImportException)4 ECKey (com.sparrowwallet.drongo.crypto.ECKey)3 ArrayList (java.util.ArrayList)3 Subscribe (com.google.common.eventbus.Subscribe)2 com.sparrowwallet.drongo.protocol (com.sparrowwallet.drongo.protocol)2 PSBTInput (com.sparrowwallet.drongo.psbt.PSBTInput)2 BlockTransaction (com.sparrowwallet.drongo.wallet.BlockTransaction)2 DeterministicSeed (com.sparrowwallet.drongo.wallet.DeterministicSeed)2 MasterPrivateExtendedKey (com.sparrowwallet.drongo.wallet.MasterPrivateExtendedKey)2 WalletModel (com.sparrowwallet.drongo.wallet.WalletModel)2 EventManager (com.sparrowwallet.sparrow.EventManager)2 KeystoreImportEvent (com.sparrowwallet.sparrow.event.KeystoreImportEvent)2 URL (java.net.URL)2 Map (java.util.Map)2 ResourceBundle (java.util.ResourceBundle)2