diff --git a/src/sakia/data/processors/sources.py b/src/sakia/data/processors/sources.py index 70e4700566fcea8f92bb532ef4252dcfc28d5fdb..006352b5552b8d3207dea2c3f59b09cd526d922b 100644 --- a/src/sakia/data/processors/sources.py +++ b/src/sakia/data/processors/sources.py @@ -62,12 +62,13 @@ class SourcesProcessor: sources = self._repo.get_all(currency=currency, pubkey=pubkey) return sum([s.amount * (10**s.base) for s in sources]) - def available(self, currency): + def available(self, currency, pubkey): """" :param str currency: the currency of the sources + :param str pubkey: the owner of the sources :rtype: list[sakia.data.entities.Source] """ - return self._repo.get_all(currency=currency) + return self._repo.get_all(currency=currency, pubkey=pubkey) def consume(self, sources): """ diff --git a/src/sakia/services/documents.py b/src/sakia/services/documents.py index 2fc43b34c9f41d7d594aa36235ade75b02b9adf9..3be55c31b2e4fae14bc9252c51627b1bd2415b1d 100644 --- a/src/sakia/services/documents.py +++ b/src/sakia/services/documents.py @@ -212,12 +212,13 @@ class DocumentsService: document.sign(self_cert, [key]) return document.signed_raw(self_cert) - def tx_sources(self, amount, amount_base, currency): + def tx_sources(self, amount, amount_base, currency, pubkey): """ Get inputs to generate a transaction with a given amount of money :param int amount: The amount target value :param int amount_base: The amount base target value :param str currency: The community target of the transaction + :param str pubkey: The pubkey owning the sources :return: The list of inputs to use in the transaction document """ @@ -234,7 +235,7 @@ class DocumentsService: return i amount, amount_base = reduce_base(amount, amount_base) - available_sources = self._sources_processor.available(currency) + available_sources = self._sources_processor.available(currency, pubkey) if available_sources: current_base = max([src.base for src in available_sources]) value = 0 @@ -335,7 +336,7 @@ class DocumentsService: :return: the transaction document :rtype: duniterpy.documents.Transaction """ - result = self.tx_sources(int(amount), amount_base, currency) + result = self.tx_sources(int(amount), amount_base, currency, issuer) sources = result[0] computed_outputs = result[1] overheads = result[2]