Skip to content

Commit 3c8b6e3

Browse files
committed
feat(api): create UtxoStatus and Utxo structs
1 parent 5740ceb commit 3c8b6e3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/api.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,33 @@ pub struct AddressTxsSummary {
123123
pub tx_count: u32,
124124
}
125125

126+
/// Information about an UTXO's status: confirmation status,
127+
/// confirmation height, confirmation block hash and confirmation block time.
128+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize)]
129+
pub struct UtxoStatus {
130+
/// Whether or not the UTXO is confirmed.
131+
pub confirmed: bool,
132+
/// The block height in which the UTXO was confirmed.
133+
pub block_height: Option<u32>,
134+
/// The block hash in which the UTXO was confirmed.
135+
pub block_hash: Option<BlockHash>,
136+
/// The UNIX timestamp in which the UTXO was confirmed.
137+
pub block_time: Option<u64>,
138+
}
139+
140+
/// Information about an UTXO's outpoint, confirmation status and value.
141+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize)]
142+
pub struct Utxo {
143+
/// The [`Txid`] of the transaction that created the UTXO.
144+
pub txid: Txid,
145+
/// The output index of the UTXO on the transaction that created the it.
146+
pub vout: u32,
147+
/// The confirmation status of the UTXO.
148+
pub status: UtxoStatus,
149+
/// The value of the UTXO as an [`Amount`].
150+
pub value: Amount,
151+
}
152+
126153
impl Tx {
127154
pub fn to_tx(&self) -> Transaction {
128155
Transaction {

0 commit comments

Comments
 (0)