Commit Graph

2466 Commits

Author SHA1 Message Date
practicalswift 2ed53025f9 Remove redundant remote_shutdown_scriptpubkey assignment 2017-12-09 16:17:58 +01:00
practicalswift b5c8b9b9b3 Add build artefacts generated during "make"/"make check" to .gitignore 2017-12-08 13:07:50 +01:00
practicalswift 61c47c09d0 Fix typos 2017-12-08 13:07:20 +01:00
Rusty Russell 5444084625 onchaind: fix reversed CSV delays.
Our config -> their CSV delay, their config -> our CSV delay.

Fixes: #395
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-04 13:00:57 +01:00
Rusty Russell af5dbbc9f8 json_connect: separate port arg so we can parse IPv6 addresses.
Fixes: #391
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-04 11:15:59 +01:00
Rusty Russell 0069787eb6 lightningd: fix crash on bad connect host arg.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-04 11:15:59 +01:00
Rusty Russell 45e9f35988 docs: Note that we need 0.15 (for estimatesmartfee with CONSERVATIVE/ECONOMCIAL flags)
Closes: #392
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-04 10:06:34 +01:00
Christian Decker 9ba99d2b2d hsm: Cleanup after merging control and client libraries
Change all calls to use the correct serialization and deserialization
functions, include the correct headers and remove the control
messages.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-03 17:06:13 +01:00
Christian Decker 2d9cd4759e hsm: Make the master simply a client with special capabilities 2017-12-03 17:06:13 +01:00
Christian Decker 8ff69e0307 hsm: channeld now also just uses the handle_client entry point
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-03 17:06:13 +01:00
Christian Decker 6ce264d3a2 hsm: Remove special case of hsmfd_ecdh, replaced with client and cap
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-03 17:06:13 +01:00
Christian Decker 5482acb837 hsm: Unifying the client creation and adding client capabilities
We had a number of entry points into the HSM, all with different
behavior, so this is my attempt at unifying the way we handle
clients. Every client, except master, now takes the same path entry
point to the HSM and we use capability bit flags to indicate whether
the client is allowed to execute a set of operations.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-03 17:06:13 +01:00
Christian Decker 70bbc46304 Un-break master after merging #389
The #389 introduced some changes that conflicted with
9de3827199 so this ports those changes
into #389 and fixes the `master` branch again.

Lesson learned: always rebase a PR before merging.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-02 13:00:29 +01:00
Rusty Russell 40516941af channeld: fill in channel_update field in errors by asking gossipd.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:54:12 +01:00
Rusty Russell 933c1794a1 gossipd: gossip_get_update / gossip_get_update_reply from channeld.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:54:12 +01:00
Rusty Russell 0a596fb043 channel: infrastructure for gossipd request/response.
The same as master request/response: we queue up incoming replies we
don't want for later processing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:54:12 +01:00
Rusty Russell 9de3827199 channeld: don't use ccan/io, go sync.
We revert to a simple select() loop.  This makes things simpler, and fixes
the problem where we want to exit but we've partially read a peer packet.

We still queue up outgoing peer packets for non-blocking send: if we
went full sync there, we'd risk deadlock if both sides wrote a huge
number of packets and neither was reading.

This also greatly simplifies the next patches, where we want to make
our first get/response from gossipd.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:54:12 +01:00
Rusty Russell ed8d65c8d7 channeld: refer to PEER_FD directly instead of using io_conn_fd(peer->peer_conn)
A no-op change, but reduces the following patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:54:12 +01:00
Rusty Russell 2bed246e10 channeld: generate error messages instead of having master do it.
The master now hands channeld either an error code, and channeld
generates the error message, or an error message relayed from another
node to pass through.

This doesn't fill in the channel_update yet: we need to wire up gossipd
to give us that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:54:12 +01:00
Rusty Russell ee8274b7a1 channeld: handle wrapping error messages messages.
Currently lightningd does this, but channeld is perfectly capable of doing it.
channeld is also in a far better position to add channel_updates to it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:54:12 +01:00
Rusty Russell db372211c0 channeld: save shared secret for incoming htlc when it comes in.
The bulk of this patch is actually hoisting the get_shared_secret()
function (unchanged) so we can call it earlier.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:54:12 +01:00
Rusty Russell fc4a7cf103 channeld: return htlc from channel_add_htlc and channel_fail_htlc.
Callers often want to know, and it saves them doing another lookup.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:54:12 +01:00
Rusty Russell be35895847 lightningd: instead of malformed code, keep generic error code.
This is in preparation for generating the actual error messages inside
channeld.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:54:12 +01:00
Rusty Russell 70cebb8653 test_addfunds_from_block: fix test flakiness.
If you run locally, it fails occasionally; presumably because it
sees previous funds.  Use a random HSM key for that teste.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:52:18 +01:00
Rusty Russell 02411b04e4 channel: remove awaiting_revoke_and_ack flag.
We can tell this more generically because the count of revocations
received != count of commitments sent.  This is the correct condition
which allows us to restore the test we had to eliminate in
c3cb7f1c85.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-02 12:52:18 +01:00
Christian Decker fda77f27a5 travis: Disable BOLT checking while they are being copy-edited
Due to the large number of changes in phrasing, we'd have a large
number of CI builds failing. So just temporarily disable BOLT
checking.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-01 18:30:57 +01:00
Rusty Russell ed60e9ee57 close_tx: use version 2.
As per the pending spec change: the other implementations use version 2,
and the current best practice advice (from maaku) is to use the latest
defined tx version.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-01 18:30:57 +01:00
Rusty Russell 06d7c40c63 lightningd: make minimum feerate significantly lower.
estimatesmartfee 4 ECONOMICAL was too high for lnd, so drop it, with some
increased security risk.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-01 18:30:57 +01:00
Rusty Russell a03fe8dc75 channeld: update acceptable feerate ranges.
master was telling us the ranges, but we weren't updating them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-01 18:30:57 +01:00
Rusty Russell 2329820460 channeld: make sure we wait for revoke_and_ack after rexmit of commitment_signed
We got horribly out-of-sync by sending a feechange and commitment after
we'd re-xmitted the commitment_signed:

lightning_channeld(16003): pid 16003, msgfd 19
lightning_channeld(16003): TRACE: init LOCAL: remote_per_commit = 03e40b239118ab37bd94fe48de0dbc7565a38f7f1028a20f045b4e5fcd6bbb6172, old_remote_per_commit = 03117de1f3de183697e0393e71dc3a04b04d5bec03a23e7371212bb93a67bcce7a next_idx_local = 1 next_idx_remote = 2 revocations_received = 0 feerates 39251/40838 (range 35398-204190)
lightning_channeld(16003): TRACE: Read decrypt 01003b6fdc3ce9edc8524c943ebd833ae02b0fbdbb871f9bdce1c58c8637ebacfaa60a5e4dd8df4046852d783194bc3eeef10388f5a5d8983fbefe9bd0ff24b2a548282dd2eb3bc28015e039f8debf18077904342cd0146622df371c408db3fbe4eb2eb959aac6fd0771cc6a47ce270ec31042b235a2198696656c52c56d42219e4d8bd1f6d3c3b6c108c3cc0ee692d0449a4f4969eb227a9949cb8ab7229fc64f8a5d01b89ff779ac56f085d8a11942f8b5d702b2eba6d19ded7b69baf58bdfaf9443d162751dbab9f9d55e2a467cb1450bc19b832a60e0949bcd253ddc29e7b52922c009df541d8db761b04ad9862bc82ee2d86cfa0f3e730f3d01885b9977ab4200006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d619000000000007905c000581000103aaa47d8296a795110154fa5fca7075d59a10d5914622a6d09ffe20a2ffbd5bb703bc4b957d5ad27b797d6fffa863d74e7946723e67b9084842622fe5e6357475690342423c8dab471815487b40a6ef7f06270c8343e1bbd0bfb80d22096e0ff1f15002d6cda71dde0903fde1939d7afa4f62ffed50c550d9f31f7d8b78955384473f46
lightning_channeld(16003): TRACE: Read decrypt 008854e83a6fa081ae34ddefc9ea3462689732fa3b4c5a4ea571d8d3a109f037e5a400000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000003117de1f3de183697e0393e71dc3a04b04d5bec03a23e7371212bb93a67bcce7a
lightning_channeld(16003): TRACE: Got reestablish commit=1 revoke=0
lightning_channeld(16003): TRACE: Derived key 029cd90c564384a612ea608933bd63aee72543f3b3998a7cbc5ca77ca41c9cb6bc from basepoint 038401ee88c0f7dc9ada0c37a9ce5265ccabce18686649f632bc244fae71bf840d, point 03e40b239118ab37bd94fe48de0dbc7565a38f7f1028a20f045b4e5fcd6bbb6172
lightning_channeld(16003): TRACE: Creating commit_sig signature 1 30440220152767c3ea9d42b19d44ea781f07d5411de918935b674927e43d5f537769376602206cdf2b557207b02bf9ee9805017856462e53fde619d2e3d75476b5c567ea3e14 for tx 020000000154e83a6fa081ae34ddefc9ea3462689732fa3b4c5a4ea571d8d3a109f037e5a5010000000058e9fe8001a22d070000000000160014d0898dc01e4061f7c6b01dba14d1d00a4319c78c81b92f20 wscript 5221022fe5495e572f8f58cbc745e3475427ff6ff51e44dfa8586366b15d1524dbe9ca2103bfd10b2265b5ca1362eba4e7664c250e0d937717e50ec0f14cd47ff25bd6203b52ae key 022fe5495e572f8f58cbc745e3475427ff6ff51e44dfa8586366b15d1524dbe9ca
lightning_channeld(16003): TRACE: peer_out WIRE_FUNDING_LOCKED
lightning_channeld(16003): TRACE: peer_out WIRE_UPDATE_FEE
lightning_channeld(16003): TRACE: peer_in WIRE_FUNDING_LOCKED
lightning_channeld(16003): TRACE: peer_out WIRE_COMMITMENT_SIGNED
lightning_channeld(16003): TRACE: peer_out WIRE_CHANNEL_UPDATE
lightning_channeld(16003): TRACE: peer_in WIRE_CHANNEL_UPDATE
lightning_channeld(16003): TRACE: peer_out WIRE_CHANNEL_ANNOUNCEMENT
lightning_channeld(16003): TRACE: peer_out WIRE_CHANNEL_UPDATE
lightning_channeld(16003): TRACE: peer_in WIRE_CHANNEL_UPDATE
lightning_channeld(16003): TRACE: peer_out WIRE_CHANNEL_UPDATE
lightning_channeld(16003): TRACE: peer_out WIRE_CHANNEL_ANNOUNCEMENT
lightning_channeld(16003): TRACE: peer_out WIRE_CHANNEL_UPDATE
lightning_channeld(16003): TRACE: peer_out WIRE_CHANNEL_ANNOUNCEMENT
lightning_channeld(16003): TRACE: peer_out WIRE_CHANNEL_UPDATE
lightning_channeld(16003): TRACE: peer_out WIRE_CHANNEL_UPDATE
lightning_channeld(16003): TRACE: peer_out WIRE_NODE_ANNOUNCEMENT
lightning_channeld(16003): TRACE: peer_out WIRE_NODE_ANNOUNCEMENT
lightning_channeld(16003): TRACE: Trying commit
lightning_channeld(16003): TRACE: Can't send commit: nothing to send
lightning_channeld(16003): TRACE: Now dealing with deferred WIRE_CHANNEL_FEERATES
lightning_channeld(16003): TRACE: Setting REMOTE feerate to 40840
lightning_channeld(16003): TRACE: Trying commit
lightning_channeld(16003): TRACE: Derived key 029cd90c564384a612ea608933bd63aee72543f3b3998a7cbc5ca77ca41c9cb6bc from basepoint 038401ee88c0f7dc9ada0c37a9ce5265ccabce18686649f632bc244fae71bf840d, point 03e40b239118ab37bd94fe48de0dbc7565a38f7f1028a20f045b4e5fcd6bbb6172
lightning_channeld(16003): TRACE: Creating commit_sig signature 2 304402204f0a041f8626fd28d001cb813c1094f40ebd4b5f99bdd7a06bebaee0de35db200220702c5c62544e512e422fdc141444fddc76410cbda4bbd512d88dc864bd979780 for tx 020000000154e83a6fa081ae34ddefc9ea3462689732fa3b4c5a4ea571d8d3a109f037e5a5010000000058e9fe8001a02d070000000000160014d0898dc01e4061f7c6b01dba14d1d00a4319c78c82b92f20 wscript 5221022fe5495e572f8f58cbc745e3475427ff6ff51e44dfa8586366b15d1524dbe9ca2103bfd10b2265b5ca1362eba4e7664c250e0d937717e50ec0f14cd47ff25bd6203b52ae key 022fe5495e572f8f58cbc745e3475427ff6ff51e44dfa8586366b15d1524dbe9ca
lightning_channeld(16003): TRACE: Telling master we're about to commit...
lightning_channeld(16003): TRACE: Sending master WIRE_CHANNEL_SENDING_COMMITSIG
lightning_channeld(16003): UPDATE WIRE_CHANNEL_SENDING_COMMITSIG
lightning_channeld(16003): TRACE: ... , awaiting WIRE_CHANNEL_SENDING_COMMITSIG_REPLY
lightning_channeld(16003): TRACE: Got it!
lightning_channeld(16003): TRACE: Sending commit_sig with 0 htlc sigs
lightning_channeld(16003): TRACE: peer_out WIRE_UPDATE_FEE
lightning_channeld(16003): STATUS_FAIL_PEER_IO: peer connection broken: Connection reset by peer
lightning_channeld(16003): Status closed, but not exited. Killing

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-01 18:30:57 +01:00
Rusty Russell daf12e4a4d channeld: channel_update must use peer's htlc_minimum_msat.
As per the spec fix: lightningnetwork/lightning-rfc#287

Reported-by: Pierre-Marie Padiou
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-29 16:56:34 +01:00
Christian Decker 00cad3a2ff fixup! txfilter: Add a simple transaction filter 2017-11-29 14:39:12 +01:00
Christian Decker 12944ffc9b pytest: Switch to 'Hello world' as startup marker
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-11-29 14:39:12 +01:00
Christian Decker c29923a623 topology: Add transaction filtering to connect_block
The filter is being populated while initializing the daemon and by
adding new keys as they are being generated. The filter is then used
in connect_block to identify transactions of interest.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-11-29 14:39:12 +01:00
Christian Decker 1eb3c9d2b3 txfilter: Add a simple transaction filter
This is mainly used to filter for transactions that may be of interest
to us, i.e., whether one of our keys is the recipient. It currently
does onyl simple scriptpubkey checks, but will eventually be extended
to use bloomfilters and add more sophisticated checks.

For now the goal is to speed up the processing of blocks during startup.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-11-29 14:39:12 +01:00
Christian Decker 88ecae301c pytest: Add a test for funds coming from blocks
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-11-29 14:39:12 +01:00
Christian Decker 26aa0e2aa4 topogoly: Extract owned funds from transactions in blocks
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-11-29 14:39:12 +01:00
Christian Decker d912d45af8 wallet: Expose wallet_shachain_get_hash to remove warning
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-11-29 14:39:12 +01:00
Christian Decker 9c4f075c6e topogoly: Reduce log noise
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-11-29 14:39:12 +01:00
Christian Decker 2fd78362ad hsm: Log incoming client messages 2017-11-29 14:39:12 +01:00
Rusty Russell cfde208e82 tests: prepare for bitcoind 0.16.
I noticed some breakage with git master:
1. getinfo no longer supported (for us, use getblockchaininfo)
2. generate no longer supported (use generatetoaddress)

Both these options are supported at least in 0.15, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-28 12:15:22 +01:00
Christian Decker f4a71f9806 tests: Add stmt2wallet test for remote_shutdown_scriptpubkey
We didn't test that this is done correctly. Now we are :-)

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-11-26 22:45:48 +00:00
Christian Decker 6beb4eb171 wallet: Fix a column mismatch and use absolute column indices
We weren't incrementing the `col` for the `local_shutdown_idx` field,
which meant that all following fields were incorrect. I removed the
`col` computation and opted for absolute indices instead, since they
are way less brittle. Just remember to add new fields to the query at
the end so we don't have to shift too often :-)

Reported-by: William Casarin @jb55
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-11-26 22:45:48 +00:00
Rusty Russell af7e6158af Makefile: clean needs to do more, distclean should remove everything.
I checked this with git status --ignored after a full build and 'make distclean'.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-24 13:29:03 +01:00
Christian Decker 9bcb01e710 fixup! common/test: add spec tests for bolt11. 2017-11-24 13:22:18 +01:00
Rusty Russell 18db1105c7 json_invoice: return absolute expiry_time
Requested-by: Nadav Ivgi <nadav@shesek.info>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-24 13:22:18 +01:00
Rusty Russell ae6faf7f9c common/test: add spec tests for bolt11.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-24 13:22:18 +01:00
Rusty Russell 60c30214c1 bolt11: fix encoding of x and c fields.
Fixes: #374
Reported-by: Nadav Ivgi
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-24 13:22:18 +01:00
Rusty Russell 1648eb548a devtools/bolt11-cli: simple helper to decode bolt11.
Can be extended to encode later, for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-24 13:22:18 +01:00
Rusty Russell 45f5bb7fac bolt11: move to common/ and sign via callback.
JSON stuff is moved to lightningd/invoice.c.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-11-24 13:22:18 +01:00