diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 998436bcd..ef16c4b19 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -918,7 +918,6 @@ static bool peer_save_commitsig_received(struct peer *peer, u64 commitnum, /* Update peer->last_sig and peer->last_tx before saving to db */ peer_last_tx(peer, tx, commit_sig); - wallet_channel_save(peer->ld->wallet, peer->channel, 0); return true; } @@ -992,10 +991,11 @@ void peer_sending_commitsig(struct peer *peer, const u8 *msg) if (!peer_save_commitsig_sent(peer, commitnum)) return; - /* Last was commit. FIXME: Save to db. */ + /* Last was commit. */ peer->last_was_revoke = false; tal_free(peer->last_sent_commit); peer->last_sent_commit = tal_steal(peer, changed_htlcs); + wallet_channel_save(peer->ld->wallet, peer->channel, 0); /* Tell it we've got it, and to go ahead with commitment_signed. */ subd_send_msg(peer->owner, @@ -1135,6 +1135,8 @@ void peer_got_commitsig(struct peer *peer, const u8 *msg) if (!peer_save_commitsig_received(peer, commitnum, tx, &commit_sig)) return; + wallet_channel_save(peer->ld->wallet, peer->channel, 0); + /* FIXME: Put these straight in the db! */ tal_free(peer->last_htlc_sigs); peer->last_htlc_sigs = tal_steal(peer, htlc_sigs);