Commit Graph

7351 Commits

Author SHA1 Message Date
darosior da476848d1 pytest: add a C testing plugin to test libplugin
We mark the test as xfail() as it exposes that libplugin's PLUGIN_RESTARTABLE
was not taken into account !
2020-02-10 09:49:15 +10:30
darosior b91433cb42 libplugin: use json_stream for all plugins' commands 2020-02-10 09:49:15 +10:30
darosior 2bff80e3de libplugin: use json_stream helpers for RPC calls
This adds helpers to start and send a jsonrpc request using json_stream
in order to benefit from the helpers.

This then simplifies existing plugins RPC requests by using json_stream
helpers.
2020-02-10 09:49:15 +10:30
darosior 0546728819 libplugin: use json_stream helpers for handle_getmanifest 2020-02-10 09:49:15 +10:30
darosior 45e9f53c6b libplugin: expose helpers to start and end a jsonrpc response
The usual json_stream starters and command_result enders.
2020-02-10 09:49:15 +10:30
Christian Decker 9521549c49 elements: Fix missing witness script entry for fee outputs
Fixes #3487
2020-02-08 14:26:12 +01:00
Niklas Claesson de5eaf2238 configurator: Enable running configurator in wrapper
Since the probing binaries compiled by the configurator needs to run on
the host machine we provide a variable CONFIGURATOR_WRAPPER that can be
set to anything that you want to wrap the calls with.

One example is `qemu-aarch64-static`.
2020-02-06 13:37:54 +10:30
Rusty Russell 6209ae1abf ccan: update to get configurator with --wrapper option
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-02-06 13:37:54 +10:30
Rusty Russell f376a9c24c common: use tabs everywhere.
Didn't generally fixup inside comments and the bech32 code: reformatting that
is just anti-social.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-02-05 14:19:12 +01:00
Rusty Russell 5d2fdfe66b common: add check that pico-valued invoices are round numbers.
Otherwise you can ask for a sub-millisatoshi amount, which is dumb and
violates the spec.

See-also: https://github.com/lightningnetwork/lightning-rfc/pull/736
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: We now reject invoices which ask for sub-millisatoshi amounts
2020-02-05 14:19:12 +01:00
Rusty Russell 3e9d4de02e common: add testing for proposed bolt11 additional tests.
See-also: https://github.com/lightningnetwork/lightning-rfc/pull/736
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-02-05 14:19:12 +01:00
Rusty Russell 77c867d95f common: fix bolt11 parsing of unknown `f` versions.
As tested in next test.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-02-05 14:19:12 +01:00
Rusty Russell d8e933aac7 common: add pico-BTC parsing test from proposed BOLT.
See-also: https://github.com/lightningnetwork/lightning-rfc/pull/699
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-02-05 14:19:12 +01:00
Rusty Russell 7028493d01 common: implement route comparison in run-bolt11.
This next test will have route hints.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-02-05 14:19:12 +01:00
darosior 4772025b5d libplugin don't expose the plugin struct 2020-02-05 17:05:56 +10:30
darosior b6b2e6727e libplugin: make deprecated_apis a global 2020-02-05 17:05:56 +10:30
darosior 02fe34ed95 libplugin: don't expose the rpc_conn struct 2020-02-04 13:24:32 +10:30
darosior b31e3b1541 libplugin: pass a pointer to plugin to send_outreq
autoclean needs to send outreqs from a timer cb, hence with cmd == NULL.
2020-02-04 13:24:32 +10:30
darosior c765a223f1 libplugin: use ccan/io for async Rpc requests 2020-02-04 13:24:32 +10:30
darosior 765626875e libplugin: use ccan/io for notifications 2020-02-04 13:24:32 +10:30
darosior 9ebfdf0b8c libplugin: add remaining globals to the global state
But not the outreqs helpers, which will be moved when passing
send_outreq_ to using ccan/io.
2020-02-04 13:24:32 +10:30
darosior 499dce1c38 libplugin: include the rpc conn into the global state
And rename the struct name, as it's now only used for RPC.
2020-02-04 13:24:32 +10:30
darosior 98e8aac75f libplugin: use ccan/io for response to plugin commands
This pass to json_stream helpers for commands outputs, but keeps
compatibility with existing plugins which use jout as of now, by not
starting/closing the "result"/"error" objects.
2020-02-04 13:24:32 +10:30
darosior e6f56765ca common/json: add a json helper for the new errcode type 2020-02-04 13:24:32 +10:30
darosior 42cd23092c libplugin: use ccan/io for lightningd connections
Now we have streams and a global object, we can use them for io_plans.
This makes the logic closer from lightningd/plugin (it has been mostly
stolen from here), and simplifies the main.
This also allows plugins to use io_plans (thanks to the io_loop) for
asynchronous connections.

This commit only handle incoming commands.
2020-02-04 13:24:32 +10:30
darosior ddf14613d1 libplugin: introduce a top-level object
Having a global object is very handy to pass to `io_plan`s, which would
have otherwise required a whole bunch of new globals.
2020-02-04 13:24:32 +10:30
darosior 3510c29e5d common: move json_stream helpers to common/json
Now that we have json_stream in common/, we can move all the related
helpers from lightningd/json to common/json. This way everyone can
benefit of them (including libplugin, the plugins themselves,
potentially lightning-cli), not lightningd alone!

Note that the Makefile of the common/test/ had to be modified, because
the new helpers make use of common/wireaddr... Which turns out to
\#include <lightingd/lightningd.h> ! So we couldnt just include the .c
and add mocks if we redefined some structs (hello run-param).
2020-02-04 13:24:32 +10:30
darosior d35387f489 common: move json_stream from lightningd/ to common/
It's not lightningd-specific and we are going to need it for libplugin. The only
drawback is the log_io removal in json_stream_output_write()..
2020-02-04 13:24:32 +10:30
darosior 9030e5d779 pytest plugins: use the standard 'no operation' syntax for hooks 2020-02-04 01:07:59 +00:00
ZmnSCPxj jxPCSnmZ 6e34aa233a lightningd/: Hooks now support a consistent interface for 'no operation'.
Changelog-Changed: The hooks `db_write`, `invoice_payment`, and `rpc_command` now accept `{ "result": "continue" }` to mean "do default action", in addition to `true` (`db_write`), `{}` (`invoice_payment`), and `{"continue": true}` (`rpc_command`). The older "default" indicators are now deprecated and are now recognized only if `--deprecated-apis` is set.
2020-02-04 01:07:59 +00:00
Niklas Claesson f9b3b96a63 external: Reorganize to support cross-compilation
On CI it is nice to cache the external dependencies. However if we
always compile them in the same folder we cannot cache for multiple
different architectures. After this commit native compile targets will
still live in `external` but cross compiled versions will live in
`external/<arch>`.
2020-02-04 11:16:02 +10:30
Niklas Claesson b8ee4896ed libs: Update libwally-core to release 0.7.5 2020-02-04 11:16:02 +10:30
Ken Sedgwick 5fd0ed79f4
lightningd: Added --subdaemon command to allow alternate subdaemons.
Changelog-Added: lightningd: Added --subdaemon command to allow alternate subdaemons.

[ Wow, that was mammoth; 44 comments over 12 commits. Feels almost unfair to squash it into one commit, so I wanted to note @ksedgwic's perseverence here! --RR ]
2020-02-04 10:44:13 +10:30
Ken Sedgwick 5c8f881a75
hsmd: Added fields to hsm_sign_remote_commitment_tx to allow complete validation.
Changelog-Added: hsmd: Added fields to hsm_sign_remote_commitment_tx to allow complete validation by signing daemon.
2020-02-04 10:40:43 +10:30
Vasil Dimov 149620ee0f build: fix and simplify doc/index.rst generation
* Fix usage of `echo "...\n..."` (without `-e`), generating a
broken output:
```
   lightningd-config <lightningd-config.5.md>
   lightningd\nlightning-autocleaninvoice.7.md <lightningd.8.md\nlightning-autocleaninvoice.7.md>
```

* Use `$(SORT)` instead of bare `sort` to avoid locale-dependent sort.

* Strip the trailing .[0-9].md without invoking sed.

* Sort all man pages as one block.

Changelog-None
2020-02-03 15:38:11 +00:00
Vasil Dimov 1015e3774a build: avoid repetition of `LC_ALL=C sort`
Put `LC_ALL=C sort` in a variable and use it everywhere. It was
forgotten in one place.

Without `LC_ALL=C` it would order `a.b` before `a-c` even though
`. (0x2E)` > `- (0x2D)`.

Changelog-None
2020-02-03 15:38:11 +00:00
Vasil Dimov 0e3fb5e590 build: use [[:space:]] instead of \s in regex
The former is defined by IEEE Std 1003.2 ("POSIX.2"), the latter does
not work on FreeBSD.

Changelog-None
2020-02-03 15:38:11 +00:00
Vasil Dimov 18a40c0c5d build: re-record the result of `make update-mocks`
Changelog-None
2020-02-03 15:38:11 +00:00
Vasil Dimov 125d63e1cc connectd: use PRIu8 for printing u8 instead of %d
Changelog-None
2020-02-03 15:38:11 +00:00
Vasil Dimov 46f6c6b96e lightningd: fix wrong command in response message
listpayments was removed in 077ba88b. Suggest listpays instead.

Changelog-None
2020-02-03 15:38:11 +00:00
ZmnSCPxj jxPCSnmZ 9346043f94 doc/PLUGINS.md: Mention `data_version` field of `db_write`, sketch how the backup plugin should work.
ChangeLog-Added: Fully documented `db_write` hooks in `doc/PLUGINS.md`.
2020-02-03 13:32:35 +01:00
darosior d2638c99af pytest: test withdrawal transactions' nLockTime 2020-02-03 00:45:27 +00:00
darosior a589daa235 wallet: fuzz the nLockTime added to withdraw transactions 2020-02-03 00:45:27 +00:00
darosior 273029f244 wallet: set nLockTime to the tip for withdrawal transactions
This sets the nLockTime to the tip (and accordingly each input's nSequence to
0xfffffffe) for withdrawal transactions.

Even if the anti fee-sniping argument might not be valid until some time yet,
this makes our regular wallet transactions far less distinguishable from
bitcoind's ones since it now defaults to using native Segwit transactions
(like us). Moreover other wallets are likely to implement this (if they
haven't already).

Changelog-Added: wallet: withdrawal transactions now sets nlocktime to the current tip.
2020-02-03 00:45:27 +00:00
Wladimir J. van der Laan e4c6fd89b7 Add missing `extern` qualifiers for gcc 10
GCC 10 defaults to `-fno-common`. no longer automatically sharing
global variable definitions, which makes it important to define
them in only one place (otherwise there will be duplicate definition
errors). Add `extern` qualifiers where (I think) is the best place for
them.
2020-02-02 12:59:17 +10:30
ZmnSCPxj jxPCSnmZ fd76b8bfba doc/: Doc clarifications regarding connecting and funding.
ChangeLog-Fixed: Clarified about connection in documentation.  Also, `fundchannel`  already `connect`s if your node knows how to contact the desired peer for a few versions now, so clarify documentation about this as well.
2020-02-01 16:53:01 +01:00
Christian Decker 6c19818314 pyln-proto: Add invoice utilities
We are about to disect a couple of invoices for features, so let's add a class
that can encode and decode invoices from bolt11 strings. This is pretty much
the lnaddr.py file created by @rustyrussell with some minor changes. I'm
planning to clean this up further which is why I'm only exporting the
`Invoice` class for now.
2020-02-01 16:50:58 +01:00
Christian Decker 24219b38f9 pyln: Add unit tests from pyln-* to `make check-python` 2020-02-01 16:50:58 +01:00
Christian Decker 9e2231aaa8 travis: Make sure to install all python dependencies 2020-02-01 16:50:58 +01:00
Rusty Russell f3600d22a0 lightningd: disallow `msatoshi` arg to sendpay unless exact when non-MPP.
Using it with a different value to the amount sent causes a crash in 0.8.0,
which is effectively deprecating it, so let's disallow it now.

Changelog-Changed: If the optional `msatoshi` param to sendpay for non-MPP is set, it must be the exact amount sent to the final recipient.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-01-31 14:23:18 +01:00