diff --git a/silkaj/tx.py b/silkaj/tx.py index acaf8ed5fe3bb79e931e43247872f3d470f69573..0f7348be0ca8cd725f7ce6aff200204a66be63eb 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -28,7 +28,6 @@ from silkaj.tools import message_exit, CurrencySymbol, coroutine from silkaj.auth import auth_method from silkaj import money from silkaj.constants import ( - SOURCES_PER_TX, MINIMAL_TX_AMOUNT, CENT_MULT_TO_UNIT, ABSOLUTE_REF, @@ -279,9 +278,11 @@ async def transaction_confirmation( return tx -async def get_list_input_for_transaction(pubkey, TXamount): +async def get_list_input_for_transaction(pubkey, TXamount, outputs_number): listinput, amount = await money.get_sources(pubkey) + # check max inputs. For now we deal only with one issuer + maxInputsNumber = max_inputs_number(outputs_number, 1) # generate final list source listinputfinal = [] totalAmountInput = 0 @@ -290,11 +291,10 @@ async def get_list_input_for_transaction(pubkey, TXamount): listinputfinal.append(input) totalAmountInput += money.amount_in_current_base(input) TXamount -= money.amount_in_current_base(input) - # if more than 40 sources, it's an intermediate transaction - if len(listinputfinal) >= SOURCES_PER_TX: + # if too much sources, it's an intermediate transaction + if len(listinputfinal) >= maxInputsNumber and not len(listinputfinal) == 1: intermediatetransaction = True - break - if TXamount <= 0: + if (len(listinputfinal) >= MAX_INPUTS_PER_TX) or (TXamount <= 0): break if TXamount > 0 and not intermediatetransaction: message_exit("Error: you don't have enough money") @@ -311,9 +311,10 @@ async def handle_intermediaries_transactions( OutputbackChange=None, ): client = ClientInstance().client + while True: listinput_and_amount = await get_list_input_for_transaction( - issuers, total_tx_amount + issuers, total_tx_amount, (len(outputAddresses) + 1) ) intermediatetransaction = listinput_and_amount[2]