Commit Graph

2766 Commits

Author SHA1 Message Date
Rusty Russell 6afc7dcc09 gossipd: don't increment broadcast_index until *after* message sent.
If the peer is moved from remote to local, this may be lost; it's more
secure to increment after we've sent the broadcast.
2017-12-17 02:44:20 +00:00
Rusty Russell 67aa95c194 gossipd: hand back peer, don't hand a new peer.
All peers come from gossipd, and maintain an fd to talk to it.  Sometimes
we hand the peer back, but to avoid a race, we always recreated it.

The race was that a daemon closed the gossip_fd, which made gossipd
forget the peer, then master handed the peer back to gossipd.  We stop
the race by never closing the gossipfd, but hand it back to gossipd
for closing.

Now gossipd has to accept two fds, but the handling of peers is far
clearer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Rusty Russell 8832925122 gossipd: don't hand length to route code, it's implied.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Rusty Russell b83ac58a98 subd: if a required daemon exits, wait instead of killing it.
Otherwise we always say it died because we killed it, so we don't get
the exit status.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Rusty Russell 36746bf65a Makefile: make gossipd objects depend correctly on its own headers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Rusty Russell bcfbc24308 gossipd: split peer structure to clearly separate local and remote fields.
We should also go through and use consistent nomenclature on functions which
are used with a local peer ("lpeer_xxx"?) and those with a remote peer
("rpeer_xxx"?) but this is minimal.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Rusty Russell 0cab9d1dd1 daemon_conn: helper to release daemon_conn.
We'll want this for the next change, where gossipd migrates remote peers
back to local ones.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Rusty Russell 8ed511b3c7 test_lightningd: add test for funding failures.
We should not disconnect from a peer just because it fails opening; we
should return it to gossipd, and give a meaningful error.

Closes: #401
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Rusty Russell 97434d9c4a openingd: handle ERROR packets (if other end fails negotiation).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Rusty Russell 6b232de7b1 openingd: return to master for more gossip when negotiation fails.
We can open other channels, if we want.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Rusty Russell afea2520ba wireaddr: marshal empty address properly.
On unmarshal, we stop unmarshaling on a 0 (ADDR_TYPE_PADDING) type.  So
we should also stop marshaling in that case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Rusty Russell 899bf3fde9 subd: add transaction to subd exit corner case.
As demonstrated in the test at the end of this series, openingd dying
spontaneously causes the conn to be freed which causes the subd to be
destroyed, which fails the peer, which hits the db.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Rusty Russell 20d7ddcb6e json_fund_channel: give more details than "peer died".
Rather than using the destructor, hook up the cmd so we can close it.
peers are allocated off ld, so they are only destroyed explicitly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-17 02:44:20 +00:00
Christian Decker a0724f45af routing: Do not set an empty channel_announcement if none is given
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-17 02:44:20 +00:00
Christian Decker 4a51de44c0 gossip: Forward when we don't have a valid node_announcement yet
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-17 02:44:20 +00:00
Christian Decker 580a2612fd routing: Add local and sigfail to trace when receiving cannounce
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-17 02:44:20 +00:00
Christian Decker ba45ccffd8 routing: Return boolean from handle_channel_announcement
This will later be used to determine whether or not we should announce
ourselves as a node.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-17 02:44:20 +00:00
Christian Decker b5f737e563 gossip: Passing alias, color and wireaddrs through to gossipd
First step towards `gossipd` managing the `node_announcement`.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-17 02:44:20 +00:00
Christian Decker 67c6d4d1f1 opts: Change alias to be u8*, better matches the unicode nature
We are still generating only char* style aliases, but the field is
defined to be unicode, which doesn't mix too well with char.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-17 02:44:20 +00:00
Christian Decker 19c030ea1f routing: Make routing_state aware of its own ID
This is used to identify our own announcements.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2017-12-17 02:44:20 +00:00
Christian Decker 8d6281175d gossip: Remove HSM_FD from handshake 2017-12-17 02:44:20 +00:00
ZmnSCPxj 4022fc0034 wallet.c: Minor leak in wallet_invoices_load. 2017-12-15 10:41:54 +00:00
ZmnSCPxj 44c37b60e4 Add test for withdrawing to P2WPKH and P2WSH. 2017-12-14 03:36:40 +00:00
ZmnSCPxj e26d294b60 Add support for withdrawing to BECH32 addresses.
Fixes: #428
2017-12-14 03:36:40 +00:00
ZmnSCPxj 8512e2c8ef README.md: Add link to waitanyinvoice 2017-12-14 03:07:20 +00:00
Rusty Russell bbbbb60863 wallet: don't leak string on update.
We actually don't need tal_fmt() here at all, anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-13 22:46:10 +01:00
Rusty Russell 5a319c781c wallet: don't leak UTXO array on extracting outputs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-13 22:46:10 +01:00
Rusty Russell 9747d1a62c database: don't leak query string.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-13 22:46:10 +01:00
Rusty Russell 65fd7ce132 bitcoind: don't leak memory on every call to bitcoin-cli.
Fixes: #412
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-13 22:46:10 +01:00
Rusty Russell b00525b8c8 options: don't leak memory when people override options.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-13 22:46:10 +01:00
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