mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
lnchan: fix per_commitment_point number in verify_htlc
This commit is contained in:
parent
1f1207ecbe
commit
38d2d4c321
1 changed files with 6 additions and 3 deletions
|
@ -354,15 +354,18 @@ class Channel(PrintError):
|
||||||
self.set_local_commitment(pending_local_commitment)
|
self.set_local_commitment(pending_local_commitment)
|
||||||
|
|
||||||
def verify_htlc(self, htlc: UpdateAddHtlc, htlc_sigs: Sequence[bytes], we_receive: bool, ctx) -> int:
|
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,
|
_script, htlc_tx = make_htlc_tx_with_open_channel(chan=self,
|
||||||
pcp=this_point,
|
pcp=point,
|
||||||
for_us=True,
|
for_us=True,
|
||||||
we_receive=we_receive,
|
we_receive=we_receive,
|
||||||
commit=ctx,
|
commit=ctx,
|
||||||
htlc=htlc)
|
htlc=htlc)
|
||||||
pre_hash = sha256d(bfh(htlc_tx.serialize_preimage(0)))
|
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):
|
for idx, sig in enumerate(htlc_sigs):
|
||||||
if ecc.verify_signature(remote_htlc_pubkey, sig, pre_hash):
|
if ecc.verify_signature(remote_htlc_pubkey, sig, pre_hash):
|
||||||
return idx
|
return idx
|
||||||
|
|
Loading…
Add table
Reference in a new issue