Commit Graph

3237 Commits

Author SHA1 Message Date
Rusty Russell
61cc3aa887 pytest: catch more broken messages in test_important_plugins.
This can happen, so allow them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-08 21:54:50 -05:00
Rusty Russell
a481dbcddd pytest: attempt to reproduce hsm signing failure.
This didn't trigger the bug, but worth explicitly testing: we spend a
to-remote output from a previous unilateral close, to spend an anchor
on a current unilateral close.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-07 16:41:47 -05:00
Rusty Russell
153567d699 pytest: test that the preapprove hooks get called by check.
We add a dev flag so we can decline them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-06 20:51:19 -05:00
Rusty Russell
c7339ea310 pytest: test various preapprove scenarios.
We wire through --dev options into the hsmd, and test preapprove accept and deby
with both old and new protocols.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-06 20:51:19 -05:00
Rusty Russell
e99f061909 setconfig: more thorough check for internal config options.
Now we can check that the setconfig would actually parse.  We do this
by handing NULL to the calback to indicate it's a test, which may not
work in general but works for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: `check` `setconfig` now checks that the new config setting would be valid.
2024-05-06 20:51:19 -05:00
Rusty Russell
dcbdb85497 libplugin: allow check setconfig on all dynamic options.
We need to pass through setconfig in check mode, then we need to have libplugin
add (and use!) a `check_only` parameter to all option setting.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `check` `setconfig` on plugin options can now check the config value would be accepted.
2024-05-06 20:51:19 -05:00
Rusty Russell
03db143216 pytest: test the check command in libplugin.
For extra points, we use an async command which calls out to listdatastore
before returning.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-06 20:51:19 -05:00
Rusty Russell
168ecb8979 pyln-client: pass through level parameter on command notifications.
Without this, everything came out as level INFO.

Changelog-Fixed: pyln-client: Fix Plugin.notify_message() not to ignore `level` parameter.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-04 11:36:23 -05:00
Erik De Smedt
f1dc64b802 cln_plugin: Support wildcard subscriptions
Adapts `cln_plugin` to make it support wildcard `*`-subscriptions.
2024-04-30 15:24:00 -05:00
Erik De Smedt
27eaa1ef44 Repro: cln-plugin cannot subscribe to wildcard "*"
This test reproduces a bug in the `cln-plugin`-crate.
Core Lightning supports a wildcard `*` that plugins can use to
subscribe to all notifications.

However, `cln-plugin` does not support this case.
It allows the developer to subscribe `*`.
But the plug-in crashes when the first notification is received
2024-04-30 15:24:00 -05:00
Alex Myers
ff7efec723 pay: ignore uncommited channels in listpeerchannels output
Uncommited channels are missing several fields which would normally be
populated by an active channel.  This simply skips them for the purposes
of finding a route.  The particular culprit was:
{
  "peer_id": "038cd9f3679d5b39bb2105978467918d549572de472f07dd729e37c7a6377d41d5",
  "peer_connected": true,
  "state": "OPENINGD",
  "owner": "lightning_openingd",
  "opener": "local",
  "to_us_msat": 8317559000,
  "total_msat": 8317559000,
  "features": [
    "option_static_remotekey",
    "option_anchors_zero_fee_htlc_tx"
  ]
}

Fixes #7197 - SEGV in direct_pay_listpeerchannels when field private missing

Changelog-Fixed: Fixed crash in pay plugin caused by parsing uncommitted dual open channels
2024-04-30 14:52:22 -05:00
Alex Myers
56d5d45448 pytest: test pay during channel open
Notably this parses the listpeerchannels output while the state is
still uncommitted, i.e., state = OPENINGD.
2024-04-30 14:52:22 -05:00
Peter Neuroth
9ae5c04583 bcli: change iteration order on peerlist
It is simpler to just iterate through the peerlist backwards.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2024-04-24 05:50:54 +09:30
Peter Neuroth
6e3ea36976 tests: add tests for getblockfrompeer
Changelog-Changed: Plugins: bcli: Add a path that tries to fetch blocks
from a peer if we can not find them locally.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2024-04-24 05:50:54 +09:30
ShahanaFarooqui
6b837ec024 plugin/wss-proxy: Testing WSS connection 2024-04-22 09:12:09 +09:30
Rusty Russell
901342b50d pyln-testing: require explicit pattern for BROKEN messages.
Rather than `allow_broken_log`, we have `broken_log` which is a regex
indicating what log lines are expected.  This tightens our tests
significantly, as it will catch *unexpected* brokenness.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-04-20 16:36:57 +09:30
daywalker90
507c2de9c1 newaddr: various fixes for msggen and docs
Changelog-None
2024-04-17 14:47:52 +02:00
Rusty Russell
c4edec8e22 plugins/clnrest: simple wrapper to handle missing python3.
Apparently NixOS didn't have Python (sometimes!) so let's not assume.
By reusing the JSON "parsing" code from cowsay, we can self-disable
to handle this case.

Reported-by: Shahana Farooqui <shahana.farooqui@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Plugins: `clnrest` now correctly self-disables if Python not present at all.
2024-04-12 10:32:32 +02:00
Jesse de Wit
09d6bb9aed tests: add test_pay_avoid_low_fee_chan
Tests whether we're able to route around a low-fee channel in the graph. We
should be able to find the more expensive route if the cheaper route is
depleted.
2024-04-04 12:49:57 +10:30
Lagrang3
22a70339de renepay: limit arc capacities by htlc_max
In the Min. Cost Flow solver we put a constraint on arcs capacities,
such that the total flow that can be allocated through a channel does
not exceed htlc_max. This solves two previous problem of the htlc_max
constraint at the MCF level.
2024-04-03 10:07:13 +10:30
Lagrang3
56ac5eebef add more fields to gossmods_listpeerchannels
Add spendable/receivable and is_local fields to the callback function
used in gossmods_from_listpeerchannels. This allows to do more fine
grained use of the listpeerchannels call.
The first use case is renepay, for which we need to ignore the htlc_max
of the local channels only.
2024-04-03 10:07:13 +10:30
Rusty Russell
06136ed3e3 fundchannel_start: delay, don't refuse, if node not synced.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-04-01 13:20:53 +02:00
Rusty Russell
f3cedb9aa7 pytest: rename lightning nodes to reduce confusion.
I was trying to debug test_zeroconf_open and getting very confused.
The reason: l0 is lightning-1, l1 is lightning-2, etc!  And there are
two other tests where an l0 has been added at the front: fix them all
to avoid future confusion!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-04-01 13:20:53 +02:00
Rusty Russell
b9b86ca526 openchannel: delay, don't refuse, if node not synced.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-04-01 13:20:53 +02:00
Rusty Russell
ef45eacc95 lightningd: allow *outgoing* HTLCs before full bitcoind sync.
This allows for faster startup for Greenlight.  We still require full sync
before *incoming* htlcs, and onchain operations.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-04-01 13:20:53 +02:00
Rusty Russell
0d7d3f5c00 lightningd: revert f450dfeb55 to allow non-gossip_query nodes.
LDK doesn't set this feature if they don't have any useful gossip (mobile nodes)
and it was agreed at the spec meeting that we should repurpose this feature
to mean "I don't have any useful gossip".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-31 12:32:05 +02:00
Rusty Russell
7fe22b29e7 pytest: test parsing of bolt12 invoice strings in runes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-27 16:09:23 +10:30
Rusty Russell
a3332dcc34 runes: handle lightning: prefix in invoice arguments
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-27 16:09:23 +10:30
Rusty Russell
8114b3b437 pytest: add test for rune pinv bolt11 parsing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-27 16:09:23 +10:30
Rusty Russell
7e0e39460b lightningd: remove delexpiredinvoice
Changelog-Removed: JSON-RPC: `delexpiredinvoice` (deprecated v22.11, EOL v24.02)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-25 15:02:35 +10:30
Rusty Russell
6a2d949250 lightningd: remove failure_code from invoice hook and htlc_accepted hook.
These were deprecated in v22.08 (invoice hook) and v0.8 (htlc_accepted hook), and
marked EOL in v23.02.

*PLEASE* complain if this breaks things for you: it's kind of a test canary of
the deprecation system!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: Plugins: `invoice_payment` and `htlc_accepted` hook `failure_code` response (derepcated v22.08 and v0.8, EOL v23.02)
2024-03-25 15:02:35 +10:30
Rusty Russell
037eb08fd6 Makefile: update CLN_NEXT_VERSION so deprecations tick over.
Indeed, we now need to adjust our tests to use --i-promise-to-fix-broken-api-user
for the specific APIs past end-of-life.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-25 15:02:35 +10:30
Rusty Russell
ed4af14d4c lightningd: fix name for deprecated APIs, and fix crash with listconfigs when --i-promise-to-fix-broken-api-user is used.
We were duplicating the command name (e.g. "autocleaninvoice.autocleaninvoice"), and also not
handling listconfigs if they specified the (currently unused!) i-promise-to-fix-broken-api-user
option, which we are going to use next patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-25 15:02:35 +10:30
Rusty Russell
42207eb239 plugins/spender: fix multifundchannel all on more than 1 channel.
We tried to put *everything* into the "all" output, which didn't work
if there were other outputs!

Fixes: https://github.com/ElementsProject/lightning/issues/6664
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSON-RPC: `multifundchannel` with `all` as an amount works as expected.
2024-03-21 19:52:56 +10:30
daywalker90
59b6cf8253 tests: multifundchannel and "all" amount 2024-03-21 19:52:56 +10:30
Rusty Russell
9450d46db1 bitcoin/short_channel_id: pass by copy everywhere.
It's a u64, we should pass by copy.  This is a big sweeping change,
but mainly mechanical (change one, compile, fix breakage, repeat).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-20 13:51:48 +10:30
Rusty Russell
e0e879c003 common: remove type_to_string files altogther.
This means including <common/utils.h> where it was indirectly included.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-20 13:51:48 +10:30
Rusty Russell
4816550b0f lightningd: check rune parameter names with and without punctuation.
Changelog-Changed: runes: named parameters (e.g. `pnameamountmsat`) no longer need to remove underscores (i.e. `pnameamount_msat` now works as expected).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-20 11:18:36 +10:30
Rusty Russell
a880146e81 lightningd: name error messages a bit more readable.
Rather than speaking 'rune' we should speak english in error messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reported-by: @ShahanaFarooqui
2024-03-20 11:18:36 +10:30
Rusty Russell
ba9daa468d ccan: update to get rune error message fix.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-20 11:18:36 +10:30
Rusty Russell
1fedae4f83 pytest: make runes amount test more specific.
This reveals an inadequacy in our rune error reporting:
we complain a missing parameter is "not an integer field" instead
of "not present":

```
        # Rune requires amount_msat < 10,000!
>       with pytest.raises(RpcError, match='Not permitted: pnameamountmsat is not present') as exc_info:
E       AssertionError: Regex pattern did not match.
E        Regex: 'Not permitted: pnameamountmsat is not present'
E        Input: "RPC call failed: method: checkrune, payload: {'nodeid': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518', 'rune': 'b3hXuEM7Pqzk-C7HUw83xzvHOV7fmuGaWjdo-wHdfg89MCZtZXRob2Q9cGF5JnBuYW1lYW1vdW50bXNhdDwxMDAwMA==', 'method': 'pay', 'params': {'bolt11': 'lnbcrt123n1pj7flqdsp5ndqgxpwk2hf50gzm0d4ssgjnd90cwkrc8udh7lfr5x583jms7yqspp5kn5stlnkv70celgw4vmdva9m7a57drd2403vnx4whq2p5nawkh3sdq5v3jhxcmjd9c8g6t0dccsxqyjw5qcqp99qxpqysgqhrgp7wp640gyujxk0mz4l6e6dxmqp7fz8pnnpnnqjfxg2scvuzfpwlxrj332u72p5g709eqr8rwaueruce84h0qmh6kc5c2zxgg9q4qps4cu8k'}}, error: {'code': 1502, 'message': 'Not permitted: pnameamountmsat is not an integer field'}"
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-20 11:18:36 +10:30
Rusty Russell
4a9b9b8b29 pay: add partial_msat option to make partial payment.
a.k.a. "Pay with a friend!".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `pay` has a new parameter `partial_msat` to only pay part of an invoice (someone else presumably will pay the rest at the same time!)
Suggested-by: Calle
2024-03-20 10:58:28 +10:30
ShahanaFarooqui
f72b0fdabd docs: Updates script and fixed test to generate lightning-sql
- Updated doc/Makefile for generating schemas/lightning-sql.json
    - Read the lightning-sql template from schemas/lightning-sql-template.json
    - Generate sql tables data and merge it with json object read from above template
    - Save final merged object in schemas/lightning-sql.json
- Updated doc/Makefile to auto generate lightning-sql.7.md and lightning-sql.7
- Deleted schemas/lightning-sql.json and adding it into .gitignore
- Added lightning-sql specific titles in the fromschema.py script
- Fixed test_sql by changing the sequence for listpeerchannels `reestablished` field
- Ignoring lightning-sql.json for msggen schema.json because it is auto generated by sql plugin and lightning-sql-template.json.
2024-03-19 14:58:59 +10:30
Rusty Russell
fdfffdc232 common: add routing test using real data which crashes.
The amount is set not to crash by default, but run
"common/test/run-route-infloop 8388607" and you'll see a crash.

Sorry about the 7MB blob, but this testing was quite revealing and
I consider it worth adding.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-07 14:09:14 +01:00
Christian Decker
052542ea28 pytest: Stabilize the test_recover_plugin test 2024-02-20 17:59:06 +01:00
Aditya Sharma
cdb0001ce6 tests/test_misc.py: Add test_recover_plugin to check if the funds are being recovered when we lose some state and enter recover mode. 2024-02-16 22:17:46 +01:00
Rusty Russell
eb6e6bd373 lightningd: clean up close logic, fix bug where we can't override destination.
Watchtowers changed the code so that we *always* have a channel->shutdown_scriptpubkey[LOCAL]
(see new_channel()).  The previous code had several problems:

1. It tested this for NULL, unnecessarily.
2. It allowed overriding if it was a default, *even* if we were already using it.
3. If the peer opened without option_shutdown_anysegwit, but upgraded before we closed,
   we would not recognize the default.
4. It set the final scriptpubkey (and other things!) even if the command failed.

Changelog-Fixed: JSON-RPC: `close` with `destination` works even if prior `destination` was rejected.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 15:02:38 +01:00
Rusty Russell
df44431f8c common: add tal_arr_eq helper.
We do `memeq(a, tal_bytelen(a), b, tal_bytelen(b))` remarkably often...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 15:02:38 +01:00
Rusty Russell
c02a278669 pytest: add test for issue #7014
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-16 15:02:38 +01:00
Lagrang3
c916066f85 renepay: update the gossmap after addgossip
Whenever there is a payment failure that requires gossip update, for
example changing the fee rates of remote channels, we call addgossip.
For renepay to consider this changes in the coming payment attempts, it
must update gossmap.
2024-02-16 14:51:14 +01:00
Lagrang3
e39e712eed autoformat test_renepay.py 2024-02-16 14:51:14 +01:00
Lagrang3
7e0d6d396e renepay bug fix: list previous sendpays
- previous pending sendpays must add up so that the plugin tries to pay
the rest of the amount,
- avoid groupid, partid collisions,
- add shadow fees if the option is set and the payment amount - total
  delivering = 0
- add a test,
- also fix a buggy shadow routing test
2024-02-16 14:51:14 +01:00
Christian Decker
abfe55e214 pyetst: Fix up a test checking fees after fee calc change 2024-02-13 15:47:48 +01:00
Rusty Russell
450d78ad67 gossipd: set dying flag on node_announcement when all channels are dying.
This avoids us gossiping about nodes which don't have live channels.

Interstingly, we previously tested that we *did* gossip such node
announcements, and now we fix that test.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-12 11:43:33 +01:00
niftynei
bc98cafe9e dual-fund: add require_confirmed_inputs to RBF flows
We now require peers to reaffirm their preference for
`require_confirmed_inputs` when executing an RBF.

Requested-By: @t-bast
2024-02-11 10:46:40 +01:00
Dusty Daemon
b8a2c396c7 splice: Add support for tx_abort to channeld
Add checking for and sending tx_abort to channeld.

When receiving it we first ACK it back, send a request to restart to lightningd, and then shutdown channeld.

We also must update the splice tests that relied on reconnect checks for splice warnings (as some are now tx_aborts instead).
2024-02-11 10:46:23 +01:00
Dusty Daemon
e102234950 dualopen: update test to handle ABORT
In he case of initiating an RBF, ABORT is used instead of ERROR.
2024-02-11 10:46:23 +01:00
Erik De Smedt
3f4306eea9 cln_plugin : Test default values for ConfigOptions 2024-02-08 15:37:44 +01:00
Rusty Russell
a005ec1e84 pytest: fix flake in test_htlc_in_timeout with anchors.
If we try to reuse the same UTXO for the HTLC as the anchor, it will clash.
One block later we can spend the anchor change, all good.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-08 06:32:01 +10:30
Rusty Russell
bbf6a89579 pytest: fix bad gossip flake in test_closing_specified_destination.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-08 06:32:01 +10:30
Rusty Russell
689e596036 options: make anchors enabled by default, ignore experimental-anchors.
We still want to test non-anchor channels, as we still support them, but
we've made it non-experimental.  To test non-anchor channels, we
use dev-force-features: -23.

Changelog-Added: Protocol: `option_anchors_zero_fee_htlc_tx` enabled, no longer experimental.
Changelog-Changed: Config: `experimental-anchors` now does nothing (it's enabled by default).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>


Header from folded patch 'fixup!_options__make_anchors_enabled_by_default,_ignore_experimental-anchors.patch':

fixup! options: make anchors enabled by default, ignore experimental-anchors.
2024-02-08 06:32:01 +10:30
Rusty Russell
0a2f03ac1e pytest: changed tests if we're using experimental-anchors.
This is in anticipation of changing the defaults for non-elements.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-08 06:32:01 +10:30
Rusty Russell
8c52efce37 funder: don't try to spend emergency_reserve
We might have (or be getting!) anchor channels, so keep this aside when funding.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-08 06:32:01 +10:30
Christian Decker
99aa1e827e msggen: Fix the offer schemas
I had to do some trickery with the interchangeability between string
and int, but now it works as expected.
2024-02-07 20:38:29 +01:00
Alex Myers
140e33b13a pytest: add tests for pip and poetry installed virtual envs
Also test checkout of a git tag on installation.
2024-02-07 13:24:34 +01:00
Alex Myers
90a20ff6e3 reckless: create virtual environments for python plugins
This uses pip to install to a venv when the dependencies are specified
with requirements.txt and poetry when it's present on the system and the
plugin has a pyproject.toml.

The directory structure will be:
reckless/
    source/                (original plugin code here)
        plugin_entrypoint  (original entrypoint)
    plugin_name            (symlink or wrapper to activate venv)
    .metadata              (installation information)
    .venv/                 (python virtual environment)

The wrapper matches the naming of the original plugin entrypoint. The
shebang is modified to use the virtual environment's python binary,
then the original plugin is imported as a module and executed as though
it was run directly.

Changelog-Changed: reckless installs python plugins in virtual environments
2024-02-07 13:24:34 +01:00
Alex Myers
c043bf2255 reckless: properly remove entry from reckless sources
Fixes a bug introduced in 6163138420 which
avoided gratuitous rewrites of the lightningd config
2024-02-07 13:24:34 +01:00
Rusty Russell
f56b9e9b73 lightningd: deprecate @-prefix hack for offer recurrence_base.
Christian points out that this makes the type harder, and it's just awkward.

Changelog-EXPERIMENTAL: JSON-RPC: Deprecated `offer` parameter `recurrence_base` with `@` prefix: use `recurrence_start_any_period`.
Changelog-EXPERIMENTAL: JSON-RPC: Added `offer` parameter `recurrence_start_any_period`.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-07 09:21:00 +10:30
Matt Morehouse
25b40d2ce8 fuzz: use explicit fetching for digest algorithms
For better performance it is recommended to use the modern OpenSSL
EVP_MD_fetch API to load digest algorithms (i.e. explicit fetching),
instead of the older implicit fetching API.

As a side effect, using this API seems to avoid memory leaks with some
versions of OpenSSL.
2024-02-04 17:16:01 +01:00
Rusty Russell
28c4a52aa6 pytest: another bad gossip flake
This time in renepay tests.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell
f0ccfeaf64 pytest: fix YA gossip flake.
We can get bad gossip if a node processes a gossip message after we've closed:

```
_________________________________________ ERROR at teardown of test_closing_specified_destination _________________________________________
...
>           raise ValueError(str(errors))
E           ValueError:
E           Node errors:
E            - lightningd-1: had warning messages
E            - lightningd-4: had bad gossip messages
E           Global errors:
...
lightningd-1 2024-02-03T00:29:02.299Z INFO    0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199-connectd: Received WIRE_WARNING: WARNING: channel_announcement: no unspent txout 105x1x0
lightningd-1 2024-02-03T00:29:02.300Z DEBUG   0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199-connectd: peer_in WIRE_WARNING
lightningd-1 2024-02-03T00:29:02.300Z INFO    0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199-connectd: Received WIRE_WARNING: WARNING: channel_announcement: no unspent txout 103x1x0
lightningd-1 2024-02-03T00:29:02.339Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-connectd: peer_in WIRE_WARNING
lightningd-1 2024-02-03T00:29:02.339Z INFO    035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-connectd: Received WIRE_WARNING: WARNING: channel_announcement: no unspent txout 103x1x0
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell
6a02cfccd7 gossipd: simplify gossip store API.
Instead of "new" and "load", we don't really need to "load" anything,
so do everything in gossip_store_new.

Have it do the compaction/rewrite, and collect the dying records
2024-02-04 09:24:44 +10:30
Rusty Russell
c286241ab3 gossipd: switch over to using gossmap_manage, not routing.c.
The gossip_store_load is now basically a noop, since gossmap
does that.

gossipd removes a pile of routines dealing with messages,
in favor of just handing them to gossmap_manage.

The stub gossmap_manage constructor is removed entirely.

We simplified behaviour around channel_announcements with
no channel update: we now add them to the store, and go
back to fix the timestamp later.  This changes a test,
which explicitly tests for the old behaviour.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell
07cd4a809b gossipd: remove spam handling.
We weakened this progressively over time, and gossip v1.5 makes spam
impossible by protocol, so we can wait until then.

Removing this code simplifies things a great deal!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: Protocol: we no longer ratelimit gossip messages by channel, making our code far simpler.
2024-02-04 09:24:44 +10:30
Rusty Russell
e7ceffd565 gossipd: remove zombie handling.
We never enabled it, because we seemed to be eliminating valid
channels.  We discard zombie-marked records on loading.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell
7f5fe52320 gossipd: remove online gossip_store compaction.
It was an obscure dev command, as it never worked reliably.
It would be much easier to re-implement once this is done.

This turned out to reveal a tiny leak on
tests/test_gossip.py::test_gossip_store_load_amount_truncated where we
didn't immedately free chan_ann if it was dangling.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
evansmj
5544911387 Convert fee result into msats 2024-02-02 17:31:23 +01:00
evansmj
c90ca104ae Remove update_count from find_account_onchain_fees
update_count is just the count of the records for a tx.  To calculate onchain fees
for an account we must sum all credits vs debits.  We don't need to GROUP BY update_count
nor ORDER BY update_count since it is just a running index of updates to this tx.
2024-02-02 17:31:23 +01:00
evansmj
78ba4138d4 Remove grouping by update_count in finding onchain fees
Remove grouping by update_count which resulted in a crash due to bad arithmetic
caused by fee calculation returned rows not being consolidated.
Remove xfail.
2024-02-02 17:31:23 +01:00
evansmj
3b0cc28d4c Add xfail tests for onchain fees lookup query
Add test for single funded channels.
Add test for dual funded channels.
2024-02-02 17:31:23 +01:00
Rusty Russell
3c9fd0ca5b pytest: fix another gossip flake.
```
2024-02-02T10:30:38.6479143Z __________________ ERROR at teardown of test_multifunding_one __________________
...
2024-02-02T10:30:38.6491895Z >           raise ValueError(str(errors))
2024-02-02T10:30:38.6492208Z E           ValueError:
2024-02-02T10:30:38.6492465Z E           Node errors:
2024-02-02T10:30:38.6492833Z E            - lightningd-2: had bad gossip messages
2024-02-02T10:30:38.6493535Z E           Global errors:
...
2024-02-02T10:30:38.7458545Z lightningd-2 2024-02-02T10:25:48.410Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-gossipd: Ignoring future channel_announcment for 103x2x1 (current block 102)
2024-02-02T10:30:38.7460140Z lightningd-2 2024-02-02T10:25:48.411Z UNUSUAL lightningd: Bad gossip order: could not find channel 103x2x1 for peer's channel update
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-02 16:14:53 +01:00
Rusty Russell
a04fdfbe89 pytest: fix gossip_store load test for EXPERIMENTAL_SPLICING=1
It can change the node_announcement size, so don't check that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-02 16:14:53 +01:00
Lagrang3
997d5aa970 renepay: flow routes limited by htlc_max/min
The flow routes returned by minflow are bounded by the htlc_min and
    htlc_max along the route whenever possible.
2024-02-02 11:28:47 +01:00
Ken Sedgwick
33c838212e tests: augment test_onchain_their_unilateral_out to check to_remote witness generation
Changelog-Added: added a withdraw all to the end of test_onchain_their_unilateral_out to ensure that the unilateral close info is correct with anchors.  Tests https://github.com/Blockstream/greenlight/issues/348
2024-01-31 15:51:31 +01:00
Rusty Russell
1f9e9777f0 lightningd: don't generate node_announcements with identical timestamps.
This caused a flake in test_gossip_lease_rates, since the peer would ignore
the node_announcement due to duplicate timestamps!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
38ff9c6d74 pytest: don't trigger bad gossip message in test_routing_gossip_reconnect.
```
2024-01-29T21:26:50.9785559Z lightningd-1 2024-01-29T21:14:09.709Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-gossipd: Ignoring future channel_announcment for 110x1x0 (current block 109)
2024-01-29T21:26:50.9786945Z lightningd-1 2024-01-29T21:14:09.710Z UNUSUAL lightningd: Bad gossip order: could not find channel 110x1x0 for peer's channel update
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
fa7c0a7809 pytest: fix flake in test_wumbo_channels
We mine blocks too fast, and l3 discard the channel_announcment as too far in the future:

```
lightningd-3 2023-12-14T06:40:04.744Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-gossipd: Ignoring future channel_announcment for 103x1x1 (current block 102)
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
9f05250ee7 lightingd: corrections from Alex Myers's review.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
dd59d0617d lightningd: expose last_stable_connection in RPC.
This isuseful to find completely dead channels which are worthy of
closing.

Changelog-Added: JSON-RPC: `listpeerchannels` field `last_stable_connection` showing when we last held an established channel for a minute or more.
Changelog-Added: JSON-RPC: `listclosedchannels` field `last_stable_connection` showing when we last held an established channel for a minute or more.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
81a280d8a3 lightningd: expose reestablished field.
This is useful to see if we've really made progress, or just bounced
off the peer (e.g. it doesn't know the channel, or we have fallen
behind somehow).

Changelog-Added: JSON-RPC: `listpeerchannels` new field `reestablished` set once we've exchanged `channel_reestablish` messages.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
e4b21b467a lightningd: refine heuristics for remote address selection.
Rather than take the first two from peers with committed channels, use
the most common address given by at least 2 peers, and accept the majority
from non-committed peers if there are no committed peers.

This works well with the node_announcement rework, which waits until
everyone has a chance to connect before creating the node_announcement.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
97ccf05117 lightningd: ignore gossip messages from channeld, switch to our own.
This commit is a bit messy, but it tries to do the minimal switchover.

Some tests change, so those are included here. 

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 14:47:33 +10:30
Rusty Russell
d2e7831d87 pytest: fix flake in test_upgrade_statickey_onchaind
We need to make sure l1 has closed previous channel:

```
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')

tests/test_connection.py:3866: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
contrib/pyln-testing/pyln/testing/utils.py:88: in wait_for
    while not success():
tests/test_connection.py:3866: in <lambda>
    wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

arr = [{'alias': {'local': '7000028x5013088x54781', 'remote': '3360520x6431919x56666'}, 'channel_id': 'fb198b27b1be882937eea...: ['static_remotekey/even']}, 'close_to': '5120888ab14b6e1655d1d00039b836d70b66e3351543ab6cd2f94166255f3d5e6cb5', ...}]

    def only_one(arr):
        """Many JSON RPC calls return an array; often we only expect a single entry
        """
>       assert len(arr) == 1
E       AssertionError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 13:39:23 +10:30
Rusty Russell
82819433bc pytest: test_gossip_pruning should not assume redundant node_announcement.
This will change.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell
9d9c30331a pytest: prepare sql test for faster gossip generation.
Mining 13 blocks to close the l1->l2 channel also causes the l2->l3
channel to confirm, and I was reliably getting the
channel_announcement to l3 in time to confuse this wait_for test.  So
query the channel we want directly to make it more robust.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell
a27bbbb734 pytest: fix up test_zeroconf_multichan_forward once routehints fixed.
After this, the invoice (correctly!) gives the zeroconf channel as a routehint,
so this test fails.  Simple workaround: make invoice before creating zeroconf
channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell
412bb137e0 pytest: fix splicing tests to be more explicit, and not rely in private gossip messages.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell
e30eadd6a9 pytest: check for short_channel_id, not status.
Status actually changes in this series.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell
11fa3da4cc pytest: Remove check for to-be-removed message about msg from channeld.
This race is resolved with the gossipd changes (and this message is
also removed!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell
8f9af62228 pytest: make sure listincoming sees remote update in test_zeroconf_forward.
Otherwise we get no routehint.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell
64678c43ab pytest: make sure gossipd sees channel before we close it.
This was fine when gossipd saw local channels.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Rusty Russell
bfa81f30e1 pytest: ignore private updates in test_addgossip.
This was triggering on private updates after gossip changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

1diff --git a/tests/test_gossip.py b/tests/test_gossip.py
index 677ec4825..285290b71 100644
2024-01-31 09:15:46 +10:30
Rusty Russell
0a8003a4d2 pytest: fix psbt db test.
When we rewrite, we actually use the remote channel_announcement signatures from the db, and notice that l1 here is actually l2:

```
0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#1: gossipd rejected our channel announcement: WARNING: Bad node_signature_1 304402204ad9f0ca9b5f1f8eec61290b6008bf2c15f011e35543d25c35c5b89d2e1a183402201aaca5883714dbe11d6ae00a146fac7302352e1b9e987eee5ce98e8eb6a82909 hash e713698e14d3d8f973210e8d93c96d1a7c117c58340ccb195785a672fd0b5ef1 on channel_announcement 01004ad9f0ca9b5f1f8eec61290b6008bf2c15f011e35543d25c35c5b89d2e1a18341aaca5883714dbe11d6ae00a146fac7302352e1b9e987eee5ce98e8eb6a829095c05509264fcf72e19180f0285cf0ca0d786f280a75d79e46e5627be20c9dd9a4e9105aa61d7faf3a375454db94376b9b9df29cf078130ed827836b0849f119014ec750ab163baef701e7889f430ee37ea7e38857aa2b2745440600999c85f2903abefde5210dd06ae12f24b8801416800db84f5c73d35594af594f9001800025dee15519d29eb81e9d1ac761deebdad91ba1d08a05c027c16ea5fc08f3a9b663f8433209392395f0107f6b4d266c46b0946bd098f88c0693817fb560e0526a8000006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f00006900000100000266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c035180266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c0351802324266de8403b3ab157a09f1f784d587af61831c998c151bcc21bb74c2b2314b0206540493a98599967a61c45172df49681e398a6cb0890a506e74f76c2d2be242
```

Explicitly remove those messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-31 09:15:46 +10:30
Christian Decker
948ee4dbc5 pyln: Consolidate on pyln.testing.db
We had a complete copy of the `db_provider` and  associated classes in
teh `tests/` directory, causing them to drift apart. Consolidating on
one version makes this more maintainable.

Changelog-None
2024-01-29 19:13:12 +01:00
Tushar Vyas
464dc02b94 wipe_db() implementation 2024-01-29 19:13:12 +01:00
Rusty Russell
af4b244f2f pytest: fix flake in test_peer_anchor_push
If l1 is one block behind, l2 goes onchain one block early:

```
        # Drops to chain
>       wait_for(lambda: only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['state'] == 'AWAITING_UNILATERAL')

tests/test_closing.py:3951:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

success = <function test_peer_anchor_push.<locals>.<lambda> at 0x7f799f9cd1f0>
timeout = 180

    def wait_for(success, timeout=TIMEOUT):
        start_time = time.time()
        interval = 0.25
        while not success():
            time_left = start_time + timeout - time.time()
            if time_left <= 0:
>               raise ValueError("Timeout while waiting for {}".format(success))
E               ValueError: Timeout while waiting for <function test_peer_anchor_push.<locals>.<lambda> at 0x7f799f9cd1f0>
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 16:47:33 +10:30
Rusty Russell
bf9cdc597e pytest: fix flake in test_custommsg_triggers_notification
If listpeers on l2 is called too fast, then it won't return any peers, and
we will fail:

```
        # Connect l1 to l2
        l1.connect(l2)
>       wait_for(lambda: l2.rpc.listpeers(l1.info['id'])['peers'][0]['connected'])

tests/test_misc.py:2690:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
contrib/pyln-testing/pyln/testing/utils.py:88: in wait_for
    while not success():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   wait_for(lambda: l2.rpc.listpeers(l1.info['id'])['peers'][0]['connected'])
E   IndexError: list index out of range
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 16:47:33 +10:30
Rusty Russell
6778f320d2 openingd: make channel-type rejection message clearer.
For example, lnprototest got the error 'You gave bad parameters: Did not support channel_type ' which doesn't make it clear that it's rejecting the empty channel type.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell
b805899b06 pytest: check that listpeerchannels gives the same channel type as returned from fund/openchannel
Could have done this in an earlier commit, but that would be a messy rebase.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell
17d0d006d2 fundchannel_start & multifundchannel: add channel_type.
Let's tell the caller what channel_type they got!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `fundchannel`, `multifundchannel`, `fundchannel_start` and `openchannel_init`: new field `channel_type`.
2024-01-29 13:40:34 +10:30
Rusty Russell
08e29ab47f lightningd: make option_static_remotekey compulsory.
As suggested in https://github.com/lightning/bolts/pull/1092.

We still support channels opened without it, but you can no longer open new ones without it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: `option_gossip_queries` is now required (advertized by all but 16 nodes)
2024-01-29 13:40:34 +10:30
Rusty Russell
e531ff83b3 lightningd: add dev-any-channel-type to allow obsolete channel types.
We're about to make static_remotekey compulsory, but we still want to
do tests for pre-existing channels.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell
3c2a57598f spenderp: add channel_type parameter to fundchannel / multifundchannel.
And add a request schema for multifundchannel.

Changelog-Added: JSON-RPC: `fundchannel` and `multifundchannel` now take an optional `channel_type` parameter.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-29 13:40:34 +10:30
Rusty Russell
e749aebbff fundchannel_start / openchannel_init: add a channel_type parameter to force channel type.
And add request schemas for openchannel_init and fundchannel_start.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `fundchannel_start` and `openchannel_init` now take an optional `channel_type` parameter.
2024-01-29 13:40:34 +10:30
Rusty Russell
f450dfeb55 lightningd: make option_gossip_queries compulsory.
As suggested in https://github.com/lightning/bolts/pull/1092.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: `option_gossip_queries` is now required (advertized by all but 11 nodes)
2024-01-29 13:40:34 +10:30
Rusty Russell
88a2146664 lightningd: make option_data_loss_protect compulsory.
As suggested in https://github.com/lightning/bolts/pull/1092.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: `option_data_loss_protect` is now required (advertized by all but 11 nodes)
2024-01-29 13:40:34 +10:30
Lagrang3
b0054aad46 renepay: accomodate fees in the payment flow
Min. Cost Flow does not take into account fees when computing a flow
    with liquidity constraints.
    This is a work-around solution that reduces the amount on every route to
    respect the liquidity bound. The deficity in the delivered amount is
    solved by running MCF once again.

    Changes:

    1. the function `flow_complete` allocates amounts to send over the set of routes
       computed by the MCF algorithm, but it does not allocate more than liquidity
       bound of the route. For this reason `minflow` returns a set of routes that
       satisfy the liquidity bounds but it is not guaranteed that the total payment
       reaches the destination therefore there could a deficit in the delivery:
       `deficit = amount_to_deliver - delivering`.

    2. in the function `add_payflows` after `minflow` returns a set of routes we
       call `flows_fit_amount` that tries to a allocate the `deficit` in the routes
       that the MCF have computed.

    3. if the resulting flows pass all payment constraints then we update
        `amount_to_deliver = amount_to_deliver - delivering`, and the loop
        repeats as long as `amount_to_deliver` is not zero.

    In other words, the excess amount, beyond the liquidity bound,
    in the routes is removed and then we try to allocate it
    into known routes, otherwise we do a whole MCF again just for the
    remaining amount.

    Fixes issue #6599
2024-01-29 10:48:24 +10:30
niftynei
a4f92eac81 bkpr: now that we're not doing empty acct logging, we dont need this bool
We stopped doing empty journal logs, so we no longer need to switch
our log severity based on whether or not an account exists.

Should make bookkeeper less chatty and remove noisy logs

Changelog-None
2024-01-29 10:05:03 +10:30
niftynei
5484aaee33 bkpr: dont log unknown accounts with zero balances
We were putting out a lot of empty journal entries. Let's
stop doing that.

Now the wallet balance stays uninitialized until/unless you have
funds in it.

Fixes #5672
2024-01-29 10:05:03 +10:30
Rusty Russell
277ed2ccbf libplugin: support version strings for deprecations.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-26 10:30:22 +10:30
Rusty Russell
4764ec794c pytest: note where we use very deprecated features, so tests don't rbeak.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-26 10:30:22 +10:30
Rusty Russell
5ef4779edc lightningd: remove msatoshi alias for amount_msat.
Changelog-Removed: JSON-RPC: `invoice`, `sendonion`, `sendpay`, `pay`, `keysend`, `fetchinvoice`, `sendinvoice`: `msatoshi` argument (deprecated 0.12.0). Use `amount_msat`.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-01-26 10:30:22 +10:30
Lagrang3
7c7d13d6dc renepay: add self-pay feature 2024-01-24 14:42:45 +10:30
Matt Morehouse
3260d7dd5e fuzz: initial fuzz-bolt12-invoice-decode corpus 2024-01-23 20:21:48 +10:30
Matt Morehouse
1c18269cd1 fuzz: initial fuzz-bolt12-invrequest-decode corpus 2024-01-23 20:21:48 +10:30
Matt Morehouse
2073d9771d fuzz: initial fuzz-bolt12-offer-decode corpus 2024-01-23 20:21:48 +10:30
Matt Morehouse
3af61e087c fuzz: initial fuzz-bolt12-bech32-decode corpus 2024-01-23 20:21:48 +10:30
Matt Morehouse
7d05f07a2b fuzz: test bolt12 decoding
Add fuzz targets for decoding of offers, invoice requests, and invoices.
Mutators are shared in bolt12.h.
2024-01-23 20:21:48 +10:30
Matt Morehouse
b73f921a91 fuzz: test bolt12 bech32 decoding 2024-01-23 20:21:48 +10:30
Rusty Russell
09c1cfde39 pyln-client: don't automatically turn JSON into Millisatoshi class.
Now _msat fields are all integers (last conversion 23.08) we can simply
leave them alone, rather than trying to convert them.

And for turning Millisatoshi into JSON, we simply globally replace the
default encoding function to try ".to_json()" on items, which allows
anything to be marshalled.

The global replacement was interfering with other uses of JSON, such
as the clnrest plugin.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: pyln-client: no longer autoconverts _msat field to Millisatoshi class (leaves as ints).
2023-12-16 10:22:01 +01:00
Rusty Russell
8b224b6ec2 pytest: don't assume that msat fields get turned into Millisatoshi.
Since the class interacts with int very well now, we don't have to
make explicit accesses, so it's easy to write code which works with
Millisatoshi or int.

Also, don't access rpc.decoder in one test, it's unnecessary.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-12-16 10:22:01 +01:00
Erik De Smedt
375985bf6c Implement tests for notifications on custommsg 2023-12-16 11:36:42 +10:30
Dusty Daemon
6f4a3c86e9 splice: Agressive restart testing during splices
Test node restarts in lots of phases of splice.

Changelog-None
2023-12-15 09:42:45 +10:30
Erik De Smedt
557b5fee46 Allow dynamic option in python plugin 2023-12-14 16:48:02 +01:00
Rusty Russell
36b631699b plugins: re-enable listchannels local info in deprecated mode.
We only deprecated this, we didn't actually remove it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-12-14 09:16:56 +10:30
Rusty Russell
58a1c4c012 topology: don't show private nodes in listchannels.
This alters a few remaining tests, as well.

[ Inclused even more test fixes from Alex Myers <alex@endothermic.dev>! ]

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: JSON-RPC: `listchannels` listing private channels: use listpeerchannels
2023-12-14 09:16:56 +10:30
Alex Myers
3a6b9f2ec6 pytest: skip test_hook_crash on liquid CI 2023-12-14 09:16:56 +10:30
Rusty Russell
b318811a2d pytest: fix tests in assumption that listchannels will no longer show private gossip.
Some can only be changed once that is true, but some can be removed/amended already.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-12-14 09:16:56 +10:30
Rusty Russell
ea0d00e677 topology: don't show private nodes in listnodes.
This breaks our tests a bit, which assumed we can always see ourselves
even if we don't have a proper channel.

Usually we would deprecate this first, but it's unlikely to break
anyone since it's a bit obscure that this worked at all.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: `listnodes` no longer shows private (peer) nodes: use listpeers
2023-12-14 09:16:56 +10:30
Rusty Russell
f61ba7b332 pytest: remove test waits for routehints.
Now listincoming sees local channels in listpeerchannels, we don't need these waits.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-12-14 09:16:56 +10:30
Rusty Russell
f3b4821d36 pytest: fix test_zeroconf_open()
l2 gave us a routehint, but it should have seen l1 as a dead-end.  It
didn't due to the presence of a channel alias, which was a bug.  We're
about to fix this, which breaks the test.

Add a dummy node off l1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-12-14 09:16:56 +10:30
Rusty Russell
c3f33eb6dd listpeerchannels: show gossip updates.
This is redundant if it's a public channel, but vital if it's not.  Publishing unconditionally makes
it easier for gossmap: we create a local modification all the time, even if redundant (and we can
have the actual capacity ceiling accurate in this case, since we know it for local channels).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Changelog-Added: JSON-RPC: `listpeerchannels` now shows gossip update contents (even if channel unannounced).
2023-12-14 09:16:56 +10:30
Alex Myers
a8995caa8b pytest: use wait_local_channel_active 2023-12-14 09:16:56 +10:30
Rusty Russell
0b23133ab2 lightningd: don't print out notification msat fields as strings.
Reported-by: Shahana Farooqui
Changelog-Fixed: JSON-RPC: Plugin notification `msat` fields in `invoice_payment` and `invoice_created` hooks now a number, not a string with "msat" suffix.
Changelog-Fixed: JSON-RPC: Plugin hook `payment` `msat` field is now a number, not a string with "msat" suffix.
2023-11-21 08:23:39 +01:00
ShahanaFarooqui
fdc7fcbf34 tests/clnrest: Test to confirm that msat suffix has been removed from notifications 2023-11-21 08:23:39 +01:00
ShahanaFarooqui
2a7a3d2371 tests/clnrest: Added rpc method name and params to use the same notifications_received_via_websocket function for other rpc requests too 2023-11-21 08:23:39 +01:00
Dusty Daemon
a6a9e5b1e3 splice: Reestablish when commit or sig sends fail
Adds tests for when the connection fails during
1) splice tx_signature
2) splice commitment_signed

Fleshed out the reestablish flow for these two cases and implemented the fixes to make these reestablish flows work.

Part of this work required changing commit process for splices: Now we send a single commit_part for the splice where previously we sent all commits, and accordingly, we no longer revoke in response.

Changelog-Fixed: Implemented splicing restart logic for tx_signature and commitment_signed. Splice commitments are reworked in a manner incompatible with the last version.
2023-11-20 07:35:22 +01:00
Rusty Russell
eae0d1da1e lightningd: fix up deprecated rest-port, rest-protocol, rest-host and rest-certs option if we would otherwise fail.
Since these worked in v23.08, we can't just rename them.  So if they are
used and unclaimed, we should rename them internally (if they're claimed,
it's probably clightning-rest, and we should *NOT* touch them!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: Plugins: `clnrest` parameters `rest-port`, `rest-protocol`, `rest-host` and `rest-certs`: prefix `cln` to them
2023-11-17 10:51:41 +01:00
ShahanaFarooqui
cc2665da7f clnrest: prefixing all rest config options with cln
This will allow users to use clnrest with c-lightning-REST without conflicts.
It was required for applications to have enough time for migrating from c-lightning-REST to clnrest.

Changelog-Changed:
config option `rest-certs` changed to `clnrest-certs`
config option `rest-protocol` changed to `clnrest-protocol`
config option `rest-host` changed to `clnrest-host`
config option `rest-port` changed to `clnrest-port`
config option `rest-cors-origins` changed to `clnrest-cors-origins`
config option `rest-csp` changed to `clnrest-csp`
2023-11-16 11:21:04 +01:00
Rusty Russell
8b84c8945b clnrest: don't convert *_msat fields to strings.
We have a global JSON encoder hack, which means that any field ending in msat gets special treatment (so we can safely talk to lightningd, even if a field expects satoshi amounts, we are explicit).  However, requests uses the JSON parser and DOES NOT want this conversion when sending it out as an HTTP response!

The simplest local fix we could find was Shahana's suggestion to iterate and covert away from Millisatoshi(): the reverse of what our JSON encoder does.

Fixes: https://github.com/ElementsProject/lightning/issues/6848
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-11-16 09:07:07 +01:00
Rusty Russell
f2f6c73977 clnrest: don't try to handle plugin.rpc.call results.
It already throws an exception or error, or decodes the JSON response:
we can simply pass it through.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-11-16 09:07:07 +01:00
Tony Aldon
b3f122a2c5 pytest: adds test suite for clnrest plugin
- cln-grpc certificate reuse
- new certificate generation
- `GET` and `POST` requests
- websocket server
- config options and HTTP headers

Link to #6436.
2023-11-16 09:07:07 +01:00
niftynei
3190c26bc9 dualfund: error on out of order sigs
We weren't blocking if the tx-sigs arrived before the commitment sigs.

This was causing problems in the openchannel (spender plugin)

spenderp: FATAL SIGNAL 11 (version v23.08.1-404-g62ff475-modded)
0x559836dc98ba send_backtrace
	common/daemon.c:33
0x559836dc9951 crashdump
	common/daemon.c:75
0x7f37f42c351f ???
	./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7f37f441ac92 ???
	../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S:83
0x559836db7760 bitcoin_txid_eq
	./bitcoin/tx.h:29
0x559836db7760 collect_sigs
	plugins/spender/openchannel.c:509
0x559836db81de check_sigs_ready
	plugins/spender/openchannel.c:531
0x559836db84dd json_peer_sigs
	plugins/spender/openchannel.c:611
0x559836dbcad7 ld_command_handle
	plugins/libplugin.c:1611
0x559836dbcd9d ld_read_json_one
	plugins/libplugin.c:1721
0x559836dbce29 ld_read_json
	plugins/libplugin.c:1741
0x559836ef3bff next_plan
	ccan/ccan/io/io.c:59
0x559836ef40da do_plan
	ccan/ccan/io/io.c:407
0x559836ef4177 io_ready
	ccan/ccan/io/io.c:417
0x559836ef5b14 io_loop
	ccan/ccan/io/poll.c:453
0x559836dbd48d plugin_main
	plugins/libplugin.c:1948
0x559836db22bf main
	plugins/spender/main.c:35
0x7f37f42aad8f __libc_start_call_main
	../sysdeps/nptl/libc_start_call_main.h:58
0x7f37f42aae3f __libc_start_main_impl
	../csu/libc-start.c:392
0x559836da3774 ???
	???:0
0xffffffffffffffff ???
	???:0
2023-10-31T15:15:57.458Z INFO    plugin-spenderp: Killing plugin: exited during normal operation
2023-10-31T15:15:57.458Z **BROKEN** plugin-spenderp: Plugin marked as important, shutting down lightningd!
2023-10-31T15:15:57.458Z DEBUG   lightningd: io_break: lightningd_exit
2023-10-31T15:15:57.458Z DEBUG   lightningd: io_loop_with_timers: main
2023-10-31T15:15:57.458Z DEBUG   connectd: REPLY WIRE_CONNECTD_START_SHUTDOWN_REPLY with 0 fds
2023-10-31T15:15:57.458Z DEBUG   lightningd: io_break: connectd_start_shutdown_reply
2023-10-31T15:15:57.458Z DEBUG   021ccce7bc396996c8f3b7bfeb1e30c6600269517026a74adfe2217b7187879797-dualopend-chan#1: Status closed, but not exited. Killing
2023-10-31T15:15:57.458Z DEBUG   lightningd: Command returned result after jcon close
2023-10-31T15:15:57.458Z INFO    021ccce7bc396996c8f3b7bfeb1e30c6600269517026a74adfe2217b7187879797-chan#1: Unsaved peer failed. Deleting channel.
2023-10-31T15:15:57.464Z DEBUG   lightningd: io_break: destroy_plugin
2023-10-31T15:15:57.464Z DEBUG   connectd: Shutting down
2023-10-31T15:15:57.464Z DEBUG   gossipd: Shutting down
2023-10-31T15:15:57.464Z DEBUG   hsmd: Shutting down

Reported-By: @t-bast
2023-11-02 19:32:05 +10:30
niftynei
fa8458c00a dualfund: add test to make sure that tx-sigs sent before commitment
results in an error.
2023-11-02 19:32:05 +10:30
niftynei
30ec8cbf8e dualfund, test: add test for dropping to chain during RBF
Here we make sure we can drop the initial tx to chain, and that an
inflight txid that's missing its commitment sigs is properly ignored.
2023-11-02 19:32:05 +10:30
niftynei
da34c369f3 dualfund, tests: break out "peer forgets" test
Now that we save the commitment sigs immediately, we have to drop the
connection elsewhere in the flow to get the state where only one peer
remembers.
2023-11-02 19:32:05 +10:30
niftynei
5417312911 tests: update opening tests for new reconnect behavior
Let's test that things stay together!

One cool thing to note is that now we sort of "magically" recover from
pretty brutal disconnects!

Very nice!
2023-11-02 19:32:05 +10:30
niftynei
20c77419dc dualfund: split 'commit-received' into two parts
Here, we split up what was "commit_received" into two phases:
	- commit-ready, where we're about to send our commitment tx to
	  peer
	- commit-received, when we've gotten the commitment tx from our
          peer

This lets us do the right thing (as far as the spec is concerned) with
returning the correct 'next_funding_txid' on reconnect (later commits).
2023-11-02 19:32:05 +10:30
Rusty Russell
f004952442 lightningd: wumbo is now the default, setting has no effect.
"Patrick, I'm sorry I doubted you."

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Config: `large-channels` is now the default, wumbology for all.
2023-11-02 08:16:51 +01:00
Alex Myers
10bac49dac ld: add commit-fee-offset option, update config schema
Changelog-Added: Added option --commit-fee-offset to potentially reduce feerate update disagreements
2023-11-02 09:49:59 +10:30
Alex Myers
4265699fcd lightningd: add a feerate offset when updating feerates as opener
Adding a fee offset as the channel opener reduces the likelihood of a
disconnect by the peer do to slight variation in feerate calculation
between nodes.

Changelog-Fixed: Some peer disconnects due to update_fee disagreements are avoided.
2023-11-02 09:49:59 +10:30
Rusty Russell
28fd70a3d8 lightningd: rewrite anchor spend to use multiple UTXOs if needed.
Closes: #6747
Changelog-EXPERIMENTAL: Fixed anchor spending to be able to use more than one UTXO.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-11-01 14:11:28 +10:30
Rusty Russell
b901f885e0 pytest: force anchor tests to use more than one UTXO.
They fail now, since one UTXO is not enough.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-11-01 14:11:28 +10:30
Rusty Russell
1d677bcba7 addpsbtoutput: allow command to specify output address.
Default is still to generate it.

Changelog-None: Introduced this release anyway.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-11-01 14:11:28 +10:30
Chris Guida
c6262189b7 cln-plugin: Add test for cln-plugin send_custom_notification
Also fix Makefile for rust plugin examples

Also add in a missing assert in the test_plugin_start test
2023-10-30 18:24:23 +01:00
Rusty Russell
af971fd025 wait forwards: add in_htlc_id
Without this, we have no unique identifier for which forward happened.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-28 15:48:26 +10:30
Rusty Russell
0317348479 pytest: add test for wait forwards.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-28 15:48:26 +10:30
Rusty Russell
1d8af90b56 listforwards: add created_index and updated_index fields.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `listforwards` fields `created_index` (old: `id`) and `updated_index`.
2023-10-28 15:48:26 +10:30
Rusty Russell
c70a326f1f lightningd: add ordering and pagination to listsendpays.
Changelog-Added: JSON-RPC: `listsendpays` new parameters `index`, `start` and `limit`.
2023-10-28 15:48:26 +10:30
Rusty Russell
00ac1a9475 listsendpays: add created_index and updated_index fields.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `sendpay`, `listsendpays`, `delpay` new fields `created_index` (old: `id`) and `updated_index`.
2023-10-28 15:48:26 +10:30
Rusty Russell
9ec6ac9922 lightningd: don't log that we're trying to pay if we're not.
Looking through logs I was surprise to see:

```
lightningd-1 2023-10-26T03:42:36.824Z INFO    lightningd: Sending 200000000msat over 1 hops to deliver 200000000msat
```

On a re-payment where we simply returned from sendpay immediately!  Move that log to later.
2023-10-28 15:48:26 +10:30
Rusty Russell
f65c3cab75 wallet: use standard-style iterators for payments.
We used to have "unsaved" payments: now we don't we can use
our normal "iterator" pattern rather than returning arrays.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-28 15:48:26 +10:30
Aditya Sharma
34692ec3c8 tests/test_misc.py: Add test_decode to test the decryption of bech32 encoding of emergency.recover 2023-10-27 16:05:28 +10:30
Dusty Daemon
990f4d0dad splice: Update test for new logs
The log messages were changed but the test fields weren’t updated, resulting in some test flakiness. Being more explicit with the log message we’re looking for should help.

Changelog-None
2023-10-27 13:20:33 +10:30
Rusty Russell
f8e036b22d channeld: use anchors on peer's commitment(s) if we can't broadcast our own.
This means refactoring out some of the generic anchor info, from the
per-commitment-tx info (we can have at least two, perhaps more with
splicing!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-27 11:19:56 +10:30
Rusty Russell
2bf21daba7 pytest: test (fails!) that we push anchor on peer's commitment tx.
We try to use anchors to CPFP our own commitment, but what if they
get there first?  We also need to use anchors on the commitment
txs they broadcast.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-27 11:19:56 +10:30
Christian Decker
0c32183e8d pytest: Mark test_plugin_startdir_lol as @unittest.skip()
It isn't that flaky, but when it gets stuck we'll be waiting for 30m
for it to complete.
2023-10-26 15:51:07 +02:00
Christian Decker
23ce9a947d pytest: Mark test_exclude_adjacent_routehint as skip
It has about a 7% flakyness rate.
2023-10-26 15:51:07 +02:00
Christian Decker
8f4c997248 pytest: Mark test_splice as falky 2023-10-26 15:51:07 +02:00
Christian Decker
7deeff8404 pytest: Fix a falke in test_gossip_pruning
Fixes cause of https://github.com/ElementsProject/lightning/actions/runs/6518612194/job/17704479411
2023-10-26 15:51:07 +02:00
Christian Decker
5c12d14e11 pytest: Skip test_commit_crash_splice as it is too flaky 2023-10-26 15:51:07 +02:00
Chris Guida
88ac2dcb7e add test, update schemas, fix warning_custom_fallbacks 2023-10-26 19:11:17 +10:30
Dusty Daemon
dc4e0a400f Splice: Better balance checking
* Regression test added for Issue #6572 (issuecomment-1730808863) w/stuck HTLC
* `check_balance` adjusted to calculate pending HTLCs explicitly
* Test confirmed to fail prior to PR #6713

ChangeLog-Fixed: Issue splicing with pending / stuck HTLCs fixed.
2023-10-26 13:24:04 +10:30
Rusty Russell
a50b795bc2 lightningd: implement recover command.
Changelog-Added: JSON-RPC: `recover` command to force (unused) lightningd node to restart with `--recover` flag.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-26 12:59:55 +10:30
Rusty Russell
7f18ed7743 lightningd: allow --recover to take a 64-char hex string.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: Config: `--recover` can take a 32-byte hex string, as well as codex32.
2023-10-26 12:59:55 +10:30
Rusty Russell
3b622f06c3 lightningd: use param_check on all commands which do extra checks.
This makes `check` much more thorough, and useful.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `check` now does much more checking on every command (not just basic parameter types).
2023-10-26 12:59:55 +10:30
Rusty Russell
25110ff2cc connectd: fix fd leak for --offline.
```
**BROKEN** connectd: dev_report_fds: 5 open but unowned?
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-26 12:59:55 +10:30
Rusty Russell
35a47c57e3 lightningd: add direct close outputs to listfunds (mutual close).
We had a complaint that you can't CPFP a mutual close, which you
should be able to do.

Fixes: #6692
Changelog-Fixed: wallet: close change outputs show up immediately in `listfunds` so you can CPFP.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-26 12:58:34 +10:30
Rusty Russell
bddff79bc5 pytest: test that we can CPFP a mutual close.
You can't (yet): it doesn't even show in listfunds.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-26 12:58:34 +10:30
Peter Neuroth
747725dabd test: Add test for datastoreusage
Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2023-10-26 12:58:04 +10:30
Rusty Russell
0550bb0a7d pytest: fix flake in test_remote_addr_port
```
FAILED tests/test_connection.py::test_remote_addr_port - TimeoutError: Unable to find "[re.compile('Update our node_announcement for discovered address')]" in logs.
```

Because it can happen before the "Already have funding locked in" message:

```
lightningd-2 2023-10-24T22:07:02.018Z DEBUG   gossipd: Update our node_announcement for discovered address: 127.0.0.1:1234
lightningd-2 2023-10-24T22:07:02.019Z DEBUG   lightningd: Plugin chanbackup returned from peer_connected hook call
lightningd-2 2023-10-24T22:07:02.019Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-chan#2: Peer has reconnected, state CHANNELD_NORMAL: connecting subd
lightningd-2 2023-10-24T22:07:02.036Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-channeld-chan#2: pid 63142, msgfd 67
lightningd-2 2023-10-24T22:07:02.037Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-chan#2: Already have funding locked in (and ready to announce)
```

Also, wait_for_log() asserts itself, no need to assert on result.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-25 23:11:37 +02:00
Rusty Russell
5f664dac77 pytest: fix flake in test_excluded_adjacent_routehint
Wait to be sure l1->l2 is ready.  And use the same pattern for l2->l3.

```
    def test_excluded_adjacent_routehint(node_factory, bitcoind):
        """Test case where we try have a routehint which leads to an adjacent
        node, but the result exceeds our maxfee; we crashed trying to find
        what part of the path was most expensive in that case
    
        """
        l1, l2, l3 = node_factory.line_graph(3)
    
        # We'll be forced to use routehint, since we don't know about l3.
        wait_for(lambda: len(l3.rpc.listchannels(source=l2.info['id'])['channels']) == 1)
        inv = l3.rpc.invoice(10**3, "lbl", "desc", exposeprivatechannels=l2.get_channel_scid(l3))
    
        # This will make it reject the routehint.
        err = r'Fee exceeds our fee budget: 1msat > 0msat, discarding route'
        with pytest.raises(RpcError, match=err):
>           l1.rpc.pay(bolt11=inv['bolt11'], maxfeepercent=0, exemptfee=0)

tests/test_pay.py:3420: 
...
>           raise RpcError(method, payload, resp['error'])
E           pyln.client.lightning.RpcError: RPC call failed: method: pay, payload: {'bolt11': 'lnbcrt10n1pjntczasp59x0weqkg4u9amd364yaeyw6rmgnmf9qtra6epylcntvt65yalpzspp5x8wgtmjhq33qruk6mmhutyr7w74xxjhct7v9tppel0t9p4rtautsdq8v3jhxccxqyjw5qcqp9rzjqgkjyd3q5dv6gllh77kygly9c3kfy0d9xwyjyxsq2nq3c83u5vw4jqqqvuqqqqgqqqqqqqqpqqqqqzsqqc9qxpqysgq4euy2qyzl2nufpxv6ahf0s5zry0h5dgrpa5adwu4swrdvjw7qe48cj8kp5fl7k20ex0x3dnk6e8xk5jp82snrdcr6he7eyqd0wrmvlgqwe5nma', 'maxfeepercent': 0, 'exemptfee': 0}, error: {'code': 210, 'message': 'Destination 035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d is not reachable directly and all routehints were unusable.', 'attempts': [{'status': 'failed', 'failreason': 'Destination 035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d is not reachable directly and all routehints were unusable.', 'partid': 0, 'amount_msat': 1000msat}]}
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-24 10:02:52 +02:00
Rusty Russell
b0ab350927 pytest: fix flake in test_listforwards_and_listhtlcs
Make sure l1 sees chanell to l4.

```
   def test_listforwards_and_listhtlcs(node_factory, bitcoind):
        """Test listforwards and listhtlcs commands."""
        l1, l2, l3, l4 = node_factory.get_nodes(4, opts=[{}, {}, {}, {}])
    
        l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
        l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
        l2.rpc.connect(l4.info['id'], 'localhost', l4.port)
    
        c12, c12res = l1.fundchannel(l2, 10**5)
        c23, _ = l2.fundchannel(l3, 10**5)
        c24, _ = l2.fundchannel(l4, 10**5)
    
        # Wait until channels are active
        mine_funding_to_announce(bitcoind, [l1, l2, l3, l4])
        l1.wait_channel_active(c23)
    
        # successful payments
        i31 = l3.rpc.invoice(1000, 'i31', 'desc')
        l1.rpc.pay(i31['bolt11'])
    
        i41 = l4.rpc.invoice(2000, 'i41', 'desc')
>       l1.rpc.pay(i41['bolt11'])

tests/test_misc.py:2871: 
...
>           raise RpcError(method, payload, resp['error'])
E           pyln.client.lightning.RpcError: RPC call failed: method: pay, payload: {'bolt11': 'lnert20n1pjnd7xlsp5lcwwuxw90nanl7cpfzp4jf7w5tats5aalkksswpps6cqrwpu0l3spp5pzng94efstxjhdc2ya8hhgrch33qavzgv4gahga3y6dxqshezuqsdq8v3jhxccxqyjw5qcqp99qxpqysgqys70jhf8aj4zpwrvfrse54c5kfaqxj98xl4ddxp7jkm75e4p59gy6l2ryvz4fejg5reqkxw44k90rp0l7c8vxut424m4ek743k0lpwcqzg2a60'}, error: {'code': 210, 'message': 'Destination 0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199 is not reachable directly and all routehints were unusable.', 'attempts': [{'status': 'failed', 'failreason': 'Destination 0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199 is not reachable directly and all routehints were unusable.', 'partid': 0, 'amount_msat': 2000msat}]}
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-24 10:02:52 +02:00
Rusty Russell
043c4ae5eb pytest: fix flake in test_even_sendcustommsg
Make sure plugin has got message to connectd before sending!

```
    def test_even_sendcustommsg(node_factory):
        l1, l2 = node_factory.get_nodes(2, opts={'log-level': 'io',
                                                 'allow_warning': True})
        l1.connect(l2)
    
        # Even-numbered message
        msg = hex(43690)[2:] + ('ff' * 30) + 'bb'
    
        # l2 will hang up when it gets this.
        l1.rpc.sendcustommsg(l2.info['id'], msg)
        l2.daemon.wait_for_log(r'\[IN\] {}'.format(msg))
        l1.daemon.wait_for_log('Invalid unknown even msg')
        wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'] == [])
    
        # Now with a plugin which allows it
        l1.connect(l2)
        l2.rpc.plugin_start(os.path.join(os.getcwd(), "tests/plugins/allow_even_msgs.py"))
    
        l1.rpc.sendcustommsg(l2.info['id'], msg)
        l2.daemon.wait_for_log(r'\[IN\] {}'.format(msg))
>       l2.daemon.wait_for_log(r'allow_even_msgs.*Got message 43690')

tests/test_misc.py:3623: 
...
>                   raise TimeoutError('Unable to find "{}" in logs.'.format(exs))
E                   TimeoutError: Unable to find "[re.compile('allow_even_msgs.*Got message 43690')]" in logs.

contrib/pyln-testing/pyln/testing/utils.py:327: TimeoutError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-24 09:51:43 +02:00
Rusty Russell
6f1bb6fa41 lightningd: don't process request twice if plugin dies.
We remove it from the pending_requests strmap before calling it,
so it doesn't get called again by destroy_plugin.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-24 15:07:08 +10:30
Rusty Russell
db7f59eeba lightningd: simplify plugin hook handling.
Now the internal code will generate a "PLUGIN_TERMINATED" response
when the plugin dies, we can handle it in plugin_hook.

But we can also simplify it by turning the snapshot of hooks into
a simple array: this means we are robust against any combination of plugins
exiting at any time.

Note: this reveals an issue with test_rpc_command_hook where we run
the request hook again (unexpectedly), so we disable that for the next
patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-24 15:07:08 +10:30
Rusty Russell
22ea202ae3 lightningd: generically fail requests when plugin dies.
We had special code to fail a forwarded request, but not for an
internally-generated request.  Instead, we should pretend the (dead)
plugin responded with a PLUGIN_TERMINATED error, and handle the
request through the normal paths.

This breaks the case where a plugin crashes (or stops itself) in a
hook, so we handle that next.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-24 15:07:08 +10:30
Matt Morehouse
a59a8557d9 fuzz: new bolt11 seeds 2023-10-24 12:17:18 +10:30
Matt Morehouse
3a7a1fad4e fuzz: add bolt11 cross-over mutator
This mutator helped the fuzzer find new coverage and detect the bug
fixed in 87f4907bb4.
2023-10-24 12:17:18 +10:30
Matt Morehouse
38e31d6034 fuzz: add custom cross-over functions
These can be used in custom mutators for libFuzzer targets.
2023-10-24 12:17:18 +10:30
Matt Morehouse
58f16c2146 fuzz: set minimum bolt11 size to 9
This prevents a buffer overflow in the custom mutator that can occur
when data_maxlen is 0.
2023-10-24 12:17:18 +10:30
Rusty Russell
dfe207d503 pytest: test for accepting even unknown messages.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-24 11:50:57 +10:30
Rusty Russell
bd80af5295 lightningd: allow sending of even messages.
It's your funeral!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-24 11:50:57 +10:30
Rusty Russell
920e50db6b pytest: fix flake in test_excluded_adjacent_routehint
Make sure l1 can see l2's channel and it's in the gossip_store.

```
    def test_excluded_adjacent_routehint(node_factory, bitcoind):
        """Test case where we try have a routehint which leads to an adjacent
        node, but the result exceeds our maxfee; we crashed trying to find
        what part of the path was most expensive in that case
    
        """
        l1, l2, l3 = node_factory.line_graph(3)
    
        # We'll be forced to use routehint, since we don't know about l3.
        wait_for(lambda: len(l3.rpc.listchannels(source=l2.info['id'])['channels']) == 1)
        inv = l3.rpc.invoice(10**3, "lbl", "desc", exposeprivatechannels=l2.get_channel_scid(l3))
    
        # This will make it reject the routehint.
        err = r'Fee exceeds our fee budget: 1msat > 0msat, discarding route'
        with pytest.raises(RpcError, match=err):
>           l1.rpc.pay(bolt11=inv['bolt11'], maxfeepercent=0, exemptfee=0)

tests/test_pay.py:3420: 
...
>           raise RpcError(method, payload, resp['error'])
E           pyln.client.lightning.RpcError: RPC call failed: method: pay, payload: {'bolt11': 'lnbcrt10n1pjjm8hesp5kp4nfgrj2ev6dz6xuqgxg29hz7263ltlafylhw7nglhtjxeqpn7spp5w92tjq8a354psfhdzmeuytfc6eye4f5egl7tj7s0f5ftz0k4pmcqdq8v3jhxccxqyjw5qcqp9rzjqgkjyd3q5dv6gllh77kygly9c3kfy0d9xwyjyxsq2nq3c83u5vw4jqqqvuqqqqgqqqqqqqqpqqqqqzsqqc9qxpqysgqetjwr6ql24jrz02qhj7pdw3kqynw6j3sgj2h32ufeyzasjyp2j6yc5durewjjpjy5yqtfgdxmdj52n7jk0ylzk5wudk4ffmjyyw6jmsqkvjex9', 'maxfeepercent': 0, 'exemptfee': 0}, error: {'code': 210, 'message': 'Destination 035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d is not reachable directly and all routehints were unusable.', 'attempts': [{'status': 'failed', 'failreason': 'Destination 035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d is not reachable directly and all routehints were unusable.', 'partid': 0, 'amount_msat': 1000msat}]}
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-23 21:57:51 +10:30
Rusty Russell
93189724dd lightningd: let channeld/dual_openingd send error to peer.
We do it here, but it's not necessary, and we also deprive them of the
chance to do so (since we kill them).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-23 15:48:50 +10:30
Rusty Russell
6fdaec313d pytest: be sure that we receive error on datalose failure.
It was intermittant before: I added a sleep(1) in the code before
sending the error (temporarily) to make it always triggers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-23 15:48:50 +10:30
Rusty Russell
6a67615274 pyln-testing: make disconnects continue after restart.
We truncate the file on stop(), but don't re-created it on start().

We didn't notice it before, but the net

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-23 15:48:50 +10:30
Rusty Russell
285595ada7 pytest: revert warning delivery failure workaround
Reverts 6203d250bf "pytest: fix flake in upfront warning." now we've actually fixed the cause.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-23 15:48:50 +10:30
Rusty Russell
08f0a54fdc connectd: don't disconnect automatically on sending warning or error.
This changes some tests which expected us to disconnect.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-23 15:48:50 +10:30
Matt Morehouse
87f4907bb4 bolt11: don't abort on invalid pubkey
Rather than crashing the entire node on invalid pubkey, check the
validity of the pubkey in decode_n, and return an error if invalid.

Detected by libFuzzer:
==265599== ERROR: libFuzzer: deadly signal
    #7 abort
    #8 bolt11_decode common/bolt11.c:999:4
2023-10-18 09:53:22 +10:30
Matt Morehouse
c1f20687a6 bolt11: validate recovery ID
Invalid recovery IDs cause
secp256k1_ecdsa_recoverable_signature_parse_compact to abort, which
crashes the entire node. We should return an error instead.

Detected by libFuzzer:
[libsecp256k1] illegal argument: recid >= 0 && recid <= 3
2023-10-18 09:53:22 +10:30
Matt Morehouse
4b29502098 fuzz: check invoice signatures
There may be bugs in signature validation, so we should fuzz that too.
2023-10-18 09:53:22 +10:30
Matt Morehouse
ee8cf69f28 bolt11: return error on unexpected lightning prefix
Remove the assertion so that an error is returned for invalid bech32.
An error is preferable to crashing the entire node if there's an extra
"lightning:" prefix:

  $ lightning-cli pay "lightning:lightning:"

Node log:
  pay: common/bolt11.c:718: bolt11_decode_nosig: Assertion `!has_lightning_prefix(str)' failed.
  pay: FATAL SIGNAL 6
  ...
  INFO    plugin-pay: Killing plugin: exited during normal operation
  **BROKEN** plugin-pay: Plugin marked as important, shutting down lightningd
2023-10-18 09:53:22 +10:30
Matt Morehouse
ee501b035b bolt11: avoid reading uninitialized memory
If both databits and *data_len are 0, pull_uint return uninitialized
stack memory in *val.

Detected by valgrind and UBSan.

valgrind:
==173904== Use of uninitialised value of size 8
==173904==    __sanitizer_cov_trace_cmp8
==173904==    decode_c (bolt11.c:292)
==173904==    bolt11_decode_nosig (bolt11.c:877)

UBSan:
common/bolt11.c:79:29: runtime error: shift exponent 64 is too large for 64-bit type 'uint64_t' (aka 'unsigned long')

Corpus input e6f7b9744a7d79b2aa4f7c477707bdd3483f40fa triggers the UBSan
report, but we didn't previously realize this because UBSan has been
disabled in the CI run. We rename the input to indicate its usefulness
as a permanent regression test.
2023-10-18 09:53:22 +10:30
Matt Morehouse
eeec529031 bolt11: check return value of pull_all
Otherwise, if pull_all fails, we attempt to create a script from NULL,
causing a UBSan report:

bitcoin/script.c:29:28: runtime error: null pointer passed as argument 2, which is declared to never be null

Corpus input bf703c2c20c0818af70a8c4caad6e6fd8cfd1ac6 triggers the UBSan
report, but we didn't previously realize this because UBSan has been
disabled in the CI run. We rename the input to indicate its usefulness
as a permanent regression test.
2023-10-18 09:53:22 +10:30
Rusty Russell
cdd58e2fe3 pytest: correctly test missing method for runes.
This makes it clear exactly what the expectation is/

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-17 14:58:40 +10:30
Vincenzo Palazzo
9b69c56cfb lightningd: print the version of cln early
As a node matures and is no longer new, it can take some time
to determine which version of `cln` it's running.

To address this, we now display the version earlier. This ensures
that even in the event of a crash, we're aware of the running version.

(cln-meta-project-py3.11) ➜  lightning git:(macros/log-version) ✗ ./lightningd/lightningd
2023-10-12T19:21:00.899Z INFO    lightningd: v23.08.1-209-gae94be4-modded
2023-10-12T19:21:00.994Z INFO    lightningd: Creating configuration directory /home/vincent/.lightning/bitcoin
2023-10-12T19:21:01.235Z INFO    lightningd: Creating database
2023-10-12T19:21:01.279Z UNUSUAL hsmd: HSM: created new hsm_secret file

Could not connect to bitcoind using bitcoin-cli. Is bitcoind running?

Make sure you have bitcoind running and that bitcoin-cli is able to connect to bitcoind.

You can verify that your Bitcoin Core installation is ready for use by running:

    $ bitcoin-cli echo 'hello world'
2023-10-12T19:21:01.349Z **BROKEN** plugin-bcli: \nCould not connect to bitcoind using bitcoin-cli. Is bitcoind running?\n\nMake sure you have bitcoind running and that bitcoin-cli is able to connect to bitcoind.\n\nYou can verify that your Bitcoin Core installation is ready for use by running:\n\n    $ bitcoin-cli echo 'hello world'\n
2023-10-12T19:21:01.349Z INFO    plugin-bcli: Killing plugin: exited before we sent init
The Bitcoin backend died.

Link: https://github.com/ElementsProject/lightning/issues/6374
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-10-14 17:52:15 +02:00
Tony Aldon
340a7316d6 pytest: test that cln-grpc certificates are not generated when cln-grpc is not started.
We update `test_grpc_no_auto_start` test to check that we do not
generate certificates when the cln-grpc plugin is not started.

This fails currently, so next commit fix it up.
2023-10-13 10:25:36 +02:00
Tony Aldon
ebee48ca8c pytest: test checkrune when method parameter is the empty string.
Add test `test_rune_method_not_equal_and_method_empty` that reproduces
issue #6725.

This fails currently, so next commit fix it up.

Error:

```
>       with pytest.raises(RpcError, match='Not permitted: method not present'):
E       Failed: DID NOT RAISE <class 'pyln.client.lightning.RpcError'>

tests/test_runes.py:605: Failed
```
2023-10-12 20:42:43 +02:00
dergoegge
02717c73dc fuzz: bolt11 inputs 2023-10-12 19:28:28 +02:00
dergoegge
0fc9fe1a81 fuzz: test bolt11 decoding 2023-10-12 19:28:28 +02:00
Rusty Russell
176a58f9e0 pytest: wean many tests off the assumption that listchannels shows private channels.
We will be changing this, or at least deprecating it, so get our
tests ready.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-04 08:02:33 +10:30
Rusty Russell
7bb6609f9a pytest: remove old test_tlv_or_legacy
We no longer support legacy at all, so this test doesn't really
test anything.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-04 08:02:33 +10:30
Dusty Daemon
bc9333ac1e addpsbtoutput: New onchain command for PSBT output
Also added splice_out tests that use the new PSBT command.

ChangeLog-Added: New `addpsbtoutput` command for creating a PSBT that can receive funds to the on-chain wallet.
2023-10-03 10:12:39 +02:00
ShahanaFarooqui
9561094433 db: removed deprecated runes_uniqueid from vars table
Fixes: #6696

Changelog-Fixed: rune: use runes table `id` instead `runes_uniqueid` from `vars` because it returns incorrect unique id if rune/s migrated from datastore.
2023-10-03 08:56:53 +10:30
ShahanaFarooqui
9bcabbc912 runes: Reimplement rate in terms of per
Changelog-Changed: JSON-RPC: `checkrune` `rate` restriction is slightly stricter (exact division of time like `per`)
2023-10-03 06:57:54 +10:30
Rusty Russell
d61dec8925 pytest: trim mostly-reundant commando-rune test.
We test this in test_runes, so make this test more cursory (otherwise
next patch breaks it).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-03 06:57:54 +10:30
Rusty Russell
acc30c0b3f lightningd: split DUALOPEND_OPEN_INIT into DUALOPEND_OPEN_INIT and DUALOPEND_OPEN_COMMITTED.
The latter is used when we're put in the db, the former is the uncommitted state.
Currently dbid == 0 is used in addition to the state, which is unwieldy.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Experimental: JSON-RPC: added new dual-funding state `DUALOPEND_OPEN_COMMITTED`
2023-10-02 11:41:19 +10:30
Rusty Russell
2de7171286 lightningd: fold funding tx depth into a single function.
Currently it's half done in funding_depth_cb, and half in
channeld_tell_depth.  It's very confusing as a result,
with splicing, dual-funding and zeroconf.

This does introduce a behaviour change: if a channel is NORMAL and
it gets reorganized, we force close (unless we were the one who funded
it, or it's zeroconf anyway).  This is safer than continuing to use
the channel in this case!

Some tests are changed to zeroconf to make them work, but v2 doesn't
support zeroconf, so that's removed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-02 11:41:19 +10:30
Rusty Russell
8dcfe1a75c pytest: make test_splice_gossip more precise.
Check the exact scids.  Makes it simpler when failures occur.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-02 11:41:19 +10:30
Rusty Russell
eaf76ddbd6 doc: fix listpeerchannels schema to allow CHANNELD_AWAITING_SPLICE in state.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-02 11:41:19 +10:30
Rusty Russell
c52ab02bc9 patch remove-developer-test-annotations.patch 2023-10-02 11:41:19 +10:30
Rusty Russell
6203d250bf pytest: fix flake in upfront warning.
This is actually a real issue (l1 doesn't see the warning before l2
drops the connection), but it's unrelated to this PR, and will require
another one to fix.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-10-02 11:41:19 +10:30
Christian Decker
4121941d92 pytest: Fix elementsd tests 2023-09-26 19:21:05 +02:00
Rusty Russell
6c15ea44dd pytest: use --developer instead of environment variable.
And we always enable it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30
Rusty Russell
2bcae6fc76 plugins/renepay: remove DEVELOPER build-time, in favor of runtime.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30
Rusty Russell
f725edad62 plugins: remove #if DEVELOPER.
And rename dev-only-option `use_shadow` to `dev_use_shadow`.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30
Rusty Russell
de81a59b1e lightningd: mark explicitly what commands are dev-only.
And require --developer to use them.

Also refuse redirection to deprecated APIs if deprecated APIs are disabled! 

Changelog-Removed: `dev-sendcustommsg` (use `sendcustommsg`, which was added in v0.10.1)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30
Rusty Russell
c5f6893e28 common: remove #if DEVELOPER.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30
Rusty Russell
67a391f8d0 lightningd: pass --developer down to plugins, subdaemons when it set.
They might need to know this before they do anything, so cmdline seems most
natural.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-21 20:08:24 +09:30
Dusty Daemon
0a5ef7f2e6 splice: Fixes from splice-out test
Added a test for splicing out that exposed some behavior and code glitches that are addressed in this commit.

Added test for splice gossip.

Also added documentation for how to do a splice out.

ChangeLog-Fixed: Added docs, testing, and some fixes related to splicing out, insufficent balance handling, and restarting during a splice.
2023-09-21 13:41:45 +09:30
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
48522f3e9e common: don't hang up when we receive a warning.
We were allowed to, but the spec removed that.  So we handle warnings
differently from errors now.

This also means the LND "internal error" workaround is done in
lightningd (we still disconnect, but we don't want to close channel).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: we no longer disconnect every time we receive a warning message.
2023-09-20 13:56:46 +09:30
Rusty Russell
8be888e63f pytest: fix renepay test_shadow flake.
Sometimes we don't shadow because it would break our budget:

```
    def test_shadow(node_factory):
        '''Make sure we shadow correctly.'''
        l1, l2, l3 = node_factory.line_graph(3,
                                             wait_for_announce=True,
                                             opts=[{},
                                                   {'fee-base': 2000, 'fee-per-satoshi': 20, 'cltv-delta': 20},
                                                   {'fee-base': 3000, 'fee-per-satoshi': 30, 'cltv-delta': 30}])
    
        # Shadow doesn't always happen (50% chance)!
        for i in range(20):
            inv = l2.rpc.invoice(123000, f'test_renepay{i}', 'description')['bolt11']
            details = l1.rpc.call('renepay', {'invstring': inv})
            assert details['status'] == 'complete'
            assert details['amount_msat'] == Millisatoshi(123000)
            assert details['destination'] == l2.info['id']
    
>           line = l1.daemon.wait_for_log("No MPP, so added .*msat shadow fee")

tests/test_renepay.py:51:
```

```
lightningd-1 2023-09-12T05:08:39.699Z UNUSUAL plugin-cln-renepay: No shadow fee for flow 0/1: fee would add 5005msat to 123000msat, exceeding budget 128000msat.
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-19 10:20:24 +09:30
Matt Morehouse
8596208f52 fuzz: initial wire message seeds
Seeds for every peer wire message, generated from fuzzing with
-max_len=65533 and minimizing the resulting corpora.
2023-09-18 13:58:45 +09:30
Matt Morehouse
42fb17fe58 fuzz: target for your_peer_storage
Fuzz the decoding and encoding of your_peer_storage.
2023-09-18 13:58:45 +09:30
Matt Morehouse
6a975f3c1d fuzz: target for update_blockheight
Fuzz the decoding and encoding of update_blockheight.
2023-09-18 13:58:45 +09:30
Matt Morehouse
eec261101f fuzz: target for tx_signatures
Fuzz the decoding and encoding of tx_signatures.
2023-09-18 13:58:45 +09:30
Matt Morehouse
6b5df73cf4 fuzz: target for tx_remove_output
Fuzz the decoding and encoding of tx_remove_output.
2023-09-18 13:58:45 +09:30