exonum-bundle-client
v0.5.2
Published
Bundle client
Downloads
5
Readme
Bundle client
- Getting started
- API
- Validate hexadecimal string
- Validate Bitcoin address
- Validate Ethereum address
- Generate mnemonic phrase
- Generate a new random signing key pair
- Register a new user
- Transfer tokens
- Get user refund addresses
- Get user balances and investment addresses
- Get user token balance
- Get wallet and transactions as cryptographic proof
- Changelog
Getting started
Install exonum-bundle-client package into your project.
npm install exonum-bundle-client
To include in Node.JS:
var ExonumBundle = require('exonum-bundle-client')
To use in browser:
<script src="node_modules/exonum-bundle-client/dist/exonum-bundle-client.js"></script>
API
Validate hexadecimal string
ExonumBundle.validateHexadecimal(hash, bytes)
| Argument | Description | Type |
|---|---|---|
| hash | Hash as hexadecimal string. | String
|
| bytes | Expected length in bytes. Optional, 32 by default. | Number
|
Returns boolean
.
Validate Bitcoin address
ExonumBundle.validateBTCAddress(address, networkType)
| Argument | Description | Type |
|---|---|---|
| address | Bitcoin address as string. | String
|
| networkType | prod
, testnet
or both
. Optional, prod
by default. | String
|
Returns boolean
.
Validate Ethereum address
ExonumBundle.validateETHAddress(address)
| Argument | Description | Type |
|---|---|---|
| address | Ethereum address as string. | String
|
Returns boolean
.
Generate mnemonic phrase
ExonumBundle.generateMnemonic()
Returns String
.
Generate a new random signing key pair
ExonumBundle.generateKeyPair(passphrase, password)
| Argument | Description | Type |
|---|---|---|
| passphrase | Mnemonic phrase as string. | String
|
| password | Password as string. | String
|
Returns promise.
Fulfilled response:
{
"publicKey": "...",
"secretKey": "..."
}
Register a new user
ExonumBundle.addUser(apiRoot, keyPair, BTCAddress, ETHAddress)
| Argument | Description | Type |
|---|---|---|
| apiRoot | Root URL for node public API. | String
|
| keyPair | Signing key pair. | Object
|
| BTCAddress | Bitcoin address as string. | String
|
| ETHAddress | Ethereum address as string. | String
|
Returns promise.
Fulfilled response:
{
"tx_hash": "..."
}
Transfer tokens
ExonumBundle.transfer(apiRoot, keyPair, to, amount)
| Argument | Description | Type |
|---|---|---|
| apiRoot | Root URL for node public API. | String
|
| keyPair | Signing key pair. | Object
|
| to | Receiver's public key as hexadecimal string. | String
|
| amount | Uint64
number as string. | String
|
Returns promise.
Fulfilled response:
{
"tx_hash": "..."
}
Get user refund addresses
ExonumBundle.getWithdraw(apiRoot, publicKey)
| Argument | Description | Type |
|---|---|---|
| apiRoot | Root URL for node public API. | String
|
| publicKey | Public key as hexadecimal string. | String
|
Returns promise.
Fulfilled response:
{
"btc_address": "...",
"eth_address": "...",
"pub_key": "..."
}
Get user balances and investment addresses
ExonumBundle.getShare(apiRoot, publicKey)
| Argument | Description | Type |
|---|---|---|
| apiRoot | Root URL for node public API. | String
|
| publicKey | Public key as hexadecimal string. | String
|
Returns promise.
Fulfilled response:
{
"btc_address": "...",
"btc_balance": "...",
"eth_balance": "...",
"eth_contract_address": "...",
"pub_key": "..."
}
Get user token balance
ExonumBundle.getDetail(apiRoot, publicKey)
| Argument | Description | Type |
|---|---|---|
| apiRoot | Root URL for node public API. | String
|
| publicKey | Public key as hexadecimal string. | String
|
Returns promise.
Fulfilled response:
{
"balance": "...",
"history_hash": "...",
"history_len": "...",
"pub_key": "..."
}
Get wallet and transactions as cryptographic proof
ExonumBundle.getHistory(apiRoot, publicKey)
| Argument | Description | Type |
|---|---|---|
| apiRoot | Root URL for node public API. | String
|
| publicKey | Public key as hexadecimal string. | String
|
Returns promise.
Fulfilled response:
{
"wallet": {
"balance": "...",
"history_hash": "...",
"history_len": "...",
"pub_key": "..."
},
"history": [
{
"body": {
"btc_address": "...",
"eth_address": "...",
"pub_key": "..."
},
"message_id": 10,
"protocol_version": 0,
"service_id": 128,
"signature": "..."
}
]
}
Changelog
Detailed changes for each release are documented in the CHANGELOG file.