Hey all,
The Paper Wallet option from wallet.peercointalk.org does not display QR codes and Paper wallets correctly when downloaded and run offline in the Firefox browser.
In Chrome browser, the same option experiences unexpected behaviour, at first displaying the Peercoin Wallet Layout with no QR Codes.
After a new generation cycle it displays QR codes, but not the Wallet layout anymore.
This certainly is an issue (people, like me, like to create paper wallets while offline) and after looking into it, I found the lines of code that cause part of this behaviour:
templateArtisticHtml: function (i) {
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='peercoinpaper.png' />" +
"<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='btcprivwif' id='btcprivwif" + i + "'></div>" +
"</div>";
return walletHtml;
},
This code snippet (starting at line 5650) has to be fixed in line 5654. Javascript code does not seem to adjust when a page is stored offline, so the file peercoinpaper.png does not exist offline in the same directory as the HTML file, causing Paper Wallet generation to fail.
Fixed code snippets
Add after line 4631:
<img id="hiddenpaper" src="peercoinpaper.png" style="display:none"></img>
This hides the peercoinpaper.png, but the browser sees it as being necessary, thus downloading it when saving page offline.
Then, one line of the big code snippet from above is changed this way:
"<img id='papersvg" + i + "' class='papersvg' src=" + document.getElementById('hiddenpaper').src + " />" +
Here, I access the hidden image element now embedded into the site, so I can get its path in the file system, no matter where it has been stored.
If there is any question regarding my proposed fix I can try and explain in more detail what I did.
Also my appologies, I am only a JavaScript intermediate and certain that it is possible to fix this more elegant.
I could upload my fixed version, but I think it is more secure when FuzzyBear just updates his version. This way, he can make sure I didn’t try to add malicious code into the script.
Have a nice day everyone.