def history(ctx, account, limit, type, csv, exclude, raw): """ Show history of an account """ from bitsharesbase.operations import getOperationNameForId header = ["#", "time (block)", "operation", "details"] if csv: import csv t = csv.writer(sys.stdout, delimiter=";") t.writerow(header) else: t = PrettyTable(header) t.align = "r" t.align["details"] = "l" for a in account: account = Account(a, bitshares_instance=ctx.bitshares) for b in account.history(limit=limit, only_ops=type, exclude_ops=exclude): block = BlockHeader(b["block_num"]) row = [ b["id"].split(".")[2], "%s (%s)" % (block.time(), b["block_num"]), "{} ({})".format(getOperationNameForId(b["op"][0]), b["op"][0]), pprintOperation(b) if not raw else json.dumps(b, indent=4), ] if csv: t.writerow(row) else: t.add_row(row) if not csv: click.echo(t)
def main(): ''' filename = "data.csv" #str(datetime.date()) f = open(filename, 'a') #f.write(HEADER) ''' account = Account(accountName) ''' market = Market("OPEN.ETH:BTS") for i in range(0, len(account.balances)): print (str(account.balances[i]).replace(' ',','), end =",") print (str(market.ticker()["latest"]).replace(' ', ','), end =",") ''' print(account.balances) print(account.openorders) i = 0 #1 this method not pulling past 100 operation event with limit set to for j in range(0, 10): for h in account.history(first=i): print(h) print(str(i)) i += 1 #2 not working for pulling all the trades, for some reason it keeps stopping at like 120 trades??? # How can I get them all? #for h in Market("BTS:OPEN.ETH").accounttrades( account=account, limit=10000000 ): # print(h) print("hi")
def account_info_refresh(): try: spending_account = Account(var_from_account_name.get(), blockchain_instance=blockchain) balances = spending_account.balances history = spending_account.history(limit=40) account_id = spending_account.identifier except AccountDoesNotExistsException: Logger.Write("ERROR: Specified account does not exist on BitShares network.") balances = [] history = [] account_id = "" frameAssets.setBalances(balances) frameHistory.setHistory(history, account_id)
def account_history(account_name: hug.types.text, api_key: hug.types.text, hug_timer=5): """Given a valid account name, output the user's history in JSON.""" if (check_api_token(api_key) == True): # Check the api key # API KEY VALID try: target_account = Account(account_name) except: # Accoun is not valid! return { 'valid_account': False, 'account': account_name, 'valid_key': True, 'took': float(hug_timer) } target_account_history = target_account.history(first=0, last=100, limit=100) tx_container = [] for transaction in target_account_history: tx_container.append(transaction) if (len(tx_container) > 0): return { 'tx_history': tx_container, 'account_has_tx_history': True, 'account': account_name, 'valid_account': True, 'valid_key': True, 'took': float(hug_timer) } else: return { 'account_has_tx_history': False, 'account': account_name, 'valid_account': True, 'valid_key': True, 'took': float(hug_timer) } else: # API KEY INVALID! return {'valid_key': False, 'took': float(hug_timer)}
def test_account(self): Account("init0") Account("1.2.3") account = Account("init0", full=True) self.assertEqual(account.name, "init0") self.assertEqual(account["name"], account.name) self.assertEqual(account["id"], "1.2.100") self.assertIsInstance(account.balance("1.3.0"), Amount) # self.assertIsInstance(account.balance({"symbol": symbol}), Amount) self.assertIsInstance(account.balances, list) for _ in account.history(limit=1): pass # BlockchainObjects method account.cached = False self.assertTrue(account.items()) account.cached = False self.assertIn("id", account) account.cached = False self.assertEqual(account["id"], "1.2.100") self.assertTrue(str(account).startswith("<Account ")) self.assertIsInstance(Account(account), Account)
def history(ctx, account, limit, type, csv, exclude, raw): """ Show history of an account """ from bitsharesbase.operations import getOperationNameForId t = [["#", "time (block)", "operation", "details"]] for a in account: account = Account(a, bitshares_instance=ctx.bitshares) for b in account.history( limit=limit, only_ops=type, exclude_ops=exclude ): block = BlockHeader(b["block_num"]) row = [ b["id"].split(".")[2], "%s (%s)" % (block.time(), b["block_num"]), "{} ({})".format(getOperationNameForId(b["op"][0]), b["op"][0]), pprintOperation(b) if not raw else json.dumps(b, indent=4), ] t.append(row) print_table(t)
def history(ctx, account, limit, type, csv, exclude, raw, memo): """ Show history of an account """ from bitsharesbase.operations import getOperationNameForId if memo: pwd = click.prompt("Current Wallet Passphrase", hide_input=True) ctx.bitshares.wallet.unlock(pwd) t = [["#", "time (block)", "operation", "details"]] for a in account: account = Account(a, bitshares_instance=ctx.bitshares) for b in tqdm(account.history(limit=limit, only_ops=type, exclude_ops=exclude)): block = BlockHeader(b["block_num"]) row = [ b["id"], "%s (%s)" % (block.time(), b["block_num"]), "{} ({})".format(getOperationNameForId(b["op"][0]), b["op"][0]), pprintOperation(b, memo, ctx) if not raw else json.dumps(b, indent=4), ] t.append(row) print_table(t)
def test_account(self): Account("witness-account") Account("1.2.3") asset = Asset("1.3.0") symbol = asset["symbol"] account = Account("witness-account", full=True) self.assertEqual(account.name, "witness-account") self.assertEqual(account["name"], account.name) self.assertEqual(account["id"], "1.2.1") self.assertIsInstance(account.balance("1.3.0"), Amount) # self.assertIsInstance(account.balance({"symbol": symbol}), Amount) self.assertIsInstance(account.balances, list) for h in account.history(limit=1): pass # BlockchainObjects method account.cached = False self.assertTrue(account.items()) account.cached = False self.assertIn("id", account) account.cached = False self.assertEqual(account["id"], "1.2.1") self.assertEqual(str(account), "<Account 1.2.1>") self.assertIsInstance(Account(account), Account)
import bitshares import datetime import time from bitshares.account import Account from bitshares.market import Market accountName = "jr-12" #Change this to your account filename = "dataPull.csv" #str(datetime.date()) f = open(filename, 'a') account = Account(accountName) f.write(str(account.balances)) f.write(str(account.openorders)) for h in account.history(): f.write(str(h)) f.close()
return ("METAFEES") if asset_id == "1.3.592": return ("METAEX.BTC") if asset_id == "1.3.839": return ("SHAREBIT") if asset_id == "1.3.539": return ("MKRCOIN") for acc in accounts: account = Account(acc, full=True) records = [] print("Working with account: %s" % acc) file_name = acc + "_bitshares_account_history.json" transactions = account.history(first=0, limit=10000000) count = 0 with open(file_name, "w") as outfile: seen = [] for record in transactions: count = count + 1 timestamp = get_time_of_block(record['block_num']) op = record['op'] #0 Transfer btsabc.org sent 10 IOU.XFQ to nikolai #1 Order wants 150 CNY for 5,540 BTS #2 Cancel nikolai cancel order #3 Adj. Short nikolai adjust collateral by 42,649 BTS, debt by 0 USD #4 Fill nikolai paid 1.36 OPEN.USD for 1.412 USD #6 Update Slate nikolai update account/votes #14 Issue Asset btcto100k issue 20 FAISAL to nikolai
from getpass import getpass from bitshares.price import Price from bitshares.market import Market from bitshares.account import Account from bitsharesbase import memo as BtsMemo from bitshares.account import Account from bitsharesbase.account import PrivateKey, PublicKey import json # import re # import pendulum import requests account_b20 = Account("bittwenty.feed") account_history_b20 = account_b20.history(0, 10, 20) # `announce`-user memo privkey to decypher memo msgs: 5KJJNfiSyzsbHoVb81WkHHjaX2vZVQ1Fqq5wE5ro8HWXe6qNFyQ wifkey_announce = "5KJJNfiSyzsbHoVb81WkHHjaX2vZVQ1Fqq5wE5ro8HWXe6qNFyQ" def is_valid_bit20_publication(trx): """ check that the transaction is a valid one, ie: - it contains a single operation - it is a transfer from 'bittwenty' (1.2.111226) to 'bittwenty.feed' (1.2.126782) note: this does not check the contents of the transaction, it only authenticates it """ try: