ILP Plugin XRP Asym Client
This plugin allows a user to create a payment channel to a connector without
the connector having to add an entry to their list of peers. It is therefore
very useful for creating your own sub-connector. The client plugin first opens
a channel to the server, and then informs the server of this channel while
providing proof that it controls it. If the proof is satisfactory and the
channel contains at least 10 XRP (to prevent a DoS attack), the server will
open a channel back to the client for carrying incoming funds.
Persistent state is not required to run this plugin, even though it makes use
of payment channels. When your peer wants you to sign a new claim, they will
first give you the best claim of yours that they have seen. This plugin will
then verify that claim and sign a higher one. In this way, the best outgoing
claim does not have to be stored.
For incoming funds, the connector will give you a signed claim for the amount
they owe you. This claim signature is verified against payment channel details,
and against an internally kept balance. This balance is set by loading the
payment channel details at every start up. If persistence is enabled, this
incoming balance will be loaded from the provided store.
ILP Plugin XRP Asym Client is based off of
ilp-plugin-btp
. The ILP
Plugin XRP Asym Server is located
here.
const clientPlugin = new IlpPluginXrpAsymClient({
server: 'btp+ws://:btp_secret@localhost:6666',
xrpServer: 'wss://s.altnet.rippletest.net:51233',
secret: 'ss1oM64ccuJuX9utz5pdPRuu5QKMs',
_store: new Store(),
claimInterval: 5 * 60 * 1000
})
Interfaucet example
Full example of obtaining money from the Interfaucet using this plugin:
const Plugin = require('.')
const crypto = require('crypto')
const IlDcp = require('ilp-protocol-ildcp')
const IlpPacket = require('ilp-packet')
function sha256(preimage) { return crypto.createHash('sha256').update(preimage).digest() }
const plugin = new Plugin({
xrpServer: 'wss://s.altnet.rippletest.net:51233',
secret: 'sspPGRjcBXT9UBxewQUJKcWZCR1zC',
claimInterval: 5 * 60 * 1000,
server: 'btp+wss://:token@amundsen.ilpdemo.org:1801'
})
console.log('connecting')
plugin.connect().then(async () => {
console.log('connected')
const request = IlDcp.serializeIldcpRequest()
const response = await plugin.sendData(request)
const info = IlDcp.deserializeIldcpResponse(response)
const fulfillment = crypto.randomBytes(32)
const condition = sha256(fulfillment)
console.log(`Now go to https://interfaucet.ilpdemo.org/?address=${info.clientAddress}&condition=${condition.toString('hex')}`)
plugin.registerDataHandler(packet => {
const prepare = IlpPacket.deserializeIlpPrepare(packet)
console.log(prepare)
return IlpPacket.serializeIlpFulfill({ fulfillment: fulfillment, data: Buffer.from([]) })
})
plugin.registerMoneyHandler(packet => {
console.log('got money!', packet)
plugin.disconnect()
})
})