Struct breez_sdk_core::bitcoin::util::taproot::TaprootSpendInfo
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§
§impl TaprootSpendInfo
impl TaprootSpendInfo
pub fn with_huffman_tree<C, I>(
secp: &Secp256k1<C>,
internal_key: XOnlyPublicKey,
script_weights: I,
) -> Result<TaprootSpendInfo, TaprootBuilderError>
pub fn with_huffman_tree<C, I>( secp: &Secp256k1<C>, internal_key: XOnlyPublicKey, script_weights: I, ) -> Result<TaprootSpendInfo, TaprootBuilderError>
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.
pub fn new_key_spend<C>(
secp: &Secp256k1<C>,
internal_key: XOnlyPublicKey,
merkle_root: Option<TapBranchHash>,
) -> TaprootSpendInfowhere
C: Verification,
pub fn new_key_spend<C>(
secp: &Secp256k1<C>,
internal_key: XOnlyPublicKey,
merkle_root: Option<TapBranchHash>,
) -> TaprootSpendInfowhere
C: Verification,
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.
pub fn tap_tweak(&self) -> TapTweakHash
pub fn tap_tweak(&self) -> TapTweakHash
Returns the TapTweakHash
for this TaprootSpendInfo
i.e., the tweak using internal_key
and merkle_root
.
pub fn internal_key(&self) -> XOnlyPublicKey
pub fn internal_key(&self) -> XOnlyPublicKey
Returns the internal key for this TaprootSpendInfo
.
pub fn merkle_root(&self) -> Option<TapBranchHash>
pub fn merkle_root(&self) -> Option<TapBranchHash>
Returns the merkle root for this TaprootSpendInfo
.
pub fn output_key(&self) -> TweakedPublicKey
pub fn output_key(&self) -> TweakedPublicKey
Returns the output key (the key used in script pubkey) for this TaprootSpendInfo
.
pub fn output_key_parity(&self) -> Parity
pub fn output_key_parity(&self) -> Parity
Returns the parity of the output key. See also TaprootSpendInfo::output_key
.
pub fn from_node_info<C>(
secp: &Secp256k1<C>,
internal_key: XOnlyPublicKey,
node: NodeInfo,
) -> TaprootSpendInfowhere
C: Verification,
pub fn from_node_info<C>(
secp: &Secp256k1<C>,
internal_key: XOnlyPublicKey,
node: NodeInfo,
) -> TaprootSpendInfowhere
C: Verification,
Computes the TaprootSpendInfo
from internal_key
and node
.
This is useful when you want to manually build a taproot tree without using
TaprootBuilder
.
pub fn as_script_map(
&self,
) -> &BTreeMap<(Script, LeafVersion), BTreeSet<TaprootMerkleBranch>>
pub fn as_script_map( &self, ) -> &BTreeMap<(Script, LeafVersion), BTreeSet<TaprootMerkleBranch>>
Returns the internal script map.
pub fn control_block(
&self,
script_ver: &(Script, LeafVersion),
) -> Option<ControlBlock>
pub fn control_block( &self, script_ver: &(Script, LeafVersion), ) -> Option<ControlBlock>
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
, returnsNone
.
Trait Implementations§
§impl Clone for TaprootSpendInfo
impl Clone for TaprootSpendInfo
§fn clone(&self) -> TaprootSpendInfo
fn clone(&self) -> TaprootSpendInfo
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for TaprootSpendInfo
impl Debug for TaprootSpendInfo
§impl<'de> Deserialize<'de> for TaprootSpendInfo
impl<'de> Deserialize<'de> for TaprootSpendInfo
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TaprootSpendInfo, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TaprootSpendInfo, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Hash for TaprootSpendInfo
impl Hash for TaprootSpendInfo
§impl Ord for TaprootSpendInfo
impl Ord for TaprootSpendInfo
§fn cmp(&self, other: &TaprootSpendInfo) -> Ordering
fn cmp(&self, other: &TaprootSpendInfo) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl PartialEq for TaprootSpendInfo
impl PartialEq for TaprootSpendInfo
§impl PartialOrd for TaprootSpendInfo
impl PartialOrd for TaprootSpendInfo
§impl Serialize for TaprootSpendInfo
impl Serialize for TaprootSpendInfo
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for TaprootSpendInfo
impl StructuralPartialEq for TaprootSpendInfo
Auto Trait Implementations§
impl Freeze for TaprootSpendInfo
impl RefUnwindSafe for TaprootSpendInfo
impl Send for TaprootSpendInfo
impl Sync for TaprootSpendInfo
impl Unpin for TaprootSpendInfo
impl UnwindSafe for TaprootSpendInfo
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any
.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request