diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 2be4025b..4ea1576d 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -18,7 +18,7 @@ concurrency: jobs: fuzz: if: ${{ !github.event.act }} - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm strategy: fail-fast: false matrix: @@ -66,7 +66,7 @@ jobs: verify-execution: if: ${{ !github.event.act }} needs: fuzz - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 32609ff8..074f22d6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -20,7 +20,7 @@ jobs: permissions: contents: read pull-requests: write - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm steps: - name: Checkout Crate uses: actions/checkout@v4 @@ -140,7 +140,7 @@ jobs: key_wallet_tests: name: Key Wallet Components Tests - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm steps: - name: Checkout Crate uses: actions/checkout@v4 @@ -157,7 +157,7 @@ jobs: core_components_tests: name: Core Components Tests - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm steps: - name: Checkout Crate uses: actions/checkout@v4 @@ -178,7 +178,7 @@ jobs: clippy: name: Clippy (Non-strict) - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm steps: - name: Checkout Crate uses: actions/checkout@v4 @@ -201,7 +201,7 @@ jobs: strict-checks: name: Strict Warnings and Clippy Checks - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm steps: - name: Checkout Crate uses: actions/checkout@v4 @@ -298,7 +298,7 @@ jobs: fmt: name: Format - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm steps: - name: Checkout Crate uses: actions/checkout@v4 @@ -311,7 +311,7 @@ jobs: rpc_tests: name: RPC Tests - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm strategy: matrix: include: @@ -330,7 +330,7 @@ jobs: integrations_tests: name: Integration Tests if: ${{ false }} # Temporarily disabled - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm strategy: matrix: rust: [stable] @@ -347,7 +347,7 @@ jobs: actionlint: name: Lint GitHub Actions - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm permissions: contents: read steps: diff --git a/.github/workflows/verify-ffi-docs.yml b/.github/workflows/verify-ffi-docs.yml index bbb0a70f..e4fd4d08 100644 --- a/.github/workflows/verify-ffi-docs.yml +++ b/.github/workflows/verify-ffi-docs.yml @@ -22,7 +22,7 @@ on: jobs: verify-key-wallet-docs: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm steps: - name: Checkout repository uses: actions/checkout@v4 @@ -53,7 +53,7 @@ jobs: fi verify-dash-spv-docs: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm steps: - name: Checkout repository uses: actions/checkout@v4 @@ -84,7 +84,7 @@ jobs: fi update-docs-comment: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-arm if: failure() && github.event_name == 'pull_request' needs: - verify-key-wallet-docs diff --git a/key-wallet-ffi/src/account_derivation_tests.rs b/key-wallet-ffi/src/account_derivation_tests.rs index 920a331d..381afbdf 100644 --- a/key-wallet-ffi/src/account_derivation_tests.rs +++ b/key-wallet-ffi/src/account_derivation_tests.rs @@ -9,6 +9,8 @@ mod tests { use crate::keys::{extended_private_key_free, private_key_free}; use crate::types::{FFIAccountType, FFINetworks}; use crate::wallet; + use std::ffi::CString; + use std::os::raw::c_char; const MNEMONIC: &str = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; @@ -215,7 +217,7 @@ mod tests { } // Helper to make C string pointers - fn c_str(s: &str) -> *const i8 { + fn c_str(s: &str) -> *const c_char { std::ffi::CString::new(s).unwrap().as_ptr() } } diff --git a/key-wallet-ffi/src/derivation.rs b/key-wallet-ffi/src/derivation.rs index b96de79d..5b8b35b8 100644 --- a/key-wallet-ffi/src/derivation.rs +++ b/key-wallet-ffi/src/derivation.rs @@ -131,7 +131,7 @@ pub extern "C" fn derivation_bip44_account_path( } unsafe { - ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len()); + ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::(), bytes.len()); } FFIError::set_success(error); @@ -189,7 +189,7 @@ pub extern "C" fn derivation_bip44_payment_path( } unsafe { - ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len()); + ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::(), bytes.len()); } FFIError::set_success(error); @@ -244,7 +244,7 @@ pub extern "C" fn derivation_coinjoin_path( } unsafe { - ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len()); + ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::(), bytes.len()); } FFIError::set_success(error); @@ -299,7 +299,7 @@ pub extern "C" fn derivation_identity_registration_path( } unsafe { - ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len()); + ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::(), bytes.len()); } FFIError::set_success(error); @@ -356,7 +356,7 @@ pub extern "C" fn derivation_identity_topup_path( } unsafe { - ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len()); + ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::(), bytes.len()); } FFIError::set_success(error); @@ -417,7 +417,7 @@ pub extern "C" fn derivation_identity_authentication_path( } unsafe { - ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len()); + ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::(), bytes.len()); } FFIError::set_success(error); diff --git a/key-wallet-ffi/src/derivation_tests.rs b/key-wallet-ffi/src/derivation_tests.rs index d5634958..e21bafda 100644 --- a/key-wallet-ffi/src/derivation_tests.rs +++ b/key-wallet-ffi/src/derivation_tests.rs @@ -7,6 +7,7 @@ mod tests { use crate::error::{FFIError, FFIErrorCode}; use crate::mnemonic; use std::ffi::{CStr, CString}; + use std::os::raw::c_char; use std::ptr; #[test] @@ -180,14 +181,14 @@ mod tests { let success = derivation_bip44_account_path( FFINetwork::Testnet, 0, - account_path.as_mut_ptr() as *mut i8, + account_path.as_mut_ptr() as *mut c_char, account_path.len(), &mut error, ); assert!(success); let path_str = - unsafe { CStr::from_ptr(account_path.as_ptr() as *const i8) }.to_str().unwrap(); + unsafe { CStr::from_ptr(account_path.as_ptr() as *const c_char) }.to_str().unwrap(); assert_eq!(path_str, "m/44'/1'/0'"); // Test BIP44 payment path @@ -197,14 +198,14 @@ mod tests { 0, // account_index false, // is_change 0, // address_index - payment_path.as_mut_ptr() as *mut i8, + payment_path.as_mut_ptr() as *mut c_char, payment_path.len(), &mut error, ); assert!(success); let path_str = - unsafe { CStr::from_ptr(payment_path.as_ptr() as *const i8) }.to_str().unwrap(); + unsafe { CStr::from_ptr(payment_path.as_ptr() as *const c_char) }.to_str().unwrap(); assert_eq!(path_str, "m/44'/1'/0'/0/0"); } @@ -217,7 +218,7 @@ mod tests { let success = derivation_coinjoin_path( FFINetwork::Testnet, 0, // account_index - coinjoin_path.as_mut_ptr() as *mut i8, + coinjoin_path.as_mut_ptr() as *mut c_char, coinjoin_path.len(), &mut error, ); @@ -228,7 +229,7 @@ mod tests { let success = derivation_identity_registration_path( FFINetwork::Testnet, 0, // identity_index - id_reg_path.as_mut_ptr() as *mut i8, + id_reg_path.as_mut_ptr() as *mut c_char, id_reg_path.len(), &mut error, ); @@ -240,7 +241,7 @@ mod tests { FFINetwork::Testnet, 0, // identity_index 2, // topup_index - id_topup_path.as_mut_ptr() as *mut i8, + id_topup_path.as_mut_ptr() as *mut c_char, id_topup_path.len(), &mut error, ); @@ -252,7 +253,7 @@ mod tests { FFINetwork::Testnet, 0, // identity_index 3, // key_index - id_auth_path.as_mut_ptr() as *mut i8, + id_auth_path.as_mut_ptr() as *mut c_char, id_auth_path.len(), &mut error, ); @@ -410,13 +411,14 @@ mod tests { let success = derivation_identity_registration_path( FFINetwork::Testnet, 0, // identity_index - buffer.as_mut_ptr() as *mut i8, + buffer.as_mut_ptr() as *mut c_char, buffer.len(), &mut error, ); assert!(success); - let path_str = unsafe { CStr::from_ptr(buffer.as_ptr() as *const i8) }.to_str().unwrap(); + let path_str = + unsafe { CStr::from_ptr(buffer.as_ptr() as *const c_char) }.to_str().unwrap(); assert!(path_str.contains("m/")); // Test identity topup path @@ -425,13 +427,14 @@ mod tests { FFINetwork::Testnet, 0, // identity_index 0, // topup_index - buffer.as_mut_ptr() as *mut i8, + buffer.as_mut_ptr() as *mut c_char, buffer.len(), &mut error, ); assert!(success); - let path_str = unsafe { CStr::from_ptr(buffer.as_ptr() as *const i8) }.to_str().unwrap(); + let path_str = + unsafe { CStr::from_ptr(buffer.as_ptr() as *const c_char) }.to_str().unwrap(); assert!(path_str.contains("m/")); // Test identity authentication path @@ -440,13 +443,14 @@ mod tests { FFINetwork::Testnet, 0, // identity_index 0, // key_index - buffer.as_mut_ptr() as *mut i8, + buffer.as_mut_ptr() as *mut c_char, buffer.len(), &mut error, ); assert!(success); - let path_str = unsafe { CStr::from_ptr(buffer.as_ptr() as *const i8) }.to_str().unwrap(); + let path_str = + unsafe { CStr::from_ptr(buffer.as_ptr() as *const c_char) }.to_str().unwrap(); assert!(path_str.contains("m/")); } @@ -527,11 +531,11 @@ mod tests { let mut error = FFIError::success(); // Test with very small buffer (should fail) - let mut small_buffer = [0i8; 5]; + let mut small_buffer = [0u8; 5]; let success = derivation_bip44_account_path( FFINetwork::Testnet, 0, - small_buffer.as_mut_ptr(), + small_buffer.as_mut_ptr() as *mut c_char, small_buffer.len(), &mut error, ); @@ -544,7 +548,7 @@ mod tests { 0, false, 0, - small_buffer.as_mut_ptr(), + small_buffer.as_mut_ptr() as *mut c_char, small_buffer.len(), &mut error, ); @@ -770,13 +774,13 @@ mod tests { #[test] fn test_identity_path_functions_small_buffer() { let mut error = FFIError::success(); - let mut small_buffer = [0i8; 5]; + let mut small_buffer = [0u8; 5]; // Test identity registration with small buffer let success = derivation_identity_registration_path( FFINetwork::Testnet, 0, - small_buffer.as_mut_ptr(), + small_buffer.as_mut_ptr() as *mut c_char, small_buffer.len(), &mut error, ); @@ -788,7 +792,7 @@ mod tests { FFINetwork::Testnet, 0, 0, - small_buffer.as_mut_ptr(), + small_buffer.as_mut_ptr() as *mut c_char, small_buffer.len(), &mut error, ); @@ -800,7 +804,7 @@ mod tests { FFINetwork::Testnet, 0, 0, - small_buffer.as_mut_ptr(), + small_buffer.as_mut_ptr() as *mut c_char, small_buffer.len(), &mut error, ); @@ -818,7 +822,7 @@ mod tests { let success1 = derivation_bip44_account_path( FFINetwork::Testnet, 0, - buffer1.as_mut_ptr() as *mut i8, + buffer1.as_mut_ptr() as *mut c_char, buffer1.len(), &mut error, ); @@ -827,14 +831,14 @@ mod tests { let success2 = derivation_bip44_account_path( FFINetwork::Testnet, 5, - buffer2.as_mut_ptr() as *mut i8, + buffer2.as_mut_ptr() as *mut c_char, buffer2.len(), &mut error, ); assert!(success2); - let path1 = unsafe { CStr::from_ptr(buffer1.as_ptr() as *const i8).to_str().unwrap() }; - let path2 = unsafe { CStr::from_ptr(buffer2.as_ptr() as *const i8).to_str().unwrap() }; + let path1 = unsafe { CStr::from_ptr(buffer1.as_ptr() as *const c_char).to_str().unwrap() }; + let path2 = unsafe { CStr::from_ptr(buffer2.as_ptr() as *const c_char).to_str().unwrap() }; assert_eq!(path1, "m/44'/1'/0'"); assert_eq!(path2, "m/44'/1'/5'"); @@ -852,12 +856,13 @@ mod tests { 0, // account_index false, // is_change (receive) 5, // address_index - buffer.as_mut_ptr() as *mut i8, + buffer.as_mut_ptr() as *mut c_char, buffer.len(), &mut error, ); assert!(success); - let path_str = unsafe { CStr::from_ptr(buffer.as_ptr() as *const i8) }.to_str().unwrap(); + let path_str = + unsafe { CStr::from_ptr(buffer.as_ptr() as *const c_char) }.to_str().unwrap(); assert_eq!(path_str, "m/44'/1'/0'/0/5"); // Test change address path @@ -867,12 +872,13 @@ mod tests { 0, // account_index true, // is_change 3, // address_index - buffer.as_mut_ptr() as *mut i8, + buffer.as_mut_ptr() as *mut c_char, buffer.len(), &mut error, ); assert!(success); - let path_str = unsafe { CStr::from_ptr(buffer.as_ptr() as *const i8) }.to_str().unwrap(); + let path_str = + unsafe { CStr::from_ptr(buffer.as_ptr() as *const c_char) }.to_str().unwrap(); assert_eq!(path_str, "m/44'/1'/0'/1/3"); } diff --git a/key-wallet-ffi/src/transaction_tests.rs b/key-wallet-ffi/src/transaction_tests.rs index 38d55184..df5f58d2 100644 --- a/key-wallet-ffi/src/transaction_tests.rs +++ b/key-wallet-ffi/src/transaction_tests.rs @@ -6,6 +6,7 @@ mod transaction_tests { use crate::types::FFINetworks; use crate::wallet; use std::ffi::CString; + use std::os::raw::c_char; use std::ptr; #[test] @@ -39,7 +40,7 @@ mod transaction_tests { // Clean up unsafe { - let _ = CString::from_raw(output.address as *mut i8); + let _ = CString::from_raw(output.address as *mut c_char); } } @@ -204,7 +205,7 @@ mod transaction_tests { // Clean up unsafe { - let _ = CString::from_raw(output.address as *mut i8); + let _ = CString::from_raw(output.address as *mut c_char); wallet::wallet_free(wallet); } } diff --git a/key-wallet-ffi/tests/test_import_wallet.rs b/key-wallet-ffi/tests/test_import_wallet.rs index 0bd31029..c4f40043 100644 --- a/key-wallet-ffi/tests/test_import_wallet.rs +++ b/key-wallet-ffi/tests/test_import_wallet.rs @@ -6,6 +6,7 @@ mod tests { use key_wallet_ffi::error::{FFIError, FFIErrorCode}; use key_wallet_ffi::types::FFINetworks; use key_wallet_ffi::wallet_manager::*; + use std::os::raw::c_char; use std::ptr; #[test] @@ -23,8 +24,8 @@ mod tests { let success = wallet_manager_add_wallet_from_mnemonic( manager, - mnemonic.as_ptr() as *const i8, - passphrase.as_ptr() as *const i8, + mnemonic.as_ptr() as *const c_char, + passphrase.as_ptr() as *const c_char, FFINetworks::DashFlag, &mut error, );