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 0d8b066 commit fd3bc90
Show file tree
Hide file tree
Showing 28 changed files with 207 additions and 296 deletions.
41 changes: 21 additions & 20 deletions applications/minotari_console_wallet/src/automation/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ pub async fn make_it_rain(
let delay_ms = if start_time > now {
println!(
"`make-it-rain` scheduled to start at {}: payment_id \"{}\"",
start_time, payment_id.compact_display()
start_time,
payment_id.user_data_as_string()
);
(start_time - now).num_milliseconds() as u64
} else {
Expand All @@ -507,7 +508,9 @@ pub async fn make_it_rain(
}
println!(
"\n`make-it-rain` starting {} {} transactions \"{}\"\n",
num_txs, transaction_type, payment_id.compact_display()
num_txs,
transaction_type,
payment_id.user_data_as_string()
);
let payment_id_clone = payment_id.clone();
let (sender, mut receiver) = mpsc::channel(num_txs);
Expand Down Expand Up @@ -552,7 +555,7 @@ pub async fn make_it_rain(
// Send transaction
let tx_id = match transaction_type {
MakeItRainTransactionType::Interactive => {
send_tari(tx_service, fee, amount, address.clone(), payment_id.clone()).await
send_tari(tx_service, fee, amount, address.clone(), payment_id_clone).await
},
MakeItRainTransactionType::StealthOneSided => {
send_one_sided_to_stealth_address(
Expand All @@ -565,11 +568,9 @@ pub async fn make_it_rain(
)
.await
},
MakeItRainTransactionType::BurnTari => {
burn_tari(tx_service, fee, amount, payment_id.clone())
.await
.map(|(tx_id, _)| tx_id)
},
MakeItRainTransactionType::BurnTari => burn_tari(tx_service, fee, amount, payment_id_clone)
.await
.map(|(tx_id, _)| tx_id),
};
let submit_time = Instant::now();

Expand Down Expand Up @@ -626,7 +627,7 @@ pub async fn make_it_rain(
"\n`make-it-rain` concluded {} {} transactions (\"{}\") at {}",
num_txs,
transaction_type,
payment_id_clone.compact_display(),
payment_id_clone.user_data_as_string(),
Utc::now(),
);
});
Expand Down Expand Up @@ -792,7 +793,7 @@ pub async fn command_runner(
transaction_service.clone(),
config.fee_per_gram,
args.amount,
PaymentId::Open(args.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&args.payment_id),
)
.await
{
Expand Down Expand Up @@ -978,7 +979,7 @@ pub async fn command_runner(
output_hash,
commitment.clone(),
args.recipient_address,
PaymentId::Open(args.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&args.payment_id),
)
.await
{
Expand Down Expand Up @@ -1344,7 +1345,7 @@ pub async fn command_runner(
} else {
UseOutput::FromBlockchain(embedded_output.hash())
},
PaymentId::Open(args.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&args.payment_id),
)
.await
{
Expand Down Expand Up @@ -1987,7 +1988,7 @@ pub async fn command_runner(
config.fee_per_gram,
args.amount,
args.destination,
PaymentId::Open(args.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&args.payment_id),
)
.await
{
Expand All @@ -2005,7 +2006,7 @@ pub async fn command_runner(
args.amount,
UtxoSelectionCriteria::default(),
args.destination,
PaymentId::Open(args.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&args.payment_id),
)
.await
{
Expand All @@ -2031,7 +2032,7 @@ pub async fn command_runner(
args.start_time.unwrap_or_else(Utc::now),
args.destination,
transaction_type,
PaymentId::Open(args.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&args.payment_id),
)
.await
{
Expand All @@ -2043,7 +2044,7 @@ pub async fn command_runner(
args.amount_per_split,
args.num_splits,
args.fee_per_gram,
PaymentId::Open(args.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&args.payment_id),
&mut output_service,
&mut transaction_service.clone(),
)
Expand Down Expand Up @@ -2243,7 +2244,7 @@ pub async fn command_runner(
args.amount,
UtxoSelectionCriteria::default(),
args.destination,
PaymentId::Open(args.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&args.payment_id),
)
.await
{
Expand All @@ -2266,7 +2267,7 @@ pub async fn command_runner(
hash,
args.pre_image.into(),
config.fee_per_gram.into(),
PaymentId::Open(args.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&args.payment_id),
)
.await
{
Expand All @@ -2286,7 +2287,7 @@ pub async fn command_runner(
transaction_service.clone(),
hash,
config.fee_per_gram.into(),
PaymentId::Open(args.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&args.payment_id),
)
.await
{
Expand Down Expand Up @@ -2327,7 +2328,7 @@ pub async fn command_runner(
),
UtxoSelectionCriteria::default(),
config.fee_per_gram * uT,
PaymentId::Open(args.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&args.payment_id),
)
.await?;
debug!(target: LOG_TARGET, "Registering VN tx_id {}", tx_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
tx_id,
tx,
amount,
PaymentId::Open("Claiming HTLC transaction with pre-image".as_bytes().to_vec()),
PaymentId::open_from_str("Claiming HTLC transaction with pre-image"),
)
.await
{
Expand Down Expand Up @@ -469,7 +469,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
tx_id,
tx,
amount,
PaymentId::Open("Creating HTLC refund transaction".as_bytes().to_vec()),
PaymentId::open_from_str("Creating HTLC refund transaction"),
)
.await
{
Expand Down Expand Up @@ -525,7 +525,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
.map_err(Status::invalid_argument)?;

let mut transfers = Vec::new();
for (hex_address, address, amount, fee_per_gram, payment_type, payment_id) in recipients {
for (hex_address, address, amount, fee_per_gram, payment_type, payment_id) in recipients {
let payment_id = PaymentId::from_bytes(&payment_id);
let mut transaction_service = self.get_transaction_service();
transfers.push(async move {
Expand Down Expand Up @@ -611,7 +611,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
message.amount.into(),
UtxoSelectionCriteria::default(),
message.fee_per_gram.into(),
PaymentId::Open(message.payment_id.as_bytes().to_vec()),
PaymentId::open_from_str(&message.payment_id),
if message.claim_public_key.is_empty() {
None
} else {
Expand Down Expand Up @@ -861,7 +861,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
.import_unblinded_output_as_non_rewindable(
o.clone(),
TariAddress::default(),
PaymentId::from_bytes(&message.payment_id)
PaymentId::from_bytes(&message.payment_id),
)
.await
.map_err(|e| Status::internal(format!("{:?}", e)))?
Expand Down Expand Up @@ -988,7 +988,7 @@ impl wallet_server::Wallet for WalletGrpcServer {
vec![output],
fee_per_gram.into(),
UtxoSelectionCriteria::default(),
PaymentId::Open(format!("Template registration {}", template_name).as_bytes().to_vec()),
PaymentId::open_from_str(&format!("Template registration {}", template_name)),
)
.await
.map_err(|e| Status::internal(e.to_string()))?;
Expand Down Expand Up @@ -1131,7 +1131,7 @@ fn convert_wallet_transaction_into_transaction_info(
fee: 0,
excess_sig: Default::default(),
timestamp: tx.timestamp.timestamp() as u64,
payment_id: vec![],
payment_id: tx.payment_id.to_bytes(),
},
PendingOutbound(tx) => TransactionInfo {
tx_id: tx.tx_id.into(),
Expand All @@ -1144,7 +1144,7 @@ fn convert_wallet_transaction_into_transaction_info(
fee: tx.fee.into(),
excess_sig: Default::default(),
timestamp: tx.timestamp.timestamp() as u64,
payment_id: vec![],
payment_id: tx.payment_id.to_bytes(),
},
Completed(tx) => TransactionInfo {
tx_id: tx.tx_id.into(),
Expand Down
4 changes: 2 additions & 2 deletions applications/minotari_console_wallet/src/notifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ fn args_from_outbound(tx: &OutboundTransaction, event: &str) -> Vec<String> {
String::from(event),
amount,
tx.tx_id.to_string(),
tx.payment_id.compact_display(),
tx.payment_id.user_data_as_string(),
tx.destination_address.to_base58(),
status,
"outbound".to_string(),
Expand All @@ -349,7 +349,7 @@ fn args_from_inbound(tx: &InboundTransaction, event: &str) -> Vec<String> {
String::from(event),
amount,
tx.tx_id.to_string(),
tx.payment_id.compact_display(),
tx.payment_id.user_data_as_string(),
tx.source_address.to_base58(),
status,
"inbound".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ impl BurnTab {
if self.payment_id_field.is_empty() {
PaymentId::Empty
} else {
let bytes = self.payment_id_field.as_bytes().to_vec();
PaymentId::Open(bytes)
PaymentId::open_from_str(&self.payment_id_field)
},
tx,
)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,7 @@ impl SendTab {
if self.payment_id_field.is_empty() {
PaymentId::Empty
} else {
let bytes = self.payment_id_field.as_bytes().to_vec();
PaymentId::Open(bytes)
PaymentId::open_from_str(&self.payment_id_field)
},
tx,
),
Expand All @@ -312,8 +311,7 @@ impl SendTab {
if self.payment_id_field.is_empty() {
PaymentId::Empty
} else {
let bytes = self.payment_id_field.as_bytes().to_vec();
PaymentId::Open(bytes)
PaymentId::open_from_str(&self.payment_id_field)
},
tx,
)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl TransactionsTab {
)));

column3_items.push(ListItem::new(Span::styled(
t.payment_id.clone().unwrap_or_default().compact_display(),
t.payment_id.clone().unwrap_or_default().user_data_as_string(),
Style::default().fg(text_color),
)));
}
Expand Down Expand Up @@ -382,7 +382,10 @@ impl TransactionsTab {
};

let status = Span::styled(status_msg, Style::default().fg(Color::White));
let message = Span::styled(tx.payment_id.clone().unwrap_or_default().compact_display(), Style::default().fg(Color::White));
let message = Span::styled(
tx.payment_id.clone().unwrap_or_default().user_data_as_string(),
Style::default().fg(Color::White),
);

// let mined_time = DateTime::<Local>::from_naive_utc_and_offset(tx.mined_timestamp,
// Local::now().offset().to_owned());
Expand Down Expand Up @@ -440,8 +443,8 @@ impl TransactionsTab {
let maturity = Span::styled(maturity, Style::default().fg(Color::White));

let payment_id = match tx.payment_id.clone() {
Some(v) => format!("{}", v.compact_display()),
None => "None".to_string(),
Some(v) => v.user_data_as_string(),
None => "".to_string(),
};
let payment_id = Span::styled(payment_id, Style::default().fg(Color::White));

Expand Down
8 changes: 1 addition & 7 deletions applications/minotari_console_wallet/src/ui/state/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,7 @@ pub async fn send_burn_transaction_task(
// ----------------------------------------------------------------------------

let (burn_tx_id, original_proof) = match transaction_service_handle
.burn_tari(
amount,
selection_criteria,
fee_per_gram,
payment_id,
claim_public_key,
)
.burn_tari(amount, selection_criteria, fee_per_gram, payment_id, claim_public_key)
.await
{
Ok((burn_tx_id, original_proof)) => (burn_tx_id, original_proof),
Expand Down
Loading

0 comments on commit fd3bc90

Please sign in to comment.