Skip to content

fix(key-wallet): discover Coinbase/AssetUnlock outputs for all fund-bearing accounts#901

Draft
thepastaclaw wants to merge 4 commits into
dashpay:devfrom
thepastaclaw:tracker-2100
Draft

fix(key-wallet): discover Coinbase/AssetUnlock outputs for all fund-bearing accounts#901
thepastaclaw wants to merge 4 commits into
dashpay:devfrom
thepastaclaw:tracker-2100

Conversation

@thepastaclaw

Copy link
Copy Markdown
Contributor

Summary

TransactionRouter::get_relevant_account_types returned only StandardBIP44 and StandardBIP32 for Coinbase and AssetUnlock, while fund_bearing_account_types() is {StandardBIP44, StandardBIP32, CoinJoin, DashpayReceivingFunds, DashpayExternalAccount}. An output of a coinbase (masternode payout / mining reward) or an asset-unlock (Platform credit withdrawal) that pays a CoinJoin or DashPay address was therefore never matched, so the coin was never credited and the balance undercounted.

This is the credit-side mirror of the debit-side routing bug fixed in #867 for AssetLock. The same membership-based reasoning applies: discovery is like Dash Core's IsMine, so consulting the full fund-bearing set cannot yield a false positive. Ownership still requires a scriptPubKey or spent UTXO that actually belongs to the account.

Note the filter layer already does the right thing — the wallet queries all of its scripts, so the block is downloaded on a match. The output was then dropped purely by the account-type narrowing (wasted download + lost coin).

Closes #900

The fix

Replace the hand-written type lists in the Coinbase and AssetUnlock arms with fund_bearing_account_types(), mirroring #867. Roughly -8/+4 in production code; no signature changes.

Also corrected the stale Coinbase comment that said "Check all account types" while listing only two.

Membership safety (verified against source)

Tests

  • Router unit tests for Coinbase and AssetUnlock assert equality with fund_bearing_account_types() (single source of truth).
  • Behavioral regressions:
    • test_coinbase_paying_coinjoin_address_is_credited — coinbase to CoinJoin creates UTXO + immature/total balance credit.
    • test_asset_unlock_paying_coinjoin_address_is_credited — AssetUnlock to CoinJoin creates UTXO + confirmed/total balance credit.
  • Shared wallet_with_coinjoin_address() fixture for the credit tests.

Validation

cargo test -p key-wallet --lib transaction_checking   # 107 passed
cargo clippy -p key-wallet --all-targets -- -D warnings
cargo fmt -p key-wallet -- --check

Related

Coinbase and AssetUnlock outputs can pay any user-chosen address, including
CoinJoin and DashPay. get_relevant_account_types previously returned only
StandardBIP44/BIP32 for those classifications, so a match on those addresses
was dropped after the block download — the credit-side mirror of the dashpay#867
AssetLock debit bug.

Use fund_bearing_account_types() for both arms (membership-based discovery,
like Dash Core's IsMine). Update routing unit tests to expect all five
fund-bearing types.

Closes dashpay#900
End-to-end regressions for dashpay#900: a coinbase mining reward and an AssetUnlock
Platform withdrawal that pay a CoinJoin address must be discovered, create a
UTXO on that account, and credit the wallet balance. Mirrors the dashpay#867
AssetLock debit regression shape; fails on pre-fix routing where only
StandardBIP44/BIP32 were consulted for those classifications.
…serts

Extract wallet_with_coinjoin_address() for the dashpay#900 credit regressions and
assert Coinbase/AssetUnlock routing against fund_bearing_account_types()
instead of re-listing the five types. Keeps the production list as the single
source of truth for those unit tests.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: baeb399f-82be-4af6-ad45-f32147025fe3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.22%. Comparing base (19690d3) to head (b0c9aec).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #901      +/-   ##
==========================================
- Coverage   74.54%   74.22%   -0.33%     
==========================================
  Files         327      327              
  Lines       75032    75161     +129     
==========================================
- Hits        55936    55786     -150     
- Misses      19096    19375     +279     
Flag Coverage Δ
core 77.29% <ø> (ø)
ffi 48.55% <ø> (-2.40%) ⬇️
rpc 20.00% <ø> (ø)
spv 91.01% <ø> (-0.20%) ⬇️
wallet 74.57% <100.00%> (+0.15%) ⬆️
Files with missing lines Coverage Δ
...src/transaction_checking/transaction_router/mod.rs 88.88% <100.00%> (-0.26%) ⬇️
...-wallet/src/transaction_checking/wallet_checker.rs 99.31% <100.00%> (+0.06%) ⬆️

... and 23 files with indirect coverage changes

@thepastaclaw

Copy link
Copy Markdown
Contributor Author

The failed Windows / spv job is unrelated to this PR. This branch changes only key-wallet transaction routing and focused wallet tests; it does not touch dash-spv, dash-spv/src/test_utils/node.rs, or tests/dashd_sync.

The job failed in the shared Windows dashd integration harness while starting nodes: two tests timed out waiting for dashd, and another hit create_wallet("default") after the database path already existed. The same Windows-only failure signature occurred on merged PR #891, whose diff was likewise confined to key-wallet/key-wallet-manager, but with a different set of dashd_sync tests failing. Ubuntu, Ubuntu ARM, and macOS SPV all pass here.

The PR is proper as-is; no branch change or CI retrigger is warranted. I filed #903 to track the pre-existing Windows integration-test flake with both run links and investigation notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

key-wallet: coinbase and asset-unlock outputs paying CoinJoin/DashPay addresses are never discovered

1 participant