{"id":13784144,"url":"https://github.com/interledgerjs/ilp-plugin-btp","last_synced_at":"2025-05-11T19:32:28.897Z","repository":{"id":37686503,"uuid":"115659735","full_name":"interledgerjs/ilp-plugin-btp","owner":"interledgerjs","description":"This has been moved to the monorepo https://github.com/interledgerjs/interledgerjs","archived":true,"fork":false,"pushed_at":"2023-01-27T06:39:28.000Z","size":1037,"stargazers_count":9,"open_issues_count":13,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-06T12:50:23.543Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/interledgerjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-28T21:09:23.000Z","updated_at":"2024-11-30T15:27:57.000Z","dependencies_parsed_at":"2023-02-15T06:30:56.875Z","dependency_job_id":null,"html_url":"https://github.com/interledgerjs/ilp-plugin-btp","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interledgerjs%2Filp-plugin-btp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interledgerjs%2Filp-plugin-btp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interledgerjs%2Filp-plugin-btp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interledgerjs%2Filp-plugin-btp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/interledgerjs","download_url":"https://codeload.github.com/interledgerjs/ilp-plugin-btp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253328967,"owners_count":21891558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T19:00:36.118Z","updated_at":"2025-05-11T19:32:28.550Z","avatar_url":"https://github.com/interledgerjs.png","language":"JavaScript","readme":"# ILP Plugin BTP\n\u003e One plugin to rule them all\n\n[![NPM Package](https://img.shields.io/npm/v/ilp-plugin-btp.svg?style=flat)](https://npmjs.org/package/ilp-plugin-btp)\n[![CircleCI](https://circleci.com/gh/interledgerjs/ilp-plugin-btp.svg?style=shield)](https://circleci.com/gh/interledgerjs/ilp-plugin-btp)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Known Vulnerabilities](https://snyk.io/test/github/interledgerjs/ilp-plugin-btp/badge.svg)](https://snyk.io/test/github/interledgerjs/ilp-plugin-btp) [![Greenkeeper badge](https://badges.greenkeeper.io/interledgerjs/ilp-plugin-btp.svg)](https://greenkeeper.io/)\n\nUsed right out of the box, this plugin is capable of representing a data\nchannel with no money involved. It will send BTP messages with no knowledge\nof the data within, so it can be used for ILP packets. The `sendMoney` function\nis a no-op, because there is no system involved handling money.\n\nThe main use of this plugin, however, is as a building block for plugins that\ndo have an underlying ledger. In this way, it's the successor of\n[`ilp-plugin-payment-channel-framework`](https://github.com/interledgerjs/ilp-plugin-payment-channel-framework)\n\nPlugins that sub-class the `AbstractBtpPlugin` should override `sendMoney` and `_handleMoney` at least.\n\n## Use as a Data Channel for ILP\n\n```js\nconst server = new BtpPlugin({\n  listener: {\n    port: 9000,\n    secret: 'shh_its_a_secret'\n  }\n})\n\nawait server.connect()\n\nconst client = new BtpPlugin({\n  server: 'btp+ws://:shh_its_a_secret@localhost:9000'\n})\n\nawait client.connect()\n\nserver.registerDataHandler(serverHandler)\nclient.registerDataHandler(clientHandler)\n\nawait client.sendData(IlpPacket.serializeIlpPrepare({\n  // ...\n})\n```\n\n## Use as a Base Class for a New Plugin\n\nTwo functions must be defined in order for the plugin to handle money.\n\n* `sendMoney (amount: string) -\u003e Promise\u003cnull\u003e`: sends `amount` of units to the peer. This should be done via a BTP `TRANSFER` call.\n* `_handleMoney (from: string, btpPacket: BtpPacket) -\u003e Promise\u003cArray\u003cBtpSubProtocol\u003e\u003e`: This function is called on an incoming BTP `TRANSFER`.\n\nBtpSubProtocol is made up of:\n\n* `protocolName: string`: The name of this side protocol. ILP-level information must be named `ilp`.\n* `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.\n* `data: buffer`: The actual protocol data.\n","funding_links":[],"categories":["Ledger Plugins"],"sub_categories":["JavaScript (Interledger.js)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterledgerjs%2Filp-plugin-btp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finterledgerjs%2Filp-plugin-btp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterledgerjs%2Filp-plugin-btp/lists"}