def vesting(ctx, account): """ List accounts vesting balances """ account = Account(account, full=True) t = [["vesting_id", "claimable"]] for vest in account["vesting_balances"]: vesting = Vesting(vest) t.append([vesting["id"], str(vesting.claimable)]) print_table(t)
def vesting(ctx, account): """ List accounts vesting balances """ account = Account(account, full=True) t = PrettyTable(["vesting_id", "claimable"]) t.align = 'r' for vest in account["vesting_balances"]: vesting = Vesting(vest) t.add_row([vesting["id"], str(vesting.claimable)]) click.echo(str(t))
def claim(ctx, vestingid, account, amount): """ Claim funds from the vesting balance """ vesting = Vesting(vestingid) if amount: amount = Amount(float(amount), "BTS") else: amount = vesting.claimable pprint( ctx.bitshares.vesting_balance_withdraw(vesting["id"], amount=amount, account=vesting["owner"]))
def test_referrar(INSTANCE, cleartxpool): before = Vesting('1.13.0', bitshares_instance=INSTANCE).claimable reset_wallet(INSTANCE) createdAccount = create_accounts(INSTANCE)[0] if createdAccount == False: logging.info('create account error') assert 0 name = createdAccount['account'] logging.info("account %s has been created", name) activeKey = createdAccount['active']['wif_priv_key'] INSTANCE.wallet.addPrivateKey(activeKey) account = cybex.Account(name) amount = 20000 INSTANCE.transfer(name, amount, 'CYB', '', 'nathan') INSTANCE.upgrade_account(account=account) # fee to update an account to LTM fee = INSTANCE.fee[8]['fee']['membership_lifetime_fee'] / 100000 left = amount - fee assert cybex.Account(name).balance('CYB') == left # print(Vesting('1.13.0', bitshares_instance=self.instance).account['name']) after = Vesting('1.13.0', bitshares_instance=INSTANCE).claimable assert after > before
account = "alfredo-worker" proposer = "oxarbitrage.a699" vesting_id = "1.13.1608" bitshares = BitShares( nobroadcast=False, bundle=True, proposer=proposer, proposal_expiration=60 * 60 * 24 * 2, ) set_shared_bitshares_instance(bitshares) market = Market("USD:BTS") price = market.ticker()["quoteSettlement_price"] bitshares.wallet.unlock(getpass()) vesting = Vesting(vesting_id) print("Claiming Vesting Balance: %s" % vesting.claimable) bitshares.vesting_balance_withdraw(vesting["id"], amount=vesting.claimable, account=account) print("Buying as much bitUSD at price up to %s or %s" % (price * 0.90, (price * 0.90).copy().invert())) market.buy(price * 0.9, Amount(3200, "USD"), killfill=True, account=account) print("Worker alfredo payment - 15 days") bitshares.transfer("oxarbitrage.a699", 3200, "USD", account=account) pprint(bitshares.broadcast())
def votes(ctx, account, type): """ List accounts vesting balances """ if not isinstance(type, (list, tuple)): type = [type] account = Account(account, full=True) ret = {key: list() for key in Vote.types()} for vote in account["votes"]: t = Vote.vote_type_from_id(vote["id"]) ret[t].append(vote) t = [["id", "url", "account"]] for vote in ret["committee"]: t.append([ vote["id"], vote["url"], Account(vote["committee_member_account"])["name"] ]) if "committee" in type: t = [["id", "url", "account", "votes"]] for vote in ret["committee"]: t.append([ vote["id"], vote["url"], Account(vote["committee_member_account"])["name"], str( Amount({ "amount": vote["total_votes"], "asset_id": "1.3.0" })), ]) print_table(t) if "witness" in type: t = [[ "id", "account", "url", "votes", "last_confirmed_block_num", "total_missed", "westing", ]] for vote in ret["witness"]: t.append([ vote["id"], Account(vote["witness_account"])["name"], vote["url"], str( Amount({ "amount": vote["total_votes"], "asset_id": "1.3.0" })), vote["last_confirmed_block_num"], vote["total_missed"], str(Vesting(vote.get("pay_vb")).claimable) if vote.get("pay_vb") else "", ]) print_table(t) if "worker" in type: t = [["id", "name/url", "daily_pay", "votes", "time", "account"]] for vote in ret["worker"]: votes = Amount({ "amount": vote["total_votes_for"], "asset_id": "1.3.0" }) amount = Amount({"amount": vote["daily_pay"], "asset_id": "1.3.0"}) t.append([ vote["id"], "{name}\n{url}".format(**vote), str(amount), str(votes), "{work_begin_date}\n-\n{work_end_date}".format(**vote), str(Account(vote["worker_account"])["name"]), ]) print_table(t)