Skip to content

Commit be6c15e

Browse files
ovitrifclaude
andcommitted
refactor: remove app-side LDK APIs from VssClient
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 678ad54 commit be6c15e

22 files changed

Lines changed: 102 additions & 1165 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "vss-rust-client-ffi"
3-
version = "0.5.11"
3+
version = "0.5.12"
44
edition = "2021"
55
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
66

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import PackageDescription
55

6-
let tag = "v0.5.11"
7-
let checksum = "6960d9472fae6af19387e933574a2db3fec03dfb02f2015ce92d089fe8bfb3eb"
6+
let tag = "v0.5.12"
7+
let checksum = "e6068b6d3301af092a65a6f8f4571165b620655c88ba7e0ce3eb8c8dcc1b096e"
88
let url = "https://github.com/synonymdev/vss-rust-client-ffi/releases/download/\(tag)/VssRustClientFfi.xcframework.zip"
99

1010
let package = Package(

README.md

Lines changed: 96 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,43 @@ print("Deleted: \(wasDeleted)")
7878
vssShutdownClient()
7979
```
8080

81-
#### LDK-Specific Operations (Swift)
81+
#### Dedicated LDK Client (Swift)
8282

83-
For interacting with data stored by ldk-node (e.g., `network_graph`, `channel_manager`, `scorer`), use the LDK variants which derive the matching encryption and obfuscation keys:
83+
For fully isolated LDK operations with independent key derivation (full 64-byte BIP39 seed):
8484

8585
```swift
86-
// Delete an ldk-node key (e.g., stale network graph)
87-
let wasDeleted = try await vssDeleteLdk(key: "network_graph", namespace: .default)
86+
// Initialize the dedicated LDK client (separate from the app client)
87+
try await vssNewLdkClientWithLnurlAuth(
88+
baseUrl: "https://vss.example.com",
89+
storeId: storeId,
90+
mnemonic: mnemonic,
91+
passphrase: passphrase,
92+
lnurlAuthServerUrl: "https://auth.example.com/lnurl"
93+
)
8894

8995
// Read an ldk-node key
90-
if let item = try await vssGetLdk(key: "network_graph", namespace: .default) {
96+
if let item = try await vssLdkGet(key: "network_graph", namespace: .default) {
9197
print("Graph size: \(item.value.count) bytes")
9298
}
9399

94-
// List all ldk-node keys across all namespaces
95-
let allLdkKeys = try await vssListAllKeysLdk()
96-
for kv in allLdkKeys {
97-
print("LDK key: \(kv.key), Version: \(kv.version)")
98-
}
100+
// Store a key
101+
let item = try await vssLdkStore(
102+
key: "network_graph",
103+
value: graphData,
104+
namespace: .default
105+
)
99106

100-
// List ldk-node keys in a specific namespace
101-
let defaultKeys = try await vssListKeysLdk(namespace: .default)
107+
// Delete a key
108+
let wasDeleted = try await vssLdkDelete(key: "network_graph", namespace: .default)
109+
110+
// List keys in a namespace
111+
let keys = try await vssLdkListKeys(namespace: .monitors)
112+
113+
// List all keys across all namespaces
114+
let allKeys = try await vssLdkListAllKeys()
115+
116+
// Clean shutdown
117+
vssShutdownLdkClient()
102118
```
103119

104120
### Python
@@ -152,19 +168,35 @@ print(f"Deleted: {was_deleted}")
152168
vss_shutdown_client()
153169
```
154170

155-
#### LDK-Specific Operations (Python)
171+
#### Dedicated LDK Client (Python)
156172

157173
```python
158-
# Delete an ldk-node key
159-
was_deleted = await vss_delete_ldk("network_graph", LdkNamespace.DEFAULT)
174+
# Initialize the dedicated LDK client (separate from the app client)
175+
await vss_new_ldk_client_with_lnurl_auth(
176+
"https://vss.example.com",
177+
store_id,
178+
mnemonic,
179+
passphrase,
180+
"https://auth.example.com/lnurl"
181+
)
160182

161183
# Read an ldk-node key
162-
item = await vss_get_ldk("network_graph", LdkNamespace.DEFAULT)
184+
item = await vss_ldk_get("network_graph", LdkNamespace.DEFAULT)
185+
186+
# Store a key
187+
item = await vss_ldk_store("network_graph", graph_data, LdkNamespace.DEFAULT)
188+
189+
# Delete a key
190+
was_deleted = await vss_ldk_delete("network_graph", LdkNamespace.DEFAULT)
191+
192+
# List keys in a namespace
193+
keys = await vss_ldk_list_keys(LdkNamespace.MONITORS)
163194

164-
# List all ldk-node keys across all namespaces
165-
all_ldk_keys = await vss_list_all_keys_ldk()
166-
for kv in all_ldk_keys:
167-
print(f"LDK key: {kv.key}, Version: {kv.version}")
195+
# List all keys across all namespaces
196+
all_keys = await vss_ldk_list_all_keys()
197+
198+
# Clean shutdown
199+
vss_shutdown_ldk_client()
168200
```
169201

170202
### Kotlin (Android)
@@ -211,22 +243,40 @@ items.forEach { item ->
211243
vssShutdownClient()
212244
```
213245

214-
#### LDK-Specific Operations (Kotlin)
246+
#### Dedicated LDK Client (Kotlin)
215247

216248
```kotlin
217-
// Delete an ldk-node key (e.g., stale network graph)
218-
val wasDeleted = vssDeleteLdk(key = "network_graph", namespace = LdkNamespace.Default)
249+
// Initialize the dedicated LDK client (separate from the app client)
250+
vssNewLdkClientWithLnurlAuth(
251+
baseUrl = "https://vss.example.com",
252+
storeId = storeId,
253+
mnemonic = mnemonic,
254+
passphrase = passphrase,
255+
lnurlAuthServerUrl = "https://auth.example.com/lnurl"
256+
)
219257

220258
// Read an ldk-node key
221-
val graph = vssGetLdk(key = "network_graph", namespace = LdkNamespace.Default)
222-
graph?.let { println("Graph size: ${it.value.size} bytes") }
259+
val item = vssLdkGet(key = "network_graph", namespace = LdkNamespace.Default)
260+
item?.let { println("Graph size: ${it.value.size} bytes") }
261+
262+
// Store a key
263+
val stored = vssLdkStore(
264+
key = "network_graph",
265+
value = graphData,
266+
namespace = LdkNamespace.Default
267+
)
223268

224-
// List all ldk-node keys across all namespaces
225-
val allLdkKeys = vssListAllKeysLdk()
226-
allLdkKeys.forEach { println("LDK key: ${it.key}, Version: ${it.version}") }
269+
// Delete a key
270+
val wasDeleted = vssLdkDelete(key = "network_graph", namespace = LdkNamespace.Default)
227271

228-
// List ldk-node keys in a specific namespace
229-
val defaultKeys = vssListKeysLdk(namespace = LdkNamespace.Default)
272+
// List keys in a namespace
273+
val keys = vssLdkListKeys(namespace = LdkNamespace.Monitors)
274+
275+
// List all keys across all namespaces
276+
val allKeys = vssLdkListAllKeys()
277+
278+
// Clean shutdown
279+
vssShutdownLdkClient()
230280
```
231281

232282
## API Reference
@@ -280,29 +330,30 @@ Store multiple items in a single atomic transaction. The server manages versioni
280330
#### `vssDelete(key: String) -> Bool`
281331
Delete an item. Returns `true` if item existed and was deleted.
282332

283-
### LDK Data Operations
333+
### Dedicated LDK Client
284334

285-
These methods derive the same encryption and obfuscation keys as ldk-node. Use them to interact with data written by ldk-node (e.g., `network_graph`, `channel_manager`, `scorer`).
335+
A fully separate client (`LdkVssClient`) with its own key derivation using the full 64-byte BIP39 seed, independent from the app backup client. Use this when LDK operations must be completely isolated from app backup operations.
286336

287-
The standard `vssStore`/`vssGet`/`vssDelete` methods use different key derivation and **cannot** read or delete keys written by ldk-node.
337+
#### `vssNewLdkClientWithLnurlAuth(baseUrl: String, storeId: String, mnemonic: String, passphrase: String?, lnurlAuthServerUrl: String) -> Void`
338+
Initialize the dedicated LDK client with LNURL-auth authentication. This client is fully separate from the app client initialized with `vssNewClientWithLnurlAuth`.
288339

289-
#### `vssStoreLdk(key: String, value: Data, namespace: LdkNamespace) -> VssItem`
290-
Store a key-value pair using ldk-node's key derivation in the given namespace.
340+
#### `vssShutdownLdkClient() -> Void`
341+
Shutdown the dedicated LDK client and clean up resources.
291342

292-
#### `vssGetLdk(key: String, namespace: LdkNamespace) -> VssItem?`
293-
Retrieve an item by key using ldk-node's key derivation. Returns `null` if not found.
343+
#### `vssLdkStore(key: String, value: Data, namespace: LdkNamespace) -> VssItem`
344+
Store a key-value pair using the dedicated LDK client.
294345

295-
#### `vssDeleteLdk(key: String, namespace: LdkNamespace) -> Bool`
296-
Delete an item using ldk-node's key derivation. Returns `true` if item existed and was deleted.
346+
#### `vssLdkGet(key: String, namespace: LdkNamespace) -> VssItem?`
347+
Retrieve an item by key using the dedicated LDK client. Returns `null` if not found.
297348

298-
#### `vssListKeysLdk(namespace: LdkNamespace) -> [KeyVersion]`
299-
List keys stored by ldk-node in the given namespace.
349+
#### `vssLdkDelete(key: String, namespace: LdkNamespace) -> Bool`
350+
Delete an item using the dedicated LDK client. Returns `true` if item existed and was deleted.
300351

301-
#### `vssListAllKeysLdk() -> [KeyVersion]`
302-
List all keys across all singleton LDK namespaces (Default, Monitors, ArchivedMonitors).
352+
#### `vssLdkListKeys(namespace: LdkNamespace) -> [KeyVersion]`
353+
List keys in a namespace using the dedicated LDK client.
303354

304-
#### `vssListLdk(namespace: LdkNamespace) -> [VssItem]`
305-
List all items stored by ldk-node in the given namespace with their full data.
355+
#### `vssLdkListAllKeys() -> [KeyVersion]`
356+
List all keys across all singleton LDK namespaces using the dedicated LDK client.
306357

307358
### Data Types
308359

@@ -390,8 +441,6 @@ cargo run --bin uniffi-bindgen generate \
390441
--out-dir ./test_bindings
391442
```
392443

393-
For detailed testing information including integration tests, see [TESTING.md](TESTING.md).
394-
395444
## Architecture
396445

397446
This library provides a thin FFI wrapper around the [vss-client-ng](https://crates.io/crates/vss-client-ng) Rust library, exposing a simplified async API suitable for mobile and cross-platform applications.

bindings/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ android.useAndroidX=true
33
android.nonTransitiveRClass=true
44
kotlin.code.style=official
55
# project settings:
6-
version=0.5.11
6+
version=0.5.12
Binary file not shown.
Binary file not shown.
-162 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)