diff --git a/liteaddress.org.html b/liteaddress.org.html index 6525ba29e..40949e30d 100644 --- a/liteaddress.org.html +++ b/liteaddress.org.html @@ -6791,7 +6791,10 @@
- +

+ + +
@@ -9642,6 +9645,86 @@ } }, + readFile: function() { + file = detailinputuploadfile.files[0]; + var reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = function(e) { + var key = reader.result; + ninja.wallets.detailwallet.viewUploadDetails( key ); + }; + }, + + viewUploadDetails: function (file) { + var bip38 = false; + file = Crypto.SHA256(file); + var key = file.toString().replace(/^\s+|\s+$/g, ""); // trim white space + document.getElementById("detailprivkey").value = key; + var bip38CommandDisplay = document.getElementById("detailbip38commands").style.display; + ninja.wallets.detailwallet.clear(); + if (key == "") { + return; + } + if (ninja.privateKey.isBIP38Format(key)) { + document.getElementById("detailbip38commands").style.display = bip38CommandDisplay; + if (bip38CommandDisplay != "block") { + document.getElementById("detailbip38commands").style.display = "block"; + document.getElementById("detailprivkeypassphrase").focus(); + return; + } + var passphrase = document.getElementById("detailprivkeypassphrase").value.toString() + if (passphrase == "") { + alert(ninja.translator.get("bip38alertpassphraserequired")); + return; + } + document.getElementById("busyblock").className = "busy"; + // show Private Key BIP38 Format + document.getElementById("detailprivbip38").innerHTML = key; + document.getElementById("detailbip38").style.display = "block"; + ninja.privateKey.BIP38EncryptedKeyToByteArrayAsync(key, passphrase, function (btcKeyOrError) { + document.getElementById("busyblock").className = ""; + if (btcKeyOrError.message) { + alert(btcKeyOrError.message); + ninja.wallets.detailwallet.clear(); + } else { + ninja.wallets.detailwallet.populateKeyDetails(new Bitcoin.ECKey(btcKeyOrError)); + } + }); + } + else { + if (Bitcoin.ECKey.isMiniFormat(key)) { + // show Private Key Mini Format + document.getElementById("detailprivmini").innerHTML = key; + document.getElementById("detailmini").style.display = "block"; + } + else if (Bitcoin.ECKey.isBase6Format(key)) { + // show Private Key Base6 Format + document.getElementById("detailprivb6").innerHTML = key; + document.getElementById("detailb6").style.display = "block"; + } + var btcKey = new Bitcoin.ECKey(key); + if (btcKey.priv == null) { + // enforce a minimum passphrase length + if (key.length >= ninja.wallets.brainwallet.minPassphraseLength) { + // Deterministic Wallet confirm box to ask if user wants to SHA256 the input to get a private key + var usePassphrase = confirm(ninja.translator.get("detailconfirmsha256")); + if (usePassphrase) { + var bytes = Crypto.SHA256(key, { asBytes: true }); + var btcKey = new Bitcoin.ECKey(bytes); + } + else { + ninja.wallets.detailwallet.clear(); + } + } + else { + alert(ninja.translator.get("detailalertnotvalidprivatekey")); + ninja.wallets.detailwallet.clear(); + } + } + ninja.wallets.detailwallet.populateKeyDetails(btcKey); + } + }, + populateKeyDetails: function (btcKey) { if (btcKey.priv != null) { btcKey.setCompressed(false);