mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-02 10:15:20 +00:00
trustedcoin: print messages in both direction when debugging
This commit is contained in:
parent
0bf0b1d20b
commit
d4e209dc3a
1 changed files with 9 additions and 5 deletions
|
@ -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…
Add table
Reference in a new issue