Search in sources :

Example 1 with Keystore

use of com.sparrowwallet.drongo.wallet.Keystore in project drongo by sparrowwallet.

the class Policy method getPolicy.

public static Policy getPolicy(PolicyType policyType, ScriptType scriptType, List<Keystore> keystores, Integer threshold) {
    if (SINGLE.equals(policyType)) {
        return new Policy(new Miniscript(scriptType.getDescriptor() + keystores.get(0).getScriptName() + scriptType.getCloseDescriptor()));
    }
    if (MULTI.equals(policyType)) {
        StringBuilder builder = new StringBuilder();
        builder.append(scriptType.getDescriptor());
        builder.append(MULTISIG.getDescriptor());
        builder.append(threshold);
        for (Keystore keystore : keystores) {
            builder.append(",").append(keystore.getScriptName());
        }
        builder.append(MULTISIG.getCloseDescriptor());
        builder.append(scriptType.getCloseDescriptor());
        return new Policy(new Miniscript(builder.toString()));
    }
    throw new PolicyException("No standard policy for " + policyType + " policy with script type " + scriptType);
}
Also used : Keystore(com.sparrowwallet.drongo.wallet.Keystore)

Example 2 with Keystore

use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.

the class MessageSignDialog method signUnencryptedKeystore.

private void signUnencryptedKeystore(Wallet decryptedWallet) {
    try {
        Keystore keystore = decryptedWallet.getKeystores().get(0);
        ECKey privKey = keystore.getKey(walletNode);
        ScriptType scriptType = electrumSignatureFormat ? ScriptType.P2PKH : decryptedWallet.getScriptType();
        String signatureText = privKey.signMessage(message.getText().trim(), scriptType);
        signature.clear();
        signature.appendText(signatureText);
        privKey.clear();
    } catch (Exception e) {
        log.error("Could not sign message", e);
        AppServices.showErrorDialog("Could not sign message", e.getMessage());
    }
}
Also used : Keystore(com.sparrowwallet.drongo.wallet.Keystore) ScriptType(com.sparrowwallet.drongo.protocol.ScriptType) ECKey(com.sparrowwallet.drongo.crypto.ECKey) SecureString(com.sparrowwallet.drongo.SecureString) InvalidAddressException(com.sparrowwallet.drongo.address.InvalidAddressException) SignatureException(java.security.SignatureException)

Example 3 with Keystore

use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.

the class MnemonicWalletKeystoreImportPane method getWallet.

private Wallet getWallet(ScriptType scriptType, List<ChildNumber> derivation) throws ImportException {
    Wallet wallet = new Wallet("");
    wallet.setPolicyType(PolicyType.SINGLE);
    wallet.setScriptType(scriptType);
    Keystore keystore = importer.getKeystore(derivation, wordEntriesProperty.get(), passphraseProperty.get());
    wallet.getKeystores().add(keystore);
    wallet.setDefaultPolicy(Policy.getPolicy(PolicyType.SINGLE, scriptType, wallet.getKeystores(), 1));
    return wallet;
}
Also used : Keystore(com.sparrowwallet.drongo.wallet.Keystore) Wallet(com.sparrowwallet.drongo.wallet.Wallet)

Example 4 with Keystore

use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.

the class FileImportPane method getScannedKeystore.

protected Keystore getScannedKeystore(ScriptType scriptType) throws ImportException {
    if (wallets != null) {
        for (Wallet wallet : wallets) {
            if (scriptType.equals(wallet.getScriptType()) && !wallet.getKeystores().isEmpty()) {
                Keystore keystore = wallet.getKeystores().get(0);
                keystore.setLabel(importer.getName().replace(" Multisig", ""));
                keystore.setSource(KeystoreSource.HW_AIRGAPPED);
                keystore.setWalletModel(importer.getWalletModel());
                return keystore;
            }
        }
        throw new ImportException("Script type " + scriptType.getDescription() + " is not supported in this QR. Check you are displaying the correct QR code.");
    }
    return null;
}
Also used : Keystore(com.sparrowwallet.drongo.wallet.Keystore) ImportException(com.sparrowwallet.sparrow.io.ImportException) Wallet(com.sparrowwallet.drongo.wallet.Wallet)

Example 5 with Keystore

use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.

the class BlueWalletMultisig method importWallet.

@Override
public Wallet importWallet(InputStream inputStream, String password) throws ImportException {
    Wallet wallet = super.importWallet(inputStream, password);
    for (Keystore keystore : wallet.getKeystores()) {
        keystore.setLabel(keystore.getLabel().replace("Coldcard", "Blue Wallet"));
        keystore.setWalletModel(WalletModel.BLUE_WALLET);
    }
    return wallet;
}
Also used : Keystore(com.sparrowwallet.drongo.wallet.Keystore) Wallet(com.sparrowwallet.drongo.wallet.Wallet)

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