Commit Graph

13812 Commits

Author SHA1 Message Date
Matt Morehouse
6334797991 configure: define macro for fuzzing builds
Sometimes we want to disable certain functionality or otherwise modify
code for fuzzing. The FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION macro is
a standard way to accomplish this.

See https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode.
2023-09-18 13:58:45 +09:30
Matt Morehouse
1b8137649a fuzz: target for announcement_signatures
Fuzz the decoding and encoding of announcement_signatures.
2023-09-18 13:58:45 +09:30
Matt Morehouse
ef28e54d65 fuzz: target for accept_channel
Fuzz the decoding and encoding of accept_channel.

We create a wire.h header to share code with future targets.
2023-09-18 13:58:45 +09:30
Matt Morehouse
4ef718276f wire: correct argument order 2023-09-18 13:58:45 +09:30
Rusty Russell
91cb4835d3 Makefile: don't delete python-generated files in distclean.
We do not, in fact, require Python to build, so we should still work
after `make distclean`.

Fixes:  #6536
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-15 20:27:24 +02:00
Christian Decker
305579305d gci: Update apt cache before installing
CI was broken due to an outdated repository cache, pointing to a
yanked file.

Changelog-None
2023-09-15 14:43:19 +02:00
Dusty Daemon
2a870eb5fa configure: typo fix
Fix typo in configure script

ChangeLog-None
2023-09-15 09:28:49 +09:30
Christian Decker
cda06db367 gci: Fix wrong guard on rebase step 2023-09-14 10:30:40 +09:30
Christian Decker
4ff513da55 ci: Add a server to track flakyness in pytest tests 2023-09-14 10:30:40 +09:30
Rusty Russell
e66d642e3d CHANGELOG.md: update for v23.08.1 release
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-13 18:07:45 +09:30
Rusty Russell
4431e4199f Makefile: regnerate config.vars if configure changes (recently PYTHON var).
We didn't want a rule to generate config.vars, since user should run configure manually
with their desired options.  However, we do want to be able to *refresh* it, because
otherwise, if we need a new configuration var for our Makefile, it won't get refreshed:

```
$ make
CC: cc -DBINTOPKGLIBEXECDIR="../libexec/c-lightning" -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -Wshadow=local -std=gnu11 -g -fstack-protector-strong  -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/libbacktrace/ -I external/gheap/ -I external/build-x86_64-linux-gnu/libbacktrace-build -I external/libsodium/src/libsodium/include -I external/libsodium/src/libsodium/include/sodium -I external/build-x86_64-linux-gnu/libsodium-build/src/libsodium/include -I . -I/usr/local/include  -I/usr/include/postgresql   -DCCAN_TAKE_DEBUG=1 -DCCAN_TAL_DEBUG=1 -DCCAN_JSON_OUT_DEBUG=1 -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS  -DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 -DCOMPAT_V081=1 -DCOMPAT_V082=1 -DCOMPAT_V090=1 -DCOMPAT_V0100=1 -DCOMPAT_V0121=1  -DBUILD_ELEMENTS=1 -c -o
PYTHONPATH=contrib/msggen  contrib/msggen/msggen/__main__.py
LD: cc     config.vars  -Lexternal/build-x86_64-linux-gnu -lwallycore -lsecp256k1 -ljsmn -lbacktrace -lsodium -L/usr/local/include -lm -lsqlite3  -lz  -L/usr/lib/x86_64-linux-gnu -lpq -o
/bin/sh: 1: contrib/msggen/msggen/__main__.py: Permission denied
make: *** [Makefile:371: cln-grpc/proto/node.proto] Error 126
make: *** Waiting for unfinished jobs....
```

Here, PYTHON is the new var (here, unset).  If we were building a binary, we'd depend on config.h,
and the Makefile says how to refresh that.  But the Makefile includes config.vars (causing an
implicit dependency) so we really should have a rule to make that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-13 14:36:29 +09:30
Rusty Russell
79d08724e3 wallet: slightly neaten fundpsbt code.
We can keep a single array of 'already considered' utxos, with the same
result as Tony's patch prior.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-13 14:34:59 +09:30
Tony Giorgio
a5367773d5 wallet: Exclude uneconomical UTXOs from fundchannel
If a node has an onchain balance with at least one uneconomical UTXO, the fundchannel RPC call will lock up the node and will eventually crash it with OOM issues if the economical UTXO(s) do not add up to the fundchannel amount. This is because the while loop never exits because it keeps pulling in the same uneconomical UTXOs forever.

Changelog-Fixed: wallet: fundchannel no longer loops forever if the wallet contains insufficient funds, but an uneconomical UTXO.
2023-09-13 14:34:59 +09:30
Rusty Russell
47f4e11c87 tests: test for fundchannel fail with tiny utxo
Tony Giorgio <tonygiorgio@protonmail.com> says:

Reproduce:

1.  Add 1 600 sat UTXO to a fresh node

2.  Verify the fundchannel command fails with a low fee rate:

```
./lightning-cli fundchannel 0366abc8eb4da61e31a8d2c4520d31cabdf58cc5250f855657397f3dd62493938a 100000 1000
{
   "code": 301,
   "message": "Could not afford 100000sat using all 1 available UTXOs: 99522sat short"
}
```

3.  Now do the command again, but with a higher fee rate, making the 600 sat UTXO uneconomical:

```
./lightning-cli fundchannel 0366abc8eb4da61e31a8d2c4520d31cabdf58cc5250f855657397f3dd62493938a 100000 10000
```

4. Observe the RPC call and the logs. The RPC call will never return, and the logs will stop after this:

```
2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: multiconnect done.
2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: 'parsefeerate' done
2023-04-16T10:58:45.839Z DEBUG   plugin-spenderp: mfc 34: fundpsbt.
```

5. Keep CLN running long enough and you'll eventually run OOM.
2023-09-13 14:34:59 +09:30
Peter Neuroth
a3d393a24d tools: Make shellcheck happy
This change proposed by RustyRussel stops a race condition on the
former `echo` line.
2023-09-13 10:42:54 +09:30
Peter Neuroth
8f02678147 tools: Fix accidental override on checksum copy
The former seemed to replace the wrong line with the copied checksum.
We now add read it from the first line and add it on top of our sums.
This expression also seems a fair bit easier to understand now.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2023-09-13 10:42:54 +09:30
Peter Neuroth
43aeaff1a8 tools: Add sha256sum check for detailed hint
Removing the Fedora fake as it seems to be not necessary. We later copy
the checksum from the release captains checksums anyway.
Also adding the sum check as it gives more details about which file did
not match if so.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2023-09-13 10:42:54 +09:30
Peter Neuroth
e76c14cb0c tools: Add check if the checksum file exists
This ensures that we have the release captains checksum file where we
expect it to be and gives a little hint where to get it if needed.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2023-09-13 10:42:54 +09:30
ShahanaFarooqui
761172001b plugin/clnrest: Deleting redundant README.md 2023-09-12 16:10:15 +09:30
Adi Shankara
2331eff2db doc/rest: add documentation for REST interface 2023-09-12 16:10:15 +09:30
Rusty Russell
2765939adb runes: fix weird unnecessary zero-test.
This seems to be a cut & paste bug (mine, AFAICT!) from the command code:

```
	rune = rune_derive_start(cmd, master_rune,
				 tal_fmt(tmpctx, "%"PRIu64,
					 rune_counter ? *rune_counter : 0));
```

In that case, rune_counter was a pointer, which could be NULL.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-12 15:19:02 +09:30
Rusty Russell
785fe973a6 runes: ensure that uniqueid is a valid number.
It always is for runes we create, but in theory you can take our secret key
and make our own runes with your own tools.

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

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-12 15:19:02 +09:30
Rusty Russell
a4644550a2 clnrest: don't require nodeid (FIXME: needs screenshot updates!)
This was a misunderstanding: nodeid is useful for commando, where it's the
peer's nodeid, and Noise-XK guarantees that we know who that is.  It's
not useful for clnrest, so don't require it (it was our node id, which
is redundant).

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

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

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
No-schema-diff-check: We're simply making optional, not deprecating!
2023-09-12 15:19:02 +09:30
Rusty Russell
bbb3459d5e doc: point checkrune at createrune for rune field details.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-12 15:19:02 +09:30
Rusty Russell
75e61a2e53 doc: clean up checkrune man page.
Usage line isn't correct, as fields are not optional, and return
needs fleshing out for error codes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-12 15:19:02 +09:30
Rusty Russell
f8a3c64500 doc: fix checkrune request schema.
There's actually no "filter" here, this was mistakenly taken from commando.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-12 15:19:02 +09:30
Tony Giorgio
5ac9fdd172 doc: update to reflect new bitcoind requirement 2023-09-12 13:55:43 +09:30
ShahanaFarooqui
51ab5858c7 doc: Updated instructions for signing, co-signing and Docker publishing
Changelog-None
2023-09-12 13:20:34 +09:30
ShahanaFarooqui
e13747bbe6 script: docker build
- With push or load options
- multiarch from single Dockerfile
- Add latest and version manifests too
2023-09-12 13:20:34 +09:30
ShahanaFarooqui
15b0d4039d docker: Install tini in final stage 2023-09-12 13:20:34 +09:30
daywalker90
451fb77e5b add Eq, PartialOrd, Ord, Hash to ShortChannelId 2023-09-11 18:24:51 +02:00
nicolas.dorier
a1e8c1c102 Dockerfiles must not invalidate the docker cache 2023-09-11 11:07:50 +09:30
ShahanaFarooqui
669fe35359 doc: Updated old links and deleted old file 2023-09-11 10:51:53 +09:30
ShahanaFarooqui
a55915be9e doc: Updated Backup and Recovery 2023-09-11 10:51:53 +09:30
Christian Decker
990096f904 schema: Fix wrong type of CLTV in route
We were using `number` instead of `u32` which caused it to be
serialized to string with a decimal, which then would be rejected by
lightningd.

Changelog-Fixed: proto: Fixed a wrong number type being used in routes
2023-09-01 07:32:14 +09:30
maxwedwards
5a4e6ec7e0 doc: add tip on extracting binary release 2023-08-31 16:13:52 +09:30
ShahanaFarooqui
e788f76f99 plugin/clnrest: do not read json payload if data length is zero
OpenAPI readme always includes `content-type: application/json` header, even when body parameters are empty.
But the server expects data if the content-type has been sent.
This results in a "Server Error" response for non-param requests from readme doc.
This only affects readme requests as it is designed to send the header by default.

Changelog-None
2023-08-31 16:13:35 +09:30
Rusty Russell
f4f4ab34f3 renepay: fix case where shadow increases amount past payment amount.
Without this, sendpay will refuse to pay.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-31 16:13:21 +09:30
Rusty Russell
3285aa0eea renepay: fix shadow route extension logic.
pseudorand(1) is always 0, and capacity test was the wrong way.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-31 16:13:21 +09:30
Rusty Russell
a234888209 pytest: test for shadow route additions.
This fails currently, so next commits fix it up.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-31 16:13:21 +09:30
Rusty Russell
7a92eb2d89 renepay: calculate fee and delay accumulation correctly.
1. When we add a shadow amount, we were using the wrong channel for
   the fee calculation.
2. Similarly, when calculating the delay amount.

The result is that we can get WIRE_INCORRECT_CLTV_EXPIRY repeatedly
from nodes.

Reported-by: https://github.com/Sjors
Fixes: #6620
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changlog-Experimental: Fixed: `renepay` handles ctlv correctly when it varies along a path.
2023-08-31 16:13:21 +09:30
Rusty Russell
0135d563a0 pytest: write test to ensure renepay the correct channel's fee/cltv info.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-31 16:13:21 +09:30
Rusty Russell
14e28a51ce renepay: don't crash if we get failure from sendpay.
This happened while I was hacking (it shouldn't normally!): cmd here is NULL.

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

Reported-by: @ShahanaFarooqui
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSON-RPC: `showrunes` on a specific rune would always say `stored`: false.
2023-08-31 05:33:15 +09:30
Rusty Russell
7429b1e7e1 pytest: test to show that we got db ids incorrect.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-31 05:33:15 +09:30
Rusty Russell
e3b1549b64 configure: don't assume python3, create $PYTHON var.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-08-28 12:18:06 +02:00
Christian Decker
8e2e7b1c51 rs: Bump crate versions before publishing
Changelog-None
2023-08-28 11:19:30 +02:00