async def main(): """ Main code """ # connection handler from BMA endpoint connection = BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler() # capture current block to get version and currency and blockstamp current_block = await get_current_block(connection) # create our SelfCertification document to sign the Certification document identity = await get_identity_document(connection, current_block, TO_PUBKEY) # load credentials from a text file salt, password = open(FROM_CREDENTIALS_FILE).readlines() # cleanup newlines salt, password = salt.strip(), password.strip() # send the Certification document to the node certification = get_certification_document(current_block, identity, FROM_PUBKEY, salt, password) # Here we request for the path wot/certify data = {'cert': certification.signed_raw(identity)} response = await bma.wot.Certify(connection).post(AIOHTTP_SESSION, **data) print(response) response.close()
async def main(): """ Main code """ # connection handler from BMA endpoint connection = BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler() # capture current block to get version and currency and blockstamp current_block = await get_current_block(connection) # load credentials from a text file salt, password = open(FROM_CREDENTIALS_FILE).readlines() # cleanup newlines salt, password = salt.strip(), password.strip() # create our signed identity document identity = get_identity_document(current_block, UID, salt, password) # send the identity document to the node data = {identity: identity.signed_raw()} response = await bma.wot.Add(connection).post(AIOHTTP_SESSION, **data) print(response) response.close()
async def main(): """ Main code """ # connection handler from BMA endpoint connection = BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler() # capture current block to get currency name current_block = await get_current_block(connection) # create our SelfCertification document to sign the revoke document identity_document = await get_identity_document(connection, current_block['currency'], PUBKEY) # load credentials from a text file salt, password = open(CREDENTIALS_FILE_PATH).readlines() # cleanup newlines salt, password = salt.strip(), password.strip() # get the revoke document revoke_document = await get_revoke_document(identity_document, salt, password) # save revoke document in a file fp = open(REVOKE_DOCUMENT_FILE_PATH, 'w') fp.write(revoke_document) fp.close() # document saved print("Revoke document saved in %s" % REVOKE_DOCUMENT_FILE_PATH)
async def main(): """ Main code """ # connection handler from BMA endpoint connection = next( BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) # capture current block to get version and currency and blockstamp current_block = await bma.blockchain.current(connection) # prompt hidden user entry salt = getpass.getpass("Enter your passphrase (salt): ") # prompt hidden user entry password = getpass.getpass("Enter your password: "******"Error while publishing identity : {0}".format(await response.text())) response.close()
async def main(): """ Main code """ # connection handler from BMA endpoint connection = next( BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) # prompt hidden user entry salt = getpass.getpass("Enter your passphrase (salt): ") # prompt hidden user entry password = getpass.getpass("Enter your password: "******"Enter your pubkey: ") # prompt entry pubkey_to = input("Enter recipient pubkey: ") # capture current block to get version and currency and blockstamp current_block = await bma.blockchain.current(connection) # capture sources of account response = await bma.tx.sources(connection, pubkey_from) if len(response['sources']) == 0: print("no sources found for account %s" % pubkey_to) exit(1) # get the first source source = response['sources'][0] # create the transaction document transaction = get_transaction_document(current_block, source, pubkey_from, pubkey_to) # create keys from credentials key = SigningKey(salt, password, ScryptParams(4096, 16, 1)) # sign document transaction.sign([key]) # send the Transaction document to the node response = await bma.tx.process(connection, transaction.signed_raw()) if response.status == 200: print(await response.text()) else: print("Error while publishing transaction: {0}".format( await response.text())) response.close()
async def main(): """ Main code """ ######################################################################################### # connection handler from BMA endpoint connection = next( BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) # capture current block to get version and currency and blockstamp current_block = await bma.blockchain.current(connection) # prompt hidden user entry #salt = getpass.getpass("Enter your passphrase (salt): ") salt = sys.argv[1] # prompt hidden user entry #password = getpass.getpass("Enter your password: "******"Enter your UID: ") UID = sys.argv[3] ######################################################################################### # create our signed identity document identity = get_identity_document(current_block, UID, salt, password) # FIRST Send the identity document to the node responseid = await bma.wot.add(connection, identity.signed_raw()) if responseid.status == 200: print(await responseid.text()) else: print("Error while publishing identity : {0}".format( await responseid.text())) responseid.close() ######################################################################################### # create a membership demand document membership = get_membership_document("IN", current_block, identity, salt, password) # SECOND Send the membership document to the node response = await bma.blockchain.membership(connection, membership.signed_raw()) if response.status == 200: print(await response.text()) else: print("Error while publishing membership : {0}".format( await response.text())) response.close()
async def main(): """ Main code """ # connection handler from BMA endpoint connection = BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler() # Get the node summary infos response = await bma.node.Summary(connection).get(AIOHTTP_SESSION) print(response) # Get the current block data response = await bma.blockchain.Current(connection).get(AIOHTTP_SESSION) print(response) # Get the block number 0 response = await bma.blockchain.Block(connection, 0).get(AIOHTTP_SESSION) print(response)
async def main(): """ Main code """ # prompt hidden user entry salt = getpass.getpass("Enter your passphrase (salt): ") # prompt hidden user entry password = getpass.getpass("Enter your password: "******"Enter your public key: ") # init signer instance signer = SigningKey(salt, password, ScryptParams(4096, 16, 1)) # check public key if signer.pubkey != pubkey: print("Bad credentials!") exit(0) # connection handler from BMA endpoint connection = next( BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) # capture current block to get currency name current_block = await bma.blockchain.current(connection) # create our Identity document to sign the revoke document identity_document = await get_identity_document(connection, current_block['currency'], pubkey) # get the revoke document revoke_document = get_revoke_document(identity_document, salt, password) # save revoke document in a file fp = open(REVOKE_DOCUMENT_FILE_PATH, 'w') fp.write(revoke_document) fp.close() # document saved print("Revoke document saved in %s" % REVOKE_DOCUMENT_FILE_PATH)
async def main(): """ Main code """ # connection handler from BMA endpoint connection = next( BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) # prompt hidden user entry salt = getpass.getpass("Enter your passphrase (salt): ") # prompt hidden user entry password = getpass.getpass("Enter your password: "******"Enter your pubkey: ") # prompt entry pubkey_to = input("Enter certified pubkey: ") # capture current block to get version and currency and blockstamp current_block = await bma.blockchain.current(connection) # create our Identity document to sign the Certification document identity = await get_identity_document(connection, current_block, pubkey_to) # send the Certification document to the node certification = get_certification_document(current_block, identity, pubkey_from, salt, password) # Here we request for the path wot/certify response = await bma.wot.certify(connection, certification.signed_raw(identity)) if response.status == 200: print(await response.text()) else: print("Error while publishing certification: {0}".format( await response.text())) response.close()
async def main(): """ Main code """ # connection handler from BMA endpoint connection = next( BMAEndpoint.from_inline(BMA_ENDPOINT).conn_handler(AIOHTTP_SESSION)) # Get the node summary infos response = await bma.node.summary(connection) print(response) # Get the current block data response = await bma.blockchain.parameters(connection) print(response) # Get the current block data response = await bma.blockchain.current(connection) print(response) # Get the block number 10 response = await bma.blockchain.block(connection, 10) print(response)