Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import psutil
import subprocess
import pkg_resources
import requests
from fastcrc import crc16

from mytoncore.utils import xhex2hex, ng2g
Expand Down Expand Up @@ -1200,14 +1201,35 @@ 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):
self.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}
network_name = self.GetNetworkName()
if network_name == 'testnet':
url = 'https://testnet.toncenter.com/api/v2/sendBoc'
elif network_name == 'mainnet':
url = 'https://toncenter.com/api/v2/sendBoc'
else:
return False
result = requests.post(url=url, json=data)
if result.status_code != 200:
self.local.add_log(f'Failed to send boc to toncenter: {result.content}', 'info')
return False
self.local.add_log('Sent boc to toncenter', 'info')
return True

def WaitTransaction(self, wallet, timeout=30):
self.local.add_log("start WaitTransaction function", "debug")
timesleep = 3
Expand Down