Skip to content

Commit

Permalink
more elegant per address unlock
Browse files Browse the repository at this point in the history
support in PyBtcWallet.lock() for partially unlocked address map
  • Loading branch information
goatpig committed Mar 10, 2014
1 parent 6284aec commit cb6561c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion armoryengine/PyBtcAddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def lock(self, secureKdfOutput=None, generateIVIfNecessary=False):
# Addr should be encrypted, and we already have encrypted priv key
self.binPrivKey32_Plain.destroy()
self.isLocked = True
else:
elif self.binPrivKey32_Plain.getSize()==32:
# Addr should be encrypted, but haven't computed encrypted value yet
if secureKdfOutput!=None:
# We have an encryption key, use it
Expand Down
14 changes: 4 additions & 10 deletions armoryengine/PyBtcWallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2574,15 +2574,6 @@ def signTxDistProposal(self, txdp, hashcode=1):
if self.hasAddr(addr) and self.addrMap[addr].hasPrivKey():
wltAddr.append( (self.addrMap[addr], index, addrIdx) )
break

for entry in wltAddr:
addr = entry[0]
if not isinstance(addr.binPrivKey32_Plain, SecureBinaryData) or addr.binPrivKey32_Plain.getSize() != 32:
#if the private key was not craeted, just unlock the whole wallet
if addr.createPrivKeyNextUnlock:
self.unlock(secureKdfOutput=self.kdfKey)
else:
addr.unlock(self.kdfKey)

# WltAddr now contains a list of every input we can sign for, and the
# PyBtcAddress object that can be used to sign it. Let's do it.
Expand All @@ -2597,7 +2588,10 @@ def signTxDistProposal(self, txdp, hashcode=1):
maxChainIndex = max(maxChainIndex, addrObj.chainIndex)
if addrObj.isLocked:
if self.kdfKey:
addrObj.unlock(self.kdfKey)
if addrObj.createPrivKeyNextUnlock:
self.unlock(self.kdfKey)
else:
addrObj.unlock(self.kdfKey)
else:
self.lock()
raise WalletLockError('Cannot sign tx without unlocking wallet')
Expand Down

0 comments on commit cb6561c

Please sign in to comment.