Skip to main content

zcash_client_backend/proto/
proposal.rs

1// This file is @generated by prost-build.
2/// A data structure that describes a series of transactions to be created.
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct Proposal {
5    /// The version of this serialization format.
6    #[prost(uint32, tag = "1")]
7    pub proto_version: u32,
8    /// The fee rule used in constructing this proposal
9    #[prost(enumeration = "FeeRule", tag = "2")]
10    pub fee_rule: i32,
11    /// The target height for which the proposal was constructed
12    ///
13    /// The chain must contain at least this many blocks in order for the proposal to
14    /// be executed.
15    #[prost(uint32, tag = "3")]
16    pub min_target_height: u32,
17    /// The series of transactions to be created.
18    #[prost(message, repeated, tag = "4")]
19    pub steps: ::prost::alloc::vec::Vec<ProposalStep>,
20    /// The confirmations policy under which the proposal was constructed. It is used to resolve the
21    /// anchor for any step that spends no shielded notes (such a step defers the choice of anchor).
22    /// Proposals serialized by older versions omit this field; they are interpreted using the
23    /// default confirmations policy.
24    #[prost(message, optional, tag = "5")]
25    pub confirmations_policy: ::core::option::Option<ConfirmationsPolicy>,
26    /// The transaction version header explicitly requested when the proposal was constructed.
27    /// Proposals serialized by older versions, or constructed without an explicit version request,
28    /// omit this field; they are built at the version implied by the target height.
29    #[prost(uint32, optional, tag = "6")]
30    pub proposed_version: ::core::option::Option<u32>,
31}
32/// The number of confirmations required before notes may be spent, per ZIP 315.
33#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
34pub struct ConfirmationsPolicy {
35    /// The number of confirmations required before trusted notes may be spent.
36    #[prost(uint32, tag = "1")]
37    pub trusted: u32,
38    /// The number of confirmations required before untrusted notes may be spent.
39    #[prost(uint32, tag = "2")]
40    pub untrusted: u32,
41    /// Whether transparent inputs may be spent with zero confirmations in shielding transactions.
42    #[prost(bool, tag = "3")]
43    pub allow_zero_conf_shielding: bool,
44}
45/// A data structure that describes the inputs to be consumed and outputs to
46/// be produced in a proposed transaction.
47#[derive(Clone, PartialEq, ::prost::Message)]
48pub struct ProposalStep {
49    /// ZIP 321 serialized transaction request
50    #[prost(string, tag = "1")]
51    pub transaction_request: ::prost::alloc::string::String,
52    /// The vector of selected payment index / output pool mappings. Payment index
53    /// 0 corresponds to the payment with no explicit index.
54    #[prost(message, repeated, tag = "2")]
55    pub payment_output_pools: ::prost::alloc::vec::Vec<PaymentOutputPool>,
56    /// The anchor height to be used in creating the transaction, if any.
57    /// Setting the anchor height to zero will disallow the use of any shielded
58    /// inputs.
59    #[prost(uint32, tag = "3")]
60    pub anchor_height: u32,
61    /// The inputs to be used in creating the transaction.
62    #[prost(message, repeated, tag = "4")]
63    pub inputs: ::prost::alloc::vec::Vec<ProposedInput>,
64    /// The total value, fee value, and change outputs of the proposed
65    /// transaction
66    #[prost(message, optional, tag = "5")]
67    pub balance: ::core::option::Option<TransactionBalance>,
68    /// A flag indicating whether the step is for a shielding transaction,
69    /// used for determining which OVK to select for wallet-internal outputs.
70    #[prost(bool, tag = "6")]
71    pub is_shielding: bool,
72}
73/// A mapping from ZIP 321 payment index to the output pool that has been chosen
74/// for that payment, based upon the payment address and the selected inputs to
75/// the transaction.
76#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
77pub struct PaymentOutputPool {
78    #[prost(uint32, tag = "1")]
79    pub payment_index: u32,
80    #[prost(enumeration = "ValuePool", tag = "2")]
81    pub value_pool: i32,
82}
83/// The unique identifier and value for each proposed input that does not
84/// require a back-reference to a prior step of the proposal.
85#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
86pub struct ReceivedOutput {
87    #[prost(bytes = "vec", tag = "1")]
88    pub txid: ::prost::alloc::vec::Vec<u8>,
89    #[prost(enumeration = "ValuePool", tag = "2")]
90    pub value_pool: i32,
91    #[prost(uint32, tag = "3")]
92    pub index: u32,
93    #[prost(uint64, tag = "4")]
94    pub value: u64,
95}
96/// A reference to a payment in a prior step of the proposal. This payment must
97/// belong to the wallet.
98#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
99pub struct PriorStepOutput {
100    #[prost(uint32, tag = "1")]
101    pub step_index: u32,
102    #[prost(uint32, tag = "2")]
103    pub payment_index: u32,
104}
105/// A reference to a change or ephemeral output from a prior step of the proposal.
106#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
107pub struct PriorStepChange {
108    #[prost(uint32, tag = "1")]
109    pub step_index: u32,
110    #[prost(uint32, tag = "2")]
111    pub change_index: u32,
112}
113/// The unique identifier and value for an input to be used in the transaction.
114#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
115pub struct ProposedInput {
116    #[prost(oneof = "proposed_input::Value", tags = "1, 2, 3")]
117    pub value: ::core::option::Option<proposed_input::Value>,
118}
119/// Nested message and enum types in `ProposedInput`.
120pub mod proposed_input {
121    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
122    pub enum Value {
123        #[prost(message, tag = "1")]
124        ReceivedOutput(super::ReceivedOutput),
125        #[prost(message, tag = "2")]
126        PriorStepOutput(super::PriorStepOutput),
127        #[prost(message, tag = "3")]
128        PriorStepChange(super::PriorStepChange),
129    }
130}
131/// The proposed change outputs and fee value.
132#[derive(Clone, PartialEq, ::prost::Message)]
133pub struct TransactionBalance {
134    /// A list of change or ephemeral output values.
135    #[prost(message, repeated, tag = "1")]
136    pub proposed_change: ::prost::alloc::vec::Vec<ChangeValue>,
137    /// The fee to be paid by the proposed transaction, in zatoshis.
138    #[prost(uint64, tag = "2")]
139    pub fee_required: u64,
140    /// The exact number of dummy outputs in each shielded bundle. Omitted by
141    /// proposals created before transaction shape was modelled explicitly.
142    #[prost(message, optional, tag = "3")]
143    pub dummy_outputs: ::core::option::Option<DummyOutputs>,
144}
145/// Exact per-pool dummy-output counts for the proposed transaction.
146#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
147pub struct DummyOutputs {
148    #[prost(uint32, tag = "1")]
149    pub sapling: u32,
150    #[prost(uint32, tag = "2")]
151    pub orchard: u32,
152    #[prost(uint32, tag = "3")]
153    pub ironwood: u32,
154}
155/// A proposed change or ephemeral output. If the transparent value pool is
156/// selected, the `memo` field must be null.
157///
158/// When the `isEphemeral` field of a `ChangeValue` is set, it represents
159/// an ephemeral output, which must be spent by a subsequent step. This is
160/// only supported for transparent outputs. Each ephemeral output will be
161/// given a unique t-address.
162///
163/// When the transparent value pool is selected and the `isEphemeral` field
164/// is not set, the value represents transparent change, which will be sent
165/// to an internal-scope (change) transparent address of the wallet.
166#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
167pub struct ChangeValue {
168    /// The value of a change or ephemeral output to be created, in zatoshis.
169    #[prost(uint64, tag = "1")]
170    pub value: u64,
171    /// The value pool in which the change or ephemeral output should be created.
172    #[prost(enumeration = "ValuePool", tag = "2")]
173    pub value_pool: i32,
174    /// The optional memo that should be associated with the newly created output.
175    /// Memos must not be present for transparent outputs.
176    #[prost(message, optional, tag = "3")]
177    pub memo: ::core::option::Option<MemoBytes>,
178    /// Whether this is to be an ephemeral output.
179    #[prost(bool, tag = "4")]
180    pub is_ephemeral: bool,
181}
182/// An object wrapper for memo bytes, to facilitate representing the
183/// `change_memo == None` case.
184#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
185pub struct MemoBytes {
186    #[prost(bytes = "vec", tag = "1")]
187    pub value: ::prost::alloc::vec::Vec<u8>,
188}
189#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
190#[repr(i32)]
191pub enum ValuePool {
192    /// Protobuf requires that enums have a zero discriminant as the default
193    /// value. However, we need to require that a known value pool is selected,
194    /// and we do not want to fall back to any default, so sending the
195    /// PoolNotSpecified value will be treated as an error.
196    PoolNotSpecified = 0,
197    /// The transparent value pool (P2SH is not distinguished from P2PKH)
198    Transparent = 1,
199    /// The Sapling value pool
200    Sapling = 2,
201    /// The Orchard value pool
202    Orchard = 3,
203    /// The Ironwood value pool (ZIP 2005). Ironwood notes are Orchard-shaped but
204    /// belong to a distinct pool; older decoders that do not recognize this value
205    /// will reject the proposal rather than misattribute it to Orchard.
206    Ironwood = 4,
207}
208impl ValuePool {
209    /// String value of the enum field names used in the ProtoBuf definition.
210    ///
211    /// The values are not transformed in any way and thus are considered stable
212    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
213    pub fn as_str_name(&self) -> &'static str {
214        match self {
215            Self::PoolNotSpecified => "PoolNotSpecified",
216            Self::Transparent => "Transparent",
217            Self::Sapling => "Sapling",
218            Self::Orchard => "Orchard",
219            Self::Ironwood => "Ironwood",
220        }
221    }
222    /// Creates an enum from field names used in the ProtoBuf definition.
223    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
224        match value {
225            "PoolNotSpecified" => Some(Self::PoolNotSpecified),
226            "Transparent" => Some(Self::Transparent),
227            "Sapling" => Some(Self::Sapling),
228            "Orchard" => Some(Self::Orchard),
229            "Ironwood" => Some(Self::Ironwood),
230            _ => None,
231        }
232    }
233}
234/// The fee rule used in constructing a Proposal
235#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
236#[repr(i32)]
237pub enum FeeRule {
238    /// Protobuf requires that enums have a zero discriminant as the default
239    /// value. However, we need to require that a known fee rule is selected,
240    /// and we do not want to fall back to any default, so sending the
241    /// FeeRuleNotSpecified value will be treated as an error.
242    NotSpecified = 0,
243    /// 10000 ZAT
244    PreZip313 = 1,
245    /// 1000 ZAT
246    Zip313 = 2,
247    /// MAX(10000, 5000 * logical_actions) ZAT
248    Zip317 = 3,
249}
250impl FeeRule {
251    /// String value of the enum field names used in the ProtoBuf definition.
252    ///
253    /// The values are not transformed in any way and thus are considered stable
254    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
255    pub fn as_str_name(&self) -> &'static str {
256        match self {
257            Self::NotSpecified => "FeeRuleNotSpecified",
258            Self::PreZip313 => "PreZip313",
259            Self::Zip313 => "Zip313",
260            Self::Zip317 => "Zip317",
261        }
262    }
263    /// Creates an enum from field names used in the ProtoBuf definition.
264    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
265        match value {
266            "FeeRuleNotSpecified" => Some(Self::NotSpecified),
267            "PreZip313" => Some(Self::PreZip313),
268            "Zip313" => Some(Self::Zip313),
269            "Zip317" => Some(Self::Zip317),
270            _ => None,
271        }
272    }
273}