@@ -30,6 +30,25 @@ typedef enum FFIValidationMode {
3030 */
3131typedef struct FFIDashSpvClient FFIDashSpvClient ;
3232
33+ /**
34+ * FFI-safe array that transfers ownership of memory to the C caller.
35+ *
36+ * # Safety
37+ *
38+ * This struct represents memory that has been allocated by Rust but ownership
39+ * has been transferred to the C caller. The caller is responsible for:
40+ * - Not accessing the memory after it has been freed
41+ * - Calling `dash_spv_ffi_array_destroy` to properly deallocate the memory
42+ * - Ensuring the data, len, and capacity fields remain consistent
43+ */
44+ typedef struct FFIArray {
45+ void * data ;
46+ uintptr_t len ;
47+ uintptr_t capacity ;
48+ uintptr_t elem_size ;
49+ uintptr_t elem_align ;
50+ } FFIArray ;
51+
3352typedef ClientConfig FFIClientConfig ;
3453
3554typedef struct FFIString {
@@ -129,25 +148,6 @@ typedef struct FFIEventCallbacks {
129148 void * user_data ;
130149} FFIEventCallbacks ;
131150
132- /**
133- * FFI-safe array that transfers ownership of memory to the C caller.
134- *
135- * # Safety
136- *
137- * This struct represents memory that has been allocated by Rust but ownership
138- * has been transferred to the C caller. The caller is responsible for:
139- * - Not accessing the memory after it has been freed
140- * - Calling `dash_spv_ffi_array_destroy` to properly deallocate the memory
141- * - Ensuring the data, len, and capacity fields remain consistent
142- */
143- typedef struct FFIArray {
144- void * data ;
145- uintptr_t len ;
146- uintptr_t capacity ;
147- uintptr_t elem_size ;
148- uintptr_t elem_align ;
149- } FFIArray ;
150-
151151/**
152152 * Handle for Core SDK that can be passed to Platform SDK
153153 */
@@ -196,6 +196,49 @@ typedef struct FFIUnconfirmedTransaction {
196196 uintptr_t addresses_len ;
197197} FFIUnconfirmedTransaction ;
198198
199+ /**
200+ * Get the latest checkpoint for the given network.
201+ *
202+ * # Safety
203+ * - `out_height` must be a valid pointer to a `u32`.
204+ * - `out_hash` must point to at least 32 writable bytes.
205+ */
206+ int32_t dash_spv_ffi_checkpoint_latest (FFINetwork network , uint32_t * out_height , uint8_t * out_hash );
207+
208+ /**
209+ * Get the last checkpoint at or before a given height.
210+ *
211+ * # Safety
212+ * - `out_height` must be a valid pointer to a `u32`.
213+ * - `out_hash` must point to at least 32 writable bytes.
214+ */
215+ int32_t dash_spv_ffi_checkpoint_before_height (FFINetwork network ,
216+ uint32_t height ,
217+ uint32_t * out_height ,
218+ uint8_t * out_hash );
219+
220+ /**
221+ * Get the last checkpoint at or before a given UNIX timestamp (seconds).
222+ *
223+ * # Safety
224+ * - `out_height` must be a valid pointer to a `u32`.
225+ * - `out_hash` must point to at least 32 writable bytes.
226+ */
227+ int32_t dash_spv_ffi_checkpoint_before_timestamp (FFINetwork network ,
228+ uint32_t timestamp ,
229+ uint32_t * out_height ,
230+ uint8_t * out_hash );
231+
232+ /**
233+ * Get all checkpoints between two heights (inclusive).
234+ *
235+ * Returns an `FFIArray` of `FFICheckpoint` items. The caller owns the memory and
236+ * must free the array buffer using `dash_spv_ffi_array_destroy` when done.
237+ */
238+ struct FFIArray dash_spv_ffi_checkpoints_between_heights (FFINetwork network ,
239+ uint32_t start_height ,
240+ uint32_t end_height );
241+
199242struct FFIDashSpvClient * dash_spv_ffi_client_new (const FFIClientConfig * config );
200243
201244/**
@@ -562,49 +605,6 @@ int32_t dash_spv_ffi_config_set_start_from_height(FFIClientConfig *config,
562605int32_t dash_spv_ffi_config_set_wallet_creation_time (FFIClientConfig * config ,
563606 uint32_t timestamp );
564607
565- /**
566- * Get the latest checkpoint for the given network.
567- *
568- * # Safety
569- * - `out_height` must be a valid pointer to a `u32`.
570- * - `out_hash` must point to at least 32 writable bytes.
571- */
572- int32_t dash_spv_ffi_checkpoint_latest (FFINetwork network , uint32_t * out_height , uint8_t * out_hash );
573-
574- /**
575- * Get the last checkpoint at or before a given height.
576- *
577- * # Safety
578- * - `out_height` must be a valid pointer to a `u32`.
579- * - `out_hash` must point to at least 32 writable bytes.
580- */
581- int32_t dash_spv_ffi_checkpoint_before_height (FFINetwork network ,
582- uint32_t height ,
583- uint32_t * out_height ,
584- uint8_t * out_hash );
585-
586- /**
587- * Get the last checkpoint at or before a given UNIX timestamp (seconds).
588- *
589- * # Safety
590- * - `out_height` must be a valid pointer to a `u32`.
591- * - `out_hash` must point to at least 32 writable bytes.
592- */
593- int32_t dash_spv_ffi_checkpoint_before_timestamp (FFINetwork network ,
594- uint32_t timestamp ,
595- uint32_t * out_height ,
596- uint8_t * out_hash );
597-
598- /**
599- * Get all checkpoints between two heights (inclusive).
600- *
601- * Returns an `FFIArray` of `FFICheckpoint` items. The caller owns the memory and
602- * must free the array buffer using `dash_spv_ffi_array_destroy` when done.
603- */
604- struct FFIArray dash_spv_ffi_checkpoints_between_heights (FFINetwork network ,
605- uint32_t start_height ,
606- uint32_t end_height );
607-
608608const char * dash_spv_ffi_get_last_error (void );
609609
610610void dash_spv_ffi_clear_error (void );
0 commit comments