<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dump_addresses(self, network, filename=None):
 """Return a list of address dictionaries for each address in all of the accounts in this wallet of the network specified by `network` """

        addrs =  [addr.data for a in self.accounts.values() if a.network == network
                            for addr in a.addresses]
        if filename:
            from json import dump
            with open(filename, 'w') as f:
                dump(addrs, f)

        return addrs