diff --git a/modules/utilities.py b/modules/utilities.py index 49ff82c7..461dd076 100644 --- a/modules/utilities.py +++ b/modules/utilities.py @@ -19,7 +19,7 @@ def view_account_status(self, args): except: color_print("{red}Bad args. Usage:{endc} vas ") 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() @@ -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() @@ -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 ") - 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 ") - 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] @@ -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")) diff --git a/modules/wallet.py b/modules/wallet.py index d4b385c0..e4bc1c86 100644 --- a/modules/wallet.py +++ b/modules/wallet.py @@ -131,7 +131,7 @@ def export_wallet(self, args): except: color_print("{red}Bad args. Usage:{endc} ew ") 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) @@ -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 ") + 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 ") + 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")) @@ -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")) diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index f1b03c8c..5d7accf2 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -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