diff --git a/wowstash/blueprints/auth/routes.py b/wowstash/blueprints/auth/routes.py index 7a7b7c7..b7595df 100644 --- a/wowstash/blueprints/auth/routes.py +++ b/wowstash/blueprints/auth/routes.py @@ -91,7 +91,7 @@ def delete(): send_es({'type': 'delete_wallet', 'user': current_user.email}) current_user.clear_wallet_data(reset_password=True, reset_wallet=True) flash('Successfully deleted wallet data') - return redirect(url_for('meta.index')) + return redirect(url_for('wallet.setup')) else: flash('Please confirm deletion of the account') return redirect(url_for('wallet.dashboard')) diff --git a/wowstash/blueprints/wallet/routes.py b/wowstash/blueprints/wallet/routes.py index 2e0fc43..e791287 100644 --- a/wowstash/blueprints/wallet/routes.py +++ b/wowstash/blueprints/wallet/routes.py @@ -28,7 +28,7 @@ def setup(): restore_form = Restore() if restore_form.validate_on_submit(): c = docker.create_wallet(current_user.id, restore_form.seed.data) - cache.store_data(f'restoring_{current_user.id}', 30, c) + cache.store_data(f'init_wallet_{current_user.id}', 30, c) current_user.wallet_created = True db.session.commit() return redirect(url_for('wallet.loading')) @@ -66,6 +66,7 @@ def dashboard(): return redirect(url_for('wallet.loading')) if not wallet.connected: + sleep(1.5) return redirect(url_for('wallet.loading')) address = wallet.get_address() @@ -130,7 +131,8 @@ def connect(): @login_required def create(): if current_user.wallet_created is False: - docker.create_wallet(current_user.id) + c = docker.create_wallet(current_user.id) + cache.store_data(f'init_wallet_{current_user.id}', 30, c) current_user.wallet_created = True db.session.commit() return redirect(url_for('wallet.loading')) @@ -141,14 +143,14 @@ def create(): @login_required def status(): user_vol = docker.get_user_volume(current_user.id) - restore_container = cache.get_data(f'restoring_{current_user.id}') + create_container = cache.get_data(f'init_wallet_{current_user.id}') data = { 'created': current_user.wallet_created, 'connected': current_user.wallet_connected, 'port': current_user.wallet_port, 'container': current_user.wallet_container, 'volume': docker.volume_exists(user_vol), - 'restoring': docker.container_exists(restore_container) + 'initializing': docker.container_exists(create_container) } return jsonify(data) diff --git a/wowstash/library/docker.py b/wowstash/library/docker.py index fad2e7f..05a2b6e 100644 --- a/wowstash/library/docker.py +++ b/wowstash/library/docker.py @@ -25,7 +25,6 @@ class Docker(object): u.wallet_password = token_urlsafe(12) db.session.commit() if seed: - action = "restore" command = f"""sh -c "yes '' | wownero-wallet-cli \ --restore-deterministic-wallet \ --generate-new-wallet /wallet/{u.id}.wallet \ @@ -34,11 +33,10 @@ class Docker(object): --daemon-address {config.DAEMON_PROTO}://{config.DAEMON_HOST}:{config.DAEMON_PORT} \ --daemon-login {config.DAEMON_USER}:{config.DAEMON_PASS} \ --electrum-seed '{seed}' \ - --log-file /wallet/{u.id}-{action}.log \ + --log-file /wallet/{u.id}-init.log \ --command refresh" """ else: - action = "create" command = f"""wownero-wallet-cli \ --generate-new-wallet /wallet/{u.id}.wallet \ --restore-height {daemon.info()['height']} \ @@ -46,7 +44,7 @@ class Docker(object): --mnemonic-language English \ --daemon-address {config.DAEMON_PROTO}://{config.DAEMON_HOST}:{config.DAEMON_PORT} \ --daemon-login {config.DAEMON_USER}:{config.DAEMON_PASS} \ - --log-file /wallet/{u.id}-{action}.log \ + --log-file /wallet/{u.id}-init.log \ --command version """ if not self.volume_exists(volume_name): @@ -58,7 +56,7 @@ class Docker(object): self.wownero_image, command=command, auto_remove=True, - name=f'{action}_wallet_{u.id}', + name=f'init_wallet_{u.id}', remove=True, detach=True, volumes={ @@ -68,7 +66,7 @@ class Docker(object): } } ) - send_es({'type': f'{action}_wallet', 'user': u.email}) + send_es({'type': f'init_wallet', 'user': u.email}) return container.short_id def start_wallet(self, user_id): diff --git a/wowstash/static/css/main.css b/wowstash/static/css/main.css index 9599989..9fd823c 100644 --- a/wowstash/static/css/main.css +++ b/wowstash/static/css/main.css @@ -552,3 +552,82 @@ ol li { border-radius: 4px; padding: 6px; } + +.teh_matrix { + margin: 2em auto; +} + +.teh_matrix img.doge { + opacity: 0; + position: absolute; + top: 10px; + left: 30px; + + -webkit-transition: opacity 1s ease-in-out; + -moz-transition: opacity 1s ease-in-out; + -ms-transition: opacity 1s ease-in-out; + -o-transition: opacity 1s ease-in-out; + transition: opacity 1s ease-in-out; +} + +.teh_matrix span.centered { + opacity: 0; + display: none; + color: #02ff44; + font-weight: bold; + font-size: 20px; + position: absolute; + top: 88px; + width: 400px; + text-align: center; + font-family: monospace; + word-break: break-word; + margin: 20px; + text-shadow: black 1px 1px 0; + + -webkit-transition: opacity 1s ease-in-out; + -moz-transition: opacity 1s ease-in-out; + -ms-transition: opacity 1s ease-in-out; + -o-transition: opacity 1s ease-in-out; + transition: opacity 1s ease-in-out; +} + +.teh_matrix span.title { + opacity: 0; + color: #02ff44; + font-weight: bold; + font-size: 18px; + position: absolute; + top: 28px; + left: 122px; + width: 300px; + font-family: monospace; + word-break: break-word; + text-shadow: black 1px 1px 0; + + -webkit-transition: opacity 1s ease-in-out; + -moz-transition: opacity 1s ease-in-out; + -ms-transition: opacity 1s ease-in-out; + -o-transition: opacity 1s ease-in-out; + transition: opacity 1s ease-in-out; +} + +.teh_matrix span.body { + position: absolute;; + opacity: 0; + color: #02ff44; + font-weight: bold; + font-size: 18px; + top: 70px; + left: 122px; + width: 300px; + font-family: monospace; + word-break: break-word; + text-shadow: black 1px 1px 0; + + -webkit-transition: opacity 1s ease-in-out; + -moz-transition: opacity 1s ease-in-out; + -ms-transition: opacity 1s ease-in-out; + -o-transition: opacity 1s ease-in-out; + transition: opacity 1s ease-in-out; +} diff --git a/wowstash/static/img/loading-doge.png b/wowstash/static/img/loading-doge.png new file mode 100644 index 0000000..12ad4b4 Binary files /dev/null and b/wowstash/static/img/loading-doge.png differ diff --git a/wowstash/templates/scripts.html b/wowstash/templates/scripts.html index 66ab7e1..d793feb 100644 --- a/wowstash/templates/scripts.html +++ b/wowstash/templates/scripts.html @@ -10,14 +10,12 @@ function check_status(){ fetch('/wallet/status') .then((resp) => resp.json()) .then(function(data) { - console.log(JSON.stringify(data)); - // If we've created a wallet and volume, but not connected a container and are not restoring, attempt connecting - if(data['created'] && data['volume'] && data['connected'] == false && data['restoring'] == false){ + if(data['created'] && data['volume'] && data['connected'] == false && data['initializing'] == false){ fetch('/wallet/connect') } - // If ... + // If all of the above and now the wallet is connected, go to dashboard if(data['created'] && data['volume'] && data['connected']){ window.setInterval(function(){ window.location.href = "{{ url_for('wallet.dashboard') }}" @@ -26,13 +24,56 @@ function check_status(){ }) } -// Check every few seconds... -window.setInterval(function(){ - check_status(); -}, 10000); +$(document).ready(function () { + // Check wallet status every few seconds... + window.setInterval(function(){ + check_status(); + }, 7000); + + // ...but also check on initial page load + check_status(); + + // enter teh matrix + let q = document.getElementById('q'); + let width = q.width; + let height = q.height; + let yPositions = Array(300).join(0).split(''); + let ctx = q.getContext('2d'); + + let draw = function () { + ctx.fillStyle = 'rgba(0,0,0,.05)'; + ctx.fillRect(0, 0, width, height); + ctx.fillStyle = '#0F0'; + ctx.font = '10pt Georgia'; + yPositions.map(function (y, index) { + let text = String.fromCharCode(1e2 + Math.random() * 33); + let x = (index * 10) + 10; + q.getContext('2d').fillText(text, x, y); + if (y > 100 + Math.random() * 1e4) { + yPositions[index] = 0; + } + else { + yPositions[index] = y + 10; + } + }); + }; + + let matrix_interval = null; + + function RunMatrix() { + matrix_interval = setInterval(draw, 33); + } + + RunMatrix(); + + $('.teh_matrix span').each(function(i, obj){ + jQuery(obj).css('opacity', '1'); + }); + $('.teh_matrix img').each(function(i, obj){ + jQuery(obj).css('opacity', '1'); + }); +}); -// ...but also check on initial page load -check_status(); {% endif %} diff --git a/wowstash/templates/wallet/loading.html b/wowstash/templates/wallet/loading.html index f779a25..90c4021 100644 --- a/wowstash/templates/wallet/loading.html +++ b/wowstash/templates/wallet/loading.html @@ -5,17 +5,26 @@ - {% include 'navbar.html' %} - -
+

Your wallet is connecting

Go smoke a fatty. This page should auto-refresh when it's ready...if not, click the button below.

If you are restoring from a seed, please allow several minutes for the process to complete.

- +
+ + + + Very Secure Login™ + + ☑ many encryptions
+ ☑ very password
+ ☑ NASA certified
+ ☑ such login
+
+
diff --git a/wowstash/templates/wallet/setup.html b/wowstash/templates/wallet/setup.html index 1841a85..0360627 100644 --- a/wowstash/templates/wallet/setup.html +++ b/wowstash/templates/wallet/setup.html @@ -20,7 +20,7 @@


-

! WARNING !
If you input a mnemonic seed here I could theoretically steal your money, even without a wallet on my server; so could a hacker if they compromised my server.

+

! WARNING !
If you input a mnemonic seed here I could theoretically steal your funds, even without a wallet on my server; so could a hacker if they compromised my server.

You can and should use a wallet you can run locally to ensure your funds are safe, especially if there is a lot there. Proceed at your own risk.

{{ restore_form.csrf_token }} {% for f in restore_form %}