Skip to content

sparko v2.1

Compare
Choose a tag to compare
@fiatjaf fiatjaf released this 29 May 18:56
· 33 commits to master since this release

sparko v2.1 has support for Range headers that allow you to only get a slice of long lists of things returned by listinvoices, listsendpays, listforwards any anything else.

Just specify the header as Range: <jsonattrname>=<from>-<to> to get response[jsonattrname].slice(from, to) or Range: <jsonattrname>=-<from> to get response[jsonattrname].slice(-from).

A practical example. Imagine I want to get my last forwarded payment. If I call listforwards I'll have to download thousands of forwards and then only filter one locally. With a Range header I can do:

~> curl -k https://etleneum.com/rpc -H 'X-Access: secretkey' -d '{"method": "listforwards"}' -H 'Range: forwards=-1'
{
  "forwards": [
    {
      "payment_hash": "ad36317a3163e23f5b6d5c2376fddf908724bd449b841298d8b6c4ca6f93b91c",
      "in_channel": "626617x2512x1",
      "out_channel": "623255x1489x0",
      "in_msatoshi": 12860001,
      "in_msat": "12860001msat",
      "out_msatoshi": 12860000,
      "out_msat": "12860000msat",
      "fee": 1,
      "fee_msat": "1msat",
      "status": "local_failed",
      "failcode": 16392,
      "failreason": "WIRE_PERMANENT_CHANNEL_FAILURE",
      "received_time": 1590002068.897
    }
  ]
}