Exemple #1
0
                try :  # if possible
                    privkey = PrivateKey(config.memo_wif_key)
                    pubkey  = PublicKey(memo["from"], prefix=prefix)
                    memomsg = Memo.decode_memo(privkey, pubkey, memo["nonce"], memo["message"])
                except Exception as e:  # if not possible
                    memomsg = "--cannot decode-- %s" % str(e)
            # Print out
            print("last_op: %s | block:%s | from %s -> to: %s | fee: %f %s | amount: %f %s | memo: %s" % (
                  opID, block,
                  from_account["name"], to_account["name"],
                  fee_amount, fee_asset["symbol"],
                  amount_amount, amount_asset["symbol"],
                  memomsg))

if __name__ == '__main__':
    # Monitor definitions
    protocol = GrapheneMonitor
    protocol.last_op = config.last_op  # last operation logged
    protocol.account_id = "1.2.%s" % config.accountID.split(".")[2]  # account to monitor

    # Open Up Graphene Websocket API
    api      = GrapheneWebsocket(config.url, config.user, config.password, protocol)

    # Set Callback for object changes
    api.setObjectCallbacks({config.accountID : protocol.onAccountUpdate})
    api.setEventCallbacks({"registered-history" : protocol.onAccountUpdate})

    # Run the Websocket connection continuously
    api.connect()
    api.run_forever()