Coder Social home page Coder Social logo

ilp-plugin-btp's Introduction

ILP Plugin BTP

One plugin to rule them all

NPM Package CircleCI JavaScript Style Guide Known Vulnerabilities

Used right out of the box, this plugin is capable of representing a data channel with no money involved. It will send BTP messages with no knowledge of the data within, so it can be used for ILP packets. The sendMoney function is a no-op, because there is no system involved handling money.

The main use of this plugin, however, is as a building block for plugins that do have an underlying ledger. In this way, it's the successor of ilp-plugin-payment-channel-framework

Use as a Data Channel for ILP

const server = new BtpPlugin({
  listener: {
    port: 9000,
    secret: 'shh_its_a_secret'
  }
})

await server.connect()

const client = new BtpPlugin({
  server: 'btp+ws://:shh_its_a_secret@localhost:9000'
})

await client.connect()

server.registerDataHandler(serverHandler)
client.registerDataHandler(clientHandler)

await client.sendData(IlpPacket.serializeIlpPrepare({
  // ...
})

Use as a Base Class for a New Plugin

Two functions must be defined in order for the plugin to handle money.

  • sendMoney (amount: string) -> Promise<null>: sends amount of units to the peer. This should be done via a BTP TRANSFER call.
  • handleMoney (from: null, { requestId: number, data: { amount: string, protocolData: Array<ProtocolData> } }) -> Array<ProtocolData>: This function is called on an incoming BTP TRANSFER.

ProtocolData is made up of:

  • protocolName: string: The name of this side protocol. ILP-level information must be named ilp.
  • contentType: number: The content type. 0 is application/octet-stream, 1 is text/plain-utf8, and 2 is application/json. Mainly used for logging and smart deserializing.
  • data: buffer: The actual protocol data.

ilp-plugin-btp's People

Contributors

justmoon avatar michielbdejong avatar sentientwaffle avatar traviscrist avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.