Commit Graph

13 Commits

Author SHA1 Message Date
ShahanaFarooqui f60882feaf tests/runes: per restriction test cases 2023-09-21 13:31:34 +09:30
ShahanaFarooqui d745323f74 lightning/runes: added last_used in showrunes
Changelog-Added: JSON-RPC: `showrunes` new field `last_used`
2023-09-21 13:31:34 +09:30
Rusty Russell 785fe973a6 runes: ensure that uniqueid is a valid number.
It always is for runes we create, but in theory you can take our secret key
and make our own runes with your own tools.

(We correctly refuse runes without uniqueids if they're *not* ours
anyway: uniqueid is only used for our own runes).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-12 15:19:02 +09:30
Rusty Russell ecb09778db lightningd: refuse to create rune with empty fields.
These look like uniqueids, and so can confuse us (I discovered this by
making a typo in a test!)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-12 15:19:02 +09:30
Rusty Russell bb38f83b88 checkrune: make nodeid and method optional.
nodeid is only useful when we know the peer we're talking to (e.g. commando).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
No-schema-diff-check: We're simply making optional, not deprecating!
2023-09-12 15:19:02 +09:30
Rusty Russell b88583e346 db: migrate old runes table to fix up id fields.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-31 05:33:15 +09:30
Rusty Russell 2de304314a runes: insert rune with correct id field.
"id" is a magic name, so it was being populated by sqlite3
automatically, starting at 0.  Fortunately, we only fetched by id in
one place: to indicate the `stored` flag when asked about an explicit
rune in `showrunes`.

Reported-by: @ShahanaFarooqui
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSON-RPC: `showrunes` on a specific rune would always say `stored`: false.
2023-08-31 05:33:15 +09:30
Rusty Russell 7429b1e7e1 pytest: test to show that we got db ids incorrect.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-31 05:33:15 +09:30
Rusty Russell 11b5f31034 lightningd: clean up commando rune_counter from datastore on migration.
Pointed out by @ShahanaFarooqui, we leave a single unused entry in the datastore,
so we should clean that up too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-25 14:47:12 +09:30
Rusty Russell 925f9fcce5 lightningd: migrate (and delete) old commando blacklists.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-25 14:47:12 +09:30
Rusty Russell dccbccf8f2 lightningd: migrate (and delete) old commando runes.
If they have invalid runes, we bail, but if they have runes which used
a different master secret (old commando.py allowed you to override
secret), we just complain and delete them.

Note that this requires more mocks in wallet/test/run-db.c...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-25 14:47:12 +09:30
Shahana Farooqui 49fdc0df99 runes: Renamed `listrunes` to `showrunes` 2023-07-25 11:07:43 +09:30
Rusty Russell 77d08d13a2 pytest: test for runes, based on commando tests.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-07-21 16:44:22 +09:30