Skip to content

Commit

Permalink
Merge branch 'armoryd'
Browse files Browse the repository at this point in the history
Some under-the-hood updates for handling reorgs and file splits better.
Also added "fragmented backup" command-line utility.   See the extras/
directory (frag and unfrag.py)
  • Loading branch information
etotheipi committed Mar 6, 2013
2 parents 7c3c8b1 + 19db205 commit ea0eccd
Show file tree
Hide file tree
Showing 35 changed files with 3,095 additions and 573 deletions.
68 changes: 18 additions & 50 deletions ArmoryQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1805,51 +1805,6 @@ def createCombinedLedger(self, wltIDList=None, withZeroConf=True):
TimerStop('createCombinedLedger')


#############################################################################
def getFeeForTx(self, txHash):
if TheBDM.isInitialized():
txref = TheBDM.getTxByHash(txHash)
if not txref.isInitialized():
LOGERROR('Why no txref? %s', binary_to_hex(txHash))
return 0
valIn, valOut = 0,0
for i in range(txref.getNumTxIn()):
valIn += TheBDM.getSentValue(txref.getTxIn(i))
for i in range(txref.getNumTxOut()):
valOut += txref.getTxOut(i).getValue()
return valIn - valOut


#############################################################################
def determineSentToSelfAmt(self, le, wlt):
"""
NOTE: this method works ONLY because we always generate a new address
whenever creating a change-output, which means it must have a
higher chainIndex than all other addresses. If you did something
creative with this tx, this may not actually work.
"""
amt = 0
if TheBDM.isInitialized() and le.isSentToSelf():
txref = TheBDM.getTxByHash(le.getTxHash())
if not txref.isInitialized():
return (0, 0)
if txref.getNumTxOut()==1:
return (txref.getTxOut(0).getValue(), -1)
maxChainIndex = -5
txOutChangeVal = 0
txOutIndex = -1
valSum = 0
for i in range(txref.getNumTxOut()):
valSum += txref.getTxOut(i).getValue()
addr160 = txref.getTxOut(i).getRecipientAddr()
addr = wlt.getAddrByHash160(addr160)
if addr and addr.chainIndex > maxChainIndex:
maxChainIndex = addr.chainIndex
txOutChangeVal = txref.getTxOut(i).getValue()
txOutIndex = i

amt = valSum - txOutChangeVal
return (amt, txOutIndex)


#############################################################################
Expand Down Expand Up @@ -1880,7 +1835,7 @@ def convertLedgerToTable(self, ledger):
# for change , which means the change address MUST have a higher
# chain index
if le.isSentToSelf():
amt = self.determineSentToSelfAmt(le, wlt)[0]
amt = determineSentToSelfAmt(le, wlt)[0]


if le.getBlockNum() >= 0xffffffff: nConf = 0
Expand Down Expand Up @@ -2017,13 +1972,22 @@ def updateAddressCommentFromView(self, view, wlt):


#############################################################################
def getAddrCommentIfAvail(self, txHash):
def getAddrCommentIfAvailAll(self, txHash):
TimerStart('getAddrCommentIfAvail')
if not TheBDM.isInitialized():
TimerStop('getAddrCommentIfAvail')
return ''
else:

appendedComments = []
for wltID,wlt in self.walletMap.iteritems():
cmt = wlt.getAddrCommentIfAvail(txHash)
if len(cmt)>0:
appendedComments.append(cmt)

return '; '.join(appendedComments)

"""
# If we haven't extracted relevant addresses for this tx, yet -- do it
if not self.txAddrMap.has_key(txHash):
self.txAddrMap[txHash] = []
Expand All @@ -2045,13 +2009,16 @@ def getAddrCommentIfAvail(self, txHash):
TimerStop('getAddrCommentIfAvail')
return '; '.join(addrComments)
"""


#############################################################################
def getCommentForLE(self, wltID, le):
# Smart comments for LedgerEntry objects: get any direct comments ...
# if none, then grab the one for any associated addresses.
wlt = self.walletMap[wltID]

return self.walletMap[wltID].getCommentForLE(le)
"""
txHash = le.getTxHash()
if wlt.commentsMap.has_key(txHash):
comment = wlt.commentsMap[txHash]
Expand All @@ -2062,6 +2029,7 @@ def getCommentForLE(self, wltID, le):
comment = ''
return comment
"""



Expand Down Expand Up @@ -2957,7 +2925,7 @@ def exportLogFile(self):
reply = MsgBoxCustom(MSGBOX.Warning, 'Privacy Warning', \
'The log file contains information that may be considered sensitive '
'by some users. Log files should be protected the same '
'way you would protect a watcing-only wallet, though it '
'way you would protect a watching-only wallet, though it '
'usually contains much less information than that. '
'<br><br>'
'<b>No private key data is ever written to the log file</b>. '
Expand Down Expand Up @@ -3504,7 +3472,7 @@ def doTheSystemTrayThing(self):

self.notifyQueue[i][2] = True
if le.isSentToSelf():
amt = self.determineSentToSelfAmt(le, wlt)[0]
amt = determineSentToSelfAmt(le, wlt)[0]
self.sysTray.showMessage('Your bitcoins just did a lap!', \
'Wallet "%s" (%s) just sent %s BTC to itself!' % \
(wlt.labelName, wltID, coin2str(amt,maxZeros=1).strip()),
Expand Down
57 changes: 57 additions & 0 deletions LICENSE_qt4reactor.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Copyright (c) 2001-2010
Allen Short
Andy Gayton
Andrew Bennetts
Antoine Pitrou
Apple Computer, Inc.
Benjamin Bruheim
Bob Ippolito
Canonical Limited
Christopher Armstrong
David Reid
Donovan Preston
Eric Mangold
Eyal Lotem
Itamar Shtull-Trauring
James Knight
Jason A. Mobarak
Jean-Paul Calderone
Jessica McKellar
Jonathan Jacobs
Jonathan Lange
Jonathan D. Simms
Jürgen Hermann
Kevin Horn
Kevin Turner
Mary Gardiner
Matthew Lefkowitz
Massachusetts Institute of Technology
Moshe Zadka
Paul Swartz
Pavel Pergamenshchik
Ralph Meijer
Sean Riley
Software Freedom Conservancy
Travis B. Hartwell
Thijs Triemstra
Thomas Herve
Timothy Allen

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 comments on commit ea0eccd

Please sign in to comment.