Commit Graph

2536 Commits

Author SHA1 Message Date
Rusty Russell 005f3826c9 wallet/tests: add mocks for futureproofing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-13 22:46:10 +01:00
Rusty Russell 2931760b5b wallet: move tests into test/ dir like other unit tests.
Trivial move, but makes it easy to add new ones.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-13 22:46:10 +01:00
ZmnSCPxj 757d45c8a3 Test withdrawal to P2SH address. 2017-12-13 03:10:04 +00:00
ZmnSCPxj 9842898ca4 Add support for withdrawing to P2SH addresses. 2017-12-13 03:10:04 +00:00
ZmnSCPxj d43fb87871 Factor out scriptpubkey_from_address function from json_withdraw. 2017-12-13 03:10:04 +00:00
ZmnSCPxj 9f481226fa Rearrange checking of withdrawal address parsing success in json_withdraw. 2017-12-13 03:10:04 +00:00
ZmnSCPxj b56fea8b2a Modify hsm_sign_withdrawal to transmit scriptpubkey to withdraw to, rather than pkh. 2017-12-13 03:10:04 +00:00
ZmnSCPxj 5fd74f9933 Change withdraw_tx to accept scriptpubkey rather than plain address. 2017-12-13 03:10:04 +00:00
Rusty Russell 0610f66c34 bolt11: handle r value fee spec change.
We don't use it yet, but now we'll decode correctly.

See: https://github.com/lightningnetwork/lightning-rfc/pull/317
lightning-rfc commit: ef053c09431442697ab46e83f9d3f86e3510a18e

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-12 11:45:44 +01:00
Rusty Russell e9f9721ed3 devtools/bolt11-cli: handle hashed descriptions
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-12 11:45:44 +01:00
Christian Decker 34444a99f9 docker: Added clang to build dependencies 2017-12-12 02:31:03 +00:00
Christian Decker 7572c22a26 travis: Add clang build to build matrix
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-12 02:31:03 +00:00
Christian Decker 61852b4603 cleanup: Use check_act* in handshake and remove unused static inline
This was tripping up `clang`.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-12 02:31:03 +00:00
practicalswift 486d321094 Avoid NULL pointer dereference in channelseq(...) 2017-12-11 16:07:57 +01:00
practicalswift 4452e3f3f1 Remove redundant code 2017-12-11 03:38:37 +00:00
practicalswift 0353ec0983 Remove trailing whitespace 2017-12-11 03:35:59 +00:00
ZmnSCPxj 7c09b6f478 Load defaults for purpose of help. 2017-12-11 03:21:07 +00:00
ZmnSCPxj f0fa01b439 Share similar code between bitcoin_witness_p2sh_p2wpkh and bitcoin_scriptsig_p2sh_p2wpkh.
Note that bitcoin_witness_p2sh_p2wpkh is not actually used in current
code.
2017-12-10 12:46:25 +01:00
practicalswift 307e8c0180 Avoid NULL pointer dereference when new_initial_channel(...) fails 2017-12-09 16:25:57 +01:00
ZmnSCPxj 38fc280fad Make json_withdraw check testnet flag.
bitcoin_from_base58 returns a testnet flag, but json_withdraw
did not actually check it. Add a basic check that the given
withdraw address belongs to the same net lightningd is using.
2017-12-09 16:18:59 +01:00
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