bisq-api-reference/python-examples/rpccalls/create_crypto_currency_payment_account.py
ghubstan cffbfcf481
Split API examples & doc generator into separate modules
This might give Python devs an easier time than if all the sample
code lived deep inside a gradle project.  This means there is
no root project gradle build file;  the reference-doc-builder and
java-examples modules are separate java projects, with their own
build files.
2022-03-16 17:21:25 -03:00

29 lines
1008 B
Python

from builtins import print
import grpc
# from getpass import getpass
import bisq.api.grpc_pb2 as bisq_messages
import bisq.api.grpc_pb2_grpc as bisq_service
def main():
grpc_channel = grpc.insecure_channel('localhost:9998')
grpc_service_stub = bisq_service.PaymentAccountsStub(grpc_channel)
api_password: str = 'xyz' # getpass("Enter API password: ")
try:
response = grpc_service_stub.CreateCryptoCurrencyPaymentAccount.with_call(
bisq_messages.CreateCryptoCurrencyPaymentAccountRequest(
account_name='name',
currency_code='XMR',
address='472CJ9TADoeVabhAe6byZQN4yqAFA4morKiyzb8DfLTj4hcQvsXNHxJUNYMw1JDmMALkQ3Bwmyn4aZYST7DzEw9nUeUTKVL',
trade_instant=False),
metadata=[('password', api_password)])
print('Response: ' + str(response[0].payment_account))
except grpc.RpcError as rpc_error:
print('gRPC API Exception: %s', rpc_error)
if __name__ == '__main__':
main()