c-lightning Plugins 04: The listpayments Plugin

An example of how to quickly create a simple alias for your lapps — it doesn’t have to be complicated

Blockstream
Blockstream Engineering Blog
2 min readNov 8, 2019

--

By Rusty Russell

Overview

  • Purpose: Quickly re-enable the listpayments command which was removed in c-lightning 0.7.3
  • Language: Python
  • Code: Twitter

The listpayments Plugin

Sometimes the c-lightning APIs have to change: either because we made a mistake in the initial API and it’s frequently misunderstood, or more commonly because it won’t fit with a new feature.

In v0.7.0, released in February 2019, we formally deprecated listpayments and replaced it with listpays(high-level) and listsendpay(low-level). This is anticipation of multi-part payments, where the same payment will be split at the low-level: listpays will only show it as a single payment to avoid breaking users.

We remove deprecated features after six months, so in v0.7.3 we finally removed listpayments and sure enough, Spark Wallet broke. I only noticed this a week before release; Shesek rushed to release an update which (among other things) would fix this issue.

There’s a Plugin for That

I was in transit on the way to the Lightning Conference, and wondered what the minimal fix for this was. Sure enough, c-lightning plugins to the rescue!

The solution was short enough to fit into a single tweet:

“listpayments” un-deprecated!

Technical Details

If you save this file as “listpayments.py” in your ~/.lightning/plugins/ directory, chmod a+x it then type lightning-cli plugins rescan your c-lightning node will regain the ability to run listpayments, and make older Spark Wallet versions happy.

A few hours later, Spark Wallet v0.2.9 was released, making my plugin obsolete. But it was a fun exercise!

Get Started

You can do similar things to create your own aliases. A user asked me if there was a way to change the default settings for the invoice command: not yet, but you can certainly create your own myinvoice command by editing the plugin above, and have it call invoice with modified arguments!

To learn more about developing powerful plugins on c-lightning check out our beginners guide, or come chat with us on IRC (#c-lightning on Freenode).

This was the first showcase in a series on c-lightning plugins. For a regularly updated list of available articles, head to our introduction to c-lightning plugins.

--

--

Blockstream
Blockstream Engineering Blog

Blockstream is the global leader in Bitcoin & blockchain technology, making financial markets more efficient by reducing reliance on trust.