def sendFrom(self, from_account, to_address, amount, provider_id, minconf=1, comment="", comment_to=""):
        if type(from_account) not in [str, unicode]:
            return {'message': 'Invalid input from account', 'code':-156}
        
        if not to_address or not provider_id:
            return {'message': 'Invalid input to account or address', 'code':-101}

        if provider_id not in self.services.keys():
            return {'message': 'Non-existing currency provider id %s' % provider_id, 'code':-100}

        if not misc.isFloat(amount) or type(amount) is bool:
            return {'message': 'Amount is not a number', 'code':-102}

        if type(comment) not in [str, unicode]  or type(comment_to) not in [str, unicode]:
            return {'message': 'Comment is not valid', 'code':-104}
        
        account_list = self.services[provider_id].listaccounts()
        
        account_names = []
        for account_name in account_list:
            account_names.append(account_name)
            
        if from_account in account_names:
            # account given exists, continue
            try:
                reply = self.services[provider_id].sendfrom(from_account, to_address, amount, minconf, comment, comment_to)
            except JSONRPCException, e:
                return e.error
            except ValueError, e:
                return {'message': e, 'code':-1}
Beispiel #2
0
 def validate(self, value):
     super(CharField, self).validate(value)
     if not misc.isFloat(value):
         raise forms.ValidationError("Please provide a valid amount eg. 12.3456789")
     
     if value == 0 or value < 0:
         raise forms.ValidationError("Please provide a valid amount eg. 12.3456789")
Beispiel #3
0
 def validate(self, value):
     super(CharField, self).validate(value)
     if not misc.isFloat(value):
         raise forms.ValidationError("Please provide a valid amount eg. 12.3456789")
     
     if value == 0 or value < 0:
         raise forms.ValidationError("Please provide a valid amount eg. 12.3456789")
Beispiel #4
0
    def moveAmount(self,
                   from_account,
                   to_account,
                   provider_id,
                   amount,
                   minconf=1,
                   comment=""):
        '''
        Move amount from local to local accounts
        Note: from_account my be an empty string 
        '''
        if provider_id not in self.services.keys():
            return {
                'message':
                'Non-existing currency provider id %s' % provider_id,
                'code': -100
            }

        if self.config[provider_id]['enabled'] is not True:
            return {
                'message':
                'Currency service with id %s disabled for now' % provider_id,
                'code': -150
            }

        if not misc.isFloat(amount) or type(amount) is bool:
            return {'message': 'Amount is not a number', 'code': -102}

        if type(comment) not in [str, unicode]:
            return {'message': 'Comment is not valid', 'code': -104}

        try:
            minconf = int(minconf)
        except:
            return {'message': 'Invalid minconf value', 'code': -105}

        account_list = self.services[provider_id].listaccounts()

        account_names = []
        for account_name in account_list:
            account_names.append(account_name)

        if from_account in account_names and to_account in account_names:
            # both accounts have being found, perform the move
            try:
                reply = self.services[provider_id].move(
                    from_account, to_account, amount, minconf, comment)
            except JSONRPCException, e:
                return e.error
            except ValueError, e:
                return {'message': e, 'code': -1}
Beispiel #5
0
    def sendFrom(self,
                 from_account,
                 to_address,
                 amount,
                 provider_id,
                 minconf=1,
                 comment="",
                 comment_to=""):
        if type(from_account) not in [str, unicode]:
            return {'message': 'Invalid input from account', 'code': -156}

        if not to_address or not provider_id:
            return {
                'message': 'Invalid input to account or address',
                'code': -101
            }

        if provider_id not in self.services.keys():
            return {
                'message':
                'Non-existing currency provider id %s' % provider_id,
                'code': -100
            }

        if not misc.isFloat(amount) or type(amount) is bool:
            return {'message': 'Amount is not a number', 'code': -102}

        if type(comment) not in [str, unicode
                                 ] or type(comment_to) not in [str, unicode]:
            return {'message': 'Comment is not valid', 'code': -104}

        account_list = self.services[provider_id].listaccounts()

        account_names = []
        for account_name in account_list:
            account_names.append(account_name)

        if from_account in account_names:
            # account given exists, continue
            try:
                reply = self.services[provider_id].sendfrom(
                    from_account, to_address, amount, minconf, comment,
                    comment_to)
            except JSONRPCException, e:
                return e.error
            except ValueError, e:
                return {'message': e, 'code': -1}
    def moveAmount(self, from_account, to_account, provider_id, amount, minconf=1, comment=""):
        '''
        Move amount from local to local accounts
        Note: from_account my be an empty string 
        '''
        if provider_id not in self.services.keys():
            return {'message': 'Non-existing currency provider id %s' % provider_id, 'code':-100}
        
        if self.config[provider_id]['enabled'] is not True:
            return {'message': 'Currency service with id %s disabled for now' % provider_id, 'code':-150}
        
        if not misc.isFloat(amount) or type(amount) is bool:
            return {'message': 'Amount is not a number', 'code':-102}
        
        if type(comment) not in [str, unicode]:
            return {'message': 'Comment is not valid', 'code':-104}
        
        try:
            minconf = int(minconf)
        except:
            return {'message': 'Invalid minconf value', 'code':-105}
        
        account_list = self.services[provider_id].listaccounts()

        account_names = []
        for account_name in account_list:
            account_names.append(account_name)
        
        if from_account in account_names and to_account in account_names:
            # both accounts have being found, perform the move
            try:
                reply = self.services[provider_id].move(from_account, to_account, amount, minconf, comment)
            except JSONRPCException, e: 
                return e.error
            except ValueError, e:
                return {'message': e, 'code':-1}
Beispiel #7
0
 def to_python(self, value):
     if not misc.isFloat(value):
         raise forms.ValidationError("Please provide a valid amount eg. 12.3456789")
     
     return float(value)
Beispiel #8
0
    def to_python(self, value):
        if not misc.isFloat(value):
            raise forms.ValidationError(
                "Please provide a valid amount eg. 12.3456789")

        return float(value)