electrum

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

commit 954e4c889285791dc0cbb37b00578e6ca1075d1e
parent 909f1e77de76abfee63ee6e6077830c55bd889eb
Author: ThomasV <thomasv@electrum.org>
Date:   Sun,  3 Feb 2019 15:27:48 +0100

lnbase: rename methods, fix tests

Diffstat:
Melectrum/lnbase.py | 14+++++++-------
Melectrum/tests/test_lnbase.py | 6++++++
2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/electrum/lnbase.py b/electrum/lnbase.py @@ -706,7 +706,7 @@ class Peer(PrintError): chan.config[LOCAL]=chan.config[LOCAL]._replace( ctn=remote_ctn, ) - self.revoke(chan) + self.send_revoke_and_ack(chan) else: self.print_error("expected local ctn {}, got {}".format(chan.config[LOCAL].ctn, local_ctn)) # TODO iff their ctn is lower than ours, we should force close instead @@ -968,15 +968,15 @@ class Peer(PrintError): async def send_and_revoke(self, chan: Channel): """ generic channel update flow """ self.send_commitment(chan) - await self.receive_revoke(chan) + await self.receive_revoke_and_ack(chan) await self.receive_commitment(chan) - self.revoke(chan) + self.send_revoke_and_ack(chan) async def receive_and_revoke(self, chan: Channel): await self.receive_commitment(chan) - self.revoke(chan) + self.send_revoke_and_ack(chan) self.send_commitment(chan) - await self.receive_revoke(chan) + await self.receive_revoke_and_ack(chan) async def pay(self, route: List['RouteEdge'], chan: Channel, amount_msat: int, payment_hash: bytes, min_final_cltv_expiry: int): @@ -1004,12 +1004,12 @@ class Peer(PrintError): await self.send_and_revoke(chan) return UpdateAddHtlc(**htlc, htlc_id=htlc_id) - async def receive_revoke(self, chan: Channel): + async def receive_revoke_and_ack(self, chan: Channel): revoke_and_ack_msg = await self.revoke_and_ack[chan.channel_id].get() chan.receive_revocation(RevokeAndAck(revoke_and_ack_msg["per_commitment_secret"], revoke_and_ack_msg["next_per_commitment_point"])) self.lnworker.save_channel(chan) - def revoke(self, chan: Channel): + def send_revoke_and_ack(self, chan: Channel): rev, _ = chan.revoke_current_commitment() self.lnworker.save_channel(chan) self.send_message("revoke_and_ack", diff --git a/electrum/tests/test_lnbase.py b/electrum/tests/test_lnbase.py @@ -96,6 +96,12 @@ class MockLNWorker: def channels_for_peer(self, pubkey): return self.channels + def get_channel_by_short_id(self, short_channel_id): + with self.lock: + for chan in self.channels.values(): + if chan.short_channel_id == short_channel_id: + return chan + def save_channel(self, chan): print("Ignoring channel save")