Beispiel #1
0
    def create(user, bet, amount):
        amount = currency.currency2btc(amount, user.profile.currency)
        if amount > bet.min_value and amount < bet.max_value:
            # Make transaction
            profile = Profile.objects.get(user=user)
            if profile.wallet.total_balance() >= amount:
                row = Tipp()
                transaction = profile.wallet.send_to_wallet(
                    bet.match.wallet, amount)

                row.player = user
                row.bet_score = bet.score
                row.match = bet.match
                row.amount = amount
                row.bet = bet.bet
                row.save()

                #add new TippState
                state = TippState()
                state.tipp = row
                state.transaction = transaction
                state.save()
            else:
                raise Exception(
                    "Your balance does not have enough funds to bid")
        else:
            raise Exception(
                "Your bet is too small or too high. Change the amount and try again"
            )
Beispiel #2
0
def pay(request):
    profile = Profile.objects.get(user=request.user)
    try:
        amount = decimal.Decimal(0 if request.POST.get("amount") ==
                                 None else request.POST.get("amount"))
        amount = currency.currency2btc(amount, profile.currency)
    except decimal.InvalidOperation:
        amount = 0.001

    return render(
        request,
        'bbil/pay.html',
        {
            'wallet': profile.wallet,
            'amount': amount,
        },
    )
Beispiel #3
0
def escrow(request):

    if request.method == 'POST':
        form = BitcoinEscrow(request.POST)
        if form.is_valid():
            profile = Profile.objects.get(user=request.user)
            #WalletTransaction
            amount = currency.currency2btc(form.cleaned_data['amount'],
                                           profile.currency)
            bwt = profile.wallet.send_to_address(
                form.cleaned_data['bitcoin_address'], amount)
            return redirect('outgoing')
    else:
        form = BitcoinEscrow()

    return render(
        request,
        'bbil/escrow.html',
        {'form': form},
    )
def currency2btc(value, other_currency="USD", rate_period="24h"):
    if other_currency=="BTC":
        return currencyformat(value)
    return bitcoinformat(currency.currency2btc(value, other_currency, rate_period))
def currency2btc(value, other_currency="USD", rate_period="24h"):
    if other_currency == "BTC":
        return currencyformat(value)
    return bitcoinformat(
        currency.currency2btc(value, other_currency, rate_period))