Skip to content

Commit

Permalink
closingd: Correct whose turn it is when moving from initial negotiati…
Browse files Browse the repository at this point in the history
…on to continuous negotiation.

[minor neatening by Rusty]

Fixes: ElementsProject#1361
Reported-by: @nayuta-ueno
Implemented-by: @ZmnSCPxj
  • Loading branch information
rustyrussell authored and cdecker committed Apr 15, 2018
1 parent 6424b2d commit 90364a8
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions closingd/closing.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,18 +530,12 @@ int main(int argc, char *argv[])
/* Now we have first two points, we can init fee range. */
init_feerange(&feerange, commitment_fee, offer, deprecated_api);

/* Now apply the one constraint from above (other is inside loop). */
adjust_feerange(&cs, gossip_index, &channel_id, &feerange,
offer[!whose_turn], !whose_turn);

/* Now any extra rounds required. */
while (offer[LOCAL] != offer[REMOTE]) {
/* If they differ, adjust feerate. */
adjust_feerange(&cs, gossip_index, &channel_id, &feerange,
offer[whose_turn], whose_turn);

/* Now its the other side's turn. */
whose_turn = !whose_turn;
/* Still don't agree: adjust feerange based on previous offer */
adjust_feerange(&cs, gossip_index, &channel_id,
&feerange,
offer[!whose_turn], !whose_turn);

if (whose_turn == LOCAL) {
offer[LOCAL] = adjust_offer(&cs, gossip_index,
Expand Down Expand Up @@ -570,6 +564,8 @@ int main(int argc, char *argv[])
our_dust_limit,
min_fee_to_accept);
}

whose_turn = !whose_turn;
}

peer_billboard(true, "We agreed on a closing fee of %"PRIu64" satoshi",
Expand Down

0 comments on commit 90364a8

Please sign in to comment.