electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 9045d7b293eb4737dff9e032d14bd7fea61b887d
parent e43a3bc63a5ae830094e9ff44f25643f6d9afcf6
Author: ThomasV <thomasv@electrum.org>
Date:   Mon, 22 Jul 2019 09:05:38 +0200

cleanup revoke_current_commitment

Diffstat:
Melectrum/lnchannel.py | 32++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/electrum/lnchannel.py b/electrum/lnchannel.py @@ -406,33 +406,26 @@ class Channel(Logger): def revoke_current_commitment(self): self.logger.info("revoke_current_commitment") + assert self.config[LOCAL].got_sig_for_next + new_ctn = self.config[LOCAL].ctn + 1 + new_ctx = self.pending_commitment(LOCAL) + assert self.signature_fits(new_ctx) + self.set_local_commitment(new_ctx) - new_feerate = self.constraints.feerate if self.pending_fee is not None: - if not self.constraints.is_initiator and self.pending_fee[FUNDEE_SIGNED]: - new_feerate = self.pending_fee.rate - self.pending_fee = None - print("FEERATE CHANGE COMPLETE (non-initiator)") - if self.constraints.is_initiator and self.pending_fee[FUNDER_SIGNED]: - new_feerate = self.pending_fee.rate + if (not self.constraints.is_initiator and self.pending_fee[FUNDEE_SIGNED])\ + or (self.constraints.is_initiator and self.pending_fee[FUNDER_SIGNED]): + self.constraints = self.constraints._replace(feerate=self.pending_fee.rate) self.pending_fee = None - print("FEERATE CHANGE COMPLETE (initiator)") + self.logger.info(f"Feerate change complete (initiator: {self.constraints.is_initiator})") - assert self.config[LOCAL].got_sig_for_next - self.constraints=self.constraints._replace( - feerate=new_feerate - ) - self.set_local_commitment(self.pending_commitment(LOCAL)) - ctx = self.pending_commitment(LOCAL) self.hm.send_rev() self.config[LOCAL]=self.config[LOCAL]._replace( - ctn=self.config[LOCAL].ctn + 1, + ctn=new_ctn, got_sig_for_next=False, ) - assert self.signature_fits(ctx) - - received = self.hm.received_in_ctn(self.config[LOCAL].ctn) - sent = self.hm.sent_in_ctn(self.config[LOCAL].ctn) + received = self.hm.received_in_ctn(new_ctn) + sent = self.hm.sent_in_ctn(new_ctn) if self.lnworker: for htlc in received: self.lnworker.payment_completed(self, RECEIVED, htlc) @@ -440,7 +433,6 @@ class Channel(Logger): self.lnworker.payment_completed(self, SENT, htlc) received_this_batch = htlcsum(received) sent_this_batch = htlcsum(sent) - last_secret, last_point = self.local_points(offset=-1) next_secret, next_point = self.local_points(offset=1) return RevokeAndAck(last_secret, next_point), (received_this_batch, sent_this_batch)