> ## Documentation Index
> Fetch the complete documentation index at: https://shinydapps-bd9fa40b.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Migration Guide

> Managed से Soberano mode में जाएं, versions के बीच upgrade करें, या Lightning providers बदलें — बिना किसी downtime के।

## Managed → Soberano (0% fee, full custody)

आपने `ManagedProvider` से शुरुआत की क्योंकि यह सबसे तेज़ तरीका है। जब आप full custody और 0% fee के लिए तैयार हों, तो migration सिर्फ एक line का काम है।

<Steps>
  <Step title="अपना Lightning provider सेट करें">
    एक soberano provider चुनें। [Blink](https://dashboard.blink.sv) मुफ़्त है, कोई KYC नहीं, तुरंत setup।

    ```bash theme={null}
    # Blink: account बनाएं → API Keys → key + wallet ID कॉपी करें
    BLINK_API_KEY=blink_xxxxxxxxxxxxxxxxxxxxxxxx
    BLINK_WALLET_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    ```
  </Step>

  <Step title="Provider बदलें — एक line">
    ```typescript theme={null}
    // Before
    import { ManagedProvider } from 'l402-kit';
    const lightning = ManagedProvider.fromAddress('you@yourdomain.com');

    // After
    import { BlinkProvider } from 'l402-kit';
    const lightning = new BlinkProvider(
      process.env.BLINK_API_KEY!,
      process.env.BLINK_WALLET_ID!,
    );
    ```

    ```python theme={null}
    # Before
    from l402kit import ManagedProvider
    lightning = ManagedProvider.from_address("you@yourdomain.com")

    # After
    from l402kit.providers.blink import BlinkProvider
    lightning = BlinkProvider(
        api_key=os.environ["BLINK_API_KEY"],
        wallet_id=os.environ["BLINK_WALLET_ID"],
    )
    ```

    बाकी सब कुछ — middleware setup, token verification, endpoint code — बिल्कुल वैसा ही रहता है।
  </Step>

  <Step title="Deploy करें">
    Managed provider द्वारा जारी किए गए Tokens migration के बाद **काम करते रहते हैं**। Verification पूरी तरह crypto पर आधारित है (`SHA256(preimage) == paymentHash`) — इसका कोई dependency नहीं है कि किस provider ने invoice बनाया।

    कोई migration window नहीं, कोई downtime नहीं, कोई database update नहीं।
  </Step>
</Steps>

<Note>
  ManagedProvider के तहत जारी किए गए already-paid tokens, providers बदलने के बाद भी valid रहते हैं। macaroon में केवल एक hash और एक expiry होती है — कोई provider-specific data नहीं।
</Note>

***

## Soberano providers के बीच बदलाव करें

Same pattern — provider instance बदलें, बाकी कुछ नहीं बदलता।

```typescript theme={null}
// Blink → LNbits
import { LNbitsProvider } from 'l402-kit';
const lightning = new LNbitsProvider(
  process.env.LNBITS_KEY!,
  process.env.LNBITS_URL ?? 'https://legend.lnbits.com',
);

// Blink → OpenNode
import { OpenNodeProvider } from 'l402-kit';
const lightning = new OpenNodeProvider(process.env.OPENNODE_KEY!, false);
```

***

## v1.x → v1.8 (current)

कोई breaking changes नहीं। SDK additive है — नए providers, नए agent utilities, नए replay adapters। इससे upgrade करें:

```bash theme={null}
npm install l402-kit@latest
pip install --upgrade l402kit
cargo update l402kit
go get github.com/shinydapps/l402-kit/go@latest
```

यदि आपने कोई specific version pin की है, तो [changelog](https://github.com/ShinyDapps/l402-kit/releases) देखें कि क्या नया है।

***

## Framework migration

### Express → Fastify

```typescript theme={null}
// Express
app.get('/api', l402({ priceSats: 10, lightning }), handler);

// Fastify
import { l402Fastify } from 'l402-kit/fastify';

fastify.get('/api', {
  preHandler: l402Fastify({ priceSats: 10, lightning }),
}, handler);
```

### Express → Hono (Cloudflare Workers)

```typescript theme={null}
import { Hono } from 'hono';
import { l402Hono } from 'l402-kit/hono';

const app = new Hono();
app.use('/api/*', l402Hono({ priceSats: 10, lightning }));
app.get('/api/data', (c) => c.json({ data: 'paid' }));
```

### Flask → FastAPI

```python theme={null}
# Flask
from l402kit.flask import l402_required

@app.route('/api')
@l402_required(price_sats=10, lightning=provider)
def handler():
    return jsonify({'data': 'paid'})

# FastAPI
from l402kit import l402_required

@app.get('/api')
@l402_required(price_sats=10, lightning=provider)
async def handler():
    return {'data': 'paid'}
```

***

## Replay store migration

### In-memory → Supabase

Environment variables सेट करें — middleware खुद ही detect करके switch कर लेता है:

```bash theme={null}
SUPABASE_URL=https://xxx.supabase.co
SUPABASE_ANON_KEY=your_anon_key
```

मौजूदा in-flight tokens काम करते रहते हैं। Supabase store उस क्षण से recording शुरू करता है जब वह active होता है — migrate करने के लिए कोई historical data नहीं है।

### In-memory → Redis

```typescript theme={null}
import { Redis } from 'ioredis';
import { RedisReplayAdapter } from 'l402-kit';

const redis = new Redis(process.env.REDIS_URL!);

app.get('/api', l402({
  priceSats: 10,
  lightning,
  replayAdapter: new RedisReplayAdapter(redis),
}), handler);
```

<CardGroup cols={2}>
  <Card title="Providers" icon="plug" href="/providers">
    सभी provider options और setup
  </Card>

  <Card title="Production Guide" icon="rocket" href="/guides/production">
    Deployment checklist
  </Card>
</CardGroup>
