From 9846c732b5b18b3a906d81c299af3f16ce3a3cff Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 1 Feb 2024 18:54:02 +0700 Subject: [PATCH 1/2] add duplicating externals to toncenter --- mytoncore.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mytoncore.py b/mytoncore.py index fd1a9671..6aee5760 100755 --- a/mytoncore.py +++ b/mytoncore.py @@ -1430,14 +1430,28 @@ def SendFile(self, filePath, wallet=None, **kwargs): wallet.oldseqno = self.GetSeqno(wallet) self.liteClient.Run("sendfile " + filePath) if duplicateSendfile: - self.liteClient.Run("sendfile " + filePath, useLocalLiteServer=False) - self.liteClient.Run("sendfile " + filePath, useLocalLiteServer=False) + self.send_boc_toncenter(filePath) + # self.liteClient.Run("sendfile " + filePath, useLocalLiteServer=False) + # self.liteClient.Run("sendfile " + filePath, useLocalLiteServer=False) if timeout and wallet: self.WaitTransaction(wallet, timeout) if remove == True: os.remove(filePath) #end define + def send_boc_toncenter(self, file_path: str): + local.add_log('Start send_boc_toncenter function: ' + file_path, 'debug') + with open(file_path, "rb") as f: + boc = f.read() + boc_b64 = base64.b64encode(boc).decode("utf-8") + data = {"boc": boc_b64} + result = requests.post(url='https://toncenter.com/api/v2/sendBoc', json=data) + if result.status_code != 200: + local.add_log(f'Failed to send boc to toncenter: {result.content}', 'info') + return False + local.add_log('Sent boc to toncenter', 'info') + return True + def WaitTransaction(self, wallet, timeout=30): local.add_log("start WaitTransaction function", "debug") timesleep = 3 From cfc85fc2ae0980bcc3f5e69734453d8619f480eb Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 1 Feb 2024 19:02:29 +0700 Subject: [PATCH 2/2] add testnet support to sending bocs via toncenter --- mytoncore.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mytoncore.py b/mytoncore.py index 6aee5760..db2dca60 100755 --- a/mytoncore.py +++ b/mytoncore.py @@ -1445,7 +1445,11 @@ def send_boc_toncenter(self, file_path: str): boc = f.read() boc_b64 = base64.b64encode(boc).decode("utf-8") data = {"boc": boc_b64} - result = requests.post(url='https://toncenter.com/api/v2/sendBoc', json=data) + if self.GetNetworkName() == 'testnet': + url = 'https://testnet.toncenter.com/api/v2/sendBoc' + else: + url = 'https://toncenter.com/api/v2/sendBoc' + result = requests.post(url=url, json=data) if result.status_code != 200: local.add_log(f'Failed to send boc to toncenter: {result.content}', 'info') return False