Feathercoin daemon and wallet production version 0.18.1
Old daemon and wallet version 0.17.0.1

Import private key


  • Spammer Banned | Tip Kevlar

    It seems like it would be a really good idea to incorporate re-versioning of private keys via the importprivkey directly into the client.

    I’ve written this code in python, but it should be pretty straight forward for someone to reproduce it in C++ and the QT client.

    The problem is the private key format has the wrong version. But this can be fixed.

    The code in python is here:
    https://github.com/hank/life/blob/master/code/python/cryptcoin_addr_convert/convert.py

    And the relevant steps in plain English are as follows:

    Goal: Turn the privkey import format back into the private key.
    Step 1: b58decode(wifpriv)
    Step 2: strip the last 4 characters off the end of step 1 (checksum).
    Step 3: strip the first character off the end of step 2 (version).

    Goal: Turn the private key back into an importable private key format with correct version
    Step 1: Concatenate version and private key. (0x8E for FTC). (version)
    Step 2: sha256(step1)
    Step 3: sha256(step2)
    Step 4: Concatenate step 1 and the last 4 characters of step 3. (checksum)
    Step 5: b58encode(step4)

    Since this code is all already in the C++ QT client, it should be pretty easy to adopt it while removing the check on the version. Or maybe just do that: remove the check on the version, since that would accomplish the same thing.

    Thoughts?


  • | Tip kris_davison

    yes good idea I guess if the first pass at importprivkey fails with a code 5 (Invalid KEY) then you could give it another go after passing through your code.


  • Moderators | Tip wrapper

    Sounds great, I’d like to look into that, once I get my head round it.


  • Spammer Banned | Tip Kevlar

    The code that’s throwing the error is here:
    https://github.com/FeatherCoin/Feathercoin-0.8.5/blob/6c960b106c1f17c61d1860a45010188b169398e4/src/base58.h

    There’s an enum of version numbers there, and when CBase58Data::SetString is called the version gets coppied…

    [quote]
    bool SetString(const char* pszSecret)
    {
    return CBase58Data::SetString(pszSecret) && IsValid();
    }
    [/quote]

    and because the version is wrong IsValid returns false.

    But I think it should be handled at a higher level, namely in src/rpcdump.cpp, line 35, importprivkey(…).

    Am I close?


  • Moderators | Tip Wellenreiter

    I’d go for a simple warning, when the version isn’t correct and give the user a selection whether to import or not.

    Another possibility could be to validate against a list of valid versions?

    This would have the advantage, that in future times, privated keys with very old versions could be rejected, e.g. if they are known to be vulnerable.

    I’m not deep into the code, so I’m not sure if this can be implemented easy


  • Moderators | Tip wrapper

    Bitcoin Worth £4.6 Million Is Buried Under A Landfill In South Wales

    [url=http://www.huffingtonpost.co.uk/2013/11/27/bitcoin-buried-wales-46-million_n_4350267.html]http://www.huffingtonpost.co.uk/2013/11/27/bitcoin-buried-wales-46-million_n_4350267.html[/url]