From 689c578081a8a2c719d73c381fd51e009a18aad7 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Tue, 9 Oct 2018 13:13:46 -0400 Subject: [PATCH] get_or_create_usable_address returns a random choice when returning an existing unused address --- torba/baseaccount.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/torba/baseaccount.py b/torba/baseaccount.py index b2c5fb8d7..f332d7a93 100644 --- a/torba/baseaccount.py +++ b/torba/baseaccount.py @@ -1,3 +1,4 @@ +import random import typing from typing import List, Dict, Tuple, Type, Optional, Any from twisted.internet import defer @@ -73,9 +74,9 @@ class AddressManager: @defer.inlineCallbacks def get_or_create_usable_address(self) -> defer.Deferred: - addresses = yield self.get_addresses(only_usable=True, limit=1) + addresses = yield self.get_addresses(only_usable=True, limit=10) if addresses: - return addresses[0] + return random.choice(addresses) addresses = yield self.ensure_address_gap() return addresses[0]