-
Notifications
You must be signed in to change notification settings - Fork 132
/
jcli_transaction_commands.rs
194 lines (178 loc) · 5.63 KB
/
jcli_transaction_commands.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#![allow(dead_code)]
use std::path::PathBuf;
use std::process::Command;
use crate::common::configuration;
#[derive(Debug)]
pub struct TransactionCommands {}
impl TransactionCommands {
pub fn new() -> TransactionCommands {
TransactionCommands {}
}
pub fn get_new_transaction_command(&self, staging_file: &PathBuf) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("new")
.arg("--staging")
.arg(staging_file.as_os_str());
command
}
pub fn get_add_input_command(
&self,
tx_id: &str,
tx_index: &i32,
amount: &str,
staging_file: &PathBuf,
) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("add-input")
.arg(&tx_id)
.arg(tx_index.to_string())
.arg(&amount)
.arg("--staging")
.arg(staging_file.as_os_str());
command
}
pub fn get_add_account_command(
&self,
account_addr: &str,
amount: &i32,
staging_file: &PathBuf,
) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("add-account")
.arg(account_addr.to_string())
.arg(amount.to_string())
.arg("--staging")
.arg(staging_file.as_os_str());
command
}
pub fn get_add_output_command(
&self,
addr: &str,
amount: &i32,
staging_file: &PathBuf,
) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("add-output")
.arg(&addr)
.arg(amount.to_string())
.arg("--staging")
.arg(staging_file.as_os_str());
command
}
pub fn get_finalize_command(&self, staging_file: &PathBuf) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("finalize")
.arg("--staging")
.arg(staging_file.as_os_str());
command
}
pub fn get_finalize_with_fee_command(
&self,
address: &str,
fee_constant: &i32,
fee_coefficient: &i32,
fee_certificate: &i32,
staging_file: &PathBuf,
) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("finalize")
.arg(address)
.arg("--fee-certificate")
.arg(fee_certificate.to_string())
.arg("--fee-coefficient")
.arg(fee_coefficient.to_string())
.arg("--fee-constant")
.arg(fee_constant.to_string())
.arg("--staging")
.arg(staging_file.as_os_str());
command
}
pub fn get_make_witness_command(
&self,
block0_hash: &str,
tx_id: &str,
addr_type: &str,
spending_account_counter: &i32,
witness_file: &PathBuf,
witness_key: &PathBuf,
) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("make-witness")
.arg("--genesis-block-hash")
.arg(block0_hash)
.arg("--type")
.arg(&addr_type)
.arg(&tx_id)
.arg(witness_file.as_os_str())
.arg("--account-spending-counter")
.arg(spending_account_counter.to_string())
.arg(witness_key.as_os_str());
command
}
pub fn get_add_witness_command(
&self,
witness_file: &PathBuf,
staging_file: &PathBuf,
) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("add-witness")
.arg(witness_file.as_os_str())
.arg("--staging")
.arg(staging_file.as_os_str());
command
}
pub fn get_seal_command(&self, staging_file: &PathBuf) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("seal")
.arg("--staging")
.arg(staging_file.as_os_str());
command
}
pub fn get_transaction_message_to_command(&self, staging_file: &PathBuf) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("to-message")
.arg("--staging")
.arg(staging_file.as_os_str());
command
}
pub fn get_transaction_id_command(&self, staging_file: &PathBuf) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("info")
.arg("--format")
.arg("{id}")
.arg("--staging")
.arg(staging_file.as_os_str());
command
}
pub fn get_transaction_info_command(&self, staging_file: &PathBuf) -> Command {
let mut command = Command::new(configuration::get_jcli_app().as_os_str());
command
.arg("transaction")
.arg("info")
.arg("--staging")
.arg(staging_file.as_os_str());
command
}
}