Commit Graph

6062 Commits

Author SHA1 Message Date
Rusty Russell 7cf0006c78 wire/tlvstream: routines to marshal/unmarshal TLV streams.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-18 06:51:35 +00:00
Rusty Russell 95d9377cfe wire: tlv base type handling.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-18 06:51:35 +00:00
Rusty Russell 54790c17ea wire: rename var_int to bigsize, and insist on minimal.
The new TLV spec uses BigSize, like Bitcoin's CompactInt but
*little-endian*.  So change our name for clarity, and insist that
decoding be minimal as the spec requires.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-18 06:51:35 +00:00
Kristaps Kaupe 868bde5e00 Add missing return fields to the manpage of listforwards 2019-07-18 04:50:00 +00:00
Rusty Russell b3215a866b gossipd: fix inverted test in debug print.
==1503== Use of uninitialised value of size 8
==1503==    at 0x566786B: _itoa_word (_itoa.c:179)
==1503==    by 0x566AF0D: vfprintf (vfprintf.c:1642)
==1503==    by 0x569790F: vsnprintf (vsnprintf.c:114)
==1503==    by 0x156CCB: do_vfmt (str.c:66)
==1503==    by 0x156DB1: tal_vfmt_ (str.c:92)
==1503==    by 0x1289CD: status_vfmt (status.c:141)
==1503==    by 0x128AAC: status_fmt (status.c:151)
==1503==    by 0x118E05: route_prune (routing.c:2495)
==1503==    by 0x11DE2D: gossip_refresh_network (gossipd.c:1997)
==1503==    by 0x1292B8: timer_expired (timeout.c:39)
==1503==    by 0x12088C: main (gossipd.c:3075)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 20:16:55 -05:00
darosior 7984a55339 doc: Add hooks to the 'getmanifest' example in PLUGINS.md 2019-07-17 20:16:08 -05:00
Rusty Russell 0eda6a5ce7 devtools/mkcommit: cleanups.
Also, change the values to match the spec values (I made the
to_self_delays different to catch more bugs).

Suggested-by: @niftynei
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell 63d5c7fc1f devtools/onion: allow setting the hop_data.
This is also required for actually creating usable onions.  For the moment,
due to API limitations, we only let them set realm 0.

Note that the privkey parsing was broken, requiring an additional two
hex digits, overflowing the buffer, and were ignored.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell b9ea1165c4 devtools/onion: allow setting the associated data.
This is required for actually creating usable onions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell 1b8adabd4f devtools/onion: fix --decode
Add odd-length string can never be valid hex!

In addition, don't try to print the next hop if there isn't one, but
always print the (raw) payload.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell cd6d0ccde7 openingd: round *down* for reserve amount.
That's what other implementations do, so it simplifies the test vectors.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell 12d8be4fdc devtools: have mkcommit support HTLCs.
This allows for complete channel simulation, including HTLC
transactions, but means we use higher-level primitives to
make the easy.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell 8b09a9ad06 devtools: add mkfunding and mkcommit.
These utilities allow us to create valid test txs and information given both
sides' complete set of secrets.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell 1e6eabf018 developer: add --dev-force-channel-secrets.
We don't have this on a per-channel basis (yet), but it's sufficient for testing
now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell 5879f6b4e0 devtools/gossipwith: expose the INIT messages.
Usually we send a canned INIT message and ignore theirs.  This adds
an option to not do that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell 1036f98613 devtools/gossipwith: allow setting the secret key.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell af535bf5ff devtools/gossipwith: allow interaction.
This lets us use it as an interactive driver of conversation, rather
than writing all packets then reading all packets.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell d59e2b1b4b developer: add --dev-force-bip32-seed to force a specific BIP32 seed.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell 07adb7efd6 developer: add --dev-force-privkey to allow setting a specific node key.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-17 12:55:37 -05:00
Rusty Russell fb6870c139 param: implement helpers for multiplex commands.
Our previous param support was a bit limited in this case.

We create a dev- command multiplexer, so we can exercise it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-16 21:39:14 +00:00
lisa neigut eaa19f23fa bolt: update to latest RFC lightning-rfc:ffeece
Update to latest rfc checkpoint; no material source changes
2019-07-16 06:10:58 +00:00
lisa neigut 81c40da3b5 bolt: update to lightning-rfc:636b9f, change opcode reference format
Updates BOLT reference to match spec; replaces OP_CSV ->
OP_CHECKSEQUENCEVERIFY
2019-07-16 06:10:58 +00:00
lisa neigut 85e325cb1f bolt: update to lightning-rfc:6f6ea63233c new fundamental types
RFC tweaks to the types used to specify message fields
2019-07-16 06:10:58 +00:00
lisa neigut 5c07afac7d bolt: update to BOLT spec changes (extract format + type specifications)
updates the bolt version to 6639cef095a2ecc7b8f0c48c6e7f2f906fbfbc58.

this requires us to use the new bolt parser at generate-bolt.py
and updates to all of the type specifications (ie. from u8 -> byte)
2019-07-16 06:10:58 +00:00
lisa neigut 6c240ab589 bolts: new parsing script and templates for new bolt format
the RFC's extract-format.py is switching to a new format.
this script can correctly parse them.

mostly moves logic over from generate-wire.py, uses a
Python formatting libarary called mako, which needs to be
installed prior to running this script.

you can add it to your system with

    sudo apt-get install python3-mako
2019-07-16 06:10:58 +00:00
lisa neigut 01e292a3ff Travis: use inline mako install
Needed for next patch.
2019-07-16 06:10:58 +00:00
lisa neigut 118caae45b tools: simplify check
in this case, we always need a pointer, so remove the check
and just add it to the template
2019-07-16 06:10:58 +00:00
lisa neigut 254ee8a5d3 bolt-spec: bring up to date at 309e86d471faf90c1f6c531701c16887684badb9 2019-07-16 06:10:58 +00:00
Juraj Bednar ab52638f93 Fix typos and options
--proxy= instead of --proxy:
--always-use-proxy needs value (true)
2019-07-15 01:00:57 +00:00
Rusty Russell 068b593d98 plugins/pay: fix crash when we reach retry timeout.
pay: ccan/ccan/json_out/json_out.c:144: check_fieldname: Assertion `!fieldname' failed.
pay: FATAL SIGNAL 6 (version v0.7.1rc4-1-gf1bea55)
0x11d914 send_backtrace
        common/daemon.c:40
0x11d9ba crashdump
        common/daemon.c:53
0x5430f1f ???
        ???:0
0x5430e97 ???
        ???:0
0x5432800 ???
        ???:0
0x5422399 ???
        ???:0
0x5422411 ???
        ???:0
0x1325c3 check_fieldname
        ccan/ccan/json_out/json_out.c:144
0x132627 json_out_member_direct
        ccan/ccan/json_out/json_out.c:162
0x10c4a4 json_out_add_raw_len
        plugins/pay.c:122
0x10c4f9 json_out_add_raw
        plugins/pay.c:130
0x10c9ae waitsendpay_expired
        plugins/pay.c:236
0x10ce39 waitsendpay_error
        plugins/pay.c:322
0x111aa7 handle_rpc_reply
        plugins/libplugin.c:431

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-14 16:16:30 +02:00
Christian Decker 53488e5739 pytest: Strengthen the htlc_accepted tests
We were having a few issues with malformed data in the past, so this time we
really check that stuff.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-07-13 14:44:12 +02:00
lisa neigut a6516f477b bash-completion: include underscores
`fundchannel_start` etc are not included in the bash-completion as
they include underscores in their names. this fixes this by including
underscores.
2019-07-09 13:23:14 +02:00
lisa neigut 4638995037 tests: log funder_faileds as unusual not broken
test_funding_cancel_race explicitly attempts to trigger this via a race
condition; this conflicts with our post-test checks that no broken
logs were logged. as a middle ground, we log it as unusual, not broken,
as it's possible for it to attempt to fail if it was begun at the same
time as the complete is.
2019-07-09 04:18:48 +00:00
Rusty Russell 789d14299b pytest: mix up order of cancel vs complete in test_funding_cancel_race
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-08 15:14:31 +00:00
Rusty Russell ee8edfe6a6 pytest: severely reduce scope of test_funding_cancel_race under valgrind.
Otherwise we get timeouts across the board.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-08 15:14:31 +00:00
Rusty Russell 9fdcb1a122 openingd: remove unnecessary is_err flag.
It probably doesn't matter to "fundchannel_cancel" exactly why the
fundchannel didn't work (though it can read the error msg), and we
should always fail any pending fundchannel_complete command.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-08 15:14:31 +00:00
Rusty Russell 280bd60988 lightningd: allow multiple cancels on a single fundchannel command.
Instead of taking over the ->cmd pointer, append ourselves to a list
of cancels.  This fixes the test_funding_cancel_race.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-08 15:14:31 +00:00
Rusty Russell 4b1a300ee3 lightningd: fix fundchannel_complete race.
If we already have a fundchannel_complete, don't attach another one.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-08 15:14:31 +00:00
Rusty Russell 13dbe6e74b pytest: stress test funding_cancel vs funding_complete
This fails, because they fight over the fc->cmd pointer, leaving
others hanging.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-08 15:14:31 +00:00
Rusty Russell 2945b25b57 onchaind: don't free proposal, correctly check it's not resolved in billboard.
Instead of freeing proposals, which we did in *some* places, we just
set ->resolved and check that in billboard_update which didn't get it right.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-07 00:12:34 +00:00
Rusty Russell e746e9c202 onchaind: fix resolution detection of complex outputs.
We shouldn't set out->resolved until we've actually resolved it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-07 00:12:34 +00:00
trueptolemy 6deed77d88 bitcoind: confirm chain with bitcoin-cli at the beginning
At the beginning of the lightningd, we use "echo" command to check if bitcoin-cli is running.
Now we raplace "echo" with "getblockchaininfo" for this check, and also check whether the "chain" field in response is same as the blockchain that  lightningd is on.
"getblockchaininfo" is also valid for litecoin-cli.
2019-07-04 16:13:09 +02:00
trueptolemy 285da33e9e Chainparam: Add 'bip70_name' field for blockchain
'bip70_name' is corresponding to the 'chain' field of
the API 'getblockchaininfo'.
At the beginning of lightningd, we use the 'chain' field of 'getblockchaininfo' to check if we are on right blockchain.
2019-07-04 16:13:09 +02:00
trueptolemy a594196c7c bitcoin-cli: rename bcli_args() to bcli_args_direct(), and also warp it in bcli_args()
1. bcli_args_direct() will be used in wait_for_bitcoind;
At the beginning, we check if bitcoin-cli is running by "echo" command
whitout any bitcoin_cli struction. If this first command fails, we need
present the agrs gathered, like "-rpcuser", like "-rpcpassword".
Related changes include:
  i) rename bcli_args() to bcli_args_direct(), and use 'const char **'
      as the paramater for bcli_args_direct();
  ii) add a new function bcli_args() warpped on bcli_args_direct(), this
      warpping can reduce the large number of changes later in the file;
2. bcli_args() warpping on bcli_args_direct() is used like original.
2019-07-04 16:13:09 +02:00
Rusty Russell c95b4eedf4 gossipd: fail clearly if we can't open/create gossip_store.
Otherwise we fail at the write, and then it's not clear
*why* we couldn't open file:

lightning_gossipd: Writing version to store: Bad file descriptor (version v0.7.1-16-g7ea5c5c)
0x560dcf1a3779 send_backtrace common/daemon.c:40
0x560dcf1a634d status_failed common/status.c:192
0x560dcf19726a gossip_store_new gossipd/gossip_store.c:195
0x560dcf199fd0 new_routing_state gossipd/routing.c:177
0x560dcf1a098b gossip_init gossipd/gossipd.c:2113
0x560dcf1a197a recv_req gossipd/gossipd.c:2946
0x560dcf1a38cd handle_read common/daemon_conn.c:31
0x560dcf1bae2c next_plan ccan/ccan/io/io.c:59
0x560dcf1bb314 do_plan ccan/ccan/io/io.c:407
0x560dcf1bb341 io_ready ccan/ccan/io/io.c:417
0x560dcf1bcb13 io_loop ccan/ccan/io/poll.c:445
0x560dcf1a1ba0 main gossipd/gossipd.c:3073

Reported-by: @JavierRSobrino
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-04 16:10:20 +02:00
darosior 7ea5c5c00f Pylightning: allow to set description and long description manually
This just adds the possibility to set a command's descriptionS by hand, so that the method docstring can be used for something else
2019-07-02 19:30:50 +02:00
Rusty Russell 54ce4ed1cf pytest: fail tests if we get any LOG_BROKEN level messages, unless flagged.
And clean up some dev ones which actually happen (mainly by calling
channel_fail_permanent which logs UNUSUAL, rather than
channel_internal_error which logs BROKEN).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-02 03:26:10 +00:00
Rusty Russell 5f02294b5b lightningd/log: prefix log messages with level.
In particular, this lets us spot UNUSUAL and BROKEN messages easily.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-07-02 03:26:10 +00:00
Nicola Squartini cbf240e110 makefiles: fix quotation of BINTOPKGLIBEXECDIR macro 2019-07-01 00:27:11 +00:00
ZmnSCPxj 011a4bcd83 CHANGELOG.md: Reset for next release.
[ Added [Unreleased] URL -- RR ]
2019-07-01 00:21:18 +00:00