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