Add qr codes to split wallet, also now only generate new keys instead of accepting pasted keys generated elsewhere.
This commit is contained in:
parent
2b5ca8a5f3
commit
04e07e6def
1 changed files with 22 additions and 15 deletions
|
@ -6321,16 +6321,15 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="splitarea" class="walletarea">
|
<div id="splitarea" class="walletarea">
|
||||||
<div id="splitcommands" class="left commands">
|
<div id="splitcommands" class="left">
|
||||||
<span><label id="splitlabelenterprivatekey">Enter Private Key (Wallet Import Format)</label>
|
<span>
|
||||||
<input type="text" id="splitprivkey" value="" size="60" onfocus="this.select();" onkeypress="if (event.keyCode == 13) ninja.wallets.splitwallet.splitKey();"> <br/>
|
|
||||||
<label id="splitlabelshares">Number of shares</label>
|
<label id="splitlabelshares">Number of shares</label>
|
||||||
<input type="text" id="splitshares" value="4" size="4"/><br/>
|
<input type="text" id="splitshares" value="4" size="4"/><br/>
|
||||||
<label id="splitlabelthreshhold">Minimum share threshhold needed to combine</label>
|
<label id="splitlabelthreshhold">Minimum share threshhold needed to combine</label>
|
||||||
<input type="text" id="splitthreshhold" value="2" size="4"/>
|
<input type="text" id="splitthreshhold" value="2" size="4"/>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span><input type="button" id="splitview" value="Split Key" onclick="ninja.wallets.splitwallet.splitKey();"></span>
|
<span><input type="button" id="splitview" value="Generate" onclick="ninja.wallets.splitwallet.splitKey();"></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="combinecommands" class="left commands">
|
<div id="combinecommands" class="left commands">
|
||||||
<span>
|
<span>
|
||||||
|
@ -7490,17 +7489,17 @@
|
||||||
document.getElementById("splitarea").style.display = "none";
|
document.getElementById("splitarea").style.display = "none";
|
||||||
},
|
},
|
||||||
|
|
||||||
mkOutputRow: function(s,n) {
|
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="Share " + (n+1);
|
label.innerHTML= lbltxt + s;
|
||||||
var txt = document.createElement("input");
|
var qr = document.createElement("div");
|
||||||
txt.setAttribute("readOnly", true);
|
|
||||||
txt.setAttribute("value", s);
|
qr.setAttribute("id", id);
|
||||||
txt.setAttribute("size", 60);
|
|
||||||
row.appendChild(label);
|
row.appendChild(label);
|
||||||
row.appendChild(txt);
|
row.appendChild(qr);
|
||||||
row.appendChild(document.createElement("br"));
|
row.appendChild(document.createElement("br"));
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -7510,24 +7509,32 @@
|
||||||
// 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 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 privkeyBase58 = document.getElementById('splitprivkey').value;
|
|
||||||
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)
|
//alert(numshares)
|
||||||
//alert(threshhold)
|
//alert(threshhold)
|
||||||
var shares = secrets.share(Crypto.util.bytesToHex(Bitcoin.Base58.decode(privkeyBase58)),
|
var shares = secrets.share(Crypto.util.bytesToHex(key.getBitcoinPrivateKeyByteArray()),
|
||||||
numshares, threshhold).map(Crypto.util.hexToBytes).map(Bitcoin.Base58.encode);
|
numshares, threshhold).map(Crypto.util.hexToBytes).map(Bitcoin.Base58.encode);
|
||||||
//alert(shares);
|
//alert(shares);
|
||||||
var output = document.createElement("div");
|
var output = document.createElement("div");
|
||||||
output.setAttribute("id", "splitoutput");
|
output.setAttribute("id", "splitoutput");
|
||||||
|
var m = {};
|
||||||
|
output.appendChild(this.mkOutputRow(bitcoinAddress, "split_addr", "Bitcoin Address: "));
|
||||||
|
m["split_addr"] = bitcoinAddress;
|
||||||
|
|
||||||
for (var i=0; i < shares.length; i++) {
|
for (var i=0; i < shares.length; i++) {
|
||||||
output.appendChild(this.mkOutputRow(shares[i], 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);
|
document.getElementById("splitcommands").appendChild(output);
|
||||||
|
ninja.qrCode.showQrCode(m);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
@ -7552,7 +7559,7 @@
|
||||||
map(Crypto.util.bytesToHex).
|
map(Crypto.util.bytesToHex).
|
||||||
map(this.stripLeadZeros));
|
map(this.stripLeadZeros));
|
||||||
|
|
||||||
var privkeyBase58 = Bitcoin.Base58.encode(Crypto.util.hexToBytes(combined));
|
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");
|
||||||
|
|
Loading…
Reference in a new issue