// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.11.1.

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import '../frb_generated.dart';
import 'error.dart';
import 'mint_info.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'payment_request.dart';
import 'token.dart';

// These functions are ignored because they are not marked as `pub`: `mint_url`, `unit`, `update_balance_streams`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `clone`, `clone`, `clone`, `clone`, `cmp`, `eq`, `eq`, `eq`, `fmt`, `fmt`, `from`, `from`, `from`, `from`, `from`, `from`, `into`, `partial_cmp`, `try_into`, `try_into`

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<PreparedSend>>
abstract class PreparedSend implements RustOpaqueInterface {
  BigInt get amount;

  BigInt get fee;

  BigInt get sendFee;

  BigInt get swapFee;

  set amount(BigInt amount);

  set fee(BigInt fee);

  set sendFee(BigInt sendFee);

  set swapFee(BigInt swapFee);
}

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<Wallet>>
abstract class Wallet implements RustOpaqueInterface {
  String get mintUrl;

  String get unit;

  set mintUrl(String mintUrl);

  set unit(String unit);

  Future<BigInt> balance();

  Future<void> cancelSend({required PreparedSend send});

  Future<void> checkAllMintQuotes();

  Future<void> checkPendingTransactions();

  /// Create a NUT-18 payment request with Nostr transport.
  ///
  /// Builds a PaymentRequest with the wallet's mint URL and unit,
  /// generates ephemeral Nostr keys, and returns both creqA and creqB
  /// encodings plus the keys needed for the Nostr listener.
  Future<CreatedPaymentRequest> createPaymentRequest({
    required CreateRequestParams params,
  });

  Future<void> finalizePendingMelts();

  Future<MintInfo?> getMint();

  Future<bool> isTokenSpent({required Token token});

  Future<List<Transaction>> listTransactions({TransactionDirection? direction});

  Future<BigInt> melt({required MeltQuote quote});

  Future<MeltQuote> meltQuote({required String request});

  Stream<MintQuote> mint({required BigInt amount, String? description});

  factory Wallet({
    required String mintUrl,
    required String unit,
    required String mnemonic,
    BigInt? targetProofCount,
    required WalletDatabase db,
  }) => RustLib.instance.api.crateApiWalletWalletNew(
    mintUrl: mintUrl,
    unit: unit,
    mnemonic: mnemonic,
    targetProofCount: targetProofCount,
    db: db,
  );

  /// Pay a NUT-18 payment request.
  /// Uses CDK's pay_request() which handles:
  /// - NUT-10 spending conditions
  /// - Transport selection (Nostr preferred, HTTP POST fallback)
  /// - Token preparation and delivery
  Future<void> payPaymentRequest({
    required String encoded,
    BigInt? customAmount,
  });

  Future<PreparedSend> prepareSend({required BigInt amount, SendOptions? opts});

  Future<BigInt> receive({required Token token, ReceiveOptions? opts});

  /// Check pending-spent proofs with the mint and revert unspent ones.
  /// Returns the number of proofs recovered.
  Future<BigInt> reclaimPendingProofs();

  Future<void> recoverIncompleteSagas();

  Future<void> restore();

  Future<SendResult> send({
    required PreparedSend send,
    String? memo,
    bool? includeMemo,
  });

  Stream<BigInt> streamBalance();

  /// Wait for an incoming Nostr payment (NIP-17 gift-wrap).
  ///
  /// Takes the opaque NostrListenerHandle returned by create_payment_request().
  /// The secret key never leaves Rust memory.
  Stream<NostrPaymentEvent> waitForNostrPayment({
    required NostrListenerHandle handle,
  });
}

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<WalletDatabase>>
abstract class WalletDatabase implements RustOpaqueInterface {
  String get path;

  set path(String path);

  static Future<WalletDatabase> newInstance({required String path}) =>
      RustLib.instance.api.crateApiWalletWalletDatabaseNewInstance(path: path);

  Future<void> removeMint({required String mintUrl});
}

class MeltQuote {
  final String id;
  final String request;
  final BigInt amount;
  final BigInt feeReserve;
  final BigInt expiry;

  const MeltQuote({
    required this.id,
    required this.request,
    required this.amount,
    required this.feeReserve,
    required this.expiry,
  });

  @override
  int get hashCode =>
      id.hashCode ^
      request.hashCode ^
      amount.hashCode ^
      feeReserve.hashCode ^
      expiry.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is MeltQuote &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          request == other.request &&
          amount == other.amount &&
          feeReserve == other.feeReserve &&
          expiry == other.expiry;
}

class MintQuote {
  final String id;
  final String request;
  final BigInt? amount;
  final BigInt? expiry;
  final MintQuoteState state;
  final Token? token;
  final String? error;

  /// Deterministic transaction ID (set when state == Issued)
  final String? transactionId;

  const MintQuote({
    required this.id,
    required this.request,
    this.amount,
    this.expiry,
    required this.state,
    this.token,
    this.error,
    this.transactionId,
  });

  @override
  int get hashCode =>
      id.hashCode ^
      request.hashCode ^
      amount.hashCode ^
      expiry.hashCode ^
      state.hashCode ^
      token.hashCode ^
      error.hashCode ^
      transactionId.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is MintQuote &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          request == other.request &&
          amount == other.amount &&
          expiry == other.expiry &&
          state == other.state &&
          token == other.token &&
          error == other.error &&
          transactionId == other.transactionId;
}

enum MintQuoteState { unpaid, paid, issued, error }

class ReceiveOptions {
  final List<String>? signingKeys;
  final List<String>? preimages;

  const ReceiveOptions({this.signingKeys, this.preimages});

  static Future<ReceiveOptions> default_() =>
      RustLib.instance.api.crateApiWalletReceiveOptionsDefault();

  @override
  int get hashCode => signingKeys.hashCode ^ preimages.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is ReceiveOptions &&
          runtimeType == other.runtimeType &&
          signingKeys == other.signingKeys &&
          preimages == other.preimages;
}

class SendOptions {
  final String? pubkey;
  final bool? includeFee;

  const SendOptions({this.pubkey, this.includeFee});

  static Future<SendOptions> default_() =>
      RustLib.instance.api.crateApiWalletSendOptionsDefault();

  @override
  int get hashCode => pubkey.hashCode ^ includeFee.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is SendOptions &&
          runtimeType == other.runtimeType &&
          pubkey == other.pubkey &&
          includeFee == other.includeFee;
}

/// Result of a confirmed send, carrying both the ecash token and the
/// deterministic transaction ID so Dart can save metadata without a racy
/// listTransactions lookup.
class SendResult {
  final Token token;

  /// Deterministic transaction ID (None if computation failed)
  final String? transactionId;

  const SendResult({required this.token, this.transactionId});

  @override
  int get hashCode => token.hashCode ^ transactionId.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is SendResult &&
          runtimeType == other.runtimeType &&
          token == other.token &&
          transactionId == other.transactionId;
}

class Transaction {
  final String id;
  final String mintUrl;
  final TransactionDirection direction;
  final BigInt amount;
  final BigInt fee;
  final String unit;
  final List<String> ys;
  final BigInt timestamp;
  final String? memo;
  final Map<String, String> metadata;
  final TransactionStatus status;

  const Transaction({
    required this.id,
    required this.mintUrl,
    required this.direction,
    required this.amount,
    required this.fee,
    required this.unit,
    required this.ys,
    required this.timestamp,
    this.memo,
    required this.metadata,
    required this.status,
  });

  @override
  int get hashCode =>
      id.hashCode ^
      mintUrl.hashCode ^
      direction.hashCode ^
      amount.hashCode ^
      fee.hashCode ^
      unit.hashCode ^
      ys.hashCode ^
      timestamp.hashCode ^
      memo.hashCode ^
      metadata.hashCode ^
      status.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is Transaction &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          mintUrl == other.mintUrl &&
          direction == other.direction &&
          amount == other.amount &&
          fee == other.fee &&
          unit == other.unit &&
          ys == other.ys &&
          timestamp == other.timestamp &&
          memo == other.memo &&
          metadata == other.metadata &&
          status == other.status;
}

enum TransactionDirection { incoming, outgoing }

enum TransactionStatus { pending, settled }
