code: def is_safe_to_wait(
          lock_expiration: BlockExpiration,
          reveal_timeout: BlockTimeout,
          block_number: BlockNumber,
  ) -> SuccessOrError:
      
      # reveal timeout will not ever be larger than the lock_expiration otherwise
      # the expected block_number is negative
      assert block_number > 0
      assert reveal_timeout > 0
      assert lock_expiration > reveal_timeout
  
      lock_timeout = lock_expiration - block_number
  
      # A node may wait for a new balance proof while there are reveal_timeout
      # blocks left, at that block and onwards it is not safe to wait.
      if lock_timeout > reveal_timeout:
          return True, None
  
      msg = (
          f'lock timeout is unsafe.'
          f' timeout must be larger than {reveal_timeout}, but it is {lock_timeout}.'
          f' expiration: {lock_expiration} block_number: {block_number}'
      )
      return False, msg
docs: True if waiting is safe, i.e. there are more than enough blocks to safely
      unlock on chain.