From 664c4430578342f372774bf2a5f5bf03195e78c0 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Tue, 2 Jun 2020 22:30:34 +0200 Subject: [PATCH] [fix] #323: Handle recipients pubkey with a checksum Passed pubkeys with a checksum wasn't returned without the checksum recipient/outputAddresses: Click stores the arguments in a tuple which is immutable. Convert it to a list in order to be able to change it. Though it is not necessary to return the value since it's a list. outputAddresses: use enumerate in order to assign the pubkeys without the checksum ouputBackChange: remove duplicate call to check_public_key() store pubkey in case it get erased by a boolean Return the value as a string is not a pointer and does not get modified in the parent scope as a list or a dict. Add comments in check_transaction_values() This feature was broken and forgotten since v0.5.0 release --- silkaj/tx.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/silkaj/tx.py b/silkaj/tx.py index c0e6e742..30636665 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -111,7 +111,8 @@ async def send_transaction( if allsources: tx_amounts = [pubkey_amount[0]] - check_transaction_values( + recipients = list(recipients) + outputbackchange = check_transaction_values( comment, recipients, outputbackchange, @@ -189,18 +190,27 @@ def compute_amounts(amounts, multiplicator): def check_transaction_values( comment, outputAddresses, outputBackChange, enough_source, issuer_pubkey ): + """ + Check the comment format + Check the pubkeys and the checksums of the recipients and the outputbackchange + In case of a valid checksum, assign and return the pubkey without the checksum + Check the balance is big enough for the transaction + """ checkComment(comment) - for outputAddress in outputAddresses: - if check_public_key(outputAddress, True) is False: + for i, outputAddress in enumerate(outputAddresses): + outputAddresses[i] = check_public_key(outputAddress, True) + if not outputAddresses[i]: message_exit(outputAddress) if outputBackChange: + pubkey = outputBackChange outputBackChange = check_public_key(outputBackChange, True) - if check_public_key(outputBackChange, True) is False: - message_exit(outputBackChange) + if not outputBackChange: + message_exit(pubkey) if enough_source: message_exit( issuer_pubkey + " pubkey doesn’t have enough money for this transaction." ) + return outputBackChange async def transaction_confirmation( -- GitLab