Пример #1
0
def create_wallet(user):
    name = input("Enter Wallet Name: ")
    bal = input("Enter Starting Balance: ")
    Wallet.create(name=name,
                  balance=bal,
                  owner=user,
                  last_transaction=datetime.now())
Пример #2
0
def CreateWalletEndpoint(session, data):
    check_wallet_schema(data)
    pk = session.public_key
    invite_code = generate_random_string(48)

    if Wallet.select().where(Wallet.source == pk).exists():
        raise APIError("Shared wallet linked with your key is already exists", 409)

    level = data['participants'] - data['signers']

    device_uid = data.get('device_uid')
    wallet = Wallet.create(
        name=data['name'],
        signers=data['signers'],
        participants=data['participants'],
        invite_code=invite_code,
        level=level,
        source=pk)

    MultisigInfo.create(
        wallet=wallet.id,
        info=data['multisig_info'],
        level=0,
        device_uid=device_uid,
        source=pk)

    return jsonify({"invite_code": wallet.invite_code})
Пример #3
0
    def decorator(*args, **kwargs):
        update = args[0]

        username = update.effective_user.username
        uid = update.effective_user.id
        first_name = update.effective_user.first_name
        last_name = update.effective_user.last_name

        user, is_created = Users.get_or_create(telegram_id=uid)
        user.first_name = first_name
        user.last_name = last_name
        user.username = username
        user.last_active_dt = dt.now()
        if is_created:
            user.created_dt = dt.now()
        if not user.wallets:
            w = MinterWallet.create()
            wallet = Wallet.create(user=user,
                                   mnemonic=w['mnemonic'],
                                   address=w['address'],
                                   balance=0)
            wallet.save()
        user.save()

        new_args = list(args)
        new_args.append(user)

        logger.info('Entering: %s', func.__name__)
        for a in new_args:
            logger.info(a)
        for k in kwargs:
            logger.info(k)
        return func(*new_args, **kwargs)
Пример #4
0
def CreateWalletEndpointV2(session, data):
    check_wallet_schema(data)
    pk = session.public_key
    invite_code = generate_random_string(48)

    if Wallet.select().where(Wallet.source == pk).exists():
        raise APIError("Shared wallet linked with your key is already exists", 409)

    level = data['participants'] - data['signers']

    wallet = Wallet.create(
        signers=data['signers'],
        participants=data['participants'],
        invite_code=invite_code,
        supported_protocols=','.join(data['supported_protocols']),
        level=level,
        source=pk,
    )

    return jsonify({"invite_code": wallet.invite_code})