@@ -148,14 +148,17 @@ def get_account(self, address):
148148 'address' : self .to_hex (address )
149149 }, 'post' )
150150
151- def get_balance (self , address ):
151+ def get_balance (self , address , from_tron : bool = False ):
152152 """Получение баланса
153153
154154 Args:
155155 address (str): Адрес учетной записи
156+ from_tron (bool): Преобразовать в обычный формат
156157
157158 """
158159 response = self .get_account (address )
160+ if from_tron :
161+ return self .from_tron (response ['balance' ])
159162
160163 return response ['balance' ]
161164
@@ -223,9 +226,19 @@ def _create_transaction(self, from_address, to_address, amount):
223226 Возвращает неподписанную транзакцию
224227
225228 """
229+
230+ if type (amount ) != float or amount < 0 :
231+ raise Exception ('Invalid amount provided' )
232+
233+ _to = self .to_hex (to_address )
234+ _from = self .from_hex (from_address )
235+
236+ if _to == _from :
237+ raise Exception ('Cannot transfer TRX to the same account' )
238+
226239 return self .full_node .request ('/wallet/createtransaction' , {
227- 'to_address' : self . to_hex ( to_address ) ,
228- 'owner_address' : self . to_hex ( from_address ) ,
240+ 'to_address' : _to ,
241+ 'owner_address' : _from ,
229242 'amount' : self .to_tron (amount )
230243 }, 'post' )
231244
0 commit comments