Commit eadc1f5f authored by Tetsuro Takemoto's avatar Tetsuro Takemoto 🐝

fix: issue#21 the app crashes with big amount of XMR

parent 45ee0ec1
......@@ -475,24 +475,26 @@ extension WalletCoordinator: AmountVCDelegate {
viewController.refresh()
viewController.nextAllowed()
}
func amountVCAmountValueChanged(amount: Double?, viewController: AmountVC) {
guard let requestedXmrDouble = amount else {
viewController.showFiatValue("---", forCurrency: self.propertyStore.currency)
viewController.nextNotAllowed()
return
}
let requestedXmrInAtomicUnits = UInt64(requestedXmrDouble * Double(Constants.atomicUnitsPerMonero))
let requestedXmrInAtomicUnitsDouble = requestedXmrDouble * Double(Constants.atomicUnitsPerMonero)
let requestedXmrInAtomicUnits = UInt64(exactly: requestedXmrInAtomicUnitsDouble)
let fiatValue = self.otherAmount(forXMRValue: requestedXmrInAtomicUnits)
viewController.showFiatValue(fiatValue, forCurrency: self.propertyStore.currency)
let available = self.moneroBag.wallet?.balance ?? 0
if requestedXmrInAtomicUnits > 0 && requestedXmrInAtomicUnits <= available {
if (requestedXmrInAtomicUnits != nil && requestedXmrInAtomicUnits! > 0 && requestedXmrInAtomicUnits! <= available) {
viewController.nextAllowed()
} else {
viewController.nextNotAllowed()
}
}
private func showPaymentIdViewController() {
......
......@@ -202,8 +202,7 @@ extension AmountVC: UITextFieldDelegate {
}
if let amountValue = textField.text {
self.delegate?.amountVCAmountValueChanged(amount: amountValue.toDouble(),
viewController: self)
self.delegate?.amountVCAmountValueChanged(amount: amountValue.toDouble(), viewController: self)
}
return false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment