Skip to content

Commit 9efd1eb

Browse files
committed
Ignore proxy accounts on load
1 parent 67eb22a commit 9efd1eb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

crates/signer/src/manager/dirk.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,11 @@ fn load_simple_accounts(
560560
consensus_accounts: &mut HashMap<BlsPublicKey, Account>,
561561
) {
562562
for account in accounts {
563+
if name_matches_proxy(&account.name) {
564+
debug!(account = account.name, "Ignoring account assuming it's a proxy key");
565+
continue;
566+
}
567+
563568
match BlsPublicKey::try_from(account.public_key.as_slice()) {
564569
Ok(public_key) => {
565570
consensus_accounts.insert(
@@ -593,6 +598,11 @@ fn load_distributed_accounts(
593598
.ok_or(eyre::eyre!("Host name not found for server {}", host.url))?;
594599

595600
for account in accounts {
601+
if name_matches_proxy(&account.name) {
602+
debug!(account = account.name, "Ignoring account assuming it's a proxy key");
603+
continue;
604+
}
605+
596606
let Ok(public_key) = BlsPublicKey::try_from(account.composite_public_key.as_slice()) else {
597607
warn!("Failed to parse composite public key for account {}", account.name);
598608
continue;
@@ -679,6 +689,14 @@ fn random_password() -> String {
679689
hex::encode(password_bytes)
680690
}
681691

692+
/// Returns whether the name of an account has a proxy name format.
693+
///
694+
/// i.e., `{wallet}/{consensus_proxy}/{module}/{uuid}`
695+
fn name_matches_proxy(name: &str) -> bool {
696+
name.split("/").count() > 3 &&
697+
name.rsplit_once("/").is_some_and(|(_, name)| uuid::Uuid::parse_str(name).is_ok())
698+
}
699+
682700
mod test {
683701

684702
#[test]

0 commit comments

Comments
 (0)