From 7db14fa7864c393e117965881697f8d7a59d953c Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Fri, 27 Mar 2026 21:49:04 +0700 Subject: [PATCH] =?UTF-8?q?chore:=20update=20dashcore=20deps=20to=20f92f11?= =?UTF-8?q?4b=20(PR=20#590=20=E2=80=94=20restored=20key-wallet-manager)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- Cargo.lock | 306 +++++------ Cargo.toml | 12 +- packages/rs-dpp/Cargo.toml | 1 - .../examples/basic_usage.rs | 2 +- .../wallet_info_interface.rs | 10 +- .../wallet_transaction_checker.rs | 5 +- packages/rs-sdk-ffi/build_ios.sh | 2 +- packages/rs-sdk-ffi/src/lib.rs | 2 - packages/rs-sdk-ffi/src/unified.rs | 478 ------------------ .../SwiftDashSDK/Core/SPV/SPVClient.swift | 99 +--- .../Core/SPV/SPVEventHandler.swift | 99 +++- .../Core/Services/WalletService.swift | 100 ++-- 12 files changed, 315 insertions(+), 801 deletions(-) delete mode 100644 packages/rs-sdk-ffi/src/unified.rs diff --git a/Cargo.lock b/Cargo.lock index 59966e61806..4db689a083a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,21 +84,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" -[[package]] -name = "anstream" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" -dependencies = [ - "anstyle", - "anstyle-parse 0.2.7", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - [[package]] name = "anstream" version = "1.0.0" @@ -106,7 +91,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" dependencies = [ "anstyle", - "anstyle-parse 1.0.0", + "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", @@ -120,15 +105,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" -[[package]] -name = "anstyle-parse" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" -dependencies = [ - "utf8parse", -] - [[package]] name = "anstyle-parse" version = "1.0.0" @@ -175,9 +151,9 @@ dependencies = [ [[package]] name = "arc-swap" -version = "1.8.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9f3647c145568cec02c42054e07bdf9a5a698e15b466fb2341bfc393cd24aa5" +checksum = "a07d1f37ff60921c83bdfc7407723bdefe89b44b98a9b772f225c8f9d67141a6" dependencies = [ "rustversion", ] @@ -271,9 +247,9 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "aws-lc-rs" -version = "1.16.1" +version = "1.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bffc006df10ac2a68c83692d734a465f8ee6c5b384d8545a636f81d858f4bf" +checksum = "a054912289d18629dc78375ba2c3726a3afe3ff71b4edba9dedfca0e3446d1fc" dependencies = [ "aws-lc-sys", "zeroize", @@ -281,9 +257,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4321e568ed89bb5a7d291a7f37997c2c0df89809d7b6d12062c81ddb54aa782e" +checksum = "1fa7e52a4c5c547c741610a2c6f123f3881e409b714cd27e6798ef020c514f0a" dependencies = [ "cc", "cmake", @@ -757,19 +733,20 @@ dependencies = [ [[package]] name = "borsh" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1da5ab77c1437701eeff7c88d968729e7766172279eab0676857b3d63af7a6f" +checksum = "cfd1e3f8955a5d7de9fab72fc8373fade9fb8a703968cb200ae3dc6cf08e185a" dependencies = [ "borsh-derive", + "bytes", "cfg_aliases", ] [[package]] name = "borsh-derive" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0686c856aa6aac0c4498f936d7d6a02df690f614c03e4d906d1018062b5c5e2c" +checksum = "bfcfdc083699101d5a7965e49925975f2f55060f94f9a05e7187be95d530ca59" dependencies = [ "once_cell", "proc-macro-crate 3.5.0", @@ -912,9 +889,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.57" +version = "1.2.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a0dd1ca384932ff3641c8718a02769f1698e7563dc6974ffd03346116310423" +checksum = "e1e928d4b69e3077709075a938a05ffbedfa53a84c8f766efbf8220bb1ff60e1" dependencies = [ "find-msvc-tools", "jobserver", @@ -1092,7 +1069,7 @@ version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" dependencies = [ - "anstream 1.0.0", + "anstream", "anstyle", "clap_lex", "strsim", @@ -1118,9 +1095,9 @@ checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" [[package]] name = "cmake" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" dependencies = [ "cc", ] @@ -1630,7 +1607,7 @@ dependencies = [ [[package]] name = "dash-spv" version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e#42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f92f114b83f6e442af8290611a10f2246ee58d3a#f92f114b83f6e442af8290611a10f2246ee58d3a" dependencies = [ "anyhow", "async-trait", @@ -1663,7 +1640,7 @@ dependencies = [ [[package]] name = "dash-spv-ffi" version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e#42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f92f114b83f6e442af8290611a10f2246ee58d3a#f92f114b83f6e442af8290611a10f2246ee58d3a" dependencies = [ "cbindgen 0.29.2", "clap", @@ -1688,7 +1665,7 @@ dependencies = [ [[package]] name = "dashcore" version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e#42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f92f114b83f6e442af8290611a10f2246ee58d3a#f92f114b83f6e442af8290611a10f2246ee58d3a" dependencies = [ "anyhow", "base64-compat", @@ -1713,12 +1690,12 @@ dependencies = [ [[package]] name = "dashcore-private" version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e#42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f92f114b83f6e442af8290611a10f2246ee58d3a#f92f114b83f6e442af8290611a10f2246ee58d3a" [[package]] name = "dashcore-rpc" version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e#42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f92f114b83f6e442af8290611a10f2246ee58d3a#f92f114b83f6e442af8290611a10f2246ee58d3a" dependencies = [ "dashcore-rpc-json", "hex", @@ -1731,7 +1708,7 @@ dependencies = [ [[package]] name = "dashcore-rpc-json" version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e#42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f92f114b83f6e442af8290611a10f2246ee58d3a#f92f114b83f6e442af8290611a10f2246ee58d3a" dependencies = [ "bincode", "dashcore", @@ -1746,7 +1723,7 @@ dependencies = [ [[package]] name = "dashcore_hashes" version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e#42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f92f114b83f6e442af8290611a10f2246ee58d3a#f92f114b83f6e442af8290611a10f2246ee58d3a" dependencies = [ "bincode", "dashcore-private", @@ -1946,7 +1923,7 @@ dependencies = [ "derive_more 1.0.0", "dpp", "dpp-json-convertible-derive", - "env_logger 0.11.9", + "env_logger 0.11.10", "getrandom 0.2.17", "grovedb-commitment-tree", "hex", @@ -2252,9 +2229,9 @@ dependencies = [ [[package]] name = "env_filter" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a1c3cc8e57274ec99de65301228b537f1e4eedc1b8e0f9411c6caac8ae7308f" +checksum = "32e90c2accc4b07a8456ea0debdc2e7587bdd890680d71173a15d4ae604f6eef" dependencies = [ "log", "regex", @@ -2275,11 +2252,11 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.9" +version = "0.11.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2daee4ea451f429a58296525ddf28b45a3b64f1acf6587e2067437bb11e218d" +checksum = "0621c04f2196ac3f488dd583365b9c09be011a4ab8b9f37248ffcc8f6198b56a" dependencies = [ - "anstream 0.6.21", + "anstream", "anstyle", "env_filter", "jiff", @@ -3591,14 +3568,15 @@ dependencies = [ [[package]] name = "ipconfig" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" +checksum = "4d40460c0ce33d6ce4b0630ad68ff63d6661961c48b6dba35e5a4d81cfb48222" dependencies = [ - "socket2 0.5.10", + "socket2 0.6.3", "widestring", - "windows-sys 0.48.0", - "winreg", + "windows-registry", + "windows-result", + "windows-sys 0.61.2", ] [[package]] @@ -3609,9 +3587,9 @@ checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" [[package]] name = "iri-string" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" +checksum = "d8e7418f59cc01c88316161279a7f665217ae316b388e58a0d10e29f54f1e5eb" dependencies = [ "memchr", "serde", @@ -3672,9 +3650,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "jiff" @@ -3709,7 +3687,7 @@ dependencies = [ "cesu8", "cfg-if", "combine", - "jni-sys", + "jni-sys 0.3.1", "log", "thiserror 1.0.69", "walkdir", @@ -3718,9 +3696,31 @@ dependencies = [ [[package]] name = "jni-sys" -version = "0.3.0" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.117", +] [[package]] name = "jobserver" @@ -3829,7 +3829,7 @@ dependencies = [ [[package]] name = "key-wallet" version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e#42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f92f114b83f6e442af8290611a10f2246ee58d3a#f92f114b83f6e442af8290611a10f2246ee58d3a" dependencies = [ "aes", "async-trait", @@ -3857,7 +3857,7 @@ dependencies = [ [[package]] name = "key-wallet-ffi" version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e#42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f92f114b83f6e442af8290611a10f2246ee58d3a#f92f114b83f6e442af8290611a10f2246ee58d3a" dependencies = [ "cbindgen 0.29.2", "dashcore", @@ -3872,15 +3872,13 @@ dependencies = [ [[package]] name = "key-wallet-manager" version = "0.42.0" -source = "git+https://github.com/dashpay/rust-dashcore?rev=42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e#42eb1d698d4f178d3a8a80c72c9c0f9bbeddcc3e" +source = "git+https://github.com/dashpay/rust-dashcore?rev=f92f114b83f6e442af8290611a10f2246ee58d3a#f92f114b83f6e442af8290611a10f2246ee58d3a" dependencies = [ "async-trait", "bincode", "dashcore", - "dashcore_hashes", "key-wallet", "rayon", - "secp256k1", "tokio", "zeroize", ] @@ -4204,9 +4202,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" dependencies = [ "libc", "wasi", @@ -4387,9 +4385,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" +checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" [[package]] name = "num-derive" @@ -5036,7 +5034,7 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" dependencies = [ - "toml_edit 0.25.4+spec-1.1.0", + "toml_edit 0.25.8+spec-1.1.0", ] [[package]] @@ -5212,9 +5210,9 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c41efbf8f90ac44de7f3a868f0867851d261b56291732d0cbf7cceaaeb55a6" +checksum = "7c3a14896dfa883796f1cb410461aef38810ea05f2b2c33c5aded3649095fdad" dependencies = [ "bitflags 2.11.0", "memchr", @@ -5247,9 +5245,9 @@ dependencies = [ [[package]] name = "quick_cache" -version = "0.6.19" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "530e84778a55de0f52645a51d4e3b9554978acd6a1e7cd50b6a6784692b3029e" +checksum = "5a70b1b8b47e31d0498ecbc3c5470bb931399a8bfed1fd79d1717a61ce7f96e3" dependencies = [ "ahash 0.8.12", "equivalent", @@ -5855,7 +5853,7 @@ dependencies = [ "dash-spv-ffi", "dotenvy", "drive-proof-verifier", - "env_logger 0.11.9", + "env_logger 0.11.10", "envy", "getrandom 0.2.17", "hex", @@ -5942,9 +5940,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61f703d19852dbf87cbc513643fa81428361eb6940f1ac14fd58155d295a3eb0" +checksum = "2ce901f9a19d251159075a4c37af514c3b8ef99c22e02dd8c19161cf397ee94a" dependencies = [ "arrayvec", "borsh", @@ -5954,6 +5952,7 @@ dependencies = [ "rkyv", "serde", "serde_json", + "wasm-bindgen", ] [[package]] @@ -6080,9 +6079,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" [[package]] name = "rustls-webpki" -version = "0.103.9" +version = "0.103.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" +checksum = "df33b2b81ac578cabaf06b89b0631153a3f416b0a886e8a7a1707fb51abbd1ef" dependencies = [ "aws-lc-rs", "ring", @@ -6391,9 +6390,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776" +checksum = "876ac351060d4f882bb1032b6369eb0aef79ad9df1ea8bc404874d8cc3d0cd98" dependencies = [ "serde_core", ] @@ -6585,9 +6584,9 @@ dependencies = [ [[package]] name = "simd-adler32" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" +checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" [[package]] name = "simdutf8" @@ -7251,7 +7250,7 @@ checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863" dependencies = [ "indexmap 2.13.0", "serde_core", - "serde_spanned 1.0.4", + "serde_spanned 1.1.0", "toml_datetime 0.7.5+spec-1.1.0", "toml_parser", "toml_writer", @@ -7278,9 +7277,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "1.0.0+spec-1.1.0" +version = "1.1.0+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32c2555c699578a4f59f0cc68e5116c8d7cabbd45e1409b989d4be085b53f13e" +checksum = "97251a7c317e03ad83774a8752a7e81fb6067740609f75ea2b585b569a59198f" dependencies = [ "serde_core", ] @@ -7312,23 +7311,23 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.25.4+spec-1.1.0" +version = "0.25.8+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7193cbd0ce53dc966037f54351dbbcf0d5a642c7f0038c382ef9e677ce8c13f2" +checksum = "16bff38f1d86c47f9ff0647e6838d7bb362522bdf44006c7068c2b1e606f1f3c" dependencies = [ "indexmap 2.13.0", - "toml_datetime 1.0.0+spec-1.1.0", + "toml_datetime 1.1.0+spec-1.1.0", "toml_parser", - "winnow 0.7.15", + "winnow 1.0.0", ] [[package]] name = "toml_parser" -version = "1.0.9+spec-1.1.0" +version = "1.1.0+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702d4415e08923e7e1ef96cd5727c0dfed80b4d2fa25db9647fe5eb6f7c5a4c4" +checksum = "2334f11ee363607eb04df9b8fc8a13ca1715a72ba8662a26ac285c98aabb4011" dependencies = [ - "winnow 0.7.15", + "winnow 1.0.0", ] [[package]] @@ -7339,9 +7338,9 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] name = "toml_writer" -version = "1.0.6+spec-1.1.0" +version = "1.1.0+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" +checksum = "d282ade6016312faf3e41e57ebbba0c073e4056dab1232ab1cb624199648f8ed" [[package]] name = "tonic" @@ -7734,9 +7733,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.12.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" [[package]] name = "unicode-xid" @@ -7768,9 +7767,9 @@ checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" [[package]] name = "ureq" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc97a28575b85cfedf2a7e7d3cc64b3e11bd8ac766666318003abbacc7a21fc" +checksum = "dea7109cdcd5864d4eeb1b58a1648dc9bf520360d7af16ec26d0a9354bafcfc0" dependencies = [ "base64 0.22.1", "flate2", @@ -7779,15 +7778,15 @@ dependencies = [ "rustls", "rustls-pki-types", "ureq-proto", - "utf-8", + "utf8-zero", "webpki-roots", ] [[package]] name = "ureq-proto" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d81f9efa9df032be5934a46a068815a10a042b494b6a58cb0a1a97bb5467ed6f" +checksum = "e994ba84b0bd1b1b0cf92878b7ef898a5c1760108fe7b6010327e274917a808c" dependencies = [ "base64 0.22.1", "http", @@ -7813,6 +7812,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8-zero" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c0a043c9540bae7c578c88f91dda8bd82e59ae27c21baca69c8b191aaf5a6e" + [[package]] name = "utf8_iter" version = "1.0.4" @@ -7827,9 +7832,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.22.0" +version = "1.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37" +checksum = "5ac8b6f42ead25368cf5b098aeb3dc8a1a2c05a3eee8a9a1a68c640edbfc79d9" dependencies = [ "getrandom 0.4.2", "js-sys", @@ -8384,15 +8389,6 @@ dependencies = [ "windows-targets 0.42.2", ] -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" @@ -8444,21 +8440,6 @@ dependencies = [ "windows_x86_64_msvc 0.42.2", ] -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - [[package]] name = "windows-targets" version = "0.52.6" @@ -8498,12 +8479,6 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" @@ -8522,12 +8497,6 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" @@ -8546,12 +8515,6 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -8582,12 +8545,6 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" @@ -8606,12 +8563,6 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -8630,12 +8581,6 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" @@ -8654,12 +8599,6 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -8691,13 +8630,12 @@ dependencies = [ ] [[package]] -name = "winreg" -version = "0.50.0" +name = "winnow" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +checksum = "a90e88e4667264a994d34e6d1ab2d26d398dcdca8b7f52bec8668957517fc7d8" dependencies = [ - "cfg-if", - "windows-sys 0.48.0", + "memchr", ] [[package]] @@ -8874,18 +8812,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.42" +version = "0.8.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2578b716f8a7a858b7f02d5bd870c14bf4ddbbcf3a4c05414ba6503640505e3" +checksum = "efbb2a062be311f2ba113ce66f697a4dc589f85e78a4aea276200804cea0ed87" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.42" +version = "0.8.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e6cc098ea4d3bd6246687de65af3f920c430e236bee1e3bf2e441463f08a02f" +checksum = "0e8bc7269b54418e7aeeef514aa68f8690b8c0489a06b0136e5f57c4c5ccab89" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 4173fa820df..bb5f1885824 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,12 +47,12 @@ members = [ ] [workspace.dependencies] -dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" } -dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" } -dash-spv-ffi = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" } -key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" } -key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" } -dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" } +dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "f92f114b83f6e442af8290611a10f2246ee58d3a" } +dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "f92f114b83f6e442af8290611a10f2246ee58d3a" } +dash-spv-ffi = { git = "https://github.com/dashpay/rust-dashcore", rev = "f92f114b83f6e442af8290611a10f2246ee58d3a" } +key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "f92f114b83f6e442af8290611a10f2246ee58d3a" } +key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "f92f114b83f6e442af8290611a10f2246ee58d3a" } +dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "f92f114b83f6e442af8290611a10f2246ee58d3a" } # Optimize heavy crypto crates even in dev/test builds so that # Halo 2 proof generation and verification run at near-release speed. diff --git a/packages/rs-dpp/Cargo.toml b/packages/rs-dpp/Cargo.toml index 1eecb169b4a..726bbedb8cc 100644 --- a/packages/rs-dpp/Cargo.toml +++ b/packages/rs-dpp/Cargo.toml @@ -25,7 +25,6 @@ chrono = { version = "0.4.35", default-features = false, features = [ chrono-tz = { version = "0.8", optional = true } ciborium = { version = "0.2.2", optional = true } dashcore = { workspace = true, features = [ - "std", "secp-recovery", "rand", "signer", diff --git a/packages/rs-platform-wallet/examples/basic_usage.rs b/packages/rs-platform-wallet/examples/basic_usage.rs index ccf3c743022..744d0059158 100644 --- a/packages/rs-platform-wallet/examples/basic_usage.rs +++ b/packages/rs-platform-wallet/examples/basic_usage.rs @@ -25,7 +25,7 @@ fn main() -> Result<(), PlatformWalletError> { // The platform wallet can be used with WalletManager (requires "manager" feature) #[cfg(feature = "manager")] { - use key_wallet_manager::wallet_manager::WalletManager; + use key_wallet_manager::WalletManager; let _wallet_manager = WalletManager::::new(network); println!("Platform wallet successfully integrated with wallet managers!"); diff --git a/packages/rs-platform-wallet/src/platform_wallet_info/wallet_info_interface.rs b/packages/rs-platform-wallet/src/platform_wallet_info/wallet_info_interface.rs index cb3ccead404..272b6b58e91 100644 --- a/packages/rs-platform-wallet/src/platform_wallet_info/wallet_info_interface.rs +++ b/packages/rs-platform-wallet/src/platform_wallet_info/wallet_info_interface.rs @@ -1,6 +1,6 @@ use crate::platform_wallet_info::PlatformWalletInfo; use crate::IdentityManager; -use dashcore::{Address as DashAddress, Network, Transaction}; +use dashcore::{Address as DashAddress, Network, Transaction, Txid}; use dpp::prelude::CoreBlockHeight; use key_wallet::account::{ManagedAccountCollection, TransactionRecord}; use key_wallet::wallet::managed_wallet_info::wallet_info_interface::WalletInfoInterface; @@ -111,4 +111,12 @@ impl WalletInfoInterface for PlatformWalletInfo { fn update_synced_height(&mut self, current_height: u32) { self.wallet_info.update_synced_height(current_height) } + + fn mark_instant_send_utxos(&mut self, txid: &Txid) -> bool { + self.wallet_info.mark_instant_send_utxos(txid) + } + + fn monitor_revision(&self) -> u64 { + self.wallet_info.monitor_revision() + } } diff --git a/packages/rs-platform-wallet/src/platform_wallet_info/wallet_transaction_checker.rs b/packages/rs-platform-wallet/src/platform_wallet_info/wallet_transaction_checker.rs index 0d711984de2..7c7527d0466 100644 --- a/packages/rs-platform-wallet/src/platform_wallet_info/wallet_transaction_checker.rs +++ b/packages/rs-platform-wallet/src/platform_wallet_info/wallet_transaction_checker.rs @@ -13,13 +13,14 @@ impl WalletTransactionChecker for PlatformWalletInfo { &mut self, tx: &Transaction, context: TransactionContext, - wallet: &Wallet, + wallet: &mut Wallet, update_state: bool, + update_balance: bool, ) -> TransactionCheckResult { // Check transaction with underlying wallet info let result = self .wallet_info - .check_core_transaction(tx, context, wallet, update_state) + .check_core_transaction(tx, context, wallet, update_state, update_balance) .await; // If the transaction is relevant, and it's an asset lock, automatically fetch identities diff --git a/packages/rs-sdk-ffi/build_ios.sh b/packages/rs-sdk-ffi/build_ios.sh index a72884a9eeb..2879a45ebd6 100755 --- a/packages/rs-sdk-ffi/build_ios.sh +++ b/packages/rs-sdk-ffi/build_ios.sh @@ -95,7 +95,7 @@ if [[ "$CLEAN_BUILD" -eq 1 ]]; then cargo clean --release --target aarch64-apple-ios-sim -p rs-sdk-ffi 2>/dev/null || true cargo clean --release --target x86_64-apple-ios -p rs-sdk-ffi 2>/dev/null || true # Also clean path-dependency crates that cargo may cache - for pkg in dashcore key-wallet key-wallet-manager dash-spv dash-spv-ffi rs-platform-wallet rs-platform-wallet-ffi; do + for pkg in dashcore key-wallet dash-spv dash-spv-ffi rs-platform-wallet rs-platform-wallet-ffi; do cargo clean --release --target aarch64-apple-ios -p "$pkg" 2>/dev/null || true cargo clean --release --target aarch64-apple-ios-sim -p "$pkg" 2>/dev/null || true cargo clean --release --target x86_64-apple-ios -p "$pkg" 2>/dev/null || true diff --git a/packages/rs-sdk-ffi/src/lib.rs b/packages/rs-sdk-ffi/src/lib.rs index 064f8d7aa58..67ab307ba1e 100644 --- a/packages/rs-sdk-ffi/src/lib.rs +++ b/packages/rs-sdk-ffi/src/lib.rs @@ -32,7 +32,6 @@ mod signer_simple; mod system; mod token; mod types; -mod unified; mod utils; mod voting; @@ -65,7 +64,6 @@ pub use signer_simple::*; pub use system::*; pub use token::*; pub use types::*; -pub use unified::*; pub use utils::*; pub use voting::*; diff --git a/packages/rs-sdk-ffi/src/unified.rs b/packages/rs-sdk-ffi/src/unified.rs deleted file mode 100644 index 1431a8e9fc1..00000000000 --- a/packages/rs-sdk-ffi/src/unified.rs +++ /dev/null @@ -1,478 +0,0 @@ -//! Unified SDK coordination module -#![allow(unexpected_cfgs)] -//! -//! This module provides unified functions that coordinate between Core SDK and Platform SDK -//! when both are available. It manages initialization, state synchronization, and -//! cross-layer operations. - -use std::ffi::c_char; -use std::sync::atomic::{AtomicBool, Ordering}; - -use crate::types::{DashSDKConfig, SDKHandle}; -use dash_spv_ffi::{FFIClientConfig, FFIDashSpvClient}; - -/// Static flag to track unified initialization -static UNIFIED_INITIALIZED: AtomicBool = AtomicBool::new(false); - -/// Unified SDK configuration combining both Core and Platform settings -#[repr(C)] -pub struct UnifiedSDKConfig { - /// Core SDK configuration (ignored if core feature disabled) - pub core_config: *const FFIClientConfig, - /// Platform SDK configuration - pub platform_config: DashSDKConfig, - /// Whether to enable cross-layer integration - pub enable_integration: bool, -} - -/// Unified SDK handle containing both Core and Platform SDKs -#[repr(C)] -pub struct UnifiedSDKHandle { - pub core_client: *mut FFIDashSpvClient, - pub platform_sdk: *mut SDKHandle, - pub integration_enabled: bool, -} - -/// Initialize the unified SDK system -/// This initializes both Core SDK (if enabled) and Platform SDK -#[no_mangle] -pub extern "C" fn dash_unified_sdk_init() -> i32 { - if UNIFIED_INITIALIZED.load(Ordering::Relaxed) { - return 0; // Already initialized - } - - // Initialize Core SDK if feature is enabled - #[cfg(feature = "core")] - { - let core_result = crate::core_sdk::dash_core_sdk_init(); - if core_result != 0 { - return core_result; - } - } - - // Initialize Platform SDK - crate::dash_sdk_init(); - - UNIFIED_INITIALIZED.store(true, Ordering::Relaxed); - 0 -} - -/// Create a unified SDK handle with both Core and Platform SDKs -/// -/// # Safety -/// - `config` must point to a valid UnifiedSDKConfig structure -#[no_mangle] -pub unsafe extern "C" fn dash_unified_sdk_create( - config: *const UnifiedSDKConfig, -) -> *mut UnifiedSDKHandle { - if config.is_null() { - return std::ptr::null_mut(); - } - - let config = &*config; - - // Create Core SDK client (always enabled in unified SDK) - let core_client = dash_spv_ffi::dash_spv_ffi_client_new(config.core_config); - - // Create Platform SDK - let platform_sdk_result = crate::dash_sdk_create(&config.platform_config); - if platform_sdk_result.data.is_null() { - // Clean up core client if it was created - #[cfg(feature = "core")] - if !core_client.is_null() { - crate::core_sdk::dash_core_sdk_destroy_client(core_client); - } - return std::ptr::null_mut(); - } - - // Create unified handle - let unified_handle = Box::new(UnifiedSDKHandle { - core_client, - platform_sdk: platform_sdk_result.data as *mut SDKHandle, - integration_enabled: config.enable_integration, - }); - - Box::into_raw(unified_handle) -} - -/// Destroy a unified SDK handle -/// -/// # Safety -/// - `handle` must be a valid unified SDK handle or null -#[no_mangle] -pub unsafe extern "C" fn dash_unified_sdk_destroy(handle: *mut UnifiedSDKHandle) { - if handle.is_null() { - return; - } - - let handle = Box::from_raw(handle); - - // Destroy Core SDK client - #[cfg(feature = "core")] - if !handle.core_client.is_null() { - crate::core_sdk::dash_core_sdk_destroy_client(handle.core_client); - } - - // Destroy Platform SDK - if !handle.platform_sdk.is_null() { - crate::dash_sdk_destroy(handle.platform_sdk); - } -} - -/// Start both Core and Platform SDKs -/// -/// # Safety -/// - `handle` must be a valid unified SDK handle -#[no_mangle] -pub unsafe extern "C" fn dash_unified_sdk_start(handle: *mut UnifiedSDKHandle) -> i32 { - if handle.is_null() { - return -1; - } - - #[cfg(feature = "core")] - let handle = &*handle; - - // Start Core SDK if available - #[cfg(feature = "core")] - if !handle.core_client.is_null() { - let core_result = crate::core_sdk::dash_core_sdk_start(handle.core_client); - if core_result != 0 { - return core_result; - } - } - - // Platform SDK doesn't have a separate start function currently - // It's started when needed for operations - - 0 -} - -/// Stop both Core and Platform SDKs -/// -/// # Safety -/// - `handle` must be a valid unified SDK handle -#[no_mangle] -pub unsafe extern "C" fn dash_unified_sdk_stop(handle: *mut UnifiedSDKHandle) -> i32 { - if handle.is_null() { - return -1; - } - - #[cfg(feature = "core")] - let handle = &*handle; - - // Stop Core SDK if available - #[cfg(feature = "core")] - if !handle.core_client.is_null() { - let core_result = crate::core_sdk::dash_core_sdk_stop(handle.core_client); - if core_result != 0 { - return core_result; - } - } - - // Platform SDK doesn't have a separate stop function currently - - 0 -} - -/// Get the Core SDK client from a unified handle -/// -/// # Safety -/// - `handle` must be a valid unified SDK handle -#[no_mangle] -pub unsafe extern "C" fn dash_unified_sdk_get_core_client( - handle: *mut UnifiedSDKHandle, -) -> *mut FFIDashSpvClient { - if handle.is_null() { - return std::ptr::null_mut(); - } - - let handle = &*handle; - handle.core_client -} - -/// Get the Platform SDK from a unified handle -/// -/// # Safety -/// - `handle` must be a valid unified SDK handle -#[no_mangle] -pub unsafe extern "C" fn dash_unified_sdk_get_platform_sdk( - handle: *mut UnifiedSDKHandle, -) -> *mut SDKHandle { - if handle.is_null() { - return std::ptr::null_mut(); - } - - let handle = &*handle; - handle.platform_sdk -} - -/// Check if integration is enabled for this unified SDK -/// -/// # Safety -/// - `handle` must be a valid unified SDK handle -#[no_mangle] -pub unsafe extern "C" fn dash_unified_sdk_is_integration_enabled( - handle: *mut UnifiedSDKHandle, -) -> bool { - if handle.is_null() { - return false; - } - - let handle = &*handle; - handle.integration_enabled -} - -/// Check if Core SDK is available in this unified SDK -/// -/// # Safety -/// - `handle` must be a valid unified SDK handle -#[no_mangle] -pub unsafe extern "C" fn dash_unified_sdk_has_core_sdk(handle: *mut UnifiedSDKHandle) -> bool { - if handle.is_null() { - return false; - } - - #[cfg(feature = "core")] - { - let handle = &*handle; - !handle.core_client.is_null() - } - #[cfg(not(feature = "core"))] - { - false - } -} - -/// Register Core SDK with Platform SDK for context provider callbacks -/// This enables Platform SDK to query Core SDK for blockchain state -/// -/// # Safety -/// - `handle` must be a valid unified SDK handle -#[no_mangle] -pub unsafe extern "C" fn dash_unified_sdk_register_core_context( - handle: *mut UnifiedSDKHandle, -) -> i32 { - if handle.is_null() { - return -1; - } - - let handle = &*handle; - - if handle.core_client.is_null() || handle.platform_sdk.is_null() { - return -1; - } - - // Register Core SDK as context provider for Platform SDK - // This would involve setting up the callback functions - // Implementation depends on the specific context provider mechanism - - // For now, return success - actual implementation would register callbacks - 0 -} - -/// Get combined status of both SDKs -/// -/// # Safety -/// - `handle` must be a valid unified SDK handle -/// - `core_height` must point to a valid u32 (set to 0 if core disabled) -/// - `platform_ready` must point to a valid bool -#[no_mangle] -pub unsafe extern "C" fn dash_unified_sdk_get_status( - handle: *mut UnifiedSDKHandle, - core_height: *mut u32, - platform_ready: *mut bool, -) -> i32 { - if handle.is_null() || core_height.is_null() || platform_ready.is_null() { - return -1; - } - - let handle = &*handle; - - // Get Core SDK height - #[cfg(feature = "core")] - if !handle.core_client.is_null() { - let result = - crate::core_sdk::dash_core_sdk_get_block_height(handle.core_client, core_height); - if result != 0 { - *core_height = 0; - } - } else { - *core_height = 0; - } - - #[cfg(not(feature = "core"))] - { - *core_height = 0; - } - - // Check Platform SDK readiness (simplified) - *platform_ready = !handle.platform_sdk.is_null(); - - 0 -} - -/// Get unified SDK version information -#[no_mangle] -pub extern "C" fn dash_unified_sdk_version() -> *const c_char { - #[cfg(feature = "core")] - const VERSION_INFO: &str = concat!("unified-", env!("CARGO_PKG_VERSION"), "+core\0"); - - #[cfg(not(feature = "core"))] - const VERSION_INFO: &str = concat!("unified-", env!("CARGO_PKG_VERSION"), "+platform-only\0"); - VERSION_INFO.as_ptr() as *const c_char -} - -/// Check if unified SDK was compiled with core support -#[no_mangle] -pub extern "C" fn dash_unified_sdk_has_core_support() -> bool { - #[cfg(feature = "core")] - { - true - } - #[cfg(not(feature = "core"))] - { - false - } -} - -#[cfg(test)] -mod tests { - use super::*; - - use std::ptr; - - /// Test the basic lifecycle of the unified SDK with core feature enabled - #[test] - #[cfg(feature = "core")] - fn test_unified_sdk_lifecycle() { - // Initialize the unified SDK system - let init_result = dash_unified_sdk_init(); - assert_eq!(init_result, 0, "Failed to initialize unified SDK"); - - // Create a testnet configuration for the unified SDK - let platform_config = DashSDKConfig { - network: DashSDKNetwork::SDKTestnet, - dapi_addresses: ptr::null(), // Use mock SDK - skip_asset_lock_proof_verification: true, - request_retry_count: 3, - request_timeout_ms: 30000, - }; - - // Step 1: Call dash_spv_ffi_config_testnet() to get a pointer to the FFI config object - let core_config_ptr = dash_spv_ffi::dash_spv_ffi_config_testnet(); - assert!(!core_config_ptr.is_null(), "Failed to create core config"); - - // Step 2: Create the UnifiedSDKConfig using the pointer - let unified_config = UnifiedSDKConfig { - core_config: core_config_ptr, - platform_config, - enable_integration: true, - }; - - // Step 3: Proceed with the test by passing a reference to dash_unified_sdk_create() - let handle = unsafe { dash_unified_sdk_create(&unified_config) }; - assert!(!handle.is_null(), "Failed to create unified SDK handle"); - - // Verify that the core client is available when core feature is enabled - let core_client = unsafe { dash_unified_sdk_get_core_client(handle) }; - assert!( - !core_client.is_null(), - "Core client should not be null when core feature is enabled" - ); - - // Verify that the platform SDK is available - let platform_sdk = unsafe { dash_unified_sdk_get_platform_sdk(handle) }; - assert!(!platform_sdk.is_null(), "Platform SDK should not be null"); - - // Verify integration status - let integration_enabled = unsafe { dash_unified_sdk_is_integration_enabled(handle) }; - assert!(integration_enabled, "Integration should be enabled"); - - // Verify core support - let has_core = unsafe { dash_unified_sdk_has_core_sdk(handle) }; - assert!( - has_core, - "Should have core SDK when core feature is enabled" - ); - - // Clean up the handle - unsafe { dash_unified_sdk_destroy(handle) }; - - // Clean up the config pointer - unsafe { dash_spv_ffi::dash_spv_ffi_config_destroy(core_config_ptr) }; - } - - /// Test that unified SDK functions handle null pointers gracefully - #[test] - fn test_unified_sdk_null_handling() { - // Test that destroy function handles null pointer - unsafe { dash_unified_sdk_destroy(ptr::null_mut()) }; - - // Test that get functions return null for null input - #[cfg(feature = "core")] - { - let core_client = unsafe { dash_unified_sdk_get_core_client(ptr::null_mut()) }; - assert!(core_client.is_null(), "Should return null for null input"); - } - - let platform_sdk = unsafe { dash_unified_sdk_get_platform_sdk(ptr::null_mut()) }; - assert!(platform_sdk.is_null(), "Should return null for null input"); - - // Test that status functions handle null input - let integration_enabled = - unsafe { dash_unified_sdk_is_integration_enabled(ptr::null_mut()) }; - assert!(!integration_enabled, "Should return false for null input"); - - let has_core = unsafe { dash_unified_sdk_has_core_sdk(ptr::null_mut()) }; - assert!(!has_core, "Should return false for null input"); - } - - /// Test unified SDK version information - #[test] - fn test_unified_sdk_version() { - let version = dash_unified_sdk_version(); - assert!(!version.is_null(), "Version string should not be null"); - - // Convert to Rust string to verify it's valid - let version_str = unsafe { - std::ffi::CStr::from_ptr(version) - .to_str() - .expect("Version should be valid UTF-8") - }; - - assert!( - version_str.starts_with("unified-"), - "Version should start with 'unified-'" - ); - - #[cfg(feature = "core")] - assert!( - version_str.contains("+core"), - "Version should contain '+core' when core feature is enabled" - ); - - #[cfg(not(feature = "core"))] - assert!( - version_str.contains("+platform-only"), - "Version should contain '+platform-only' when core feature is disabled" - ); - } - - /// Test unified SDK core support detection - #[test] - fn test_unified_sdk_core_support() { - let has_core_support = dash_unified_sdk_has_core_support(); - - #[cfg(feature = "core")] - assert!( - has_core_support, - "Should report core support when core feature is enabled" - ); - - #[cfg(not(feature = "core"))] - assert!( - !has_core_support, - "Should not report core support when core feature is disabled" - ); - } -} diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swift b/packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swift index a33193153b2..f2e2614e5c5 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swift @@ -16,10 +16,7 @@ import Foundation /// ensure is unlocked by freeing the pointer, FFI limitation /// - Clearing the storage stops the SPVClient, a new one has to be created, FFI limitation class SPVClient: @unchecked Sendable { - private var progressUpdateEventHandler: SPVProgressUpdateEventHandler? - private var syncEventsHandler: SPVSyncEventsHandler? - private var networkEventsHandler: SPVNetworkEventsHandler? - private var walletEventsHandler: SPVWalletEventsHandler? + private var spvEventHandlers: SPVEventHandlers? // FFI handles private var client: UnsafeMutablePointer? @@ -34,7 +31,7 @@ class SPVClient: @unchecked Sendable { return false }() - init(network: Network = DashSDKNetwork(rawValue: 1), dataDir: String?, startHeight: UInt32) throws { + init(network: Network = DashSDKNetwork(rawValue: 1), dataDir: String?, startHeight: UInt32, eventHandlers: SPVEventHandlers) throws { if swiftLoggingEnabled { let level = (ProcessInfo.processInfo.environment["SPV_LOG"] ?? "off") print("[SPV][Log] Initialized SPV logging level=\(level)") @@ -118,8 +115,12 @@ class SPVClient: @unchecked Sendable { _ = dash_spv_ffi_config_set_start_from_height(configPtr, startHeight) + // Convert event handlers to FFI callbacks + self.spvEventHandlers = eventHandlers + let ffiEventCallbacks = eventHandlers.intoFFIEventCallbacks() + // Create client - let client = dash_spv_ffi_client_new(configPtr) + let client = dash_spv_ffi_client_new(configPtr, ffiEventCallbacks) guard let client = client else { print("[SPV][Init] Failed to create client: \(SPVClient.getLastDashFFIError())") throw SPVError.initializationFailed @@ -159,88 +160,6 @@ class SPVClient: @unchecked Sendable { return String(cString: errorMsg) } - // MARK: - Event Handlers operations - - func setProgressUpdateEventHandler(_ handler: SPVProgressUpdateEventHandler) { - progressUpdateEventHandler = handler - - let result = dash_spv_ffi_client_set_progress_callback( - client, - handler.intoFFIProgressCallback() - ) - - assert(result == 0, "It should only fail if the client is nil, but client is not nil") - - // We dont receive an initial progress update from the client - // so we trigger one manually here - handler.onProgressUpdate(getSyncProgress()) - } - - func clearProgressUpdateEventHandler() { - progressUpdateEventHandler = nil - - let result = dash_spv_ffi_client_clear_progress_callback(client) - - assert(result == 0, "It should only fail if the client is nil, but client is not nil") - } - - func setSyncEventsHandler(_ handler: SPVSyncEventsHandler) { - syncEventsHandler = handler - - let result = dash_spv_ffi_client_set_sync_event_callbacks( - client, - handler.intoFFISyncEventCallbacks() - ) - - assert(result == 0, "It should only fail if the client is nil, but client is not nil") - } - - func clearSyncEventsHandler() { - syncEventsHandler = nil - - let result = dash_spv_ffi_client_clear_sync_event_callbacks(client) - - assert(result == 0, "It should only fail if the client is nil, but client is not nil") - } - - func setNetworkEventsHandler(_ handler: SPVNetworkEventsHandler) { - networkEventsHandler = handler - - let result = dash_spv_ffi_client_set_network_event_callbacks( - client, - handler.intoFFINetworkEventCallbacks() - ) - - assert(result == 0, "It should only fail if the client is nil, but client is not nil") - } - - func clearNetworkEventsHandler() { - networkEventsHandler = nil - - let result = dash_spv_ffi_client_clear_network_event_callbacks(client) - - assert(result == 0, "It should only fail if the client is nil, but client is not nil") - } - - func setWalletEventsHandler(_ handler: SPVWalletEventsHandler) { - walletEventsHandler = handler - - let result = dash_spv_ffi_client_set_wallet_event_callbacks( - client, - handler.intoFFIWalletEventCallbacks() - ) - - assert(result == 0, "It should only fail if the client is nil, but client is not nil") - } - - func clearWalletEventsHandler() { - walletEventsHandler = nil - - let result = dash_spv_ffi_client_clear_wallet_event_callbacks(client) - - assert(result == 0, "It should only fail if the client is nil, but client is not nil") - } - /// Enable/disable masternode sync. If the client is running, apply the update immediately. func setMasternodeSyncEnabled(_ enabled: Bool) throws { var rc = dash_spv_ffi_config_set_masternode_sync_enabled(config, enabled) @@ -260,13 +179,13 @@ class SPVClient: @unchecked Sendable { // TODO: // Manually calling the event doesn't look like the right approach, // if FFISPVClient could send us an event callback automatically... - progressUpdateEventHandler?.onProgressUpdate(getSyncProgress()) + spvEventHandlers?.progress.onProgressUpdate(getSyncProgress()) } func destroy() { dash_spv_ffi_client_destroy(client) dash_spv_ffi_config_destroy(config) - + client = nil config = nil } diff --git a/packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVEventHandler.swift b/packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVEventHandler.swift index e1e8e1fe64b..3bf53c8db2c 100644 --- a/packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVEventHandler.swift +++ b/packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVEventHandler.swift @@ -36,6 +36,48 @@ private typealias Byte96 = ( UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8 ) +// MARK: - SPV Event Handlers + +struct SPVEventHandlers { + let progress: SPVProgressUpdateEventHandler + let sync: SPVSyncEventsHandler + let network: SPVNetworkEventsHandler + let wallet: SPVWalletEventsHandler + let error: SPVClientErrorEventsHandler + + init( + _ progress: SPVProgressUpdateEventHandler, + _ sync: SPVSyncEventsHandler, + _ network: SPVNetworkEventsHandler, + _ wallet: SPVWalletEventsHandler, + _ error: SPVClientErrorEventsHandler + ) { + self.progress = progress + self.sync = sync + self.network = network + self.wallet = wallet + self.error = error + } + + init() { + self.progress = DummySPVProgressUpdateEventHandler() + self.sync = DummySPVSyncEventsHandler() + self.network = DummySPVNetworkEventsHandler() + self.wallet = DummySPVWalletEventsHandler() + self.error = DummySPVClientErrorEventsHandler() + } + + func intoFFIEventCallbacks() -> FFIEventCallbacks { + return FFIEventCallbacks( + sync: self.sync.intoFFISyncEventCallbacks(), + network: self.network.intoFFINetworkEventCallbacks(), + progress: self.progress.intoFFIProgressCallback(), + wallet: self.wallet.intoFFIWalletEventCallbacks(), + error: self.error.intoFFIClientErrorCallback(), + ) + } +} + // MARK: - Progress callback protocol SPVProgressUpdateEventHandler: AnyObject { @@ -219,6 +261,8 @@ private func onSpvBlockProcessedCallbackC( height: UInt32, hashPtr: UnsafePointer?, newAddressCount: UInt32, + confirmedTxids: UnsafePointer?, + confirmedTxidCount: UInt32, userData: UnsafeMutableRawPointer? ) { let hash = bytePtrIntoData(hashPtr, 32) @@ -419,6 +463,7 @@ extension SPVWalletEventsHandler { func intoFFIWalletEventCallbacks() -> FFIWalletEventCallbacks { FFIWalletEventCallbacks( on_transaction_received: onSpvTransactionReceivedCallbackC, + on_transaction_status_changed: nil, on_balance_updated: onSpvBalanceUpdatedCallbackC, user_data: Unmanaged.passUnretained(self).toOpaque() ) @@ -427,6 +472,7 @@ extension SPVWalletEventsHandler { private func onSpvTransactionReceivedCallbackC( walletIdPtr: UnsafePointer?, + status: FFITransactionContext, accountIndex: UInt32, txidPtr: UnsafePointer?, amount: Int64, @@ -514,6 +560,57 @@ private final class DummySPVWalletEventsHandler: SPVWalletEventsHandler { } } +// MARK: - Client error events callbacks + +protocol SPVClientErrorEventsHandler: AnyObject { + func onClientError(_ error: String); +} + +extension SPVClientErrorEventsHandler { + func intoFFIClientErrorCallback() -> FFIClientErrorCallback { + FFIClientErrorCallback( + on_error: onSpvClientErrorCallbackC, + user_data: Unmanaged.passUnretained(self).toOpaque() + ) + } +} + +private func onSpvClientErrorCallbackC( + errorPtr: UnsafePointer?, + userData: UnsafeMutableRawPointer? +) { + let handler = rawPtrIntoSpvClientErrorEventsHandler(userData) + + guard let errorPtr else { + assertionFailure("ClientError address pointer is nil") + return + } + + let error = String(cString: errorPtr) + handler.onClientError(error) +} + +private func rawPtrIntoSpvClientErrorEventsHandler( + _ ptr: UnsafeMutableRawPointer? +) -> any SPVClientErrorEventsHandler { + guard let ptr else { + assertionFailure("SPVClientErrorEventsHandler pointer is nil!") + return DummySPVClientErrorEventsHandler() + } + + return Unmanaged + .fromOpaque(ptr) + .takeUnretainedValue() as! any SPVClientErrorEventsHandler +} + +private final class DummySPVClientErrorEventsHandler: SPVClientErrorEventsHandler { + func onClientError(_: String) {} + + func intoFFIClientErrorCallback() -> FFIClientErrorCallback { + .init() + } +} + // MARK: - Helpers private func bytePtrIntoData(_ ptr: UnsafeRawPointer?, _: Int) -> Data { @@ -545,4 +642,4 @@ public func ffiSyncProgressPtrIntoSpvSyncProgress(_ ptr: UnsafePointer