Constructor
new Client(baseURL, clientState)
Create a Client.
Parameters:
Name | Type | Description |
---|---|---|
baseURL |
string | The URL of the Starlight agent. |
clientState |
object | The client state. |
Methods
cancel(channelID) → {Promise.<ClientResponse.<string>>}
Cancel a proposed channel that your counterparty has not yet accepted.
Parameters:
Name | Type | Description |
---|---|---|
channelID |
string | The channel ID. |
Returns:
- Type
- Promise.<ClientResponse.<string>>
channelPay(channelID, amount) → {Promise.<ClientResponse.<string>>}
Make a payment over a channel.
Parameters:
Name | Type | Description |
---|---|---|
channelID |
string | The channel ID. |
amount |
number | The amount (in stroops) to be paid. |
Returns:
- Type
- Promise.<ClientResponse.<string>>
clearState()
Resets the client's state to an initial state.
close(channelID) → {Promise.<ClientResponse.<string>>}
Cooperatively close a channel.
Parameters:
Name | Type | Description |
---|---|---|
channelID |
string | The channel ID. |
Returns:
- Type
- Promise.<ClientResponse.<string>>
configEdit(params) → {Promise.<ClientResponse.<string>>}
Edit the instance's configuration.
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object | The configuration parameters.
Properties
|
Returns:
- Type
- Promise.<ClientResponse.<string>>
(async) configInit(params) → {Promise.<ClientResponse.<Status>>}
Configure the instance with a username, password, and horizon URL.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object | The configuration parameters.
Properties
|
Returns:
- Type
- Promise.<ClientResponse.<Status>>
createChannel(counterpartyAddress, initialDeposit) → {Promise.<ClientResponse.<string>>}
Attempt to open a channel with a specific counterparty.
Parameters:
Name | Type | Description |
---|---|---|
counterpartyAddress |
string | The Stellar address of your counterparty (e.g., "alice*stellar.org"). |
initialDeposit |
number | The amount (in stroops) you will initially deposit into the channel. |
Returns:
- Type
- Promise.<ClientResponse.<string>>
deposit(channelID, amount) → {Promise.<ClientResponse.<string>>}
Add more money to a channel you created.
Parameters:
Name | Type | Description |
---|---|---|
channelID |
string | The channel ID. |
amount |
number | The amount (in stroops) to be deposited. |
Returns:
- Type
- Promise.<ClientResponse.<string>>
findAccount(address) → {Promise.<ClientResponse.<Status>>}
Find the account ID (e.g., "G...") corresponding to a Stellar address (e.g., "alice*stellar.org").
Parameters:
Name | Type | Description |
---|---|---|
address |
string |
Returns:
accountID
- Type
- Promise.<ClientResponse.<Status>>
forceClose(channelID) → {Promise.<ClientResponse.<string>>}
Attempt to force close a channel.
Parameters:
Name | Type | Description |
---|---|---|
channelID |
string | The channel ID. |
Returns:
- Type
- Promise.<ClientResponse.<string>>
getStatus() → {Promise.<(Status|undefined)>}
Get the current status of the instance (whether the instance is configured, and if so, whether the user is logged in).
Returns:
- Type
- Promise.<(Status|undefined)>
login(username, password) → {Promise.<ClientResponse.<string>>}
Authenticate with a Starlight instance.
This also decrypts the instance's private key,
allowing it to sign transactions and accept channels.
Parameters:
Name | Type | Description |
---|---|---|
username |
string | |
password |
number |
Returns:
- Type
- Promise.<ClientResponse.<string>>
logout(username, password) → {Promise.<ClientResponse.<string>>}
Log out of a Starlight instance.
Parameters:
Name | Type | Description |
---|---|---|
username |
string | |
password |
number |
Returns:
- Type
- Promise.<ClientResponse.<string>>
setState(clientState)
Restore the client's state from a snapshot.
Parameters:
Name | Type | Description |
---|---|---|
clientState |
object | The client state. |
subscribe(updateHandler)
Subscribe to updates from the Starlight instance.
The first time this is called, the handler will be called with all updates in the instance's history.
Parameters:
Name | Type | Description |
---|---|---|
updateHandler |
function | A handler function that updates will be passed to. |
unsubscribe()
Stop subscribing to updates from the Starlight instance.
walletPay(channelID, amount) → {Promise.<ClientResponse.<string>>}
Make a payment on the public network.
Parameters:
Name | Type | Description |
---|---|---|
channelID |
string | The channel ID. |
amount |
number | The amount (in stroops) to be paid. |
Returns:
- Type
- Promise.<ClientResponse.<string>>