Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "53130869e5
dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "53130869e5b9343ae59016323e5e5269e717a8fd" }
dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "53130869e5b9343ae59016323e5e5269e717a8fd" }
key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "53130869e5b9343ae59016323e5e5269e717a8fd" }
key-wallet-ffi = { git = "https://github.com/dashpay/rust-dashcore", rev = "53130869e5b9343ae59016323e5e5269e717a8fd" }
key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "53130869e5b9343ae59016323e5e5269e717a8fd" }
dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "53130869e5b9343ae59016323e5e5269e717a8fd" }
dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "53130869e5b9343ae59016323e5e5269e717a8fd" }
Expand Down
29 changes: 29 additions & 0 deletions packages/rs-platform-wallet-ffi/src/core_addresses.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! Dash Core (on-chain) address validation.

use dash_network::ffi::FFINetwork;
use std::ffi::CStr;
use std::os::raw::c_char;
use std::str::FromStr;

/// Validate that `address` is a well-formed Dash address on `network`.
/// Any null, non-UTF-8, malformed, or wrong-network input returns `false`.
///
/// # Safety
/// `address` must be a valid NUL-terminated C string.
#[no_mangle]
pub unsafe extern "C" fn platform_wallet_address_validate(
address: *const c_char,
network: FFINetwork,
) -> bool {
if address.is_null() {
return false;
}
let Ok(address_str) = CStr::from_ptr(address).to_str() else {
return false;
};
let Ok(parsed) = dashcore::Address::from_str(address_str) else {
return false;
};
let net: dashcore::Network = network.into();
parsed.require_network(net).is_ok()
}
95 changes: 95 additions & 0 deletions packages/rs-platform-wallet-ffi/src/key_wallet_ffi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//! BIP-39 mnemonic and BIP-32 derivation primitives.
//!
//! Thin C-ABI wrappers over the `key-wallet` crate — the surface that
//! `key-wallet-ffi` used to provide before it was dropped from this repo.

use crate::error::*;
use crate::{check_ptr, unwrap_result_or_return};
use dash_network::ffi::FFINetwork;
use key_wallet::mnemonic::{Language, Mnemonic};
use std::os::raw::c_char;

/// BIP-39 wordlist language. Mirrors `key_wallet::mnemonic::Language`.
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub enum FFILanguage {
English = 0,
ChineseSimplified = 1,
ChineseTraditional = 2,
Czech = 3,
French = 4,
Italian = 5,
Japanese = 6,
Korean = 7,
Portuguese = 8,
Spanish = 9,
}

impl From<FFILanguage> for Language {
fn from(language: FFILanguage) -> Self {
match language {
FFILanguage::English => Language::English,
FFILanguage::ChineseSimplified => Language::ChineseSimplified,
FFILanguage::ChineseTraditional => Language::ChineseTraditional,
FFILanguage::Czech => Language::Czech,
FFILanguage::French => Language::French,
FFILanguage::Italian => Language::Italian,
FFILanguage::Japanese => Language::Japanese,
FFILanguage::Korean => Language::Korean,
FFILanguage::Portuguese => Language::Portuguese,
FFILanguage::Spanish => Language::Spanish,
}
}
}

/// Generate a fresh BIP-39 mnemonic of `word_count` words (12, 15, 18,
/// 21, or 24) in `language`. Writes a heap C string into `out_mnemonic`
/// (caller frees via `platform_wallet_string_free`).
///
/// # Safety
/// `out_mnemonic` must be a valid writable `*mut c_char` location.
#[no_mangle]
pub unsafe extern "C" fn platform_wallet_generate_mnemonic(
word_count: u32,
language: FFILanguage,
out_mnemonic: *mut *mut c_char,
) -> PlatformWalletFFIResult {
check_ptr!(out_mnemonic);
let phrase = unwrap_result_or_return!(Mnemonic::generate(word_count as usize, language.into()));
let c_str = unwrap_result_or_return!(std::ffi::CString::new(phrase.to_string()));
*out_mnemonic = c_str.into_raw();
PlatformWalletFFIResult::ok()
}

/// Build the DIP-9 identity-authentication path
/// `m/9'/<coin>'/5'/0'/identity_index'/key_index'`. Writes a heap C
/// string into `out_path` (caller frees via `platform_wallet_string_free`).
/// Returns 0 on success, -1 on failure.
///
/// # Safety
/// `out_path` must be a valid writable `*mut c_char` location.
#[no_mangle]
pub unsafe extern "C" fn platform_wallet_derive_identity_authentication_path(
network: FFINetwork,
identity_index: u32,
key_index: u32,
out_path: *mut *mut c_char,
) -> i32 {
if out_path.is_null() {
return -1;
}
use key_wallet::bip32::{DerivationPath, KeyDerivationType};
let net: key_wallet::Network = network.into();
let derivation = DerivationPath::identity_authentication_path(
net,
KeyDerivationType::ECDSA,
identity_index,
key_index,
);
let path_str = format!("{}", derivation);
let Ok(c_str) = std::ffi::CString::new(path_str) else {
return -1;
};
*out_path = c_str.into_raw();
0
}
4 changes: 4 additions & 0 deletions packages/rs-platform-wallet-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub mod contact;
pub mod contact_persistence;
pub mod contact_request;
pub mod core_address_types;
pub mod core_addresses;
pub mod core_wallet;
pub mod core_wallet_types;
pub mod dashpay;
Expand Down Expand Up @@ -41,6 +42,7 @@ pub mod identity_top_up;
pub mod identity_transfer;
pub mod identity_update;
pub mod identity_withdrawal;
pub mod key_wallet_ffi;
pub mod managed_identity;
pub mod manager;
pub mod manager_diagnostics;
Expand Down Expand Up @@ -71,6 +73,7 @@ pub use contact::*;
pub use contact_persistence::*;
pub use contact_request::*;
pub use core_address_types::*;
pub use core_addresses::*;
pub use core_wallet::*;
pub use core_wallet_types::*;
pub use dashpay::*;
Expand All @@ -97,6 +100,7 @@ pub use identity_top_up::*;
pub use identity_transfer::*;
pub use identity_update::*;
pub use identity_withdrawal::*;
pub use key_wallet_ffi::*;
pub use managed_identity::*;
pub use manager::*;
pub use manager_diagnostics::*;
Expand Down
1 change: 0 additions & 1 deletion packages/rs-platform-wallet-ffi/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2313,4 +2313,3 @@ unsafe fn slice_from_raw<'a>(ptr: *const u8, len: usize) -> &'a [u8] {
slice::from_raw_parts(ptr, len)
}
}

3 changes: 1 addition & 2 deletions packages/rs-sdk-ffi/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ documentation_style = "c99"

[export]
include = ["dash_sdk_*", "dash_core_*", "dash_unified_sdk_*"]
# Exclude types that come from key-wallet-ffi to avoid duplication
exclude = ["FFIAccountType", "FFIAccountTypePreference", "FFIAccountTypeUsed", "FFIAccountCreationOptionType"]
exclude = []
prefix = ""
item_types = ["enums", "structs", "unions", "typedefs", "opaque", "functions"]

Expand Down
3 changes: 1 addition & 2 deletions packages/rs-unified-sdk-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ rust-version.workspace = true
crate-type = ["staticlib", "cdylib"]

[dependencies]
key-wallet-ffi = { workspace = true }
platform-wallet-ffi = { path = "../rs-platform-wallet-ffi" }
rs-sdk-ffi = { path = "../rs-sdk-ffi" }
dash-network = { workspace = true, features = ["ffi"] }
Expand All @@ -18,4 +17,4 @@ default = []
# Forwards to `platform-wallet-ffi/shielded`. Pulls Orchard / ZK
# shielded sync support into the unified iOS framework. Off by
# default so the framework's transparent surface stays slim.
shielded = ["platform-wallet-ffi/shielded"]
shielded = ["platform-wallet-ffi/shielded"]
1 change: 0 additions & 1 deletion packages/rs-unified-sdk-ffi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub use dash_network;
pub use key_wallet_ffi;
pub use platform_wallet_ffi;
pub use rs_sdk_ffi;
65 changes: 0 additions & 65 deletions packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Account.swift

This file was deleted.

This file was deleted.

Loading
Loading