safeheron-api-sdk-python 1.1.22__tar.gz → 1.1.23__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/LICENSE +1 -1
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/PKG-INFO +1 -1
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/api/gas_api.py +8 -2
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/tools.py +0 -53
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python.egg-info/PKG-INFO +1 -1
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/setup.py +1 -1
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/README.rst +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/api/account_api.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/api/api_key_management_api.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/api/coin_api.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/api/compliance_api.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/api/mpc_sign_api.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/api/tools_api.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/api/transaction_api.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/api/web3_api.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/api/webhook_api.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/api/whitelist_api.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/client.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/cosigner/co_signer_converter.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python/webhook/webhook_converter.py +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python.egg-info/SOURCES.txt +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python.egg-info/dependency_links.txt +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python.egg-info/requires.txt +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/safeheron_api_sdk_python.egg-info/top_level.txt +0 -0
- {safeheron_api_sdk_python-1.1.22 → safeheron_api_sdk_python-1.1.23}/setup.cfg +0 -0
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
from safeheron_api_sdk_python.client import *
|
|
2
|
+
|
|
3
|
+
class GasStatusRequest:
|
|
4
|
+
def __init__(self):
|
|
5
|
+
# networkMode
|
|
6
|
+
self.networkMode = None
|
|
7
|
+
|
|
2
8
|
class GasTransactionsGetByTxKeyRequest:
|
|
3
9
|
def __init__(self):
|
|
4
10
|
# Transaction key, obtained from transactions created via the Create a Transaction V3 API, App, or Web Console.
|
|
@@ -12,8 +18,8 @@ class GasApi:
|
|
|
12
18
|
|
|
13
19
|
# Retrieve Gas Balance
|
|
14
20
|
# Retrieve your Gas balance for the TRON energy rental service.
|
|
15
|
-
def gas_status(self):
|
|
16
|
-
return self.api_client.send_request(
|
|
21
|
+
def gas_status(self, request: GasStatusRequest):
|
|
22
|
+
return self.api_client.send_request(request, '/v1/gas/status')
|
|
17
23
|
|
|
18
24
|
# Retrieve Automatic Gas Records for Transactions
|
|
19
25
|
# When the TRON energy rental service is enabled, Safeheron automatically tops up the required Gas fees for TRON network transactions. This API allows you to query the energy rental records used by a transaction. A single transaction may have multiple records. The actual Gas fee consumed by the transaction is the sum of all records with SUCCESS and FAILURE_GAS_CONSUMED statuses.
|
|
@@ -274,59 +274,6 @@ def decrypt_response(response_dict, platform_rsa_pk, api_user_rsa_sk):
|
|
|
274
274
|
|
|
275
275
|
return json.loads(r.decode())
|
|
276
276
|
|
|
277
|
-
#Used for webhook decryption callback request data
|
|
278
|
-
def decrypt_request(response_dict, verify_rsa_pk, decrypt_rsa_sk):
|
|
279
|
-
verify_rsa_pk = get_rsa_key(PEM_PUBLIC_HEAD + verify_rsa_pk + PEM_PUBLIC_END)
|
|
280
|
-
decrypt_rsa_sk = get_rsa_key(decrypt_rsa_sk)
|
|
281
|
-
# 1 rsa verify
|
|
282
|
-
sig = response_dict.pop('sig')
|
|
283
|
-
need_sign_message = sort_request(response_dict)
|
|
284
|
-
v = rsa_verify(verify_rsa_pk, need_sign_message, sig)
|
|
285
|
-
if not v:
|
|
286
|
-
raise Exception("rsa verify: false")
|
|
287
|
-
|
|
288
|
-
# 2 get aes key and iv
|
|
289
|
-
aes_data = rsa_decrypt(decrypt_rsa_sk, response_dict['key'])
|
|
290
|
-
aes_key = aes_data[0:32]
|
|
291
|
-
aes_iv = aes_data[32:48]
|
|
292
|
-
|
|
293
|
-
# 3 aes decrypt data, get response data
|
|
294
|
-
r = aes_decrypt(aes_key, aes_iv, b64decode(response_dict['bizContent']))
|
|
295
|
-
|
|
296
|
-
return json.loads(r.decode())
|
|
297
|
-
|
|
298
|
-
#For webhook to send encrypted response content
|
|
299
|
-
def encrypt_response(raw_data,encrpyt_rsa_pk, sign_rsa_sk):
|
|
300
|
-
encrpyt_rsa_pk = get_rsa_key(PEM_PUBLIC_HEAD + encrpyt_rsa_pk + PEM_PUBLIC_END)
|
|
301
|
-
sign_rsa_sk = get_rsa_key(sign_rsa_sk)
|
|
302
|
-
ret = dict()
|
|
303
|
-
# prepare aes key and iv
|
|
304
|
-
aes_key = get_random_bytes(32)
|
|
305
|
-
aes_iv = get_random_bytes(16)
|
|
306
|
-
res_data = json.dumps(raw_data).replace('\n', '').encode('utf-8')
|
|
307
|
-
|
|
308
|
-
# 1 rsa encrypt aes key + iv
|
|
309
|
-
aes_data = aes_key + aes_iv
|
|
310
|
-
ret['key'] = rsa_encrypt(encrpyt_rsa_pk, aes_data)
|
|
311
|
-
|
|
312
|
-
# 2 aes encrypt request data
|
|
313
|
-
aes_encrypted_bytes = aes_encrypt(aes_key, aes_iv, res_data)
|
|
314
|
-
ret['bizContent'] = b64encode(aes_encrypted_bytes).decode()
|
|
315
|
-
|
|
316
|
-
# 3 set timestamp , no need to add
|
|
317
|
-
ret['timestamp'] = str(int(time.time() * 1000))
|
|
318
|
-
|
|
319
|
-
# 4 code
|
|
320
|
-
ret['code'] = "200"
|
|
321
|
-
|
|
322
|
-
# 5 message
|
|
323
|
-
ret['message'] = "callback_ok"
|
|
324
|
-
|
|
325
|
-
# 6 sign request
|
|
326
|
-
need_sign_message = sort_request(ret)
|
|
327
|
-
ret['sig'] = rsa_sign(sign_rsa_sk, need_sign_message)
|
|
328
|
-
return ret
|
|
329
|
-
|
|
330
277
|
def rsa_gen_key():
|
|
331
278
|
rsa_key = RSA.generate(4096)
|
|
332
279
|
sk = rsa_key.export_key()
|
|
@@ -3,7 +3,7 @@ from setuptools import find_packages
|
|
|
3
3
|
with open("README.rst", "r") as f:
|
|
4
4
|
long_description = f.read()
|
|
5
5
|
setup(name='safeheron_api_sdk_python',
|
|
6
|
-
version='1.1.
|
|
6
|
+
version='1.1.23',
|
|
7
7
|
description='Python for Safeheron API',
|
|
8
8
|
long_description=long_description,
|
|
9
9
|
author='safeheron',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|