Skip to content
Snippets Groups Projects
Commit 1d063d7f authored by Moul's avatar Moul
Browse files

[mod] #72: tx: use generic f() to generate tx outputs.

parent 39f9bb9c
No related branches found
No related tags found
No related merge requests found
......@@ -252,40 +252,11 @@ def generate_transaction_document(
listoutput = []
# Outputs to receiver (if not himself)
for outputAddress in outputAddresses:
rest = AmountTransfered
unitbase = curentUnitBase
while rest > 0:
outputAmount = truncBase(rest, unitbase)
rest -= outputAmount
if outputAmount > 0:
outputAmount = int(outputAmount / math.pow(10, unitbase))
listoutput.append(
str(outputAmount)
+ ":"
+ str(unitbase)
+ ":SIG("
+ outputAddress
+ ")"
)
unitbase = unitbase - 1
generate_output(listoutput, curentUnitBase, AmountTransfered, outputAddresses)
# Outputs to himself
unitbase = curentUnitBase
rest = totalAmountInput - totalAmountTransfered
while rest > 0:
outputAmount = truncBase(rest, unitbase)
rest -= outputAmount
if outputAmount > 0:
outputAmount = int(outputAmount / math.pow(10, unitbase))
listoutput.append(
str(outputAmount)
+ ":"
+ str(unitbase)
+ ":SIG("
+ OutputbackChange
+ ")"
)
unitbase = unitbase - 1
generate_output(listoutput, curentUnitBase, rest, OutputbackChange)
# Generate transaction document
##############################
......@@ -311,6 +282,23 @@ def generate_transaction_document(
return transaction_document
def generate_output(listoutput, unitbase, rest, recipient_address):
while rest > 0:
outputAmount = truncBase(rest, unitbase)
rest -= outputAmount
if outputAmount > 0:
outputAmount = int(outputAmount / math.pow(10, unitbase))
listoutput.append(
str(outputAmount)
+ ":"
+ str(unitbase)
+ ":SIG("
+ recipient_address
+ ")"
)
unitbase = unitbase - 1
def get_list_input_for_transaction(pubkey, TXamount, allinput=False):
listinput, amount = get_sources(pubkey)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment