From 0a2470ebb7715999064294e994f97ca02ca2d5a5 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Mon, 29 Nov 2021 17:30:39 +0200 Subject: [PATCH] Use BMConfigParser.safeGetBoolean() in the methods for send* API commands --- src/api.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/api.py b/src/api.py index de220cc4..b2833070 100644 --- a/src/api.py +++ b/src/api.py @@ -1117,10 +1117,8 @@ class BMRPCDispatcher(object): toAddress = addBMIfNotPresent(toAddress) fromAddress = addBMIfNotPresent(fromAddress) self._verifyAddress(fromAddress) - try: - fromAddressEnabled = self.config.getboolean( - fromAddress, 'enabled') - except BaseException: + fromAddressEnabled = self.config.safeGetBoolean(fromAddress, 'enabled') + if fromAddressEnabled is None: raise APIError( 13, 'Could not find your fromAddress in the keys.dat file.') if not fromAddressEnabled: @@ -1163,9 +1161,7 @@ class BMRPCDispatcher(object): TTL = 28 * 24 * 60 * 60 fromAddress = addBMIfNotPresent(fromAddress) self._verifyAddress(fromAddress) - try: - self.config.getboolean(fromAddress, 'enabled') - except BaseException: + if not self.config.safeGetBoolean(fromAddress, 'enabled'): raise APIError( 13, 'Could not find your fromAddress in the keys.dat file.') toAddress = str_broadcast_subscribers