66
77import filters as f
88
9- from iota import Address
9+ from iota import Address , AddressChecksum
1010from iota .commands import FilterCommand , RequestFilter
1111from iota .commands .core .find_transactions import FindTransactionsCommand
1212from iota .crypto .addresses import AddressGenerator
@@ -33,28 +33,33 @@ def get_response_filter(self):
3333 pass
3434
3535 def _execute (self , request ):
36+ checksum = request ['checksum' ] # type: bool
3637 count = request ['count' ] # type: Optional[int]
3738 index = request ['index' ] # type: int
3839 security_level = request ['securityLevel' ] # type: int
3940 seed = request ['seed' ] # type: Seed
4041
4142 return {
42- 'addresses' : self ._find_addresses (seed , index , count , security_level ),
43+ 'addresses' :
44+ self ._find_addresses (seed , index , count , security_level , checksum ),
4345 }
4446
45- def _find_addresses (self , seed , index , count , security_level ):
46- # type: (Seed, int, Optional[int], int) -> List[Address]
47+ def _find_addresses (self , seed , index , count , security_level , checksum ):
48+ # type: (Seed, int, Optional[int], int, bool ) -> List[Address]
4749 """
4850 Find addresses matching the command parameters.
4951 """
50- # type: (Seed, int, Optional[int]) -> List[Address]
51- generator = AddressGenerator (seed , security_level )
52+ generator = AddressGenerator (seed , security_level , checksum )
5253
5354 if count is None :
5455 # Connect to Tangle and find the first address without any
5556 # transactions.
5657 for addy in generator .create_iterator (start = index ):
57- response = FindTransactionsCommand (self .adapter )(addresses = [addy ])
58+ # We use addy.address here because FindTransactions does
59+ # not work on an address with a checksum
60+ response = FindTransactionsCommand (self .adapter )(
61+ addresses = [addy .address ]
62+ )
5863
5964 if not response .get ('hashes' ):
6065 return [addy ]
@@ -75,8 +80,10 @@ def __init__(self):
7580 super (GetNewAddressesRequestFilter , self ).__init__ (
7681 {
7782 # Everything except ``seed`` is optional.
78- 'count' : f .Type (int ) | f .Min (1 ),
79- 'index' : f .Type (int ) | f .Min (0 ) | f .Optional (default = 0 ),
83+
84+ 'checksum' : f .Type (bool ) | f .Optional (default = False ),
85+ 'count' : f .Type (int ) | f .Min (1 ),
86+ 'index' : f .Type (int ) | f .Min (0 ) | f .Optional (default = 0 ),
8087
8188 'securityLevel' :
8289 f .Type (int )
@@ -88,6 +95,7 @@ def __init__(self):
8895 },
8996
9097 allow_missing_keys = {
98+ 'checksum' ,
9199 'count' ,
92100 'index' ,
93101 'securityLevel' ,
0 commit comments