Five Bells Wallet Client
A high-level JS library for sending and receiving Interledger payments.
Installation
npm install five-bells-wallet-client --save
Usage
This is a client for the five-bells-wallet
.
To use it with a hosted demo wallet, create an account on red.ilpdemo.org or blue.ilpdemo.org (it doesn't matter which because they're connected via the Interledger Protocol!).
Sending
const WalletClient = const sender = address: 'alice@red.ilpdemo.org' password: 'super-secret-password' sender sender
Receiving
const WalletClient = const receiver = address: 'bob@blue.ilpdemo.org' password: 'ultra-secret-password' receiver receiver
API Reference
Client for connecting to the five-bells-wallet
WalletClient~WalletClient
Kind: inner class of WalletClient
- ~WalletClient
- new WalletClient(opts)
- .connect() ⇒
Promise.<null>
- .isConnected() ⇒
Boolean
- .getAccount() ⇒
Promise.<String>
- .disconnect() ⇒
null
- .payment(params) ⇒
Payment
- .send(params) ⇒
Promise.<Object>
- .convertAmount() ⇒
Promise.<BigNumber>
new WalletClient(opts)
Param | Type | Default | Description |
---|---|---|---|
opts | Object |
WalletClient options | |
opts.address | String |
Account at five-bells-wallet in the form user@wallet-url.example | |
opts.password | String |
Account password for five-bells-wallet | |
[opts.autoConnect] | Boolean |
true |
Subscribe to WebSocket notifications automatically when new event listeners are added |
Promise.<null>
walletClient.connect() ⇒ Login to wallet and subscribe to WebSocket notifications
Kind: instance method of WalletClient
Returns: Promise.<null>
- Resolves once client is subscribed
Boolean
walletClient.isConnected() ⇒ Check if the client is currently subscribed to wallet notifications
Kind: instance method of WalletClient
Promise.<String>
walletClient.getAccount() ⇒ Get the ledger account URI corresponding to the user's address
Kind: instance method of WalletClient
null
walletClient.disconnect() ⇒ Unsubscribe from wallet notifications
Kind: instance method of WalletClient
Payment
walletClient.payment(params) ⇒ Create a new Payment object
Kind: instance method of WalletClient
Param | Type | Description |
---|---|---|
params | PaymentParams |
Payment parameters |
Promise.<Object>
walletClient.send(params) ⇒ Create a new Payment object, get a quote, and send the payment. Resolves when the payment is complete.
Kind: instance method of WalletClient
Returns: Promise.<Object>
- Payment result
Param | Type | Description |
---|---|---|
params | PaymentParams |
Payment parameters |
[params.onQuote] | function |
Function to call when a quote is received |
[params.onSent] | function |
Function to call when payment is sent (before it is complete) |
Promise.<BigNumber>
walletClient.convertAmount() ⇒ Convert the given destination amount into the local asset
Kind: instance method of WalletClient
Returns: Promise.<BigNumber>
- Source amount as a BigNumber
Param | Type | Description |
---|---|---|
params.destinationAmount | String | Number |
The destination amount to convert |
params.destinationAccount | String |
Destination account to convert amount for |
Class for quoting and sending payments
Payment~Payment
Kind: inner class of Payment
- ~Payment
- new Payment(walletClient, params)
- .quote() ⇒
Promise.<PaymentParams>
- .send() ⇒
Promise.<Object>
new Payment(walletClient, params)
Param | Type | Description |
---|---|---|
walletClient | WalletClient |
WalletClient instance used for quoting and sending |
params | PaymentParams |
Payment parameters |
Promise.<PaymentParams>
payment.quote() ⇒ Get a quote to fill in either the sourceAmount or destinationAmount, whichever was not given.
Kind: instance method of Payment
Returns: Promise.<PaymentParams>
- Original payment params with sourceAmount or destinationAmount filled in
Emits: quote
Promise.<Object>
payment.send() ⇒ Execute the payment
Kind: instance method of Payment
Returns: Promise.<Object>
- Resolves when the payment is complete
Emits: sent
Object
Payment~PaymentParams : Kind: inner typedef of Payment
Param | Type | Default | Description |
---|---|---|---|
destinationAccount | String |
Receiver account URI | |
[sourceAmount] | String | Number | BigNumber |
(quoted from destinationAmount) |
Either sourceAmount or destinationAmount must be supplied |
[destinationAmount] | String | Number | BigNumber |
(quoted from sourceAmount) |
Either sourceAmount or destinationAmount must be supplied |
[message] | String |
"" |
Message to send to recipient |