示例#1
0
def main(debug, config, wallet_password, buy_only, sell_only, market, account):

    if buy_only and sell_only:
        log.critical('--buy-only and --sell-only are mutually exclusive')
        sys.exit(1)

    # create logger
    if 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
    conf = yaml.safe_load(config)

    bitshares = BitShares(node=conf['node_bts'])

    # Wallet unlock
    try:
        bitshares.unlock(wallet_password)
    except WrongMasterPasswordException:
        log.critical('Wrong wallet password provided')
        sys.exit(1)

    account = Account(account, blockchain_instance=bitshares)
    orders = [order for order in account.openorders if 'id' in order]

    if market:
        market = Market(market, blockchain_instance=bitshares)
        market_ids = [market['base']['symbol'], market['quote']['symbol']]
        orders = [
            order
            for order in orders
            if order['base']['symbol'] in market_ids and order['quote']['symbol'] in market_ids
        ]

    if buy_only:
        orders = [order for order in orders if order['base']['symbol'] == market['base']['symbol']]
    elif sell_only:
        orders = [order for order in orders if order['base']['symbol'] == market['quote']['symbol']]

    ids = [order['id'] for order in orders if 'id' in order]

    bitshares.cancel(ids, account=account)
示例#2
0
def main(debug, config, wallet_password, password, broadcast, account_name):
    """ Use this script to change account keys. By default, a random will be
        generated. By default, transaction will not be broadcasted (dry-run mode).
    """
    # create logger
    if 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
    conf = yaml.safe_load(config)

    b = not broadcast
    bitshares = BitShares(node=conf['node_bts'], nobroadcast=b)
    account = Account(account_name, bitshares_instance=bitshares)

    # Wallet unlock
    try:
        bitshares.unlock(wallet_password)
    except WrongMasterPasswordException:
        log.critical('Wrong wallet password provided')
        sys.exit(1)

    # random password
    if password:
        password = password
    else:
        password = generate_password()

    print('password: {}\n'.format(password))

    key = dict()
    for key_type in key_types:
        # PasswordKey object
        k = PasswordKey(account_name, password, role=key_type)

        privkey = k.get_private_key()
        print('{} private: {}'.format(key_type, str(privkey)))  # we need explicit str() conversion!

        # pubkey with default prefix GPH
        pubkey = k.get_public_key()

        # pubkey with correct prefix
        key[key_type] = format(pubkey, bitshares.prefix)
        print('{} public: {}\n'.format(key_type, key[key_type]))

    # prepare for json format
    account['options']['memo_key'] = key['memo']
    owner_key_authority = [[key['owner'], 1]]
    active_key_authority = [[key['active'], 1]]
    owner_accounts_authority = []
    active_accounts_authority = []
    posting_accounts_authority = []

    s = {
        'account': account['id'],
        'new_options': account['options'],
        'owner': {'account_auths': owner_accounts_authority, 'key_auths': owner_key_authority, 'weight_threshold': 1},
        'active': {
            'account_auths': active_accounts_authority,
            'key_auths': active_key_authority,
            'weight_threshold': 1,
        },
        'fee': {'amount': 0, 'asset_id': '1.3.0'},
        'extensions': {},
        'prefix': bitshares.prefix,
    }

    # pprint(s)
    op = operations.Account_update(**s)

    try:
        bitshares.finalizeOp(op, account_name, 'owner')
    except MissingKeyError:
        log.critical('No key for {} in storage, use `uptick addkey` to add'.format(account_name))
        sys.exit(1)
示例#3
0
def main(debug, config, wallet_password, password, broadcast, parent_account,
         account_name):
    """ Use this script to create new account. By default, a random password will be
        generated. By default, transaction will not be broadcasted (dry-run mode).
    """
    # create logger
    if 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
    conf = yaml.safe_load(config)

    b = not broadcast
    bitshares = BitShares(node=conf['node_bts'], nobroadcast=b)
    account = Account(parent_account, bitshares_instance=bitshares)

    # Wallet unlock
    try:
        bitshares.unlock(wallet_password)
    except WrongMasterPasswordException:
        log.critical('Wrong wallet password provided')
        sys.exit(1)

    # random password
    if password:
        password = password
    else:
        password = generate_password()

    print('password: {}\n'.format(password))

    key = dict()
    for key_type in key_types:
        # PasswordKey object
        k = PasswordKey(account_name, password, role=key_type)

        privkey = k.get_private_key()
        print('{} private: {}'.format(
            key_type, str(privkey)))  # we need explicit str() conversion!

        # pubkey with default prefix GPH
        pubkey = k.get_public_key()

        # pubkey with correct prefix
        key[key_type] = format(pubkey, bitshares.prefix)
        print('{} public: {}\n'.format(key_type, key[key_type]))

    try:
        bitshares.create_account(
            account_name,
            registrar=parent_account,
            referrer=account['id'],
            referrer_percent=0,
            password=password,
            storekeys=broadcast,
        )
    except MissingKeyError:
        log.critical(
            'No key for {} in storage, use `uptick addkey` to add'.format(
                parent_account))
        sys.exit(1)