Wallet Class - wallet

Table of Contents

Description:

Wallet Class for signing, generating, and interacting with a Tradehub account. This client is called as part of the Authenticated Client and the Demex Client. This class is designed to generate mnemonics, convert mnemonics, private keys, public keys, and addresses.

Usage:

from tradehub.wallet import Wallet

Classes:

Wallet(mnemonic, network)

This class allows the user to interact with the Demex and Tradehub wallet functions. Execution of this function is as follows::.

class tradehub.wallet.Wallet(mnemonic: Optional[str] = None, network: str = 'testnet')[source]

Bases: object

This class allows the user to interact with the Demex and Tradehub wallet functions. Execution of this function is as follows:

Wallet(mnemonic='lorem ipsum dolor consectetur adipiscing eiusmod tempor incididunt labore magna',
       network='mainnet')

Attributes:

_DEFAULT_DERIVATION_PATH

Methods:

_sign(message)

Function to find the readable address from the public key.

generate_12_word_wallet()

Function to generate a 12 word mnemonic.

generate_24_word_wallet()

Function to generate a 24 word mnemonic.

mnemonic_to_private_key([mnemonic_phrase, …])

Function to find the private key based on the mnemonic passed to the function.

private_key_to_address([private_key, hrp])

Function to find the readable address from the private key.

private_key_to_public_key([private_key])

Function to find the public key based on the private key passed to the function.

public_key_to_address([public_key, hrp])

Function to find the readable address from the public key.

_DEFAULT_DERIVATION_PATH = "m/44'/118'/0'/0/0"
_sign(message: dict)str[source]

Function to find the readable address from the public key.

Execution of this function is as follows:

_sign(message={'message': 'This is a Tradehub test.'})

The expected return result for this function is as follows:

XP4s5fCY6UKh/dvscYsDylhYeD64WOTYohEU3QuuUygPCiQF9uFS9mHgwLaTFfFL41mdTRZclxq6CETr8bcZ5w==
Parameters

message – Dictionary message to sign.

Returns

Signed message.

generate_12_word_wallet()[source]

Function to generate a 12 word mnemonic.

Execution of this function is as follows:

generate_12_word_wallet()

The expected return result for this function is as follows:

venture consider cool fury front middle junk person suit assist garbage category
Returns

12 word String that should be highly protected if storing any funds.

generate_24_word_wallet()[source]

Function to generate a 24 word mnemonic.

Execution of this function is as follows:

generate_24_word_wallet()

The expected return result for this function is as follows:

refuse flag merge fiction choose dream frown gauge need fabric once pizza actual armed reopen couple family fury reopen slush blue try focus minute
Returns

24 word String that should be highly protected if storing any funds.

mnemonic_to_private_key(mnemonic_phrase: Optional[str] = None, wallet_path: str = "m/44'/118'/0'/0/0")bytes[source]

Function to find the private key based on the mnemonic passed to the function.

Execution of this function is as follows:

mnemonic_to_private_key(mnemonic_phrase='venture consider cool fury front middle junk person suit assist garbage category',
                        wallet_path=_DEFAULT_DERIVATION_PATH)

The expected return result for this function is as follows:

b'ÏÝßêdˆÒy!Û¶1¦˜îQmí%43!

ÌSËsf’

param mnemonic_phrase

String mnemonic phrase for a tradehub wallet.

param wallet_path

String Derivation path to generated the private key from the mnemonic.

return

Byte value that is equal to the private key.

private_key_to_address(private_key: Optional[bytes] = None, hrp: Optional[str] = None)str[source]

Function to find the readable address from the private key.

Execution of this function is as follows:

public_key_to_address(public_key=b'ÏÝßêdˆÒy!Û¶1¦˜îQmí%43!
ÌSËsf’,

hrp=None)

The expected return result for this function is as follows:

tswth1upcgussnx4p3jegwj3x2fccwlajwckkzgstrp8
param private_key

Byte representation of the wallets private key.

return

String and human readable Tradehub address.

private_key_to_public_key(private_key: Optional[bytes] = None)bytes[source]

Function to find the public key based on the private key passed to the function.

Execution of this function is as follows:

private_key_to_public_key(private_key=b'ÏÝßêdˆÒy!Û¶1¦˜îQmí%43!

ÌSËsf’)

The expected return result for this function is as follows:

b'oûL–è

°V€Çtü´0R®uó{ö×m]Ñ©‘¨àDf’

param private_key

Byte representation of the wallets private key.

return

Binary value that is equal to the public key.

public_key_to_address(public_key: Optional[bytes] = None, hrp: Optional[str] = None)str[source]

Function to find the readable address from the public key.

Execution of this function is as follows:

public_key_to_address(public_key=b'oûL–è
°V€Çtü´0R®uó{ö×m]Ñ©‘¨àDf’,

hrp=None)

The expected return result for this function is as follows:

tswth1upcgussnx4p3jegwj3x2fccwlajwckkzgstrp8
param public_key

Byte representation of the wallets public key.

return

String and human readable Tradehub address.