/* tslint:disable */
/* eslint-disable */

export class AddressNamespace {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  static to_output_script_with_coin(address: string, coin: string): Uint8Array;
  static from_output_script_with_coin(script: Uint8Array, coin: string, format?: string | null): string;
}

export class BitGoPsbt {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Add an output to the PSBT
   *
   * # Arguments
   * * `script` - The output script (scriptPubKey)
   * * `value` - The value in satoshis
   *
   * # Returns
   * The index of the newly added output
   */
  add_output(script: Uint8Array, value: bigint): number;
  /**
   * Deserialize a PSBT from bytes with network-specific logic
   */
  static from_bytes(bytes: Uint8Array, network: string): BitGoPsbt;
  /**
   * Create an empty PSBT for the given network with wallet keys
   *
   * # Arguments
   * * `network` - Network name (utxolib or coin name)
   * * `wallet_keys` - The wallet's root keys (used to set global xpubs)
   * * `version` - Optional transaction version (default: 2)
   * * `lock_time` - Optional lock time (default: 0)
   */
  static create_empty(network: string, wallet_keys: WasmRootWalletKeys, version?: number | null, lock_time?: number | null): BitGoPsbt;
  /**
   * Get the Zcash expiry height (returns None for non-Zcash PSBTs)
   */
  expiry_height(): number | undefined;
  /**
   * Get the unsigned transaction ID
   */
  unsigned_txid(): string;
  /**
   * Sign a single input with an extended private key (xpriv)
   *
   * This method signs a specific input using the provided xpriv. It accepts:
   * - An xpriv (WasmBIP32) for wallet inputs - derives the key and signs
   *
   * This method automatically detects and handles different input types:
   * - For regular inputs: uses standard PSBT signing
   * - For MuSig2 inputs: uses the FirstRound state stored by generate_musig2_nonces()
   * - For replay protection inputs: returns error (use sign_with_privkey instead)
   *
   * # Arguments
   * - `input_index`: The index of the input to sign (0-based)
   * - `xpriv`: The extended private key as a WasmBIP32 instance
   *
   * # Returns
   * - `Ok(())` if signing was successful
   * - `Err(WasmUtxoError)` if signing fails
   */
  sign_with_xpriv(input_index: number, xpriv: WasmBIP32): void;
  /**
   * Add a wallet input with full PSBT metadata
   *
   * This is a higher-level method that adds an input and populates all required
   * PSBT fields (scripts, derivation info, etc.) based on the wallet's chain type.
   *
   * # Arguments
   * * `txid` - The transaction ID (hex string)
   * * `vout` - The output index being spent
   * * `value` - The value in satoshis
   * * `chain` - The chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
   * * `index` - The derivation index
   * * `wallet_keys` - The root wallet keys
   * * `signer` - The key that will sign ("user", "backup", or "bitgo") - required for p2tr/p2trMusig2
   * * `cosigner` - The key that will co-sign - required for p2tr/p2trMusig2
   * * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
   * * `prev_tx` - Optional full previous transaction bytes (for non-segwit)
   *
   * # Returns
   * The index of the newly added input
   */
  add_wallet_input(txid: string, vout: number, value: bigint, wallet_keys: WasmRootWalletKeys, chain: number, index: number, signer?: string | null, cosigner?: string | null, sequence?: number | null, prev_tx?: Uint8Array | null): number;
  /**
   * Get the Zcash version group ID (returns None for non-Zcash PSBTs)
   */
  version_group_id(): number | undefined;
  /**
   * Add a wallet output with full PSBT metadata
   *
   * This creates a verifiable wallet output (typically for change) with all required
   * PSBT fields (scripts, derivation info) based on the wallet's chain type.
   *
   * # Arguments
   * * `chain` - The chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
   * * `index` - The derivation index
   * * `value` - The value in satoshis
   * * `wallet_keys` - The root wallet keys
   *
   * # Returns
   * The index of the newly added output
   */
  add_wallet_output(chain: number, index: number, value: bigint, wallet_keys: WasmRootWalletKeys): number;
  /**
   * Sign a single input with a raw private key
   *
   * This method signs a specific input using the provided ECPair. It accepts:
   * - A raw privkey (WasmECPair) for replay protection inputs - signs directly
   *
   * This method automatically detects and handles different input types:
   * - For replay protection inputs: signs with legacy P2SH sighash
   * - For regular inputs: uses standard PSBT signing
   * - For MuSig2 inputs: returns error (requires FirstRound, use sign_with_xpriv instead)
   *
   * # Arguments
   * - `input_index`: The index of the input to sign (0-based)
   * - `ecpair`: The ECPair containing the private key
   *
   * # Returns
   * - `Ok(())` if signing was successful
   * - `Err(WasmUtxoError)` if signing fails
   */
  sign_with_privkey(input_index: number, ecpair: WasmECPair): void;
  /**
   * Create an empty Zcash PSBT with the required consensus branch ID
   *
   * This method is specifically for Zcash networks which require additional
   * parameters for sighash computation.
   *
   * # Arguments
   * * `network` - Network name (must be "zcash" or "zcashTest")
   * * `wallet_keys` - The wallet's root keys (used to set global xpubs)
   * * `consensus_branch_id` - Zcash consensus branch ID (e.g., 0xC2D6D0B4 for NU5)
   * * `version` - Optional transaction version (default: 4 for Zcash Sapling+)
   * * `lock_time` - Optional lock time (default: 0)
   * * `version_group_id` - Optional version group ID (defaults to Sapling: 0x892F2085)
   * * `expiry_height` - Optional expiry height
   */
  static create_empty_zcash(network: string, wallet_keys: WasmRootWalletKeys, consensus_branch_id: number, version?: number | null, lock_time?: number | null, version_group_id?: number | null, expiry_height?: number | null): BitGoPsbt;
  /**
   * Extract the final transaction from a finalized PSBT
   *
   * This method should be called after all inputs have been finalized.
   * It extracts the fully signed transaction.
   *
   * # Returns
   * - `Ok(Vec<u8>)` containing the serialized transaction bytes
   * - `Err(WasmUtxoError)` if the PSBT is not fully finalized or extraction fails
   */
  extract_transaction(): Uint8Array;
  /**
   * Finalize all inputs in the PSBT
   *
   * This method attempts to finalize all inputs in the PSBT, computing the final
   * scriptSig and witness data for each input.
   *
   * # Returns
   * - `Ok(())` if all inputs were successfully finalized
   * - `Err(WasmUtxoError)` if any input failed to finalize
   */
  finalize_all_inputs(): void;
  /**
   * Add a PayGo attestation to a PSBT output
   *
   * # Arguments
   * - `output_index`: The index of the output to add the attestation to
   * - `entropy`: 64 bytes of entropy
   * - `signature`: ECDSA signature bytes
   *
   * # Returns
   * - `Ok(())` if the attestation was successfully added
   * - `Err(WasmUtxoError)` if the output index is out of bounds or entropy is invalid
   */
  add_paygo_attestation(output_index: number, entropy: Uint8Array, signature: Uint8Array): void;
  /**
   * Combine/merge data from another PSBT into this one
   *
   * This method copies MuSig2 nonces and signatures (proprietary key-value pairs) from the
   * source PSBT to this PSBT. This is useful for merging PSBTs during the nonce exchange
   * and signature collection phases.
   *
   * # Arguments
   * * `source_psbt` - The source PSBT containing data to merge
   *
   * # Returns
   * Ok(()) if data was successfully merged
   *
   * # Errors
   * Returns error if networks don't match
   */
  combine_musig2_nonces(source_psbt: BitGoPsbt): void;
  /**
   * Generate and store MuSig2 nonces for all MuSig2 inputs
   *
   * This method generates nonces using the State-Machine API and stores them in the PSBT.
   * The nonces are stored as proprietary fields in the PSBT and will be included when serialized.
   * After ALL participants have generated their nonces, they can sign MuSig2 inputs using
   * sign_with_xpriv().
   *
   * # Arguments
   * * `xpriv` - The extended private key (xpriv) for signing
   * * `session_id_bytes` - Optional 32-byte session ID for nonce generation. **Only allowed on testnets**.
   *                        On mainnets, a secure random session ID is always generated automatically.
   *                        Must be unique per signing session.
   *
   * # Returns
   * Ok(()) if nonces were successfully generated and stored
   *
   * # Errors
   * Returns error if:
   * - Nonce generation fails
   * - session_id length is invalid
   * - Custom session_id is provided on a mainnet (security restriction)
   *
   * # Security
   * The session_id MUST be cryptographically random and unique for each signing session.
   * Never reuse a session_id with the same key! On mainnets, session_id is always randomly
   * generated for security. Custom session_id is only allowed on testnets for testing purposes.
   */
  generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
  /**
   * Verify if a valid signature exists for a given ECPair key at the specified input index
   *
   * This method verifies the signature directly with the provided ECPair's public key. It supports:
   * - ECDSA signatures (for legacy/SegWit inputs)
   * - Schnorr signatures (for Taproot script path inputs)
   *
   * Note: This method does NOT support MuSig2 inputs, as MuSig2 requires derivation from xpubs.
   * Use `verify_signature_with_xpub` for MuSig2 inputs.
   *
   * # Arguments
   * - `input_index`: The index of the input to check
   * - `ecpair`: The ECPair key (uses the public key for verification)
   *
   * # Returns
   * - `Ok(true)` if a valid signature exists for the public key
   * - `Ok(false)` if no signature exists for the public key
   * - `Err(WasmUtxoError)` if the input index is out of bounds or verification fails
   */
  verify_signature_with_pub(input_index: number, ecpair: WasmECPair): boolean;
  /**
   * Verify if a valid signature exists for a given xpub at the specified input index
   *
   * This method derives the public key from the xpub using the derivation path found in the
   * PSBT input, then verifies the signature. It supports:
   * - ECDSA signatures (for legacy/SegWit inputs)
   * - Schnorr signatures (for Taproot script path inputs)
   * - MuSig2 partial signatures (for Taproot keypath MuSig2 inputs)
   *
   * # Arguments
   * - `input_index`: The index of the input to check
   * - `xpub`: The extended public key as a WasmBIP32 instance
   *
   * # Returns
   * - `Ok(true)` if a valid signature exists for the derived public key
   * - `Ok(false)` if no signature exists for the derived public key
   * - `Err(WasmUtxoError)` if the input index is out of bounds, derivation fails, or verification fails
   */
  verify_signature_with_xpub(input_index: number, xpub: WasmBIP32): boolean;
  /**
   * Add a replay protection input to the PSBT
   *
   * Replay protection inputs are P2SH-P2PK inputs used on forked networks to prevent
   * transaction replay attacks. They use a simple pubkey script without wallet derivation.
   *
   * # Arguments
   * * `ecpair` - The ECPair containing the public key for the replay protection input
   * * `txid` - The transaction ID (hex string) of the output being spent
   * * `vout` - The output index being spent
   * * `value` - The value in satoshis
   * * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
   *
   * # Returns
   * The index of the newly added input
   */
  add_replay_protection_input(ecpair: WasmECPair, txid: string, vout: number, value: bigint, sequence?: number | null): number;
  /**
   * Create an empty Zcash PSBT with consensus branch ID determined from block height
   *
   * This method automatically determines the correct consensus branch ID based on
   * the network and block height using the network upgrade activation heights.
   *
   * # Arguments
   * * `network` - Network name (must be "zcash" or "zcashTest")
   * * `wallet_keys` - The wallet's root keys (used to set global xpubs)
   * * `block_height` - Block height to determine consensus rules
   * * `version` - Optional transaction version (default: 4 for Zcash Sapling+)
   * * `lock_time` - Optional lock time (default: 0)
   * * `version_group_id` - Optional version group ID (defaults to Sapling: 0x892F2085)
   * * `expiry_height` - Optional expiry height
   *
   * # Errors
   * Returns error if block height is before Overwinter activation
   */
  static create_empty_zcash_at_height(network: string, wallet_keys: WasmRootWalletKeys, block_height: number, version?: number | null, lock_time?: number | null, version_group_id?: number | null, expiry_height?: number | null): BitGoPsbt;
  /**
   * Parse outputs with wallet keys to identify which outputs belong to a wallet
   *
   * Note: This method does NOT validate wallet inputs. It only parses outputs.
   */
  parse_outputs_with_wallet_keys(wallet_keys: WasmRootWalletKeys, paygo_pubkeys?: WasmECPair[] | null): any;
  /**
   * Parse transaction with wallet keys to identify wallet inputs/outputs
   */
  parse_transaction_with_wallet_keys(wallet_keys: WasmRootWalletKeys, replay_protection: WasmReplayProtection, paygo_pubkeys?: WasmECPair[] | null): any;
  /**
   * Verify if a replay protection input has a valid signature
   *
   * This method checks if a given input is a replay protection input and cryptographically verifies
   * the signature. Replay protection inputs (like P2shP2pk) don't use standard derivation paths,
   * so this method verifies signatures without deriving from xpub.
   *
   * # Arguments
   * - `input_index`: The index of the input to check
   * - `replay_protection`: Replay protection configuration (same format as parseTransactionWithWalletKeys)
   *   Can be either `{ outputScripts: Buffer[] }` or `{ addresses: string[] }`
   *
   * # Returns
   * - `Ok(true)` if the input is a replay protection input and has a valid signature
   * - `Ok(false)` if the input is a replay protection input but has no valid signature
   * - `Err(WasmUtxoError)` if the input is not a replay protection input, index is out of bounds, or configuration is invalid
   */
  verify_replay_protection_signature(input_index: number, replay_protection: WasmReplayProtection): boolean;
  /**
   * Get the network of the PSBT
   */
  network(): string;
  /**
   * Get the transaction version
   */
  version(): number;
  /**
   * Add an input to the PSBT
   *
   * # Arguments
   * * `txid` - The transaction ID (hex string) of the output being spent
   * * `vout` - The output index being spent
   * * `value` - The value in satoshis of the output being spent
   * * `script` - The output script (scriptPubKey) of the output being spent
   * * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
   *
   * # Returns
   * The index of the newly added input
   */
  add_input(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null, prev_tx?: Uint8Array | null): number;
  /**
   * Get the transaction lock time
   */
  lock_time(): number;
  /**
   * Serialize the PSBT to bytes
   *
   * # Returns
   * The serialized PSBT as a byte array
   */
  serialize(): Uint8Array;
}

export class FixedScriptWalletNamespace {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  static output_script(keys: WasmRootWalletKeys, chain: number, index: number, network: any): Uint8Array;
  static address(keys: WasmRootWalletKeys, chain: number, index: number, network: any, address_format?: string | null): string;
}

export class UtxolibCompatNamespace {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Convert address string to output script
   *
   * # Arguments
   * * `address` - The address string
   * * `network` - The UtxolibNetwork object from JavaScript
   * * `format` - Optional address format (currently unused for decoding as all formats are accepted)
   */
  static to_output_script(address: string, network: any, format?: string | null): Uint8Array;
  /**
   * Convert output script to address string
   *
   * # Arguments
   * * `script` - The output script as a byte array
   * * `network` - The UtxolibNetwork object from JavaScript
   * * `format` - Optional address format: "default" or "cashaddr" (only applicable for Bitcoin Cash and eCash)
   */
  static from_output_script(script: Uint8Array, network: any, format?: string | null): string;
}

export class WasmBIP32 {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Derive a key using a derivation path (e.g., "0/1/2" or "m/0/1/2")
   */
  derive_path(path: string): WasmBIP32;
  /**
   * Create a BIP32 key from a base58 string (xpub/xprv/tpub/tprv)
   */
  static from_base58(base58_str: string): WasmBIP32;
  /**
   * Check if this is a neutered (public) key
   */
  is_neutered(): boolean;
  /**
   * Derive a hardened child key (only works for private keys)
   */
  derive_hardened(index: number): WasmBIP32;
  /**
   * Create a BIP32 key from a BIP32Interface JavaScript object properties
   * Expects an object with: network.bip32.public, depth, parentFingerprint,
   * index, chainCode, and publicKey properties
   */
  static from_bip32_interface(bip32_key: any): WasmBIP32;
  /**
   * Create a BIP32 key from BIP32 properties
   * Extracts properties from a JavaScript object and constructs an xpub
   */
  static from_bip32_properties(bip32_key: any): WasmBIP32;
  /**
   * Derive a normal (non-hardened) child key
   */
  derive(index: number): WasmBIP32;
  /**
   * Get the WIF encoding of the private key
   */
  to_wif(): string;
  /**
   * Get the neutered (public) version of this key
   */
  neutered(): WasmBIP32;
  /**
   * Create a BIP32 master key from a seed
   */
  static from_seed(seed: Uint8Array, network?: string | null): WasmBIP32;
  /**
   * Create a BIP32 key from an xprv string (base58-encoded)
   */
  static from_xprv(xprv_str: string): WasmBIP32;
  /**
   * Create a BIP32 key from an xpub string (base58-encoded)
   */
  static from_xpub(xpub_str: string): WasmBIP32;
  /**
   * Serialize to base58 string
   */
  to_base58(): string;
  /**
   * Get the chain code as a Uint8Array
   */
  readonly chain_code: Uint8Array;
  /**
   * Get the identifier as a Uint8Array
   */
  readonly identifier: Uint8Array;
  /**
   * Get the public key as a Uint8Array
   */
  readonly public_key: Uint8Array;
  /**
   * Get the fingerprint as a Uint8Array
   */
  readonly fingerprint: Uint8Array;
  /**
   * Get the private key as a Uint8Array (if available)
   */
  readonly private_key: Uint8Array | undefined;
  /**
   * Get the parent fingerprint
   */
  readonly parent_fingerprint: number;
  /**
   * Get the depth
   */
  readonly depth: number;
  /**
   * Get the child index
   */
  readonly index: number;
}

export class WasmDashTransaction {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Deserialize a Dash transaction from bytes (supports EVO special tx extra payload).
   */
  static from_bytes(bytes: Uint8Array): WasmDashTransaction;
  /**
   * Serialize the Dash transaction to bytes (preserving tx_type and extra payload).
   */
  to_bytes(): Uint8Array;
}

export class WasmECPair {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Convert to mainnet WIF string
   */
  to_wif_mainnet(): string;
  /**
   * Convert to testnet WIF string
   */
  to_wif_testnet(): string;
  /**
   * Create an ECPair from a public key (always uses compressed keys)
   */
  static from_public_key(public_key: Uint8Array): WasmECPair;
  /**
   * Create an ECPair from a private key (always uses compressed keys)
   */
  static from_private_key(private_key: Uint8Array): WasmECPair;
  /**
   * Create an ECPair from a mainnet WIF string
   */
  static from_wif_mainnet(wif_string: string): WasmECPair;
  /**
   * Create an ECPair from a testnet WIF string
   */
  static from_wif_testnet(wif_string: string): WasmECPair;
  /**
   * Convert to WIF string (mainnet)
   */
  to_wif(): string;
  /**
   * Create an ECPair from a WIF string (auto-detects network)
   */
  static from_wif(wif_string: string): WasmECPair;
  /**
   * Get the compressed public key as a Uint8Array (always 33 bytes)
   */
  readonly public_key: Uint8Array;
  /**
   * Get the private key as a Uint8Array (if available)
   */
  readonly private_key: Uint8Array | undefined;
}

export class WasmReplayProtection {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Create from addresses (requires network for decoding)
   */
  static from_addresses(addresses: any[], network: string): WasmReplayProtection;
  /**
   * Create from public keys (derives P2SH-P2PK output scripts)
   */
  static from_public_keys(public_keys: Uint8Array[]): WasmReplayProtection;
  /**
   * Create from output scripts directly
   */
  static from_output_scripts(output_scripts: Uint8Array[]): WasmReplayProtection;
}

export class WasmRootWalletKeys {
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Get the backup key (second xpub)
   */
  backup_key(): WasmBIP32;
  /**
   * Create a RootWalletKeys from three BIP32 keys with custom derivation prefixes
   *
   * # Arguments
   * - `user`: User key (first xpub)
   * - `backup`: Backup key (second xpub)
   * - `bitgo`: BitGo key (third xpub)
   * - `user_derivation`: Derivation path for user key (e.g., "m/0/0")
   * - `backup_derivation`: Derivation path for backup key (e.g., "m/0/0")
   * - `bitgo_derivation`: Derivation path for bitgo key (e.g., "m/0/0")
   */
  static with_derivation_prefixes(user: WasmBIP32, backup: WasmBIP32, bitgo: WasmBIP32, user_derivation: string, backup_derivation: string, bitgo_derivation: string): WasmRootWalletKeys;
  /**
   * Create a RootWalletKeys from three BIP32 keys
   * Uses default derivation prefix of m/0/0 for all three keys
   *
   * # Arguments
   * - `user`: User key (first xpub)
   * - `backup`: Backup key (second xpub)
   * - `bitgo`: BitGo key (third xpub)
   */
  constructor(user: WasmBIP32, backup: WasmBIP32, bitgo: WasmBIP32);
  /**
   * Get the user key (first xpub)
   */
  user_key(): WasmBIP32;
  /**
   * Get the bitgo key (third xpub)
   */
  bitgo_key(): WasmBIP32;
}

export class WasmTransaction {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Deserialize a transaction from bytes
   *
   * # Arguments
   * * `bytes` - The serialized transaction bytes
   *
   * # Returns
   * A WasmTransaction instance
   *
   * # Errors
   * Returns an error if the bytes cannot be parsed as a valid transaction
   */
  static from_bytes(bytes: Uint8Array): WasmTransaction;
  /**
   * Serialize the transaction to bytes
   *
   * # Returns
   * The serialized transaction bytes
   */
  to_bytes(): Uint8Array;
}

export class WasmZcashTransaction {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  /**
   * Deserialize a Zcash transaction from bytes
   *
   * # Arguments
   * * `bytes` - The serialized transaction bytes
   *
   * # Returns
   * A WasmZcashTransaction instance
   *
   * # Errors
   * Returns an error if the bytes cannot be parsed as a valid Zcash transaction
   */
  static from_bytes(bytes: Uint8Array): WasmZcashTransaction;
  /**
   * Serialize the transaction to bytes
   *
   * # Returns
   * The serialized transaction bytes
   */
  to_bytes(): Uint8Array;
}

export class WrapDescriptor {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  hasWildcard(): boolean;
  scriptPubkey(): Uint8Array;
  toAsmString(): string;
  atDerivationIndex(index: number): WrapDescriptor;
  maxWeightToSatisfy(): number;
  node(): any;
  encode(): Uint8Array;
  descType(): any;
  toString(): string;
}

export class WrapMiniscript {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  toAsmString(): string;
  node(): any;
  encode(): Uint8Array;
  toString(): string;
}

export class WrapPsbt {
  private constructor();
  free(): void;
  [Symbol.dispose](): void;
  static deserialize(psbt: Uint8Array): WrapPsbt;
  finalize(): void;
  signWithPrv(prv: Uint8Array): any;
  signWithXprv(xprv: string): any;
  updateInputWithDescriptor(input_index: number, descriptor: WrapDescriptor): void;
  updateOutputWithDescriptor(output_index: number, descriptor: WrapDescriptor): void;
  clone(): WrapPsbt;
  serialize(): Uint8Array;
}
