| Filename | Latest commit message | Latest commit date |
|---|---|---|
`get_balance` carries two numbers and the wallet screen only showed one:
`Node::wallet_balance_line` now reads both out of a single answer
(`balance {total} XMR · unlocked {unlocked} XMR`, the `balance 0 XMR` prefix
kept, total-only when the RPC reports no unlocked half), and
`Node::wallet_unlocked_balance` reports the unlocked half on its own with
`wallet_balance`'s `off` / `err` sentinels. `wallet_balance` keeps its shape.
`get_transfers` sends `out: true` and parses the `out` bucket, so `TransferRow`
carries `direction` (`in`, `out`, `pending`; a pending item's own `type` wins)
and the screen can tell a spent transfer from a received one.
`Wallet::restore_wallet` / `Node::wallet_restore` take an optional
`restore_height` beside the seed offset: blank omits the field, a typed `0` is
sent as `0`, `Some(n)` is a JSON number, and a non-numeric height is a local
refusal (`restore height must be a block number`). A height after the first
receive hides the older funds and this version has no rescan — the TUI says so
on its own step, whose footer is not the offset's.
`Node::wallet_send` spends to a pasted address: `check_address`, then
`xmr_to_atomic`, then `Wallet::transfer` — no friend, no `tip` frame, no chat
line, no payment row. The outgoing transfer list is the record. `pay::check_address`
and `Wallet::transfer` own the gates, so a view-only or unsynced refusal is the
string they already return.
`Wallet::import_view_only` / `Node::wallet_import_view_only` watch an address
through `generate_from_keys` with no `spendkey` in the request at all: same
filename/password refusals, `check_address`, a 64-hex view key or a local
refusal, no 64th catalogue column. The view key is typed into a hidden entry
(twice), is never sealed, never logged and never on an argv, and the screen
wipes it on every exit.
TUI: `n` sends (address, amount, then `SEND`; Esc spends nothing), `y` copies
the receive address over OSC 52, `v` imports a view-only wallet (no seed, so no
`SEEN` gate), and the seed import gained a `restore height` step between the
offset and the file passphrase. The wallet footer and its help line carry the
new keys and keep every old token. The F6 body renders in the flexible region —
a bordered block in the two-row slot it used drew its borders and clipped the
whole body, address and balance line included.
SDK: `wallet_unlocked_balance`, `wallet_send`, `wallet_view_only`,
`import_seed(password, seed, offset, height)` and
`import_view_only(password, address, view_key, height)`, plus
`TransferRow.direction`. `wallet_balance`, `import_wallet` and
`import_wallet_with_offset` are untouched.
Docs: WALLET (unlocked vs total, restore height, outgoing rows, local send,
view-only import), THREAT_MODEL (a view key entered at import is a secret and a
view-only file is not a spend authority), TUI (footer + the new keys and steps),
README (one sentence).
Tests: recorded-request cases in `tests/wallet.rs` (height as a number and
omitted when blank, `generate_from_keys` carries the view key and no spendkey,
`get_transfers` asks for `out`, `wallet_send` reaches `transfer` and never
`tip`, a bad view key never dials), node-level line/unlocked pairs from one
dial, and TUI step tests for the send, copy, height and view-only flows.
No new crate, no Cargo change, no android/ change.
|
||
| .. | ||
| src | ||
| tests | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
| uniffi.toml | ||
onionwire-sdk (Android)
Kotlin-facing UniFFI bindings over the same Rust crate the OnionWire Linux TUI runs on. An Android peer and a Linux peer that exchange invites interoperate — there is one protocol, not two.
This is not a WebView wrapper and not a client for a hosted service.
Each install runs Arti in-process (arti-client 0.46, onion-service-client +
onion-service-service), hosts its own v3 onion service, and dials friends'
onions directly. There is no tor binary, no torrc, no Orbot as the pipe.
Locked protocol facts
| Piece | Rule |
|---|---|
| Identity | ed25519 keypair. The pubkey is who you are. |
| Roster key | friends.pubkey, UNIQUE. Petnames are local only. |
| Onion | A locator, not an identity. It rotates. |
| Invite | onionwire:v1:k=…:o=…:spk=…:sig=… |
| Crypto | Noise IK (Noise_IK_25519_ChaChaPoly_BLAKE2s). spk is x25519. |
| Chat send | Unreachable peer onion → the message goes to the local outbox and is retried with backoff. send() returns SendState.Sent or SendState.Queued. File transfer and payments stay fail-closed. |
| At rest | The whole sqlite file is SQLCipher (key = Argon2id of the store passphrase), and chat bodies carry a second per-row ChaCha20-Poly1305 layer with row-bound AAD. Identity keys live in that same encrypted file. |
Invite string
onionwire:v1:k=<ed25519 pubkey hex64>:o=<v3 onion address>:spk=<x25519 prekey hex64>:sig=<ed25519 sig hex128>
sigis ed25519 overonionwire-invite-v1+0x00-separatedk,o,spk(hex/onion as they appear in the string). Decode still accepts the legacy raw concatenation so old invites verify. See docs/PROTOCOL.md.- A malformed, unsigned, or tampered invite is rejected before anything is stored.
- Same
knever creates a second friend. It updates the stored locator on the existing row. That is the whole point of keying the roster on the pubkey. - The invite carries no display name and no Monero address — those arrive later
over the wire as signed
prfframes, not through the invite.
Adding the AAR to another Android app
The SDK ships as onionwire-sdk-<version>.aar on the Forgejo release, with a
matching .sha256.
// settings.gradle.kts
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
flatDir { dirs("libs") } // or however you vendor the AAR
}
}
// app/build.gradle.kts
dependencies {
implementation(files("libs/onionwire-sdk-0.1.0.aar"))
}
Requirements:
minSdk >= 26. The AAR is built with the NDK againstandroid-26.abiFiltersmust include an ABI the AAR ships. The release AAR includesarm64-v8a. Addx86_64at build time with-Ponionwire.abis=arm64-v8a,x86_64if you need an emulator.- Keep
uniffi.onionwire_sdk.**(see the AAR'sconsumer-rules.pro, applied automatically by AGP) if you enable R8.
Kotlin surface
Everything is a suspend fun — Arti bootstrap and onion publish take minutes.
A send that cannot reach the peer comes back immediately as QUEUED (it is not
a long retry inside the call): the message is stored locally and a background
worker in the core keeps retrying it.
import uniffi.onionwire_sdk.*
// 1. Open (or create) the identity inside app-private storage.
// `filesDir`, never external storage. Empty passphrase fails closed.
val wire: Wire = openWire(File(context.filesDir, "onionwire").absolutePath, passphrase)
// 2. Who you are, and where you are right now.
val fingerprint: String = wire.fingerprint() // stable forever
val onion: String = wire.onion() // changes on rotate
// 3. Invite out / invite in.
val mine: String = wire.invite()
val preview: InviteInfo = decodeInvite(pasted) // verifies sig, stores nothing
val friend: FriendInfo = wire.addFriend(pasted)
// 4. Roster and chat.
val roster: List<FriendInfo> = wire.friends()
wire.setPetname(friend.pubkeyHex, "ada")
when (wire.send(friend.pubkeyHex, "hello wire")) {
SendState.SENT -> { /* the peer's onion took the frame */ }
SendState.QUEUED -> { /* unreachable: stored in the local outbox and
retried in the background. Show it as pending —
it is local-only until a circuit takes it. */ }
}
val msgs: List<ChatMessage> = wire.messages(friend.pubkeyHex)
// msgs[i].direction == "out" -> msgs[i].delivery is "sent" | "queued" |
// "sending" | "failed: <reason>"; null for incoming messages. Render the
// queued and failed states distinctly from sent.
// 5. Locator rotation. Do NOT wire this to a single tap — the app that embeds
// the SDK owns the typed confirmation.
val out: RotateOutcome = wire.rotateOnion() // out.notified / out.friends
// 6. Saved wallets, and which one is open.
val wallets: List<WalletRow> = wire.wallets() // a store read: never dials
val active: String? = wire.activeWalletFilename() // the open file, or null
val open = wallets.firstOrNull { it.walletFilename == active }
wire.openWallet("onionwire-2") // may restart a running wallet child; a name
// outside the catalogue is refused
// A wallet child is up but its file is not open -> the child answers `-13 No
// wallet file` to every read. `walletStatus()` says which:
val st: WalletChildStatus = wire.walletStatus()
if (st.running && !st.walletOpen && st.needsPassphrase) {
val pass = askForTheWalletPassphrase() // your own input surface, echo off
wire.openWalletWithPassphrase(active!!, pass) // stored (sealed) on success;
// a refused passphrase is an
// error and is NOT stored
}
val keys: WalletKeys = wire.walletKeys() // the OPEN wallet's private keys
// keys.spendKey == null -> a view-only wallet (the RPC's -29 watch-only answer).
// That is not an error. The seed (`walletSeed()`) and these keys always belong
// to `activeWalletFilename()`: to show another wallet's backup, open it first.
// Both are spend secrets — show them from an explicit user action only, never
// log them, never persist them.
// 7. Your own profile (nickname, bio, Monero address).
val me: SelfProfile = wire.selfProfile()
wire.setSelfProfile("ada", "on the wire", "4AdUnd...") // validated on write
wire.pushSelfProfile(friend.pubkeyHex) // signed `prf`, one-shot and fail-closed
All peer references are lowercase hex strings so nothing Rust-shaped leaks into the AAR.
Building the bindings yourself
The Gradle task :sdk:uniffiBindgen runs, inside crates/onionwire-sdk:
cargo build --release --lib # host cdylib
cargo run --release --bin uniffi-bindgen -- generate \
--library target/release/libonionwire_sdk.so \
--language kotlin --out-dir <generated dir>
Do not hand-edit anything under android/sdk/build/generated/; it is a build
output.
Why this crate has its own Cargo workspace
Arti's TLS backends are non-additive: exactly one of native-tls and
rustls may be enabled in a given feature resolution. The root crate defaults
to rustls (Linux TUI and releases), so this crate does not differ from the
root on TLS; it does add static-sqlite, because Android has no system
libsqlite3. Two separate workspaces keep the two resolutions from colliding.