Skip to content

Commit 5e2e672

Browse files
committed
move mg mgtp to wallet module
1 parent b5b80fe commit 5e2e672

File tree

3 files changed

+59
-60
lines changed

3 files changed

+59
-60
lines changed

modules/utilities.py

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def view_account_status(self, args):
1919
except:
2020
color_print("{red}Bad args. Usage:{endc} vas <account-addr>")
2121
return
22-
addrB64 = self.get_destination_addr(addrB64)
22+
addrB64 = self.ton.get_destination_addr(addrB64)
2323
account = self.ton.GetAccount(addrB64)
2424
version = self.ton.GetVersionFromCodeHash(account.codeHash)
2525
statusTable = list()
@@ -34,11 +34,10 @@ def view_account_status(self, args):
3434
print_table(codeHashTable)
3535
print()
3636
print_table(historyTable)
37-
3837
# end define
3938

4039
def get_history_table(self, addr, limit):
41-
addr = self.get_destination_addr(addr)
40+
addr = self.ton.get_destination_addr(addr)
4241
account = self.ton.GetAccount(addr)
4342
history = self.ton.GetAccountHistory(account, limit)
4443
table = list()
@@ -73,61 +72,6 @@ def view_account_history(self, args):
7372
print_table(table)
7473
# end define
7574

76-
def get_destination_addr(self, destination):
77-
if self.ton.IsAddrB64(destination):
78-
pass
79-
elif self.ton.IsAddrFull(destination):
80-
destination = self.ton.AddrFull2AddrB64(destination)
81-
else:
82-
wallets_name_list = self.ton.GetWalletsNameList()
83-
if destination in wallets_name_list:
84-
wallet = self.ton.GetLocalWallet(destination)
85-
destination = wallet.addrB64
86-
return destination
87-
# end define
88-
89-
def move_coins(self, args):
90-
try:
91-
wallet_name = args[0]
92-
destination = args[1]
93-
amount = args[2]
94-
flags = args[3:]
95-
except:
96-
color_print("{red}Bad args. Usage:{endc} mg <wallet-name> <account-addr | bookmark-name> <amount>")
97-
return
98-
wallet = self.ton.GetLocalWallet(wallet_name)
99-
destination = self.get_destination_addr(destination)
100-
self.ton.MoveCoins(wallet, destination, amount, flags=flags)
101-
color_print("MoveCoins - {green}OK{endc}")
102-
# end define
103-
104-
def do_move_coins_through_proxy(self, wallet, dest, coins):
105-
self.local.add_log("start MoveCoinsThroughProxy function", "debug")
106-
wallet1 = self.ton.CreateWallet("proxy_wallet1", 0)
107-
wallet2 = self.ton.CreateWallet("proxy_wallet2", 0)
108-
self.ton.MoveCoins(wallet, wallet1.addrB64_init, coins)
109-
self.ton.ActivateWallet(wallet1)
110-
self.ton.MoveCoins(wallet1, wallet2.addrB64_init, "alld")
111-
self.ton.ActivateWallet(wallet2)
112-
self.ton.MoveCoins(wallet2, dest, "alld", flags=["-n"])
113-
wallet1.Delete()
114-
wallet2.Delete()
115-
# end define
116-
117-
def move_coins_through_proxy(self, args):
118-
try:
119-
wallet_name = args[0]
120-
destination = args[1]
121-
amount = args[2]
122-
except:
123-
color_print("{red}Bad args. Usage:{endc} mgtp <wallet-name> <account-addr | bookmark-name> <amount>")
124-
return
125-
wallet = self.ton.GetLocalWallet(wallet_name)
126-
destination = self.get_destination_addr(destination)
127-
self.do_move_coins_through_proxy(wallet, destination, amount)
128-
color_print("MoveCoinsThroughProxy - {green}OK{endc}")
129-
# end define
130-
13175
def create_new_bookmark(self, args):
13276
try:
13377
name = args[0]
@@ -396,8 +340,6 @@ def print_validator_list(self, args):
396340
def add_console_commands(self, console):
397341
console.AddItem("vas", self.view_account_status, self.local.translate("vas_cmd"))
398342
console.AddItem("vah", self.view_account_history, self.local.translate("vah_cmd"))
399-
console.AddItem("mg", self.move_coins, self.local.translate("mg_cmd"))
400-
console.AddItem("mgtp", self.move_coins_through_proxy, self.local.translate("mgtp_cmd"))
401343

402344
console.AddItem("nb", self.create_new_bookmark, self.local.translate("nb_cmd"))
403345
console.AddItem("bl", self.print_bookmarks_list, self.local.translate("bl_cmd"))

modules/wallet.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,48 @@ def delete_wallet(self, args):
151151
color_print("DeleteWallet - {green}OK{endc}")
152152
# end define
153153

154+
def move_coins(self, args):
155+
try:
156+
wallet_name = args[0]
157+
destination = args[1]
158+
amount = args[2]
159+
flags = args[3:]
160+
except:
161+
color_print("{red}Bad args. Usage:{endc} mg <wallet-name> <account-addr | bookmark-name> <amount>")
162+
return
163+
wallet = self.ton.GetLocalWallet(wallet_name)
164+
destination = self.ton.get_destination_addr(destination)
165+
self.ton.MoveCoins(wallet, destination, amount, flags=flags)
166+
color_print("MoveCoins - {green}OK{endc}")
167+
# end define
168+
169+
def do_move_coins_through_proxy(self, wallet, dest, coins):
170+
self.local.add_log("start MoveCoinsThroughProxy function", "debug")
171+
wallet1 = self.ton.CreateWallet("proxy_wallet1", 0)
172+
wallet2 = self.ton.CreateWallet("proxy_wallet2", 0)
173+
self.ton.MoveCoins(wallet, wallet1.addrB64_init, coins)
174+
self.ton.ActivateWallet(wallet1)
175+
self.ton.MoveCoins(wallet1, wallet2.addrB64_init, "alld")
176+
self.ton.ActivateWallet(wallet2)
177+
self.ton.MoveCoins(wallet2, dest, "alld", flags=["-n"])
178+
wallet1.Delete()
179+
wallet2.Delete()
180+
# end define
181+
182+
def move_coins_through_proxy(self, args):
183+
try:
184+
wallet_name = args[0]
185+
destination = args[1]
186+
amount = args[2]
187+
except:
188+
color_print("{red}Bad args. Usage:{endc} mgtp <wallet-name> <account-addr | bookmark-name> <amount>")
189+
return
190+
wallet = self.ton.GetLocalWallet(wallet_name)
191+
destination = self.ton.get_destination_addr(destination)
192+
self.do_move_coins_through_proxy(wallet, destination, amount)
193+
color_print("MoveCoinsThroughProxy - {green}OK{endc}")
194+
# end define
195+
154196
def add_console_commands(self, console):
155197
console.AddItem("nw", self.create_new_wallet, self.local.translate("nw_cmd"))
156198
console.AddItem("aw", self.activate_wallet, self.local.translate("aw_cmd"))
@@ -159,3 +201,5 @@ def add_console_commands(self, console):
159201
console.AddItem("swv", self.set_wallet_version, self.local.translate("swv_cmd"))
160202
console.AddItem("ew", self.export_wallet, self.local.translate("ex_cmd"))
161203
console.AddItem("dw", self.delete_wallet, self.local.translate("dw_cmd"))
204+
console.AddItem("mg", self.move_coins, self.local.translate("mg_cmd"))
205+
console.AddItem("mgtp", self.move_coins_through_proxy, self.local.translate("mgtp_cmd"))

mytoncore/mytoncore.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2840,6 +2840,19 @@ def GetVotedComplaints(self, complaints: dict):
28402840
return result
28412841
#end define
28422842

2843+
def get_destination_addr(self, destination):
2844+
if self.IsAddrB64(destination):
2845+
pass
2846+
elif self.IsAddrFull(destination):
2847+
destination = self.AddrFull2AddrB64(destination)
2848+
else:
2849+
wallets_name_list = self.GetWalletsNameList()
2850+
if destination in wallets_name_list:
2851+
wallet = self.GetLocalWallet(destination)
2852+
destination = wallet.addrB64
2853+
return destination
2854+
# end define
2855+
28432856
def AddrFull2AddrB64(self, addrFull, bounceable=True):
28442857
if addrFull is None or "None" in addrFull:
28452858
return

0 commit comments

Comments
 (0)