diff --git a/silkaj/auth.py b/silkaj/auth.py index 91ca04f3828234cb58429eda12d527e55df822f8..2a4279acebdb7cf58a76ca3565a305287a4f2ff6 100644 --- a/silkaj/auth.py +++ b/silkaj/auth.py @@ -46,6 +46,16 @@ def auth_method(ctx): return auth_by_scrypt() +@pass_context +def has_auth_method(ctx): + return ( + ctx.obj["AUTH_SCRYPT"] + or ctx.obj["AUTH_FILE"] + or ctx.obj["AUTH_SEED"] + or ctx.obj["AUTH_WIF"] + ) + + @command("authfile", help="Generate authentication file") @option("--file", default="authfile", show_default=True, help="Path file") def generate_auth_file(file): diff --git a/silkaj/money.py b/silkaj/money.py index 7e124925e17a55cc79a869e33880d8e517aa6c4a..6d9930b334d5f77955943492b9a0a9299d719b52 100644 --- a/silkaj/money.py +++ b/silkaj/money.py @@ -21,7 +21,7 @@ from tabulate import tabulate from silkaj.network_tools import ClientInstance from silkaj.blockchain_tools import HeadBlock from silkaj.tools import CurrencySymbol, message_exit, coroutine -from silkaj.auth import auth_method +from silkaj.auth import auth_method, has_auth_method # had to import wot to prevent loop dependency. No use here. from silkaj import wot @@ -38,12 +38,7 @@ from duniterpy.documents.transaction import InputSource @coroutine async def cmd_amount(ctx, pubkeys): client = ClientInstance().client - if not ( - ctx.obj["AUTH_SCRYPT"] - or ctx.obj["AUTH_FILE"] - or ctx.obj["AUTH_SEED"] - or ctx.obj["AUTH_WIF"] - ): + if not has_auth_method(): if not pubkeys: message_exit("You should specify one or many pubkeys") pubkey_list = list()