Created
August 11, 2022 19:53
-
-
Save sethforprivacy/63dd7a35edf5a49496c35bc5e64e01a2 to your computer and use it in GitHub Desktop.
Recover Bitcoin private key to WIF format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bitcoin | |
private_key = 'REPLACE_WITH_PRIVATE_KEY' | |
compressed_private_key = private_key + '01' | |
wifcomp1 = bitcoin.encode_privkey(bitcoin.decode_privkey(private_key, 'hex'), \ | |
'wif_compressed') | |
print(wifcomp1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get the private key in raw format, follow https://github.com/mandelbit/bitcoin-tutorials/blob/master/CLightningRecoverFunds.md, but use this script instead of the mentioned JS script.
Simply
pip3 install bitcoin
, replaceREPLACE_WITH_PRIVATE_KEY
with the private key output bylightning-hsmtool
, and run with:python3 privkey_to_wif.py
Once you get the WIF key you can easily sweep it into Sparrow Wallet or Samourai Wallet.