Browse Source

lnchan: make force_close_tx() assure that tx is valid, trigger failure in test

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
Janus 6 years ago
committed by ThomasV
parent
commit
1d8fe52fa3
  1. 5
      electrum/lnchan.py
  2. 2
      electrum/tests/test_lnchan.py

5
electrum/lnchan.py

@ -868,6 +868,11 @@ class Channel(PrintError):
tx = self.current_commitment(LOCAL)
tx.sign({bh2u(self.config[LOCAL].multisig_key.pubkey): (self.config[LOCAL].multisig_key.privkey, True)})
remote_sig = self.config[LOCAL].current_commitment_signature
preimage_hex = tx.serialize_preimage(0)
pre_hash = sha256d(bfh(preimage_hex))
assert ecc.verify_signature(self.config[REMOTE].multisig_key.pubkey, remote_sig, pre_hash)
remote_sig = ecc.der_sig_from_sig_string(remote_sig) + b"\x01"
none_idx = tx._inputs[0]["signatures"].index(None)
tx.add_signature_to_txin(0, none_idx, bh2u(remote_sig))

2
electrum/tests/test_lnchan.py

@ -237,6 +237,8 @@ class TestChannel(unittest.TestCase):
# forward since she's sending an outgoing HTLC.
alice_channel.receive_revocation(bobRevocation)
alice_channel.force_close_tx()
# test serializing with locked_in htlc
self.assertEqual(len(alice_channel.to_save()['local_log']), 1)
alice_channel.serialize()

Loading…
Cancel
Save