I get a not a P2TR scriptPubKey error when trying to generate a bech32m taproot complient P2TR address with python
0
0
I have the following script that is supposed to derive a taproot P2TR address:
from bitcointx import set_custom_secp256k1_path
set_custom_secp256k1_path('./bitcointx_secp256k1_here/libsecp256k1.2.dylib')
from bitcointx.wallet import P2TRBitcoinTestnetAddress, P2TRCoinAddress, CBitcoinTestnetKey, CBitcoinTestnetExtKey
from bitcointx.core.script import (CScript, OP_CHECKSIG, OP_NUMEQUAL, CScriptWitness)
sender_priv_key = CBitcoinTestnetExtKey('PRIVATE KEY TESTNET EXTENDED WIF')
sender_pub_key = sender_priv_key.pub
csript_from_pub = CScript([sender_pub_key, OP_CHECKSIG])
addrs_for_script = P2TRBitcoinTestnetAddress.from_scriptPubKey(csript_from_pub)
print(addrs_for_script)
But all that this prints in my terminal is:
Traceback (most recent call last):
File "/Users/MYUSERNAME/Desktop/Dev/bit_useful_scripts/simple_send_from_segv1.py", line 12, in <module>
addrs_for_script = P2TRBitcoinTestnetAddress.from_scriptPubKey(csript_from_pub)
File "/Users/MYUSERNAME/.virtualenvs/py_scratch_310_071722/lib/python3.10/site-packages/bitcointx/util.py", line 331, in wrapper
return fn(*args, **kwargs)
File "/Users/MYUSERNAME/.virtualenvs/py_scratch_310_071722/lib/python3.10/site-packages/bitcointx/wallet.py", line 504, in from_scriptPubKey
raise P2TRCoinAddressError('not a P2TR scriptPubKey')
bitcointx.wallet.P2TRCoinAddressError: not a P2TR scriptPubKey
It fails with a "not a P2TR scriptPubKey" error.
I know that PRIVATE KEY TESTNET EXTENDED WIF is capable of producing a P2TR address. What am I doing wrong?