pub struct CosmosPrivateKey(_);
Expand description

This structure represents a private key of a Cosmos Network.

Implementations§

source§

impl CosmosPrivateKey

source

pub fn to_public_key( &self, prefix: &str ) -> Result<CosmosPublicKey, PrivateKeyError>

Obtain a public key for a given private key

Trait Implementations§

source§

impl Clone for CosmosPrivateKey

source§

fn clone(&self) -> CosmosPrivateKey

Returns a copy 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 CosmosPrivateKey

source§

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

Formats the value using the given formatter. Read more
source§

impl FromStr for CosmosPrivateKey

§

type Err = PrivateKeyError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for CosmosPrivateKey

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<CosmosPrivateKey> for CosmosPrivateKey

source§

fn eq(&self, other: &CosmosPrivateKey) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PrivateKey for CosmosPrivateKey

source§

fn from_secret(secret: &[u8]) -> CosmosPrivateKey

Create a private key using an arbitrary slice of bytes. This function is not resistant to side channel attacks and may reveal your secret and private key. It is on the other hand more compact than the bip32+bip39 logic.

source§

fn from_phrase( phrase: &str, passphrase: &str ) -> Result<CosmosPrivateKey, PrivateKeyError>

This function will take the key_import phrase provided by CosmosCLI and import that key. How this is done behind the scenes is quite complex. The actual seed bytes from the key_import are used to derive the root of a Bip32 HD wallet. From that root Cosmos keys are derived on the path m/44’/118’/0’/0/a where a=0 is the most common value used. Most Cosmos wallets do not even expose a=1..n much less the rest of the potential key space. This function returns m/44’/118’/0’/0/0 because that’s going to be the key you want essentially all the time. If you need a different path use from_hd_wallet_path()

source§

fn from_hd_wallet_path( hd_path: &str, phrase: &str, passphrase: &str ) -> Result<CosmosPrivateKey, PrivateKeyError>

Derives a private key from a mnemonic phrase and passphrase, using a BIP-44 HDPath The actual seed bytes are derived from the mnemonic phrase, which are then used to derive the root of a Bip32 HD wallet. From that application private keys are derived on the given hd_path (e.g. Cosmos’ m/44’/118’/0’/0/a where a=0 is the most common value used). Most Cosmos wallets do not even expose a=1..n much less the rest of the potential key space.

source§

fn to_address(&self, prefix: &str) -> Result<Address, PrivateKeyError>

Obtain an Address for a given private key, skipping the intermediate public key

source§

fn get_signed_tx( &self, messages: &[Msg], args: MessageArgs, memo: &str ) -> Result<Tx, PrivateKeyError>

Signs a transaction that contains at least one message using a single private key, returns the standard Tx type, useful for simulations

source§

fn sign_std_msg( &self, messages: &[Msg], args: MessageArgs, memo: &str ) -> Result<Vec<u8>, PrivateKeyError>

Signs a transaction that contains at least one message using a single private key.

source§

impl Copy for CosmosPrivateKey

source§

impl Eq for CosmosPrivateKey

source§

impl StructuralEq for CosmosPrivateKey

source§

impl StructuralPartialEq for CosmosPrivateKey

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> Twhere T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

const: unstable · 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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more