JSPM

  • Created
  • Published
  • Downloads 1874
  • Score
    100M100P100Q116907F
  • License Apache-2.0

Module for parsing and serializing ILP packets

Package Exports

  • ilp-packet
  • ilp-packet/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ilp-packet) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ILP Packet

npm

A serializer and deserializer for ILP packets and messages

Usage

Install

npm install ilp-packet

Serialize PREPARE, FULFILL, REJECT

const IlpPacket = require('ilp-packet')
const crypto = require('crypto')
function sha256(preimage) {
  return crypto.createHash('sha256').update(preimage).digest()
}

const fulfillment = crypto.randomBytes(32)
const condition = sha256(fulfillment)

const binaryPrepare = IlpPacket.serializeIlpPrepare({
  amount: '10',
  executionCondition: condition,
  destination: 'g.us.nexus.bob',
  data: Buffer.from('hello world'),
  expiresAt: new Date(new Date().getTime() + 10000),
})

const binaryFulfill = IlpPacket.serializeIlpFulfill({
  fulfillment,
  data: Buffer.from('thank you'),
})

const binaryReject = IlpPacket.serializeIlpReject({
  code: 'F00',
  triggeredBy: 'g.us.nexus.gateway',
  message: 'more details, human-readable',
  data: Buffer.from('more details, machine-readable'),
})

Types

IlpPrepare

Property Type
amount string
executionCondition Buffer
expiresAt Date
destination string
data Buffer

IlpFulfill

Property Type
fulfillment Buffer
data Buffer

IlpReject

Property Type
code IlpErrorCode
triggeredBy string
message string
data Buffer