Constructor
new Wallet(seedopt, optionsopt) → {Wallet}
Create a new BIP44 wallet with the supplied settings
Examples
Create wallet with Random Mnemonic
let wallet = new Wallet()
Create wallet from BIP39 Mnemonic
let wallet = new Wallet("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")
Create wallet from BIP39 Entropy
let wallet = new Wallet('00000000000000000000000000000000')
Create wallet from Seed Hex
let wallet = new Wallet("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4")
Create wallet from Seed Buffer
let wallet = new Wallet(Buffer.from("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4", "hex"))
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
seed |
string | Buffer |
<optional> |
||||||||||||||||||||||||||
options |
Object |
<optional> |
Wallet settings Properties
|
Example
let wallet = new Wallet("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")
Returns:
- Type:
- Wallet
Methods
addCoin(name, optionsopt)
Add a Coin to the Wallet
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String |
The coin "name" as defined in CoinInfo.name |
|
options |
Object |
<optional> |
Options you want passed to the coin being added |
addTestnetCoins(boolopt)
Add default SUPPORTED testnet coins to wallet
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
bool |
Boolean |
<optional> |
true |
if true, add testnet coins, is false, remove them |
fromEntropy(entropy) → {Boolean}
Init Wallet from BIP39 Entropy
Parameters:
Name | Type | Description |
---|---|---|
entropy |
string |
A BIP39 Entropy String |
Returns:
Returns if the operation was successful
- Type:
- Boolean
fromMnemonic(mnemonic) → {Boolean}
Init Wallet from BIP39 Mnemonic
Parameters:
Name | Type | Description |
---|---|---|
mnemonic |
string |
A BIP39 Mnemonic String |
Example
let wallet = new Wallet();
wallet.fromMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")
Returns:
Returns if the operation was successful
- Type:
- Boolean
fromSeed(seed) → {Boolean}
Init Wallet from a Seed
Parameters:
Name | Type | Description |
---|---|---|
seed |
string | Buffer |
Returns:
Returns if the operation was successful
- Type:
- Boolean
getCoin(coin) → {Coin}
Get a specific Coin
Parameters:
Name | Type | Description |
---|---|---|
coin |
string |
The coin "name" as defined in CoinInfo.name |
Returns:
Returns the requested Coin
- Type:
- Coin
(async) getCoinBalances(optionsopt) → {Promise.<Object>}
Get Coin Balances
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
The options for searching the Balance of coins Properties
|
Example
let wallet = new Wallet(...)
wallet.getCoinBalances(["bitcoin", "litecoin", "flo"])
//example return
{
"flo": 2.16216,
"bitcoin": "error fetching balance",
"litecoin": 3.32211
}
Returns:
Returns a Promise that will resolve to an Object containing info about each coins balance, along with errors if there are any
- Type:
- Promise.<Object>
getCoins() → {Object.<number, Coin>}
Get all Coins running inside the Wallet
Example
let wallet = new Wallet();
let coins = wallet.getCoins();
// coins = {
// "bitcoin": Coin,
// "litecoin": Coin,
// "flo": Coin
// }
Returns:
Object containing all coins
- Type:
- Object.<number, Coin>
getEntropy() → {string}
Get the Entropy value used to generate the BIP39 Mnemonic. Note that the Entropy will only be defined if we are creating a wallet from Entropy or a Mnemonic, not off of just the Seed Hex
Example
let wallet = new Wallet("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about");
let entropy = wallet.getEntropy()
// entropy = '00000000000000000000000000000000'
Returns:
- Type:
- string
(async) getExchangeRates(optionsopt) → {Promise.<Object>}
Calculate Exchange Rates for supported coins
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
The options for getting the exchange rates Properties
|
Example
let wallet = new Wallet(...)
wallet.getExchangeRates(["flo", "bitcoin", "litecoin"], "usd")
//returns
{
"flo": expect.any(Number) || "error",
"bitcoin": expect.any(Number) || "error",
"litecoin": expect.any(Number) || "error"
}
Returns:
Returns a Promise that will resolve to an Object containing info about each coins exchange rate, along with errors if there are any
- Type:
- Promise.<Object>
getExplorerUrls()
Get back the network explorer apis for supported coins
(async) getFiatBalances(optionsopt) → {Promise.<Object>}
Calculate Balance of coins after exchange rate conversion
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
The options for getting the exchange rates Properties
|
Example
let wallet = new Wallet(...)
wallet.getFiatBalances(["flo", "bitcoin", "litecoin"], "usd")
//returns
{
"flo": expect.any(Number) || "error",
"bitcoin": expect.any(Number) || "error",
"litecoin": expect.any(Number) || "error"
}
Returns:
Returns a Promise that will resolve to the fiat balances for each coin
- Type:
- Promise.<Object>
getMnemonic() → {string}
Get the BIP39 Mnemonic, if defined
Example
let wallet = new Wallet('00000000000000000000000000000000');
let mnemonic = wallet.getMnemonic()
// mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
Returns:
- Type:
- string
getNetworks()
Returns the network information for the coins available
Returns:
Array.
getSeed() → {string}
Get the Encoded Seed hex string
Example
let wallet = new Wallet('00000000000000000000000000000000');
let seedHex = wallet.getSeed()
// seedHex = '5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4'
Returns:
The hex string of the seed buffer
- Type:
- string
(async) sendPayment(options) → {Promise.<string>}
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Options about the payment you wish to send Properties
|
Returns:
Returns a promise that will resolve to the success TXID
- Type:
- Promise.<string>
setExplorerUrls(options)
Set the urls for the insight api explorers
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Properties
|