Browse Source

rename paying -> inflight

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
ThomasV 6 years ago
parent
commit
0a08ccc1c6
  1. 14
      electrum/lnworker.py
  2. 2
      electrum/tests/test_lnbase.py

14
electrum/lnworker.py

@ -68,7 +68,7 @@ class LNWorker(PrintError):
self.wallet = wallet self.wallet = wallet
# invoices we are currently trying to pay (might be pending HTLCs on a commitment transaction) # invoices we are currently trying to pay (might be pending HTLCs on a commitment transaction)
self.invoices = self.wallet.storage.get('lightning_invoices', {}) # type: Dict[str, Tuple[str,str]] # RHASH -> (preimage, invoice) self.invoices = self.wallet.storage.get('lightning_invoices', {}) # type: Dict[str, Tuple[str,str]] # RHASH -> (preimage, invoice)
self.paying = self.wallet.storage.get('lightning_payments_inflight', {}) # type: Dict[bytes, Tuple[str, Optional[int], str]] self.inflight = self.wallet.storage.get('lightning_payments_inflight', {}) # type: Dict[bytes, Tuple[str, Optional[int], str]]
self.completed = self.wallet.storage.get('lightning_payments_completed', {}) self.completed = self.wallet.storage.get('lightning_payments_completed', {})
self.sweep_address = wallet.get_receiving_address() self.sweep_address = wallet.get_receiving_address()
self.lock = threading.RLock() self.lock = threading.RLock()
@ -128,8 +128,8 @@ class LNWorker(PrintError):
chan_id = chan.channel_id chan_id = chan.channel_id
if direction == SENT: if direction == SENT:
assert htlc.payment_hash not in self.invoices assert htlc.payment_hash not in self.invoices
self.paying.pop(key) self.inflight.pop(key)
self.wallet.storage.put('lightning_payments_inflight', self.paying) self.wallet.storage.put('lightning_payments_inflight', self.inflight)
if not preimage: if not preimage:
preimage, _addr = self.get_invoice(htlc.payment_hash) preimage, _addr = self.get_invoice(htlc.payment_hash)
tupl = (time.time(), direction, json.loads(encoder.encode(htlc)), bh2u(preimage), bh2u(chan_id)) tupl = (time.time(), direction, json.loads(encoder.encode(htlc)), bh2u(preimage), bh2u(chan_id))
@ -142,7 +142,7 @@ class LNWorker(PrintError):
from electrum.util import PR_UNPAID, PR_EXPIRED, PR_PAID, PR_UNKNOWN, PR_INFLIGHT from electrum.util import PR_UNPAID, PR_EXPIRED, PR_PAID, PR_UNKNOWN, PR_INFLIGHT
if key in self.completed: if key in self.completed:
return PR_PAID return PR_PAID
elif key in self.paying: elif key in self.inflight:
return PR_INFLIGHT return PR_INFLIGHT
elif key in self.invoices: elif key in self.invoices:
return PR_UNPAID return PR_UNPAID
@ -169,7 +169,7 @@ class LNWorker(PrintError):
for preimage, pay_req in invoices.values(): for preimage, pay_req in invoices.values():
addr = lndecode(pay_req, expected_hrp=constants.net.SEGWIT_HRP) addr = lndecode(pay_req, expected_hrp=constants.net.SEGWIT_HRP)
unsettled.append((addr, bfh(preimage), pay_req)) unsettled.append((addr, bfh(preimage), pay_req))
for pay_req, amount_sat, this_chan_id in self.paying.values(): for pay_req, amount_sat, this_chan_id in self.inflight.values():
if chan_id is not None and bfh(this_chan_id) != chan_id: if chan_id is not None and bfh(this_chan_id) != chan_id:
continue continue
addr = lndecode(pay_req, expected_hrp=constants.net.SEGWIT_HRP) addr = lndecode(pay_req, expected_hrp=constants.net.SEGWIT_HRP)
@ -447,8 +447,8 @@ class LNWorker(PrintError):
break break
else: else:
assert False, 'Found route with short channel ID we don\'t have: ' + repr(route[0].short_channel_id) assert False, 'Found route with short channel ID we don\'t have: ' + repr(route[0].short_channel_id)
self.paying[bh2u(addr.paymenthash)] = (invoice, amount_sat, bh2u(chan_id)) self.inflight[bh2u(addr.paymenthash)] = (invoice, amount_sat, bh2u(chan_id))
self.wallet.storage.put('lightning_payments_inflight', self.paying) self.wallet.storage.put('lightning_payments_inflight', self.inflight)
self.wallet.storage.write() self.wallet.storage.write()
return addr, peer, self._pay_to_route(route, addr) return addr, peer, self._pay_to_route(route, addr)

2
electrum/tests/test_lnbase.py

@ -82,7 +82,7 @@ class MockLNWorker:
self.network = MockNetwork(tx_queue) self.network = MockNetwork(tx_queue)
self.channels = {self.chan.channel_id: self.chan} self.channels = {self.chan.channel_id: self.chan}
self.invoices = {} self.invoices = {}
self.paying = {} self.inflight = {}
self.wallet = MockWallet() self.wallet = MockWallet()
@property @property

Loading…
Cancel
Save