예제 #1
0
 def test_valid(self):
     # bitcoin testnet
     self.assertTrue(bitcoinaddress.validate(
         'mpc1rKeaMSCuQnJevMViLuq8uWjHwgdjiV', magicbyte=111))
     # bitcoin multisig (from https://gist.github.com/gavinandresen/3966071)
     self.assertTrue(bitcoinaddress.validate(
         '3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC', magicbyte=5))
예제 #2
0
 def test_valid(self):
     # bitcoin testnet
     self.assertTrue(
         bitcoinaddress.validate('mpc1rKeaMSCuQnJevMViLuq8uWjHwgdjiV',
                                 magicbyte=111))
     # bitcoin multisig (from https://gist.github.com/gavinandresen/3966071)
     self.assertTrue(
         bitcoinaddress.validate('3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC',
                                 magicbyte=5))
예제 #3
0
def qrcode_reader(status, session_id):
    reader = Reader('/dev/video0')
    transaction = Transactions.objects.get(session_id = session_id)
    if status == 'start':
        per = Peripherals.objects.get()
        per.qrcode_status = True
        cam_status = per.qrcode_status
        per.save()
        while cam_status:
            address = reader.read_address()
            if address != '':
                if bitcoinaddress.validate(address):
                    per.qrcode_status = False
                    per.save()
                    transaction.dest_address = address
                    transaction.status = 2
                    transaction.updated_on = transaction.updated_on = datetime.now()
                    transaction.save()
            per = Peripherals.objects.get()
            cam_status = per.qrcode_status
            time.sleep(0.1)
    if status == 'stop':
        per = Peripherals.objects.get()
        per.qrcode_status = False
        per.save()
    elif status == 'check':
        transaction = Transactions.objects.get(session_id = session_id)
        return transaction.dest_address
예제 #4
0
def qrcode_reader(status, session_id):
    reader = Reader('/dev/video0')
    transaction = Transactions.objects.get(session_id=session_id)
    if status == 'start':
        per = Peripherals.objects.get()
        per.qrcode_status = True
        cam_status = per.qrcode_status
        per.save()
        while cam_status:
            address = reader.read_address()
            if address != '':
                if bitcoinaddress.validate(address):
                    per.qrcode_status = False
                    per.save()
                    transaction.dest_address = address
                    transaction.status = 2
                    transaction.updated_on = transaction.updated_on = datetime.now(
                    )
                    transaction.save()
            per = Peripherals.objects.get()
            cam_status = per.qrcode_status
            time.sleep(0.1)
    if status == 'stop':
        per = Peripherals.objects.get()
        per.qrcode_status = False
        per.save()
    elif status == 'check':
        transaction = Transactions.objects.get(session_id=session_id)
        return transaction.dest_address
예제 #5
0
    def withdraw_to_address(self, address, amount, description=""):
        if not validate(address, magicbyte=self.currency.magicbyte.split(',')):
            raise ValueError('Invalid address')

        if amount < 0:
            raise ValueError('Invalid amount')

        if self.balance - amount < -settings.CC_ALLOW_NEGATIVE_BALANCE:
            raise ValueError('No money')

        tx = WithdrawTransaction.objects.create(
            currency=self.currency,
            amount=amount,
            address=address,
            wallet=self
        )
        Operation.objects.create(
            wallet=self,
            balance=-amount,
            holded=amount,
            description=description,
            reason=tx
        )
        self.balance -= amount
        self.holded += amount
        self.save()
예제 #6
0
 def validateButtonPressed(self):
     #self.view.setLabel_text()
     if validate(self.view.entry_text.get()):
         self.view.setGreenImg()
         self.view.setLabel_text(self.view.entry_text.get())
     else:
         self.view.setRedImg()
         self.view.setLabel_text('Invalid address')
예제 #7
0
 def addressInText(text):
     #gets rid of candidates that are too small and cleans for punctuation
     regex = re.compile('[%s]' % re.escape(string.punctuation))
     possibleKeys = [regex.sub('', x) for x in text.split() if len(x) > 23]
     keys = []
     for x in possibleKeys:
         if btcAdr.validate(x) == True:
             keys.append(x)
     if len(keys) > 0:
         return ', '.join(keys)
     else:
         return False
예제 #8
0
	def addressInText(text):
		#gets rid of candidates that are too small and cleans for punctuation
		regex = re.compile('[%s]' % re.escape(string.punctuation))
		possibleKeys= [regex.sub('', x) for x in text.split() if len(x)>23]
		keys=[]
		for x in possibleKeys:
			if btcAdr.validate(x)== True:
				keys.append(x)
		if len(keys)>0:
			return ', '.join(keys)
		else:
			return False
예제 #9
0
def set_address(session_id, address):
    try:
        transaction = Transactions.objects.get(session_id=session_id)
        if not address:
            message = 'no address supplied'
            error = 1
        else:
            if bitcoinaddress.validate(address):
                transaction.dest_address = address
                transaction.status = Transactions.ADDRESS_SET
                transaction.updated_on = datetime.now()
                transaction.save()
                message = 'address set'
                error = 0
            else:
                message = 'invalid address'
                error = 1
    except Transactions.DoesNotExist:
        message = 'invalid session_id'
        error = 1
    return {'error': error, 'message': message}
예제 #10
0
def set_address(session_id, address):
    try:
        transaction = Transactions.objects.get(session_id=session_id)
        if not address:
            message = 'no address supplied'
            error = 1
        else:
            if bitcoinaddress.validate(address):
                transaction.dest_address = address
                transaction.status = Transactions.ADDRESS_SET
                transaction.updated_on = datetime.now()
                transaction.save()
                message = 'address set'
                error = 0
            else:
                message = 'invalid address'
                error = 1
    except Transactions.DoesNotExist:
        message = 'invalid session_id'
        error = 1
    return {'error': error, 'message': message}
예제 #11
0
    def post(self, joinhash):
        address = self.get_argument("selleraddress", None)
        escrow = self.get_joinhash_url(joinhash)

        if not bitcoinaddress.validate(address):
            logging.error(
                "an invalid bitcoin address was submitted by the seller on signup. Address: %s"
                % address)
            self.render('sellerjoin.html',
                        joinhash=joinhash,
                        escrow=escrow,
                        errors="invalid")
            return

        # create multi sig address if we don't have one because escrow was started in native client
        if not escrow.has_key(
                'multisigaddress') or not escrow['multisigaddress']:
            self.create_multisig(escrow)

        escrow = self.set_seller_address(joinhash, address)
        self.update_step1_seller(escrow['sellerurlhash'])
        self.redirect("/seller/%s" % escrow['sellerurlhash'])
예제 #12
0
    def post(self, base58):
        selleraddress = self.get_argument("selleraddress", None)
        escrow = self.get_seller(base58)

        if not bitcoinaddress.validate(selleraddress):
            logging.error(
                "an invalid bitcoin address was submitted by the seller on signup. Address: %s"
                % selleraddress)
            self.render('sellerstep1.html',
                        base58=base58,
                        escrow=escrow,
                        errors="invalid")
            return

        if not escrow.has_key(
                'multisigaddress') or not escrow['multisigaddress']:
            # first time we're getting the seller payout address
            logging.info("first time seller with public address of %s" %
                         selleraddress)
            escrow = self.create_escrow(sellerurlhash=base58,
                                        selleraddress=selleraddress)

        self.render('sellerstep2.html', base58=base58, escrow=escrow)
        return
예제 #13
0
 def test_invalid(self):
     for bitcoin_address in self.addresses:
         self.assertFalse(bitcoinaddress.validate(bitcoin_address))
예제 #14
0
 def clean_address(self):
     address = self.cleaned_data['address']
     if not bitcoinaddress.validate(address):
         raise forms.ValidationError("Invalid Bitcoin Address")
     return address
예제 #15
0
 def validate(self, address):
   return bitcoinaddress.validate(address)
예제 #16
0
 def test_valid(self):
     for bitcoin_address in self.addresses:
         self.assertTrue(bitcoinaddress.validate(bitcoin_address))
예제 #17
0
 def clean_address(self):
     address = self.cleaned_data['address']
     if not bitcoinaddress.validate(address):
         raise forms.ValidationError("Invalid Bitcoin Address")
     return address
예제 #18
0
파일: util.py 프로젝트: thefinn93/oniontip
def extract_bitcoin_address(field):
    for bitcoin_match in re.finditer(r"[13][a-km-zA-HJ-NP-Z0-9]{26,33}", field):
        bitcoin_address = bitcoin_match.group(0)
        if bitcoinaddress.validate(bitcoin_address):
            return bitcoin_address
예제 #19
0
 def test_valid(self):
     for bitcoin_address in self.addresses:
         self.assertTrue(bitcoinaddress.validate(bitcoin_address))
예제 #20
0
 def test_invalid(self):
     for bitcoin_address in self.addresses:
         self.assertFalse(bitcoinaddress.validate(bitcoin_address))
예제 #21
0
def extract_bitcoin_address(field):
    for bitcoin_match in re.finditer(r"[13][a-km-zA-HJ-NP-Z0-9]{26,33}", field):
        bitcoin_address = bitcoin_match.group(0)
        if bitcoinaddress.validate(bitcoin_address):
            return bitcoin_address
예제 #22
0
파일: util.py 프로젝트: benhc123/oniontip
def extract_bitcoin_address(field):
    bitcoin_match = re.search(r"[13][a-km-zA-HJ-NP-Z0-9]{26,33}", field)
    if bitcoin_match:
        bitcoin_address = bitcoin_match.group(0)
        if bitcoinaddress.validate(bitcoin_address):
            return bitcoin_address
예제 #23
0
 def validate(self, address):
     return bitcoinaddress.validate(address)