Skip to content
Snippets Groups Projects
Commit cb6c366b authored by Moul's avatar Moul
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 3e3f66cc
No related branches found
No related tags found
2 merge requests!110Merge dev into master for v0.58.0 release,!104Rework send membership and identity documents examples
Pipeline #9671 waiting for manual action
......@@ -18,15 +18,16 @@ BMAS_ENDPOINT = "BMAS g1-test.duniter.org 443"
def get_identity_document(
current_block: dict, uid: str, salt: str, password: str
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 +35,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 +74,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 register or to comment