from flask import Blueprint, request, jsonify, flash, redirect, render_template
import flask_security
from flask_security.utils import encrypt_password, verify_password
from flask_security.recoverable import send_reset_password_instructions
from flask_socketio import Namespace, emit, join_room, leave_room

import web_utils
from web_utils import bad_request, get_json_params, request_get_signature, check_auth, auth_request, auth_request_get_single_param
import utils
from app_core import db, socketio, limiter
from models import user_datastore, User, UserCreateRequest, UserUpdateEmailRequest, Permission, ApiKey, ApiKeyRequest, PayDbTransaction
import paydb_core

logger = logging.getLogger(__name__)
paydb = Blueprint('paydb', __name__, template_folder='templates')
limiter.limit('100/minute')(paydb)
ws_sids = {}

#
# Websocket events
#

NS = '/paydb'


def tx_event(txn):
    txt = json.dumps(txn.to_json())
    socketio.emit("tx", txt, json=True, room=txn.sender.email, namespace=NS)
    if txn.recipient and txn.recipient != txn.sender:
        socketio.emit("tx",
                      txt,
Beispiel #2
0
import json
import base64
from urllib.parse import urlparse

from flask import Blueprint, render_template, request, jsonify
from flask_jsonrpc.exceptions import OtherError

from app_core import app, db, limiter
from models import WavesTx, WavesTxSig
import utils
import tx_utils
from web_utils import bad_request, get_json_params

logger = logging.getLogger(__name__)
mw = Blueprint('mw', __name__, template_folder='templates')
limiter.limit("100 per hour")(mw)

# wave specific config settings
NODE_BASE_URL = app.config["NODE_BASE_URL"]
SEED = app.config["WALLET_SEED"]
ADDRESS = app.config["WALLET_ADDRESS"]
ASSET_ID = app.config["ASSET_ID"]
ASSET_NAME = app.config["ASSET_NAME"]
TESTNET = app.config["TESTNET"]
TX_SIGNERS = app.config["TX_SIGNERS"]
ASSET_MASTER_PUBKEY = app.config["ASSET_MASTER_PUBKEY"]

#
# Jinja2 filters
#
# pylint: disable=unbalanced-tuple-unpacking

import logging
import time

from flask import Blueprint, request, jsonify

import web_utils
from web_utils import bad_request, get_json_params, request_get_signature, check_auth, auth_request, auth_request_get_single_param
import utils
from app_core import app, db, limiter
from models import User, Role, Category, Proposal, Payment, Referral

logger = logging.getLogger(__name__)
reward = Blueprint('reward', __name__, template_folder='templates')
limiter.limit("100/minute")(reward)
use_referrals = app.config["USE_REFERRALS"]


def _reward_create(user, reason, category, recipient, amount, message):
    proposal = Proposal(user, reason)
    proposal.categories.append(category)
    proposal.authorize(user)
    db.session.add(proposal)
    email = recipient if utils.is_email(recipient) else None
    mobile = recipient if utils.is_mobile(recipient) else None
    address = recipient if utils.is_address(recipient) else None
    payment = Payment(proposal, mobile, email, address, message, amount)
    db.session.add(payment)
    return proposal, payment