Skip to content

Commit 87560ea

Browse files
fixes
1 parent 9af4e64 commit 87560ea

File tree

14 files changed

+476
-208
lines changed

14 files changed

+476
-208
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ jobs:
225225
strategy:
226226
matrix:
227227
rust: [stable]
228-
dashversion: ["22.0.0", "22.1.3"]
228+
dashversion: ["22.1.3"]
229229
steps:
230230
- name: Checkout Crate
231231
uses: actions/checkout@v4

dash-spv-ffi/include/dash_spv_ffi.h

Lines changed: 104 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ typedef enum FFIValidationMode {
2525
Full = 2,
2626
} FFIValidationMode;
2727

28-
/**
29-
* FFIDashSpvClient structure
30-
*/
3128
typedef struct FFIDashSpvClient FFIDashSpvClient;
3229

3330
/**
@@ -239,6 +236,13 @@ struct FFIArray dash_spv_ffi_checkpoints_between_heights(FFINetwork network,
239236
uint32_t start_height,
240237
uint32_t end_height);
241238

239+
/**
240+
* Create a new SPV client and return an opaque pointer.
241+
*
242+
* # Safety
243+
* - `config` must be a valid, non-null pointer for the duration of the call.
244+
* - The returned pointer must be freed with `dash_spv_ffi_client_destroy`.
245+
*/
242246
struct FFIDashSpvClient *dash_spv_ffi_client_new(const FFIClientConfig *config);
243247

244248
/**
@@ -252,8 +256,20 @@ struct FFIDashSpvClient *dash_spv_ffi_client_new(const FFIClientConfig *config);
252256
int32_t dash_spv_ffi_client_update_config(struct FFIDashSpvClient *client,
253257
const FFIClientConfig *config);
254258

259+
/**
260+
* Start the SPV client.
261+
*
262+
* # Safety
263+
* - `client` must be a valid, non-null pointer to a created client.
264+
*/
255265
int32_t dash_spv_ffi_client_start(struct FFIDashSpvClient *client);
256266

267+
/**
268+
* Stop the SPV client.
269+
*
270+
* # Safety
271+
* - `client` must be a valid, non-null pointer to a created client.
272+
*/
257273
int32_t dash_spv_ffi_client_stop(struct FFIDashSpvClient *client);
258274

259275
/**
@@ -347,27 +363,87 @@ int32_t dash_spv_ffi_client_sync_to_tip_with_progress(struct FFIDashSpvClient *c
347363
*/
348364
int32_t dash_spv_ffi_client_cancel_sync(struct FFIDashSpvClient *client);
349365

366+
/**
367+
* Get the current sync progress snapshot.
368+
*
369+
* # Safety
370+
* - `client` must be a valid, non-null pointer.
371+
*/
350372
struct FFISyncProgress *dash_spv_ffi_client_get_sync_progress(struct FFIDashSpvClient *client);
351373

374+
/**
375+
* Get current runtime statistics for the SPV client.
376+
*
377+
* # Safety
378+
* - `client` must be a valid, non-null pointer.
379+
*/
352380
struct FFISpvStats *dash_spv_ffi_client_get_stats(struct FFIDashSpvClient *client);
353381

382+
/**
383+
* Check if compact filter sync is currently available.
384+
*
385+
* # Safety
386+
* - `client` must be a valid, non-null pointer.
387+
*/
354388
bool dash_spv_ffi_client_is_filter_sync_available(struct FFIDashSpvClient *client);
355389

390+
/**
391+
* Set event callbacks for the client.
392+
*
393+
* # Safety
394+
* - `client` must be a valid, non-null pointer.
395+
*/
356396
int32_t dash_spv_ffi_client_set_event_callbacks(struct FFIDashSpvClient *client,
357397
struct FFIEventCallbacks callbacks);
358398

399+
/**
400+
* Destroy the client and free associated resources.
401+
*
402+
* # Safety
403+
* - `client` must be either null or a pointer obtained from `dash_spv_ffi_client_new`.
404+
*/
359405
void dash_spv_ffi_client_destroy(struct FFIDashSpvClient *client);
360406

407+
/**
408+
* Destroy a `FFISyncProgress` object returned by this crate.
409+
*
410+
* # Safety
411+
* - `progress` must be a pointer returned from this crate, or null.
412+
*/
361413
void dash_spv_ffi_sync_progress_destroy(struct FFISyncProgress *progress);
362414

415+
/**
416+
* Destroy an `FFISpvStats` object returned by this crate.
417+
*
418+
* # Safety
419+
* - `stats` must be a pointer returned from this crate, or null.
420+
*/
363421
void dash_spv_ffi_spv_stats_destroy(struct FFISpvStats *stats);
364422

423+
/**
424+
* Request a rescan of the blockchain from a given height (not yet implemented).
425+
*
426+
* # Safety
427+
* - `client` must be a valid, non-null pointer.
428+
*/
365429
int32_t dash_spv_ffi_client_rescan_blockchain(struct FFIDashSpvClient *client,
366430
uint32_t _from_height);
367431

432+
/**
433+
* Enable mempool tracking with a given strategy.
434+
*
435+
* # Safety
436+
* - `client` must be a valid, non-null pointer.
437+
*/
368438
int32_t dash_spv_ffi_client_enable_mempool_tracking(struct FFIDashSpvClient *client,
369439
enum FFIMempoolStrategy strategy);
370440

441+
/**
442+
* Record that we attempted to send a transaction by its txid.
443+
*
444+
* # Safety
445+
* - `client` and `txid` must be valid, non-null pointers.
446+
*/
371447
int32_t dash_spv_ffi_client_record_send(struct FFIDashSpvClient *client, const char *txid);
372448

373449
/**
@@ -386,6 +462,10 @@ int32_t dash_spv_ffi_client_record_send(struct FFIDashSpvClient *client, const c
386462
*
387463
* An opaque pointer (void*) to the wallet manager, or NULL if the client is not initialized.
388464
* Swift should treat this as an OpaquePointer.
465+
* Get a handle to the wallet manager owned by this client.
466+
*
467+
* # Safety
468+
* - `client` must be a valid, non-null pointer.
389469
*/
390470
void *dash_spv_ffi_client_get_wallet_manager(struct FFIDashSpvClient *client);
391471

@@ -661,8 +741,18 @@ struct FFIResult ffi_dash_spv_get_quorum_public_key(struct FFIDashSpvClient *cli
661741
struct FFIResult ffi_dash_spv_get_platform_activation_height(struct FFIDashSpvClient *client,
662742
uint32_t *out_height);
663743

744+
/**
745+
* # Safety
746+
* - `s.ptr` must be a pointer previously returned by `FFIString::new` or compatible.
747+
* - It must not be used after this call.
748+
*/
664749
void dash_spv_ffi_string_destroy(struct FFIString s);
665750

751+
/**
752+
* # Safety
753+
* - `arr` must be either null or a valid pointer to an `FFIArray` previously constructed in Rust.
754+
* - The memory referenced by `arr.data` must not be used after this call.
755+
*/
666756
void dash_spv_ffi_array_destroy(struct FFIArray *arr);
667757

668758
/**
@@ -672,6 +762,10 @@ void dash_spv_ffi_array_destroy(struct FFIArray *arr);
672762
* - Iterates the array elements as pointers to FFIString and destroys each via dash_spv_ffi_string_destroy
673763
* - Frees the underlying vector buffer stored in FFIArray
674764
* - Does not free the FFIArray struct itself (safe for both stack- and heap-allocated structs)
765+
* # Safety
766+
* - `arr` must be either null or a valid pointer to an `FFIArray` whose elements are `*mut FFIString`.
767+
* - Each element pointer must be valid or null; non-null entries are freed.
768+
* - The memory referenced by `arr.data` must not be used after this call.
675769
*/
676770
void dash_spv_ffi_string_array_destroy(struct FFIArray *arr);
677771

@@ -713,6 +807,13 @@ void dash_spv_ffi_unconfirmed_transaction_destroy_addresses(struct FFIString *ad
713807
*/
714808
void dash_spv_ffi_unconfirmed_transaction_destroy(struct FFIUnconfirmedTransaction *tx);
715809

810+
/**
811+
* Initialize logging for the SPV library.
812+
*
813+
* # Safety
814+
* - `level` may be null or point to a valid, NUL-terminated C string.
815+
* - If non-null, the pointer must remain valid for the duration of this call.
816+
*/
716817
int32_t dash_spv_ffi_init_logging(const char *level);
717818

718819
const char *dash_spv_ffi_version(void);

dash-spv-ffi/src/callbacks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ impl FFIEventCallbacks {
338338
}
339339
}
340340

341+
#[allow(clippy::too_many_arguments)]
341342
pub fn call_wallet_transaction(
342343
&self,
343344
wallet_id: &str,

0 commit comments

Comments
 (0)