URI: 
       tsubmarine_swaps: wallet.get_unused_address -> get_receiving_address - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 5f2d347d81f9b8daeab3757eeed736c867cf12bd
   DIR parent eb910ba14f2a5493b85ef65efcc46cdeacfa787a
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Thu, 18 Jun 2020 17:11:14 +0200
       
       submarine_swaps: wallet.get_unused_address -> get_receiving_address
       
       Diffstat:
         M electrum/submarine_swaps.py         |       2 +-
         M electrum/wallet.py                  |      13 +++++++++++--
       
       2 files changed, 12 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/electrum/submarine_swaps.py b/electrum/submarine_swaps.py
       t@@ -142,7 +142,7 @@ class SwapManager(Logger):
                    if amount_sat < dust_threshold():
                        self.logger.info('utxo value below dust threshold')
                        continue
       -            address = self.wallet.get_unused_address()
       +            address = self.wallet.get_receiving_address()
                    preimage = swap.preimage if swap.is_reverse else 0
                    tx = create_claim_tx(txin, swap.redeem_script, preimage, swap.privkey, address, amount_sat, swap.locktime)
                    await self.network.broadcast_transaction(tx)
   DIR diff --git a/electrum/wallet.py b/electrum/wallet.py
       t@@ -1566,19 +1566,28 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
        
            def get_unused_addresses(self) -> Sequence[str]:
                domain = self.get_receiving_addresses()
       -        in_use_by_request = [k for k in self.receive_requests.keys() if self.get_request_status(k) != PR_EXPIRED] # we should index receive_requests by id
       +        # TODO we should index receive_requests by id
       +        in_use_by_request = [k for k in self.receive_requests.keys()
       +                             if self.get_request_status(k) != PR_EXPIRED]
       +        in_use_by_request = set(in_use_by_request)
                return [addr for addr in domain if not self.is_used(addr)
                        and addr not in in_use_by_request]
        
            @check_returned_address_for_corruption
            def get_unused_address(self) -> Optional[str]:
       +        """Get an unused receiving address, if there is one.
       +        Note: there might NOT be one available!
       +        """
                addrs = self.get_unused_addresses()
                if addrs:
                    return addrs[0]
        
            @check_returned_address_for_corruption
            def get_receiving_address(self) -> str:
       -        # always return an address
       +        """Get a receiving address. Guaranteed to always return an address."""
       +        unused_addr = self.get_unused_address()
       +        if unused_addr:
       +            return unused_addr
                domain = self.get_receiving_addresses()
                if not domain:
                    raise Exception("no receiving addresses in wallet?!")