|
2 | 2 | //! |
3 | 3 | //! See: <https://github.com/Blockstream/esplora/blob/master/API.md> |
4 | 4 |
|
| 5 | +use bitcoin::hash_types; |
| 6 | +use serde::Deserialize; |
| 7 | + |
5 | 8 | pub use bitcoin::consensus::{deserialize, serialize}; |
6 | 9 | pub use bitcoin::hex::FromHex; |
7 | | -use bitcoin::Weight; |
8 | 10 | pub use bitcoin::{ |
9 | | - transaction, Amount, BlockHash, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, Witness, |
| 11 | + absolute, block, transaction, Amount, BlockHash, CompactTarget, OutPoint, ScriptBuf, |
| 12 | + ScriptHash, Transaction, TxIn, TxOut, Txid, Weight, Witness, |
10 | 13 | }; |
11 | 14 |
|
12 | | -use serde::Deserialize; |
13 | | - |
14 | 15 | #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] |
15 | 16 | pub struct PrevOut { |
16 | 17 | pub value: u64, |
@@ -215,6 +216,36 @@ pub struct Utxo { |
215 | 216 | pub value: Amount, |
216 | 217 | } |
217 | 218 |
|
| 219 | +/// Statistics about the mempool. |
| 220 | +#[derive(Clone, Debug, PartialEq, Deserialize)] |
| 221 | +pub struct MempoolStats { |
| 222 | + /// The number of transactions in the mempool. |
| 223 | + pub count: usize, |
| 224 | + /// The total size of mempool transactions in virtual bytes. |
| 225 | + pub vsize: usize, |
| 226 | + /// The total fee paid by mempool transactions, in sats. |
| 227 | + pub total_fee: u64, |
| 228 | + /// The mempool's fee rate distribution histogram. |
| 229 | + /// |
| 230 | + /// An array of `(feerate, vsize)` tuples, where each entry's `vsize` is the total vsize |
| 231 | + /// of transactions paying more than `feerate` but less than the previous entry's `feerate` |
| 232 | + /// (except for the first entry, which has no upper bound). |
| 233 | + pub fee_histogram: Vec<(f64, usize)>, |
| 234 | +} |
| 235 | + |
| 236 | +/// A [`Transaction`] that recently entered the mempool. |
| 237 | +#[derive(Clone, Debug, PartialEq, Eq, Deserialize)] |
| 238 | +pub struct MempoolRecentTx { |
| 239 | + /// Transaction ID as a [`Txid`]. |
| 240 | + pub txid: Txid, |
| 241 | + /// [`Amount`] of fees paid by the transaction, in satoshis. |
| 242 | + pub fee: u64, |
| 243 | + /// The transaction size, in virtual bytes. |
| 244 | + pub vsize: usize, |
| 245 | + /// Combined [`Amount`] of the transaction, in satoshis. |
| 246 | + pub value: u64, |
| 247 | +} |
| 248 | + |
218 | 249 | impl Tx { |
219 | 250 | pub fn to_tx(&self) -> Transaction { |
220 | 251 | Transaction { |
|
0 commit comments