예제 #1
0
def address_add_view(request):
    account = MondoAccount.objects.get(id=request.session.get('account_id'))

    raw_address = request.POST.get('address')
    address, created = BitcoinAddress.objects.get_or_create(account=account, address=raw_address,
                                                            last_balance=get_balance(raw_address))
    address.save()
    return HttpResponseRedirect(reverse('mondo:home'))
예제 #2
0
파일: cron.py 프로젝트: ondrejsika/bitmondo
def cron():
    for account in MondoAccount.objects.all():
        for address in account.bitcoinaddress_set.all():
            balance = get_balance(address.address)
            if address.last_balance != balance:
                tx_id = get_last_tx_id(address.address)
                address.send_notification(balance, tx_id)
                address.last_balance = balance
                address.save()
예제 #3
0
def cron():
    for user in User.objects.all():
        # single wallets
        for wallet in user.wallet_set.all():
            balance = get_balance(wallet.wallet)
            if wallet.last_balance != balance:
                wallet.send_notification(balance)
                wallet.last_balance = balance
                wallet.save()

        # xpubs
        for xpub in user.xpub_set.all():
            for wallet in xpub.xpubwallet_set.all().order_by('i'):
                balance = get_balance(wallet.wallet)
                if get_txs_count(wallet.wallet):
                    wallet.is_used = True
                    wallet.save()
                if wallet.last_balance != balance:
                    wallet.send_notification(balance)
                    wallet.last_balance = balance
                    wallet.save()

            # Create new wallets from xpub
            try:
                last_used = xpub.xpubwallet_set.filter(
                    is_used=True).order_by('i').last().i
            except AttributeError:
                last_used = 0
            try:
                last_generated = xpub.xpubwallet_set.all().order_by(
                    'i').last().i
            except AttributeError:
                last_generated = 0

            if last_used + BIP44_OFFSET > last_generated:
                for i in range(last_used + BIP44_OFFSET - last_generated):
                    i = i + last_generated + 1
                    XpubWallet(xpub=xpub,
                               i=i,
                               last_balance=0,
                               wallet=get_wallet_from_xpub(xpub.xpub,
                                                           i)).save()
예제 #4
0
def cron():
    for user in User.objects.all():
        # single wallets
        for wallet in user.wallet_set.all():
            balance = get_balance(wallet.wallet)
            if wallet.last_balance != balance:
                wallet.send_notification(balance)
                wallet.last_balance = balance
                wallet.save()

        # xpubs
        for xpub in user.xpub_set.all():
            for wallet in xpub.xpubwallet_set.all().order_by('i'):
                balance = get_balance(wallet.wallet)
                if get_txs_count(wallet.wallet):
                    wallet.is_used = True
                    wallet.save()
                if wallet.last_balance != balance:
                    wallet.send_notification(balance)
                    wallet.last_balance = balance
                    wallet.save()

            # Create new wallets from xpub
            try:
                last_used = xpub.xpubwallet_set.filter(is_used=True).order_by('i').last().i
            except AttributeError:
                last_used = 0
            try:
                last_generated = xpub.xpubwallet_set.all().order_by('i').last().i
            except AttributeError:
                last_generated = 0

            if last_used + BIP44_OFFSET > last_generated:
                for i in range(last_used + BIP44_OFFSET - last_generated):
                    i = i + last_generated + 1
                    XpubWallet(xpub=xpub, i=i, last_balance=0, wallet=get_wallet_from_xpub(xpub.xpub, i)).save()