From 4c0d37561504423775d2b8385d3647ab4657e446 Mon Sep 17 00:00:00 2001
From: matograine <tom.ngr@zaclys.net>
Date: Thu, 24 Sep 2020 18:50:46 +0200
Subject: [PATCH] [enh] #301 display the checksum in the tx command    * for
 each pubkey in the tx confirmation    * when sending the transaction

   * modify the function display_pubkey() and related tests
---
 silkaj/tui.py     |  2 +-
 silkaj/tx.py      | 14 ++++++++++----
 tests/test_tui.py |  4 ++--
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/silkaj/tui.py b/silkaj/tui.py
index 955a2232..a76d0940 100644
--- a/silkaj/tui.py
+++ b/silkaj/tui.py
@@ -43,7 +43,7 @@ async def display_pubkey(tx, message, pubkey):
     """
     Displays a pubkey and the eventually associated id.
     """
-    tx.append([message + " (pubkey)", pubkey])
+    tx.append([message + " (pubkey:checksum)", display_pubkey_and_checksum(pubkey)])
     id = await wot.is_member(pubkey)
     if id:
         tx.append([message + " (id)", id["uid"]])
diff --git a/silkaj/tx.py b/silkaj/tx.py
index b482cd27..03779a60 100644
--- a/silkaj/tx.py
+++ b/silkaj/tx.py
@@ -34,7 +34,7 @@ from silkaj.constants import (
     CENT_MULT_TO_UNIT,
     ASYNC_SLEEP,
 )
-from silkaj.tui import display_amount, display_pubkey
+from silkaj.tui import display_amount, display_pubkey, display_pubkey_and_checksum
 
 from duniterpy.api.bma.tx import process
 from duniterpy.documents import BlockUID, Transaction
@@ -211,7 +211,8 @@ def check_transaction_values(
             outputBackChange = validate_checksum(outputBackChange)
     if enough_source:
         message_exit(
-            issuer_pubkey + " pubkey doesn’t have enough money for this transaction."
+            display_pubkey_and_checksum(issuer_pubkey)
+            + " pubkey doesn’t have enough money for this transaction."
         )
     return outputBackChange
 
@@ -348,7 +349,7 @@ async def generate_and_send_transaction(
         print("Generate Change Transaction")
     else:
         print("Generate Transaction:")
-    print("   - From:    " + issuers)
+    print("   - From:    " + display_pubkey_and_checksum(issuers))
     for tx_amount, outputAddress in zip(tx_amounts, outputAddresses):
         display_sent_tx(outputAddress, tx_amount)
     print("   - Total:   " + str(sum(tx_amounts) / 100))
@@ -373,7 +374,12 @@ async def generate_and_send_transaction(
 
 
 def display_sent_tx(outputAddress, amount):
-    print("   - To:     ", outputAddress, "\n   - Amount: ", amount / 100)
+    print(
+        "   - To:     ",
+        display_pubkey_and_checksum(outputAddress),
+        "\n   - Amount: ",
+        amount / 100,
+    )
 
 
 async def generate_transaction_document(
diff --git a/tests/test_tui.py b/tests/test_tui.py
index b66b8255..dfabcc28 100644
--- a/tests/test_tui.py
+++ b/tests/test_tui.py
@@ -25,7 +25,7 @@ import patched
 @pytest.mark.parametrize(
     "message, amount, currency_symbol", [("Total", 1000, G1_SYMBOL)]
 )
-def test_display_amount(message, amount, currency_symbol, monkeypatch):
+def test_display_amount(message, amount, currency_symbol):
     ud_value = patched.mock_ud_value
     amount_UD = round(amount / ud_value, 2)
     expected = [
@@ -57,7 +57,7 @@ def test_display_amount(message, amount, currency_symbol, monkeypatch):
 async def test_display_pubkey(message, pubkey, id, monkeypatch):
     monkeypatch.setattr("silkaj.wot.is_member", patched.is_member)
 
-    expected = [[message + " (pubkey)", pubkey]]
+    expected = [[message + " (pubkey:checksum)", display_pubkey_and_checksum(pubkey)]]
     if id:
         expected.append([message + " (id)", id])
     tx = list()
-- 
GitLab