Skip to content
Merged
Show file tree
Hide file tree
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
62 changes: 2 additions & 60 deletions modules/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def view_account_status(self, args):
except:
color_print("{red}Bad args. Usage:{endc} vas <account-addr>")
return
addrB64 = self.get_destination_addr(addrB64)
addrB64 = self.ton.get_destination_addr(addrB64)
account = self.ton.GetAccount(addrB64)
version = self.ton.GetVersionFromCodeHash(account.codeHash)
statusTable = list()
Expand All @@ -34,11 +34,10 @@ def view_account_status(self, args):
print_table(codeHashTable)
print()
print_table(historyTable)

# end define

def get_history_table(self, addr, limit):
addr = self.get_destination_addr(addr)
addr = self.ton.get_destination_addr(addr)
account = self.ton.GetAccount(addr)
history = self.ton.GetAccountHistory(account, limit)
table = list()
Expand Down Expand Up @@ -73,61 +72,6 @@ def view_account_history(self, args):
print_table(table)
# end define

def get_destination_addr(self, destination):
if self.ton.IsAddrB64(destination):
pass
elif self.ton.IsAddrFull(destination):
destination = self.ton.AddrFull2AddrB64(destination)
else:
wallets_name_list = self.ton.GetWalletsNameList()
if destination in wallets_name_list:
wallet = self.ton.GetLocalWallet(destination)
destination = wallet.addrB64
return destination
# end define

def move_coins(self, args):
try:
wallet_name = args[0]
destination = args[1]
amount = args[2]
flags = args[3:]
except:
color_print("{red}Bad args. Usage:{endc} mg <wallet-name> <account-addr | bookmark-name> <amount>")
return
wallet = self.ton.GetLocalWallet(wallet_name)
destination = self.get_destination_addr(destination)
self.ton.MoveCoins(wallet, destination, amount, flags=flags)
color_print("MoveCoins - {green}OK{endc}")
# end define

def do_move_coins_through_proxy(self, wallet, dest, coins):
self.local.add_log("start MoveCoinsThroughProxy function", "debug")
wallet1 = self.ton.CreateWallet("proxy_wallet1", 0)
wallet2 = self.ton.CreateWallet("proxy_wallet2", 0)
self.ton.MoveCoins(wallet, wallet1.addrB64_init, coins)
self.ton.ActivateWallet(wallet1)
self.ton.MoveCoins(wallet1, wallet2.addrB64_init, "alld")
self.ton.ActivateWallet(wallet2)
self.ton.MoveCoins(wallet2, dest, "alld", flags=["-n"])
wallet1.Delete()
wallet2.Delete()
# end define

def move_coins_through_proxy(self, args):
try:
wallet_name = args[0]
destination = args[1]
amount = args[2]
except:
color_print("{red}Bad args. Usage:{endc} mgtp <wallet-name> <account-addr | bookmark-name> <amount>")
return
wallet = self.ton.GetLocalWallet(wallet_name)
destination = self.get_destination_addr(destination)
self.do_move_coins_through_proxy(wallet, destination, amount)
color_print("MoveCoinsThroughProxy - {green}OK{endc}")
# end define

def create_new_bookmark(self, args):
try:
name = args[0]
Expand Down Expand Up @@ -396,8 +340,6 @@ def print_validator_list(self, args):
def add_console_commands(self, console):
console.AddItem("vas", self.view_account_status, self.local.translate("vas_cmd"))
console.AddItem("vah", self.view_account_history, self.local.translate("vah_cmd"))
console.AddItem("mg", self.move_coins, self.local.translate("mg_cmd"))
console.AddItem("mgtp", self.move_coins_through_proxy, self.local.translate("mgtp_cmd"))

console.AddItem("nb", self.create_new_bookmark, self.local.translate("nb_cmd"))
console.AddItem("bl", self.print_bookmarks_list, self.local.translate("bl_cmd"))
Expand Down
46 changes: 45 additions & 1 deletion modules/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def export_wallet(self, args):
except:
color_print("{red}Bad args. Usage:{endc} ew <wallet-name>")
return
addr, key = self.ton.ExportWallet(name)
addr, key = self.do_export_wallet(name)
print("Wallet name:", name)
print("Address:", addr)
print("Secret key:", key)
Expand All @@ -151,6 +151,48 @@ def delete_wallet(self, args):
color_print("DeleteWallet - {green}OK{endc}")
# end define

def move_coins(self, args):
try:
wallet_name = args[0]
destination = args[1]
amount = args[2]
flags = args[3:]
except:
color_print("{red}Bad args. Usage:{endc} mg <wallet-name> <account-addr | bookmark-name> <amount>")
return
wallet = self.ton.GetLocalWallet(wallet_name)
destination = self.ton.get_destination_addr(destination)
self.ton.MoveCoins(wallet, destination, amount, flags=flags)
color_print("MoveCoins - {green}OK{endc}")
# end define

def do_move_coins_through_proxy(self, wallet, dest, coins):
self.local.add_log("start MoveCoinsThroughProxy function", "debug")
wallet1 = self.ton.CreateWallet("proxy_wallet1", 0)
wallet2 = self.ton.CreateWallet("proxy_wallet2", 0)
self.ton.MoveCoins(wallet, wallet1.addrB64_init, coins)
self.ton.ActivateWallet(wallet1)
self.ton.MoveCoins(wallet1, wallet2.addrB64_init, "alld")
self.ton.ActivateWallet(wallet2)
self.ton.MoveCoins(wallet2, dest, "alld", flags=["-n"])
wallet1.Delete()
wallet2.Delete()
# end define

def move_coins_through_proxy(self, args):
try:
wallet_name = args[0]
destination = args[1]
amount = args[2]
except:
color_print("{red}Bad args. Usage:{endc} mgtp <wallet-name> <account-addr | bookmark-name> <amount>")
return
wallet = self.ton.GetLocalWallet(wallet_name)
destination = self.ton.get_destination_addr(destination)
self.do_move_coins_through_proxy(wallet, destination, amount)
color_print("MoveCoinsThroughProxy - {green}OK{endc}")
# end define

def add_console_commands(self, console):
console.AddItem("nw", self.create_new_wallet, self.local.translate("nw_cmd"))
console.AddItem("aw", self.activate_wallet, self.local.translate("aw_cmd"))
Expand All @@ -159,3 +201,5 @@ def add_console_commands(self, console):
console.AddItem("swv", self.set_wallet_version, self.local.translate("swv_cmd"))
console.AddItem("ew", self.export_wallet, self.local.translate("ex_cmd"))
console.AddItem("dw", self.delete_wallet, self.local.translate("dw_cmd"))
console.AddItem("mg", self.move_coins, self.local.translate("mg_cmd"))
console.AddItem("mgtp", self.move_coins_through_proxy, self.local.translate("mgtp_cmd"))
13 changes: 13 additions & 0 deletions mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2840,6 +2840,19 @@ def GetVotedComplaints(self, complaints: dict):
return result
#end define

def get_destination_addr(self, destination):
if self.IsAddrB64(destination):
pass
elif self.IsAddrFull(destination):
destination = self.AddrFull2AddrB64(destination)
else:
wallets_name_list = self.GetWalletsNameList()
if destination in wallets_name_list:
wallet = self.GetLocalWallet(destination)
destination = wallet.addrB64
return destination
# end define

def AddrFull2AddrB64(self, addrFull, bounceable=True):
if addrFull is None or "None" in addrFull:
return
Expand Down