Commit 871ce24
feat(key-wallet-manager): carry addresses_derived on TransactionDetected / BlockProcessed (#725)
* feat(key-wallet-manager): carry addresses_derived on TransactionDetected / BlockProcessed
Address-pool extensions triggered by gap-limit maintenance during tx /
block processing now ride along on the existing event the persister
already consumes, rather than living silently in Rust memory. UTXOs
landing on freshly derived addresses keep their parent CoreAddress row
in downstream stores.
`AddressPool::maintain_gap_limit` returns `Vec<AddressInfo>` (was
`Vec<Address>`); the wallet checker tags each new entry with the owning
account type and pool type via a new `DerivedAddressInfo`, and the
manager projects that into `DerivedAddress` (account_type, pool_type,
derivation_index, derivation_path, address, public_key) on the event.
Block emission de-duplicates by (account_type, pool_type, index) so two
records pushing the same boundary collapse to one entry. Non-ECDSA
pools (BLS / EdDSA) are silently skipped during projection. IS-lock and
sync-height events are unchanged — those paths don't extend the pool.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(docs): repair rustdoc intra-doc links
`AccountType` is now imported in account_checker.rs, which makes the
explicit `(crate::account::AccountType)` link target redundant under
`-D warnings`. And `[AddressInfo]` in key-wallet-manager/src/lib.rs
needs the fully-qualified path since the type isn't imported into the
crate root.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(key-wallet-manager): drop redundant derivation_path from DerivedAddress
`account_type` (which carries Dashpay identity ids, IdentityTopUp's
registration_index, and the like), `pool_type`, and `derivation_index`
fully determine the path. Consumers that need a rendered path can
recompute it deterministically rather than carrying a redundant
String on every event.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* review(key-wallet-manager): per-record derivations, observability, real dedup test
Address review feedback on PR #725:
- `DerivedAddress::from_info` is now `pub(crate)` since the only caller
is the in-crate `project_derived_addresses` helper. Keeps the
compatibility boundary at `WalletEvent` / `DerivedAddress` and avoids
re-exporting `key_wallet::transaction_checking::DerivedAddressInfo`
through this crate's public API.
- Drops in `from_info` now log via `tracing` — `warn!` for the
unreachable-by-construction "ECDSA but not 33 bytes" arm (which
signals a bug if ever hit), `warn!` for "no public key", and `debug!`
for the BLS / EdDSA fall-through (expected if a future change wires
gap-limit extension into one of those pools, currently unreachable).
- Mempool path now attributes derivations per-record via partition on
`record.account_type == DerivedAddressInfo.account_type`. A tx that
pays into multiple accounts of the same wallet now ships each record
with its own account's derivations — consistent with the field's
documented "transactional with `record`" semantics. Doc tightened
accordingly.
- `maintain_gap_limit` previously silently produced a shorter `Vec` if
the just-inserted entry wasn't found; now it panics with an explicit
invariant message, turning a regression that breaks the post-insert
invariant into a loud failure rather than a silent infinite loop on
the outer `while`.
- New unit tests for `project_derived_addresses` directly exercise the
dedup branch (overlapping `(account, pool, index)` → first-wins),
distinct indices, distinct pools, and the missing-pubkey drop. The
existing block-level test couldn't reach the dedup branch since
`maintain_gap_limit` is idempotent on a second call.
- The "highest external" event test now pins each emitted
`(address, public_key)` against the wallet's own `AddressInfo` for
the same `(account, pool, index)`. Catches regressions in
`from_info` that would silently corrupt persister rows while keeping
the count-and-index assertions green.
- `dash-spv-ffi` dispatch arms tagged with TODOs documenting that
`addresses_derived` is dropped at the FFI seam pending a paired
callback.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(dash-spv-ffi): expose addresses_derived on Wallet event callbacks
Closes the FFI-side TODOs left by PR #725: the Rust event already
carries `Vec<DerivedAddress>`, but the C callback signature had no slot
for it, so the field was dropped at the dispatch seam — defeating the
persistence contract for FFI consumers (Swift / mobile persisters
mirroring the address pool to disk).
- New `FFIDerivedAddress { account_type, pool_type, derivation_index,
address, public_key[33] }` and `FFIDerivedAddressPoolType` (4-variant,
mirrors `key_wallet::AddressPoolType` 1:1; kept distinct from the
existing `FFIAddressPoolType` which collapses Absent / AbsentHardened).
- `OnTransactionDetectedCallback` and `OnWalletBlockProcessedCallback`
signatures grow `addresses_derived: *const FFIDerivedAddress,
addresses_derived_count: u32`. The C ABI is broken — every consumer
has to update its callback signature; this is intentional, since the
alternative (a paired auxiliary callback) would let consumers persist
records without the matching address rows and reintroduce the
orphan-`CoreAddress`-row failure mode the field is designed to
prevent.
- Memory: `FFIDerivedAddress` owns the `address` C string (freed on
drop via `CString::from_raw`) and the `FFIAccountType` (which has its
own Drop for the optional Dashpay identity ids). The `Vec` lives on
the Rust stack across the callback and is dropped after.
- `dash-spv-ffi/src/bin/ffi_cli.rs` and the dashd integration test
callbacks updated for the new signatures (counts logged in the CLI;
arrays are not retained in tests).
- cbindgen header regenerates correctly (verified via `cargo build`).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e8e8283 commit 871ce24
12 files changed
Lines changed: 955 additions & 37 deletions
File tree
- dash-spv-ffi
- src
- bin
- tests/dashd_sync
- key-wallet-manager/src
- key-wallet/src
- managed_account
- transaction_checking
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
| |||
189 | 192 | | |
190 | 193 | | |
191 | 194 | | |
192 | | - | |
| 195 | + | |
193 | 196 | | |
194 | 197 | | |
195 | 198 | | |
| |||
198 | 201 | | |
199 | 202 | | |
200 | 203 | | |
| 204 | + | |
201 | 205 | | |
202 | 206 | | |
203 | 207 | | |
| |||
243 | 247 | | |
244 | 248 | | |
245 | 249 | | |
| 250 | + | |
| 251 | + | |
246 | 252 | | |
247 | 253 | | |
248 | 254 | | |
249 | 255 | | |
250 | 256 | | |
251 | | - | |
| 257 | + | |
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
| |||
259 | 265 | | |
260 | 266 | | |
261 | 267 | | |
| 268 | + | |
262 | 269 | | |
263 | 270 | | |
264 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
570 | 670 | | |
571 | 671 | | |
572 | 672 | | |
| |||
584 | 684 | | |
585 | 685 | | |
586 | 686 | | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
587 | 694 | | |
588 | 695 | | |
589 | 696 | | |
590 | 697 | | |
591 | 698 | | |
592 | 699 | | |
593 | 700 | | |
| 701 | + | |
| 702 | + | |
594 | 703 | | |
595 | 704 | | |
596 | 705 | | |
| |||
629 | 738 | | |
630 | 739 | | |
631 | 740 | | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
632 | 748 | | |
633 | 749 | | |
634 | 750 | | |
| |||
644 | 760 | | |
645 | 761 | | |
646 | 762 | | |
| 763 | + | |
| 764 | + | |
647 | 765 | | |
648 | 766 | | |
649 | 767 | | |
| |||
784 | 902 | | |
785 | 903 | | |
786 | 904 | | |
| 905 | + | |
787 | 906 | | |
788 | 907 | | |
789 | 908 | | |
790 | 909 | | |
791 | 910 | | |
792 | 911 | | |
793 | 912 | | |
| 913 | + | |
794 | 914 | | |
795 | 915 | | |
796 | 916 | | |
797 | 917 | | |
798 | 918 | | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
799 | 924 | | |
800 | 925 | | |
801 | 926 | | |
802 | 927 | | |
803 | 928 | | |
804 | 929 | | |
805 | 930 | | |
| 931 | + | |
| 932 | + | |
806 | 933 | | |
807 | 934 | | |
808 | 935 | | |
809 | 936 | | |
| 937 | + | |
810 | 938 | | |
811 | 939 | | |
812 | 940 | | |
| |||
851 | 979 | | |
852 | 980 | | |
853 | 981 | | |
| 982 | + | |
854 | 983 | | |
855 | 984 | | |
856 | 985 | | |
| |||
863 | 992 | | |
864 | 993 | | |
865 | 994 | | |
| 995 | + | |
866 | 996 | | |
867 | 997 | | |
868 | 998 | | |
| |||
887 | 1017 | | |
888 | 1018 | | |
889 | 1019 | | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
890 | 1025 | | |
891 | 1026 | | |
892 | 1027 | | |
| |||
900 | 1035 | | |
901 | 1036 | | |
902 | 1037 | | |
| 1038 | + | |
| 1039 | + | |
903 | 1040 | | |
904 | 1041 | | |
905 | 1042 | | |
906 | 1043 | | |
907 | 1044 | | |
908 | 1045 | | |
909 | 1046 | | |
| 1047 | + | |
910 | 1048 | | |
911 | 1049 | | |
912 | 1050 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
| 424 | + | |
| 425 | + | |
424 | 426 | | |
425 | 427 | | |
426 | 428 | | |
| |||
493 | 495 | | |
494 | 496 | | |
495 | 497 | | |
| 498 | + | |
| 499 | + | |
496 | 500 | | |
497 | 501 | | |
498 | 502 | | |
| |||
0 commit comments