Browse Source

trustedcoin: print messages in both direction when debugging

sqlite_db
SomberNight 6 years ago
parent
commit
d4e209dc3a
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 14
      electrum/plugins/trustedcoin/trustedcoin.py

14
electrum/plugins/trustedcoin/trustedcoin.py

@ -45,7 +45,7 @@ from electrum.mnemonic import Mnemonic
from electrum.wallet import Multisig_Wallet, Deterministic_Wallet
from electrum.i18n import _
from electrum.plugin import BasePlugin, hook
from electrum.util import NotEnoughFunds, UserFacingException
from electrum.util import NotEnoughFunds, UserFacingException, PrintError
from electrum.storage import STO_EV_USER_PW
from electrum.network import Network
from electrum.base_wizard import BaseWizard
@ -111,7 +111,7 @@ class ErrorConnectingServer(Exception):
pass
class TrustedCoinCosignerClient(object):
class TrustedCoinCosignerClient(PrintError):
def __init__(self, user_agent=None, base_url='https://api.trustedcoin.com/2/'):
self.base_url = base_url
self.debug = False
@ -136,21 +136,25 @@ class TrustedCoinCosignerClient(object):
raise ErrorConnectingServer('You are offline.')
url = urljoin(self.base_url, relative_url)
if self.debug:
print('%s %s %s' % (method, url, data))
self.print_error(f'<-- {method} {url} {data}')
headers = {}
if self.user_agent:
headers['user-agent'] = self.user_agent
try:
if method == 'get':
return Network.send_http_on_proxy(method, url, params=data, headers=headers, on_finish=self.handle_response)
response = Network.send_http_on_proxy(method, url, params=data, headers=headers, on_finish=self.handle_response)
elif method == 'post':
return Network.send_http_on_proxy(method, url, json=data, headers=headers, on_finish=self.handle_response)
response = Network.send_http_on_proxy(method, url, json=data, headers=headers, on_finish=self.handle_response)
else:
assert False
except TrustedCoinException:
raise
except Exception as e:
raise ErrorConnectingServer(e)
else:
if self.debug:
self.print_error(f'--> {response}')
return response
def get_terms_of_service(self, billing_plan='electrum-per-tx-otp'):
"""

Loading…
Cancel
Save