Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Cleaning up code based on PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
chitowncrispy committed Oct 25, 2019
1 parent 4f3094b commit a5b7658
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
17 changes: 5 additions & 12 deletions Library/Scenes/ModalDetail/Send/SendViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,27 +187,20 @@ final class SendViewModel: NSObject {
guard let amount = amount else { return }

let feeCompletion = { [weak self] (result: Result<(amount: Satoshi, fee: Satoshi?), LndApiError>) -> Void in
guard
let self = self
else { return }
switch result {
case .success(let result):
guard
let self = self,
result.amount == self.amount
else { return }

self.isTransactionDust = false
self.fee.value = .element(result.fee)
case .failure(let lndApiError):
guard
let self = self
else { return }

if lndApiError == LndApiError.transactionDust {
self.isTransactionDust = true
} else {
self.isTransactionDust = false
}

self.fee.value = .error(lndApiError)
self.isTransactionDust = lndApiError == .transactionDust
self.fee.value = amount > 0 ? .error(lndApiError) : .element(nil)
self.updateIsUIEnabled()
}
}
Expand Down
4 changes: 2 additions & 2 deletions SwiftLnd/Api/Helper/RpcZapHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ final class LndCallback<T: SwiftProtobuf.Message>: NSObject, LndmobileCallbackPr
if error.localizedDescription == "Closed" {
result = .walletAlreadyUnlocked
} else if error.localizedDescription == "rpc error: code = Unknown desc = transaction output is dust" {
result = LndApiError.transactionDust
result = .transactionDust
} else {
result = LndApiError.localizedError(error.localizedDescription)
result = .localizedError(error.localizedDescription)
}
completion(.failure(result))
} else {
Expand Down

0 comments on commit a5b7658

Please sign in to comment.