Enum bp::short_id::Descriptor
source · pub enum Descriptor {
OnchainBlock {
block_height: u32,
block_checksum: BlockChecksum,
},
OnchainTransaction {
block_height: u32,
block_checksum: BlockChecksum,
tx_index: u16,
},
OnchainTxInput {
block_height: u32,
block_checksum: BlockChecksum,
tx_index: u16,
input_index: u16,
},
OnchainTxOutput {
block_height: u32,
block_checksum: BlockChecksum,
tx_index: u16,
output_index: u16,
},
OffchainTransaction {
tx_checksum: TxChecksum,
},
OffchainTxInput {
tx_checksum: TxChecksum,
input_index: u16,
},
OffchainTxOutput {
tx_checksum: TxChecksum,
output_index: u16,
},
}Expand description
Descriptor enum defines the onchain/offchain entity type
Variants
OnchainBlock
Fields
block_height: u32Height of onchain block
block_checksum: BlockChecksumChecksum of onchain block
Block included onchain
OnchainTransaction
Fields
block_height: u32Height of the block tx belongs to
block_checksum: BlockChecksumChecksum of the block tx belongs to
tx_index: u16Index in the block tx belongs to
Tx included onchain
OnchainTxInput
Fields
block_height: u32Height of the block the tx input belongs to
block_checksum: BlockChecksumChecksum of the block the tx input belongs to
tx_index: u16Index in the block tx belongs to
input_index: u16Index in the tx the input belongs to
Tx input included onchain
OnchainTxOutput
Fields
block_height: u32Height of the block the tx input belongs to
block_checksum: BlockChecksumChecksum of the block the tx input belongs to
tx_index: u16Index in the block tx belongs to
output_index: u16Index in the tx the output belongs to
Tx output included onchain
OffchainTransaction
Fields
tx_checksum: TxChecksumOffchain tx checksum
Tx not included onchain
OffchainTxInput
Fields
tx_checksum: TxChecksumOffchain tx checksum
input_index: u16Index in the tx the input belongs to
Tx input not included onchain
OffchainTxOutput
Fields
tx_checksum: TxChecksumOffchain tx checksum
output_index: u16Index in the tx the output belongs to
Tx output not included onchain
Implementations
sourceimpl Descriptor
impl Descriptor
sourcepub fn try_validity(&self) -> Result<(), Error>
pub fn try_validity(&self) -> Result<(), Error>
Verifies if Descriptor type has valid properties otherwise returns validation error
sourcepub fn is_onchain(&self) -> bool
pub fn is_onchain(&self) -> bool
Returns true if Descriptor type is either OnchainBlock or OnchainTransaction or OnchainTxInput or OnchainTxOutput
sourcepub fn is_offchain(&self) -> bool
pub fn is_offchain(&self) -> bool
Returns true if Descriptor type is not onchain type
sourcepub fn upgraded(
&self,
index: u16,
dimension: Option<Dimension>
) -> Result<Self, Error>
pub fn upgraded(
&self,
index: u16,
dimension: Option<Dimension>
) -> Result<Self, Error>
Upgraded returns the “wrapped descriptor” based on provided parameters. for instance, tx is returned in case descriptor is a block, as well as input/out is returned in case descriptor is a tx and dimension is specified
sourcepub fn downgraded(self) -> Result<Self, Error>
pub fn downgraded(self) -> Result<Self, Error>
Downgraded returns the “wrapper descriptor”, i.e. in case the descriptor is an onchain tx, the onchain block is returned, as well as the onchain tx is returned for onchain input/output
sourcepub fn get_block_height(&self) -> Option<u32>
pub fn get_block_height(&self) -> Option<u32>
Get block height extracting from Descriptor
sourcepub fn get_block_checksum(&self) -> Option<u8>
pub fn get_block_checksum(&self) -> Option<u8>
Get block checksum extracting from Descriptor
sourcepub fn get_tx_checksum(&self) -> Option<u64>
pub fn get_tx_checksum(&self) -> Option<u64>
Get tx checksum extracting from Descriptor
sourcepub fn get_tx_index(&self) -> Option<u16>
pub fn get_tx_index(&self) -> Option<u16>
Get tx index extracting from Descriptor
sourcepub fn get_input_index(&self) -> Option<u16>
pub fn get_input_index(&self) -> Option<u16>
Get input index extracting from Descriptor
sourcepub fn get_output_index(&self) -> Option<u16>
pub fn get_output_index(&self) -> Option<u16>
Get output index extracting from Descriptor
sourcepub fn try_into_u64(self) -> Result<u64, Error>
pub fn try_into_u64(self) -> Result<u64, Error>
Tries to convert short id from Descriptor to u64
Trait Implementations
sourceimpl Clone for Descriptor
impl Clone for Descriptor
sourcefn clone(&self) -> Descriptor
fn clone(&self) -> Descriptor
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more