-
Notifications
You must be signed in to change notification settings - Fork 22
Refactor API for latest suite of protocols #130
Copy link
Copy link
Open
Description
The ilp module should be updated for the latest suite of protocols. It should expose a reasonable API for ILP and PSK/Paystream.
Here is a sketch of what the new API might look like:
Basic Usage: PayStream
const ilp = require('ilp')
;(async () => {
// Connect to a PayStream, defaults to using moneyd
const socket = await ilp.createConnection([ilp address], [shared secret])
// Lower the paystream maximum by 1000 (minimum will be lowered if necessary)
await socket.pay('1000')
// Lower the paystream minimum by 2000
socket.payUpTo('2000')
// Increase the paystream minimum by 4000 (maximum will be increased if necessary)
await socket.charge('4000')
// Increase the paystream maximum by 2000
socket.chargeUpTo('2000')
// Write some data
socket.write(Buffer.alloc(128))
await socket.flush()
// Read data
socket.on('data', (data) => {
console.log(data.toString('utf8'))
})
})()Basic Usage: Raw packet
const ilp = require('ilp')
;(async () => {
const { fulfillment, data } = await ilp.sendPacket({
destination: 'test.bob',
amount: '100',
executionCondition: '...',
expiresAt: '...',
data: Buffer.alloc(0)
})
})()Advanced Usage: Using a custom plugin
const { create as createIlp } = require('ilp')
const CustomPlugin = require('ilp-plugin-custom')
;(async () => {
const ilp = createIlp({
plugin: new CustomPlugin({ /* ... */ })
})
// ... ready to use
})()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels