Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
606888e
refactor(key-wallet)!: derive pool addresses in one place
ZocoLini Nov 11, 2026
58e89b8
refactor(key-wallet)!: mark pool addresses used by address only
ZocoLini Nov 11, 2026
0d93557
refactor(key-wallet)!: drop unused `AddressPool` API
ZocoLini Nov 11, 2026
cc41eb6
refactor(key-wallet)!: drop unused batch address getters
ZocoLini Nov 11, 2026
f5036cb
refactor(key-wallet): drop redundant `NoKeySource` checks in `Address…
ZocoLini Nov 11, 2026
e493ee2
refactor(key-wallet): simplify `AddressPool::address_info_mut`
ZocoLini Nov 11, 2026
67fa80d
refactor(key-wallet): build `AddressInfo` through one constructor
ZocoLini Nov 11, 2026
83eafc1
refactor(key-wallet)!: derive `AddressPool` high-water marks from its…
ZocoLini Nov 11, 2026
e3de006
refactor(key-wallet)!: drop unused `AddressPool` and `AddressInfo` fi…
ZocoLini Nov 11, 2026
d1520f3
refactor(key-wallet)!: always store derived pool addresses
ZocoLini Nov 11, 2026
14e8537
docs(key-wallet): drop links to crate-private pool methods
ZocoLini Nov 11, 2026
f92e77a
refactor(key-wallet)!: drop unused `GapLimit` tracker
ZocoLini Nov 11, 2026
6147e3d
refactor(key-wallet)!: move gap limit constants into `address_pool`
ZocoLini Nov 11, 2026
fd68794
docs(key-wallet): remove stale implementation notes
ZocoLini Nov 11, 2026
17f1b9c
refactor(key-wallet): derive serde for `PublicKeyType`
ZocoLini Nov 11, 2026
7ea1be5
fix(key-wallet): clamp pool gap limit and saturate derive counts
ZocoLini Nov 11, 2026
0458fdd
refactor(key-wallet)!: make `AddressPool` fields private
ZocoLini Nov 11, 2026
0b1dfb6
test(key-wallet): drop vacuous change address assertion
ZocoLini Nov 11, 2026
a4c8be8
fix(key-wallet): reject duplicates in `AddressPool::insert`
ZocoLini Nov 11, 2026
749029c
refactor(key-wallet)!: drop `script_pubkey` from `AddressInfo`
ZocoLini Nov 12, 2026
108e52c
docs(key-wallet): fix the `add_funding` change-address note
ZocoLini Nov 12, 2026
850431f
fix(key-wallet): reject index gaps in `AddressPool::insert`
ZocoLini Nov 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions dash-spv/src/sync/filters/coinjoin_gap_discovery_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use dashcore::{
Address, Block, BlockHash, Network, OutPoint, Transaction, TxIn, TxOut, Txid, Witness,
};
use key_wallet::account::ManagedAccountTrait;
use key_wallet::gap_limit::DEFAULT_COINJOIN_GAP_LIMIT;
use key_wallet::managed_account::address_pool::DEFAULT_COINJOIN_GAP_LIMIT;
use key_wallet::managed_account::address_pool::{AddressPool, AddressPoolType};
use key_wallet::wallet::initialization::WalletAccountCreationOptions;
use key_wallet::wallet::managed_wallet_info::ManagedWalletInfo;
Expand Down Expand Up @@ -111,7 +111,7 @@ fn coinjoin_external_pool(info: &ManagedWalletInfo) -> &AddressPool {
.managed_account_type()
.address_pools()
.into_iter()
.find(|p| p.pool_type == AddressPoolType::External)
.find(|p| p.pool_type() == AddressPoolType::External)
.expect("CoinJoin External pool")
}

Expand All @@ -124,7 +124,11 @@ async fn coinjoin_pool_state(
let wm = wallet.read().await;
let info = wm.get_wallet_info(wallet_id).expect("wallet info present");
let pool = coinjoin_external_pool(info);
(pool.highest_used, pool.highest_generated, pool.used_indices.len())
(
pool.highest_used(),
pool.highest_generated(),
pool.addresses().values().filter(|info| info.is_used()).count(),
)
}

/// One block at `height` whose single transaction pays every address in
Expand Down
2 changes: 1 addition & 1 deletion dash-spv/src/sync/mempool/sync_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ mod tests {
let address = preview
.bip44_managed_account_at_index_mut(1)
.unwrap()
.next_receive_address(None, true)
.next_receive_address(None)
.unwrap();
let mut funding = Transaction::dummy(&ctx.receive_address, 0..1, &[100_000]);
funding.output.push(TxOut {
Expand Down
2 changes: 1 addition & 1 deletion dash-spv/tests/dashd_sync/tests_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use dash_spv::test_utils::{create_test_wallet, TestChain};
use dashcore::PublicKey;
use key_wallet::account::ManagedAccountTrait;
use key_wallet::bip32::{ChildNumber, ExtendedPrivKey};
use key_wallet::gap_limit::DEFAULT_EXTERNAL_GAP_LIMIT;
use key_wallet::managed_account::address_pool::DEFAULT_EXTERNAL_GAP_LIMIT;
use key_wallet::mnemonic::Mnemonic;
use key_wallet::wallet::balance::WalletCoreBalance;
use key_wallet::wallet::initialization::WalletAccountCreationOptions;
Expand Down
2 changes: 1 addition & 1 deletion key-wallet-manager/benches/filter_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn wallet_with_mixing_history(used: u32) -> (Manager, [u8; 32]) {
panic!("expected CoinJoin managed account type");
};
external_addresses
.generate_addresses(used, &key_source, true)
.generate_addresses(used, &key_source)
.expect("derive CoinJoin addresses");
external_addresses.all_addresses()
};
Expand Down
11 changes: 6 additions & 5 deletions key-wallet-manager/src/event_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ async fn test_block_with_index_less_account_tx_carries_account_type() {
.expect("wallet info")
.identity_registration_managed_account_mut()
.expect("managed IdentityRegistration account")
.next_address(Some(&xpub), true)
.next_address(Some(&xpub))
.expect("identity registration address");

// Build a DIP-2 AssetLock transaction whose `credit_outputs` pay to the
Expand Down Expand Up @@ -1439,8 +1439,8 @@ fn pool_state(
) => internal_addresses,
_ => panic!("unexpected pool type {:?}", pool_type),
};
let highest = pool.highest_generated.expect("pre-generated pool must have addresses");
let gap_limit = pool.gap_limit;
let highest = pool.highest_generated().expect("pre-generated pool must have addresses");
let gap_limit = pool.gap_limit();
let addr = pool.address_at_index(highest).expect("highest index must exist");
(highest, gap_limit, addr)
}
Expand Down Expand Up @@ -1536,7 +1536,8 @@ async fn test_mempool_tx_to_highest_external_carries_addresses_derived() {
// Pin the persistence-critical payload against the wallet's
// own AddressInfo for the same index.
let stored = external_pool_after
.info_at_index(derived.derivation_index)
.addresses()
.get(&derived.derivation_index)
.unwrap_or_else(|| panic!("pool missing index {}", derived.derivation_index));
assert_eq!(
derived.address, stored.address,
Expand Down Expand Up @@ -2321,7 +2322,7 @@ async fn late_funding_block_publishes_spender_correction() {
.unwrap()
.first_bip44_managed_account_mut()
.unwrap()
.next_change_address(None, true)
.next_change_address(None)
.unwrap();
let funding = create_tx_paying_to(&addr, 0xd5);
let mut spender = create_tx_paying_to(&change, 0xd6);
Expand Down
9 changes: 0 additions & 9 deletions key-wallet-manager/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@ mod project_derived_addresses_tests {
use key_wallet::account::StandardAccountType;
use key_wallet::bip32::{ChildNumber, DerivationPath};
use key_wallet::managed_account::address_pool::{AddressInfo, AddressState};
use std::collections::BTreeMap;

/// Compressed encoding of the secp256k1 generator point (G).
const TEST_PUBKEY_G: [u8; 33] = [
Expand Down Expand Up @@ -661,7 +660,6 @@ mod project_derived_addresses_tests {
let pubkey =
dashcore::PublicKey::from_slice(&TEST_PUBKEY_G).expect("generator point is valid");
let address = dashcore::Address::p2pkh(&pubkey, key_wallet::Network::Testnet);
let script_pubkey = address.script_pubkey();
let path = DerivationPath::from(vec![
ChildNumber::from_normal_idx(0).unwrap(),
ChildNumber::from_normal_idx(index).unwrap(),
Expand All @@ -676,17 +674,10 @@ mod project_derived_addresses_tests {
pool_type,
info: AddressInfo {
address,
script_pubkey,
public_key: Some(PublicKeyType::ECDSA(pubkey_bytes)),
index,
path,
state: AddressState::Available,
tx_count: 0,
total_received: 0,
total_sent: 0,
balance: 0,
label: None,
metadata: BTreeMap::new(),
},
}
}
Expand Down
8 changes: 4 additions & 4 deletions key-wallet-manager/src/process_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<T: WalletInfoInterface + Send + Sync + 'static> WalletInterface for WalletM
for (wallet_id, derived) in check_result.new_addresses {
derived_wallets.insert(wallet_id);
let scripts =
derived.iter().map(|d| d.info.script_pubkey.clone()).collect::<Vec<_>>();
derived.iter().map(|d| d.info.address.script_pubkey()).collect::<Vec<_>>();
result.new_scripts.entry(wallet_id).or_default().extend(scripts);
per_wallet_derived.entry(wallet_id).or_default().extend(derived);
}
Expand Down Expand Up @@ -729,8 +729,8 @@ mod tests {
};
use key_wallet::account::ManagedAccountTrait as _;
use key_wallet::account::StandardAccountType;
use key_wallet::gap_limit::DEFAULT_COINJOIN_GAP_LIMIT;
use key_wallet::managed_account::address_pool::AddressPoolType;
use key_wallet::managed_account::address_pool::DEFAULT_COINJOIN_GAP_LIMIT;
use key_wallet::mnemonic::Language;
use key_wallet::wallet::initialization::WalletAccountCreationOptions;
use key_wallet::wallet::managed_wallet_info::transaction_building::AccountTypePreference;
Expand Down Expand Up @@ -1051,8 +1051,8 @@ mod tests {
.managed_account_type()
.address_pools()
.iter()
.find(|p| p.pool_type == AddressPoolType::External)
.and_then(|p| p.highest_used);
.find(|p| p.pool_type() == AddressPoolType::External)
.and_then(|p| p.highest_used());
assert_eq!(pool_used, Some(gap + 8));

let txids = BTreeSet::from([early.txid(), late.txid(), both.txid()]);
Expand Down
4 changes: 2 additions & 2 deletions key-wallet-manager/src/test_utils/coinjoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ pub fn coinjoin_external_addresses(
let pools = account.managed_account_type().address_pools();
let live = pools
.iter()
.find(|p| p.pool_type == AddressPoolType::External)
.find(|p| p.pool_type() == AddressPoolType::External)
.expect("CoinJoin External pool");
let pool = AddressPool::new(
live.base_path.clone(),
live.base_path().clone(),
AddressPoolType::External,
count,
wallet.network,
Expand Down
2 changes: 1 addition & 1 deletion key-wallet-manager/tests/spv_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async fn test_immature_balance_matures_during_block_processing() {
wallet_info
.first_bip44_managed_account_mut()
.expect("Should have managed account")
.next_receive_address(Some(&account_xpub), true)
.next_receive_address(Some(&account_xpub))
.expect("Should get address")
};

Expand Down
3 changes: 1 addition & 2 deletions key-wallet/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ This crate handles key material. Correctness comes before performance, and priva

- `wallet/`: `Wallet` and its construction, backup and restore. `wallet/managed_wallet_info/` holds `ManagedWalletInfo` plus coin selection, fees and transaction building.
- `account/`: `Account`, `AccountType` and `AccountCollection`, with the BLS and EdDSA variants.
- `managed_account/`: the mutable account state and `AddressPool`.
- `managed_account/`: the mutable account state, and `AddressPool` with the default gap limits and `MAX_GAP_LIMIT`.
- `transaction_checking/`: `TransactionRouter` and the `WalletTransactionChecker` trait that decides which transactions belong to the wallet.
- `bip32.rs`, `dip9.rs`, `derivation*.rs`, `mnemonic.rs`, `seed.rs`: key derivation and the DIP-9 path constants.
- `gap_limit.rs`: the default gap limits and `MAX_GAP_LIMIT`.
- `src/tests/`: crate-level tests grouped by topic. `src/test_utils/`: helpers behind the `test-utils` feature.

## Invariants
Expand Down
200 changes: 0 additions & 200 deletions key-wallet/IMPLEMENTATION_SUMMARY.md

This file was deleted.

Loading
Loading