@@ -197,15 +197,18 @@ def run(self):
197197 self .logger .info ("Quitting..." )
198198
199199 def _getKeysForAddress (self , address ):
200- privSigningKeyBase58 = config .get (
201- address , 'privsigningkey' )
202- privEncryptionKeyBase58 = config .get (
203- address , 'privencryptionkey' )
200+ try :
201+ privSigningKeyBase58 = config .get (address , 'privsigningkey' )
202+ privEncryptionKeyBase58 = config .get (address , 'privencryptionkey' )
203+ except (configparser .NoSectionError , configparser .NoOptionError ):
204+ self .logger .error (
205+ 'Could not read or decode privkey for address %s' , address )
206+ raise ValueError
204207
205- privSigningKeyHex = hexlify (shared . decodeWalletImportFormat (
206- privSigningKeyBase58 ))
207- privEncryptionKeyHex = hexlify (shared . decodeWalletImportFormat (
208- privEncryptionKeyBase58 ))
208+ privSigningKeyHex = hexlify (
209+ highlevelcrypto . decodeWalletImportFormat ( privSigningKeyBase58 ))
210+ privEncryptionKeyHex = hexlify (
211+ highlevelcrypto . decodeWalletImportFormat ( privEncryptionKeyBase58 ))
209212
210213 # The \x04 on the beginning of the public keys are not sent.
211214 # This way there is only one acceptable way to encode
@@ -256,9 +259,7 @@ def doPOWForMyV2Pubkey(self, adressHash):
256259 message once it is done with the POW"""
257260 # Look up my stream number based on my address hash
258261 myAddress = shared .myAddressesByHash [adressHash ]
259- # status
260- _ , addressVersionNumber , streamNumber , adressHash = (
261- decodeAddress (myAddress ))
262+ addressVersionNumber , streamNumber = decodeAddress (myAddress )[1 :3 ]
262263
263264 # 28 days from now plus or minus five minutes
264265 TTL = int (28 * 24 * 60 * 60 + helper_random .randomrandrange (- 300 , 300 ))
@@ -271,17 +272,15 @@ def doPOWForMyV2Pubkey(self, adressHash):
271272 payload += protocol .getBitfield (myAddress )
272273
273274 try :
274- # privSigningKeyHex, privEncryptionKeyHex
275- _ , _ , pubSigningKey , pubEncryptionKey = \
276- self ._getKeysForAddress (myAddress )
277- except (configparser .NoSectionError , configparser .NoOptionError ) as err :
278- self .logger .warning ("Section or Option did not found: %s" , err )
279- except Exception as err :
275+ pubSigningKey , pubEncryptionKey = self ._getKeysForAddress (
276+ myAddress )[2 :]
277+ except ValueError :
278+ return
279+ except Exception : # pylint:disable=broad-exception-caught
280280 self .logger .error (
281281 'Error within doPOWForMyV2Pubkey. Could not read'
282282 ' the keys from the keys.dat file for a requested'
283- ' address. %s\n ' , err
284- )
283+ ' address. %s\n ' , exc_info = True )
285284 return
286285
287286 payload += pubSigningKey + pubEncryptionKey
@@ -320,8 +319,8 @@ def sendOutOrStoreMyV3Pubkey(self, adressHash):
320319 try :
321320 myAddress = shared .myAddressesByHash [adressHash ]
322321 except KeyError :
323- # The address has been deleted.
324- self . logger . warning ( "Can't find %s in myAddressByHash" , hexlify (adressHash ))
322+ self . logger . warning ( # The address has been deleted.
323+ "Can't find %s in myAddressByHash" , hexlify (adressHash ))
325324 return
326325 if config .safeGetBoolean (myAddress , 'chan' ):
327326 self .logger .info ('This is a chan address. Not sending pubkey.' )
@@ -353,14 +352,13 @@ def sendOutOrStoreMyV3Pubkey(self, adressHash):
353352 # , privEncryptionKeyHex
354353 privSigningKeyHex , _ , pubSigningKey , pubEncryptionKey = \
355354 self ._getKeysForAddress (myAddress )
356- except ( configparser . NoSectionError , configparser . NoOptionError ) as err :
357- self . logger . warning ( "Section or Option did not found: %s" , err )
358- except Exception as err :
355+ except ValueError :
356+ return
357+ except Exception : # pylint:disable=broad-exception-caught
359358 self .logger .error (
360359 'Error within sendOutOrStoreMyV3Pubkey. Could not read'
361360 ' the keys from the keys.dat file for a requested'
362- ' address. %s\n ' , err
363- )
361+ ' address. %s\n ' , exc_info = True )
364362 return
365363
366364 payload += pubSigningKey + pubEncryptionKey
@@ -428,14 +426,13 @@ def sendOutOrStoreMyV4Pubkey(self, myAddress):
428426 # , privEncryptionKeyHex
429427 privSigningKeyHex , _ , pubSigningKey , pubEncryptionKey = \
430428 self ._getKeysForAddress (myAddress )
431- except ( configparser . NoSectionError , configparser . NoOptionError ) as err :
432- self . logger . warning ( "Section or Option did not found: %s" , err )
433- except Exception as err :
429+ except ValueError :
430+ return
431+ except Exception : # pylint:disable=broad-exception-caught
434432 self .logger .error (
435433 'Error within sendOutOrStoreMyV4Pubkey. Could not read'
436434 ' the keys from the keys.dat file for a requested'
437- ' address. %s\n ' , err
438- )
435+ ' address. %s\n ' , exc_info = True )
439436 return
440437
441438 dataToEncrypt += pubSigningKey + pubEncryptionKey
@@ -1118,8 +1115,9 @@ def sendMsg(self):
11181115 ' from the keys.dat file for our own address. %s\n ' ,
11191116 err )
11201117 continue
1121- privEncryptionKeyHex = hexlify (shared .decodeWalletImportFormat (
1122- privEncryptionKeyBase58 ))
1118+ privEncryptionKeyHex = hexlify (
1119+ highlevelcrypto .decodeWalletImportFormat (
1120+ privEncryptionKeyBase58 ))
11231121 pubEncryptionKeyBase256 = unhexlify (highlevelcrypto .privToPub (
11241122 privEncryptionKeyHex ))[1 :]
11251123 requiredAverageProofOfWorkNonceTrialsPerByte = \
0 commit comments