Struct psbt::Output

source · []
pub struct Output {
    pub amount: u64,
    pub script: Script,
    pub redeem_script: Option<Script>,
    pub witness_script: Option<Script>,
    pub bip32_derivation: BTreeMap<PublicKey, KeySource>,
    pub tap_internal_key: Option<XOnlyPublicKey>,
    pub tap_tree: Option<TapTree>,
    pub tap_key_origins: BTreeMap<XOnlyPublicKey, (Vec<TapLeafHash>, KeySource)>,
    pub proprietary: BTreeMap<ProprietaryKey, Vec<u8>>,
    pub unknown: BTreeMap<Key, Vec<u8>>,
    /* private fields */
}

Fields

amount: u64

The output’s amount in satoshis.

script: Script

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

redeem_script: Option<Script>

The redeem script for this output.

witness_script: Option<Script>

The witness script for this output.

bip32_derivation: BTreeMap<PublicKey, KeySource>

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

tap_internal_key: Option<XOnlyPublicKey>

The internal pubkey.

tap_tree: Option<TapTree>

Taproot Output tree.

tap_key_origins: BTreeMap<XOnlyPublicKey, (Vec<TapLeafHash>, KeySource)>

Map of tap root x only keys to origin info and leaf hashes contained in it.

proprietary: BTreeMap<ProprietaryKey, Vec<u8>>

Proprietary key-value pairs for this output.

unknown: BTreeMap<Key, Vec<u8>>

Unknown key-value pairs for this output.

Implementations

Extension trait for Output for working with proprietary LNPBP4 keys.

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

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

Errors

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

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

Errors

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

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.

Sets LNPBP4 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.

Sets LNPBP4 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.

Sets LNPBP4 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).

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

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

Errors

If output script is not OP_RETURN script

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

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

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 OP_RETURN script

Assigns value of the tapreturn commitment to this PSBT output, by adding PSBT_OUT_OPRET_COMMITMENT proprietary key containing the 32-byte commitment as its value.

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.

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

Returns information on the specific path within taproot script tree which is allowed as a place for tapret commitment. The path is taken from PSBT_OUT_TAPRET_HOST key.

Returns

A value of the PSBT_OUT_TAPRET_HOST key, if present, or None otherwise. The value is deserialized from the key value data, and if the serialization fails a Some(Err(DfsPathEncodeError)) is returned.

Sets information on the specific path within taproot script tree which is allowed as a place for tapret commitment. The path is put into PSBT_OUT_TAPRET_HOST key.

Errors

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

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.

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

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.

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.

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.

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 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.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Converts to this type from the input type.

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

This method tests for !=.

Decode with the given std::io::Read instance; must either construct an instance or return implementation-specific error type. Read more

Tries to deserialize byte array into the current type using StrictDecode::strict_decode. If there are some data remains in the buffer once deserialization is completed, fails with Error::DataNotEntirelyConsumed. Use io::Cursor over the buffer and StrictDecode::strict_decode to avoid such failures. Read more

Reads data from file at path and reconstructs object from it. Fails with Error::DataNotEntirelyConsumed if file contains remaining data after the object reconstruction. Read more

Encode with the given std::io::Write instance; must return result with either amount of bytes encoded – or implementation-specific error type. Read more

Serializes data as a byte array using StrictEncode::strict_encode function Read more

Saves data to a file at a given path. If the file does not exists, attempts to create the file. If the file already exists, it gets truncated. 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

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.

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