from grapheneapi.grapheneclient import GrapheneClient
from pprint import pprint
import config
from datetime import datetime
import time


def formatTimeFromNow(secs=0):
    return datetime.utcfromtimestamp(time.time() +
                                     int(secs)).strftime('%Y-%m-%dT%H:%M:%S')


if __name__ == '__main__':
    client = GrapheneClient(config)
    core_asset = client.getObject("1.3.0")
    account = client.rpc.get_account(config.account)
    proposer = client.rpc.get_account(config.proposer)

    ops = []

    for asset_name in config.burn_assets:
        asset = client.rpc.get_asset(asset_name)
        amount = config.burn_assets[asset_name]

        op = client.rpc.get_prototype_operation("asset_reserve_operation")
        op[1]["payer"] = account["id"]
        op[1]["amount_to_reserve"]["asset_id"] = asset["id"]
        op[1]["amount_to_reserve"]["amount"] = int(amount *
                                                   10**asset["precision"])
        ops.append(op)
from grapheneapi.grapheneclient import GrapheneClient
import json
from deepdiff import DeepDiff

proposer   = "xeroc"
expiration = "2016-01-28T05:59:59"
broadcast  = False


class Wallet():
    wallet_host           = "localhost"
    wallet_port           = 8092

if __name__ == '__main__':
    graphene = GrapheneClient(Wallet)
    obj = graphene.getObject("2.0.0")
    current_fees = obj["parameters"]["current_fees"]["parameters"]
    old_fees = obj["parameters"]["current_fees"]
    scale = obj["parameters"]["current_fees"]["scale"] / 1e4

    # General change of parameter
    changes = {"limit_order_cancel": {
               "fee" : int(0.01 / scale * 1e5)
               }}

    print("=" * 80)
    tx = graphene.rpc.propose_fee_change(proposer, expiration, changes, broadcast)
    new_fees = tx["operations"][0][1]["proposed_ops"][0]["op"][1]["new_parameters"]["current_fees"]

    print(json.dumps(DeepDiff(old_fees, new_fees), indent=4))
class Config:
    wallet_host = "localhost"
    wallet_port = 8092
    witness_url = "wss://bitshares.openledger.info/ws"

    drain = "<asset>"
    account = "<asset-issuer>"


def formatTimeFromNow(secs=0):
    return datetime.utcfromtimestamp(time.time() + int(secs)).strftime("%Y-%m-%dT%H:%M:%S")


if __name__ == "__main__":
    config = Config
    client = GrapheneClient(config)

    account = client.rpc.get_account(config.account)
    asset = client.rpc.get_asset(config.drain)
    assetdyn = client.getObject(asset["dynamic_asset_data_id"])
    fee_pool = int(assetdyn["fee_pool"]) / 10 ** client.getObject("1.3.0")["precision"]

    op = client.rpc.get_prototype_operation("limit_order_create_operation")
    op[1]["fee"]["amount"] = int(fee_pool * 10 ** asset["precision"])
    op[1]["fee"]["asset_id"] = asset["id"]
    op[1]["seller"] = account["id"]
    op[1]["amount_to_sell"]["amount"] = 1
    op[1]["amount_to_sell"]["asset_id"] = asset["id"]
    op[1]["min_to_receive"]["amount"] = 1
    op[1]["min_to_receive"]["asset_id"] = "1.3.0"
    op[1]["expiration"] = formatTimeFromNow(60 * 60 * 12)
Exemple #4
0
from pprint import pprint


class Config():
    wallet_host           = "localhost"
    wallet_port           = 8092
    witness_url           = "wss://bitshares.openledger.info/ws"
    broadcast             = True


if __name__ == '__main__':

    asset = "TMPASSET"
    whitelist_accounts = ["null", "committee-account"]

    client = GrapheneClient(Config)
    asset = client.rpc.get_asset(asset)

    op = client.rpc.get_prototype_operation("asset_update_operation")
    op[1]["asset_to_update"] = asset["id"]
    op[1]["issuer"] = asset["issuer"]
    op[1]["new_options"] = asset["options"]

    whitelist_authorities = []
    for a in whitelist_accounts:
        ac = client.rpc.get_account(a)
        whitelist_authorities.append(ac["id"])

    op[1]["new_options"]["whitelist_authorities"] = whitelist_authorities
    buildHandle = client.rpc.begin_builder_transaction()
    client.rpc.add_operation_to_builder_transaction(buildHandle, op)
Exemple #5
0
import json

fee_paying_account = "xeroc"

data = "Foobar"


class Config():
    wallet_host = "localhost"
    wallet_port = 8092
    wallet_user = ""
    wallet_password = ""


if __name__ == '__main__':

    graphene = GrapheneClient(Config)
    payer = graphene.rpc.get_account(fee_paying_account)

    op = graphene.rpc.get_prototype_operation("custom_operation")
    op[1]["payer"] = payer["id"]
    op[1]["required_auths"] = [payer["id"]]
    op[1]["data"] = hexlify(bytes(data, 'utf-8')).decode('ascii')
    op[1]["id"] = int(16)

    handle = graphene.rpc.begin_builder_transaction()
    graphene.rpc.add_operation_to_builder_transaction(handle, op)
    graphene.rpc.set_fees_on_builder_transaction(handle, "1.3.0")
    tx = graphene.rpc.sign_builder_transaction(handle, False)
    print(json.dumps(tx, indent=4))
    wallet_host = "localhost"
    wallet_port = 8092
    witness_url = "wss://bitshares.openledger.info/ws"

    drain = "<asset>"
    account = "<asset-issuer>"


def formatTimeFromNow(secs=0):
    return datetime.utcfromtimestamp(time.time() +
                                     int(secs)).strftime('%Y-%m-%dT%H:%M:%S')


if __name__ == '__main__':
    config = Config
    client = GrapheneClient(config)

    account = client.rpc.get_account(config.account)
    asset = client.rpc.get_asset(config.drain)
    assetdyn = client.getObject(asset["dynamic_asset_data_id"])
    fee_pool = int(
        assetdyn["fee_pool"]) / 10**client.getObject("1.3.0")["precision"]

    op = client.rpc.get_prototype_operation("limit_order_create_operation")
    op[1]["fee"]["amount"] = int(fee_pool * 10**asset["precision"])
    op[1]["fee"]["asset_id"] = asset["id"]
    op[1]["seller"] = account["id"]
    op[1]["amount_to_sell"]["amount"] = 1
    op[1]["amount_to_sell"]["asset_id"] = asset["id"]
    op[1]["min_to_receive"]["amount"] = 1
    op[1]["min_to_receive"]["asset_id"] = "1.3.0"
from grapheneapi.grapheneclient import GrapheneClient
from pprint import pprint
import config
from datetime import datetime
import time


def formatTimeFromNow(secs=0):
    return datetime.utcfromtimestamp(time.time() + int(secs)).strftime(
        "%Y-%m-%dT%H:%M:%S"
    )


if __name__ == "__main__":
    client = GrapheneClient(config)
    core_asset = client.getObject("1.3.0")
    account = client.rpc.get_account(config.account)
    proposer = client.rpc.get_account(config.proposer)

    ops = []

    for assetname in config.refund_asset_pools:
        asset = client.rpc.get_asset(assetname)
        dynamic = client.getObject(asset["dynamic_asset_data_id"])
        fee_pool = dynamic["fee_pool"]

        difference = config.refund_target_amount * 10 ** core_asset["precision"] - int(
            fee_pool
        )

        if difference > 0:
from grapheneapi.grapheneclient import GrapheneClient
from grapheneapi.graphenewsprotocol import GrapheneWebsocketProtocol
class Config(GrapheneWebsocketProtocol):
    wallet_host           = "localhost"
    wallet_port           = 8092
    witness_url           = "wss://bitshares.openledger.info/ws"
    def onBlock(self, data) :
        print(data)
if __name__ == '__main__':
    r = GrapheneClient(Config)
    r.run()
Exemple #9
0
from grapheneapi.grapheneclient import GrapheneClient
from grapheneapi.graphenewsprotocol import GrapheneWebsocketProtocol


class Config(GrapheneWebsocketProtocol):
    wallet_host = "localhost"
    wallet_port = 8092
    witness_url = "wss://bitshares.openledger.info/ws"

    def onBlock(self, data):
        print(data)


if __name__ == '__main__':
    r = GrapheneClient(Config)
    r.run()
Exemple #10
0
from grapheneapi.grapheneclient import GrapheneClient
import json
from deepdiff import DeepDiff

proposer = "xeroc"
expiration = "2016-01-28T05:59:59"
broadcast = False


class Wallet:
    wallet_host = "localhost"
    wallet_port = 8092


if __name__ == "__main__":
    graphene = GrapheneClient(Wallet)
    obj = graphene.getObject("2.0.0")
    current_fees = obj["parameters"]["current_fees"]["parameters"]
    old_fees = obj["parameters"]["current_fees"]
    scale = obj["parameters"]["current_fees"]["scale"] / 1e4

    # General change of parameter
    changes = {"limit_order_cancel": {"fee": int(0.01 / scale * 1e5)}}

    print("=" * 80)
    tx = graphene.rpc.propose_fee_change(proposer, expiration, changes, broadcast)
    new_fees = tx["operations"][0][1]["proposed_ops"][0]["op"][1]["new_parameters"][
        "current_fees"
    ]

    print(json.dumps(DeepDiff(old_fees, new_fees), indent=4))
Exemple #11
0
from grapheneapi.grapheneclient import GrapheneClient
from pprint import pprint


class config():
    witness_url = "ws://testnet.bitshares.eu/ws"
    wallet_host = "localhost"
    wallet_port = 8092


if __name__ == '__main__':
    client = GrapheneClient(config)
    graphene = client.rpc

    # Get current fees
    core_asset = graphene.get_asset("1.3.0")
    committee_account = graphene.get_account("committee-account")
    proposals = client.ws.get_proposed_transactions(committee_account["id"])

    for proposal in proposals:
        print("Proposal: %s" % proposal["id"])

        prop_op = proposal["proposed_transaction"]["operations"]

        if len(prop_op) > 1:
            print(" - [Warning] This proposal has more than 1 operation")

        if graphene._confirm("Approve?"):
            tx = graphene.approve_proposal(
                "xeroc", proposal["id"], {
                    "active_approvals_to_add": [