bitaddress.org/src/ninja.paperwallet.js

249 lines
362 KiB
JavaScript
Raw Normal View History

2013-08-28 04:05:31 +02:00
ninja.wallets.paperwallet = {
2015-07-05 23:14:49 +02:00
isOpen: function () {
return (document.getElementById("paperwallet").className.indexOf("selected") != -1);
},
2013-08-28 04:05:31 +02:00
open: function () {
document.getElementById("main").setAttribute("class", "paper"); // add 'paper' class to main div
var paperArea = document.getElementById("paperarea");
paperArea.style.display = "block";
var perPageLimitElement = document.getElementById("paperlimitperpage");
var limitElement = document.getElementById("paperlimit");
var pageBreakAt = (ninja.wallets.paperwallet.useArtisticWallet) ? ninja.wallets.paperwallet.pageBreakAtArtisticDefault : ninja.wallets.paperwallet.pageBreakAtDefault;
if (perPageLimitElement && perPageLimitElement.value < 1) {
perPageLimitElement.value = pageBreakAt;
}
if (limitElement && limitElement.value < 1) {
limitElement.value = pageBreakAt;
}
if (document.getElementById("paperkeyarea").innerHTML == "") {
document.getElementById("paperpassphrase").disabled = true;
document.getElementById("paperencrypt").checked = false;
ninja.wallets.paperwallet.encrypt = false;
ninja.wallets.paperwallet.build(pageBreakAt, pageBreakAt, !document.getElementById('paperart').checked, document.getElementById('paperpassphrase').value);
2013-08-28 04:05:31 +02:00
}
},
close: function () {
document.getElementById("paperarea").style.display = "none";
document.getElementById("main").setAttribute("class", ""); // remove 'paper' class from main div
},
remaining: null, // use to keep track of how many addresses are left to process when building the paper wallet
count: 0,
pageBreakAtDefault: 7,
pageBreakAtArtisticDefault: 3,
useArtisticWallet: true,
pageBreakAt: null,
build: function (numWallets, pageBreakAt, useArtisticWallet, passphrase) {
2013-08-28 04:05:31 +02:00
if (numWallets < 1) numWallets = 1;
if (pageBreakAt < 1) pageBreakAt = 1;
ninja.wallets.paperwallet.remaining = numWallets;
ninja.wallets.paperwallet.count = 0;
ninja.wallets.paperwallet.useArtisticWallet = useArtisticWallet;
ninja.wallets.paperwallet.pageBreakAt = pageBreakAt;
document.getElementById("paperkeyarea").innerHTML = "";
if (ninja.wallets.paperwallet.encrypt) {
if (passphrase == "") {
alert(ninja.translator.get("bip38alertpassphraserequired"));
return;
}
document.getElementById("busyblock").className = "busy";
ninja.privateKey.BIP38GenerateIntermediatePointAsync(passphrase, null, null, function (intermediate) {
ninja.wallets.paperwallet.intermediatePoint = intermediate;
document.getElementById("busyblock").className = "";
setTimeout(ninja.wallets.paperwallet.batch, 0);
});
}
else {
setTimeout(ninja.wallets.paperwallet.batch, 0);
}
2013-08-28 04:05:31 +02:00
},
batch: function () {
if (ninja.wallets.paperwallet.remaining > 0) {
var paperArea = document.getElementById("paperkeyarea");
ninja.wallets.paperwallet.count++;
var i = ninja.wallets.paperwallet.count;
var pageBreakAt = ninja.wallets.paperwallet.pageBreakAt;
var div = document.createElement("div");
div.setAttribute("id", "keyarea" + i);
if (ninja.wallets.paperwallet.useArtisticWallet) {
div.innerHTML = ninja.wallets.paperwallet.templateArtisticHtml(i);
div.setAttribute("class", "keyarea art");
}
else {
div.innerHTML = ninja.wallets.paperwallet.templateHtml(i);
div.setAttribute("class", "keyarea");
}
if (paperArea.innerHTML != "") {
// page break
if ((i - 1) % pageBreakAt == 0 && i >= pageBreakAt) {
var pBreak = document.createElement("div");
pBreak.setAttribute("class", "pagebreak");
document.getElementById("paperkeyarea").appendChild(pBreak);
div.style.pageBreakBefore = "always";
if (!ninja.wallets.paperwallet.useArtisticWallet) {
div.style.borderTop = "2px solid green";
}
}
}
document.getElementById("paperkeyarea").appendChild(div);
ninja.wallets.paperwallet.generateNewWallet(i);
ninja.wallets.paperwallet.remaining--;
setTimeout(ninja.wallets.paperwallet.batch, 0);
}
},
// generate bitcoin address, private key, QR Code and update information in the HTML
// idPostFix: 1, 2, 3, etc.
generateNewWallet: function (idPostFix) {
if (ninja.wallets.paperwallet.encrypt) {
ninja.privateKey.BIP38GenerateECAddressAsync(ninja.wallets.paperwallet.intermediatePoint, false, function (address, encryptedKey) {
2015-10-25 19:54:59 +01:00
Bitcoin.KeyPool.push(new Bitcoin.Bip38Key(address, encryptedKey));
if (ninja.wallets.paperwallet.useArtisticWallet) {
ninja.wallets.paperwallet.showArtisticWallet(idPostFix, address, encryptedKey);
}
else {
ninja.wallets.paperwallet.showWallet(idPostFix, address, encryptedKey);
}
});
2013-08-28 04:05:31 +02:00
}
else {
var key = new Bitcoin.ECKey(false);
var bitcoinAddress = key.getBitcoinAddress();
var privateKeyWif = key.getBitcoinWalletImportFormat();
if (ninja.wallets.paperwallet.useArtisticWallet) {
ninja.wallets.paperwallet.showArtisticWallet(idPostFix, bitcoinAddress, privateKeyWif);
}
else {
ninja.wallets.paperwallet.showWallet(idPostFix, bitcoinAddress, privateKeyWif);
}
2013-08-28 04:05:31 +02:00
}
},
templateHtml: function (i) {
var privateKeyLabel = ninja.translator.get("paperlabelprivatekey");
if (ninja.wallets.paperwallet.encrypt) {
privateKeyLabel = ninja.translator.get("paperlabelencryptedkey");
}
2013-08-28 04:05:31 +02:00
var walletHtml =
"<div class='public'>" +
"<div id='qrcode_public" + i + "' class='qrcode_public'></div>" +
"<div class='pubaddress'>" +
"<span class='label'>" + ninja.translator.get("paperlabelbitcoinaddress") + "</span>" +
"<span class='output' id='btcaddress" + i + "'></span>" +
"</div>" +
"</div>" +
"<div class='private'>" +
"<div id='qrcode_private" + i + "' class='qrcode_private'></div>" +
"<div class='privwif'>" +
"<span class='label'>" + privateKeyLabel + "</span>" +
2013-08-28 04:05:31 +02:00
"<span class='output' id='btcprivwif" + i + "'></span>" +
"</div>" +
"</div>";
return walletHtml;
},
showWallet: function (idPostFix, bitcoinAddress, privateKey) {
2013-08-28 04:05:31 +02:00
document.getElementById("btcaddress" + idPostFix).innerHTML = bitcoinAddress;
document.getElementById("btcprivwif" + idPostFix).innerHTML = privateKey;
2013-08-28 04:05:31 +02:00
var keyValuePair = {};
keyValuePair["qrcode_public" + idPostFix] = bitcoinAddress;
keyValuePair["qrcode_private" + idPostFix] = privateKey;
2013-08-28 04:05:31 +02:00
ninja.qrCode.showQrCode(keyValuePair);
document.getElementById("keyarea" + idPostFix).style.display = "block";
},
templateArtisticHtml: function (i) {
var keyelement = 'btcprivwif';
var image;
if (ninja.wallets.paperwallet.encrypt) {
keyelement = 'btcencryptedkey'
image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeYAAAEFCAYAAAA2Q0TjAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAgAElEQVR42uy9d5gkV3ku/n5V1VXVeXpy2N3ZnJPyalcZBUBCCCEwQSSDsTEOP2z/bGNfX+41trmOOMA1mGhsQMHKIIRy2l3l1Wpz3smxp3NXdVX1+e4fp3ume6Z7ZnZXWsmI8zzz7D5d3VWnqs753u97v0T7e50iSmM0A7SGMecYzwLNodfne2kbCPgATT3zc83nOxNZoHGO7yTzQENgjusEAVDt414RyDtAxF/7uGAgmas/j2wB0FVA1079PidyQGNwlmOB2vOu9+6TeSBkzHw/eUfeR8iYeY2GAKBUXoOB8Zyc8yOPPUNW3po81N7WiLWrFmF0LIm9B07C51Nx8/Vbccf9z4IFAwDWbb4UrPpxOsNvELoaGaaOX443eNguMDRByNn8lpmTTy2C3QxcrzhtXfjQ1RZmUmjW3z++zzs6kuTlDUG5ZxuCQNYGbAG0BRlZT4HnCMSCNLlfHQ9IWQS/zggZ1fJkKEloCjF0Te6fdGkrNASAgssYtxToBOSLoAYD7AFo8jOSeSlPsrb8dyIHqApBMGAX5bkCGuA6Bfzotsdpy5aNCJqEFUtbOFvQ0Fza2z1JogYD7Hhyj/p1Rq5A8IqA7YKgAsyMqEEcC/LkPi64jLyrIGwy8gXAcgmmDwgaDE2plm3xrDwfIOWGpgIqMVIWwTTlPB1PHleJ4RZp8rtZFxAeKOpnZhDSFuAyk+EjVgQQCzIIci6xgFxnnpBrrygIBIZPIxianLsngFyBEPXPvSYdT97XXN8VDCRsgsJy/kQEXRXwaYTpy0mwXAvluc42EnlC2JTPU6t10TnWKgRLYQs6842jUOl8mMc1X48x15wZEGL2r3jF2c/jFOuDKgDYD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P9F7Jo+TYgNdPw6szbtyuxm5Uc32iznamNI7Pf1O1+5sQBAIAkyZg4cxSJzj50dPdj885rVgTMJIeB0CowKe8WA+EX8pMUOQZENwHWNGAn37dpRNQigAbg3DHE0tJ31rMkQAI5aQIYkDSGpAtw8kyQnRPKJ/sVA8MtgiP9QrGV9YAvwuJv3xVuVXMeJaOEFR2sRkBmkiAbTJ4F1hNiwWYfKEwD4V7hGnaygGuKbzAgN0VkGwdO7aHdrzxJn/rVP/S7BtZjdvoMstksF1mDPT+GTZsv4+5EBy/MjdHc9HGsX7WakZ8AK1FAi7NwrQNMCogtQfDKF4RiooSZtZhQPEDCgrYWhXvbtUDWgnCNSwrId8GhPvF7axFwsgStjVmNgZyM8LSiKLDBTAqFINTNPmmYGD9GJ47twfiZQ1QorNDwAwBmWHYRll1EenGOJsaDtYOIEolejKzayGvWbObunmGwpIPDfSArXUtcWy6SClbC4tgGHJnyFPT2JeQtWVjivl22xMEMllWhsHhF8eybeKbrk79WIisFZt8+f7ftUvHdmk0zZ/ZR78j2c1uTg1jS4twZhKId0EOx6v3NiFDlYy4QBpoBu283JxM0g6CmgN9gn52tz0B3i/Xn4WQBNVa7vZ473Eo2Z7cHIhEh3t4JIsLRA68hs7jQ8jcUGgTUdjD/Io78z
}
2013-08-28 04:05:31 +02:00
var walletHtml =
"<div class='artwallet' id='artwallet" + i + "'>" +
//"<iframe src='bitcoin-wallet-01.svg' id='papersvg" + i + "' class='papersvg' ></iframe>" +
"<img id='papersvg" + i + "' class='papersvg' src='" + image + "' />" +
2013-08-28 04:05:31 +02:00
"<div id='qrcode_public" + i + "' class='qrcode_public'></div>" +
"<div id='qrcode_private" + i + "' class='qrcode_private'></div>" +
"<div class='btcaddress' id='btcaddress" + i + "'></div>" +
"<div class='" + keyelement + "' id='" + keyelement + i + "'></div>" +
2013-08-28 04:05:31 +02:00
"</div>";
return walletHtml;
},
showArtisticWallet: function (idPostFix, bitcoinAddress, privateKey) {
2013-08-28 04:05:31 +02:00
var keyValuePair = {};
keyValuePair["qrcode_public" + idPostFix] = bitcoinAddress;
keyValuePair["qrcode_private" + idPostFix] = privateKey;
2013-08-28 04:05:31 +02:00
ninja.qrCode.showQrCode(keyValuePair, 2.5);
document.getElementById("btcaddress" + idPostFix).innerHTML = bitcoinAddress;
if (ninja.wallets.paperwallet.encrypt) {
var half = privateKey.length / 2;
document.getElementById("btcencryptedkey" + idPostFix).innerHTML = privateKey.slice(0, half) + '<br />' + privateKey.slice(half);
}
else {
document.getElementById("btcprivwif" + idPostFix).innerHTML = privateKey;
}
2013-08-28 04:05:31 +02:00
// CODE to modify SVG DOM elements
//var paperSvg = document.getElementById("papersvg" + idPostFix);
//if (paperSvg) {
// svgDoc = paperSvg.contentDocument;
// if (svgDoc) {
// var bitcoinAddressElement = svgDoc.getElementById("bitcoinaddress");
// var privateKeyElement = svgDoc.getElementById("privatekey");
// if (bitcoinAddressElement && privateKeyElement) {
// bitcoinAddressElement.textContent = bitcoinAddress;
// privateKeyElement.textContent = privateKeyWif;
// }
// }
//}
},
toggleArt: function (element) {
ninja.wallets.paperwallet.resetLimits();
},
toggleEncrypt: function (element) {
// enable/disable passphrase textbox
document.getElementById("paperpassphrase").disabled = !element.checked;
ninja.wallets.paperwallet.encrypt = element.checked;
ninja.wallets.paperwallet.resetLimits();
},
resetLimits: function () {
var hideArt = document.getElementById("paperart");
var paperEncrypt = document.getElementById("paperencrypt");
var limit;
var limitperpage;
document.getElementById("paperkeyarea").style.fontSize = "100%";
2013-11-03 21:27:03 +01:00
if (!hideArt.checked) {
limit = ninja.wallets.paperwallet.pageBreakAtArtisticDefault;
2013-11-03 21:27:03 +01:00
limitperpage = ninja.wallets.paperwallet.pageBreakAtArtisticDefault;
}
else if (hideArt.checked && paperEncrypt.checked) {
limit = ninja.wallets.paperwallet.pageBreakAtDefault;
limitperpage = ninja.wallets.paperwallet.pageBreakAtDefault;
// reduce font size
document.getElementById("paperkeyarea").style.fontSize = "95%";
}
else if (hideArt.checked && !paperEncrypt.checked) {
limit = ninja.wallets.paperwallet.pageBreakAtDefault;
limitperpage = ninja.wallets.paperwallet.pageBreakAtDefault;
}
document.getElementById("paperlimitperpage").value = limitperpage;
document.getElementById("paperlimit").value = limit;
2013-08-28 04:05:31 +02:00
}
};