Example #1
0
    def add_address(self,wallet_id,address):
        try:
            db = Database()
            conn = db.get_connection()
            cursor = db.get_cursor()
            if cursor == 0:
                return 0
        except:
            return 0

        if isinstance(wallet_id,int):
            cursor.execute(""" INSERT INTO `addresses_table`(wallet_id, address) VALUES ({},'{}') """.format(wallet_id,address))
            conn.commit()
        else:
            return 0
Example #2
0
    def get_wallets(self):
        try:
            db = Database()
            conn = db.get_connection()
            cursor = db.get_cursor()
            if cursor == 0:
                return 0
        except:
            return 0

        status = cursor.execute(""" SELECT * FROM `wallets_table` """)

        if status > 0:
            data = cursor.fetchall()
            return data
        else:
            return 0
Example #3
0
    def get_wallet(self,wallet_id):
        try:
            db = Database()
            conn = db.get_connection()
            cursor = db.get_cursor()
            if cursor == 0:
                return 0
        except:
            return 0


        status = cursor.execute(""" SELECT * FROM `wallets_table` WHERE wallet_id={}""".format(int(wallet_id)))

        if status > 0:
            data = cursor.fetchone()
            return data
        else:
            return 0
Example #4
0
    def get_wallet_addresses(self, wallet_id):
        try:
            db = Database()
            conn = db.get_connection()
            cursor = db.get_cursor()  # Note : Ordinary List Cursor
            if cursor == 0:
                return 0
        except:
            return 0

        address_list = []
        if isinstance(wallet_id,int):
            cursor.execute(""" SELECT address FROM `addresses_table` WHERE wallet_id={}""".format(wallet_id))
            data = cursor.fetchall()
            for i in data:
                address_list.append(i['address'])
            return address_list
        else:
            return 0
Example #5
0
    def add_wallet(self, wallet_name, wallet_desc, wallet_type):
        try:
            db = Database()
            conn = db.get_connection()
            cursor = db.get_cursor()
            if cursor == 0:
                return 0
        except:
            return 0

        wallet_id = int(str(random.randint(1,9)) + str(random.randint(1,9)) + str(random.randint(1,9)) + str(random.randint(1,9)) + str(random.randint(1,9)) + str(random.randint(1,9)))

        if isinstance(wallet_name,str) and isinstance(wallet_desc,str) and isinstance(wallet_type,str):
           if len(wallet_name) > 2 and len(wallet_type) > 1:
               status = cursor.execute("""INSERT INTO `wallets_table`(wallet_id, wallet_name, wallet_desc, wallet_type) VALUES ('{}','{}','{}','{}')""".format(wallet_id,wallet_name,wallet_desc,wallet_type))
               conn.commit()
               return 1
        else:
           return 0
Example #6
0
    def update_balance(self, wallet_id, balance):
        try:
            db = Database()
            conn = db.get_connection()
            cursor = db.get_cursor()
            if cursor == 0:
                return 0
        except:
            return 0

        if isinstance(balance,float) and isinstance(wallet_id,int):
            status = cursor.execute("UPDATE `wallets_table` SET wallet_balance={} WHERE wallet_id={}".format(balance,wallet_id))
            conn.commit()
            if status == 0:
                return 0
            else:
                return 1
        else:
            return 0