Skip to content
Snippets Groups Projects
Unverified Commit cb5d78cb authored by Moul's avatar Moul Committed by GitHub
Browse files

Merge pull request #38 from duniter/floppy_fix_examples

start to fix example (not ended -> first test)
parents 066112ef 5bbdf91b
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ def _ensure_bytes(data): ...@@ -26,7 +26,7 @@ def _ensure_bytes(data):
class SigningKey(libnacl.sign.Signer): class SigningKey(libnacl.sign.Signer):
def __init__(self, salt, password, scrypt_params): def __init__(self, salt, password, scrypt_params=ScryptParams(4096,16,1)):
salt = _ensure_bytes(salt) salt = _ensure_bytes(salt)
password = _ensure_bytes(password) password = _ensure_bytes(password)
seed = scrypt(password, salt, seed = scrypt(password, salt,
......
...@@ -12,7 +12,7 @@ from duniterpy.key import SigningKey ...@@ -12,7 +12,7 @@ from duniterpy.key import SigningKey
# You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT] # You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT]
# or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT] # or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT]
# Here we use the BASIC_MERKLED_API # Here we use the BASIC_MERKLED_API
BMA_ENDPOINT = "BASIC_MERKLED_API cgeek.fr 9330" BMA_ENDPOINT = "BASIC_MERKLED_API g1.duniter.org 10901"
# Your unique identifier in the Web of Trust # Your unique identifier in the Web of Trust
UID = "MyIdentity" UID = "MyIdentity"
...@@ -43,7 +43,7 @@ def get_identity_document(current_block, uid, salt, password): ...@@ -43,7 +43,7 @@ def get_identity_document(current_block, uid, salt, password):
# create identity document # create identity document
identity = Identity( identity = Identity(
version=2, version=10,
currency=current_block['currency'], currency=current_block['currency'],
pubkey=key.pubkey, pubkey=key.pubkey,
uid=uid, uid=uid,
...@@ -56,13 +56,14 @@ def get_identity_document(current_block, uid, salt, password): ...@@ -56,13 +56,14 @@ def get_identity_document(current_block, uid, salt, password):
return identity return identity
async def main(): async def main():
""" """
Main code Main code
""" """
# connection handler from BMA endpoint # connection handler from BMA endpoint
connection = BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) connection = next(BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION))
# capture current block to get version and currency and blockstamp # capture current block to get version and currency and blockstamp
current_block = await bma.blockchain.current(connection) current_block = await bma.blockchain.current(connection)
......
...@@ -8,7 +8,7 @@ from duniterpy.documents import BMAEndpoint ...@@ -8,7 +8,7 @@ from duniterpy.documents import BMAEndpoint
# You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT] # You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT]
# or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT] # or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT]
# Here we use the BASIC_MERKLED_API # Here we use the BASIC_MERKLED_API
BMA_ENDPOINT = "BASIC_MERKLED_API cgeek.fr 9330" BMA_ENDPOINT = "BASIC_MERKLED_API g1.duniter.org 10901"
################################################ ################################################
...@@ -21,7 +21,7 @@ async def main(): ...@@ -21,7 +21,7 @@ async def main():
Main code Main code
""" """
# connection handler from BMA endpoint # connection handler from BMA endpoint
connection = BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) connection = next(BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION))
# Get the node summary infos # Get the node summary infos
response = await bma.node.summary(connection) response = await bma.node.summary(connection)
......
...@@ -21,7 +21,7 @@ else: ...@@ -21,7 +21,7 @@ else:
# You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT] # You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT]
# or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT] # or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT]
# Here we use the BASIC_MERKLED_API # Here we use the BASIC_MERKLED_API
BMA_ENDPOINT = "BASIC_MERKLED_API cgeek.fr 9330" BMA_ENDPOINT = "BASIC_MERKLED_API g1.duniter.org 10901"
# WARNING : Hide this file in a safe and secure place # WARNING : Hide this file in a safe and secure place
# If one day you forget your credentials, # If one day you forget your credentials,
...@@ -31,8 +31,8 @@ REVOKE_DOCUMENT_FILE_PATH = os.path.join(home_path, "duniter_account_revoke_docu ...@@ -31,8 +31,8 @@ REVOKE_DOCUMENT_FILE_PATH = os.path.join(home_path, "duniter_account_revoke_docu
################################################ ################################################
AIOHTTP_SESSION = aiohttp.ClientSession() AIOHTTP_SESSION = aiohttp.ClientSession()
# Current protocole version # Current protocol version
PROTOCOL_VERSION = 2 PROTOCOL_VERSION = 10
async def get_identity_document(connection, currency, pubkey): async def get_identity_document(connection, currency, pubkey):
""" """
...@@ -112,7 +112,7 @@ async def main(): ...@@ -112,7 +112,7 @@ async def main():
exit(0) exit(0)
# connection handler from BMA endpoint # connection handler from BMA endpoint
connection = BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) connection = next(BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION))
# capture current block to get currency name # capture current block to get currency name
current_block = await bma.blockchain.current(connection) current_block = await bma.blockchain.current(connection)
......
...@@ -11,7 +11,7 @@ from duniterpy.key import SigningKey ...@@ -11,7 +11,7 @@ from duniterpy.key import SigningKey
# You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT] # You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT]
# or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT] # or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT]
# Here we use the BASIC_MERKLED_API # Here we use the BASIC_MERKLED_API
BMA_ENDPOINT = "BASIC_MERKLED_API cgeek.fr 9330" BMA_ENDPOINT = "BASIC_MERKLED_API g1.duniter.org 10901"
################################################ ################################################
...@@ -49,7 +49,7 @@ async def get_identity_document(connection, current_block, pubkey): ...@@ -49,7 +49,7 @@ async def get_identity_document(connection, current_block, pubkey):
# return self-certification document # return self-certification document
return Identity( return Identity(
version=2, version=10,
currency=current_block['currency'], currency=current_block['currency'],
pubkey=pubkey, pubkey=pubkey,
uid=uid, uid=uid,
...@@ -72,7 +72,7 @@ def get_certification_document(current_block, self_cert_document, from_pubkey, s ...@@ -72,7 +72,7 @@ def get_certification_document(current_block, self_cert_document, from_pubkey, s
""" """
# construct Certification Document # construct Certification Document
certification = Certification( certification = Certification(
version=2, version=10,
currency=current_block['currency'], currency=current_block['currency'],
pubkey_from=from_pubkey, pubkey_from=from_pubkey,
pubkey_to=self_cert_document.pubkey, pubkey_to=self_cert_document.pubkey,
...@@ -90,7 +90,7 @@ async def main(): ...@@ -90,7 +90,7 @@ async def main():
Main code Main code
""" """
# connection handler from BMA endpoint # connection handler from BMA endpoint
connection = BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) connection = next(BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION))
# prompt hidden user entry # prompt hidden user entry
salt = getpass.getpass("Enter your passphrase (salt): ") salt = getpass.getpass("Enter your passphrase (salt): ")
......
...@@ -12,7 +12,7 @@ from duniterpy.key import SigningKey ...@@ -12,7 +12,7 @@ from duniterpy.key import SigningKey
# You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT] # You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT]
# or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT] # or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT]
# Here we use the BASIC_MERKLED_API # Here we use the BASIC_MERKLED_API
BMA_ENDPOINT = "BASIC_MERKLED_API cgeek.fr 9330" BMA_ENDPOINT = "BASIC_MERKLED_API g1.duniter.org 10901"
################################################ ################################################
...@@ -96,7 +96,7 @@ async def main(): ...@@ -96,7 +96,7 @@ async def main():
Main code Main code
""" """
# connection handler from BMA endpoint # connection handler from BMA endpoint
connection = BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) connection = next(BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION))
# capture current block to get version and currency and blockstamp # capture current block to get version and currency and blockstamp
current_block = await bma.blockchain.current(connection) current_block = await bma.blockchain.current(connection)
......
...@@ -13,7 +13,7 @@ from duniterpy.key import SigningKey ...@@ -13,7 +13,7 @@ from duniterpy.key import SigningKey
# You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT] # You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT]
# or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT] # or the simple definition : [NAME_OF_THE_API] [DOMAIN] [PORT]
# Here we use the BASIC_MERKLED_API # Here we use the BASIC_MERKLED_API
BMA_ENDPOINT = "BASIC_MERKLED_API cgeek.fr 9330" BMA_ENDPOINT = "BASIC_MERKLED_API g1.duniter.org 10901"
################################################ ################################################
...@@ -94,7 +94,7 @@ async def main(): ...@@ -94,7 +94,7 @@ async def main():
Main code Main code
""" """
# connection handler from BMA endpoint # connection handler from BMA endpoint
connection = BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION) connection = next(BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION))
# prompt hidden user entry # prompt hidden user entry
salt = getpass.getpass("Enter your passphrase (salt): ") salt = getpass.getpass("Enter your passphrase (salt): ")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment