Commit Graph

5649 Commits

Author SHA1 Message Date
Rusty Russell 1069f48082 connectd: fix binding to a UNIX domain socket.
lightning_connectd(19780): STATUS_FAIL_INTERNAL_ERROR: Failed to bind on 2 socket: Address family not supported by protocol

"Untested code is buggy code"

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-14 15:05:56 +01:00
Rusty Russell 740f4314ea pytest: test binding lightningd to a UNIX domain socket.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-14 15:05:56 +01:00
wailo e843e138fe Fix installing plugins in dockerfile (#2451)
* Improved plugin install in docker

- All files generated by 'make install' are copied
- Fixes issues with incomplete installation.
- Example: New executables created by build but are missing in docker.
2019-03-11 09:51:47 +01:00
Michael Schmoock 6f71564bdd fix: missing closedir in plugin.c 2019-03-06 23:27:07 +00:00
dlogemann afcbadf374 Remove missing config option "port" 2019-03-06 23:18:53 +00:00
Rusty Russell 1facf626d5 pylightning: allow version querying from within modules.
With the preceeding UTF-8 fix, I'd like to detect UTF-8 support.  But
AFAICT Python doesn't have a standard way of doing version exposure.

So I added __version__, but now we need to make sure it matches.  I
used the hackiest possible method.

[ Christian Decker fixed version to be sane, so previous comment no longer
  applies! --RR ]
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-05 11:43:22 +01:00
Rusty Russell cc342fda83 pylightning: make sure UTF-8 gets passed intact.
1. We need to read in as a byte string, then decode into utf8 once we
   have a marker.  Otherwise we seem to mangle it horribly, and we
   might have a bad utf8 string anyway.

2. We need to suppress the JSON \u escapes on output.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-05 11:43:22 +01:00
Rusty Russell 5f437de771 pytest: test passing utf8 into and out of plugin JSON.
We should be able to pass UTF-8 strings to and from plugins without
python turning them into JSON-\u escapes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-05 11:43:22 +01:00
Rusty Russell 00f3a84af2 test: fix thinko in gossipd/test/run-bench-find_route.c
Reported-by: @cdecker
Fixes: #2440
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-05 11:42:43 +01:00
Michael Schmoock 624ec6da27 tests: always call db_migrate() with non-NULL ld.
This will be useful when we add hooks.  For the moment, ld's contents is
undefined, but this can easily be changed.
2019-03-05 10:14:17 +00:00
Conor Scott 0d35a7111a [rpc] don't get uncommitted channels towards num_pending 2019-03-04 15:28:01 +01:00
Rusty Russell 049f2351d4 newaddr: deprecate 'address' output.
It doesn't make sense with 'all', and it's ok to be explicit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-04 15:11:20 +01:00
Rusty Russell 3e67c09d5e newaddr: support getting both bech32 and p2sh addresses.
Higher layers consume less addresses this way.

Fixes: #2390
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-04 15:11:20 +01:00
Christian Decker 5518c7cba8 configure: Check for lower-case IETF acronym in sodium constants
The v1.0.9 release of libsodium added
crypto_aead_chacha20poly1305_ietf_NPUBBYTES which we use; before that it was
...IETF_NPUBBYTES.

Since that release was in April 2016, it seems fair to simply check for
ancient versions and use the internal one if found. The alternative would be
to use the older names (which are still in the header), but given we've never
tested with such old versions, this seems safer.

Reported-by: Zoltán Gálli <@gallizoltan>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-03-04 02:38:53 +00:00
Christian Decker 61f95be0e9 pylightning: Bump version so pypi includes plugin infra 2019-03-04 00:41:40 +00:00
Christian Decker 3d4c0ab626 changelog: Setup new unreleased section post-0.7.0
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-03-04 00:34:47 +00:00
neil saitug 7f89ce43cc Update wallet/db.h
Co-Authored-By: rustyrussell <rusty@rustcorp.com.au>
2019-03-04 00:04:38 +00:00
Rusty Russell 60285187fd db: support more powerful migrations.
Allow a function as well as (or instead of!) an sql statement.  That
will let us do things like set per-channel values to the global
defaults, for example.

Since we remove the NULL termination, the final entry is ARRAY_SIZE()-1
not ARRAY_SIZE()-2.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-04 00:04:38 +00:00
Rusty Russell bef7d45f1c db: remove manual db_migration_count function.
More efficient to measure the ARRAY_SIZE(), which is a runtime
constant.  We move it into the unit test.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-04 00:04:38 +00:00
Rusty Russell b65c279557 db: don't enter into db_upgrades table on every startup.
Below this code appears:

	if (current != orig)
		db_exec(__func__, db,
			"INSERT INTO db_upgrades VALUES (%i, '%s');",
			orig, version());

But since the loop pre-increments current, this is always true.  I wondered
why there were so many duplicates in my db_upgrades table!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-04 00:04:38 +00:00
William Casarin 9aaf2fe8d4 build: fix uninitialized variable error on gcc 7.4.0
*best is checked for null before the comparison against the uninitialized
variable ever happens, so this isn't a real issue.

Initialize it to zero so that we don't fail to compile on certain gcc versions.

plugins/pay.c: In function ‘add_shadow_route’:
plugins/pay.c:644:18: error: ‘sample’ may be used uninitialized in this function
   if (!best || v > sample) {
                ~~^~~~~~~~

Signed-off-by: William Casarin <jb55@jb55.com>
2019-03-03 14:47:33 +01:00
thestick613 e613ae2d8e Increase TCP socket backlog. 2019-03-03 01:27:00 +01:00
nicolas.dorier 063149079e Installing the Pay plugin in Dockerfile for arm32v7 2019-03-02 15:21:57 +01:00
Rusty Russell 4a11bc07f9 CHANGELOG.md: v0.7.0
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-01 21:38:08 +00:00
Rusty Russell 73c02691a3 tools/built-release.sh: fix archives we produce.
We were tarring up the build dir, not the destination dir!  We did this
for 0.6.3 and nobody noticed :(

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-01 21:38:08 +00:00
Rusty Russell 1da8e498c0 doc: fill in parameters in getroute manpage.
Fixes: #2419
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-01 06:20:58 +00:00
Rusty Russell a988ed70b9 doc/REPRODUCIBLE.md: describe to do reproducible builds.
This is a separate commit, as it describes the results (as sha256sum)
of doing a test on the previous commit.  Obviously these values will
have to updated after a rebase!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-03-01 03:48:04 +00:00
wailo 2e129dd932 Installing the Pay plugin in Dockerfile 2019-03-01 00:07:56 +00:00
Rusty Russell 30445165d0 CHANGELOG.md: update for rc3.
Side note: it's also a birthday, this is not the 0.7 release name :)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-28 09:50:35 +00:00
Rusty Russell 66efcfa855 tools/repro-build.sh: do not turn on address-sanitizer by default.
@cdecker reports that this gives warnings on exit; and we can't suppress
them by setting ASAN_OPTIONS within the binary itself, unfortunately.

So for 0.7, disable it by default.  I'll work through the errors for 0.7.1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-28 05:17:21 +00:00
Rusty Russell d98fb0fd5b configure: remove bashism.
== is bash-only; for other shells this gives an error (meaning that you won't
get the sanity check):

	./configure
	Compiling ccan/tools/configurator/configurator...done
	./configure: 148: [: gcc: unexpected operator

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-28 05:17:21 +00:00
Rusty Russell 02faadfb93 amount: make it work with gcc-4.8.
```
In file included from bitcoin/chainparams.h:7:0,from bitcoin/chainparams.c:1:
./common/amount.h:36:11: error: initializer element is not constant
((struct amount_sat){(constant) + AMOUNT_MUST_BE_CONST(constant)})
^
bitcoin/chainparams.c:20:21: note: in expansion of macro ‘AMOUNT_SAT’
.max_funding = AMOUNT_SAT((1 << 24) - 1),
^
./common/amount.h:36:11: error: (near initialization for ‘networks[0].max_funding’)
((struct amount_sat){(constant) + AMOUNT_MUST_BE_CONST(constant)})
^
bitcoin/chainparams.c:20:21: note: in expansion of macro ‘AMOUNT_SAT’
.max_funding = AMOUNT_SAT((1 << 24) - 1),
```

Fixes: #2404
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-27 23:12:50 +00:00
Rusty Russell a3bac88e08 travis: add a test that we compile under gcc-4.8 (CentOS!)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-27 23:12:50 +00:00
Rusty Russell 6bfeea334b README.md: update link from listpayments to listpays.
Fixes: #2401
Reported-by: @stevenroose
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-27 23:12:04 +00:00
Rusty Russell 1dcc482350 Update CHANGELOG.md for -rc2.
And fix trivial typo in MAKING-RELEASES.md, and date retreival in
build-release.sh and repro-build.sh (real git tags start with v!)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-26 04:16:34 +00:00
Rusty Russell dce58393cb build-release.sh: fix zipfile determinism.
I tried building zipfile on a fresh clone inside KVM, and got

1. Different times inside the zipfile, since zip seems to save *local* times.
2. A different zipfile order, since zip seems to use filesystem order.

Fix both of these.  I don't know if LANG=C is necessary for git
ls-files, but it can't hurt.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 23:36:47 +00:00
Rusty Russell 6e63d79159 pylightning: translate msat input to class Millisatoshi
Rather than using LightningJSONDecoder's implicit "field name and
value ends in msat, try converting to Millisatoshi", we do it to
parameters using type annotations.

If you had a parameter which was an array or dict itself, we don't
delve into that, but that's probably OK.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 690064f7e0 pylightning: don't compare v with inspect._empty.
I originally converted input JSON naively into Millisatoshi, and the
result was a strange failure in Millisatoshi.__eq__.

It seems this is because inspect._empty.__eq__(Millisatoshi) raises
NotImplemented, and so it tries Millisatoshi.__eq__(inspect._empty)
which doesn't like it.

'is' is the correct test here, AFAICT, and doesn't suffer from these
problems.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 6ace13ba22 pylightning: make plugins use Millisatoshi-converting encoder.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 5a7d038e6e pylightning: provide a class for Lightning JSONDecoder.
Some JSON functions want a *class*, not just a hook, so provide one.
To make it clear that we want an encoding *class* and a decoding *object*,
rename the UnixDomainSocketRpc encode parameter to encode_cls.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 464858883b pylightning: reduce scope for deadlock in plugins.
If we can't marshall an object into JSON, the exception causes a deadlock
and we don't get any results.

Instead of deadlocking, our failure now is:

	lightning.lightning.RpcError: RPC call failed: method: echo, payload: {'msat': 17msat}, error: Error while processing echo: TypeError("Object of type 'Millisatoshi' is not JSON serializable",)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell c7316d7ba2 pytest: test that we translate to and from Millisatoshi on plugin RPC.
We don't, but we should, like we do for normal RPC.  However, I chose
to use function annotations, rather than names-ending-in-'msat'
because it's more Pythony.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 1982c73ebc pylightning: support functions with type annotations.
I tried annotating the plugin-millisatoshis.py plugin, and it failed like so:

	plugin-millisatoshis.py Killing plugin: "getmanifest" result is not an object: {"jsonrpc": "2.0", "id": 1, "error": "Error while processing getmanifest: ValueError(\'Function has keyword-only parameters or annotations, use getfullargspec() API which can support them\',)"}'

So, let's do that!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell e3bdc32ee8 plugin: give *some* clue in the logs of getmanifest raises an exception!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-25 21:45:21 +00:00
Rusty Russell 7ca0000869 CHANGELOG.md: update for 0.7.0-rc1
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-23 10:19:33 +00:00
Rusty Russell b2ae4f0fd7 tools/repro-build.sh: script to build an identical binary tarball.
For the moment it's only Ubuntu 18.04.1.

Complete documentation is in the final commit; you can test this using
the prior commit and comparing with my intermediate files and results
at:

	https://ozlabs.org/~rusty/clightning-repro

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-23 10:19:33 +00:00
Rusty Russell ce5d61be32 CHANGELOG.md: order into user impact and coolness, while maintaining sections.
Add the one 'Changelog-fixed' entry from a405c22fc9,
and reorder a bit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-23 10:19:33 +00:00
Rusty Russell b99617312f plugins/pay: use json_ prefix for json command handlers.
That makes them intuitive to find with TAGS or grep.

Suggested-by: @cdecker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-23 05:45:25 +00:00
Rusty Russell 203ef2ed0b listsendpays: updated version of listpayments.
New name is less confusing, and most people should be transitioning to
listpays rather than this anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-23 05:45:25 +00:00
Rusty Russell 56dfbec6bd listpays: new command to summarize pay commands.
This is to future-proof against multi-part-payments: the low-level commands
will start returning multiple results once we have that, so prepare
transition plan now.

Closes: #2372
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-02-23 05:45:25 +00:00