pub struct TaprootSpendInfo { /* private fields */ }
Expand description

Represents taproot spending information.

Taproot output corresponds to a combination of a single public key condition (known as the internal key), and zero or more general conditions encoded in scripts organized in the form of a binary tree.

Taproot can be spent by either:

  • Spending using the key path i.e., with secret key corresponding to the tweaked output_key.
  • By satisfying any of the scripts in the script spend path. Each script can be satisfied by providing a witness stack consisting of the script’s inputs, plus the script itself and the control block.

If one or more of the spending conditions consist of just a single key (after aggregation), the most likely key should be made the internal key. See BIP341 for more details on choosing internal keys for a taproot application.

Note: This library currently does not support annex.

Implementations

Creates a new TaprootSpendInfo from a list of scripts (with default script version) and weights of satisfaction for that script.

See TaprootBuilder::with_huffman_tree for more detailed documentation.

Creates a new key spend with internal_key and merkle_root. Provide None for the merkle_root if there is no script path.

Note: As per BIP341

When the merkle root is None, the output key commits to an unspendable script path instead of having no script path. This is achieved by computing the output key point as Q = P + int(hashTapTweak(bytes(P)))G. See also TaprootSpendInfo::tap_tweak.

Refer to BIP 341 footnote (‘Why should the output key always have a taproot commitment, even if there is no script path?’) for more details.

Returns the TapTweakHash for this TaprootSpendInfo i.e., the tweak using internal_key and merkle_root.

Returns the internal key for this TaprootSpendInfo.

Returns the merkle root for this TaprootSpendInfo.

Returns the output key (the key used in script pubkey) for this TaprootSpendInfo.

Returns the parity of the output key. See also TaprootSpendInfo::output_key.

Computes the TaprootSpendInfo from internal_key and node.

This is useful when you want to manually build a taproot tree without using TaprootBuilder.

Returns the internal script map.

Constructs a ControlBlock for particular script with the given version.

Returns
  • If there are multiple control blocks possible, returns the shortest one.
  • If the script is not contained in the TaprootSpendInfo, returns None.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.