diff --git a/daemon/peer.c b/daemon/peer.c index 73f0fdd6b..31e32148b 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -4365,7 +4365,9 @@ struct bitcoin_tx *peer_create_close_tx(const tal_t *ctx, peer->anchor.index, peer->anchor.satoshis, cstate.side[LOCAL].pay_msat / 1000, - cstate.side[REMOTE].pay_msat / 1000, 0); + cstate.side[REMOTE].pay_msat / 1000, + /* FIXME: Real dust limit! */ + 0); } /* Sets up the initial cstate and commit tx for both nodes: false if diff --git a/lightningd/channel.h b/lightningd/channel.h index ba5c4e6d8..4f4dd4fa3 100644 --- a/lightningd/channel.h +++ b/lightningd/channel.h @@ -372,7 +372,7 @@ bool channel_sending_revoke_and_ack(struct channel *channel); bool channel_awaiting_revoke_and_ack(const struct channel *channel); /** - * channel_has_htlcs: are there any HTLCs at all in channel? + * channel_has_htlcs: are there any (live) HTLCs at all in channel? * @channel: the channel */ bool channel_has_htlcs(const struct channel *channel); diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index e66a2828e..9afaf2e2d 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -191,6 +191,20 @@ static struct io_plan *send_error(struct io_conn *conn, return peer_write_message(conn, pcs, pcs->peer->error, (void *)io_close_cb); } +/* FIXME: + * + * This is a lot of code duplication! We should turn gossipd into welcomed(?): + * + * 1. gossipd listens to the socket for new connections, and also + * handles outgoing, absorbing handshaked. + * + * 2. gossipd thus knows who we're trying to connect to, and knows to + * return them immediately. + * + * That unifies the paths nicely and removes all this code. When + * gossipd hands a connection to us, it gives us the gossip fd for + * that peer, and it's all good. + */ struct getting_gossip_fd { struct pubkey id; int peer_fd; @@ -1281,7 +1295,8 @@ static int peer_closing_complete(struct peer *peer, const u8 *msg) * The amounts for each output MUST BE rounded down to whole satoshis. */ out_amounts[LOCAL] = *peer->our_msatoshi / 1000; - out_amounts[REMOTE] = peer->funding_satoshi - *peer->our_msatoshi / 1000; + out_amounts[REMOTE] = peer->funding_satoshi + - (*peer->our_msatoshi / 1000); out_amounts[peer->funder] -= peer->closing_fee_received; derive_basepoints(peer->seed, &local_funding_pubkey, NULL, NULL, NULL);