P2SH as the name suggests is created using a script not the public key. So you have to first construct your desired script then compute HASH160 of that serialized script and finally encode it using Base58 using the different version byte.
BTW the library you are using is very old and is obsolete.
Thanks, appreciate the explanation. Do you have any suggestions for a new well maintained & secure Python Bitcoin Library? Only reason I am using that because the code doesn't have anything malicious (it was published by Vitalik) and provides what I need in order to test things.
Since it's only for testing purpose, this code should do the job. Don't forget to install
https://github.com/ofek/bit first.
>>> from bit import Key
>>> key = Key()
>>> key.address
'1GCfsCqwdtM3BSxj1iXKRE4RpK4qMvZZQn'
>>> key.segwit_address
'3Gkt8rYpVuDKxCDM3dDHGUaaFEeANfqbQo'
I want to generate a P2SH address from the pubkey instead.
If you don't need any specific feature (e.g. timelock or multi-signature), you don't really need P2SH address.
Thanks for that, having a quick look at the code on github method segwit_address is pointing to multisig_to_segwit etc I couldn't see the difference between P2PKH & P2SH Type
I will explain what am trying to do exactly, I have generated a public key and then used it in web wallet to generate an address:
- P2SH Type
Now am trying to regenerate the same using python Bitcoin library, I want to get (P2SH type) address using python Bitcoin library in order to receive the same address (P2SH Type) generated by the web wallet when giving it the public key. The reason I am asking if someone can edit the above code in order to get P2SH type instead of P2PKH because the library code can be trusted, unless someone can suggest another reputable Bitcoin python library that can provide the methods needed.
Public Key: 03bbdd00bafea40bf7b268baff4ec7635a0b12e94542067cf4077369be938f7b73
address am trying to match is this: 33ELcBdg6W7parjGxNYUz5uHVHwPqopNjE (P2SH)