Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
add cli command: account sign-data
Browse files Browse the repository at this point in the history
Allow the signature of arbitrary data

references: #261
  • Loading branch information
noandrea authored and shekhar-shubhendu committed Nov 28, 2019
1 parent d4f3a34 commit c98385f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion aeternity/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

from aeternity.node import NodeClient, Config
from aeternity.transactions import TxSigner, TxBuilder, TxObject
from aeternity.identifiers import NETWORK_ID_MAINNET, PROTOCOL_LIMA # TODO: remove after HF
from aeternity.identifiers import NETWORK_ID_MAINNET, PROTOCOL_LIMA, SIGNATURE # TODO: remove after HF
from aeternity.hashing import encode
from . import utils, signing, aens, defaults, exceptions
from aeternity.compiler import CompilerClient
from aeternity.openapi import OpenAPIClientException
Expand Down Expand Up @@ -415,6 +416,26 @@ def account_sign(keystore_name, password, network_id, unsigned_transaction, json
except Exception as e:
_print_error(e, exit_code=1)


@account.command('sign-data', help="Sign arbitrary data")
@click.argument('keystore_name', required=True)
@click.argument('data', required=True)
@global_options
@account_options
def account_sign_data(keystore_name, password, data, json_):
try:
set_global_options(json_)
account, _ = _account(keystore_name, password=password)
# force offline mode for the node_client
signature = encode(SIGNATURE, account.sign(data.encode('utf-8')))
# _print_object(txu, title='unsigned transaction')
_print_object({
"account": account.get_address(),
"signature": signature
}, title="data signature")
except Exception as e:
_print_error(e, exit_code=1)

# _________ ____ ____
# | _ _ ||_ _||_ _|
# |_/ | | \_| \ \ / /
Expand Down

0 comments on commit c98385f

Please sign in to comment.