Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: pbies on June 04, 2023, 11:16:00 PM



Title: Ckey to WIF
Post by: pbies on June 04, 2023, 11:16:00 PM
How to convert unencrypted ckey to Wallet Import Format?

I am looking for a Python or JavaScript solution.

Let's say I have ckey in bytes format or hex, need to convert it to WIF as bytes or string.


Title: Re: Ckey to WIF
Post by: PowerGlove on June 05, 2023, 12:29:12 AM
How to convert unencrypted ckey to Wallet Import Format?
I wrote a Python script late last year that can convert raw scalars into addresses (and WIFs), here it is: [Code] Generating addresses from scratch (Python 3.6+) (https://bitcointalk.org/index.php?topic=5432111).

If you have a raw scalar (e.g. 0xb46ed3fbb61ed98b2f8791fc9c79ba382e187140a7326ca03d7204d705a6586d), then you can supply it to the script, like this:

Code:
$ python3 make_address.py 0xb46ed3fbb61ed98b2f8791fc9c79ba382e187140a7326ca03d7204d705a6586d

That will output the following (WIFs highlighted):

       +------+--------------------+
       | Type | Legacy, Compressed |
    +--+------+--------------------+---------------+
    | Address | 1L5hbU5BnNC9PWdJLqQUdUTC1FqvCZG1go |
+---+---------+------------------------------------+-----------------------+
| Private Key | p2pkh:L3GSzNCJjj4z1UmSkPUxc8aUrnJ6VbGsKq3kxyVWkEdVXM8S1pnF |
+-------------+------------------------------------------------------------+
       +------+---------------+
       | Type | Native SegWit |
    +--+------+---------------+----------------------------+
    | Address | bc1q69xlp2mjka4w0nywe4eps97gk3ryu968p98amh |
+---+---------+--------------------------------------------+----------------+
| Private Key | p2wpkh:L3GSzNCJjj4z1UmSkPUxc8aUrnJ6VbGsKq3kxyVWkEdVXM8S1pnF |
+-------------+-------------------------------------------------------------+


Title: Re: Ckey to WIF
Post by: pbies on June 05, 2023, 02:20:08 AM
...

Thank you very much!

Works like a charm!


Title: Re: Ckey to WIF
Post by: Greg Tonoski on October 05, 2023, 08:45:52 AM
For JavaScript: SeedTool -> Single Address Tool. https://github.com/BitcoinQnA/seedtool