Skip to content

Commit

Permalink
Initial attempt at Namecoin support
Browse files Browse the repository at this point in the history
  • Loading branch information
josephbisch committed Nov 13, 2014
1 parent e755986 commit 90351e1
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 73 deletions.
34 changes: 25 additions & 9 deletions ArmoryQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ def __init__(self, parent=None):
self.lblLogoIcon.setPixmap(QPixmap(':/armory_logo_green_h56.png'))
if Colors.isDarkBkgd:
self.lblLogoIcon.setPixmap(QPixmap(':/armory_logo_white_text_green_h56.png'))
elif USE_NAMECOIN:
self.setWindowTitle('Armory - Namecoin Wallet Management')
self.iconfile = ':/armory_icon_32x32.png'
self.lblLogoIcon.setPixmap(QPixmap(':/armory_logo_h44.png'))
if Colors.isDarkBkgd:
self.lblLogoIcon.setPixmap(QPixmap(':/armory_logo_white_text_h65.png'))
elif USE_NAMECOIN_TESTNET:
self.setWindowTitle('Armory - Namecoin Wallet Management [TESTNET]')
self.iconfile = ':/armory_icon_green_32x32.png'
self.lblLogoIcon.setPixmap(QPixmap(':/armory_logo_green_h56.png'))
if Colors.isDarkBkgd:
self.lblLogoIcon.setPixmap(QPixmap(':/armory_logo_white_text_green_h56.png'))
else:
self.setWindowTitle('Armory - Bitcoin Wallet Management')
self.iconfile = ':/armory_icon_32x32.png'
Expand All @@ -115,7 +127,7 @@ def __init__(self, parent=None):
self.setWindowIcon(QIcon(self.iconfile))
else:
self.notifCtr = ArmoryMac.MacNotificationHandler.None
if USE_TESTNET:
if USE_TESTNET or USE_NAMECOIN_TESTNET:
self.iconfile = ':/armory_icon_green_fullres.png'
ArmoryMac.MacDockIconHandler.instance().setMainWindow(self)
ArmoryMac.MacDockIconHandler.instance().setIcon(QIcon(self.iconfile))
Expand Down Expand Up @@ -526,7 +538,7 @@ def __init__(self, parent=None):
self.mainDisplayTabs.addTab(self.tabAnnounce, 'Announcements')

##########################################################################
if USE_TESTNET and not CLI_OPTIONS.disableModules:
if (USE_TESTNET or USE_NAMECOIN_TESTNET) and not CLI_OPTIONS.disableModules:
self.loadArmoryModules()
##########################################################################

Expand Down Expand Up @@ -949,7 +961,7 @@ def loadArmoryModules(self):
LOGWARN('Sig on "%s" is valid: %s' % (moduleName, str(isSignedByATI)))


if not isSignedByATI and not USE_TESTNET:
if not isSignedByATI and not (USE_TESTNET or USE_NAMECOIN_TESTNET):
reply = QMessageBox.warning(self, tr("UNSIGNED Module"), tr("""
Armory detected the following module which is
<font color="%s"><b>unsigned</b></font> and may be dangerous:
Expand Down Expand Up @@ -1311,7 +1323,7 @@ def setupSystemTray(self):
self.sysTray = QSystemTrayIcon(self)
self.sysTray.setIcon( QIcon(self.iconfile) )
self.sysTray.setVisible(True)
self.sysTray.setToolTip('Armory' + (' [Testnet]' if USE_TESTNET else ''))
self.sysTray.setToolTip('Armory' + (' [Testnet]' if USE_TESTNET or USE_NAMECOIN_TESTNET else ''))
self.connect(self.sysTray, SIGNAL('messageClicked()'), self.bringArmoryToFront)
self.connect(self.sysTray, SIGNAL('activated(QSystemTrayIcon::ActivationReason)'), \
self.sysTrayActivated)
Expand Down Expand Up @@ -1411,7 +1423,7 @@ def setupUriRegistration(self, justDoIt=False):
"""
LOGINFO('setupUriRegistration')

if USE_TESTNET:
if USE_TESTNET or USE_NAMECOIN or USE_NAMECOIN_TESTNET:
return

if OS_LINUX:
Expand Down Expand Up @@ -5091,8 +5103,12 @@ def updateSyncProgress(self):
lastBlkTime = info['toptime']

# Use a reference point if we are starting from scratch
refBlock = max(290746, lastBlkNum)
refTime = max(1394922889, lastBlkTime)
if COIN == 'Namecoin':
refBlock = max(204428, lastBlkNum)
refTime = max(1415390883, lastBlkTime)
else:
refBlock = max(290746, lastBlkNum)
refTime = max(1394922889, lastBlkTime)


# Ten min/block is pretty accurate, even from genesis (about 1% slow)
Expand Down Expand Up @@ -6904,7 +6920,7 @@ def checkForAlreadyOpenError():
armoryExists.append(proc.pid)
if bexe in proc.name:
LOGINFO('Found bitcoind PID: %d', proc.pid)
if ('testnet' in proc.name) == USE_TESTNET:
if ('testnet' in proc.name) == USE_TESTNET or USE_NAMECOIN_TESTNET:
bitcoindExists.append(proc.pid)

if len(armoryExists)>0:
Expand All @@ -6931,7 +6947,7 @@ def checkForAlreadyOpenError():
checkForAlreadyOpen()

pixLogo = QPixmap(':/splashlogo.png')
if USE_TESTNET:
if USE_TESTNET or USE_NAMECOIN_TESTNET:
pixLogo = QPixmap(':/splashlogo_testnet.png')
SPLASH = QSplashScreen(pixLogo)
SPLASH.setMask(pixLogo.mask())
Expand Down
39 changes: 23 additions & 16 deletions SDM.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
launchProcess, killProcessTree, killProcess, LOGWARN, RightNow, HOUR, \
PyBackgroundThread, touchFile, DISABLE_TORRENTDL, secondsToHumanTime, \
bytesToHumanSize, MAGIC_BYTES, deleteBitcoindDBs, TheTDM, satoshiIsAvailable,\
MEGABYTE, ARMORY_HOME_DIR, CLI_OPTIONS
MEGABYTE, ARMORY_HOME_DIR, CLI_OPTIONS, COIN, USE_NAMECOIN_TESTNET
from bitcoinrpc_jsonrpc import authproxy


Expand Down Expand Up @@ -277,7 +277,10 @@ def shouldTryBootstrapTorrent(self):
LOGINFO('Total size of files in %s is %s' % (blockDir, sizeStr))

# If they have only a small portion of the blockchain, do it
szThresh = 100*MEGABYTE if USE_TESTNET else 6*GIGABYTE
if USE_TESTNET or USE_NAMECOIN_TESTNET:
szThresh = 100*MEGABYTE
else:
szThresh = 6*GIGABYTE
if blockDirSize < szThresh:
return True

Expand Down Expand Up @@ -308,7 +311,7 @@ def setupSDM(self, pathToBitcoindExe=None, satoshiHome=None, \
self.failedFindHome = False
# If we are supplied a path, then ignore the extra exe search paths
if pathToBitcoindExe==None:
pathToBitcoindExe = self.findBitcoind(extraExeSearch)
pathToBitcoindExe = self.findDaemon(extraExeSearch)
if len(pathToBitcoindExe)==0:
LOGDEBUG('Failed to find bitcoind')
self.failedFindExe = True
Expand Down Expand Up @@ -374,15 +377,15 @@ def getAllFoundExe(self):


#############################################################################
def findBitcoind(self, extraSearchPaths=[]):
def findDaemon(self, extraSearchPaths=[]):
self.foundExe = []

searchPaths = list(extraSearchPaths) # create a copy

if OS_WINDOWS:
# Making sure the search path argument comes with /daemon and /Bitcoin on Windows

searchPaths.extend([os.path.join(sp, 'Bitcoin') for sp in searchPaths])
searchPaths.extend([os.path.join(sp, COIN) for sp in searchPaths])
searchPaths.extend([os.path.join(sp, 'daemon') for sp in searchPaths])

possBaseDir = []
Expand All @@ -407,7 +410,7 @@ def findBitcoind(self, extraSearchPaths=[]):
shell = win32com.client.Dispatch('WScript.Shell')
targ = shell.CreateShortCut(path).Targetpath
targDir = os.path.dirname(targ)
LOGINFO('Found Bitcoin-Qt link on desktop: %s', targDir)
LOGINFO('Found %s-Qt link on desktop: %s', COIN, targDir)
possBaseDir.append( targDir )

# Also look in default place in ProgramFiles dirs
Expand All @@ -417,12 +420,12 @@ def findBitcoind(self, extraSearchPaths=[]):

# Now look at a few subdirs of the
searchPaths.extend(possBaseDir)
searchPaths.extend([os.path.join(p, 'Bitcoin', 'daemon') for p in possBaseDir])
searchPaths.extend([os.path.join(p, COIN, 'daemon') for p in possBaseDir])
searchPaths.extend([os.path.join(p, 'daemon') for p in possBaseDir])
searchPaths.extend([os.path.join(p, 'Bitcoin') for p in possBaseDir])
searchPaths.extend([os.path.join(p, COIN) for p in possBaseDir])

for p in searchPaths:
testPath = os.path.join(p, 'bitcoind.exe')
testPath = os.path.join(p, COIN.lower() + '.exe')
if os.path.exists(testPath):
self.foundExe.append(testPath)

Expand All @@ -433,18 +436,18 @@ def findBitcoind(self, extraSearchPaths=[]):
else:
searchPaths.extend([os.path.join(p, 'bin/32') for p in extraSearchPaths])

searchPaths.extend(['/usr/lib/bitcoin/'])
searchPaths.extend(['/usr/lib/' + COIN.lower() + '/'])
searchPaths.extend(os.getenv("PATH").split(':'))

for p in searchPaths:
testPath = os.path.join(p, 'bitcoind')
testPath = os.path.join(p, COIN.lower() + 'd')
if os.path.exists(testPath):
self.foundExe.append(testPath)

try:
locs = subprocess_check_output(['whereis','bitcoind']).split()
locs = subprocess_check_output(['whereis',COIN.lower() + 'd']).split()
if len(locs)>1:
locs = filter(lambda x: os.path.basename(x)=='bitcoind', locs)
locs = filter(lambda x: os.path.basename(x)==COIN.lower() + 'd', locs)
LOGINFO('"whereis" returned: %s', str(locs))
self.foundExe.extend(locs)
except:
Expand All @@ -461,10 +464,10 @@ def findBitcoind(self, extraSearchPaths=[]):
foundIt=True

if not foundIt:
LOGERROR('Bitcoind could not be found in the specified installation:')
LOGERROR(COIN + 'd could not be found in the specified installation:')
for p in extraSearchPaths:
LOGERROR(' %s', p)
LOGERROR('Bitcoind is being started from:')
LOGERROR(COIN + 'd is being started from:')
LOGERROR(' %s', self.foundExe[0])

return self.foundExe
Expand Down Expand Up @@ -607,12 +610,16 @@ def launchBitcoindAndGuardian(self):

pargs = [self.executable]

if USE_TESTNET:
if USE_TESTNET or USE_NAMECOIN_TESTNET:
testhome = self.satoshiHome[:]
if self.satoshiHome.endswith('/testnet3/'):
pargs.append('-datadir=%s' % self.satoshiHome[:-10])
elif self.satoshiHome.endswith('/testnet3'):
pargs.append('-datadir=%s' % self.satoshiHome[:-9])
elif self.satoshiHome.endswith('/testnet/'):
pargs.append('-datadir=%s' % self.satoshiHome[:-9])
elif self.satoshiHome.endswith('/testnet'):
pargs.append('-datadir=%s' % self.satoshiHome[:-8])
pargs.append('-testnet')
else:
pargs.append('-datadir=%s' % self.satoshiHome)
Expand Down
3 changes: 2 additions & 1 deletion armoryd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,8 @@ def jsonrpc_getarmorydinfo(self):
#'proxy': '',
'difficulty': TheBDM.getTopBlockDifficulty() \
if isReady else -1,
'testnet': USE_TESTNET,
'testnet': USE_TESTNET or USE_NAMECOIN_TESTNET,
'chain': COIN
'keypoolsize': self.curWlt.addrPoolSize
}

Expand Down
Loading

0 comments on commit 90351e1

Please sign in to comment.