I get a not a P2TR scriptPubKey error when attempting to generate a bech32m taproot complient P2TR deal with with python

0
77


I’ve the next script that’s imagined to derive a taproot P2TR deal with:

from bitcointx import set_custom_secp256k1_path
set_custom_secp256k1_path('./bitcointx_secp256k1_here/libsecp256k1.2.dylib')

from bitcointx.pockets 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])
print(csript_from_pub)
addrs_for_script = P2TRBitcoinTestnetAddress.from_scriptPubKey(csript_from_pub)
print(addrs_for_script)

However all that this prints in my terminal is:

b'!x02x8fyx12xc2xc1kOx0erxfcx98xeaMx87Xxeexbbfx16xd9x02x9exca-xdcxeax03xb2x02kx07{xac'
Traceback (most up-to-date name final):
  File "/Customers/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 "/Customers/MYUSERNAME/.virtualenvs/py_scratch_310_071722/lib/python3.10/site-packages/bitcointx/util.py", line 331, in wrapper
    return fn(*args, **kwargs)
  File "/Customers/MYUSERNAME/.virtualenvs/py_scratch_310_071722/lib/python3.10/site-packages/bitcointx/pockets.py", line 504, in from_scriptPubKey
    increase P2TRCoinAddressError('not a P2TR scriptPubKey')
bitcointx.pockets.P2TRCoinAddressError: not a P2TR scriptPubKey

It fails with a “not a P2TR scriptPubKey” error.

I do know that ‘PRIVATE KEY TESTNET EXTENDED WIF’ is able to producing a P2TR deal with. What am I doing improper?

LEAVE A REPLY

Please enter your comment!
Please enter your name here