electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit d4e209dc3a684c1565a6902f9223fa423e60ed4a
parent 0bf0b1d20be25bf77a553d644a651f04bc2dd783
Author: SomberNight <somber.night@protonmail.com>
Date:   Mon, 18 Feb 2019 18:03:42 +0100

trustedcoin: print messages in both direction when debugging

Diffstat:
Melectrum/plugins/trustedcoin/trustedcoin.py | 14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/electrum/plugins/trustedcoin/trustedcoin.py b/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'): """