diff --git a/silkaj/cert.py b/silkaj/cert.py index 17ba70cfc64d8a1d067961a34c4f63684b8e5e80..c581c5937bbb0c9f1845d11e4efcd22e9c2b8495 100644 --- a/silkaj/cert.py +++ b/silkaj/cert.py @@ -35,8 +35,9 @@ from silkaj.crypto_tools import is_pubkey_and_check @click.command("cert", help="Send certification") @click.argument("uid_pubkey_to_certify") +@click.pass_context @coroutine -async def send_certification(uid_pubkey_to_certify): +async def send_certification(ctx, uid_pubkey_to_certify): client = ClientInstance().client checked_pubkey = is_pubkey_and_check(uid_pubkey_to_certify) @@ -84,7 +85,7 @@ async def send_certification(uid_pubkey_to_certify): # Certification confirmation await certification_confirmation( - issuer, issuer_pubkey, pubkey_to_certify, idty_to_certify + ctx, issuer, issuer_pubkey, pubkey_to_certify, idty_to_certify ) identity = Identity( @@ -105,6 +106,10 @@ async def send_certification(uid_pubkey_to_certify): signature="", ) + if ctx.obj["DISPLAY_DOCUMENT"]: + click.echo(certification.signed_raw()) + await confirmation() + # Sign document certification.sign([key]) @@ -120,7 +125,7 @@ async def send_certification(uid_pubkey_to_certify): async def certification_confirmation( - issuer, issuer_pubkey, pubkey_to_certify, idty_to_certify + ctx, issuer, issuer_pubkey, pubkey_to_certify, idty_to_certify ): cert = list() cert.append(["Cert", "Issuer", "–>", "Recipient: Published: #block-hash date"]) @@ -145,6 +150,12 @@ async def certification_confirmation( cert_ends = convert_time(time() + params["sigValidity"], "date") cert.append(["Valid", cert_begins, "—>", cert_ends]) click.echo(tabulate(cert, tablefmt="fancy_grid")) + if not ctx.obj["DISPLAY_DOCUMENT"]: + await confirmation() + + +async def confirmation(): if not click.confirm("Do you confirm sending this certification?"): + client = ClientInstance().client await client.close() sys.exit(SUCCESS_EXIT_STATUS)