Skip to content
Snippets Groups Projects
Commit 70531a3b authored by inso's avatar inso
Browse files

Fix owner of sources sent ( #553 )

parent 7cb55cf7
No related branches found
No related tags found
No related merge requests found
...@@ -62,12 +62,13 @@ class SourcesProcessor: ...@@ -62,12 +62,13 @@ class SourcesProcessor:
sources = self._repo.get_all(currency=currency, pubkey=pubkey) sources = self._repo.get_all(currency=currency, pubkey=pubkey)
return sum([s.amount * (10**s.base) for s in sources]) 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 currency: the currency of the sources
:param str pubkey: the owner of the sources
:rtype: list[sakia.data.entities.Source] :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): def consume(self, sources):
""" """
......
...@@ -212,12 +212,13 @@ class DocumentsService: ...@@ -212,12 +212,13 @@ class DocumentsService:
document.sign(self_cert, [key]) document.sign(self_cert, [key])
return document.signed_raw(self_cert) 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 Get inputs to generate a transaction with a given amount of money
:param int amount: The amount target value :param int amount: The amount target value
:param int amount_base: The amount base target value :param int amount_base: The amount base target value
:param str currency: The community target of the transaction :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 :return: The list of inputs to use in the transaction document
""" """
...@@ -234,7 +235,7 @@ class DocumentsService: ...@@ -234,7 +235,7 @@ class DocumentsService:
return i return i
amount, amount_base = reduce_base(amount, amount_base) 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: if available_sources:
current_base = max([src.base for src in available_sources]) current_base = max([src.base for src in available_sources])
value = 0 value = 0
...@@ -335,7 +336,7 @@ class DocumentsService: ...@@ -335,7 +336,7 @@ class DocumentsService:
:return: the transaction document :return: the transaction document
:rtype: duniterpy.documents.Transaction :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] sources = result[0]
computed_outputs = result[1] computed_outputs = result[1]
overheads = result[2] overheads = result[2]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment