diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 053418ca..68ec821a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -1328,13 +1328,16 @@ public class AppController implements Initializable { return; } - WalletNameDialog nameDlg = new WalletNameDialog(wallet.getName(), true, wallet.getBirthDate()); + WalletNameDialog nameDlg = new WalletNameDialog(wallet.getName(), true, wallet.getPolicyType(), wallet.getBirthDate(), false); nameDlg.initOwner(rootStack.getScene().getWindow()); Optional optNameAndBirthDate = nameDlg.showAndWait(); if(optNameAndBirthDate.isPresent()) { WalletNameDialog.NameAndBirthDate nameAndBirthDate = optNameAndBirthDate.get(); wallet.setName(nameAndBirthDate.getName()); wallet.setBirthDate(nameAndBirthDate.getBirthDate()); + if(wallet.getPolicyType() == PolicyType.SINGLE_SP && wallet.getBirthDate() == null) { + wallet.setBirthDate(new Date()); + } } else { return; } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WalletNameDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/WalletNameDialog.java index 79567146..9b76a4a6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WalletNameDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WalletNameDialog.java @@ -1,5 +1,6 @@ package com.sparrowwallet.sparrow.control; +import com.sparrowwallet.drongo.policy.PolicyType; import com.sparrowwallet.sparrow.AppServices; import com.sparrowwallet.sparrow.glyphfont.FontAwesome5; import com.sparrowwallet.sparrow.io.Config; @@ -48,9 +49,13 @@ public class WalletNameDialog extends Dialog } public WalletNameDialog(String initialName, boolean hasExistingTransactions, Date startDate, boolean rename) { + this(initialName, hasExistingTransactions, null, startDate, rename); + } + + public WalletNameDialog(String initialName, boolean hasExistingTransactions, PolicyType walletPolicyType, Date startDate, boolean rename) { final DialogPane dialogPane = getDialogPane(); AppServices.setStageIcon(dialogPane.getScene().getWindow()); - boolean requestBirthDate = !rename && (Config.get().getServerType() == null || Config.get().getServerType() == ServerType.BITCOIN_CORE); + boolean requestBirthDate = !rename && (walletPolicyType == PolicyType.SINGLE_SP || Config.get().getServerType() == null || Config.get().getServerType() == ServerType.BITCOIN_CORE); setTitle("Wallet Name"); dialogPane.setHeaderText("Enter a name for this wallet:"); diff --git a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/Bip39Dialog.java b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/Bip39Dialog.java index 610bd1a6..92c22488 100644 --- a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/Bip39Dialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/Bip39Dialog.java @@ -20,6 +20,7 @@ import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; public class Bip39Dialog extends NewWalletDialog { @@ -160,6 +161,9 @@ public class Bip39Dialog extends NewWalletDialog { Keystore keystore = importer.getKeystore(type.policyType(), wallet.getScriptType().getDefaultDerivation(), getWords(), passphrase.getText()); wallet.getKeystores().add(keystore); wallet.setDefaultPolicy(Policy.getPolicy(type.policyType(), wallet.getScriptType(), wallet.getKeystores(), 1)); + if(type.policyType() == PolicyType.SINGLE_SP) { + wallet.setBirthDate(new Date()); + } return List.of(wallet); } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java index b5de85bc..659aced9 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java @@ -259,6 +259,9 @@ public class SettingsController extends WalletFormController implements Initiali revert.setDisable(true); apply.setDisable(true); boolean addressChange = ((SettingsWalletForm)walletForm).isAddressChange(); + if(walletForm.getWallet().getPolicyType() == PolicyType.SINGLE_SP && walletForm.getWallet().getBirthDate() == null && walletForm.getStorage().getEncryptionPubKey() == null) { + walletForm.getWallet().setBirthDate(new Date()); + } saveWallet(false, false); Wallet wallet = walletForm.getWallet();