simplify wallet init and enter teh matrix
This commit is contained in:
parent
d0b573a11c
commit
a2174b8d03
|
@ -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'))
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 216 KiB |
|
@ -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();
|
||||
|
||||
</script>
|
||||
{% endif %}
|
||||
|
|
|
@ -5,17 +5,26 @@
|
|||
|
||||
<body id="page-top">
|
||||
|
||||
{% include 'navbar.html' %}
|
||||
|
||||
<section class="section2">
|
||||
<section class="section1">
|
||||
<div class="container">
|
||||
<div class="section-heading text-center">
|
||||
<h2>Your wallet is connecting</h2>
|
||||
<p>Go smoke a fatty. This page should auto-refresh when it's ready...if not, click the button below. <br /><br />If you are restoring from a seed, please allow several minutes for the process to complete.</p>
|
||||
<img src="/static/img/loading-cat.gif" width=300>
|
||||
<div class="teh_matrix" style="position: relative;border-radius:4px;width:450px;margin-bottom:32px;border:1px solid green;height:250px;overflow:hidden;background-color:black;">
|
||||
<canvas id="q" width="450px" height="250px"></canvas>
|
||||
<span class="centered"></span>
|
||||
<img class="doge" width=80px src="/static/img/loading-doge.png"/>
|
||||
<span class="title">Very Secure Login™</span>
|
||||
<span class="body">
|
||||
☑ many encryptions<br>
|
||||
☑ very password<br>
|
||||
☑ NASA certified<br>
|
||||
☑ such login<br>
|
||||
</span>
|
||||
</div>
|
||||
<span class="dashboard-buttons">
|
||||
<div class="col-sm-12 dashboard-button">
|
||||
<a class="btn btn-lg btn-link btn-outline btn-xl" href="{{ url_for('wallet.dashboard') }}">Check Again</a>
|
||||
<a class="btn-link" href="{{ url_for('wallet.dashboard') }}">Check Again</a>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<hr><br /><br />
|
||||
|
||||
<form method="POST" action="{{ url_for('wallet.setup') }}" class="send-form">
|
||||
<p><strong>! WARNING !</strong><br /> 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.</p>
|
||||
<p><strong>! WARNING !</strong><br /> 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.</p>
|
||||
<p>You <strong>can</strong> and <strong>should</strong> use a <a href="https://wownero.org/#wallets" target="_blank">wallet</a> you can run locally to ensure your funds are safe, especially if there is a lot there. Proceed at your own risk.</p>
|
||||
{{ restore_form.csrf_token }}
|
||||
{% for f in restore_form %}
|
||||
|
|
Loading…
Reference in New Issue