From 8a003ecee31b09011199f59d70f252f0d676d132 Mon Sep 17 00:00:00 2001 From: pasta Date: Mon, 7 Sep 2026 17:24:39 -0500 Subject: [PATCH 1/2] fix(key-wallet): discover DashPay asset unlock receipts --- CHANGELOG.md | 6 ++ .../transaction_router/mod.rs | 4 +- .../transaction_router/tests/asset_unlock.rs | 70 ++++++++++++++++++- 3 files changed, 76 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9dd317ca..e87be81bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## Unreleased + +### Fixed + +- Discover AssetUnlock withdrawal receipts in DashPay and CoinJoin accounts. + ## 0.44.0 - 2026-07-01 ### Added diff --git a/key-wallet/src/transaction_checking/transaction_router/mod.rs b/key-wallet/src/transaction_checking/transaction_router/mod.rs index 51f35acbe..29436fde2 100644 --- a/key-wallet/src/transaction_checking/transaction_router/mod.rs +++ b/key-wallet/src/transaction_checking/transaction_router/mod.rs @@ -157,7 +157,9 @@ impl TransactionRouter { accounts } TransactionType::AssetUnlock => { - vec![AccountTypeToCheck::StandardBIP44, AccountTypeToCheck::StandardBIP32] + // Withdrawal outputs may pay any owned script, including DIP-15 contact + // addresses. Restricting discovery to standard accounts loses those receipts. + Self::fund_bearing_account_types() } TransactionType::Coinbase => vec![ // Check all account types for unknown special transactions diff --git a/key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs b/key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs index 6371710b1..11d5a9718 100644 --- a/key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs +++ b/key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs @@ -21,8 +21,11 @@ fn test_asset_unlock_routing() { let tx_type = TransactionType::AssetUnlock; let accounts = TransactionRouter::get_relevant_account_types(&tx_type); - // Asset unlock only goes to standard accounts - assert_eq!(accounts.len(), 2); + // Withdrawals can pay any fund-bearing account. + assert_eq!(accounts.len(), 5); + assert!(accounts.contains(&AccountTypeToCheck::CoinJoin)); + assert!(accounts.contains(&AccountTypeToCheck::DashpayReceivingFunds)); + assert!(accounts.contains(&AccountTypeToCheck::DashpayExternalAccount)); assert!(accounts.contains(&AccountTypeToCheck::StandardBIP44)); assert!(accounts.contains(&AccountTypeToCheck::StandardBIP32)); @@ -62,7 +65,7 @@ fn test_asset_unlock_classification() { // Verify routing for AssetUnlock let accounts = TransactionRouter::get_relevant_account_types(&tx_type); - assert_eq!(accounts.len(), 2, "AssetUnlock should route to exactly 2 account types"); + assert_eq!(accounts.len(), 5, "AssetUnlock must check every fund-bearing account"); assert!(accounts.contains(&AccountTypeToCheck::StandardBIP44)); assert!(accounts.contains(&AccountTypeToCheck::StandardBIP32)); } @@ -195,3 +198,64 @@ async fn test_asset_unlock_routing_to_bip32_account() { "Asset unlock should have affected the BIP44 account" ); } + +/// A Platform withdrawal has no Core inputs and can pay a DIP-15 contact address. +#[tokio::test] +async fn test_asset_unlock_credits_dashpay_contact() { + use crate::account::AccountType; + use crate::managed_account::managed_account_trait::ManagedAccountTrait; + use crate::wallet::managed_wallet_info::managed_account_operations::ManagedAccountOperations; + use crate::{KeySource, ManagedAccountType}; + + let mut ctx = TestWalletContext::new_random(); + let account_type = AccountType::DashpayReceivingFunds { + index: 0, + user_identity_id: [0xaa; 32], + friend_identity_id: [0xbb; 32], + }; + ctx.wallet.add_account(account_type, None).unwrap(); + ctx.managed_wallet.add_managed_account(&ctx.wallet, account_type).unwrap(); + let xpub = ctx.wallet.accounts.account_of_type(account_type).unwrap().account_xpub; + let account = ctx.managed_wallet.accounts.funds_account_mut(&account_type).unwrap(); + let ManagedAccountType::DashpayReceivingFunds { + addresses, + .. + } = account.managed_account_type_mut() + else { + panic!("expected contact account"); + }; + let address = addresses.next_unused(&KeySource::Public(xpub), true).unwrap(); + let mut tx = Transaction::dummy(&address, 0..0, &[2_000_000]); + tx.version = 3; + tx.special_transaction_payload = + Some(TransactionPayload::AssetUnlockPayloadType(AssetUnlockPayload { + base: AssetUnlockBasePayload { + version: 1, + index: 42, + fee: 1000, + }, + request_info: AssetUnlockRequestInfo { + request_height: 500000, + quorum_hash: [5u8; 32].into(), + }, + quorum_sig: BLSSignature::from([6u8; 96]), + })); + let context = TransactionContext::InBlock(BlockInfo::new( + 500100, + BlockHash::from_byte_array([7; 32]), + 1234567890, + )); + let result = ctx.check_transaction(&tx, context.clone()).await; + assert!(result.is_relevant, "withdrawal to a contact must be discovered"); + assert_eq!(result.total_received, 2_000_000); + let outpoint = OutPoint { + txid: tx.txid(), + vout: 0, + }; + let account = ctx.managed_wallet.accounts.funds_account_mut(&account_type).unwrap(); + assert_eq!(account.utxos.get(&outpoint).unwrap().txout.value, 2_000_000); + assert!(account.transactions().contains_key(&tx.txid())); + ctx.check_transaction(&tx, context).await; + let account = ctx.managed_wallet.accounts.funds_account_mut(&account_type).unwrap(); + assert_eq!(account.utxos.len(), 1, "block replay must not duplicate funds"); +} From 7afab3cd3ba676971e14db2fd1a21d0230848101 Mon Sep 17 00:00:00 2001 From: pasta Date: Mon, 7 Sep 2026 21:04:44 -0500 Subject: [PATCH 2/2] docs: leave changelog updates to release preparation --- CHANGELOG.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e87be81bd..a9dd317ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,6 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). -## Unreleased - -### Fixed - -- Discover AssetUnlock withdrawal receipts in DashPay and CoinJoin accounts. - ## 0.44.0 - 2026-07-01 ### Added