<!--
Sitemap:
- [MBGA · Reactive Primitives for Spark](/index)
- [Acknowledgments](/acknowledgments)
- [API Reference](/api/)
- [Connectors](/connectors/)
- [Examples](/examples/)
- [Flashnet](/flashnet/)
- [Getting Started](/getting-started)
- [Installation](/installation)
- [Kit](/kit/)
- [Configuration](/api/configuration)
- [Core Actions](/api/core-actions)
- [React Hooks](/api/hooks)
- [Types & Errors](/api/types)
- [Custom Connectors](/connectors/custom)
- [Sats Connect (Xverse)](/connectors/sats-connect)
- [Spark SDK](/connectors/spark-sdk)
- [Wallet Standard](/connectors/wallet-standard)
- [Flashnet Authentication](/flashnet/authentication)
- [Next.js](/frameworks/nextjs)
- [Vite](/frameworks/vite)
- [AccountModal](/kit/account-modal)
- [ConnectButton](/kit/connect-button)
- [ConnectModal](/kit/connect-modal)
-->

# Types & Errors

## Utilities

### `detectPaymentDestination`

Detects whether a payment destination is a Lightning invoice, on-chain Bitcoin address, or Spark address.

```ts
import { detectPaymentDestination } from '@mbga/core'

detectPaymentDestination('lnbc1...')   // 'lightning'
detectPaymentDestination('bc1q...')    // 'bitcoin'
detectPaymentDestination('1A1z...')    // 'bitcoin'
detectPaymentDestination('sp1q...')    // 'spark'
```

```ts
type PaymentDestinationType = 'lightning' | 'bitcoin' | 'spark'
function detectPaymentDestination(to: string): PaymentDestinationType
```

**Detection rules:**

* Starts with `ln` -- `'lightning'` (BOLT11 invoice)
* Matches legacy (`1...`, `3...`) or bech32 (`bc1q...`, `bc1p...`, `tb1...`) -- `'bitcoin'`
* Everything else -- `'spark'`
