Skip to content
Snippets Groups Projects
Commit b04e2def authored by Moul's avatar Moul Committed by Vincent Texier
Browse files

[enh] Improve send_identity.py example

Pass the key to get_identity_document()
Rename the file to 'send_identity' for consistency with the other files
parent e0b82901
No related branches found
No related tags found
No related merge requests found
Pipeline #9314 passed
......@@ -17,16 +17,13 @@ BMAS_ENDPOINT = "BMAS g1-test.duniter.org 443"
################################################
def get_identity_document(
current_block: dict, uid: str, salt: str, password: str
) -> Identity:
def get_identity_document(current_block: dict, uid: str, key: SigningKey,) -> Identity:
"""
Get an Identity document
:param current_block: Current block data
:param uid: Unique IDentifier
:param salt: Passphrase of the account
:param password: Password of the account
:param key: cryptographic key to sign documents
:rtype: Identity
"""
......@@ -34,9 +31,6 @@ def get_identity_document(
# get current block BlockStamp
timestamp = BlockUID(current_block["number"], current_block["hash"])
# create keys from credentials
key = SigningKey.from_credentials(salt, password)
# create identity document
identity = Identity(
version=10,
......@@ -76,10 +70,13 @@ async def main():
# prompt hidden user entry
password = getpass.getpass("Enter your password: ")
# create keys from credentials
key = SigningKey.from_credentials(salt, password)
# create our signed identity document
identity = get_identity_document(current_block, uid, salt, password)
identity = get_identity_document(current_block, uid, key)
# send the identity document to the node
# send the identity signed raw document to the node
response = await client(bma.wot.add, identity.signed_raw())
if response.status == 200:
print(await response.text())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment