示例#1
0
class User:
    def __init__(self, login="******", password="******"):
        self.steem_instance_ = Steem(node="wss://ws.testnet3.golos.io",
                                     rpcuser=login,
                                     rpcpassword=password)
        self.user_ = account.Account(account_name=login,
                                     steem_instance=self.steem_instance_)
        print(self.user_.get('name'))

    def get_posts(self, limit=10, sort="active", category=None, start=None):
        # list of dicts
        return self.steem_instance_.get_posts(limit=limit,
                                              sort=sort,
                                              category=category,
                                              start=start)

    # cause of Golos API doesnt work
    def get_user_posts(self):
        return self.steem_instance_.get_blog(self.user_.get('name'))

    def post(self, title, body, category=None, tags=[]):

        self.steem_instance_.post(title,
                                  body,
                                  author=self.user_.get('name'),
                                  category=category,
                                  tags=tags)
示例#2
0
 def __init__(self, login="******", password="******"):
     self.steem_instance_ = Steem(node="wss://ws.testnet3.golos.io",
                                  rpcuser=login,
                                  rpcpassword=password)
     self.user_ = account.Account(account_name=login,
                                  steem_instance=self.steem_instance_)
     print(self.user_.get('name'))
示例#3
0
 def __init__(
         self,
         login="******",
         password="******"):
     self.steem_instance_ = Steem(node="wss://ws.testnet3.golos.io",
                                  rpcuser=login,
                                  rpcpassword=password)
     self.user_ = account.Account(account_name=login,
                                  steem_instance=self.steem_instance_)
示例#4
0
 def post_to_golos(self, is_repeat_request=False):
     """
     Method to post pages to Golos
     """
     # steem = Steem(node=settings.NODE_URL, wif=settings.POSTING_KEY)
     steem = Steem(
         node='wss://ws.golos.io',
         wif='5JgEDJqUKLSK6sD2rCqaPxZ2YAyaxTXmcqmp14WtWJ2BCpFzh4o')
     try:
         if settings.POST_TO_BLOCKCHAIN:
             steem.post(title=self.title,
                        body=self.build_body_for_golos(),
                        author=settings.POST_AUTHOR,
                        category=settings.POST_AUTHOR,
                        meta=self.metadata)
         self.is_published = True
     except Exception as e:
         print(e)
         self.is_published = False
     if is_repeat_request:
         self.save()
示例#5
0
def feed():
    steem = Steem()    

    url = "/@eroche/where-have-all-the-votes-gone"
    
    text_file = open("voting_history.txt","w")

    text_file.write("Post: %s\n" %url + "Began Recording at " + datetime.utcnow().strftime("%H:%M:%S") + "\n############################\n")

    end_time = datetime.utcnow() + timedelta(minutes=1)    

    #Finish Script after 60 seconds,
    #you could set this to 2 hours or 5 hours to track a post over a longer time
    t_end = time.time() + 60 * 5

    #Loop and every 10 seconds print the value of the post to a file
    while time.time() < t_end:
        print("Running...")
        text_file.write(datetime.utcnow().strftime("%H:%M:%S")  + "\t")
        text_file.write("%f" %steem.get_post(url)["pending_payout_value"] + "\n")
        time.sleep(10)
    
    #When the program has finished running save and close the file
    text_file.close()
示例#6
0
def main():

    parser = argparse.ArgumentParser(
        description='transfer',
        epilog='Report bugs to: https://github.com/bitfag/golos-scripts/issues'
    )
    parser.add_argument('-d',
                        '--debug',
                        action='store_true',
                        help='enable debug output'),
    parser.add_argument('--broadcast',
                        action='store_true',
                        default=False,
                        help='broadcast transactions'),
    parser.add_argument('-c',
                        '--config',
                        default='./common.yml',
                        help='specify custom path for config file')
    parser.add_argument('f', help='from'),
    parser.add_argument('to', help='to'),
    parser.add_argument('amount', help='amount'),
    parser.add_argument('asset', help='asset'),
    parser.add_argument('memo', help='memo'),

    args = parser.parse_args()

    # create logger
    if args.debug == True:
        log.setLevel(logging.DEBUG)
    else:
        log.setLevel(logging.INFO)
    handler = logging.StreamHandler()
    formatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s")
    handler.setFormatter(formatter)
    log.addHandler(handler)

    # parse config
    with open(args.config, 'r') as ymlfile:
        conf = yaml.load(ymlfile)

    # initialize steem instance
    log.debug('broadcast: %s', args.broadcast)
    # toggle args.broadcast
    b = not args.broadcast
    golos = Steem(node=conf['nodes_old'], nobroadcast=b, keys=conf['keys'])

    transfer(golos, args.f, args.to, args.amount, args.asset, args.memo)
示例#7
0
class Man:
    def __init__(
            self,
            login="******",
            password="******"):
        self.steem_instance_ = Steem(node="wss://ws.testnet3.golos.io",
                                     rpcuser=login,
                                     rpcpassword=password)
        self.user_ = account.Account(account_name=login,
                                     steem_instance=self.steem_instance_)

    def get_posts(self, limit=10, sort="active", category=None, start=None):
        # list of dicts
        return self.steem_instance_.get_posts(limit=limit,
                                              sort=sort,
                                              category=category,
                                              start=start)

    def get_user_posts(self, ):
        pass
def main():

    parser = argparse.ArgumentParser(
        description='Calculate actual voting power',
        epilog='Report bugs to: https://github.com/bitfag/golos-scripts/issues'
    )
    parser.add_argument('-d',
                        '--debug',
                        action='store_true',
                        help='enable debug output'),
    parser.add_argument('-c',
                        '--config',
                        default='./common.yml',
                        help='specify custom path for config file')
    parser.add_argument('account',
                        help='specify account which VP should be estimated')

    args = parser.parse_args()

    # create logger
    if args.debug == True:
        log.setLevel(logging.DEBUG)
    else:
        log.setLevel(logging.INFO)
    handler = logging.StreamHandler()
    formatter = logging.Formatter("%(levelname)s: %(message)s")
    handler.setFormatter(formatter)
    log.addHandler(handler)

    # parse config
    with open(args.config, 'r') as ymlfile:
        conf = yaml.load(ymlfile)

    golos = Steem(node=conf['nodes_old'], keys=conf['keys'])
    vp = functions.get_voting_power(golos, args.account)
    log.info('VP of {}: {:.2f}'.format(args.account, vp))
示例#9
0
def main():

    parser = argparse.ArgumentParser(
        description='Estimate current bandwidth usage for an account',
        epilog='Report bugs to: https://github.com/bitfag/golos-scripts/issues'
    )
    parser.add_argument('-c',
                        '--config',
                        default='./common.yml',
                        help='specify custom path for config file')
    parser.add_argument(
        '-t',
        '--type',
        default='market',
        choices=['market', 'forum'],
        help=
        'bandwidth type to estimate. Market - transfers, forum - posting ops')
    parser.add_argument(
        '-w',
        '--warning',
        default=99,
        type=float,
        help=
        'exit with 1 error code whether bandwidth exceeded specified percent')
    parser.add_argument(
        'account', help='specify account which bandwidth should be estimated')

    verbosity_args = parser.add_mutually_exclusive_group()
    verbosity_args.add_argument(
        '-q',
        '--quiet',
        action='store_true',
        help=
        'do not show any output except errors, just return 0 if has_bandwidth or 1 if not'
    )
    verbosity_args.add_argument('-d',
                                '--debug',
                                action='store_true',
                                help='enable debug output')
    args = parser.parse_args()

    # create logger
    if args.debug == True:
        log.setLevel(logging.DEBUG)
    else:
        log.setLevel(logging.INFO)
    if args.quiet == True:
        log.setLevel(logging.CRITICAL)

    handler = logging.StreamHandler()
    #formatter = logging.Formatter("%(levelname)s: %(message)s")
    #handler.setFormatter(formatter)
    log.addHandler(handler)

    # parse config
    with open(args.config, 'r') as ymlfile:
        conf = yaml.load(ymlfile)

    golos = Steem(node=conf['nodes_old'], keys=conf['keys'])

    ratio = functions.get_bandwidth(golos, args.account, args.type)

    if ratio > args.warning:
        log.warning(
            'bandwidth usage ratio execeeded limit: {:.2f}'.format(ratio))
        sys.exit(1)
    else:
        sys.exit(0)
示例#10
0
from piston import Steem
from piston.account import Account
from piston.post import Post
import datetime
import time
import csv
import sys

from pprint import pprint

skipyear = 2017
lastyear = 2016
user = '******'
s = Steem(['wss://steemd.pevo.science'])

prices = 'btcusd_investingcom.csv'
eurusd = 'eurusd_investingcom.csv'


# Hilfsfunktion für Dateien
def csv_to_list(filename, options):
    #Datei lesend öffnen
    with open(filename, 'r') as f:
        #Liste erstellen
        res = list(csv.reader(f))

        #Titel entfernen
        if 'purgeTitle' in options and options['purgeTitle'] == 1:
            del res[0]

        #aufsteigend nach Datum sortieren
示例#11
0
import time

votewith = 'accountname'
wif = '5...'
node = 'ws://steemd.pevo.science:8090'

follow = {
    'curator1': 0.1,  # follow with 10% of curator's weight
    'curator2': 10  # follow with 10% fixed
}

clones = {'curator1': ['sockpuppet1', 'sockpuppet2']}

except_authors = ['spammer', 'plagiarizer']

client = Steem(node=node, wif=wif)
blockchain = Blockchain()
rpc = SteemNodeRPC(node)
conn = sqlite3.connect('bot.db')
c = conn.cursor()


def main(lastblock):
    thisblock = blockchain.get_current_block_num()
    if lastblock == thisblock:
        return thisblock

    for op in blockchain.ops(lastblock + 1, thisblock):
        type = op['op'][0]
        op = op['op'][1]
        op['type'] = type
示例#12
0
def main():

    parser = argparse.ArgumentParser(
        description=
        'This script is for changing account keys. By default, random password are geneeated.',
        epilog='Report bugs to: https://github.com/bitfag/golos-scripts/issues'
    )
    parser.add_argument('-d',
                        '--debug',
                        action='store_true',
                        help='enable debug output'),
    parser.add_argument('-c',
                        '--config',
                        default='./common.yml',
                        help='specify custom path for config file')
    parser.add_argument('account', help='account name'),
    parser.add_argument('-p', '--password',
                        help='manually specify a password'),
    args = parser.parse_args()

    # create logger
    if args.debug == True:
        log.setLevel(logging.DEBUG)
    else:
        log.setLevel(logging.INFO)
    handler = logging.StreamHandler()
    formatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s")
    handler.setFormatter(formatter)
    log.addHandler(handler)

    # parse config
    with open(args.config, 'r') as ymlfile:
        conf = yaml.load(ymlfile)

    golos = Steem(node=conf['nodes_old'], nobroadcast=False, keys=conf['keys'])
    account_name = args.account
    account = Account(args.account, steem_instance=golos)

    # random password
    if args.password:
        password = args.password
    else:
        password = functions.generate_password()

    print('password: {}\n'.format(password))

    key = dict()
    for key_type in key_types:

        # PasswordKey object
        k = PasswordKey(account_name, password, role=key_type)

        privkey = k.get_private_key()
        print('{} private: {}'.format(
            key_type, str(privkey)))  # we need explicit str() conversion!

        # pubkey with default prefix GPH
        pubkey = k.get_public_key()

        # pubkey with correct prefix
        key[key_type] = format(pubkey, golos.rpc.chain_params["prefix"])
        print('{} public: {}\n'.format(key_type, key[key_type]))

    # prepare for json format
    owner_key_authority = [[key['owner'], 1]]
    active_key_authority = [[key['active'], 1]]
    posting_key_authority = [[key['posting'], 1]]
    owner_accounts_authority = []
    active_accounts_authority = []
    posting_accounts_authority = []

    s = {
        'account': account_name,
        'memo_key': key['memo'],
        'owner': {
            'account_auths': owner_accounts_authority,
            'key_auths': owner_key_authority,
            'weight_threshold': 1
        },
        'active': {
            'account_auths': active_accounts_authority,
            'key_auths': active_key_authority,
            'weight_threshold': 1
        },
        'posting': {
            'account_auths': posting_accounts_authority,
            'key_auths': posting_key_authority,
            'weight_threshold': 1
        },
        'prefix': golos.rpc.chain_params["prefix"]
    }

    #pprint(s)
    op = operations.Account_update(**s)

    golos.finalizeOp(op, args.account, "owner")
from piston import Steem
from piston.witness import Witness
from pistonbase import transactions
from pistonapi.steemnoderpc import SteemNodeRPC

from smtplib import SMTP_SSL as SMTP
from email.mime.text import MIMEText

import json
import time
import sys


text_subtype = "plain"
client = Steem()
rpc = SteemNodeRPC(rpcnode)

def sendmail(content,subject):
  try:
    msg = MIMEText(content, text_subtype)
    msg['Subject']= subject
    msg['From']   = sender

    conn = SMTP(SMTPserver)
    conn.set_debuglevel(False)
    conn.login(SMTPuser, SMTPpass)
    try:
        conn.sendmail(sender, destination, msg.as_string())
    finally:
        conn.quit()
示例#14
0
from piston import Steem
from piston.block import Block
from pistonbase import transactions
from pistonapi.steemnoderpc import SteemNodeRPC
import sqlite3
import json
import sys

#config
watching = 'steemdice1'

wif = ''
node = 'wss://steemd.pevo.science'
client = Steem(node)
rpc = SteemNodeRPC(node)

conn = sqlite3.connect('dice.db')
c = conn.cursor()

checkblocks = 1000

def transfer(sender,recipient,amount,memo):
  expiration = transactions.formatTimeFromNow(60)
  op = transactions.Transfer(
    **{"from": sender,
       "to": recipient,
       "amount": amount,
       "memo": memo}
  )
  ops    = [transactions.Operation(op)]
  ref_block_num, ref_block_prefix = transactions.getBlockParams(rpc)
示例#15
0
def main():

    parser = argparse.ArgumentParser(
            description='Use this script to estimate potential upvote profit',
            epilog='Report bugs to: https://github.com/bitfag/golos-scripts/issues')
    parser.add_argument('-d', '--debug', action='store_true',
            help='enable debug output'),
    parser.add_argument('-c', '--config', default='./common.yml',
            help='specify custom path for config file')
    parser.add_argument('-a', '--account',
            help='specify account which upvote should be estimated')
    parser.add_argument('-p', '--percent', default=100, type=float,
            help='specify upvote percent')
    parser.add_argument('url',
            help='post id in format @author/article or full url')
    args = parser.parse_args()

    # create logger
    if args.debug == True:
        log.setLevel(logging.DEBUG)
    else:
        log.setLevel(logging.INFO)
    handler = logging.StreamHandler()
    formatter = logging.Formatter("%(levelname)s: %(message)s")
    handler.setFormatter(formatter)
    log.addHandler(handler)

    # parse config
    with open(args.config, 'r') as ymlfile:
        conf = yaml.load(ymlfile)

    golos = Steem(node=conf['nodes_old'], keys=conf['keys'])

    # extract author and post permlink from args.url
    p = re.search('@(.*?)/([^/]+)', args.url)
    if p == None:
        log.critical('Wrong post id specified')
        sys.exit(1)
    else:
        author = p.group(1)
        log.debug('author: {}'.format(author))

        post_permlink = p.group(2)
        log.debug('permlink: {}'.format(post_permlink))


    post = functions.get_post_content(golos, author, post_permlink)
    if not post:
        log.critical('could not find post in blockchain')
        sys.exit(1)

    # current post rshares
    net_rshares = int(post['net_rshares'])

    # current pending_payout_value, GBG
    current_pending_payout_value = post['pending_payout_value']
    log.info('current pending_payout_value: {}'.format(current_pending_payout_value))

    # estimate current expected author reward
    author_payout_gp, author_payout_gbg, author_payout_golos = functions.estimate_author_payout(golos, current_pending_payout_value)
    log.info('estimated author payout: {:.3f} GBG, {:.3f} GOLOS, {:.3f} GP'.format(
        author_payout_gbg, author_payout_golos, author_payout_gp))

    rshares = functions.calc_rshares(golos, args.account, args.percent)
    new_rshares = net_rshares + rshares

    new_payout = functions.calc_payout(golos, new_rshares)
    new_payout_gbg = functions.convert_golos_to_gbg(golos, new_payout, price_source='median')
    new_payout_gbg = Amount('{} GBG'.format(new_payout_gbg))
    log.info('new pending_payout_value: {}'.format(new_payout_gbg))

    payout_diff = new_payout_gbg.amount - current_pending_payout_value.amount
    log.info('pending_payout diff: {:.3f}'.format(payout_diff))

    # estimate new author reward
    author_payout_gp, author_payout_gbg, author_payout_golos = functions.estimate_author_payout(golos, new_payout_gbg)
    log.info('new estimated author payout: {:.3f} GBG, {:.3f} GOLOS, {:.3f} GP'.format(
        author_payout_gbg, author_payout_golos, author_payout_gp))
示例#16
0
#create this db
db = client.heroku_4j3zgpqc

#create collection
collection = db.iamgrootbot_collection

steemPostingKey = os.environ.get('steemPostingKey')
steemAccountName = os.environ.get('steemAccountName')

votewith = steemAccountName
wif = steemPostingKey
node = 'ws://steemd.pevo.science:8090'

print('voting with: '+votewith+ ' and wif: '+wif)
steem = Steem(wif = steemPostingKey)
tags = ["life","steemit","photography","kry","art","bitcoin","introduceyourself","travel","blog","food","cryptocurrency","steem","spanish","news","funny","nature","money","story","writing","colorchallenge","music","health","cn","poetry","politics","love","indonesia","science","technology","video","introducemyself","crypto","aceh","blockchain","philosophy","meme","deutsch","gaming","photo","contest","history","animals","steemitphotochallenge","ethereum","kr-newbie","fun","drawing","steemit-health","freedom"]
past_authors = ["riounh34","alex-icey","amvanaken","djneontiger","midgetspinner","bubusik","amirl","hauntedbrain","riounh34","dtworker"]

for p in steem.stream_comments():
    for x in tags:
        try:
            if x in p["tags"] and collection.find({"author": p["author"]}).count() != 1 and p["author"] not in past_authors:
                #print(p.get_comments())
                print("Author of post: "+p["author"])
                post = p.reply(body = "I am Groot! :D", author = steemAccountName)
                print("comment on post done.")
                autherofpost = {"author": p["author"]}
                insert_id = collection.insert_one(autherofpost).inserted_id
                print("inserted id :"+ str(insert_id))
                #p.upvote(weight=100)
示例#17
0
import asyncio
import websockets
import time
import sys
import random
import os
from pistonbase import operations
from collections import OrderedDict
from piston.transactionbuilder import TransactionBuilder
from graphenebase import base58
from piston import Steem

import config

st = Steem(keys=config.wif)

tx = TransactionBuilder()
tx.appendOps(
    operations.Witness_update(
        **{
            "owner": config.owner,
            "url": config.witnessthread,
            "block_signing_key": config.block_signing_public_key,
            "props": {
                "account_creation_fee": config.account_creation_fee,
                "maximum_block_size": config.maximum_block_size,
                "sbd_interest_rate": config.sbd_interest_rate
            },
            "fee": config.fee,
        }))
示例#18
0
import random
from pprint import pprint
import requests
import simplejson as json
import asyncio
import websockets
import time
from pistonbase import operations
from collections import OrderedDict
from piston.transactionbuilder import TransactionBuilder
from graphenebase import base58
from piston import Steem

import config

st = Steem(keys=[config.wif], node=config.node)

old_price = "999999.999"

while True:
    print("[" + str(time.time()) + "] Checking coinmarketcap...")

    r_cmc = requests.get("https://api.coinmarketcap.com/v1/ticker/")

    result_cmc = json.loads(r_cmc.text)

    for i in result_cmc:
        if (i['id'] == 'steem'):
            price_usd = i['price_usd']
            formatted_price = "{0:.3f}".format(float(i['price_usd']))
            if (formatted_price != old_price):