new HTTPClient(uri, optionsnullable)
BCoin HTTP client.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
uri |
String | ||
options |
Object |
<nullable> |
- Source:
Methods
(private) _del(endpoint, json, callback)
Make a DELETE http request to endpoint.
Parameters:
Name | Type | Description |
---|---|---|
endpoint |
String | Path. |
json |
Object | Body. |
callback |
function | Returns [Error, Object?]. |
- Source:
(private) _get(endpoint, json, callback)
Make a GET http request to endpoint.
Parameters:
Name | Type | Description |
---|---|---|
endpoint |
String | Path. |
json |
Object | Querystring. |
callback |
function | Returns [Error, Object?]. |
- Source:
(private) _post(endpoint, json, callback)
Make a POST http request to endpoint.
Parameters:
Name | Type | Description |
---|---|---|
endpoint |
String | Path. |
json |
Object | Body. |
callback |
function | Returns [Error, Object?]. |
- Source:
(private) _put(endpoint, json, callback)
Make a PUT http request to endpoint.
Parameters:
Name | Type | Description |
---|---|---|
endpoint |
String | Path. |
json |
Object | Body. |
callback |
function | Returns [Error, Object?]. |
- Source:
(private) _request(method, endpoint, json, callback)
Make an http request to endpoint.
Parameters:
Name | Type | Description |
---|---|---|
method |
String | |
endpoint |
String | Path. |
json |
Object | Body or query depending on method. |
callback |
function | Returns [Error, Object?]. |
- Source:
addKey(id, keys, callback)
Add a public account/purpose key to the wallet for multisig.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
keys |
Array.<HDPublicKey> | Array.<Base58String> | Account (bip44) or Purpose (bip45) key (can be in base58 form). |
callback |
function |
- Source:
all()
Listen for events on all wallets.
- Source:
broadcast(tx, callback)
Add a transaction to the mempool and broadcast it.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function |
- Source:
close(callback)
Close the client, wait for the socket to close.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
- Source:
(private) createWallet(options, callback)
Request the raw wallet JSON (will create wallet if it does not exist).
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | See Wallet. |
callback |
function | Returns [Error, Object]. |
- Source:
createWalletAccount(id, options, callback)
Create account.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
options |
Object | |
callback |
function | Returns [Error, Array]. |
- Source:
getBlock(hash, callback)
Retrieve a block from the chain database.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
callback |
function | Returns [Error, Block]. |
- Source:
getCoin(hash, index, callback)
Retrieve a coin from the mempool or chain database. Takes into account spent coins in the mempool.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
index |
Number | |
callback |
function | Returns [Error, Coin]. |
- Source:
getCoinsByAddress(addresses, callback)
Get coins that pertain to an address from the mempool or chain database. Takes into account spent coins in the mempool.
Parameters:
Name | Type | Description |
---|---|---|
addresses |
Base58Address | Array.<Base58Address> | |
callback |
function | Returns [Error, Coin[]]. |
- Source:
getInfo(callback)
Get some info about the server (network and version).
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | Returns [Error, Object]. |
- Source:
getMempool(callback)
Get a mempool snapshot.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | Returns [Error, TX[]]. |
- Source:
getTX(hash, callback)
Retrieve a transaction from the mempool or chain database.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash | |
callback |
function | Returns [Error, TX]. |
- Source:
getTXByAddress(addresses, callback)
Retrieve transactions pertaining to an address from the mempool or chain database.
Parameters:
Name | Type | Description |
---|---|---|
addresses |
Base58Address | Array.<Base58Address> | |
callback |
function | Returns [Error, TX[]]. |
- Source:
(private) getWallet(id, callback)
Get the raw wallet JSON.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
callback |
function | Returns [Error, Object]. |
- Source:
getWalletAccounts(id, callback)
Get wallet accounts.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
callback |
function | Returns [Error, Array]. |
- Source:
getWalletBalance(id, callback)
Calculate wallet balance.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
callback |
function | Returns [Error, Balance]. |
- Source:
getWalletCoin(id, hash, index, callback)
Get unspent coin (only possible if the transaction is available in the wallet history).
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
hash |
Hash | |
index |
Number | |
callback |
function | Returns [Error, Coin[]]. |
- Source:
getWalletCoins(id, callback)
Get wallet coins.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
callback |
function | Returns [Error, Coin[]]. |
- Source:
getWalletHistory(id, callback)
Get wallet transaction history.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
callback |
function | Returns [Error, TX[]]. |
- Source:
getWalletLast(id, limit, callback)
Get last N wallet transactions.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
limit |
Number | Max number of transactions. |
callback |
function | Returns [Error, TX[]]. |
- Source:
getWalletRange(id, options, callback)
Get wallet transactions by timestamp range.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
WalletID | |||||||||||||||||||||
options |
Object |
Properties
|
||||||||||||||||||||
callback |
function | Returns [Error, TX[]]. |
- Source:
getWalletTX(id, hash, callback)
Get transaction (only possible if the transaction is available in the wallet history).
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
hash |
Hash | |
callback |
function | Returns [Error, TX[]]. |
- Source:
getWalletUnconfirmed(id, callback)
Get all unconfirmed transactions.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
callback |
function | Returns [Error, TX[]]. |
- Source:
join(id)
Listen for events on wallet id.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID |
- Source:
leave(id)
Unlisten for events on wallet id.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID |
- Source:
none()
Unlisten for events on all wallets.
- Source:
open(callback)
Open the client, wait for the socket to load.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
- Source:
removeKey(id, keys, callback)
Remove a public account/purpose key to the wallet for multisig.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
keys |
Array.<HDPublicKey> | Array.<Base58String> | Account (bip44) or Purpose (bip45) key (can be in base58 form). |
callback |
function |
- Source:
walletCreate(id, options, callback)
Create a transaction, fill.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
id |
WalletID | ||||||||||
options |
Object |
Properties
|
|||||||||
callback |
function | Returns [Error, TX]. |
- Source:
walletFill(tx, callback)
Fill a transaction with coins.
Parameters:
Name | Type | Description |
---|---|---|
tx |
TX | |
callback |
function | Returns [Error, TX]. |
- Source:
walletSend(id, options, callback)
Create a transaction, fill, sign, and broadcast.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
id |
WalletID | ||||||||||
options |
Object |
Properties
|
|||||||||
callback |
function | Returns [Error, TX]. |
- Source:
walletSign(id, tx, options, callback)
Sign a transaction.
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
tx |
TX | |
options |
Object | |
callback |
function | Returns [Error, TX]. |
- Source:
walletZap(id, now, age, callback)
Parameters:
Name | Type | Description |
---|---|---|
id |
WalletID | |
now |
Number | Current time. |
age |
Number | Age delta (delete transactions older than |
callback |
function |
- Source: