From 707d828e341ad0102b9c3e5a66222da6bc3bf1fa Mon Sep 17 00:00:00 2001 From: etotheipi Date: Wed, 1 Feb 2012 19:40:24 -0500 Subject: [PATCH] Updated Makefile and code for OSX support. I also fixed a few bugs, including the address ledger not updating automatically with new zero-conf transactions. --- ArmoryQt.py | 51 ++++++++++++++++++++++++++++----------------- armoryengine.py | 21 ++++--------------- cppForSwig/Makefile | 20 ++++++++++-------- qtdialogs.py | 13 ++++-------- 4 files changed, 51 insertions(+), 54 deletions(-) diff --git a/ArmoryQt.py b/ArmoryQt.py index caed28536..1dbbbf821 100644 --- a/ArmoryQt.py +++ b/ArmoryQt.py @@ -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( \ @@ -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: @@ -1276,7 +1276,6 @@ def checkForTxInBDM(): ############################################################################# def execImportWallet(self): - print 'Executing!' dlg = DlgImportWallet(self, self) if dlg.exec_(): @@ -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 ' @@ -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) @@ -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 ' @@ -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_() @@ -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() diff --git a/armoryengine.py b/armoryengine.py index b150b4246..e1287aaaa 100644 --- a/armoryengine.py +++ b/armoryengine.py @@ -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 = '' @@ -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) diff --git a/cppForSwig/Makefile b/cppForSwig/Makefile index 5e9dfd46c..01d0acbd8 100755 --- a/cppForSwig/Makefile +++ b/cppForSwig/Makefile @@ -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++ @@ -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 @@ -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 @@ -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 diff --git a/qtdialogs.py b/qtdialogs.py index f8283e7c0..457f375c6 100755 --- a/qtdialogs.py +++ b/qtdialogs.py @@ -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) @@ -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) @@ -3331,7 +3331,7 @@ def getWalletInfoFrame(wlt): # Format balance if necessary bal = wlt.getBalance('Spendable') if bal==0: dispBal.setText('0.0000') - else: dispBal.setText(''+coin2str(bal, maxZeros=1)+'') + else: dispBal.setText(''+coin2str(bal, maxZeros=1)+'') dispBal.setTextFormat(Qt.RichText) dispDescr.setWordWrap(True) @@ -3678,8 +3678,6 @@ def createTxAndBroadcast(self): return - print self.origRVPairs - print self.comments commentStr = '' if len(self.comments)==1: commentStr = self.comments[0] @@ -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) @@ -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