electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 06d4224101c51fb40048f847b2f4542e6b9aeab0
parent 2323118bda08dcb62b98c7bf08beba35bf2324a9
Author: Janus <ysangkok@gmail.com>
Date:   Tue, 18 Dec 2018 15:07:07 +0100

lnchan: remove debugging code, commented out code

Diffstat:
Melectrum/lnchan.py | 14+++++---------
Melectrum/tests/test_lnchan.py | 14--------------
2 files changed, 5 insertions(+), 23 deletions(-)

diff --git a/electrum/lnchan.py b/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 diff --git a/electrum/tests/test_lnchan.py b/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):