psrgbt

Struct Output

Source
pub struct Output {
    pub amount: Sats,
    pub script: ScriptPubkey,
    pub redeem_script: Option<RedeemScript>,
    pub witness_script: Option<WitnessScript>,
    pub bip32_derivation: IndexMap<LegacyPk, KeyOrigin>,
    pub tap_internal_key: Option<InternalPk>,
    pub tap_tree: Option<TapTree>,
    pub tap_bip32_derivation: IndexMap<XOnlyPk, TapDerivation>,
    pub proprietary: IndexMap<PropKey, ValueData>,
    pub unknown: IndexMap<u8, IndexMap<ByteStr, ValueData>>,
    /* private fields */
}

Fields§

§amount: Sats

The output’s amount in satoshis.

§script: ScriptPubkey

The script for this output, also known as the scriptPubKey.

§redeem_script: Option<RedeemScript>

The redeem script for this output.

§witness_script: Option<WitnessScript>

The witness script for this output.

§bip32_derivation: IndexMap<LegacyPk, KeyOrigin>

A map from public keys needed to spend this output to their corresponding master key fingerprints and derivation paths.

§tap_internal_key: Option<InternalPk>

The X-only pubkey used as the internal key in this output.

§tap_tree: Option<TapTree>

One or more tuples representing the depth, leaf version, and script for a leaf in the Taproot tree, allowing the entire tree to be reconstructed. The tuples must be in depth first search order so that the tree is correctly reconstructed. Each tuple is an 8-bit unsigned integer representing the depth in the Taproot tree for this script, an 8-bit unsigned integer representing the leaf version, the length of the script as a compact size unsigned integer, and the script itself.

§tap_bip32_derivation: IndexMap<XOnlyPk, TapDerivation>

A compact size unsigned integer representing the number of leaf hashes, followed by a list of leaf hashes, followed by the 4 byte master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. The leaf hashes are of the leaves which involve this public key. The internal key does not have leaf hashes, so can be indicated with a hashes len of 0. Finalizers should remove this field after PSBT_IN_FINAL_SCRIPTWITNESS is constructed.

§proprietary: IndexMap<PropKey, ValueData>

Proprietary keys

§unknown: IndexMap<u8, IndexMap<ByteStr, ValueData>>

Unknown keys

Implementations§

Source§

impl Output

Source

pub fn new(index: usize) -> Output

Source

pub fn with_txout(txout: TxOut, index: usize) -> Output

Source

pub fn from_txout(_: (usize, TxOut)) -> Output

Source

pub fn to_txout(&self) -> TxOut

Source

pub fn value(&self) -> Sats

Source

pub fn index(&self) -> usize

Source

pub fn vout(&self) -> Vout

Source

pub fn terminal_derivation(&self) -> Option<Terminal>

Source§

impl Output

Extension trait for Output for working with proprietary MPC keys.

Source

pub fn mpc_message_map( &self, ) -> Result<Confined<BTreeMap<ProtocolId, Message>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>, MpcPsbtError>

Returns mpc::MessageMap constructed from the proprietary key data.

Source

pub fn mpc_message(&self, protocol_id: ProtocolId) -> Option<Message>

Returns a valid LNPBP-4 Message associated with the given ProtocolId, if any.

We do not error on invalid data in order to support future update of this proprietary key to a standard one. In this case, the invalid data will be filtered at the moment of PSBT deserialization and this function will return None only in situations when the key is absent.

Source

pub fn mpc_entropy(&self) -> Option<u64>

Returns a valid LNPBP-4 entropy value, if present.

We do not error on invalid data in order to support future update of this proprietary key to a standard one. In this case, the invalid data will be filtered at the moment of PSBT deserialization and this function will return None only in situations when the key is absent.

Source

pub fn mpc_min_tree_depth(&self) -> Option<u8>

Returns a valid LNPBP-4 minimal tree depth value, if present.

§Errors

If the key is present, but it’s value can’t be deserialized as a valid minimal tree depth value.

Source

pub fn set_mpc_message( &mut self, protocol_id: ProtocolId, message: Message, ) -> Result<bool, MpcPsbtError>

Sets MPC Message for the given ProtocolId.

§Returns

true, if the message was set successfully, false if this message was already present for this protocol.

§Errors

If the key for the given ProtocolId is already present and the message is different.

Source

pub fn set_mpc_entropy(&mut self, entropy: u64) -> Result<bool, MpcPsbtError>

Sets MPC entropy value.

§Returns

true, if the entropy was set successfully, false if this entropy value was already set.

§Errors

If the entropy was already set with a different value than the provided one.

Source

pub fn set_mpc_min_tree_depth( &mut self, min_depth: u8, ) -> Result<Option<u8>, MpcPsbtError>

Sets MPC min tree depth value.

§Returns

Previous minimal tree depth value, if it was present and valid - or None if the value was absent or invalid (the new value is still assigned).

Source

pub fn mpc_commit(&mut self) -> Result<(Commitment, MerkleBlock), MpcPsbtError>

Source§

impl Output

Source

pub fn is_opret_host(&self) -> bool

Returns whether this output may contain opret commitment. This is detected by the presence of PSBT_OUT_OPRET_HOST key.

Source

pub fn set_opret_host(&mut self) -> Result<bool, OpretKeyError>

Allows opret commitments for this output. Returns whether opret commitments were enabled before.

§Errors

If output script is not OP_RETURN script

Source

pub fn has_opret_commitment(&self) -> Result<bool, OpretKeyError>

Detects presence of a valid PSBT_OUT_OPRET_COMMITMENT.

If PSBT_OUT_OPRET_COMMITMENT is absent or its value is invalid, returns false. In the future, when PSBT_OUT_OPRET_COMMITMENT will become a standard and non-custom key, PSBTs with invalid key values will error at deserialization and this function will return false only in cases when the output does not have PSBT_OUT_OPRET_COMMITMENT.

§Errors

If output script is not OP_RETURN script

Source

pub fn opret_commitment(&self) -> Result<Commitment, OpretKeyError>

Returns valid opret commitment from the PSBT_OUT_OPRET_COMMITMENT key, if present. If the commitment is absent or invalid, returns OpretKeyError::NoCommitment.

We do not error on invalid commitments in order to support future update of this proprietary key to the standard one. In this case, the invalid commitments (having non-32 bytes) will be filtered at the moment of PSBT deserialization and this function will return None only in situations when the commitment is absent.

§Errors

If output script is not a valid opret host script.

Source

pub fn opret_commit( &mut self, commitment: Commitment, ) -> Result<(), OpretKeyError>

Assigns value of the opreturn commitment to this PSBT output, by adding PSBT_OUT_OPRET_COMMITMENT proprietary key containing the 32-byte commitment as its value. Also modifies the output script and removes PSBT_OUT_OPRET_HOST key.

Opret commitment can be set only once.

Errors with OpretKeyError::OutputAlreadyHasCommitment if the commitment is already present in the output.

§Errors

If output script is not OP_RETURN script or opret commitments are not enabled for this output.

Source§

impl Output

Source

pub fn is_tapret_host(&self) -> bool

Returns whether this output may contain tapret commitment. This is detected by the presence of PSBT_OUT_TAPRET_HOST key.

Source

pub fn set_tapret_host(&mut self) -> Result<bool, TapretKeyError>

Allows tapret commitments for this output. Returns whether tapret commitments were enabled before.

§Errors

Errors with TapretKeyError::NotTaprootOutput if the output is not a taproot output.

Source

pub fn has_tapret_commitment(&self) -> Result<bool, TapretKeyError>

Detects presence of a valid PSBT_OUT_TAPRET_COMMITMENT.

If PSBT_OUT_TAPRET_COMMITMENT is absent or its value is invalid, returns false. In the future, when PSBT_OUT_TAPRET_COMMITMENT will become a standard and non-custom key, PSBTs with invalid key values will error at deserialization and this function will return false only in cases when the output does not have PSBT_OUT_TAPRET_COMMITMENT.

Source

pub fn tapret_commitment(&self) -> Result<TapretCommitment, TapretKeyError>

Returns valid tapret commitment from the PSBT_OUT_TAPRET_COMMITMENT key, if present. If the commitment is absent or invalid, returns TapretKeyError::NoCommitment.

We do not error on invalid commitments in order to support future update of this proprietary key to the standard one. In this case, the invalid commitments (having non-32 bytes) will be filtered at the moment of PSBT deserialization and this function will return None only in situations when the commitment is absent.

Source

pub fn tapret_commit( &mut self, commitment: Commitment, ) -> Result<TapretProof, TapretKeyError>

Assigns value of the tapreturn commitment to this PSBT output, by adding PSBT_OUT_TAPRET_COMMITMENT and PSBT_OUT_TAPRET_PROOF proprietary keys containing the 32-byte commitment as its proof.

§Errors

Errors with TapretKeyError::OutputAlreadyHasCommitment if the commitment is already present in the output, and with TapretKeyError::TapretProhibited if tapret commitments are not enabled for this output.

Source

pub fn has_tapret_proof(&self) -> bool

Detects presence of a valid PSBT_OUT_TAPRET_PROOF.

If PSBT_OUT_TAPRET_PROOF is absent or its value is invalid, returns false. In the future, when PSBT_OUT_TAPRET_PROOF will become a standard and non-custom key, PSBTs with invalid key values will error at deserialization and this function will return false only in cases when the output does not have PSBT_OUT_TAPRET_PROOF.

Source

pub fn tapret_proof(&self) -> Option<TapretProof>

Returns valid tapret commitment proof from the PSBT_OUT_TAPRET_PROOF key, if present. If the commitment is absent or invalid, returns None.

We do not error on invalid proofs in order to support future update of this proprietary key to a standard one. In this case, the invalid commitments (having non-32 bytes) will be filtered at the moment of PSBT deserialization and this function will return None only in situations when the commitment is absent.

Function returns generic type since the real type will create dependency on bp-dpc crate, which will result in circular dependency with the current crate.

Trait Implementations§

Source§

impl Clone for Output

Source§

fn clone(&self) -> Output

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Output

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl KeyMap for Output

Source§

const PROPRIETARY_TYPE: <Output as KeyMap>::Keys = OutputKey::Proprietary

Source§

type Keys = OutputKey

Source§

fn retrieve_key_pair<'enc>( &'enc self, _: PsbtVer, key_type: <Output as KeyMap>::Keys, ) -> Vec<KeyPair<<Output as KeyMap>::Keys, Box<dyn Encode + 'enc>, Box<dyn Encode + 'enc>>>

Source§

fn insert_singular( &mut self, key_type: <Output as KeyMap>::Keys, value_data: ValueData, ) -> Result<(), PsbtError>

Source§

fn insert_plural( &mut self, key_type: <Output as KeyMap>::Keys, key_data: ByteStr, value_data: ValueData, ) -> Result<(), PsbtError>

Source§

fn encode_map( &self, version: PsbtVer, writer: &mut dyn Write, ) -> Result<usize, IoError>

Source§

fn parse_map( &mut self, version: PsbtVer, map: Map<Self::Keys>, ) -> Result<(), PsbtError>

Source§

fn has_proprietary(&self, key: &PropKey) -> bool

Source§

fn proprietary(&self, key: &PropKey) -> Option<&ValueData>

Source§

fn proprietary_mut(&mut self, key: &PropKey) -> Option<&mut ValueData>

Source§

fn push_proprietary( &mut self, key: PropKey, value: impl Into<ValueData>, ) -> Result<(), KeyAlreadyPresent>

Source§

fn remove_proprietary(&mut self, key: &PropKey) -> Option<ValueData>

Source§

fn insert_proprietary(&mut self, prop_key: PropKey, value_data: ValueData)

Source§

fn insert_unknown( &mut self, key_type: u8, key_data: ByteStr, value_data: ValueData, )

Source§

impl PartialEq for Output

Source§

fn eq(&self, other: &Output) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RgbOutExt for Output

Source§

fn rgb_velocity_hint(&self) -> Option<VelocityHint>

Returns hint for the velocity of the state which may be assigned to the provided output. Read more
Source§

fn set_rgb_velocity_hint(&mut self, hint: VelocityHint) -> bool

Adds hint for the velocity of the state which may be assigned to the PSBT output. Read more
Source§

impl Serialize for Output

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Output

Source§

impl StructuralPartialEq for Output

Auto Trait Implementations§

§

impl Freeze for Output

§

impl RefUnwindSafe for Output

§

impl Send for Output

§

impl Sync for Output

§

impl Unpin for Output

§

impl UnwindSafe for Output

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> VerifyEq for T
where T: Eq,

Source§

fn verify_eq(&self, other: &T) -> bool

Verifies commit-equivalence of two instances of the same type.