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

[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
parent 415d829b
No related branches found
No related tags found
2 merge requests!146Merge dev into master branch to complete v0.8.0 development cycle,!143#301: Generalize pubkey checksum display and check
......@@ -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"]])
......
......@@ -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(
......
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment