Skip to content

Instantly share code, notes, and snippets.

@qwadratic
Created April 28, 2020 16:49
Show Gist options
  • Select an option

  • Save qwadratic/0ecce80848c74e6d10adc9e949515fab to your computer and use it in GitHub Desktop.

Select an option

Save qwadratic/0ecce80848c74e6d10adc9e949515fab to your computer and use it in GitHub Desktop.
(.venv) ✘  ~/Desktop/minter/dicetime   master ●✚  ./manage.py shell_plus
# Shell Plus Model Imports
from django.contrib.admin.models import LogEntry
from django.contrib.auth.models import Group, Permission
from users.models import AllowedChat, ChatMember, ChatWallet, DiceEvent, Exceptions, Language, MinterWallets, Payment, Service, Text, Tools, Triggers, User
from django.contrib.contenttypes.models import ContentType
from django.contrib.sessions.models import Session
# Shell Plus Django Imports
from django.core.cache import cache
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import transaction
from django.db.models import Avg, Case, Count, F, Max, Min, Prefetch, Q, Sum, When, Exists, OuterRef, Subquery
from django.utils import timezone
from django.urls import reverse
Python 3.7.5 (default, Dec 14 2019, 13:37:31)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: token = '1123558278:AAFKgK6yvXOysI69w7tmcW569shaQoO5O5o'
In [2]: from pyrogram import Client
In [3]: app = Client(':memory:', api_id=TG_API_ID, api_hash=TG_API_HASH, bot_token=token)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-20f2e25fe299> in <module>
----> 1 app = Client(':memory:', api_id=TG_API_ID, api_hash=TG_API_HASH, bot_token=token)
NameError: name 'TG_API_ID' is not defined
In [4]: app = Client(':memory:', api_id=settings.TG_API_ID, api_hash=settings.TG_API_HASH, bot_token=token)
In [5]: app.start()
Pyrogram v0.16.0, Copyright (C) 2017-2019 Dan <https://github.com/delivrance>
Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)
Out[5]: <pyrogram.client.client.Client at 0x11085ee50>
In [6]: from users.dice import get_chat_creation_date
In [7]: def get_chat_date(app, chat_id):
...: chat_date = None
...: full = get_fullchat(app, chat_id)
File "<ipython-input-7-ddda27aeb5c0>", line 3
full = get_fullchat(app, chat_id)
^
IndentationError: unexpected indent
In [8]: if len(full.chats) == 1:
...: chat_date = full.chats[0].date
...: else:
...: for chat in full.chats:
...: if not chat.broadcast:
...: chat_date = chat.date
File "<ipython-input-8-73ecc6edf656>", line 3
else:
^
SyntaxError: invalid syntax
In [9]: break
File "<ipython-input-9-6aaf1f276005>", line 4
SyntaxError: 'break' outside loop
...: chat_date = None
...: full = get_fullchat(app, chat_id)
...: if len(full.chats) == 1:
...: chat_date = full.chats[0].date
...: else:
...: for chat in full.chats:
...: if not chat.broadcast:
...: chat_date = chat.date
...: break
...: return chat_date
...:
In [11]: from users.dice import get_fullchat
In [12]: get_chat_date(app, -1001341500725)
Out[12]: 1587733135
In [13]: from datetime import datetime
In [14]: datetime.utcfromtimestamp(1587733135)
Out[14]: datetime.datetime(2020, 4, 24, 12, 58, 55)
In [15]: full = get_fullchat(app, -1001341500725)
In [16]: print(full)
{
"_": "types.messages.ChatFull",
"full_chat": {
"_": "types.ChannelFull",
"id": 1341500725,
"about": "🕊 Новости о Minter онлайн от Ласточки: @swallow_minter\n@swallow_chat\n\nЕжедневные Итоги дня Minter.\nО валидаторах, проектах, монетах.\n\n🕊 Список СКАМ каналов, чатов... Скам монеты. Онлайн информация.\n@minterhelper\n\nMxd87f5c128dab251de71dc9ca1714f0f1d9fda54b",
"read_inbox_max_id": 130496,
"read_outbox_max_id": 133199,
"unread_count": 2376,
"chat_photo": {
"_": "types.Photo",
"id": 3791644807796991922,
"access_hash": -454978266117003521,
"file_reference": "b'\\x00^\\xa6\\xe4\\xfa{zM\\xafJ\\x83\\x08\\r,\\x9d\\xed\\x1e\\x94\\xcck\\x0f'",
"date": 1566851481,
"sizes": [
{
"_": "types.PhotoSize",
"type": "a",
"location": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 263705863,
"local_id": 184208
},
"w": 160,
"h": 160,
"size": 3196
},
{
"_": "types.PhotoSize",
"type": "b",
"location": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 263705863,
"local_id": 184209
},
"w": 320,
"h": 320,
"size": 8400
},
{
"_": "types.PhotoSize",
"type": "c",
"location": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 263705863,
"local_id": 184210
},
"w": 640,
"h": 640,
"size": 21784
}
],
"dc_id": 2,
"has_stickers": false
},
"notify_settings": {
"_": "types.PeerNotifySettings"
},
"exported_invite": {
"_": "types.ChatInviteEmpty"
},
"bot_info": [
{
"_": "types.BotInfo",
"user_id": 1123558278,
"description": "This is a Telegram loyalty club. \nThis bot gives away rewards to loyal chat members every day. \nBy the way you can add this bot to any chat!",
"commands": []
},
{
"_": "types.BotInfo",
"user_id": 821710898,
"description": "This bot can delete, unpin and repin posts in your group from the connected channel.\n\nLanguages: 🇺🇸🇷🇺🇺🇿",
"commands": []
},
{
"_": "types.BotInfo",
"user_id": 631698620,
"description": "",
"commands": []
},
{
"_": "types.BotInfo",
"user_id": 817488818,
"description": "",
"commands": []
},
{
"_": "types.BotInfo",
"user_id": 210944655,
"description": "The best possible solution in Telegram for moderation and maintaining your chats. \nSpam protection, warns, reputation system, restricions and full vizual chat analytics.\n\nAdd the bot to your group/supergroup and It'll starts to work immediately.\nPM to bot for accessing to chats preferences and moderation system.",
"commands": [
{
"_": "types.BotCommand",
"command": "stat",
"description": "See chat stats. For more options start the bot via direct message."
}
]
}
],
"pts": 159492,
"can_view_participants": true,
"can_set_username": false,
"can_set_stickers": false,
"hidden_prehistory": false,
"can_view_stats": false,
"can_set_location": false,
"has_scheduled": false,
"participants_count": 1329,
"admins_count": 9,
"kicked_count": 1380,
"banned_count": 652,
"online_count": 454,
"pinned_msg_id": 133198,
"linked_chat_id": 1324507814
},
"chats": [
{
"_": "types.Channel",
"id": 1341500725,
"title": "Ласточка CHAT (Minter)",
"photo": {
"_": "types.ChatPhoto",
"photo_small": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 263705863,
"local_id": 184208
},
"photo_big": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 263705863,
"local_id": 184210
},
"dc_id": 2
},
"date": 1587733135,
"version": 0,
"creator": false,
"left": false,
"broadcast": false,
"verified": false,
"megagroup": true,
"restricted": false,
"signatures": false,
"min": false,
"scam": false,
"has_link": true,
"has_geo": false,
"slowmode_enabled": false,
"access_hash": -6654776647094085316,
"username": "swallow_chat",
"restriction_reason": [],
"admin_rights": {
"_": "types.ChatAdminRights",
"change_info": false,
"post_messages": false,
"edit_messages": false,
"delete_messages": false,
"ban_users": false,
"invite_users": false,
"pin_messages": true,
"add_admins": false
},
"default_banned_rights": {
"_": "types.ChatBannedRights",
"until_date": 2147483647,
"view_messages": false,
"send_messages": false,
"send_media": false,
"send_stickers": false,
"send_gifs": false,
"send_games": false,
"send_inline": false,
"embed_links": false,
"send_polls": true,
"change_info": true,
"invite_users": true,
"pin_messages": true
}
},
{
"_": "types.Channel",
"id": 1324507814,
"title": "ЛАСТОЧКА (Minter)",
"photo": {
"_": "types.ChatPhoto",
"photo_small": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 263711765,
"local_id": 183199
},
"photo_big": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 263711765,
"local_id": 183201
},
"dc_id": 2
},
"date": 1566060227,
"version": 0,
"creator": false,
"left": true,
"broadcast": true,
"verified": false,
"megagroup": false,
"restricted": false,
"signatures": false,
"min": false,
"scam": false,
"has_link": true,
"has_geo": false,
"slowmode_enabled": false,
"access_hash": 3215947042206870698,
"username": "swallow_minter",
"restriction_reason": []
}
],
"users": [
{
"_": "types.User",
"id": 1123558278,
"is_self": true,
"contact": false,
"mutual_contact": false,
"deleted": false,
"bot": true,
"bot_chat_history": true,
"bot_nochats": false,
"verified": false,
"restricted": false,
"min": false,
"bot_inline_geo": false,
"support": false,
"scam": false,
"access_hash": 8496688685685387185,
"first_name": "Dice Time",
"username": "dicetimebot",
"photo": {
"_": "types.UserProfilePhoto",
"photo_id": 5221994304640233083,
"photo_small": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 264423751,
"local_id": 371730
},
"photo_big": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 264423751,
"local_id": 371732
},
"dc_id": 2
},
"bot_info_version": 4,
"restriction_reason": []
},
{
"_": "types.User",
"id": 821710898,
"is_self": false,
"contact": false,
"mutual_contact": false,
"deleted": false,
"bot": true,
"bot_chat_history": false,
"bot_nochats": false,
"verified": false,
"restricted": false,
"min": false,
"bot_inline_geo": false,
"support": false,
"scam": false,
"access_hash": 4929428934672021031,
"first_name": "AntiDiscussBot",
"username": "AntiDiscussBot",
"photo": {
"_": "types.UserProfilePhoto",
"photo_id": 3529221434133030825,
"photo_small": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 257019003,
"local_id": 343206
},
"photo_big": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 257019003,
"local_id": 343208
},
"dc_id": 2
},
"bot_info_version": 4,
"restriction_reason": []
},
{
"_": "types.User",
"id": 631698620,
"is_self": false,
"contact": false,
"mutual_contact": false,
"deleted": false,
"bot": true,
"bot_chat_history": true,
"bot_nochats": false,
"verified": false,
"restricted": false,
"min": false,
"bot_inline_geo": false,
"support": false,
"scam": false,
"access_hash": 8062656073301206343,
"first_name": "SWALLOW",
"username": "swallowwbot",
"bot_info_version": 1,
"restriction_reason": []
},
{
"_": "types.User",
"id": 817488818,
"is_self": false,
"contact": false,
"mutual_contact": false,
"deleted": false,
"bot": true,
"bot_chat_history": false,
"bot_nochats": false,
"verified": false,
"restricted": false,
"min": false,
"bot_inline_geo": false,
"support": false,
"scam": false,
"access_hash": 2239974595547192344,
"first_name": "Saya-shi",
"username": "sayashibot",
"photo": {
"_": "types.UserProfilePhoto",
"photo_id": 3511087738611935146,
"photo_small": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 257033689,
"local_id": 145869
},
"photo_big": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 257033689,
"local_id": 145871
},
"dc_id": 2
},
"bot_info_version": 1,
"restriction_reason": []
},
{
"_": "types.User",
"id": 210944655,
"is_self": false,
"contact": false,
"mutual_contact": false,
"deleted": false,
"bot": true,
"bot_chat_history": true,
"bot_nochats": false,
"verified": false,
"restricted": false,
"min": false,
"bot_inline_geo": false,
"support": false,
"scam": false,
"access_hash": -3145185432416096451,
"first_name": "Combot",
"username": "combot",
"photo": {
"_": "types.UserProfilePhoto",
"photo_id": 906000394947241900,
"photo_small": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 263702468,
"local_id": 252616
},
"photo_big": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 263702468,
"local_id": 252618
},
"dc_id": 2
},
"bot_info_version": 38,
"restriction_reason": []
}
]
}
In [17]: chat
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-17-eb3bbd8e0783> in <module>
----> 1 chat
NameError: name 'chat' is not defined
In [18]: full.chats[0]
Out[18]: pyrogram.api.types.Channel(id=1341500725, title='Ласточка CHAT (Minter)', photo=pyrogram.api.types.ChatPhoto(photo_small=pyrogram.api.types.FileLocationToBeDeprecated(volume_id=263705863, local_id=184208), photo_big=pyrogram.api.types.FileLocationToBeDeprecated(volume_id=263705863, local_id=184210), dc_id=2), date=1587733135, version=0, creator=False, left=False, broadcast=False, verified=False, megagroup=True, restricted=False, signatures=False, min=False, scam=False, has_link=True, has_geo=False, slowmode_enabled=False, access_hash=-6654776647094085316, username='swallow_chat', restriction_reason=[], admin_rights=pyrogram.api.types.ChatAdminRights(change_info=False, post_messages=False, edit_messages=False, delete_messages=False, ban_users=False, invite_users=False, pin_messages=True, add_admins=False), default_banned_rights=pyrogram.api.types.ChatBannedRights(until_date=2147483647, view_messages=False, send_messages=False, send_media=False, send_stickers=False, send_gifs=False, send_games=False, send_inline=False, embed_links=False, send_polls=True, change_info=True, invite_users=True, pin_messages=True))
In [19]:
In [19]: messages = filter(
...: lambda m: not m.empty,
...: app.get_messages(full.chats[0].id, range(1, 201), replies=0))
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/client.py in resolve_peer(self, peer_id)
1658 try:
-> 1659 return self.storage.get_peer_by_id(peer_id)
1660 except KeyError:
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/storage/sqlite_storage.py in get_peer_by_id(self, peer_id)
107 if r is None:
--> 108 raise KeyError("ID not found: {}".format(peer_id))
109
KeyError: 'ID not found: 1341500725'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/client.py in resolve_peer(self, peer_id)
1719 try:
-> 1720 return self.storage.get_peer_by_id(peer_id)
1721 except KeyError:
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/storage/sqlite_storage.py in get_peer_by_id(self, peer_id)
107 if r is None:
--> 108 raise KeyError("ID not found: {}".format(peer_id))
109
KeyError: 'ID not found: 1341500725'
During handling of the above exception, another exception occurred:
PeerIdInvalid Traceback (most recent call last)
<ipython-input-19-17add7c84aea> in <module>
1 messages = filter(
2 lambda m: not m.empty,
----> 3 app.get_messages(full.chats[0].id, range(1, 201), replies=0))
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/methods/messages/get_messages.py in get_messages(self, chat_id, message_ids, reply_to_message_ids, replies)
99 raise ValueError("No argument supplied. Either pass message_ids or reply_to_message_ids")
100
--> 101 peer = self.resolve_peer(chat_id)
102
103 is_iterable = not isinstance(ids, int)
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/client.py in resolve_peer(self, peer_id)
1720 return self.storage.get_peer_by_id(peer_id)
1721 except KeyError:
-> 1722 raise PeerIdInvalid
1723
1724 def save_file(
PeerIdInvalid: [400 PEER_ID_INVALID]: The id/access_hash combination is invalid
In [20]: messages = filter(
...: lambda m: not m.empty,
...: app.get_messages(full.chats[0].id, range(1, 201), replies=0))
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/client.py in resolve_peer(self, peer_id)
1658 try:
-> 1659 return self.storage.get_peer_by_id(peer_id)
1660 except KeyError:
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/storage/sqlite_storage.py in get_peer_by_id(self, peer_id)
107 if r is None:
--> 108 raise KeyError("ID not found: {}".format(peer_id))
109
KeyError: 'ID not found: 1341500725'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/client.py in resolve_peer(self, peer_id)
1719 try:
-> 1720 return self.storage.get_peer_by_id(peer_id)
1721 except KeyError:
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/storage/sqlite_storage.py in get_peer_by_id(self, peer_id)
107 if r is None:
--> 108 raise KeyError("ID not found: {}".format(peer_id))
109
KeyError: 'ID not found: 1341500725'
During handling of the above exception, another exception occurred:
PeerIdInvalid Traceback (most recent call last)
<ipython-input-20-17add7c84aea> in <module>
1 messages = filter(
2 lambda m: not m.empty,
----> 3 app.get_messages(full.chats[0].id, range(1, 201), replies=0))
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/methods/messages/get_messages.py in get_messages(self, chat_id, message_ids, reply_to_message_ids, replies)
99 raise ValueError("No argument supplied. Either pass message_ids or reply_to_message_ids")
100
--> 101 peer = self.resolve_peer(chat_id)
102
103 is_iterable = not isinstance(ids, int)
~/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/pyrogram/client/client.py in resolve_peer(self, peer_id)
1720 return self.storage.get_peer_by_id(peer_id)
1721 except KeyError:
-> 1722 raise PeerIdInvalid
1723
1724 def save_file(
PeerIdInvalid: [400 PEER_ID_INVALID]: The id/access_hash combination is invalid
In [21]: full.chats[0].id
Out[21]: 1341500725
In [22]: print(full.chats[0])
{
"_": "types.Channel",
"id": 1341500725,
"title": "Ласточка CHAT (Minter)",
"photo": {
"_": "types.ChatPhoto",
"photo_small": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 263705863,
"local_id": 184208
},
"photo_big": {
"_": "types.FileLocationToBeDeprecated",
"volume_id": 263705863,
"local_id": 184210
},
"dc_id": 2
},
"date": 1587733135,
"version": 0,
"creator": false,
"left": false,
"broadcast": false,
"verified": false,
"megagroup": true,
"restricted": false,
"signatures": false,
"min": false,
"scam": false,
"has_link": true,
"has_geo": false,
"slowmode_enabled": false,
"access_hash": -6654776647094085316,
"username": "swallow_chat",
"restriction_reason": [],
"admin_rights": {
"_": "types.ChatAdminRights",
"change_info": false,
"post_messages": false,
"edit_messages": false,
"delete_messages": false,
"ban_users": false,
"invite_users": false,
"pin_messages": true,
"add_admins": false
},
"default_banned_rights": {
"_": "types.ChatBannedRights",
"until_date": 2147483647,
"view_messages": false,
"send_messages": false,
"send_media": false,
"send_stickers": false,
"send_gifs": false,
"send_games": false,
"send_inline": false,
"embed_links": false,
"send_polls": true,
"change_info": true,
"invite_users": true,
"pin_messages": true
}
}
In [23]:
Do you really want to exit ([y]/n)? y
^CException ignored in: <module 'threading' from '/Users/ivankotelnikov/.pyenv/versions/3.7.5/lib/python3.7/threading.py'>
Traceback (most recent call last):
File "/Users/ivankotelnikov/.pyenv/versions/3.7.5/lib/python3.7/threading.py", line 1307, in _shutdown
lock.acquire()
KeyboardInterrupt
(.venv) ~/Desktop/minter/dicetime   master ●✚  git status
On branch master
Your branch is up to date with 'dadon/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: users/__pycache__/texts.cpython-38.pyc
Untracked files:
(use "git add <file>..." to include in what will be committed)
.DS_Store
.python-version
dump.rdb
polygon.py
pyrosession.session
users/management/commands/daemon.py
no changes added to commit (use "git add" and/or "git commit -a")
(.venv) ~/Desktop/minter/dicetime   master ●  git log
(.venv) ~/Desktop/minter/dicetime   master ●  git diff 29c5fe136894d6bae0b3beb66f4084a5629175ee
(.venv) ~/Desktop/minter/dicetime   master ● 
(.venv) ~/Desktop/minter/dicetime   master ●  git status
On branch master
Your branch is up to date with 'dadon/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: users/__pycache__/texts.cpython-38.pyc
Untracked files:
(use "git add <file>..." to include in what will be committed)
.DS_Store
.python-version
dump.rdb
polygon.py
pyrosession.session
users/management/commands/daemon.py
no changes added to commit (use "git add" and/or "git commit -a")
(.venv) ~/Desktop/minter/dicetime   master ●  ./manage.py startapp --help
Traceback (most recent call last):
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
raise err
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
chunked=chunked,
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Users/ivankotelnikov/.pyenv/versions/3.7.5/lib/python3.7/http/client.py", line 1252, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Users/ivankotelnikov/.pyenv/versions/3.7.5/lib/python3.7/http/client.py", line 1298, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Users/ivankotelnikov/.pyenv/versions/3.7.5/lib/python3.7/http/client.py", line 1247, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Users/ivankotelnikov/.pyenv/versions/3.7.5/lib/python3.7/http/client.py", line 1026, in _send_output
self.send(msg)
File "/Users/ivankotelnikov/.pyenv/versions/3.7.5/lib/python3.7/http/client.py", line 966, in send
self.connect()
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect
conn = self._new_conn()
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x10e7a05d0>: Failed to establish a new connection: [Errno 61] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 439, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=4040): Max retries exceeded with url: /api/tunnels (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10e7a05d0>: Failed to establish a new connection: [Errno 61] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 325, in execute
settings.INSTALLED_APPS
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/django/conf/__init__.py", line 79, in __getattr__
self._setup(name)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/django/conf/__init__.py", line 66, in _setup
self._wrapped = Settings(settings_module)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/django/conf/__init__.py", line 157, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/ivankotelnikov/Desktop/minter/dicetime/dice_time/settings.py", line 50, in <module>
resp = requests.get(ngrok_tunnels)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=4040): Max retries exceeded with url: /api/tunnels (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10e7a05d0>: Failed to establish a new connection: [Errno 61] Connection refused'))
(.venv) ✘  ~/Desktop/minter/dicetime   master ●  ./manage.py startapp --help
usage: manage.py startapp [-h] [--template TEMPLATE] [--extension EXTENSIONS]
[--name FILES] [--version] [-v {0,1,2,3}]
[--settings SETTINGS] [--pythonpath PYTHONPATH]
[--traceback] [--no-color] [--force-color]
name [directory]
Creates a Django app directory structure for the given app name in the current
directory or optionally in the given directory.
positional arguments:
name Name of the application or project.
directory Optional destination directory
optional arguments:
-h, --help show this help message and exit
--template TEMPLATE The path or URL to load the template from.
--extension EXTENSIONS, -e EXTENSIONS
The file extension(s) to render (default: "py").
Separate multiple extensions with commas, or use -e
multiple times.
--name FILES, -n FILES
The file name(s) to render. Separate multiple file
names with commas, or use -n multiple times.
--version show program's version number and exit
-v {0,1,2,3}, --verbosity {0,1,2,3}
Verbosity level; 0=minimal output, 1=normal output,
2=verbose output, 3=very verbose output
--settings SETTINGS The Python path to a settings module, e.g.
"myproject.settings.main". If this isn't provided, the
DJANGO_SETTINGS_MODULE environment variable will be
used.
--pythonpath PYTHONPATH
A directory to add to the Python path, e.g.
"/home/djangoprojects/myproject".
--traceback Raise on CommandError exceptions
--no-color Don't colorize the command output.
--force-color Force colorization of the command output.
(.venv) ~/Desktop/minter/dicetime   master ●  ./manage.py startapp dicebot
(.venv) ~/Desktop/minter/dicetime   master ●✚  ./manage.py shell_plus
Traceback (most recent call last):
File "./manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/Users/ivankotelnikov/Desktop/minter/dicetime/.venv/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'dicebot.apps.DicebotConfigusers'; 'dicebot.apps' is not a package
(.venv) ✘  ~/Desktop/minter/dicetime   master ●✚  ./manage.py shell_plus
# Shell Plus Model Imports
from django.contrib.admin.models import LogEntry
from django.contrib.auth.models import Group, Permission
from users.models import AllowedChat, ChatMember, ChatWallet, DiceEvent, Exceptions, Language, MinterWallets, Payment, Service, Text, Tools, Triggers, User
from django.contrib.contenttypes.models import ContentType
from django.contrib.sessions.models import Session
# Shell Plus Django Imports
from django.core.cache import cache
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import transaction
from django.db.models import Avg, Case, Count, F, Max, Min, Prefetch, Q, Sum, When, Exists, OuterRef, Subquery
from django.utils import timezone
from django.urls import reverse
Python 3.7.5 (default, Dec 14 2019, 13:37:31)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from users.minter import API
In [2]: API.get_latest_block_height()
Out[2]: 971906
In [3]: API
Out[3]: <users.minter.MinterRetryAPI at 0x1072431d0>
In [4]: API.__dict__
Out[4]: {'api_url': 'https://api.minter.one/'}
In [5]: API.get_latest_block_height()
Out[5]: 971913
In [6]: API.get_latest_block_height()
Out[6]: 971913
In [7]: API.get_latest_block_height()
Out[7]: 971914
In [8]: API.get_latest_block_height()
Out[8]: 971914
In [9]: API.get_latest_block_height()
Out[9]: 971914
In [10]: API.get_latest_block_height()
Out[10]: 971914
In [11]:
In [11]: API.get_latest_block_height()
Out[11]: 971914
In [12]: API.get_latest_block_height()
Out[12]: 971914
In [13]: API.get_latest_block_height()
Out[13]: 971915
In [14]: API.get_latest_block_height()
Out[14]: 971915
In [15]: API.get_latest_block_height()
Out[15]: 971915
In [16]: API.get_latest_block_height()
Out[16]: 971915
In [17]: API.get_latest_block_height()
Out[17]: 971915
In [18]: API.get_latest_block_height()
Out[18]: 971915
In [19]: API.get_latest_block_height()
Out[19]: 971915
In [20]: API.get_latest_block_height()
Out[20]: 971916
In [21]: API.get_latest_block_height()
Out[21]: 971916
In [22]: API.get_latest_block_height()
Out[22]: 971916
In [23]: API.get_latest_block_height()
Out[23]: 971916
In [24]: current_block = API.get_latest_block_height()
In [25]: current_block
Out[25]: 971925
In [26]: API.get_block(current_block)
Out[26]:
{'jsonrpc': '2.0',
'id': '',
'result': {'hash': '40ab60ca4df605375dab65c8327e5fee75af34717aedc4591327c4788eebc067',
'height': 971925,
'time': '2020-04-28T16:23:54.506407288Z',
'num_txs': 0,
'transactions': [],
'block_reward': 304000000000000000000,
'size': 6831,
'proposer': 'Mpd7a9eae76d3e98145b6b897c00c407b42ae8c42f937527ebdcd0239a4d88c0a5',
'validators': [{'pub_key': 'Mp4c45b862300e0d6a05febb742caa0448aef0e80c53d341bb10236b039ac54c1a',
'signed': True},
{'pub_key': 'Mp88883bcd4e9a4eeb7f5a7b7d1f4c02ac0fadc268824694fcccc84e39f4e08888',
'signed': True},
{'pub_key': 'Mp02ff680cbea3fb95f547bddde69c9150b3b7ab8d1c5c2a1bf94ccb70bf073b2c',
'signed': True},
{'pub_key': 'Mped3eb71dcd50122dc8f50f6cc7464f22128eb58fa0af6864ffbcb733febf6113',
'signed': True},
{'pub_key': 'Mpe782c9a2c62f085f4d1bedf307de525b13226c20c597e66b0cf246a061f31b2d',
'signed': True},
{'pub_key': 'Mp65758496f8a5d626cac77f5a38894beae0050fdef862da201964cd2fd8111111',
'signed': True},
{'pub_key': 'Mp7979c5a8d974e0c8c99f568b91454853f0c48fbbe68ac39d40efd0b330f30885',
'signed': True},
{'pub_key': 'Mp5e3e1da62c7eabd9d8d168a36a92727fc1970a54ec61eadd285d4199c41191d7',
'signed': True},
{'pub_key': 'Mp1ada5ac409b965623bf6a4320260190038ae27230abfb5ebc9158280cdffffff',
'signed': True},
{'pub_key': 'Mp5905de85699cb72bbf1dd0cfaa19db632e212b6fdf67db27bf03b602536249e7',
'signed': True},
{'pub_key': 'Mp4926c68cec9b85d743810c801c35c33bd3d1e74ae0a801e4e08998e656835727',
'signed': True},
{'pub_key': 'Mp999d3789d40ff0c699f861758bcafde15d3b4828c7518bc94810837688888888',
'signed': True},
{'pub_key': 'Mp92d05e745464f4d17a12440f48d73dddf8135e45cf91a7e3c4bcacdb2cc1c99f',
'signed': True},
{'pub_key': 'Mpeee9614b63a7ed6370ccd1fa227222fa30d6106770145c55bd4b482b88888888',
'signed': True},
{'pub_key': 'Mp9fdd4c54b5a1ea0c014c8a8cf012cdb756630d0c35728c8659d6f69d2d00ffa5',
'signed': True},
{'pub_key': 'Mp1c3cc265a7c1d80f0f83d97eb6d7c261b71b0732d731f8c92678f381260e434d',
'signed': True},
{'pub_key': 'Mp120c15e48aed0ac866a1a918bd367cfa31909a6b09f328a18bd18f32edef2be8',
'signed': True},
{'pub_key': 'Mp2cbade2b08501047bb9d2a08abeee21e276cb0e027e84e3a526ede85c4cbd442',
'signed': True},
{'pub_key': 'Mp14d5f76de9ddc5c3eb7ed24af7de91274c9156de4585a01d2731e75c0fc65170',
'signed': True},
{'pub_key': 'Mp5ed0739ee51e77b3906a3fc63449f0564be1c9d5e307d720b3d4c52faf4976ae',
'signed': True},
{'pub_key': 'Mp4881ad167ca5fb5886322841f992d68aed894ffcb58abc080e8ad3b156f1045b',
'signed': True},
{'pub_key': 'Mpbf129ef2bb58a383b637e14607f164f9fff6441094ade5830ef90d216db86244',
'signed': True},
{'pub_key': 'Mpadeb65fa666a4a8e033d20c1a48d09b3f024eb8756da7f7a21e0932582222222',
'signed': True},
{'pub_key': 'Mp03478aae43a1a660573fab0763ae44492cdaf8deffc3fcbcc844acd67dfb2db6',
'signed': True},
{'pub_key': 'Mpa70d12c096cb459e7c191be0dffb1a7dbe4a9587bfa7174c654959e5e9da7203',
'signed': True},
{'pub_key': 'Mpb9f5eb577c73f92b27175aa91608ea3e6bb8fc2dbd1eeeaa9d397f27d76a4e45',
'signed': True},
{'pub_key': 'Mpaaaa175f44e40e31d0f16fc05fc65e5802dcdf40fe897dd762076d633bc1aaaa',
'signed': True},
{'pub_key': 'Mp5606ddda3d999cdc9d3b1da0a68d871d1b15aea8ec9a074af4c13e9b1889a083',
'signed': True},
{'pub_key': 'Mp47f5c19c3ac5d66c960f36aa1a2d74ec8127f96308b67054332c988ee9eafaf0',
'signed': True},
{'pub_key': 'Mp77774337c2212ce5a9b57b9392daf5e11639f7fd38e1a16a584291ed3a98b777',
'signed': True},
{'pub_key': 'Mpc6df0dd44cae3cb49ee0ef8bd78750b961e64e231e6dfdc22fbd8e0c476d66d2',
'signed': True},
{'pub_key': 'Mp052f704bdfce99a28af7bce2c40cbb0662fd757a709eee40c83c43b0afaec02a',
'signed': True},
{'pub_key': 'Mpc9fc1052e075054cdbfb6443a6d14d97be9d4f19a10505c4323b52a78ca4bb18',
'signed': True},
{'pub_key': 'Mp89c617e56f97ffd798aa33a1addb50c43a000e579756219ad48c7bbd89d5eec8',
'signed': True},
{'pub_key': 'Mp7373d6d5a4ec18d87d766e5b4c6d3a0c94b357c4460a9ed377bf5d09fcd77373',
'signed': True},
{'pub_key': 'Mpfe176f944623a8ca9f409a62f0ea3ca75c1cf8d89970adf9384fc9ae8d77fa0b',
'signed': True},
{'pub_key': 'Mp7779ec1c6492e7c71a36f4009d7ee5a43fed2fe4048882b8a099e748869f0777',
'signed': True},
{'pub_key': 'Mp6ff5bd93c430e06e70ef9aff1eec8c617e03464bef2545180b9de1757fb578ac',
'signed': True},
{'pub_key': 'Mp77f71834108e9b5e65237a39263631b4f99a9d58437a1385c930c13ee1d4e2a6',
'signed': True},
{'pub_key': 'Mp777776a9f5110bc4c676dc34191881716484db7d5242a94bfe0b93afa56815f6',
'signed': True},
{'pub_key': 'Mp04eefbbdeba47c8c7d41ef86668639c09d5013148a0ba726c4600c9943936b2c',
'signed': True},
{'pub_key': 'Mp85834d014d0af97fe49589196f3e80e832fb7dcb69d572bc0ea2456c067e9b5b',
'signed': True},
{'pub_key': 'Mp02bc3c3f77d5ab9732ef9fc3801a6d72dc18f88328c14dc735648abfe551f50f',
'signed': True},
{'pub_key': 'Mp01cc99ae5a349ecaeef187dcbb12816bf2b3d8eae80f654034b21213aa445b2c',
'signed': True},
{'pub_key': 'Mp46d3d6afe0084fcf530b03d1f4427e516a1cb4ec542640bcbc84c2c4b4f53c13',
'signed': True},
{'pub_key': 'Mp95b76c6893dc28a34f005b9708bac59eae238232ef86798d672387bbb849bd22',
'signed': True},
{'pub_key': 'Mp00454817134295dc6d39517672b2467ee8301a836216ace04bf0cf3910000000',
'signed': True},
{'pub_key': 'Mpf979659e45f25defab5ef8624f8060e27b1440157f86779b12b98e7e293136cb',
'signed': True},
{'pub_key': 'Mp2c827f0365d6592b5377b771d36cb6b1006ca13243122476800febab59b4a2e9',
'signed': True},
{'pub_key': 'Mp97a5a64cbbf65a3474beb0a0cbf8eb054b14a59623f1416580099f4433333333',
'signed': True},
{'pub_key': 'Mp629b5528f09d1c74a83d18414f2e4263e14850c47a3fac3f855f200111111111',
'signed': True},
{'pub_key': 'Mpaaaaa16ebd6af229b4cfc02c3ab40bd25c1051c3aa2120f07d08c1bd01777777',
'signed': True},
{'pub_key': 'Mp7b4174732a169c467c9ee791576fc5860ca99bc7a49d8cfb041a91f9202178cc',
'signed': True},
{'pub_key': 'Mp30f65492c3b2937856864088eec4417da66a61c1be3415b417232603e33c3bd9',
'signed': True},
{'pub_key': 'Mp3b6e2632cd0c91ef96ea4f4a16f554ff1b4dd41324fd421a0161947c50603b9b',
'signed': True},
{'pub_key': 'Mpaf167d3b1d37733928b28615f4168e79de3d45529945a3630a10e0767e03b6e3',
'signed': True},
{'pub_key': 'Mpef20aabe66bf65fc607a4cc9aae7450872763942f945e5fe3e609a2fdf8a327d',
'signed': True},
{'pub_key': 'Mpd7a9eae76d3e98145b6b897c00c407b42ae8c42f937527ebdcd0239a4d88c0a5',
'signed': True},
{'pub_key': 'Mp31d08d6f64f7a8a528ed2df77de2a02e4d8cefae93c771eb0b7de97322901215',
'signed': True},
{'pub_key': 'Mp3ff4490148c0cf42a9780dbb24a08e012d30d6f371021d28f8e4d3a8e2d6d9cf',
'signed': True}]}}
In [27]: API.get_block(current_block - 1)
Out[27]:
{'jsonrpc': '2.0',
'id': '',
'result': {'hash': 'a83ec3825f20bc83ce459c848dfb6bd9deb34610c955bdca69549e47b3fcdaf7',
'height': 971924,
'time': '2020-04-28T16:23:49.752481385Z',
'num_txs': 0,
'transactions': [],
'block_reward': 304000000000000000000,
'size': 6865,
'proposer': 'Mpeee9614b63a7ed6370ccd1fa227222fa30d6106770145c55bd4b482b88888888',
'validators': [{'pub_key': 'Mp4c45b862300e0d6a05febb742caa0448aef0e80c53d341bb10236b039ac54c1a',
'signed': True},
{'pub_key': 'Mp88883bcd4e9a4eeb7f5a7b7d1f4c02ac0fadc268824694fcccc84e39f4e08888',
'signed': True},
{'pub_key': 'Mp02ff680cbea3fb95f547bddde69c9150b3b7ab8d1c5c2a1bf94ccb70bf073b2c',
'signed': True},
{'pub_key': 'Mped3eb71dcd50122dc8f50f6cc7464f22128eb58fa0af6864ffbcb733febf6113',
'signed': True},
{'pub_key': 'Mpe782c9a2c62f085f4d1bedf307de525b13226c20c597e66b0cf246a061f31b2d',
'signed': True},
{'pub_key': 'Mp65758496f8a5d626cac77f5a38894beae0050fdef862da201964cd2fd8111111',
'signed': True},
{'pub_key': 'Mp7979c5a8d974e0c8c99f568b91454853f0c48fbbe68ac39d40efd0b330f30885',
'signed': True},
{'pub_key': 'Mp5e3e1da62c7eabd9d8d168a36a92727fc1970a54ec61eadd285d4199c41191d7',
'signed': True},
{'pub_key': 'Mp1ada5ac409b965623bf6a4320260190038ae27230abfb5ebc9158280cdffffff',
'signed': True},
{'pub_key': 'Mp5905de85699cb72bbf1dd0cfaa19db632e212b6fdf67db27bf03b602536249e7',
'signed': True},
{'pub_key': 'Mp4926c68cec9b85d743810c801c35c33bd3d1e74ae0a801e4e08998e656835727',
'signed': True},
{'pub_key': 'Mp999d3789d40ff0c699f861758bcafde15d3b4828c7518bc94810837688888888',
'signed': True},
{'pub_key': 'Mp92d05e745464f4d17a12440f48d73dddf8135e45cf91a7e3c4bcacdb2cc1c99f',
'signed': True},
{'pub_key': 'Mpeee9614b63a7ed6370ccd1fa227222fa30d6106770145c55bd4b482b88888888',
'signed': True},
{'pub_key': 'Mp9fdd4c54b5a1ea0c014c8a8cf012cdb756630d0c35728c8659d6f69d2d00ffa5',
'signed': True},
{'pub_key': 'Mp1c3cc265a7c1d80f0f83d97eb6d7c261b71b0732d731f8c92678f381260e434d',
'signed': True},
{'pub_key': 'Mp120c15e48aed0ac866a1a918bd367cfa31909a6b09f328a18bd18f32edef2be8',
'signed': True},
{'pub_key': 'Mp2cbade2b08501047bb9d2a08abeee21e276cb0e027e84e3a526ede85c4cbd442',
'signed': True},
{'pub_key': 'Mp14d5f76de9ddc5c3eb7ed24af7de91274c9156de4585a01d2731e75c0fc65170',
'signed': True},
{'pub_key': 'Mp5ed0739ee51e77b3906a3fc63449f0564be1c9d5e307d720b3d4c52faf4976ae',
'signed': True},
{'pub_key': 'Mp4881ad167ca5fb5886322841f992d68aed894ffcb58abc080e8ad3b156f1045b',
'signed': True},
{'pub_key': 'Mpbf129ef2bb58a383b637e14607f164f9fff6441094ade5830ef90d216db86244',
'signed': True},
{'pub_key': 'Mpadeb65fa666a4a8e033d20c1a48d09b3f024eb8756da7f7a21e0932582222222',
'signed': True},
{'pub_key': 'Mp03478aae43a1a660573fab0763ae44492cdaf8deffc3fcbcc844acd67dfb2db6',
'signed': True},
{'pub_key': 'Mpa70d12c096cb459e7c191be0dffb1a7dbe4a9587bfa7174c654959e5e9da7203',
'signed': True},
{'pub_key': 'Mpb9f5eb577c73f92b27175aa91608ea3e6bb8fc2dbd1eeeaa9d397f27d76a4e45',
'signed': True},
{'pub_key': 'Mpaaaa175f44e40e31d0f16fc05fc65e5802dcdf40fe897dd762076d633bc1aaaa',
'signed': True},
{'pub_key': 'Mp5606ddda3d999cdc9d3b1da0a68d871d1b15aea8ec9a074af4c13e9b1889a083',
'signed': True},
{'pub_key': 'Mp47f5c19c3ac5d66c960f36aa1a2d74ec8127f96308b67054332c988ee9eafaf0',
'signed': True},
{'pub_key': 'Mp77774337c2212ce5a9b57b9392daf5e11639f7fd38e1a16a584291ed3a98b777',
'signed': True},
{'pub_key': 'Mpc6df0dd44cae3cb49ee0ef8bd78750b961e64e231e6dfdc22fbd8e0c476d66d2',
'signed': True},
{'pub_key': 'Mp052f704bdfce99a28af7bce2c40cbb0662fd757a709eee40c83c43b0afaec02a',
'signed': True},
{'pub_key': 'Mpc9fc1052e075054cdbfb6443a6d14d97be9d4f19a10505c4323b52a78ca4bb18',
'signed': True},
{'pub_key': 'Mp89c617e56f97ffd798aa33a1addb50c43a000e579756219ad48c7bbd89d5eec8',
'signed': True},
{'pub_key': 'Mp7373d6d5a4ec18d87d766e5b4c6d3a0c94b357c4460a9ed377bf5d09fcd77373',
'signed': True},
{'pub_key': 'Mpfe176f944623a8ca9f409a62f0ea3ca75c1cf8d89970adf9384fc9ae8d77fa0b',
'signed': True},
{'pub_key': 'Mp7779ec1c6492e7c71a36f4009d7ee5a43fed2fe4048882b8a099e748869f0777',
'signed': True},
{'pub_key': 'Mp6ff5bd93c430e06e70ef9aff1eec8c617e03464bef2545180b9de1757fb578ac',
'signed': True},
{'pub_key': 'Mp77f71834108e9b5e65237a39263631b4f99a9d58437a1385c930c13ee1d4e2a6',
'signed': True},
{'pub_key': 'Mp777776a9f5110bc4c676dc34191881716484db7d5242a94bfe0b93afa56815f6',
'signed': True},
{'pub_key': 'Mp04eefbbdeba47c8c7d41ef86668639c09d5013148a0ba726c4600c9943936b2c',
'signed': True},
{'pub_key': 'Mp85834d014d0af97fe49589196f3e80e832fb7dcb69d572bc0ea2456c067e9b5b',
'signed': True},
{'pub_key': 'Mp02bc3c3f77d5ab9732ef9fc3801a6d72dc18f88328c14dc735648abfe551f50f',
'signed': True},
{'pub_key': 'Mp01cc99ae5a349ecaeef187dcbb12816bf2b3d8eae80f654034b21213aa445b2c',
'signed': True},
{'pub_key': 'Mp46d3d6afe0084fcf530b03d1f4427e516a1cb4ec542640bcbc84c2c4b4f53c13',
'signed': True},
{'pub_key': 'Mp95b76c6893dc28a34f005b9708bac59eae238232ef86798d672387bbb849bd22',
'signed': True},
{'pub_key': 'Mp00454817134295dc6d39517672b2467ee8301a836216ace04bf0cf3910000000',
'signed': True},
{'pub_key': 'Mpf979659e45f25defab5ef8624f8060e27b1440157f86779b12b98e7e293136cb',
'signed': True},
{'pub_key': 'Mp2c827f0365d6592b5377b771d36cb6b1006ca13243122476800febab59b4a2e9',
'signed': True},
{'pub_key': 'Mp97a5a64cbbf65a3474beb0a0cbf8eb054b14a59623f1416580099f4433333333',
'signed': True},
{'pub_key': 'Mp629b5528f09d1c74a83d18414f2e4263e14850c47a3fac3f855f200111111111',
'signed': True},
{'pub_key': 'Mpaaaaa16ebd6af229b4cfc02c3ab40bd25c1051c3aa2120f07d08c1bd01777777',
'signed': True},
{'pub_key': 'Mp7b4174732a169c467c9ee791576fc5860ca99bc7a49d8cfb041a91f9202178cc',
'signed': True},
{'pub_key': 'Mp30f65492c3b2937856864088eec4417da66a61c1be3415b417232603e33c3bd9',
'signed': True},
{'pub_key': 'Mp3b6e2632cd0c91ef96ea4f4a16f554ff1b4dd41324fd421a0161947c50603b9b',
'signed': True},
{'pub_key': 'Mpaf167d3b1d37733928b28615f4168e79de3d45529945a3630a10e0767e03b6e3',
'signed': True},
{'pub_key': 'Mpef20aabe66bf65fc607a4cc9aae7450872763942f945e5fe3e609a2fdf8a327d',
'signed': True},
{'pub_key': 'Mpd7a9eae76d3e98145b6b897c00c407b42ae8c42f937527ebdcd0239a4d88c0a5',
'signed': True},
{'pub_key': 'Mp31d08d6f64f7a8a528ed2df77de2a02e4d8cefae93c771eb0b7de97322901215',
'signed': True},
{'pub_key': 'Mp3ff4490148c0cf42a9780dbb24a08e012d30d6f371021d28f8e4d3a8e2d6d9cf',
'signed': True}]}}
In [28]: API.get_block(current_block - 2)
Out[28]:
{'jsonrpc': '2.0',
'id': '',
'result': {'hash': '1f293acc65c320f6e4986ec654cf06995954f1bcd9b065c032cec5d8e2b45928',
'height': 971923,
'time': '2020-04-28T16:23:44.96425681Z',
'num_txs': 3,
'transactions': [{'hash': 'Mt2617c07f25081818d8cd80020ba1f4b489190ae7dd9717d0b477217d373bb644',
'raw_tx': 'f88882117a01018a4249500000000000000001aceb8a42495000000000000000947ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc28a010f0cf064dd59200000808001b845f8431ba0282ef7194da4e0c4d24ef2dbf932fcbbb7cb3cce78a61528ac4d1e268d455214a074bbbfb3b4b72ad41a5e55073794820fab491bef4489acfd0d6af99d1f726fb9',
'from': 'Mxc7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'nonce': 4474,
'gas_price': 1,
'type': 1,
'data': {'coin': 'BIP',
'to': 'Mx7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2',
'value': 5000000000000000000000},
'payload': '',
'service_data': '',
'gas': 10,
'gas_coin': 'BIP',
'tags': {'tx.coin': 'BIP',
'tx.type': '01',
'tx.from': 'c7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'tx.to': '7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2'}},
{'hash': 'Mtc5c1ee6bc5a4805c1082433715cb2fa33b133e9fb6c675b809fb468c83c86552',
'raw_tx': 'f8d382057301018a4249500000000000000001abea8a4249500000000000000094086870ca15484e47ea631dd7bb4e4958888a31c98901380d641f454a1000b84bd092d0bed0b7d0b2d180d0b0d18220d181d180d0b5d0b4d181d18220d0bfd0be20d181d0bfd0b8d181d0b0d0bdd0b8d18e20d188d182d180d0b0d184d0b020d0bed182204269747465616d8001b845f8431ca0785a2349f1848055f3e9b51e6ff471de37aa5528c23cf033f73124b6391ee348a043fbc94f3eeecc9ee55f07f13e787156635960db16ba8666ba3bc84790df7874',
'from': 'Mx1d708e7121d08cf9174d2a79ec804aed320937ad',
'nonce': 1395,
'gas_price': 1,
'type': 1,
'data': {'coin': 'BIP',
'to': 'Mx086870ca15484e47ea631dd7bb4e4958888a31c9',
'value': 22485738600000000000},
'payload': '0JLQvtC30LLRgNCw0YIg0YHRgNC10LTRgdGCINC/0L4g0YHQv9C40YHQsNC90LjRjiDRiNGC0YDQsNGE0LAg0L7RgiBCaXR0ZWFt',
'service_data': '',
'gas': 160,
'gas_coin': 'BIP',
'tags': {'tx.type': '01',
'tx.from': '1d708e7121d08cf9174d2a79ec804aed320937ad',
'tx.to': '086870ca15484e47ea631dd7bb4e4958888a31c9',
'tx.coin': 'BIP'}},
{'hash': 'Mtf22e11c11f995ae89bfc92c7aabd25e223e462be8a7664fca9e4510736f3be67',
'raw_tx': 'f8748202af01018a424950000000000000000398d78a424950000000000000008a474f4f444c590000000080808001b845f8431ba0baf9049d759201980c1591faf4f346b5ac7d6163190247fb02ff4ad6a9758c6fa05472a2332ac450955d464604c2e189ca2e2324342bcaf044d79115cee76c3eb8',
'from': 'Mx94bcf3c4a5254649c602a2499f4ff89ced18958a',
'nonce': 687,
'gas_price': 1,
'type': 3,
'data': {'coin_to_sell': 'BIP',
'coin_to_buy': 'GOODLY',
'minimum_value_to_buy': 0},
'payload': '',
'service_data': '',
'gas': 100,
'gas_coin': 'BIP',
'tags': {'tx.sell_amount': 647365234905766587,
'tx.type': '03',
'tx.from': '94bcf3c4a5254649c602a2499f4ff89ced18958a',
'tx.coin_to_buy': 'GOODLY',
'tx.coin_to_sell': 'BIP',
'tx.return': 806080150430990891}}],
'block_reward': 304000000000000000000,
'size': 7368,
'proposer': 'Mp04eefbbdeba47c8c7d41ef86668639c09d5013148a0ba726c4600c9943936b2c',
'validators': [{'pub_key': 'Mp4c45b862300e0d6a05febb742caa0448aef0e80c53d341bb10236b039ac54c1a',
'signed': True},
{'pub_key': 'Mp88883bcd4e9a4eeb7f5a7b7d1f4c02ac0fadc268824694fcccc84e39f4e08888',
'signed': True},
{'pub_key': 'Mp02ff680cbea3fb95f547bddde69c9150b3b7ab8d1c5c2a1bf94ccb70bf073b2c',
'signed': True},
{'pub_key': 'Mped3eb71dcd50122dc8f50f6cc7464f22128eb58fa0af6864ffbcb733febf6113',
'signed': True},
{'pub_key': 'Mpe782c9a2c62f085f4d1bedf307de525b13226c20c597e66b0cf246a061f31b2d',
'signed': True},
{'pub_key': 'Mp65758496f8a5d626cac77f5a38894beae0050fdef862da201964cd2fd8111111',
'signed': True},
{'pub_key': 'Mp7979c5a8d974e0c8c99f568b91454853f0c48fbbe68ac39d40efd0b330f30885',
'signed': True},
{'pub_key': 'Mp5e3e1da62c7eabd9d8d168a36a92727fc1970a54ec61eadd285d4199c41191d7',
'signed': True},
{'pub_key': 'Mp1ada5ac409b965623bf6a4320260190038ae27230abfb5ebc9158280cdffffff',
'signed': True},
{'pub_key': 'Mp5905de85699cb72bbf1dd0cfaa19db632e212b6fdf67db27bf03b602536249e7',
'signed': True},
{'pub_key': 'Mp4926c68cec9b85d743810c801c35c33bd3d1e74ae0a801e4e08998e656835727',
'signed': True},
{'pub_key': 'Mp999d3789d40ff0c699f861758bcafde15d3b4828c7518bc94810837688888888',
'signed': True},
{'pub_key': 'Mp92d05e745464f4d17a12440f48d73dddf8135e45cf91a7e3c4bcacdb2cc1c99f',
'signed': True},
{'pub_key': 'Mpeee9614b63a7ed6370ccd1fa227222fa30d6106770145c55bd4b482b88888888',
'signed': True},
{'pub_key': 'Mp9fdd4c54b5a1ea0c014c8a8cf012cdb756630d0c35728c8659d6f69d2d00ffa5',
'signed': True},
{'pub_key': 'Mp1c3cc265a7c1d80f0f83d97eb6d7c261b71b0732d731f8c92678f381260e434d',
'signed': True},
{'pub_key': 'Mp120c15e48aed0ac866a1a918bd367cfa31909a6b09f328a18bd18f32edef2be8',
'signed': True},
{'pub_key': 'Mp2cbade2b08501047bb9d2a08abeee21e276cb0e027e84e3a526ede85c4cbd442',
'signed': True},
{'pub_key': 'Mp14d5f76de9ddc5c3eb7ed24af7de91274c9156de4585a01d2731e75c0fc65170',
'signed': True},
{'pub_key': 'Mp5ed0739ee51e77b3906a3fc63449f0564be1c9d5e307d720b3d4c52faf4976ae',
'signed': True},
{'pub_key': 'Mp4881ad167ca5fb5886322841f992d68aed894ffcb58abc080e8ad3b156f1045b',
'signed': True},
{'pub_key': 'Mpbf129ef2bb58a383b637e14607f164f9fff6441094ade5830ef90d216db86244',
'signed': True},
{'pub_key': 'Mpadeb65fa666a4a8e033d20c1a48d09b3f024eb8756da7f7a21e0932582222222',
'signed': True},
{'pub_key': 'Mp03478aae43a1a660573fab0763ae44492cdaf8deffc3fcbcc844acd67dfb2db6',
'signed': True},
{'pub_key': 'Mpa70d12c096cb459e7c191be0dffb1a7dbe4a9587bfa7174c654959e5e9da7203',
'signed': True},
{'pub_key': 'Mpb9f5eb577c73f92b27175aa91608ea3e6bb8fc2dbd1eeeaa9d397f27d76a4e45',
'signed': True},
{'pub_key': 'Mpaaaa175f44e40e31d0f16fc05fc65e5802dcdf40fe897dd762076d633bc1aaaa',
'signed': True},
{'pub_key': 'Mp5606ddda3d999cdc9d3b1da0a68d871d1b15aea8ec9a074af4c13e9b1889a083',
'signed': True},
{'pub_key': 'Mp47f5c19c3ac5d66c960f36aa1a2d74ec8127f96308b67054332c988ee9eafaf0',
'signed': True},
{'pub_key': 'Mp77774337c2212ce5a9b57b9392daf5e11639f7fd38e1a16a584291ed3a98b777',
'signed': True},
{'pub_key': 'Mpc6df0dd44cae3cb49ee0ef8bd78750b961e64e231e6dfdc22fbd8e0c476d66d2',
'signed': True},
{'pub_key': 'Mp052f704bdfce99a28af7bce2c40cbb0662fd757a709eee40c83c43b0afaec02a',
'signed': True},
{'pub_key': 'Mpc9fc1052e075054cdbfb6443a6d14d97be9d4f19a10505c4323b52a78ca4bb18',
'signed': True},
{'pub_key': 'Mp89c617e56f97ffd798aa33a1addb50c43a000e579756219ad48c7bbd89d5eec8',
'signed': True},
{'pub_key': 'Mp7373d6d5a4ec18d87d766e5b4c6d3a0c94b357c4460a9ed377bf5d09fcd77373',
'signed': True},
{'pub_key': 'Mpfe176f944623a8ca9f409a62f0ea3ca75c1cf8d89970adf9384fc9ae8d77fa0b',
'signed': True},
{'pub_key': 'Mp7779ec1c6492e7c71a36f4009d7ee5a43fed2fe4048882b8a099e748869f0777',
'signed': True},
{'pub_key': 'Mp6ff5bd93c430e06e70ef9aff1eec8c617e03464bef2545180b9de1757fb578ac',
'signed': True},
{'pub_key': 'Mp77f71834108e9b5e65237a39263631b4f99a9d58437a1385c930c13ee1d4e2a6',
'signed': True},
{'pub_key': 'Mp777776a9f5110bc4c676dc34191881716484db7d5242a94bfe0b93afa56815f6',
'signed': True},
{'pub_key': 'Mp04eefbbdeba47c8c7d41ef86668639c09d5013148a0ba726c4600c9943936b2c',
'signed': True},
{'pub_key': 'Mp85834d014d0af97fe49589196f3e80e832fb7dcb69d572bc0ea2456c067e9b5b',
'signed': True},
{'pub_key': 'Mp02bc3c3f77d5ab9732ef9fc3801a6d72dc18f88328c14dc735648abfe551f50f',
'signed': True},
{'pub_key': 'Mp01cc99ae5a349ecaeef187dcbb12816bf2b3d8eae80f654034b21213aa445b2c',
'signed': True},
{'pub_key': 'Mp46d3d6afe0084fcf530b03d1f4427e516a1cb4ec542640bcbc84c2c4b4f53c13',
'signed': True},
{'pub_key': 'Mp95b76c6893dc28a34f005b9708bac59eae238232ef86798d672387bbb849bd22',
'signed': True},
{'pub_key': 'Mp00454817134295dc6d39517672b2467ee8301a836216ace04bf0cf3910000000',
'signed': True},
{'pub_key': 'Mpf979659e45f25defab5ef8624f8060e27b1440157f86779b12b98e7e293136cb',
'signed': True},
{'pub_key': 'Mp2c827f0365d6592b5377b771d36cb6b1006ca13243122476800febab59b4a2e9',
'signed': True},
{'pub_key': 'Mp97a5a64cbbf65a3474beb0a0cbf8eb054b14a59623f1416580099f4433333333',
'signed': True},
{'pub_key': 'Mp629b5528f09d1c74a83d18414f2e4263e14850c47a3fac3f855f200111111111',
'signed': True},
{'pub_key': 'Mpaaaaa16ebd6af229b4cfc02c3ab40bd25c1051c3aa2120f07d08c1bd01777777',
'signed': True},
{'pub_key': 'Mp7b4174732a169c467c9ee791576fc5860ca99bc7a49d8cfb041a91f9202178cc',
'signed': True},
{'pub_key': 'Mp30f65492c3b2937856864088eec4417da66a61c1be3415b417232603e33c3bd9',
'signed': True},
{'pub_key': 'Mp3b6e2632cd0c91ef96ea4f4a16f554ff1b4dd41324fd421a0161947c50603b9b',
'signed': True},
{'pub_key': 'Mpaf167d3b1d37733928b28615f4168e79de3d45529945a3630a10e0767e03b6e3',
'signed': True},
{'pub_key': 'Mpef20aabe66bf65fc607a4cc9aae7450872763942f945e5fe3e609a2fdf8a327d',
'signed': True},
{'pub_key': 'Mpd7a9eae76d3e98145b6b897c00c407b42ae8c42f937527ebdcd0239a4d88c0a5',
'signed': True},
{'pub_key': 'Mp31d08d6f64f7a8a528ed2df77de2a02e4d8cefae93c771eb0b7de97322901215',
'signed': True},
{'pub_key': 'Mp3ff4490148c0cf42a9780dbb24a08e012d30d6f371021d28f8e4d3a8e2d6d9cf',
'signed': True}]}}
In [29]: API.get_block(current_block - 2)['transactions']
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-29-0a87dc72c74b> in <module>
----> 1 API.get_block(current_block - 2)['transactions']
KeyError: 'transactions'
In [30]: API.get_block(current_block - 2)['result']['transactions']
Out[30]:
[{'hash': 'Mt2617c07f25081818d8cd80020ba1f4b489190ae7dd9717d0b477217d373bb644',
'raw_tx': 'f88882117a01018a4249500000000000000001aceb8a42495000000000000000947ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc28a010f0cf064dd59200000808001b845f8431ba0282ef7194da4e0c4d24ef2dbf932fcbbb7cb3cce78a61528ac4d1e268d455214a074bbbfb3b4b72ad41a5e55073794820fab491bef4489acfd0d6af99d1f726fb9',
'from': 'Mxc7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'nonce': 4474,
'gas_price': 1,
'type': 1,
'data': {'coin': 'BIP',
'to': 'Mx7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2',
'value': 5000000000000000000000},
'payload': '',
'service_data': '',
'gas': 10,
'gas_coin': 'BIP',
'tags': {'tx.coin': 'BIP',
'tx.type': '01',
'tx.from': 'c7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'tx.to': '7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2'}},
{'hash': 'Mtc5c1ee6bc5a4805c1082433715cb2fa33b133e9fb6c675b809fb468c83c86552',
'raw_tx': 'f8d382057301018a4249500000000000000001abea8a4249500000000000000094086870ca15484e47ea631dd7bb4e4958888a31c98901380d641f454a1000b84bd092d0bed0b7d0b2d180d0b0d18220d181d180d0b5d0b4d181d18220d0bfd0be20d181d0bfd0b8d181d0b0d0bdd0b8d18e20d188d182d180d0b0d184d0b020d0bed182204269747465616d8001b845f8431ca0785a2349f1848055f3e9b51e6ff471de37aa5528c23cf033f73124b6391ee348a043fbc94f3eeecc9ee55f07f13e787156635960db16ba8666ba3bc84790df7874',
'from': 'Mx1d708e7121d08cf9174d2a79ec804aed320937ad',
'nonce': 1395,
'gas_price': 1,
'type': 1,
'data': {'coin': 'BIP',
'to': 'Mx086870ca15484e47ea631dd7bb4e4958888a31c9',
'value': 22485738600000000000},
'payload': '0JLQvtC30LLRgNCw0YIg0YHRgNC10LTRgdGCINC/0L4g0YHQv9C40YHQsNC90LjRjiDRiNGC0YDQsNGE0LAg0L7RgiBCaXR0ZWFt',
'service_data': '',
'gas': 160,
'gas_coin': 'BIP',
'tags': {'tx.type': '01',
'tx.from': '1d708e7121d08cf9174d2a79ec804aed320937ad',
'tx.to': '086870ca15484e47ea631dd7bb4e4958888a31c9',
'tx.coin': 'BIP'}},
{'hash': 'Mtf22e11c11f995ae89bfc92c7aabd25e223e462be8a7664fca9e4510736f3be67',
'raw_tx': 'f8748202af01018a424950000000000000000398d78a424950000000000000008a474f4f444c590000000080808001b845f8431ba0baf9049d759201980c1591faf4f346b5ac7d6163190247fb02ff4ad6a9758c6fa05472a2332ac450955d464604c2e189ca2e2324342bcaf044d79115cee76c3eb8',
'from': 'Mx94bcf3c4a5254649c602a2499f4ff89ced18958a',
'nonce': 687,
'gas_price': 1,
'type': 3,
'data': {'coin_to_sell': 'BIP',
'coin_to_buy': 'GOODLY',
'minimum_value_to_buy': 0},
'payload': '',
'service_data': '',
'gas': 100,
'gas_coin': 'BIP',
'tags': {'tx.sell_amount': 647365234905766587,
'tx.type': '03',
'tx.from': '94bcf3c4a5254649c602a2499f4ff89ced18958a',
'tx.coin_to_buy': 'GOODLY',
'tx.coin_to_sell': 'BIP',
'tx.return': 806080150430990891}}]
In [31]: txs = API.get_block(current_block - 2)['result']['transactions']
In [32]: txs
Out[32]:
[{'hash': 'Mt2617c07f25081818d8cd80020ba1f4b489190ae7dd9717d0b477217d373bb644',
'raw_tx': 'f88882117a01018a4249500000000000000001aceb8a42495000000000000000947ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc28a010f0cf064dd59200000808001b845f8431ba0282ef7194da4e0c4d24ef2dbf932fcbbb7cb3cce78a61528ac4d1e268d455214a074bbbfb3b4b72ad41a5e55073794820fab491bef4489acfd0d6af99d1f726fb9',
'from': 'Mxc7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'nonce': 4474,
'gas_price': 1,
'type': 1,
'data': {'coin': 'BIP',
'to': 'Mx7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2',
'value': 5000000000000000000000},
'payload': '',
'service_data': '',
'gas': 10,
'gas_coin': 'BIP',
'tags': {'tx.coin': 'BIP',
'tx.type': '01',
'tx.from': 'c7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'tx.to': '7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2'}},
{'hash': 'Mtc5c1ee6bc5a4805c1082433715cb2fa33b133e9fb6c675b809fb468c83c86552',
'raw_tx': 'f8d382057301018a4249500000000000000001abea8a4249500000000000000094086870ca15484e47ea631dd7bb4e4958888a31c98901380d641f454a1000b84bd092d0bed0b7d0b2d180d0b0d18220d181d180d0b5d0b4d181d18220d0bfd0be20d181d0bfd0b8d181d0b0d0bdd0b8d18e20d188d182d180d0b0d184d0b020d0bed182204269747465616d8001b845f8431ca0785a2349f1848055f3e9b51e6ff471de37aa5528c23cf033f73124b6391ee348a043fbc94f3eeecc9ee55f07f13e787156635960db16ba8666ba3bc84790df7874',
'from': 'Mx1d708e7121d08cf9174d2a79ec804aed320937ad',
'nonce': 1395,
'gas_price': 1,
'type': 1,
'data': {'coin': 'BIP',
'to': 'Mx086870ca15484e47ea631dd7bb4e4958888a31c9',
'value': 22485738600000000000},
'payload': '0JLQvtC30LLRgNCw0YIg0YHRgNC10LTRgdGCINC/0L4g0YHQv9C40YHQsNC90LjRjiDRiNGC0YDQsNGE0LAg0L7RgiBCaXR0ZWFt',
'service_data': '',
'gas': 160,
'gas_coin': 'BIP',
'tags': {'tx.type': '01',
'tx.from': '1d708e7121d08cf9174d2a79ec804aed320937ad',
'tx.to': '086870ca15484e47ea631dd7bb4e4958888a31c9',
'tx.coin': 'BIP'}},
{'hash': 'Mtf22e11c11f995ae89bfc92c7aabd25e223e462be8a7664fca9e4510736f3be67',
'raw_tx': 'f8748202af01018a424950000000000000000398d78a424950000000000000008a474f4f444c590000000080808001b845f8431ba0baf9049d759201980c1591faf4f346b5ac7d6163190247fb02ff4ad6a9758c6fa05472a2332ac450955d464604c2e189ca2e2324342bcaf044d79115cee76c3eb8',
'from': 'Mx94bcf3c4a5254649c602a2499f4ff89ced18958a',
'nonce': 687,
'gas_price': 1,
'type': 3,
'data': {'coin_to_sell': 'BIP',
'coin_to_buy': 'GOODLY',
'minimum_value_to_buy': 0},
'payload': '',
'service_data': '',
'gas': 100,
'gas_coin': 'BIP',
'tags': {'tx.sell_amount': 647365234905766587,
'tx.type': '03',
'tx.from': '94bcf3c4a5254649c602a2499f4ff89ced18958a',
'tx.coin_to_buy': 'GOODLY',
'tx.coin_to_sell': 'BIP',
'tx.return': 806080150430990891}}]
In [33]: txs = list(filter(lambda tx: tx['type'] == 1, API.get_block(current_block - 2)['result']['transactions'])
...:
...: )
In [34]: txs
Out[34]:
[{'hash': 'Mt2617c07f25081818d8cd80020ba1f4b489190ae7dd9717d0b477217d373bb644',
'raw_tx': 'f88882117a01018a4249500000000000000001aceb8a42495000000000000000947ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc28a010f0cf064dd59200000808001b845f8431ba0282ef7194da4e0c4d24ef2dbf932fcbbb7cb3cce78a61528ac4d1e268d455214a074bbbfb3b4b72ad41a5e55073794820fab491bef4489acfd0d6af99d1f726fb9',
'from': 'Mxc7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'nonce': 4474,
'gas_price': 1,
'type': 1,
'data': {'coin': 'BIP',
'to': 'Mx7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2',
'value': 5000000000000000000000},
'payload': '',
'service_data': '',
'gas': 10,
'gas_coin': 'BIP',
'tags': {'tx.coin': 'BIP',
'tx.type': '01',
'tx.from': 'c7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'tx.to': '7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2'}},
{'hash': 'Mtc5c1ee6bc5a4805c1082433715cb2fa33b133e9fb6c675b809fb468c83c86552',
'raw_tx': 'f8d382057301018a4249500000000000000001abea8a4249500000000000000094086870ca15484e47ea631dd7bb4e4958888a31c98901380d641f454a1000b84bd092d0bed0b7d0b2d180d0b0d18220d181d180d0b5d0b4d181d18220d0bfd0be20d181d0bfd0b8d181d0b0d0bdd0b8d18e20d188d182d180d0b0d184d0b020d0bed182204269747465616d8001b845f8431ca0785a2349f1848055f3e9b51e6ff471de37aa5528c23cf033f73124b6391ee348a043fbc94f3eeecc9ee55f07f13e787156635960db16ba8666ba3bc84790df7874',
'from': 'Mx1d708e7121d08cf9174d2a79ec804aed320937ad',
'nonce': 1395,
'gas_price': 1,
'type': 1,
'data': {'coin': 'BIP',
'to': 'Mx086870ca15484e47ea631dd7bb4e4958888a31c9',
'value': 22485738600000000000},
'payload': '0JLQvtC30LLRgNCw0YIg0YHRgNC10LTRgdGCINC/0L4g0YHQv9C40YHQsNC90LjRjiDRiNGC0YDQsNGE0LAg0L7RgiBCaXR0ZWFt',
'service_data': '',
'gas': 160,
'gas_coin': 'BIP',
'tags': {'tx.type': '01',
'tx.from': '1d708e7121d08cf9174d2a79ec804aed320937ad',
'tx.to': '086870ca15484e47ea631dd7bb4e4958888a31c9',
'tx.coin': 'BIP'}}]
In [35]: txs = list(filter(lambda tx: tx['type'] == 1, API.get_block(current_block - 2)['result']['transactions']))
In [36]: addresses = [w.address for w in MinterWallets.objects.all()]
In [37]: len(addresses)
Out[37]: 4597
In [38]: txs[0]
Out[38]:
{'hash': 'Mt2617c07f25081818d8cd80020ba1f4b489190ae7dd9717d0b477217d373bb644',
'raw_tx': 'f88882117a01018a4249500000000000000001aceb8a42495000000000000000947ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc28a010f0cf064dd59200000808001b845f8431ba0282ef7194da4e0c4d24ef2dbf932fcbbb7cb3cce78a61528ac4d1e268d455214a074bbbfb3b4b72ad41a5e55073794820fab491bef4489acfd0d6af99d1f726fb9',
'from': 'Mxc7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'nonce': 4474,
'gas_price': 1,
'type': 1,
'data': {'coin': 'BIP',
'to': 'Mx7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2',
'value': 5000000000000000000000},
'payload': '',
'service_data': '',
'gas': 10,
'gas_coin': 'BIP',
'tags': {'tx.coin': 'BIP',
'tx.type': '01',
'tx.from': 'c7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'tx.to': '7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2'}}
In [39]: txs = list(filter(lambda tx: tx['type'] == 1 and tx['data']['to'] in addresses, API.get_block(current_block - 2)['result']['trans
...: actions']))
In [40]: txs
Out[40]: []
In [41]: txs = [{'hash': 'Mt2617c07f25081818d8cd80020ba1f4b489190ae7dd9717d0b477217d373bb644',
...: 'raw_tx': 'f88882117a01018a4249500000000000000001aceb8a42495000000000000000947ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc28a010f0cf06
...: 4dd59200000808001b845f8431ba0282ef7194da4e0c4d24ef2dbf932fcbbb7cb3cce78a61528ac4d1e268d455214a074bbbfb3b4b72ad41a5e55073794820fab
...: 491bef4489acfd0d6af99d1f726fb9',
...: 'from': 'Mxc7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
...: 'nonce': 4474,
...: 'gas_price': 1,
...: 'type': 1,
...: 'data': {'coin': 'BIP',
...: 'to': 'Mx7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2',
...: 'value': 5000000000000000000000},
...: 'payload': '',
...: 'service_data': '',
...: 'gas': 10,
...: 'gas_coin': 'BIP',
...: 'tags': {'tx.coin': 'BIP',
...: 'tx.type': '01',
...: 'tx.from': 'c7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
...: 'tx.to': '7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2'}}
...: ]
In [42]: txs
Out[42]:
[{'hash': 'Mt2617c07f25081818d8cd80020ba1f4b489190ae7dd9717d0b477217d373bb644',
'raw_tx': 'f88882117a01018a4249500000000000000001aceb8a42495000000000000000947ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc28a010f0cf064dd59200000808001b845f8431ba0282ef7194da4e0c4d24ef2dbf932fcbbb7cb3cce78a61528ac4d1e268d455214a074bbbfb3b4b72ad41a5e55073794820fab491bef4489acfd0d6af99d1f726fb9',
'from': 'Mxc7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'nonce': 4474,
'gas_price': 1,
'type': 1,
'data': {'coin': 'BIP',
'to': 'Mx7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2',
'value': 5000000000000000000000},
'payload': '',
'service_data': '',
'gas': 10,
'gas_coin': 'BIP',
'tags': {'tx.coin': 'BIP',
'tx.type': '01',
'tx.from': 'c7839fdb4a5b4fc2f6d3559f0a458bb1d5fd2f8d',
'tx.to': '7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2'}}]
In [43]: diff = {}
...: for tx in txs:
...: value = tx['data']['value']
...: coin = tx['data']['coin']
...: diff[tx['data']['to'], coin] = value
...:
...:
In [44]: diff
Out[44]: {('Mx7ec469c4f30e5c6c5a2b499ae0ed8a68efc8ddc2', 'BIP'): 5000000000000000000000}
In [45]: diff = {}
...: for tx in txs:
...: value = tx['data']['value']
...: coin = tx['data']['coin']
...: # save
...:
In [46]: class Service:
...: last_block = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment