Skip to content
Merged
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
1 change: 0 additions & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions packages/kotlin-sdk/BUILD_GUIDE_FOR_AI.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ schema-hash crash at app start on devices with old data.

## Architecture Notes

- One JNI library: `rs-unified-sdk-jni` links `rs-sdk-ffi`,
`platform-wallet-ffi`, and `key-wallet-ffi` as **rlibs** — FFI structs
- One JNI library: `rs-unified-sdk-jni` links `rs-sdk-ffi` and
`platform-wallet-ffi` as **rlibs** — FFI structs
never cross JNI by value. Errors become
`org.dashfoundation.dashsdk.ffi.DashSDKException(code, message)`;
every export is panic-guarded.
Expand Down
2 changes: 1 addition & 1 deletion packages/kotlin-sdk/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ file too; the architectural rules are identical.
response to Rust state (via the persistence callback bridge).
2. **Load data** — expose Room `Flow` queries for reactive UI updates.
3. **Bridge** — thin JNI wrappers around functions defined in the Rust
libraries (`rs-sdk-ffi`, `platform-wallet-ffi`, `key-wallet-ffi`).
libraries (`rs-sdk-ffi`, `platform-wallet-ffi`).

## Forbidden in Kotlin (belongs in Rust `platform-wallet`)

Expand Down
2 changes: 1 addition & 1 deletion packages/kotlin-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ kotlin-sdk/
```

The native layer is [`packages/rs-unified-sdk-jni`](../rs-unified-sdk-jni), a Rust JNI shim
over `rs-sdk-ffi`, `platform-wallet-ffi` and `key-wallet-ffi`. There is no C
over `rs-sdk-ffi` and `platform-wallet-ffi`. There is no C
glue and no generated headers on Android — the shim calls the FFI crates as
ordinary Rust dependencies and exposes JNI symbols directly.

Expand Down
2 changes: 1 addition & 1 deletion packages/kotlin-sdk/build_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Build libdash_sdk_jni.so for Android — the analog of ../swift-sdk/build_ios.sh.
#
# Produces one cdylib per ABI containing the JNI exports of rs-unified-sdk-jni plus
# the C ABI of rs-sdk-ffi / platform-wallet-ffi / key-wallet-ffi (linked in
# the C ABI of rs-sdk-ffi / platform-wallet-ffi (linked in
# as rlibs), and drops them into sdk/src/main/jniLibs/<abi>/ where AGP
# packages them.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ internal object MnemonicNative {
external fun destroyResolver(handle: Long)

/**
* Generate a BIP-39 mnemonic (key-wallet-ffi). wordCount ∈ {12,15,18,21,24};
* language is the FFILanguage ordinal (0 = English).
* Generate a BIP-39 mnemonic (platform-wallet-ffi). wordCount ∈ {12,15,18,21,24};
* language is the FFIMnemonicLanguage ordinal (0 = English).
* @throws DashSDKException on failure
*/
external fun generateMnemonic(wordCount: Int, language: Int): String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ package org.dashfoundation.dashsdk.ffi
internal object TxDecodeNative {

/**
* Consensus-decode raw transaction bytes (key-wallet-ffi
* `transaction_decode`) into the packed big-endian BLOB documented in
* Consensus-decode raw transaction bytes (platform-wallet-ffi
* `platform_wallet_transaction_decode`) into the packed big-endian BLOB documented in
* `tx_decode.rs` / parsed by
* [org.dashfoundation.dashsdk.keywallet.TransactionDecoder.parseBlob].
* [networkOrd] is [org.dashfoundation.dashsdk.Network.ffiValue].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@ import org.dashfoundation.dashsdk.ffi.MnemonicNative

/**
* BIP-39 mnemonic operations — port of `SwiftDashSDK/KeyWallet/Mnemonic.swift`.
* Generation runs entirely in Rust (key-wallet-ffi); the phrase transits
* Generation runs entirely in Rust (platform-wallet-ffi); the phrase transits
* Kotlin only to be shown for backup and stored encrypted.
*/
object Mnemonic {

/** Mirror of the iOS `MnemonicLanguage` enum (FFILanguage ordinals). */
/** Mirror of the iOS `MnemonicLanguage` enum (FFIMnemonicLanguage ordinals). */
enum class Language(val ffiValue: Int) {
ENGLISH(0),
CHINESE_SIMPLIFIED(1),
CHINESE_TRADITIONAL(2),
CZECH(3),
FRENCH(4),
ITALIAN(5),
JAPANESE(6),
KOREAN(7),
PORTUGUESE(8),
SPANISH(9),
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.dashfoundation.dashsdk.ffi.TxDecodeNative
* A consensus-decoded Dash transaction: per-output `(address, value,
* script)` plus per-input previous outpoints with a best-effort P2PKH
* sender address — port of `SwiftDashSDK/KeyWallet/TransactionDecoder.swift`
* (platform PR #3981) over key-wallet-ffi's `transaction_decode`.
* (platform PR #3981) over platform-wallet-ffi's `platform_wallet_transaction_decode`.
*
* Wallet persistence stores every transaction's raw bytes
* (`TransactionEntity.transactionData`) but only materializes TXO rows for
Expand Down Expand Up @@ -88,8 +88,8 @@ class DecodedTransaction(
}

/**
* Pure utility — decodes raw transaction bytes via key-wallet-ffi's
* `transaction_decode`. No wallet handle or state involved.
* Pure utility — decodes raw transaction bytes via platform-wallet-ffi's
* `platform_wallet_transaction_decode`. No wallet handle or state involved.
*/
object TransactionDecoder {

Expand All @@ -99,7 +99,7 @@ object TransactionDecoder {
* @param txData serialized transaction bytes (e.g. a persisted
* `TransactionEntity.transactionData`).
* @param network network used to render addresses (base58 version bytes).
* @throws org.dashfoundation.dashsdk.errors.DashSdkError.InvalidParameter
* @throws org.dashfoundation.dashsdk.errors.DashSdkError.PlatformWallet
* for malformed or empty bytes (including trailing garbage).
*/
fun decode(txData: ByteArray, network: Network): DecodedTransaction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ class PlatformWalletPersistenceHandler(
/**
* Where the sweep pass gets a stored loser's input outpoints (the
* outpoint-keyed hold, see `applySweptTransactions`). The production
* default decodes the stored consensus bytes through key-wallet-ffi's
* `transaction_decode`; tests inject a fake keyed by txid, since the
* default decodes the stored consensus bytes through platform-wallet-ffi's
* `platform_wallet_transaction_decode`; tests inject a fake keyed by txid, since the
* native library is not loadable under Robolectric.
*/
private val storedTransactionInputs: StoredTransactionInputs =
Expand Down Expand Up @@ -4265,8 +4265,8 @@ fun interface StoredTransactionInputs {
}

/**
* Production [StoredTransactionInputs]: key-wallet-ffi's
* `transaction_decode` through [org.dashfoundation.dashsdk.keywallet.TransactionDecoder].
* Production [StoredTransactionInputs]: platform-wallet-ffi's
* `platform_wallet_transaction_decode` through [org.dashfoundation.dashsdk.keywallet.TransactionDecoder].
* The decoder is a stateless marshaler — it takes no wallet-manager lock —
* so calling it from inside a persistence callback (which runs while Rust
* holds that lock) cannot deadlock; the "no native calls under
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class PlatformWalletPersistenceHandlerTest {
/**
* What the sweep pass "decodes" from a stored record's bytes, keyed by
* txid. Every fixture records transactions with dummy bytes
* (`ByteArray(10) { 5 }`) that key-wallet-ffi could never decode, and
* (`ByteArray(10) { 5 }`) that the native decoder could never decode, and
* the native decoder is not loadable under Robolectric anyway, so
* [recordTransaction] registers each record's `inputOutpoints` here and
* [storedInputs] hands them back. A txid never registered throws, as
Expand Down
6 changes: 6 additions & 0 deletions packages/rs-platform-wallet-ffi/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ cpp_compat = true
documentation = true
documentation_style = "c99"

[export]
# Not a parameter type, which cbindgen would require to emit it: the
# mnemonic functions take the language as a plain integer. Exported for the
# value list.
include = ["FFIMnemonicLanguage"]

[fn]
args = "horizontal"
rename_args = "snake_case"
Expand Down
Loading
Loading