added address add command and test

This commit is contained in:
Kevin Froman 2018-02-27 15:23:49 -06:00
parent 3033de1d9e
commit d0593ef300
No known key found for this signature in database
GPG key ID: 0D414D0FE405B63B
5 changed files with 63 additions and 4 deletions

View file

@ -71,7 +71,33 @@ class Core:
conn.commit()
conn.close()
return True
def addAddress(self, address):
'''Add an address to the address database (only tor currently)'''
if self._utils.validateID(address):
conn = sqlite3.connect(self.addressDB)
c = conn.cursor()
t = (address, 1)
c.execute('INSERT INTO adders (address, type) VALUES(?, ?);', t)
conn.commit()
conn.close()
return True
else:
return False
def removeAddress(self, address):
'''Remove an address from the address database'''
if self._utils.validateID(address):
conn = sqlite3.connect(self.addressDB)
c = conn.cursor()
t = (address,)
c.execute('Delete from adders where address=?;', t)
conn.commit()
conn.close()
return True
else:
return False
def createAddressDB(self):
'''
Generate the address database