npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ilp-plugin-xrp-asym-client

v1.6.0

Published

Asymmetric XRP paychan client for ILP

Downloads

8

Readme

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({
  // The BTP address of the asymmetric server plugin. The `btp_secret`
  // in here is hashed to become the account name. Note that if you switch
  // XRP accounts, you also have to switch `btp_secret`s
  server: 'btp+ws://:btp_secret@localhost:6666',

  // Rippled server for client use
  xrpServer: 'wss://s.altnet.rippletest.net:51233',

  // XRP secret. The address can be dynamically determined from this,
  // or can be specified as a separate option.
  secret: 'ss1oM64ccuJuX9utz5pdPRuu5QKMs',

  // A store can be optionally passed in to save claims in case of a crash.
  // If no store is present, then the best claim will be submitted on plugin
  // disconnect, as well as once every five minutes (interval is configurable
  // via claimInterval)
  _store: new Store(),

  // Interval on which to claim funds from channel. Defaults to 5 minutes.
  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',

  // Interval on which to claim funds from channel. Defaults to 5 minutes.
  claimInterval: 5 * 60 * 1000,
  server: 'btp+wss://:[email protected]: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()
  })
})