From d4d96c8c2d363632b8128108df2dfb17ab25d5eb Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Tue, 10 Sep 2019 14:51:58 -0300 Subject: [PATCH 01/13] Set up typedoc --- docs/README.md | 11 + docs/classes/ethereumhdkey.md | 171 ++++++++++++ docs/classes/wallet.md | 425 ++++++++++++++++++++++++++++++ docs/classes/walletsubprovider.md | 38 +++ package.json | 5 +- 5 files changed, 649 insertions(+), 1 deletion(-) create mode 100644 docs/README.md create mode 100644 docs/classes/ethereumhdkey.md create mode 100644 docs/classes/wallet.md create mode 100644 docs/classes/walletsubprovider.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..de1f588 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,11 @@ +# ethereumjs-wallet + +## Index + +### Classes + +- [EthereumHDKey](classes/ethereumhdkey.md) +- [Wallet](classes/wallet.md) +- [WalletSubprovider](classes/walletsubprovider.md) + +--- diff --git a/docs/classes/ethereumhdkey.md b/docs/classes/ethereumhdkey.md new file mode 100644 index 0000000..7ea4858 --- /dev/null +++ b/docs/classes/ethereumhdkey.md @@ -0,0 +1,171 @@ +[ethereumjs-wallet](../README.md) > [EthereumHDKey](../classes/ethereumhdkey.md) + +# Class: EthereumHDKey + +## Hierarchy + +**EthereumHDKey** + +## Index + +### Constructors + +- [constructor](ethereumhdkey.md#constructor) + +### Properties + +- [\_hdkey](ethereumhdkey.md#_hdkey) + +### Methods + +- [deriveChild](ethereumhdkey.md#derivechild) +- [derivePath](ethereumhdkey.md#derivepath) +- [getWallet](ethereumhdkey.md#getwallet) +- [privateExtendedKey](ethereumhdkey.md#privateextendedkey) +- [publicExtendedKey](ethereumhdkey.md#publicextendedkey) +- [fromExtendedKey](ethereumhdkey.md#fromextendedkey) +- [fromMasterSeed](ethereumhdkey.md#frommasterseed) + +--- + +## Constructors + + + +### constructor + +⊕ **new EthereumHDKey**(\_hdkey?: _`any`_): [EthereumHDKey](ethereumhdkey.md) + +_Defined in [hdkey.ts:12](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L12)_ + +**Parameters:** + +| Name | Type | +| ------------------ | ----- | +| `Optional` \_hdkey | `any` | + +**Returns:** [EthereumHDKey](ethereumhdkey.md) + +--- + +## Properties + + + +### ` `` ` \_hdkey + +**● \_hdkey**: _`any`_ + +_Defined in [hdkey.ts:14](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L14)_ + +--- + +## Methods + + + +### deriveChild + +▸ **deriveChild**(index: _`number`_): [EthereumHDKey](ethereumhdkey.md) + +_Defined in [hdkey.ts:31](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L31)_ + +**Parameters:** + +| Name | Type | +| ----- | -------- | +| index | `number` | + +**Returns:** [EthereumHDKey](ethereumhdkey.md) + +--- + + + +### derivePath + +▸ **derivePath**(path: _`string`_): [EthereumHDKey](ethereumhdkey.md) + +_Defined in [hdkey.ts:27](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L27)_ + +**Parameters:** + +| Name | Type | +| ---- | -------- | +| path | `string` | + +**Returns:** [EthereumHDKey](ethereumhdkey.md) + +--- + + + +### getWallet + +▸ **getWallet**(): [Wallet](wallet.md) + +_Defined in [hdkey.ts:35](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L35)_ + +**Returns:** [Wallet](wallet.md) + +--- + + + +### privateExtendedKey + +▸ **privateExtendedKey**(): `Buffer` + +_Defined in [hdkey.ts:16](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L16)_ + +**Returns:** `Buffer` + +--- + + + +### publicExtendedKey + +▸ **publicExtendedKey**(): `Buffer` + +_Defined in [hdkey.ts:23](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L23)_ + +**Returns:** `Buffer` + +--- + + + +### `` fromExtendedKey + +▸ **fromExtendedKey**(base58Key: _`string`_): [EthereumHDKey](ethereumhdkey.md) + +_Defined in [hdkey.ts:10](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L10)_ + +**Parameters:** + +| Name | Type | +| --------- | -------- | +| base58Key | `string` | + +**Returns:** [EthereumHDKey](ethereumhdkey.md) + +--- + + + +### `` fromMasterSeed + +▸ **fromMasterSeed**(seedBuffer: _`Buffer`_): [EthereumHDKey](ethereumhdkey.md) + +_Defined in [hdkey.ts:6](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L6)_ + +**Parameters:** + +| Name | Type | +| ---------- | -------- | +| seedBuffer | `Buffer` | + +**Returns:** [EthereumHDKey](ethereumhdkey.md) + +--- diff --git a/docs/classes/wallet.md b/docs/classes/wallet.md new file mode 100644 index 0000000..796186e --- /dev/null +++ b/docs/classes/wallet.md @@ -0,0 +1,425 @@ +[ethereumjs-wallet](../README.md) > [Wallet](../classes/wallet.md) + +# Class: Wallet + +## Hierarchy + +**Wallet** + +## Index + +### Constructors + +- [constructor](wallet.md#constructor) + +### Properties + +- [privateKey](wallet.md#privatekey) +- [publicKey](wallet.md#publickey) + +### Accessors + +- [privKey](wallet.md#privkey) +- [pubKey](wallet.md#pubkey) + +### Methods + +- [getAddress](wallet.md#getaddress) +- [getAddressString](wallet.md#getaddressstring) +- [getChecksumAddressString](wallet.md#getchecksumaddressstring) +- [getPrivateKey](wallet.md#getprivatekey) +- [getPrivateKeyString](wallet.md#getprivatekeystring) +- [getPublicKey](wallet.md#getpublickey) +- [getPublicKeyString](wallet.md#getpublickeystring) +- [getV3Filename](wallet.md#getv3filename) +- [toV3](wallet.md#tov3) +- [toV3String](wallet.md#tov3string) +- [fromEthSale](wallet.md#fromethsale) +- [fromExtendedPrivateKey](wallet.md#fromextendedprivatekey) +- [fromExtendedPublicKey](wallet.md#fromextendedpublickey) +- [fromPrivateKey](wallet.md#fromprivatekey) +- [fromPublicKey](wallet.md#frompublickey) +- [fromV1](wallet.md#fromv1) +- [fromV3](wallet.md#fromv3) +- [generate](wallet.md#generate) +- [generateVanityAddress](wallet.md#generatevanityaddress) + +--- + +## Constructors + + + +### constructor + +⊕ **new Wallet**(privateKey?: _`Buffer` \| `undefined`_, publicKey?: _`Buffer` \| `undefined`_): [Wallet](wallet.md) + +_Defined in [index.ts:226](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L226)_ + +**Parameters:** + +| Name | Type | Default value | +| ------------------------- | ----------------------- | ------------- | +| `Optional` privateKey | `Buffer` \| `undefined` | - | +| `Default value` publicKey | `Buffer` \| `undefined` | undefined | + +**Returns:** [Wallet](wallet.md) + +--- + +## Properties + + + +### ` `` ` privateKey + +**● privateKey**: _`Buffer` \| `undefined`_ + +_Defined in [index.ts:228](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L228)_ + +--- + + + +### `` publicKey + +**● publicKey**: _`Buffer` \| `undefined`_ + +_Defined in [index.ts:229](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L229)_ + +--- + +## Accessors + + + +### `` privKey + +**get privKey**(): `Buffer` + +_Defined in [index.ts:432](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L432)_ + +**Returns:** `Buffer` + +--- + + + +### `` pubKey + +**get pubKey**(): `Buffer` + +_Defined in [index.ts:425](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L425)_ + +**Returns:** `Buffer` + +--- + +## Methods + + + +### getAddress + +▸ **getAddress**(): `Buffer` + +_Defined in [index.ts:459](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L459)_ + +**Returns:** `Buffer` + +--- + + + +### getAddressString + +▸ **getAddressString**(): `string` + +_Defined in [index.ts:463](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L463)_ + +**Returns:** `string` + +--- + + + +### getChecksumAddressString + +▸ **getChecksumAddressString**(): `string` + +_Defined in [index.ts:467](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L467)_ + +**Returns:** `string` + +--- + + + +### getPrivateKey + +▸ **getPrivateKey**(): `Buffer` + +_Defined in [index.ts:442](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L442)_ + +**Returns:** `Buffer` + +--- + + + +### getPrivateKeyString + +▸ **getPrivateKeyString**(): `string` + +_Defined in [index.ts:446](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L446)_ + +**Returns:** `string` + +--- + + + +### getPublicKey + +▸ **getPublicKey**(): `Buffer` + +_Defined in [index.ts:451](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L451)_ + +**Returns:** `Buffer` + +--- + + + +### getPublicKeyString + +▸ **getPublicKeyString**(): `string` + +_Defined in [index.ts:455](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L455)_ + +**Returns:** `string` + +--- + + + +### getV3Filename + +▸ **getV3Filename**(timestamp?: _`undefined` \| `number`_): `string` + +_Defined in [index.ts:540](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L540)_ + +**Parameters:** + +| Name | Type | +| -------------------- | ----------------------- | +| `Optional` timestamp | `undefined` \| `number` | + +**Returns:** `string` + +--- + + + +### toV3 + +▸ **toV3**(password: _`string`_, opts?: _`Partial`<`V3Params`>_): `V3Keystore` + +_Defined in [index.ts:471](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L471)_ + +**Parameters:** + +| Name | Type | +| --------------- | --------------------- | +| password | `string` | +| `Optional` opts | `Partial`<`V3Params`> | + +**Returns:** `V3Keystore` + +--- + + + +### toV3String + +▸ **toV3String**(password: _`string`_, opts?: _`Partial`<`V3Params`>_): `string` + +_Defined in [index.ts:558](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L558)_ + +**Parameters:** + +| Name | Type | +| --------------- | --------------------- | +| password | `string` | +| `Optional` opts | `Partial`<`V3Params`> | + +**Returns:** `string` + +--- + + + +### `` fromEthSale + +▸ **fromEthSale**(input: _`string` \| `EthSaleKeystore`_, password: _`string`_): [Wallet](wallet.md) + +_Defined in [index.ts:402](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L402)_ + +**Parameters:** + +| Name | Type | +| -------- | ----------------------------- | +| input | `string` \| `EthSaleKeystore` | +| password | `string` | + +**Returns:** [Wallet](wallet.md) + +--- + + + +### `` fromExtendedPrivateKey + +▸ **fromExtendedPrivateKey**(extendedPrivateKey: _`string`_): [Wallet](wallet.md) + +_Defined in [index.ts:295](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L295)_ + +**Parameters:** + +| Name | Type | +| ------------------ | -------- | +| extendedPrivateKey | `string` | + +**Returns:** [Wallet](wallet.md) + +--- + + + +### `` fromExtendedPublicKey + +▸ **fromExtendedPublicKey**(extendedPublicKey: _`string`_): [Wallet](wallet.md) + +_Defined in [index.ts:282](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L282)_ + +**Parameters:** + +| Name | Type | +| ----------------- | -------- | +| extendedPublicKey | `string` | + +**Returns:** [Wallet](wallet.md) + +--- + + + +### `` fromPrivateKey + +▸ **fromPrivateKey**(privateKey: _`Buffer`_): [Wallet](wallet.md) + +_Defined in [index.ts:291](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L291)_ + +**Parameters:** + +| Name | Type | +| ---------- | -------- | +| privateKey | `Buffer` | + +**Returns:** [Wallet](wallet.md) + +--- + + + +### `` fromPublicKey + +▸ **fromPublicKey**(publicKey: _`Buffer`_, nonStrict?: _`boolean`_): [Wallet](wallet.md) + +_Defined in [index.ts:275](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L275)_ + +**Parameters:** + +| Name | Type | Default value | +| ------------------------- | --------- | ------------- | +| publicKey | `Buffer` | - | +| `Default value` nonStrict | `boolean` | false | + +**Returns:** [Wallet](wallet.md) + +--- + + + +### `` fromV1 + +▸ **fromV1**(input: _`string` \| `V1Keystore`_, password: _`string`_): [Wallet](wallet.md) + +_Defined in [index.ts:306](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L306)_ + +**Parameters:** + +| Name | Type | +| -------- | ------------------------ | +| input | `string` \| `V1Keystore` | +| password | `string` | + +**Returns:** [Wallet](wallet.md) + +--- + + + +### `` fromV3 + +▸ **fromV3**(input: _`string` \| `V3Keystore`_, password: _`string`_, nonStrict?: _`boolean`_): [Wallet](wallet.md) + +_Defined in [index.ts:340](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L340)_ + +**Parameters:** + +| Name | Type | Default value | +| ------------------------- | ------------------------ | ------------- | +| input | `string` \| `V3Keystore` | - | +| password | `string` | - | +| `Default value` nonStrict | `boolean` | false | + +**Returns:** [Wallet](wallet.md) + +--- + + + +### `` generate + +▸ **generate**(icapDirect?: _`boolean`_): [Wallet](wallet.md) + +_Defined in [index.ts:246](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L246)_ + +**Parameters:** + +| Name | Type | Default value | +| -------------------------- | --------- | ------------- | +| `Default value` icapDirect | `boolean` | false | + +**Returns:** [Wallet](wallet.md) + +--- + + + +### `` generateVanityAddress + +▸ **generateVanityAddress**(pattern: _`RegExp` \| `string`_): [Wallet](wallet.md) + +_Defined in [index.ts:260](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L260)_ + +**Parameters:** + +| Name | Type | +| ------- | -------------------- | +| pattern | `RegExp` \| `string` | + +**Returns:** [Wallet](wallet.md) + +--- diff --git a/docs/classes/walletsubprovider.md b/docs/classes/walletsubprovider.md new file mode 100644 index 0000000..f295e4b --- /dev/null +++ b/docs/classes/walletsubprovider.md @@ -0,0 +1,38 @@ +[ethereumjs-wallet](../README.md) > [WalletSubprovider](../classes/walletsubprovider.md) + +# Class: WalletSubprovider + +## Hierarchy + +`any` + +**↳ WalletSubprovider** + +## Index + +### Constructors + +- [constructor](walletsubprovider.md#constructor) + +--- + +## Constructors + + + +### constructor + +⊕ **new WalletSubprovider**(wallet: _[Wallet](wallet.md)_, opts?: _`any`_): [WalletSubprovider](walletsubprovider.md) + +_Defined in [provider-engine.ts:5](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/provider-engine.ts#L5)_ + +**Parameters:** + +| Name | Type | +| --------------- | ------------------- | +| wallet | [Wallet](wallet.md) | +| `Optional` opts | `any` | + +**Returns:** [WalletSubprovider](walletsubprovider.md) + +--- diff --git a/package.json b/package.json index 17c8014..e7bfb14 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "scripts": { "build": "ethereumjs-config-build", "prepublishOnly": "npm run format && npm run tslint && npm run test", + "docs:build": "typedoc --out docs --mode file --readme none --theme markdown --mdEngine github --excludeNotExported src", "coverage": "ethereumjs-config-coverage", "coveralls": "ethereumjs-config-coveralls", "format": "ethereumjs-config-format", @@ -72,6 +73,8 @@ "ts-node": "^8.3.0", "tslint": "^5.12.0", "typescript": "^3.2.2", - "typestrict": "^1.0.2" + "typestrict": "^1.0.2", + "typedoc": "^0.14.2", + "typedoc-plugin-markdown": "^1.2.0" } } From 8b5f5a9e48167ce6bbc6721781e0b459a5e08dbe Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Tue, 10 Sep 2019 15:09:53 -0300 Subject: [PATCH 02/13] Move the readme doc where appropiate --- README.md | 55 +++++------------------------------------------ src/index.ts | 30 ++++++++++++++++++++++++++ src/thirdparty.ts | 12 +++++------ 3 files changed, 41 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index a41811d..255f6ef 100644 --- a/README.md +++ b/README.md @@ -28,68 +28,23 @@ Features not supported: ## Wallet API -Constructors: - -- `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 - -For the V1, V3 and EthSale formats the input is a JSON serialized string. All these formats require a password. - -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) - -All of the above instance methods return a Buffer or JSON. Use the `String` suffixed versions for a string output, such as `getPrivateKeyString()`. - -Note: `getPublicKey()` only returns uncompressed Ethereum-style public keys. +For information about the Wallet's API, please go to [./docs/classes/wallet.md](./docs/classes/wallet.md). ## Thirdparty API Importing various third party wallets is possible through the `thirdparty` submodule: -`var thirdparty = require('ethereumjs-wallet/thirdparty')` - -Constructors: +`const thirdparty = require('ethereumjs-wallet/thirdparty')` -- `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: -`var hdkey = require('ethereumjs-wallet/hdkey')` - -Constructors: - -- `fromMasterSeed(seed)` - create an instance based on a seed -- `fromExtendedKey(key)` - create an instance based on a BIP32 extended private or public key - -For the seed we suggest to use [bip39](https://npmjs.org/package/bip39) to create one from a BIP39 mnemonic. - -Instance methods: +`const hdkey = require('ethereumjs-wallet/hdkey')` -- `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 diff --git a/src/index.ts b/src/index.ts index 8845f61..99f8559 100644 --- a/src/index.ts +++ b/src/index.ts @@ -243,6 +243,11 @@ export default class Wallet { // static methods + /** + * Create an instance based on a new random key. + * + * @param icapDirect setting this to `true` will generate an address suitable for the `ICAP Direct mode` + */ public static generate(icapDirect: boolean = false): Wallet { if (icapDirect) { const max = new ethUtil.BN('088f924eeceeda7fe92e1f5b0fffffffffffffff', 16) @@ -257,6 +262,9 @@ export default class Wallet { } } + /** + * Create an instance where the address is valid against the supplied pattern (**this will be very slow**) + */ public static generateVanityAddress(pattern: RegExp | string): Wallet { if (!(pattern instanceof RegExp)) { pattern = new RegExp(pattern) @@ -272,6 +280,12 @@ export default class Wallet { } } + /** + * Create an instance based on a public key (certain methods will not be available) + * + * This method only accepts uncompressed Ethereum-style public keys, unless + * the `nonStrict` flag is set to true. + */ public static fromPublicKey(publicKey: Buffer, nonStrict: boolean = false): Wallet { if (nonStrict) { publicKey = ethUtil.importPublic(publicKey) @@ -279,6 +293,9 @@ export default class Wallet { return new Wallet(undefined, publicKey) } + /** + * Create an instance based on a BIP32 extended public key (xpub) + */ public static fromExtendedPublicKey(extendedPublicKey: string): Wallet { if (extendedPublicKey.slice(0, 4) !== 'xpub') { throw new Error('Not an extended public key') @@ -288,10 +305,16 @@ export default class Wallet { return Wallet.fromPublicKey(publicKey, true) } + /** + * Create an instance based on a raw private key + */ public static fromPrivateKey(privateKey: Buffer): Wallet { return new Wallet(privateKey) } + /** + * Create an instance based on a BIP32 extended private key (xprv) + */ public static fromExtendedPrivateKey(extendedPrivateKey: string): Wallet { if (extendedPrivateKey.slice(0, 4) !== 'xprv') { throw new Error('Not an extended private key') @@ -303,6 +326,9 @@ export default class Wallet { return Wallet.fromPrivateKey(tmp.slice(46)) } + /** + * Import a wallet (Version 1 of the Ethereum wallet format) + */ public static fromV1(input: string | V1Keystore, password: string): Wallet { const json: V1Keystore = typeof input === 'object' ? input : JSON.parse(input) if (json.Version !== '1') { @@ -337,6 +363,9 @@ export default class Wallet { return new Wallet(seed) } + /** + * Import a wallet (Version 3 of the Ethereum wallet format). Set `nonStrict` true to accept files with mixed-caps. + */ public static fromV3( input: string | V3Keystore, password: string, @@ -396,6 +425,7 @@ export default class Wallet { } /* + * Import an Ethereum Pre Sale wallet * Based on https://github.com/ethereum/pyethsaletool/blob/master/pyethsaletool.py * JSON fields: encseed, ethaddr, btcaddr, email */ diff --git a/src/thirdparty.ts b/src/thirdparty.ts index bbb2179..75a148c 100644 --- a/src/thirdparty.ts +++ b/src/thirdparty.ts @@ -13,7 +13,7 @@ function runCipherBuffer(cipher: crypto.Cipher | crypto.Decipher, data: Buffer): // evp_kdf -interface EvpKdfOpts { +export interface EvpKdfOpts { count: number keysize: number ivsize: number @@ -104,7 +104,7 @@ function decodeCryptojsSalt(input: string): { ciphertext: Buffer; salt?: Buffer // "public": "U2FsdGVkX19EaDNK52q7LEz3hL/VR3dYW5VcoP04tcVKNS0Q3JINpM4XzttRJCBtq4g22hNDrOR8RWyHuh3nPo0pRSe9r5AUfEiCLaMBAhI16kf2KqCA8ah4brkya9ZLECdIl0HDTMYfDASBnyNXd87qodt46U0vdRT3PppK+9hsyqP8yqm9kFcWqMHktqubBE937LIU0W22Rfw6cJRwIw==" // } -interface EtherWalletOptions { +export interface EtherWalletOptions { address: string encrypted: boolean locked: boolean @@ -117,7 +117,7 @@ interface EtherWalletOptions { * This wallet format is created by https://github.com/SilentCicero/ethereumjs-accounts * and used on https://www.myetherwallet.com/ */ -function fromEtherWallet(input: string | EtherWalletOptions, password: string): Wallet { +export function fromEtherWallet(input: string | EtherWalletOptions, password: string): Wallet { const json: EtherWalletOptions = typeof input === 'object' ? input : JSON.parse(input) let privateKey: Buffer @@ -162,11 +162,11 @@ function fromEtherWallet(input: string | EtherWalletOptions, password: string): return wallet } -function fromEtherCamp(passphrase: string): Wallet { +export function fromEtherCamp(passphrase: string): Wallet { return new Wallet(ethUtil.keccak256(Buffer.from(passphrase))) } -function fromKryptoKit(entropy: string, password: string): Wallet { +export function fromKryptoKit(entropy: string, password: string): Wallet { function kryptoKitBrokenScryptSeed(buf: Buffer) { // js-scrypt calls `Buffer.from(String(salt), 'utf8')` on the seed even though it is a buffer // @@ -252,7 +252,7 @@ function fromKryptoKit(entropy: string, password: string): Wallet { return new Wallet(privateKey) } -function fromQuorumWallet(passphrase: string, userid: string): Wallet { +export function fromQuorumWallet(passphrase: string, userid: string): Wallet { if (passphrase.length < 10) { throw new Error('Passphrase must be at least 10 characters') } From 47d7c34b83985df73856b2f10b75f7e5fe537cea Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Tue, 10 Sep 2019 15:10:14 -0300 Subject: [PATCH 03/13] Update doc --- docs/README.md | 89 +++++++++++++++++++++++++++ docs/classes/ethereumhdkey.md | 18 +++--- docs/classes/wallet.md | 72 ++++++++++++++-------- docs/classes/walletsubprovider.md | 2 +- docs/interfaces/etherwalletoptions.md | 82 ++++++++++++++++++++++++ docs/interfaces/evpkdfopts.md | 60 ++++++++++++++++++ 6 files changed, 286 insertions(+), 37 deletions(-) create mode 100644 docs/interfaces/etherwalletoptions.md create mode 100644 docs/interfaces/evpkdfopts.md diff --git a/docs/README.md b/docs/README.md index de1f588..faeece6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,4 +8,93 @@ - [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 + + + +### fromEtherCamp + +▸ **fromEtherCamp**(passphrase: _`string`_): [Wallet](classes/wallet.md) + +_Defined in [thirdparty.ts:165](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L165)_ + +**Parameters:** + +| Name | Type | +| ---------- | -------- | +| passphrase | `string` | + +**Returns:** [Wallet](classes/wallet.md) + +--- + + + +### fromEtherWallet + +▸ **fromEtherWallet**(input: _`string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md)_, password: _`string`_): [Wallet](classes/wallet.md) + +_Defined in [thirdparty.ts:120](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L120)_ + +**Parameters:** + +| Name | Type | +| -------- | ------------------------------------------------------------------ | +| input | `string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md) | +| password | `string` | + +**Returns:** [Wallet](classes/wallet.md) + +--- + + + +### fromKryptoKit + +▸ **fromKryptoKit**(entropy: _`string`_, password: _`string`_): [Wallet](classes/wallet.md) + +_Defined in [thirdparty.ts:169](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L169)_ + +**Parameters:** + +| Name | Type | +| -------- | -------- | +| entropy | `string` | +| password | `string` | + +**Returns:** [Wallet](classes/wallet.md) + +--- + + + +### fromQuorumWallet + +▸ **fromQuorumWallet**(passphrase: _`string`_, userid: _`string`_): [Wallet](classes/wallet.md) + +_Defined in [thirdparty.ts:255](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L255)_ + +**Parameters:** + +| Name | Type | +| ---------- | -------- | +| passphrase | `string` | +| userid | `string` | + +**Returns:** [Wallet](classes/wallet.md) + --- diff --git a/docs/classes/ethereumhdkey.md b/docs/classes/ethereumhdkey.md index 7ea4858..14651a6 100644 --- a/docs/classes/ethereumhdkey.md +++ b/docs/classes/ethereumhdkey.md @@ -36,7 +36,7 @@ ⊕ **new EthereumHDKey**(\_hdkey?: _`any`_): [EthereumHDKey](ethereumhdkey.md) -_Defined in [hdkey.ts:12](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L12)_ +_Defined in [hdkey.ts:12](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L12)_ **Parameters:** @@ -56,7 +56,7 @@ _Defined in [hdkey.ts:12](https://github.com/ethereumjs/ethereumjs-wallet/blob/a **● \_hdkey**: _`any`_ -_Defined in [hdkey.ts:14](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L14)_ +_Defined in [hdkey.ts:14](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L14)_ --- @@ -68,7 +68,7 @@ _Defined in [hdkey.ts:14](https://github.com/ethereumjs/ethereumjs-wallet/blob/a ▸ **deriveChild**(index: _`number`_): [EthereumHDKey](ethereumhdkey.md) -_Defined in [hdkey.ts:31](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L31)_ +_Defined in [hdkey.ts:31](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L31)_ **Parameters:** @@ -86,7 +86,7 @@ _Defined in [hdkey.ts:31](https://github.com/ethereumjs/ethereumjs-wallet/blob/a ▸ **derivePath**(path: _`string`_): [EthereumHDKey](ethereumhdkey.md) -_Defined in [hdkey.ts:27](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L27)_ +_Defined in [hdkey.ts:27](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L27)_ **Parameters:** @@ -104,7 +104,7 @@ _Defined in [hdkey.ts:27](https://github.com/ethereumjs/ethereumjs-wallet/blob/a ▸ **getWallet**(): [Wallet](wallet.md) -_Defined in [hdkey.ts:35](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L35)_ +_Defined in [hdkey.ts:35](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L35)_ **Returns:** [Wallet](wallet.md) @@ -116,7 +116,7 @@ _Defined in [hdkey.ts:35](https://github.com/ethereumjs/ethereumjs-wallet/blob/a ▸ **privateExtendedKey**(): `Buffer` -_Defined in [hdkey.ts:16](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L16)_ +_Defined in [hdkey.ts:16](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L16)_ **Returns:** `Buffer` @@ -128,7 +128,7 @@ _Defined in [hdkey.ts:16](https://github.com/ethereumjs/ethereumjs-wallet/blob/a ▸ **publicExtendedKey**(): `Buffer` -_Defined in [hdkey.ts:23](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L23)_ +_Defined in [hdkey.ts:23](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L23)_ **Returns:** `Buffer` @@ -140,7 +140,7 @@ _Defined in [hdkey.ts:23](https://github.com/ethereumjs/ethereumjs-wallet/blob/a ▸ **fromExtendedKey**(base58Key: _`string`_): [EthereumHDKey](ethereumhdkey.md) -_Defined in [hdkey.ts:10](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L10)_ +_Defined in [hdkey.ts:10](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L10)_ **Parameters:** @@ -158,7 +158,7 @@ _Defined in [hdkey.ts:10](https://github.com/ethereumjs/ethereumjs-wallet/blob/a ▸ **fromMasterSeed**(seedBuffer: _`Buffer`_): [EthereumHDKey](ethereumhdkey.md) -_Defined in [hdkey.ts:6](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/hdkey.ts#L6)_ +_Defined in [hdkey.ts:6](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L6)_ **Parameters:** diff --git a/docs/classes/wallet.md b/docs/classes/wallet.md index 796186e..1b30d62 100644 --- a/docs/classes/wallet.md +++ b/docs/classes/wallet.md @@ -54,7 +54,7 @@ ⊕ **new Wallet**(privateKey?: _`Buffer` \| `undefined`_, publicKey?: _`Buffer` \| `undefined`_): [Wallet](wallet.md) -_Defined in [index.ts:226](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L226)_ +_Defined in [index.ts:226](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L226)_ **Parameters:** @@ -75,7 +75,7 @@ _Defined in [index.ts:226](https://github.com/ethereumjs/ethereumjs-wallet/blob/ **● privateKey**: _`Buffer` \| `undefined`_ -_Defined in [index.ts:228](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L228)_ +_Defined in [index.ts:228](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L228)_ --- @@ -85,7 +85,7 @@ _Defined in [index.ts:228](https://github.com/ethereumjs/ethereumjs-wallet/blob/ **● publicKey**: _`Buffer` \| `undefined`_ -_Defined in [index.ts:229](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L229)_ +_Defined in [index.ts:229](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L229)_ --- @@ -97,7 +97,7 @@ _Defined in [index.ts:229](https://github.com/ethereumjs/ethereumjs-wallet/blob/ **get privKey**(): `Buffer` -_Defined in [index.ts:432](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L432)_ +_Defined in [index.ts:462](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L462)_ **Returns:** `Buffer` @@ -109,7 +109,7 @@ _Defined in [index.ts:432](https://github.com/ethereumjs/ethereumjs-wallet/blob/ **get pubKey**(): `Buffer` -_Defined in [index.ts:425](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L425)_ +_Defined in [index.ts:455](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L455)_ **Returns:** `Buffer` @@ -123,7 +123,7 @@ _Defined in [index.ts:425](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **getAddress**(): `Buffer` -_Defined in [index.ts:459](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L459)_ +_Defined in [index.ts:489](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L489)_ **Returns:** `Buffer` @@ -135,7 +135,7 @@ _Defined in [index.ts:459](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **getAddressString**(): `string` -_Defined in [index.ts:463](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L463)_ +_Defined in [index.ts:493](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L493)_ **Returns:** `string` @@ -147,7 +147,7 @@ _Defined in [index.ts:463](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **getChecksumAddressString**(): `string` -_Defined in [index.ts:467](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L467)_ +_Defined in [index.ts:497](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L497)_ **Returns:** `string` @@ -159,7 +159,7 @@ _Defined in [index.ts:467](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **getPrivateKey**(): `Buffer` -_Defined in [index.ts:442](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L442)_ +_Defined in [index.ts:472](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L472)_ **Returns:** `Buffer` @@ -171,7 +171,7 @@ _Defined in [index.ts:442](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **getPrivateKeyString**(): `string` -_Defined in [index.ts:446](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L446)_ +_Defined in [index.ts:476](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L476)_ **Returns:** `string` @@ -183,7 +183,7 @@ _Defined in [index.ts:446](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **getPublicKey**(): `Buffer` -_Defined in [index.ts:451](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L451)_ +_Defined in [index.ts:481](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L481)_ **Returns:** `Buffer` @@ -195,7 +195,7 @@ _Defined in [index.ts:451](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **getPublicKeyString**(): `string` -_Defined in [index.ts:455](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L455)_ +_Defined in [index.ts:485](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L485)_ **Returns:** `string` @@ -207,7 +207,7 @@ _Defined in [index.ts:455](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **getV3Filename**(timestamp?: _`undefined` \| `number`_): `string` -_Defined in [index.ts:540](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L540)_ +_Defined in [index.ts:570](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L570)_ **Parameters:** @@ -225,7 +225,7 @@ _Defined in [index.ts:540](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **toV3**(password: _`string`_, opts?: _`Partial`<`V3Params`>_): `V3Keystore` -_Defined in [index.ts:471](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L471)_ +_Defined in [index.ts:501](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L501)_ **Parameters:** @@ -244,7 +244,7 @@ _Defined in [index.ts:471](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **toV3String**(password: _`string`_, opts?: _`Partial`<`V3Params`>_): `string` -_Defined in [index.ts:558](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L558)_ +_Defined in [index.ts:588](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L588)_ **Parameters:** @@ -263,7 +263,7 @@ _Defined in [index.ts:558](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **fromEthSale**(input: _`string` \| `EthSaleKeystore`_, password: _`string`_): [Wallet](wallet.md) -_Defined in [index.ts:402](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L402)_ +_Defined in [index.ts:432](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L432)_ **Parameters:** @@ -282,7 +282,9 @@ _Defined in [index.ts:402](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **fromExtendedPrivateKey**(extendedPrivateKey: _`string`_): [Wallet](wallet.md) -_Defined in [index.ts:295](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L295)_ +_Defined in [index.ts:318](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L318)_ + +Create an instance based on a BIP32 extended private key (xprv) **Parameters:** @@ -300,7 +302,9 @@ _Defined in [index.ts:295](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **fromExtendedPublicKey**(extendedPublicKey: _`string`_): [Wallet](wallet.md) -_Defined in [index.ts:282](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L282)_ +_Defined in [index.ts:299](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L299)_ + +Create an instance based on a BIP32 extended public key (xpub) **Parameters:** @@ -318,7 +322,9 @@ _Defined in [index.ts:282](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **fromPrivateKey**(privateKey: _`Buffer`_): [Wallet](wallet.md) -_Defined in [index.ts:291](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L291)_ +_Defined in [index.ts:311](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L311)_ + +Create an instance based on a raw private key **Parameters:** @@ -336,7 +342,11 @@ _Defined in [index.ts:291](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **fromPublicKey**(publicKey: _`Buffer`_, nonStrict?: _`boolean`_): [Wallet](wallet.md) -_Defined in [index.ts:275](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L275)_ +_Defined in [index.ts:289](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L289)_ + +Create an instance based on a public key (certain methods will not be available) + +This method only accepts uncompressed Ethereum-style public keys, unless the `nonStrict` flag is set to true. **Parameters:** @@ -355,7 +365,9 @@ _Defined in [index.ts:275](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **fromV1**(input: _`string` \| `V1Keystore`_, password: _`string`_): [Wallet](wallet.md) -_Defined in [index.ts:306](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L306)_ +_Defined in [index.ts:332](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L332)_ + +Import a wallet (Version 1 of the Ethereum wallet format) **Parameters:** @@ -374,7 +386,9 @@ _Defined in [index.ts:306](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **fromV3**(input: _`string` \| `V3Keystore`_, password: _`string`_, nonStrict?: _`boolean`_): [Wallet](wallet.md) -_Defined in [index.ts:340](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L340)_ +_Defined in [index.ts:369](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L369)_ + +Import a wallet (Version 3 of the Ethereum wallet format). Set `nonStrict` true to accept files with mixed-caps. **Parameters:** @@ -394,13 +408,15 @@ _Defined in [index.ts:340](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **generate**(icapDirect?: _`boolean`_): [Wallet](wallet.md) -_Defined in [index.ts:246](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L246)_ +_Defined in [index.ts:251](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L251)_ + +Create an instance based on a new random key. **Parameters:** -| Name | Type | Default value | -| -------------------------- | --------- | ------------- | -| `Default value` icapDirect | `boolean` | false | +| Name | Type | Default value | Description | +| -------------------------- | --------- | ------------- | --------------------------------------------------------------------------------------- | +| `Default value` icapDirect | `boolean` | false | setting this to \`true\` will generate an address suitable for the \`ICAP Direct mode\` | **Returns:** [Wallet](wallet.md) @@ -412,7 +428,9 @@ _Defined in [index.ts:246](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **generateVanityAddress**(pattern: _`RegExp` \| `string`_): [Wallet](wallet.md) -_Defined in [index.ts:260](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/index.ts#L260)_ +_Defined in [index.ts:268](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L268)_ + +Create an instance where the address is valid against the supplied pattern (**this will be very slow**) **Parameters:** diff --git a/docs/classes/walletsubprovider.md b/docs/classes/walletsubprovider.md index f295e4b..efe83d6 100644 --- a/docs/classes/walletsubprovider.md +++ b/docs/classes/walletsubprovider.md @@ -24,7 +24,7 @@ ⊕ **new WalletSubprovider**(wallet: _[Wallet](wallet.md)_, opts?: _`any`_): [WalletSubprovider](walletsubprovider.md) -_Defined in [provider-engine.ts:5](https://github.com/ethereumjs/ethereumjs-wallet/blob/ac90675/src/provider-engine.ts#L5)_ +_Defined in [provider-engine.ts:5](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/provider-engine.ts#L5)_ **Parameters:** diff --git a/docs/interfaces/etherwalletoptions.md b/docs/interfaces/etherwalletoptions.md new file mode 100644 index 0000000..b9d4445 --- /dev/null +++ b/docs/interfaces/etherwalletoptions.md @@ -0,0 +1,82 @@ +[ethereumjs-wallet](../README.md) > [EtherWalletOptions](../interfaces/etherwalletoptions.md) + +# Interface: EtherWalletOptions + +## Hierarchy + +**EtherWalletOptions** + +## Index + +### Properties + +- [address](etherwalletoptions.md#address) +- [encrypted](etherwalletoptions.md#encrypted) +- [hash](etherwalletoptions.md#hash) +- [locked](etherwalletoptions.md#locked) +- [private](etherwalletoptions.md#private) +- [public](etherwalletoptions.md#public) + +--- + +## Properties + + + +### address + +**● address**: _`string`_ + +_Defined in [thirdparty.ts:108](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L108)_ + +--- + + + +### encrypted + +**● encrypted**: _`boolean`_ + +_Defined in [thirdparty.ts:109](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L109)_ + +--- + + + +### hash + +**● hash**: _`string`_ + +_Defined in [thirdparty.ts:111](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L111)_ + +--- + + + +### locked + +**● locked**: _`boolean`_ + +_Defined in [thirdparty.ts:110](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L110)_ + +--- + + + +### private + +**● private**: _`string`_ + +_Defined in [thirdparty.ts:112](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L112)_ + +--- + + + +### public + +**● public**: _`string`_ + +_Defined in [thirdparty.ts:113](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L113)_ + +--- diff --git a/docs/interfaces/evpkdfopts.md b/docs/interfaces/evpkdfopts.md new file mode 100644 index 0000000..9db788a --- /dev/null +++ b/docs/interfaces/evpkdfopts.md @@ -0,0 +1,60 @@ +[ethereumjs-wallet](../README.md) > [EvpKdfOpts](../interfaces/evpkdfopts.md) + +# Interface: EvpKdfOpts + +## Hierarchy + +**EvpKdfOpts** + +## Index + +### Properties + +- [count](evpkdfopts.md#count) +- [digest](evpkdfopts.md#digest) +- [ivsize](evpkdfopts.md#ivsize) +- [keysize](evpkdfopts.md#keysize) + +--- + +## Properties + + + +### count + +**● count**: _`number`_ + +_Defined in [thirdparty.ts:17](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L17)_ + +--- + + + +### digest + +**● digest**: _`string`_ + +_Defined in [thirdparty.ts:20](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L20)_ + +--- + + + +### ivsize + +**● ivsize**: _`number`_ + +_Defined in [thirdparty.ts:19](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L19)_ + +--- + + + +### keysize + +**● keysize**: _`number`_ + +_Defined in [thirdparty.ts:18](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L18)_ + +--- From 99b5683e22f3a6c8298256510ad972dc9cbb9981 Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Tue, 21 Apr 2020 19:35:57 -0300 Subject: [PATCH 04/13] Addressed the PR comments --- README.md | 39 +++++++++++++++++++++++++++++++++++--- src/hdkey.ts | 24 ++++++++++++++++++++++++ src/index.ts | 48 +++++++++++++++++++++++++++++++++++++++++++++-- src/thirdparty.ts | 10 ++++++++++ 4 files changed, 116 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 255f6ef..cc1b464 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,17 @@ For information about the Wallet's API, please go to [./docs/classes/wallet.md]( Importing various third party wallets is possible through the `thirdparty` submodule: -`const thirdparty = require('ethereumjs-wallet/thirdparty')` +Node.js / ES5: + +```js +const thirdparty = require('ethereumjs-wallet/thirdparty').default +``` + +ESM / TypeScript: + +```js +import thirdparty from 'ethereumjs-wallet/thirdparty' +``` Please go to [./docs/README.md](./docs/README.md) for more info. @@ -42,7 +52,18 @@ Please go to [./docs/README.md](./docs/README.md) for more info. To use BIP32 HD wallets, first include the `hdkey` submodule: -`const hdkey = require('ethereumjs-wallet/hdkey')` +Node.js / ES5: + +```js +const hdkey = require('ethereumjs-wallet/hdkey').default +``` + +ESM / TypeScript: + +```js +import hdkey from 'ethereumjs-wallet/hdkey' +``` + Please go to [./docs/classes/ethereumhdkey.md](./docs/classes/ethereumhdkey.md) for more info. @@ -50,14 +71,26 @@ Please go to [./docs/classes/ethereumhdkey.md](./docs/classes/ethereumhdkey.md) 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/provider-engine') +const WalletSubprovider = require('ethereumjs-wallet/provider-engine').default + +.addProvider(new WalletSubprovider()) +``` + +ESM / TypeScript: + +```js +import WalletSubprovider from 'ethereumjs-wallet/provider-engine' .addProvider(new WalletSubprovider()) ``` 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: diff --git a/src/hdkey.ts b/src/hdkey.ts index 2eafb27..1070821 100644 --- a/src/hdkey.ts +++ b/src/hdkey.ts @@ -3,16 +3,28 @@ import Wallet from './index' const HDKey = require('hdkey') export default class EthereumHDKey { + /** + * Creates an instance based on a seed. + * + * For the seed we suggest to use [bip39](https://npmjs.org/package/bip39) to + * create one from a BIP39 mnemonic. + */ public static fromMasterSeed(seedBuffer: Buffer): EthereumHDKey { return new EthereumHDKey(HDKey.fromMasterSeed(seedBuffer)) } + /** + * Create an instance based on a BIP32 extended private or public key. + */ public static fromExtendedKey(base58Key: string): EthereumHDKey { return new EthereumHDKey(HDKey.fromExtendedKey(base58Key)) } constructor(private readonly _hdkey?: any) {} + /** + * Returns a BIP32 extended private key (xprv) + */ public privateExtendedKey(): Buffer { if (!this._hdkey.privateExtendedKey) { throw new Error('This is a public key only wallet') @@ -20,18 +32,30 @@ export default class EthereumHDKey { return this._hdkey.privateExtendedKey } + /** + * Return a BIP32 extended public key (xpub) + */ public publicExtendedKey(): Buffer { return this._hdkey.publicExtendedKey } + /** + * Derives a node based on a path (e.g. m/44'/0'/0/1) + */ public derivePath(path: string): EthereumHDKey { return new EthereumHDKey(this._hdkey.derive(path)) } + /** + * Derive a node based on a child index + */ public deriveChild(index: number): EthereumHDKey { return new EthereumHDKey(this._hdkey.deriveChild(index)) } + /** + * Return a `Wallet` instance as seen above + */ public getWallet(): Wallet { if (this._hdkey._privateKey) { return Wallet.fromPrivateKey(this._hdkey._privateKey) diff --git a/src/index.ts b/src/index.ts index 99f8559..6cfdf79 100644 --- a/src/index.ts +++ b/src/index.ts @@ -327,7 +327,10 @@ export default class Wallet { } /** - * Import a wallet (Version 1 of the Ethereum wallet format) + * Import a wallet (Version 1 of the Ethereum wallet format). + * + * @param input A JSON serialized string, or an object representing V1 Keystore. + * @param password The keystore password. */ public static fromV1(input: string | V1Keystore, password: string): Wallet { const json: V1Keystore = typeof input === 'object' ? input : JSON.parse(input) @@ -365,6 +368,9 @@ export default class Wallet { /** * Import a wallet (Version 3 of the Ethereum wallet format). Set `nonStrict` true to accept files with mixed-caps. + * + * @param input A JSON serialized string, or an object representing V3 Keystore. + * @param password The keystore password. */ public static fromV3( input: string | V3Keystore, @@ -425,9 +431,12 @@ export default class Wallet { } /* - * Import an Ethereum Pre Sale wallet + * Import an Ethereum Pre Sale wallet. * Based on https://github.com/ethereum/pyethsaletool/blob/master/pyethsaletool.py * JSON fields: encseed, ethaddr, btcaddr, email + * + * @param input A JSON serialized string, or an object representing EthSale Keystore. + * @param password The keystore password. */ public static fromEthSale(input: string | EthSaleKeystore, password: string): Wallet { const json: EthSaleKeystore = typeof input === 'object' ? input : JSON.parse(input) @@ -452,6 +461,9 @@ export default class Wallet { // private getters + /** + * Returns the wallet's public key. + */ private get pubKey(): Buffer { if (!keyExists(this.publicKey)) { this.publicKey = ethUtil.privateToPublic(this.privateKey as Buffer) @@ -459,6 +471,9 @@ export default class Wallet { return this.publicKey } + /** + * Returns the wallet's private key. + */ private get privKey(): Buffer { if (!keyExists(this.privateKey)) { throw new Error('This is a public key only wallet') @@ -468,6 +483,10 @@ export default class Wallet { // public instance methods + /** + * Returns the wallet's private key. + * + */ // tslint:disable-next-line public getPrivateKey(): Buffer { return this.privKey @@ -477,27 +496,49 @@ export default class Wallet { return ethUtil.bufferToHex(this.privKey) } + /** + * Returns the wallet's public key. + */ // tslint:disable-next-line public getPublicKey(): Buffer { return this.pubKey } + /** + * Returns the wallet's public key as a "0x" prefixed hex string + */ public getPublicKeyString(): string { return ethUtil.bufferToHex(this.getPublicKey()) } + /** + * Returns the wallet's address. + */ public getAddress(): Buffer { return ethUtil.publicToAddress(this.pubKey) } + /** + * Returns the wallet's address as a "0x" prefixed hex string + */ public getAddressString(): string { return ethUtil.bufferToHex(this.getAddress()) } + /** + * Returns the wallet's private key as a "0x" prefixed hex string checksummed + * according to [EIP 55](https://github.com/ethereum/EIPs/issues/55). + */ public getChecksumAddressString(): string { return ethUtil.toChecksumAddress(this.getAddressString()) } + /** + * Returns an Etherem Version 3 Keystore Format object representing the wallet + * + * @param password The password used to encrypt the Keystore. + * @param opts The options for the keystore. See [its spec](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition) for more info. + */ public toV3(password: string, opts?: Partial): V3Keystore { if (!keyExists(this.privateKey)) { throw new Error('This is a public key only wallet') @@ -567,6 +608,9 @@ export default class Wallet { } } + /** + * Return the suggested filename for V3 keystores. + */ public getV3Filename(timestamp?: number): string { /* * We want a timestamp like 2016-03-15T17-11-33.007598288Z. Date formatting diff --git a/src/thirdparty.ts b/src/thirdparty.ts index 75a148c..24352a0 100644 --- a/src/thirdparty.ts +++ b/src/thirdparty.ts @@ -114,6 +114,7 @@ export interface EtherWalletOptions { } /* + * Third Party API: Import a wallet generated by EtherWallet * This wallet format is created by https://github.com/SilentCicero/ethereumjs-accounts * and used on https://www.myetherwallet.com/ */ @@ -162,10 +163,16 @@ export function fromEtherWallet(input: string | EtherWalletOptions, password: st return wallet } +/** + * Third Party API: Import a brain wallet used by Ether.Camp + */ export function fromEtherCamp(passphrase: string): Wallet { return new Wallet(ethUtil.keccak256(Buffer.from(passphrase))) } +/** + * Third Party API: Import a wallet from a KryptoKit seed + */ export function fromKryptoKit(entropy: string, password: string): Wallet { function kryptoKitBrokenScryptSeed(buf: Buffer) { // js-scrypt calls `Buffer.from(String(salt), 'utf8')` on the seed even though it is a buffer @@ -252,6 +259,9 @@ export function fromKryptoKit(entropy: string, password: string): Wallet { return new Wallet(privateKey) } +/** + * Third Party API: Import a brain wallet used by Quorum Wallet + */ export function fromQuorumWallet(passphrase: string, userid: string): Wallet { if (passphrase.length < 10) { throw new Error('Passphrase must be at least 10 characters') From 1c1bfb2f950a2dce0856a702c135d3d937f0280d Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Tue, 21 Apr 2020 19:44:42 -0300 Subject: [PATCH 05/13] Regenerated docs --- docs/README.md | 87 +++---- docs/classes/ethereumhdkey.md | 125 +++++----- docs/classes/wallet.md | 323 +++++++++++++------------- docs/classes/walletsubprovider.md | 21 +- docs/interfaces/etherwalletoptions.md | 66 +++--- docs/interfaces/evpkdfopts.md | 44 ++-- 6 files changed, 339 insertions(+), 327 deletions(-) diff --git a/docs/README.md b/docs/README.md index faeece6..753724b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,24 +1,25 @@ -# ethereumjs-wallet + +# ethereumjs-wallet ## Index ### Classes -- [EthereumHDKey](classes/ethereumhdkey.md) -- [Wallet](classes/wallet.md) -- [WalletSubprovider](classes/walletsubprovider.md) +* [EthereumHDKey](classes/ethereumhdkey.md) +* [Wallet](classes/wallet.md) +* [WalletSubprovider](classes/walletsubprovider.md) ### Interfaces -- [EtherWalletOptions](interfaces/etherwalletoptions.md) -- [EvpKdfOpts](interfaces/evpkdfopts.md) +* [EtherWalletOptions](interfaces/etherwalletoptions.md) +* [EvpKdfOpts](interfaces/evpkdfopts.md) ### Functions -- [fromEtherCamp](#fromethercamp) -- [fromEtherWallet](#frometherwallet) -- [fromKryptoKit](#fromkryptokit) -- [fromQuorumWallet](#fromquorumwallet) +* [fromEtherCamp](#fromethercamp) +* [fromEtherWallet](#frometherwallet) +* [fromKryptoKit](#fromkryptokit) +* [fromQuorumWallet](#fromquorumwallet) --- @@ -26,75 +27,79 @@ -### fromEtherCamp +### fromEtherCamp + +▸ **fromEtherCamp**(passphrase: *`string`*): [Wallet](classes/wallet.md) -▸ **fromEtherCamp**(passphrase: _`string`_): [Wallet](classes/wallet.md) +*Defined in [thirdparty.ts:169](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L169)* -_Defined in [thirdparty.ts:165](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L165)_ +Third Party API: Import a brain wallet used by Ether.Camp **Parameters:** -| Name | Type | -| ---------- | -------- | +| Name | Type | +| ------ | ------ | | passphrase | `string` | **Returns:** [Wallet](classes/wallet.md) ---- - +___ -### fromEtherWallet +### fromEtherWallet -▸ **fromEtherWallet**(input: _`string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md)_, password: _`string`_): [Wallet](classes/wallet.md) +▸ **fromEtherWallet**(input: *`string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md)*, password: *`string`*): [Wallet](classes/wallet.md) -_Defined in [thirdparty.ts:120](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L120)_ +*Defined in [thirdparty.ts:121](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L121)* **Parameters:** -| Name | Type | -| -------- | ------------------------------------------------------------------ | -| input | `string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md) | -| password | `string` | +| Name | Type | +| ------ | ------ | +| input | `string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md) | +| password | `string` | **Returns:** [Wallet](classes/wallet.md) ---- - +___ -### fromKryptoKit +### fromKryptoKit -▸ **fromKryptoKit**(entropy: _`string`_, password: _`string`_): [Wallet](classes/wallet.md) +▸ **fromKryptoKit**(entropy: *`string`*, password: *`string`*): [Wallet](classes/wallet.md) -_Defined in [thirdparty.ts:169](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L169)_ +*Defined in [thirdparty.ts:176](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L176)* + +Third Party API: Import a wallet from a KryptoKit seed **Parameters:** -| Name | Type | -| -------- | -------- | -| entropy | `string` | +| Name | Type | +| ------ | ------ | +| entropy | `string` | | password | `string` | **Returns:** [Wallet](classes/wallet.md) ---- - +___ -### fromQuorumWallet +### fromQuorumWallet -▸ **fromQuorumWallet**(passphrase: _`string`_, userid: _`string`_): [Wallet](classes/wallet.md) +▸ **fromQuorumWallet**(passphrase: *`string`*, userid: *`string`*): [Wallet](classes/wallet.md) -_Defined in [thirdparty.ts:255](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L255)_ +*Defined in [thirdparty.ts:265](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L265)* + +Third Party API: Import a brain wallet used by Quorum Wallet **Parameters:** -| Name | Type | -| ---------- | -------- | +| Name | Type | +| ------ | ------ | | passphrase | `string` | -| userid | `string` | +| userid | `string` | **Returns:** [Wallet](classes/wallet.md) ---- +___ + diff --git a/docs/classes/ethereumhdkey.md b/docs/classes/ethereumhdkey.md index 14651a6..6e5893b 100644 --- a/docs/classes/ethereumhdkey.md +++ b/docs/classes/ethereumhdkey.md @@ -10,21 +10,21 @@ ### Constructors -- [constructor](ethereumhdkey.md#constructor) +* [constructor](ethereumhdkey.md#constructor) ### Properties -- [\_hdkey](ethereumhdkey.md#_hdkey) +* [_hdkey](ethereumhdkey.md#_hdkey) ### Methods -- [deriveChild](ethereumhdkey.md#derivechild) -- [derivePath](ethereumhdkey.md#derivepath) -- [getWallet](ethereumhdkey.md#getwallet) -- [privateExtendedKey](ethereumhdkey.md#privateextendedkey) -- [publicExtendedKey](ethereumhdkey.md#publicextendedkey) -- [fromExtendedKey](ethereumhdkey.md#fromextendedkey) -- [fromMasterSeed](ethereumhdkey.md#frommasterseed) +* [deriveChild](ethereumhdkey.md#derivechild) +* [derivePath](ethereumhdkey.md#derivepath) +* [getWallet](ethereumhdkey.md#getwallet) +* [privateExtendedKey](ethereumhdkey.md#privateextendedkey) +* [publicExtendedKey](ethereumhdkey.md#publicextendedkey) +* [fromExtendedKey](ethereumhdkey.md#fromextendedkey) +* [fromMasterSeed](ethereumhdkey.md#frommasterseed) --- @@ -32,140 +32,151 @@ -### constructor +### constructor -⊕ **new EthereumHDKey**(\_hdkey?: _`any`_): [EthereumHDKey](ethereumhdkey.md) +⊕ **new EthereumHDKey**(_hdkey?: *`any`*): [EthereumHDKey](ethereumhdkey.md) -_Defined in [hdkey.ts:12](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L12)_ +*Defined in [hdkey.ts:21](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L21)* **Parameters:** -| Name | Type | -| ------------------ | ----- | -| `Optional` \_hdkey | `any` | +| Name | Type | +| ------ | ------ | +| `Optional` _hdkey | `any` | **Returns:** [EthereumHDKey](ethereumhdkey.md) ---- +___ ## Properties -### ` `` ` \_hdkey +### ```` _hdkey -**● \_hdkey**: _`any`_ +**● _hdkey**: *`any`* -_Defined in [hdkey.ts:14](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L14)_ +*Defined in [hdkey.ts:23](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L23)* ---- +___ ## Methods -### deriveChild +### deriveChild + +▸ **deriveChild**(index: *`number`*): [EthereumHDKey](ethereumhdkey.md) -▸ **deriveChild**(index: _`number`_): [EthereumHDKey](ethereumhdkey.md) +*Defined in [hdkey.ts:52](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L52)* -_Defined in [hdkey.ts:31](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L31)_ +Derive a node based on a child index **Parameters:** -| Name | Type | -| ----- | -------- | +| Name | Type | +| ------ | ------ | | index | `number` | **Returns:** [EthereumHDKey](ethereumhdkey.md) ---- - +___ -### derivePath +### derivePath + +▸ **derivePath**(path: *`string`*): [EthereumHDKey](ethereumhdkey.md) -▸ **derivePath**(path: _`string`_): [EthereumHDKey](ethereumhdkey.md) +*Defined in [hdkey.ts:45](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L45)* -_Defined in [hdkey.ts:27](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L27)_ +Derives a node based on a path (e.g. m/44'/0'/0/1) **Parameters:** -| Name | Type | -| ---- | -------- | +| Name | Type | +| ------ | ------ | | path | `string` | **Returns:** [EthereumHDKey](ethereumhdkey.md) ---- - +___ -### getWallet +### getWallet ▸ **getWallet**(): [Wallet](wallet.md) -_Defined in [hdkey.ts:35](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L35)_ +*Defined in [hdkey.ts:59](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L59)* -**Returns:** [Wallet](wallet.md) +Return a `Wallet` instance as seen above ---- +**Returns:** [Wallet](wallet.md) +___ -### privateExtendedKey +### privateExtendedKey ▸ **privateExtendedKey**(): `Buffer` -_Defined in [hdkey.ts:16](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L16)_ +*Defined in [hdkey.ts:28](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L28)* -**Returns:** `Buffer` +Returns a BIP32 extended private key (xprv) ---- +**Returns:** `Buffer` +___ -### publicExtendedKey +### publicExtendedKey ▸ **publicExtendedKey**(): `Buffer` -_Defined in [hdkey.ts:23](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L23)_ +*Defined in [hdkey.ts:38](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L38)* -**Returns:** `Buffer` +Return a BIP32 extended public key (xpub) ---- +**Returns:** `Buffer` +___ ### `` fromExtendedKey -▸ **fromExtendedKey**(base58Key: _`string`_): [EthereumHDKey](ethereumhdkey.md) +▸ **fromExtendedKey**(base58Key: *`string`*): [EthereumHDKey](ethereumhdkey.md) + +*Defined in [hdkey.ts:19](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L19)* -_Defined in [hdkey.ts:10](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L10)_ +Create an instance based on a BIP32 extended private or public key. **Parameters:** -| Name | Type | -| --------- | -------- | +| Name | Type | +| ------ | ------ | | base58Key | `string` | **Returns:** [EthereumHDKey](ethereumhdkey.md) ---- - +___ ### `` fromMasterSeed -▸ **fromMasterSeed**(seedBuffer: _`Buffer`_): [EthereumHDKey](ethereumhdkey.md) +▸ **fromMasterSeed**(seedBuffer: *`Buffer`*): [EthereumHDKey](ethereumhdkey.md) + +*Defined in [hdkey.ts:12](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L12)* -_Defined in [hdkey.ts:6](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/hdkey.ts#L6)_ +Creates an instance based on a seed. + +For the seed we suggest to use [bip39](https://npmjs.org/package/bip39) to create one from a BIP39 mnemonic. **Parameters:** -| Name | Type | -| ---------- | -------- | +| Name | Type | +| ------ | ------ | | seedBuffer | `Buffer` | **Returns:** [EthereumHDKey](ethereumhdkey.md) ---- +___ + diff --git a/docs/classes/wallet.md b/docs/classes/wallet.md index 1b30d62..11811b4 100644 --- a/docs/classes/wallet.md +++ b/docs/classes/wallet.md @@ -10,39 +10,39 @@ ### Constructors -- [constructor](wallet.md#constructor) +* [constructor](wallet.md#constructor) ### Properties -- [privateKey](wallet.md#privatekey) -- [publicKey](wallet.md#publickey) +* [privateKey](wallet.md#privatekey) +* [publicKey](wallet.md#publickey) ### Accessors -- [privKey](wallet.md#privkey) -- [pubKey](wallet.md#pubkey) +* [privKey](wallet.md#privkey) +* [pubKey](wallet.md#pubkey) ### Methods -- [getAddress](wallet.md#getaddress) -- [getAddressString](wallet.md#getaddressstring) -- [getChecksumAddressString](wallet.md#getchecksumaddressstring) -- [getPrivateKey](wallet.md#getprivatekey) -- [getPrivateKeyString](wallet.md#getprivatekeystring) -- [getPublicKey](wallet.md#getpublickey) -- [getPublicKeyString](wallet.md#getpublickeystring) -- [getV3Filename](wallet.md#getv3filename) -- [toV3](wallet.md#tov3) -- [toV3String](wallet.md#tov3string) -- [fromEthSale](wallet.md#fromethsale) -- [fromExtendedPrivateKey](wallet.md#fromextendedprivatekey) -- [fromExtendedPublicKey](wallet.md#fromextendedpublickey) -- [fromPrivateKey](wallet.md#fromprivatekey) -- [fromPublicKey](wallet.md#frompublickey) -- [fromV1](wallet.md#fromv1) -- [fromV3](wallet.md#fromv3) -- [generate](wallet.md#generate) -- [generateVanityAddress](wallet.md#generatevanityaddress) +* [getAddress](wallet.md#getaddress) +* [getAddressString](wallet.md#getaddressstring) +* [getChecksumAddressString](wallet.md#getchecksumaddressstring) +* [getPrivateKey](wallet.md#getprivatekey) +* [getPrivateKeyString](wallet.md#getprivatekeystring) +* [getPublicKey](wallet.md#getpublickey) +* [getPublicKeyString](wallet.md#getpublickeystring) +* [getV3Filename](wallet.md#getv3filename) +* [toV3](wallet.md#tov3) +* [toV3String](wallet.md#tov3string) +* [fromEthSale](wallet.md#fromethsale) +* [fromExtendedPrivateKey](wallet.md#fromextendedprivatekey) +* [fromExtendedPublicKey](wallet.md#fromextendedpublickey) +* [fromPrivateKey](wallet.md#fromprivatekey) +* [fromPublicKey](wallet.md#frompublickey) +* [fromV1](wallet.md#fromv1) +* [fromV3](wallet.md#fromv3) +* [generate](wallet.md#generate) +* [generateVanityAddress](wallet.md#generatevanityaddress) --- @@ -50,44 +50,43 @@ -### constructor +### constructor -⊕ **new Wallet**(privateKey?: _`Buffer` \| `undefined`_, publicKey?: _`Buffer` \| `undefined`_): [Wallet](wallet.md) +⊕ **new Wallet**(privateKey?: *`Buffer` \| `undefined`*, publicKey?: *`Buffer` \| `undefined`*): [Wallet](wallet.md) -_Defined in [index.ts:226](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L226)_ +*Defined in [index.ts:230](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L230)* **Parameters:** -| Name | Type | Default value | -| ------------------------- | ----------------------- | ------------- | -| `Optional` privateKey | `Buffer` \| `undefined` | - | -| `Default value` publicKey | `Buffer` \| `undefined` | undefined | +| Name | Type | Default value | +| ------ | ------ | ------ | +| `Optional` privateKey | `Buffer` \| `undefined` | - | +| `Default value` publicKey | `Buffer` \| `undefined` | undefined | **Returns:** [Wallet](wallet.md) ---- +___ ## Properties -### ` `` ` privateKey - -**● privateKey**: _`Buffer` \| `undefined`_ +### ```` privateKey -_Defined in [index.ts:228](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L228)_ +**● privateKey**: *`Buffer` \| `undefined`* ---- +*Defined in [index.ts:232](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L232)* +___ ### `` publicKey -**● publicKey**: _`Buffer` \| `undefined`_ +**● publicKey**: *`Buffer` \| `undefined`* -_Defined in [index.ts:229](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L229)_ +*Defined in [index.ts:233](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L233)* ---- +___ ## Accessors @@ -97,252 +96,257 @@ _Defined in [index.ts:229](https://github.com/alcuadrado/ethereumjs-wallet/blob/ **get privKey**(): `Buffer` -_Defined in [index.ts:462](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L462)_ +*Defined in [index.ts:481](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L481)* -**Returns:** `Buffer` +Returns the wallet's private key. ---- +**Returns:** `Buffer` +___ ### `` pubKey **get pubKey**(): `Buffer` -_Defined in [index.ts:455](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L455)_ +*Defined in [index.ts:471](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L471)* + +Returns the wallet's public key. **Returns:** `Buffer` ---- +___ ## Methods -### getAddress +### getAddress ▸ **getAddress**(): `Buffer` -_Defined in [index.ts:489](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L489)_ +*Defined in [index.ts:521](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L521)* -**Returns:** `Buffer` +Returns the wallet's address. ---- +**Returns:** `Buffer` +___ -### getAddressString +### getAddressString ▸ **getAddressString**(): `string` -_Defined in [index.ts:493](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L493)_ +*Defined in [index.ts:528](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L528)* -**Returns:** `string` +Returns the wallet's address as a "0x" prefixed hex string ---- +**Returns:** `string` +___ -### getChecksumAddressString +### getChecksumAddressString ▸ **getChecksumAddressString**(): `string` -_Defined in [index.ts:497](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L497)_ +*Defined in [index.ts:536](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L536)* -**Returns:** `string` +Returns the wallet's private key as a "0x" prefixed hex string checksummed according to [EIP 55](https://github.com/ethereum/EIPs/issues/55). ---- +**Returns:** `string` +___ -### getPrivateKey +### getPrivateKey ▸ **getPrivateKey**(): `Buffer` -_Defined in [index.ts:472](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L472)_ +*Defined in [index.ts:495](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L495)* -**Returns:** `Buffer` +Returns the wallet's private key. ---- +**Returns:** `Buffer` +___ -### getPrivateKeyString +### getPrivateKeyString ▸ **getPrivateKeyString**(): `string` -_Defined in [index.ts:476](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L476)_ +*Defined in [index.ts:499](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L499)* **Returns:** `string` ---- - +___ -### getPublicKey +### getPublicKey ▸ **getPublicKey**(): `Buffer` -_Defined in [index.ts:481](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L481)_ +*Defined in [index.ts:507](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L507)* -**Returns:** `Buffer` +Returns the wallet's public key. ---- +**Returns:** `Buffer` +___ -### getPublicKeyString +### getPublicKeyString ▸ **getPublicKeyString**(): `string` -_Defined in [index.ts:485](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L485)_ +*Defined in [index.ts:514](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L514)* -**Returns:** `string` +Returns the wallet's public key as a "0x" prefixed hex string ---- +**Returns:** `string` +___ -### getV3Filename +### getV3Filename + +▸ **getV3Filename**(timestamp?: *`undefined` \| `number`*): `string` -▸ **getV3Filename**(timestamp?: _`undefined` \| `number`_): `string` +*Defined in [index.ts:618](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L618)* -_Defined in [index.ts:570](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L570)_ +Return the suggested filename for V3 keystores. **Parameters:** -| Name | Type | -| -------------------- | ----------------------- | +| Name | Type | +| ------ | ------ | | `Optional` timestamp | `undefined` \| `number` | **Returns:** `string` ---- - +___ -### toV3 +### toV3 -▸ **toV3**(password: _`string`_, opts?: _`Partial`<`V3Params`>_): `V3Keystore` +▸ **toV3**(password: *`string`*, opts?: *`Partial`<`V3Params`>*): `V3Keystore` -_Defined in [index.ts:501](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L501)_ +*Defined in [index.ts:546](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L546)* + +Returns an Etherem Version 3 Keystore Format object representing the wallet **Parameters:** -| Name | Type | -| --------------- | --------------------- | -| password | `string` | -| `Optional` opts | `Partial`<`V3Params`> | +| Name | Type | Description | +| ------ | ------ | ------ | +| password | `string` | The password used to encrypt the Keystore. | +| `Optional` opts | `Partial`<`V3Params`> | The options for the keystore. See [its spec](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition) for more info. | **Returns:** `V3Keystore` ---- - +___ -### toV3String +### toV3String -▸ **toV3String**(password: _`string`_, opts?: _`Partial`<`V3Params`>_): `string` +▸ **toV3String**(password: *`string`*, opts?: *`Partial`<`V3Params`>*): `string` -_Defined in [index.ts:588](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L588)_ +*Defined in [index.ts:636](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L636)* **Parameters:** -| Name | Type | -| --------------- | --------------------- | -| password | `string` | +| Name | Type | +| ------ | ------ | +| password | `string` | | `Optional` opts | `Partial`<`V3Params`> | **Returns:** `string` ---- - +___ ### `` fromEthSale -▸ **fromEthSale**(input: _`string` \| `EthSaleKeystore`_, password: _`string`_): [Wallet](wallet.md) +▸ **fromEthSale**(input: *`string` \| `EthSaleKeystore`*, password: *`string`*): [Wallet](wallet.md) -_Defined in [index.ts:432](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L432)_ +*Defined in [index.ts:445](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L445)* **Parameters:** -| Name | Type | -| -------- | ----------------------------- | -| input | `string` \| `EthSaleKeystore` | -| password | `string` | +| Name | Type | +| ------ | ------ | +| input | `string` \| `EthSaleKeystore` | +| password | `string` | **Returns:** [Wallet](wallet.md) ---- - +___ ### `` fromExtendedPrivateKey -▸ **fromExtendedPrivateKey**(extendedPrivateKey: _`string`_): [Wallet](wallet.md) +▸ **fromExtendedPrivateKey**(extendedPrivateKey: *`string`*): [Wallet](wallet.md) -_Defined in [index.ts:318](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L318)_ +*Defined in [index.ts:322](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L322)* Create an instance based on a BIP32 extended private key (xprv) **Parameters:** -| Name | Type | -| ------------------ | -------- | +| Name | Type | +| ------ | ------ | | extendedPrivateKey | `string` | **Returns:** [Wallet](wallet.md) ---- - +___ ### `` fromExtendedPublicKey -▸ **fromExtendedPublicKey**(extendedPublicKey: _`string`_): [Wallet](wallet.md) +▸ **fromExtendedPublicKey**(extendedPublicKey: *`string`*): [Wallet](wallet.md) -_Defined in [index.ts:299](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L299)_ +*Defined in [index.ts:303](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L303)* Create an instance based on a BIP32 extended public key (xpub) **Parameters:** -| Name | Type | -| ----------------- | -------- | +| Name | Type | +| ------ | ------ | | extendedPublicKey | `string` | **Returns:** [Wallet](wallet.md) ---- - +___ ### `` fromPrivateKey -▸ **fromPrivateKey**(privateKey: _`Buffer`_): [Wallet](wallet.md) +▸ **fromPrivateKey**(privateKey: *`Buffer`*): [Wallet](wallet.md) -_Defined in [index.ts:311](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L311)_ +*Defined in [index.ts:315](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L315)* Create an instance based on a raw private key **Parameters:** -| Name | Type | -| ---------- | -------- | +| Name | Type | +| ------ | ------ | | privateKey | `Buffer` | **Returns:** [Wallet](wallet.md) ---- - +___ ### `` fromPublicKey -▸ **fromPublicKey**(publicKey: _`Buffer`_, nonStrict?: _`boolean`_): [Wallet](wallet.md) +▸ **fromPublicKey**(publicKey: *`Buffer`*, nonStrict?: *`boolean`*): [Wallet](wallet.md) -_Defined in [index.ts:289](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L289)_ +*Defined in [index.ts:293](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L293)* Create an instance based on a public key (certain methods will not be available) @@ -350,94 +354,91 @@ This method only accepts uncompressed Ethereum-style public keys, unless the `no **Parameters:** -| Name | Type | Default value | -| ------------------------- | --------- | ------------- | -| publicKey | `Buffer` | - | -| `Default value` nonStrict | `boolean` | false | +| Name | Type | Default value | +| ------ | ------ | ------ | +| publicKey | `Buffer` | - | +| `Default value` nonStrict | `boolean` | false | **Returns:** [Wallet](wallet.md) ---- - +___ ### `` fromV1 -▸ **fromV1**(input: _`string` \| `V1Keystore`_, password: _`string`_): [Wallet](wallet.md) +▸ **fromV1**(input: *`string` \| `V1Keystore`*, password: *`string`*): [Wallet](wallet.md) -_Defined in [index.ts:332](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L332)_ +*Defined in [index.ts:339](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L339)* -Import a wallet (Version 1 of the Ethereum wallet format) +Import a wallet (Version 1 of the Ethereum wallet format). **Parameters:** -| Name | Type | -| -------- | ------------------------ | -| input | `string` \| `V1Keystore` | -| password | `string` | +| Name | Type | Description | +| ------ | ------ | ------ | +| input | `string` \| `V1Keystore` | A JSON serialized string, or an object representing V1 Keystore. | +| password | `string` | The keystore password. | **Returns:** [Wallet](wallet.md) ---- - +___ ### `` fromV3 -▸ **fromV3**(input: _`string` \| `V3Keystore`_, password: _`string`_, nonStrict?: _`boolean`_): [Wallet](wallet.md) +▸ **fromV3**(input: *`string` \| `V3Keystore`*, password: *`string`*, nonStrict?: *`boolean`*): [Wallet](wallet.md) -_Defined in [index.ts:369](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L369)_ +*Defined in [index.ts:379](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L379)* Import a wallet (Version 3 of the Ethereum wallet format). Set `nonStrict` true to accept files with mixed-caps. **Parameters:** -| Name | Type | Default value | -| ------------------------- | ------------------------ | ------------- | -| input | `string` \| `V3Keystore` | - | -| password | `string` | - | -| `Default value` nonStrict | `boolean` | false | +| Name | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| input | `string` \| `V3Keystore` | - | A JSON serialized string, or an object representing V3 Keystore. | +| password | `string` | - | The keystore password. | +| `Default value` nonStrict | `boolean` | false | **Returns:** [Wallet](wallet.md) ---- - +___ ### `` generate -▸ **generate**(icapDirect?: _`boolean`_): [Wallet](wallet.md) +▸ **generate**(icapDirect?: *`boolean`*): [Wallet](wallet.md) -_Defined in [index.ts:251](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L251)_ +*Defined in [index.ts:255](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L255)* Create an instance based on a new random key. **Parameters:** -| Name | Type | Default value | Description | -| -------------------------- | --------- | ------------- | --------------------------------------------------------------------------------------- | -| `Default value` icapDirect | `boolean` | false | setting this to \`true\` will generate an address suitable for the \`ICAP Direct mode\` | +| Name | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `Default value` icapDirect | `boolean` | false | setting this to \`true\` will generate an address suitable for the \`ICAP Direct mode\` | **Returns:** [Wallet](wallet.md) ---- - +___ ### `` generateVanityAddress -▸ **generateVanityAddress**(pattern: _`RegExp` \| `string`_): [Wallet](wallet.md) +▸ **generateVanityAddress**(pattern: *`RegExp` \| `string`*): [Wallet](wallet.md) -_Defined in [index.ts:268](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/index.ts#L268)_ +*Defined in [index.ts:272](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L272)* Create an instance where the address is valid against the supplied pattern (**this will be very slow**) **Parameters:** -| Name | Type | -| ------- | -------------------- | +| Name | Type | +| ------ | ------ | | pattern | `RegExp` \| `string` | **Returns:** [Wallet](wallet.md) ---- +___ + diff --git a/docs/classes/walletsubprovider.md b/docs/classes/walletsubprovider.md index efe83d6..63861dc 100644 --- a/docs/classes/walletsubprovider.md +++ b/docs/classes/walletsubprovider.md @@ -4,7 +4,7 @@ ## Hierarchy -`any` + `any` **↳ WalletSubprovider** @@ -12,7 +12,7 @@ ### Constructors -- [constructor](walletsubprovider.md#constructor) +* [constructor](walletsubprovider.md#constructor) --- @@ -20,19 +20,20 @@ -### constructor +### constructor -⊕ **new WalletSubprovider**(wallet: _[Wallet](wallet.md)_, opts?: _`any`_): [WalletSubprovider](walletsubprovider.md) +⊕ **new WalletSubprovider**(wallet: *[Wallet](wallet.md)*, opts?: *`any`*): [WalletSubprovider](walletsubprovider.md) -_Defined in [provider-engine.ts:5](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/provider-engine.ts#L5)_ +*Defined in [provider-engine.ts:5](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/provider-engine.ts#L5)* **Parameters:** -| Name | Type | -| --------------- | ------------------- | -| wallet | [Wallet](wallet.md) | -| `Optional` opts | `any` | +| Name | Type | +| ------ | ------ | +| wallet | [Wallet](wallet.md) | +| `Optional` opts | `any` | **Returns:** [WalletSubprovider](walletsubprovider.md) ---- +___ + diff --git a/docs/interfaces/etherwalletoptions.md b/docs/interfaces/etherwalletoptions.md index b9d4445..8074598 100644 --- a/docs/interfaces/etherwalletoptions.md +++ b/docs/interfaces/etherwalletoptions.md @@ -10,12 +10,12 @@ ### Properties -- [address](etherwalletoptions.md#address) -- [encrypted](etherwalletoptions.md#encrypted) -- [hash](etherwalletoptions.md#hash) -- [locked](etherwalletoptions.md#locked) -- [private](etherwalletoptions.md#private) -- [public](etherwalletoptions.md#public) +* [address](etherwalletoptions.md#address) +* [encrypted](etherwalletoptions.md#encrypted) +* [hash](etherwalletoptions.md#hash) +* [locked](etherwalletoptions.md#locked) +* [private](etherwalletoptions.md#private) +* [public](etherwalletoptions.md#public) --- @@ -23,60 +23,56 @@ -### address +### address -**● address**: _`string`_ +**● address**: *`string`* -_Defined in [thirdparty.ts:108](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L108)_ - ---- +*Defined in [thirdparty.ts:108](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L108)* +___ -### encrypted - -**● encrypted**: _`boolean`_ +### encrypted -_Defined in [thirdparty.ts:109](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L109)_ +**● encrypted**: *`boolean`* ---- +*Defined in [thirdparty.ts:109](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L109)* +___ -### hash - -**● hash**: _`string`_ +### hash -_Defined in [thirdparty.ts:111](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L111)_ +**● hash**: *`string`* ---- +*Defined in [thirdparty.ts:111](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L111)* +___ -### locked +### locked -**● locked**: _`boolean`_ +**● locked**: *`boolean`* -_Defined in [thirdparty.ts:110](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L110)_ - ---- +*Defined in [thirdparty.ts:110](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L110)* +___ -### private - -**● private**: _`string`_ +### private -_Defined in [thirdparty.ts:112](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L112)_ +**● private**: *`string`* ---- +*Defined in [thirdparty.ts:112](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L112)* +___ -### public +### public -**● public**: _`string`_ +**● public**: *`string`* -_Defined in [thirdparty.ts:113](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L113)_ +*Defined in [thirdparty.ts:113](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L113)* + +___ ---- diff --git a/docs/interfaces/evpkdfopts.md b/docs/interfaces/evpkdfopts.md index 9db788a..5393119 100644 --- a/docs/interfaces/evpkdfopts.md +++ b/docs/interfaces/evpkdfopts.md @@ -10,10 +10,10 @@ ### Properties -- [count](evpkdfopts.md#count) -- [digest](evpkdfopts.md#digest) -- [ivsize](evpkdfopts.md#ivsize) -- [keysize](evpkdfopts.md#keysize) +* [count](evpkdfopts.md#count) +* [digest](evpkdfopts.md#digest) +* [ivsize](evpkdfopts.md#ivsize) +* [keysize](evpkdfopts.md#keysize) --- @@ -21,40 +21,38 @@ -### count +### count -**● count**: _`number`_ +**● count**: *`number`* -_Defined in [thirdparty.ts:17](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L17)_ - ---- +*Defined in [thirdparty.ts:17](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L17)* +___ -### digest +### digest -**● digest**: _`string`_ +**● digest**: *`string`* -_Defined in [thirdparty.ts:20](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L20)_ - ---- +*Defined in [thirdparty.ts:20](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L20)* +___ -### ivsize +### ivsize -**● ivsize**: _`number`_ +**● ivsize**: *`number`* -_Defined in [thirdparty.ts:19](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L19)_ - ---- +*Defined in [thirdparty.ts:19](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L19)* +___ -### keysize +### keysize -**● keysize**: _`number`_ +**● keysize**: *`number`* -_Defined in [thirdparty.ts:18](https://github.com/alcuadrado/ethereumjs-wallet/blob/8b5f5a9/src/thirdparty.ts#L18)_ +*Defined in [thirdparty.ts:18](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L18)* + +___ ---- From 14ebc2e6747184d4f32539adb57de5800be187ef Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Wed, 22 Apr 2020 07:11:58 -0300 Subject: [PATCH 06/13] Autofix linter errors --- README.md | 7 +- docs/README.md | 81 +++---- docs/classes/ethereumhdkey.md | 109 +++++----- docs/classes/wallet.md | 301 ++++++++++++++------------ docs/classes/walletsubprovider.md | 21 +- docs/interfaces/etherwalletoptions.md | 66 +++--- docs/interfaces/evpkdfopts.md | 44 ++-- src/hdkey.ts | 2 +- src/index.ts | 10 +- test/index.ts | 28 +-- 10 files changed, 348 insertions(+), 321 deletions(-) diff --git a/README.md b/README.md index d49a7f6..b89c98e 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,8 @@ Importing various third party wallets is possible through the `thirdparty` submo `var thirdparty = require('ethereumjs-wallet/thirdparty')` ======= Node.js / ES5: ->>>>>>> typedoc + +> > > > > > > typedoc ```js const thirdparty = require('ethereumjs-wallet/thirdparty').default @@ -64,7 +65,8 @@ To use BIP32 HD wallets, first include the `hdkey` submodule: `var hdkey = require('ethereumjs-wallet/hdkey')` ======= Node.js / ES5: ->>>>>>> typedoc + +> > > > > > > typedoc ```js const hdkey = require('ethereumjs-wallet/hdkey').default @@ -76,7 +78,6 @@ ESM / TypeScript: import hdkey from 'ethereumjs-wallet/hdkey' ``` - Please go to [./docs/classes/ethereumhdkey.md](./docs/classes/ethereumhdkey.md) for more info. ## Provider Engine diff --git a/docs/README.md b/docs/README.md index 753724b..4d3f605 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,25 +1,24 @@ - -# ethereumjs-wallet +# ethereumjs-wallet ## Index ### Classes -* [EthereumHDKey](classes/ethereumhdkey.md) -* [Wallet](classes/wallet.md) -* [WalletSubprovider](classes/walletsubprovider.md) +- [EthereumHDKey](classes/ethereumhdkey.md) +- [Wallet](classes/wallet.md) +- [WalletSubprovider](classes/walletsubprovider.md) ### Interfaces -* [EtherWalletOptions](interfaces/etherwalletoptions.md) -* [EvpKdfOpts](interfaces/evpkdfopts.md) +- [EtherWalletOptions](interfaces/etherwalletoptions.md) +- [EvpKdfOpts](interfaces/evpkdfopts.md) ### Functions -* [fromEtherCamp](#fromethercamp) -* [fromEtherWallet](#frometherwallet) -* [fromKryptoKit](#fromkryptokit) -* [fromQuorumWallet](#fromquorumwallet) +- [fromEtherCamp](#fromethercamp) +- [fromEtherWallet](#frometherwallet) +- [fromKryptoKit](#fromkryptokit) +- [fromQuorumWallet](#fromquorumwallet) --- @@ -27,79 +26,81 @@ -### fromEtherCamp +### fromEtherCamp -▸ **fromEtherCamp**(passphrase: *`string`*): [Wallet](classes/wallet.md) +▸ **fromEtherCamp**(passphrase: _`string`_): [Wallet](classes/wallet.md) -*Defined in [thirdparty.ts:169](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L169)* +_Defined in [thirdparty.ts:169](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L169)_ Third Party API: Import a brain wallet used by Ether.Camp **Parameters:** -| Name | Type | -| ------ | ------ | +| Name | Type | +| ---------- | -------- | | passphrase | `string` | **Returns:** [Wallet](classes/wallet.md) -___ +--- + -### fromEtherWallet +### fromEtherWallet -▸ **fromEtherWallet**(input: *`string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md)*, password: *`string`*): [Wallet](classes/wallet.md) +▸ **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/15de3c4/src/thirdparty.ts#L121)* +_Defined in [thirdparty.ts:121](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L121)_ **Parameters:** -| Name | Type | -| ------ | ------ | -| input | `string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md) | -| password | `string` | +| Name | Type | +| -------- | ------------------------------------------------------------------ | +| input | `string` \| [EtherWalletOptions](interfaces/etherwalletoptions.md) | +| password | `string` | **Returns:** [Wallet](classes/wallet.md) -___ +--- + -### fromKryptoKit +### fromKryptoKit -▸ **fromKryptoKit**(entropy: *`string`*, password: *`string`*): [Wallet](classes/wallet.md) +▸ **fromKryptoKit**(entropy: _`string`_, password: _`string`_): [Wallet](classes/wallet.md) -*Defined in [thirdparty.ts:176](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L176)* +_Defined in [thirdparty.ts:176](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L176)_ Third Party API: Import a wallet from a KryptoKit seed **Parameters:** -| Name | Type | -| ------ | ------ | -| entropy | `string` | +| Name | Type | +| -------- | -------- | +| entropy | `string` | | password | `string` | **Returns:** [Wallet](classes/wallet.md) -___ +--- + -### fromQuorumWallet +### fromQuorumWallet -▸ **fromQuorumWallet**(passphrase: *`string`*, userid: *`string`*): [Wallet](classes/wallet.md) +▸ **fromQuorumWallet**(passphrase: _`string`_, userid: _`string`_): [Wallet](classes/wallet.md) -*Defined in [thirdparty.ts:265](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L265)* +_Defined in [thirdparty.ts:265](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L265)_ Third Party API: Import a brain wallet used by Quorum Wallet **Parameters:** -| Name | Type | -| ------ | ------ | +| Name | Type | +| ---------- | -------- | | passphrase | `string` | -| userid | `string` | +| userid | `string` | **Returns:** [Wallet](classes/wallet.md) -___ - +--- diff --git a/docs/classes/ethereumhdkey.md b/docs/classes/ethereumhdkey.md index 6e5893b..06db7b6 100644 --- a/docs/classes/ethereumhdkey.md +++ b/docs/classes/ethereumhdkey.md @@ -10,21 +10,21 @@ ### Constructors -* [constructor](ethereumhdkey.md#constructor) +- [constructor](ethereumhdkey.md#constructor) ### Properties -* [_hdkey](ethereumhdkey.md#_hdkey) +- [\_hdkey](ethereumhdkey.md#_hdkey) ### Methods -* [deriveChild](ethereumhdkey.md#derivechild) -* [derivePath](ethereumhdkey.md#derivepath) -* [getWallet](ethereumhdkey.md#getwallet) -* [privateExtendedKey](ethereumhdkey.md#privateextendedkey) -* [publicExtendedKey](ethereumhdkey.md#publicextendedkey) -* [fromExtendedKey](ethereumhdkey.md#fromextendedkey) -* [fromMasterSeed](ethereumhdkey.md#frommasterseed) +- [deriveChild](ethereumhdkey.md#derivechild) +- [derivePath](ethereumhdkey.md#derivepath) +- [getWallet](ethereumhdkey.md#getwallet) +- [privateExtendedKey](ethereumhdkey.md#privateextendedkey) +- [publicExtendedKey](ethereumhdkey.md#publicextendedkey) +- [fromExtendedKey](ethereumhdkey.md#fromextendedkey) +- [fromMasterSeed](ethereumhdkey.md#frommasterseed) --- @@ -32,139 +32,145 @@ -### constructor +### constructor -⊕ **new EthereumHDKey**(_hdkey?: *`any`*): [EthereumHDKey](ethereumhdkey.md) +⊕ **new EthereumHDKey**(\_hdkey?: _`any`_): [EthereumHDKey](ethereumhdkey.md) -*Defined in [hdkey.ts:21](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L21)* +_Defined in [hdkey.ts:21](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L21)_ **Parameters:** -| Name | Type | -| ------ | ------ | -| `Optional` _hdkey | `any` | +| Name | Type | +| ------------------ | ----- | +| `Optional` \_hdkey | `any` | **Returns:** [EthereumHDKey](ethereumhdkey.md) -___ +--- ## Properties -### ```` _hdkey +### ` `` ` \_hdkey -**● _hdkey**: *`any`* +**● \_hdkey**: _`any`_ -*Defined in [hdkey.ts:23](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L23)* +_Defined in [hdkey.ts:23](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L23)_ -___ +--- ## Methods -### deriveChild +### deriveChild -▸ **deriveChild**(index: *`number`*): [EthereumHDKey](ethereumhdkey.md) +▸ **deriveChild**(index: _`number`_): [EthereumHDKey](ethereumhdkey.md) -*Defined in [hdkey.ts:52](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L52)* +_Defined in [hdkey.ts:52](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L52)_ Derive a node based on a child index **Parameters:** -| Name | Type | -| ------ | ------ | +| Name | Type | +| ----- | -------- | | index | `number` | **Returns:** [EthereumHDKey](ethereumhdkey.md) -___ +--- + -### derivePath +### derivePath -▸ **derivePath**(path: *`string`*): [EthereumHDKey](ethereumhdkey.md) +▸ **derivePath**(path: _`string`_): [EthereumHDKey](ethereumhdkey.md) -*Defined in [hdkey.ts:45](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L45)* +_Defined in [hdkey.ts:45](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L45)_ Derives a node based on a path (e.g. m/44'/0'/0/1) **Parameters:** -| Name | Type | -| ------ | ------ | +| Name | Type | +| ---- | -------- | | path | `string` | **Returns:** [EthereumHDKey](ethereumhdkey.md) -___ +--- + -### getWallet +### getWallet ▸ **getWallet**(): [Wallet](wallet.md) -*Defined in [hdkey.ts:59](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L59)* +_Defined in [hdkey.ts:59](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L59)_ Return a `Wallet` instance as seen above **Returns:** [Wallet](wallet.md) -___ +--- + -### privateExtendedKey +### privateExtendedKey ▸ **privateExtendedKey**(): `Buffer` -*Defined in [hdkey.ts:28](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L28)* +_Defined in [hdkey.ts:28](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L28)_ Returns a BIP32 extended private key (xprv) **Returns:** `Buffer` -___ +--- + -### publicExtendedKey +### publicExtendedKey ▸ **publicExtendedKey**(): `Buffer` -*Defined in [hdkey.ts:38](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L38)* +_Defined in [hdkey.ts:38](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L38)_ Return a BIP32 extended public key (xpub) **Returns:** `Buffer` -___ +--- + ### `` fromExtendedKey -▸ **fromExtendedKey**(base58Key: *`string`*): [EthereumHDKey](ethereumhdkey.md) +▸ **fromExtendedKey**(base58Key: _`string`_): [EthereumHDKey](ethereumhdkey.md) -*Defined in [hdkey.ts:19](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L19)* +_Defined in [hdkey.ts:19](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L19)_ Create an instance based on a BIP32 extended private or public key. **Parameters:** -| Name | Type | -| ------ | ------ | +| Name | Type | +| --------- | -------- | | base58Key | `string` | **Returns:** [EthereumHDKey](ethereumhdkey.md) -___ +--- + ### `` fromMasterSeed -▸ **fromMasterSeed**(seedBuffer: *`Buffer`*): [EthereumHDKey](ethereumhdkey.md) +▸ **fromMasterSeed**(seedBuffer: _`Buffer`_): [EthereumHDKey](ethereumhdkey.md) -*Defined in [hdkey.ts:12](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L12)* +_Defined in [hdkey.ts:12](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L12)_ Creates an instance based on a seed. @@ -172,11 +178,10 @@ For the seed we suggest to use [bip39](https://npmjs.org/package/bip39) to creat **Parameters:** -| Name | Type | -| ------ | ------ | +| Name | Type | +| ---------- | -------- | | seedBuffer | `Buffer` | **Returns:** [EthereumHDKey](ethereumhdkey.md) -___ - +--- diff --git a/docs/classes/wallet.md b/docs/classes/wallet.md index 11811b4..4b6d2f1 100644 --- a/docs/classes/wallet.md +++ b/docs/classes/wallet.md @@ -10,39 +10,39 @@ ### Constructors -* [constructor](wallet.md#constructor) +- [constructor](wallet.md#constructor) ### Properties -* [privateKey](wallet.md#privatekey) -* [publicKey](wallet.md#publickey) +- [privateKey](wallet.md#privatekey) +- [publicKey](wallet.md#publickey) ### Accessors -* [privKey](wallet.md#privkey) -* [pubKey](wallet.md#pubkey) +- [privKey](wallet.md#privkey) +- [pubKey](wallet.md#pubkey) ### Methods -* [getAddress](wallet.md#getaddress) -* [getAddressString](wallet.md#getaddressstring) -* [getChecksumAddressString](wallet.md#getchecksumaddressstring) -* [getPrivateKey](wallet.md#getprivatekey) -* [getPrivateKeyString](wallet.md#getprivatekeystring) -* [getPublicKey](wallet.md#getpublickey) -* [getPublicKeyString](wallet.md#getpublickeystring) -* [getV3Filename](wallet.md#getv3filename) -* [toV3](wallet.md#tov3) -* [toV3String](wallet.md#tov3string) -* [fromEthSale](wallet.md#fromethsale) -* [fromExtendedPrivateKey](wallet.md#fromextendedprivatekey) -* [fromExtendedPublicKey](wallet.md#fromextendedpublickey) -* [fromPrivateKey](wallet.md#fromprivatekey) -* [fromPublicKey](wallet.md#frompublickey) -* [fromV1](wallet.md#fromv1) -* [fromV3](wallet.md#fromv3) -* [generate](wallet.md#generate) -* [generateVanityAddress](wallet.md#generatevanityaddress) +- [getAddress](wallet.md#getaddress) +- [getAddressString](wallet.md#getaddressstring) +- [getChecksumAddressString](wallet.md#getchecksumaddressstring) +- [getPrivateKey](wallet.md#getprivatekey) +- [getPrivateKeyString](wallet.md#getprivatekeystring) +- [getPublicKey](wallet.md#getpublickey) +- [getPublicKeyString](wallet.md#getpublickeystring) +- [getV3Filename](wallet.md#getv3filename) +- [toV3](wallet.md#tov3) +- [toV3String](wallet.md#tov3string) +- [fromEthSale](wallet.md#fromethsale) +- [fromExtendedPrivateKey](wallet.md#fromextendedprivatekey) +- [fromExtendedPublicKey](wallet.md#fromextendedpublickey) +- [fromPrivateKey](wallet.md#fromprivatekey) +- [fromPublicKey](wallet.md#frompublickey) +- [fromV1](wallet.md#fromv1) +- [fromV3](wallet.md#fromv3) +- [generate](wallet.md#generate) +- [generateVanityAddress](wallet.md#generatevanityaddress) --- @@ -50,43 +50,44 @@ -### constructor +### constructor -⊕ **new Wallet**(privateKey?: *`Buffer` \| `undefined`*, publicKey?: *`Buffer` \| `undefined`*): [Wallet](wallet.md) +⊕ **new Wallet**(privateKey?: _`Buffer` \| `undefined`_, publicKey?: _`Buffer` \| `undefined`_): [Wallet](wallet.md) -*Defined in [index.ts:230](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L230)* +_Defined in [index.ts:230](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L230)_ **Parameters:** -| Name | Type | Default value | -| ------ | ------ | ------ | -| `Optional` privateKey | `Buffer` \| `undefined` | - | -| `Default value` publicKey | `Buffer` \| `undefined` | undefined | +| Name | Type | Default value | +| ------------------------- | ----------------------- | ------------- | +| `Optional` privateKey | `Buffer` \| `undefined` | - | +| `Default value` publicKey | `Buffer` \| `undefined` | undefined | **Returns:** [Wallet](wallet.md) -___ +--- ## Properties -### ```` privateKey +### ` `` ` privateKey + +**● privateKey**: _`Buffer` \| `undefined`_ -**● privateKey**: *`Buffer` \| `undefined`* +_Defined in [index.ts:232](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L232)_ -*Defined in [index.ts:232](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L232)* +--- -___ ### `` publicKey -**● publicKey**: *`Buffer` \| `undefined`* +**● publicKey**: _`Buffer` \| `undefined`_ -*Defined in [index.ts:233](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L233)* +_Defined in [index.ts:233](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L233)_ -___ +--- ## Accessors @@ -96,257 +97,272 @@ ___ **get privKey**(): `Buffer` -*Defined in [index.ts:481](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L481)* +_Defined in [index.ts:481](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L481)_ Returns the wallet's private key. **Returns:** `Buffer` -___ +--- + ### `` pubKey **get pubKey**(): `Buffer` -*Defined in [index.ts:471](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L471)* +_Defined in [index.ts:471](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L471)_ Returns the wallet's public key. **Returns:** `Buffer` -___ +--- ## Methods -### getAddress +### getAddress ▸ **getAddress**(): `Buffer` -*Defined in [index.ts:521](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L521)* +_Defined in [index.ts:521](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L521)_ Returns the wallet's address. **Returns:** `Buffer` -___ +--- + -### getAddressString +### getAddressString ▸ **getAddressString**(): `string` -*Defined in [index.ts:528](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L528)* +_Defined in [index.ts:528](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L528)_ Returns the wallet's address as a "0x" prefixed hex string **Returns:** `string` -___ +--- + -### getChecksumAddressString +### getChecksumAddressString ▸ **getChecksumAddressString**(): `string` -*Defined in [index.ts:536](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L536)* +_Defined in [index.ts:536](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L536)_ Returns the wallet's private key as a "0x" prefixed hex string checksummed according to [EIP 55](https://github.com/ethereum/EIPs/issues/55). **Returns:** `string` -___ +--- + -### getPrivateKey +### getPrivateKey ▸ **getPrivateKey**(): `Buffer` -*Defined in [index.ts:495](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L495)* +_Defined in [index.ts:495](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L495)_ Returns the wallet's private key. **Returns:** `Buffer` -___ +--- + -### getPrivateKeyString +### getPrivateKeyString ▸ **getPrivateKeyString**(): `string` -*Defined in [index.ts:499](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L499)* +_Defined in [index.ts:499](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L499)_ **Returns:** `string` -___ +--- + -### getPublicKey +### getPublicKey ▸ **getPublicKey**(): `Buffer` -*Defined in [index.ts:507](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L507)* +_Defined in [index.ts:507](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L507)_ Returns the wallet's public key. **Returns:** `Buffer` -___ +--- + -### getPublicKeyString +### getPublicKeyString ▸ **getPublicKeyString**(): `string` -*Defined in [index.ts:514](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L514)* +_Defined in [index.ts:514](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L514)_ Returns the wallet's public key as a "0x" prefixed hex string **Returns:** `string` -___ +--- + -### getV3Filename +### getV3Filename -▸ **getV3Filename**(timestamp?: *`undefined` \| `number`*): `string` +▸ **getV3Filename**(timestamp?: _`undefined` \| `number`_): `string` -*Defined in [index.ts:618](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L618)* +_Defined in [index.ts:618](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L618)_ Return the suggested filename for V3 keystores. **Parameters:** -| Name | Type | -| ------ | ------ | +| Name | Type | +| -------------------- | ----------------------- | | `Optional` timestamp | `undefined` \| `number` | **Returns:** `string` -___ +--- + -### toV3 +### toV3 -▸ **toV3**(password: *`string`*, opts?: *`Partial`<`V3Params`>*): `V3Keystore` +▸ **toV3**(password: _`string`_, opts?: _`Partial`<`V3Params`>_): `V3Keystore` -*Defined in [index.ts:546](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L546)* +_Defined in [index.ts:546](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L546)_ Returns an Etherem Version 3 Keystore Format object representing the wallet **Parameters:** -| Name | Type | Description | -| ------ | ------ | ------ | -| password | `string` | The password used to encrypt the Keystore. | -| `Optional` opts | `Partial`<`V3Params`> | The options for the keystore. See [its spec](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition) for more info. | +| Name | Type | Description | +| --------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------- | +| password | `string` | The password used to encrypt the Keystore. | +| `Optional` opts | `Partial`<`V3Params`> | The options for the keystore. See [its spec](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition) for more info. | **Returns:** `V3Keystore` -___ +--- + -### toV3String +### toV3String -▸ **toV3String**(password: *`string`*, opts?: *`Partial`<`V3Params`>*): `string` +▸ **toV3String**(password: _`string`_, opts?: _`Partial`<`V3Params`>_): `string` -*Defined in [index.ts:636](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L636)* +_Defined in [index.ts:636](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L636)_ **Parameters:** -| Name | Type | -| ------ | ------ | -| password | `string` | +| Name | Type | +| --------------- | --------------------- | +| password | `string` | | `Optional` opts | `Partial`<`V3Params`> | **Returns:** `string` -___ +--- + ### `` fromEthSale -▸ **fromEthSale**(input: *`string` \| `EthSaleKeystore`*, password: *`string`*): [Wallet](wallet.md) +▸ **fromEthSale**(input: _`string` \| `EthSaleKeystore`_, password: _`string`_): [Wallet](wallet.md) -*Defined in [index.ts:445](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L445)* +_Defined in [index.ts:445](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L445)_ **Parameters:** -| Name | Type | -| ------ | ------ | -| input | `string` \| `EthSaleKeystore` | -| password | `string` | +| Name | Type | +| -------- | ----------------------------- | +| input | `string` \| `EthSaleKeystore` | +| password | `string` | **Returns:** [Wallet](wallet.md) -___ +--- + ### `` fromExtendedPrivateKey -▸ **fromExtendedPrivateKey**(extendedPrivateKey: *`string`*): [Wallet](wallet.md) +▸ **fromExtendedPrivateKey**(extendedPrivateKey: _`string`_): [Wallet](wallet.md) -*Defined in [index.ts:322](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L322)* +_Defined in [index.ts:322](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L322)_ Create an instance based on a BIP32 extended private key (xprv) **Parameters:** -| Name | Type | -| ------ | ------ | +| Name | Type | +| ------------------ | -------- | | extendedPrivateKey | `string` | **Returns:** [Wallet](wallet.md) -___ +--- + ### `` fromExtendedPublicKey -▸ **fromExtendedPublicKey**(extendedPublicKey: *`string`*): [Wallet](wallet.md) +▸ **fromExtendedPublicKey**(extendedPublicKey: _`string`_): [Wallet](wallet.md) -*Defined in [index.ts:303](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L303)* +_Defined in [index.ts:303](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L303)_ Create an instance based on a BIP32 extended public key (xpub) **Parameters:** -| Name | Type | -| ------ | ------ | +| Name | Type | +| ----------------- | -------- | | extendedPublicKey | `string` | **Returns:** [Wallet](wallet.md) -___ +--- + ### `` fromPrivateKey -▸ **fromPrivateKey**(privateKey: *`Buffer`*): [Wallet](wallet.md) +▸ **fromPrivateKey**(privateKey: _`Buffer`_): [Wallet](wallet.md) -*Defined in [index.ts:315](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L315)* +_Defined in [index.ts:315](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L315)_ Create an instance based on a raw private key **Parameters:** -| Name | Type | -| ------ | ------ | +| Name | Type | +| ---------- | -------- | | privateKey | `Buffer` | **Returns:** [Wallet](wallet.md) -___ +--- + ### `` fromPublicKey -▸ **fromPublicKey**(publicKey: *`Buffer`*, nonStrict?: *`boolean`*): [Wallet](wallet.md) +▸ **fromPublicKey**(publicKey: _`Buffer`_, nonStrict?: _`boolean`_): [Wallet](wallet.md) -*Defined in [index.ts:293](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L293)* +_Defined in [index.ts:293](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L293)_ Create an instance based on a public key (certain methods will not be available) @@ -354,91 +370,94 @@ This method only accepts uncompressed Ethereum-style public keys, unless the `no **Parameters:** -| Name | Type | Default value | -| ------ | ------ | ------ | -| publicKey | `Buffer` | - | -| `Default value` nonStrict | `boolean` | false | +| Name | Type | Default value | +| ------------------------- | --------- | ------------- | +| publicKey | `Buffer` | - | +| `Default value` nonStrict | `boolean` | false | **Returns:** [Wallet](wallet.md) -___ +--- + ### `` fromV1 -▸ **fromV1**(input: *`string` \| `V1Keystore`*, password: *`string`*): [Wallet](wallet.md) +▸ **fromV1**(input: _`string` \| `V1Keystore`_, password: _`string`_): [Wallet](wallet.md) -*Defined in [index.ts:339](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L339)* +_Defined in [index.ts:339](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L339)_ Import a wallet (Version 1 of the Ethereum wallet format). **Parameters:** -| Name | Type | Description | -| ------ | ------ | ------ | -| input | `string` \| `V1Keystore` | A JSON serialized string, or an object representing V1 Keystore. | -| password | `string` | The keystore password. | +| Name | Type | Description | +| -------- | ------------------------ | ---------------------------------------------------------------- | +| input | `string` \| `V1Keystore` | A JSON serialized string, or an object representing V1 Keystore. | +| password | `string` | The keystore password. | **Returns:** [Wallet](wallet.md) -___ +--- + ### `` fromV3 -▸ **fromV3**(input: *`string` \| `V3Keystore`*, password: *`string`*, nonStrict?: *`boolean`*): [Wallet](wallet.md) +▸ **fromV3**(input: _`string` \| `V3Keystore`_, password: _`string`_, nonStrict?: _`boolean`_): [Wallet](wallet.md) -*Defined in [index.ts:379](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L379)* +_Defined in [index.ts:379](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L379)_ Import a wallet (Version 3 of the Ethereum wallet format). Set `nonStrict` true to accept files with mixed-caps. **Parameters:** -| Name | Type | Default value | Description | -| ------ | ------ | ------ | ------ | -| input | `string` \| `V3Keystore` | - | A JSON serialized string, or an object representing V3 Keystore. | -| password | `string` | - | The keystore password. | -| `Default value` nonStrict | `boolean` | false | +| Name | Type | Default value | Description | +| ------------------------- | ------------------------ | ------------- | ---------------------------------------------------------------- | +| input | `string` \| `V3Keystore` | - | A JSON serialized string, or an object representing V3 Keystore. | +| password | `string` | - | The keystore password. | +| `Default value` nonStrict | `boolean` | false | **Returns:** [Wallet](wallet.md) -___ +--- + ### `` generate -▸ **generate**(icapDirect?: *`boolean`*): [Wallet](wallet.md) +▸ **generate**(icapDirect?: _`boolean`_): [Wallet](wallet.md) -*Defined in [index.ts:255](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L255)* +_Defined in [index.ts:255](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L255)_ Create an instance based on a new random key. **Parameters:** -| Name | Type | Default value | Description | -| ------ | ------ | ------ | ------ | -| `Default value` icapDirect | `boolean` | false | setting this to \`true\` will generate an address suitable for the \`ICAP Direct mode\` | +| Name | Type | Default value | Description | +| -------------------------- | --------- | ------------- | --------------------------------------------------------------------------------------- | +| `Default value` icapDirect | `boolean` | false | setting this to \`true\` will generate an address suitable for the \`ICAP Direct mode\` | **Returns:** [Wallet](wallet.md) -___ +--- + ### `` generateVanityAddress -▸ **generateVanityAddress**(pattern: *`RegExp` \| `string`*): [Wallet](wallet.md) +▸ **generateVanityAddress**(pattern: _`RegExp` \| `string`_): [Wallet](wallet.md) -*Defined in [index.ts:272](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L272)* +_Defined in [index.ts:272](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L272)_ Create an instance where the address is valid against the supplied pattern (**this will be very slow**) **Parameters:** -| Name | Type | -| ------ | ------ | +| Name | Type | +| ------- | -------------------- | | pattern | `RegExp` \| `string` | **Returns:** [Wallet](wallet.md) -___ - +--- diff --git a/docs/classes/walletsubprovider.md b/docs/classes/walletsubprovider.md index 63861dc..9f84c11 100644 --- a/docs/classes/walletsubprovider.md +++ b/docs/classes/walletsubprovider.md @@ -4,7 +4,7 @@ ## Hierarchy - `any` +`any` **↳ WalletSubprovider** @@ -12,7 +12,7 @@ ### Constructors -* [constructor](walletsubprovider.md#constructor) +- [constructor](walletsubprovider.md#constructor) --- @@ -20,20 +20,19 @@ -### constructor +### constructor -⊕ **new WalletSubprovider**(wallet: *[Wallet](wallet.md)*, opts?: *`any`*): [WalletSubprovider](walletsubprovider.md) +⊕ **new WalletSubprovider**(wallet: _[Wallet](wallet.md)_, opts?: _`any`_): [WalletSubprovider](walletsubprovider.md) -*Defined in [provider-engine.ts:5](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/provider-engine.ts#L5)* +_Defined in [provider-engine.ts:5](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/provider-engine.ts#L5)_ **Parameters:** -| Name | Type | -| ------ | ------ | -| wallet | [Wallet](wallet.md) | -| `Optional` opts | `any` | +| Name | Type | +| --------------- | ------------------- | +| wallet | [Wallet](wallet.md) | +| `Optional` opts | `any` | **Returns:** [WalletSubprovider](walletsubprovider.md) -___ - +--- diff --git a/docs/interfaces/etherwalletoptions.md b/docs/interfaces/etherwalletoptions.md index 8074598..d73666d 100644 --- a/docs/interfaces/etherwalletoptions.md +++ b/docs/interfaces/etherwalletoptions.md @@ -10,12 +10,12 @@ ### Properties -* [address](etherwalletoptions.md#address) -* [encrypted](etherwalletoptions.md#encrypted) -* [hash](etherwalletoptions.md#hash) -* [locked](etherwalletoptions.md#locked) -* [private](etherwalletoptions.md#private) -* [public](etherwalletoptions.md#public) +- [address](etherwalletoptions.md#address) +- [encrypted](etherwalletoptions.md#encrypted) +- [hash](etherwalletoptions.md#hash) +- [locked](etherwalletoptions.md#locked) +- [private](etherwalletoptions.md#private) +- [public](etherwalletoptions.md#public) --- @@ -23,56 +23,60 @@ -### address +### address -**● address**: *`string`* +**● address**: _`string`_ -*Defined in [thirdparty.ts:108](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L108)* +_Defined in [thirdparty.ts:108](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L108)_ + +--- -___ -### encrypted +### encrypted + +**● encrypted**: _`boolean`_ -**● encrypted**: *`boolean`* +_Defined in [thirdparty.ts:109](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L109)_ -*Defined in [thirdparty.ts:109](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L109)* +--- -___ -### hash +### hash + +**● hash**: _`string`_ -**● hash**: *`string`* +_Defined in [thirdparty.ts:111](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L111)_ -*Defined in [thirdparty.ts:111](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L111)* +--- -___ -### locked +### locked -**● locked**: *`boolean`* +**● locked**: _`boolean`_ -*Defined in [thirdparty.ts:110](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L110)* +_Defined in [thirdparty.ts:110](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L110)_ + +--- -___ -### private +### private -**● private**: *`string`* +**● private**: _`string`_ -*Defined in [thirdparty.ts:112](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L112)* +_Defined in [thirdparty.ts:112](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L112)_ -___ - +--- -### public + -**● public**: *`string`* +### public -*Defined in [thirdparty.ts:113](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L113)* +**● public**: _`string`_ -___ +_Defined in [thirdparty.ts:113](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L113)_ +--- diff --git a/docs/interfaces/evpkdfopts.md b/docs/interfaces/evpkdfopts.md index 5393119..c66aa76 100644 --- a/docs/interfaces/evpkdfopts.md +++ b/docs/interfaces/evpkdfopts.md @@ -10,10 +10,10 @@ ### Properties -* [count](evpkdfopts.md#count) -* [digest](evpkdfopts.md#digest) -* [ivsize](evpkdfopts.md#ivsize) -* [keysize](evpkdfopts.md#keysize) +- [count](evpkdfopts.md#count) +- [digest](evpkdfopts.md#digest) +- [ivsize](evpkdfopts.md#ivsize) +- [keysize](evpkdfopts.md#keysize) --- @@ -21,38 +21,40 @@ -### count +### count -**● count**: *`number`* +**● count**: _`number`_ -*Defined in [thirdparty.ts:17](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L17)* +_Defined in [thirdparty.ts:17](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L17)_ + +--- -___ -### digest +### digest -**● digest**: *`string`* +**● digest**: _`string`_ -*Defined in [thirdparty.ts:20](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L20)* +_Defined in [thirdparty.ts:20](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L20)_ + +--- -___ -### ivsize +### ivsize -**● ivsize**: *`number`* +**● ivsize**: _`number`_ -*Defined in [thirdparty.ts:19](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L19)* +_Defined in [thirdparty.ts:19](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L19)_ -___ - +--- -### keysize + -**● keysize**: *`number`* +### keysize -*Defined in [thirdparty.ts:18](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L18)* +**● keysize**: _`number`_ -___ +_Defined in [thirdparty.ts:18](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L18)_ +--- diff --git a/src/hdkey.ts b/src/hdkey.ts index 1070821..6c6f5d4 100644 --- a/src/hdkey.ts +++ b/src/hdkey.ts @@ -5,7 +5,7 @@ const HDKey = require('hdkey') export default class EthereumHDKey { /** * Creates an instance based on a seed. - * + * * For the seed we suggest to use [bip39](https://npmjs.org/package/bip39) to * create one from a BIP39 mnemonic. */ diff --git a/src/index.ts b/src/index.ts index 5ae1f48..7bc14b1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -332,7 +332,7 @@ export default class Wallet { /** * Import a wallet (Version 1 of the Ethereum wallet format). - * + * * @param input A JSON serialized string, or an object representing V1 Keystore. * @param password The keystore password. */ @@ -372,7 +372,7 @@ export default class Wallet { /** * Import a wallet (Version 3 of the Ethereum wallet format). Set `nonStrict` true to accept files with mixed-caps. - * + * * @param input A JSON serialized string, or an object representing V3 Keystore. * @param password The keystore password. */ @@ -438,7 +438,7 @@ export default class Wallet { * Import an Ethereum Pre Sale wallet. * Based on https://github.com/ethereum/pyethsaletool/blob/master/pyethsaletool.py * JSON fields: encseed, ethaddr, btcaddr, email - * + * * @param input A JSON serialized string, or an object representing EthSale Keystore. * @param password The keystore password. */ @@ -489,7 +489,7 @@ export default class Wallet { /** * Returns the wallet's private key. - * + * */ // tslint:disable-next-line public getPrivateKey(): Buffer { @@ -539,7 +539,7 @@ export default class Wallet { /** * Returns an Etherem Version 3 Keystore Format object representing the wallet - * + * * @param password The password used to encrypt the Keystore. * @param opts The options for the keystore. See [its spec](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition) for more info. */ diff --git a/test/index.ts b/test/index.ts index 3c8c724..ab0cf4a 100644 --- a/test/index.ts +++ b/test/index.ts @@ -297,14 +297,12 @@ describe('.toV3()', function() { p: p, }) - const encFixtureEthersWallet = ( - await fixtureEthersWallet.encrypt(pw, { - scrypt: { N: n, r: r, p: p }, - salt: ethersOpts.salt, - iv: ethersOpts.iv, - uuid: ethersOpts.uuid, - }) - ).toLowerCase() + const encFixtureEthersWallet = (await fixtureEthersWallet.encrypt(pw, { + scrypt: { N: n, r: r, p: p }, + salt: ethersOpts.salt, + iv: ethersOpts.iv, + uuid: ethersOpts.uuid, + })).toLowerCase() const encRandomWallet = wRandom.toV3String(pw, { kdf: 'scrypt', @@ -316,14 +314,12 @@ describe('.toV3()', function() { p: p, }) - const encEthersWallet = ( - await wEthers.encrypt(pw, { - scrypt: { N: n, r: r, p: p }, - salt: ethersOpts.salt, - iv: ethersOpts.iv, - uuid: ethersOpts.uuid, - }) - ).toLowerCase() + const encEthersWallet = (await wEthers.encrypt(pw, { + scrypt: { N: n, r: r, p: p }, + salt: ethersOpts.salt, + iv: ethersOpts.iv, + uuid: ethersOpts.uuid, + })).toLowerCase() assert.deepStrictEqual(JSON.parse(wStatic), JSON.parse(encFixtureWallet)) assert.deepStrictEqual(JSON.parse(wStatic), JSON.parse(encFixtureEthersWallet)) From 3ef9980dce72adfda53101d0d53f8c30ca69f9c3 Mon Sep 17 00:00:00 2001 From: holgerd77 Date: Wed, 22 Apr 2020 15:18:11 +0200 Subject: [PATCH 07/13] Normalized lint and tslint fix commands in package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1cc90ea..5aa5f23 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,9 @@ "coverage": "ethereumjs-config-coverage", "coveralls": "ethereumjs-config-coveralls", "format": "ethereumjs-config-format", - "format-fix": "ethereumjs-config-format-fix", + "format:fix": "ethereumjs-config-format-fix", "lint": "ethereumjs-config-lint", - "lint-fix": "ethereumjs-config-lint-fix", + "lint:fix": "ethereumjs-config-lint-fix", "pretest": "npm run build", "test": "nyc mocha ./test/**/*.ts", "tsc": "ethereumjs-config-tsc", From c748f9795ef5fd2811979117702d0e5427ebcaf2 Mon Sep 17 00:00:00 2001 From: holgerd77 Date: Wed, 22 Apr 2020 15:18:49 +0200 Subject: [PATCH 08/13] Fixed linting errors --- test/index.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/test/index.ts b/test/index.ts index ab0cf4a..3c8c724 100644 --- a/test/index.ts +++ b/test/index.ts @@ -297,12 +297,14 @@ describe('.toV3()', function() { p: p, }) - const encFixtureEthersWallet = (await fixtureEthersWallet.encrypt(pw, { - scrypt: { N: n, r: r, p: p }, - salt: ethersOpts.salt, - iv: ethersOpts.iv, - uuid: ethersOpts.uuid, - })).toLowerCase() + const encFixtureEthersWallet = ( + await fixtureEthersWallet.encrypt(pw, { + scrypt: { N: n, r: r, p: p }, + salt: ethersOpts.salt, + iv: ethersOpts.iv, + uuid: ethersOpts.uuid, + }) + ).toLowerCase() const encRandomWallet = wRandom.toV3String(pw, { kdf: 'scrypt', @@ -314,12 +316,14 @@ describe('.toV3()', function() { p: p, }) - const encEthersWallet = (await wEthers.encrypt(pw, { - scrypt: { N: n, r: r, p: p }, - salt: ethersOpts.salt, - iv: ethersOpts.iv, - uuid: ethersOpts.uuid, - })).toLowerCase() + const encEthersWallet = ( + await wEthers.encrypt(pw, { + scrypt: { N: n, r: r, p: p }, + salt: ethersOpts.salt, + iv: ethersOpts.iv, + uuid: ethersOpts.uuid, + }) + ).toLowerCase() assert.deepStrictEqual(JSON.parse(wStatic), JSON.parse(encFixtureWallet)) assert.deepStrictEqual(JSON.parse(wStatic), JSON.parse(encFixtureEthersWallet)) From 490d35c244589dc6f63273cb05dd9f602beb8432 Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Fri, 24 Apr 2020 10:05:20 -0300 Subject: [PATCH 09/13] Fix broken merge --- README.md | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/README.md b/README.md index b89c98e..853bff1 100644 --- a/README.md +++ b/README.md @@ -34,15 +34,8 @@ For information about the Wallet's API, please go to [./docs/classes/wallet.md]( Importing various third party wallets is possible through the `thirdparty` submodule: -<<<<<<< HEAD -`const { thirdparty } = require('ethereumjs-wallet')` -||||||| ac90675 -`var thirdparty = require('ethereumjs-wallet/thirdparty')` -======= Node.js / ES5: -> > > > > > > typedoc - ```js const thirdparty = require('ethereumjs-wallet/thirdparty').default ``` @@ -59,15 +52,8 @@ Please go to [./docs/README.md](./docs/README.md) for more info. To use BIP32 HD wallets, first include the `hdkey` submodule: -<<<<<<< HEAD -`const { hdkey } = require('ethereumjs-wallet')` -||||||| ac90675 -`var hdkey = require('ethereumjs-wallet/hdkey')` -======= Node.js / ES5: -> > > > > > > typedoc - ```js const hdkey = require('ethereumjs-wallet/hdkey').default ``` @@ -95,13 +81,7 @@ const WalletSubprovider = require('ethereumjs-wallet/provider-engine').default ESM / TypeScript: ```js -<<<<<<< HEAD -const { WalletSubprovider } = require('ethereumjs-wallet') -||||||| ac90675 -const WalletSubprovider = require('ethereumjs-wallet/provider-engine') -======= import WalletSubprovider from 'ethereumjs-wallet/provider-engine' ->>>>>>> typedoc .addProvider(new WalletSubprovider()) ``` From e9154c50a54e06e1f856db5bc44a15d44e525d61 Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Fri, 24 Apr 2020 10:05:31 -0300 Subject: [PATCH 10/13] Regenerate docs and autofix style --- docs/README.md | 8 ++--- docs/classes/ethereumhdkey.md | 18 +++++----- docs/classes/wallet.md | 48 +++++++++++++-------------- docs/classes/walletsubprovider.md | 2 +- docs/interfaces/etherwalletoptions.md | 12 +++---- docs/interfaces/evpkdfopts.md | 8 ++--- test/index.ts | 28 +++++++--------- 7 files changed, 60 insertions(+), 64 deletions(-) diff --git a/docs/README.md b/docs/README.md index 4d3f605..d23f44c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -30,7 +30,7 @@ ▸ **fromEtherCamp**(passphrase: _`string`_): [Wallet](classes/wallet.md) -_Defined in [thirdparty.ts:169](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L169)_ +_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 @@ -50,7 +50,7 @@ Third Party API: Import a brain wallet used by Ether.Camp ▸ **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/15de3c4/src/thirdparty.ts#L121)_ +_Defined in [thirdparty.ts:121](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L121)_ **Parameters:** @@ -69,7 +69,7 @@ _Defined in [thirdparty.ts:121](https://github.com/ethereumjs/ethereumjs-wallet/ ▸ **fromKryptoKit**(entropy: _`string`_, password: _`string`_): [Wallet](classes/wallet.md) -_Defined in [thirdparty.ts:176](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L176)_ +_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 @@ -90,7 +90,7 @@ Third Party API: Import a wallet from a KryptoKit seed ▸ **fromQuorumWallet**(passphrase: _`string`_, userid: _`string`_): [Wallet](classes/wallet.md) -_Defined in [thirdparty.ts:265](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L265)_ +_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 diff --git a/docs/classes/ethereumhdkey.md b/docs/classes/ethereumhdkey.md index 06db7b6..ded79f9 100644 --- a/docs/classes/ethereumhdkey.md +++ b/docs/classes/ethereumhdkey.md @@ -36,7 +36,7 @@ ⊕ **new EthereumHDKey**(\_hdkey?: _`any`_): [EthereumHDKey](ethereumhdkey.md) -_Defined in [hdkey.ts:21](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L21)_ +_Defined in [hdkey.ts:21](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/hdkey.ts#L21)_ **Parameters:** @@ -56,7 +56,7 @@ _Defined in [hdkey.ts:21](https://github.com/ethereumjs/ethereumjs-wallet/blob/1 **● \_hdkey**: _`any`_ -_Defined in [hdkey.ts:23](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L23)_ +_Defined in [hdkey.ts:23](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/hdkey.ts#L23)_ --- @@ -68,7 +68,7 @@ _Defined in [hdkey.ts:23](https://github.com/ethereumjs/ethereumjs-wallet/blob/1 ▸ **deriveChild**(index: _`number`_): [EthereumHDKey](ethereumhdkey.md) -_Defined in [hdkey.ts:52](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L52)_ +_Defined in [hdkey.ts:52](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/hdkey.ts#L52)_ Derive a node based on a child index @@ -88,7 +88,7 @@ Derive a node based on a child index ▸ **derivePath**(path: _`string`_): [EthereumHDKey](ethereumhdkey.md) -_Defined in [hdkey.ts:45](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L45)_ +_Defined in [hdkey.ts:45](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/hdkey.ts#L45)_ Derives a node based on a path (e.g. m/44'/0'/0/1) @@ -108,7 +108,7 @@ Derives a node based on a path (e.g. m/44'/0'/0/1) ▸ **getWallet**(): [Wallet](wallet.md) -_Defined in [hdkey.ts:59](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L59)_ +_Defined in [hdkey.ts:59](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/hdkey.ts#L59)_ Return a `Wallet` instance as seen above @@ -122,7 +122,7 @@ Return a `Wallet` instance as seen above ▸ **privateExtendedKey**(): `Buffer` -_Defined in [hdkey.ts:28](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L28)_ +_Defined in [hdkey.ts:28](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/hdkey.ts#L28)_ Returns a BIP32 extended private key (xprv) @@ -136,7 +136,7 @@ Returns a BIP32 extended private key (xprv) ▸ **publicExtendedKey**(): `Buffer` -_Defined in [hdkey.ts:38](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L38)_ +_Defined in [hdkey.ts:38](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/hdkey.ts#L38)_ Return a BIP32 extended public key (xpub) @@ -150,7 +150,7 @@ Return a BIP32 extended public key (xpub) ▸ **fromExtendedKey**(base58Key: _`string`_): [EthereumHDKey](ethereumhdkey.md) -_Defined in [hdkey.ts:19](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L19)_ +_Defined in [hdkey.ts:19](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/hdkey.ts#L19)_ Create an instance based on a BIP32 extended private or public key. @@ -170,7 +170,7 @@ Create an instance based on a BIP32 extended private or public key. ▸ **fromMasterSeed**(seedBuffer: _`Buffer`_): [EthereumHDKey](ethereumhdkey.md) -_Defined in [hdkey.ts:12](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/hdkey.ts#L12)_ +_Defined in [hdkey.ts:12](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/hdkey.ts#L12)_ Creates an instance based on a seed. diff --git a/docs/classes/wallet.md b/docs/classes/wallet.md index 4b6d2f1..381df17 100644 --- a/docs/classes/wallet.md +++ b/docs/classes/wallet.md @@ -54,7 +54,7 @@ ⊕ **new Wallet**(privateKey?: _`Buffer` \| `undefined`_, publicKey?: _`Buffer` \| `undefined`_): [Wallet](wallet.md) -_Defined in [index.ts:230](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L230)_ +_Defined in [index.ts:230](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L230)_ **Parameters:** @@ -75,7 +75,7 @@ _Defined in [index.ts:230](https://github.com/ethereumjs/ethereumjs-wallet/blob/ **● privateKey**: _`Buffer` \| `undefined`_ -_Defined in [index.ts:232](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L232)_ +_Defined in [index.ts:232](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L232)_ --- @@ -85,7 +85,7 @@ _Defined in [index.ts:232](https://github.com/ethereumjs/ethereumjs-wallet/blob/ **● publicKey**: _`Buffer` \| `undefined`_ -_Defined in [index.ts:233](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L233)_ +_Defined in [index.ts:233](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L233)_ --- @@ -97,7 +97,7 @@ _Defined in [index.ts:233](https://github.com/ethereumjs/ethereumjs-wallet/blob/ **get privKey**(): `Buffer` -_Defined in [index.ts:481](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L481)_ +_Defined in [index.ts:481](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L481)_ Returns the wallet's private key. @@ -111,7 +111,7 @@ Returns the wallet's private key. **get pubKey**(): `Buffer` -_Defined in [index.ts:471](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L471)_ +_Defined in [index.ts:471](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L471)_ Returns the wallet's public key. @@ -127,7 +127,7 @@ Returns the wallet's public key. ▸ **getAddress**(): `Buffer` -_Defined in [index.ts:521](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L521)_ +_Defined in [index.ts:521](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L521)_ Returns the wallet's address. @@ -141,7 +141,7 @@ Returns the wallet's address. ▸ **getAddressString**(): `string` -_Defined in [index.ts:528](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L528)_ +_Defined in [index.ts:528](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L528)_ Returns the wallet's address as a "0x" prefixed hex string @@ -155,7 +155,7 @@ Returns the wallet's address as a "0x" prefixed hex string ▸ **getChecksumAddressString**(): `string` -_Defined in [index.ts:536](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L536)_ +_Defined in [index.ts:536](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L536)_ Returns the wallet's private key as a "0x" prefixed hex string checksummed according to [EIP 55](https://github.com/ethereum/EIPs/issues/55). @@ -169,7 +169,7 @@ Returns the wallet's private key as a "0x" prefixed hex string checksummed accor ▸ **getPrivateKey**(): `Buffer` -_Defined in [index.ts:495](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L495)_ +_Defined in [index.ts:495](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L495)_ Returns the wallet's private key. @@ -183,7 +183,7 @@ Returns the wallet's private key. ▸ **getPrivateKeyString**(): `string` -_Defined in [index.ts:499](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L499)_ +_Defined in [index.ts:499](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L499)_ **Returns:** `string` @@ -195,7 +195,7 @@ _Defined in [index.ts:499](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **getPublicKey**(): `Buffer` -_Defined in [index.ts:507](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L507)_ +_Defined in [index.ts:507](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L507)_ Returns the wallet's public key. @@ -209,7 +209,7 @@ Returns the wallet's public key. ▸ **getPublicKeyString**(): `string` -_Defined in [index.ts:514](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L514)_ +_Defined in [index.ts:514](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L514)_ Returns the wallet's public key as a "0x" prefixed hex string @@ -223,7 +223,7 @@ Returns the wallet's public key as a "0x" prefixed hex string ▸ **getV3Filename**(timestamp?: _`undefined` \| `number`_): `string` -_Defined in [index.ts:618](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L618)_ +_Defined in [index.ts:618](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L618)_ Return the suggested filename for V3 keystores. @@ -243,7 +243,7 @@ Return the suggested filename for V3 keystores. ▸ **toV3**(password: _`string`_, opts?: _`Partial`<`V3Params`>_): `V3Keystore` -_Defined in [index.ts:546](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L546)_ +_Defined in [index.ts:546](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L546)_ Returns an Etherem Version 3 Keystore Format object representing the wallet @@ -264,7 +264,7 @@ Returns an Etherem Version 3 Keystore Format object representing the wallet ▸ **toV3String**(password: _`string`_, opts?: _`Partial`<`V3Params`>_): `string` -_Defined in [index.ts:636](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L636)_ +_Defined in [index.ts:636](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L636)_ **Parameters:** @@ -283,7 +283,7 @@ _Defined in [index.ts:636](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **fromEthSale**(input: _`string` \| `EthSaleKeystore`_, password: _`string`_): [Wallet](wallet.md) -_Defined in [index.ts:445](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L445)_ +_Defined in [index.ts:445](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L445)_ **Parameters:** @@ -302,7 +302,7 @@ _Defined in [index.ts:445](https://github.com/ethereumjs/ethereumjs-wallet/blob/ ▸ **fromExtendedPrivateKey**(extendedPrivateKey: _`string`_): [Wallet](wallet.md) -_Defined in [index.ts:322](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L322)_ +_Defined in [index.ts:322](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L322)_ Create an instance based on a BIP32 extended private key (xprv) @@ -322,7 +322,7 @@ Create an instance based on a BIP32 extended private key (xprv) ▸ **fromExtendedPublicKey**(extendedPublicKey: _`string`_): [Wallet](wallet.md) -_Defined in [index.ts:303](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L303)_ +_Defined in [index.ts:303](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L303)_ Create an instance based on a BIP32 extended public key (xpub) @@ -342,7 +342,7 @@ Create an instance based on a BIP32 extended public key (xpub) ▸ **fromPrivateKey**(privateKey: _`Buffer`_): [Wallet](wallet.md) -_Defined in [index.ts:315](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L315)_ +_Defined in [index.ts:315](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L315)_ Create an instance based on a raw private key @@ -362,7 +362,7 @@ Create an instance based on a raw private key ▸ **fromPublicKey**(publicKey: _`Buffer`_, nonStrict?: _`boolean`_): [Wallet](wallet.md) -_Defined in [index.ts:293](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L293)_ +_Defined in [index.ts:293](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L293)_ Create an instance based on a public key (certain methods will not be available) @@ -385,7 +385,7 @@ This method only accepts uncompressed Ethereum-style public keys, unless the `no ▸ **fromV1**(input: _`string` \| `V1Keystore`_, password: _`string`_): [Wallet](wallet.md) -_Defined in [index.ts:339](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L339)_ +_Defined in [index.ts:339](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L339)_ Import a wallet (Version 1 of the Ethereum wallet format). @@ -406,7 +406,7 @@ Import a wallet (Version 1 of the Ethereum wallet format). ▸ **fromV3**(input: _`string` \| `V3Keystore`_, password: _`string`_, nonStrict?: _`boolean`_): [Wallet](wallet.md) -_Defined in [index.ts:379](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L379)_ +_Defined in [index.ts:379](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L379)_ Import a wallet (Version 3 of the Ethereum wallet format). Set `nonStrict` true to accept files with mixed-caps. @@ -428,7 +428,7 @@ Import a wallet (Version 3 of the Ethereum wallet format). Set `nonStrict` true ▸ **generate**(icapDirect?: _`boolean`_): [Wallet](wallet.md) -_Defined in [index.ts:255](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L255)_ +_Defined in [index.ts:255](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L255)_ Create an instance based on a new random key. @@ -448,7 +448,7 @@ Create an instance based on a new random key. ▸ **generateVanityAddress**(pattern: _`RegExp` \| `string`_): [Wallet](wallet.md) -_Defined in [index.ts:272](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/index.ts#L272)_ +_Defined in [index.ts:272](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/index.ts#L272)_ Create an instance where the address is valid against the supplied pattern (**this will be very slow**) diff --git a/docs/classes/walletsubprovider.md b/docs/classes/walletsubprovider.md index 9f84c11..4e767e5 100644 --- a/docs/classes/walletsubprovider.md +++ b/docs/classes/walletsubprovider.md @@ -24,7 +24,7 @@ ⊕ **new WalletSubprovider**(wallet: _[Wallet](wallet.md)_, opts?: _`any`_): [WalletSubprovider](walletsubprovider.md) -_Defined in [provider-engine.ts:5](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/provider-engine.ts#L5)_ +_Defined in [provider-engine.ts:5](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/provider-engine.ts#L5)_ **Parameters:** diff --git a/docs/interfaces/etherwalletoptions.md b/docs/interfaces/etherwalletoptions.md index d73666d..3ccb292 100644 --- a/docs/interfaces/etherwalletoptions.md +++ b/docs/interfaces/etherwalletoptions.md @@ -27,7 +27,7 @@ **● address**: _`string`_ -_Defined in [thirdparty.ts:108](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L108)_ +_Defined in [thirdparty.ts:108](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L108)_ --- @@ -37,7 +37,7 @@ _Defined in [thirdparty.ts:108](https://github.com/ethereumjs/ethereumjs-wallet/ **● encrypted**: _`boolean`_ -_Defined in [thirdparty.ts:109](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L109)_ +_Defined in [thirdparty.ts:109](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L109)_ --- @@ -47,7 +47,7 @@ _Defined in [thirdparty.ts:109](https://github.com/ethereumjs/ethereumjs-wallet/ **● hash**: _`string`_ -_Defined in [thirdparty.ts:111](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L111)_ +_Defined in [thirdparty.ts:111](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L111)_ --- @@ -57,7 +57,7 @@ _Defined in [thirdparty.ts:111](https://github.com/ethereumjs/ethereumjs-wallet/ **● locked**: _`boolean`_ -_Defined in [thirdparty.ts:110](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L110)_ +_Defined in [thirdparty.ts:110](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L110)_ --- @@ -67,7 +67,7 @@ _Defined in [thirdparty.ts:110](https://github.com/ethereumjs/ethereumjs-wallet/ **● private**: _`string`_ -_Defined in [thirdparty.ts:112](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L112)_ +_Defined in [thirdparty.ts:112](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L112)_ --- @@ -77,6 +77,6 @@ _Defined in [thirdparty.ts:112](https://github.com/ethereumjs/ethereumjs-wallet/ **● public**: _`string`_ -_Defined in [thirdparty.ts:113](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L113)_ +_Defined in [thirdparty.ts:113](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L113)_ --- diff --git a/docs/interfaces/evpkdfopts.md b/docs/interfaces/evpkdfopts.md index c66aa76..3e6d4b6 100644 --- a/docs/interfaces/evpkdfopts.md +++ b/docs/interfaces/evpkdfopts.md @@ -25,7 +25,7 @@ **● count**: _`number`_ -_Defined in [thirdparty.ts:17](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L17)_ +_Defined in [thirdparty.ts:17](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L17)_ --- @@ -35,7 +35,7 @@ _Defined in [thirdparty.ts:17](https://github.com/ethereumjs/ethereumjs-wallet/b **● digest**: _`string`_ -_Defined in [thirdparty.ts:20](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L20)_ +_Defined in [thirdparty.ts:20](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L20)_ --- @@ -45,7 +45,7 @@ _Defined in [thirdparty.ts:20](https://github.com/ethereumjs/ethereumjs-wallet/b **● ivsize**: _`number`_ -_Defined in [thirdparty.ts:19](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L19)_ +_Defined in [thirdparty.ts:19](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L19)_ --- @@ -55,6 +55,6 @@ _Defined in [thirdparty.ts:19](https://github.com/ethereumjs/ethereumjs-wallet/b **● keysize**: _`number`_ -_Defined in [thirdparty.ts:18](https://github.com/ethereumjs/ethereumjs-wallet/blob/15de3c4/src/thirdparty.ts#L18)_ +_Defined in [thirdparty.ts:18](https://github.com/ethereumjs/ethereumjs-wallet/blob/c748f97/src/thirdparty.ts#L18)_ --- diff --git a/test/index.ts b/test/index.ts index 3c8c724..ab0cf4a 100644 --- a/test/index.ts +++ b/test/index.ts @@ -297,14 +297,12 @@ describe('.toV3()', function() { p: p, }) - const encFixtureEthersWallet = ( - await fixtureEthersWallet.encrypt(pw, { - scrypt: { N: n, r: r, p: p }, - salt: ethersOpts.salt, - iv: ethersOpts.iv, - uuid: ethersOpts.uuid, - }) - ).toLowerCase() + const encFixtureEthersWallet = (await fixtureEthersWallet.encrypt(pw, { + scrypt: { N: n, r: r, p: p }, + salt: ethersOpts.salt, + iv: ethersOpts.iv, + uuid: ethersOpts.uuid, + })).toLowerCase() const encRandomWallet = wRandom.toV3String(pw, { kdf: 'scrypt', @@ -316,14 +314,12 @@ describe('.toV3()', function() { p: p, }) - const encEthersWallet = ( - await wEthers.encrypt(pw, { - scrypt: { N: n, r: r, p: p }, - salt: ethersOpts.salt, - iv: ethersOpts.iv, - uuid: ethersOpts.uuid, - }) - ).toLowerCase() + const encEthersWallet = (await wEthers.encrypt(pw, { + scrypt: { N: n, r: r, p: p }, + salt: ethersOpts.salt, + iv: ethersOpts.iv, + uuid: ethersOpts.uuid, + })).toLowerCase() assert.deepStrictEqual(JSON.parse(wStatic), JSON.parse(encFixtureWallet)) assert.deepStrictEqual(JSON.parse(wStatic), JSON.parse(encFixtureEthersWallet)) From 7ad83fe77cab2a30ab00ec4dc037e26ce4f0084e Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Fri, 24 Apr 2020 11:20:23 -0300 Subject: [PATCH 11/13] Fix linting error --- test/index.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/test/index.ts b/test/index.ts index ab0cf4a..3c8c724 100644 --- a/test/index.ts +++ b/test/index.ts @@ -297,12 +297,14 @@ describe('.toV3()', function() { p: p, }) - const encFixtureEthersWallet = (await fixtureEthersWallet.encrypt(pw, { - scrypt: { N: n, r: r, p: p }, - salt: ethersOpts.salt, - iv: ethersOpts.iv, - uuid: ethersOpts.uuid, - })).toLowerCase() + const encFixtureEthersWallet = ( + await fixtureEthersWallet.encrypt(pw, { + scrypt: { N: n, r: r, p: p }, + salt: ethersOpts.salt, + iv: ethersOpts.iv, + uuid: ethersOpts.uuid, + }) + ).toLowerCase() const encRandomWallet = wRandom.toV3String(pw, { kdf: 'scrypt', @@ -314,12 +316,14 @@ describe('.toV3()', function() { p: p, }) - const encEthersWallet = (await wEthers.encrypt(pw, { - scrypt: { N: n, r: r, p: p }, - salt: ethersOpts.salt, - iv: ethersOpts.iv, - uuid: ethersOpts.uuid, - })).toLowerCase() + const encEthersWallet = ( + await wEthers.encrypt(pw, { + scrypt: { N: n, r: r, p: p }, + salt: ethersOpts.salt, + iv: ethersOpts.iv, + uuid: ethersOpts.uuid, + }) + ).toLowerCase() assert.deepStrictEqual(JSON.parse(wStatic), JSON.parse(encFixtureWallet)) assert.deepStrictEqual(JSON.parse(wStatic), JSON.parse(encFixtureEthersWallet)) From f90caf1263a198a8233af1f37193e11239870822 Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Sun, 26 Apr 2020 19:05:52 -0300 Subject: [PATCH 12/13] Move web3-provider-engine to dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5aa5f23..4025fd7 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,8 @@ "hdkey": "^1.1.1", "randombytes": "^2.0.6", "utf8": "^3.0.0", - "uuid": "^3.3.2" + "uuid": "^3.3.2", + "web3-provider-engine": "^15.0.7" }, "devDependencies": { "@ethereumjs/config-nyc": "^1.1.1", @@ -75,7 +76,6 @@ "typescript": "^3.2.2", "typestrict": "^1.0.2", "typedoc": "^0.14.2", - "typedoc-plugin-markdown": "^1.2.0", - "web3-provider-engine": "^15.0.7" + "typedoc-plugin-markdown": "^1.2.0" } } From ac5ba8a4c512647eb2a38240e2eb4a123581f6e8 Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Sun, 26 Apr 2020 19:06:17 -0300 Subject: [PATCH 13/13] Fix imports in the README file --- README.md | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 853bff1..22f6905 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,20 @@ Features not supported: For information about the Wallet's API, please go to [./docs/classes/wallet.md](./docs/classes/wallet.md). +You can import the `Wallet` class like this + +Node.js / ES5: + +```js +const { Wallet } = require('ethereumjs-wallet') +``` + +ESM / TypeScript: + +```js +import { Wallet } from 'ethereumjs-wallet' +``` + ## Thirdparty API Importing various third party wallets is possible through the `thirdparty` submodule: @@ -37,13 +51,13 @@ Importing various third party wallets is possible through the `thirdparty` submo Node.js / ES5: ```js -const thirdparty = require('ethereumjs-wallet/thirdparty').default +const { thirdparty } = require('ethereumjs-wallet') ``` ESM / TypeScript: ```js -import thirdparty from 'ethereumjs-wallet/thirdparty' +import { thirdparty } from 'ethereumjs-wallet' ``` Please go to [./docs/README.md](./docs/README.md) for more info. @@ -55,13 +69,13 @@ To use BIP32 HD wallets, first include the `hdkey` submodule: Node.js / ES5: ```js -const hdkey = require('ethereumjs-wallet/hdkey').default +const { hdkey } = require('ethereumjs-wallet') ``` ESM / TypeScript: ```js -import hdkey from 'ethereumjs-wallet/hdkey' +import { hdkey } from 'ethereumjs-wallet' ``` Please go to [./docs/classes/ethereumhdkey.md](./docs/classes/ethereumhdkey.md) for more info. @@ -73,7 +87,7 @@ The Wallet can be easily plugged into [provider-engine](https://github.com/metam Node.js / ES5: ```js -const WalletSubprovider = require('ethereumjs-wallet/provider-engine').default +const { WalletSubprovider } = require('ethereumjs-wallet') .addProvider(new WalletSubprovider()) ``` @@ -81,7 +95,7 @@ const WalletSubprovider = require('ethereumjs-wallet/provider-engine').default ESM / TypeScript: ```js -import WalletSubprovider from 'ethereumjs-wallet/provider-engine' +import { WalletSubprovider } from 'ethereumjs-wallet' .addProvider(new WalletSubprovider()) ```