You are viewing a single comment's thread from:

RE: Piston help

in #piston8 years ago

Below is the code i'm using to make the claims for multiple accounts. It's by no means polished, but it's working right now, to claim and show some basic account stats. I adapted parts of the votebot code from felixxx (and winfrey) to do this as i'm hoping to join the two scripts together when I have time. Hope it helps.

PS the accounts have been imported (same as in piston) when running the script it asks for the wallet passphrase to make the transaction on each account. I haven't looked into setting the unlock variable yet

from steem import Steem
from steem import converter
import time
import csv
from time import localtime

c = converter.Converter()


def claim():
    account = list_load('accounts.txt')
    posting_key = list_load('wif.txt')
    total_claimed = 0
    
    for (k,v) in enumerate(account):
            s = Steem(wif=posting_key[k])
            pre_account_info = s.get_account(v)
            rewards = float(pre_account_info['reward_vesting_steem'].split()[0])                        

            if rewards > 0:
                s.claim_reward_balance(account=v)
                status = 'Claimed Reward Balance of '
                total_claimed += rewards
            else:
                status = 'Nothing to claim '
                        
            post_account_info = s.get_account(v)
            follower_count = s.get_follow_count(v)
            vests = float(post_account_info['vesting_shares'].split()[0])
            steem_power = c.vests_to_sp(vests)
            
            print(timestamp_builder(), v, '<--', status, rewards, '\n',
                'Steem Power', steem_power, '\n',
                'Steem Balance', post_account_info['balance'],'\n',
                'Steem Savings', post_account_info['savings_balance'],'\n',
                'SBD Balance', post_account_info['sbd_balance'],'\n',
                'SBD Savings', post_account_info['savings_sbd_balance'],'\n',
                'Follower Count', follower_count['follower_count'], '\n\n')
                
    
            
    print('Total rewards claimed', total_claimed)
            

def list_load(listfile):
    with open(listfile, 'r') as readstuff:
        listvar= []
        reader= csv.reader(readstuff)
        for rows in reader:
            v= rows[0]
            listvar.append(v)   
    return listvar


def timestamp_builder(): 
    lt = localtime()
    timestamp = time.strftime("%d/%m/%Y-%H:%M:%S ", lt)
    return timestamp
    


if __name__ == "__main__":
    try:
        claim()
    except Exception as e:
        print("Exception ...")
            #traceback.print_exc()
Sort:  

Cool! Thanks. FWIW, I don't use "unlock," I just pass a list of keys to my Steem instance when I create it. I don't have a good sense of what's more secure.