mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
qt receive tab: fix creating new payreq with all used imported wallet
fixes #6325
This commit is contained in:
parent
0f6898ed90
commit
c54b9a6874
2 changed files with 18 additions and 12 deletions
|
@ -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)
|
||||
|
|
|
@ -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…
Add table
Reference in a new issue