This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.html
239 lines (202 loc) · 11.4 KB
/
index.html
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE HTML>
<html>
<head>
<title>Bitcoin Wallet | Binary.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Bitcoin Wallet">
<meta name="keywords" content="bitcoin, wallet, btc">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="apple-touch-icon" sizes="57x57" href="https://style.binary.com/images/favicons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="114x114" href="https://style.binary.com/images/favicons/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="https://style.binary.com/images/favicons/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="144x144" href="https://style.binary.com/images/favicons/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="60x60" href="https://style.binary.com/images/favicons/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="120x120" href="https://style.binary.com/images/favicons/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="76x76" href="https://style.binary.com/images/favicons/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="152x152" href="https://style.binary.com/images/favicons/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="https://style.binary.com/images/favicons/apple-touch-icon-180x180.png">
<link rel="icon" sizes="192x192" type="image/png" href="https://style.binary.com/images/favicons/favicon-192x192.png">
<link rel="icon" sizes="160x160" type="image/png" href="https://style.binary.com/images/favicons/favicon-160x160.png">
<link rel="icon" sizes="96x96" type="image/png" href="https://style.binary.com/images/favicons/favicon-96x96.png">
<link rel="icon" sizes="16x16" type="image/png" href="https://style.binary.com/images/favicons/favicon-16x16.png">
<link rel="icon" sizes="32x32" type="image/png" href="https://style.binary.com/images/favicons/favicon-32x32.png">
<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="https://style.binary.com/binary.css">
<script language='JavaScript' type='text/javascript' src='javascript/common.js'></script>
<script language='JavaScript' type='text/javascript' src='javascript/hashes.js'></script>
<script language='JavaScript' type='text/javascript' src='javascript/jsbn.js'></script>
<script language='JavaScript' type='text/javascript' src='javascript/elliptic.js'></script>
<script language='JavaScript' type='text/javascript' src='javascript/btc.js'></script>
<script language='JavaScript' type='text/javascript' src='javascript/backend_bci.js'></script>
<script src="javascript/password_check/Mellt.js"></script>
<!-- Make sure common-passwords.js is included AFTER Mellt.js -->
<script src="javascript/password_check/common-passwords.js"></script>
<style id="antiClickjack">body{display:none !important;}</style>
<script type="text/javascript">
if (self === top) {
var antiClickjack = document.getElementById("antiClickjack");
antiClickjack.parentNode.removeChild(antiClickjack);
} else {
top.location = self.location;
}
</script>
</head>
<body>
<div id="header-binary">
<a target="_blank" href="https://www.binary.com">
<img id="symbol-logo" src="https://style.binary.com/images/logo/symbol.svg" alt=""/>
<img id="type-logo" src="https://style.binary.com/images/logo/type.svg" alt="Binary.com"/>
</a>
</div>
<div id="wrapper">
<div id="container" class="center-text">
<span id="close" onclick="location.reload()" title="sign out"><img src="images/close_button.svg" /></span>
<div id="content">
<img src="images/bitcoin_wallet.svg"/>
<h1>Bitcoin Wallet</h1>
<p>This Bitcoin wallet works entirely in your browser. No information is ever sent to Binary.com</p>
<form id="pass_form" action="javascript:open_wallet();">
<p>To open your wallet, simply choose a very strong password.</p>
<input id="passphrase" type="password" placeholder="Passphrase" title="Can also use compressed WIF key.">
<button type="submit">Open</button>
<div class="hint" id="days_to_crack"></div>
</form>
<form id="send_form" action="javascript:send_tx();">
<div class="left-text">
<p>To deposit funds to your wallet, send Bitcoin to this address:</p>
<span id="adr"></span>
<div>
<h2 id="balance">Balance: </h2>
<span id="transactions"></span>
</div>
<div>
<input id="to" type="text" placeholder="Address">
<input id="amount" type="text" placeholder="Amount">
<button type="submit">Send</button>
</div>
</div>
<div id="status"></div>
</form>
<p>View the source code of this Bitcoin wallet on <a href="https://github.com/binary-com/bitcoin-wallet" target="_blank">Github</a>.</p>
</div>
</div>
</div>
<div id="footer" class="primary-bg-color content-inverse-color">
Notice: In the interest of keeping this wallet as user-friendly as possible, the wallet generates a private key from a password, and re-uses bitcoin addresses, both of which are not considered best practice. It is hence not recommended to use this wallet for large amounts of bitcoin. For larger bitcoin amounts we recommend using another wallet such as <a target="_blank" href="https://blockchain.info/wallet">blockchain.info/wallet</a>, <a target="_blank" href="https://copay.io">copay.io</a>, <a target="_blank" href="https://coinb.in">coinb.in</a>, <a target="_blank" href="https://breadwallet.com">breadwallet.com</a>, <a target="_blank" href="https://electrum.org">electrum.org</a>, <a target="_blank" href="https://wallet.mycelium.com">wallet.mycelium.com</a>, <a target="_blank" href="https://greenaddress.it">greenaddress.it</a>, <a target="_blank" href="https://bitcoinarmory.com">bitcoinarmory.com</a>, or <a target="_blank" href="https://multibit.org">multibit.org</a>.
</div>
<script>
var tx, keys, fee = 0.0001,
mellt;
function balance_cb(amount) {
if (isNaN(amount)) amount = '?'; else amount = js.format_money(amount, 8);
$('balance').innerHTML = "<span title='click to refresh' onclick='refresh(true);' style='cursor:pointer'>Balance: <b id=amt>" + amount + "</b> BTC</span>";
$('transactions').innerHTML = "<a class='button-secondary' href='" + backend.adr_page + keys.adr + "' target=_blank><span>transactions</span></a>";
}
function refresh(set_amount) {
if (set_amount) $('amt').innerHTML = '?';
backend.get_balance(keys.adr, balance_cb);
}
function open_wallet() {
var pass = js.trim($('passphrase').value);
if (pass.length < 1) return;
keys = btc.get_keys(pass);
$('pass_form').hide();
$('send_form').show();
$('close').show();
$('to').focus();
$('adr').innerHTML = "<b>" + keys.adr + "</b>– <a href='javascript:show_wif()'><span id='key_action'>Show</span> my private key</a><br><span id=wif></span>";
refresh();
setInterval(refresh, 60000);
}
function show_wif() {
if ($('wif').innerHTML == '') {
$('wif').innerHTML = keys.wif;
$('key_action').innerHTML = 'Hide';
} else {
$('wif').innerHTML = '';
$('key_action').innerHTML = 'Show';
}
}
function broadcast_cb(res) {
if (res === '') {
$('to').value = '';
$('amount').value = '';
$('status').innerHTML = '<a target="_blank" href="https://blockchain.info/tx/' + tx.txid() + '" target=_blank>Transaction</a> sent.';
}
else $('status').innerHTML = 'Error: ' + res;
tx = null;
js.enable_form('send_form', true);
setTimeout(refresh, 1000);
}
function broadcast() {
var status = $('status');
status.innerHTML = 'Signing tx...';
var signed = tx.sign(keys);
status.innerHTML = 'Broadcasting...';
backend.send(signed, broadcast_cb);
}
function unspent_cb(utxo) {
if (utxo !== false) {
var total = tx.add_unspent(utxo), err = '';
var tx_total = tx.amount + fee;
if (total >= tx_total) {
var change = total - tx_total;
if (change > 0.000001) tx.add_output(keys.adr, change);
setTimeout(broadcast, 300);
return;
}
else err = 'Not enough money! Need ' + js.format_money(tx_total - total, 8) + ' BTC more.';
}
else err = 'Failed to get unspent outputs!';
tx = null;
js.enable_form('send_form', true);
$('status').innerHTML = err;
}
function send_tx() {
var dst = js.trim($('to').value), amount = parseFloat(js.trim($('amount').value));
if (dst === '' || btc.decode_adr(dst) === false || isNaN(amount)) return;
if (confirm('Send ' + amount + ' BTC to ' + dst + '?')) {
tx = btc.new_tx();
tx.add_output(dst, amount);
js.enable_form('send_form', false);
$('status').innerHTML = 'Getting unspent outputs...';
backend.get_utxo(keys.adr, unspent_cb);
}
}
if (!JSON || !JSON.parse) alert("Your browser doesn't support native JSON decoding. This page will not work, sorry.");
else {
var x = new XMLHttpRequest();
if ('withCredentials' in x) {
// $('backend').innerHTML = backend.link;
$('pass_form').show();
var passphrase = $('passphrase');
passphrase.focus();
mellt = new Mellt();
passphrase.addEventListener('input', function () {
var pass = js.trim($('passphrase').value);
var daysToCrack = mellt.CheckPassword(pass);
var days_to_crack = $('days_to_crack');
if (daysToCrack < 0) {
days_to_crack.innerHTML = 'The password you entered is one of the world\'s most commonly used passwords. You should not be using this password.'
} else {
var years;
if (daysToCrack > 365) {
years = Math.round(daysToCrack / 365 * 10) / 10;
if (years > 1000000) {
years = (Math.round(years / 1000000 * 10) / 10) + ' million'
} else if (years > 1000) {
years = (Math.round(years / 1000)) + ' thousand'
}
}
days_to_crack.innerHTML = 'It takes approximately ' + (daysToCrack === 1000000000 ? '>' : '')
+ (years ? years + ' years' : daysToCrack + ' days')
+ ' to crack this password.';
}
days_to_crack.style.color = daysToCrack > 7 ? (days_to_crack < 30 ? '#AF7817' : 'green') : '#c03';
});
}
else alert("Your browser doesn't support Cross-Origin Resource Sharing. This page will not work, sorry.");
}
</script>
</body>
</html>