Skip to content

Commit 90596a9

Browse files
committed
feat: add pczt build
1 parent 08e702f commit 90596a9

File tree

5 files changed

+178
-14
lines changed

5 files changed

+178
-14
lines changed

rust/pczt/build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() -> Result<(), std::io::Error> {
2+
prost_build::Config::new().out_dir("src/pb").compile_protos(&["src/protos/pczt.proto"], &["src/"])?;
3+
Ok(())
4+
}

rust/pczt/src/lib.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
pub fn add(left: usize, right: usize) -> usize {
2-
left + right
3-
}
4-
5-
#[cfg(test)]
6-
mod tests {
7-
use super::*;
1+
#![no_std]
82

9-
#[test]
10-
fn it_works() {
11-
let result = add(2, 2);
12-
assert_eq!(result, 4);
13-
}
3+
pub mod protos {
4+
include!("pb/pczt.rs");
145
}

rust/pczt/src/pb/pczt.rs

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
// This file is @generated by prost-build.
2+
#[derive(Clone, PartialEq, ::prost::Message)]
3+
pub struct PartiallyCreatedTransaction {
4+
/// The version of this wire format, for storage.
5+
#[prost(uint32, tag = "1")]
6+
pub proto_version: u32,
7+
#[prost(message, optional, tag = "2")]
8+
pub global: ::core::option::Option<PcztGlobal>,
9+
#[prost(message, optional, tag = "3")]
10+
pub transparent: ::core::option::Option<PcztTransparent>,
11+
#[prost(message, optional, tag = "4")]
12+
pub sapling: ::core::option::Option<PcztSapling>,
13+
#[prost(message, optional, tag = "5")]
14+
pub orchard: ::core::option::Option<PcztOrchard>,
15+
}
16+
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
17+
pub struct PcztGlobal {
18+
#[prost(uint32, tag = "1")]
19+
pub tx_version: u32,
20+
/// is versionGroupId still needed?
21+
#[prost(fixed32, tag = "2")]
22+
pub version_group_id: u32,
23+
#[prost(uint32, tag = "3")]
24+
pub lock_time: u32,
25+
#[prost(uint32, tag = "4")]
26+
pub expiry_height: u32,
27+
#[prost(uint32, tag = "5")]
28+
pub consensus_branch_id: u32,
29+
#[prost(uint32, tag = "6")]
30+
pub network_id: u32,
31+
}
32+
#[derive(Clone, PartialEq, ::prost::Message)]
33+
pub struct PcztTransparent {
34+
#[prost(message, repeated, tag = "1")]
35+
pub inputs: ::prost::alloc::vec::Vec<PcztTransparentInput>,
36+
#[prost(message, repeated, tag = "2")]
37+
pub outputs: ::prost::alloc::vec::Vec<PcztTransparentOutput>,
38+
}
39+
#[derive(Clone, PartialEq, ::prost::Message)]
40+
pub struct PcztTransparentInput {
41+
#[prost(bytes = "vec", tag = "1")]
42+
pub pubkey: ::prost::alloc::vec::Vec<u8>,
43+
#[prost(message, optional, tag = "2")]
44+
pub previous_coin: ::core::option::Option<PcztTransparentCoin>,
45+
#[prost(message, optional, tag = "3")]
46+
pub previous_outpoint: ::core::option::Option<PcztTransparentOutpoint>,
47+
#[prost(message, optional, tag = "4")]
48+
pub path: ::core::option::Option<PcztDerivationPath>,
49+
#[prost(bytes = "vec", repeated, tag = "5")]
50+
pub signatures: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
51+
}
52+
#[derive(Clone, PartialEq, ::prost::Message)]
53+
pub struct PcztTransparentCoin {
54+
#[prost(uint64, tag = "1")]
55+
pub value: u64,
56+
#[prost(bytes = "vec", tag = "2")]
57+
pub script_pubkey: ::prost::alloc::vec::Vec<u8>,
58+
}
59+
#[derive(Clone, PartialEq, ::prost::Message)]
60+
pub struct PcztTransparentOutput {
61+
#[prost(message, optional, tag = "1")]
62+
pub coin: ::core::option::Option<PcztTransparentCoin>,
63+
/// if an output has path, it is a change output
64+
#[prost(message, optional, tag = "2")]
65+
pub path: ::core::option::Option<PcztDerivationPath>,
66+
}
67+
#[derive(Clone, PartialEq, ::prost::Message)]
68+
pub struct PcztTransparentOutpoint {
69+
#[prost(bytes = "vec", tag = "1")]
70+
pub tx_hash: ::prost::alloc::vec::Vec<u8>,
71+
#[prost(uint32, tag = "2")]
72+
pub index: u32,
73+
}
74+
#[derive(Clone, PartialEq, ::prost::Message)]
75+
pub struct PcztDerivationPath {
76+
/// the 32 bytes seed fingerprint;
77+
#[prost(bytes = "vec", tag = "1")]
78+
pub seed_fingerprint: ::prost::alloc::vec::Vec<u8>,
79+
/// for orchard it should be pk_d(DiversifiedTransmissionKey)
80+
/// hardware wallet should check this with the derived key from it self.
81+
#[prost(bytes = "vec", tag = "2")]
82+
pub pubkey: ::prost::alloc::vec::Vec<u8>,
83+
#[prost(message, repeated, tag = "3")]
84+
pub path_components: ::prost::alloc::vec::Vec<PathComponent>,
85+
}
86+
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
87+
pub struct PathComponent {
88+
#[prost(uint32, tag = "1")]
89+
pub value: u32,
90+
#[prost(bool, tag = "2")]
91+
pub harden: bool,
92+
}
93+
#[derive(Clone, PartialEq, ::prost::Message)]
94+
pub struct PcztOrchard {
95+
#[prost(uint32, tag = "1")]
96+
pub flag: u32,
97+
#[prost(int64, tag = "2")]
98+
pub value_balance: i64,
99+
#[prost(bytes = "vec", tag = "3")]
100+
pub anchor: ::prost::alloc::vec::Vec<u8>,
101+
#[prost(message, repeated, tag = "4")]
102+
pub actions: ::prost::alloc::vec::Vec<PcztOrchardAction>,
103+
}
104+
#[derive(Clone, PartialEq, ::prost::Message)]
105+
pub struct PcztOrchardAction {
106+
#[prost(bytes = "vec", tag = "1")]
107+
pub nf: ::prost::alloc::vec::Vec<u8>,
108+
#[prost(bytes = "vec", tag = "2")]
109+
pub rk: ::prost::alloc::vec::Vec<u8>,
110+
#[prost(bytes = "vec", tag = "3")]
111+
pub cmx: ::prost::alloc::vec::Vec<u8>,
112+
/// (epk, enc_ciphertext, out_ciphertext)
113+
#[prost(bytes = "vec", tag = "4")]
114+
pub encrypted_note: ::prost::alloc::vec::Vec<u8>,
115+
#[prost(bytes = "vec", tag = "5")]
116+
pub cv_net: ::prost::alloc::vec::Vec<u8>,
117+
#[prost(bytes = "vec", tag = "6")]
118+
pub alpha: ::prost::alloc::vec::Vec<u8>,
119+
/// the serilized spend note(rho, rseed, value, receipent) of this action, to verify the nf and cmx in this action.
120+
#[prost(bytes = "vec", tag = "7")]
121+
pub spend_note: ::prost::alloc::vec::Vec<u8>,
122+
#[prost(message, optional, tag = "8")]
123+
pub path: ::core::option::Option<PcztDerivationPath>,
124+
#[prost(bytes = "vec", repeated, tag = "9")]
125+
pub signatures: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
126+
}
127+
#[derive(Clone, PartialEq, ::prost::Message)]
128+
pub struct PcztSapling {
129+
#[prost(int64, tag = "1")]
130+
pub value_balance: i64,
131+
#[prost(message, repeated, tag = "2")]
132+
pub spends: ::prost::alloc::vec::Vec<PcztSaplingSpend>,
133+
#[prost(message, repeated, tag = "3")]
134+
pub outputs: ::prost::alloc::vec::Vec<PcztSaplingOutput>,
135+
}
136+
#[derive(Clone, PartialEq, ::prost::Message)]
137+
pub struct PcztSaplingSpend {
138+
#[prost(bytes = "vec", tag = "1")]
139+
pub nf: ::prost::alloc::vec::Vec<u8>,
140+
#[prost(bytes = "vec", tag = "2")]
141+
pub cv: ::prost::alloc::vec::Vec<u8>,
142+
#[prost(bytes = "vec", tag = "3")]
143+
pub rk: ::prost::alloc::vec::Vec<u8>,
144+
#[prost(bytes = "vec", tag = "4")]
145+
pub proof: ::prost::alloc::vec::Vec<u8>,
146+
#[prost(bytes = "vec", tag = "5")]
147+
pub anchor: ::prost::alloc::vec::Vec<u8>,
148+
#[prost(bytes = "vec", tag = "6")]
149+
pub alpha: ::prost::alloc::vec::Vec<u8>,
150+
#[prost(message, optional, tag = "7")]
151+
pub path: ::core::option::Option<PcztDerivationPath>,
152+
#[prost(bytes = "vec", repeated, tag = "8")]
153+
pub signatures: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
154+
}
155+
#[derive(Clone, PartialEq, ::prost::Message)]
156+
pub struct PcztSaplingOutput {
157+
#[prost(bytes = "vec", tag = "1")]
158+
pub cv: ::prost::alloc::vec::Vec<u8>,
159+
#[prost(bytes = "vec", tag = "2")]
160+
pub cmu: ::prost::alloc::vec::Vec<u8>,
161+
/// (epk, enc_ciphertext, out_ciphertext)
162+
#[prost(bytes = "vec", tag = "3")]
163+
pub encrypted_note: ::prost::alloc::vec::Vec<u8>,
164+
/// if an output has path, it is a change output
165+
#[prost(message, optional, tag = "4")]
166+
pub path: ::core::option::Option<PcztDerivationPath>,
167+
}

rust/pczt/src/protos/pczt.proto

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
syntax = "proto3";
22

3+
package pczt;
4+
35
message PartiallyCreatedTransaction {
46
// The version of this wire format, for storage.
57
uint32 protoVersion = 1;

rust/rust_c/Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)