Hey everyone,
I’ve been trying to set up my own payment processor recently. I found this script that supposedly generates all sorts of Bitcoin addresses. I tested it and the legacy addresses worked fine. But then I moved on to bech32 and segwit addresses and sent some coins to them. Turns out, the bech32 address was invalid. I think I messed up somewhere. I tried importing the private keys to access the bech address.
Sorry to say, but your coins are definitely gone. If you sent them to an invalid address, they’re lost for good. Bitcoin transactions can’t be reversed, so unless the owner of the wallet decides to send them back, they’re just gone. Be careful next time and double-check those addresses.
If you sent to an address you don’t control, it’s lost for sure.
How did you import it to Electrum?
If it was done incorrectly, it might give you a totally different address, usually a legacy one. Next time, try checking the script type before importing that private key. Maybe use BTCpayserver instead? It's easier and you can just import your master public key and handle invoices from there.
AFAIK, one master key can create all three address types. The differences you're seeing could be due to different derivation paths.
Make sure the addresses generated from those private keys actually hold the funds. Try importing the private key again.
About your private key, the info you gave isn’t right, here’s how it should look.
Using the right library is key, I recommend pycoin for Python. Good luck with that.
That address is definitely invalid.
None of the addresses you've shown have any coins. I’m guessing you meant that 3JKyqNxb5Wb9uh5NUX4S5PhMZTddEiY92n address as p2sh-segwit? A block explorer shows it’s never received anything.
You can’t send coins to an invalid address, just doesn’t work like that.
Two months ago, there was already a known issue with that script:
check it out here, and remember you can’t send coins to an invalid address. Something else must be at play.
What’s the actual address where you sent the coins? Do you have the TXID?
The warning comes too late, honestly.
I’ve written scripts myself, and let me tell you, avoid using untested ones. Open source is great, but it can also be full of issues if not properly reviewed. Always check:
1. open issues
2. forks/stars ratio
3. general code quality.
Looks like ZPyWallet’s generating the legacy address correctly.
But I have no routine to test P2SH generation. Your bech32 addresses don’t match mine at all. How are you creating those addresses? I use Pieter Wuille’s implementation.
Your routine for P2SH and bech32 looks off to me.