mirror of
https://github.com/bisq-network/bisq-api-reference.git
synced 2026-01-26 17:33:33 +00:00
Validate payment-acct-id and shutdown a bit more cleanly
This commit is contained in:
parent
40a0295614
commit
a578ac2b33
@ -396,5 +396,23 @@ class BisqClient(object):
|
||||
currency_code,
|
||||
payment_details)
|
||||
|
||||
def get_payment_account(self, payment_account_id):
|
||||
try:
|
||||
response = self.payment_accts_stub.GetPaymentAccounts.with_call(
|
||||
bisq_messages.GetPaymentAccountsRequest(),
|
||||
metadata=[('password', self.api_password)])
|
||||
payment_accounts = list(response[0].payment_accounts)
|
||||
if len(payment_accounts):
|
||||
payment_accounts_filter = filter(lambda account: (account.id == payment_account_id), payment_accounts)
|
||||
filtered_accounts = list(payment_accounts_filter)
|
||||
if len(filtered_accounts):
|
||||
return filtered_accounts[0]
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
except grpc.RpcError as rpc_error:
|
||||
print('gRPC API Exception: %s', rpc_error)
|
||||
|
||||
def __str__(self):
|
||||
return 'host=' + self.host + ' port=' + self.port + ' api_password=' + '*****'
|
||||
|
||||
@ -69,6 +69,14 @@ class SepaMMBot(BisqClient):
|
||||
self.close_channel()
|
||||
self.is_running = False
|
||||
|
||||
def is_valid_sepa_payment_account_id(self, sepa_payment_account_id):
|
||||
account = self.get_payment_account(sepa_payment_account_id)
|
||||
if account is None:
|
||||
log.error('{0} is not a valid PaymentAccount.id.'.format(sepa_payment_account_id))
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def make_market(self, reference_price_margin,
|
||||
target_spread,
|
||||
amount_in_satoshis,
|
||||
|
||||
@ -70,6 +70,12 @@ def start():
|
||||
|
||||
|
||||
def start_bot():
|
||||
payment_account_exists = bot.is_valid_sepa_payment_account_id(sepa_payment_account_id)
|
||||
if payment_account_exists is False:
|
||||
window.quit()
|
||||
log.error('Shutting down UI.')
|
||||
return
|
||||
|
||||
disable_button(start_button)
|
||||
enable_button(stop_button)
|
||||
reference_price_margin = Decimal(price_margin_input.get())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user