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
22 changes: 20 additions & 2 deletions mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1430,14 +1430,32 @@ 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}
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
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
Expand Down