Commit Graph

9027 Commits

Author SHA1 Message Date
Rusty Russell ca2bd98082 unittest: use common_setup / common_shutdown almost everywhere.
Avoids much cut & paste.  Some tests don't need any of it, but most
want at least some of this infrastructure.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-12-02 12:55:09 +10:30
Rusty Russell 39f4ca98b5 common: check for outstanding taken() pointers in common_shutdown.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-12-02 12:55:09 +10:30
Rusty Russell ae1a130ab5 ccan: update ccan/utf-8 to reject NULs embedded in strings.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-12-02 10:38:04 +10:30
Rusty Russell c29e290ee6 common/json: json_add_stringn helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-12-02 10:38:04 +10:30
Rusty Russell 9361b62e3a libplugin: add command_hook_success helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-12-02 10:38:04 +10:30
Rusty Russell d9586bbde1 json: add json_tok_endswith and json_tok_startswith helpers.
I wanted this for offers, and it's generally useful.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-12-02 10:38:04 +10:30
Rusty Russell 3408f8f998 gossipd: fix memleak.
Not really a leak, since we eventually process pending, but still:

```
    **BROKEN** gossipd: MEMLEAK: 0x5562fa63bab8
    **BROKEN** gossipd:   label=wire/peer_exp_wiregen.c:3858:u8[]
    DEBUG   gossipd:   backtrace:
    DEBUG   gossipd:     ccan/ccan/tal/tal.c:442 (tal_alloc_)
    DEBUG   gossipd:     ccan/ccan/tal/tal.c:471 (tal_alloc_arr_)
    DEBUG   gossipd:     wire/peer_exp_wiregen.c:3858 (fromwire_channel_announcement)
    DEBUG   gossipd:     gossipd/routing.c:1706 (handle_channel_announcement)
    DEBUG   gossipd:     gossipd/gossipd.c:238 (handle_channel_announcement_msg)
    DEBUG   gossipd:     gossipd/gossipd.c:444 (peer_msg_in)
    DEBUG   gossipd:     common/daemon_conn.c:31 (handle_read)
    DEBUG   gossipd:     ccan/ccan/io/io.c:59 (next_plan)
    DEBUG   gossipd:     ccan/ccan/io/io.c:407 (do_plan)
    DEBUG   gossipd:     ccan/ccan/io/io.c:417 (io_ready)
    DEBUG   gossipd:     ccan/ccan/io/poll.c:445 (io_loop)
    DEBUG   gossipd:     gossipd/gossipd.c:1730 (main)
    **BROKEN** gossipd:   parents:
    **BROKEN** gossipd:     gossipd/routing.c:1698:struct pending_cannouncement
    **BROKEN** gossipd:     gossipd/gossipd.c:1700:struct daemon
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-12-02 10:38:04 +10:30
Rusty Russell 25fcc4ddbf Makefile: separate check-python targets.
There's a 60 second delay in one of the contrib tests, and I just want
to run flake8 on my alterations.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-12-02 10:38:04 +10:30
Rusty Russell f0621cec0d JSON-RPC: don't allow any strings which aren't valid UTF-8.
We already do some sanity checks, add this one.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: invalid UTF-8 strings now rejected.
2020-12-02 10:38:04 +10:30
Rusty Russell 5bdd282c2b common/bolt11: reject bad UTF-8 strings.
We don't have a problem with them, but callers may; easier to reject bad
UTF8 here than let the caller fail when it tries to parse output.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-12-02 10:38:04 +10:30
Rusty Russell f1bea50e1d common/utils: simple utf8 helpers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-12-02 10:38:04 +10:30
Michael Schmoock 7bfb5f10c7 pyln: failing test msat from float str
We were not able to create pyln Millisatoshi from floats, e.g.:
 - "0.01btc"
 - "0.1sat"
 - ...

This adds a test that makes sure this won't happen again.
2020-12-02 10:37:31 +10:30
Michael Schmoock 83a21138b8 pyln: fix msat from float str
Changelog-fixed: pyln: parsing msat from a float string
2020-12-02 10:37:31 +10:30
Michael Schmoock 899022e452 pytest: use default fundamount on two tests 2020-12-01 11:15:30 +10:30
Michael Schmoock bdad9fcdd9 pyln: def amount 10**6 for fund- and openchannel
Changelog-None
2020-12-01 11:15:30 +10:30
Rusty Russell 68c6ae67b3 external/Makefile: fix parallel build with missing secp headers.
Fixes: #4229
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-11-30 16:10:26 +01:00
ZmnSCPxj jxPCSnmZ 32de621886 lightningd/plugin_hook.c: Make `db_write` a chained hook.
Fixes: #4219

Changelog-Changed: Plugins: Multiple plugins can now register `db_write` hooks.
2020-11-30 10:40:11 +10:30
ZmnSCPxj jxPCSnmZ 904e110554 lightningd/plugin.c: Make plugin-exclusive loop support multiple plugins. 2020-11-30 10:40:11 +10:30
Jon Griffiths 5c2fc4c1cb wally: remove wally casts that are no longer needed
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2020-11-30 10:28:04 +10:30
Jon Griffiths 5bdad04976 tx: Remove wally workaround that is no longer needed
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2020-11-30 10:28:04 +10:30
Rusty Russell 70977a4fbd libwally: update to latest which uses libsecp-zkp submodule
And get rid of the now-obsolete PYTHON_VERSION hack.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-11-25 11:59:22 -06:00
niftynei 5e71de7819 df-spec: fail the open if they send us too many tx-collab msgs 2020-11-23 12:41:05 -06:00
niftynei 29c3532856 mfc-psbt: mark all of our inputs as "ours", then only sign those
we only want to sign the inputs that we've reserved via utxopsbt or
fundpsbt. we mark them with a flag (reusing the now defunct max-len
flag is fine), then look for inputs with that flag to pass to signonly
2020-11-23 12:41:05 -06:00
niftynei 6077eca660 df: pass back 'close_to' for completed/commitment secured channels
When commitments are secured, also return the 'close_to' script if we've
got a local_upfront_shutdown_script set.
2020-11-23 12:41:05 -06:00
niftynei 405453859c mfc-df: add 'happy path' tests for the v1+v2 things
We can't test disconnects et.al. quite yet because the 'cancel' flow for
openchannelv2 still needs to be resolved
2020-11-23 12:41:05 -06:00
niftynei da98a9d0af df-accepter plugin: temporarily dont pass in signpsbt 2020-11-23 12:41:05 -06:00
niftynei c6b45e052b mfc-df: after openchannel_signed is finished, we call finished
We done!?
2020-11-23 12:41:05 -06:00
niftynei 3e19b6c8f5 mfc-df: after psbt signed, send to openchannel_signed if v2s
If there's an v2 destinations, they'll broadcast the tx for us
2020-11-23 12:41:05 -06:00
niftynei a34425abd1 mfc-df: after sigs are collected, go sign the psbt 2020-11-23 12:41:05 -06:00
niftynei d7c06b5b0e mfc-df: once we've gotten the PSBT finalized, we wait for peer sigs
We need our peer's signatures to arrive before we sign/broadcast the
funding transaction (but only if there's v2 peers present)
2020-11-23 12:41:05 -06:00
niftynei c90a19f739 mfc-df: only add outputs for v1 outs; go to openchannel_update if v2s
We only have output scripts for v1 protocols after the
fundchannel_start/openchannel_init round. We need to add them before
we get into the openchannel_update rounds, however, so we do that here.
2020-11-23 12:41:05 -06:00
niftynei 3d2c0951d5 mfc-df: rework how openchannel_update works, callbacks 2020-11-23 12:41:05 -06:00
niftynei 381658dee6 mfc-df: merge openchannel_init/fundchannel_start results
These happen simultaneously, and should resolve to the same place when
they're finished.
2020-11-23 12:41:05 -06:00
niftynei 95de8b1174 mfc-df: have both paths use redo_multifundchannel
Still need handling of failure for v2 opens (no rpc exists?!)
2020-11-23 12:41:05 -06:00
niftynei a31b078721 mfc: consolidate to a single FAILED state 2020-11-23 12:41:05 -06:00
niftynei 991ae65e9e mfc-df: track destination's openchannel version
Plus method to help count/tabulate how many of each we've got
around still.
2020-11-23 12:41:05 -06:00
niftynei e0c4865eea mfc: add a 'fail_destination' helper
Caches state at which we failed + sets error
2020-11-23 12:41:05 -06:00
niftynei 5b6b012af9 mfc: add happy path-way for v2 in multifundchannel
Tested and works with both sides funding! Yay.

Doesn't do any amount of reasonable cleanup or handling of errors.
2020-11-23 12:41:05 -06:00
niftynei 78d32b12d0 nit,df test plugin: change up how feerate is formatted
Suggested-by: @cdecker
2020-11-23 12:41:05 -06:00
ZmnSCPxj jxPCSnmZ ff090ecfe6 doc/TOR.md: Add missing instructions to add user to Tor group.
Changelog-None

Fixes: #4208
2020-11-23 12:22:10 -06:00
niftynei e4cd5eac28 htlc.h: move NUM_SIDES to define, not enum member 2020-11-23 12:21:33 -06:00
YOSHIDA Masanori ff2535651e lightningd: remove unused pid_fd member in struct lightningd
Signed-off-by: YOSHIDA Masanori <masanori.yoshida@gmail.com>
Changelog-None
2020-11-23 12:13:28 -06:00
ZmnSCPxj jxPCSnmZ dc83862fc2 doc/PLUGINS.md: Fix typo. 2020-11-23 12:13:09 -06:00
niftynei 66b2bb9a90 Update to v0.9.2 2020-11-20 15:32:38 -06:00
niftynei ce0888d7d6 release: bump to v0.9.2rc2 2020-11-17 11:22:31 -06:00
Rusty Russell 5ae18ecb32 Revert accidental experimental libwally update from f56266c1c1
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-11-17 11:21:58 -06:00
Rusty Russell f56266c1c1 plugins: undeprecate old form of hooks.
This effectively reverts ac93b780d5.

Christian points out that plugins need time before we deprecate
the old options (probably 6 months) as they need to work with
both old and new.

Changelog-Deprecated: **UNDO** plugins: hooks should now be specified using objects, not raw names.
Suggested-by: @cdecker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-11-17 14:42:58 +10:30
Christian Decker 313976e2f4 pay: Cleanup the route applicability checks for channel hints
I previously mistyped the rather lengthy conditions for failures, so
let's dissect it into its smaller components and add rationale behind
the individual parts of the decision.
2020-11-17 14:04:19 +10:30
Christian Decker 4d6b4a0445 pay: Retry the route computation if we could not apply the chanhints
This adds a new state `PAYMENT_STEP_RETRY_GETROUTE` which is used to
retry just that one step, without spawning a completely new
attempt. It's a new state so that modifiers do not act on it twice.

Changelog-Fixed: pay: Improved the performance of the `pay` command considerably by avoiding conflicting changes to our local network view.
2020-11-17 14:04:19 +10:30
Christian Decker 544e110c96 pay: Add a pre-apply check to channel_hint updates
This allows us to atomically update all channel_hints and determine if
we had a collision and therefore should retry.
2020-11-17 14:04:19 +10:30