I recently was locked out of my Ledger NanoS when I forgot the pin code. Upon trying to reset from my recovery phrase I realized that I only have 23 of the 24 required words (not sure how it happened unfortunately). I am not positive which position the word is in but I am certain the order of the other 23 words is correct. That being said I have to try all possibilities in every other position.

I found this post giving me a list of words to populate the missing word: Lost my Bitcoin wallet and have only 11 out of 12 mnemonic seed phrase words. How can I get my Bitcoins?

I am searching for a piece of code that would allow me to churn the solutions without manually trying the wallets 1 by 1.

  • Do you have to need a program for generating all possible combinations? an example a program that save inside the file that all possible combination. Or you are finding an program for testing all possible combinations directly on dispositive? – vincenzopalazzo Oct 9 '19 at 19:49
  • I have now listed all the possibilities through the code on the link the the original post. I just want to have an automated way to test the list of about 200 entries (I believe the list is so small due to checksum rule). I downloaded electrum wallet and have been testing a few manually but the process is quite tedious – Nate Gray Oct 9 '19 at 20:11

Do you know one of the addresses in the keychain? Ledger uses BIP44 derivation so you could write a loop to check different seed phrases and check the resulting addresses against an address you know that should be in the keychain. This way you can type in your recovery words without having to be online.

For example if it were me I'd probably write something using the bitcoinjs-lib. Here's a start written with bitcoinjs (NOTE I'm using version 3.3.2). This will take a recovery seed and an address and it will search the keychain and tell you whether or not the address exists within it.

//var words = "segment increase inch ensure corn cigar suggest fetch output proof peasant enact";
//var addr = "1c4XzQx7Uh8CnxzAN5CRrUjkbxGB1GUWp";

var searchbtn = document.getElementById("searchbtn");
searchbtn.onclick = function(){

    var words = document.getElementById("words").value;
    var addr = document.getElementById("addr").value;
    var depth = document.getElementById("depth").value;
    inkeychain(addr, words, depth);

function inkeychain(addr, keychain, depth){
    var isfound = false;
    for(var i=0;i<depth;i++){
        var seed = hd.bip39.mnemonicToSeed(keychain);
        var root = b.bitcoin.HDNode.fromSeedBuffer(seed)
        //const root = bitcoin.HDNode.fromSeedHex(seed.toString('hex'))
        var wallet = root.derivePath("m/44'/0'/0'/0/"+i);

        var address = wallet.getAddress();
        var wif = wallet.keyPair.toWIF();

        //segwit p2sh
        var pubKey = wallet.keyPair.getPublicKeyBuffer();
        var pubKeyHash = b.bitcoin.crypto.hash160(pubKey);
        var redeemScript = b.bitcoin.script.witnessPubKeyHash.output.encode(pubKeyHash);
        var redeemScriptHash = b.bitcoin.crypto.hash160(redeemScript);
        var scriptPubKey2 = b.bitcoin.script.scriptHash.output.encode(redeemScriptHash);
        var p2shsegwit = b.bitcoin.address.fromOutputScript(scriptPubKey2);

        isfound = true;
            console.log(address, wif);
            $('#result').html('Found '+addr+' in this keychain at '+i+' position in the keychain');
        } else if (p2shsegwit===addr){
            //check for segwit p2sh
            isfound = true; 
            console.log(p2shsegwit, wif);
            $('#result').html('Found '+addr+' in this keychain at '+i+' position in the keychain');
    $('#result').html('No matches');



From here you could take it a step further and make the words variable an array with all your different combos and then loop them all through.

  • I only know 23 of the 24 words and I actually just found the transaction record of me moving the bitcoin from a different wallet to the ledger nano s. Would you method work in this case? Also if I were manually testing sets of words in electrum and I selected m/84'/0'/0' instead of m/44'/0'/0' would it show me if there were coins in the wallet or not? I am slightly computer savvy but some of this is way over my head, so sorry for what may seem like stupid questions. – Nate Gray Oct 10 '19 at 20:53

1 - I'm afraid, you can't find/search a bitcoin address with 23 of 24 mnemonic seed phrase words.

2 - Another disaster is not knowing the order of the words.

Going forward... My suggestion will be that you generate and save an entropy like the hex value in this sample . So that you can easily retrieve any address in cases like this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.