pub trait TapretOutput {
    fn can_host_tapret(&self) -> bool;
fn set_can_host_tapret(&mut self, can_host_commitment: bool) -> bool;
fn has_tapret_commitment(&self) -> bool;
fn tapret_commitment(&self) -> Option<Slice32>;
fn set_tapret_commitment(
        &mut self,
        commitment: impl Into<[u8; 32]>
    ) -> Result<(), KeyError>;
fn has_tapret_proof(&self) -> bool;
fn tapret_proof(&self) -> Option<TaprootMerkleBranch>; }
Expand description

Extension trait adding support for tapreturn commitments to PSBT Output.

Required methods

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

Sets whether this output may contain tapret commitment bu adding or removing PSBT_OUT_TAPRET_HOST key basing on can_host_commitment value.

Detects presence of a vaid 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 proprietary key containing the 32-byte commitment as its value.

Errors with KeyError::OutputAlreadyHasCommitment if the commitment is already present in the 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.

Implementors