c-lightning Plugins 04: The listpayments Plugin

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

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:

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.

Note: This blog was originally posted at https://medium.com/p/a04c2427c31b

Core Lightning (previously c-lightning) is a lightweight, highly customizable and standard compliant implementation of the Lightning Network protocol.

© 2023 Core Lightning
All rights reserved.

Discussion Forum

The official Core Lightning forum is coming soon!

BuildonL2 Community

The official BuildOnL2 community lives at community.corelightning.org. Join us and build the future of bitcoin on lightning.

Mailing List

For general discussions about CLN implementation, use c-lightning@lists.ozlabs.org. For the Lightning Network, use lightning-dev@lists.linuxfoundation.org

Telegram

Community-driven telegram group where most of the node operators hang out. Go to https://t.me/lightningd to join.

Discord

Community-driven discord server where the devs flock together. Go to https://discord.gg/w27fMFESMN to join.

Internet Relay Chat

Don't hesitate to reach out to us on IRC at #lightning-dev @ libera.chat, #c-lightning @ libera.chat.