From a92b637e72f69ecd7f0bfed17f5b0862ac89dbea Mon Sep 17 00:00:00 2001 From: kvhnuke Date: Sun, 24 Jan 2016 22:22:03 -0800 Subject: [PATCH] minor currency formatting --- index.html | 2 ++ js/etherwallet-master.min.js | 2 +- js/source/01_global.js | 16 ++++++++++++---- js/source/02_ajax.js | 2 +- pages/index.html | 2 ++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index d4c5e3759e..eb4d2415b8 100644 --- a/index.html +++ b/index.html @@ -244,6 +244,8 @@

Account Information

loading...
loading... +
+ loading...


diff --git a/js/etherwallet-master.min.js b/js/etherwallet-master.min.js index cfb2473edb..4e71f56a67 100644 --- a/js/etherwallet-master.min.js +++ b/js/etherwallet-master.min.js @@ -1 +1 @@ -function checkAndRedirectHTTPS(){var t="myetherwallet.com",e="kvhnuke.github.io",a="www.kvhnuke.github.io",n="www.myetherwallet.com";t!=window.location.host&&e!=window.location.host&&n!=window.location.host&&a!=window.location.host||"https:"==window.location.protocol||(window.location.protocol="https")}function checkAndLoadPageHash(){if(window.location.hash){var t=window.location.hash.substr(1);$(".ptabs").each(function(e){return $(this).attr("id")==t?($(this).click(),void setTimeout(function(){$("html,body").scrollTop(0)},50)):void 0})}}function paneNavigate(t,e){hideAllMainContainers(),$("#"+t).show(),$("#"+e).parent().addClass("active"),location.hash=e,$("html,body").scrollTop(0)}function bindElements(){$(".ptabs").each(function(t){$(this).click(function(){paneNavigate($(this).attr("showId"),this.id)})}),$("#privkeyenc,#address,#privkey").click(function(){this.focus(),this.select()}),$("#btndonate").click(function(){$("#sendtxaddress").val("0x7cb57b5a97eabe94205c07890be4c1ad31e486a8"),$("#donateThanks").show(),$("#sendtxaddress").trigger("keyup")}),$("#generatewallet").click(function(){generateSingleWallet()}),$("#btngeneratetranaction").click(function(){preCreateTransaction()}),$("#printqr").click(function(){printQRcode()}),$("#btnapprovesend").click(function(){preSendTransaction()}),$("#bulkgenerate").click(function(){generateBulkWallets()}),$("#transferAllBalance").click(function(){getMaxSendAmount($("#accountAddress").html(),function(t){$("#sendtxamount").val(t),$("input[type=radio][name=currencyRadio][value=ether]").prop("checked",!0),$("#sendtxamount").trigger("keyup")},function(t){$("#txcreatestatus").html('

'+t+"

").fadeIn(50).fadeOut(3e3)})}),$("#decryptdata").click(function(){$("#decryptStatus").html('

Please Wait...

').fadeIn(10),setTimeout(function(){decryptFormData()},100)}),$("input[type=radio][name=typeOfKeyRadio]").change(function(){PrivKey="",$("#fuploadStatus").empty(),$("#walletfilepassword").val(""),$("#privkeypassword").val(""),$(".btn-file :file").val(""),$("#manualprivkey").val(""),$("#walletuploadbutton").hide(),$("#walletPasdiv").hide(),$("#divprikeypassword").hide(),$("#wallettransactions").hide(),$("#decryptStatus").hide(),"fileupload"==this.value?($("#selectedTypeKey").hide(),$("#selectedUploadKey").show(),decryptType="fupload"):"pasteprivkey"==this.value&&($("#selectedUploadKey").hide(),$("#selectedTypeKey").show(),decryptType="privkey")}),$("input[type=radio][name=currencyRadio]").change(function(){$("#sendtxamount").trigger("keyup")}),$("#walletfilepassword").on("paste, keyup",function(){""!=$("#walletfilepassword").val()?($("#uploadbtntxt-wallet").show(),$("#uploadbtntxt-privkey").hide(),$("#walletuploadbutton").show()):$("#walletuploadbutton").hide()}),$("#sendtxamount").on("paste, keyup",function(){var t=$("#sendtxamount").val();if(""!=$("#sendtxamount").val()&&$.isNumeric(t)&&t>0){var e=$("input[type=radio][name=currencyRadio]:checked").val();$("#weiamount").html('

'+toWei(t,e)+" wei ( approximately "+toFiat(t,e,usdval)+" USD/"+toFiat(t,e,eurval)+" EUR )

")}else $("#weiamount").html(""==$("#sendtxamount").val()||$.isNumeric(t)?"":'

Invalid amount

')}),$("#sendtxaddress").on("paste, keyup",function(){validateEtherAddress($("#sendtxaddress").val())?$("#addressvalidate").html('

Address is valid

').fadeIn(50):""==$("#sendtxaddress").val()?$("#addressvalidate").html(""):$("#addressvalidate").html('

Invalid address

').fadeIn(50)}),$("#privkeypassword").on("paste, keyup",function(){$("#privkeypassword").val().length>6?($("#uploadbtntxt-wallet").hide(),$("#uploadbtntxt-privkey").show(),$("#walletuploadbutton").show()):$("#walletuploadbutton").hide()}),$("#manualprivkey").on("paste, keyup",function(){$("#divprikeypassword").hide(),$("#walletuploadbutton").hide(),$("#uploadbtntxt-wallet").hide(),$("#uploadbtntxt-privkey").hide(),$("#manualprivkey").val($("#manualprivkey").val().replace(/(?:\r\n|\r|\n| )/g,"")),128==$("#manualprivkey").val().length||132==$("#manualprivkey").val().length?$("#divprikeypassword").show():64==$("#manualprivkey").val().length&&($("#uploadbtntxt-wallet").hide(),$("#uploadbtntxt-privkey").show(),$("#walletuploadbutton").show())}),$(".btn-file :file").change(function(){if(!(window.File&&window.FileReader&&window.FileList&&window.Blob))return void alert("The File APIs are not fully supported in this browser. Please use a modern browser");var t=$(this),e=t.get(0).files?t.get(0).files.length:1,a=t.val().replace(/\\/g,"/").replace(/.*\//,"");t.trigger("fileselect",[e,a])}),$(".btn-file :file").on("fileselect",function(t,e,a){$("#fuploadStatus").empty(),$("#walletfilepassword").val(""),PrivKey="",file=$(".btn-file :file")[0].files[0];var n=new FileReader;n.onload=function(){try{walletRequirePass(n.result)?($("#walletPasdiv").show(),$("#walletuploadbutton").hide()):($("#walletPasdiv").hide(),$("#walletuploadbutton").show(),$("#uploadbtntxt-wallet").show(),$("#uploadbtntxt-privkey").hide())}catch(t){$("#fuploadStatus").append('

'+t+"

")}},n.readAsText(file);var r=$(this).parents(".input-group").find(":text"),i=e>1?e+" files selected":a;r.length?r.val(i):i&&$("#fuploadStatus").append('

File Selected: '+i+"

")})}function preSendTransaction(){sendTransaction($("#tasignedtx").val(),function(t){$("#txsendstatus").html('

Transaction submitted. TX ID: '+t+"

"),setWalletBalance()},function(t){$("#txsendstatus").html('

'+t+"

")}),$("#sendTransaction").modal("hide")}function preCreateTransaction(){try{$("#tarawtx").val(""),$("#tasignedtx").val(""),$("#txsendstatus").html("");var t=$("#sendtxaddress").val();if(64!=PrivKey.length)throw"Invalid Private key, try again";if(!validateEtherAddress(t))throw"Invalid to Address, try again";if(!$.isNumeric($("#sendtxamount").val())||$("#sendtxamount").val()<=0)throw"Invalid amount, try again";var e=$("input[type=radio][name=currencyRadio]:checked").val(),a=toWei($("#sendtxamount").val(),e);createTransaction(PrivKey,t,a,function(a){$("#tarawtx").val(a.raw),$("#tasignedtx").val(a.signed),$("#txcreatestatus").html('

Transaction generated

').fadeIn(50),$("#divtransactionTAs").show(),$("#divsendtranaction").show(),$("#confirmAmount").html($("#sendtxamount").val()),$("#confirmCurrancy").html(e),$("#confirmAddress").html(t)},function(t){$("#txcreatestatus").html('

'+t+"

").fadeIn(50).fadeOut(3e3),$("#divtransactionTAs").hide(),$("#divsendtranaction").hide()})}catch(n){$("#txcreatestatus").html('

'+n+"

").fadeIn(50).fadeOut(3e3),$("#divtransactionTAs").hide(),$("#divsendtranaction").hide()}}function setWalletBalance(){getBalance($("#accountAddress").html(),function(t){if(t.error)alert(t.msg);else{var e=getBestEtherKnownUnit(t.data.balance);$("#accountBalance").html(e.amount+" "+e.unit),getETHvalue("USD",function(t){usdval=toFiat(e.amount,e.unit,t),$("#accountBalanceUsd").html(usdval+" USD")}),getETHvalue("EUR",function(t){eurval=toFiat(e.amount,e.unit,t),$("#accountBalanceEur").html(eurval+" EUR")})}})}function walletDecryptSuccess(){$("#accountAddress").html(formatAddress(strPrivateKeyToAddress(PrivKey),"hex")),setWalletBalance(),$("#decryptStatus").html('

Wallet successfully decrypted

').fadeIn(2e3),$("#wallettransactions").show()}function walletDecryptFailed(t){$("#decryptStatus").html('

'+t+"

").fadeIn(50).fadeOut(3e3),$("#wallettransactions").hide()}function decryptFormData(){if(PrivKey="","fupload"==decryptType){file=$(".btn-file :file")[0].files[0];var t=new FileReader;t.onload=function(){try{PrivKey=getWalletFilePrivKey(t.result,$("#walletfilepassword").val()),walletDecryptSuccess()}catch(e){walletDecryptFailed(e)}},t.readAsText(file)}else if("privkey"==decryptType)try{PrivKey=decryptTxtPrivKey($("#manualprivkey").val(),$("#privkeypassword").val()),walletDecryptSuccess()}catch(e){walletDecryptFailed("Invalid password")}}function hideAllMainContainers(){$("#paneWalgen").hide(),$("#paneBulkgen").hide(),$("#paneSendTrans").hide(),$("#panePopContracts").hide(),$("#paneHelp").hide(),$("#paneContact").hide(),$("#panePrint").hide(),$("#bulk-generate").parent().removeClass("active"),$("#generate-wallet").parent().removeClass("active"),$("#send-transaction").parent().removeClass("active"),$("#popular-contracts").parent().removeClass("active"),$("#help").parent().removeClass("active"),$("#contact").parent().removeClass("active")}function generateSingleWallet(){var t=$("#ethgenpassword").val();if(""==t)return void alert("Please enter a password.");if(t.length<7)return void alert("Your password must be at least 7 characters");$("#generatedWallet").show();var e=new Accounts,a=e["new"](t);$("#address").val(a.address);var n=cryptoJSToHex(CryptoJS.SHA3(a.address));n=n.substr(n.length-4);var r=e.get(a.address,t);$("#privkey").val(r["private"]),a["private"]=a["private"]+n,$("#privkeyenc").val(a["private"]),$("#qrcodeAdd").empty(),new QRCode($("#qrcodeAdd")[0],{text:a.address,width:$("#qrcode").width(),height:$("#qrcode").width(),colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.H}),$("#qrcode").empty(),new QRCode($("#qrcode")[0],{text:r["private"],width:$("#qrcode").width(),height:$("#qrcode").width(),colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.H});var i="text/json;charset=UTF-8",o=new Blob([JSON.stringify(a)],{type:i}),s=new Blob([JSON.stringify(r)],{type:i});$("#encdownload").attr("href",window.URL.createObjectURL(o)),$("#encdownload").attr("download",a.address+"-Encrypted.json"),$("#unencdownload").attr("href",window.URL.createObjectURL(s)),$("#unencdownload").attr("download",a.address+"-Unencrypted.json"),e.clear()}function generateBulkWallets(){var t=$("#bulkgenpassword").val(),e=$("#numberwallets").val();if(""==e)return void alert("Please enter the amount of wallets you want to generate.");if(e!=parseInt(e,10))return void alert("Digits only please");var a=!1;if(""!=t&&t.length<7)return void alert("Your password must be at least 7 characters.");""!=t&&t.length>=7&&(a=!0),$("#bulkIsEnc").html(a?" (Encrypted)":" (Unencrypted)"),$("#generatedbulkwallets").show(),$("#bulkgentable tr:not(:first)").remove();for(var n=new Accounts,r="",i=[],o=[],s="",l=0;e>l;l++){if(a){var d=n["new"](t),c=cryptoJSToHex(CryptoJS.SHA3(d.address));c=c.substr(c.length-4),d["private"]=d["private"]+c}else var d=n["new"]();$("#bulkgentable tr:last").after('"),r+=d.address+","+d["private"]+"\n",s+=d.address+" "+d["private"]+"\n",i.push({address:d.address,"private":d["private"]}),o.push({address:d.address,"private":n.get(d.address,t)["private"]})}var u=new Blob([r],{type:"text/csv;charset=UTF-8"}),p=new Blob([s],{type:"text/plain;charset=UTF-8"}),v=new Blob([JSON.stringify(i)],{type:"text/json;charset=UTF-8"}),h="bulk_ether_accounts";$("#bulkexportjson").attr("href",window.URL.createObjectURL(v)),$("#bulkexportjson").attr("download",h+".json"),$("#bulkexportcsv").attr("href",window.URL.createObjectURL(u)),$("#bulkexportcsv").attr("download",h+".csv"),$("#bulkexporttxt").attr("href",window.URL.createObjectURL(p)),$("#bulkexporttxt").attr("download",h+".txt"),$("#bulkwalletprint").unbind(),$("#bulkwalletprint").click(function(){openPrintPaperWallets(JSON.stringify(o))}),n.clear()}function openPrintPaperWallets(t){var e=window.open("about:blank","_blank");data='',data=data.replace("{{WALLETJSON}}",t),e.document.write(data),$(e).ready(function(){e.document.write("")})}function printQRcode(){var t=$("#address").val(),e=$("#privkey").val(),a=[];a.push({address:t,"private":e}),openPrintPaperWallets(JSON.stringify(a))}function getBalance(t,e){$.post(SERVERURL,{balance:t}).done(e)}function getTransactionData(t,e){$.post(SERVERURL,{txdata:t}).done(e)}function sendRawTx(t,e){$.post(SERVERURL,{rawtx:t}).done(e)}function getEstimatedGas(t,e){$.post(SERVERURL,{estimatedGas:t}).done(e)}function getEthCall(t,e){$.post(SERVERURL,{ethCall:t}).done(e)}function getETHvalue(t,e){var a="XETHZ";$.post(KRAKENAPI+"Ticker",{pair:a+t}).done(function(n){e(n.result[a+t].o)})}function createTransaction(t,e,a,n,r){if(64!=t.length)return void r("Invalid Private key, try again");if(!validateEtherAddress(e))return void r("Invalid to Address, try again");if(!$.isNumeric(a)||0>=a)return void r("Invalid amount, try again");var i=new Buffer(t,"hex"),o=strPrivateKeyToAddress(t);getTransactionData(o,function(t){if(t.error)return void r("Error occurred: "+t.msg);t=t.data;var o=padLeftEven(BNtoHex(new BigNumber(t.nonce))),s=padLeftEven(BNtoHex(new BigNumber(t.gasprice).plus(1e9).toDigits(1))),l=padLeftEven(BNtoHex(new BigNumber(stdTransactionGas))),d=padLeftEven(BNtoHex(new BigNumber(String(a)))),c={nonce:"0x"+o,gasPrice:"0x"+s,gasLimit:"0x"+l,to:e,value:"0x"+d,data:""},u=new Tx(c);u.sign(i),verifyUpFrontCost(c,function(e){if(e>t.balance)return void r("You dont have enough balance in your account to process is transaction");var a="0x"+u.serialize().toString("hex"),i={raw:JSON.stringify(c),signed:a};n(i)},r)})}function createTransactionFromRaw(t,e,a,n){if(64!=e.length)return void n("Invalid Private key, try again");if(!validateEtherAddress(t.from)||!validateEtherAddress(t.to))return void n("Invalid Address, try again");if(!$.isNumeric(t.value)||t.value<=0)return void n("Invalid amount, try again");var r=new Buffer(e,"hex"),i=strPrivateKeyToAddress(e);getTransactionData(i,function(e){if(e.error)return void n("Error occurred: "+e.msg);e=e.data;var i=padLeftEven(BNtoHex(new BigNumber(e.nonce))),o=padLeftEven(BNtoHex(new BigNumber(e.gasprice).plus(1e9).toDigits(1))),s=padLeftEven(BNtoHex(new BigNumber(t.gas))),l=padLeftEven(BNtoHex(new BigNumber(String(t.value)))),d={nonce:"0x"+i,gasPrice:"0x"+o,gasLimit:"0x"+s,to:t.to,value:"0x"+l,data:"0x"+t.data},c=new Tx(d);c.sign(r),verifyUpFrontCost(d,function(t){if(t>e.balance)return void n("You dont have enough balance in your account to process is transaction");var r="0x"+c.serialize().toString("hex"),i={raw:JSON.stringify(d),signed:r};a(i)},n)})}function verifyUpFrontCost(t,e,a){getEstimatedGas(t,function(n){if(n.error)a("Error occurred: "+n.msg);else if(new BigNumber(formatHexString(n.data,"hex")).greaterThan(new BigNumber(formatHexString(t.gasLimit,"hex"))))a("Gas limit is too low");else{var r=new BigNumber(formatHexString(t.gasPrice,"hex")).times(new BigNumber(formatHexString(t.gasLimit,"hex")));e(r.plus(new BigNumber(formatHexString(t.value,"hex"))).toNumber())}})}function getMaxSendAmount(t,e,a){getTransactionData(t,function(t){if(t.error)return void a("Error occurred: "+t.msg);t=t.data;var n=new BigNumber(t.gasprice).plus(1e9).toDigits(1).times(stdTransactionGas),r=new BigNumber(String(t.balance)).minus(n);r.lessThan(0)?a("Not enough balance to send a transaction"):e(toEther(r.toString(),"wei"))})}function sendTransaction(t,e,a){sendRawTx(t,function(t){return t.error?void a("Error occurred: "+t.msg):void e(t.data)})}function BNtoHex(t){return t.toString(16)}function padLeftEven(t){return t.length%2!=0?"0"+t:t}function formatHexString(t,e){return"hex"==e?"0x"==t.substring(0,2)?t:"0x"+t:"raw"==e?"0x"==t.substring(0,2)?t.substring(2):t:void 0}function fiatToWei(t,e){var a=new BigNumber(String(t)).div(e).times(getValueOfUnit("ether")).round(0);return a.toString(10)}function toFiat(t,e,a){var n=new BigNumber(toEther(t,e)).times(a).round(5);return n.toString(10)}function toEther(t,e){var a=new BigNumber(toWei(t,e)).div(getValueOfUnit("ether"));return a.toString(10)}function toWei(t,e){var a=new BigNumber(String(t)).times(getValueOfUnit(e));return a.toString(10)}function getValueOfUnit(t){t=t?t.toLowerCase():"ether";var e=unitMap[t];if(void 0===e)throw new Error("This unit doesn't exists, please use the one of the following units"+JSON.stringify(unitMap,null,2));return new BigNumber(e,10)}function getBestEtherKnownUnit(t){t=String(t);var e="wei",a=new BigNumber(t);for(var n in knownUnitMap)knownUnitMap.hasOwnProperty(n)&&new BigNumber(t).greaterThan(new BigNumber(knownUnitMap[n]))&&(e=n,a=new BigNumber(t).div(new BigNumber(knownUnitMap[n])));return{unit:e,amount:a.toDigits(10).toString(10)}}function decryptPresaleKey(t,e){t=JSON.parse(t);var a=hexToBytes(t.encseed),n=hexToCryptoJS(bytesToHex(a.slice(0,16))),r=hexToCryptoJS(bytesToHex(a.slice(16))),i=sha256.pbkdf2(stringToBytes(e),stringToBytes(e),2e3,16),o=hexToBytes(bytesToHex(i)).slice(0,16),s=CryptoJS.AES.decrypt({ciphertext:r},hexToCryptoJS(bytesToHex(o)),{iv:n,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),l=cryptoJSToHex(s);s=hex2str(l);var d=CryptoJS.SHA3(s,{outputLength:256}),c=d.toString();if(verifyPrivKey(c,t.ethaddr))return c;throw"Invalid Password"}function decryptGethKeyV3(t,e){t=JSON.parse(t),null==t.Crypto&&null!=t.crypto&&(t.Crypto=t.crypto);var a=t.Crypto.cipherparams.iv,n=t.Crypto.ciphertext,r=getKDFKey(t.Crypto,e),i=hexToBytes(bytesToHex(r)).slice(0,16),o=CryptoJS.AES.decrypt({ciphertext:hexToCryptoJS(n)},hexToCryptoJS(bytesToHex(i)),{mode:CryptoJS.mode.CTR,padding:CryptoJS.pad.ZeroPadding,iv:hexToCryptoJS(a)}),s=cryptoJSToHex(o);if(verifyPrivKey(s,t.address))return s;throw"Invalid Password"}function decryptTxtPrivKey(t,e){if(128==t.length)var a=CryptoJS.AES.decrypt(t,e),n=hex2str(cryptoJSToHex(a));else if(132==t.length){var a=CryptoJS.AES.decrypt(t.substr(0,128),e),n=hex2str(cryptoJSToHex(a)),r=t.substr(t.length-4),i=formatAddress(strPrivateKeyToAddress(n),"hex"),o=cryptoJSToHex(CryptoJS.SHA3(i));if(o.substr(o.length-4)!=r)throw"Invalid Password"}else{if(64!=t.length)throw"Error while decrypting your wallet";var n=t}return n}function decryptEthWalletJson(t,e){if(t=JSON.parse(t),t.locked&&128==t["private"].length)var a=CryptoJS.AES.decrypt(t["private"],e),n=hex2str(cryptoJSToHex(a));else if(t.locked&&132==t["private"].length)var a=CryptoJS.AES.decrypt(t["private"].substr(0,128),e),n=hex2str(cryptoJSToHex(a));else{if(t.locked||64!=t["private"].length)throw"Error while decrypting your wallet";var n=t["private"]}if(verifyPrivKey(n,formatAddress(t.address,"raw")))return n;throw"Invalid Password"}function walletRequirePass(t){var e;try{e=JSON.parse(t)}catch(a){throw"not a valid wallet file"}if(null!=e.encseed)return!0;if(null!=e.Crypto||null!=e.crypto)return!0;if(null!=e.hash&&e.locked)return!0;if(null==e.hash||e.locked)throw"Sorry! we dont have a clue what kind of wallet file this is.";return!1}function verifyPrivKey(t,e){return 64!=t.length?!1:strPrivateKeyToAddress(t)!=e?!1:!0}function getWalletFilePrivKey(t,e){var a=JSON.parse(t);if(null!=a.encseed)return decryptPresaleKey(t,e);if(null!=a.Crypto||null!=a.crypto)return decryptGethKeyV3(t,e);if(null!=a.hash)return decryptEthWalletJson(t,e);throw"Sorry! we dont have a clue what kind of wallet file this is."}function formatAddress(t,e){return"0x"==t.substr(0,2)&&"raw"==e&&(t=t.substr(2)),"0x"!=t.substr(0,2)&&"hex"==e&&(t="0x"+t),t}function strPrivateKeyToAddress(t){var e=ethUtil.privateToPublic(new Buffer(t,"hex"));return ethUtil.publicToAddress(e).toString("hex")}function getKDFKey(t,e){var a=hexToBytes(t.kdfparams.salt),n=stringToBytes(e),r=t.kdfparams.dklen;if("scrypt"==t.kdf){var i=t.kdfparams.n,o=t.kdfparams.r,s=t.kdfparams.p,l=scrypt_module_factory(335544320);return l.crypto_scrypt(n,a,i,o,s,r)}if("pbkdf2"==t.kdf){var d=t.kdfparams.c,c=(t.kdfparams.prf,sha256.pbkdf2(stringToBytes(e),hexToBytes(t.kdfparams.salt),d,r));return c}}function hexToCryptoJS(t){return CryptoJS.enc.Hex.parse(t)}function cryptoJSToHex(t){return CryptoJS.enc.Hex.stringify(t)}function validateEtherAddress(t){return 42==t.length&&"0x"==t.substr(0,2)&&/^[0-9A-F]+$/i.test(t.substr(2))}function hex2str(t){for(var t=t.toString(),e="",a=0;a>>4).toString(16)),e.push((15&t[a]).toString(16));return e.join("")}function hexToBytes(t){for(var e=[],a=0;a Transaction generated

').fadeIn(50),$("#divtransactionTAs").show(),$("#divsendtranaction").show(),$("#confirmAmount").html($("#sendtxamount").val()),$("#confirmCurrancy").html(t)},function(t){$("#txcreatestatus").html('

'+t+"

").fadeIn(50).fadeOut(3e3),$("#divtransactionTAs").hide(),$("#divsendtranaction").hide()})}catch(n){$("#txcreatestatus").html('

'+n+"

").fadeIn(50).fadeOut(3e3),$("#divtransactionTAs").hide(),$("#divsendtranaction").hide()}}var PrivKey="",decryptType="",usdval,eurval,web3=new Web3;$(document).ready(function(){bindElements(),checkAndLoadPageHash(),checkAndRedirectHTTPS()});var SERVERURL="https://rpc.myetherwallet.com/api.php",KRAKENAPI="https://api.kraken.com/0/public/",stdTransactionGas=21e3,knownUnitMap={wei:"1",kwei:"1000",gwei:"1000000000",szabo:"1000000000000",finney:"1000000000000000",ether:"1000000000000000000"},unitMap={wei:"1",kwei:"1000",ada:"1000",femtoether:"1000",mwei:"1000000",babbage:"1000000",picoether:"1000000",gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",einstein:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};$(document).ready(function(){bindAugurElements()});var augurContract=web3.eth.contract([{name:"addrToFunder(int256)",type:"function",inputs:[{name:"address",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"buyRep()",type:"function",inputs:[],outputs:[{name:"out",type:"int256"}]},{name:"getAddrByIndex(int256)",type:"function",inputs:[{name:"index",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"getAmountSent(int256)",type:"function",inputs:[{name:"address",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"getAmtByIndex(int256)",type:"function",inputs:[{name:"index",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"getBlockNumByIndex(int256)",type:"function",inputs:[{name:"index",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"getBlockNumSent(int256)",type:"function",inputs:[{name:"address",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"getFunderNum()",type:"function",inputs:[],outputs:[{name:"out",type:"int256"}]},{name:"getFundsRaised()",type:"function",inputs:[],outputs:[{name:"out",type:"int256"}]}]).at("0xe28e72fcf78647adce1f1252f240bbfaebd63bcc"); \ No newline at end of file +function checkAndRedirectHTTPS(){var t="myetherwallet.com",e="kvhnuke.github.io",a="www.kvhnuke.github.io",n="www.myetherwallet.com";t!=window.location.host&&e!=window.location.host&&n!=window.location.host&&a!=window.location.host||"https:"==window.location.protocol||(window.location.protocol="https")}function checkAndLoadPageHash(){if(window.location.hash){var t=window.location.hash.substr(1);$(".ptabs").each(function(e){return $(this).attr("id")==t?($(this).click(),void setTimeout(function(){$("html,body").scrollTop(0)},50)):void 0})}}function paneNavigate(t,e){hideAllMainContainers(),$("#"+t).show(),$("#"+e).parent().addClass("active"),location.hash=e,$("html,body").scrollTop(0)}function bindElements(){$(".ptabs").each(function(t){$(this).click(function(){paneNavigate($(this).attr("showId"),this.id)})}),$("#privkeyenc,#address,#privkey").click(function(){this.focus(),this.select()}),$("#btndonate").click(function(){$("#sendtxaddress").val("0x7cb57b5a97eabe94205c07890be4c1ad31e486a8"),$("#donateThanks").show(),$("#sendtxaddress").trigger("keyup")}),$("#generatewallet").click(function(){generateSingleWallet()}),$("#btngeneratetranaction").click(function(){preCreateTransaction()}),$("#printqr").click(function(){printQRcode()}),$("#btnapprovesend").click(function(){preSendTransaction()}),$("#bulkgenerate").click(function(){generateBulkWallets()}),$("#transferAllBalance").click(function(){getMaxSendAmount($("#accountAddress").html(),function(t){$("#sendtxamount").val(t),$("input[type=radio][name=currencyRadio][value=ether]").prop("checked",!0),$("#sendtxamount").trigger("keyup")},function(t){$("#txcreatestatus").html('

'+t+"

").fadeIn(50).fadeOut(3e3)})}),$("#decryptdata").click(function(){$("#decryptStatus").html('

Please Wait...

').fadeIn(10),setTimeout(function(){decryptFormData()},100)}),$("input[type=radio][name=typeOfKeyRadio]").change(function(){PrivKey="",$("#fuploadStatus").empty(),$("#walletfilepassword").val(""),$("#privkeypassword").val(""),$(".btn-file :file").val(""),$("#manualprivkey").val(""),$("#walletuploadbutton").hide(),$("#walletPasdiv").hide(),$("#divprikeypassword").hide(),$("#wallettransactions").hide(),$("#decryptStatus").hide(),"fileupload"==this.value?($("#selectedTypeKey").hide(),$("#selectedUploadKey").show(),decryptType="fupload"):"pasteprivkey"==this.value&&($("#selectedUploadKey").hide(),$("#selectedTypeKey").show(),decryptType="privkey")}),$("input[type=radio][name=currencyRadio]").change(function(){$("#sendtxamount").trigger("keyup")}),$("#walletfilepassword").on("paste, keyup",function(){""!=$("#walletfilepassword").val()?($("#uploadbtntxt-wallet").show(),$("#uploadbtntxt-privkey").hide(),$("#walletuploadbutton").show()):$("#walletuploadbutton").hide()}),$("#sendtxamount").on("paste, keyup",function(){var t=$("#sendtxamount").val();if(""!=$("#sendtxamount").val()&&$.isNumeric(t)&&t>0){var e=$("input[type=radio][name=currencyRadio]:checked").val();$("#weiamount").html('

'+toWei(t,e)+" wei ( approximately "+toFiat(t,e,usdval)+" USD/"+toFiat(t,e,eurval)+" EUR )

")}else $("#weiamount").html(""==$("#sendtxamount").val()||$.isNumeric(t)?"":'

Invalid amount

')}),$("#sendtxaddress").on("paste, keyup",function(){validateEtherAddress($("#sendtxaddress").val())?$("#addressvalidate").html('

Address is valid

').fadeIn(50):""==$("#sendtxaddress").val()?$("#addressvalidate").html(""):$("#addressvalidate").html('

Invalid address

').fadeIn(50)}),$("#privkeypassword").on("paste, keyup",function(){$("#privkeypassword").val().length>6?($("#uploadbtntxt-wallet").hide(),$("#uploadbtntxt-privkey").show(),$("#walletuploadbutton").show()):$("#walletuploadbutton").hide()}),$("#manualprivkey").on("paste, keyup",function(){$("#divprikeypassword").hide(),$("#walletuploadbutton").hide(),$("#uploadbtntxt-wallet").hide(),$("#uploadbtntxt-privkey").hide(),$("#manualprivkey").val($("#manualprivkey").val().replace(/(?:\r\n|\r|\n| )/g,"")),128==$("#manualprivkey").val().length||132==$("#manualprivkey").val().length?$("#divprikeypassword").show():64==$("#manualprivkey").val().length&&($("#uploadbtntxt-wallet").hide(),$("#uploadbtntxt-privkey").show(),$("#walletuploadbutton").show())}),$(".btn-file :file").change(function(){if(!(window.File&&window.FileReader&&window.FileList&&window.Blob))return void alert("The File APIs are not fully supported in this browser. Please use a modern browser");var t=$(this),e=t.get(0).files?t.get(0).files.length:1,a=t.val().replace(/\\/g,"/").replace(/.*\//,"");t.trigger("fileselect",[e,a])}),$(".btn-file :file").on("fileselect",function(t,e,a){$("#fuploadStatus").empty(),$("#walletfilepassword").val(""),PrivKey="",file=$(".btn-file :file")[0].files[0];var n=new FileReader;n.onload=function(){try{walletRequirePass(n.result)?($("#walletPasdiv").show(),$("#walletuploadbutton").hide()):($("#walletPasdiv").hide(),$("#walletuploadbutton").show(),$("#uploadbtntxt-wallet").show(),$("#uploadbtntxt-privkey").hide())}catch(t){$("#fuploadStatus").append('

'+t+"

")}},n.readAsText(file);var r=$(this).parents(".input-group").find(":text"),i=e>1?e+" files selected":a;r.length?r.val(i):i&&$("#fuploadStatus").append('

File Selected: '+i+"

")})}function preSendTransaction(){sendTransaction($("#tasignedtx").val(),function(t){$("#txsendstatus").html('

Transaction submitted. TX ID: '+t+"

"),setWalletBalance()},function(t){$("#txsendstatus").html('

'+t+"

")}),$("#sendTransaction").modal("hide")}function preCreateTransaction(){try{$("#tarawtx").val(""),$("#tasignedtx").val(""),$("#txsendstatus").html("");var t=$("#sendtxaddress").val();if(64!=PrivKey.length)throw"Invalid Private key, try again";if(!validateEtherAddress(t))throw"Invalid to Address, try again";if(!$.isNumeric($("#sendtxamount").val())||$("#sendtxamount").val()<=0)throw"Invalid amount, try again";var e=$("input[type=radio][name=currencyRadio]:checked").val(),a=toWei($("#sendtxamount").val(),e);createTransaction(PrivKey,t,a,function(a){$("#tarawtx").val(a.raw),$("#tasignedtx").val(a.signed),$("#txcreatestatus").html('

Transaction generated

').fadeIn(50),$("#divtransactionTAs").show(),$("#divsendtranaction").show(),$("#confirmAmount").html($("#sendtxamount").val()),$("#confirmCurrancy").html(e),$("#confirmAddress").html(t)},function(t){$("#txcreatestatus").html('

'+t+"

").fadeIn(50).fadeOut(3e3),$("#divtransactionTAs").hide(),$("#divsendtranaction").hide()})}catch(n){$("#txcreatestatus").html('

'+n+"

").fadeIn(50).fadeOut(3e3),$("#divtransactionTAs").hide(),$("#divsendtranaction").hide()}}function setWalletBalance(){getBalance($("#accountAddress").html(),function(t){if(t.error)alert(t.msg);else{var e=getBestEtherKnownUnit(t.data.balance);$("#accountBalance").html(e.amount+" "+e.unit),getETHvalue("ZUSD",function(t){usdval=toFiat(e.amount,e.unit,t),$("#accountBalanceUsd").html(formatCurrency(usdval,"$")+" USD")}),getETHvalue("ZEUR",function(t){eurval=toFiat(e.amount,e.unit,t),$("#accountBalanceEur").html(formatCurrency(eurval,"�")+" EUR")}),getETHvalue("XXBT",function(t){btcval=toFiat(e.amount,e.unit,t),$("#accountBalanceBtc").html(btcval+" BTC")})}})}function walletDecryptSuccess(){$("#accountAddress").html(formatAddress(strPrivateKeyToAddress(PrivKey),"hex")),setWalletBalance(),$("#decryptStatus").html('

Wallet successfully decrypted

').fadeIn(2e3),$("#wallettransactions").show()}function walletDecryptFailed(t){$("#decryptStatus").html('

'+t+"

").fadeIn(50).fadeOut(3e3),$("#wallettransactions").hide()}function formatCurrency(t,e){return e+" "+t.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g,"$1,")}function decryptFormData(){if(PrivKey="","fupload"==decryptType){file=$(".btn-file :file")[0].files[0];var t=new FileReader;t.onload=function(){try{PrivKey=getWalletFilePrivKey(t.result,$("#walletfilepassword").val()),walletDecryptSuccess()}catch(e){walletDecryptFailed(e)}},t.readAsText(file)}else if("privkey"==decryptType)try{PrivKey=decryptTxtPrivKey($("#manualprivkey").val(),$("#privkeypassword").val()),walletDecryptSuccess()}catch(e){walletDecryptFailed("Invalid password")}}function hideAllMainContainers(){$("#paneWalgen").hide(),$("#paneBulkgen").hide(),$("#paneSendTrans").hide(),$("#panePopContracts").hide(),$("#paneHelp").hide(),$("#paneContact").hide(),$("#panePrint").hide(),$("#bulk-generate").parent().removeClass("active"),$("#generate-wallet").parent().removeClass("active"),$("#send-transaction").parent().removeClass("active"),$("#popular-contracts").parent().removeClass("active"),$("#help").parent().removeClass("active"),$("#contact").parent().removeClass("active")}function generateSingleWallet(){var t=$("#ethgenpassword").val();if(""==t)return void alert("Please enter a password.");if(t.length<7)return void alert("Your password must be at least 7 characters");$("#generatedWallet").show();var e=new Accounts,a=e["new"](t);$("#address").val(a.address);var n=cryptoJSToHex(CryptoJS.SHA3(a.address));n=n.substr(n.length-4);var r=e.get(a.address,t);$("#privkey").val(r["private"]),a["private"]=a["private"]+n,$("#privkeyenc").val(a["private"]),$("#qrcodeAdd").empty(),new QRCode($("#qrcodeAdd")[0],{text:a.address,width:$("#qrcode").width(),height:$("#qrcode").width(),colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.H}),$("#qrcode").empty(),new QRCode($("#qrcode")[0],{text:r["private"],width:$("#qrcode").width(),height:$("#qrcode").width(),colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.H});var i="text/json;charset=UTF-8",o=new Blob([JSON.stringify(a)],{type:i}),s=new Blob([JSON.stringify(r)],{type:i});$("#encdownload").attr("href",window.URL.createObjectURL(o)),$("#encdownload").attr("download",a.address+"-Encrypted.json"),$("#unencdownload").attr("href",window.URL.createObjectURL(s)),$("#unencdownload").attr("download",a.address+"-Unencrypted.json"),e.clear()}function generateBulkWallets(){var t=$("#bulkgenpassword").val(),e=$("#numberwallets").val();if(""==e)return void alert("Please enter the amount of wallets you want to generate.");if(e!=parseInt(e,10))return void alert("Digits only please");var a=!1;if(""!=t&&t.length<7)return void alert("Your password must be at least 7 characters.");""!=t&&t.length>=7&&(a=!0),$("#bulkIsEnc").html(a?" (Encrypted)":" (Unencrypted)"),$("#generatedbulkwallets").show(),$("#bulkgentable tr:not(:first)").remove();for(var n=new Accounts,r="",i=[],o=[],s="",l=0;e>l;l++){if(a){var d=n["new"](t),c=cryptoJSToHex(CryptoJS.SHA3(d.address));c=c.substr(c.length-4),d["private"]=d["private"]+c}else var d=n["new"]();$("#bulkgentable tr:last").after('"),r+=d.address+","+d["private"]+"\n",s+=d.address+" "+d["private"]+"\n",i.push({address:d.address,"private":d["private"]}),o.push({address:d.address,"private":n.get(d.address,t)["private"]})}var u=new Blob([r],{type:"text/csv;charset=UTF-8"}),p=new Blob([s],{type:"text/plain;charset=UTF-8"}),v=new Blob([JSON.stringify(i)],{type:"text/json;charset=UTF-8"}),h="bulk_ether_accounts";$("#bulkexportjson").attr("href",window.URL.createObjectURL(v)),$("#bulkexportjson").attr("download",h+".json"),$("#bulkexportcsv").attr("href",window.URL.createObjectURL(u)),$("#bulkexportcsv").attr("download",h+".csv"),$("#bulkexporttxt").attr("href",window.URL.createObjectURL(p)),$("#bulkexporttxt").attr("download",h+".txt"),$("#bulkwalletprint").unbind(),$("#bulkwalletprint").click(function(){openPrintPaperWallets(JSON.stringify(o))}),n.clear()}function openPrintPaperWallets(t){var e=window.open("about:blank","_blank");data='',data=data.replace("{{WALLETJSON}}",t),e.document.write(data),$(e).ready(function(){e.document.write("")})}function printQRcode(){var t=$("#address").val(),e=$("#privkey").val(),a=[];a.push({address:t,"private":e}),openPrintPaperWallets(JSON.stringify(a))}function getBalance(t,e){$.post(SERVERURL,{balance:t}).done(e)}function getTransactionData(t,e){$.post(SERVERURL,{txdata:t}).done(e)}function sendRawTx(t,e){$.post(SERVERURL,{rawtx:t}).done(e)}function getEstimatedGas(t,e){$.post(SERVERURL,{estimatedGas:t}).done(e)}function getEthCall(t,e){$.post(SERVERURL,{ethCall:t}).done(e)}function getETHvalue(t,e){var a="XETH";$.post(KRAKENAPI+"Ticker",{pair:a+t}).done(function(n){e(n.result[a+t].o)})}function createTransaction(t,e,a,n,r){if(64!=t.length)return void r("Invalid Private key, try again");if(!validateEtherAddress(e))return void r("Invalid to Address, try again");if(!$.isNumeric(a)||0>=a)return void r("Invalid amount, try again");var i=new Buffer(t,"hex"),o=strPrivateKeyToAddress(t);getTransactionData(o,function(t){if(t.error)return void r("Error occurred: "+t.msg);t=t.data;var o=padLeftEven(BNtoHex(new BigNumber(t.nonce))),s=padLeftEven(BNtoHex(new BigNumber(t.gasprice).plus(1e9).toDigits(1))),l=padLeftEven(BNtoHex(new BigNumber(stdTransactionGas))),d=padLeftEven(BNtoHex(new BigNumber(String(a)))),c={nonce:"0x"+o,gasPrice:"0x"+s,gasLimit:"0x"+l,to:e,value:"0x"+d,data:""},u=new Tx(c);u.sign(i),verifyUpFrontCost(c,function(e){if(e>t.balance)return void r("You dont have enough balance in your account to process is transaction");var a="0x"+u.serialize().toString("hex"),i={raw:JSON.stringify(c),signed:a};n(i)},r)})}function createTransactionFromRaw(t,e,a,n){if(64!=e.length)return void n("Invalid Private key, try again");if(!validateEtherAddress(t.from)||!validateEtherAddress(t.to))return void n("Invalid Address, try again");if(!$.isNumeric(t.value)||t.value<=0)return void n("Invalid amount, try again");var r=new Buffer(e,"hex"),i=strPrivateKeyToAddress(e);getTransactionData(i,function(e){if(e.error)return void n("Error occurred: "+e.msg);e=e.data;var i=padLeftEven(BNtoHex(new BigNumber(e.nonce))),o=padLeftEven(BNtoHex(new BigNumber(e.gasprice).plus(1e9).toDigits(1))),s=padLeftEven(BNtoHex(new BigNumber(t.gas))),l=padLeftEven(BNtoHex(new BigNumber(String(t.value)))),d={nonce:"0x"+i,gasPrice:"0x"+o,gasLimit:"0x"+s,to:t.to,value:"0x"+l,data:"0x"+t.data},c=new Tx(d);c.sign(r),verifyUpFrontCost(d,function(t){if(t>e.balance)return void n("You dont have enough balance in your account to process is transaction");var r="0x"+c.serialize().toString("hex"),i={raw:JSON.stringify(d),signed:r};a(i)},n)})}function verifyUpFrontCost(t,e,a){getEstimatedGas(t,function(n){if(n.error)a("Error occurred: "+n.msg);else if(new BigNumber(formatHexString(n.data,"hex")).greaterThan(new BigNumber(formatHexString(t.gasLimit,"hex"))))a("Gas limit is too low");else{var r=new BigNumber(formatHexString(t.gasPrice,"hex")).times(new BigNumber(formatHexString(t.gasLimit,"hex")));e(r.plus(new BigNumber(formatHexString(t.value,"hex"))).toNumber())}})}function getMaxSendAmount(t,e,a){getTransactionData(t,function(t){if(t.error)return void a("Error occurred: "+t.msg);t=t.data;var n=new BigNumber(t.gasprice).plus(1e9).toDigits(1).times(stdTransactionGas),r=new BigNumber(String(t.balance)).minus(n);r.lessThan(0)?a("Not enough balance to send a transaction"):e(toEther(r.toString(),"wei"))})}function sendTransaction(t,e,a){sendRawTx(t,function(t){return t.error?void a("Error occurred: "+t.msg):void e(t.data)})}function BNtoHex(t){return t.toString(16)}function padLeftEven(t){return t.length%2!=0?"0"+t:t}function formatHexString(t,e){return"hex"==e?"0x"==t.substring(0,2)?t:"0x"+t:"raw"==e?"0x"==t.substring(0,2)?t.substring(2):t:void 0}function fiatToWei(t,e){var a=new BigNumber(String(t)).div(e).times(getValueOfUnit("ether")).round(0);return a.toString(10)}function toFiat(t,e,a){var n=new BigNumber(toEther(t,e)).times(a).round(5);return n.toString(10)}function toEther(t,e){var a=new BigNumber(toWei(t,e)).div(getValueOfUnit("ether"));return a.toString(10)}function toWei(t,e){var a=new BigNumber(String(t)).times(getValueOfUnit(e));return a.toString(10)}function getValueOfUnit(t){t=t?t.toLowerCase():"ether";var e=unitMap[t];if(void 0===e)throw new Error("This unit doesn't exists, please use the one of the following units"+JSON.stringify(unitMap,null,2));return new BigNumber(e,10)}function getBestEtherKnownUnit(t){t=String(t);var e="wei",a=new BigNumber(t);for(var n in knownUnitMap)knownUnitMap.hasOwnProperty(n)&&new BigNumber(t).greaterThan(new BigNumber(knownUnitMap[n]))&&(e=n,a=new BigNumber(t).div(new BigNumber(knownUnitMap[n])));return{unit:e,amount:a.toDigits(10).toString(10)}}function decryptPresaleKey(t,e){t=JSON.parse(t);var a=hexToBytes(t.encseed),n=hexToCryptoJS(bytesToHex(a.slice(0,16))),r=hexToCryptoJS(bytesToHex(a.slice(16))),i=sha256.pbkdf2(stringToBytes(e),stringToBytes(e),2e3,16),o=hexToBytes(bytesToHex(i)).slice(0,16),s=CryptoJS.AES.decrypt({ciphertext:r},hexToCryptoJS(bytesToHex(o)),{iv:n,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}),l=cryptoJSToHex(s);s=hex2str(l);var d=CryptoJS.SHA3(s,{outputLength:256}),c=d.toString();if(verifyPrivKey(c,t.ethaddr))return c;throw"Invalid Password"}function decryptGethKeyV3(t,e){t=JSON.parse(t),null==t.Crypto&&null!=t.crypto&&(t.Crypto=t.crypto);var a=t.Crypto.cipherparams.iv,n=t.Crypto.ciphertext,r=getKDFKey(t.Crypto,e),i=hexToBytes(bytesToHex(r)).slice(0,16),o=CryptoJS.AES.decrypt({ciphertext:hexToCryptoJS(n)},hexToCryptoJS(bytesToHex(i)),{mode:CryptoJS.mode.CTR,padding:CryptoJS.pad.ZeroPadding,iv:hexToCryptoJS(a)}),s=cryptoJSToHex(o);if(verifyPrivKey(s,t.address))return s;throw"Invalid Password"}function decryptTxtPrivKey(t,e){if(128==t.length)var a=CryptoJS.AES.decrypt(t,e),n=hex2str(cryptoJSToHex(a));else if(132==t.length){var a=CryptoJS.AES.decrypt(t.substr(0,128),e),n=hex2str(cryptoJSToHex(a)),r=t.substr(t.length-4),i=formatAddress(strPrivateKeyToAddress(n),"hex"),o=cryptoJSToHex(CryptoJS.SHA3(i));if(o.substr(o.length-4)!=r)throw"Invalid Password"}else{if(64!=t.length)throw"Error while decrypting your wallet";var n=t}return n}function decryptEthWalletJson(t,e){if(t=JSON.parse(t),t.locked&&128==t["private"].length)var a=CryptoJS.AES.decrypt(t["private"],e),n=hex2str(cryptoJSToHex(a));else if(t.locked&&132==t["private"].length)var a=CryptoJS.AES.decrypt(t["private"].substr(0,128),e),n=hex2str(cryptoJSToHex(a));else{if(t.locked||64!=t["private"].length)throw"Error while decrypting your wallet";var n=t["private"]}if(verifyPrivKey(n,formatAddress(t.address,"raw")))return n;throw"Invalid Password"}function walletRequirePass(t){var e;try{e=JSON.parse(t)}catch(a){throw"not a valid wallet file"}if(null!=e.encseed)return!0;if(null!=e.Crypto||null!=e.crypto)return!0;if(null!=e.hash&&e.locked)return!0;if(null==e.hash||e.locked)throw"Sorry! we dont have a clue what kind of wallet file this is.";return!1}function verifyPrivKey(t,e){return 64!=t.length?!1:strPrivateKeyToAddress(t)!=e?!1:!0}function getWalletFilePrivKey(t,e){var a=JSON.parse(t);if(null!=a.encseed)return decryptPresaleKey(t,e);if(null!=a.Crypto||null!=a.crypto)return decryptGethKeyV3(t,e);if(null!=a.hash)return decryptEthWalletJson(t,e);throw"Sorry! we dont have a clue what kind of wallet file this is."}function formatAddress(t,e){return"0x"==t.substr(0,2)&&"raw"==e&&(t=t.substr(2)),"0x"!=t.substr(0,2)&&"hex"==e&&(t="0x"+t),t}function strPrivateKeyToAddress(t){var e=ethUtil.privateToPublic(new Buffer(t,"hex"));return ethUtil.publicToAddress(e).toString("hex")}function getKDFKey(t,e){var a=hexToBytes(t.kdfparams.salt),n=stringToBytes(e),r=t.kdfparams.dklen;if("scrypt"==t.kdf){var i=t.kdfparams.n,o=t.kdfparams.r,s=t.kdfparams.p,l=scrypt_module_factory(335544320);return l.crypto_scrypt(n,a,i,o,s,r)}if("pbkdf2"==t.kdf){var d=t.kdfparams.c,c=(t.kdfparams.prf,sha256.pbkdf2(stringToBytes(e),hexToBytes(t.kdfparams.salt),d,r));return c}}function hexToCryptoJS(t){return CryptoJS.enc.Hex.parse(t)}function cryptoJSToHex(t){return CryptoJS.enc.Hex.stringify(t)}function validateEtherAddress(t){return 42==t.length&&"0x"==t.substr(0,2)&&/^[0-9A-F]+$/i.test(t.substr(2))}function hex2str(t){for(var t=t.toString(),e="",a=0;a>>4).toString(16)),e.push((15&t[a]).toString(16));return e.join("")}function hexToBytes(t){for(var e=[],a=0;a Transaction generated

').fadeIn(50),$("#divtransactionTAs").show(),$("#divsendtranaction").show(),$("#confirmAmount").html($("#sendtxamount").val()),$("#confirmCurrancy").html(t)},function(t){$("#txcreatestatus").html('

'+t+"

").fadeIn(50).fadeOut(3e3),$("#divtransactionTAs").hide(),$("#divsendtranaction").hide()})}catch(n){$("#txcreatestatus").html('

'+n+"

").fadeIn(50).fadeOut(3e3),$("#divtransactionTAs").hide(),$("#divsendtranaction").hide()}}var PrivKey="",decryptType="",usdval,eurval,btcval,web3=new Web3;$(document).ready(function(){bindElements(),checkAndLoadPageHash(),checkAndRedirectHTTPS()});var SERVERURL="https://rpc.myetherwallet.com/api.php",KRAKENAPI="https://api.kraken.com/0/public/",stdTransactionGas=21e3,knownUnitMap={wei:"1",kwei:"1000",gwei:"1000000000",szabo:"1000000000000",finney:"1000000000000000",ether:"1000000000000000000"},unitMap={wei:"1",kwei:"1000",ada:"1000",femtoether:"1000",mwei:"1000000",babbage:"1000000",picoether:"1000000",gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",einstein:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"};$(document).ready(function(){bindAugurElements()});var augurContract=web3.eth.contract([{name:"addrToFunder(int256)",type:"function",inputs:[{name:"address",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"buyRep()",type:"function",inputs:[],outputs:[{name:"out",type:"int256"}]},{name:"getAddrByIndex(int256)",type:"function",inputs:[{name:"index",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"getAmountSent(int256)",type:"function",inputs:[{name:"address",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"getAmtByIndex(int256)",type:"function",inputs:[{name:"index",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"getBlockNumByIndex(int256)",type:"function",inputs:[{name:"index",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"getBlockNumSent(int256)",type:"function",inputs:[{name:"address",type:"int256"}],outputs:[{name:"out",type:"int256"}]},{name:"getFunderNum()",type:"function",inputs:[],outputs:[{name:"out",type:"int256"}]},{name:"getFundsRaised()",type:"function",inputs:[],outputs:[{name:"out",type:"int256"}]}]).at("0xe28e72fcf78647adce1f1252f240bbfaebd63bcc"); \ No newline at end of file diff --git a/js/source/01_global.js b/js/source/01_global.js index 26bb883fe5..9562100926 100644 --- a/js/source/01_global.js +++ b/js/source/01_global.js @@ -2,6 +2,7 @@ var PrivKey = ""; var decryptType = ""; var usdval; var eurval; +var btcval; var web3 = new Web3(); $(document).ready(function() { bindElements(); @@ -253,13 +254,17 @@ function setWalletBalance() { if (!result.error) { var bestCurAmount = getBestEtherKnownUnit(result.data.balance); $("#accountBalance").html(bestCurAmount.amount + " " + bestCurAmount.unit); - getETHvalue('USD', function(value) { + getETHvalue('ZUSD', function(value) { usdval = toFiat(bestCurAmount.amount, bestCurAmount.unit, value); - $("#accountBalanceUsd").html(usdval + " USD"); + $("#accountBalanceUsd").html(formatCurrency(usdval,'$') + " USD"); }); - getETHvalue('EUR', function(value) { + getETHvalue('ZEUR', function(value) { eurval = toFiat(bestCurAmount.amount, bestCurAmount.unit, value); - $("#accountBalanceEur").html(eurval + " EUR"); + $("#accountBalanceEur").html(formatCurrency(eurval,'€')+ " EUR"); + }); + getETHvalue('XXBT', function(value) { + btcval = toFiat(bestCurAmount.amount, bestCurAmount.unit, value); + $("#accountBalanceBtc").html(btcval + " BTC"); }); } else alert(result.msg); @@ -278,6 +283,9 @@ function walletDecryptFailed(err) { $("#wallettransactions").hide(); } +function formatCurrency(n, currency) { + return currency + " " + n.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,"); +} function decryptFormData() { PrivKey = ""; if (decryptType == 'fupload') { diff --git a/js/source/02_ajax.js b/js/source/02_ajax.js index 6d6d9ef200..61324fe829 100644 --- a/js/source/02_ajax.js +++ b/js/source/02_ajax.js @@ -16,7 +16,7 @@ function getEthCall(txobj, callback){ $.post( SERVERURL, { ethCall: txobj }).done(callback); } function getETHvalue(slavePair, callback){ - var prefix = "XETHZ"; + var prefix = "XETH"; $.post( KRAKENAPI+"Ticker", { pair: prefix+slavePair }).done(function(data){ callback(data['result'][prefix+slavePair]['o']); }); diff --git a/pages/index.html b/pages/index.html index 924b69713b..46d85b1a07 100644 --- a/pages/index.html +++ b/pages/index.html @@ -202,6 +202,8 @@

Account Information

loading...
loading... +
+ loading...