mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-08 09:21:06 +02:00
Merge #20207: Follow-up extra comments on taproot code and tests
2d8099c713
Mention units of MAX_STANDARD_ policy constants (Pieter Wuille)84e29c7c01
Mention in validation that IsWitnessStandard tests for P2TR (Pieter Wuille)f867cbcc26
Clean up assets test minimizer LDFLAGS (Pieter Wuille)ea0e78677b
Document additional IsWitnessStandard behavior (Pieter Wuille)6040de9a46
Add comments on CPubKey::IsValid (Pieter Wuille)8dbb7de67c
Add comments to VerifyTaprootCommitment (Pieter Wuille)cdf900cbf2
Document need_vin_vout_mismatch argument to make_spender (Pieter Wuille)18246ed5f0
Fix and improve taproot_construct comments (Pieter Wuille) Pull request description: Addressing some review comments raised here: https://github.com/bitcoin/bitcoin/pull/19953#pullrequestreview-512238027 and https://github.com/bitcoin/bitcoin/pull/19953#pullrequestreview-513499921 ACKs for top commit: jonatack: ACK2d8099c
per `git range-diff5009159
4f10965 2d8099c` ariard: ACK2d8099c
, only changes are comment light improvements on IsValid/IsWitnessStandard. Tree-SHA512: c4881546c379ea8efc7ef99a43cbf3b9cd3f9dde5fd97a07ee66f2b593c78aef0bd8784853c5c9c737b66c269241a1048bbbdd6c964a3d872efd8ba0ec410b68
This commit is contained in:
@ -824,21 +824,33 @@ def taproot_tree_helper(scripts):
|
||||
h = TaggedHash("TapBranch", left_h + right_h)
|
||||
return (left + right, h)
|
||||
|
||||
# A TaprootInfo object has the following fields:
|
||||
# - scriptPubKey: the scriptPubKey (witness v1 CScript)
|
||||
# - inner_pubkey: the inner pubkey (32 bytes)
|
||||
# - negflag: whether the pubkey in the scriptPubKey was negated from inner_pubkey+tweak*G (bool).
|
||||
# - tweak: the tweak (32 bytes)
|
||||
# - leaves: a dict of name -> TaprootLeafInfo objects for all known leaves
|
||||
TaprootInfo = namedtuple("TaprootInfo", "scriptPubKey,inner_pubkey,negflag,tweak,leaves")
|
||||
|
||||
# A TaprootLeafInfo object has the following fields:
|
||||
# - script: the leaf script (CScript or bytes)
|
||||
# - version: the leaf version (0xc0 for BIP342 tapscript)
|
||||
# - merklebranch: the merkle branch to use for this leaf (32*N bytes)
|
||||
TaprootLeafInfo = namedtuple("TaprootLeafInfo", "script,version,merklebranch")
|
||||
|
||||
def taproot_construct(pubkey, scripts=None):
|
||||
"""Construct a tree of Taproot spending conditions
|
||||
|
||||
pubkey: an ECPubKey object for the internal pubkey
|
||||
pubkey: a 32-byte xonly pubkey for the internal pubkey (bytes)
|
||||
scripts: a list of items; each item is either:
|
||||
- a (name, CScript) tuple
|
||||
- a (name, CScript, leaf version) tuple
|
||||
- a (name, CScript or bytes, leaf version) tuple
|
||||
- a (name, CScript or bytes) tuple (defaulting to leaf version 0xc0)
|
||||
- another list of items (with the same structure)
|
||||
- a function, which specifies how to compute the hashing partner
|
||||
in function of the hash of whatever it is combined with
|
||||
- a list of two items; the first of which is an item itself, and the
|
||||
second is a function. The function takes as input the Merkle root of the
|
||||
first item, and produces a (fictitious) partner to hash with.
|
||||
|
||||
Returns: script (sPK or redeemScript), tweak, {name:(script, leaf version, negation flag, innerkey, merklepath), ...}
|
||||
Returns: a TaprootInfo object
|
||||
"""
|
||||
if scripts is None:
|
||||
scripts = []
|
||||
|
Reference in New Issue
Block a user