Ejemplo n.º 1
0
    def save(self, *args, **kwargs):
        if not self.code:
            for currency in get_wallet_currencies():
                if currency['bip44'] == self.currency:
                    self.code = currency['code']

        return super(ExchangeCurrency, self).save(*args, **kwargs)
Ejemplo n.º 2
0
    def save(self, *args, **kwargs):
        if not self.code:
            for currency in get_wallet_currencies():
                if currency['bip44'] == self.currency:
                    self.code = currency['code']

        return super(ExchangeCurrency, self).save(*args, **kwargs)
Ejemplo n.º 3
0
def get_ticks(verbose=False):
    """
    Run this function every 60 or so minutes so to keep the PriceTicks table
    fresh.
    """
    all_ticks = []
    for fiat in settings.WALLET_SUPPORTED_FIATS:
        all_ticks.append(PriceTick.get_current_price('btc', fiat, verbose=verbose))

    for crypto in [x['code'] for x in get_wallet_currencies()]:
        if crypto == 'btc':
            continue
        all_ticks.append(PriceTick.get_current_price(crypto, 'btc', verbose=verbose))

    return all_ticks
Ejemplo n.º 4
0
def get_ticks(verbose=False):
    """
    Run this function every 60 or so minutes so to keep the PriceTicks table
    fresh.
    """
    all_ticks = []
    for fiat in settings.WALLET_SUPPORTED_FIATS:
        all_ticks.append(
            PriceTick.get_current_price('btc', fiat, verbose=verbose))

    for crypto in [x['code'] for x in get_wallet_currencies()]:
        if crypto == 'btc':
            continue
        all_ticks.append(
            PriceTick.get_current_price(crypto, 'btc', verbose=verbose))

    return all_ticks
Ejemplo n.º 5
0
import json

from django.template.response import TemplateResponse
from django import http
from django.conf import settings
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import redirect

try:
    from models import ExchangeCurrency, ExchangeAddress
except ImportError:
    from .models import ExchangeCurrency, ExchangeAddress

from multiexplorer.utils import get_wallet_currencies

crypto_data = get_wallet_currencies()
crypto_data_json = json.dumps(crypto_data)


def home(request):
    return TemplateResponse(request, "exchange_home.html", {
        'supported_cryptos': ExchangeCurrency.objects.all(),
        'crypto_data': crypto_data_json,
        'ENABLE_EXCHANGE': settings.ENABLE_EXCHANGE
    })


@csrf_exempt
def create_exchange(request):
    if request.method == "POST":
        deposit_code = request.POST['deposit_code']
Ejemplo n.º 6
0
import json

from django.template.response import TemplateResponse
from django import http
from django.conf import settings
from django.views.decorators.csrf import csrf_exempt

from .models import ExchangeCurrency, ExchangeAddress

from multiexplorer.utils import get_wallet_currencies

crypto_data = get_wallet_currencies()
crypto_data_json = json.dumps(crypto_data)


def home(request):
    return TemplateResponse(
        request, "exchange_home.html", {
            'supported_cryptos': ExchangeCurrency.objects.all(),
            'crypto_data': crypto_data_json,
            'ENABLE_EXCHANGE': settings.ENABLE_EXCHANGE
        })


@csrf_exempt
def create_exchange(request):
    deposit_code = request.POST['deposit_code']
    withdraw_address = request.POST['withdraw_address']
    withdraw_code = request.POST['withdraw_code']
    error = None
Ejemplo n.º 7
0
 def get_address_byte(self):
     for currency in get_wallet_currencies():
         if currency['bip44'] == self.currency:
             return currency['address_byte']
Ejemplo n.º 8
0
 def logo(self):
     for currency in get_wallet_currencies():
         if currency['bip44'] == self.currency:
             return currency['logo']
Ejemplo n.º 9
0
 def name(self):
     for currency in get_wallet_currencies():
         if currency['bip44'] == self.currency:
             return currency['name']
Ejemplo n.º 10
0
import datetime
import json
import os

from django.db import models
from django.conf import settings
from django.utils import timezone
from bitcoin import bip32_ckd, bip32_master_key, bip32_extract_key, privtoaddr
from moneywagon.tx import Transaction
from moneywagon import get_unspent_outputs, get_current_price
from multiexplorer.utils import get_wallet_currencies
from multiexplorer.models import CachedTransaction

SUPPORTED_CURRENCIES = [(x['bip44'], "%(code)s - %(name)s" % x)
                        for x in get_wallet_currencies()]


class ExchangeMasterKey(models.Model):
    created = models.DateTimeField(default=timezone.now)
    xpriv = models.CharField(max_length=120, blank=True)
    from_passphrase = models.TextField(blank=True)
    notes = models.TextField(blank=True)
    utxos = models.TextField(blank=True)

    class Meta:
        get_latest_by = 'created'

    def save(self, *args, **kwargs):
        if not self.xpriv:
            seed_words = self.from_passphrase and self.from_passphrase.encode(
                'ascii')
Ejemplo n.º 11
0
 def name(self):
     for currency in get_wallet_currencies():
         if currency['bip44'] == self.currency:
             return currency['name']
Ejemplo n.º 12
0
 def get_address_byte(self):
     for currency in get_wallet_currencies():
         if currency['bip44'] == self.currency:
             return currency['address_byte']
Ejemplo n.º 13
0
 def logo(self):
     for currency in get_wallet_currencies():
         if currency['bip44'] == self.currency:
             return currency['logo']
Ejemplo n.º 14
0
import datetime
import json
import os

from django.db import models
from django.conf import settings
from django.utils import timezone
from bitcoin import bip32_ckd, bip32_master_key, bip32_extract_key, privtoaddr
from moneywagon.tx import Transaction
from moneywagon import get_unspent_outputs, get_current_price
from multiexplorer.utils import get_wallet_currencies
from multiexplorer.models import CachedTransaction

SUPPORTED_CURRENCIES = [(x['bip44'], "%(code)s - %(name)s" % x)
                        for x in get_wallet_currencies()]


class ExchangeMasterKey(models.Model):
    created = models.DateTimeField(default=timezone.now)
    xpriv = models.CharField(max_length=120, blank=True)
    from_passphrase = models.TextField(blank=True)
    notes = models.TextField(blank=True)
    utxos = models.TextField(blank=True)

    class Meta:
        get_latest_by = 'created'

    def save(self, *args, **kwargs):
        if not self.xpriv:
            seed_words = self.from_passphrase and self.from_passphrase.encode(
                'ascii')
Ejemplo n.º 15
0
import datetime
import json
import os

from django.db import models
from django.conf import settings
from django.utils import timezone
from bitcoin import bip32_ckd, bip32_master_key, bip32_extract_key, privtoaddr
from moneywagon.tx import Transaction
from moneywagon import get_unspent_outputs, get_current_price
from multiexplorer.utils import get_wallet_currencies
from multiexplorer.models import CachedTransaction

SUPPORTED_CURRENCIES = [(x['bip44'], "%(code)s - %(name)s" % x) for x in get_wallet_currencies()]

class ExchangeMasterKey(models.Model):
    created = models.DateTimeField(default=timezone.now)
    xpriv = models.CharField(max_length=120, blank=True)
    from_passphrase = models.TextField(blank=True)
    notes = models.TextField(blank=True)
    utxos = models.TextField(blank=True)

    class Meta:
        get_latest_by = 'created'

    def save(self, *args, **kwargs):
        if not self.xpriv:
            seed_words = self.from_passphrase and self.from_passphrase.encode('ascii')
            self.xpriv = bip32_master_key(seed=seed_words or os.urandom(100))
            self.from_passphrase = ''