@@ -1180,9 +1180,7 @@ def SignBocWithWallet(self, wallet, boc_path, dest, coins, **kwargs):
11801180
11811181 # Balance checking
11821182 account = self .GetAccount (wallet .addrB64 )
1183- if account .balance < coins + 0.1 :
1184- raise Exception ("Wallet balance is less than requested coins" )
1185- #end if
1183+ self .check_account_balance (account , coins + 0.1 )
11861184
11871185 # Bounceable checking
11881186 destAccount = self .GetAccount (dest )
@@ -1864,6 +1862,25 @@ def GetWalletId(self, wallet):
18641862 return subwallet
18651863 #end define
18661864
1865+ def check_account_balance (self , account , coins ):
1866+ if not isinstance (account , Account ):
1867+ account = self .GetAccount (account )
1868+ if account .balance < coins :
1869+ raise Exception (f"Account { account .addrB64 } balance is less than requested coins. Balance: { account .balance } , requested amount: { coins } (need { coins - account .balance } more)" )
1870+ # end if
1871+ # end define
1872+
1873+ def check_account_active (self , account ):
1874+ if not isinstance (account , Account ):
1875+ address = account
1876+ account = self .GetAccount (account )
1877+ else :
1878+ address = account .addrB64
1879+ if account .status != "active" :
1880+ raise Exception (f"Account { address } account is uninitialized" )
1881+ # end if
1882+ # end define
1883+
18671884 def MoveCoins (self , wallet , dest , coins , ** kwargs ):
18681885 self .local .add_log ("start MoveCoins function" , "debug" )
18691886 flags = kwargs .get ("flags" , list ())
@@ -1884,11 +1901,8 @@ def MoveCoins(self, wallet, dest, coins, **kwargs):
18841901
18851902 # Balance checking
18861903 account = self .GetAccount (wallet .addrB64 )
1887- if account .balance < coins + 0.1 :
1888- raise Exception ("Wallet balance is less than requested coins" )
1889- if account .status != "active" :
1890- raise Exception ("Wallet account is uninitialized" )
1891- #end if
1904+ self .check_account_balance (account , coins + 0.1 )
1905+ self .check_account_active (account )
18921906
18931907 # Bounceable checking
18941908 destAccount = self .GetAccount (dest )
0 commit comments