electrum

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

commit 2f31e9fa44c36140710b86657ce51ecb5ccf34fd
parent 3d69f3b0beb4a3be74aeef8a96f5ffef5f82ee90
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 10 Mar 2020 13:51:08 +0100

follow-up prev commit

Diffstat:
Melectrum/lnworker.py | 16+++++++++-------
Melectrum/tests/test_lnpeer.py | 2++
2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -1214,14 +1214,14 @@ class LNWallet(LNWorker): elif key in self.is_routing: self.is_routing.remove(key) if status in SAVED_PR_STATUS: - self.save_payment_status(bfh(key), status) + self.set_payment_status(bfh(key), status) async def await_payment(self, payment_hash): success, preimage, reason = await self.pending_payments[payment_hash] self.pending_payments.pop(payment_hash) return success, preimage, reason - def save_payment_status(self, payment_hash: bytes, status): + def set_payment_status(self, payment_hash: bytes, status): try: info = self.get_payment_info(payment_hash) except UnknownPaymentHash: @@ -1231,29 +1231,31 @@ class LNWallet(LNWorker): self.save_payment_info(info) def payment_failed(self, chan, payment_hash: bytes, reason): - self.save_payment_status(payment_hash, PR_UNPAID) + self.set_payment_status(payment_hash, PR_UNPAID) + key = payment_hash.hex() f = self.pending_payments.get(payment_hash) if f and not f.cancelled(): f.set_result((False, None, reason)) else: chan.logger.info('received unexpected payment_failed, probably from previous session') self.network.trigger_callback('invoice_status', key) - self.network.trigger_callback('payment_failed', payment_hash.hex()) + self.network.trigger_callback('payment_failed', key, '') def payment_sent(self, chan, payment_hash: bytes): - self.save_payment_status(payment_hash, PR_PAID) + self.set_payment_status(payment_hash, PR_PAID) preimage = self.get_preimage(payment_hash) + key = payment_hash.hex() f = self.pending_payments.get(payment_hash) if f and not f.cancelled(): f.set_result((True, preimage, None)) else: chan.logger.info('received unexpected payment_sent, probably from previous session') self.network.trigger_callback('invoice_status', key) - self.network.trigger_callback('payment_succeeded', payment_hash.hex()) + self.network.trigger_callback('payment_succeeded', key) self.network.trigger_callback('ln_payment_completed', payment_hash, chan.channel_id) def payment_received(self, chan, payment_hash: bytes): - self.save_payment_status(payment_hash, PR_PAID) + self.set_payment_status(payment_hash, PR_PAID) self.network.trigger_callback('request_status', payment_hash.hex(), PR_PAID) self.network.trigger_callback('ln_payment_completed', payment_hash, chan.channel_id) diff --git a/electrum/tests/test_lnpeer.py b/electrum/tests/test_lnpeer.py @@ -126,9 +126,11 @@ class MockLNWallet(Logger): def save_channel(self, chan): print("Ignoring channel save") + is_routing = set() preimages = {} get_payment_info = LNWallet.get_payment_info save_payment_info = LNWallet.save_payment_info + set_invoice_status = LNWallet.set_invoice_status set_payment_status = LNWallet.set_payment_status get_payment_status = LNWallet.get_payment_status await_payment = LNWallet.await_payment