You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(key-wallet): add `keep-finalized-transactions` feature
By default, records of chainlocked transactions are now dropped from
each managed account's in-memory `transactions` map; only their txids
are retained (in a new `finalized_txids` set on `ManagedCoreKeysAccount`)
to keep dedup, `has_transaction`, and finality queries working. The
opt-in `keep-finalized-transactions` Cargo feature reverts to the
old behavior — every processed transaction stays in the map for the
wallet's lifetime.
The drop is driven off `TransactionContext::is_finalized_in_block`
(chainlock only), not `is_finalized` (chainlock or IS-lock), so
IS-locked records survive long enough to absorb the surrounding
block-confirmation event (xdustinface review on #709).
`confirm_transaction` now returns `Option<TransactionRecord>` so
callers always observe the record even when it's about to be dropped.
The feature is forwarded through `key-wallet-manager` and
`key-wallet-ffi`. Three FFI accessors that walk the full
`transactions` map (`managed_core_account_get_transaction_count`,
`managed_core_account_get_transactions`,
`managed_core_account_free_transactions`) are gated to the feature
because they would otherwise return a partial history.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(dash-spv-ffi): enable `keep-finalized-transactions` for tests
Integration tests under `dash-spv-ffi/tests/dashd_sync/` walk the full
per-account transaction history (`managed_core_account_get_transactions`,
`managed_core_account_get_transaction_count`,
`managed_core_account_free_transactions`) to verify end-to-end wallet
sync against a regtest dashd. These accessors are gated behind the
`keep-finalized-transactions` feature on `key-wallet-ffi`, so under the
default feature set they aren't compiled in and the test build fails to
resolve the imports.
Add `key-wallet-ffi` as a dev-dependency with the feature enabled.
Cargo unifies features across the build graph at test time, which
makes the gated accessors available in the test binaries without
expanding the lib crate's default feature surface.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(key-wallet): align finalization with chainlock-only semantics
Address xdustinface review feedback on PR #733:
- Drop `TransactionContext::is_finalized()` (the soft IS-or-chainlock
check). The wallet now treats only a chainlock as finality.
- Rename `TransactionContext::is_finalized_in_block()` to
`is_chain_locked()` so the predicate name describes the variant
rather than overloading "finalized" — same naming style as the
existing `is_instant_send()` helper.
- Drop `ManagedAccountTrait::transaction_is_finalized()` (the
unused soft-finality variant) and rename
`transaction_is_finalized_in_block()` to `transaction_is_finalized()`.
Now that there's a single finalization concept, the trait method
name aligns with the feature name.
- Replace runtime `if cfg!(...) { ... } else { ... }` branches in
`ManagedCoreKeysAccount::has_transaction` and
`transaction_is_finalized` with two `#[cfg]`-gated function bodies
— one per feature configuration. Same for the chainlock-driven
drop call in `confirm_transaction` / `record_transaction`: the
`let drop_now = …` binding now only exists when the feature is off,
removing the `#[allow(unused_variables)]` workaround.
- Rewrite the doc on `has_transaction` so it's clear what it actually
reports (live record OR finalized-txid marker) and how callers use
it (distinguish brand-new sightings from re-processings) instead of
the misleading "dedup signal in `confirm_transaction`" wording.
Drop logic still triggers on the strict `is_chain_locked()` check —
IS-locked-but-not-yet-chainlocked records still survive so the
surrounding block-confirmation event can populate height / block
hash before the chainlock catches up.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs(key-wallet): fix stale `transaction_is_finalized_in_block` mention
The previous commit renamed the trait method to `transaction_is_finalized`
but missed this Cargo.toml feature-doc reference. Caught by CodeRabbit on
PR #733.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: key-wallet-ffi/FFI_API.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -230,15 +230,15 @@ Functions: 108
230
230
| `managed_account_collection_summary_data` | Get structured account collection summary data for managed collection ... | managed_account_collection |
231
231
| `managed_account_collection_summary_free` | Free a managed account collection summary and all its allocated memory #... | managed_account_collection |
232
232
| `managed_core_account_free` | Free a managed account handle # Safety - `account` must be a valid pointer... | managed_account |
233
-
| `managed_core_account_free_transactions` | Free transactions array returned by managed_core_account_get_transactions #... | managed_account |
233
+
| `managed_core_account_free_transactions` | Free transactions array returned by managed_core_account_get_transactions ... | managed_account |
234
234
| `managed_core_account_get_account_type` | Get the account type of a managed account # Safety - `account` must be a... | managed_account |
235
235
| `managed_core_account_get_address_pool` | Get an address pool from a managed account by type This function returns... | managed_account |
236
236
| `managed_core_account_get_balance` | Get the balance of a managed account # Safety - `account` must be a valid... | managed_account |
237
237
| `managed_core_account_get_external_address_pool` | Get the external address pool from a managed account This function returns... | managed_account |
238
238
| `managed_core_account_get_index` | Get the account index from a managed account Returns the primary account... | managed_account |
239
239
| `managed_core_account_get_internal_address_pool` | Get the internal address pool from a managed account This function returns... | managed_account |
240
240
| `managed_core_account_get_network` | Get the network of a managed account # Safety - `account` must be a valid... | managed_account |
241
-
| `managed_core_account_get_transaction_count` | Get the number of transactions in a managed account # Safety - `account`... | managed_account |
241
+
| `managed_core_account_get_transaction_count` | Get the number of transactions in a managed account Only available with the... | managed_account |
242
242
| `managed_core_account_get_transactions` | Get all transactions from a managed account Returns an array of... | managed_account |
243
243
| `managed_core_account_get_utxo_count` | Get the number of UTXOs in a managed account # Safety - `account` must be... | managed_account |
244
244
| `managed_platform_account_free` | Free a managed platform account handle # Safety - `account` must be a... | managed_account |
Free transactions array returned by managed_core_account_get_transactions # Safety - `transactions` must be a pointer returned by `managed_core_account_get_transactions` - `count` must be the count returned by `managed_core_account_get_transactions` - This function must only be called once per allocation
3050
+
Free transactions array returned by managed_core_account_get_transactions Only available with the `keep-finalized-transactions` Cargo feature, in which configuration `managed_core_account_get_transactions` is also available — the two functions are paired. # Safety - `transactions` must be a pointer returned by `managed_core_account_get_transactions` - `count` must be the count returned by `managed_core_account_get_transactions` - This function must only be called once per allocation
3051
3051
3052
3052
**Safety:**
3053
3053
- `transactions` must be a pointer returned by `managed_core_account_get_transactions` - `count` must be the count returned by `managed_core_account_get_transactions` - This function must only be called once per allocation
Get the number of transactions in a managed account # Safety - `account` must be a valid pointer to an FFIManagedCoreAccount instance
3178
+
Get the number of transactions in a managed account Only available with the `keep-finalized-transactions` Cargo feature. With the feature off (the default), records of chainlocked transactions are dropped from the in-memory map, so the count would not reflect the full history — the function is intentionally not exposed. # Safety - `account` must be a valid pointer to an FFIManagedCoreAccount instance
3179
3179
3180
3180
**Safety:**
3181
3181
- `account` must be a valid pointer to an FFIManagedCoreAccount instance
@@ -3191,7 +3191,7 @@ managed_core_account_get_transactions(account: *const FFIManagedCoreAccount, tra
3191
3191
```
3192
3192
3193
3193
**Description:**
3194
-
Get all transactions from a managed account Returns an array of FFITransactionRecord structures. # Safety - `account` must be a valid pointer to an FFIManagedCoreAccount instance - `transactions_out` must be a valid pointer to receive the transactions array pointer - `count_out` must be a valid pointer to receive the count - The caller must free the returned array using `managed_core_account_free_transactions`
3194
+
Get all transactions from a managed account Returns an array of FFITransactionRecord structures. Only available with the `keep-finalized-transactions` Cargo feature. With the feature off (the default), records of chainlocked transactions are dropped from the in-memory map, so this would only return a partial history — the function is intentionally not exposed. # Safety - `account` must be a valid pointer to an FFIManagedCoreAccount instance - `transactions_out` must be a valid pointer to receive the transactions array pointer - `count_out` must be a valid pointer to receive the count - The caller must free the returned array using `managed_core_account_free_transactions`
3195
3195
3196
3196
**Safety:**
3197
3197
- `account` must be a valid pointer to an FFIManagedCoreAccount instance - `transactions_out` must be a valid pointer to receive the transactions array pointer - `count_out` must be a valid pointer to receive the count - The caller must free the returned array using `managed_core_account_free_transactions`
0 commit comments