Skip to main content

DerivedAccount

Struct DerivedAccount 

Source
#[non_exhaustive]
pub struct DerivedAccount { pub path: String, pub private_key: Zeroizing<String>, pub public_key: String, pub address: String, }
Expand description

A derived account from any chain.

Contains the derivation path, key material, and on-chain address. The private key is zeroized on drop.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§path: String

BIP-32/SLIP-10 derivation path used (e.g. m/44'/60'/0'/0/0).

§private_key: Zeroizing<String>

Private key in hex (zeroized on drop).

§public_key: String

Public key in hex.

§address: String

On-chain address in the chain’s native format.

Implementations§

Source§

impl DerivedAccount

Source

pub const fn new( path: String, private_key: Zeroizing<String>, public_key: String, address: String, ) -> Self

Create a new derived account.

Source

pub fn private_key_bytes(&self) -> Result<Zeroizing<[u8; 32]>, DeriveError>

Decode the hex-encoded private key into raw 32-byte material.

Every chain deriver in this workspace produces a 32-byte scalar (secp256k1 for EVM/BTC/Cosmos/Tron/Spark/Filecoin/XRPL/Nostr, Ed25519 for SVM/SUI/TON/Aptos), so the output is fixed-length. The returned buffer is zeroized on drop.

§Errors

Returns an error if the stored hex is malformed or not exactly 32 bytes. Derivers in this workspace never produce malformed data, so this error is unexpected in normal use.

Source

pub fn public_key_bytes(&self) -> Result<Vec<u8>, DeriveError>

Decode the hex-encoded public key into raw bytes.

Length is chain-specific: 33 for compressed secp256k1, 65 for uncompressed, 32 for Ed25519 / x-only secp256k1.

§Errors

Returns an error if the stored hex is malformed.

Trait Implementations§

Source§

impl Clone for DerivedAccount

Source§

fn clone(&self) -> DerivedAccount

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DerivedAccount

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.