electrum

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

commit 392a648de5f6edf2e06620763bf0685854d0d56d
parent 0f6898ed90be7777254b6868e1e1b0b5af79372f
Author: ThomasV <thomasv@electrum.org>
Date:   Fri,  3 Jul 2020 21:45:08 +0200

Merge pull request #6326 from SomberNight/202007_fix_importedwallet_new_request

qt receive tab: fix creating new payreq with all used imported wallet
Diffstat:
Melectrum/gui/qt/main_window.py | 26++++++++++++++++----------
Melectrum/lnworker.py | 4++--
2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/electrum/gui/qt/main_window.py b/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,20 +1224,23 @@ 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)) - return - 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) + 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) req = self.wallet.make_payment_request(addr, amount, message, expiration) try: self.wallet.add_payment_request(req) diff --git a/electrum/lnworker.py b/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)