aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/script.py
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2022-10-24 14:26:29 -0400
committerPieter Wuille <pieter@wuille.net>2022-11-21 14:00:43 -0500
commit5d413c8e793a439540d064d24fddfc868e1817d0 (patch)
tree0be2e576c9c292b2d547bc26a8d2e2e1a2dbe39a /test/functional/test_framework/script.py
parent1c5c951713a97511274299856f1d7c09f86bf2f0 (diff)
Add feature_taproot case involved invalid internal pubkey
Diffstat (limited to 'test/functional/test_framework/script.py')
-rw-r--r--test/functional/test_framework/script.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/test/functional/test_framework/script.py b/test/functional/test_framework/script.py
index 2b70eab4e4..f531ccc030 100644
--- a/test/functional/test_framework/script.py
+++ b/test/functional/test_framework/script.py
@@ -12,7 +12,7 @@ import struct
import unittest
from typing import List, Dict
-from .key import TaggedHash, tweak_add_pubkey
+from .key import TaggedHash, tweak_add_pubkey, compute_xonly_pubkey
from .messages import (
CTransaction,
@@ -872,7 +872,7 @@ TaprootInfo = namedtuple("TaprootInfo", "scriptPubKey,internal_pubkey,negflag,tw
# - merklebranch: the merkle branch to use for this leaf (32*N bytes)
TaprootLeafInfo = namedtuple("TaprootLeafInfo", "script,version,merklebranch,leaf_hash")
-def taproot_construct(pubkey, scripts=None):
+def taproot_construct(pubkey, scripts=None, treat_internal_as_infinity=False):
"""Construct a tree of Taproot spending conditions
pubkey: a 32-byte xonly pubkey for the internal pubkey (bytes)
@@ -891,7 +891,10 @@ def taproot_construct(pubkey, scripts=None):
ret, h = taproot_tree_helper(scripts)
tweak = TaggedHash("TapTweak", pubkey + h)
- tweaked, negated = tweak_add_pubkey(pubkey, tweak)
+ if treat_internal_as_infinity:
+ tweaked, negated = compute_xonly_pubkey(tweak)
+ else:
+ tweaked, negated = tweak_add_pubkey(pubkey, tweak)
leaves = dict((name, TaprootLeafInfo(script, version, merklebranch, leaf)) for name, version, script, merklebranch, leaf in ret)
return TaprootInfo(CScript([OP_1, tweaked]), pubkey, negated + 0, tweak, leaves, h, tweaked)