import { AtomicBEEF, BasketStringUnder300Bytes, Beef, CommsLayer, HexString, LockingScript, LookupNetworkPreset, PubKeyHex, SatoshiValue, TXIDHexString, WalletCounterparty, WalletInterface, WalletProtocol } from "@bsv/sdk"; //#region src/types.d.ts /** * BTMS Token Protocol Field Schema * * BTMS tokens use 2-4 PushDrop fields: * - Field 0: assetId (or "ISSUE" for new token issuance) * - Field 1: amount (as UTF-8 string of a positive integer) * - Field 2: metadata (optional JSON string) * - Field 3: optional PushDrop signature (present when script-level signing is enabled) * * For ISSUE tokens, the canonical assetId becomes `{txid}.{outputIndex}` * after the transaction is mined. */ interface BTMSTokenFields { /** * For issuance: "ISSUE" literal * For transfers: the canonical assetId (e.g., "abc123.0") */ assetId: string; /** Token amount (positive integer) */ amount: number; /** Optional JSON metadata string */ metadata?: string; } /** * Decoded BTMS token from a locking script */ interface DecodedBTMSToken { /** Whether the token is valid according to BTMS protocol */ valid: true; /** The asset identifier (or "ISSUE" for issuance outputs) */ assetId: string; /** Token amount */ amount: number; /** Optional metadata JSON string */ metadata?: string; /** The locking public key from PushDrop */ lockingPublicKey: string; } /** * Invalid token decode result */ interface InvalidBTMSToken { valid: false; error?: string; } /** * Result of decoding a BTMS token */ type BTMSTokenDecodeResult = DecodedBTMSToken | InvalidBTMSToken; /** * Represents a BTMS token asset */ interface BTMSAsset { /** Canonical asset ID (txid.outputIndex format) */ assetId: string; /** Human-readable name from metadata */ name?: string; /** Current balance owned by this wallet */ balance: number; /** Asset metadata */ metadata?: BTMSAssetMetadata; /** Whether there are pending incoming tokens */ hasPendingIncoming?: boolean; } /** * Transaction history entry */ interface BTMSTransaction { /** Transaction ID */ txid: TXIDHexString; /** Transaction type */ type: 'issue' | 'send' | 'receive' | 'burn'; /** Transaction direction from user's perspective */ direction: 'incoming' | 'outgoing'; /** Token amount involved */ amount: number; /** Asset ID */ assetId: string; /** Counterparty public key (if applicable) */ counterparty?: PubKeyHex; /** Transaction timestamp (if available) */ timestamp?: number; /** Transaction description */ description?: string; /** Transaction status */ status: 'completed' | 'pending' | 'failed'; } /** * Result of getTransactions query */ interface GetTransactionsResult { /** List of transactions */ transactions: BTMSTransaction[]; /** Total number of transactions (for pagination) */ total: number; } /** * Asset metadata structure */ interface BTMSAssetMetadata { /** Asset name */ name?: string; /** Asset description */ description?: string; /** Asset icon URL */ iconURL?: string; /** Additional custom fields */ [key: string]: unknown; } /** * UTXO selection strategy for spending tokens. * Different strategies optimize for different goals. */ type SelectionStrategy = 'largest-first' | 'smallest-first' | 'exact-match' | 'random'; /** * Options for UTXO selection */ interface SelectionOptions { /** Selection strategy to use (default: 'largest-first') */ strategy?: SelectionStrategy; /** Fallback strategy when exact-match fails (default: 'largest-first') */ fallbackStrategy?: Exclude; /** Maximum number of UTXOs to select (default: unlimited) */ maxInputs?: number; /** Minimum UTXO amount to consider (default: 0) */ minUtxoAmount?: number; } /** * Result of UTXO selection */ interface SelectionResult { /** Selected UTXOs */ selected: T[]; /** Total input amount from selected UTXOs */ totalInput: number; /** UTXOs that were excluded (not found on overlay, etc.) */ excluded: T[]; } /** * Represents a single change output to be created */ interface ChangeOutput { /** Token amount for this change output */ amount: number; } /** * Context provided to change strategies for computing change outputs */ interface ChangeContext { /** Total change amount to distribute */ changeAmount: number; /** Original payment amount being sent */ paymentAmount: number; /** Total input amount from selected UTXOs */ totalInput: number; /** Asset ID being transferred */ assetId: string; } /** * Interface for custom change generation strategies. * Implementations determine how change is split across outputs. */ interface ChangeStrategy { /** * Compute the change outputs for a transaction. * The sum of all returned output amounts must equal changeAmount. * * @param context - Context about the transaction * @returns Array of change outputs to create */ computeChange(context: ChangeContext): ChangeOutput[]; } /** * Built-in change strategy types */ type ChangeStrategyType = 'single' | 'split-equal' | 'split-random'; /** * Options for built-in change strategies */ interface ChangeStrategyOptions { /** Strategy type or custom strategy implementation */ strategy?: ChangeStrategyType | ChangeStrategy; /** Number of outputs for split strategies (default: 2) */ splitCount?: number; /** Minimum amount per output for split strategies (default: 1) */ minOutputAmount?: number; } /** * Represents a single transaction in a multi-transaction transfer */ interface TransferTransaction { /** Transaction ID */ txid: TXIDHexString; /** Output index for the recipient's token */ outputIndex: number; /** Token amount in this transaction */ amount: number; /** Locking script for the recipient's output */ lockingScript: HexString; /** Derivation suffix for this specific output */ derivationSuffix: string; } /** * Options for splitting transfers across multiple transactions */ interface TransferSplitOptions { /** Number of transactions to split across (default: 1 = no split) */ transactionCount?: number; /** How to distribute amounts across transactions */ distribution?: 'equal' | 'random'; /** Minimum amount per transaction (default: 1) */ minAmountPerTx?: number; } /** * Token transfer data for recipient (supports multi-transaction transfers) */ interface MultiTransactionTransfer { /** Shared derivation prefix for all outputs in this transfer */ derivationPrefix: string; /** Asset being transferred */ assetId: string; /** Total amount across all transactions */ totalAmount: number; /** Asset metadata */ metadata?: string; /** Individual transactions in this transfer */ transactions: TransferTransaction[]; /** Merged BEEF containing all transactions */ beef: AtomicBEEF; } /** * A BTMS token UTXO from the wallet */ interface BTMSTokenOutput { /** Outpoint in "txid.outputIndex" format */ outpoint: string; /** Transaction ID */ txid: TXIDHexString; /** Output index */ outputIndex: number; /** Satoshi value (typically 1 for BTMS tokens) */ satoshis: SatoshiValue; /** Locking script hex */ lockingScript: HexString; /** Custom instructions containing derivation keys */ customInstructions?: string; /** Decoded token data */ token: DecodedBTMSToken; /** Whether this output is spendable */ spendable: boolean; /** Full transaction BEEF (when available) */ beef?: AtomicBEEF; } /** * Token data sent to a recipient */ interface TokenForRecipient { /** Transaction ID containing the token */ txid: TXIDHexString; /** Output index of the token */ outputIndex: number; /** Locking script hex */ lockingScript: HexString; /** Token amount */ amount: number; /** Satoshi value */ satoshis: SatoshiValue; /** Full BEEF for SPV verification */ beef: AtomicBEEF; /** Custom instructions containing derivation keys */ customInstructions: string; /** Asset ID */ assetId: string; /** Metadata JSON */ metadata?: string; } /** * Incoming token from another user. * Extends TokenForRecipient with messaging metadata. */ interface IncomingToken extends TokenForRecipient { /** Sender's identity key (added by messaging layer) */ sender: PubKeyHex; /** Message ID for acknowledgment (added by messaging layer) */ messageId: string; } /** * Result of a token issuance operation */ interface IssueResult { /** Whether the operation succeeded */ success: boolean; /** Transaction ID of the issuance */ txid: TXIDHexString; /** Canonical asset ID (txid.0 for single output) */ assetId: string; /** Output index of the token */ outputIndex: number; /** Amount issued */ amount: number; /** Error message if failed */ error?: string; } /** * Result of a token send operation */ interface SendResult { /** Whether the operation succeeded */ success: boolean; /** Transaction ID */ txid: TXIDHexString; /** Token data for recipient */ tokenForRecipient: TokenForRecipient; /** Change amount returned to sender (if any) */ changeAmount?: number; /** Error message if failed */ error?: string; } /** * Result of accepting an incoming payment */ interface AcceptResult { /** Whether the operation succeeded */ success: boolean; /** The accepted asset ID */ assetId: string; /** Amount accepted */ amount: number; /** Error message if failed */ error?: string; } /** * Result of refunding an incoming payment */ interface RefundResult { /** Whether the operation succeeded */ success: boolean; /** Transaction ID for the refund */ txid: TXIDHexString; /** The refunded asset ID */ assetId: string; /** Amount refunded */ amount: number; /** Error message if failed */ error?: string; } /** * Result of a token burn operation */ interface BurnResult { /** Whether the operation succeeded */ success: boolean; /** Transaction ID */ txid: TXIDHexString; /** Asset ID that was burned */ assetId: string; /** Amount of tokens burned (destroyed) */ amountBurned: number; /** Error message if failed */ error?: string; } /** * BTMS configuration options */ interface BTMSConfig { /** Wallet interface for signing transactions (default: new WalletClient()) */ wallet?: WalletInterface; /** Network preset for overlay services (default: 'mainnet') */ networkPreset?: LookupNetworkPreset; /** Optional communications layer for token messaging (e.g., MessageBoxClient) */ comms?: CommsLayer; } /** * Key linkage revelation for a specific token */ interface TokenKeyLinkage { /** The prover's identity public key */ prover: PubKeyHex; /** The verifier's identity public key */ verifier: PubKeyHex; /** The counterparty (for BTMS, typically 'self' resolved to prover's key) */ counterparty: PubKeyHex; /** Encrypted linkage data */ encryptedLinkage: number[]; /** Encrypted linkage proof */ encryptedLinkageProof: number[]; /** Proof type byte */ proofType: number; } /** * A proven token with its output data and key linkage */ interface ProvenToken { /** The token output being proven */ output: { txid: TXIDHexString; outputIndex: number; lockingScript: HexString; satoshis: SatoshiValue; }; /** Key derivation identifier used to create the linkage proof */ keyID: string; /** Key linkage revelation for this token */ linkage: TokenKeyLinkage; } /** * Ownership proof for a set of tokens */ interface OwnershipProof { /** The prover's identity public key */ prover: PubKeyHex; /** The verifier's identity public key */ verifier: PubKeyHex; /** The proven tokens with their linkages */ tokens: ProvenToken[]; /** Total amount being proven */ amount: number; /** Asset ID being proven */ assetId: string; } /** * Result of proving ownership */ interface ProveOwnershipResult { /** Whether the operation succeeded */ success: boolean; /** The ownership proof (if successful) */ proof?: OwnershipProof; /** Error message if failed */ error?: string; } /** * Result of verifying ownership */ interface VerifyOwnershipResult { /** Whether the proof is valid */ valid: boolean; /** The verified amount */ amount?: number; /** The verified asset ID */ assetId?: string; /** The prover's identity key */ prover?: PubKeyHex; /** Error message if verification failed */ error?: string; } /** * Marketplace listing for atomic swaps (future use) */ interface MarketplaceListing { /** Listing ID */ listingId: string; /** Asset being sold */ assetId: string; /** Amount for sale */ amount: number; /** Price in satoshis */ priceSatoshis: number; /** Seller's identity key */ seller: PubKeyHex; /** Listing expiry timestamp */ expiresAt?: number; } /** * Marketplace offer for atomic swaps (future use) */ interface MarketplaceOffer { /** Offer ID */ offerId: string; /** Listing being offered on */ listingId: string; /** Offered price in satoshis */ offerSatoshis: number; /** Buyer's identity key */ buyer: PubKeyHex; /** Offer expiry timestamp */ expiresAt?: number; } //#endregion //#region src/BTMSHelpers.d.ts interface BadOutput { outpoint: string; reason: string; } //#endregion //#region src/BTMS.d.ts /** * BTMS - Basic Token Management System * * @example * ```typescript * // Create a BTMS instance * const btms = new BTMS() * * // Issue new tokens * const result = await btms.issue(1000, { name: 'GOLD', description: 'A test token' }) * console.log('Asset ID:', result.assetId) * * // Check balance * const balance = await btms.getBalance(result.assetId) * console.log('Balance:', balance) * * // Send tokens * await btms.send(result.assetId, recipientPubKey, 100) * * // List all assets * const assets = await btms.listAssets() * ``` */ export declare class BTMS { private readonly wallet; private readonly networkPreset; private readonly comms?; private tokenTemplate; private cachedIdentityKey?; private originator?; private static readonly LIST_OUTPUTS_PAGE_SIZE; private static readonly MAX_LIST_OUTPUTS_PAGES; private static readonly BROADCAST_MAX_ATTEMPTS; constructor(config?: BTMSConfig); /** * Set the originator for wallet calls. * This is passed through to all wallet operations. */ setOriginator(originator: string): void; /** * Issue new BTMS tokens. * * Creates a new token with the specified amount and optional metadata. * The token will be stored in basket 'p btms ' where assetId is * the canonical txid.0 format determined after transaction creation. * * @param amount - Number of tokens to issue (positive integer) * @param metadata - Optional metadata including name, description, iconURL, etc. * @returns Issue result with txid and assetId * * @example * ```typescript * const result = await btms.issue(1000000, { * name: 'GOLD', * description: 'Represents 1 gram of gold', * iconURL: 'https://example.com/gold.png' // or a UHRP url * }) * console.log('Asset ID:', result.assetId) // e.g., 'abc123...def.0' * ``` */ issue(amount: number, metadata?: BTMSAssetMetadata): Promise; /** * Send tokens to a recipient. * * Selects UTXOs to cover the amount, creates transfer outputs, * and broadcasts the transaction. If a messenger is configured, * also sends the token data to the recipient. * * @param assetId - The asset to send * @param recipient - Recipient's identity public key * @param amount - Amount to send * @param options - Optional send options including change strategy * @returns Send result with transaction details */ send(assetId: string, recipient: PubKeyHex, amount: number, options?: { changeStrategy?: ChangeStrategyOptions; }): Promise; /** * Burn (destroy) tokens permanently. * * This operation spends token UTXOs without creating corresponding outputs, * effectively destroying the tokens. This is useful when tokens represent * claims on physical assets that have been redeemed (e.g., trading gold * tokens for physical gold). * * @param assetId - The asset to burn * @param amount - Amount to burn (if undefined, burns entire balance) * @param options - Optional change strategy for remaining balance * @returns Burn result with transaction details * * @example * ```typescript * // Burn 50 tokens * const result = await btms.burn('abc123.0', 50) * * // Burn entire balance * const result = await btms.burn('abc123.0') * ``` */ burn(assetId: string, amount?: number, options?: { changeStrategy?: ChangeStrategyOptions; }): Promise; /** * List incoming token payments (requires comms layer). * * @param assetId - Optional filter by asset ID * @returns List of incoming payments */ listIncoming(assetId?: string): Promise; /** * Accept an incoming token. * * Verifies the token on the overlay, internalizes it into the wallet, * and acknowledges receipt via the messenger. * * @param token - The incoming token to accept * @returns Accept result */ accept(token: IncomingToken): Promise; /** * Refund an incoming token back to the sender without internalizing it. * * Verifies the token, spends it, and sends a new token of equal value * back to the original sender. The original incoming message is acknowledged * so it disappears from the receiver's incoming list. * * @param token - The incoming token to refund * @returns Refund result */ refundIncoming(token: IncomingToken): Promise; /** * Get the balance of a specific asset. * * @param assetId - The asset to check * @returns Total spendable balance */ getBalance(assetId: string): Promise; /** * Get info for a specific asset by ID using a targeted tag-based query. * Uses the assetId label to efficiently find outputs for this asset. * * @param assetId - The asset ID to look up * @returns Asset info with name and metadata, or null if not found */ getAssetInfo(assetId: string): Promise<{ name?: string; metadata?: BTMSAssetMetadata; } | null>; /** * Lookup asset metadata from the overlay using assetId and BEEF. */ private lookupAssetMetadataOnOverlay; /** * List all assets owned by this wallet. * * @returns List of assets with balances */ listAssets(): Promise; /** Scan basket outputs and populate `assetIds` + `assetBalances`. */ private collectOwnedTokensIntoBalances; /** Fetch pending incoming messages and add their asset IDs to `assetIds`. */ private collectIncomingMessages; /** Build the final `BTMSAsset[]` from accumulated data. */ private buildAssetList; /** * Get transaction history for an asset. * * @param assetId - The asset to query * @param limit - Maximum number of transactions to return * @param offset - Number of transactions to skip (for pagination) * @returns Transaction history with pagination info */ getTransactions(assetId: string, limit?: number, offset?: number): Promise; /** * Get all spendable token UTXOs for an asset. * * @param assetId - The asset to query * @param includeBeef - Whether to include full transaction data (for spending) * @returns List of spendable token outputs and optional BEEF */ getSpendableTokens(assetId: string, includeBeef?: boolean): Promise<{ tokens: BTMSTokenOutput[]; beef?: Beef; }>; /** Attempt to decode one basket output into a `BTMSTokenOutput` for the given asset. */ private tryDecodeSpendableOutput; /** * Find outputs in the BTMS basket that cannot be decoded as valid tokens. * Useful for cleaning up corrupted or non-overlay outputs. */ findBadOutputs(): Promise; /** * Relinquish corrupted outputs from the BTMS basket using wallet.relinquishOutput. * Returns which outpoints were relinquished and which failed. */ relinquishBadOutputs(): Promise<{ relinquished: string[]; failed: Array<{ outpoint: string; error: string; }>; }>; /** * Prove ownership of tokens to a verifier. * * Creates a cryptographic proof that the caller owns the specified tokens * by revealing key linkage information that only the owner could produce. * * @param assetId - The asset to prove ownership of * @param amount - The amount to prove (must have sufficient balance) * @param verifier - The verifier's identity public key * @returns Ownership proof that can be verified by the verifier * * @example * ```typescript * const proof = await btms.proveOwnership('abc123.0', 100, verifierPubKey) * // Send proof to verifier for verification * ``` */ proveOwnership(assetId: string, amount: number, verifier: PubKeyHex): Promise; /** * Verify an ownership proof from a prover. * * Validates that: * 1. The key linkage is valid for each token * 2. The tokens exist on the overlay * 3. The total amount matches the claimed amount * 4. All tokens belong to the claimed prover * * @param proof - The ownership proof to verify * @returns Verification result * * @example * ```typescript * const result = await btms.verifyOwnership(proof) * if (result.valid) { * console.log(`Verified ${result.amount} tokens owned by ${result.prover}`) * } * ``` */ verifyOwnership(proof: OwnershipProof): Promise; /** * Lookup a token on the overlay network. * * @param txid - Transaction ID * @param outputIndex - Output index * @param includeBeef - Whether to return BEEF data * @returns Whether the token was found and optionally the BEEF */ protected lookupTokenOnOverlay(txid: TXIDHexString, outputIndex: number, includeBeef?: boolean): Promise<{ found: boolean; beef?: Beef; }>; /** * Get the wallet's identity public key (cached after first call). */ getIdentityKey(): Promise; private getMonthLabel; private getTimestampLabel; private getMonthTag; private getTimestampTag; private buildSpendsForInputs; private signAndBroadcast; private broadcastWithRetry; private listOutputsPaged; /** * Ensure a createAction inputBEEF is complete and non-txid-only for required inputs. */ private ensureCompleteInputBeef; /** * Decode a token from a locking script. */ decodeToken(lockingScript: string | LockingScript): BTMSTokenDecodeResult; /** Assert that all selected UTXOs carry the same metadata. */ private assertConsistentMetadata; /** Build change `CreateActionOutput` entries for a send or burn. */ private buildChangeOutputs; /** * Sign and broadcast a burn transaction. * When burning all tokens (no change outputs), overlay rejection is treated as success. */ private signAndBroadcastBurn; /** Verify a single proven token and return its amount contribution. */ private verifySingleProvenToken; private verifySelectedUtxos; private missingUtxoBeefByOutpoint; private rebroadcastMissingUtxos; private mergeVerificationBeefs; /** * Select and verify UTXOs on the overlay. * * Selects UTXOs first using the specified strategy, then verifies only * the selected ones on the overlay. If any fail verification, retries * with remaining UTXOs. * * @param utxos - Available UTXOs to select from * @param amount - Target amount to cover * @param options - Selection options including strategy * @returns Selected UTXOs, total input, and merged BEEF from overlay */ selectAndVerifyUTXOs(utxos: BTMSTokenOutput[], amount: number, options?: SelectionOptions): Promise<{ selected: BTMSTokenOutput[]; totalInput: number; inputBeef: Beef; }>; /** Resolve the locking-script hex for one page output (handles BEEF and plain-script modes). */ private resolveScriptHex; /** Attempt to re-broadcast a UTXO and return whether it was admitted by the overlay. */ private tryRebroadcastUtxo; /** * Select UTXOs to cover a target amount using a configurable strategy. * * @param utxos - Available UTXOs to select from * @param amount - Target amount to cover * @param options - Selection options including strategy * @returns Selected UTXOs, total input amount, and excluded UTXOs */ static selectUTXOs(utxos: T[], amount: number, options?: SelectionOptions): SelectionResult; /** * Compute change outputs using the specified strategy. * * @param context - Change context with amounts and asset info * @param options - Change strategy options * @returns Array of change outputs to create */ static computeChangeOutputs(context: ChangeContext, options?: ChangeStrategyOptions): ChangeOutput[]; /** * Split change into equal amounts. */ private static splitEqualChange; /** * Split change into random amounts using a logarithmic distribution. * Uses a Benford-inspired formula to favor smaller amounts, creating * more natural-looking output amounts for privacy. */ private static splitRandomChange; /** * Generate a logarithmically-distributed random number. * Uses a formula inspired by Benford's law to favor smaller values, * creating more natural-looking distributions. */ private static benfordNumber; private static shuffle; private static randomInt; } //#endregion //#region src/BTMSToken.d.ts /** * BTMSToken handles encoding and decoding of BTMS PushDrop tokens. * * The token format follows the BTMSTopicManager protocol exactly: * - Field 0: assetId or "ISSUE" * - Field 1: amount (positive integer as string) * - Field 2: metadata (optional JSON) * * @example * ```typescript * const token = new BTMSToken(wallet) * * // Create an issuance token * const lockScript = await token.createIssuance(1000, { name: 'MyToken' }) * * // Create a transfer token * const transferScript = await token.createTransfer('abc123.0', 500, metadata, recipient) * * // Decode a token * const decoded = BTMSToken.decode(lockingScriptHex) * ``` */ export declare class BTMSToken { private readonly wallet; private readonly protocolID; private readonly originator?; constructor(wallet?: WalletInterface, protocolID?: WalletProtocol, originator?: string); /** * Create a token issuance locking script. * * Issuance tokens use "ISSUE" as field[0]. The canonical assetId * becomes `{txid}.{outputIndex}` after the transaction is mined. * * @param amount - Number of tokens to issue (positive integer) * @param keyID - Key ID for derivation * @param metadata - Optional metadata object (will be JSON stringified) * @param counterparty - Who can spend this token (default: 'self') * @returns The locking script for the issuance output */ createIssuance(amount: number, keyID: string, metadata?: Record, counterparty?: WalletCounterparty): Promise; /** * Create a token transfer locking script. * * Transfer tokens reference an existing assetId in field[0]. * The metadata must match the original issuance metadata for the * TopicManager to accept the output. * * @param assetId - The canonical asset ID (txid.outputIndex format) * @param amount - Number of tokens to transfer (positive integer) * @param metadata - Metadata (must match original issuance) * @param counterparty - Recipient's identity key or 'self' * @param keyID - key ID for derivation * @param includeSignature - Whether to include PushDrop signature (default false, since signAction handles signing) * @returns The locking script for the transfer output */ createTransfer(assetId: string, amount: number, keyID: string, counterparty?: WalletCounterparty, metadata?: string, includeSignature?: boolean): Promise; /** * Create an unlocking script template for spending a BTMS token. * * @param counterparty - The counterparty used when the token was created * @param keyID - Key ID for derivation from customInstructions * @returns An unlocker that can sign transactions */ createUnlocker(keyID: string, counterparty?: WalletCounterparty): { sign: (tx: import("@bsv/sdk").Transaction, inputIndex: number) => Promise; estimateLength: () => Promise<73>; }; /** * Decode a BTMS token from a locking script. * * This is a static method that can be used without a wallet instance. * * @param lockingScript - The locking script (hex string or LockingScript) * @returns Decoded token data or invalid result */ static decode(lockingScript: string | LockingScript): BTMSTokenDecodeResult; /** * Check if a string is a valid asset ID format (txid.outputIndex) */ static isValidAssetId(assetId: string): boolean; /** * Check if a decoded token is an issuance */ static isIssuance(decoded: DecodedBTMSToken): boolean; /** * Compute the canonical asset ID from a transaction ID and output index. * This is used after an issuance transaction is mined. */ static computeAssetId(txid: string, outputIndex: number): string; private validateAmount; private validateAssetId; private buildFields; private buildFieldsRaw; } //#endregion //#region src/constants.d.ts /** BTMS Topic Manager identifier */ export declare const BTMS_TOPIC = "tm_btms"; /** BTMS Lookup Service identifier */ export declare const BTMS_LOOKUP_SERVICE = "ls_btms"; /** Literal used in field[0] to indicate token issuance */ export declare const ISSUE_MARKER = "ISSUE"; /** Default satoshi value for BTMS token outputs */ export declare const DEFAULT_TOKEN_SATOSHIS: SatoshiValue; /** * BTMS Protocol ID for wallet operations * * Format: [securityLevel, protocolName] * - Security level 0: No special security requirements * - Protocol name "p btms": Matches the basket prefix for consistency */ export declare const BTMS_PROTOCOL_ID: WalletProtocol; /** * Basket name for all BTMS tokens * * All BTMS token outputs are stored in a single basket: "p btms" * Individual assets are differentiated by: * - Tags: btms_issue, btms_change, btms_received, btms_send * - Token script content (assetId encoded in the token) * * This architecture allows efficient querying: * - Single listOutputs call to get all BTMS tokens * - Filter by tags to get owned tokens (issue/change/received) * - Decode scripts to discover unique assets */ export declare const BTMS_BASKET: BasketStringUnder300Bytes; /** Prefix for BTMS P-labels (BRC-111 format: `p `) */ export declare const BTMS_LABEL_PREFIX = "p btms "; /** Maximum allowed token amount */ export declare const MAX_TOKEN_AMOUNT: number; /** Minimum allowed token amount */ export declare const MIN_TOKEN_AMOUNT = 1; //#endregion //#region src/utils.d.ts /** * Parsed custom instructions containing key derivation info */ interface ParsedCustomInstructions { /** The keyID string (derivationPrefix + ' ' + derivationSuffix) */ keyID: string; /** The sender's identity key (counterparty for unlocking) */ senderIdentityKey?: string; } /** * Extract keyID and senderIdentityKey from customInstructions stored with a UTXO. * * @param customInstructions - The customInstructions JSON string * @param txid - Transaction ID (for error messages) * @param outputIndex - Output index (for error messages) * @returns Parsed instructions containing keyID and optional senderIdentityKey * @throws Error if customInstructions are missing or invalid */ export declare function parseCustomInstructions(customInstructions: string | undefined, txid: string, outputIndex: number): ParsedCustomInstructions; //#endregion export type { AcceptResult, BTMSAsset, BTMSAssetMetadata, BTMSConfig, BTMSTokenDecodeResult, BTMSTokenFields, BTMSTokenOutput, BTMSTransaction, BurnResult, ChangeContext, ChangeOutput, ChangeStrategy, ChangeStrategyOptions, ChangeStrategyType, DecodedBTMSToken, GetTransactionsResult, IncomingToken, InvalidBTMSToken, IssueResult, MarketplaceListing, MarketplaceOffer, MultiTransactionTransfer, OwnershipProof, ParsedCustomInstructions, ProveOwnershipResult, ProvenToken, RefundResult, SelectionOptions, SelectionResult, SelectionStrategy, SendResult, TokenForRecipient, TokenKeyLinkage, TransferSplitOptions, TransferTransaction, VerifyOwnershipResult }; //# sourceMappingURL=index.d.mts.map