forked from nebulasio/web-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewWalletInfo.html
More file actions
168 lines (153 loc) · 6.54 KB
/
Copy pathviewWalletInfo.html
File metadata and controls
168 lines (153 loc) · 6.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<link rel="icon shortcut" href=img/logo.png type=image/png>
<link rel=apple-touch-icon href=img/logo.png>
<link rel=stylesheet href=lib/bootstrap-4.0.0-dist/css/bootstrap.min.css>
<link rel=stylesheet href=css/base.css>
<link rel=stylesheet href=css/ui-block.css>
<meta name=viewport content="width=device-width">
<title>NEBULAS</title>
</head>
<style>
.qr_code>div {
display: inline-block;
}
.qr_code>.display-none {
display: none;
}
.transaction {
margin-top: 1rem;
display: none;
}
</style>
<body>
<div class=logo-main></div>
<div class=header></div>
<div class="container select-wallet-file"></div>
<div id=walletinfo class="container transaction">
<div class=row>
<div class=col>
<div class=form-group>
<label for=address data-i18n=wallet-info/your-addr>Your Address</label>
<input type=text class=form-control id=address disabled>
</div>
<div class=form-group>
<label for=amount data-i18n=wallet-info/acc-balance>Account Balance : </label>
<input type=text id=amount class=form-control disabled>
</div>
<div class=form-group>
<label for=keystore>
<span data-i18n=keystore-file>Keystore File</span>
(JSON / Recommended / Encrypted)
</label>
<button type=submit class="btn btn-default col-xs-12 col-sm-12 col-md-12 text-center" id=keystore data-i18n=download>Download</button>
</div>
<div class=form-group>
<label for=password data-i18n=wallet-info/private-key>Private Key (unencrypted)</label>
<input type=password id=password class=form-control disabled>
<div>
<input id=togglePassword type=checkbox>
<label for=togglePassword>visible</label>
</div>
</div>
</div>
<div class="col qr_code">
<div class=text-center>
<label for=addressqr data-i18n=wallet-info/your-addr>Your Address</label>
<div class=form-group id=addressqr></div>
</div>
<div class="display-none key_qr text-center">
<label for=privateqr data-i18n=wallet-info/private-key>Private Key (unencrypted)</label>
<div class=form-group id=privateqr></div>
</div>
</div>
</div>
</div>
<div class=footer></div>
<script src=lib/jquery-3.3.1.min.js></script>
<script src=lib/bootstrap-4.0.0-dist/js/bootstrap.bundle.min.js data-depends=jquery.slim></script>
<script src=lib/jquery.qrcode.min.js data-depends=jquery></script>
<script src=lib/bootbox.min.js data-depends="bootstrap jquery.slim"></script>
<script src=lib/Blob.js></script>
<script src=lib/FileSaver.min.js></script>
<script src=lib/nebulas.js></script>
<script src=js/1-localSave.js></script>
<script src=js/home.v1.js></script>
<script src=js/i18n.js data-depends=jquery.slim></script>
<script src=js/ui-block.js data-depends="bootbox blockies jquery.slim i18n.js nebulas.js"></script>
<script>
"use strict";
var nebulas = require("nebulas"),
Account = nebulas.Account,
Neb = nebulas.Neb,
Transaction = nebulas.Transaction,
Utils = nebulas.Utils,
neb = new Neb(),
gAccount, gFileJson;
neb.setRequest(new nebulas.HttpRequest(localSave.getItem("apiPrefix") || "https://testnet.nebulas.io/"));
$("#keystore").on("click", onClickKeystore);
$("#togglePassword").on("change", onChangeTogglePassword);
uiBlock.insert({
footer: ".footer",
header: ".header",
logoMain: ".logo-main",
selectWalletFile: [".select-wallet-file", onUnlockFile]
});
function onUnlockFile(swf, fileJson, account, password) {
try {
gAccount = account;
gFileJson = fileJson;
account.fromKey(fileJson, password);
$("#address").val(account.getAddressString());
$("#sideaddress").text(account.getAddressString());
$("#password").val(account.getPrivateKeyString());
$("#addressqr").html('').qrcode(account.getAddressString());
$("#privateqr").html('').qrcode(account.getPrivateKeyString());
$("#walletinfo").show();
neb.api.getAccountState(account.getAddressString())
.then(function (resp) {
if (resp.error) {
throw new Error(resp.error);
} else {
$("#amount").val(nebulas.Unit.fromBasic(Utils.toBigNumber(resp.balance), "nas").toNumber() + " NAS");
}
})
.catch(function (e) {
// this catches e thrown by nebulas.js!neb
bootbox.dialog({
backdrop: true,
onEscape: true,
message: i18n.apiErrorToText(e.message),
size: "large",
title: "Error"
});
});
} catch (e) {
// this catches e thrown by nebulas.js!account
bootbox.dialog({
backdrop: true,
onEscape: true,
message: localSave.getItem("lang") == "en" ? e : "keystore 文件错误, 或者密码错误",
size: "large",
title: "Error"
});
}
}
function onClickKeystore() {
var blob = new Blob([JSON.stringify(gFileJson)], { type: "application/json; charset=utf-8" });
saveAs(blob, gAccount.getAddressString());
}
function onChangeTogglePassword(e) {
if (e.target.checked) {
$("#password").prop("type", "text");
$(".key_qr").removeClass("display-none");
} else {
$("#password").prop("type", "password");
$(".key_qr").addClass("display-none");
}
}
</script>
</body>
</html>