Skip to content

Commit

Permalink
feat(auditor): skip royalty track using default key
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Jun 11, 2024
1 parent 84156b3 commit 965d180
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sn_client/src/audit/dag_crawling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use crate::{Client, Error, SpendDag};
use futures::{future::join_all, StreamExt};
use sn_networking::{GetRecordError, NetworkError};
use sn_transfers::{
SignedSpend, SpendAddress, SpendReason, WalletError, WalletResult, GENESIS_SPEND_UNIQUE_KEY,
NETWORK_ROYALTIES_PK,
SignedSpend, SpendAddress, SpendReason, WalletError, WalletResult,
DEFAULT_NETWORK_ROYALTIES_PK, GENESIS_SPEND_UNIQUE_KEY, NETWORK_ROYALTIES_PK,
};
use std::{
collections::{BTreeMap, BTreeSet},
Expand Down Expand Up @@ -520,13 +520,22 @@ fn beta_track_analyze_spend(spend: &SignedSpend) -> BTreeSet<SpendAddress> {
.iter()
.map(|derivation_idx| NETWORK_ROYALTIES_PK.new_unique_pubkey(derivation_idx))
.collect();
let default_royalty_pubkeys: BTreeSet<_> = spend
.spend
.network_royalties
.iter()
.map(|derivation_idx| DEFAULT_NETWORK_ROYALTIES_PK.new_unique_pubkey(derivation_idx))
.collect();

let new_utxos: BTreeSet<_> = spend
.spend
.spent_tx
.outputs
.iter()
.filter_map(|output| {
if default_royalty_pubkeys.contains(&output.unique_pubkey) {
return None;
}
if !royalty_pubkeys.contains(&output.unique_pubkey) {
Some(SpendAddress::from_unique_pubkey(&output.unique_pubkey))
} else {
Expand Down
6 changes: 6 additions & 0 deletions sn_transfers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ lazy_static! {
Err(err) => panic!("Failed to parse network royalties PK: {err:?}"),
}
};
pub static ref DEFAULT_NETWORK_ROYALTIES_PK: MainPubkey = {
match MainPubkey::from_hex(DEFAULT_NETWORK_ROYALTIES_STR) {
Ok(pk) => pk,
Err(err) => panic!("Failed to parse default network royalties PK: {err:?}"),
}
};
}

lazy_static! {
Expand Down

0 comments on commit 965d180

Please sign in to comment.