Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hansieodendaal committed Dec 10, 2024
1 parent c8b0f48 commit 0d8b066
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 125 deletions.
1 change: 1 addition & 0 deletions applications/minotari_app_grpc/proto/wallet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ message CoinSplitResponse {

message ImportUtxosRequest {
repeated UnblindedOutput outputs = 1;
bytes payment_id = 2;
}

message ImportUtxosResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ pub async fn make_it_rain(
"\n`make-it-rain` starting {} {} transactions \"{}\"\n",
num_txs, transaction_type, payment_id.compact_display()
);
let payment_id_clone = payment_id.clone();
let (sender, mut receiver) = mpsc::channel(num_txs);
{
let sender = sender;
Expand Down Expand Up @@ -545,6 +546,7 @@ pub async fn make_it_rain(
let sender_clone = sender.clone();
let fee = fee_per_gram;
let address = destination.clone();
let payment_id_clone = payment_id.clone();
tokio::task::spawn(async move {
let spawn_start = Instant::now();
// Send transaction
Expand All @@ -559,7 +561,7 @@ pub async fn make_it_rain(
amount,
UtxoSelectionCriteria::default(),
address.clone(),
payment_id.clone(),
payment_id_clone,
)
.await
},
Expand Down Expand Up @@ -624,7 +626,7 @@ pub async fn make_it_rain(
"\n`make-it-rain` concluded {} {} transactions (\"{}\") at {}",
num_txs,
transaction_type,
message,
payment_id_clone.compact_display(),
Utc::now(),
);
});
Expand Down
3 changes: 0 additions & 3 deletions applications/minotari_console_wallet/src/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub fn convert_to_transaction_event(event: String, source: TransactionWrapper) -
status: completed.status.to_string(),
direction: completed.direction.to_string(),
amount: completed.amount.as_u64(),
message: completed.message.to_string(),
payment_id: completed.payment_id.to_bytes(),
},
TransactionWrapper::Outbound(outbound) => TransactionEvent {
Expand All @@ -39,7 +38,6 @@ pub fn convert_to_transaction_event(event: String, source: TransactionWrapper) -
status: outbound.status.to_string(),
direction: "outbound".to_string(),
amount: outbound.amount.as_u64(),
message: outbound.message,
payment_id: vec![],
},
TransactionWrapper::Inbound(inbound) => TransactionEvent {
Expand All @@ -50,7 +48,6 @@ pub fn convert_to_transaction_event(event: String, source: TransactionWrapper) -
status: inbound.status.to_string(),
direction: "inbound".to_string(),
amount: inbound.amount.as_u64(),
message: inbound.message.clone(),
payment_id: vec![],
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
message.amount.into(),
UtxoSelectionCriteria::default(),
message.fee_per_gram.into(),
message.message,
PaymentId::from_bytes(&message.payment_id),
)
.await
{
Expand Down Expand Up @@ -414,8 +414,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
tx_id,
tx,
amount,
"Claiming HTLC transaction with pre-image".to_string(),
PaymentId::Empty,
PaymentId::Open("Claiming HTLC transaction with pre-image".as_bytes().to_vec()),
)
.await
{
Expand Down Expand Up @@ -470,8 +469,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
tx_id,
tx,
amount,
"Creating HTLC refund transaction".to_string(),
PaymentId::Empty,
PaymentId::Open("Creating HTLC refund transaction".as_bytes().to_vec()),
)
.await
{
Expand Down Expand Up @@ -791,7 +789,6 @@ impl wallet_server::Wallet for WalletGrpcServer {
.unwrap_or(&Signature::default())
.get_signature()
.to_vec(),
message: txn.message.clone(),
payment_id: txn.payment_id.to_bytes(),
}),
};
Expand Down Expand Up @@ -834,7 +831,6 @@ impl wallet_server::Wallet for WalletGrpcServer {
usize::try_from(message.split_count)
.map_err(|_| Status::internal("Count not convert u64 to usize".to_string()))?,
MicroMinotari::from(message.fee_per_gram),
message.message,
PaymentId::Empty,
)
.await
Expand Down Expand Up @@ -865,6 +861,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
.import_unblinded_output_as_non_rewindable(
o.clone(),
TariAddress::default(),
PaymentId::from_bytes(&message.payment_id)
)
.await
.map_err(|e| Status::internal(format!("{:?}", e)))?
Expand Down Expand Up @@ -973,6 +970,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
)
.map_err(|e| Status::invalid_argument(format!("template_registration is invalid: {}", e)))?;
let fee_per_gram = message.fee_per_gram;
let template_name = template_registration.template_name.clone();

let mut output = output_manager
.create_output_with_features(1 * T, OutputFeatures {
Expand All @@ -990,7 +988,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
vec![output],
fee_per_gram.into(),
UtxoSelectionCriteria::default(),
PaymentId::Open(format!("Template registration {}", template_registration.template_name).as_bytes().to_vec()),
PaymentId::Open(format!("Template registration {}", template_name).as_bytes().to_vec()),
)
.await
.map_err(|e| Status::internal(e.to_string()))?;
Expand Down Expand Up @@ -1045,7 +1043,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
validator_node_signature,
UtxoSelectionCriteria::default(),
request.fee_per_gram.into(),
request.message,
PaymentId::from_bytes(&request.payment_id),
)
.await
{
Expand Down Expand Up @@ -1112,7 +1110,6 @@ fn simple_event(event: &str) -> TransactionEvent {
status: event.to_string(),
direction: event.to_string(),
amount: 0,
message: String::default(),
payment_id: vec![],
}
}
Expand All @@ -1134,7 +1131,6 @@ fn convert_wallet_transaction_into_transaction_info(
fee: 0,
excess_sig: Default::default(),
timestamp: tx.timestamp.timestamp() as u64,
message: tx.message,
payment_id: vec![],
},
PendingOutbound(tx) => TransactionInfo {
Expand All @@ -1148,7 +1144,6 @@ fn convert_wallet_transaction_into_transaction_info(
fee: tx.fee.into(),
excess_sig: Default::default(),
timestamp: tx.timestamp.timestamp() as u64,
message: tx.message,
payment_id: vec![],
},
Completed(tx) => TransactionInfo {
Expand All @@ -1166,7 +1161,6 @@ fn convert_wallet_transaction_into_transaction_info(
.first_kernel_excess_sig()
.map(|s| s.get_signature().to_vec())
.unwrap_or_default(),
message: tx.message,
payment_id: tx.payment_id.to_bytes(),
},
}
Expand Down
5 changes: 2 additions & 3 deletions applications/minotari_console_wallet/src/notifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ fn args_from_complete(tx: &CompletedTransaction, event: &str, confirmations: Opt
String::from(event),
amount,
tx.tx_id.to_string(),
tx.message.clone(),
payment_id,
tx.source_address.to_base58(),
tx.destination_address.to_base58(),
Expand All @@ -334,7 +333,7 @@ fn args_from_outbound(tx: &OutboundTransaction, event: &str) -> Vec<String> {
String::from(event),
amount,
tx.tx_id.to_string(),
tx.message.clone(),
tx.payment_id.compact_display(),
tx.destination_address.to_base58(),
status,
"outbound".to_string(),
Expand All @@ -350,7 +349,7 @@ fn args_from_inbound(tx: &InboundTransaction, event: &str) -> Vec<String> {
String::from(event),
amount,
tx.tx_id.to_string(),
tx.message.clone(),
tx.payment_id.compact_display(),
tx.source_address.to_base58(),
status,
"inbound".to_string(),
Expand Down
40 changes: 4 additions & 36 deletions applications/minotari_console_wallet/src/ui/components/burn_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,13 @@ impl BurnTab {
.block(Block::default().borders(Borders::ALL).title("(F)ee-per-gram (uT):"));
f.render_widget(fee_input, amount_fee_layout[1]);

let message_payment_id_layout = Layout::default()
.direction(Direction::Horizontal)
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
.split(vert_chunks[4]);

let message_input = Paragraph::new(self.message_field.as_ref())
.style(match self.burn_input_mode {
BurnInputMode::Message => Style::default().fg(Color::Magenta),
_ => Style::default(),
})
.block(Block::default().borders(Borders::ALL).title("(M)essage:"));
f.render_widget(message_input, message_payment_id_layout[0]);

let payment_id_input = Paragraph::new(self.payment_id_field.as_ref())
.style(match self.burn_input_mode {
BurnInputMode::PaymentId => Style::default().fg(Color::Magenta),
_ => Style::default(),
})
.block(Block::default().borders(Borders::ALL).title("(P)ayment-id:"));
f.render_widget(payment_id_input, message_payment_id_layout[1]);
f.render_widget(payment_id_input, vert_chunks[4]);

match self.burn_input_mode {
BurnInputMode::None => (),
Expand Down Expand Up @@ -211,17 +198,11 @@ impl BurnTab {
// Move one line down, from the border to the input line
amount_fee_layout[1].y + 1,
),
BurnInputMode::Message => f.set_cursor(
// Put cursor past the end of the input text
message_payment_id_layout[0].x + self.message_field.width() as u16 + 1,
// Move one line down, from the border to the input line
message_payment_id_layout[0].y + 1,
),
BurnInputMode::PaymentId => f.set_cursor(
// Put cursor past the end of the input text
message_payment_id_layout[1].x + self.payment_id_field.width() as u16 + 1,
vert_chunks[4].x + self.payment_id_field.width() as u16 + 1,
// Move one line down, from the border to the input line
message_payment_id_layout[1].y + 1,
vert_chunks[4].y + 1,
),
}
}
Expand Down Expand Up @@ -379,7 +360,6 @@ impl BurnTab {
self.claim_public_key_field = "".to_string();
self.amount_field = "".to_string();
self.fee_field = app_state.get_default_fee_per_gram().as_u64().to_string();
self.message_field = "".to_string();
self.payment_id_field = "".to_string();
self.burn_input_mode = BurnInputMode::None;
self.burn_result_watch = Some(rx);
Expand Down Expand Up @@ -415,7 +395,7 @@ impl BurnTab {
},
},
BurnInputMode::Amount => match c {
'\n' => self.burn_input_mode = BurnInputMode::Message,
'\n' => self.burn_input_mode = BurnInputMode::PaymentId,
c => {
if c.is_numeric() || ['t', 'T', 'u', 'U'].contains(&c) {
self.amount_field.push(c);
Expand All @@ -432,13 +412,6 @@ impl BurnTab {
return KeyHandled::Handled;
},
},
BurnInputMode::Message => match c {
'\n' => self.burn_input_mode = BurnInputMode::PaymentId,
c => {
self.message_field.push(c);
return KeyHandled::Handled;
},
},
BurnInputMode::PaymentId => match c {
'\n' => self.burn_input_mode = BurnInputMode::None,
c => {
Expand Down Expand Up @@ -646,7 +619,6 @@ impl<B: Backend> Component<B> for BurnTab {
self.burn_input_mode = BurnInputMode::Amount;
},
'f' => self.burn_input_mode = BurnInputMode::Fee,
'm' => self.burn_input_mode = BurnInputMode::Message,
'p' => self.burn_input_mode = BurnInputMode::PaymentId,
'b' => {
self.show_proofs = !self.show_proofs;
Expand Down Expand Up @@ -702,9 +674,6 @@ impl<B: Backend> Component<B> for BurnTab {
BurnInputMode::Fee => {
let _ = self.fee_field.pop();
},
BurnInputMode::Message => {
let _ = self.message_field.pop();
},
BurnInputMode::PaymentId => {
let _ = self.payment_id_field.pop();
},
Expand All @@ -719,7 +688,6 @@ pub enum BurnInputMode {
BurntProofPath,
ClaimPublicKey,
Amount,
Message,
PaymentId,
Fee,
}
Expand Down
Loading

0 comments on commit 0d8b066

Please sign in to comment.