diff --git a/silkaj/commands.py b/silkaj/commands.py index 67e6a82d32dc8ed2f667e4168052b2e4e669bbab..8b6718f73c11b374105ffad3d01cc6789561ad55 100644 --- a/silkaj/commands.py +++ b/silkaj/commands.py @@ -19,7 +19,7 @@ def currency_info(ep): system("clear") print("Connected to node:", ep[best_node(ep, False)], ep["port"], "\nCurrent block number:", head_block["number"], - "\nCurrency name:", get_currency_symbol(head_block["currency"]), + "\nCurrency name:", currency_symbol, "\nNumber of members:", head_block["membersCount"], "\nMinimal Proof-of-Work:", head_block["powMin"], "\nCurrent time:", convert_time(head_block["time"], "all"), @@ -231,7 +231,7 @@ def argos_info(ep): href = 'href=http://%s:%s/' % (ep[best_node(ep, False)], ep["port"]) print("Connected to node:", ep[best_node(ep, False)], ep["port"], "|", href, "\nCurrent block number:", head_block["number"], - "\nCurrency name:", get_currency_symbol(head_block["currency"]), + "\nCurrency name:", currency_symbol, "\nNumber of members:", head_block["membersCount"], "\nMinimal Proof-of-Work:", head_block["powMin"], "\nCurrent time:", convert_time(head_block["time"], "all"), diff --git a/silkaj/money.py b/silkaj/money.py index 4decd91c329c0479fe8ff2e9258af43a148ff7b3..2e999738e55b8447f4a41f2c683e31bc6cc686a7 100644 --- a/silkaj/money.py +++ b/silkaj/money.py @@ -18,35 +18,32 @@ def cmd_amount(ep, cli_args): total[0] += value[0] total[1] += value[1] if (len(pubkeys) > 1): - show_amount_from_pubkey(ep, "Total", total) + show_amount_from_pubkey("Total", total, ud_value, currency_symbol) else: seed = auth_method(cli_args) pubkey = get_publickey_from_seed(seed) show_amount_from_pubkey(ep, pubkey, get_amount_from_pubkey(ep, pubkey)) -def show_amount_from_pubkey(ep, pubkey, value): +def show_amount_from_pubkey(pubkey, value, ud_value, currency_symbol): totalAmountInput = value[0] amount = value[1] # output - UDvalue = get_last_ud_value(ep) - current_blk = get_current_block(ep) - currency_symbol = get_currency_symbol(current_blk["currency"]) if totalAmountInput - amount != 0: print("Blockchain:") print("-----------") - print("Relative =", round(amount / UDvalue, 2), "UD", currency_symbol) + print("Relative =", round(amount / ud_value, 2), "UD", currency_symbol) print("Quantitative =", round(amount / 100, 2), currency_symbol + "\n") print("Pending Transaction:") print("--------------------") - print("Relative =", round((totalAmountInput - amount) / UDvalue, 2), "UD", currency_symbol) + print("Relative =", round((totalAmountInput - amount) / ud_value, 2), "UD", currency_symbol) print("Quantitative =", round((totalAmountInput - amount) / 100, 2), currency_symbol + "\n") print("Total amount of: " + pubkey) print("----------------------------------------------------------------") - print("Total Relative =", round(totalAmountInput / UDvalue, 2), "UD", currency_symbol) + print("Total Relative =", round(totalAmountInput / ud_value, 2), "UD", currency_symbol) print("Total Quantitative =", round(totalAmountInput / 100, 2), currency_symbol + "\n") diff --git a/silkaj/silkaj.py b/silkaj/silkaj.py index 271148291b25f3c7ba72406c9dff2d9a9d308b10..a8144d9e485bee95150626df6181fd9568c3d180 100644 --- a/silkaj/silkaj.py +++ b/silkaj/silkaj.py @@ -3,7 +3,7 @@ from sys import stderr from commandlines import Command from silkaj.tx import send_transaction -from silkaj.money import cmd_amount +from silkaj.money import cmd_amount, get_last_ud_value from silkaj.cert import send_certification from silkaj.commands import currency_info, difficulties, set_network_sort_keys,\ network_info, argos_info, list_issuers diff --git a/silkaj/tx.py b/silkaj/tx.py index d4ccce632a2e20eb2f1e5c6b09ccf22f2cf1f6e5..f5dbac93463a084e4f29127afc830fdac533dd60 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -9,7 +9,7 @@ from silkaj.tools import get_publickey_from_seed, sign_document_from_seed,\ check_public_key, message_exit from silkaj.auth import auth_method from silkaj.wot import get_uid_from_pubkey -from silkaj.money import get_last_ud_value, get_amount_from_pubkey +from silkaj.money import get_amount_from_pubkey from silkaj.constants import NO_MATCHING_ID @@ -17,8 +17,7 @@ def send_transaction(ep, cli_args): """ Main function """ - ud = get_last_ud_value(ep) - amount, output, comment, allSources, outputBackChange = cmd_transaction(cli_args, ud) + amount, output, comment, allSources, outputBackChange = cmd_transaction(cli_args, ud_value) seed = auth_method(cli_args) issuer_pubkey = get_publickey_from_seed(seed) @@ -27,7 +26,7 @@ def send_transaction(ep, cli_args): check_transaction_values(comment, outputAddresses, outputBackChange, pubkey_amount < amount * len(outputAddresses), issuer_pubkey) if cli_args.contains_switches('yes') or cli_args.contains_switches('y') or \ - input(tabulate(transaction_confirmation(ep, issuer_pubkey, amount, ud, outputAddresses, comment), + input(tabulate(transaction_confirmation(ep, issuer_pubkey, amount, ud_value, currency_symbol, outputAddresses, comment), tablefmt="fancy_grid") + "\nDo you confirm sending this transaction? [yes/no]: ") == "yes": generate_and_send_transaction(ep, seed, issuer_pubkey, amount, outputAddresses, comment, allSources, outputBackChange) @@ -70,13 +69,12 @@ def check_transaction_values(comment, outputAddresses, outputBackChange, enough_ message_exit(issuer_pubkey + " pubkey doesn’t have enough money for this transaction.") -def transaction_confirmation(ep, issuer_pubkey, amount, ud, outputAddresses, comment): +def transaction_confirmation(ep, issuer_pubkey, amount, ud, currency_symbol, outputAddresses, comment): """ Generate transaction confirmation """ tx = list() - currency_symbol = get_currency_symbol(get_current_block(ep)["currency"]) tx.append(["amount (" + currency_symbol + ")", amount / 100 * len(outputAddresses)]) tx.append(["amount (UD " + currency_symbol + ")", round(amount / ud, 4)]) tx.append(["from", issuer_pubkey])