Hi all,
I have been recently working on making a payment processor for myself. I found this script, that seemed to generate all of the basic types of Bitcoin addresses. I tested it, and I was able to use the legacy addresses just fine, so I kept going with it.
Some time into testing, I started generating addresses, including the bech and segwith accesses (bc and 3 prefixes), and sent some transactions to those addresses. I noticed that the bech address was invalid, and realized that I may have made a mistake. I tried importing the private keys I had generated to see if I can access the bech and segwith addresses, and to my horror the addresses are different to what the script generated.
Here is the repo:
https://github.com/BRO200BS/Bitcoin-Address-GeneratorFor example, here is a key I just generated:
'private_key': '188ffa83fc4f665b4fb24460d560540e635ea824ad1576e27644f7835600c85b'
'WIF': '5J16zh1Mktz1iWEavJFT8nVRBscDCLQDzChYTeYxU33cQDRnty5'
'p2pkh_address': '1EcW6UVqRCpsww7RA8moBjx6RypYnnraDA'
'compressed_p2pkh_address': '16cSkuPktoD5u9aN3ttnNf9YYb1jvK4Sjw'
'p2sh_address': '3JKyqNxb5Wb9uh5NUX4S5PhMZTddEiY92n'
'bech32_address': 'bc1qq2tvlagcm8zdwf9h0mjhzu9m6s3q84w8kpsj83wvj'
As you can see, the bech address is starting with "bc1qq" which doesnt seem to be valid. I also had no luck in getting my private key to resolve to the p2sh address.
I tried using this service to see what the output would be:
https://secretscan.org/PrivateKeySegwitInserting the private key above to the site above yields the following address: 32kecU8BJMWCiDbCxCR4EaYc3fZx5bDPpy, likewise when I import the compressed WIF to my Electrum, it results in this address not the one generated by my script.
I had already sent some coins to my seemingly invalid p2sh/segwit addresses - are these coins now entirely lost?
Thanks to anyone who might be able to assist me!
The correct information of the private key in the example you give is below.
input : 5J16zh1Mktz1iWEavJFT8nVRBscDCLQDzChYTeYxU33cQDRnty5
network : Bitcoin mainnet
symbol : BTC
secret exponent : 11109896491172774014105289341808672370464295922053509351635184062993478502491
hex : 188ffa83fc4f665b4fb24460d560540e635ea824ad1576e27644f7835600c85b
wif : Kx3TTdaackSeAC2xiF8nMMnRkzNQq2dWKUdwrck3pL2XFTaYX3f5
uncompressed : 5J16zh1Mktz1iWEavJFT8nVRBscDCLQDzChYTeYxU33cQDRnty5
public pair x : 90629257113961921745629633883391754337878636139328260909933221655819498999864
public pair y : 88699594181249121212269429001654019420539278288000816039192792995060957725698
x as hex : c85e577b31823438840964c8aa545e3a348a283f5ee66e70cbb478ed3136d038
y as hex : c41a30f30173e2d1ff34f444c11e90ff97cbba3bc3fc05a60658ff361a664402
y parity : even
key pair as sec : 02c85e577b31823438840964c8aa545e3a348a283f5ee66e70cbb478ed3136d038
uncompressed : 04c85e577b31823438840964c8aa545e3a348a283f5ee66e70cbb478ed3136d038\
c41a30f30173e2d1ff34f444c11e90ff97cbba3bc3fc05a60658ff361a664402
hash160 : 3d8cb03b39d2e1a7202279e0f678afa477b3e1f3
uncompressed : 95507b09c46da9af57aaa398dc2ebcc79b164810
Bitcoin address : 16cSkuPktoD5u9aN3ttnNf9YYb1jvK4Sjw
Bitcoin address uncompressed : 1EcW6UVqRCpsww7RA8moBjx6RypYnnraDA
Bitcoin segwit address : bc1q8kxtqwee6ts6wgpz08s0v79053mm8c0n82rvxm
p2sh segwit : 32kecU8BJMWCiDbCxCR4EaYc3fZx5bDPpy
corresponding p2sh script : 00143d8cb03b39d2e1a7202279e0f678afa477b3e1f3