Skip to content

Instantly share code, notes, and snippets.

@justmoon
Last active November 24, 2018 13:02
Show Gist options
  • Save justmoon/cfe84c6c9a2f773f081c74aa4c26f134 to your computer and use it in GitHub Desktop.
Save justmoon/cfe84c6c9a2f773f081c74aa4c26f134 to your computer and use it in GitHub Desktop.
ILP Kit Peering Flow

User Experience

Ben would like to peer with Stefan. So he logs into his server running ILP kit and runs:

$ ilp-admin help

Usage: ilp-admin [command] ...

peer list      List my peers
peer add       Add a new peer (interactive)
peer remove    Remove an existing peer

$ ilp-admin peer add
Who would you like to peer with? (Enter hostname, e.g. red.ilpdemo.org)
nexus.justmoon.com
What should the currency of the trustline be? (default: USD) (my currency)
USD
How much can the other side borrow before they have to settle? (in USD)
2000
Which MQTT broker would you like to use? (default: mqtt.ripple.com)
mqtt.ripple.com

Generating…. done!

Internally, ILP Kit CLI will query the destination hostname using a well-known URI:

Request
GET /.well-known/ilp-kit.json HTTP/1.1
Host: nexus.justmoon.com
Accept: application/json
Response
HTTP/1.1 200 OK
Content-Type: application/json
{
  "publicKey": "n++1M9z7NkgUmqkRw7IkEHmlXArUlJrCi+pN7yL7KWs",
  "ledger": "https://nexus.justmoon.com/ledger"
}

ILP Kit CLI generates the plugin configuration which looks like this:

{
  // MQTT broker to use
  broker: 'mqtt.ripple.com',

  // Peer's public key
  peerPublicKey: 'n++1M9z7NkgUmqkRw7IkEHmlXArUlJrCi+pN7yL7KWs',

  // The most credit that we are willing to extend
  maxBalance: '100'
}

When running the plugin, the connector will inject two additional properties:

{
  // Key/value store (provided by connector)
  _store: {},

  // Some kind of connector-provided secret that stays constant
  _privateKey: 'HyjOMnubNVmYwOrEMjidQ+JaBhXyT3maOZ39y8tf5eI=',

  // …
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment