Commit a8e381a
chore: merge v0.42-dev into feat/per-wallet-filter-scan (#698)
* chore(dash-spv): refresh masternode seed files (#695)
Co-authored-by: QuantumExplorer <11468583+QuantumExplorer@users.noreply.github.com>
* feat: make wallet events atomic (#696)
* feat: make wallet events atomic
Reshape `WalletEvent` so each variant carries the records or context needed to persist a wallet update atomically off a single event, alongside the post-change balance.
The variant set is now:
- `TransactionReceived { wallet_id, record, balance }`. Fires when the wallet first sees an off-chain transaction.
- `TransactionStatusChanged { wallet_id, txid, context, balance }`. Fires when a known off-chain transaction has its state change. Currently fires only for InstantSend locks.
- `BlockUpdate { wallet_id, height, inserted, updated, matured, balance }`. Carries records bucketed by what happened to them in the block, plus the post-block balance.
- `SyncHeightUpdate { wallet_id, height }`. Marks a filter-batch checkpoint.
`TransactionRecord` carries `account_type` directly, identifying the owning account. `WalletInfoInterface` gains a `matured_coinbase_records` method that enumerates coinbase records crossing the maturity threshold during a height advance, populating `BlockUpdate.matured`.
The FFI groups the flattened account-discriminator fields into an `FFIAccountType` struct and renames the prior discriminant enum to `FFIAccountKind`.
* fix: record balance before bumping `block_processed_wallet_count`
Tests wait on `block_processed_wallet_count` and then read `last_confirmed`/`last_unconfirmed`. Bumping the counter before storing the balance snapshot left those reads racey. Reorder so the balance is recorded first.
Addresses CodeRabbit review comment on PR #696
#696 (comment)
* fix: place `IdentityTopUp.registration_index` in `index_secondary`
The `FFIAccountType` doc states `index_secondary` carries `registration_index` for `IdentityTopUp` and `index = 0` for variants without a meaningful primary index, matching the parallel encoding in `FFIAccountKind::from_account_type`. The `From<&AccountType>` impl wrote `registration_index` into `index` instead, breaking the documented FFI contract.
Addresses CodeRabbit review comment on PR #696
#696 (comment)
* fix: route confirmation backfills to `new_records`
`is_new` is wallet-wide (set on the first matching account, then breaks), so the per-account `else` branch can run for an account that did not previously hold the record. `confirm_transaction` backfills via `record_transaction` in that case, but the post-call record was always pushed onto `updated_records`, breaking the atomic `inserted`/`updated` contract consumed by `WalletEvent::BlockUpdate`. Capture `existed_before` per account and route to `new_records` when the record was just created.
Addresses CodeRabbit review comment on PR #696
#696 (comment)
* refactor(key-wallet-manager): extract `finalize_block_advance` helper
`process_block` and `update_last_processed_height` duplicated the entire balance-snapshot, prior-heights collection, matured-coinbase window, height advance, and per-wallet `BlockUpdate` emission. Extract the shared tail into a private `WalletManager::finalize_block_advance` helper that takes the inserted/updated maps. `update_last_processed_height` becomes a one-line call with empty maps; `process_block` keeps only its txdata loop before delegating.
* refactor: rename wallet events for clearer semantics
Rename `WalletEvent` variants and the matching FFI callbacks to past-participle names that say what happened, replacing vague "Update" suffixes:
- `TransactionReceived` -> `TransactionDetected`. "Received" implied incoming funds, but the event fires for any first-time off-chain sighting (incoming or outgoing).
- `TransactionStatusChanged` -> `TransactionInstantLocked`. The event only ever fires for an InstantSend lock applied to a known mempool tx, so name it for what it actually is. Drop the `status: TransactionContext` field and carry the `InstantLock` directly.
- `BlockUpdate` -> `BlockProcessed`. Mirrors `process_block` and matches the past-participle pattern.
- `SyncHeightUpdate` -> `SyncHeightAdvanced`. Conveys monotonic forward motion.
FFI rename mirrors the Rust side: the IS callback now takes `islock_data: *const u8` + `islock_len: usize` instead of an `FFITransactionContext`, removing a discriminant that was always `InstantSend`. The wallet-side `OnBlockProcessedCallback` becomes `OnWalletBlockProcessedCallback` to disambiguate from the existing sync-event type with the same name.
* fix: record balance before bumping IS-locked counter in test callback
Addresses CodeRabbit review comment on PR #696
#696 (review)
The instant_locked callback bumped `transaction_instant_send_locked_count` before calling `record_balance`. Tests that wait on the counter and then read `last_confirmed`/`last_unconfirmed` could observe the previous balance snapshot. Match the ordering used by the other callbacks: store the balance first, then bump the counter.
* fix: backfill missing transaction record in InstantSend path
Addresses CodeRabbit review comment on PR #696
#696 (review)
The IS-lock branch in `WalletTransactionChecker::check_core_transaction` only updated accounts that already held a `TransactionRecord` for the txid. When wallet-level `is_new` was `false` (because at least one account had the record) but another matched account did not, the latter was silently skipped: no record was created and `mark_utxos_instant_send` ran against an empty UTXO set on that account.
Mirror the confirmation path: when the affected account lacks the record, call `record_transaction` to register the record and its UTXOs, then mark them IS-locked. This ordering ensures the freshly registered UTXOs receive the IS-lock flag too. The backfilled record is pushed into `new_records` to match the existing convention from commit 659a6d5.
Add `test_instantsend_backfills_missing_record_in_other_account` covering the multi-account scenario.
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: QuantumExplorer <11468583+QuantumExplorer@users.noreply.github.com>
Co-authored-by: Kevin Rombach <35775977+xdustinface@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 541d0cf commit a8e381a
35 files changed
Lines changed: 2010 additions & 1179 deletions
File tree
- dash-network-seeds/seeds
- dash-spv-ffi
- src
- bin
- tests/dashd_sync
- dash-spv/tests/dashd_sync
- key-wallet-ffi
- src
- tests
- key-wallet-manager/src
- key-wallet/src
- managed_account
- tests
- transaction_checking
- wallet/managed_wallet_info
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | | - | |
57 | | - | |
| 56 | + | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
| |||
221 | 222 | | |
222 | 223 | | |
223 | 224 | | |
| 225 | + | |
224 | 226 | | |
225 | 227 | | |
226 | 228 | | |
| |||
391 | 393 | | |
392 | 394 | | |
393 | 395 | | |
| 396 | + | |
394 | 397 | | |
395 | 398 | | |
396 | 399 | | |
| |||
413 | 416 | | |
414 | 417 | | |
415 | 418 | | |
416 | | - | |
| 419 | + | |
417 | 420 | | |
418 | 421 | | |
419 | 422 | | |
| |||
469 | 472 | | |
470 | 473 | | |
471 | 474 | | |
| 475 | + | |
472 | 476 | | |
473 | | - | |
474 | 477 | | |
475 | 478 | | |
476 | 479 | | |
| |||
533 | 536 | | |
534 | 537 | | |
535 | 538 | | |
536 | | - | |
537 | | - | |
| 539 | + | |
| 540 | + | |
538 | 541 | | |
539 | 542 | | |
540 | 543 | | |
| |||
714 | 717 | | |
715 | 718 | | |
716 | 719 | | |
717 | | - | |
| 720 | + | |
718 | 721 | | |
719 | 722 | | |
720 | 723 | | |
721 | 724 | | |
722 | | - | |
| 725 | + | |
723 | 726 | | |
724 | 727 | | |
725 | 728 | | |
| |||
738 | 741 | | |
739 | 742 | | |
740 | 743 | | |
741 | | - | |
742 | 744 | | |
743 | 745 | | |
744 | 746 | | |
| |||
812 | 814 | | |
813 | 815 | | |
814 | 816 | | |
| 817 | + | |
815 | 818 | | |
816 | 819 | | |
817 | 820 | | |
818 | 821 | | |
819 | 822 | | |
820 | 823 | | |
821 | 824 | | |
822 | | - | |
823 | | - | |
| 825 | + | |
| 826 | + | |
824 | 827 | | |
825 | 828 | | |
826 | 829 | | |
| |||
861 | 864 | | |
862 | 865 | | |
863 | 866 | | |
864 | | - | |
| 867 | + | |
865 | 868 | | |
866 | 869 | | |
867 | 870 | | |
868 | 871 | | |
869 | 872 | | |
870 | 873 | | |
871 | 874 | | |
872 | | - | |
| 875 | + | |
873 | 876 | | |
874 | 877 | | |
875 | 878 | | |
| |||
1092 | 1095 | | |
1093 | 1096 | | |
1094 | 1097 | | |
1095 | | - | |
| 1098 | + | |
1096 | 1099 | | |
1097 | 1100 | | |
1098 | 1101 | | |
| |||
1194 | 1197 | | |
1195 | 1198 | | |
1196 | 1199 | | |
1197 | | - | |
| 1200 | + | |
1198 | 1201 | | |
1199 | 1202 | | |
1200 | 1203 | | |
| |||
1219 | 1222 | | |
1220 | 1223 | | |
1221 | 1224 | | |
1222 | | - | |
| 1225 | + | |
1223 | 1226 | | |
1224 | 1227 | | |
1225 | 1228 | | |
| |||
1228 | 1231 | | |
1229 | 1232 | | |
1230 | 1233 | | |
1231 | | - | |
| 1234 | + | |
1232 | 1235 | | |
1233 | 1236 | | |
1234 | 1237 | | |
1235 | 1238 | | |
1236 | 1239 | | |
1237 | 1240 | | |
1238 | 1241 | | |
1239 | | - | |
| 1242 | + | |
1240 | 1243 | | |
1241 | 1244 | | |
1242 | 1245 | | |
| |||
1274 | 1277 | | |
1275 | 1278 | | |
1276 | 1279 | | |
| 1280 | + | |
1277 | 1281 | | |
1278 | 1282 | | |
1279 | 1283 | | |
| |||
1404 | 1408 | | |
1405 | 1409 | | |
1406 | 1410 | | |
1407 | | - | |
| 1411 | + | |
1408 | 1412 | | |
1409 | 1413 | | |
1410 | 1414 | | |
| |||
1424 | 1428 | | |
1425 | 1429 | | |
1426 | 1430 | | |
1427 | | - | |
| 1431 | + | |
1428 | 1432 | | |
1429 | 1433 | | |
1430 | 1434 | | |
1431 | | - | |
| 1435 | + | |
1432 | 1436 | | |
1433 | 1437 | | |
1434 | 1438 | | |
1435 | | - | |
| 1439 | + | |
1436 | 1440 | | |
1437 | 1441 | | |
1438 | 1442 | | |
| |||
1488 | 1492 | | |
1489 | 1493 | | |
1490 | 1494 | | |
1491 | | - | |
1492 | 1495 | | |
1493 | 1496 | | |
1494 | 1497 | | |
| |||
1560 | 1563 | | |
1561 | 1564 | | |
1562 | 1565 | | |
1563 | | - | |
| 1566 | + | |
1564 | 1567 | | |
1565 | 1568 | | |
1566 | 1569 | | |
| |||
1652 | 1655 | | |
1653 | 1656 | | |
1654 | 1657 | | |
| 1658 | + | |
1655 | 1659 | | |
1656 | 1660 | | |
1657 | 1661 | | |
| |||
1722 | 1726 | | |
1723 | 1727 | | |
1724 | 1728 | | |
1725 | | - | |
1726 | | - | |
1727 | 1729 | | |
1728 | 1730 | | |
1729 | 1731 | | |
| |||
1768 | 1770 | | |
1769 | 1771 | | |
1770 | 1772 | | |
| 1773 | + | |
1771 | 1774 | | |
1772 | 1775 | | |
1773 | 1776 | | |
| |||
1950 | 1953 | | |
1951 | 1954 | | |
1952 | 1955 | | |
1953 | | - | |
1954 | 1956 | | |
1955 | 1957 | | |
1956 | 1958 | | |
| |||
1971 | 1973 | | |
1972 | 1974 | | |
1973 | 1975 | | |
1974 | | - | |
| 1976 | + | |
1975 | 1977 | | |
1976 | 1978 | | |
1977 | 1979 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
0 commit comments