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
impl Output
pub fn new(index: usize) -> Output
pub fn with_txout(txout: TxOut, index: usize) -> Output
pub fn from_txout(_: (usize, TxOut)) -> Output
pub fn to_txout(&self) -> TxOut
pub fn value(&self) -> Sats
pub fn index(&self) -> usize
pub fn vout(&self) -> Vout
pub fn terminal_derivation(&self) -> Option<Terminal>
Source§impl Output
impl Output
Extension trait for Output
for working with proprietary MPC
keys.
Sourcepub fn mpc_message_map(
&self,
) -> Result<Confined<BTreeMap<ProtocolId, Message>, amplify::::collection::confinement::MediumOrdMap::{constant#0}, amplify::::collection::confinement::MediumOrdMap::{constant#1}>, MpcPsbtError>
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.
Sourcepub fn mpc_message(&self, protocol_id: ProtocolId) -> Option<Message>
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.
Sourcepub fn mpc_entropy(&self) -> Option<u64>
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.
Sourcepub fn mpc_min_tree_depth(&self) -> Option<u8>
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.
Sourcepub fn set_mpc_message(
&mut self,
protocol_id: ProtocolId,
message: Message,
) -> Result<bool, MpcPsbtError>
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.
Sourcepub fn set_mpc_entropy(&mut self, entropy: u64) -> Result<bool, MpcPsbtError>
pub fn set_mpc_entropy(&mut self, entropy: u64) -> Result<bool, MpcPsbtError>
Sourcepub fn set_mpc_min_tree_depth(
&mut self,
min_depth: u8,
) -> Result<Option<u8>, MpcPsbtError>
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).
pub fn mpc_commit(&mut self) -> Result<(Commitment, MerkleBlock), MpcPsbtError>
Source§impl Output
impl Output
Sourcepub fn is_opret_host(&self) -> bool
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.
Sourcepub fn set_opret_host(&mut self) -> Result<bool, OpretKeyError>
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
Sourcepub fn has_opret_commitment(&self) -> Result<bool, OpretKeyError>
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
Sourcepub fn opret_commitment(&self) -> Result<Commitment, OpretKeyError>
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.
Sourcepub fn opret_commit(
&mut self,
commitment: Commitment,
) -> Result<(), OpretKeyError>
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
impl Output
Sourcepub fn is_tapret_host(&self) -> bool
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.
Sourcepub fn set_tapret_host(&mut self) -> Result<bool, TapretKeyError>
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.
Sourcepub fn has_tapret_commitment(&self) -> Result<bool, TapretKeyError>
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
.
Sourcepub fn tapret_commitment(&self) -> Result<TapretCommitment, TapretKeyError>
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.
Sourcepub fn tapret_commit(
&mut self,
commitment: Commitment,
) -> Result<TapretProof, TapretKeyError>
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.
Sourcepub fn has_tapret_proof(&self) -> bool
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
.
Sourcepub fn tapret_proof(&self) -> Option<TapretProof>
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 KeyMap for Output
impl KeyMap for Output
const PROPRIETARY_TYPE: <Output as KeyMap>::Keys = OutputKey::Proprietary
type Keys = OutputKey
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>>>
fn insert_singular( &mut self, key_type: <Output as KeyMap>::Keys, value_data: ValueData, ) -> Result<(), PsbtError>
fn insert_plural( &mut self, key_type: <Output as KeyMap>::Keys, key_data: ByteStr, value_data: ValueData, ) -> Result<(), PsbtError>
fn encode_map( &self, version: PsbtVer, writer: &mut dyn Write, ) -> Result<usize, IoError>
fn parse_map( &mut self, version: PsbtVer, map: Map<Self::Keys>, ) -> Result<(), PsbtError>
fn has_proprietary(&self, key: &PropKey) -> bool
fn proprietary(&self, key: &PropKey) -> Option<&ValueData>
fn proprietary_mut(&mut self, key: &PropKey) -> Option<&mut ValueData>
fn push_proprietary( &mut self, key: PropKey, value: impl Into<ValueData>, ) -> Result<(), KeyAlreadyPresent>
fn remove_proprietary(&mut self, key: &PropKey) -> Option<ValueData>
fn insert_proprietary(&mut self, prop_key: PropKey, value_data: ValueData)
fn insert_unknown( &mut self, key_type: u8, key_data: ByteStr, value_data: ValueData, )
Source§impl RgbOutExt for Output
impl RgbOutExt for Output
Source§fn rgb_velocity_hint(&self) -> Option<VelocityHint>
fn rgb_velocity_hint(&self) -> Option<VelocityHint>
Source§fn set_rgb_velocity_hint(&mut self, hint: VelocityHint) -> bool
fn set_rgb_velocity_hint(&mut self, hint: VelocityHint) -> bool
Source§impl Serialize for Output
impl Serialize for Output
Source§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 Output
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> 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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.