Skip to content
Snippets Groups Projects
Commit ad5e8b06 authored by matograine's avatar matograine
Browse files

issue #236 : modify confirmation display

* add display_pubkey() and display_amount() functions to match the proposal
* modify transaction_confirmation()
parent f335a2bd
No related branches found
No related tags found
No related merge requests found
...@@ -146,6 +146,35 @@ def check_transaction_values( ...@@ -146,6 +146,35 @@ def check_transaction_values(
) )
async def display_amount(tx, message, amount, currency_symbol):
"""
For transaction_confirmation,
Displays an amount in unit and relative reference.
"""
amount_UD = round((amount / await UDValue().ud_value), 4)
tx.append(
[
message + " (unit|relative)",
"{unit_amount} {currency_symbol} | {UD_amount} UD {currency_symbol}".format(
unit_amount=str(amount / 100),
currency_symbol=currency_symbol,
UD_amount=str(amount_UD),
),
]
)
async def display_pubkey(tx, message, pubkey):
"""
For transaction_confirmation,
Displays a pubkey and the eventually associated id.
"""
tx.append([message + " (pubkey)", pubkey])
id = await is_member(pubkey)
if id:
tx.append([message + " (id)", id["uid"]])
async def transaction_confirmation( async def transaction_confirmation(
issuer_pubkey, pubkey_amount, tx_amount, outputAddresses, outputBackChange, comment issuer_pubkey, pubkey_amount, tx_amount, outputAddresses, outputBackChange, comment
): ):
...@@ -158,20 +187,11 @@ async def transaction_confirmation( ...@@ -158,20 +187,11 @@ async def transaction_confirmation(
tx.append( tx.append(
["pubkey’s balance before tx", str(pubkey_amount / 100) + " " + currency_symbol] ["pubkey’s balance before tx", str(pubkey_amount / 100) + " " + currency_symbol]
) )
tx.append(
[ await display_amount(
"tx amount (unit)", tx, "total amount", float(tx_amount * len(outputAddresses)), currency_symbol
str(tx_amount / 100 * len(outputAddresses)) + " " + currency_symbol,
]
)
tx.append(
[
"tx amount (relative)",
str(round(tx_amount / await UDValue().ud_value, 4))
+ " UD "
+ currency_symbol,
]
) )
tx.append( tx.append(
[ [
"pubkey’s balance after tx", "pubkey’s balance after tx",
...@@ -180,20 +200,14 @@ async def transaction_confirmation( ...@@ -180,20 +200,14 @@ async def transaction_confirmation(
+ currency_symbol, + currency_symbol,
] ]
) )
tx.append(["from (pubkey)", issuer_pubkey])
id_from = await is_member(issuer_pubkey) await display_pubkey(tx, "from", issuer_pubkey)
if id_from:
tx.append(["from (id)", id_from["uid"]])
for outputAddress in outputAddresses: for outputAddress in outputAddresses:
tx.append(["to (pubkey)", outputAddress]) await display_pubkey(tx, "to", outputAddress)
id_to = await is_member(outputAddress) await display_amount(tx, "amount", tx_amount, currency_symbol)
if id_to:
tx.append(["to (id)", id_to["uid"]])
if outputBackChange: if outputBackChange:
tx.append(["Backchange (pubkey)", outputBackChange]) await display_pubkey(tx, "Backchange", outputBackChange)
id_backchange = await is_member(outputBackChange)
if id_backchange:
tx.append(["Backchange (id)", id_backchange["uid"]])
tx.append(["comment", comment]) tx.append(["comment", comment])
return tx return tx
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment