Documentation

MnemonicWallet extends AbstractWallet
in package

MnemonicWallet extends the AbstractWallet to create a wallet from a mnemonic phrase.

It handles the derivation and management of keys using BIP39 and HD Wallet standards.

Tags
author

DubbaThony

Table of Contents

Constants

offset  = 0x80000000

Properties

$key  : Key

Methods

__construct()  : mixed
Constructor to create a MnemonicWallet from words. While constructing, the words are processed into private key.
genNew()  : array<string|int, mixed>
Generates a new mnemonic phrase. If you don't have reason, use defaults.
getAddress()  : Address
Returns the wallet's associated Ethereum address.
getKeyRaw()  : string
Returns the raw private key in binary or hexadecimal format.
key()  : Key
Returns the underlying private key object stored in the wallet.
deriveChild()  : array<string|int, mixed>
parsePath()  : array<string|int, mixed>
serializeCurvePoint()  : string

Constants

Properties

Methods

__construct()

Constructor to create a MnemonicWallet from words. While constructing, the words are processed into private key.

public __construct(string|array<string|int, mixed> $words[, string $passPhrase = "" ][, string $path = "m/44'/60'/0'/0/0" ][, MnemonicLanguage|string $language = MnemonicLanguage::ENGLISH ]) : mixed
Parameters
$words : string|array<string|int, mixed>

Mnemonic phrase words.

$passPhrase : string = ""

Optional passphrase for seed generation. For any passphrase it will generate another key, and there is no way of knowing if passphrase matched other than checking returning address is what was expected

$path : string = "m/44'/60'/0'/0/0"

HD Wallet derivation path.

$language : MnemonicLanguage|string = MnemonicLanguage::ENGLISH

Language for the mnemonic words.

Tags
throws
WrongMnemonicPathException
throws
MnemonicWalletInternalException
throws
InvalidHexException

genNew()

Generates a new mnemonic phrase. If you don't have reason, use defaults.

public static genNew([int $wordCount = 24 ][, MnemonicLanguage|string $language = MnemonicLanguage::ENGLISH ]) : array<string|int, mixed>
Parameters
$wordCount : int = 24

Number of words in the mnemonic phrase.

$language : MnemonicLanguage|string = MnemonicLanguage::ENGLISH

Language for the mnemonic words. Defaults to english

Tags
throws
MnemonicWalletInternalException
Return values
array<string|int, mixed>

List of words for the mnemonic.

getKeyRaw()

Returns the raw private key in binary or hexadecimal format.

public getKeyRaw([bool $bin = false ]) : string
Parameters
$bin : bool = false

If true, returns in binary. Otherwise, returns in hexadecimal.

Return values
string

The raw key.

key()

Returns the underlying private key object stored in the wallet.

public key() : Key
Return values
Key

The Key object.

deriveChild()

private deriveChild(string $privateKeyBin, string $chainCodeBin, int $childNum) : array<string|int, mixed>
Parameters
$privateKeyBin : string
$chainCodeBin : string
$childNum : int
Tags
throws
InvalidHexException
Return values
array<string|int, mixed>

serializeCurvePoint()

private serializeCurvePoint(KeyPair $p) : string
Parameters
$p : KeyPair
Return values
string

        
On this page

Search results