Browse Source

avoid saving xpubs on bip47 wallets, restore from seed on opening

terminal
Craig Raw 2 years ago
parent
commit
f4c8bfa48c
  1. 2
      drongo
  2. 12
      src/main/java/com/sparrowwallet/sparrow/AppController.java
  3. 4
      src/main/java/com/sparrowwallet/sparrow/io/db/KeystoreDao.java

2
drongo

@ -1 +1 @@
Subproject commit ca833fbf6807e9db30135562000329b7423b9fb7
Subproject commit ddaf698c1011e5b01c7c3ed1e7693145ba5531ac

12
src/main/java/com/sparrowwallet/sparrow/AppController.java

@ -5,10 +5,7 @@ import com.google.common.base.Charsets;
import com.google.common.eventbus.Subscribe;
import com.google.common.io.ByteSource;
import com.sparrowwallet.drongo.*;
import com.sparrowwallet.drongo.crypto.ECKey;
import com.sparrowwallet.drongo.crypto.EncryptionType;
import com.sparrowwallet.drongo.crypto.InvalidPasswordException;
import com.sparrowwallet.drongo.crypto.Key;
import com.sparrowwallet.drongo.crypto.*;
import com.sparrowwallet.drongo.policy.PolicyType;
import com.sparrowwallet.drongo.protocol.ScriptType;
import com.sparrowwallet.drongo.protocol.Sha256Hash;
@ -1102,8 +1099,13 @@ public class AppController implements Initializable {
for(Wallet childWallet : wallet.getChildWallets()) {
if(childWallet.isBip47()) {
try {
Keystore masterKeystore = wallet.getKeystores().get(0);
Keystore keystore = childWallet.getKeystores().get(0);
keystore.setBip47ExtendedPrivateKey(wallet.getKeystores().get(0).getBip47ExtendedPrivateKey());
keystore.setBip47ExtendedPrivateKey(masterKeystore.getBip47ExtendedPrivateKey());
List<ChildNumber> derivation = keystore.getKeyDerivation().getDerivation();
keystore.setKeyDerivation(new KeyDerivation(masterKeystore.getKeyDerivation().getMasterFingerprint(), derivation));
DeterministicKey pubKey = keystore.getBip47ExtendedPrivateKey().getKey().dropPrivateBytes().dropParent();
keystore.setExtendedPublicKey(new ExtendedKey(pubKey, keystore.getBip47ExtendedPrivateKey().getParentFingerprint(), derivation.get(derivation.size() - 1)));
} catch(Exception e) {
log.error("Cannot prepare BIP47 keystore", e);
}

4
src/main/java/com/sparrowwallet/sparrow/io/db/KeystoreDao.java

@ -69,9 +69,9 @@ public interface KeystoreDao {
}
long id = insert(truncate(keystore.getLabel()), keystore.getSource().ordinal(), keystore.getWalletModel().ordinal(),
keystore.hasMasterPrivateKey() ? null : keystore.getKeyDerivation().getMasterFingerprint(),
keystore.hasMasterPrivateKey() || wallet.isBip47() ? null : keystore.getKeyDerivation().getMasterFingerprint(),
keystore.getKeyDerivation().getDerivationPath(),
keystore.hasMasterPrivateKey() ? null : keystore.getExtendedPublicKey().toString(),
keystore.hasMasterPrivateKey() || wallet.isBip47() ? null : keystore.getExtendedPublicKey().toString(),
keystore.getExternalPaymentCode() == null ? null : keystore.getExternalPaymentCode().toString(),
keystore.getMasterPrivateExtendedKey() == null ? null : keystore.getMasterPrivateExtendedKey().getId(),
keystore.getSeed() == null ? null : keystore.getSeed().getId(), wallet.getId(), i);

Loading…
Cancel
Save