pub struct Output {
pub amount: u64,
pub script: PubkeyScript,
pub redeem_script: Option<RedeemScript>,
pub witness_script: Option<WitnessScript>,
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: PubkeyScript
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: 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§
source§impl Output
impl Output
Extension trait for Output
for working with proprietary LNPBP4
keys.
sourcepub fn lnpbp4_message_map(&self) -> Result<MessageMap, Lnpbp4KeyError>
pub fn lnpbp4_message_map(&self) -> Result<MessageMap, Lnpbp4KeyError>
Returns lnpbp4::MessageMap
constructed from the proprietary key
data.
sourcepub fn lnpbp4_message(
&self,
protocol_id: ProtocolId
) -> Result<Option<Message>, Lnpbp4KeyError>
pub fn lnpbp4_message(
&self,
protocol_id: ProtocolId
) -> Result<Option<Message>, Lnpbp4KeyError>
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
.
sourcepub fn lnpbp4_entropy(&self) -> Result<Option<u64>, Lnpbp4KeyError>
pub fn lnpbp4_entropy(&self) -> Result<Option<u64>, Lnpbp4KeyError>
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.
sourcepub fn lnpbp4_min_tree_depth(&self) -> Result<Option<u8>, Lnpbp4KeyError>
pub fn lnpbp4_min_tree_depth(&self) -> Result<Option<u8>, Lnpbp4KeyError>
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_lnpbp4_message(
&mut self,
protocol_id: ProtocolId,
message: Message
) -> Result<bool, Lnpbp4KeyError>
pub fn set_lnpbp4_message(
&mut self,
protocol_id: ProtocolId,
message: Message
) -> Result<bool, Lnpbp4KeyError>
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.
sourcepub fn set_lnpbp4_entropy(
&mut self,
entropy: u64
) -> Result<bool, Lnpbp4KeyError>
pub fn set_lnpbp4_entropy(
&mut self,
entropy: u64
) -> Result<bool, Lnpbp4KeyError>
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<Option<Slice32>, OpretKeyError>
pub fn opret_commitment(&self) -> Result<Option<Slice32>, OpretKeyError>
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
sourcepub fn set_opret_commitment(
&mut self,
commitment: impl Into<[u8; 32]>
) -> Result<(), OpretKeyError>
pub fn set_opret_commitment(
&mut self,
commitment: impl Into<[u8; 32]>
) -> 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.
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 tapret_dfs_path(&self) -> Option<Result<DfsPath, DfsPathEncodeError>>
pub fn tapret_dfs_path(&self) -> Option<Result<DfsPath, DfsPathEncodeError>>
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.
sourcepub fn set_tapret_dfs_path(
&mut self,
path: &DfsPath
) -> Result<(), TapretKeyError>
pub fn set_tapret_dfs_path(
&mut self,
path: &DfsPath
) -> Result<(), TapretKeyError>
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.
sourcepub fn has_tapret_commitment(&self) -> bool
pub fn has_tapret_commitment(&self) -> bool
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) -> Option<Slice32>
pub fn tapret_commitment(&self) -> Option<Slice32>
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.
sourcepub fn set_tapret_commitment(
&mut self,
commitment: impl Into<[u8; 32]>,
proof: &impl StrictEncode
) -> Result<(), TapretKeyError>
pub fn set_tapret_commitment(
&mut self,
commitment: impl Into<[u8; 32]>,
proof: &impl StrictEncode
) -> Result<(), 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<T>(&self) -> Result<Option<T>, TapretKeyError>where
T: StrictDecode,
pub fn tapret_proof<T>(&self) -> Result<Option<T>, TapretKeyError>where
T: StrictDecode,
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§
source§impl PartialEq<Output> for Output
impl PartialEq<Output> for Output
source§impl StrictDecode for Output
impl StrictDecode for Output
source§fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
std::io::Read
instance; must either
construct an instance or return implementation-specific error type.source§fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
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.source§fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
path
and reconstructs object from it. Fails
with Error::DataNotEntirelyConsumed
if file contains remaining
data after the object reconstruction.source§impl StrictEncode for Output
impl StrictEncode for Output
source§fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
std::io::Write
instance; must return result
with either amount of bytes encoded – or implementation-specific
error type.source§fn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
fn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
StrictEncode::strict_encode
function