コード例 #1
0
ファイル: routes.py プロジェクト: oldcryptogeek/coinjerk-btcp
def client_setup(pairing_code):
    client = BTCPayClient.create_client(host='http://localhost:14142',
                                        code=pairing_code)
    client_connector = PaymentProcessor(client=client)
    db.session.add(client_connector)
    db.session.commit()

    return jsonify({'code': pairing_code, 'url': 'http://localhost:14142'})
コード例 #2
0
    def on_model_change(self, form, model: Users, is_created: bool):
        if is_created:
            raise Exception('Can not create users')

        if model.btcpay_host is None:
            model.btcpay_client = None

        if model.btcpay_pairing_code is not None:
            model.btcpay_client = BTCPayClient.create_client(
                host=model.btcpay_host, code=model.btcpay_pairing_code)
        model.btcpay_pairing_code = None
コード例 #3
0
ファイル: routes.py プロジェクト: niftynei/btcqbo
def authbtc():
    # accepts BTCPay pairing code and calls pairing fn
    status = login(request.cookies)
    if status is not None:
        return redirect(status)
    form = BTCCodeForm()
    url = urljoin(str(os.getenv('BTCPAY_HOST')), 'api-tokens')
    if form.validate_on_submit():
        client = BTCPayClient.create_client(
                host=app.config.get('BTCPAY_HOST'),
                code=form.code.data,
        )
        save('btc_client', client)
        save('forward_url', form.forward_url.data)
        flash('Pairing to BTCPay Successful')
        return render_template('index.html')
    return render_template(
        'authbtc.html',
        title='Enter Code',
        form=form,
        url=url
    )
コード例 #4
0
ファイル: db.py プロジェクト: psqnt/flask-btcpay-example
def _create_new_client(token, url=None):
    '''
    creates new client
    this only needs to be done once, since it will be saved in the database
    get the pairing code from btc pay when you pair
    example: Server initiated pairing code: XXXXXX

    TOKENS only work once, if you get a weird http /tokens not found error,
    generate a new one and try again
    python
    >>> from btcpay import BTCPayClient
    >>> url = 'http://mynode.local:49393'
    >>> client = BTCPayClient.create_client(host=url, code=token)
    '''
    if url is None:
        url = 'http://localhost:23001'
    client = BTCPayClient.create_client(host=url, code=token)
    pickled = pickle.dumps(client)
    db = get_db()
    db.execute(
        '''INSERT INTO btc_pay_server_client (pickled_client) VALUES (?)''',
        (pickled,)
    )
    db.commit()
コード例 #5
0
def btcpay_server_setup(params):
    return BTCPayClient.create_client(
            host=params['host'],
            code=params['code']
            )