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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-01-30 16:54:18 +10:30 committed by Alex Myers
parent 9a591277f5
commit d8320f015f
3 changed files with 87 additions and 3 deletions

View file

@ -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: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:93309f8c45ea3aa153bfd8822f2748c1254812d41a408de39bacefa292e11374)
[comment]: # ( SHA256STAMP:dbb9286cf31dc82b33143d5274b1c4eecc75c5ba1dfc18bdf21b4baab585bd45)

View file

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

View file

@ -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')