daemon: fix close fee negotiation.

We always set *matches to false (outside the branch, oops).  We also
distinguish the case where we ack from the case where they acked,
which removes a FIXME and makes it work.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-04-11 16:30:43 +09:30
parent 4c136dde98
commit 0e07cc7a36
3 changed files with 30 additions and 10 deletions

16
state.c
View File

@@ -516,13 +516,21 @@ enum command_status state(struct peer *peer,
break;
case STATE_WAIT_FOR_CLOSE_SIG:
if (input_is(input, PKT_CLOSE_SIGNATURE)) {
bool matches;
err = accept_pkt_close_sig(peer, idata->pkt, &matches);
bool acked, we_agree;
err = accept_pkt_close_sig(peer, idata->pkt,
&acked, &we_agree);
if (err)
goto err_start_unilateral_close;
/* Did they offer the same fee we did? */
if (matches) {
/* Are we about to offer the same fee they did? */
if (we_agree) {
/* Offer the new fee. */
queue_pkt_close_signature(peer);
acked = true;
}
/* Do fees now match? */
if (acked) {
peer_unwatch_close_timeout(peer,
INPUT_CLOSE_COMPLETE_TIMEOUT);