> ## 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.

# Wallets

> Verbinde Blink oder Alby, damit dein Agent automatisch Lightning-Rechnungen bezahlen kann.

## Unterstützte Wallets

| Wallet                          | Installation           |     Eigene Verwahrung     | Hinweise                            |
| ------------------------------- | ---------------------- | :-----------------------: | ----------------------------------- |
| [Blink](https://blink.sv)       | integriert             |         ❌ verwahrt        | Einfachste Einrichtung, GraphQL API |
| [Alby Hub](https://getalby.com) | integriert             | ✅ selbst gehostete Option | REST API, unterstützt eigenen Hub   |
| Benutzerdefiniert               | `L402Wallet`-Interface |             ✅             | Eigenes Wallet verwenden            |

***

## BlinkWallet

### Einrichtung

1. Registriere dich auf [blink.sv](https://blink.sv)
2. Gehe zu **Dashboard → API Keys** → erstelle einen Schlüssel
3. Kopiere deine **Wallet ID** aus dem Dashboard

```bash theme={null}
export BLINK_API_KEY="your-api-key"
export BLINK_WALLET_ID="your-wallet-id"
```

### Node.js

```typescript theme={null}
import { BlinkWallet } from "l402-kit";

const wallet = new BlinkWallet(
  process.env.BLINK_API_KEY!,
  process.env.BLINK_WALLET_ID!,
);
```

### Python

```python theme={null}
from l402kit.wallets import BlinkWallet

wallet = BlinkWallet(
    api_key=os.environ["BLINK_API_KEY"],
    wallet_id=os.environ["BLINK_WALLET_ID"],
)
```

### Funktionsweise

Ruft die [Blink GraphQL API](https://api.blink.sv/graphql) mit der `lnInvoicePaymentSend`-Mutation auf. Gibt den `preImage` der abgeschlossenen Transaktion zurück.

***

## AlbyWallet

### Einrichtung

1. Erstelle ein Konto auf [getalby.com](https://getalby.com)
2. Gehe zu **Einstellungen → Zugriffstoken** → erstelle ein Token mit dem Bereich `payments:send`
3. (Optional) Betreibe deinen eigenen [Alby Hub](https://github.com/getAlby/hub) für eigene Verwahrung

```bash theme={null}
export ALBY_TOKEN="your-access-token"
# Optional — nur für selbst gehosteten Hub erforderlich:
export ALBY_HUB_URL="https://your-hub.example.com"
```

### Node.js

```typescript theme={null}
import { AlbyWallet } from "l402-kit";

// Alby cloud
const wallet = new AlbyWallet(process.env.ALBY_TOKEN!);

// Selbst gehosteter Hub
const wallet = new AlbyWallet(
  process.env.ALBY_TOKEN!,
  process.env.ALBY_HUB_URL,  // optionale Basis-URL
);
```

### Python

```python theme={null}
from l402kit.wallets import AlbyWallet

# Alby cloud
wallet = AlbyWallet(os.environ["ALBY_TOKEN"])

# Selbst gehosteter Hub
wallet = AlbyWallet(
    access_token=os.environ["ALBY_TOKEN"],
    base_url=os.environ.get("ALBY_HUB_URL", "https://api.getalby.com"),
)
```

### Funktionsweise

Ruft `POST /payments/bolt11` auf der Alby Hub REST API mit einem `Bearer`-Token auf. Gibt den `payment_preimage` aus der Antwort zurück.

***

## Benutzerdefiniertes Wallet

Implementiere das `L402Wallet`-Interface, um ein beliebiges Lightning-Wallet zu verwenden:

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    import type { L402Wallet } from "l402-kit";

    class PhoenixWallet implements L402Wallet {
      async payInvoice(bolt11: string): Promise<{ preimage: string }> {
        const res = await fetch("http://localhost:9740/payinvoice", {
          method: "POST",
          body: new URLSearchParams({ invoice: bolt11 }),
        });
        const data = await res.json();
        return { preimage: data.paymentPreimage };
      }
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    from l402kit import L402Wallet
    import httpx

    class PhoenixWallet(L402Wallet):
        def pay_invoice(self, bolt11: str) -> str:
            r = httpx.post(
                "http://localhost:9740/payinvoice",
                data={"invoice": bolt11},
            )
            r.raise_for_status()
            return r.json()["paymentPreimage"]
    ```
  </Tab>
</Tabs>

Das Interface erfordert eine einzige Methode:

| Methode                       | TypeScript                                          | Python                            |
| ----------------------------- | --------------------------------------------------- | --------------------------------- |
| Eine BOLT11-Rechnung bezahlen | `payInvoice(bolt11): Promise<{ preimage: string }>` | `pay_invoice(bolt11: str) -> str` |

***

## Wallet auswählen

* **Testen / Prototyping** → Blink (verwahrt, sofortige Einrichtung, kostenloses Kontingent)
* **Produktions-Agent, maximale Kontrolle** → Alby Hub selbst gehostet (nicht verwahrt, REST API)
* **Hoher Durchsatz / niedrige Gebühren** → Phoenix über benutzerdefiniertes `L402Wallet` (nicht verwahrt, ACINQ)
* **Enterprise** → LNbits selbst gehostet über benutzerdefiniertes Wallet
