Skip to content

Commit 6f91ccf

Browse files
committed
fix(send): max send amount incorrect for onchain invoice
1 parent 412f19e commit 6f91ccf

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Bitkit/Views/Wallets/Send/SendAmountView.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ struct SendAmountView: View {
174174
maxSendableAmount = nil
175175
}
176176
}
177+
.onChange(of: wallet.selectedFeeRateSatsPerVByte) { _ in
178+
// Recalculate max sendable amount when fee rate becomes available or changes
179+
if app.selectedWalletToPayFrom == .onchain {
180+
Task {
181+
await calculateMaxSendableAmount()
182+
}
183+
}
184+
}
177185
}
178186

179187
private func onContinue() async {
@@ -258,8 +266,8 @@ struct SendAmountView: View {
258266
} catch {
259267
Logger.error("Failed to calculate max sendable amount: \(error)")
260268
await MainActor.run {
261-
// Fall back to total balance if calculation fails
262-
maxSendableAmount = UInt64(wallet.spendableOnchainBalanceSats)
269+
// Keep as nil on error - availableAmount will fall back to total balance
270+
maxSendableAmount = nil
263271
}
264272
}
265273
}

0 commit comments

Comments
 (0)