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
Nov 8 · 2 min read

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.

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).


Blockstream Engineering Blog

The latest developments in cutting-edge Bitcoin technology from Blockstream.

Blockstream

Written by

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

Blockstream Engineering Blog

The latest developments in cutting-edge Bitcoin technology from Blockstream.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade