Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*This is the "not-yet-browserified" source code of the mnemonic checksum tool found on my website: suttersebastian.com*/
- const bitcoin = require('bip39');
- window.onload = function () {
- let output = document.getElementById("output");
- document.getElementById("button").addEventListener("click", function () {
- output.innerHTML = "";
- let shortened = false, actual;
- let valid = [];
- let input = document.getElementById("input").value.trim().toLowerCase();
- if (input.length == 0) {
- output.innerHTML = "<p id='red'>NO INPUT GIVEN</p><p id='note'>Please enter a incomplete mnemonic phrase in the gray input field.</p>";
- return;
- }
- for (const word of bitcoin.wordlists.english) {
- if (bitcoin.validateMnemonic((input + " " + word), bitcoin.wordlists.english)) {
- valid.push(word);
- }
- }
- if (valid.length > 0) {
- output.innerHTML = "<p id='green'>Any of these words will work:</p>";
- for (const word of valid) {
- output.innerHTML += word + ", ";
- }
- output.innerHTML = output.innerHTML.slice(0, -2);
- }
- else {
- output.innerHTML = "<p id='red'>INVALID INPUT</p><p id='note'>Check for spelling mistakes and/or incorrect amount of words.<br>Trailing white space and case sensitivity are taken care of.</p>";
- }
- });
- }
Add Comment
Please, Sign In to add comment