Skip to content

Commit

Permalink
fix standalone key regression
Browse files Browse the repository at this point in the history
  • Loading branch information
OBorce committed Feb 3, 2025
1 parent f4c9b41 commit f16c3e3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
5 changes: 2 additions & 3 deletions wallet/src/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,12 +850,11 @@ impl<K: AccountKeyChains> Account<K> {
.into_iter()
.filter(|(_, pool_data)| match filter {
WalletPoolsFilter::All => true,
// FIXME for standalone private keys
WalletPoolsFilter::Decommission => {
self.key_chain.is_destination_mine(&pool_data.decommission_key)
self.key_chain.has_private_key_for_destination(&pool_data.decommission_key)
}
WalletPoolsFilter::Stake => {
self.key_chain.is_destination_mine(&pool_data.stake_destination)
self.key_chain.has_private_key_for_destination(&pool_data.stake_destination)
}
})
.collect()
Expand Down
5 changes: 5 additions & 0 deletions wallet/src/key_chain/account_key_chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ impl<V: VrfKeyChain> AccountKeyChains for AccountKeyChainImpl<V> {
Ok(())
}

fn has_private_key_for_destination(&self, destination: &Destination) -> bool {
self.is_destination_mine(destination)
|| self.standalone_private_keys.contains_key(destination)
}

// Return true if the provided destination belongs to this key chain
fn is_destination_mine(&self, destination: &Destination) -> bool {
KeyPurpose::ALL
Expand Down
2 changes: 2 additions & 0 deletions wallet/src/key_chain/account_key_chain/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ fn check_mine_methods(#[case] public: &str) {
assert!(key_chain.is_public_key_hash_mine(&pkh));
assert!(key_chain.is_destination_mine(&addr_destination));
assert!(key_chain.is_destination_mine(&pk_destination));
assert!(key_chain.has_private_key_for_destination(&addr_destination));
assert!(key_chain.has_private_key_for_destination(&pk_destination));
}
3 changes: 3 additions & 0 deletions wallet/src/key_chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ where
// Return true if the provided destination belongs to this key chain
fn is_destination_mine(&self, destination: &Destination) -> bool;

// Return true if we have the private key for the provided destination
fn has_private_key_for_destination(&self, destination: &Destination) -> bool;

// Return true if the provided public key belongs to this key chain
fn is_public_key_mine(&self, public_key: &PublicKey) -> bool;

Expand Down

0 comments on commit f16c3e3

Please sign in to comment.