Skip to content

Commit

Permalink
Create InternalCapability capability trait
Browse files Browse the repository at this point in the history
  • Loading branch information
pacu committed Nov 18, 2024
1 parent 1ca832e commit 2a98a4f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion zingolib/src/wallet/keys/ledger.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// Holds information related to the ledger
//! Holds information related to the ledger



Expand Down
45 changes: 45 additions & 0 deletions zingolib/src/wallet/keys/unified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,50 @@ fn read_write_receiver_selections() {
}
}

pub (crate) trait InternalCapability {
fn get_ua_from_contained_transparent_receiver(
&self,
capability: WalletCapability,
receiver: &TransparentAddress,
) -> Option<UnifiedAddress>;

fn addresses(&self, capability: WalletCapability) -> &AppendOnlyVec<UnifiedAddress>;

fn transparent_child_addresses(
&self,
capability: WalletCapability
) -> &Arc<AppendOnlyVec<(usize, TransparentAddress)>>;

fn new_address(
&self,
capability: WalletCapability,
desired_receivers: ReceiverSelection,
legacy_key: bool,
) -> Result<UnifiedAddress, String>;

fn generate_transparent_receiver(
&self,
capability: WalletCapability,
// this should only be `true` when generating transparent addresses while loading from legacy keys (pre wallet version 29)
// legacy transparent keys are already derived to the external scope so setting `legacy_key` to `true` will skip this scope derivation
legacy_key: bool,
) -> Result<Option<TransparentAddress>, bip32::Error>;

/// TODO: Add Doc Comment Here!
#[deprecated(note = "not used in zingolib codebase")]
fn get_taddr_to_secretkey_map(
&self,
capability: WalletCapability,
chain: &ChainType,
) -> Result<HashMap<String, secp256k1::SecretKey>, KeyError>;

fn first_sapling_address(&self, capability: WalletCapability) -> sapling_crypto::PaymentAddress;

fn get_trees_witness_trees(&self, capability: WalletCapability) -> Option<crate::data::witness_trees::WitnessTrees>;

fn can_view(&self, capability: WalletCapability) -> ReceiverSelection;
}

impl WalletCapability {
#[cfg(feature = "ledger-support")]
/// checks whether this WalletCapability is a Ledger device or not
Expand Down Expand Up @@ -604,6 +648,7 @@ impl WalletCapability {
.collect()
}

/// TODO: This does not appear to be used
pub(crate) fn get_taddrs(&self, chain: &crate::config::ChainType) -> HashSet<String> {
self.get_external_taddrs(chain)
.union(&self.get_rejection_address_set(chain))
Expand Down

0 comments on commit 2a98a4f

Please sign in to comment.