From 7f282d9fea06e5f51b59981192984cb034d98056 Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Thu, 26 Sep 2024 12:50:36 +0200 Subject: [PATCH] feat: add payment id to notify script (#6586) Description --- Adds payment_id to the notify scripts --- Cargo.lock | 1 - .../minotari_console_wallet/src/notifier/mod.rs | 4 ++++ .../src/notifier/notify_example.sh | 17 +++++++++-------- .../transaction_components/encrypted_data.rs | 2 +- base_layer/tari_mining_helper_ffi/Cargo.toml | 1 - 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 989c6643f3..4292817a16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3524,7 +3524,6 @@ version = "1.5.1-pre.1" dependencies = [ "borsh", "cbindgen", - "hex", "libc", "rand", "tari_common", diff --git a/applications/minotari_console_wallet/src/notifier/mod.rs b/applications/minotari_console_wallet/src/notifier/mod.rs index 2d5722f2d2..c79404e3e2 100644 --- a/applications/minotari_console_wallet/src/notifier/mod.rs +++ b/applications/minotari_console_wallet/src/notifier/mod.rs @@ -37,8 +37,10 @@ use minotari_wallet::{ WalletSqlite, }; use tari_common_types::transaction::TxId; +use tari_core::transactions::transaction_components::encrypted_data::PaymentId; use tari_utilities::hex::Hex; use tokio::{runtime::Handle, sync::broadcast::Sender}; + pub const LOG_TARGET: &str = "wallet::notifier"; pub const RECEIVED: &str = "received"; pub const SENT: &str = "sent"; @@ -287,6 +289,7 @@ fn args_from_complete(tx: &CompletedTransaction, event: &str, confirmations: Opt let amount = format!("{}", tx.amount); let status = format!("{}", tx.status); let direction = format!("{}", tx.direction); + let payment_id = format!("{}", tx.payment_id.clone().unwrap_or(PaymentId::Empty)); let kernel = tx.transaction.body.kernels().first(); let (excess, public_nonce, signature) = match kernel { @@ -311,6 +314,7 @@ fn args_from_complete(tx: &CompletedTransaction, event: &str, confirmations: Opt amount, tx.tx_id.to_string(), tx.message.clone(), + payment_id, tx.source_address.to_base58(), tx.destination_address.to_base58(), status, diff --git a/applications/minotari_console_wallet/src/notifier/notify_example.sh b/applications/minotari_console_wallet/src/notifier/notify_example.sh index ea1d367cd6..712e5013ef 100755 --- a/applications/minotari_console_wallet/src/notifier/notify_example.sh +++ b/applications/minotari_console_wallet/src/notifier/notify_example.sh @@ -7,14 +7,15 @@ # $2 = amount, # $3 = tx_id # $4 = message -# $5 = source address public key -# $6 = destination address public key -# $7 = status -# $8 = excess, -# $9 = public_nonce, -# $10 = signature, -# $11 = number of confirmations (if applicable, otherwise empty string) -# $12 = direction +# $5 = payment_id +# $6 = source address public key +# $7 = destination address public key +# $8 = status +# $9 = excess, +# $10 = public_nonce, +# $11 = signature, +# $12 = number of confirmations (if applicable, otherwise empty string) +# $13 = direction # 2. # For transaction "sent" event, we only have the pending outbound transaction: diff --git a/base_layer/core/src/transactions/transaction_components/encrypted_data.rs b/base_layer/core/src/transactions/transaction_components/encrypted_data.rs index d986d8f3ee..4630da74c8 100644 --- a/base_layer/core/src/transactions/transaction_components/encrypted_data.rs +++ b/base_layer/core/src/transactions/transaction_components/encrypted_data.rs @@ -187,7 +187,7 @@ impl Display for PaymentId { PaymentId::U64(v) => write!(f, "{}", v), PaymentId::U256(v) => write!(f, "{}", v), PaymentId::Address(v) => write!(f, "{}", v.to_emoji_string()), - PaymentId::Open(v) => write!(f, "byte vector of len: {}", v.len()), + PaymentId::Open(v) => write!(f, "byte vector: {}", v.to_hex()), PaymentId::AddressAndData(v, d) => write!(f, "From {} with data: {:?}", v.to_emoji_string(), d), } } diff --git a/base_layer/tari_mining_helper_ffi/Cargo.toml b/base_layer/tari_mining_helper_ffi/Cargo.toml index 450442cea4..2778f5796a 100644 --- a/base_layer/tari_mining_helper_ffi/Cargo.toml +++ b/base_layer/tari_mining_helper_ffi/Cargo.toml @@ -20,7 +20,6 @@ tari_utilities = { version = "0.7" } libc = "0.2.65" thiserror = "1.0.26" borsh = "1.2" -hex = "0.4.2" tokio = { version = "1.36", features = ["rt"] } [dev-dependencies]