Commit Graph

8897 Commits

Author SHA1 Message Date
Christian Decker 15842d056d docker: Bump OS version to debian buster
Since we're planning on standardizing on Python 3.6+ [1] I think it is a good
idea to bump our own docker image to a Debian version that fulfills that
requirement as well.

[1] https://github.com/lightningd/plugins/issues/146
2020-09-16 06:27:12 +09:30
Rusty Russell 817a7533d1 Ready for release!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-15 12:07:58 +09:30
Rusty Russell 5eb121ffc3 common/amount: fix OpenBSD compile warning.
```
cc common/amount.c
common/amount.c:306:15: error: implicit conversion from 'unsigned long long' to
      'double' changes value from 18446744073709551615 to 18446744073709551616
      [-Werror,-Wimplicit-int-float-conversion]
        if (scaled > UINT64_MAX)
                   ~ ^~~~~~~~~~
/usr/include/sys/stdint.h:123:21: note: expanded from macro 'UINT64_MAX'
                                ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
gmake: *** [Makefile:254: common/amount.o] Error 1
bsd$
```

Fixes: #4044
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-14 03:57:17 +09:30
Rusty Russell ea810b7011 lightningd: don't declare local vars stdin and stdout.
OpenBSD uses macros for these, and gets upset.

Fixes: #4044
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-14 03:57:17 +09:30
Sergi Delgado Segura f1d5fdf323 pyln: Sets remote_pubkey for LightningConnection if node is not the initiator
Currently ``LightningConnection.remote_pubkey`` is set to ``None`` if the node is not the handshake initiator. This sets it to ``rs`` in act three from the receiver side
2020-09-12 15:06:08 +09:30
Rusty Russell 26c10ffefe CHANGELOG.md: 0.9.1rc2
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-12 10:26:15 +09:30
Rusty Russell 5bb6af6ba8 doc: note default proxy port.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-11 21:29:01 +09:30
Rusty Russell f658dd0d78 pytest: test connection timeout.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-11 21:27:45 +09:30
Rusty Russell 7f2b332021 connectd: implement connection timeout (60 seconds).
This is simple, and we now can multifundchannel to every node on testnet
(one simply hangs once we connect).

Changelog-Fixed: Protocol: We now hang up if peer doesn't respond to init message after 60 seconds.
2020-09-11 21:27:45 +09:30
Rusty Russell 1deba1c8e4 plugins/pay: handle case where amount_msat is 'null'.
Deprecated, but this can happen:

```
==1578== Conditional jump or move depends on uninitialised value(s)
==1578== at 0x12B30E: amount_msat_add (amount.c:224)
==1578== by 0x11270B: add_amount_sent (pay.c:1734)
==1578== by 0x112D89: listsendpays_done (pay.c:1831)
==1578== by 0x114F4B: handle_rpc_reply (libplugin.c:555)
==1578== by 0x115704: rpc_read_response_one (libplugin.c:685)
==1578== by 0x115821: rpc_conn_read_response (libplugin.c:705)
==1578== by 0x148E40: next_plan (io.c:59)
==1578== by 0x1499BD: do_plan (io.c:407)
==1578== by 0x1499FB: io_ready (io.c:417)
==1578== by 0x14BBC1: io_loop (poll.c:445)
==1578== by 0x117A82: plugin_main (libplugin.c:1322)
==1578== by 0x113ABC: main (pay.c:2096)
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-11 12:48:48 +09:30
Rusty Russell dcf45b47b3 Travis: spread the load a little more.
Commit cec755f796 reduced from 14 runners to 10,
but we're seeing some timeouts again.  So turn it up to 11.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-11 09:18:28 +09:30
Rusty Russell 9b41d608ee CHANGELOG.md: v0.9.1-rc1
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-10 20:04:09 +09:30
Christian Decker f5dd393113 pyln: Bump proto version to match pyln-bolt*
Since pyln-bolt* specify the 0.8.4 version which we didn't upload, and the
requirements.txt specify ==0.8.4, we need to backfill that version, even if we
could just bump it directly to 0.9.1.
2020-09-10 20:01:41 +09:30
Vincenzo Palazzo f62d7bbe45 Added additional fix to code formatting and English spelling.
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2020-09-10 17:27:51 +09:30
Vincenzo Palazzo 9fbeb9bcdc delpay: code style changes and fixed docs
Changelog-Added: JSON-RPC: delpay a new method to delete the payment completed or failed.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2020-09-10 17:27:51 +09:30
ZmnSCPxj jxPCSnmZ 0eb1e7e0ca plugins/libplugin-pay.c: Add new payee_incoming_limit to limit number of HTLCs based on payee connectivity.
Fixes: #3926

(probably)

Changelog-Fixed: pay: Also limit the number of splits if the payee seems to have a low number of channels that can enter it, given the max-concurrent-htlcs limit.
2020-09-10 16:50:52 +09:30
ZmnSCPxj jxPCSnmZ deced56344 plugins/libplugin-pay.c: Add facility to have paymods request lowering of the estimated max HTLCs. 2020-09-10 16:50:52 +09:30
ZmnSCPxj jxPCSnmZ d15717b576 plugins/libplugin-pay.c: Keep p->invoice->routes valid when the routehints paymod mutates it.
The routehints paymod shares the storage of the array d->routehints and
p->invoice->routes, but once it operates, it possibly leaves it as a stale
pointer to memory it used to have.

Since other paymods may be interested in the invoice details, including
the routehints in the invoice, we should ensure the p->invoice->routes
remains valid whenever we try mutating that array.
2020-09-10 16:50:52 +09:30
ZmnSCPxj jxPCSnmZ 2d86014e53 tests/test_pay.py: Test for overload of number of HTLCs at the payee. 2020-09-10 16:50:52 +09:30
Rusty Russell 191355e0e7 pay: fix handling of legacy vs tlv encoding.
As revealed by the failure of tests in #3936, where we ended up trying
to send a partial payment using legacy style, we are not handling
style properly.

1. BOLT9 has features, so we can *know* that the destination supports
   MPP.  We may not have seen a node_announcement.
2. We can't assume that nodes inside routehints support TLV.
3. We can't assume direct peers support TLV.

The keysend code tried to fix this up, so I'm not sure that this caused
the issue in #3968, though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: `pay` will now make reliable multi-part payments to nodes it doesn't have a node_announcement for.
2020-09-10 16:50:32 +09:30
ZmnSCPxj jxPCSnmZ 9587425f2d plugins/spender/fundchannel.c: Make fundchannel a thin layer around multifundchannel.
Changelog-Changed: protocol: `fundchannel` now shuffles inputs and outputs, and no longer follows BIP69.
2020-09-10 15:28:50 +09:30
ZmnSCPxj jxPCSnmZ f6c145d2df plugins/spender/multifundchannel.c: Move multifundchannel to the spenderp plugin. 2020-09-10 15:28:50 +09:30
Rusty Russell 976c6e5c83 json_add_tok: simplify, don't try to canonicalize.
I'm not sure why we were turning strings into bools, etc.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-10 15:28:50 +09:30
niftynei 165d039f6c elements: consolidate fee outputs into a single fee output
In the case that you've got more than one fee output already on a
psbt, we consolidate them into a single fee output (the first)
2020-09-10 12:31:36 +09:30
niftynei 9771273c4d elements: these can coin moves can arrive in either order 2020-09-10 12:31:36 +09:30
niftynei 81a7a6742a elements: use normalization for elements fee output
This will update the fee output if it exists, rather than unilaterally
adding a new one.

Also, if the fee output already exists, we should make sure that it
doesn't interfere with the outnums of the other outputs
2020-09-10 12:31:36 +09:30
niftynei eab7fcf8e5 test_utxopsbt: account for fee output diff when elements 2020-09-10 12:31:36 +09:30
niftynei 4311c658d0 test_txprepare: skip over fee outputs (elements) 2020-09-10 12:31:36 +09:30
niftynei 4c28e7b362 txprepare: elements requires inclusion of an accurate fee output
so we add an accurate one
2020-09-10 12:31:36 +09:30
niftynei 65f01d8180 bitcoin: pull up elements_fee calc to allow wtx passed in
We're moving away from bitcoin_tx, slowly
2020-09-10 12:31:36 +09:30
niftynei 250af67908 elements: run sign + send psbt check for elements tests
Now that we're using an 'elements' witness_utxo and issue 3998 has been
resolved, this should work as expected.
2020-09-10 12:31:36 +09:30
niftynei 273f0991b0 elements: include the value + asset tag for 'PSET's
Not strictly necessary as technically this info is included in the
witness_utxo, but nice to have
2020-09-10 12:31:36 +09:30
niftynei 24578c7fea elementsd: use the elements version of a 'witness utxo'
Elements requires the witness utxo to include the asset and value info,
in order for the signing hash to be constructed correctly

Changelog-Fixed: elementsd: PSBTs include correct witness_utxo struct for elements transactions
2020-09-10 12:31:36 +09:30
Christian Decker bd811fbd1a pyln: Add safe fallback results for hooks
Hooks do not tolerate failures at all. If we return a JSON-RPC error to a hook
call the only thing the main daemon can really do is to crash. This commit
adds a mapping of error to a safe fallback result, including a warning to the
node operator that this should be addressed in the plugin. The warning is
reported as a `**BROKEN**` message, and should therefore fail any testing done
on the plugin.

Changelog-Fixed: pyln: Fixed HTLCs hanging indefinitely if the hook function raises an exception. A safe fallback result is now returned instead.
2020-09-10 10:27:24 +09:30
Christian Decker 3d6c4e93b3 pytest: Add a test to reproduce #3748 2020-09-10 10:27:24 +09:30
Michael Schmoock 160c564e5f fix: suppress duplicated channel_state_changed events 2020-09-10 10:24:06 +09:30
Michael Schmoock ddc759c49e test: plugin channel_state_changed notification 2020-09-10 10:24:06 +09:30
Michael Schmoock 218a9efaec pyln-testing: add get_channel_id helper 2020-09-10 10:24:06 +09:30
Michael Schmoock 45a0e049e3 doc: plugin channel_state_changed 2020-09-10 10:24:06 +09:30
Michael Schmoock d86855d1f7 feat: adds channel_state_changed notification
This notification will be raised whenever a channel state changes.
The payload includes the channel and peer identifiers and the
old and the new state.

Example payload:

```
{
    "channel_state_changed": {
        "peer_id": "03bc9337c7a28bb784d67742ebedd30a93bacdf7e4ca16436ef3798000242b2251",
        "channel_id": "a2d0851832f0e30a0cf778a826d72f077ca86b69f72677e0267f23f63a0599b4",
        "short_channel_id" : "561820x1020x1",
        "old_state": "CHANNELD_NORMAL",
        "new_state": "AWAITING_UNILATERAL"
    }
}
```

Changelog-Added: Plugins: channel_state_changed notification
2020-09-10 10:24:06 +09:30
Antoine Poinsot b80ad95f1c channel_control: fix an use-after-free
As the cmd gets freed on a received error, the node id in which we iterate in `process_check_funding_broadcast`
may gets freed while we are using it.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-09-10 10:23:35 +09:30
Antoine Poinsot 2a9e847055 tools: remove headerversions.o on clean
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-09-10 10:23:35 +09:30
Michael Schmoock dd60332d91 chore: adds experimental wiregen to gitignore
Changelog-None
2020-09-09 20:46:46 +09:30
Rusty Russell c76cfe9c5c Makefile: fix typo which can cause build failures.
And add secp_recovery to headers, while we're at it.

```
./wire/wire.h:7:10: fatal error: secp256k1_recovery.h: No such file or directory
 #include <secp256k1_recovery.h>
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:254: recipe for target 'connectd/test/run-initiator-success.o' failed
make: *** [connectd/test/run-initiator-success.o] Error 1
m
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-09-09 20:44:22 +09:30
Moller40 4d672077e1 Avoid compile error on macos mojave
Fixing the following error by changing 'enum feerate' to int.

lightningd/bitcoind.c:183:29: error: result of comparison of constant
8 with expression of type 'enum feerate' is always true [-Werror,
-Wtautological-constant-out-of-range-compare]
        for (enum feerate f = 0; f < NUM_FEERATES; f++) {

Changelog-Fixed: compile error on macos
2020-09-09 20:43:27 +09:30
ZmnSCPxj jxPCSnmZ c6186829df tests/test_wallet.py: Simple multiwithdraw tests. 2020-09-09 20:36:08 +09:30
ZmnSCPxj jxPCSnmZ 277ff0f44c plugins/spender/multiwithdraw.c: Implement multiwithdraw command.
Fixes: #2679

Changelog-Added: JSON-RPC: New `multiwithdraw` command to batch multiple onchain sends in a single transaction.  Note it shuffles inputs and outputs, does not use BIP69.
2020-09-09 20:36:08 +09:30
ZmnSCPxj jxPCSnmZ 5d7178d488 bitcoin/psbt.c: Add psbt_insert_output function. 2020-09-09 20:36:08 +09:30
ZmnSCPxj jxPCSnmZ e04febfe0c plugins/spender/: New plugin that will eventually absorb all onchain-spending commands. 2020-09-09 20:36:08 +09:30
Christian Decker 210734f1b6 docs: Update the repro-build docs to the new docker-based system
Changelog-Added: New reproducible build system now uses docker: try it at home with `doc/REPRODUCIBLE.md`!
2020-09-09 20:22:42 +09:30