Skip to content

Commit 9846c73

Browse files
committed
add duplicating externals to toncenter
1 parent b9d5937 commit 9846c73

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

mytoncore.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,14 +1430,28 @@ def SendFile(self, filePath, wallet=None, **kwargs):
14301430
wallet.oldseqno = self.GetSeqno(wallet)
14311431
self.liteClient.Run("sendfile " + filePath)
14321432
if duplicateSendfile:
1433-
self.liteClient.Run("sendfile " + filePath, useLocalLiteServer=False)
1434-
self.liteClient.Run("sendfile " + filePath, useLocalLiteServer=False)
1433+
self.send_boc_toncenter(filePath)
1434+
# self.liteClient.Run("sendfile " + filePath, useLocalLiteServer=False)
1435+
# self.liteClient.Run("sendfile " + filePath, useLocalLiteServer=False)
14351436
if timeout and wallet:
14361437
self.WaitTransaction(wallet, timeout)
14371438
if remove == True:
14381439
os.remove(filePath)
14391440
#end define
14401441

1442+
def send_boc_toncenter(self, file_path: str):
1443+
local.add_log('Start send_boc_toncenter function: ' + file_path, 'debug')
1444+
with open(file_path, "rb") as f:
1445+
boc = f.read()
1446+
boc_b64 = base64.b64encode(boc).decode("utf-8")
1447+
data = {"boc": boc_b64}
1448+
result = requests.post(url='https://toncenter.com/api/v2/sendBoc', json=data)
1449+
if result.status_code != 200:
1450+
local.add_log(f'Failed to send boc to toncenter: {result.content}', 'info')
1451+
return False
1452+
local.add_log('Sent boc to toncenter', 'info')
1453+
return True
1454+
14411455
def WaitTransaction(self, wallet, timeout=30):
14421456
local.add_log("start WaitTransaction function", "debug")
14431457
timesleep = 3

0 commit comments

Comments
 (0)