def main():

    parser = argparse.ArgumentParser(
        description='Scan account history looking for transfers',
        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',
        '--amount',
        type=float,
        default=0,
        help='minimal transfer amount to look for (default: 0)')
    parser.add_argument(
        '-l',
        '--limit',
        type=int,
        default=50,
        help='limit number of transactions to scan, default: 50')
    parser.add_argument('account', help='account to scan')
    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(nodes=conf['nodes_old'], keys=conf['keys'])

    account = Account(args.account, steemd_instance=golos)
    history = account.rawhistory(only_ops=['transfer'], limit=args.limit)

    for item in history:
        #pprint(item)

        timestamp = datetime.strptime(item[1]['timestamp'],
                                      '%Y-%m-%dT%H:%M:%S')
        t_from = item[1]['op'][1]['from']
        to = item[1]['op'][1]['to']
        amount = Amount(item[1]['op'][1]['amount'])

        if amount.amount > args.amount:
            print('{}: {:<16} -> {:<16}, {}'.format(timestamp, t_from, to,
                                                    amount))
Beispiel #2
0
def main(ctx, amount_limit, limit, account):
    """Scan account history looking for transfers."""

    account = Account(account)
    history = account.rawhistory(only_ops=['transfer'], limit=limit)

    for item in history:
        ctx.log.debug(pformat(item))

        timestamp = parse_time(item[1]['timestamp'])
        from_ = item[1]['op'][1]['from']
        to = item[1]['op'][1]['to']
        amount = Amount(item[1]['op'][1]['amount'])
        memo = item[1]['op'][1]['memo']

        if amount.amount > amount_limit:
            print('{}: {:<16} -> {:<16}, {}, {}'.format(timestamp, from_, to, amount, memo))
Beispiel #3
0
def main():

    parser = argparse.ArgumentParser(
        description=
        'Scan account history looking for author or curator payouts',
        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(
        '-t',
        '--type',
        default='author',
        choices=['author', 'curator'],
        help='reward type, "author" or "curator", default: author')
    parser.add_argument('account', help='account to scan')
    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)

    if args.type == 'author':
        ops = ['author_reward']
    elif args.type == 'curator':
        ops = ['curation_reward']

    golos = Steem(nodes=conf['nodes_old'], keys=conf['keys'])
    cv = Converter(golos)

    account = Account(args.account, steemd_instance=golos)
    history = account.rawhistory(only_ops=ops)

    for item in history:
        #pprint(item)

        permlink = item[1]['op'][1]['permlink']
        payout_timestamp = datetime.strptime(item[1]['timestamp'],
                                             '%Y-%m-%dT%H:%M:%S')

        sbd_payout = Amount(item[1]['op'][1]['sbd_payout'])
        steem_payout = Amount(item[1]['op'][1]['steem_payout'])
        vesting_payout = Amount(item[1]['op'][1]['vesting_payout'])
        gp = cv.vests_to_sp(vesting_payout.amount)

        golos_payout = steem_payout.amount + gp
        gpg_repr = sbd_payout.amount + functions.convert_golos_to_gbg(
            golos, golos_payout, price_source='market')

        print('{} {}: {} {} {:.3f} GP, GBG repr: {:.3f}'.format(
            payout_timestamp, permlink, sbd_payout, steem_payout, gp,
            gpg_repr))