Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #112 from ethereumjs/setup-typedoc
Browse files Browse the repository at this point in the history
Setup typedoc and fix web3-provider-engine dependency
  • Loading branch information
holgerd77 authored Apr 27, 2020
2 parents 20171a9 + ac5ba8a commit 2121d5a
Show file tree
Hide file tree
Showing 11 changed files with 1,099 additions and 51 deletions.
83 changes: 42 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,81 +28,82 @@ Features not supported:

## Wallet API

Constructors:
For information about the Wallet's API, please go to [./docs/classes/wallet.md](./docs/classes/wallet.md).

- `generate([icap])` - create an instance based on a new random key (setting `icap` to true will generate an address suitable for the `ICAP Direct mode`)
- `generateVanityAddress(pattern)` - create an instance where the address is valid against the supplied pattern (**this will be very slow**)
- `fromPrivateKey(input)` - create an instance based on a raw private key
- `fromExtendedPrivateKey(input)` - create an instance based on a BIP32 extended private key (xprv)
- `fromPublicKey(input, [nonStrict])` - create an instance based on a public key (certain methods will not be available)
- `fromExtendedPublicKey(input)` - create an instance based on a BIP32 extended public key (xpub)
- `fromV1(input, password)` - import a wallet (Version 1 of the Ethereum wallet format)
- `fromV3(input, password, [nonStrict])` - import a wallet (Version 3 of the Ethereum wallet format). Set `nonStrict` true to accept files with mixed-caps.
- `fromEthSale(input, password)` - import an Ethereum Pre Sale wallet
You can import the `Wallet` class like this

For the V1, V3 and EthSale formats the input is a JSON serialized string. All these formats require a password.
Node.js / ES5:

Note: `fromPublicKey()` only accepts uncompressed Ethereum-style public keys, unless the `nonStrict` flag is set to true.

Instance methods:

- `getPrivateKey()` - return the private key
- `getPublicKey()` - return the public key
- `getAddress()` - return the address
- `getChecksumAddressString()` - return the [address with checksum](https://github.com/ethereum/EIPs/issues/55)
- `getV3Filename([timestamp])` - return the suggested filename for V3 keystores
- `toV3(password, [options])` - return the wallet as a JSON string (Version 3 of the Ethereum wallet format)
```js
const { Wallet } = require('ethereumjs-wallet')
```

All of the above instance methods return a Buffer or JSON. Use the `String` suffixed versions for a string output, such as `getPrivateKeyString()`.
ESM / TypeScript:

Note: `getPublicKey()` only returns uncompressed Ethereum-style public keys.
```js
import { Wallet } from 'ethereumjs-wallet'
```

## Thirdparty API

Importing various third party wallets is possible through the `thirdparty` submodule:

`const { thirdparty } = require('ethereumjs-wallet')`
Node.js / ES5:

Constructors:
```js
const { thirdparty } = require('ethereumjs-wallet')
```

ESM / TypeScript:

```js
import { thirdparty } from 'ethereumjs-wallet'
```

- `fromEtherCamp(passphrase)` - import a brain wallet used by Ether.Camp
- `fromEtherWallet(input, password)` - import a wallet generated by EtherWallet
- `fromKryptoKit(seed)` - import a wallet from a KryptoKit seed
- `fromQuorumWallet(passphrase, userid)` - import a brain wallet used by Quorum Wallet
Please go to [./docs/README.md](./docs/README.md) for more info.

## HD Wallet API

To use BIP32 HD wallets, first include the `hdkey` submodule:

`const { hdkey } = require('ethereumjs-wallet')`

Constructors:
Node.js / ES5:

- `fromMasterSeed(seed)` - create an instance based on a seed
- `fromExtendedKey(key)` - create an instance based on a BIP32 extended private or public key
```js
const { hdkey } = require('ethereumjs-wallet')
```

For the seed we suggest to use [bip39](https://npmjs.org/package/bip39) to create one from a BIP39 mnemonic.
ESM / TypeScript:

Instance methods:
```js
import { hdkey } from 'ethereumjs-wallet'
```

- `privateExtendedKey()` - return a BIP32 extended private key (xprv)
- `publicExtendedKey()` - return a BIP32 extended public key (xpub)
- `derivePath(path)` - derive a node based on a path (e.g. m/44'/0'/0/1)
- `deriveChild(index)` - derive a node based on a child index
- `getWallet()` - return a `Wallet` instance as seen above
Please go to [./docs/classes/ethereumhdkey.md](./docs/classes/ethereumhdkey.md) for more info.

## Provider Engine

The Wallet can be easily plugged into [provider-engine](https://github.com/metamask/provider-engine) to provide signing:

Node.js / ES5:

```js
const { WalletSubprovider } = require('ethereumjs-wallet')

<engine>.addProvider(new WalletSubprovider(<wallet instance>))
```

ESM / TypeScript:

```js
import { WalletSubprovider } from 'ethereumjs-wallet'

<engine>.addProvider(new WalletSubprovider(<wallet instance>))
```

Note it only supports the basic wallet. With a HD Wallet, call `getWallet()` first.

Please go to [./docs/classes/walletsubprovider.md](./docs/README.md) for more info.

### Remarks about `toV3`

The `options` is an optional object hash, where all the serialization parameters can be fine tuned:
Expand Down
106 changes: 106 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# ethereumjs-wallet

## Index

### Classes

- [EthereumHDKey](classes/ethereumhdkey.md)
- [Wallet](classes/wallet.md)
- [WalletSubprovider](classes/walletsubprovider.md)

### Interfaces

- [EtherWalletOptions](interfaces/etherwalletoptions.md)
- [EvpKdfOpts](interfaces/evpkdfopts.md)

### Functions

- [fromEtherCamp](#fromethercamp)
- [fromEtherWallet](#frometherwallet)
- [fromKryptoKit](#fromkryptokit)
- [fromQuorumWallet](#fromquorumwallet)

---

## Functions

<a id="fromethercamp"></a>

### fromEtherCamp

**fromEtherCamp**(passphrase: _`string`_): [Wallet](classes/wallet.md)

_Defined in [thirdparty.ts:169](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L169)_

Third Party API: Import a brain wallet used by Ether.Camp

**Parameters:**

| Name | Type |
| ---------- | -------- |
| passphrase | `string` |

**Returns:** [Wallet](classes/wallet.md)

---

<a id="frometherwallet"></a>

### fromEtherWallet

**fromEtherWallet**(input: _`string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md)_, password: _`string`_): [Wallet](classes/wallet.md)

_Defined in [thirdparty.ts:121](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L121)_

**Parameters:**

| Name | Type |
| -------- | ------------------------------------------------------------------ |
| input | `string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md) |
| password | `string` |

**Returns:** [Wallet](classes/wallet.md)

---

<a id="fromkryptokit"></a>

### fromKryptoKit

**fromKryptoKit**(entropy: _`string`_, password: _`string`_): [Wallet](classes/wallet.md)

_Defined in [thirdparty.ts:176](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L176)_

Third Party API: Import a wallet from a KryptoKit seed

**Parameters:**

| Name | Type |
| -------- | -------- |
| entropy | `string` |
| password | `string` |

**Returns:** [Wallet](classes/wallet.md)

---

<a id="fromquorumwallet"></a>

### fromQuorumWallet

**fromQuorumWallet**(passphrase: _`string`_, userid: _`string`_): [Wallet](classes/wallet.md)

_Defined in [thirdparty.ts:265](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L265)_

Third Party API: Import a brain wallet used by Quorum Wallet

**Parameters:**

| Name | Type |
| ---------- | -------- |
| passphrase | `string` |
| userid | `string` |

**Returns:** [Wallet](classes/wallet.md)

---
Loading

0 comments on commit 2121d5a

Please sign in to comment.