Saturday, December 2, 2023

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

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

from bitcointx import set_custom_secp256k1_path

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 =
csript_from_pub = CScript([sender_pub_key, OP_CHECKSIG])
addrs_for_script = P2TRBitcoinTestnetAddress.from_scriptPubKey(csript_from_pub)

However all that this prints in my terminal is:

Traceback (most up-to-date name final):
  File "/Customers/MYUSERNAME/Desktop/Dev/bit_useful_scripts/", 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/", line 331, in wrapper
    return fn(*args, **kwargs)
  File "/Customers/MYUSERNAME/.virtualenvs/py_scratch_310_071722/lib/python3.10/site-packages/bitcointx/", line 504, in from_scriptPubKey
    elevate 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 mistaken?

Related Articles


Please enter your comment!
Please enter your name here

Latest Articles