Skip to content

Commit 69592f8

Browse files
committed
fix standalone key regression
1 parent 0d5722a commit 69592f8

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

wallet/src/account/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,12 +850,11 @@ impl<K: AccountKeyChains> Account<K> {
850850
.into_iter()
851851
.filter(|(_, pool_data)| match filter {
852852
WalletPoolsFilter::All => true,
853-
// FIXME for standalone private keys
854853
WalletPoolsFilter::Decommission => {
855-
self.key_chain.is_destination_mine(&pool_data.decommission_key)
854+
self.key_chain.has_private_key_for_destination(&pool_data.decommission_key)
856855
}
857856
WalletPoolsFilter::Stake => {
858-
self.key_chain.is_destination_mine(&pool_data.stake_destination)
857+
self.key_chain.has_private_key_for_destination(&pool_data.stake_destination)
859858
}
860859
})
861860
.collect()

wallet/src/key_chain/account_key_chain/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,11 @@ impl<V: VrfKeyChain> AccountKeyChains for AccountKeyChainImpl<V> {
432432
Ok(())
433433
}
434434

435+
fn has_private_key_for_destination(&self, destination: &Destination) -> bool {
436+
self.is_destination_mine(destination)
437+
|| self.standalone_private_keys.contains_key(destination)
438+
}
439+
435440
// Return true if the provided destination belongs to this key chain
436441
fn is_destination_mine(&self, destination: &Destination) -> bool {
437442
KeyPurpose::ALL

wallet/src/key_chain/account_key_chain/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,6 @@ fn check_mine_methods(#[case] public: &str) {
6060
assert!(key_chain.is_public_key_hash_mine(&pkh));
6161
assert!(key_chain.is_destination_mine(&addr_destination));
6262
assert!(key_chain.is_destination_mine(&pk_destination));
63+
assert!(key_chain.has_private_key_for_destination(&addr_destination));
64+
assert!(key_chain.has_private_key_for_destination(&pk_destination));
6365
}

wallet/src/key_chain/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ where
187187
// Return true if the provided destination belongs to this key chain
188188
fn is_destination_mine(&self, destination: &Destination) -> bool;
189189

190+
// Return true if we have the private key for the provided destination
191+
fn has_private_key_for_destination(&self, destination: &Destination) -> bool;
192+
190193
// Return true if the provided public key belongs to this key chain
191194
fn is_public_key_mine(&self, public_key: &PublicKey) -> bool;
192195

0 commit comments

Comments
 (0)