コード例 #1
0
ファイル: forms.py プロジェクト: ryepdx/bitcoin-pouch
 def save(self):
     username = self.cleaned_data["username"]
     email = self.cleaned_data["email"]
     password = self.cleaned_data["password1"]
     conn = bitcoind.connect_to_local()
     
     if self.cleaned_data["confirmation_key"]:
         from friends.models import JoinInvitation # @@@ temporary fix for issue 93
         try:
             join_invitation = JoinInvitation.objects.get(confirmation_key = self.cleaned_data["confirmation_key"])
             confirmed = True
         except JoinInvitation.DoesNotExist:
             confirmed = False
     else:
         confirmed = False
     
     # @@@ clean up some of the repetition below -- DRY!
     
     if confirmed:
         if email == join_invitation.contact.email:
             new_user = User.objects.create_user(username, email, password)
             join_invitation.accept(new_user) # should go before creation of EmailAddress below
             new_user.message_set.create(message=ugettext(u"Your email address has already been verified"))
             # already verified so can just create
             EmailAddress(user=new_user, email=email, verified=True, primary=True).save()
         else:
             new_user = User.objects.create_user(username, "", password)
             join_invitation.accept(new_user) # should go before creation of EmailAddress below
             if email:
                 new_user.message_set.create(message=ugettext(u"Confirmation email sent to %(email)s") % {'email': email})
                 EmailAddress.objects.add_email(new_user, email)
     else:
         new_user = User.objects.create_user(username, "", password)
         if email:
             new_user.message_set.create(message=ugettext(u"Confirmation email sent to %(email)s") % {'email': email})
             EmailAddress.objects.add_email(new_user, email)
     
     if settings.ACCOUNT_EMAIL_VERIFICATION:
         new_user.is_active = False
         new_user.save()
     
     # Create their bitcoin account.
     # By default we will be creating an account with only their username.
     # Subsequent accounts made via the JSON-RPC interface will be in the
     # format username+label, where username is their username and label
     # is the label passed in by the JSON-RPC call.
     address = conn.getnewaddress(util.getaccount(username, ""))
     addressObj = Address(user=new_user, address=address, label="", is_primary=True)
     addressObj.save()
     
     return username, password # required for authenticate()
コード例 #2
0
ファイル: views.py プロジェクト: ryepdx/bitcoin-pouch
'''
from django.core.exceptions import ObjectDoesNotExist
from jsonrpc import jsonrpc_method
from jsonrpc.decorators import basicauth
from decimal import *

import bitcoind
from bitcoind.proxy import JSONRPCException
from bitcoind.exceptions import _wrap_exception
from bitcoind.connection import BitcoinConnection
from bitcoind.models import Address, DEFAULT_ADDRESS_LABEL
from bitcoind import util
from django.db import connection, transaction
from account.models import MAX_USERNAME_LENGTH

conn = bitcoind.connect_to_local()


@jsonrpc_method('getblockcount')
def getblockcount(request):
    """
    Returns the number of blocks in the longest block chain.
    """
    return conn.getblockcount()


@jsonrpc_method('getblocknumber')
def getblocknumber(request):
    """
    Returns the block number of the latest block in the longest block chain.
    """
コード例 #3
0
    def save(self):
        username = self.cleaned_data["username"]
        email = self.cleaned_data["email"]
        password = self.cleaned_data["password1"]
        conn = bitcoind.connect_to_local()

        if self.cleaned_data["confirmation_key"]:
            from friends.models import JoinInvitation  # @@@ temporary fix for issue 93
            try:
                join_invitation = JoinInvitation.objects.get(
                    confirmation_key=self.cleaned_data["confirmation_key"])
                confirmed = True
            except JoinInvitation.DoesNotExist:
                confirmed = False
        else:
            confirmed = False

        # @@@ clean up some of the repetition below -- DRY!

        if confirmed:
            if email == join_invitation.contact.email:
                new_user = User.objects.create_user(username, email, password)
                join_invitation.accept(
                    new_user
                )  # should go before creation of EmailAddress below
                new_user.message_set.create(message=ugettext(
                    u"Your email address has already been verified"))
                # already verified so can just create
                EmailAddress(user=new_user,
                             email=email,
                             verified=True,
                             primary=True).save()
            else:
                new_user = User.objects.create_user(username, "", password)
                join_invitation.accept(
                    new_user
                )  # should go before creation of EmailAddress below
                if email:
                    new_user.message_set.create(message=ugettext(
                        u"Confirmation email sent to %(email)s") %
                                                {'email': email})
                    EmailAddress.objects.add_email(new_user, email)
        else:
            new_user = User.objects.create_user(username, "", password)
            if email:
                new_user.message_set.create(
                    message=ugettext(u"Confirmation email sent to %(email)s") %
                    {'email': email})
                EmailAddress.objects.add_email(new_user, email)

        if settings.ACCOUNT_EMAIL_VERIFICATION:
            new_user.is_active = False
            new_user.save()

        # Create their bitcoin account.
        # By default we will be creating an account with only their username.
        # Subsequent accounts made via the JSON-RPC interface will be in the
        # format username+label, where username is their username and label
        # is the label passed in by the JSON-RPC call.
        address = conn.getnewaddress(util.getaccount(username, ""))
        addressObj = Address(user=new_user,
                             address=address,
                             label="",
                             is_primary=True)
        addressObj.save()

        return username, password  # required for authenticate()
コード例 #4
0
ファイル: views.py プロジェクト: ryepdx/bitcoin-pouch
'''
from django.core.exceptions import ObjectDoesNotExist
from jsonrpc import jsonrpc_method
from jsonrpc.decorators import basicauth
from decimal import *

import bitcoind
from bitcoind.proxy import JSONRPCException
from bitcoind.exceptions import _wrap_exception
from bitcoind.connection import BitcoinConnection
from bitcoind.models import Address, DEFAULT_ADDRESS_LABEL
from bitcoind import util
from django.db import connection, transaction
from account.models import MAX_USERNAME_LENGTH

conn = bitcoind.connect_to_local()

@jsonrpc_method('getblockcount')
def getblockcount(request):
    """
    Returns the number of blocks in the longest block chain.
    """
    return conn.getblockcount()

@jsonrpc_method('getblocknumber')
def getblocknumber(request):
    """
    Returns the block number of the latest block in the longest block chain.
    """
    return conn.getblocknumber()