コード例 #1
0
def test_witness_update():
    # TODO: Remove when witness_update is fixed.
    return
    wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
    c = Commit(steemd_instance=Steemd(nodes=[]), keys=[wif])

    signing_key = 'BMT1111111111111111111111111111111114T1Anm'
    props = {
        'account_creation_fee': '0.500 BMT',
        'maximum_block_size': 65536,
        'sbd_interest_rate': 0
    }

    rpc_error = None
    try:
        c.witness_update(signing_key=signing_key,
                         account='test',
                         props=props,
                         url='foo')
    except RPCError as e:
        rpc_error = str(e)
    else:
        raise Exception('expected RPCError')

    assert 'tx_missing_active_auth' in rpc_error
コード例 #2
0
def update_post():
    s = Steemd()
    now = datetime.datetime.now()
    users = User.objects.all()
    for user in users:
        posts = s.get_discussions_by_author_before_date(
            user.username, None, now.strftime("%Y-%m-%dT%H:%M"), 10)
        for post in posts:

            try:
                steem_post = Post.objects.get(slug=post.pop('root_permlink'))
                steem_post.update(post)

            except Post.DoesNotExist:

                pass
コード例 #3
0
ファイル: core.py プロジェクト: phoneman13/hivemind
def sync_from_steemd():
    s = Steemd()

    lbound = db_last_block() + 1
    ubound = s.last_irreversible_block_num

    start_num = lbound
    start_time = time.time()
    while lbound < ubound:
        to = min(lbound + 1000, ubound)
        blocks = s.get_blocks_range(lbound, to)
        lbound = to
        process_blocks(blocks)

        rate = (lbound - start_num) / (time.time() - start_time)
        print("[SYNC] Got block {} ({}/s) {}m remaining".format(
            to - 1, round(rate, 1), round((ubound - lbound) / rate / 60, 2)))
コード例 #4
0
ファイル: test_steemd.py プロジェクト: s-n-d-p/steem-python
def test_get_block():
    """ We should be able to fetch some blocks. """
    s = Steemd()

    for num in [1000, 1000000, 10000000, 20000000, 21000000]:
        b = s.get_block(num)
        assert b, 'block %d was blank' % num
        assert num == int(b['block_id'][:8], base=16)

    start = 21000000
    for num in range(start, start + 50):
        b = s.get_block(num)
        assert b, 'block %d was blank' % num
        assert num == int(b['block_id'][:8], base=16)

    non_existent_block = 99999999
    b = s.get_block(non_existent_block)
    assert not b, 'block %d expected to be blank' % non_existent_block
コード例 #5
0
def get_inbound_steem_transfers(account_name):
    nodes = ['https://api.steemit.com', 'https://gtg.steem.house:8090']
    set_shared_steemd_instance(Steemd(nodes=nodes))
    acc = Account('greenman')

    def filter(t):
        return t['to'] == account_name and float(
            t['amount'].split(' ')[0]) > .1

    return [t for t in acc.history(filter_by=['transfer']) if filter(t)]
コード例 #6
0
    def run(self):
        steemd_nodes = [
            'https://api.steemit.com',
        ]
        s = Steemd(nodes=steemd_nodes)
        b = Blockchain(s)
        while True:
            head_block_number = b.info()['head_block_number']
            end_block_num = int(head_block_number)

            start_block_num = end_block_num - 1
            block_infos = s.get_blocks(range(start_block_num, end_block_num))
            print('start from {start} to {end}'.format(start=start_block_num,
                                                       end=end_block_num))
            for block_info in block_infos:
                transactions = block_info['transactions']
                for trans in transactions:
                    operations = trans['operations']
                    self.data.put(operations)
            time.sleep(3)
コード例 #7
0
def test_transfer():
    wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
    c = Commit(steemd_instance=Steemd(nodes=[]), keys=[wif])

    rpc_error = None
    try:
        c.transfer('test2', '1.000', 'STEEM', 'foo', 'test')
    except RPCError as e:
        rpc_error = str(e)
    else:
        raise Exception('expected RPCError')

    assert 'tx_missing_active_auth' in rpc_error
コード例 #8
0
ファイル: tasks.py プロジェクト: avral/golosdata-mongo
def override_steemd():
    """override steemd node list for this worker"""
    from steem.steemd import Steemd
    from steem.instance import set_shared_steemd_instance

    global _custom_node

    if not _custom_node:
        steemd_nodes = [
            # GOLOS node
            os.getenv('GOLOS_NODE', 'https://ws.golos.io'),
        ]
        set_shared_steemd_instance(Steemd(nodes=steemd_nodes))
        _custom_node = True
コード例 #9
0
ファイル: serve.py プロジェクト: phoneman13/hivemind
def health():
    steemd = Steemd()
    last_db_block = db_last_block()
    last_irreversible_block = steemd.last_irreversible_block_num
    diff = last_irreversible_block - last_db_block
    if diff > app.config['hive.MAX_BLOCK_NUM_DIFF']:
        abort(
            500,
            'last irreversible block (%s) - highest db block (%s) = %s, > max allowable difference (%s)'
            % (last_irreversible_block, last_db_block, diff,
               app.config['hive.MAX_BLOCK_NUM_DIFF']))
    else:
        return dict(last_db_block=last_db_block,
                    last_irreversible_block=last_irreversible_block,
                    diff=diff,
                    timestamp=datetime.utcnow().isoformat())
コード例 #10
0
def test_claim_reward():
    wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
    c = Commit(steemd_instance=Steemd(nodes=[]), keys=[wif])

    rpc_error = None
    try:
        c.claim_reward_balance(account='test',
                               reward_steem='1.000 STEEM',
                               reward_vests='0.000000 VESTS',
                               reward_sbd='0.000 SBD')
    except RPCError as e:
        rpc_error = str(e)
    else:
        raise Exception('expected RPCError')

    assert 'tx_missing_posting_auth' in rpc_error
コード例 #11
0
ファイル: bots.py プロジェクト: steemfans/steemtools
def run():
    global start_block_num
    steemd_nodes = [
        steemd_url,
    ]
    s = Steemd(nodes=steemd_nodes)
    b = Blockchain(s)

    while True:
        head_block_number = b.info()['head_block_number']
        end_block_num = int(head_block_number)
        if start_block_num == 0:
            start_block_num = end_block_num - 3
        if start_block_num >= end_block_num:
            continue
        with futures.ThreadPoolExecutor(max_workers=worker_num) as executor:
            executor.submit(worker, start_block_num, end_block_num)
        start_block_num = end_block_num + 1
コード例 #12
0
def run():
    global start_block_num
    steemd_nodes = [
        'https://rpc.buildteam.io',
        'https://api.steemit.com',
    ]
    s = Steemd(nodes=steemd_nodes)
    b = Blockchain(s)

    while True:
        head_block_number = b.info()['head_block_number']
        end_block_num = int(head_block_number)
        if start_block_num == 0:
            start_block_num = end_block_num - 3
        if start_block_num >= end_block_num:
            continue
        with futures.ThreadPoolExecutor(max_workers=worker_num) as executor:
            executor.submit(worker, start_block_num, end_block_num)
        start_block_num = end_block_num + 1
        time.sleep(3)
コード例 #13
0
ファイル: watcher.py プロジェクト: ety001/dockerfile
def run():
    global start_block_num
    steemd_nodes = [
        steemd_url,
    ]
    s = Steemd(nodes=steemd_nodes)
    b = Blockchain(s)

    create_db()
    create_table()
    connect_db()

    start_block_num_from_db = get_start_num_from_db()
    if start_block_num_from_db != 0:
        start_block_num = start_block_num_from_db

    while True:
        head_block_number = b.info()['head_block_number']
        end_block_num = int(head_block_number)
        if start_block_num == 0:
            start_block_num = end_block_num - 3
        if start_block_num >= end_block_num:
            continue
        if end_block_num - start_block_num >= 50:
            while start_block_num < end_block_num:
                tmp_end_block_num = start_block_num + 50
                if tmp_end_block_num > end_block_num:
                    tmp_end_block_num = end_block_num
                with futures.ThreadPoolExecutor(
                        max_workers=worker_num) as executor:
                    executor.submit(worker, start_block_num, tmp_end_block_num)
                start_block_num = tmp_end_block_num + 1
        else:
            with futures.ThreadPoolExecutor(
                    max_workers=worker_num) as executor:
                executor.submit(worker, start_block_num, end_block_num)
            start_block_num = end_block_num + 1
コード例 #14
0
def test_witness_set_properties():
    wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
    c = Commit(steemd_instance=Steemd(nodes=[]),
               keys=[wif])

    signing_key = 'STM1111111111111111111111111111111114T1Anm'
    props = [
        ['account_creation_fee', 'd0070000000000000354455354530000'],
        ['key', ('032d2a4af3e23294e0a1d9dbc46e0272d'
                 '8e1977ce2ae3349527cc90fe1cc9c5db9')]
    ]

    rpc_error = None
    try:
        c.witness_set_properties(
            signing_key=signing_key,
            props=props,
            account='test')
    except RPCError as e:
        rpc_error = str(e)
    else:
        raise Exception('expected RPCError')

    assert 'tx_missing_other_auth' in rpc_error
コード例 #15
0
ファイル: priSBD.py プロジェクト: aitorres/priSBD
def fetch_sbd_balance(nodes, username):
    steemd = Steemd(nodes)
    balance = steemd.get_account(username)['sbd_balance']
    balance = balance.strip(' SBD')
    return float(balance)
コード例 #16
0
print(config)

#########################################
# Connections
#########################################

# steemd
#nodes = [
#    # 'http://192.168.1.50:8090',
#    os.environ['steem_node'] if 'steem_node' in os.environ else 'http://51.15.55.185:8090',
#]

nodes = config['steemd_nodes']

s = Steem(nodes)
d = Steemd(nodes)
b = Blockchain(steemd_instance=s, mode='head')
c = Converter(steemd_instance=s)

fullnodes = [
    'https://rpc.buildteam.io',
    'https://api.steemit.com',
]
fn = Steem(fullnodes)

# MongoDB
ns = os.environ['namespace'] if 'namespace' in os.environ else 'eostalk'
# mongo = MongoClient('mongodb://mongo')
mongo = MongoClient(config['mongo_url'])
db = mongo[ns]
コード例 #17
0
from steem.steemd import Steemd
from steem import Steem
from steem.instance import set_shared_steemd_instance
from steem.account import Account
from steembase.account import PrivateKey
from steembase.exceptions import AccountDoesNotExistsException
nodes = ['http://steemd.pevo.science']
custom_instance = Steemd(nodes=nodes)
set_shared_steemd_instance(custom_instance)

s = Steem(nodes)
w = s.wallet

file = open("k", "r")
for line in file:
    account_values = line.split(",")
    account = account_values[1].strip()
    key = account_values[0].strip()
    # print("key("+key+"),account("+account+")")
    try:
        acc = Account(account)
        privkey = PrivateKey(key)
        pubkey = privkey.pubkey
        print(account + "," + str(pubkey) + "," + str(privkey) + "," +
              str(w.getKeyType(acc, str(pubkey))))
    except AccountDoesNotExistsException:
        print("account " + account + " does not exists")
コード例 #18
0
ファイル: marshal.py プロジェクト: symbiotes/steem-moderation
import os

# Here you can modify the bot's prefix and description and wether it sends help in direct messages or not. @client.command is strongly discouraged, edit your commands into the command() function instead.
client = Bot(description="Server-Management-Bot",
             command_prefix='!',
             pm_help=True)

s = Steem()
steemd_nodes = [
    'https://api.steemit.com/',
    'https://gtg.steem.house:8090/',
    'https://steemd.steemitstage.com/',
    'https://steemd.steemgigs.org/'
    'https://steemd.steemit.com/',
]
set_shared_steemd_instance(Steemd(nodes=steemd_nodes))  # set backup API nodes

cmc = Market()  # Coinmarketcap API call.
ste_usd = cmc.ticker("steem", limit="3",
                     convert="USD")[0].get("price_usd", "none")
sbd_usd = cmc.ticker("steem-dollars", limit="3",
                     convert="USD")[0].get("price_usd", "none")

react_dict = {}

bot_role = 'marshal'  # Set a role for all of your bots here. You need to give them such role on the discord server.

allowed_channels = [
    '402402513321721857',  #review-linkdrop
    '399691348028030989'  # testing:
]
コード例 #19
0
ファイル: base.py プロジェクト: tokenika/eosprojects.org
    'rest_framework.pagination.LimitOffsetPagination',
    'PAGE_SIZE': 20
}

import datetime
DEPLOYMENT_DATETIME = environ.get('DEPLOYMENT_DATETIME',
                                  datetime.datetime.utcnow().isoformat())
GOOGLE_ANALYTICS_PROPERTY_ID = environ.get('GOOGLE_ANALYTICS_PROPERTY_ID')

ROCKET_CHAT_LOGIN = environ.get('ROCKET_CHAT_LOGIN')
ROCKET_CHAT_PASSWORD = environ.get('ROCKET_CHAT_PASSWORD')
ROCKET_CHAT_URL = environ.get('ROCKET_CHAT_URL')

STEEM_NODES = [node.strip() for node in environ.get('STEEM_NODES').split(',')]

set_shared_steemd_instance(Steemd(nodes=STEEM_NODES))

STEEM_NODES = [node.strip() for node in environ.get('STEEM_NODES').split(',')]

STEEM_ACCOUNT = environ.get('STEEM_ACCOUNT')
STEEM_POSTING_KEY = environ.get('STEEM_POSTING_KEY')

from steem.wallet import Wallet
Wallet(keys=[STEEM_POSTING_KEY])

PROJECT_GITHUB_REPOSITORY_URL = environ.get('PROJECT_GITHUB_REPOSITORY_URL')
if PROJECT_GITHUB_REPOSITORY_URL.endswith("/"):
    PROJECT_GITHUB_REPOSITORY_URL = PROJECT_GITHUB_REPOSITORY_URL[:-1]

PROJECT_SLUG_ON_PAGE = environ.get('PROJECT_SLUG_ON_PAGE')
コード例 #20
0
    ])


def get_block(block_num):
    req = json.dumps({
        "jsonrpc": "2.0",
        "id": 0,
        "method": "call",
        "params": [0, "get_ops_in_block", [block_num, False]]
    })
    res = requests.post('https://api.steemit.com', data=req).json()['result']
    return res


if __name__ == '__main__':
    s = Steemd(nodes=["https://api.steemit.com"])
    start_block_num = s.head_block_number
    time.sleep(7)
    last_block_num = s.head_block_number

    with suppress(KeyboardInterrupt):
        while True:
            # 블록에서 댓글(reply)만 가져오는 처리
            recent_blocks = read_block(start_block_num, last_block_num)
            replies = get_replies_from_blocks(recent_blocks)

            for reply in replies:
                print(reply)

            # 블록 번호 갱신
            start_block_num = last_block_num
コード例 #21
0
 def reconnect(self):
     """Creates a new Steemd and Commit"""
     self.steemd = Steemd(nodes=self.nodes.copy(), **self.kwargs.copy())
     self.commit = Commit(steemd_instance=self.steemd,
                          no_broadcast=self.no_broadcast,
                          **self.kwargs.copy())
コード例 #22
0
from steem.transactionbuilder import TransactionBuilder
from steembase import operations
from steembase.account import PrivateKey
from steembase.memo import get_shared_secret, init_aes, _pad, _unpad
from steem.utils import compat_bytes

from contextlib import suppress
from binascii import hexlify, unhexlify
from collections import OrderedDict
from datetime import datetime
import json

epoch = datetime.utcfromtimestamp(0)

steemd_nodes = ['http://127.0.0.1:8765']
set_shared_steemd_instance(Steemd(nodes=steemd_nodes))
custom_instance = Steemd(nodes=steemd_nodes)
pr = custom_instance.get_chain_properties()
wallet_instance = Wallet(steemd_instance=custom_instance)


def encrypt(priv, pub, nonce, message):
    shared_secret = get_shared_secret(priv, pub)
    aes, check = init_aes(shared_secret, nonce)
    raw = compat_bytes(message, 'utf8')
    " Padding "
    BS = 16
    if len(raw) % BS:
        raw = _pad(raw, BS)
    " Encryption "
    enc_msg = aes.encrypt(raw)
コード例 #23
0
ファイル: BaseTasks.py プロジェクト: steemfans/steem-lightdb
def get():
    # get db config
    config = utils.get_config()
    db_c = config['steem_config']
    # connect db
    db = pymysql.connect(host=db_c['host'],
                         user=db_c['user'],
                         password=db_c['pass'],
                         database=db_c['db'],
                         charset='utf8mb4',
                         cursorclass=pymysql.cursors.DictCursor,
                         autocommit=True)

    # check lost block first
    result = checkLostBlockCache(db, config)

    # get synced head_block_num
    sql = 'select block_num from block_cache order by block_num desc limit 1'
    with db.cursor() as cur:
        cur.execute(sql)
        res = cur.fetchone()
        if res == None:
            print('no_block_cache')
            curr_cache_head = 0
        else:
            curr_cache_head = int(res['block_num'])
    db.close()

    print('curr_cache_head: ', curr_cache_head)

    base_step = config['base_step']

    # get lastest block_num
    steemd_nodes = [
        'https://api.steemit.com',
        'https://rpc.buildteam.io',
        #'https://steemd.privex.io',
        #'https://rpc.steemviz.com',
    ]
    s = Steemd(nodes=steemd_nodes)
    b = Blockchain(s)

    head_block_number = int(b.info()['head_block_number'])
    print('blockchain_head', head_block_number)

    if head_block_number <= curr_cache_head:
        print('It is newest', head_block_number, latest_num)
        return []

    start_num = curr_cache_head + 1

    if head_block_number > start_num + 10000:
        end_num = start_num + 10000
    else:
        end_num = head_block_number

    i = start_num
    while i <= end_num:
        tmp_end_num = i + base_step
        if tmp_end_num >= end_num:
            tmp_end_num = end_num
        result.append({
            "task_type": "new_block",
            "content": range(i, tmp_end_num + 1)
        })
        i = tmp_end_num + 1

    return result
コード例 #24
0
ファイル: bots.py プロジェクト: steemfans/steemtools
print(api_url)
worker_num = env_dist.get('WORKER_NUM')
if worker_num == None:
    worker_num = 5
print('Worker num: %s' % (worker_num))
worker_num = int(worker_num)
env_block_num = env_dist.get('BLOCK_NUM')
if env_block_num == None:
    start_block_num = 0
else:
    start_block_num = int(env_block_num)

steemd_nodes = [
    steemd_url,
]
s = Steemd(nodes=steemd_nodes)
b = Blockchain(s)


def worker(start, end):
    global s, b
    print('start from {start} to {end}'.format(start=start, end=end))
    block_infos = s.get_blocks(range(start, end + 1))
    # print(block_infos)
    for block_info in block_infos:
        transactions = block_info['transactions']
        for trans in transactions:
            operations = trans['operations']
            for op in operations:
                if (op[0] == 'comment' and op[1]['parent_author'] != '') \
                    or op[0] == 'transfer' \
コード例 #25
0
ファイル: test_steemd.py プロジェクト: s-n-d-p/steem-python
def test_get_version():
    """ We should be able to call get_version on steemd """
    s = Steemd()
    response = s.call('get_version', api='login_api')
    version = response['blockchain_version']
    assert version[0:4] == '0.19'
コード例 #26
0
ファイル: base.py プロジェクト: steemfans/steem-lightdb
import queue
import threading
import pymysql

check_point_sum = 0
config = utils.get_config()
base_step = config['base_step']
base_thread_count = config['base_thread_count']

steemd_nodes = [
    'https://api.steemit.com',
    'https://rpc.buildteam.io',
    #'https://steemd.privex.io',
    #'https://rpc.steemviz.com',
]
s = Steemd(nodes=steemd_nodes, maxsize=base_step*base_thread_count)
b = Blockchain(s)

def processor(task_queue):
    global s, b, check_point_sum
    while task_queue.qsize():
        tasks = task_queue.get()
        print('get_blocks_start', tasks)
        task_start_time = time.time()
        try:
            block_infos = s.get_blocks(tasks['content'])
        except Exception as e:
            print('get_data_from_chain_failed:', tasks, e)
            return
    
        print('got_data', tasks)
コード例 #27
0
ファイル: test_steemd.py プロジェクト: kirkins/steem-python-1
def test_ensured_block_ranges():
    """ Post should load correctly if passed a dict or string identifier. """
    s = Steemd()
    assert list(pluck('block_num',
                      s.get_blocks_range(1000,
                                         2000))) == list(range(1000, 2000))
コード例 #28
0
ファイル: stream.py プロジェクト: toluwanicareer/sportherald
 def handle(self, *args, **options):
     s = Steemd()
     now = datetime.datetime.now()
     update_post()
コード例 #29
0
from steem.blog import Blog
from steembase.exceptions import PostDoesNotExist
from textblob import TextBlob
from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer
from sklearn.naive_bayes import MultinomialNB
from sklearn.svm import SVC, LinearSVC, NuSVC
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
from bs4 import BeautifulSoup

steemd_nodes = [
    'https://api.steemit.com/', 'https://gtg.steem.house:8090/',
    'https://steemd.steemitstage.com/', 'https://steemd.steemgigs.org/'
]
set_shared_steemd_instance(Steemd(nodes=steemd_nodes))

# private posting key from environment variable
POSTING_KEY = os.getenv('POMOCNIK_POSTING_KEY')


# removes markdown and html tags from text
def remove_html_and_markdown(text):
    return ''.join(BeautifulSoup(text, 'lxml').findAll(text=True))


def replace_white_spaces_with_space(text):
    return text.replace('\t', ' ').replace('\r', ' ').replace('\n', ' ')


def get_message_from_post(post):
コード例 #30
0
ファイル: test_steemd.py プロジェクト: s-n-d-p/steem-python
def test_get_dgp():
    """ We should be able to call get_dynamic_global_properties on steemd """
    s = Steemd()
    response = s.call('get_dynamic_global_properties', api='database_api')
    assert response['head_block_number'] > 20e6