Skip to content

Instantly share code, notes, and snippets.

@AlexanderPavlenko
Last active April 22, 2023 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexanderPavlenko/cfcd6da01cc2c92bb6d17c3caa683c8f to your computer and use it in GitHub Desktop.
Save AlexanderPavlenko/cfcd6da01cc2c92bb6d17c3caa683c8f to your computer and use it in GitHub Desktop.
bit32_rescue #bitcoin

If you have received a payment to some address, which is not listed in your wallet, but was generated from your XPub — don't worry, it's not lost and can be recovered as follows:

  1. install Electrum (tested on version 2.7.12)
  2. in Electrum, restore wallet with the inaccessible funds from its BIP32 Passphrase (also called Seed, 13 words)
  3. in the restored wallet, switch to Console tab, paste getmasterprivate(), hit enter
  4. visit bip32.org
  5. select "Derive From: BIP32 Key"
  6. paste xprv… from Electrum Console into the "BIP32 Extended Key" field
  7. select "Derivation Path: Custom"
  8. paste m/0/n (or whatever is your gateway's address_derivation_scheme) into the "Custom Path" field, where n is the order's keychain_id
  9. ensure that generated value in "Address" field is equal to the order's address
  10. copy value from the "Private Key (WIF)" field
  11. import the obtained keys into a new wallet in Electrum: "File -> New/Restore -> Standard wallet -> Use public or private keys"
  12. paste one or more "Private Key (WIF)" values, one per line
  13. on the next step, addresses should appear on "Addresses" tab with the actual balances, ready to be spent
@Annychenka
Copy link

Hello! This job looks great! I lost my hope, but still need help. After running 'getmasterprivate()' I got this one: 'AttributeError: 'Old_KeyStore' object has no attribute 'get_master_private_key''
Would you mind help me a bit more?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment