Update README and attempt to fix whitespace.

This commit is contained in:
Jeff Weiss 2013-04-29 10:43:24 -04:00
parent 04e07e6def
commit e555680e1c
2 changed files with 77 additions and 82 deletions

1
README
View file

@ -49,6 +49,7 @@ window.EllipticCurve BSD License
window.BigInteger BSD License window.BigInteger BSD License
window.QRCode MIT License window.QRCode MIT License
window.Bitcoin MIT License window.Bitcoin MIT License
window.secrets MIT Licenses
The bitaddress.org software is available under The MIT License (MIT) The bitaddress.org software is available under The MIT License (MIT)
Copyright (c) 2011-2012 bitaddress.org Copyright (c) 2011-2012 bitaddress.org

View file

@ -7477,65 +7477,59 @@
<script type="text/javascript"> <script type="text/javascript">
ninja.wallets.splitwallet = { ninja.wallets.splitwallet = {
open: function () { open: function () {
/* if (document.getElementById("btcaddress").innerHTML == "") {
ninja.wallets.singlewallet.generateNewAddressAndKey();
} */
document.getElementById("splitarea").style.display = "block"; document.getElementById("splitarea").style.display = "block";
secrets.setRNG(); secrets.setRNG();
secrets.init(3); secrets.init(3);
}, },
close: function () { close: function () {
document.getElementById("splitarea").style.display = "none"; document.getElementById("splitarea").style.display = "none";
}, },
mkOutputRow: function(s,id,lbltxt) { mkOutputRow: function(s,id,lbltxt) {
var row = document.createElement("span"); var row = document.createElement("span");
var label = document.createElement("label"); var label = document.createElement("label");
label.innerHTML= lbltxt + s; label.innerHTML= lbltxt + s;
var qr = document.createElement("div"); var qr = document.createElement("div");
qr.setAttribute("id", id); qr.setAttribute("id", id);
row.appendChild(label); row.appendChild(label);
row.appendChild(qr); row.appendChild(qr);
row.appendChild(document.createElement("br")); row.appendChild(document.createElement("br"));
return row; return row;
}, },
stripLeadZeros: function(hex) { return hex.split(/^0+/).slice(-1)[0]; }, stripLeadZeros: function(hex) { return hex.split(/^0+/).slice(-1)[0]; },
// Split a private key and update information in the HTML // Split a private key and update information in the HTML
splitKey: function () { splitKey: function () {
try { try {
var key = new Bitcoin.ECKey(false); var key = new Bitcoin.ECKey(false);
var bitcoinAddress = key.getBitcoinAddress(); var bitcoinAddress = key.getBitcoinAddress();
var element = document.getElementById("splitoutput"); var element = document.getElementById("splitoutput");
if (element != null) element.parentNode.removeChild(element); if (element != null) element.parentNode.removeChild(element);
var numshares = parseInt(document.getElementById('splitshares').value); var numshares = parseInt(document.getElementById('splitshares').value);
var threshhold = parseInt(document.getElementById('splitthreshhold').value); var threshhold = parseInt(document.getElementById('splitthreshhold').value);
//alert(numshares) var shares = secrets.share(Crypto.util.bytesToHex(key.getBitcoinPrivateKeyByteArray()),
//alert(threshhold) numshares, threshhold).map(Crypto.util.hexToBytes).map(Bitcoin.Base58.encode);
var shares = secrets.share(Crypto.util.bytesToHex(key.getBitcoinPrivateKeyByteArray()), var output = document.createElement("div");
numshares, threshhold).map(Crypto.util.hexToBytes).map(Bitcoin.Base58.encode); output.setAttribute("id", "splitoutput");
//alert(shares); var m = {};
var output = document.createElement("div"); output.appendChild(this.mkOutputRow(bitcoinAddress, "split_addr", "Bitcoin Address: "));
output.setAttribute("id", "splitoutput"); m["split_addr"] = bitcoinAddress;
var m = {};
output.appendChild(this.mkOutputRow(bitcoinAddress, "split_addr", "Bitcoin Address: ")); for (var i=0; i < shares.length; i++) {
m["split_addr"] = bitcoinAddress; var id = "split_qr_"+ i;
output.appendChild(this.mkOutputRow(shares[i], id, "Share " + (i+1) + ": "));
for (var i=0; i < shares.length; i++) { m[id]=shares[i];
var id = "split_qr_"+ i; }
output.appendChild(this.mkOutputRow(shares[i], id, "Share " + (i+1) + ": "));
m[id]=shares[i]; document.getElementById("splitcommands").appendChild(output);
} ninja.qrCode.showQrCode(m);
document.getElementById("splitcommands").appendChild(output);
ninja.qrCode.showQrCode(m);
} }
catch (e) { catch (e) {
// browser does not have sufficient JavaScript support to generate a bitcoin address // browser does not have sufficient JavaScript support to generate a bitcoin address
@ -7546,37 +7540,37 @@
document.getElementById("qrcode_private").innerHTML = ""; document.getElementById("qrcode_private").innerHTML = "";
} }
}, },
// Combine shares of a private key to retrieve the key // Combine shares of a private key to retrieve the key
combineShares: function () { combineShares: function () {
try{ try {
var element = document.getElementById("combineoutput"); var element = document.getElementById("combineoutput");
if (element != null) element.parentNode.removeChild(element); if (element != null) element.parentNode.removeChild(element);
var shares = document.getElementById("combineinput").value.split(/\W+/); var shares = document.getElementById("combineinput").value.trim().split(/\W+/);
var combined = secrets.combine(shares.map(Bitcoin.Base58.decode). var combined = secrets.combine(shares.map(Bitcoin.Base58.decode).
map(Crypto.util.bytesToHex). map(Crypto.util.bytesToHex).
map(this.stripLeadZeros)); map(this.stripLeadZeros));
var privkeyBase58 = new Bitcoin.ECKey(Crypto.util.hexToBytes(combined)).getBitcoinWalletImportFormat(); var privkeyBase58 = new Bitcoin.ECKey(Crypto.util.hexToBytes(combined)).getBitcoinWalletImportFormat();
var output = document.createElement("div"); var output = document.createElement("div");
output.setAttribute("id", "combineoutput"); output.setAttribute("id", "combineoutput");
var txt = document.createElement("input"); var txt = document.createElement("input");
txt.setAttribute("id","combineoutputtext"); txt.setAttribute("id","combineoutputtext");
txt.setAttribute("value",privkeyBase58); txt.setAttribute("value",privkeyBase58);
txt.setAttribute("size",55); txt.setAttribute("size",55);
var lbl = document.createElement("label"); var lbl = document.createElement("label");
lbl.innerHTML="Private key"; lbl.innerHTML="Private key";
output.appendChild(lbl); output.appendChild(lbl);
output.appendChild(txt); output.appendChild(txt);
document.getElementById("combinecommands").appendChild(output); document.getElementById("combinecommands").appendChild(output);
} }
catch (e) { catch (e) {
alert(e); alert(e);
} }
} }
}; };
</script> </script>