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 id="splitarea" class="walletarea">
|
||||
<div id="splitcommands" class="left commands">
|
||||
<span><label id="splitlabelenterprivatekey">Enter Private Key (Wallet Import Format)</label>
|
||||
<input type="text" id="splitprivkey" value="" size="60" onfocus="this.select();" onkeypress="if (event.keyCode == 13) ninja.wallets.splitwallet.splitKey();"> <br/>
|
||||
<div id="splitcommands" class="left">
|
||||
<span>
|
||||
<label id="splitlabelshares">Number of shares</label>
|
||||
<input type="text" id="splitshares" value="4" size="4"/><br/>
|
||||
<label id="splitlabelthreshhold">Minimum share threshhold needed to combine</label>
|
||||
<input type="text" id="splitthreshhold" value="2" size="4"/>
|
||||
</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 id="combinecommands" class="left commands">
|
||||
<span>
|
||||
|
@ -7490,17 +7489,17 @@
|
|||
document.getElementById("splitarea").style.display = "none";
|
||||
},
|
||||
|
||||
mkOutputRow: function(s,n) {
|
||||
mkOutputRow: function(s,id,lbltxt) {
|
||||
var row = document.createElement("span");
|
||||
var label = document.createElement("label");
|
||||
label.innerHTML="Share " + (n+1);
|
||||
var txt = document.createElement("input");
|
||||
txt.setAttribute("readOnly", true);
|
||||
txt.setAttribute("value", s);
|
||||
txt.setAttribute("size", 60);
|
||||
label.innerHTML= lbltxt + s;
|
||||
var qr = document.createElement("div");
|
||||
|
||||
qr.setAttribute("id", id);
|
||||
row.appendChild(label);
|
||||
row.appendChild(txt);
|
||||
row.appendChild(qr);
|
||||
row.appendChild(document.createElement("br"));
|
||||
|
||||
return row;
|
||||
|
||||
},
|
||||
|
@ -7510,24 +7509,32 @@
|
|||
// Split a private key and update information in the HTML
|
||||
splitKey: function () {
|
||||
try {
|
||||
var key = new Bitcoin.ECKey(false);
|
||||
var bitcoinAddress = key.getBitcoinAddress();
|
||||
var element = document.getElementById("splitoutput");
|
||||
if (element != null) element.parentNode.removeChild(element);
|
||||
|
||||
var privkeyBase58 = document.getElementById('splitprivkey').value;
|
||||
var numshares = parseInt(document.getElementById('splitshares').value);
|
||||
var threshhold = parseInt(document.getElementById('splitthreshhold').value);
|
||||
//alert(numshares)
|
||||
//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);
|
||||
//alert(shares);
|
||||
var output = document.createElement("div");
|
||||
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++) {
|
||||
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);
|
||||
ninja.qrCode.showQrCode(m);
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
|
@ -7552,7 +7559,7 @@
|
|||
map(Crypto.util.bytesToHex).
|
||||
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");
|
||||
output.setAttribute("id", "combineoutput");
|
||||
var txt = document.createElement("input");
|
||||
|
|
Loading…
Reference in a new issue