Skip to content

Commit 603caff

Browse files
committed
send: avoid build transaction with zero amount
Signed-off-by: Luca Vaccaro <[email protected]>
1 parent 9cfcdb4 commit 603caff

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

gaios/Sendflow/Controllers/SendAmountViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class SendAmountViewController: KeyboardViewController {
338338
infoView.isHidden = false
339339
} else {
340340
btnNextEnabled = false
341-
if viewModel.createTx.satoshi != nil || viewModel.createTx.sendAll || viewModel.createTx.txType == .sweep || viewModel.createTx.txType == .redepositExpiredUtxos {
341+
if viewModel.createTx.satoshi ?? 0 > 0 || viewModel.createTx.sendAll || viewModel.createTx.txType == .sweep || viewModel.createTx.txType == .redepositExpiredUtxos {
342342
btnNextEnabled = true
343343
}
344344
lblError.text = ""

gaios/Sendflow/ViewModels/SendAmountViewModel.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ class SendAmountViewModel {
3636
}
3737

3838
var error: String? {
39+
if transaction?.txType == .transaction {
40+
if !sendAll && (createTx.satoshi ?? 0 == 0) {
41+
return nil
42+
}
43+
}
3944
if let error = transaction?.error, !error.isEmpty {
4045
return error
4146
}
@@ -277,6 +282,8 @@ class SendAmountViewModel {
277282
case .transaction, .psbt:
278283
if createTx.sendAll && createTx.satoshi == nil {
279284
createTx.satoshi = 0
285+
} else if !createTx.sendAll && (createTx.satoshi == nil || createTx.satoshi == 0){
286+
return tx
280287
}
281288
if let addressee = createTx.addressee {
282289
tx.addressees = [addressee]

gaios/Sendflow/ViewModels/SendTxConfirmViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class SendTxConfirmViewModel {
161161
}
162162
bcurUnsignedPsbt = res
163163
}
164-
164+
165165
func sendPsbt() async throws -> SendTransactionSuccess {
166166
guard let session = session else {
167167
throw TransactionError.invalid(localizedDescription: "Invalid session")

0 commit comments

Comments
 (0)