smplx_sdk/transaction/
tx_receipt.rs1use std::fmt;
2use std::fmt::{Debug, Display, Formatter};
3
4use simplicityhl::elements::Txid;
5
6use crate::provider::{ProviderError, ProviderTrait};
7
8#[derive(Clone, Copy)]
10pub struct TxReceipt<'a> {
11 provider: &'a dyn ProviderTrait,
12 tx_id: Txid,
13}
14
15impl Display for TxReceipt<'_> {
16 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
17 Display::fmt(&self.tx_id, f)
18 }
19}
20
21impl Debug for TxReceipt<'_> {
22 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
23 Debug::fmt(&self.tx_id, f)
24 }
25}
26
27impl AsRef<Txid> for TxReceipt<'_> {
28 fn as_ref(&self) -> &Txid {
29 &self.tx_id
30 }
31}
32
33impl<'a> TxReceipt<'a> {
34 pub fn new(provider: &'a dyn ProviderTrait, tx_id: Txid) -> Self {
36 Self { provider, tx_id }
37 }
38
39 #[must_use]
41 pub fn txid(self) -> Txid {
42 self.tx_id
43 }
44
45 #[inline]
50 pub fn wait(&self) -> Result<(), ProviderError> {
51 self.provider.wait(&self.tx_id)
52 }
53}