closingd: Correct whose turn it is when moving from initial negotiation to continuous negotiation.

[minor neatening by Rusty]

Fixes: #1361
Reported-by: @nayuta-ueno
Implemented-by: @ZmnSCPxj
This commit is contained in:
Rusty Russell 2018-04-12 12:33:26 +09:30 committed by Christian Decker
parent 6424b2decd
commit 90364a8cc6

View File

@ -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,
@ -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",