Skip to content

Commit a1eb4ee

Browse files
committed
fix(wallet): save complete burn proof in file
1 parent 9f5adb7 commit a1eb4ee

20 files changed

Lines changed: 178 additions & 162 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applications/minotari_console_wallet/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ zxcvbn = "2"
7373
tui = { version = "^0.19", default-features = false, features = ["crossterm"] }
7474

7575

76+
[dev-dependencies]
77+
tempfile = "3.1.0"
78+
7679
[build-dependencies]
7780
tari_features = { workspace = true }
7881

applications/minotari_console_wallet/src/cli.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ pub struct Cli {
108108
/// Path to the libtor data directory
109109
#[clap(short = 'z', long, parse(from_os_str))]
110110
pub libtor_data_dir: Option<PathBuf>,
111+
/// Directory where burn proof files are written after a burn transaction completes. If relative, resolved against
112+
/// base-dir. Defaults to the platform shared data directory (e.g. ~/.local/share/tari/burn_proofs).
113+
#[clap(long, alias = "burn-proof-out", parse(from_os_str))]
114+
pub burn_proof_out: Option<PathBuf>,
111115
/// Skip wallet recovery
112116
#[clap(long)]
113117
pub skip_recovery: bool,
@@ -139,6 +143,9 @@ impl ConfigOverrideProvider for Cli {
139143
} else {
140144
// GRPC is disabled
141145
}
146+
if let Some(ref path) = self.burn_proof_out {
147+
replace_or_add_override(&mut overrides, "wallet.burn_proofs_dir", &path.display().to_string());
148+
}
142149
overrides
143150
}
144151
}

applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3034,11 +3034,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
30343034
leaf_index: p.leaf_index,
30353035
}),
30363036
kernel: Some(proof.kernel.into()),
3037-
encrypted_data: proof
3038-
.encrypted_data
3039-
.as_ref()
3040-
.map(|ed| ed.to_byte_vec())
3041-
.unwrap_or_default(),
3037+
encrypted_data: proof.encrypted_data.map(|ed| ed.into_vec()).unwrap_or_default(),
30423038
value: proof.value.as_ref().map(|v| v.as_u64()).unwrap_or_default(),
30433039
}))
30443040
}

applications/minotari_console_wallet/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub fn run_wallet(shutdown: &mut Shutdown, runtime: Runtime, config: &mut Applic
100100
view_private_key: None,
101101
spend_key: None,
102102
birthday: None,
103+
burn_proof_out: None,
103104
libtor_data_dir: None,
104105
skip_recovery: false,
105106
print_env: false,

applications/minotari_console_wallet/src/ui/components/burn_tab.rs

Lines changed: 17 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const LOG_TARGET: &str = "wallet::console_wallet::burn_tab ";
3535
pub struct BurnTab {
3636
balance: Balance,
3737
burn_input_mode: BurnInputMode,
38-
burnt_proof_filepath_field: String,
3938
claim_public_key_field: String,
4039
sidechain_key_field: String,
4140
amount_field: String,
@@ -54,7 +53,6 @@ impl BurnTab {
5453
Self {
5554
balance: Balance::new(),
5655
burn_input_mode: BurnInputMode::None,
57-
burnt_proof_filepath_field: String::new(),
5856
claim_public_key_field: String::new(),
5957
sidechain_key_field: String::new(),
6058
amount_field: String::new(),
@@ -88,7 +86,6 @@ impl BurnTab {
8886
Constraint::Length(3),
8987
Constraint::Length(3),
9088
Constraint::Length(3),
91-
Constraint::Length(3),
9289
]
9390
.as_ref(),
9491
)
@@ -98,10 +95,6 @@ impl BurnTab {
9895
let instructions = Paragraph::new(vec![
9996
Spans::from(vec![
10097
Span::raw("Press "),
101-
Span::styled("V", Style::default().add_modifier(Modifier::BOLD)),
102-
Span::raw(" to edit "),
103-
Span::styled("Burn Proof Filepath", Style::default().add_modifier(Modifier::BOLD)),
104-
Span::raw(", "),
10598
Span::styled("C", Style::default().add_modifier(Modifier::BOLD)),
10699
Span::raw(" to edit "),
107100
Span::styled("Claim Public Key", Style::default().add_modifier(Modifier::BOLD)),
@@ -113,7 +106,7 @@ impl BurnTab {
113106
Span::styled("F", Style::default().add_modifier(Modifier::BOLD)),
114107
Span::raw(" to edit "),
115108
Span::styled("Fee-Per-Gram", Style::default().add_modifier(Modifier::BOLD)),
116-
Span::raw(" and "),
109+
Span::raw(", "),
117110
]),
118111
Spans::from(vec![
119112
Span::raw("Press "),
@@ -125,38 +118,26 @@ impl BurnTab {
125118
.block(Block::default());
126119
f.render_widget(instructions, vert_chunks[0]);
127120

128-
let burnt_proof_filepath_input = Paragraph::new(self.burnt_proof_filepath_field.as_ref())
129-
.style(match self.burn_input_mode {
130-
BurnInputMode::BurntProofPath => Style::default().fg(Color::Magenta),
131-
_ => Style::default(),
132-
})
133-
.block(
134-
Block::default()
135-
.borders(Borders::ALL)
136-
.title("Sa(v)e burn proof to file path:"),
137-
);
138-
f.render_widget(burnt_proof_filepath_input, vert_chunks[1]);
139-
140121
let claim_public_key_input = Paragraph::new(self.claim_public_key_field.as_ref())
141122
.style(match self.burn_input_mode {
142123
BurnInputMode::ClaimPublicKey => Style::default().fg(Color::Magenta),
143124
_ => Style::default(),
144125
})
145126
.block(Block::default().borders(Borders::ALL).title("To (C)laim Public Key:"));
146-
f.render_widget(claim_public_key_input, vert_chunks[2]);
127+
f.render_widget(claim_public_key_input, vert_chunks[1]);
147128

148129
let sidechain_key_input = Paragraph::new(self.sidechain_key_field.as_ref())
149130
.style(match self.burn_input_mode {
150131
BurnInputMode::SidechainKey => Style::default().fg(Color::Magenta),
151132
_ => Style::default(),
152133
})
153134
.block(Block::default().borders(Borders::ALL).title("Sidechain Key:"));
154-
f.render_widget(sidechain_key_input, vert_chunks[3]);
135+
f.render_widget(sidechain_key_input, vert_chunks[2]);
155136

156137
let amount_fee_layout = Layout::default()
157138
.direction(Direction::Horizontal)
158139
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
159-
.split(vert_chunks[4]);
140+
.split(vert_chunks[3]);
160141

161142
let amount_input = Paragraph::new(self.amount_field.to_string())
162143
.style(match self.burn_input_mode {
@@ -180,47 +161,29 @@ impl BurnTab {
180161
_ => Style::default(),
181162
})
182163
.block(Block::default().borders(Borders::ALL).title("(P)ayment-id:"));
183-
f.render_widget(payment_id_input, vert_chunks[5]);
164+
f.render_widget(payment_id_input, vert_chunks[4]);
184165

185166
match self.burn_input_mode {
186167
BurnInputMode::None => (),
187-
BurnInputMode::BurntProofPath => f.set_cursor(
188-
// Put cursor past the end of the input text
189-
vert_chunks[1].x + self.burnt_proof_filepath_field.width() as u16 + 1,
190-
// Move one line down, from the border to the input line
168+
BurnInputMode::ClaimPublicKey => f.set_cursor(
169+
vert_chunks[1].x + self.claim_public_key_field.width() as u16 + 1,
191170
vert_chunks[1].y + 1,
192171
),
193-
BurnInputMode::ClaimPublicKey => f.set_cursor(
194-
// Put cursor past the end of the input text
195-
vert_chunks[2].x + self.claim_public_key_field.width() as u16 + 1,
196-
// Move one line down, from the border to the input line
172+
BurnInputMode::SidechainKey => f.set_cursor(
173+
vert_chunks[2].x + self.sidechain_key_field.width() as u16 + 1,
197174
vert_chunks[2].y + 1,
198175
),
199-
BurnInputMode::Amount => {
200-
f.set_cursor(
201-
// Put cursor past the end of the input text
202-
amount_fee_layout[0].x + self.amount_field.width() as u16 + 1,
203-
// Move one line down, from the border to the input line
204-
amount_fee_layout[0].y + 1,
205-
)
206-
},
176+
BurnInputMode::Amount => f.set_cursor(
177+
amount_fee_layout[0].x + self.amount_field.width() as u16 + 1,
178+
amount_fee_layout[0].y + 1,
179+
),
207180
BurnInputMode::Fee => f.set_cursor(
208-
// Put cursor past the end of the input text
209181
amount_fee_layout[1].x + self.fee_field.width() as u16 + 1,
210-
// Move one line down, from the border to the input line
211182
amount_fee_layout[1].y + 1,
212183
),
213-
BurnInputMode::SidechainKey => f.set_cursor(
214-
// Put cursor past the end of the input text
215-
vert_chunks[3].x + self.sidechain_key_field.width() as u16 + 1,
216-
// Move one line down, from the border to the input line
217-
vert_chunks[3].y + 1,
218-
),
219184
BurnInputMode::PaymentId => f.set_cursor(
220-
// Put cursor past the end of the input text
221-
vert_chunks[5].x + self.payment_id_field.width() as u16 + 1,
222-
// Move one line down, from the border to the input line
223-
vert_chunks[5].y + 1,
185+
vert_chunks[4].x + self.payment_id_field.width() as u16 + 1,
186+
vert_chunks[4].y + 1,
224187
),
225188
}
226189
}
@@ -321,12 +284,6 @@ impl BurnTab {
321284
return KeyHandled::Handled;
322285
};
323286

324-
let burn_proof_filepath = if self.burnt_proof_filepath_field.is_empty() {
325-
None
326-
} else {
327-
Some(self.burnt_proof_filepath_field.clone())
328-
};
329-
330287
let claim_public_key = if self.claim_public_key_field.is_empty() {
331288
None
332289
} else {
@@ -346,7 +303,6 @@ impl BurnTab {
346303
Some(BurnConfirmationDialogType::Normal) => {
347304
match Handle::current().block_on(
348305
app_state.send_burn_transaction(
349-
burn_proof_filepath,
350306
claim_public_key,
351307
amount.into(),
352308
UtxoSelectionCriteria::default(),
@@ -393,7 +349,6 @@ impl BurnTab {
393349
}
394350

395351
if reset_fields {
396-
self.burnt_proof_filepath_field = "".to_string();
397352
self.claim_public_key_field = "".to_string();
398353
self.amount_field = "".to_string();
399354
self.fee_field = app_state.get_default_fee_per_gram().as_u64().to_string();
@@ -410,13 +365,6 @@ impl BurnTab {
410365
if self.burn_input_mode != BurnInputMode::None {
411366
match self.burn_input_mode {
412367
BurnInputMode::None => (),
413-
BurnInputMode::BurntProofPath => match c {
414-
'\n' => self.burn_input_mode = BurnInputMode::ClaimPublicKey,
415-
c => {
416-
self.burnt_proof_filepath_field.push(c);
417-
return KeyHandled::Handled;
418-
},
419-
},
420368
BurnInputMode::ClaimPublicKey => match c {
421369
'\n' => self.burn_input_mode = BurnInputMode::SidechainKey,
422370
c => {
@@ -554,8 +502,8 @@ impl<B: Backend> Component<B> for BurnTab {
554502
return;
555503
},
556504
UiTransactionBurnStatus::TransactionComplete => {
557-
self.success_message =
558-
Some("Transaction completed successfully!\nPlease press Enter to continue".to_string());
505+
let msg = "Transaction completed successfully!\nPlease press Enter to continue".to_string();
506+
self.success_message = Some(msg);
559507
return;
560508
},
561509
};
@@ -667,7 +615,6 @@ impl<B: Backend> Component<B> for BurnTab {
667615
}
668616

669617
match c {
670-
'v' => self.burn_input_mode = BurnInputMode::BurntProofPath,
671618
'c' => self.burn_input_mode = BurnInputMode::ClaimPublicKey,
672619
'a' => {
673620
self.burn_input_mode = BurnInputMode::Amount;
@@ -713,9 +660,6 @@ impl<B: Backend> Component<B> for BurnTab {
713660

714661
fn on_backspace(&mut self, _app_state: &mut AppState) {
715662
match self.burn_input_mode {
716-
BurnInputMode::BurntProofPath => {
717-
let _ = self.burnt_proof_filepath_field.pop();
718-
},
719663
BurnInputMode::ClaimPublicKey => {
720664
let _ = self.claim_public_key_field.pop();
721665
},
@@ -739,7 +683,6 @@ impl<B: Backend> Component<B> for BurnTab {
739683
#[derive(PartialEq, Debug)]
740684
pub enum BurnInputMode {
741685
None,
742-
BurntProofPath,
743686
ClaimPublicKey,
744687
SidechainKey,
745688
Amount,

applications/minotari_console_wallet/src/ui/state/app_state.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#![allow(clippy::indexing_slicing)]
2424
use std::{
2525
collections::{HashMap, VecDeque},
26-
path::PathBuf,
2726
str::FromStr,
2827
sync::Arc,
2928
time::{Duration, Instant},
@@ -222,7 +221,6 @@ impl AppState {
222221

223222
pub async fn send_burn_transaction(
224223
&mut self,
225-
burn_proof_filepath: Option<String>,
226224
claim_public_key: Option<String>,
227225
amount: u64,
228226
selection_criteria: UtxoSelectionCriteria,
@@ -233,19 +231,6 @@ impl AppState {
233231
) -> Result<(), UiError> {
234232
let inner = self.inner.write().await;
235233

236-
let burn_proof_filepath = match burn_proof_filepath {
237-
None => None,
238-
Some(path) => {
239-
let path = PathBuf::from(path);
240-
241-
if path.exists() {
242-
return Err(UiError::BurntProofFileExists);
243-
}
244-
245-
Some(path)
246-
},
247-
};
248-
249234
let fee_per_gram = fee_per_gram * uT;
250235
let tx_service_handle = inner.wallet.transaction_service.clone();
251236
let claim_public_key = match claim_public_key {
@@ -261,7 +246,6 @@ impl AppState {
261246
.transpose()?;
262247

263248
send_burn_transaction_task(
264-
burn_proof_filepath,
265249
claim_public_key,
266250
MicroMinotari::from(amount),
267251
selection_criteria,

applications/minotari_console_wallet/src/ui/state/mod.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,4 @@ mod debouncer;
2525
mod tasks;
2626
mod wallet_event_monitor;
2727

28-
use serde::{Deserialize, Serialize};
29-
use tari_common_types::serializers;
30-
3128
pub use self::app_state::*;
32-
33-
#[derive(Serialize, Deserialize)]
34-
pub struct SignatureBase64 {
35-
#[serde(with = "serializers::base64")]
36-
pub public_nonce: Vec<u8>,
37-
#[serde(with = "serializers::base64")]
38-
pub signature: Vec<u8>,
39-
}
40-
41-
#[derive(Serialize, Deserialize)]
42-
pub struct BurntProofBase64 {
43-
#[serde(with = "serializers::base64")]
44-
pub claim_public_key: Vec<u8>,
45-
#[serde(with = "serializers::base64")]
46-
pub commitment: Vec<u8>,
47-
pub ownership_proof: SignatureBase64,
48-
}

0 commit comments

Comments
 (0)