daemon: simple close support for the case of one side closing transaction.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-01-22 06:45:27 +10:30
parent 6ba5c3cc3b
commit fc4c94cb06
6 changed files with 57 additions and 1 deletions

View File

@@ -219,7 +219,23 @@ Pkt *pkt_err(const tal_t *ctx, const char *msg, ...)
Pkt *pkt_close(const tal_t *ctx, const struct peer *peer)
{
FIXME_STUB(peer);
CloseChannel *c = tal(ctx, CloseChannel);
struct signature sig;
close_channel__init(c);
/* FIXME: If we're not connected, we don't create close tx. */
if (!peer->close_tx) {
c->close_fee = 0;
memset(&sig, 0, sizeof(sig));
c->sig = signature_to_proto(c, &sig);
} else {
c->close_fee = peer->close_tx->fee;
peer_sign_mutual_close(peer, peer->close_tx, &sig);
c->sig = signature_to_proto(c, &sig);
}
return make_pkt(ctx, PKT__PKT_CLOSE, c);
}
Pkt *pkt_close_complete(const tal_t *ctx, const struct peer *peer)