Add closedchannels RPC#2642
Conversation
|
Can you explain why you think this is useful? Please note that the API is strictly for managing your node and we don't want to end up maintaining too many unused APIs. Exotic use-cases / analysis should run directly on the DB (and ideally on the read-only replicated DB to avoid impacting the running node). |
First of all, it's going to make me as famous as Rusty Russell is (well, sorta :)) via Bitcoin Optech Newsletter: https://bitcoinops.org/en/newsletters/2023/04/05/#core-lightning-5967 Second, in addition to providing more control over the node to the users, it helps to retain the users' privacy. Eg.: every time I receive a "channel closed" notification on my Nostr alarm bot, the closed channel disappears from the list that returns the
What is so exotic about knowing what happened with my own money? It's an essential part of managing my node. As I'm a node op, I know that very well. The code and the data already exist. Just a few lines of code are needed to put them together. Also, it's not the first time you suggest to access the database directly. There are 2 problems though:
Although JSON format isn't documented either, one can use their natural (or artificial for some) intelligence to figure out the structure. I use Python for my small automation scripts. How should I write a script that tells if the channel force closed using this data? sqlite> select * from local_channels where is_closed=1 limit 1;
K? ????5?R??z? ?1 ?N?] ????||1|1681668108044||||1681668156943With this PR I can do channel = json.loads('{ closed channel JSON }')
if not channel['data']['mutualClosePublished']:
print("force closed") |
|
Fair enough! The list of closed channels is an always-growing list that will eventually be huge, so I think we shouldn't allow listing everything at once, this is too footgunny. What about adding pagination and making the |
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## master #2642 +/- ##
=======================================
Coverage 85.88% 85.88%
=======================================
Files 214 214
Lines 17591 17613 +22
Branches 728 738 +10
=======================================
+ Hits 15108 15127 +19
- Misses 2483 2486 +3
|
t-bast
left a comment
There was a problem hiding this comment.
Getting close, a few comments on the changes in the DB files, but otherwise looks good to me.
t-bast
left a comment
There was a problem hiding this comment.
LGTM, thanks for your patience 🙏
|
Congrats 😄 |
This release introduces a few API changes: - `audit` now accepts `--count` and `--skip` parameters to limit the number of retrieved items (#2474, #2487) - `sendtoroute` removes the `--trampolineNodes` argument and implicitly uses a single trampoline hop (#2480) - `sendtoroute` now accept `--maxFeeMsat` to specify an upper bound of fees (#2626) - `payinvoice` always returns the payment result when used with `--blocking`, even when using MPP (#2525) - `node` returns high-level information about a remote node (#2568) - `channel-created` is a new websocket event that is published when a channel's funding transaction has been broadcast (#2567) - `channel-opened` websocket event was updated to contain the final `channel_id` and be published when a channel is ready to process payments (#2567) - `getsentinfo` can now be used with `--offer` to list payments sent to a specific offer - `listreceivedpayments` lists payments received by your node (#2607) - `closedchannels` lists closed channels. It accepts `--count` and `--skip` parameters to limit the number of retrieved items as well (#2642) - `cpfpbumpfees` can be used to unblock chains of unconfirmed transactions by creating a child transaction that pays a high fee (#1783)
This PR allows to access the historic channel data without relying on third party services like LN explorers.