Skip to content

Commit

Permalink
Updated Makefile and code for OSX support.
Browse files Browse the repository at this point in the history
I also fixed a few bugs, including the address ledger not updating
automatically with new zero-conf transactions.
  • Loading branch information
etotheipi committed Feb 2, 2012
1 parent c90c828 commit 553c195
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 55 deletions.
53 changes: 33 additions & 20 deletions ArmoryQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ def newTxFunc(pytxObj):
for wltID,wlt in self.walletMap.iteritems():
TheBDM.rescanWalletZeroConf(self.walletMap[wltID].cppWallet)
#self.walletListChanged()
self.createCombinedLedger()
self.ledgerModel.reset()

self.NetworkingFactory = ArmoryClientFactory( \
Expand Down Expand Up @@ -760,7 +761,6 @@ def loadBlockchain(self):

self.createCombinedLedger()
self.ledgerSize = len(self.combinedLedger)
print 'Ledger entries:', len(self.combinedLedger), 'Max Block:', self.latestBlockNum
self.statusBar().showMessage('Blockchain loaded, wallets sync\'d!', 10000)

if self.isOnline:
Expand Down Expand Up @@ -1276,7 +1276,6 @@ def checkForTxInBDM():

#############################################################################
def execImportWallet(self):
print 'Executing!'
dlg = DlgImportWallet(self, self)
if dlg.exec_():

Expand Down Expand Up @@ -1367,6 +1366,8 @@ def dblClickLedger(self, index):

#############################################################################
def clickSendBitcoins(self):
wltID = None
selectionMade = True
if len(self.walletMap)==0:
reply = QMessageBox.information(self, 'No Wallets!', \
'You cannot send any Bitcoins until you create a wallet and '
Expand All @@ -1375,15 +1376,20 @@ def clickSendBitcoins(self):
if reply==QMessageBox.Yes:
self.createNewWallet(initLabel='Primary Wallet')
return
elif len(self.walletMap)==1:
wltID = self.walletMap.keys()[0]
else:
wltSelect = self.walletsView.selectedIndexes()
if len(wltSelect)>0:
row = wltSelect[0].row()
wltID = str(self.walletsView.model().index(row, WLTVIEWCOLS.ID).data().toString())
dlg = DlgWalletSelect(self, self, 'Send from Wallet...', wltID, onlyMyWallets=False)
if dlg.exec_():
wltID = dlg.selectedID
else:
selectionMade = False

wltSelect = self.walletsView.selectedIndexes()
wltID = None
if len(wltSelect)>0:
row = wltSelect[0].row()
wltID = str(self.walletsView.model().index(row, WLTVIEWCOLS.ID).data().toString())
dlg = DlgWalletSelect(self, self, 'Send from Wallet...', wltID, onlyMyWallets=True)
if dlg.exec_():
wltID = dlg.selectedID
if selectionMade:
wlt = self.walletMap[wltID]
wlttype = determineWalletType(wlt, self)[0]
dlgSend = DlgSendBitcoins(wlt, self, self)
Expand All @@ -1393,6 +1399,8 @@ def clickSendBitcoins(self):
#############################################################################
def clickReceiveCoins(self):

wltID = None
selectionMade = True
if len(self.walletMap)==0:
reply = QMessageBox.information(self, 'No Wallets!', \
'You have not created any wallets which means there is nowhere to '
Expand All @@ -1401,16 +1409,22 @@ def clickReceiveCoins(self):
if reply==QMessageBox.Yes:
self.createNewWallet(initLabel='Primary Wallet')
return
elif len(self.walletMap)==1:
wltID = self.walletMap.keys()[0]
else:
wltSelect = self.walletsView.selectedIndexes()
if len(wltSelect)>0:
row = wltSelect[0].row()
wltID = str(self.walletsView.model().index(row, WLTVIEWCOLS.ID).data().toString())
dlg = DlgWalletSelect(self, self, 'Send from Wallet...', wltID, onlyMyWallets=False)
if dlg.exec_():
wltID = dlg.selectedID
else:
selectionMade = False

wltSelect = self.walletsView.selectedIndexes()
wltID = None
if len(wltSelect)>0:
row = wltSelect[0].row()
wltID = str(self.walletsView.model().index(row, WLTVIEWCOLS.ID).data().toString())
dlg = DlgWalletSelect(self, self, wltID, onlyMyWallets=True)
if dlg.exec_():
wltID = dlg.selectedID
if selectionMade:
wlt = self.walletMap[wltID]
wlttype = determineWalletType(wlt, self)[0]
dlgaddr = DlgNewAddressDisp(wlt, self, self)
dlgaddr.exec_()

Expand All @@ -1421,7 +1435,6 @@ def Heartbeat(self, nextBeatSec=2):
run every 2 seconds, or whatever is specified in the nextBeatSec
argument.
"""
#print '.',
# Check for new blocks in the blk0001.dat file
if TheBDM.isInitialized():
newBlks = TheBDM.readBlkFileUpdate()
Expand Down Expand Up @@ -1512,7 +1525,7 @@ def closeEvent(self, event=None):


pixLogo = QPixmap('img/splashlogo.png')
if options.testnet:
if USE_TESTNET:
pixLogo = QPixmap('img/splashlogo_testnet.png')
SPLASH = QSplashScreen(pixLogo)
SPLASH.setMask(pixLogo.mask())
Expand Down
21 changes: 4 additions & 17 deletions armoryengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ def readVersionInt(verInt):
# Get the host operating system
import platform
opsys = platform.system()
OS_WINDOWS = 'win' in opsys.lower()
OS_LINUX = 'nix' in opsys.lower() or 'nux' in opsys.lower()
OS_MACOSX = 'mac' in opsys.lower() or 'osx' in opsys.lower()
OS_WINDOWS = 'win32' in opsys.lower() or 'windows' in opsys.lower()
OS_LINUX = 'nix' in opsys.lower() or 'nux' in opsys.lower()
OS_MACOSX = 'darwin' in opsys.lower() or 'osx' in opsys.lower()

# Figure out the default directories for Satoshi client, and BicoinArmory
OS_NAME = ''
Expand Down Expand Up @@ -766,20 +766,7 @@ def BDM_LoadBlockchainFile(blkfile=None):
the bdm object.
"""
if blkfile==None:
if not USE_TESTNET:
if 'win' in opsys.lower():
blkfile = os.path.join(os.getenv('APPDATA'), 'Bitcoin', 'blk0001.dat')
if 'nix' in opsys.lower() or 'nux' in opsys.lower():
blkfile = os.path.join(os.getenv('HOME'), '.bitcoin', 'blk0001.dat')
if 'mac' in opsys.lower() or 'osx' in opsys.lower():
blkfile = os.path.expanduser('~/Library/Application Support/Bitcoin/blk0001.dat')
else:
if 'win' in opsys.lower():
blkfile = os.path.join(os.getenv('APPDATA'), 'Bitcoin/testnet', 'blk0001.dat')
if 'nix' in opsys.lower() or 'nux' in opsys.lower():
blkfile = os.path.join(os.getenv('HOME'), '.bitcoin/testnet', 'blk0001.dat')
if 'mac' in opsys.lower() or 'osx' in opsys.lower():
blkfile = os.path.expanduser('~/Library/Application Support/Bitcoin/testnet/blk0001.dat')
blkfile = BLK0001_PATH

if not os.path.exists(blkfile):
raise FileExistsError, ('File does not exist: %s' % blkfile)
Expand Down
20 changes: 11 additions & 9 deletions cppForSwig/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
COMPILER = g++
#COMPILER_OPTS = -c -g -Wall -D_DEBUG
COMPILER_OPTS = -c -march=native -O2 -pipe
COMPILER_OPTS = -c -O2 -pipe


LINKER = g++
Expand All @@ -10,7 +10,7 @@ OBJS = UniversalTimer.o BinaryData.o BtcUtils.o BlockObj.o BlockObjRef.o BlockUt
# but ever since adding AES, I've found that I need to link to the
# installed libraries...
INCLUDE_OPTS += -I/usr/include/cryptopp -Icryptopp -fPIC -DUSE_CRYPTOPP -D__STDC_LIMIT_MACROS
LIBRARY_OPTS += -lcryptopp -lpthread
LIBRARY_OPTS += -lcryptopp -lpthread -lpython2.7
SWIG_INC += -I/usr/include/python2.7

SWIG_OPTS += -c++ -python -classic
Expand All @@ -19,8 +19,10 @@ SWIG_OPTS += -c++ -python -classic

ifneq (exists, $(shell [ -d /usr/include/python2.7 ] && echo exists ))
SWIG_INC = -I/usr/include/python2.6
LIBRARY_OPTS = -lcryptopp -lpthread -lpython2.6
ifneq (exists, $(shell [ -d /usr/include/python2.6 ] && echo exists ))
SWIG_INC = -I/usr/include/python2.5
LIBRARY_OPTS = -lcryptopp -lpthread -lpython2.5
endif
endif

Expand All @@ -38,25 +40,25 @@ BlockUtilsTest.out : $(OBJS) BlockUtilsTest.cpp
# Rules for performing the compilation of each individual object file.

UniversalTimer.o: UniversalTimer.h UniversalTimer.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) $(LIBRARY_OPTS) UniversalTimer.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) UniversalTimer.cpp

BinaryData.o: BinaryData.h BinaryData.cpp BtcUtils.h
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) $(LIBRARY_OPTS) BinaryData.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) BinaryData.cpp

BtcUtils.o: BtcUtils.h BtcUtils.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) $(LIBRARY_OPTS) BtcUtils.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) BtcUtils.cpp

BlockObj.o: BinaryData.h BtcUtils.h BlockObjRef.h BlockObj.h BlockObj.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) $(LIBRARY_OPTS) BlockObj.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) BlockObj.cpp

BlockObjRef.o: BinaryData.h BtcUtils.h BlockObj.h BlockObjRef.h BlockObjRef.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) $(LIBRARY_OPTS) BlockObjRef.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) BlockObjRef.cpp

BlockUtils.o: BlockUtils.h BinaryData.h UniversalTimer.h BlockUtils.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) $(LIBRARY_OPTS) BlockUtils.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) BlockUtils.cpp

EncryptionUtils.o: BtcUtils.h BinaryData.h EncryptionUtils.h EncryptionUtils.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) $(LIBRARY_OPTS) EncryptionUtils.cpp
$(COMPILER) $(COMPILER_OPTS) $(INCLUDE_OPTS) EncryptionUtils.cpp

CppBlockUtils_wrap.cxx: BlockUtils.h BinaryData.h BlockObj.h BlockObjRef.h UniversalTimer.h BlockUtils.h BlockUtils.cpp CppBlockUtils.i
swig $(SWIG_OPTS) -outdir ../ -v CppBlockUtils.i
Expand Down
13 changes: 4 additions & 9 deletions qtdialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3222,7 +3222,7 @@ def __init__(self, parent=None, main=None, title='Select Wallet:', \
lbls.append( QLabel("Wallet ID:") )
lbls.append( QLabel("Name:"))
lbls.append( QLabel("Description:"))
lbls.append( QLabel("Current Balance:"))
lbls.append( QLabel("Spendable Balance:"))

for i in range(len(lbls)):
lbls[i].setAlignment(Qt.AlignLeft | Qt.AlignTop)
Expand Down Expand Up @@ -3315,7 +3315,7 @@ def getWalletInfoFrame(wlt):
lbls.append( QLabel("Wallet ID:") )
lbls.append( QLabel("Name:"))
lbls.append( QLabel("Description:"))
lbls.append( QLabel("Current Balance:"))
lbls.append( QLabel("Spendable Balance:"))

for i in range(len(lbls)):
lbls[i].setAlignment(Qt.AlignLeft | Qt.AlignTop)
Expand All @@ -3331,7 +3331,7 @@ def getWalletInfoFrame(wlt):
# Format balance if necessary
bal = wlt.getBalance('Spendable')
if bal==0: dispBal.setText('<font color="red"><b>0.0000</b></font>')
else: dispBal.setText('<b>'+coin2str(bal, maxZeros=1)+'</b>')
else: dispBal.setText('<font color="green"><b>'+coin2str(bal, maxZeros=1)+'</font></b>')

dispBal.setTextFormat(Qt.RichText)
dispDescr.setWordWrap(True)
Expand Down Expand Up @@ -3678,8 +3678,6 @@ def createTxAndBroadcast(self):
return


print self.origRVPairs
print self.comments
commentStr = ''
if len(self.comments)==1:
commentStr = self.comments[0]
Expand All @@ -3689,14 +3687,11 @@ def createTxAndBroadcast(self):
if len(self.comments[i].strip())>0:
commentStr += '%s (%s); ' % (self.comments[i], coin2str_approx(amt).strip())

print commentStr

txdp = self.wlt.signTxDistProposal(txdp)
finalTx = txdp.prepareFinalTx()
if len(commentStr)>0:
self.wlt.setComment(finalTx.getHash(), commentStr)
print self.wlt.commentsMap
print '\n\n'
print binary_to_hex(finalTx.serialize())
print txdp.serializeAscii()
self.main.broadcastTransaction(finalTx)
Expand Down Expand Up @@ -5913,7 +5908,7 @@ def showContextMenuTxOut(self, pos):
s = self.txOutView.model().index(idx.row(), TXOUTCOLS.Recip).data().toString()
elif action==actCopyAmount:
s = self.txOutView.model().index(idx.row(), TXOUTCOLS.Btc).data().toString()
elif dev and action==actCopyAmount:
elif dev and action==actCopyScript:
s = self.txOutView.model().index(idx.row(), TXOUTCOLS.Script).data().toString()
else:
return
Expand Down

0 comments on commit 553c195

Please sign in to comment.