diff --git a/main.qml b/main.qml index 3a98d9b8..45f16595 100644 --- a/main.qml +++ b/main.qml @@ -289,13 +289,16 @@ ApplicationWindow { daemonSynced = (currentWallet.connected != Wallet.ConnectionStatus_Disconnected && dCurrentBlock >= dTargetBlock) - - // Store wallet after every refresh. + // Refresh is succesfull if blockchain height > 1 if (currentWallet.blockChainHeight() > 1){ - //TODO: Doesn't need path after creation. Change libwalletqt - currentWallet.store("") - console.log("Saving wallet"); + // Save new wallet after first refresh + // Wallet is nomrmally saved to disk on app exit. This prevents rescan from block 0 after app crash + if(isNewWallet){ + console.log("Saving wallet after first refresh"); + currentWallet.store() + isNewWallet = false + } // recovering from seed is finished after first refresh if(persistentSettings.is_recovering) { @@ -303,7 +306,6 @@ ApplicationWindow { } } - isNewWallet = false // initialize transaction history once wallet is initializef first time; if (!walletInitialized) { @@ -978,6 +980,7 @@ ApplicationWindow { } } onClosing: { - //walletManager.closeWallet(currentWallet); + // Close and save to disk on app close + walletManager.closeWallet(currentWallet); } } diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 74c4fea1..fc7363e8 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -79,7 +79,8 @@ public: QString address() const; //! saves wallet to the file by given path - Q_INVOKABLE bool store(const QString &path); + //! empty path stores in current location + Q_INVOKABLE bool store(const QString &path = ""); //! initializes wallet Q_INVOKABLE bool init(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering = false, quint64 restoreHeight = 0);