mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
avoid saving xpubs on bip47 wallets, restore from seed on opening
This commit is contained in:
parent
e0a14fdea6
commit
f4c8bfa48c
3 changed files with 10 additions and 8 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit ca833fbf6807e9db30135562000329b7423b9fb7
|
Subproject commit ddaf698c1011e5b01c7c3ed1e7693145ba5531ac
|
|
@ -5,10 +5,7 @@ import com.google.common.base.Charsets;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.google.common.io.ByteSource;
|
import com.google.common.io.ByteSource;
|
||||||
import com.sparrowwallet.drongo.*;
|
import com.sparrowwallet.drongo.*;
|
||||||
import com.sparrowwallet.drongo.crypto.ECKey;
|
import com.sparrowwallet.drongo.crypto.*;
|
||||||
import com.sparrowwallet.drongo.crypto.EncryptionType;
|
|
||||||
import com.sparrowwallet.drongo.crypto.InvalidPasswordException;
|
|
||||||
import com.sparrowwallet.drongo.crypto.Key;
|
|
||||||
import com.sparrowwallet.drongo.policy.PolicyType;
|
import com.sparrowwallet.drongo.policy.PolicyType;
|
||||||
import com.sparrowwallet.drongo.protocol.ScriptType;
|
import com.sparrowwallet.drongo.protocol.ScriptType;
|
||||||
import com.sparrowwallet.drongo.protocol.Sha256Hash;
|
import com.sparrowwallet.drongo.protocol.Sha256Hash;
|
||||||
|
@ -1102,8 +1099,13 @@ public class AppController implements Initializable {
|
||||||
for(Wallet childWallet : wallet.getChildWallets()) {
|
for(Wallet childWallet : wallet.getChildWallets()) {
|
||||||
if(childWallet.isBip47()) {
|
if(childWallet.isBip47()) {
|
||||||
try {
|
try {
|
||||||
|
Keystore masterKeystore = wallet.getKeystores().get(0);
|
||||||
Keystore keystore = childWallet.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) {
|
} catch(Exception e) {
|
||||||
log.error("Cannot prepare BIP47 keystore", e);
|
log.error("Cannot prepare BIP47 keystore", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,9 +69,9 @@ public interface KeystoreDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
long id = insert(truncate(keystore.getLabel()), keystore.getSource().ordinal(), keystore.getWalletModel().ordinal(),
|
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.getKeyDerivation().getDerivationPath(),
|
||||||
keystore.hasMasterPrivateKey() ? null : keystore.getExtendedPublicKey().toString(),
|
keystore.hasMasterPrivateKey() || wallet.isBip47() ? null : keystore.getExtendedPublicKey().toString(),
|
||||||
keystore.getExternalPaymentCode() == null ? null : keystore.getExternalPaymentCode().toString(),
|
keystore.getExternalPaymentCode() == null ? null : keystore.getExternalPaymentCode().toString(),
|
||||||
keystore.getMasterPrivateExtendedKey() == null ? null : keystore.getMasterPrivateExtendedKey().getId(),
|
keystore.getMasterPrivateExtendedKey() == null ? null : keystore.getMasterPrivateExtendedKey().getId(),
|
||||||
keystore.getSeed() == null ? null : keystore.getSeed().getId(), wallet.getId(), i);
|
keystore.getSeed() == null ? null : keystore.getSeed().getId(), wallet.getId(), i);
|
||||||
|
|
Loading…
Reference in a new issue