v1.3 testnet edition feature added. Update to isMiniFormat function.

This commit is contained in:
pointbiz 2011-11-28 20:22:12 -04:00
parent 132f70cd45
commit 0ba1fb6a6e

View file

@ -2,13 +2,16 @@
<html>
<head>
<!--
Donation Address: 1NiNja1bUmhSoTXozBRBEtR8LeF9TGbZBN
Notice of Copyrights and Licenses:
-------------------------------------
The bitaddress.org project, software and embedded resources are copyright bitaddress.org.
The bitaddress.org name and logo are not part of the open source license.
This HTML document is copyright bitaddress.org.
Portions of this document contain JavaScript codes that are the copyrights of others. The individual
copyrights are included throughout the document along with their licenses. Included JavaScript
libraries are separated with HTML script tags.
Portions of the all-in-one HTML document contain JavaScript codes that are the copyrights of others.
The individual copyrights are included throughout the document along with their licenses.
Included JavaScript libraries are separated with HTML script tags.
Summary of JavaScript functions with a redistributable license:
JavaScript function License
@ -20,6 +23,26 @@
window.BigInteger BSD License
window.QRCode MIT License
window.Bitcoin MIT License
The bitaddress.org software is available under The MIT License (MIT)
Copyright (c) 2011 bitaddress.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
GitHub Repository: https://github.com/pointbiz/bitaddress.org
-->
<title>bitaddress.org</title>
@ -3416,6 +3439,8 @@
})();
</script>
<script type="text/javascript">
var Bitcoin = {};
@ -3493,9 +3518,11 @@
bytes = Bitcoin.Address.decodeString(bytes);
}
this.hash = bytes;
this.version = 0x00;
this.version = Bitcoin.Address.networkVersion;
};
Bitcoin.Address.networkVersion = 0x00; // mainnet
Bitcoin.Address.prototype.toString = function () {
// Get a copy of the hash
var hash = this.hash.slice(0);
@ -3540,9 +3567,6 @@
Bitcoin.ECDSA = (function () {
var ecparams = EllipticCurve.getSECCurveByName("secp256k1");
var rng = new SecureRandom();
@ -3880,6 +3904,8 @@
.qrcode_tddark { border-width: 0px; border-style: none; border-color: #0000ff; border-collapse: collapse; padding: 0; margin: 0; width: 2px; height: 2px; background-color: #000000; }
.qrcode_tdlight { border-width: 0px; border-style: none; border-color: #0000ff; border-collapse: collapse; padding: 0; margin: 0; width: 2px; height: 2px; background-color: #ffffff; }
#testnet { font-family: Tahoma; display: none; background-color: Orange; color: #000000; border-radius: 5px; width: 700px; font-weight: bold; padding: 10px 0; margin: 0 auto 20px auto; }
@media screen
{
#tagline { margin: 0 0 15px 0; font-style: italic; }
@ -3934,6 +3960,10 @@
JavaScript Client-Side Bitcoin Wallet Generator
</div>
<div id="testnet">
TESTNET EDITION ACTIVATED
</div>
<div class="menu">
<div class="tab selected" id="singlewallet" onclick="ninja.tabSwitch(this);">Single Wallet</div>
<div class="tab" id="paperwallet" onclick="ninja.tabSwitch(this);">Paper Wallet</div>
@ -4026,7 +4056,7 @@
</div>
<div class="item" style="display: none;" id="detailmini">
<span class="label">Private Key Mini Format (22 characters, always starts with an 'S'):</span>
<span class="label">Private Key Mini Format (22, 26 or 30 characters, always starts with an 'S'):</span>
<span class="output" id="detailprivmini"></span>
</div>
</div>
@ -4411,13 +4441,15 @@
key = key.toString();
return (/^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789=+\/]{44}$/.test(key));
},
// 22 characters, always starts with an 'S'
// 22, 26 or 30 characters, always starts with an 'S'
isMiniFormat: function (key) {
key = key.toString();
var validChars = /^S[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21}$/.test(key);
var validChars22 = /^S[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21}$/.test(key);
var validChars26 = /^S[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{25}$/.test(key);
var validChars30 = /^S[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{29}$/.test(key);
var testBytes = Crypto.SHA256(key + "?", { asBytes: true });
return (testBytes[0] === 0 && validChars);
return ((testBytes[0] === 0x00 || testBytes[0] === 0x01) && (validChars22 || validChars26 || validChars30));
}
},
@ -4483,7 +4515,25 @@
}
},
walletType: { "singlewallet": "singlewallet", "bulkwallet": "bulkwallet", "paperwallet": "paperwallet", "detailwallet": "detailwallet" }
walletType: { "singlewallet": "singlewallet", "bulkwallet": "bulkwallet", "paperwallet": "paperwallet", "detailwallet": "detailwallet" },
getQueryString: function() {
var result = {}, queryString = location.search.substring(1), re = /([^&=]+)=([^&]*)/g, m;
while (m = re.exec(queryString)) {
result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
return result;
}
}
// testnet, check if testnet edition should be activated
if (ninja.getQueryString()["testnet"] == "true" || ninja.getQueryString()["testnet"] == "1") {
document.getElementById("testnet").style.display = "block";
Bitcoin.Address.networkVersion = 0x6f; // testnet
}
// if users does not move mouse after random amount of time then generate the key anyway.