1
0

network: randomise the order of address subscriptions

Before this, we were subscribing to our addresses in their bip32 order,
leaking this information to servers. While this leak seems mostly harmless,
it is trivial to fix.
This commit is contained in:
SomberNight
2020-06-17 19:25:52 +02:00
parent 2580832a88
commit 2c962abe51
4 changed files with 18 additions and 9 deletions

View File

@@ -24,7 +24,7 @@ import binascii
import os, sys, re, json
from collections import defaultdict, OrderedDict
from typing import (NamedTuple, Union, TYPE_CHECKING, Tuple, Optional, Callable, Any,
Sequence, Dict, Generic, TypeVar)
Sequence, Dict, Generic, TypeVar, List, Iterable)
from datetime import datetime
import decimal
from decimal import Decimal
@@ -1398,3 +1398,12 @@ class JsonRPCClient:
async def coro(*args):
return await self.request(endpoint, *args)
setattr(self, endpoint, coro)
T = TypeVar('T')
def random_shuffled_copy(x: Iterable[T]) -> List[T]:
"""Returns a shuffled copy of the input."""
x_copy = list(x) # copy
random.shuffle(x_copy) # shuffle in-place
return x_copy