From d8320f015fc6f6b474941816873d91bada62fba9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 30 Jan 2023 16:54:18 +1030 Subject: [PATCH] plugins/sql: add bkpr-listaccountevents and bkpr-listincome support. This *would* be a 1-line change (add it to Makefile) except that we previously assumed a "list" prefix on commands. These use the default refreshing, but they could be done better using the time-range parameters. Suggested-by: @niftynei Signed-off-by: Rusty Russell --- doc/lightning-sql.7.md | 32 +++++++++++++++++++++++- plugins/Makefile | 2 +- tests/test_plugin.py | 56 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 87 insertions(+), 3 deletions(-) diff --git a/doc/lightning-sql.7.md b/doc/lightning-sql.7.md index 0b5c7d50a..f682a00e7 100644 --- a/doc/lightning-sql.7.md +++ b/doc/lightning-sql.7.md @@ -79,6 +79,36 @@ TABLES ------ [comment]: # (GENERATE-DOC-START) The following tables are currently supported: +- `bkpr_accountevents` (see lightning-bkpr-listaccountevents(7)) + - `account` (type `string`, sqltype `TEXT`) + - `type` (type `string`, sqltype `TEXT`) + - `tag` (type `string`, sqltype `TEXT`) + - `credit_msat` (type `msat`, sqltype `INTEGER`) + - `debit_msat` (type `msat`, sqltype `INTEGER`) + - `currency` (type `string`, sqltype `TEXT`) + - `timestamp` (type `u32`, sqltype `INTEGER`) + - `outpoint` (type `string`, sqltype `TEXT`) + - `blockheight` (type `u32`, sqltype `INTEGER`) + - `origin` (type `string`, sqltype `TEXT`) + - `payment_id` (type `hex`, sqltype `BLOB`) + - `txid` (type `txid`, sqltype `BLOB`) + - `description` (type `string`, sqltype `TEXT`) + - `fees_msat` (type `msat`, sqltype `INTEGER`) + - `is_rebalance` (type `boolean`, sqltype `INTEGER`) + - `part_id` (type `u32`, sqltype `INTEGER`) + +- `bkpr_income` (see lightning-bkpr-listincome(7)) + - `account` (type `string`, sqltype `TEXT`) + - `tag` (type `string`, sqltype `TEXT`) + - `credit_msat` (type `msat`, sqltype `INTEGER`) + - `debit_msat` (type `msat`, sqltype `INTEGER`) + - `currency` (type `string`, sqltype `TEXT`) + - `timestamp` (type `u32`, sqltype `INTEGER`) + - `description` (type `string`, sqltype `TEXT`) + - `outpoint` (type `string`, sqltype `TEXT`) + - `txid` (type `txid`, sqltype `BLOB`) + - `payment_id` (type `hex`, sqltype `BLOB`) + - `channels` indexed by `short_channel_id` (see lightning-listchannels(7)) - `source` (type `pubkey`, sqltype `BLOB`) - `destination` (type `pubkey`, sqltype `BLOB`) @@ -334,4 +364,4 @@ RESOURCES --------- Main web site: -[comment]: # ( SHA256STAMP:93309f8c45ea3aa153bfd8822f2748c1254812d41a408de39bacefa292e11374) +[comment]: # ( SHA256STAMP:dbb9286cf31dc82b33143d5274b1c4eecc75c5ba1dfc18bdf21b4baab585bd45) diff --git a/plugins/Makefile b/plugins/Makefile index fad17d248..e02db26d3 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -205,7 +205,7 @@ plugins/fetchinvoice: $(PLUGIN_FETCHINVOICE_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_CO plugins/funder: bitcoin/psbt.o common/psbt_open.o $(PLUGIN_FUNDER_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) # This covers all the low-level list RPCs which return simple arrays -SQL_LISTRPCS := listchannels listforwards listhtlcs listinvoices listnodes listoffers listpeers listpeerchannels listtransactions listsendpays +SQL_LISTRPCS := listchannels listforwards listhtlcs listinvoices listnodes listoffers listpeers listpeerchannels listtransactions listsendpays bkpr-listaccountevents bkpr-listincome SQL_LISTRPCS_SCHEMAS := $(foreach l,$(SQL_LISTRPCS),doc/schemas/$l.schema.json) # We squeeze: # descriptions (we don't need) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index b163f560f..6a6b43a2c 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -3727,7 +3727,61 @@ def test_sql(node_factory, bitcoind): {'name': 'type', 'type': 'string'}, {'name': 'channel', - 'type': 'short_channel_id'}]}} + 'type': 'short_channel_id'}]}, + 'bkpr_accountevents': { + 'columns': [{'name': 'account', + 'type': 'string'}, + {'name': 'type', + 'type': 'string'}, + {'name': 'tag', + 'type': 'string'}, + {'name': 'credit_msat', + 'type': 'msat'}, + {'name': 'debit_msat', + 'type': 'msat'}, + {'name': 'currency', + 'type': 'string'}, + {'name': 'timestamp', + 'type': 'u32'}, + {'name': 'outpoint', + 'type': 'string'}, + {'name': 'blockheight', + 'type': 'u32'}, + {'name': 'origin', + 'type': 'string'}, + {'name': 'payment_id', + 'type': 'hex'}, + {'name': 'txid', + 'type': 'txid'}, + {'name': 'description', + 'type': 'string'}, + {'name': 'fees_msat', + 'type': 'msat'}, + {'name': 'is_rebalance', + 'type': 'boolean'}, + {'name': 'part_id', + 'type': 'u32'}]}, + 'bkpr_income': { + 'columns': [{'name': 'account', + 'type': 'string'}, + {'name': 'tag', + 'type': 'string'}, + {'name': 'credit_msat', + 'type': 'msat'}, + {'name': 'debit_msat', + 'type': 'msat'}, + {'name': 'currency', + 'type': 'string'}, + {'name': 'timestamp', + 'type': 'u32'}, + {'name': 'description', + 'type': 'string'}, + {'name': 'outpoint', + 'type': 'string'}, + {'name': 'txid', + 'type': 'txid'}, + {'name': 'payment_id', + 'type': 'hex'}]}} # Very rough checks of other list commands (make sure l2 has one of each) l2.rpc.offer(1, 'desc')