Browse Source

Merge pull request #6326 from SomberNight/202007_fix_importedwallet_new_request

qt receive tab: fix creating new payreq with all used imported wallet
bip39-recovery
ThomasV 5 years ago
committed by GitHub
parent
commit
392a648de5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      electrum/gui/qt/main_window.py
  2. 4
      electrum/lnworker.py

18
electrum/gui/qt/main_window.py

@ -1209,7 +1209,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
key = self.wallet.lnworker.add_request(amount, message, expiry)
else:
key = self.create_bitcoin_request(amount, message, expiry)
if not key:
return
self.address_list.update()
assert key is not None
self.request_list.update()
self.request_list.select_key(key)
# clear request fields
@ -1221,17 +1224,20 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
title = _('Invoice') if is_lightning else _('Address')
self.do_copy(content, title=title)
def create_bitcoin_request(self, amount, message, expiration):
def create_bitcoin_request(self, amount, message, expiration) -> Optional[str]:
addr = self.wallet.get_unused_address()
if addr is None:
if not self.wallet.is_deterministic():
if not self.wallet.is_deterministic(): # imported wallet
msg = [
_('No more addresses in your wallet.'),
_('You are using a non-deterministic wallet, which cannot create new addresses.'),
_('If you want to create new addresses, use a deterministic wallet instead.')
_('No more addresses in your wallet.'), ' ',
_('You are using a non-deterministic wallet, which cannot create new addresses.'), ' ',
_('If you want to create new addresses, use a deterministic wallet instead.'), '\n\n',
_('Creating a new payment request will reuse one of your addresses and overwrite an existing request. Continue anyway?'),
]
self.show_message(' '.join(msg))
if not self.question(''.join(msg)):
return
addr = self.wallet.get_receiving_address()
else: # deterministic wallet
if not self.question(_("Warning: The next address will not be recovered automatically if you restore your wallet from seed; you may need to add it manually.\n\nThis occurs because you have too many unused addresses in your wallet. To avoid this situation, use the existing addresses first.\n\nCreate anyway?")):
return
addr = self.wallet.create_new_address(False)

4
electrum/lnworker.py

@ -1123,7 +1123,7 @@ class LNWallet(LNWorker):
route[-1].node_features |= invoice_features
return route
def add_request(self, amount_sat, message, expiry):
def add_request(self, amount_sat, message, expiry) -> str:
coro = self._add_request_coro(amount_sat, message, expiry)
fut = asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop)
try:
@ -1158,7 +1158,7 @@ class LNWallet(LNWorker):
self.save_payment_info(info)
return lnaddr, invoice
async def _add_request_coro(self, amount_sat: Optional[int], message, expiry: int):
async def _add_request_coro(self, amount_sat: Optional[int], message, expiry: int) -> str:
lnaddr, invoice = await self.create_invoice(amount_sat, message, expiry)
key = bh2u(lnaddr.paymenthash)
req = LNInvoice.from_bech32(invoice)

Loading…
Cancel
Save