Skip to main content

taproot_assets_rpc/
lib.rs

1pub mod client;
2pub use client::Client;
3
4pub mod convert;
5
6// Include the generated Rust code from prost-build under the taprpc module
7pub mod taprpc {
8    include!(concat!(env!("CARGO_MANIFEST_DIR"), "/generated/taprpc.rs"));
9
10    pub mod types {
11        use taproot_assets_types as types;
12
13        use serde::{Deserialize, Serialize};
14
15        #[derive(Debug, Clone, Eq, PartialEq, Hash)]
16        pub struct ListAssetsResponse {
17            pub assets: Vec<types::asset::Asset>,
18            pub unconfirmed_transfers: u64,
19            pub unconfirmed_mints: u64,
20        }
21
22        #[derive(Debug, Clone, Eq, PartialEq, Hash)]
23        pub struct ExportProofResponse {
24            pub raw_proof_file: Vec<u8>,
25            pub genesis_point: Option<bitcoin::OutPoint>,
26        }
27
28        #[derive(Debug, Clone, Eq, PartialEq)]
29        pub struct VerifyProofResponse {
30            pub valid: bool,
31            pub decoded_proof: Option<DecodedProof>,
32        }
33
34        /// This struct represents the result of decoding either a proof file or a single
35        /// issuence/transfer proof. It contains all the information needed to verify the validity
36        /// of an asset state and prove asset ownership.
37        #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
38        pub struct DecodedProof {
39            /// The index depth of the decoded proof, with 0 being the latest proof.
40            /// This field indicates which proof within a proof file has been decoded.
41            pub proof_at_depth: u32,
42
43            /// The total number of proofs contained in the decoded proof file (this will
44            /// always be 1 if a single mint/transition proof was given as the raw_proof
45            /// instead of a file).
46            pub number_of_proofs: u32,
47
48            /// The asset referenced in the proof. This is the resulting asset after its
49            /// state transition.
50            pub asset: types::asset::Asset,
51
52            /// The reveal meta data associated with the proof, if available.
53            /// This field is optional and can only be specified if the asset
54            /// above is a genesis asset.
55            pub meta_reveal: Option<types::asset::AssetMeta>,
56
57            /// The merkle proof for AnchorTx used to prove its inclusion within
58            /// BlockHeader.
59            pub tx_merkle_proof: types::proof::TxMerkleProof,
60
61            /// The TaprootProof proving the new inclusion of the resulting asset
62            /// within AnchorTx.
63            pub inclusion_proof: types::proof::TaprootProof,
64
65            /// The set of TaprootProofs proving the exclusion of the resulting asset
66            /// from all other Taproot outputs within AnchorTx.
67            pub exclusion_proofs: Vec<types::proof::TaprootProof>,
68
69            /// An optional TaprootProof needed if this asset is the result of a split.
70            /// SplitRootProof proves inclusion of the root asset of the split.
71            pub split_root_proof: Option<types::proof::TaprootProof>,
72
73            /// The number of additional nested full proofs for any inputs found within
74            /// the resulting asset.
75            pub num_additional_inputs: u32,
76
77            /// ChallengeWitness is an optional virtual transaction witness that serves
78            /// as an ownership proof for the asset. If this is non-nil, then it is a
79            /// valid transfer witness for a 1-input, 1-output virtual transaction that
80            /// spends the asset in this proof and sends it to the NUMS key, to prove
81            /// that the creator of the proof is able to produce a valid signature to
82            /// spend the asset.
83            pub challenge_witness: Option<bitcoin::Witness>,
84
85            /// Indicates whether the state transition this proof represents is a burn,
86            /// meaning that the assets were provably destroyed and can no longer be
87            /// spent.
88            pub is_burn: bool,
89
90            /// GenesisReveal is an optional field that is the Genesis information for
91            /// the asset. This is required for minting proofs and must be empty for
92            /// non-minting proofs. This allows for derivation of the asset ID.
93            pub genesis_reveal: Option<types::asset::GenesisReveal>,
94
95            /// GroupKeyReveal is an optional field that includes the information needed
96            /// to derive the tweaked group key. This field is mandatory for the group
97            /// anchor (i.e., the initial minting tranche of an asset group). Subsequent
98            /// minting tranches require only a valid signature for the previously revealed
99            /// group key.
100            pub group_key_reveal: Option<types::asset::GroupKeyReveal>,
101        }
102    }
103}