Title: HELP! Loss of funds / Invalid address Post by: WebStuffs on April 03, 2024, 03:30:46 PM 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-Generator For 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/PrivateKeySegwit Inserting 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! Title: Re: HELP! Loss of funds / Invalid address Post by: Frankolala on April 03, 2024, 03:58:32 PM It is certain that your coins are lost. This is because coins sent to the wrong bitcoin wallet address cannot be retrieve unless, the owner of that wallet choose to send them back to the address that sent him those coins. In your own case, you sent your coins to an invalid address, it is lost forever.
There is always a warning that bitcoin transaction is irreversible. Sorry for your lost mate. Be careful next time to make sure that you are sending your coins to the right wallet address. Title: Re: HELP! Loss of funds / Invalid address Post by: BitMaxz on April 03, 2024, 04:08:04 PM I had already sent some coins to my seemingly invalid p2sh/segwit addresses - are these coins now entirely lost? It's lost if you send it to an address that you don't fully control. How did you import it to Electrum? If you imported the private key to Electrum in a wrong way it would gives you a different address usually legacy address. If I were you try adding the script type before importing the private key check the guide below as sample Code: p2wpkh: bc1...... Next time use BTCpayserver as your payment processor or blockonomics you don't need to develop anything you just need to import your wallet master public key and all invoice(BTC addresses) generated should be came from your master public key that you fully control. Title: Re: HELP! Loss of funds / Invalid address Post by: Findingnemo on April 03, 2024, 05:23:03 PM AFAIK, one master key can generate all three types of addresses, and the reason why you see two different address is because you are using two different derivation path. As long as the address generated using that private keys should have the funds that you send, please try importing the private key again. Title: Re: HELP! Loss of funds / Invalid address Post by: mamuu on April 03, 2024, 06:00:15 PM Hi all, The correct information of the private key in the example you give is below.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-Generator For 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/PrivateKeySegwit Inserting 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! I suggest you use a correct library, I use pycoin (http://"https://github.com/pycoin/pycoin") for python get well soon, thank you Code: input : 5J16zh1Mktz1iWEavJFT8nVRBscDCLQDzChYTeYxU33cQDRnty5 Title: Re: HELP! Loss of funds / Invalid address Post by: BlackHatCoiner on April 03, 2024, 08:12:53 PM 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. It is an invalid address.I had already sent some coins to my seemingly invalid p2sh/segwit addresses - are these coins now entirely lost? None of the addresses you've shared have coins. I assume you meant - 3JKyqNxb5Wb9uh5NUX4S5PhMZTddEiY92n - as p2sh-segwit, and as anyone can notice from a block explorer it has never received any coins. In your own case, you sent your coins to an invalid address, it is lost forever. You can't send coins to an invalid address. An address is (usually) an encoded version of the witness public key hash. If the address is invalid, then it means decoding it will not result in an acceptable locking script.Title: Re: HELP! Loss of funds / Invalid address Post by: DaveF on April 03, 2024, 08:53:38 PM As of 2 months ago this was a known issue with that script:
https://github.com/BRO200BS/Bitcoin-Address-Generator/issues and as @BlackHatCoiner pointed out you can't send coins to an invalid address so there is something else going on. What was the actual address that you generated that had coins sent to it? And do you have the TXID of that transaction? -Dave Title: Re: HELP! Loss of funds / Invalid address Post by: apogio on April 04, 2024, 06:31:10 AM The following warning is a day late and a dollar short.
Let me share my point of view, having written some similar script (https://bitcointalk.org/index.php?topic=5483173.0)myself: Don't! Don't! Don't use scripts that are not properly tested, qualified and used. Open source is fantastic because it allows many pairs of eyes to review the same code. However, it's not a panacea. Most of the time, these pairs of eyes distinguish corner cases and issues. In your particular occasion, as DaveF said above, there was an open issue in the code. So, when using open source, we should at least check: 1. the open issues. 2. the number of forks / stars. 3. the number and quality of open merge requests. 4. the number of contributors. Title: Re: HELP! Loss of funds / Invalid address Post by: NotATether on April 04, 2024, 07:42:45 AM Seems to generate the correct legacy address in ZPyWallet too:
Code: >>> p = zpywallet.PrivateKey.from_hex('188ffa83fc4f665b4fb24460d560540e635ea824ad1576e27644f7835600c85b') I do not have a P2SH generation routine to test against. Neither of the above bech32 addresses match up with yours even slightly. How are you creating the bech32 addresses? I use Pieter Wuille's reference implementation. I think you are also using the same one. However, your P2SH and Bech32 address generation routines are wrong: Code: # Get P2SH address First of all, your script hash is supposed to be just the public key by itself, not the entire redeem script. The opcodes are only to be added right before the Base58 encode. (those opcodes are not even bytes, you made them ASCII characters.) Your second mistake is not resetting the hash160 when you are done so you are using the already incorrect P2SH script hash to create the bech32 address... And even the bech32 calculation itself also has another mistake, you are adding 0x00 0x14, the witness program at the beginning of the address. Why are you adding the witness program into the bech32 address? You are not supposed to do that. Anything that's supposed to be a script opcode is not supposed to be encoded into an address. This is why it's making an invalid qq address. You did not lose any funds unless your coins were sent to the invalid P2SH address, which is the reason why I don't like P2SH-P2WPKH in the first place. Why are you debugging with mainnet addresses anyway? Testnet would've caught this error in a less expensive way. Title: Re: HELP! Loss of funds / Invalid address Post by: brainless on April 07, 2024, 02:35:55 PM Hi all, What address from ? You sent funds ?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-Generator For 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/PrivateKeySegwit Inserting 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! Title: Re: HELP! Loss of funds / Invalid address Post by: Rabbitqt on April 08, 2024, 09:23:17 AM It's lost, and honestly, it sounded like you didn't know what you were doing.
|