Skip to content

Potential infinite wait state in SendSheet.swift #417

@piotr-iohk

Description

@piotr-iohk

Code review

After reviewing this PR for bugs and CLAUDE.md compliance, I found one issue:


Potential infinite wait state in SendSheet.swift

Location: Bitkit/Views/Wallets/Send/SendSheet.swift lines 197-200

Issue: If Lightning channels exist but never become usable (e.g., peer permanently offline, stuck channel state), users will be trapped in the sync overlay indefinitely with no escape.

The early return at lines 197-200 exits without setting hasValidatedAfterSync = true. The onChange(of: wallet.hasUsableChannels) handler only fires when the value changes. If channels remain permanently unusable, the validation never completes and the user cannot dismiss the sync overlay or proceed.

Suggested fix: Add a timeout mechanism or fallback logic:

// Option 1: Add timeout state
@State private var syncStartTime: Date?

// In .onAppear or when showing overlay:
syncStartTime = Date()

// In validatePaymentAfterSync:
let syncDuration = Date().timeIntervalSince(syncStartTime ?? Date())
if hasAnyChannels, !wallet.hasUsableChannels {
    if syncDuration > 30 { // 30 second timeout
        // Fall back to onchain or show "channels unavailable" error
        hasValidatedAfterSync = true
        // Proceed with validation or dismiss
    } else {
        return
    }
}

Or add a manual dismiss option in the sync overlay UI so users aren't trapped if something goes wrong.

Originally posted by @claude[bot] in #401 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions