JavaScript Ledger Plug-in interface version 2
The Interledger protocol is a suite of protocols that are used to pay across multiple different settlement systems.
The specification defines a JavaScript ledger abstraction interface for Interledger clients and connectors for communication and routing payments across different ledger protocols. Although the exact methods and events defined here are specific to JavaScript implementations, it can be used as a guide to ledger abstraction in other languages.
To send a ILP payment through a new ledger, a ledger plug-in must be implemented, which exposes the following defined interfaces. This can be used with ILP clients and connectors and should be used directly.
This specification depends on the ILP specification. class: Ledgerplugin
Class Ledgerplugin Method
|
name |
New |
Ledgerplugin (OPTS,API) |
|
Connect (options) ⇒promise.<undefined> |
|
Disconnect () ⇒promise.<undefined> |
|
IsConnected () ⇒boolean |
|
SendData (Options) ⇒promise.<buffer> |
|
Sendmoney (amount) ⇒promise.<undefined> |
|
Registerdatahandler (DataHandler) ⇒undefined |
|
Deregisterdatahandler () ⇒undefined |
|
Registermoneyhandler (Moneyhandler) ⇒undefined |
|
Deregistermoneyhandler () ⇒undefined |
Constants
Activities
name |
Processor |
Connect |
() ⇒ |
Connect |
() ⇒ |
Error |
() ⇒ |
Instance Management
the new Ledgerplugin
New Ledgerplugin (Opts:object, API?: pluginservices)
Creates a new instance of a plug-in. Each instance usually corresponds to a different ledger. However, some plug-ins may deviate from a strict one-to-one relationship and may act as a virtual connector for more than one opponent internally.
The first parameter, opts, is a configuration object whose shape is unique to each plug-in. Plug-ins are typically configured through environment variables, so it is recommended that opts should use JSON serialization. However, Plug-ins may use a value that is not serializable to provide advanced functionality.
The second parameter API is optional, which is used to pass an additional ambient service to a plug-in, such as a logger or key-value store. Most plug-ins should work, even if this parameter is undefined, but may provide less functionality (for example, no persistence).
Invalidfieldserror throws a opts if the constructor is given an incorrect argument. Throws TypeError if OPTs is not an object or is defined by an API instead of an object. Throw Invalidserviceserror If service is required, but does not provide through API. Parameters
name |
type |
Description |
OPTS |
Pluginoptions |
An object that contains ledger-related settings. May contain plug-in-specific fields. |
cases
const ledgerplugin = new Ledgerplugin ({//AUTH parameters are defined by Plug-ins _store: {//May require some ledger plug-ins for persistence internal Use///(for example, when there is a reduced standby in the system Forget recording function, we can only put the value under the Memo (ID)//Storage key: (Key,value) => {//return promise. <undefined>}, Get: (key) => {//return promise. <Object>},//Press to delete a value del: (