export interface BlinkGraphQlError {
  message?: string;
}

export interface BlinkMutationError {
  message?: string;
}

export interface BlinkWallet {
  id: string;
  walletCurrency: string;
}

export interface BlinkCreateInvoiceInput {
  amount: number;
  walletId: string;
  externalId?: string;
  memo?: string;
  expiresIn?: number;
}

export interface BlinkInvoice {
  createdAt: number;
  externalId: string;
  paymentHash: string;
  paymentRequest: string;
  paymentSecret?: string;
  paymentStatus: string;
  satoshis: number;
}

export interface BlinkCreateInvoicePayload {
  invoice?: BlinkInvoice | null;
  errors?: BlinkMutationError[] | null;
}

export interface BlinkGraphQlResponse<TData> {
  data?: TData;
  errors?: BlinkGraphQlError[] | null;
}

export interface LightningInvoiceCreateRequest {
  user_id: number;
  amount_sats: number;
  currency: string;
  reference: string;
}

export interface LightningInvoiceResponse {
  provider: "blink";
  network: "bitcoin_lightning";
  asset: "BTC";
  payment_request: string;
  payment_hash: string;
  amount_sats: number;
  expires_at: string | null;
  reference: string;
}

export interface PendingBlinkInvoiceRecord extends LightningInvoiceResponse {
  user_id: number;
  currency: string;
  status: "pending" | "confirmed";
  provider_reference?: string | null;
  transaction_status?: string | null;
  wallet_currency?: string | null;
  created_at: string;
  updated_at: string;
  raw_invoice_payload: Record<string, unknown>;
  raw_webhook_payload?: Record<string, unknown> | null;
}

export interface BlinkWebhookPayload {
  accountId?: string;
  eventType?: string;
  walletId?: string;
  transaction?: {
    createdAt?: string;
    id?: string;
    memo?: string | null;
    settlementAmount?: number | string | null;
    settlementCurrency?: string;
    settlementDisplayAmount?: string | null;
    settlementDisplayFee?: string | null;
    settlementDisplayPrice?: {
      base?: string;
      displayCurrency?: string;
      offset?: string;
      walletCurrency?: string;
    } | null;
    settlementFee?: number | string | null;
    settlementVia?: {
      type?: string;
    } | null;
    status?: string;
    walletId?: string;
    initiationVia?: {
      paymentHash?: string;
      pubkey?: string;
      paymentRequest?: string;
      type?: string;
    } | null;
  } | null;
}
