[FIX] wallet.peercointalk.org - Paper Wallet offline creation display error

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.

hey lackfish

Many thanks for the spot… i’ll make your changes now to the code and then please retest to verify everything all good pls


OK changes made and github repo updated … please let me know if there are still any issues


Hey, thanks for reacting this fast.

Another thing to improve would be to add the necessary images to the github repository.

Otherwise, the same issue still occurs as there are no images to work with when downloading directly from the repo.

You could also get rid of the bitcoinwallet.html, as it is not needed for the index.html to function. At least I have experienced zero issues after deleting it.

I’d love to contribute to other minor code projects involving Peercoin. Just hit me up if there is something that needs to be done. Otherwise I’ll continue to bug test here and there and report back if I find anything.

I sent you a pull request on github. Just check the code I changed and merge it with your repository if you are happy with my changes.

Yay! Working Paper Wallet offline generation!

[quote=“lacksfish, post:5, topic:1799”]I sent you a pull request on github. Just check the code I changed and merge it with your repository if you are happy with my changes.

Yay! Working Paper Wallet offline generation![/quote]

Awesome :slight_smile: made it real easy for me and yes I approve of your changes and have updated the code ty