From 4b677bb7e259e125fbfbcea4d2effdd006729fa2 Mon Sep 17 00:00:00 2001 From: Manolis Mandrapilias <70536101+moneymanolis@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:57:17 +0100 Subject: [PATCH] Bugfix: Wallet creation timeout, RPC error when deleting wallet and sync messages (#2250) * higher timeout for wallet creation * Fix raising RPC error when deleting a wallet * remove sync notifications --- cypress/integration/spec_connections.js | 4 ---- .../specter/managers/wallet_manager.py | 1 + .../specter/server_endpoints/wallets/wallets.py | 16 ++++------------ .../sidebar/components/node_connection.jinja | 6 ------ src/cryptoadvance/specter/wallet.py | 10 ++++++++-- .../components/spectrum_node_connection.jinja | 6 ------ 6 files changed, 13 insertions(+), 30 deletions(-) diff --git a/cypress/integration/spec_connections.js b/cypress/integration/spec_connections.js index 9e6213ff0..710f26ef2 100644 --- a/cypress/integration/spec_connections.js +++ b/cypress/integration/spec_connections.js @@ -53,11 +53,7 @@ describe('Connecting nodes', () => { it('Check sync status of Bitcoin Core node', () => { cy.intercept("GET", "/nodes/sync_status/", {'fullySynced': false}); cy.visit('/') - cy.contains('Your Bitcoin node is syncing.') cy.get('[data-cy="unfinished-sync-indicator"]').should('be.visible') - // The message should only pop up once per session - cy.visit('/') - cy.contains('Your Bitcoin node is syncing.').should('not.exist'); }) }) diff --git a/src/cryptoadvance/specter/managers/wallet_manager.py b/src/cryptoadvance/specter/managers/wallet_manager.py index 8c133e1d8..7b73143fa 100644 --- a/src/cryptoadvance/specter/managers/wallet_manager.py +++ b/src/cryptoadvance/specter/managers/wallet_manager.py @@ -355,6 +355,7 @@ class WalletManager: self._check_duplicate_keys(keys) wallet_alias = alias(name) i = 2 + # Ensure unique wallet alias while ( os.path.isfile(os.path.join(self.working_folder, "%s.json" % wallet_alias)) or os.path.join(self.rpc_path, wallet_alias) in walletsindir diff --git a/src/cryptoadvance/specter/server_endpoints/wallets/wallets.py b/src/cryptoadvance/specter/server_endpoints/wallets/wallets.py index e3f8ab621..f9f517d18 100644 --- a/src/cryptoadvance/specter/server_endpoints/wallets/wallets.py +++ b/src/cryptoadvance/specter/server_endpoints/wallets/wallets.py @@ -933,31 +933,23 @@ def settings_deletewallet(wallet_alias): # deleted is a tuple: (specter_wallet_deleted, core_wallet_file_deleted) if deleted == (True, True): flash(_("Wallet in Specter and wallet file on node deleted successfully.")) + return redirect(url_for("index")) elif deleted == (True, False): flash( _( "Wallet in Specter deleted successfully but wallet file on node could not be removed automatically." ) ) + return redirect(url_for("index")) elif deleted == (False, True): flash( _("Deletion of wallet in Specter failed, but wallet on node was removed."), "error", ) + return redirect(url_for("index")) else: flash(_("Deletion of wallet failed."), "error") - return redirect(url_for("index")) - scroll_to_rescan_blockchain = request.args.get("rescan_blockchain") - return render_template( - "wallet/settings/wallet_settings.jinja", - purposes=purposes, - wallet_alias=wallet_alias, - wallet=wallet, - specter=app.specter, - rand=rand, - error=error, - scroll_to_rescan_blockchain=scroll_to_rescan_blockchain, - ) + return redirect(request.referrer or "/") @wallets_endpoint.route("/wallet//settings/clearcache", methods=["POST"]) diff --git a/src/cryptoadvance/specter/templates/includes/sidebar/components/node_connection.jinja b/src/cryptoadvance/specter/templates/includes/sidebar/components/node_connection.jinja index 4574d0b51..59bcc00c4 100644 --- a/src/cryptoadvance/specter/templates/includes/sidebar/components/node_connection.jinja +++ b/src/cryptoadvance/specter/templates/includes/sidebar/components/node_connection.jinja @@ -32,7 +32,6 @@ {% endif %} }) - let showCoreSyncMsg = sessionStorage.getItem('showCoreSyncMsg') || true async function checkSyncStatus() { let url = `{{ url_for('nodes_endpoint.check_sync_status') }}`; const response = await send_request(url, 'GET', "{{ csrf_token() }}"); @@ -46,11 +45,6 @@ document.getElementById('unfinished-ibd-indicator').classList.remove('hidden') document.getElementById('unfinished-ibd-indicator').classList.add('animate-spin') document.getElementById('connected-icon').classList.add('hidden') - // Show message only once per session - if (showCoreSyncMsg === true) { - showNotification(`{{ _("Your Bitcoin node is syncing. Check the progress by clicking on the connection.") }}`) - } - sessionStorage.setItem('showCoreSyncMsg', false); setTimeout(checkSyncStatus, 5*60000); } } diff --git a/src/cryptoadvance/specter/wallet.py b/src/cryptoadvance/specter/wallet.py index 6920334d9..db1bf548e 100644 --- a/src/cryptoadvance/specter/wallet.py +++ b/src/cryptoadvance/specter/wallet.py @@ -302,14 +302,20 @@ class Wallet: # Use descriptor wallet try: rpc.createwallet( - os.path.join(rpc_path, alias), True, True, "", False, True + os.path.join(rpc_path, alias), + True, + True, + "", + False, + True, + timeout=20, ) created = True except Exception as e: logger.exception(e) # if we failed to create or didn't try - create without descriptors if not created: - rpc.createwallet(os.path.join(rpc_path, alias), True) + rpc.createwallet(os.path.join(rpc_path, alias), True, timeout=20) use_descriptors = False wallet_rpc = rpc.wallet(os.path.join(rpc_path, alias)) diff --git a/src/cryptoadvance/specterext/spectrum/templates/spectrum/components/spectrum_node_connection.jinja b/src/cryptoadvance/specterext/spectrum/templates/spectrum/components/spectrum_node_connection.jinja index 5aa9e265b..01191933b 100644 --- a/src/cryptoadvance/specterext/spectrum/templates/spectrum/components/spectrum_node_connection.jinja +++ b/src/cryptoadvance/specterext/spectrum/templates/spectrum/components/spectrum_node_connection.jinja @@ -27,7 +27,6 @@ {% endif %} }) - let showSpectrumSyncMsg = sessionStorage.getItem('showSyncMsg') || true async function checkSyncStatus() { let url = `{{ url_for('nodes_endpoint.check_sync_status') }}`; const response = await send_request(url, 'GET', "{{ csrf_token() }}"); @@ -41,11 +40,6 @@ document.getElementById('unfinished-ibd-indicator').classList.remove('hidden') document.getElementById('unfinished-ibd-indicator').classList.add('animate-spin') document.getElementById('connected-icon').classList.add('hidden') - // Show message only once per session - if (showSpectrumSyncMsg === true) { - showNotification(`{{ _("Spectrum is syncing. Check the progress by clicking on the connection.") }}`) - } - sessionStorage.setItem('showSpectrumSyncMsg', false); setTimeout(checkSyncStatus, 30000); } }