URI: 
       tlnchan: fix per_commitment_point number in verify_htlc - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 38d2d4c32165ee9014bd32e7e26f34b6bf05f7e5
   DIR parent 1f1207ecbe1c075028527e2adf73ecac8799480a
  HTML Author: Janus <ysangkok@gmail.com>
       Date:   Thu, 24 Jan 2019 17:19:08 +0100
       
       lnchan: fix per_commitment_point number in verify_htlc
       
       Diffstat:
         M electrum/lnchan.py                  |       9 ++++++---
       
       1 file changed, 6 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/electrum/lnchan.py b/electrum/lnchan.py
       t@@ -354,15 +354,18 @@ class Channel(PrintError):
                self.set_local_commitment(pending_local_commitment)
        
            def verify_htlc(self, htlc: UpdateAddHtlc, htlc_sigs: Sequence[bytes], we_receive: bool, ctx) -> int:
       -        _, this_point, _, _ = self.points()
       +        ctn = extract_ctn_from_tx_and_chan(ctx, self)
       +        secret = get_per_commitment_secret_from_seed(self.config[LOCAL].per_commitment_secret_seed, RevocationStore.START_INDEX - ctn)
       +        point = secret_to_pubkey(int.from_bytes(secret, 'big'))
       +
                _script, htlc_tx = make_htlc_tx_with_open_channel(chan=self,
       -                                                          pcp=this_point,
       +                                                          pcp=point,
                                                                  for_us=True,
                                                                  we_receive=we_receive,
                                                                  commit=ctx,
                                                                  htlc=htlc)
                pre_hash = sha256d(bfh(htlc_tx.serialize_preimage(0)))
       -        remote_htlc_pubkey = derive_pubkey(self.config[REMOTE].htlc_basepoint.pubkey, this_point)
       +        remote_htlc_pubkey = derive_pubkey(self.config[REMOTE].htlc_basepoint.pubkey, point)
                for idx, sig in enumerate(htlc_sigs):
                    if ecc.verify_signature(remote_htlc_pubkey, sig, pre_hash):
                        return idx