Skip to content
Snippets Groups Projects
Commit df2376ad authored by matograine's avatar matograine Committed by Moul
Browse files

[feat] #111 : Send multiple amounts

* modiication of transaction_amount() function
* transaction_amount() now :
	* splits the amount string into a list
	* computes the total
	* returns the list and the total into a tuple
* ! Code is in an unstable state.
* ! tests_tx.py shouldn't pass
parent b5cd4bbc
No related branches found
No related tags found
No related merge requests found
......@@ -158,14 +158,28 @@ def check_amount(amounts, amount, minimal_amount, multiplicator, reference):
)
async def transaction_amount(amount, amountUD, allSources):
async def transaction_amount(amount, amountUD, outputAddresses):
"""
Return transaction amount
Check command line interface amount option
Returns transaction amounts (list) and total amount.
"""
amounts = list()
# creating amounts list
if amount:
return round(amount * 100)
check_amount(amounts, amount, MINIMAL_TX_AMOUNT, CENT_MULT_TO_UNIT, "unit")
if amountUD:
return round(amountUD * await money.UDValue().ud_value)
UD_value = await money.UDValue().ud_value
check_amount(amounts, amountUD, 0, UD_value, "UD")
# calculating the total
if len(amounts) != len(outputAddresses) and len(amounts) != 1:
message_exit(
"Error : The number of passed recipients (--output) is not the same as the passed amounts (--amount)."
)
if len(amounts) == 1:
total = amounts[0] * len(outputAddresses)
elif len(amounts) > 1:
total = sum(amounts)
return amounts, total
def check_transaction_values(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment