mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
lnhtlc: also check received htlcs when validating commitment sigs
This commit is contained in:
parent
137bf72602
commit
0448db0019
1 changed files with 14 additions and 9 deletions
|
@ -316,13 +316,21 @@ class HTLCStateMachine(PrintError):
|
||||||
|
|
||||||
_, this_point, _ = self.points
|
_, this_point, _ = self.points
|
||||||
|
|
||||||
if len(self.htlcs_in_remote) > 0 and len(pending_local_commitment.outputs()) == 3:
|
if len(pending_local_commitment.outputs()) >= 3:
|
||||||
print("CHECKING HTLC SIGS")
|
print("CHECKING HTLC SIGS")
|
||||||
we_receive = True
|
assert len(pending_local_commitment.outputs()) == 3
|
||||||
payment_hash = self.htlcs_in_remote[0].payment_hash
|
if len(self.htlcs_in_remote) > 0:
|
||||||
amount_msat = self.htlcs_in_remote[0].amount_msat
|
assert len(self.htlcs_in_remote) == 1
|
||||||
cltv_expiry = self.htlcs_in_remote[0].cltv_expiry
|
we_receive = True
|
||||||
htlc_tx = make_htlc_tx_with_open_channel(self, this_point, True, we_receive, amount_msat, cltv_expiry, payment_hash, pending_local_commitment, 0)
|
htlc = self.htlcs_in_remote[0]
|
||||||
|
elif len(self.htlcs_in_local) > 0:
|
||||||
|
assert len(self.htlcs_in_local) == 1
|
||||||
|
we_receive = False
|
||||||
|
htlc = self.htlcs_in_local[0]
|
||||||
|
else:
|
||||||
|
assert False
|
||||||
|
|
||||||
|
htlc_tx = make_htlc_tx_with_open_channel(self, this_point, True, we_receive, htlc.amount_msat, htlc.cltv_expiry, htlc.payment_hash, pending_local_commitment, 0)
|
||||||
pre_hash = Hash(bfh(htlc_tx.serialize_preimage(0)))
|
pre_hash = Hash(bfh(htlc_tx.serialize_preimage(0)))
|
||||||
remote_htlc_pubkey = derive_pubkey(self.remote_config.htlc_basepoint.pubkey, this_point)
|
remote_htlc_pubkey = derive_pubkey(self.remote_config.htlc_basepoint.pubkey, this_point)
|
||||||
if not ecc.verify_signature(remote_htlc_pubkey, htlc_sigs[0], pre_hash):
|
if not ecc.verify_signature(remote_htlc_pubkey, htlc_sigs[0], pre_hash):
|
||||||
|
@ -451,9 +459,6 @@ class HTLCStateMachine(PrintError):
|
||||||
amount_msat = self.local_state.amount_msat + (received_this_batch - sent_this_batch)
|
amount_msat = self.local_state.amount_msat + (received_this_batch - sent_this_batch)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.balance(LOCAL)
|
|
||||||
self.balance(REMOTE)
|
|
||||||
|
|
||||||
for pending_fee in self.fee_mgr:
|
for pending_fee in self.fee_mgr:
|
||||||
if pending_fee.is_proposed():
|
if pending_fee.is_proposed():
|
||||||
if self.constraints.is_initiator:
|
if self.constraints.is_initiator:
|
||||||
|
|
Loading…
Add table
Reference in a new issue