Skip to content

Instantly share code, notes, and snippets.

@michielbdejong
Last active June 2, 2017 09:10
Show Gist options
  • Save michielbdejong/52257fb9e46c62e72fe96020b3afbb62 to your computer and use it in GitHub Desktop.
Save michielbdejong/52257fb9e46c62e72fe96020b3afbb62 to your computer and use it in GitHub Desktop.
plugin-virtual's REST API
# WebFinger for peering:
1. GET https://red.ilpdemo.org/.well-known/webfinger?resource=https://red.ilpdemo.org
{
"subject":"https://red.ilpdemo.org",
"properties":{
"https://interledger.org/rel/publicKey":"0ZwLzlPLd2UWJPwYSz6RhOh3S-N-cdAhVqG62iqb6xI",
"https://interledger.org/rel/protocolVersion":"Compatible: ilp-kit v2.0.2"},
"links":[
{"rel":"https://interledger.org/rel/ledgerUri","href":"https://red.ilpdemo.org/ledger"},
{"rel":"https://interledger.org/rel/peersRpcUri","href":"https://red.ilpdemo.org/api/peers/rpc"},
{"rel":"https://interledger.org/rel/settlementMethods","href":"https://red.ilpdemo.org/api/settlement_methods"}
]
}
2. Use that publicKey '0ZwLzlPLd2UWJPwYSz6RhOh3S-N-cdAhVqG62iqb6xI', plus your own privateKey,
calculate the virtual ledger prefix, e.g.: `peer.ABCDE.usd.9.`
and the auth token, e.g. '9C_o6JxhgZUX5FBJ-2jlyybtb_zGrDFlzzSdGA5WEXg'
# the way to calculate the 'ABCDE' part is the first 5 characters of https://github.com/michielbdejong/ilp-node/blob/master/src/lib/keypair.js#L69-L72
# (the Base64 of the SHA256 of the scalar product of your private key and their public key, with input 'token').
# the way to calculate the auth token is the same, but with input 'authorization').
3. POST { Authorization: Bearer 9C_o6JxhgZUX5FBJ-2jlyybtb_zGrDFlzzSdGA5WEXg } https://red.ilpdemo.org/api/peers/rpc?method=get_limit&prefix=peer.ABCDE.usd.9.
10000000000
# the https://red.ilpdemo.org/api/peers/rpc comes from step 1, rel: "https://interledger.org/rel/peersRpcUri"
# because of the .usd.9. in the virtual prefix, these are nano-dollars, so 10 USD
4. POST { Authorization: Bearer 9C_o6JxhgZUX5FBJ-2jlyybtb_zGrDFlzzSdGA5WEXg } https://red.ilpdemo.org/api/peers/rpc?method=get_balance&prefix=peer.ABCDE.usd.9.
3000000000
# because of the .usd.9. in the virtual prefix, these are nano-dollars, so 3 USD
5. POST { Authorization: Bearer 9C_o6JxhgZUX5FBJ-2jlyybtb_zGrDFlzzSdGA5WEXg } https://red.ilpdemo.org/api/peers/rpc?method=send_message&prefix=peer.ABCDE.usd.9.
[
{
"ledger":"peer.fkYhM.usd.9.",
"from":"peer.fkYhM.usd.9.gqI9E_7v9XaUX95I51D6i8miDHl1Fx0Dd_WZRR9fcgI", # your public key
"to":"peer.fkYhM.usd.9.8Zq10b79NO7RGHgfrX4lCXPbhVXL3Gt63SVLRH-BvR0", # their public key
"data":{
"method":"broadcast_routes",
"data": {
"new_routes": [
{
"source_ledger": "peer.fkYhM.usd.9.",
"destination_ledger": "us.usd.nexus.",
"points":[
[3.012040120336898e-9,0],
[0.001010741924421146,0.0010026762264884013],
[100000000000000000,99202396801600000]
],
"min_message_window":15,
"paths": [
["peer.SUdMG.usd.9."],
["peer.eJ-cT.usd.9.","peer.SUdMG.usd.9."],
[]
],
"source_account":"peer.fkYhM.usd.9.gqI9E_7v9XaUX95I51D6i8miDHl1Fx0Dd_WZRR9fcgI"
}
],
"hold_down_time":45000,
"unreachable_through_me":[
]
}
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment