Skip to content

Latest commit

 

History

History
259 lines (240 loc) · 5.14 KB

lightning_api.md

File metadata and controls

259 lines (240 loc) · 5.14 KB

Lightning UI - Lightning API


get info

  • path: /api/lightning/getinfo
  • request: GET
  • response: JSON
{
   "id":"036cc6f4aa007f10964993aba1b8535e20e36f6d7c455ca93452f66adbf28e8182",
   "port":9911,
   "network":"regtest",
   "version":"v0.5.2-2016-11-21-901-ge418f2a",
   "blockheight":500
}

list configs

  • path: /api/lightning/listconfigs
  • request: GET
  • response: JSON
{
  "# version": "v0.5.2-2016-11-21-2611-gccfd7d61",
  "port": 9735,
  "rgb": "e52b50",
  
  "dev-broadcast-interval": 60000
}

list configs config

  • path: /api/lightning/listconfigs/{config}
  • request: GET
  • response: JSON
{
  "rgb": "e52b50",
}

list peers

  • path: /api/lightning/listpeers
  • request: GET
  • response: JSON
{
   "peers":[
      {
         "unique_id":0,
         "state":"CHANNELD_NORMAL",
         "netaddr":"::1:9912",
         "peerid":"03b01a87d7922bf4d8017644ae75d0bcbf238e11ee31f6d1a5a6ddb014d33197b2",
         "connected":true,
         "owner":"lightning_channeld",
         "channel":"523:2:0",
         "msatoshi_to_us":100000000,
         "msatoshi_total":100000000
      }
   ]
}

list nodes

  • path: /api/lightning/listnodes
  • request: GET
  • response: JSON
{
   "nodes":[
      {
         "nodeid":"03a1c56b699077c2596c86ecc529891a7f188a599774cf91594654fc28c5554045",
         "addresses":[

         ]
      },
      {
         "nodeid":"03b01a87d7922bf4d8017644ae75d0bcbf238e11ee31f6d1a5a6ddb014d33197b2",
         "addresses":[

         ]
      }
   ]
}

list channels

  • path: /api/lightning/listchannels
  • request: GET
  • response: JSON
{
   "channels":[
      {
         "source":"03a1c56b699077c2596c86ecc529891a7f188a599774cf91594654fc28c5554045",
         "destination":"03b01a87d7922bf4d8017644ae75d0bcbf238e11ee31f6d1a5a6ddb014d33197b2",
         "short_id":"512:2:0/0",
         "flags":0,
         "active":true,
         "last_update":1505898540,
         "base_fee_millisatoshi":1,
         "fee_per_millionth":10,
         "delay":36
      }
   ]
}

generate new address

  • path: /api/lightning/getnewaddress
  • request: GET
  • response: JSON
{
   "address":"2NCxz1cAcg9fCgF9KW9m8usXgZKjVHfxqfh"
}

open channel

  • path: /api/lightning/openchannel
  • request: POST
  • params: {"ip":"localhost","port":"8899","nodeid":"","amount":100000}
  • response: JSON
{}

add funds

  • path: /api/lightning/addfunds
  • request: POST
  • params: {"rawtx":""}
  • response: JSON
{
   "outputs":1,
   "satoshis":100000000
}

fund channel

  • path: /api/lightning/fundchannel
  • request: POST
  • params: {"nodeid":"", "amount": 1000}
  • response: JSON
{}

connect

  • path: /api/lightning/connect
  • request: POST
  • params: {"nodeid":"", "ip": "127.0.0.1", "port":10000}
  • response: JSON
{}

close channel

  • path: /api/lightning/closechannel
  • request: POST
  • params: {"nodeid":""}
  • response: JSON
{}

get route

  • path: /api/lightning/getroute
  • request: POST
  • params: {"nodeid":"nodeid","amount":"1000","riskFactor":"1"}
  • note: amount is in millisatoshi.
  • response: JSON
{
   "route":[
      {
         "id":"03b01a87d7922bf4d8017644ae75d0bcbf238e11ee31f6d1a5a6ddb014d33197b2",
         "channel":"512:2:0",
         "msatoshi":1000,
         "delay":36
      }
   ]
}

create invoice

  • path: /api/lightning/createinvoice
  • request: POST
  • params: {"amount":"1000","label":"invoice name"}
  • note: amount is in millisatoshi.
  • response: JSON
{
    "rhash": "06W9WTfJDpkHwXt9JQYSoPB2JYBrxngJ2Mup2W9WTfJDpkHwXt9JQYSod18"
}

list invoices

  • path: /api/lightning/listinvoices
  • request: GET
  • response: JSON
[
   {
      "label":"label",
      "rhash":"f19b481b91b62da05298d7b1bc3beb8898aa7213fb8de6d31627e98d3d2011fc",
      "msatoshi":1000,
      "complete":false
   }
]

delete invoice

  • path: /api/lightning/invoice/{label}
  • request: DELETE
  • params: {"amount":1000,"address":""}
  • response: JSON
{}

withdraw

  • path: /api/lightning/withdraw
  • request: POST
  • params: {"amount":1000,"address":""}
  • response: JSON
{
  "tx":"...",
  "txid":"..."
}

send payment

  • path: /api/lightning/sendpay
  • request: POST
  • params: {"route":[...],"hash":""}
  • response: JSON
{
   "preimage":"aeaf224f68fbe05f011dbe49d8db1365b0caf3baca09333f62fa10f36b0bc09d"
}