use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.
the class SettingsWalletForm method isRefreshNecessary.
// Returns true for any change, other than a keystore label change, to trigger a full wallet refresh
// Even though this is not strictly necessary for some changes, it it better to refresh on saving so background transaction history updates on the old wallet have no effect/are not lost
private boolean isRefreshNecessary(Wallet original, Wallet changed) {
if (!original.isValid() || !changed.isValid()) {
return true;
}
if (isAddressChange(original, changed)) {
return true;
}
for (int i = 0; i < original.getKeystores().size(); i++) {
Keystore originalKeystore = original.getKeystores().get(i);
Keystore changedKeystore = changed.getKeystores().get(i);
if (originalKeystore.getSource() != changedKeystore.getSource()) {
return true;
}
if (originalKeystore.getWalletModel() != changedKeystore.getWalletModel()) {
return true;
}
if ((originalKeystore.getSeed() == null && changedKeystore.getSeed() != null) || (originalKeystore.getSeed() != null && changedKeystore.getSeed() == null)) {
return true;
}
if ((originalKeystore.getMasterPrivateExtendedKey() == null && changedKeystore.getMasterPrivateExtendedKey() != null) || (originalKeystore.getMasterPrivateExtendedKey() != null && changedKeystore.getMasterPrivateExtendedKey() == null)) {
return true;
}
}
if (original.getGapLimit() != changed.getGapLimit()) {
return true;
}
if (!Objects.equals(original.getBirthDate(), changed.getBirthDate())) {
return true;
}
return false;
}
use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.
the class CoboVaultSinglesigTest method testImport.
@Test
public void testImport() throws ImportException {
CoboVaultSinglesig coboSingleSig = new CoboVaultSinglesig();
Keystore keystore = coboSingleSig.getKeystore(ScriptType.P2WPKH, getInputStream("cobo-singlesig-keystore-1.json"), null);
Assert.assertEquals("Cobo Vault", keystore.getLabel());
Assert.assertEquals("m/84'/0'/0'", keystore.getKeyDerivation().getDerivationPath());
Assert.assertEquals("73c5da0a", keystore.getKeyDerivation().getMasterFingerprint());
Assert.assertEquals(ExtendedKey.fromDescriptor("zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs"), keystore.getExtendedPublicKey());
Assert.assertTrue(keystore.isValid());
}
use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.
the class CoboVaultSinglesigTest method testIncorrectScriptType.
@Test(expected = ImportException.class)
public void testIncorrectScriptType() throws ImportException {
CoboVaultSinglesig coboSingleSig = new CoboVaultSinglesig();
Keystore keystore = coboSingleSig.getKeystore(ScriptType.P2SH_P2WPKH, getInputStream("cobo-singlesig-keystore-1.json"), null);
Assert.assertEquals("Cobo Vault", keystore.getLabel());
Assert.assertEquals("m/84'/0'/0'", keystore.getKeyDerivation().getDerivationPath());
Assert.assertEquals("73c5da0a", keystore.getKeyDerivation().getMasterFingerprint());
Assert.assertEquals(ExtendedKey.fromDescriptor("zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs"), keystore.getExtendedPublicKey());
Assert.assertTrue(keystore.isValid());
}
use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.
the class ColdcardMultisigTest method importKeystore1IncorrectScriptType.
@Test(expected = ImportException.class)
public void importKeystore1IncorrectScriptType() throws ImportException {
ColdcardMultisig ccMultisig = new ColdcardMultisig();
Keystore keystore = ccMultisig.getKeystore(ScriptType.P2SH_P2WPKH, getInputStream("cc-multisig-keystore-1.json"), null);
}
use of com.sparrowwallet.drongo.wallet.Keystore in project sparrow by sparrowwallet.
the class ColdcardMultisigTest method importKeystore2b.
@Test
public void importKeystore2b() throws ImportException {
Network.set(Network.TESTNET);
ColdcardMultisig ccMultisig = new ColdcardMultisig();
Keystore keystore = ccMultisig.getKeystore(ScriptType.P2WSH, getInputStream("cc-multisig-keystore-2.json"), null);
Assert.assertEquals("Coldcard", keystore.getLabel());
Assert.assertEquals("m/48'/1'/0'/2'", keystore.getKeyDerivation().getDerivationPath());
Assert.assertEquals("6ba6cfd0", keystore.getKeyDerivation().getMasterFingerprint());
Assert.assertEquals(ExtendedKey.fromDescriptor("Vpub5nUnvPehg1VYQh13dGznx1P9moac3SNUrn3qhU9r85RhXabYbSSBNsNNwyR7akozAZJw1SZmRRjry1zY8PWMuw8Ga1vQZ5qzPjKyTDQwtzs"), keystore.getExtendedPublicKey());
Assert.assertTrue(keystore.isValid());
}
Aggregations