diff --git a/applications/minotari_console_wallet/src/automation/commands.rs b/applications/minotari_console_wallet/src/automation/commands.rs index cab5925c05e..98a557ab9c2 100644 --- a/applications/minotari_console_wallet/src/automation/commands.rs +++ b/applications/minotari_console_wallet/src/automation/commands.rs @@ -158,7 +158,6 @@ pub(crate) const SPEND_STEP_2_SELF: &str = "step_2_for_self"; pub(crate) const SPEND_STEP_3_SELF: &str = "step_3_for_self"; pub(crate) const SPEND_STEP_3_PARTIES: &str = "step_3_for_parties"; pub(crate) const SPEND_STEP_4_LEADER: &str = "step_4_for_leader_from_"; -pub(crate) const NO_PAYMENT_ID: &str = ""; #[derive(Debug)] pub struct SentTransaction {} @@ -323,14 +322,13 @@ pub async fn claim_htlc_refund( mut transaction_service: TransactionServiceHandle, output_hash: FixedHash, fee_per_gram: MicroMinotari, - message: String, payment_id: PaymentId, ) -> Result { let (tx_id, _fee, amount, tx) = output_service .create_htlc_refund_transaction(output_hash, fee_per_gram) .await?; transaction_service - .submit_transaction(tx_id, tx, amount, message, payment_id) + .submit_transaction(tx_id, tx, amount, payment_id) .await?; Ok(tx_id) } @@ -342,7 +340,7 @@ pub async fn register_validator_node( validator_node_signature: Signature, selection_criteria: UtxoSelectionCriteria, fee_per_gram: MicroMinotari, - message: String, + payment_id: PaymentId, ) -> Result { wallet_transaction_service .register_validator_node( @@ -351,7 +349,7 @@ pub async fn register_validator_node( validator_node_signature, selection_criteria, fee_per_gram, - message, + payment_id, ) .await .map_err(CommandError::TransactionServiceError) @@ -363,7 +361,6 @@ pub async fn send_one_sided_to_stealth_address( amount: MicroMinotari, selection_criteria: UtxoSelectionCriteria, dest_address: TariAddress, - message: String, payment_id: PaymentId, ) -> Result { wallet_transaction_service @@ -373,7 +370,6 @@ pub async fn send_one_sided_to_stealth_address( selection_criteria, OutputFeatures::default(), fee_per_gram * uT, - message, payment_id, ) .await @@ -384,7 +380,6 @@ pub async fn coin_split( amount_per_split: MicroMinotari, num_splits: usize, fee_per_gram: MicroMinotari, - message: String, payment_id: PaymentId, output_service: &mut OutputManagerHandle, transaction_service: &mut TransactionServiceHandle, @@ -393,7 +388,7 @@ pub async fn coin_split( .create_coin_split(vec![], amount_per_split, num_splits, fee_per_gram) .await?; transaction_service - .submit_transaction(tx_id, tx, amount, message, payment_id) + .submit_transaction(tx_id, tx, amount, payment_id) .await?; Ok(tx_id) @@ -472,7 +467,7 @@ pub async fn make_it_rain( start_time: DateTime, destination: TariAddress, transaction_type: MakeItRainTransactionType, - message: String, + payment_id: PaymentId, ) -> Result<(), CommandError> { // Limit the transactions per second to a reasonable range // Notes: @@ -487,8 +482,8 @@ pub async fn make_it_rain( let now = Utc::now(); let delay_ms = if start_time > now { println!( - "`make-it-rain` scheduled to start at {}: msg \"{}\"", - start_time, message + "`make-it-rain` scheduled to start at {}: payment_id \"{}\"", + start_time, payment_id.compact_display() ); (start_time - now).num_milliseconds() as u64 } else { @@ -512,7 +507,7 @@ pub async fn make_it_rain( } println!( "\n`make-it-rain` starting {} {} transactions \"{}\"\n", - num_txs, transaction_type, message + num_txs, transaction_type, payment_id.compact_display() ); let (sender, mut receiver) = mpsc::channel(num_txs); { @@ -550,13 +545,12 @@ pub async fn make_it_rain( let sender_clone = sender.clone(); let fee = fee_per_gram; let address = destination.clone(); - let msg = message.clone(); tokio::task::spawn(async move { let spawn_start = Instant::now(); // Send transaction let tx_id = match transaction_type { MakeItRainTransactionType::Interactive => { - send_tari(tx_service, fee, amount, address.clone(), msg.clone(), PaymentId::Empty).await + send_tari(tx_service, fee, amount, address.clone(), payment_id.clone()).await }, MakeItRainTransactionType::StealthOneSided => { send_one_sided_to_stealth_address( @@ -565,13 +559,12 @@ pub async fn make_it_rain( amount, UtxoSelectionCriteria::default(), address.clone(), - msg.clone(), - PaymentId::Empty, + payment_id.clone(), ) .await }, MakeItRainTransactionType::BurnTari => { - burn_tari(tx_service, fee, amount, msg.clone(), PaymentId::Empty) + burn_tari(tx_service, fee, amount, payment_id.clone()) .await .map(|(tx_id, _)| tx_id) }, @@ -797,8 +790,7 @@ pub async fn command_runner( transaction_service.clone(), config.fee_per_gram, args.amount, - args.message, - get_payment_id(&args.payment_id), + PaymentId::Open(args.payment_id.as_bytes().to_vec()), ) .await { @@ -984,7 +976,7 @@ pub async fn command_runner( output_hash, commitment.clone(), args.recipient_address, - get_payment_id(&args.payment_id), + PaymentId::Open(args.payment_id.as_bytes().to_vec()), ) .await { @@ -1350,7 +1342,7 @@ pub async fn command_runner( } else { UseOutput::FromBlockchain(embedded_output.hash()) }, - get_payment_id(&args.payment_id), + PaymentId::Open(args.payment_id.as_bytes().to_vec()), ) .await { @@ -1993,8 +1985,7 @@ pub async fn command_runner( config.fee_per_gram, args.amount, args.destination, - args.message, - get_payment_id(&args.payment_id), + PaymentId::Open(args.payment_id.as_bytes().to_vec()), ) .await { @@ -2012,8 +2003,7 @@ pub async fn command_runner( args.amount, UtxoSelectionCriteria::default(), args.destination, - args.message, - get_payment_id(&args.payment_id), + PaymentId::Open(args.payment_id.as_bytes().to_vec()), ) .await { @@ -2039,7 +2029,7 @@ pub async fn command_runner( args.start_time.unwrap_or_else(Utc::now), args.destination, transaction_type, - args.message, + PaymentId::Open(args.payment_id.as_bytes().to_vec()), ) .await { @@ -2051,8 +2041,7 @@ pub async fn command_runner( args.amount_per_split, args.num_splits, args.fee_per_gram, - args.message, - get_payment_id(&args.payment_id), + PaymentId::Open(args.payment_id.as_bytes().to_vec()), &mut output_service, &mut transaction_service.clone(), ) @@ -2252,7 +2241,7 @@ pub async fn command_runner( args.amount, UtxoSelectionCriteria::default(), args.destination, - args.message, + PaymentId::Open(args.payment_id.as_bytes().to_vec()), ) .await { @@ -2275,8 +2264,7 @@ pub async fn command_runner( hash, args.pre_image.into(), config.fee_per_gram.into(), - args.message, - get_payment_id(&args.payment_id), + PaymentId::Open(args.payment_id.as_bytes().to_vec()), ) .await { @@ -2296,8 +2284,7 @@ pub async fn command_runner( transaction_service.clone(), hash, config.fee_per_gram.into(), - args.message, - get_payment_id(&args.payment_id), + PaymentId::Open(args.payment_id.as_bytes().to_vec()), ) .await { @@ -2338,7 +2325,7 @@ pub async fn command_runner( ), UtxoSelectionCriteria::default(), config.fee_per_gram * uT, - args.message, + PaymentId::Open(args.payment_id.as_bytes().to_vec()), ) .await?; debug!(target: LOG_TARGET, "Registering VN tx_id {}", tx_id); @@ -2713,16 +2700,6 @@ pub async fn command_runner( Ok(unban_peer_manager_peers) } -fn get_payment_id(payment_id: &str) -> PaymentId { - match payment_id { - NO_PAYMENT_ID => PaymentId::Empty, - _ => { - let payment_id_arg = payment_id.as_bytes().to_vec(); - PaymentId::Open(payment_id_arg) - }, - } -} - async fn temp_ban_peers(wallet: &WalletSqlite, peer_list: &mut Vec) { for peer in peer_list { let _unused = wallet diff --git a/applications/minotari_console_wallet/src/cli.rs b/applications/minotari_console_wallet/src/cli.rs index 6ab5928392b..fd81288c88b 100644 --- a/applications/minotari_console_wallet/src/cli.rs +++ b/applications/minotari_console_wallet/src/cli.rs @@ -41,8 +41,6 @@ use tari_utilities::{ }; use thiserror::Error; -use crate::automation::commands::NO_PAYMENT_ID; - #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] #[clap(propagate_version = true)] @@ -178,8 +176,6 @@ pub struct SendMinotariArgs { pub amount: MicroMinotari, pub destination: TariAddress, #[clap(short, long, default_value = "")] - pub message: String, - #[clap(short, long, default_value = NO_PAYMENT_ID)] pub payment_id: String, } @@ -187,8 +183,6 @@ pub struct SendMinotariArgs { pub struct BurnMinotariArgs { pub amount: MicroMinotari, #[clap(short, long, default_value = "Burn funds")] - pub message: String, - #[clap(short, long, default_value = NO_PAYMENT_ID)] pub payment_id: String, } @@ -272,8 +266,6 @@ pub struct PreMineSpendEncumberAggregateUtxoArgs { #[clap(long)] pub pre_mine_file_path: Option, #[clap(short, long, default_value = "Spend pre-mine encumber aggregate UTXO")] - pub message: String, - #[clap(short, long, default_value = NO_PAYMENT_ID)] pub payment_id: String, } @@ -304,8 +296,6 @@ pub struct PreMineSpendBackupUtxoArgs { #[clap(long)] pub pre_mine_file_path: Option, #[clap(short, long, default_value = "Spend pre-mine backup UTXO")] - pub message: String, - #[clap(short, long, default_value = NO_PAYMENT_ID)] pub payment_id: String, } @@ -327,7 +317,7 @@ pub struct MakeItRainArgs { #[clap(short, long)] pub burn_tari: bool, #[clap(short, long, default_value = "Make it rain")] - pub message: String, + pub payment_id: String, } impl MakeItRainArgs { @@ -375,8 +365,6 @@ pub struct CoinSplitArgs { #[clap(short, long, default_value = "1")] pub fee_per_gram: MicroMinotari, #[clap(short, long, default_value = "Coin split")] - pub message: String, - #[clap(short, long, default_value = NO_PAYMENT_ID)] pub payment_id: String, } @@ -446,8 +434,6 @@ pub struct FinaliseShaAtomicSwapArgs { #[clap(short, long)] pub pre_image: UniPublicKey, #[clap(short, long, default_value = "Claimed HTLC atomic swap")] - pub message: String, - #[clap(short, long, default_value = NO_PAYMENT_ID)] pub payment_id: String, } @@ -460,8 +446,6 @@ pub struct ClaimShaAtomicSwapRefundArgs { #[clap(short, long, parse(try_from_str = parse_hex), required = true)] pub output_hash: Vec>, #[clap(short, long, default_value = "Claimed HTLC atomic swap refund")] - pub message: String, - #[clap(short, long, default_value = NO_PAYMENT_ID)] pub payment_id: String, } @@ -472,7 +456,7 @@ pub struct RegisterValidatorNodeArgs { pub validator_node_public_nonce: UniPublicKey, pub validator_node_signature: Vec, #[clap(short, long, default_value = "Registering VN")] - pub message: String, + pub payment_id: String, } #[derive(Debug, Args, Clone)] diff --git a/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs b/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs index 6b7251d62f1..5373f750af1 100644 --- a/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs +++ b/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs @@ -2126,7 +2126,7 @@ impl TryFrom for UnconfirmedTransactionInfo { PrivateKey::from_vec(&i.transaction_signature_key)?, ), status: TransactionStatus::try_from(i.status)?, - payment_id: i.payment_id, + payment_id: PaymentId::from_bytes(&i.payment_id.unwrap_or_default()), }) } } @@ -2137,7 +2137,7 @@ pub struct UnconfirmedTransactionInfoSql { pub status: i32, pub transaction_signature_nonce: Vec, pub transaction_signature_key: Vec, - pub payment_id: PaymentId, + pub payment_id: Option>, } impl UnconfirmedTransactionInfoSql { diff --git a/base_layer/wallet/src/wallet.rs b/base_layer/wallet/src/wallet.rs index 5da426142b2..6d86629db6f 100644 --- a/base_layer/wallet/src/wallet.rs +++ b/base_layer/wallet/src/wallet.rs @@ -564,6 +564,7 @@ where encrypted_data: EncryptedData, minimum_value_promise: MicroMinotari, range_proof: Option, + payment_id: PaymentId, ) -> Result { let unblinded_output = UnblindedOutput::new_current_version( amount, @@ -580,7 +581,7 @@ where minimum_value_promise, range_proof, ); - self.import_unblinded_output_as_non_rewindable(unblinded_output, source_address) + self.import_unblinded_output_as_non_rewindable(unblinded_output, source_address, payment_id) .await } @@ -591,6 +592,7 @@ where &mut self, unblinded_output: UnblindedOutput, source_address: TariAddress, + payment_id: PaymentId, ) -> Result { let value = unblinded_output.value; let wallet_output = unblinded_output @@ -606,7 +608,7 @@ where None, None, wallet_output.to_transaction_output(&self.key_manager_service).await?, - PaymentId::Empty, + payment_id, ) .await?; // As non-rewindable diff --git a/base_layer/wallet_ffi/src/lib.rs b/base_layer/wallet_ffi/src/lib.rs index d4c1fb5f614..dc9f694dc44 100644 --- a/base_layer/wallet_ffi/src/lib.rs +++ b/base_layer/wallet_ffi/src/lib.rs @@ -2125,7 +2125,7 @@ pub unsafe extern "C" fn wallet_import_external_utxo_as_non_rewindable( wallet: *mut TariWallet, output: *mut TariUnblindedOutput, source_address: *mut TariWalletAddress, - message: *const c_char, + payment_id: *const c_char, error_out: *mut c_int, ) -> c_ulonglong { let mut error = 0; @@ -2145,23 +2145,24 @@ pub unsafe extern "C" fn wallet_import_external_utxo_as_non_rewindable( } else { (*source_address).clone() }; - if message.is_null() { + let payment_id_string; + if payment_id.is_null() { error = LibWalletError::from(InterfaceError::NullError("message".to_string())).code; ptr::swap(error_out, &mut error as *mut c_int); - message_string = CString::new("Imported UTXO") + payment_id_string = CString::new("Imported UTXO") .expect("CString will not fail") .to_str() .expect("CString.toStr() will not fail") .to_owned(); } else { - match CStr::from_ptr(message).to_str() { + match CStr::from_ptr(payment_id).to_str() { Ok(v) => { - message_string = v.to_owned(); + payment_id_string = v.to_owned(); }, _ => { error = LibWalletError::from(InterfaceError::PointerError("message".to_string())).code; ptr::swap(error_out, &mut error as *mut c_int); - message_string = CString::new("Imported UTXO") + payment_id_string = CString::new("Imported UTXO") .expect("CString will not fail") .to_str() .expect("CString.to_str() will not fail") @@ -2174,6 +2175,7 @@ pub unsafe extern "C" fn wallet_import_external_utxo_as_non_rewindable( .block_on((*wallet).wallet.import_unblinded_output_as_non_rewindable( (*output).clone(), source_address, + PaymentId::Open(payment_id_string.as_bytes().to_vec()) )) { Ok(tx_id) => tx_id.as_u64(), Err(e) => { @@ -4175,46 +4177,7 @@ pub unsafe extern "C" fn completed_transaction_get_timestamp( (*transaction).timestamp.timestamp() as c_ulonglong } -/// Gets the message of a TariCompletedTransaction -/// -/// ## Arguments -/// `transaction` - The pointer to a TariCompletedTransaction -/// `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions -/// as an out parameter. -/// -/// ## Returns -/// `*const c_char` - Returns the pointer to the char array, note that it will return a pointer -/// to an empty char array if transaction is null -/// -/// # Safety -/// The ```string_destroy``` method must be called when finished with string coming from rust to prevent a memory leak -#[no_mangle] -pub unsafe extern "C" fn completed_transaction_get_message( - transaction: *mut TariCompletedTransaction, - error_out: *mut c_int, -) -> *const c_char { - let mut error = 0; - ptr::swap(error_out, &mut error as *mut c_int); - let message = (*transaction).message.clone(); - let mut result = CString::new("").expect("Blank CString will not fail."); - if transaction.is_null() { - error = LibWalletError::from(InterfaceError::NullError("transaction".to_string())).code; - ptr::swap(error_out, &mut error as *mut c_int); - return result.into_raw(); - } - - match CString::new(message) { - Ok(v) => result = v, - _ => { - error = LibWalletError::from(InterfaceError::PointerError("message".to_string())).code; - ptr::swap(error_out, &mut error as *mut c_int); - }, - } - - result.into_raw() -} - -/// Gets the payment id of a TariCompletedTransaction +/// Gets the payment ID of a TariCompletedTransaction /// /// ## Arguments /// `transaction` - The pointer to a TariCompletedTransaction @@ -4241,15 +4204,7 @@ pub unsafe extern "C" fn completed_transaction_get_payment_id( ptr::swap(error_out, &mut error as *mut c_int); return result.into_raw(); } - let payment_id_str = { - let bytes = payment_id.get_user_data(); - if bytes.is_empty() { - format!("#{}", payment_id) - } else { - PaymentId::stringify_bytes(&bytes) - } - }; - match CString::new(payment_id_str) { + match CString::new(payment_id.compact_display()) { Ok(v) => result = v, _ => { error = LibWalletError::from(InterfaceError::PointerError("payment id".to_string())).code; @@ -4615,7 +4570,7 @@ pub unsafe extern "C" fn pending_outbound_transaction_get_timestamp( (*transaction).timestamp.timestamp() as c_ulonglong } -/// Gets the message of a TariPendingOutboundTransaction +/// Gets the payment ID of a TariPendingOutboundTransaction /// /// ## Arguments /// `transaction` - The pointer to a TariPendingOutboundTransaction @@ -4630,13 +4585,13 @@ pub unsafe extern "C" fn pending_outbound_transaction_get_timestamp( /// The ```string_destroy``` method must be called when finished with a string coming from rust to prevent a memory /// leak #[no_mangle] -pub unsafe extern "C" fn pending_outbound_transaction_get_message( +pub unsafe extern "C" fn pending_outbound_transaction_get_payment_id( transaction: *mut TariPendingOutboundTransaction, error_out: *mut c_int, ) -> *const c_char { let mut error = 0; ptr::swap(error_out, &mut error as *mut c_int); - let message = (*transaction).message.clone(); + let payment_id = (*transaction).payment_id.clone(); let mut result = CString::new("").expect("Blank CString will not fail."); if transaction.is_null() { error = LibWalletError::from(InterfaceError::NullError("transaction".to_string())).code; @@ -4644,7 +4599,7 @@ pub unsafe extern "C" fn pending_outbound_transaction_get_message( return result.into_raw(); } - match CString::new(message) { + match CString::new(payment_id.compact_display()) { Ok(v) => result = v, _ => { error = LibWalletError::from(InterfaceError::PointerError("message".to_string())).code; @@ -4823,7 +4778,7 @@ pub unsafe extern "C" fn pending_inbound_transaction_get_timestamp( (*transaction).timestamp.timestamp() as c_ulonglong } -/// Gets the message of a TariPendingInboundTransaction +/// Gets the payment ID of a TariPendingInboundTransaction /// /// ## Arguments /// `transaction` - The pointer to a TariPendingInboundTransaction @@ -4838,13 +4793,13 @@ pub unsafe extern "C" fn pending_inbound_transaction_get_timestamp( /// The ```string_destroy``` method must be called when finished with a string coming from rust to prevent a memory /// leak #[no_mangle] -pub unsafe extern "C" fn pending_inbound_transaction_get_message( +pub unsafe extern "C" fn pending_inbound_transaction_get_payment_id( transaction: *mut TariPendingInboundTransaction, error_out: *mut c_int, ) -> *const c_char { let mut error = 0; ptr::swap(error_out, &mut error as *mut c_int); - let message = (*transaction).message.clone(); + let payment_id = (*transaction).payment_id.clone(); let mut result = CString::new("").expect("Blank CString will not fail."); if transaction.is_null() { error = LibWalletError::from(InterfaceError::NullError("transaction".to_string())).code; @@ -4852,7 +4807,7 @@ pub unsafe extern "C" fn pending_inbound_transaction_get_message( return result.into_raw(); } - match CString::new(message) { + match CString::new(payment_id.compact_display()) { Ok(v) => result = v, _ => { error = LibWalletError::from(InterfaceError::PointerError("message".to_string())).code; @@ -6580,7 +6535,7 @@ pub unsafe extern "C" fn wallet_coin_split( commitments, number_of_splits, MicroMinotari(fee_per_gram), - String::new(), + PaymentId::Empty, )) { Ok(tx_id) => { ptr::replace(error_ptr, 0); @@ -7415,7 +7370,6 @@ pub unsafe extern "C" fn wallet_send_transaction( selection_criteria, OutputFeatures::default(), MicroMinotari::from(fee_per_gram), - message_string, payment_id, ), ) { @@ -7435,7 +7389,6 @@ pub unsafe extern "C" fn wallet_send_transaction( selection_criteria, OutputFeatures::default(), MicroMinotari::from(fee_per_gram), - message_string, payment_id, )) { Ok(tx_id) => tx_id.as_u64(), diff --git a/base_layer/wallet_ffi/wallet.h b/base_layer/wallet_ffi/wallet.h index cd74fec4662..78a32104538 100644 --- a/base_layer/wallet_ffi/wallet.h +++ b/base_layer/wallet_ffi/wallet.h @@ -2196,24 +2196,6 @@ unsigned long long completed_transaction_get_fee(TariCompletedTransaction *trans unsigned long long completed_transaction_get_timestamp(TariCompletedTransaction *transaction, int *error_out); -/** - * Gets the message of a TariCompletedTransaction - * - * ## Arguments - * `transaction` - The pointer to a TariCompletedTransaction - * `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions - * as an out parameter. - * - * ## Returns - * `*const c_char` - Returns the pointer to the char array, note that it will return a pointer - * to an empty char array if transaction is null - * - * # Safety - * The ```string_destroy``` method must be called when finished with string coming from rust to prevent a memory leak - */ -const char *completed_transaction_get_message(TariCompletedTransaction *transaction, - int *error_out); - /** * Gets the payment id of a TariCompletedTransaction * @@ -2431,7 +2413,7 @@ unsigned long long pending_outbound_transaction_get_timestamp(TariPendingOutboun int *error_out); /** - * Gets the message of a TariPendingOutboundTransaction + * Gets the payment ID of a TariPendingOutboundTransaction * * ## Arguments * `transaction` - The pointer to a TariPendingOutboundTransaction @@ -2446,7 +2428,7 @@ unsigned long long pending_outbound_transaction_get_timestamp(TariPendingOutboun * The ```string_destroy``` method must be called when finished with a string coming from rust to prevent a memory * leak */ -const char *pending_outbound_transaction_get_message(TariPendingOutboundTransaction *transaction, +const char *pending_outbound_transaction_get_payment_id(TariPendingOutboundTransaction *transaction, int *error_out); /** @@ -2577,7 +2559,7 @@ unsigned long long pending_inbound_transaction_get_timestamp(TariPendingInboundT * The ```string_destroy``` method must be called when finished with a string coming from rust to prevent a memory * leak */ -const char *pending_inbound_transaction_get_message(TariPendingInboundTransaction *transaction, +const char *pending_inbound_transaction_get_payment_id(TariPendingInboundTransaction *transaction, int *error_out); /** diff --git a/integration_tests/src/ffi/completed_transaction.rs b/integration_tests/src/ffi/completed_transaction.rs index 66cd82108e8..b901745bbc6 100644 --- a/integration_tests/src/ffi/completed_transaction.rs +++ b/integration_tests/src/ffi/completed_transaction.rs @@ -138,14 +138,14 @@ impl CompletedTransaction { } #[allow(dead_code)] - pub fn get_message(&self) -> String { + pub fn get_payment_id(&self) -> String { let ptr; let mut error = 0; unsafe { - ptr = ffi_import::completed_transaction_get_message(self.ptr, &mut error); + ptr = ffi_import::completed_transaction_get_payment_id(self.ptr, &mut error); if error > 0 { - println!("completed_transaction_get_message error {}", error); - panic!("completed_transaction_get_message error"); + println!("completed_transaction_get_payment_id error {}", error); + panic!("completed_transaction_get_payment_id error"); } } FFIString::from_ptr(ptr as *mut i8).as_string() diff --git a/integration_tests/src/ffi/ffi_import.rs b/integration_tests/src/ffi/ffi_import.rs index 5e1889808f3..c70be2b90ca 100644 --- a/integration_tests/src/ffi/ffi_import.rs +++ b/integration_tests/src/ffi/ffi_import.rs @@ -151,7 +151,7 @@ extern "C" { wallet: *mut TariWallet, output: *mut TariUnblindedOutput, source_address: *mut TariWalletAddress, - message: *const c_char, + payment_id: *const c_char, error_out: *mut c_int, ) -> c_ulonglong; pub fn wallet_get_unspent_outputs(wallet: *mut TariWallet, error_out: *mut c_int) -> *mut TariUnblindedOutputs; @@ -276,7 +276,7 @@ extern "C" { transaction: *mut TariCompletedTransaction, error_out: *mut c_int, ) -> c_ulonglong; - pub fn completed_transaction_get_message( + pub fn completed_transaction_get_payment_id( transaction: *mut TariCompletedTransaction, error_out: *mut c_int, ) -> *const c_char; @@ -310,7 +310,7 @@ extern "C" { transaction: *mut TariPendingOutboundTransaction, error_out: *mut c_int, ) -> c_ulonglong; - pub fn pending_outbound_transaction_get_message( + pub fn pending_outbound_transaction_get_payment_id( transaction: *mut TariPendingOutboundTransaction, error_out: *mut c_int, ) -> *const c_char; @@ -335,7 +335,7 @@ extern "C" { transaction: *mut TariPendingInboundTransaction, error_out: *mut c_int, ) -> c_ulonglong; - pub fn pending_inbound_transaction_get_message( + pub fn pending_inbound_transaction_get_payment_id( transaction: *mut TariPendingInboundTransaction, error_out: *mut c_int, ) -> *const c_char; diff --git a/integration_tests/src/ffi/pending_inbound_transaction.rs b/integration_tests/src/ffi/pending_inbound_transaction.rs index 4024f9ae6e7..95c3c251c0c 100644 --- a/integration_tests/src/ffi/pending_inbound_transaction.rs +++ b/integration_tests/src/ffi/pending_inbound_transaction.rs @@ -101,10 +101,10 @@ impl PendingInboundTransaction { let ptr; let mut error = 0; unsafe { - ptr = ffi_import::pending_inbound_transaction_get_message(self.ptr, &mut error); + ptr = ffi_import::pending_inbound_transaction_get_payment_id(self.ptr, &mut error); if error > 0 { - println!("pending_inbound_transaction_get_message error {}", error); - panic!("pending_inbound_transaction_get_message error"); + println!("pending_inbound_transaction_get_payment_id error {}", error); + panic!("pending_inbound_transaction_get_payment_id error"); } } FFIString::from_ptr(ptr as *mut i8).as_string() diff --git a/integration_tests/src/ffi/pending_outbound_transaction.rs b/integration_tests/src/ffi/pending_outbound_transaction.rs index 43854de92eb..48bbf35fd31 100644 --- a/integration_tests/src/ffi/pending_outbound_transaction.rs +++ b/integration_tests/src/ffi/pending_outbound_transaction.rs @@ -118,10 +118,10 @@ impl PendingOutboundTransaction { let ptr; let mut error = 0; unsafe { - ptr = ffi_import::pending_outbound_transaction_get_message(self.ptr, &mut error); + ptr = ffi_import::pending_outbound_transaction_get_payment_id(self.ptr, &mut error); if error > 0 { - println!("pending_outbound_transaction_get_message error {}", error); - panic!("pending_outbound_transaction_get_message error"); + println!("pending_outbound_transaction_get_payment_id error {}", error); + panic!("pending_outbound_transaction_get_payment_id error"); } } FFIString::from_ptr(ptr as *mut i8).as_string()