From 4af1db9ad59c717738bed410dfdf0fbc8882c1fc Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Thu, 7 May 2020 10:19:38 +0930 Subject: [PATCH] wallet: Store penalty_bases from openingd and channeld in the DB --- lightningd/opening_control.c | 6 ++++++ lightningd/peer_htlcs.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 70a8ed9e7..40a62bcda 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -438,6 +438,9 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp, /* Needed for the success statement */ derive_channel_id(&fc->cid, &channel->funding_txid, funding_txout); + if (pbase) + wallet_penalty_base_add(ld->wallet, channel->dbid, pbase); + funding_success(channel); peer_start_channeld(channel, pps, NULL, false); @@ -543,6 +546,9 @@ static void opening_fundee_finished(struct subd *openingd, notify_channel_opened(ld, &channel->peer->id, &channel->funding, &channel->funding_txid, &channel->remote_funding_locked); + if (pbase) + wallet_penalty_base_add(ld->wallet, channel->dbid, pbase); + /* On to normal operation! */ peer_start_channeld(channel, pps, funding_signed, false); diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 96fd1001f..9693f05a6 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -1731,6 +1731,9 @@ void peer_sending_commitsig(struct channel *channel, const u8 *msg) channel->last_sent_commit = tal_steal(channel, changed_htlcs); wallet_channel_save(ld->wallet, channel); + if (pbase) + wallet_penalty_base_add(ld->wallet, channel->dbid, pbase); + /* Tell it we've got it, and to go ahead with commitment_signed. */ subd_send_msg(channel->owner, take(towire_channel_sending_commitsig_reply(msg)));