Commit Graph

11944 Commits

Author SHA1 Message Date
Rusty Russell df4b477e88 keysend: allow extratlvs parameter, even in non-experimental mode.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `keysend` now has `extratlvs` option in non-EXPERIMENTAL builds.
2022-09-22 17:19:11 +09:30
Rusty Russell ce0f544073 keysend: try to find description in TLV.
"Who needs specs?"  FFS...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: Protocol: `keysend` will now attach the longest valid text field in the onion to the invoice (so you can have Sphinx.chat users spam you!)
2022-09-22 17:19:11 +09:30
antongalitch 41502be60a Fix a small typo 2022-09-22 10:00:35 +09:30
Christian Decker 4355612646 gh: Mark some derived files as such
These should never be merged manually, rather have the local copy
remain untouched and ask them to regenerate altogether. Also not
showing in Github so reviewers don't get confused.
2022-09-21 14:33:13 +02:00
Rusty Russell 0db01c882f pytest: fix flake in test_sendcustommsg
We assume that because we've told l3 to shut down, l2 already sees it
as disconnected.  But CI is ...slow... today!

```
        # `l3` is disconnected and we can't send messages to it
>       assert(not l2.rpc.listpeers(l3.info['id'])['peers'][0]['connected'])
E       assert not True

tests/test_misc.py:2218: AssertionError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-21 12:15:48 +02:00
Rusty Russell 5a1c2447cb pyln-client: use f strings to concatenate JSON ids, handle older integer ids.
We don't really support using pyln-client with older Core Lightning versions,
but this is neater anyway.  I checked: f-strings go back to python 3.6, so
we can use them (I think this may be the first!).

Suggested-by: @MiWCryptAnalytics
Fixes: #5609
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-21 12:15:48 +02:00
Christian Decker 774d16a72e openingd: Fail if dust and max_htlcs result in 0output commitment tx
Prior to this we might end up with a commitment transaction without
any outputs, if combined with `--dev-allowdustreserve`. Otherwise the
reserve being larger than dust means the funder could not drop its
direct output to be below dust.

Reported-by: Rusty Russell <@rustyrussell>
2022-09-21 11:25:47 +02:00
Christian Decker 75fe1c1a66 common: Add multiplication primitives for amount_msat and amount_sat
The scale variants weren't usable since they use `double` as a scale
factor, which in turn causes imprecisions.
2022-09-21 11:25:47 +02:00
Christian Decker 493a0dfcd4 pytest: Exercise all dust zeroreserve case
This just shows we need to add that constraint.

Reported-by: Rusty Russell <@rustyrussell>
2022-09-21 11:25:47 +02:00
Christian Decker 759fcb64a8 pay: If the channel_hint matches our allocation allow it
It means we consume the channel completely to the best of our
knowledge, so let that through.

Changelog-Fixed: pay: Squeezed out the last `msat` from our local view of the network
2022-09-21 11:25:47 +02:00
Christian Decker bdda62e1a4 pytest: Add test for mixed zeroreserve funding
Tests that we can have zeroreserve nodes accept and open new channels
with non-zeroreserve nodes, without throwing errors
2022-09-21 11:25:47 +02:00
Christian Decker 54b4baabb0 opening: Add `dev-allowdustreserve` option to opt into dust reserves
Technically this is a non-conformance with the spec, hence the `dev`
flag to opt-in, however I'm being told that it is also implemented in
other implementations. I'll follow this up with a proposal to the spec
to remove the checks we now bypass.
2022-09-21 11:25:47 +02:00
Christian Decker 1bd3d8d9f9 openingd: Remove dust check for reserve imposed on us
This check, while in line with the specification, would cause issues
in mixed setups when the funder or fundee allows dust reserves, but
the counterparty does not. It is not an issue for the non-dust reserve
node since in this case it's the peer giving us more flexibility not
the other way around.
2022-09-21 11:25:47 +02:00
Christian Decker 67467213cb opening: Add `dev-allowdustreserve` option to opt into dust reserves
Technically this is a non-conformance with the spec, hence the `dev`
flag to opt-in, however I'm being told that it is also implemented in
other implementations. I'll follow this up with a proposal to the spec
to remove the checks we now bypass.
2022-09-21 11:25:47 +02:00
Christian Decker c5b2aee5c6 pytest: Add a zeroreserve test 2022-09-21 11:25:47 +02:00
Christian Decker c3e9cb7a47 openingd: Add zeroconf-no-really-zero mode
This is incompatible with the spec as it removes the enforcement for
reserves being above dust, but from what I can see from other
implementations it seems that others have allowed this as well.

This commit just guards the necessary changes with compilation guards, so
we can decide either way quickly. This part of the PR is not intended
to be final, just as a discussion basis.
2022-09-21 11:25:47 +02:00
Christian Decker 2def843dce pay: Allow using a channel on equality of estimated capacity
In the case of the local channel we set the estimation to the exact
value spendable, which is important when we want to drain a channel,
because there we actually want to get the last msat.
2022-09-21 11:25:47 +02:00
Christian Decker 5a54f450bd openingd: Pass `reserve` down to openingd when funding 2022-09-21 11:25:47 +02:00
Christian Decker 8d6423389a openingd: Wire `reserve` value through to `openingd` 2022-09-21 11:25:47 +02:00
Christian Decker 9a97f8c154 plugin: Add `reserve` to `openchannel` hook result
Changelog-Added: plugin: The `openchannel` hook may return a custom absolute `reserve` value that the peer must not dip below.
2022-09-21 11:25:47 +02:00
Christian Decker 5c1de8029a openingd: Add `reserve` to `fundchannel` and `multifundchannel`
Changelog-Added: JSON-RPC: `fundchannel`, `multifundchannel` and `fundchannel_start` now accept a `reserve` parameter to indicate the absolute reserve to impose on the peer.
2022-09-21 11:25:47 +02:00
Christian Decker 7159a25e73 openingd: Add method to set absolute reserve 2022-09-21 11:25:47 +02:00
Christian Decker fcd2320de7 gha: Make the setup and build scripts exit if anything fails
Caused quite a few headaches and red herrings in the past, so let's be
stricter.

Changelog-None
2022-09-20 10:33:40 +02:00
Christian Decker ab95d2718f pyln: Reduce dependency strictness for pyln-testing 2022-09-20 10:33:40 +02:00
Greg Sanders 248d60d7bd Don't report redundant feerates to subdaemons 2022-09-19 19:10:35 +02:00
Rusty Russell 5b58eda748 libplugin: mark the cmd notleak() whenever command_still_pending() called.
This is what we do in lightningd, which makes memleak much more forgiving:
you can hang temporaries off cmd without getting reports of leaks (also
when send_outreq called).

We remove all the notleak() calls in plugins which worked around this!
And avoid multiple notleak labels, since both send_outreq() and
command_still_pending() can be called multiple times.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-19 11:34:42 +09:30
Rusty Russell 701dd3dcef memleak: remove exclusions from memleak_start()
Add memleak_ignore_children() so callers can do exclusions themselves.

Having two exclusions was always such a hack!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-19 11:34:42 +09:30
Rusty Russell 3380f559f9 memleak: simplify API.
Mainly renaming.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-19 11:34:42 +09:30
Rusty Russell fd71dfc7f7 gossmap: optimize asserts().
They are surprisingly expensive!

Running `time ./plugins/renepay/test/run-not_mcf-gossmap gossip_store-sgl.rustcorp.com.au-2022-04-19 024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605 02ebb3b8a2316b3e876ea3f3d8124a3ab97f30b128f619608eb06b5251235dc2d9 10000000000 0.1`:

Before (-Og):
	real	0m1.495s
Before (no opt):
	real	0m2.552s

After (-Og):
	real	0m0.579s
After (no opt):
	real	0m1.061s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-19 10:18:55 +09:30
Rusty Russell 4cdb4167d2 gossmap: make local_addchan create private channel_announcement in correct order.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-19 10:18:55 +09:30
Rusty Russell 016e332304 gossmap: add functions to map index back to node/chan.
Useful if you want to store per-chan or per-node side-data in an array.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-19 10:18:55 +09:30
Rusty Russell 6a48ed9e82 gossmap: fail to get capacity of locally-added chans (don't crash!).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-19 10:18:55 +09:30
Rusty Russell 2da5244e83 jsonrpc: make error codes an enum.
This allows GDB to print values, but also allows us to use them in
'case' statements.  This wasn't allowed before because they're not
constant terms.

This also made it clear there's a clash between two error codes,
so move one.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: Error code from bcli plugin changed from 400 to 500.
2022-09-19 10:18:55 +09:30
Rusty Russell 7fa1364645 build: allow DEVELOPER builds with -Og and gcc 9.4.0
Removes some warnings.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-19 10:18:55 +09:30
Rusty Russell d2edeff698 contrib/giantnode.py: populate three regtest nodes with many invoices/forwards/payments.
If you don't want to run this (and it's v slow without the coming
optimizations!) you can download a copy from:

	https://ozlabs.org/~rusty/giantnodes.tar.xz

(Unpack in /, then just `start_ln 3`).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-18 16:21:54 +02:00
Rusty Russell a99a72be9b contrib/startup_regtest.sh: misc fixes and add destroy_ln, print usage.
We weren't consistent with passing through regtest, and we should be.
Also, destroy_ln is useful for getting rid of all dirs.  Finally, use
eatmydata if it's available.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-18 16:21:54 +02:00
Christian Decker 9bba7ba1a4 Update doc/INSTALL.md
Co-authored-by: neil saitug <niftynei@gmail.com>
2022-09-18 14:19:16 +02:00
Dustin Dettmer 3aeac0a58c docs: Correct a command typo for Ubuntuu 2022-09-18 14:19:16 +02:00
Dustin Dettmer cc206e1f0e connectd+: Flake/race fix for new channels
1) dualopen has fd to connectd
2) channeld needs to take over
3) dualopen passes fd that leads to a connectd over for channeld to use
4) lightningd must receive the fd transfer request and process
5) dualopen shuts down and closes everything it owns

4 & 5 end up in a race. If 5 happens before 4, channeld ends up with an invalid fd for connectd — leaving it in a position to not receive messages.

Lingering for a second makes 4 win the race. Since the daemon is closing anyway, waiting for a second should be alright.

Changelog-Fixed: Fixed a condition for newly created channels that could trigger a need for reconnect.
2022-09-18 21:18:32 +09:30
niftynei 05e2317142 doc/install: get rid of out of date mrkd / mistune install instructions 2022-09-18 09:48:50 +09:30
niftynei 37fc0d8c6f docker: use pip install + poetry export instead of poetry update
I dunno man, poetry just seems like a mess.
2022-09-18 09:48:50 +09:30
Christian Decker 37c07ddfe5 pyln: Add grpcio and protobuf dependencies to pyln-testing 2022-09-17 13:45:51 +02:00
Christian Decker 74cd0a7280 gci: Use stable rust instead of nightly
Nightly occasionally breaks, so use stable instead.

Changelog-None
2022-09-16 17:23:40 +02:00
Rusty Russell bbe1711e16 lightningd: use jcon logging for commands where possible.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-16 12:31:45 +09:30
Rusty Russell caecd1ee0a lightningd: don't log JSON ids as debug, use log io.
They are cute, sure, but they do spam the logs.

@Suggested-by: @niftynei
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-16 12:31:45 +09:30
Rusty Russell 42c9aa1a5f libplugin: forget pending requests if associated command freed.
This is usually fine, but without this, commando (another branch!) has
a race:

1. A command has multiple parts.
2. We start sending them out.
3. We get a response, which completes the cmd.
4. We go to send the next one out, but it's been freed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-16 12:31:45 +09:30
Rusty Russell bf54d6dcf5 libplugin: use proper JSON id for rpc_scan().
And fold start_json_request() and start_json_rpc() into the core
function since it's the only caller.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-16 12:31:45 +09:30
Rusty Russell fdc59dc94a contrib/pyln-testing: pass through id correctly.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-16 12:31:45 +09:30
Rusty Russell f1f2c1322d contrib/pyln-client: construct JSON ID correctly.
They can set their name explicitly, but if they don't we extract it from argv[0].

We also set it around callbacks, so it will be expanded by default.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-16 12:31:45 +09:30
Rusty Russell d360075d22 libplugin: use string ids correctly.
Build them from the command which caused them, and take plugin name
as basename with extension stripped.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-16 12:31:45 +09:30