Browse Source

lnchan: remove debugging code, commented out code

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

14
electrum/lnchan.py

@ -147,7 +147,7 @@ class Channel(PrintError):
except:
return super().diagnostic_name()
def __init__(self, state, sweep_address = None, name = None, payment_completed : Optional[Callable[[HTLCOwner, UpdateAddHtlc, bytes], None]] = None, local_commitment = None):
def __init__(self, state, sweep_address = None, name = None, payment_completed : Optional[Callable[[HTLCOwner, UpdateAddHtlc, bytes], None]] = None):
self.preimages = {}
if not payment_completed:
payment_completed = lambda this, x, y, z: None
@ -205,12 +205,7 @@ class Channel(PrintError):
for sub in (LOCAL, REMOTE):
self.log[sub].locked_in.update(self.log[sub].adds.keys())
if local_commitment:
local_commitment = Transaction(str(local_commitment))
local_commitment.deserialize(True)
self.set_local_commitment(local_commitment)
else:
self.set_local_commitment(self.current_commitment(LOCAL))
self.set_local_commitment(self.current_commitment(LOCAL))
self.set_remote_commitment(self.current_commitment(REMOTE))
def set_local_commitment(self, ctx):
@ -781,7 +776,7 @@ class Channel(PrintError):
serialized_channel[k] = v
dumped = ChannelJsonEncoder().encode(serialized_channel)
roundtripped = json.loads(dumped)
reconstructed = Channel(roundtripped, local_commitment=self.local_commitment)
reconstructed = Channel(roundtripped)
to_save_new = reconstructed.to_save()
if to_save_new != to_save_ref:
from pprint import PrettyPrinter
@ -877,7 +872,8 @@ class Channel(PrintError):
if remote_sig: # only None in test
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)
if not ecc.verify_signature(self.config[REMOTE].multisig_key.pubkey, remote_sig, pre_hash):
self.print_error("WARNING: commitment signature inconsistency, cannot force close")
def force_close_tx(self):
tx = self.local_commitment

14
electrum/tests/test_lnchan.py

@ -82,7 +82,6 @@ def create_channel_state(funding_txid, funding_index, funding_sat, local_feerate
per_commitment_secret_seed=seed,
funding_locked_received=True,
was_announced=False,
# just a random signature
current_commitment_signature=None,
current_htlc_signatures=None,
),
@ -135,19 +134,6 @@ def create_test_channels(feerate=6000, local=None, remote=None):
alice.set_state('OPEN')
bob.set_state('OPEN')
#old_bob = bob.config[REMOTE]
#bob.config[REMOTE] = bob.config[REMOTE]._replace(ctn=bob.config[REMOTE].ctn)
#sig_from_bob = bob.sign_next_commitment()[0]
#bob.config[REMOTE] = old_bob
#old_alice = alice.config[REMOTE]
#alice.config[REMOTE] = alice.config[REMOTE]._replace(ctn=alice.config[REMOTE].ctn)
#sig_from_alice = alice.sign_next_commitment()[0]
#alice.config[REMOTE] = old_alice
#alice.config[LOCAL] = alice.config[LOCAL]._replace(current_commitment_signature=sig_from_bob)
#bob.config[LOCAL] = bob.config[LOCAL]._replace(current_commitment_signature=sig_from_alice)
return alice, bob
class TestFee(unittest.TestCase):

Loading…
Cancel
Save