@@ -410,7 +410,7 @@ def formatMilliSats(self, amount, with_unit=False):
410410 return self .config .format_amount (sats , precision = precision )
411411
412412 @pyqtSlot (str , result = QEAmount )
413- def unitsToSats (self , unitAmount ):
413+ def baseunitStrToAmount (self , unitAmount ):
414414 self ._amount = QEAmount ()
415415 try :
416416 x = Decimal (unitAmount )
@@ -422,6 +422,12 @@ def unitsToSats(self, unitAmount):
422422 self ._amount = QEAmount (amount_msat = msat_max_prec_amount )
423423 return self ._amount
424424
425- @pyqtSlot ('quint64' , result = float )
426- def satsToUnits (self , satoshis ):
427- return satoshis / pow (10 , self .config .BTC_AMOUNTS_DECIMAL_POINT )
425+ @pyqtSlot ('quint64' , result = str )
426+ @pyqtSlot (QEAmount , result = str )
427+ def amountToBaseunitStr (self , amount ) -> str :
428+ assert isinstance (amount , (QEAmount , int ))
429+ if isinstance (amount , QEAmount ):
430+ satoshis = Decimal (amount .msatsInt ) / 1000
431+ elif isinstance (amount , int ):
432+ satoshis = Decimal (amount )
433+ return str (satoshis / pow (10 , self .config .BTC_AMOUNTS_DECIMAL_POINT ))
0 commit comments