Coder Social home page Coder Social logo

interledger-deprecated / ilp-plugin-payment-channel-framework Goto Github PK

View Code? Open in Web Editor NEW
2.0 5.0 3.0 611 KB

Framework for creating payment-channel based ILP ledger plugins

License: Other

JavaScript 100.00%
ilp interledger payment-channel trustline ledger-plugin btp bilateral-transfer-protocol

ilp-plugin-payment-channel-framework's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ilp-plugin-payment-channel-framework's Issues

Calling send_request without "from" gives a wrong error message

Calling send_request with:

[
  {
    "ledger": "g.crypto.paychan.framework.",
    "to": "g.crypto.paychan.framework.server",
    "ilp": "ARwAAAAAB1TUwA5nLnVzLm5leHVzLmJvYgMEEEEA"
  }
]

Result:

{
    "id": "InvalidFieldsError",
    "message": "must have a destination (.to)"
}

To fix this error, from: ... has to be added to the request, which does not make much sense given the error message and the request has already a to field.

When looking at a debug track, it becomes apparent what goes wrong:

[api]   ilp-plugin-virtual incoming send_request from [ 'https://wallet2.example/api/pseers/rpc' ] with [ { ledger: 'g.crypto.paychan.framework.',
[api]     to: 'g.crypto.paychan.framework.server',
[api]     ilp: '...' } ] +0ms
[api] validate incoming
[api] ASDF { ledger: 'g.crypto.paychan.framework.',
[api]   to: 'g.crypto.paychan.framework.server',
[api]   ilp: '...' }
[api] validate outgoing
[api] ASDF { ledger: 'g.crypto.paychan.framework.',
[api]   to: undefined,
[api]   from: 'g.crypto.paychan.framework.server',
[api]   ilp: '...' }

The from field from the incoming message is used to set the to field in the outgoing message. Since from is undefined in the incoming message, to becomes undefined in the outoing message.

We might want to remove .to and .from from the message to avoid such bugs. In a bilateral trustline, these field are redundant.

Related to interledger/rfcs/issues/234 (cc: @sharafian @michielbdejong)

add PluginFactory

It occurred to me that in the WebSocket server case, we're doing this wrong. :)

Currently, we're telling one plugin to listen on a port. That will work for a sender or a receiver that just has one peer (e.g. my ILSP will connect to my online shop server's WebSocket server to deliver BTP Prepare messages, but I don't expect anyone else to ever connect to that WebSocket URL).

What would be more correct would be to have one Plugin per WebSocket connection. So:

const opts = {
 listenOnPort: 443,
 cert: <bla.pdx>
}

const factory = new PluginFactory(opts)

factory.on('clientConnected', async (plugin) => {
  // now we have one plugin, because one peer connected to the WebSocket server
  // which the factory is running.
  await plugin.connect()
  await plugin.sendTransfer(foo)
  await plugin.disconnect()
})

fulfillment data should be base64-decoded from LPI

Throws non-existing error

plugin.js:437 instantiates the error class AlreadyRejectedError, but this error class does not exist.

From looking into the LPI docs, I assume this should be an AlreadyRolledBackError error.

separate ledger from LPI-BTP codec

PluginVirtual basically has two functions: the ledger and the codec.

While working on https://github.com/interledgerjs/amundsen/pull/2/files#diff-034b86edf6fcd40d95d1588b485d6d9e it occurred to me that it would probably make sense to make the virtual ledger inside src/lib/plugin.js more explicit.

If we define an in-memory ledger, whose interface is the LPI, it can:

  • expose the LPI interface of the plugin (e.g. to the connector when this plugin is used in ilp-connector)
  • keep track of the balance
  • expose an LPI interface to the outside (e.g. to the peer when used to connect to a peer).
  • ledger.myPlugin.getBalance() === -ledger.peerPlugin.getBalance()
  • ledger.peerPlugin.sendTransfer() triggers ledger.myPlugin.on('incoming-prepare')
  • etc.

A separate part of the code can then act as a codec, deal with translating between LPI and BTP and back (see interledger-deprecated/btp-toolbox#2 for an example).

Separating the peer-ledger, which exposes two LPI interfaces (ledger.myPlugin and ledger.peerPlugin) makes LPI more important and confines the impact of BTP to inside the codec. A nice separation of concerns, maybe?

Question: newbie question about account

Sorry I'm new to Interledger, I already setup ILP-KIT (3 instances) my own, now I try to make transfer between kits.

My question is:

"server": "btp+wss://username:[email protected]:1234/example_path"

What exactly username in config bellow come from? it's an account in ILP-KIT, or connector account in five-bell-ledger?

Find an elegant solution to load integration test configuration

The config files required to run plugin-xrp-paychan's integration tests are hardcoded in circle.yaml, which is a little janky.

Putting the config files in the integration test repo is not a solution. The config files need to be loaded (and rippled has to be started) before the integration tests are installed.

decode username and password from connection string

Username and password provided in the connection string are not decoded. For example, providing a client plugin with the option server: btp+ws://username with blanks:shh its a [email protected]:3333 will result in user and pass being parsed as username%20with%20blank and shh%20its%20a%secret, respectively.

Errors cause RPC server to break down

When an error occurs in the payment channel handler for handleIncomingPrepare, the plugin ceases to accept incoming RPC connections, and also disconnects all of its sockets. I'm not certain why this occurs, but I'm looking into it.

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.