@neuraiproject/neurai-scripts 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NeuraiScripts.global.js +3 -0
- package/dist/NeuraiScripts.global.js.map +1 -1
- package/dist/browser.js +3 -0
- package/dist/browser.js.map +1 -1
- package/dist/core/opcodes.d.ts +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sources":["../build/core/bytes.js","../node_modules/@neuraiproject/neurai-create-transaction/dist/amounts.js","../build/core/opcodes.js","../build/core/script-builder.js","../build/standard/p2pkh.js","../build/standard/p2wpkh.js","../build/standard/p2wsh.js","../build/standard/authscript.js","../build/standard/nulldata.js","../build/standard/multisig.js","../node_modules/@neuraiproject/neurai-create-transaction/dist/index.js","../build/address.js","../build/asset-wrapper.js","../build/core/script-parser.js","../build/covenants/partial-fill/expiration.js","../build/covenants/partial-fill/fill-branches.js","../build/covenants/partial-fill/script.js","../build/covenants/partial-fill/script-pq.js","../build/covenants/partial-fill/spend.js","../build/covenants/partial-fill/spend-pq.js","../build/covenants/partial-fill/witness.js","../build/covenants/partial-fill/parse.js","../build/covenants/partial-fill/parse-pq.js","../build/covenants/asset-auth/policy.js","../node_modules/@noble/hashes/_u64.js","../node_modules/@noble/hashes/utils.js","../node_modules/@noble/hashes/_md.js","../node_modules/@noble/hashes/sha2.js","../build/covenants/asset-auth/proposal.js","../build/covenants/asset-auth/vote.js"],"sourcesContent":["/**\n * Minimal byte helpers. A subset of what `neurai-create-transaction` exposes,\n * duplicated here to keep this package free of runtime coupling beyond its\n * declared `dependencies` field. All sizes are little-endian, per Neurai.\n */\nexport function ensureHex(hex, label = 'hex') {\n const normalized = String(hex || '').trim().toLowerCase();\n if (!/^[0-9a-f]*$/.test(normalized) || normalized.length % 2 !== 0) {\n throw new Error(`Invalid ${label}: expected even-length hex string`);\n }\n return normalized;\n}\nexport function hexToBytes(hex) {\n const normalized = ensureHex(hex);\n const bytes = new Uint8Array(normalized.length / 2);\n for (let i = 0; i < normalized.length; i += 2) {\n bytes[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16);\n }\n return bytes;\n}\nexport function bytesToHex(bytes) {\n return Array.from(bytes, (value) => value.toString(16).padStart(2, '0')).join('');\n}\nexport function concatBytes(...parts) {\n const total = parts.reduce((sum, part) => sum + part.length, 0);\n const out = new Uint8Array(total);\n let offset = 0;\n for (const part of parts) {\n out.set(part, offset);\n offset += part.length;\n }\n return out;\n}\nexport function bytesEqual(a, b) {\n if (a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i += 1) {\n if (a[i] !== b[i])\n return false;\n }\n return true;\n}\n","/** Exact monetary primitives. This module has no runtime dependencies. */\nconst SATS_PER_XNA = 100000000n;\nconst MAX_MONEY = 2100000000000000000n;\n/** Normalize a raw integer without preserving an already rounded number. */\nfunction toRawInteger(value, label = 'amount') {\n if (typeof value === 'bigint')\n return value;\n if (typeof value === 'number' && Number.isSafeInteger(value))\n return BigInt(value);\n if (typeof value === 'string' && /^-?\\d+$/.test(value) && value.length <= 100)\n return BigInt(value);\n throw new Error(`${label}: expected an exact integer; use bigint or an integer string for large values`);\n}\nfunction assertMoneyRange(value, label = 'amount') {\n const raw = toRawInteger(value, label);\n if (raw < 0n || raw > MAX_MONEY)\n throw new Error(`${label} outside Neurai monetary range`);\n return raw;\n}\n/** Parse decimal units exactly, including scientific notation, with at most 8 decimals. */\nfunction decimalToSatoshis(value) {\n if (typeof value !== 'string' && typeof value !== 'number')\n throw new Error('Expected decimal string or number');\n if (typeof value === 'number' && !Number.isFinite(value))\n throw new Error('Amount must be finite');\n const text = String(value);\n if (text.length > 100)\n throw new Error('Amount too long');\n const match = /^(-?)(\\d+)(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/.exec(text);\n if (!match)\n throw new Error('Invalid decimal amount');\n const exponent = Number(match[4] ?? 0);\n if (!Number.isSafeInteger(exponent) || Math.abs(exponent) > 100)\n throw new Error('Invalid decimal exponent');\n const fraction = match[3] ?? '';\n const shift = 8 + exponent - fraction.length;\n let raw = BigInt(match[2] + fraction);\n if (shift >= 0)\n raw *= 10n ** BigInt(shift);\n else {\n const divisor = 10n ** BigInt(-shift);\n if (raw % divisor !== 0n)\n throw new Error('Amount has more than 8 decimals');\n raw /= divisor;\n }\n if (typeof value === 'number' && raw > BigInt(Number.MAX_SAFE_INTEGER) && !Number.isSafeInteger(value)) {\n throw new Error('Large fractional amounts must be supplied as decimal strings');\n }\n return match[1] ? -raw : raw;\n}\n/** Format signed raw units without converting to floating point. */\nfunction satoshisToDecimal(value) {\n const raw = toRawInteger(value);\n const abs = raw < 0n ? -raw : raw;\n const fraction = (abs % SATS_PER_XNA).toString().padStart(8, '0').replace(/0+$/, '');\n return `${raw < 0n ? '-' : ''}${abs / SATS_PER_XNA}${fraction ? '.' + fraction : ''}`;\n}\n\nexport { MAX_MONEY, SATS_PER_XNA, assertMoneyRange, decimalToSatoshis, satoshisToDecimal, toRawInteger };\n","/**\n * Opcode constants for Neurai Script.\n *\n * Covers:\n * - Classic Script opcodes used by covenants.\n * - New opcodes activated in the `DePIN-Test` branch (BIP 119, BIP 347 and\n * Neurai-specific introspection / asset / arithmetic additions).\n *\n * Authority: `src/script/script.h` (enum `opcodetype`) in the Neurai repo.\n * Reference: `doc/new-opcodes-depin-branch.md`.\n *\n * Disabled in consensus and intentionally omitted: OP_SUBSTR, OP_LEFT,\n * OP_RIGHT, OP_INVERT, OP_AND, OP_OR, OP_XOR, OP_2MUL, OP_2DIV, OP_LSHIFT,\n * OP_RSHIFT. Also omitted: OP_VER / OP_VERIF / OP_VERNOTIF (reserved), the\n * template-matching pseudo-opcodes (OP_SMALLINTEGER, OP_PUBKEYS,\n * OP_PUBKEYHASH, OP_PUBKEY) and OP_INVALIDOPCODE.\n */\n// ---------- Push values ----------\nexport const OP_0 = 0x00;\nexport const OP_FALSE = OP_0;\nexport const OP_PUSHDATA1 = 0x4c;\nexport const OP_PUSHDATA2 = 0x4d;\nexport const OP_PUSHDATA4 = 0x4e;\nexport const OP_1NEGATE = 0x4f;\nexport const OP_RESERVED = 0x50;\nexport const OP_1 = 0x51;\nexport const OP_TRUE = OP_1;\nexport const OP_2 = 0x52;\nexport const OP_3 = 0x53;\nexport const OP_4 = 0x54;\nexport const OP_5 = 0x55;\nexport const OP_6 = 0x56;\nexport const OP_7 = 0x57;\nexport const OP_8 = 0x58;\nexport const OP_9 = 0x59;\nexport const OP_10 = 0x5a;\nexport const OP_11 = 0x5b;\nexport const OP_12 = 0x5c;\nexport const OP_13 = 0x5d;\nexport const OP_14 = 0x5e;\nexport const OP_15 = 0x5f;\nexport const OP_16 = 0x60;\n// ---------- Control flow ----------\nexport const OP_NOP = 0x61;\nexport const OP_IF = 0x63;\nexport const OP_NOTIF = 0x64;\nexport const OP_ELSE = 0x67;\nexport const OP_ENDIF = 0x68;\nexport const OP_VERIFY = 0x69;\nexport const OP_RETURN = 0x6a;\n// ---------- Stack ----------\nexport const OP_TOALTSTACK = 0x6b;\nexport const OP_FROMALTSTACK = 0x6c;\nexport const OP_2DROP = 0x6d;\nexport const OP_2DUP = 0x6e;\nexport const OP_3DUP = 0x6f;\nexport const OP_2OVER = 0x70;\nexport const OP_2ROT = 0x71;\nexport const OP_2SWAP = 0x72;\nexport const OP_IFDUP = 0x73;\nexport const OP_DEPTH = 0x74;\nexport const OP_DROP = 0x75;\nexport const OP_DUP = 0x76;\nexport const OP_NIP = 0x77;\nexport const OP_OVER = 0x78;\nexport const OP_PICK = 0x79;\nexport const OP_ROLL = 0x7a;\nexport const OP_ROT = 0x7b;\nexport const OP_SWAP = 0x7c;\nexport const OP_TUCK = 0x7d;\n// ---------- Splice ----------\nexport const OP_SIZE = 0x82;\n// ---------- Bitwise / comparison ----------\nexport const OP_EQUAL = 0x87;\nexport const OP_EQUALVERIFY = 0x88;\n// ---------- Unary numeric ----------\nexport const OP_1ADD = 0x8b;\nexport const OP_1SUB = 0x8c;\nexport const OP_NEGATE = 0x8f;\nexport const OP_ABS = 0x90;\nexport const OP_NOT = 0x91;\nexport const OP_0NOTEQUAL = 0x92;\n// ---------- Arithmetic (64-bit after SCRIPT_VERIFY_64BIT_INTEGERS) ----------\nexport const OP_ADD = 0x93;\nexport const OP_SUB = 0x94;\nexport const OP_MUL = 0x95;\nexport const OP_DIV = 0x96;\nexport const OP_MOD = 0x97;\n// ---------- Boolean / numeric comparison ----------\nexport const OP_BOOLAND = 0x9a;\nexport const OP_BOOLOR = 0x9b;\nexport const OP_NUMEQUAL = 0x9c;\nexport const OP_NUMEQUALVERIFY = 0x9d;\nexport const OP_NUMNOTEQUAL = 0x9e;\nexport const OP_LESSTHAN = 0x9f;\nexport const OP_GREATERTHAN = 0xa0;\nexport const OP_LESSTHANOREQUAL = 0xa1;\nexport const OP_GREATERTHANOREQUAL = 0xa2;\nexport const OP_MIN = 0xa3;\nexport const OP_MAX = 0xa4;\nexport const OP_WITHIN = 0xa5;\n// ---------- Crypto ----------\nexport const OP_RIPEMD160 = 0xa6;\nexport const OP_SHA1 = 0xa7;\nexport const OP_SHA256 = 0xa8;\nexport const OP_HASH160 = 0xa9;\nexport const OP_HASH256 = 0xaa;\nexport const OP_CODESEPARATOR = 0xab;\nexport const OP_CHECKSIG = 0xac;\nexport const OP_CHECKSIGVERIFY = 0xad;\nexport const OP_CHECKMULTISIG = 0xae;\nexport const OP_CHECKMULTISIGVERIFY = 0xaf;\n// ---------- Extended hash opcodes ----------\n// NIP-030: KECCAK256 / BLAKE2B in previously unassigned slots.\nexport const OP_KECCAK256 = 0xba;\nexport const OP_BLAKE2B = 0xbb;\n// NIP-034a: modern hash opcodes (BLAKE3, SHA3-256, SHA-512).\n// NIP-036: OP_POSEIDON — SNARK-friendly Poseidon hash over the BN254\n// scalar field. Occupies slot 0xc9.\nexport const OP_BLAKE3 = 0xc8;\nexport const OP_POSEIDON = 0xc9;\nexport const OP_SHA3_256 = 0xca;\nexport const OP_SHA512 = 0xcb;\n// ---------- Extended signature opcodes ----------\n// NIP-035: strict-profile RFC 8032 PureEd25519 verifier in slot 0xdd.\n// Stack contract: (sig64, msg, pubkey32 -- 0|1). Slots 0xd8..0xdc are\n// reserved by NIP-033 (BLS12-381 family), unassigned in current code.\nexport const OP_CHECKSIG_ED25519 = 0xdd;\n// NIP-039: generic OP_CHECKSIG-compatible signature accumulator in slot\n// 0xde. Stack contract: (sig, count, pubkey -- count + 0|1). Works with\n// both legacy secp256k1 and PQ ML-DSA-44 keys via CPubKey::Verify().\nexport const OP_CHECKSIGADD = 0xde;\n// NIP-054 (P2AH): M-of-N authorization by owner-token roles in slot 0xdf,\n// AuthScript only. Stack contract: (c a b T 1 M G role_1 .. role_n n -- 1),\n// failing the script instead of pushing 0. See covenants/asset-auth.\nexport const OP_CHECKASSETAUTH = 0xdf;\n// ---------- Expansion / NOPs ----------\n// Only the NOPs not aliased by DePIN-Test opcodes are exported as NOPs.\n// OP_NOP2 == OP_CHECKLOCKTIMEVERIFY (0xb1)\n// OP_NOP3 == OP_CHECKSEQUENCEVERIFY (0xb2)\n// OP_NOP4 == OP_CHECKTEMPLATEVERIFY (0xb3)\n// OP_NOP5 == OP_CHECKSIGFROMSTACK (0xb4)\n// OP_NOP6 == OP_TXHASH (0xb5)\n// OP_NOP7 == OP_TXFIELD (0xb6)\n// OP_NOP8 == OP_SPLIT (0xb7)\nexport const OP_NOP1 = 0xb0;\nexport const OP_NOP9 = 0xb8;\nexport const OP_NOP10 = 0xb9;\n// ---------- Locktime ----------\nexport const OP_CHECKLOCKTIMEVERIFY = 0xb1;\nexport const OP_CHECKSEQUENCEVERIFY = 0xb2;\n// ---------- Covenants & templates (DePIN-Test) ----------\nexport const OP_CHECKTEMPLATEVERIFY = 0xb3; // BIP 119\nexport const OP_CHECKSIGFROMSTACK = 0xb4;\n// ---------- Transaction introspection (DePIN-Test) ----------\nexport const OP_TXHASH = 0xb5;\nexport const OP_TXFIELD = 0xb6;\nexport const OP_TXLOCKTIME = 0xc5;\nexport const OP_OUTPUTVALUE = 0xcc;\nexport const OP_OUTPUTSCRIPT = 0xcd;\nexport const OP_INPUTCOUNT = 0xd0;\nexport const OP_OUTPUTCOUNT = 0xd1;\n// ---------- Asset introspection (DePIN-Test) ----------\nexport const OP_OUTPUTASSETFIELD = 0xce;\nexport const OP_INPUTASSETFIELD = 0xcf;\nexport const OP_XNA_ASSET = 0xc0;\n// ---------- Reference inputs (DePIN-Test, NIP-017) ----------\nexport const OP_REFINPUTFIELD = 0xd2;\nexport const OP_REFINPUTASSETFIELD = 0xd3;\nexport const OP_REFINPUTCOUNT = 0xd4;\n// ---------- Output auth commitment introspection (NIP-023) ----------\n// Pushes the 32-byte AuthScript v1 commitment of a selected output's\n// scriptPubKey. Symmetric to TXFIELD_AUTHSCRIPT_COMMITMENT for inputs;\n// ignores any trailing OP_XNA_ASSET asset wrapper bytes.\nexport const OP_OUTPUTAUTHCOMMITMENT = 0xd5;\n// ---------- Input value introspection (NIP-024) ----------\n// Pushes the satoshi value of a selected input's spent prevout.\nexport const OP_INPUTVALUE = 0xd6;\n// ---------- Chain context introspection (NIP-026) ----------\n// Pushes chain-context fields (block height, median time, etc.) selected\n// by a single-byte selector consumed from the stack.\nexport const OP_CHAINCONTEXT = 0xd7;\n// ---------- Selectors for OP_CHAINCONTEXT ----------\n// Valid selector bytes consumed by OP_CHAINCONTEXT. HEIGHT is the candidate\n// confirmation block height; MTP is the previous block's median time past.\nexport const CHAINCONTEXT_HEIGHT = 0x01;\nexport const CHAINCONTEXT_MTP = 0x02;\nexport const CHAINCONTEXT_CHAIN_ID = 0x03;\n// ---------- Merkle inclusion (NIP-031) ----------\n// Native Merkle inclusion verifier. Consumes (leaf, scheme_id, proof,\n// root) and pushes a boolean. Flag off → bad-opcode.\nexport const OP_CHECKMERKLEINCLUSION = 0xc1;\n// NIP-041: (outputIndex -- witnessVersion || 32-byte program).\nexport const OP_OUTPUTAUTHDEST = 0xc2;\n// NIP-018: verifies an AuthScript proof and returns a boolean.\nexport const OP_ZKVERIFY = 0xc3;\n// NIP-043: spent-input field introspection, distinct from reference inputs.\nexport const OP_INPUTFIELD = 0xc4;\n// ---------- Byte manipulation (DePIN-Test) ----------\nexport const OP_CAT = 0x7e;\nexport const OP_SPLIT = 0xb7;\nexport const OP_REVERSEBYTES = 0xbc;\n// ---------- Selectors for OP_TXFIELD / OP_REFINPUTFIELD ----------\n// OP_TXFIELD, OP_INPUTFIELD and OP_REFINPUTFIELD share selectors 0x01..0x03.\n// NIP-041 adds 0x04 for a strict 33-byte AuthScript destination.\nexport const TXFIELD_VALUE = 0x01;\nexport const TXFIELD_AUTHSCRIPT_COMMITMENT = 0x02;\nexport const TXFIELD_SCRIPTPUBKEY = 0x03;\nexport const TXFIELD_AUTHDEST = 0x04;\n// ---------- Bitmask selectors for OP_TXHASH ----------\n// NIP-042 requires a two-byte little-endian selector, even for low masks.\n// Bits 0..8 select fields for the tagged NeuraiTxHash digest. Valid masks\n// are 0x001..0x1ff; zero and all higher bits are rejected by consensus.\nexport const TXHASH_VERSION = 0x01;\nexport const TXHASH_LOCKTIME = 0x02;\nexport const TXHASH_INPUT_PREVOUTS = 0x04;\nexport const TXHASH_INPUT_SEQUENCES = 0x08;\nexport const TXHASH_OUTPUTS = 0x10;\nexport const TXHASH_CURRENT_PREVOUT = 0x20;\nexport const TXHASH_CURRENT_SEQUENCE = 0x40;\nexport const TXHASH_CURRENT_INDEX = 0x80;\nexport const TXHASH_REFINPUTS = 0x100;\nexport const TXHASH_ALL = 0x1ff;\n// ---------- Selectors for OP_OUTPUTASSETFIELD / OP_INPUTASSETFIELD / OP_REFINPUTASSETFIELD ----------\n// All three opcodes share this selector table. 0x08 is gated by NIP-043\n// and extracts the optional transfer message from a strict asset wrapper.\nexport const ASSETFIELD_NAME = 0x01;\nexport const ASSETFIELD_AMOUNT = 0x02;\nexport const ASSETFIELD_UNITS = 0x03;\nexport const ASSETFIELD_REISSUABLE = 0x04;\nexport const ASSETFIELD_HAS_IPFS = 0x05;\nexport const ASSETFIELD_IPFS_HASH = 0x06;\nexport const ASSETFIELD_TYPE = 0x07;\nexport const ASSETFIELD_MESSAGE = 0x08;\n// NIP-031/043 Merkle inclusion scheme identifiers.\nexport const MERKLE_SCHEME_BITCOIN_NEURAI = 0x01;\nexport const MERKLE_SCHEME_SHA256_PLAIN = 0x02;\nexport const MERKLE_SCHEME_KECCAK256_PLAIN = 0x03;\nexport const MERKLE_SCHEME_BLAKE2B_PLAIN = 0x04;\nexport const MERKLE_SCHEME_POSEIDON_BN254 = 0x05;\n","import { toRawInteger } from '@neuraiproject/neurai-create-transaction/amounts';\n/**\n * Low-level Script assembler. Emits the exact byte layout expected by the\n * Neurai interpreter: pushdata prefixes follow the same rules as Bitcoin\n * (direct push for 1..75 bytes, OP_PUSHDATA1/2/4 otherwise), and integers\n * are minimally-encoded as CScriptNum.\n */\nimport { bytesToHex, concatBytes, hexToBytes } from './bytes.js';\nimport { OP_0, OP_1NEGATE, OP_1 } from './opcodes.js';\n/**\n * Minimal CScriptNum encoding (Bitcoin consensus rules).\n *\n * - 0 → empty vector\n * - 1..16 → single opcode OP_1..OP_16 (handled in `pushInt`, not here)\n * - -1 → OP_1NEGATE (handled in `pushInt`)\n * - otherwise: sign-magnitude little-endian, with a sign bit on the last byte\n */\nexport function encodeScriptNum(value) {\n let n = toRawInteger(value, 'ScriptNum');\n if (n === 0n)\n return new Uint8Array();\n const negative = n < 0n;\n if (negative)\n n = -n;\n const result = [];\n while (n > 0n) {\n result.push(Number(n & 0xffn));\n n >>= 8n;\n }\n // If the most-significant bit is set, add a padding byte so the sign bit\n // is unambiguous. If negative, flip that sign bit instead.\n if (result[result.length - 1] & 0x80) {\n result.push(negative ? 0x80 : 0x00);\n }\n else if (negative) {\n result[result.length - 1] |= 0x80;\n }\n return Uint8Array.from(result);\n}\n/**\n * Emit a pushdata opcode followed by the payload. Chooses the shortest\n * valid encoding.\n *\n * Neurai Script caps stack elements at `MAX_SCRIPT_ELEMENT_SIZE = 520`\n * bytes by default, but NIP-18 raises the cap to\n * `MAX_PQ_SCRIPT_ELEMENT_SIZE = 3072` whenever\n * `SCRIPT_VERIFY_CHECKSIGFROMSTACK` is active (testnet today, mainnet once\n * the CSFS fork lands). The builder here emits pushes up to 3072 bytes so\n * it can target either regime; legacy scripts should stay under 520 bytes\n * per push, and the node will reject anything larger if the CSFS flag is\n * not set during evaluation.\n */\nexport function pushBytes(data) {\n if (data.length === 0) {\n return Uint8Array.of(OP_0);\n }\n if (data.length <= 75) {\n return concatBytes(Uint8Array.of(data.length), data);\n }\n if (data.length <= 0xff) {\n return concatBytes(Uint8Array.of(0x4c, data.length), data);\n }\n if (data.length <= 3072) {\n return concatBytes(Uint8Array.of(0x4d, data.length & 0xff, (data.length >> 8) & 0xff), data);\n }\n throw new Error(`pushBytes: element of ${data.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (3072)`);\n}\n/**\n * Emit a minimally-encoded integer push. Uses OP_1NEGATE, OP_0 and OP_1..OP_16\n * when available to match how the node's own templates look on the wire.\n */\nexport function pushInt(value) {\n const n = toRawInteger(value, 'ScriptNum');\n if (n === -1n)\n return Uint8Array.of(OP_1NEGATE);\n if (n === 0n)\n return Uint8Array.of(OP_0);\n if (n >= 1n && n <= 16n) {\n return Uint8Array.of(OP_1 + Number(n) - 1);\n }\n return pushBytes(encodeScriptNum(n));\n}\nexport function pushHex(hex) {\n return pushBytes(hexToBytes(hex));\n}\n/** Fluent assembler for readable script definitions. */\nexport class ScriptBuilder {\n parts = [];\n op(...opcodes) {\n for (const op of opcodes) {\n if (!Number.isInteger(op) || op < 0 || op > 0xff) {\n throw new Error(`Invalid opcode byte: ${op}`);\n }\n this.parts.push(Uint8Array.of(op));\n }\n return this;\n }\n pushInt(value) {\n this.parts.push(pushInt(value));\n return this;\n }\n pushBytes(data) {\n this.parts.push(pushBytes(data));\n return this;\n }\n pushHex(hex) {\n this.parts.push(pushHex(hex));\n return this;\n }\n raw(bytes) {\n this.parts.push(bytes);\n return this;\n }\n build() {\n return concatBytes(...this.parts);\n }\n buildHex() {\n return bytesToHex(this.build());\n }\n}\n","/**\n * Pay-to-Public-Key-Hash (P2PKH) scriptPubKey.\n * Layout: OP_DUP OP_HASH160 0x14 <20-byte PKH> OP_EQUALVERIFY OP_CHECKSIG\n */\nimport { concatBytes } from '../core/bytes.js';\nimport { OP_CHECKSIG, OP_DUP, OP_EQUALVERIFY, OP_HASH160 } from '../core/opcodes.js';\nexport function encodeP2PKHScriptPubKey(pubKeyHash) {\n if (!(pubKeyHash instanceof Uint8Array) || pubKeyHash.length !== 20) {\n throw new Error('P2PKH pubKeyHash must be a 20-byte Uint8Array');\n }\n return concatBytes(Uint8Array.of(OP_DUP, OP_HASH160, 0x14), pubKeyHash, Uint8Array.of(OP_EQUALVERIFY, OP_CHECKSIG));\n}\n","/**\n * Native segwit v0 Pay-to-Witness-Public-Key-Hash (P2WPKH) scriptPubKey.\n * Layout: OP_0 0x14 <20-byte HASH160(pubKey)>\n *\n * Callers compute HASH160 externally (e.g. via neurai-key / their crypto\n * stack). This helper only encodes the scriptPubKey once the hash is known.\n */\nimport { concatBytes } from '../core/bytes.js';\nimport { OP_0 } from '../core/opcodes.js';\nexport function encodeP2WPKHScriptPubKey(pubKeyHash) {\n if (!(pubKeyHash instanceof Uint8Array) || pubKeyHash.length !== 20) {\n throw new Error('P2WPKH pubKeyHash must be a 20-byte Uint8Array');\n }\n return concatBytes(Uint8Array.of(OP_0, 0x14), pubKeyHash);\n}\n","/**\n * Native segwit v0 Pay-to-Witness-Script-Hash (P2WSH) scriptPubKey.\n * Layout: OP_0 0x20 <32-byte SHA256(witnessScript)>\n *\n * This helper takes the SHA256 digest of the witness script directly. The\n * SHA256 is computed externally by the caller's crypto stack (kept out of\n * this library to avoid a hash dependency).\n */\nimport { concatBytes } from '../core/bytes.js';\nimport { OP_0 } from '../core/opcodes.js';\nexport function encodeP2WSHScriptPubKey(witnessScriptSha256) {\n if (!(witnessScriptSha256 instanceof Uint8Array) || witnessScriptSha256.length !== 32) {\n throw new Error('P2WSH witnessScriptSha256 must be a 32-byte Uint8Array');\n }\n return concatBytes(Uint8Array.of(OP_0, 0x20), witnessScriptSha256);\n}\n","/**\n * AuthScript scriptPubKey + witness-stack builders.\n *\n * AuthScript outputs encode a 32-byte commitment in a witness program:\n * scriptPubKey = OP_n 0x20 <32-byte program>\n *\n * OP_1 generic AuthScript v1 (nc1p… / tnc1p…): any auth type, any witnessScript\n * OP_2 strict PQ v2 (pq1z… / tpq1z…): auth type 0x01, witnessScript OP_TRUE\n * OP_3 strict ECDSA v3 (nq1r… / tnq1r…): auth type 0x02, witnessScript OP_TRUE\n *\n * The witness version is also the first byte of the commitment preimage:\n * tagged_hash(\"NeuraiAuthScript\", version || auth_descriptor || SHA256(witnessScript))\n *\n * The program is `HASH160`/`SHA256` over a descriptor that depends on the\n * `auth_type` byte carried as the first witness-stack element at spend time.\n * This library only assembles the stack; computing the descriptor/commitment\n * and producing the signature live in neurai-key / neurai-sign-transaction.\n *\n * Auth type values (authoritative: Neurai `src/script/interpreter.cpp`,\n * cross-checked against `lib/neurai-key/src/shared/address.ts`):\n *\n * 0x00 NoAuth — no signature; spend gated only by witnessScript\n * 0x01 PQ — ML-DSA-44 signature (post-quantum)\n * 0x02 Legacy — secp256k1 ECDSA signature (classic)\n * 0x03 RefScript — NIP-015 reference-script spend (future)\n *\n * Witness stack (exact order consumed by the interpreter):\n * [ auth_type, sig, pubkey, arg0, ..., argN, witnessScript ]\n *\n * NoAuth and RefScript spends omit the `sig`/`pubkey` items.\n */\nimport { concatBytes } from '../core/bytes.js';\nimport { OP_1, OP_2, OP_3, OP_TRUE } from '../core/opcodes.js';\nexport const AUTHSCRIPT_NOAUTH = 0x00;\nexport const AUTHSCRIPT_PQ = 0x01;\nexport const AUTHSCRIPT_LEGACY = 0x02;\n/** NIP-015: reference-script spend mode. Not yet activated in consensus. */\nexport const AUTHSCRIPT_REF = 0x03;\n/** Cap for PQ signature / pubkey pushes under NIP-018 (3072 B). */\nconst MAX_PQ_PUSH = 3072;\nconst WITNESS_VERSION_OPCODE = {\n 1: OP_1,\n 2: OP_2,\n 3: OP_3\n};\n/**\n * `OP_n 0x20 <program>` for witness version `n`. Defaults to the generic\n * AuthScript v1 (`OP_1`), which is what every covenant commits to.\n */\nexport function encodeAuthScriptScriptPubKey(program, witnessVersion = 1) {\n if (!(program instanceof Uint8Array) || program.length !== 32) {\n throw new Error('AuthScript program must be a 32-byte Uint8Array');\n }\n const opcode = WITNESS_VERSION_OPCODE[witnessVersion];\n if (opcode === undefined) {\n throw new Error(`AuthScript witness version must be 1, 2 or 3, got ${String(witnessVersion)}`);\n }\n return concatBytes(Uint8Array.of(opcode, 0x20), program);\n}\nfunction assertWitnessScript(ws) {\n if (!(ws instanceof Uint8Array) || ws.length === 0) {\n throw new Error('witnessScript must be a non-empty Uint8Array');\n }\n}\nfunction assertArgs(args) {\n if (args == null)\n return;\n if (!Array.isArray(args)) {\n throw new Error('args must be an array of Uint8Array');\n }\n for (let i = 0; i < args.length; i += 1) {\n if (!(args[i] instanceof Uint8Array)) {\n throw new Error(`args[${i}] must be a Uint8Array`);\n }\n }\n}\n/**\n * Build the witness stack for a legacy ECDSA AuthScript spend.\n *\n * Returns an array of raw stack elements. Serialization of the witness\n * (compact-size item count + per-item length-prefixes) is the caller's\n * responsibility — neurai-create-transaction handles it at tx-assembly time.\n */\nexport function buildAuthScriptWitnessLegacy(input) {\n if (!(input.signature instanceof Uint8Array) || input.signature.length === 0) {\n throw new Error('signature must be a non-empty Uint8Array');\n }\n if (!(input.pubKey instanceof Uint8Array) ||\n (input.pubKey.length !== 33 && input.pubKey.length !== 65)) {\n throw new Error('pubKey must be a compressed (33B) or uncompressed (65B) secp256k1 key');\n }\n assertArgs(input.args);\n assertWitnessScript(input.witnessScript);\n return [\n Uint8Array.of(AUTHSCRIPT_LEGACY),\n input.signature,\n input.pubKey,\n ...(input.args ?? []),\n input.witnessScript\n ];\n}\n/**\n * Build the witness stack for a PQ (ML-DSA-44) AuthScript spend.\n * NIP-018 must be active: both signature and pubKey are pushed as single\n * stack elements and may each be up to 3072 B.\n */\nexport function buildAuthScriptWitnessPQ(input) {\n if (!(input.signature instanceof Uint8Array) || input.signature.length === 0) {\n throw new Error('signature must be a non-empty Uint8Array');\n }\n if (input.signature.length > MAX_PQ_PUSH) {\n throw new Error(`signature of ${input.signature.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (${MAX_PQ_PUSH})`);\n }\n if (!(input.pubKey instanceof Uint8Array) || input.pubKey.length === 0) {\n throw new Error('pubKey must be a non-empty Uint8Array');\n }\n if (input.pubKey.length > MAX_PQ_PUSH) {\n throw new Error(`pubKey of ${input.pubKey.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (${MAX_PQ_PUSH})`);\n }\n assertArgs(input.args);\n assertWitnessScript(input.witnessScript);\n return [\n Uint8Array.of(AUTHSCRIPT_PQ),\n input.signature,\n input.pubKey,\n ...(input.args ?? []),\n input.witnessScript\n ];\n}\n/** Length of the versioned ML-DSA-44 pubkey the node expects (0x05 prefix + 1312 B). */\nexport const STRICT_PQ_PUBKEY_LENGTH = 1313;\n/** Version prefix of an ML-DSA-44 pubkey on the witness stack. */\nexport const PQ_PUBKEY_PREFIX = 0x05;\n/**\n * Witness stack for spending a strict PQ witness v2 output (`pq1z…`):\n * exactly `[0x01, sig, pubKey, OP_TRUE]`. The node rejects any other\n * shape (extra arguments, another witnessScript) for the strict families.\n */\nexport function buildStrictWitnessPQ(input) {\n if (!(input.signature instanceof Uint8Array) || input.signature.length === 0) {\n throw new Error('signature must be a non-empty Uint8Array');\n }\n if (input.signature.length > MAX_PQ_PUSH) {\n throw new Error(`signature of ${input.signature.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (${MAX_PQ_PUSH})`);\n }\n if (!(input.pubKey instanceof Uint8Array) ||\n input.pubKey.length !== STRICT_PQ_PUBKEY_LENGTH ||\n input.pubKey[0] !== PQ_PUBKEY_PREFIX) {\n throw new Error(`pubKey must be the ${STRICT_PQ_PUBKEY_LENGTH}-byte versioned ML-DSA-44 key (0x05 prefix)`);\n }\n return [Uint8Array.of(AUTHSCRIPT_PQ), input.signature, input.pubKey, Uint8Array.of(OP_TRUE)];\n}\n/**\n * Witness stack for spending a strict ECDSA witness v3 output (`nq1r…`):\n * exactly `[0x02, sig, pubKey33, OP_TRUE]`. The node rejects uncompressed\n * keys for this family.\n */\nexport function buildStrictWitnessECDSA(input) {\n if (!(input.signature instanceof Uint8Array) || input.signature.length === 0) {\n throw new Error('signature must be a non-empty Uint8Array');\n }\n if (!(input.pubKey instanceof Uint8Array) ||\n input.pubKey.length !== 33 ||\n (input.pubKey[0] !== 0x02 && input.pubKey[0] !== 0x03)) {\n throw new Error('pubKey must be a compressed (33B) secp256k1 key for strict ECDSA witness v3');\n }\n return [Uint8Array.of(AUTHSCRIPT_LEGACY), input.signature, input.pubKey, Uint8Array.of(OP_TRUE)];\n}\n/**\n * Build the witness stack for a NoAuth AuthScript spend. The spend is gated\n * by the witnessScript alone (covenants, hash-locks, time-locks, ...); no\n * signature or public key is carried.\n */\nexport function buildAuthScriptWitnessNoAuth(input) {\n assertArgs(input.args);\n assertWitnessScript(input.witnessScript);\n return [\n Uint8Array.of(AUTHSCRIPT_NOAUTH),\n ...(input.args ?? []),\n input.witnessScript\n ];\n}\n/**\n * Build the witness stack for a NIP-015 reference-script spend. The last\n * item is the 4-byte little-endian index into `tx.vrefin` that locates the\n * reference-script carrier output; the interpreter resolves the `refScript`\n * from that carrier at validation time.\n *\n * NOTE: NIP-015 is not yet activated in consensus. This builder emits the\n * spec-conformant witness for forward compatibility and testnet experiments.\n */\nexport function buildAuthScriptWitnessRef(input) {\n if (!Number.isInteger(input.refIndex) || input.refIndex < 0 || input.refIndex > 0xffffffff) {\n throw new Error('refIndex must be a uint32 (0 .. 2^32 - 1)');\n }\n assertArgs(input.args);\n const refLocator = new Uint8Array(4);\n const dv = new DataView(refLocator.buffer);\n dv.setUint32(0, input.refIndex, /* little-endian */ true);\n return [\n Uint8Array.of(AUTHSCRIPT_REF),\n ...(input.args ?? []),\n refLocator\n ];\n}\n","/**\n * Provably-unspendable OP_RETURN (null-data) output scripts.\n * Layout: OP_RETURN <push> [<push> ...]\n *\n * Neurai inherits the Bitcoin Core standard policy cap of 80 bytes of\n * payload for a relayed null-data output. Outputs over that cap are still\n * consensus-valid but will not be relayed by default mempool policy; use\n * the `allowNonStandard` option to opt in explicitly.\n */\nimport { concatBytes } from '../core/bytes.js';\nimport { pushBytes } from '../core/script-builder.js';\nimport { OP_RETURN } from '../core/opcodes.js';\nexport const NULLDATA_STANDARD_MAX_SIZE = 80;\nexport function encodeNullDataScript(payload, options = {}) {\n const payloads = payload instanceof Uint8Array ? [payload] : payload;\n if (!Array.isArray(payloads) || payloads.length === 0) {\n throw new Error('payload must be a Uint8Array or a non-empty array of Uint8Array');\n }\n let totalPayload = 0;\n for (let i = 0; i < payloads.length; i += 1) {\n const p = payloads[i];\n if (!(p instanceof Uint8Array)) {\n throw new Error(`payload[${i}] must be a Uint8Array`);\n }\n totalPayload += p.length;\n }\n if (!options.allowNonStandard && totalPayload > NULLDATA_STANDARD_MAX_SIZE) {\n throw new Error(`nulldata payload of ${totalPayload} bytes exceeds standard cap ${NULLDATA_STANDARD_MAX_SIZE}; set allowNonStandard=true to override`);\n }\n const parts = [Uint8Array.of(OP_RETURN)];\n for (const p of payloads)\n parts.push(pushBytes(p));\n return concatBytes(...parts);\n}\n","/**\n * Classic bare m-of-n multisig via OP_CHECKMULTISIG, plus the P2SH wrapper\n * that is normally used in practice.\n *\n * redeemScript = <m> <pubkey_1> ... <pubkey_n> <n> OP_CHECKMULTISIG\n * P2SH spk = OP_HASH160 0x14 <HASH160(redeemScript)> OP_EQUAL\n *\n * OP_CHECKMULTISIG caps n at 20 pubkeys (see `MAX_PUBKEYS_PER_MULTISIG` in\n * the Neurai interpreter). Bare multisig outputs are still consensus-valid\n * but non-standard for relay; the P2SH wrapping is what mempool accepts.\n */\nimport { bytesToHex, concatBytes } from '../core/bytes.js';\nimport { pushBytes, pushInt } from '../core/script-builder.js';\nimport { OP_CHECKMULTISIG, OP_EQUAL, OP_HASH160 } from '../core/opcodes.js';\nexport const MULTISIG_MAX_PUBKEYS = 20;\nfunction assertPubKey(pk, idx) {\n if (!(pk instanceof Uint8Array) || (pk.length !== 33 && pk.length !== 65)) {\n throw new Error(`pubKey[${idx}] must be 33 or 65 bytes (got ${pk?.length})`);\n }\n}\nexport function encodeMultisigRedeemScript({ m, pubKeys }) {\n if (!Array.isArray(pubKeys) || pubKeys.length === 0) {\n throw new Error('pubKeys must be a non-empty array');\n }\n if (pubKeys.length > MULTISIG_MAX_PUBKEYS) {\n throw new Error(`pubKeys length ${pubKeys.length} exceeds OP_CHECKMULTISIG cap (${MULTISIG_MAX_PUBKEYS})`);\n }\n if (!Number.isInteger(m) || m < 1 || m > pubKeys.length) {\n throw new Error(`m must be an integer in [1, ${pubKeys.length}] (got ${m})`);\n }\n for (let i = 0; i < pubKeys.length; i += 1)\n assertPubKey(pubKeys[i], i);\n const parts = [pushInt(m)];\n for (const pk of pubKeys)\n parts.push(pushBytes(pk));\n parts.push(pushInt(pubKeys.length));\n parts.push(Uint8Array.of(OP_CHECKMULTISIG));\n return concatBytes(...parts);\n}\nexport function encodeMultisigRedeemScriptHex(params) {\n return bytesToHex(encodeMultisigRedeemScript(params));\n}\n/**\n * P2SH scriptPubKey wrapping any redeem script. Pass the 20-byte HASH160 of\n * the redeem script (RIPEMD160(SHA256(redeemScript))) — compute it\n * externally via the caller's crypto stack.\n */\nexport function encodeP2SHScriptPubKey(redeemScriptHash160) {\n if (!(redeemScriptHash160 instanceof Uint8Array) || redeemScriptHash160.length !== 20) {\n throw new Error('redeemScriptHash160 must be a 20-byte Uint8Array');\n }\n return concatBytes(Uint8Array.of(OP_HASH160, 0x14), redeemScriptHash160, Uint8Array.of(OP_EQUAL));\n}\n","/** Exact monetary primitives. This module has no runtime dependencies. */\nconst SATS_PER_XNA = 100000000n;\nconst MAX_MONEY = 2100000000000000000n;\n/** Normalize a raw integer without preserving an already rounded number. */\nfunction toRawInteger(value, label = 'amount') {\n if (typeof value === 'bigint')\n return value;\n if (typeof value === 'number' && Number.isSafeInteger(value))\n return BigInt(value);\n if (typeof value === 'string' && /^-?\\d+$/.test(value) && value.length <= 100)\n return BigInt(value);\n throw new Error(`${label}: expected an exact integer; use bigint or an integer string for large values`);\n}\nfunction assertMoneyRange(value, label = 'amount') {\n const raw = toRawInteger(value, label);\n if (raw < 0n || raw > MAX_MONEY)\n throw new Error(`${label} outside Neurai monetary range`);\n return raw;\n}\n/** Parse decimal units exactly, including scientific notation, with at most 8 decimals. */\nfunction decimalToSatoshis(value) {\n if (typeof value !== 'string' && typeof value !== 'number')\n throw new Error('Expected decimal string or number');\n if (typeof value === 'number' && !Number.isFinite(value))\n throw new Error('Amount must be finite');\n const text = String(value);\n if (text.length > 100)\n throw new Error('Amount too long');\n const match = /^(-?)(\\d+)(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/.exec(text);\n if (!match)\n throw new Error('Invalid decimal amount');\n const exponent = Number(match[4] ?? 0);\n if (!Number.isSafeInteger(exponent) || Math.abs(exponent) > 100)\n throw new Error('Invalid decimal exponent');\n const fraction = match[3] ?? '';\n const shift = 8 + exponent - fraction.length;\n let raw = BigInt(match[2] + fraction);\n if (shift >= 0)\n raw *= 10n ** BigInt(shift);\n else {\n const divisor = 10n ** BigInt(-shift);\n if (raw % divisor !== 0n)\n throw new Error('Amount has more than 8 decimals');\n raw /= divisor;\n }\n if (typeof value === 'number' && raw > BigInt(Number.MAX_SAFE_INTEGER) && !Number.isSafeInteger(value)) {\n throw new Error('Large fractional amounts must be supplied as decimal strings');\n }\n return match[1] ? -raw : raw;\n}\n/** Format signed raw units without converting to floating point. */\nfunction satoshisToDecimal(value) {\n const raw = toRawInteger(value);\n const abs = raw < 0n ? -raw : raw;\n const fraction = (abs % SATS_PER_XNA).toString().padStart(8, '0').replace(/0+$/, '');\n return `${raw < 0n ? '-' : ''}${abs / SATS_PER_XNA}${fraction ? '.' + fraction : ''}`;\n}\n\nfunction ensureHex(hex, label = 'hex') {\n const normalized = String(hex || '').trim().toLowerCase();\n if (!/^[0-9a-f]*$/.test(normalized) || normalized.length % 2 !== 0) {\n throw new Error(`Invalid ${label}: expected even-length hex string`);\n }\n return normalized;\n}\nfunction hexToBytes(hex) {\n const normalized = ensureHex(hex);\n const bytes = new Uint8Array(normalized.length / 2);\n for (let i = 0; i < normalized.length; i += 2) {\n bytes[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16);\n }\n return bytes;\n}\nfunction bytesToHex(bytes) {\n return Array.from(bytes, (value) => value.toString(16).padStart(2, '0')).join('');\n}\nfunction concatBytes(...parts) {\n const total = parts.reduce((sum, part) => sum + part.length, 0);\n const out = new Uint8Array(total);\n let offset = 0;\n for (const part of parts) {\n out.set(part, offset);\n offset += part.length;\n }\n return out;\n}\nfunction asciiBytes(text) {\n return Uint8Array.from(Array.from(text, (char) => char.charCodeAt(0)));\n}\nfunction serializeString(text) {\n const bytes = asciiBytes(text);\n return concatBytes(compactSize(bytes.length), bytes);\n}\nfunction reverseBytes(bytes) {\n return Uint8Array.from(Array.from(bytes).reverse());\n}\nfunction u32LE(value) {\n if (!Number.isInteger(value) || value < 0 || value > 0xffffffff) {\n throw new Error(`uint32 out of range: ${value}`);\n }\n const out = new Uint8Array(4);\n const view = new DataView(out.buffer);\n view.setUint32(0, value, true);\n return out;\n}\nfunction u64LE(value) {\n const bigintValue = toRawInteger(value);\n if (bigintValue < 0n || bigintValue > 0xffffffffffffffffn) {\n throw new Error(`uint64 out of range: ${bigintValue}`);\n }\n const out = new Uint8Array(8);\n let remaining = bigintValue;\n for (let i = 0; i < 8; i += 1) {\n out[i] = Number(remaining & 0xffn);\n remaining >>= 8n;\n }\n return out;\n}\nfunction i64LE(value) {\n const bigintValue = toRawInteger(value);\n if (bigintValue < -0x8000000000000000n || bigintValue > 0x7fffffffffffffffn) {\n throw new Error(`int64 out of range: ${bigintValue}`);\n }\n const out = new Uint8Array(8);\n const view = new DataView(out.buffer);\n view.setBigInt64(0, bigintValue, true);\n return out;\n}\nfunction compactSize(value) {\n const bigintValue = toRawInteger(value);\n if (bigintValue < 0n)\n throw new Error('CompactSize cannot encode negative numbers');\n if (bigintValue < 253n) {\n return Uint8Array.of(Number(bigintValue));\n }\n if (bigintValue <= 0xffffn) {\n return concatBytes(Uint8Array.of(0xfd), u16LE(Number(bigintValue)));\n }\n if (bigintValue <= 0xffffffffn) {\n return concatBytes(Uint8Array.of(0xfe), u32LE(Number(bigintValue)));\n }\n return concatBytes(Uint8Array.of(0xff), u64LE(bigintValue));\n}\nfunction u16LE(value) {\n if (!Number.isInteger(value) || value < 0 || value > 0xffff) {\n throw new Error(`uint16 out of range: ${value}`);\n }\n const out = new Uint8Array(2);\n const view = new DataView(out.buffer);\n view.setUint16(0, value, true);\n return out;\n}\nfunction pushData(data) {\n if (data.length > 0xffff) {\n throw new Error(`Pushdata too large for current implementation: ${data.length} bytes`);\n }\n if (data.length < 0x4c) {\n return concatBytes(Uint8Array.of(data.length), data);\n }\n if (data.length <= 0xff) {\n return concatBytes(Uint8Array.of(0x4c, data.length), data);\n }\n return concatBytes(Uint8Array.of(0x4d), u16LE(data.length), data);\n}\n\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\nfunction base (ALPHABET) {\n if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }\n const BASE_MAP = new Uint8Array(256);\n for (let j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255;\n }\n for (let i = 0; i < ALPHABET.length; i++) {\n const x = ALPHABET.charAt(i);\n const xc = x.charCodeAt(0);\n if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }\n BASE_MAP[xc] = i;\n }\n const BASE = ALPHABET.length;\n const LEADER = ALPHABET.charAt(0);\n const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up\n const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up\n function encode (source) {\n // eslint-disable-next-line no-empty\n if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n } else if (Array.isArray(source)) {\n source = Uint8Array.from(source);\n }\n if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }\n if (source.length === 0) { return '' }\n // Skip & count leading zeroes.\n let zeroes = 0;\n let length = 0;\n let pbegin = 0;\n const pend = source.length;\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++;\n zeroes++;\n }\n // Allocate enough space in big-endian base58 representation.\n const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;\n const b58 = new Uint8Array(size);\n // Process the bytes.\n while (pbegin !== pend) {\n let carry = source[pbegin];\n // Apply \"b58 = b58 * 256 + ch\".\n let i = 0;\n for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0;\n b58[it1] = (carry % BASE) >>> 0;\n carry = (carry / BASE) >>> 0;\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i;\n pbegin++;\n }\n // Skip leading zeroes in base58 result.\n let it2 = size - length;\n while (it2 !== size && b58[it2] === 0) {\n it2++;\n }\n // Translate the result into a string.\n let str = LEADER.repeat(zeroes);\n for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }\n return str\n }\n function decodeUnsafe (source) {\n if (typeof source !== 'string') { throw new TypeError('Expected String') }\n if (source.length === 0) { return new Uint8Array() }\n let psz = 0;\n // Skip and count leading '1's.\n let zeroes = 0;\n let length = 0;\n while (source[psz] === LEADER) {\n zeroes++;\n psz++;\n }\n // Allocate enough space in big-endian base256 representation.\n const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.\n const b256 = new Uint8Array(size);\n // Process the characters.\n while (psz < source.length) {\n // Find code of next character\n const charCode = source.charCodeAt(psz);\n // Base map can not be indexed using char code\n if (charCode > 255) { return }\n // Decode character\n let carry = BASE_MAP[charCode];\n // Invalid character\n if (carry === 255) { return }\n let i = 0;\n for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0;\n b256[it3] = (carry % 256) >>> 0;\n carry = (carry / 256) >>> 0;\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i;\n psz++;\n }\n // Skip leading zeroes in b256.\n let it4 = size - length;\n while (it4 !== size && b256[it4] === 0) {\n it4++;\n }\n const vch = new Uint8Array(zeroes + (size - it4));\n let j = zeroes;\n while (it4 !== size) {\n vch[j++] = b256[it4++];\n }\n return vch\n }\n function decode (string) {\n const buffer = decodeUnsafe(string);\n if (buffer) { return buffer }\n throw new Error('Non-base' + BASE + ' character')\n }\n return {\n encode,\n decodeUnsafe,\n decode\n }\n}\n\nvar ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\nvar base58 = base(ALPHABET);\n\nconst IPFS_LENGTH = 0x20;\nconst TXID_PREFIX = 0x54;\nfunction encodeAssetDataReference(value) {\n const normalized = String(value || '').trim();\n if (!normalized) {\n return new Uint8Array();\n }\n if (normalized.startsWith('Qm') && normalized.length === 46) {\n const decoded = Uint8Array.from(base58.decode(normalized));\n if (decoded.length !== 34) {\n throw new Error(`Invalid CIDv0 length for asset data: ${decoded.length}`);\n }\n return decoded;\n }\n if (normalized.length === 64 && /^[0-9a-fA-F]+$/.test(normalized)) {\n const txidBytes = hexToBytes(normalized);\n return Uint8Array.of(TXID_PREFIX, IPFS_LENGTH, ...txidBytes);\n }\n if (normalized.length === 68 && /^[0-9a-fA-F]+$/.test(normalized)) {\n const raw = hexToBytes(normalized);\n if (raw[1] !== IPFS_LENGTH) {\n throw new Error('Invalid raw asset data reference length prefix');\n }\n return raw;\n }\n throw new Error('Unsupported asset data reference. Expected CIDv0 (Qm...), 64-char txid, or 68-char raw hex');\n}\nfunction decodeAssetDataReferenceHex(value) {\n return bytesToHex(encodeAssetDataReference(value));\n}\nfunction isEncodedAssetDataReferenceHex(hex) {\n const normalized = ensureHex(hex);\n return normalized.length === 68 || normalized.length === 0;\n}\nfunction isCidV0AssetReference(value) {\n const normalized = String(value || '').trim();\n return normalized.startsWith('Qm') && normalized.length === 46;\n}\nfunction isTxidAssetReference(value) {\n const normalized = String(value || '').trim();\n return normalized.length === 64 && /^[0-9a-fA-F]+$/.test(normalized);\n}\nfunction isRawAssetDataReferenceHex(value) {\n const normalized = String(value || '').trim();\n return normalized.length === 68 && /^[0-9a-fA-F]+$/.test(normalized);\n}\nfunction formatAssetDataReferenceHex(value) {\n return bytesToHex(encodeAssetDataReference(value));\n}\n\nvar dist = {};\n\nvar hasRequiredDist;\n\nfunction requireDist () {\n\tif (hasRequiredDist) return dist;\n\thasRequiredDist = 1;\n\tObject.defineProperty(dist, \"__esModule\", { value: true });\n\tdist.bech32m = dist.bech32 = void 0;\n\tconst ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';\n\tconst ALPHABET_MAP = {};\n\tfor (let z = 0; z < ALPHABET.length; z++) {\n\t const x = ALPHABET.charAt(z);\n\t ALPHABET_MAP[x] = z;\n\t}\n\tfunction polymodStep(pre) {\n\t const b = pre >> 25;\n\t return (((pre & 0x1ffffff) << 5) ^\n\t (-((b >> 0) & 1) & 0x3b6a57b2) ^\n\t (-((b >> 1) & 1) & 0x26508e6d) ^\n\t (-((b >> 2) & 1) & 0x1ea119fa) ^\n\t (-((b >> 3) & 1) & 0x3d4233dd) ^\n\t (-((b >> 4) & 1) & 0x2a1462b3));\n\t}\n\tfunction prefixChk(prefix) {\n\t let chk = 1;\n\t for (let i = 0; i < prefix.length; ++i) {\n\t const c = prefix.charCodeAt(i);\n\t if (c < 33 || c > 126)\n\t return 'Invalid prefix (' + prefix + ')';\n\t chk = polymodStep(chk) ^ (c >> 5);\n\t }\n\t chk = polymodStep(chk);\n\t for (let i = 0; i < prefix.length; ++i) {\n\t const v = prefix.charCodeAt(i);\n\t chk = polymodStep(chk) ^ (v & 0x1f);\n\t }\n\t return chk;\n\t}\n\tfunction convert(data, inBits, outBits, pad) {\n\t let value = 0;\n\t let bits = 0;\n\t const maxV = (1 << outBits) - 1;\n\t const result = [];\n\t for (let i = 0; i < data.length; ++i) {\n\t value = (value << inBits) | data[i];\n\t bits += inBits;\n\t while (bits >= outBits) {\n\t bits -= outBits;\n\t result.push((value >> bits) & maxV);\n\t }\n\t }\n\t if (pad) {\n\t if (bits > 0) {\n\t result.push((value << (outBits - bits)) & maxV);\n\t }\n\t }\n\t else {\n\t if (bits >= inBits)\n\t return 'Excess padding';\n\t if ((value << (outBits - bits)) & maxV)\n\t return 'Non-zero padding';\n\t }\n\t return result;\n\t}\n\tfunction toWords(bytes) {\n\t return convert(bytes, 8, 5, true);\n\t}\n\tfunction fromWordsUnsafe(words) {\n\t const res = convert(words, 5, 8, false);\n\t if (Array.isArray(res))\n\t return res;\n\t}\n\tfunction fromWords(words) {\n\t const res = convert(words, 5, 8, false);\n\t if (Array.isArray(res))\n\t return res;\n\t throw new Error(res);\n\t}\n\tfunction getLibraryFromEncoding(encoding) {\n\t let ENCODING_CONST;\n\t if (encoding === 'bech32') {\n\t ENCODING_CONST = 1;\n\t }\n\t else {\n\t ENCODING_CONST = 0x2bc830a3;\n\t }\n\t function encode(prefix, words, LIMIT) {\n\t LIMIT = LIMIT || 90;\n\t if (prefix.length + 7 + words.length > LIMIT)\n\t throw new TypeError('Exceeds length limit');\n\t prefix = prefix.toLowerCase();\n\t // determine chk mod\n\t let chk = prefixChk(prefix);\n\t if (typeof chk === 'string')\n\t throw new Error(chk);\n\t let result = prefix + '1';\n\t for (let i = 0; i < words.length; ++i) {\n\t const x = words[i];\n\t if (x >> 5 !== 0)\n\t throw new Error('Non 5-bit word');\n\t chk = polymodStep(chk) ^ x;\n\t result += ALPHABET.charAt(x);\n\t }\n\t for (let i = 0; i < 6; ++i) {\n\t chk = polymodStep(chk);\n\t }\n\t chk ^= ENCODING_CONST;\n\t for (let i = 0; i < 6; ++i) {\n\t const v = (chk >> ((5 - i) * 5)) & 0x1f;\n\t result += ALPHABET.charAt(v);\n\t }\n\t return result;\n\t }\n\t function __decode(str, LIMIT) {\n\t LIMIT = LIMIT || 90;\n\t if (str.length < 8)\n\t return str + ' too short';\n\t if (str.length > LIMIT)\n\t return 'Exceeds length limit';\n\t // don't allow mixed case\n\t const lowered = str.toLowerCase();\n\t const uppered = str.toUpperCase();\n\t if (str !== lowered && str !== uppered)\n\t return 'Mixed-case string ' + str;\n\t str = lowered;\n\t const split = str.lastIndexOf('1');\n\t if (split === -1)\n\t return 'No separator character for ' + str;\n\t if (split === 0)\n\t return 'Missing prefix for ' + str;\n\t const prefix = str.slice(0, split);\n\t const wordChars = str.slice(split + 1);\n\t if (wordChars.length < 6)\n\t return 'Data too short';\n\t let chk = prefixChk(prefix);\n\t if (typeof chk === 'string')\n\t return chk;\n\t const words = [];\n\t for (let i = 0; i < wordChars.length; ++i) {\n\t const c = wordChars.charAt(i);\n\t const v = ALPHABET_MAP[c];\n\t if (v === undefined)\n\t return 'Unknown character ' + c;\n\t chk = polymodStep(chk) ^ v;\n\t // not in the checksum?\n\t if (i + 6 >= wordChars.length)\n\t continue;\n\t words.push(v);\n\t }\n\t if (chk !== ENCODING_CONST)\n\t return 'Invalid checksum for ' + str;\n\t return { prefix, words };\n\t }\n\t function decodeUnsafe(str, LIMIT) {\n\t const res = __decode(str, LIMIT);\n\t if (typeof res === 'object')\n\t return res;\n\t }\n\t function decode(str, LIMIT) {\n\t const res = __decode(str, LIMIT);\n\t if (typeof res === 'object')\n\t return res;\n\t throw new Error(res);\n\t }\n\t return {\n\t decodeUnsafe,\n\t decode,\n\t encode,\n\t toWords,\n\t fromWordsUnsafe,\n\t fromWords,\n\t };\n\t}\n\tdist.bech32 = getLibraryFromEncoding('bech32');\n\tdist.bech32m = getLibraryFromEncoding('bech32m');\n\treturn dist;\n}\n\nvar distExports = requireDist();\n\n/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\n/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */\nfunction isBytes$1(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n/** Asserts something is Uint8Array. */\nfunction abytes$1(b, ...lengths) {\n if (!isBytes$1(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n/** Asserts a hash instance has not been destroyed / finished */\nfunction aexists$1(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\n/** Asserts output is properly-sized byte array */\nfunction aoutput$1(out, instance) {\n abytes$1(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n/** Zeroize a byte array. Warning: JS provides no guarantees. */\nfunction clean$1(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n/** Create DataView of an array for easy byte-level manipulation. */\nfunction createView$1(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** The rotate right (circular right shift) operation for uint32 */\nfunction rotr$1(word, shift) {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/**\n * Converts string to bytes using UTF8 encoding.\n * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])\n */\nfunction utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nfunction toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes$1(data);\n return data;\n}\n/** For runtime check if class implements interface */\nclass Hash {\n}\n/** Wraps hash function, creating an interface on top of it */\nfunction createHasher$1(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\n/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\n/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */\nfunction setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n/** Choice: a ? b : c */\nfunction Chi$1(a, b, c) {\n return (a & b) ^ (~a & c);\n}\n/** Majority function, true if any two inputs is true. */\nfunction Maj$1(a, b, c) {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nlet HashMD$1 = class HashMD extends Hash {\n constructor(blockLen, outputLen, padOffset, isLE) {\n super();\n this.finished = false;\n this.length = 0;\n this.pos = 0;\n this.destroyed = false;\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView$1(this.buffer);\n }\n update(data) {\n aexists$1(this);\n data = toBytes(data);\n abytes$1(data);\n const { view, buffer, blockLen } = this;\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView$1(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n aexists$1(this);\n aoutput$1(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n clean$1(this.buffer.subarray(pos));\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView$1(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to || (to = new this.constructor());\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.destroyed = destroyed;\n to.finished = finished;\n to.length = length;\n to.pos = pos;\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n clone() {\n return this._cloneInto();\n }\n};\n/**\n * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.\n * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.\n */\n/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */\nconst SHA256_IV$1 = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n\n/**\n * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.\n * SHA256 is the fastest hash implementable in JS, even faster than Blake3.\n * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and\n * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).\n * @module\n */\n/**\n * Round constants:\n * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)\n */\n// prettier-ignore\nconst SHA256_K$1 = /* @__PURE__ */ Uint32Array.from([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n/** Reusable temporary buffer. \"W\" comes straight from spec. */\nconst SHA256_W$1 = /* @__PURE__ */ new Uint32Array(64);\nclass SHA256 extends HashMD$1 {\n constructor(outputLen = 32) {\n super(64, outputLen, 8, false);\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n this.A = SHA256_IV$1[0] | 0;\n this.B = SHA256_IV$1[1] | 0;\n this.C = SHA256_IV$1[2] | 0;\n this.D = SHA256_IV$1[3] | 0;\n this.E = SHA256_IV$1[4] | 0;\n this.F = SHA256_IV$1[5] | 0;\n this.G = SHA256_IV$1[6] | 0;\n this.H = SHA256_IV$1[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W$1[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W$1[i - 15];\n const W2 = SHA256_W$1[i - 2];\n const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ (W2 >>> 10);\n SHA256_W$1[i] = (s1 + SHA256_W$1[i - 7] + s0 + SHA256_W$1[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);\n const T1 = (H + sigma1 + Chi$1(E, F, G) + SHA256_K$1[i] + SHA256_W$1[i]) | 0;\n const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);\n const T2 = (sigma0 + Maj$1(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n clean$1(SHA256_W$1);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n clean$1(this.buffer);\n }\n}\n/**\n * SHA2-256 hash function from RFC 4634.\n *\n * It is the fastest JS hash, even faster than Blake3.\n * To break sha256 using birthday attack, attackers need to try 2^128 hashes.\n * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n */\nconst sha256$2 = /* @__PURE__ */ createHasher$1(() => new SHA256());\n\n/**\n * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.\n *\n * To break sha256 using birthday attack, attackers need to try 2^128 hashes.\n * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n *\n * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).\n * @module\n * @deprecated\n */\n/** @deprecated Use import from `noble/hashes/sha2` module */\nconst sha256$1 = sha256$2;\n\nfunction bs58checkBase (checksumFn) {\n // Encode a buffer as a base58-check encoded string\n function encode(payload) {\n var payloadU8 = Uint8Array.from(payload);\n var checksum = checksumFn(payloadU8);\n var length = payloadU8.length + 4;\n var both = new Uint8Array(length);\n both.set(payloadU8, 0);\n both.set(checksum.subarray(0, 4), payloadU8.length);\n return base58.encode(both);\n }\n function decodeRaw(buffer) {\n var payload = buffer.slice(0, -4);\n var checksum = buffer.slice(-4);\n var newChecksum = checksumFn(payload);\n // eslint-disable-next-line\n if (checksum[0] ^ newChecksum[0] |\n checksum[1] ^ newChecksum[1] |\n checksum[2] ^ newChecksum[2] |\n checksum[3] ^ newChecksum[3])\n return;\n return payload;\n }\n // Decode a base58-check encoded string to a buffer, no result if checksum is wrong\n function decodeUnsafe(str) {\n var buffer = base58.decodeUnsafe(str);\n if (buffer == null)\n return;\n return decodeRaw(buffer);\n }\n function decode(str) {\n var buffer = base58.decode(str);\n var payload = decodeRaw(buffer);\n if (payload == null)\n throw new Error('Invalid checksum');\n return payload;\n }\n return {\n encode: encode,\n decode: decode,\n decodeUnsafe: decodeUnsafe\n };\n}\n\n// SHA256(SHA256(buffer))\nfunction sha256x2(buffer) {\n return sha256$1(sha256$1(buffer));\n}\nvar bs58check = bs58checkBase(sha256x2);\n\nfunction resolveAddressInput(address) {\n if (typeof address === 'string') {\n return String(address).trim();\n }\n if (address && typeof address.address === 'string') {\n return String(address.address).trim();\n }\n throw new Error('Address must be a string or an object with an address field');\n}\n\nconst LEGACY_MAINNET_PREFIX = 53;\nconst LEGACY_TESTNET_PREFIX = 127;\nconst OP_XNA_ASSET = 0xc0;\nconst OP_DROP = 0x75;\nconst OP_1 = 0x51;\nconst OP_RESERVED = 0x50;\nconst WITNESS_FAMILIES = [\n {\n type: 'authscript',\n witnessVersion: 1,\n hrp: { mainnet: 'nc', testnet: 'tnc' },\n network: { mainnet: 'xna-authscript', testnet: 'xna-authscript-test' }\n },\n {\n type: 'pq',\n witnessVersion: 2,\n hrp: { mainnet: 'pq', testnet: 'tpq' },\n network: { mainnet: 'xna-pq', testnet: 'xna-pq-test' }\n },\n {\n type: 'ecdsa',\n witnessVersion: 3,\n hrp: { mainnet: 'nq', testnet: 'tnq' },\n network: { mainnet: 'xna', testnet: 'xna-test' }\n }\n];\nconst AUTHSCRIPT_MAINNET_HRP = 'nc';\nconst AUTHSCRIPT_TESTNET_HRP = 'tnc';\nconst PQ_MAINNET_HRP = 'pq';\nconst PQ_TESTNET_HRP = 'tpq';\nconst ECDSA_MAINNET_HRP = 'nq';\nconst ECDSA_TESTNET_HRP = 'tnq';\n/** The family that owns `hrp` (lowercase), with the chain it encodes. */\nfunction witnessFamilyByHrp(hrp) {\n for (const family of WITNESS_FAMILIES) {\n if (family.hrp.mainnet === hrp)\n return { family, chain: 'mainnet' };\n if (family.hrp.testnet === hrp)\n return { family, chain: 'testnet' };\n }\n return undefined;\n}\n/** The family encoded by `witnessVersion`, or undefined for any other version. */\nfunction witnessFamilyByVersion(witnessVersion) {\n return WITNESS_FAMILIES.find((family) => family.witnessVersion === witnessVersion);\n}\n/** `OP_1`, `OP_2` or `OP_3`: the scriptPubKey opcode of a witness version. */\nfunction witnessVersionOpcode(witnessVersion) {\n if (!witnessFamilyByVersion(witnessVersion)) {\n throw new Error(`Unsupported AuthScript witness version: ${String(witnessVersion)} (expected 1, 2 or 3)`);\n }\n return OP_1 - 1 + witnessVersion;\n}\n/**\n * NIP-040 asset payload marker.\n *\n * Every transfer / new / owner / reissue payload opens with a 3-byte marker\n * followed by the type byte. The marker is consensus: blocks below the NIP-040\n * activation height of a network only accept `rvn` on new asset outputs and\n * blocks at or above it only accept `xna` (mainnet: not scheduled; reset testnet:\n * 10; regtest: 1). This library does NOT know chain state and never\n * infers the marker from a network or an address: the caller passes the\n * value reported by the node for the next block\n * (`getblockchaininfo.asset_marker`, node commit 347362b) — or, when building\n * offline, the marker it knows to be right. Without it the default is `rvn`,\n * byte-for-byte identical to 0.6.0.\n */\nconst DEFAULT_ASSET_MARKER = 'rvn';\nconst ASSET_MARKER_BYTES = {\n rvn: [0x72, 0x76, 0x6e],\n xna: [0x78, 0x6e, 0x61]\n};\nconst ASSET_PAYLOAD_TYPE_BYTE = {\n transfer: 0x74, // 't'\n new: 0x71, // 'q'\n owner: 0x6f, // 'o'\n reissue: 0x72 // 'r'\n};\n/**\n * Applies the default only when the marker was not given at all (`undefined`)\n * and rejects anything else that is not `'rvn'` or `'xna'` — including\n * `null`, which is what a missing or null `asset_marker` in a JSON reply\n * becomes: it must fail loudly, not silently build a legacy output.\n */\nfunction resolveAssetMarker(value) {\n if (value === undefined)\n return DEFAULT_ASSET_MARKER;\n if (value === 'rvn' || value === 'xna')\n return value;\n throw new Error(`Invalid assetMarker: ${String(value)} (expected 'rvn' or 'xna', the value of getblockchaininfo.asset_marker)`);\n}\n/**\n * The only place marker bytes are assembled (mirror of the node's\n * `AppendAssetMarkerPrefix`): `<marker 3B> <type 1B>`.\n */\nfunction assetPayloadPrefix(marker, type) {\n const typeByte = ASSET_PAYLOAD_TYPE_BYTE[type];\n if (typeByte === undefined) {\n throw new Error(`Unknown asset payload type: ${String(type)}`);\n }\n const [a, b, c] = ASSET_MARKER_BYTES[resolveAssetMarker(marker)];\n return Uint8Array.of(a, b, c, typeByte);\n}\n\n// Longest Bech32m string the node's decoder accepts (bech32.cpp).\nconst BECH32M_MAX_LENGTH = 90;\nconst AUTHSCRIPT_PROGRAM_LENGTH = 32;\nfunction tryBech32mDecode(address) {\n try {\n const { prefix, words } = distExports.bech32m.decode(address, BECH32M_MAX_LENGTH);\n return { hrp: prefix.toLowerCase(), words };\n }\n catch {\n return null;\n }\n}\nfunction decodeWitnessAddress(address, parts) {\n const owner = witnessFamilyByHrp(parts.hrp);\n if (!owner) {\n throw new Error(`Unsupported Bech32m prefix \"${parts.hrp}\" for ${address}`);\n }\n if (parts.words.length === 0) {\n throw new Error(`Empty witness program in ${address}`);\n }\n const version = parts.words[0];\n const { family, chain } = owner;\n if (version !== family.witnessVersion) {\n const actual = witnessFamilyByVersion(version);\n const hint = actual\n ? `; witness v${version} addresses use the \"${actual.hrp[chain]}\" prefix`\n : '';\n const legacyHint = family.type === 'ecdsa' && version === 1\n ? ' Generic AuthScript v1 addresses are now encoded as nc1p… / tnc1p… ' +\n '(same scriptPubKey): regenerate the address (neurai-key xna-authscript networks).'\n : '';\n throw new Error(`Address ${address}: the \"${parts.hrp}\" prefix only encodes witness v${family.witnessVersion}, ` +\n `not v${version}${hint}.${legacyHint}`);\n }\n let program;\n try {\n program = Uint8Array.from(distExports.bech32m.fromWords(parts.words.slice(1)));\n }\n catch {\n throw new Error(`Invalid witness program padding in ${address}`);\n }\n if (program.length !== AUTHSCRIPT_PROGRAM_LENGTH) {\n throw new Error(`Unsupported AuthScript program length ${program.length} for ${address} (expected ${AUTHSCRIPT_PROGRAM_LENGTH})`);\n }\n return {\n address,\n type: family.type,\n witnessVersion: family.witnessVersion,\n network: family.network[chain],\n program,\n commitment: program\n };\n}\nfunction decodeLegacyAddress(address) {\n const payload = Uint8Array.from(bs58check.decode(address));\n if (payload.length !== 21) {\n throw new Error(`Unsupported legacy address payload length for ${address}`);\n }\n const prefix = payload[0];\n if (prefix !== LEGACY_MAINNET_PREFIX && prefix !== LEGACY_TESTNET_PREFIX) {\n throw new Error(`Unsupported legacy address prefix ${prefix} for ${address}`);\n }\n return {\n address,\n type: 'p2pkh',\n network: prefix === LEGACY_MAINNET_PREFIX ? 'xna-legacy' : 'xna-legacy-test',\n program: payload.slice(1),\n hash: payload.slice(1)\n };\n}\n/**\n * Decode a Neurai address the way the node does (base58.cpp\n * `DecodeDestination`): Bech32m first, Base58Check otherwise.\n *\n * - Base58 P2PKH → `type: 'p2pkh'`, network `xna-legacy` / `xna-legacy-test`\n * (an `xna-old-legacy` address is indistinguishable and reports\n * `xna-legacy`).\n * - Bech32m → `authscript` (v1, `nc`/`tnc`), `pq` (v2, `pq`/`tpq`) or\n * `ecdsa` (v3, `nq`/`tnq`), with `witnessVersion` and the 32-byte\n * commitment. Any other HRP/version pair is rejected, including the old\n * `nq1p…` / `tnq1p…` encoding of generic AuthScript v1.\n *\n * The decoder does not know whether a witness family is active on the\n * target chain: before activation the node refuses v2/v3 addresses and a\n * witness output is anyone-can-spend.\n */\nfunction decodeAddress(address) {\n const normalized = resolveAddressInput(address);\n if (!normalized)\n throw new Error('Address is required');\n const bech32mParts = tryBech32mDecode(normalized);\n if (bech32mParts) {\n return decodeWitnessAddress(normalized, bech32mParts);\n }\n try {\n return decodeLegacyAddress(normalized);\n }\n catch (legacyError) {\n // Not Base58 either. When the string carries a known Bech32m prefix the\n // Bech32m failure (bad checksum, mixed case…) is the useful diagnosis.\n const separator = normalized.lastIndexOf('1');\n const hrp = separator > 0 ? normalized.slice(0, separator).toLowerCase() : '';\n if (witnessFamilyByHrp(hrp)) {\n throw new Error(`Invalid Bech32m address ${normalized} (checksum, case or character error)`);\n }\n throw legacyError;\n }\n}\n/** Chain-family label of an address: see `decodeAddress`. */\nfunction inferNetworkFromAddress(address) {\n return decodeAddress(address).network;\n}\n/** True for the Bech32m (AuthScript v1, PQ v2, ECDSA v3) destinations. */\nfunction isWitnessDestination(destination) {\n return destination.type !== 'p2pkh';\n}\n/** `OP_n 0x20 <32-byte commitment>` for witness version `n` (1, 2 or 3). */\nfunction encodeWitnessProgramScript(witnessVersion, commitment) {\n const bytes = typeof commitment === 'string' ? hexToBytes(commitment) : commitment;\n if (bytes.length !== AUTHSCRIPT_PROGRAM_LENGTH) {\n throw new Error(`AuthScript commitment must be ${AUTHSCRIPT_PROGRAM_LENGTH} bytes, got ${bytes.length}`);\n }\n return concatBytes(Uint8Array.of(witnessVersionOpcode(witnessVersion)), pushData(bytes));\n}\nfunction encodeP2PKHScript(address) {\n const destination = decodeAddress(address);\n if (destination.type !== 'p2pkh') {\n throw new Error(`Address ${resolveAddressInput(address)} is not legacy P2PKH`);\n }\n return Uint8Array.of(0x76, 0xa9, 0x14, ...destination.hash, 0x88, 0xac);\n}\n/**\n * scriptPubKey of an AuthScript destination of any witness version:\n * `OP_1` (generic v1), `OP_2` (PQ) or `OP_3` (ECDSA) followed by the\n * 32-byte commitment.\n */\nfunction encodeAuthScriptDestinationScript(address) {\n const destination = decodeAddress(address);\n if (!isWitnessDestination(destination)) {\n throw new Error(`Address ${resolveAddressInput(address)} is not an AuthScript (witness v1, v2 or v3) address`);\n }\n return encodeWitnessProgramScript(destination.witnessVersion, destination.commitment);\n}\nfunction encodeDestinationScript(address) {\n const destination = decodeAddress(address);\n return isWitnessDestination(destination)\n ? encodeWitnessProgramScript(destination.witnessVersion, destination.commitment)\n : encodeP2PKHScript(address);\n}\nfunction encodeNullAssetDestinationScript(address, mode = 'strict') {\n const destination = decodeAddress(address);\n if (isWitnessDestination(destination)) {\n if (mode === 'hash20') {\n throw new Error('hash20 null-asset mode is not supported for AuthScript destinations');\n }\n return concatBytes(Uint8Array.of(OP_XNA_ASSET, witnessVersionOpcode(destination.witnessVersion)), pushData(destination.commitment));\n }\n return concatBytes(Uint8Array.of(OP_XNA_ASSET), pushData(destination.hash));\n}\n/**\n * @deprecated The name predates the PQ witness v2 family: it encodes every\n * AuthScript witness version. Use `encodeAuthScriptDestinationScript`.\n */\nconst encodePQWitnessScript = encodeAuthScriptDestinationScript;\n/**\n * Classify a scriptPubKey by its destination prefix, ignoring any trailing\n * asset wrapper: `76a914<20>88ac…` is P2PKH, `5120<32>…`, `5220<32>…` and\n * `5320<32>…` are AuthScript v1 (generic), v2 (PQ) and v3 (ECDSA).\n */\nfunction classifyScriptPubKey(script) {\n const bytes = typeof script === 'string' ? hexToBytes(script) : script;\n if (bytes.length >= 25 &&\n bytes[0] === 0x76 &&\n bytes[1] === 0xa9 &&\n bytes[2] === 0x14 &&\n bytes[23] === 0x88 &&\n bytes[24] === 0xac) {\n return { type: 'p2pkh', program: bytes.slice(3, 23), hasSuffix: bytes.length > 25 };\n }\n if (bytes.length >= 34 && bytes[1] === 0x20) {\n const family = witnessFamilyByVersion(bytes[0] - (OP_1 - 1));\n if (family) {\n return {\n type: family.type,\n witnessVersion: family.witnessVersion,\n program: bytes.slice(2, 34),\n hasSuffix: bytes.length > 34\n };\n }\n }\n return { type: 'unknown', hasSuffix: false };\n}\n\nconst OWNER_ASSET_AMOUNT = 100000000n;\nconst UNIQUE_ASSET_AMOUNT = 100000000n;\nconst UNIQUE_ASSET_UNITS = 0;\nconst UNIQUE_ASSETS_REISSUABLE = false;\nconst MAINNET_BURN_ADDRESSES = {\n ISSUE_ROOT: 'NbURNXXXXXXXXXXXXXXXXXXXXXXXT65Gdr',\n ISSUE_SUB: 'NXissueSubAssetXXXXXXXXXXXXXX6B2JF',\n ISSUE_UNIQUE: 'NXissueUniqueAssetXXXXXXXXXXUBzP4Z',\n ISSUE_DEPIN: 'NXissueUniqueAssetXXXXXXXXXXUBzP4Z',\n ISSUE_MSGCHANNEL: 'NXissueMsgChanneLAssetXXXXXXTUzrtJ',\n REISSUE: 'NXReissueAssetXXXXXXXXXXXXXXWLe4Ao',\n REISSUE_RESTRICTED: 'NXReissueAssetXXXXXXXXXXXXXXWLe4Ao',\n ISSUE_RESTRICTED: 'NXissueRestrictedXXXXXXXXXXXWpXx4H',\n ISSUE_QUALIFIER: 'NXissueQuaLifierXXXXXXXXXXXXWurNcU',\n ISSUE_SUB_QUALIFIER: 'NXissueSubQuaLifierXXXXXXXXXV71vM3',\n TAG_ADDRESS: 'NXaddTagBurnXXXXXXXXXXXXXXXXWucUTr',\n UNTAG_ADDRESS: 'NXaddTagBurnXXXXXXXXXXXXXXXXWucUTr'\n};\nconst TESTNET_BURN_ADDRESSES = {\n ISSUE_ROOT: 'tBURNXXXXXXXXXXXXXXXXXXXXXXXVZLroy',\n ISSUE_SUB: 'tSubAssetXXXXXXXXXXXXXXXXXXXXGTvF4',\n ISSUE_UNIQUE: 'tUniqueAssetXXXXXXXXXXXXXXXXVCgpLs',\n ISSUE_DEPIN: 'tUniqueAssetXXXXXXXXXXXXXXXXVCgpLs',\n ISSUE_MSGCHANNEL: 'tMsgChanneLAssetXXXXXXXXXXXXVsJoya',\n REISSUE: 'tAssetXXXXXXXXXXXXXXXXXXXXXXas6pz8',\n REISSUE_RESTRICTED: 'tAssetXXXXXXXXXXXXXXXXXXXXXXas6pz8',\n ISSUE_RESTRICTED: 'tRestrictedXXXXXXXXXXXXXXXXXVyPBEK',\n ISSUE_QUALIFIER: 'tQuaLifierXXXXXXXXXXXXXXXXXXT5czoV',\n ISSUE_SUB_QUALIFIER: 'tSubQuaLifierXXXXXXXXXXXXXXXW5MmGk',\n TAG_ADDRESS: 'tTagBurnXXXXXXXXXXXXXXXXXXXXYm6pxA',\n UNTAG_ADDRESS: 'tTagBurnXXXXXXXXXXXXXXXXXXXXYm6pxA'\n};\nconst BURN_COSTS_XNA = {\n ISSUE_ROOT: 1000,\n ISSUE_SUB: 200,\n ISSUE_UNIQUE: 10,\n ISSUE_DEPIN: 10,\n ISSUE_MSGCHANNEL: 200,\n ISSUE_QUALIFIER: 2000,\n ISSUE_SUB_QUALIFIER: 200,\n ISSUE_RESTRICTED: 3000,\n REISSUE: 200,\n REISSUE_RESTRICTED: 200,\n TAG_ADDRESS: 0.2,\n UNTAG_ADDRESS: 0.2\n};\n// Regtest chainparams use one global burn address for every operation\n// (node chainparams.cpp strGlobalBurnAddress). Pass it as the\n// `burnAddress` override of the issuance/reissue builders when targeting\n// regtest; `getBurnAddressForOperation` only models mainnet/testnet.\nconst REGTEST_GLOBAL_BURN_ADDRESS = 'tBURNXXXXXXXXXXXXXXXXXXXXXXXVZLroy';\n/**\n * Every value `SupportedNetwork` admits, and the chain family each belongs to.\n *\n * Written as an exhaustive map rather than a couple of comparisons so that a\n * network added to the union upstream fails to compile here instead of\n * silently defaulting to testnet.\n */\nconst NETWORK_FAMILY = {\n 'xna': 'mainnet',\n 'xna-legacy': 'mainnet',\n 'xna-old-legacy': 'mainnet',\n 'xna-pq': 'mainnet',\n 'xna-authscript': 'mainnet',\n 'xna-test': 'testnet',\n 'xna-legacy-test': 'testnet',\n 'xna-pq-test': 'testnet',\n 'xna-authscript-test': 'testnet'\n};\n/**\n * Resolve a network to its chain family, rejecting anything unrecognised.\n *\n * This used to return `'testnet'` for every value that was not explicitly\n * mainnet. TypeScript keeps its own callers honest, but a JavaScript consumer\n * passing the alias `'mainnet'` — which other libraries in the stack accept —\n * landed in the testnet branch and **slipped past the DEPIN mainnet guard**,\n * while the canonical `'xna'` triggered it. An unrecognised label is a caller\n * error, not an implicit testnet.\n *\n * Callers that speak in aliases must normalize first: `'mainnet'` to `'xna'`,\n * `'testnet'` to `'xna-test'`.\n *\n * Regtest is not a member of `SupportedNetwork` — it shares testnet's address\n * prefixes — and now throws here. That reaches `getBurnAddressForOperation`,\n * which used to answer with the TESTNET burn addresses: wrong for regtest,\n * whose chainparams use a single global burn address for every operation, so\n * only ISSUE_ROOT happened to coincide. Pass `REGTEST_GLOBAL_BURN_ADDRESS` as\n * the `burnAddress` override instead; the previous answer had to be replaced\n * anyway.\n *\n * @param network - Network label\n * @returns The chain family\n * @throws If the label is not a supported network\n */\nfunction resolveNetworkFamily(network) {\n const family = NETWORK_FAMILY[network];\n if (family === undefined) {\n throw new Error(`Unsupported network: ${JSON.stringify(network)}. Expected one of ` +\n `${Object.keys(NETWORK_FAMILY).join(', ')}. Aliases such as 'mainnet' ` +\n `or 'testnet' must be normalized by the caller ('xna', 'xna-test'); ` +\n `for regtest, pass REGTEST_GLOBAL_BURN_ADDRESS as the burnAddress override.`);\n }\n return family;\n}\nfunction getBurnAddressForOperation(network, operation) {\n const byFamily = resolveNetworkFamily(network) === 'mainnet'\n ? MAINNET_BURN_ADDRESSES\n : TESTNET_BURN_ADDRESSES;\n return byFamily[operation];\n}\nfunction getBurnAmountXna(operation, multiplier = 1) {\n return BURN_COSTS_XNA[operation] * multiplier;\n}\nfunction getBurnAmountSats(operation, multiplier = 1) {\n return assertMoneyRange(decimalToSatoshis(BURN_COSTS_XNA[operation]) * assertMoneyRange(toRawInteger(multiplier, 'burn multiplier')));\n}\n/**\n * Network label of an address, from its encoding (see `decodeAddress`):\n * `xna-legacy[-test]` for Base58, `xna-authscript[-test]` for `nc1`/`tnc1`,\n * `xna-pq[-test]` for `pq1`/`tpq1` and `xna[-test]` for `nq1`/`tnq1`.\n */\nfunction inferNetworkFromAnyAddress(address) {\n return inferNetworkFromAddress(address);\n}\nfunction getOwnerTokenName(assetName) {\n if (assetName.startsWith('$')) {\n return `${assetName.slice(1)}!`;\n }\n return `${assetName}!`;\n}\nfunction getParentAssetName(assetName) {\n // The parent is the immediate one, not the root: \"A/B/C\" is owned by \"A/B!\"\n // (node GetParentName resolves with find_last_of for SUB and DEPIN alike).\n const slashIndex = assetName.lastIndexOf('/');\n if (slashIndex === -1) {\n return null;\n }\n return assetName.slice(0, slashIndex);\n}\nfunction getUniqueAssetName(rootName, tag) {\n return `${rootName}#${tag}`;\n}\nfunction normalizeVerifierString(verifierString) {\n return String(verifierString || '')\n .replace(/\\s+/g, '')\n .replace(/#/g, '');\n}\n// The node accepts DEPIN names up to 121 chars where DePIN is enabled, but a\n// 121-char base name yields a 122-char owner token (\"&X!\") that fails the\n// global name-length check, making the asset untransferable. Capped at 120\n// here so every name this library issues keeps a nameable owner token.\nconst DEPIN_MAX_NAME_LENGTH = 120;\nfunction isDepinAssetName(assetName) {\n const normalized = String(assetName || '').trim();\n if (normalized.length > DEPIN_MAX_NAME_LENGTH) {\n return false;\n }\n if (!normalized.includes('/')) {\n return /^&[A-Z0-9._]{3,}$/.test(normalized);\n }\n if (!/^&[A-Z0-9._]+\\/[A-Z0-9._/]+$/.test(normalized)) {\n return false;\n }\n // The node parser lets the first part count its leading '&' toward the\n // 3-char minimum (\"&AB/CDE\" parses), but such an asset can never be issued:\n // its parent \"&AB\" is not a valid root, so the parent owner token \"&AB!\"\n // required at issuance cannot exist. Require 3 real chars in every segment.\n const [root, ...rest] = normalized.split('/');\n return root.length >= 4 && rest.every((part) => part.length >= 3);\n}\nfunction assertDepinAssetName(assetName) {\n if (!isDepinAssetName(assetName)) {\n throw new Error(`Invalid DEPIN asset name: ${assetName}`);\n }\n}\nfunction assertDepinNetwork(network) {\n if (network !== undefined && resolveNetworkFamily(network) === 'mainnet') {\n throw new Error(`DEPIN assets are only available on testnet/regtest networks: ${network}`);\n }\n}\n\nfunction xnaToSatoshis(amount) {\n return assertMoneyRange(decimalToSatoshis(amount));\n}\nfunction assetUnitsToRaw(amount) {\n return xnaToSatoshis(amount);\n}\nfunction encodeAssetTransferPayload(assetName, amountRaw, message, expireTime, options) {\n const payload = [\n assetPayloadPrefix(options?.assetMarker, 'transfer'),\n serializeString(assetName),\n u64LE(assertMoneyRange(amountRaw))\n ];\n const encodedMessage = encodeAssetDataReference(message);\n if (encodedMessage.length > 0) {\n payload.push(encodedMessage);\n if (expireTime !== undefined && toRawInteger(expireTime) !== 0n) {\n payload.push(i64LE(expireTime));\n }\n }\n return concatBytes(...payload);\n}\nfunction encodeAssetTransferScript(address, assetName, amountRaw, message, expireTime, options) {\n return concatBytes(encodeDestinationScript(address), Uint8Array.of(OP_XNA_ASSET), pushData(encodeAssetTransferPayload(assetName, amountRaw, message, expireTime, options)), Uint8Array.of(OP_DROP));\n}\n/**\n * True when `script` is exactly the 25-byte P2PKH form\n * `OP_DUP OP_HASH160 0x14 <20B> OP_EQUALVERIFY OP_CHECKSIG`. Consensus only\n * recognises the asset wrapper when OP_XNA_ASSET sits at byte 25 after this\n * exact prefix (node `HasAssetOpcodeInExpectedPosition`).\n */\nfunction isP2pkhScript(script) {\n return (script.length === 25 &&\n script[0] === 0x76 &&\n script[1] === 0xa9 &&\n script[2] === 0x14 &&\n script[23] === 0x88 &&\n script[24] === 0xac);\n}\n/**\n * True when `script` is exactly the 34-byte AuthScript form\n * `OP_n 0x20 <32-byte commitment>`, with `OP_1` (generic v1), `OP_2` (PQ)\n * or `OP_3` (ECDSA). Consensus only recognises the asset wrapper when\n * OP_XNA_ASSET sits at byte 34 after this exact prefix; `OP_2` / `OP_3`\n * only where the strict AuthScript families are active.\n */\nfunction isAuthScriptScript(script) {\n return (script.length === 34 &&\n (script[0] === 0x51 || script[0] === 0x52 || script[0] === 0x53) &&\n script[1] === 0x20);\n}\n/**\n * Like `encodeAssetTransferScript` but takes a raw scriptPubKey instead of\n * deriving one from an address, for callers that already hold the\n * scriptPubKey bytes.\n *\n * The recipient script must be exactly P2PKH (25 bytes) or AuthScript\n * `OP_n <32B>` (34 bytes, n = 1, 2 or 3): the node's OP_XNA_ASSET placement rules only\n * accept the asset wrapper right after one of those two prefixes, on every\n * network, so appending it to any other script (a bare covenant, P2SH, …)\n * produces a consensus-invalid output. To pay assets into an arbitrary\n * script, commit it into an AuthScript destination instead (derive the\n * address with neurai-key's `getNoAuthAddress`) and use the regular\n * address-based transfer helpers.\n *\n * The asset-transfer wrapper is appended exactly as in the address-based\n * variant: `<recipientScriptPubKey> OP_XNA_ASSET <pushdata(payload)> OP_DROP`.\n *\n * Note: this helper only builds the output. Spending an AuthScript output\n * takes a witness stack; `createUnsignedTransaction` serializes the legacy\n * pre-segwit format only, so serialize such spends with the transaction\n * codec's `serializeTransaction` (tx-codec.ts, 0.5.1+) instead.\n */\nfunction encodeAssetTransferScriptToScript(recipientScriptPubKey, assetName, amountRaw, message, expireTime, options) {\n const spkBytes = typeof recipientScriptPubKey === 'string'\n ? hexToBytes(ensureHex(recipientScriptPubKey, 'recipientScriptPubKey'))\n : recipientScriptPubKey;\n if (!isP2pkhScript(spkBytes) && !isAuthScriptScript(spkBytes)) {\n throw new Error('asset transfers to arbitrary scripts are rejected by consensus ' +\n '(OP_XNA_ASSET placement rules): the recipient scriptPubKey must be ' +\n 'exactly P2PKH (25 bytes) or AuthScript OP_1/OP_2/OP_3 <32B> (34 bytes); ' +\n 'commit the script into an AuthScript destination instead');\n }\n return concatBytes(spkBytes, Uint8Array.of(OP_XNA_ASSET), pushData(encodeAssetTransferPayload(assetName, amountRaw, message, expireTime, options)), Uint8Array.of(OP_DROP));\n}\nfunction encodeNewAssetPayload(assetName, quantityRaw, units = 0, reissuable = true, ipfsHash, options) {\n const encodedIpfs = encodeAssetDataReference(ipfsHash);\n return concatBytes(assetPayloadPrefix(options?.assetMarker, 'new'), serializeString(assetName), u64LE(assertMoneyRange(quantityRaw)), Uint8Array.of(units & 0xff, reissuable ? 1 : 0, encodedIpfs.length > 0 ? 1 : 0), encodedIpfs);\n}\nfunction encodeNewAssetScript(address, assetName, quantityRaw, units = 0, reissuable = true, ipfsHash, options) {\n return concatBytes(encodeDestinationScript(address), Uint8Array.of(OP_XNA_ASSET), pushData(encodeNewAssetPayload(assetName, quantityRaw, units, reissuable, ipfsHash, options)), Uint8Array.of(OP_DROP));\n}\nfunction encodeOwnerAssetPayload(ownerTokenName, options) {\n return concatBytes(assetPayloadPrefix(options?.assetMarker, 'owner'), serializeString(ownerTokenName));\n}\nfunction encodeOwnerAssetScript(address, ownerTokenName, options) {\n return concatBytes(encodeDestinationScript(address), Uint8Array.of(OP_XNA_ASSET), pushData(encodeOwnerAssetPayload(ownerTokenName, options)), Uint8Array.of(OP_DROP));\n}\n/** \"Keep the asset's current units\", encoded as the signed byte -1 (0xff). */\nconst REISSUE_UNITS_UNCHANGED = -1;\n/**\n * Resolve the `units` byte of a reissue payload.\n *\n * Omitting `units` means \"do not change them\", which the protocol spells `-1`\n * (`0xff`) — the value the node's own `reissue` RPC defaults to. Its\n * validation is `nNewUnits == -1 || nNewUnits >= currentUnits`, so the\n * previous default of `0` said \"set units to 0\" and was rejected outright for\n * any asset with `units > 0` (`unit must be larger than current unit\n * selection`).\n *\n * An explicit `0` still encodes `0x00`: it is legitimate for an asset that\n * already has `units=0`, and folding it into -1 would lose the distinction in\n * the other direction.\n *\n * The range is validated rather than masked. `units & 0xff` used to turn `-2`\n * into `0xfe` and `255` into `0xff` — manufacturing a valid-looking\n * \"unchanged\" byte out of an invalid input.\n *\n * @param units - Requested units, or undefined to keep the current ones\n * @returns The byte to encode\n * @throws If units is not an integer in -1..8\n */\nfunction reissueUnitsByte(units) {\n const resolved = units ?? REISSUE_UNITS_UNCHANGED;\n if (!Number.isInteger(resolved) || resolved < -1 || resolved > 8) {\n throw new Error(`Invalid reissue units: ${units}. Use an integer 0..8 to set the units, ` +\n `or -1 (or omit it) to keep the asset's current units.`);\n }\n return resolved & 0xff;\n}\nfunction encodeReissueAssetPayload(assetName, quantityRaw, units, reissuable = true, ipfsHash, options) {\n return concatBytes(assetPayloadPrefix(options?.assetMarker, 'reissue'), serializeString(assetName), u64LE(assertMoneyRange(quantityRaw)), Uint8Array.of(reissueUnitsByte(units), reissuable ? 1 : 0), encodeAssetDataReference(ipfsHash));\n}\nfunction encodeReissueAssetScript(address, assetName, quantityRaw, units, reissuable = true, ipfsHash, options) {\n return concatBytes(encodeDestinationScript(address), Uint8Array.of(OP_XNA_ASSET), pushData(encodeReissueAssetPayload(assetName, quantityRaw, units, reissuable, ipfsHash, options)), Uint8Array.of(OP_DROP));\n}\nfunction encodeNullAssetDataPayload(assetName, flag) {\n const nameBytes = asciiBytes(assetName);\n return concatBytes(compactSize(nameBytes.length), nameBytes, Uint8Array.of(flag & 0xff));\n}\nfunction encodeNullAssetTagPayload(qualifierName, operation) {\n return encodeNullAssetDataPayload(qualifierName, operation === 'tag' ? 1 : 0);\n}\nfunction encodeNullAssetTagScript(address, qualifierName, operation, mode = 'strict') {\n return concatBytes(encodeNullAssetDestinationScript(address, mode), pushData(encodeNullAssetTagPayload(qualifierName, operation)));\n}\nfunction encodeNullAssetRestrictionScript(address, assetName, freezeFlag, mode = 'strict') {\n return concatBytes(encodeNullAssetDestinationScript(address, mode), pushData(encodeNullAssetDataPayload(assetName, freezeFlag)));\n}\nfunction encodeVerifierStringPayload(verifierString) {\n return serializeString(verifierString);\n}\nfunction encodeVerifierStringScript(verifierString) {\n return concatBytes(Uint8Array.of(OP_XNA_ASSET, OP_RESERVED), pushData(encodeVerifierStringPayload(verifierString)));\n}\nfunction encodeGlobalRestrictionScript(assetName, freezeFlag) {\n return concatBytes(Uint8Array.of(OP_XNA_ASSET, OP_RESERVED, OP_RESERVED), pushData(encodeNullAssetDataPayload(assetName, freezeFlag)));\n}\nfunction createXnaOutput(address, valueSats) {\n return {\n valueSats: assertMoneyRange(valueSats),\n scriptPubKeyHex: bytesToHex(encodeDestinationScript(address))\n };\n}\nfunction createAssetTransferOutput(address, assetName, amountRaw, options) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeAssetTransferScript(address, assetName, amountRaw, undefined, undefined, options))\n };\n}\nfunction createTransferWithMessageOutput(params) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeAssetTransferScript(params.address, params.assetName, params.amountRaw, params.message, params.expireTime, { assetMarker: params.assetMarker }))\n };\n}\nfunction createOwnerAssetIssueOutput(address, ownerTokenName, options) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeOwnerAssetScript(address, ownerTokenName, options))\n };\n}\nfunction createOwnerAssetTransferOutput(address, ownerTokenName, options) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeAssetTransferScript(address, ownerTokenName, OWNER_ASSET_AMOUNT, undefined, undefined, options))\n };\n}\nfunction createIssueAssetOutput(params) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeNewAssetScript(params.address, params.assetName, params.quantityRaw, params.units ?? 0, params.reissuable ?? true, params.ipfsHash, { assetMarker: params.assetMarker }))\n };\n}\nfunction createReissueAssetOutput(params) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeReissueAssetScript(params.address, params.assetName, params.quantityRaw, \n // Omitted means \"keep the current units\" (-1); do NOT collapse to 0.\n params.units, params.reissuable ?? true, params.ipfsHash, { assetMarker: params.assetMarker }))\n };\n}\nfunction createNullAssetTagOutput(address, qualifierName, operation, mode = 'strict') {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeNullAssetTagScript(address, qualifierName, operation, mode))\n };\n}\nfunction createNullAssetRestrictionOutput(address, assetName, freezeFlag, mode = 'strict') {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeNullAssetRestrictionScript(address, assetName, freezeFlag, mode))\n };\n}\nfunction createVerifierStringOutput(verifierString) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeVerifierStringScript(verifierString))\n };\n}\nfunction createGlobalRestrictionOutput(assetName, freezeFlag) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeGlobalRestrictionScript(assetName, freezeFlag))\n };\n}\nfunction createTransferOutput(params) {\n return createAssetTransferOutput(params.address, params.assetName, params.amountRaw, {\n assetMarker: params.assetMarker\n });\n}\n/**\n * Build a SerializedTxOutput that locks `amountRaw` of `assetName` under a\n * raw P2PKH or AuthScript scriptPubKey (the only shapes consensus accepts —\n * see `encodeAssetTransferScriptToScript`; covenants go through neurai-key's\n * `getNoAuthAddress` and the address-based helpers). `valueSats` is\n * hardcoded to 0n (asset-only outputs carry no XNA; matches\n * `createAssetTransferOutput` semantics).\n */\nfunction createAssetTransferToScriptOutput(params) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeAssetTransferScriptToScript(params.scriptPubKeyHex, params.assetName, params.amountRaw, params.message, params.expireTime, { assetMarker: params.assetMarker }))\n };\n}\n\nfunction serializeInput(input) {\n const txidBytes = reverseBytes(hexToBytes(input.txid));\n const scriptSig = input.scriptSigHex ? hexToBytes(input.scriptSigHex) : new Uint8Array();\n return concatBytes(txidBytes, u32LE(input.vout), compactSize(scriptSig.length), scriptSig, u32LE(input.sequence ?? 0xffffffff));\n}\nfunction serializeOutput(output) {\n const scriptPubKey = hexToBytes(ensureHex(output.scriptPubKeyHex, 'scriptPubKeyHex'));\n return concatBytes(u64LE(output.valueSats), compactSize(scriptPubKey.length), scriptPubKey);\n}\nfunction createUnsignedTransaction(tx) {\n let total = 0n;\n for (const output of tx.outputs)\n total += assertMoneyRange(output.valueSats, 'output');\n assertMoneyRange(total, 'total outputs');\n const version = tx.version ?? 2;\n const locktime = tx.locktime ?? 0;\n const inputs = tx.inputs.map(serializeInput);\n const outputs = tx.outputs.map(serializeOutput);\n const bytes = concatBytes(u32LE(version), compactSize(inputs.length), ...inputs, compactSize(outputs.length), ...outputs, u32LE(locktime));\n return Array.from(bytes, (value) => value.toString(16).padStart(2, '0')).join('');\n}\n\nfunction buildTransaction(version, locktime, inputs, outputs) {\n return {\n rawTx: createUnsignedTransaction({\n version: version ?? 2,\n locktime: locktime ?? 0,\n inputs,\n outputs\n }),\n outputs\n };\n}\nfunction appendXnaEnvelope(outputs, burnAddress, burnAmountSats, changeAddress, changeSats) {\n if (burnAddress && burnAmountSats !== undefined && toRawInteger(burnAmountSats) > 0n) {\n outputs.push(createXnaOutput(burnAddress, burnAmountSats));\n }\n if (changeAddress && changeSats !== undefined && toRawInteger(changeSats) > 0n) {\n outputs.push(createXnaOutput(changeAddress, changeSats));\n }\n}\nfunction appendExtraOutputs(outputs, extraOutputs) {\n if (extraOutputs?.length) {\n outputs.push(...extraOutputs);\n }\n}\n/**\n * Null-asset data flag: 1 freezes, 0 unfreezes.\n *\n * Consensus accepts nothing else. The node's `VerifyNullAssetDataFlag`\n * (`src/assets/assets.cpp`) rejects any other value with\n * `bad-txns-null-data-flag-must-be-0-or-1`, and it takes neither the network\n * nor the height, so the mapping is identical on mainnet, testnet and regtest.\n *\n * These same two values serve the per-address restriction, the qualifier\n * tag/untag AND the global restriction: `VerifyRestrictedAddressChange`,\n * `VerifyQualifierChange` and `VerifyGlobalRestrictedChange` all delegate to\n * that one check. Captured from the node's own transactions:\n *\n * freezerestrictedasset $PROBE → c0505008062450524f424501 (flag 01)\n * unfreezerestrictedasset $PROBE → c0505008062450524f424500 (flag 00)\n *\n * Until 0.7.1 the global restriction added 2 to this value, emitting 3 and 2,\n * which the node rejected outright.\n */\nfunction freezeFlagFromOperation(operation) {\n return operation === 'freeze' ? 1 : 0;\n}\n// NIP-040: the transaction-level marker reaches every asset output a builder\n// creates; an output-level marker wins. `extraOutputs` are never touched.\nfunction marker(params) {\n return { assetMarker: params.assetMarker };\n}\nfunction withMarker(output, params) {\n return output.assetMarker === undefined && params.assetMarker !== undefined\n ? { ...output, assetMarker: params.assetMarker }\n : output;\n}\n// Compare by decoded destination script, not by address text: two encodings of\n// the same destination (e.g. different Bech32 case) must count as equal.\nfunction sameDestination(a, b) {\n return bytesToHex(encodeDestinationScript(a)) === bytesToHex(encodeDestinationScript(b));\n}\nfunction createPaymentTransaction(params) {\n const outputs = [\n ...params.payments.map((payment) => createXnaOutput(payment.address, payment.valueSats)),\n ...(params.extraOutputs ?? [])\n ];\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createStandardAssetTransferTransaction(params) {\n // Output order is fixed:\n // payments → transfers → transferMessages → transfersToScript → extraOutputs.\n // Keep transfersToScript after transferMessages so indices of existing\n // callers (payments + transfers + transferMessages) remain stable.\n const outputs = [];\n for (const payment of params.payments ?? []) {\n outputs.push(createXnaOutput(payment.address, payment.valueSats));\n }\n for (const transfer of params.transfers ?? []) {\n outputs.push(createTransferOutput(withMarker(transfer, params)));\n }\n for (const transfer of params.transferMessages ?? []) {\n outputs.push(createTransferWithMessageOutput(withMarker(transfer, params)));\n }\n for (const transfer of params.transfersToScript ?? []) {\n outputs.push(createAssetTransferToScriptOutput(withMarker(transfer, params)));\n }\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueAssetTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n // Consensus locates issuance outputs positionally (issue at vout[n-1], owner\n // at vout[n-2]), so extraOutputs must come before them, not after.\n appendExtraOutputs(outputs, params.extraOutputs);\n if (params.includeOwnerOutput ?? true) {\n outputs.push(createOwnerAssetIssueOutput(params.ownerTokenAddress ?? params.toAddress, params.ownerTokenName ?? getOwnerTokenName(params.assetName), marker(params)));\n }\n outputs.push(createIssueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n units: params.units ?? 0,\n reissuable: params.reissuable ?? true,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueSubAssetTransaction(params) {\n const parentAssetName = getParentAssetName(params.assetName);\n if (!parentAssetName) {\n throw new Error(`Sub-asset name must contain '/': ${params.assetName}`);\n }\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n outputs.push(createOwnerAssetTransferOutput(params.parentOwnerAddress ?? params.xnaChangeAddress ?? params.toAddress, getOwnerTokenName(parentAssetName), marker(params)));\n outputs.push(createOwnerAssetIssueOutput(params.ownerTokenAddress ?? params.toAddress, getOwnerTokenName(params.assetName), marker(params)));\n outputs.push(createIssueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n units: params.units ?? 0,\n reissuable: params.reissuable ?? true,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueDepinTransaction(params) {\n assertDepinAssetName(params.assetName);\n assertDepinNetwork(params.network);\n if (toRawInteger(params.quantityRaw) <= 0n) {\n throw new Error('DEPIN issue quantity must be positive');\n }\n if (params.reissuable !== undefined && typeof params.reissuable !== 'boolean') {\n throw new Error('DEPIN reissuable must be boolean when provided');\n }\n // A sub-DEPIN (\"&X/Y\") must transfer the immediate parent's owner token in\n // the issuing transaction, exactly like sub-assets. It stays AssetType DEPIN\n // (same burn as the root), so only the output layout follows the sub flow.\n if (getParentAssetName(params.assetName)) {\n return createIssueSubAssetTransaction({\n ...params,\n units: 0,\n reissuable: params.reissuable ?? true,\n parentOwnerAddress: params.parentOwnerAddress,\n ownerTokenAddress: params.ownerTokenAddress ?? params.toAddress\n });\n }\n return createIssueAssetTransaction({\n ...params,\n units: 0,\n includeOwnerOutput: true,\n ownerTokenAddress: params.ownerTokenAddress ?? params.toAddress,\n reissuable: params.reissuable ?? true\n });\n}\nfunction createDepinTransferTransaction(params) {\n assertDepinNetwork(params.network);\n if (!params.transfers?.length) {\n throw new Error('DEPIN transfer requires at least one transfer');\n }\n const assetName = params.transfers[0].assetName;\n assertDepinAssetName(assetName);\n for (const transfer of params.transfers) {\n if (transfer.assetName !== assetName) {\n throw new Error(`DEPIN transfers must all move the same asset (got ${transfer.assetName} and ${assetName}); build one transaction per DEPIN asset`);\n }\n if (toRawInteger(transfer.amountRaw) <= 0n) {\n throw new Error(`DEPIN transfer amount must be positive: ${assetName}`);\n }\n }\n const outputs = [];\n for (const transfer of params.transfers) {\n outputs.push(createTransferOutput(withMarker(transfer, params)));\n }\n // Soulbound escort: consensus also requires SPENDING an \"&X!\" UTXO, which\n // must be present in params.inputs (this package does not select UTXOs).\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress, getOwnerTokenName(assetName), marker(params)));\n appendXnaEnvelope(outputs, undefined, undefined, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createDepinSelfRevokeTransaction(params) {\n assertDepinAssetName(params.assetName);\n assertDepinNetwork(params.network);\n if (toRawInteger(params.amountRaw) <= 0n) {\n throw new Error('DEPIN self-revoke amount must be positive');\n }\n // Exact consensus pattern: one self-transfer of \"&X\" back to the holder plus\n // one null-data with flag 1 (the only valid flag without the owner token).\n // No owner token, no burn. The input-side rules live on the caller — see\n // DepinSelfRevokeTransactionParams.\n const outputs = [\n createAssetTransferOutput(params.holderAddress, params.assetName, params.amountRaw, marker(params)),\n createNullAssetRestrictionOutput(params.holderAddress, params.assetName, 1, params.nullAssetDestinationMode ?? 'strict')\n ];\n appendXnaEnvelope(outputs, undefined, undefined, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueUniqueAssetTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n outputs.push(createOwnerAssetTransferOutput(params.ownerTokenAddress ?? params.toAddress, getOwnerTokenName(params.rootName), marker(params)));\n for (let index = 0; index < params.assetTags.length; index += 1) {\n outputs.push(createIssueAssetOutput({\n address: params.toAddress,\n assetName: getUniqueAssetName(params.rootName, params.assetTags[index]),\n quantityRaw: UNIQUE_ASSET_AMOUNT,\n units: UNIQUE_ASSET_UNITS,\n reissuable: UNIQUE_ASSETS_REISSUABLE,\n ipfsHash: params.ipfsHashes?.[index],\n assetMarker: params.assetMarker\n }));\n }\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueQualifierTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n const parentQualifier = getParentAssetName(params.assetName);\n if (parentQualifier) {\n outputs.push(createAssetTransferOutput(params.rootChangeAddress ?? params.xnaChangeAddress ?? params.toAddress, parentQualifier, params.changeQuantityRaw ?? OWNER_ASSET_AMOUNT, marker(params)));\n }\n outputs.push(createIssueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n units: 0,\n reissuable: false,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueRestrictedTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n outputs.push(createVerifierStringOutput(normalizeVerifierString(params.verifierString)));\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress ?? params.toAddress, getOwnerTokenName(params.assetName), marker(params)));\n outputs.push(createIssueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n units: params.units ?? 0,\n reissuable: params.reissuable ?? true,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createReissueTransaction(params) {\n if (isDepinAssetName(params.assetName)) {\n // DEPIN reissue: units must stay 0 (-1 means \"keep\"), and the owner-token\n // change must return to the destination address itself.\n if (params.units !== undefined && params.units !== 0 && params.units !== -1) {\n throw new Error('DEPIN reissue units must be 0 or -1 (keep)');\n }\n if (params.ownerChangeAddress !== undefined &&\n !sameDestination(params.ownerChangeAddress, params.toAddress)) {\n throw new Error('DEPIN reissue owner change address must match the destination address');\n }\n }\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n // Consensus locates the reissue output at vout[n-1]; extraOutputs go first.\n appendExtraOutputs(outputs, params.extraOutputs);\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress ?? params.toAddress, getOwnerTokenName(params.assetName), marker(params)));\n outputs.push(createReissueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n // Omitted means \"keep the current units\" (-1); do NOT collapse to 0.\n units: params.units,\n reissuable: params.reissuable ?? true,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createReissueRestrictedTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n if (params.verifierString) {\n outputs.push(createVerifierStringOutput(normalizeVerifierString(params.verifierString)));\n }\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress ?? params.toAddress, getOwnerTokenName(params.assetName), marker(params)));\n outputs.push(createReissueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n // Omitted means \"keep the current units\" (-1); do NOT collapse to 0.\n units: params.units,\n reissuable: params.reissuable ?? true,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createQualifierTagTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n outputs.push(createAssetTransferOutput(params.qualifierChangeAddress, params.qualifierName, params.qualifierChangeAmountRaw, marker(params)));\n for (const address of params.targetAddresses) {\n outputs.push(createNullAssetTagOutput(address, params.qualifierName, params.operation, params.nullAssetDestinationMode ?? 'strict'));\n }\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createFreezeAddressesTransaction(params) {\n if (isDepinAssetName(params.assetName)) {\n // The address holding (or receiving) the owner token cannot be frozen or\n // revoked. The node also rejects spending an \"&X!\" UTXO that sits on a\n // target address — that input-side rule cannot be checked here (inputs\n // carry no address) and stays the caller's responsibility.\n for (const target of params.targetAddresses) {\n if (sameDestination(target, params.ownerChangeAddress)) {\n throw new Error('DEPIN owner change address cannot be one of the target addresses (owner-holder address cannot be frozen or revoked)');\n }\n }\n }\n const outputs = [];\n appendXnaEnvelope(outputs, undefined, undefined, params.xnaChangeAddress, params.xnaChangeSats);\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress, getOwnerTokenName(params.assetName), marker(params)));\n for (const address of params.targetAddresses) {\n outputs.push(createNullAssetRestrictionOutput(address, params.assetName, freezeFlagFromOperation(params.operation), params.nullAssetDestinationMode ?? 'strict'));\n }\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createFreezeAssetTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, undefined, undefined, params.xnaChangeAddress, params.xnaChangeSats);\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress, getOwnerTokenName(params.assetName), marker(params)));\n outputs.push(createGlobalRestrictionOutput(params.assetName, freezeFlagFromOperation(params.operation)));\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createFromOperation(build) {\n switch (build.operationType) {\n case 'STANDARD_PAYMENT':\n return createPaymentTransaction(build.params);\n case 'STANDARD_TRANSFER':\n return createStandardAssetTransferTransaction(build.params);\n case 'ISSUE_ROOT':\n case 'ISSUE_MSGCHANNEL':\n return createIssueAssetTransaction(build.params);\n case 'ISSUE_SUB':\n return createIssueSubAssetTransaction(build.params);\n case 'ISSUE_UNIQUE':\n return createIssueUniqueAssetTransaction(build.params);\n case 'ISSUE_DEPIN':\n return createIssueDepinTransaction(build.params);\n case 'ISSUE_QUALIFIER':\n case 'ISSUE_SUB_QUALIFIER':\n return createIssueQualifierTransaction(build.params);\n case 'ISSUE_RESTRICTED':\n return createIssueRestrictedTransaction(build.params);\n case 'REISSUE':\n return createReissueTransaction(build.params);\n case 'REISSUE_RESTRICTED':\n return createReissueRestrictedTransaction(build.params);\n case 'TRANSFER_DEPIN':\n return createDepinTransferTransaction(build.params);\n case 'SELF_REVOKE_DEPIN':\n return createDepinSelfRevokeTransaction(build.params);\n case 'TAG_ADDRESSES':\n return createQualifierTagTransaction({\n ...build.params,\n operation: 'tag'\n });\n case 'UNTAG_ADDRESSES':\n return createQualifierTagTransaction({\n ...build.params,\n operation: 'untag'\n });\n case 'FREEZE_ADDRESSES':\n return createFreezeAddressesTransaction({\n ...build.params,\n operation: 'freeze'\n });\n case 'UNFREEZE_ADDRESSES':\n return createFreezeAddressesTransaction({\n ...build.params,\n operation: 'unfreeze'\n });\n case 'FREEZE_ASSET':\n return createFreezeAssetTransaction({\n ...build.params,\n operation: 'freeze'\n });\n case 'UNFREEZE_ASSET':\n return createFreezeAssetTransaction({\n ...build.params,\n operation: 'unfreeze'\n });\n default: {\n const unsupported = build;\n throw new Error(`Unsupported operation type: ${JSON.stringify(unsupported)}`);\n }\n }\n}\n\n/**\n * Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.\n * @param a - value to test\n * @returns `true` when the value is a Uint8Array-compatible view.\n * @example\n * Check whether a value is a Uint8Array-compatible view.\n * ```ts\n * isBytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nfunction isBytes(a) {\n // Plain `instanceof Uint8Array` is too strict for some Buffer / proxy / cross-realm cases.\n // The fallback still requires a real ArrayBuffer view, so plain\n // JSON-deserialized `{ constructor: ... }` spoofing is rejected, and\n // `BYTES_PER_ELEMENT === 1` keeps the fallback on byte-oriented views.\n return (a instanceof Uint8Array ||\n (ArrayBuffer.isView(a) &&\n a.constructor.name === 'Uint8Array' &&\n 'BYTES_PER_ELEMENT' in a &&\n a.BYTES_PER_ELEMENT === 1));\n}\n/**\n * Asserts something is Uint8Array.\n * @param value - value to validate\n * @param length - optional exact length constraint\n * @param title - label included in thrown errors\n * @returns The validated byte array.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate that a value is a byte array.\n * ```ts\n * abytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nfunction abytes(value, length, title = '') {\n const bytes = isBytes(value);\n const len = value?.length;\n const needsLen = length !== undefined;\n if (!bytes || (needsLen)) {\n const prefix = title && `\"${title}\" `;\n const ofLen = '';\n const got = bytes ? `length=${len}` : `type=${typeof value}`;\n const message = prefix + 'expected Uint8Array' + ofLen + ', got ' + got;\n if (!bytes)\n throw new TypeError(message);\n throw new RangeError(message);\n }\n return value;\n}\n/**\n * Asserts a hash instance has not been destroyed or finished.\n * @param instance - hash instance to validate\n * @param checkFinished - whether to reject finalized instances\n * @throws If the hash instance has already been destroyed or finalized. {@link Error}\n * @example\n * Validate that a hash instance is still usable.\n * ```ts\n * import { aexists } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const hash = sha256.create();\n * aexists(hash);\n * ```\n */\nfunction aexists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\n/**\n * Asserts output is a sufficiently-sized byte array.\n * @param out - destination buffer\n * @param instance - hash instance providing output length\n * Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate a caller-provided digest buffer.\n * ```ts\n * import { aoutput } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const hash = sha256.create();\n * aoutput(new Uint8Array(hash.outputLen), hash);\n * ```\n */\nfunction aoutput(out, instance) {\n abytes(out, undefined, 'digestInto() output');\n const min = instance.outputLen;\n if (out.length < min) {\n throw new RangeError('\"digestInto() output\" expected to be of length >=' + min);\n }\n}\n/**\n * Zeroizes typed arrays in place. Warning: JS provides no guarantees.\n * @param arrays - arrays to overwrite with zeros\n * @example\n * Zeroize sensitive buffers in place.\n * ```ts\n * clean(new Uint8Array([1, 2, 3]));\n * ```\n */\nfunction clean(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n/**\n * Creates a DataView for byte-level manipulation.\n * @param arr - source typed array\n * @returns DataView over the same buffer region.\n * @example\n * Create a DataView over an existing buffer.\n * ```ts\n * createView(new Uint8Array(4));\n * ```\n */\nfunction createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/**\n * Rotate-right operation for uint32 values.\n * @param word - source word\n * @param shift - shift amount in bits\n * @returns Rotated word.\n * @example\n * Rotate a 32-bit word to the right.\n * ```ts\n * rotr(0x12345678, 8);\n * ```\n */\nfunction rotr(word, shift) {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/**\n * Rotate-left operation for uint32 values.\n * @param word - source word\n * @param shift - shift amount in bits\n * @returns Rotated word.\n * @example\n * Rotate a 32-bit word to the left.\n * ```ts\n * rotl(0x12345678, 8);\n * ```\n */\nfunction rotl(word, shift) {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n/**\n * Creates a callable hash function from a stateful class constructor.\n * @param hashCons - hash constructor or factory\n * @param info - optional metadata such as DER OID\n * @returns Frozen callable hash wrapper with `.create()`.\n * Wrapper construction eagerly calls `hashCons(undefined)` once to read\n * `outputLen` / `blockLen`, so constructor side effects happen at module\n * init time.\n * @example\n * Wrap a stateful hash constructor into a callable helper.\n * ```ts\n * import { createHasher } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const wrapped = createHasher(sha256.create, { oid: sha256.oid });\n * wrapped(new Uint8Array([1]));\n * ```\n */\nfunction createHasher(hashCons, info = {}) {\n const hashC = (msg, opts) => hashCons(opts)\n .update(msg)\n .digest();\n const tmp = hashCons(undefined);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.canXOF = tmp.canXOF;\n hashC.create = (opts) => hashCons(opts);\n Object.assign(hashC, info);\n return Object.freeze(hashC);\n}\n/**\n * Creates OID metadata for NIST hashes with prefix `06 09 60 86 48 01 65 03 04 02`.\n * @param suffix - final OID byte for the selected hash.\n * The helper accepts any byte even though only the documented NIST hash\n * suffixes are meaningful downstream.\n * @returns Object containing the DER-encoded OID.\n * @example\n * Build OID metadata for a NIST hash.\n * ```ts\n * oidNist(0x01);\n * ```\n */\nconst oidNist = (suffix) => ({\n // Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.\n // Larger suffix values would need base-128 OID encoding and a different length byte.\n oid: Uint8Array.from([0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, suffix]),\n});\n\n/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\n/**\n * Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.\n * Returns bits from `b` when `a` is set, otherwise from `c`.\n * The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never\n * set the same bit.\n * @param a - selector word\n * @param b - word chosen when selector bit is set\n * @param c - word chosen when selector bit is clear\n * @returns Mixed 32-bit word.\n * @example\n * Combine three words with the shared 32-bit choice primitive.\n * ```ts\n * Chi(0xffffffff, 0x12345678, 0x87654321);\n * ```\n */\nfunction Chi(a, b, c) {\n return (a & b) ^ (~a & c);\n}\n/**\n * Shared 32-bit majority primitive reused by SHA-256 and SHA-1.\n * Returns bits shared by at least two inputs.\n * @param a - first input word\n * @param b - second input word\n * @param c - third input word\n * @returns Mixed 32-bit word.\n * @example\n * Combine three words with the shared 32-bit majority primitive.\n * ```ts\n * Maj(0xffffffff, 0x12345678, 0x87654321);\n * ```\n */\nfunction Maj(a, b, c) {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n * Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit\n * strings with partial-byte tails.\n * @param blockLen - internal block size in bytes\n * @param outputLen - digest size in bytes\n * @param padOffset - trailing length field size in bytes\n * @param isLE - whether length and state words are encoded in little-endian\n * @example\n * Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.\n * ```ts\n * import { _SHA1 } from '@noble/hashes/legacy.js';\n * const hash = new _SHA1();\n * hash.update(new Uint8Array([97, 98, 99]));\n * hash.digest();\n * ```\n */\nclass HashMD {\n blockLen;\n outputLen;\n canXOF = false;\n padOffset;\n isLE;\n // For partial updates less than block size\n buffer;\n view;\n finished = false;\n length = 0;\n pos = 0;\n destroyed = false;\n constructor(blockLen, outputLen, padOffset, isLE) {\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data) {\n aexists(this);\n abytes(data);\n const { view, buffer, blockLen } = this;\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path only when there is no buffered partial block: `take === blockLen` implies\n // `this.pos === 0`, so we can process full blocks directly from the input view.\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n clean(this.buffer.subarray(pos));\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // `padOffset` reserves the whole length field. For SHA-384/512 the high 64 bits stay zero from\n // the padding fill above, and JS will overflow before user input can make that half non-zero.\n // So we only need to write the low 64 bits here.\n view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which must be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen must be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n // Copy before destroy(): subclasses wipe `buffer` during cleanup, but `digest()` must return\n // fresh bytes to the caller.\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to ||= new this.constructor();\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.destroyed = destroyed;\n to.finished = finished;\n to.length = length;\n to.pos = pos;\n // Only partial-block bytes need copying: when `length % blockLen === 0`, `pos === 0` and\n // later `update()` / `digestInto()` overwrite `to.buffer` from the start before reading it.\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n clone() {\n return this._cloneInto();\n }\n}\n/**\n * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.\n * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.\n */\n/** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the\n * square roots of the first eight prime numbers. Exported as a shared table; callers must treat\n * it as read-only because constructors copy words from it by index. */\nconst SHA256_IV = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n\n/**\n * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.\n * SHA256 is the fastest hash implementable in JS, even faster than Blake3.\n * Check out {@link https://www.rfc-editor.org/rfc/rfc4634 | RFC 4634} and\n * {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf | FIPS 180-4}.\n * @module\n */\n/**\n * SHA-224 / SHA-256 round constants from RFC 6234 §5.1: the first 32 bits\n * of the cube roots of the first 64 primes (2..311).\n */\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ Uint32Array.from([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n/** Reusable SHA-224 / SHA-256 message schedule buffer `W_t` from RFC 6234 §6.2 step 1. */\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\n/** Internal SHA-224 / SHA-256 compression engine from RFC 6234 §6.2. */\nclass SHA2_32B extends HashMD {\n constructor(outputLen) {\n super(64, outputLen, 8, false);\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n clean(SHA256_W);\n }\n destroy() {\n // HashMD callers route post-destroy usability through `destroyed`; zeroizing alone still leaves\n // update()/digest() callable on reused instances.\n this.destroyed = true;\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n clean(this.buffer);\n }\n}\n/** Internal SHA-256 hash class grounded in RFC 6234 §6.2. */\nclass _SHA256 extends SHA2_32B {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n A = SHA256_IV[0] | 0;\n B = SHA256_IV[1] | 0;\n C = SHA256_IV[2] | 0;\n D = SHA256_IV[3] | 0;\n E = SHA256_IV[4] | 0;\n F = SHA256_IV[5] | 0;\n G = SHA256_IV[6] | 0;\n H = SHA256_IV[7] | 0;\n constructor() {\n super(32);\n }\n}\n/**\n * SHA2-256 hash function from RFC 4634. In JS it's the fastest: even faster than Blake3. Some info:\n *\n * - Trying 2^128 hashes would get 50% chance of collision, using birthday attack.\n * - BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n * - Each sha256 hash is executing 2^18 bit operations.\n * - Good 2024 ASICs can do 200Th/sec with 3500 watts of power, corresponding to 2^36 hashes/joule.\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-256.\n * ```ts\n * sha256(new Uint8Array([97, 98, 99]));\n * ```\n */\nconst sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(), \n/* @__PURE__ */ oidNist(0x01));\n\n// Hard deserialization bound, mirroring the node (serialize.h MAX_SIZE):\n// ReadCompactSize rejects anything above it, canonical or not.\nconst MAX_SIZE = 0x02000000;\nfunction hash256(bytes) {\n return sha256(sha256(bytes));\n}\nclass ByteReader {\n bytes;\n offset = 0;\n constructor(bytes) {\n this.bytes = bytes;\n }\n need(count) {\n if (count > this.bytes.length - this.offset) {\n throw new Error(`Transaction hex truncated: need ${count} more byte(s) at offset ${this.offset}, ` +\n `${this.bytes.length - this.offset} remaining`);\n }\n }\n readBytes(count) {\n this.need(count);\n const slice = this.bytes.subarray(this.offset, this.offset + count);\n this.offset += count;\n return slice;\n }\n readU8() {\n return this.readBytes(1)[0];\n }\n readU32() {\n const slice = this.readBytes(4);\n return (slice[0] | (slice[1] << 8) | (slice[2] << 16) | (slice[3] << 24)) >>> 0;\n }\n readU64() {\n const slice = this.readBytes(8);\n let value = 0n;\n for (let i = 7; i >= 0; i -= 1) {\n value = (value << 8n) | BigInt(slice[i]);\n }\n return value;\n }\n // Canonical CompactSize with the node's range bound: the shortest encoding\n // is mandatory and anything above MAX_SIZE throws, exactly like\n // ReadCompactSize. Lengths are validated against the remaining bytes by the\n // callers BEFORE any allocation or iteration.\n readCompactSize() {\n const first = this.readU8();\n let value;\n if (first < 0xfd) {\n value = first;\n }\n else if (first === 0xfd) {\n const slice = this.readBytes(2);\n value = slice[0] | (slice[1] << 8);\n if (value < 0xfd)\n throw new Error('Non-canonical CompactSize (0xfd form for value < 253)');\n }\n else if (first === 0xfe) {\n value = this.readU32();\n if (value < 0x10000)\n throw new Error('Non-canonical CompactSize (0xfe form for value < 0x10000)');\n }\n else {\n const big = this.readU64();\n if (big < 0x100000000n)\n throw new Error('Non-canonical CompactSize (0xff form for value < 2^32)');\n if (big > BigInt(MAX_SIZE))\n throw new Error(`CompactSize exceeds MAX_SIZE: ${big}`);\n value = Number(big);\n }\n if (value > MAX_SIZE) {\n throw new Error(`CompactSize exceeds MAX_SIZE: ${value}`);\n }\n return value;\n }\n /** Read a length prefix that must fit in the remaining bytes at `bytesPerItem`. */\n readCount(bytesPerItem, label) {\n const count = this.readCompactSize();\n if (count * bytesPerItem > this.bytes.length - this.offset) {\n throw new Error(`Declared ${label} count ${count} does not fit in the remaining ` +\n `${this.bytes.length - this.offset} byte(s)`);\n }\n return count;\n }\n get finished() {\n return this.offset === this.bytes.length;\n }\n get position() {\n return this.offset;\n }\n}\nfunction readOutpoint(reader) {\n const txid = bytesToHex(reverseBytes(reader.readBytes(32)));\n const vout = reader.readU32();\n return { txid, vout };\n}\nfunction readInput(reader) {\n const { txid, vout } = readOutpoint(reader);\n const scriptLength = reader.readCount(1, 'scriptSig');\n const scriptSigHex = bytesToHex(reader.readBytes(scriptLength));\n const sequence = reader.readU32();\n return { txid, vout, scriptSigHex, sequence };\n}\nfunction readOutput(reader) {\n const valueSats = reader.readU64();\n const scriptLength = reader.readCount(1, 'scriptPubKey');\n const scriptPubKeyHex = bytesToHex(reader.readBytes(scriptLength));\n return { valueSats, scriptPubKeyHex };\n}\n// Minimum serialized size per item, used only to bound counts before reading:\n// input = outpoint(36) + compactSize(1) + sequence(4); output = value(8) +\n// compactSize(1); witness element = compactSize(1).\nconst MIN_INPUT_SIZE = 41;\nconst MIN_OUTPUT_SIZE = 9;\nfunction parseTransaction(hex) {\n const reader = new ByteReader(hexToBytes(ensureHex(hex, 'transaction hex')));\n // nVersion is a signed int32 (negative versions exist on-chain historically).\n const version = reader.readU32() | 0;\n const inputs = [];\n const outputs = [];\n let flags = 0;\n const vinCount = reader.readCount(MIN_INPUT_SIZE, 'input');\n if (vinCount === 0) {\n // Either a dummy marker for the extended (witness) format, or a genuinely\n // empty vin. Mirrors UnserializeTransaction: a flags byte follows; when it\n // is non-zero the real vin/vout follow, when zero the vout is NOT read.\n flags = reader.readU8();\n if (flags !== 0) {\n const realVinCount = reader.readCount(MIN_INPUT_SIZE, 'input');\n for (let i = 0; i < realVinCount; i += 1)\n inputs.push(readInput(reader));\n const voutCount = reader.readCount(MIN_OUTPUT_SIZE, 'output');\n for (let i = 0; i < voutCount; i += 1)\n outputs.push(readOutput(reader));\n }\n }\n else {\n for (let i = 0; i < vinCount; i += 1)\n inputs.push(readInput(reader));\n const voutCount = reader.readCount(MIN_OUTPUT_SIZE, 'output');\n for (let i = 0; i < voutCount; i += 1)\n outputs.push(readOutput(reader));\n }\n // NIP-014: reference inputs sit between vout and witness, announced by flag\n // 0x02. Without the flag a version 3 transaction reads as 1.0.7 reads it.\n const vrefin = [];\n const hasRefInputs = (flags & 2) !== 0;\n if (hasRefInputs) {\n flags ^= 2;\n const refCount = reader.readCount(36, 'refinput');\n for (let i = 0; i < refCount; i += 1)\n vrefin.push(readOutpoint(reader));\n if (vrefin.length === 0) {\n // One encoding per transaction: the flag means some.\n throw new Error('Superfluous reference inputs record (flag 0x02 with no reference inputs)');\n }\n }\n if (flags & 1) {\n flags ^= 1;\n for (const input of inputs) {\n const stackSize = reader.readCount(1, 'witness element');\n const stack = [];\n for (let i = 0; i < stackSize; i += 1) {\n const elementLength = reader.readCount(1, 'witness bytes');\n stack.push(bytesToHex(reader.readBytes(elementLength)));\n }\n input.witness = stack;\n }\n if (hasRefInputs && !inputs.some(inputHasWitness)) {\n // With reference inputs the witness flag means some witness; 1.0.7 reads\n // an empty witness record without them, and so does the node.\n throw new Error('Superfluous witness record (flag 0x01 with no witness data)');\n }\n }\n if (flags) {\n throw new Error(`Unknown transaction optional data (flags 0x${flags.toString(16)})`);\n }\n const locktime = reader.readU32();\n if (!reader.finished) {\n throw new Error(`Trailing bytes after transaction (offset ${reader.position})`);\n }\n return { version, inputs, outputs, vrefin, locktime };\n}\nfunction serializeOutpoint(ref) {\n const txid = hexToBytes(ensureHex(ref.txid, 'txid'));\n if (txid.length !== 32) {\n throw new Error(`Invalid txid: expected 32 bytes, got ${txid.length}`);\n }\n return concatBytes(reverseBytes(txid), u32LE(ref.vout));\n}\nfunction serializeCodecInput(input) {\n const scriptSig = hexToBytes(ensureHex(input.scriptSigHex ?? '', 'scriptSigHex'));\n return concatBytes(serializeOutpoint(input), compactSize(scriptSig.length), scriptSig, u32LE(input.sequence ?? 0xffffffff));\n}\nfunction serializeCodecOutput(output) {\n const script = hexToBytes(ensureHex(output.scriptPubKeyHex, 'scriptPubKeyHex'));\n return concatBytes(u64LE(output.valueSats), compactSize(script.length), script);\n}\nfunction inputHasWitness(input) {\n return (input.witness?.length ?? 0) > 0;\n}\nfunction serializeTransaction(tx, options = {}) {\n if (!Number.isInteger(tx.version) || tx.version < -2147483648 || tx.version > 0x7fffffff) {\n throw new Error(`Transaction version out of int32 range: ${tx.version}`);\n }\n const vrefin = tx.vrefin ?? [];\n if (tx.version !== 3 && vrefin.length > 0) {\n throw new Error(`vrefin requires transaction version 3 (got version ${tx.version})`);\n }\n const withWitness = (options.includeWitness ?? true) && tx.inputs.some(inputHasWitness);\n // NIP-014: reference inputs keep the extended format without witnesses too,\n // because the txid commits to them.\n const flags = (withWitness ? 1 : 0) | (vrefin.length > 0 ? 2 : 0);\n const parts = [u32LE(tx.version >>> 0)];\n if (flags) {\n // Extended format: dummy empty vin + flags byte.\n parts.push(Uint8Array.of(0x00, flags));\n }\n parts.push(compactSize(tx.inputs.length));\n for (const input of tx.inputs)\n parts.push(serializeCodecInput(input));\n parts.push(compactSize(tx.outputs.length));\n for (const output of tx.outputs)\n parts.push(serializeCodecOutput(output));\n if (flags & 2) {\n parts.push(compactSize(vrefin.length));\n for (const ref of vrefin)\n parts.push(serializeOutpoint(ref));\n }\n if (withWitness) {\n // One stack per input, empty (CompactSize 0) where the input has none.\n for (const input of tx.inputs) {\n const stack = input.witness ?? [];\n parts.push(compactSize(stack.length));\n for (const element of stack) {\n const bytes = hexToBytes(ensureHex(element, 'witness element'));\n parts.push(compactSize(bytes.length), bytes);\n }\n }\n }\n parts.push(u32LE(tx.locktime));\n return bytesToHex(concatBytes(...parts));\n}\nfunction toDecoded(txOrHex) {\n return typeof txOrHex === 'string' ? parseTransaction(txOrHex) : txOrHex;\n}\nfunction computeTxid(txOrHex) {\n const stripped = serializeTransaction(toDecoded(txOrHex), { includeWitness: false });\n return bytesToHex(reverseBytes(hash256(hexToBytes(stripped))));\n}\nfunction computeWtxid(txOrHex) {\n const full = serializeTransaction(toDecoded(txOrHex));\n return bytesToHex(reverseBytes(hash256(hexToBytes(full))));\n}\nfunction estimateTransactionSize(txOrHex) {\n const tx = toDecoded(txOrHex);\n const size = serializeTransaction(tx).length / 2;\n const strippedSize = serializeTransaction(tx, { includeWitness: false }).length / 2;\n // consensus/validation.h: weight = stripped * (WITNESS_SCALE_FACTOR - 1) + total.\n const weight = strippedSize * 3 + size;\n return { size, strippedSize, weight, vsize: Math.ceil(weight / 4) };\n}\n\n/**\n\nSHA1 (RFC 3174), MD5 (RFC 1321), and RIPEMD160 legacy, weak hash functions.\nRFC 2286 only covers HMAC-RIPEMD160 wrapper material and test vectors,\nnot the base RIPEMD-160 compression spec.\nDon't use them in a new protocol. What \"weak\" means:\n\n- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160.\n- No practical pre-image attacks (only theoretical, 2^123.4)\n- HMAC seems kinda ok: https://www.rfc-editor.org/rfc/rfc6151\n * @module\n */\n// RIPEMD-160\n// Permutation repeatedly applied to derive the later RIPEMD-160 message-order tables.\nconst Rho160 = /* @__PURE__ */ Uint8Array.from([\n 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,\n]);\nconst Id160 = /* @__PURE__ */ (() => Uint8Array.from(new Array(16).fill(0).map((_, i) => i)))();\nconst Pi160 = /* @__PURE__ */ (() => Id160.map((i) => (9 * i + 5) % 16))();\n// Five left/right message-word orderings for the RIPEMD-160 dual-lane rounds.\nconst idxLR = /* @__PURE__ */ (() => {\n const L = [Id160];\n const R = [Pi160];\n const res = [L, R];\n for (let i = 0; i < 4; i++)\n for (let j of res)\n j.push(j[i].map((k) => Rho160[k]));\n return res;\n})();\nconst idxL = /* @__PURE__ */ (() => idxLR[0])();\nconst idxR = /* @__PURE__ */ (() => idxLR[1])();\n// const [idxL, idxR] = idxLR;\n// Base per-group shift table before the left/right message-order permutations are applied.\nconst shifts160 = /* @__PURE__ */ [\n [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],\n [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],\n [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],\n [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],\n [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5],\n].map((i) => Uint8Array.from(i));\nconst shiftsL160 = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts160[i][j]));\nconst shiftsR160 = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts160[i][j]));\n// Five left-lane additive constants for RIPEMD-160.\nconst Kl160 = /* @__PURE__ */ Uint32Array.from([\n 0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e,\n]);\n// Five right-lane additive constants for RIPEMD-160.\nconst Kr160 = /* @__PURE__ */ Uint32Array.from([\n 0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000,\n]);\n// Called `f()` in the spec; valid `group` values are 0..4, and out-of-range\n// inputs currently fall through to the group-4 branch.\nfunction ripemd_f(group, x, y, z) {\n if (group === 0)\n return x ^ y ^ z;\n if (group === 1)\n return (x & y) | (~x & z);\n if (group === 2)\n return (x | ~y) ^ z;\n if (group === 3)\n return (x & z) | (y & ~z);\n return x ^ (y | ~z);\n}\n// Reusable 16-word RIPEMD-160 message block buffer.\nconst BUF_160 = /* @__PURE__ */ new Uint32Array(16);\n/**\n * Internal RIPEMD-160 legacy hash class.\n * RFC 2286 only adds HMAC-RIPEMD160 material, not the core hash specification.\n */\nclass _RIPEMD160 extends HashMD {\n h0 = 0x67452301 | 0;\n h1 = 0xefcdab89 | 0;\n h2 = 0x98badcfe | 0;\n h3 = 0x10325476 | 0;\n h4 = 0xc3d2e1f0 | 0;\n constructor() {\n super(64, 20, 8, true);\n }\n get() {\n const { h0, h1, h2, h3, h4 } = this;\n return [h0, h1, h2, h3, h4];\n }\n set(h0, h1, h2, h3, h4) {\n this.h0 = h0 | 0;\n this.h1 = h1 | 0;\n this.h2 = h2 | 0;\n this.h3 = h3 | 0;\n this.h4 = h4 | 0;\n }\n process(view, offset) {\n for (let i = 0; i < 16; i++, offset += 4)\n BUF_160[i] = view.getUint32(offset, true);\n // prettier-ignore\n let al = this.h0 | 0, ar = al, bl = this.h1 | 0, br = bl, cl = this.h2 | 0, cr = cl, dl = this.h3 | 0, dr = dl, el = this.h4 | 0, er = el;\n // Instead of iterating 0 to 80, we split it into 5 groups\n // And use the groups in constants, functions, etc. Much simpler\n for (let group = 0; group < 5; group++) {\n const rGroup = 4 - group;\n const hbl = Kl160[group], hbr = Kr160[group]; // prettier-ignore\n const rl = idxL[group], rr = idxR[group]; // prettier-ignore\n const sl = shiftsL160[group], sr = shiftsR160[group]; // prettier-ignore\n for (let i = 0; i < 16; i++) {\n const tl = (rotl(al + ripemd_f(group, bl, cl, dl) + BUF_160[rl[i]] + hbl, sl[i]) + el) | 0;\n al = el, el = dl, dl = rotl(cl, 10) | 0, cl = bl, bl = tl; // prettier-ignore\n }\n // 2 loops are 10% faster\n for (let i = 0; i < 16; i++) {\n const tr = (rotl(ar + ripemd_f(rGroup, br, cr, dr) + BUF_160[rr[i]] + hbr, sr[i]) + er) | 0;\n ar = er, er = dr, dr = rotl(cr, 10) | 0, cr = br, br = tr; // prettier-ignore\n }\n }\n // Add the compressed chunk to the current hash value\n // Final recombination cross-adds the left/right lane accumulators into the next h0..h4 order.\n this.set((this.h1 + cl + dr) | 0, (this.h2 + dl + er) | 0, (this.h3 + el + ar) | 0, (this.h4 + al + br) | 0, (this.h0 + bl + cr) | 0);\n }\n roundClean() {\n clean(BUF_160);\n }\n destroy() {\n this.destroyed = true;\n clean(this.buffer);\n this.set(0, 0, 0, 0, 0);\n }\n}\n/**\n * RIPEMD-160 - a legacy hash function from 1990s.\n * RFC 2286 only covers HMAC-RIPEMD160 test material; the links below point\n * at the base RIPEMD-160 references.\n * * {@link https://homes.esat.kuleuven.be/~bosselae/ripemd160.html}\n * * {@link https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf}\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with RIPEMD-160.\n * ```ts\n * ripemd160(new Uint8Array([97, 98, 99]));\n * ```\n */\nconst ripemd160 = /* @__PURE__ */ createHasher(() => new _RIPEMD160());\n\nconst PSBT_MAGIC = Uint8Array.of(0x70, 0x73, 0x62, 0x74, 0xff);\nconst PSBT_GLOBAL_UNSIGNED_TX = 0x00;\nconst PSBT_GLOBAL_VERSION = 0xfb;\nconst PSBT_IN_NON_WITNESS_UTXO = 0x00;\nconst PSBT_IN_WITNESS_UTXO = 0x01;\nconst PSBT_IN_PARTIAL_SIG = 0x02;\nconst PSBT_IN_SIGHASH_TYPE = 0x03;\nconst PSBT_IN_REDEEM_SCRIPT = 0x04;\nconst PSBT_IN_WITNESS_SCRIPT = 0x05;\nconst PSBT_IN_BIP32_DERIVATION = 0x06;\nconst PSBT_IN_FINAL_SCRIPTSIG = 0x07;\nconst PSBT_IN_FINAL_SCRIPTWITNESS = 0x08;\nconst PSBT_OUT_REDEEM_SCRIPT = 0x00;\nconst PSBT_OUT_WITNESS_SCRIPT = 0x01;\nconst PSBT_OUT_BIP32_DERIVATION = 0x02;\nconst INPUT_FIELD_NAMES = {\n [PSBT_IN_NON_WITNESS_UTXO]: 'previous transaction',\n [PSBT_IN_WITNESS_UTXO]: 'witness UTXO',\n [PSBT_IN_PARTIAL_SIG]: 'partial signature',\n [PSBT_IN_SIGHASH_TYPE]: 'sighash type',\n [PSBT_IN_REDEEM_SCRIPT]: 'redeem script',\n [PSBT_IN_WITNESS_SCRIPT]: 'witness script',\n [PSBT_IN_BIP32_DERIVATION]: 'BIP32 derivation',\n [PSBT_IN_FINAL_SCRIPTSIG]: 'final scriptSig',\n [PSBT_IN_FINAL_SCRIPTWITNESS]: 'final script witness'\n};\nconst OUTPUT_FIELD_NAMES = {\n [PSBT_OUT_REDEEM_SCRIPT]: 'redeem script',\n [PSBT_OUT_WITNESS_SCRIPT]: 'witness script',\n [PSBT_OUT_BIP32_DERIVATION]: 'BIP32 derivation'\n};\n// A Finalizer clears the signing data it knows about (BIP-174) and keeps the\n// UTXO, the final scripts and the fields it does not interpret.\nconst CLEARED_ON_FINALIZE = new Set([\n PSBT_IN_PARTIAL_SIG,\n PSBT_IN_SIGHASH_TYPE,\n PSBT_IN_REDEEM_SCRIPT,\n PSBT_IN_WITNESS_SCRIPT,\n PSBT_IN_BIP32_DERIVATION\n]);\nconst UPDATE_FIELDS = new Set([\n 'previousTx',\n 'witnessUtxo',\n 'witnessScript',\n 'sighashType',\n 'bip32Derivation',\n 'partialSig',\n 'finalScriptSig',\n 'finalScriptWitness'\n]);\n// Strict ECDSA (AuthScript witness v3): witness [authType 0x02, sig, pubkey, OP_TRUE]\n// against taggedHash(\"NeuraiAuthScript\", 0x03 || 0x02 || HASH160(pubkey) || SHA256(OP_TRUE)).\nconst AUTHSCRIPT_TAG = 'NeuraiAuthScript';\nconst ECDSA_WITNESS_VERSION = 0x03;\nconst ECDSA_AUTH_TYPE = 0x02;\nconst OP_TRUE_SCRIPT = Uint8Array.of(0x51);\nconst HARDENED = 0x80000000;\n// ---------------------------------------------------------------------------\n// Bytes\nconst BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nfunction bytesToBase64(bytes) {\n let out = '';\n for (let i = 0; i < bytes.length; i += 3) {\n const n = (bytes[i] << 16) | ((bytes[i + 1] ?? 0) << 8) | (bytes[i + 2] ?? 0);\n out += BASE64[(n >> 18) & 63] + BASE64[(n >> 12) & 63];\n out += i + 1 < bytes.length ? BASE64[(n >> 6) & 63] : '=';\n out += i + 2 < bytes.length ? BASE64[n & 63] : '=';\n }\n return out;\n}\nfunction base64ToBytes(text) {\n if (text.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(text)) {\n throw new Error('PSBT string is neither base64 nor hex');\n }\n const padding = text.endsWith('==') ? 2 : text.endsWith('=') ? 1 : 0;\n const out = new Uint8Array((text.length / 4) * 3 - padding);\n const digit = (char) => (char === '=' ? 0 : BASE64.indexOf(char));\n let o = 0;\n for (let i = 0; i < text.length; i += 4) {\n const n = (digit(text[i]) << 18) | (digit(text[i + 1]) << 12) | (digit(text[i + 2]) << 6) | digit(text[i + 3]);\n for (const shift of [16, 8, 0])\n if (o < out.length)\n out[o++] = (n >> shift) & 255;\n }\n return out;\n}\nfunction psbtBytes(psbt) {\n if (psbt instanceof Uint8Array)\n return psbt;\n if (typeof psbt !== 'string')\n throw new TypeError('PSBT must be a base64 or hex string, or bytes');\n const text = psbt.trim();\n return /^70736274ff/i.test(text) ? hexToBytes(text) : base64ToBytes(text);\n}\nfunction equalBytes(a, b) {\n return a.length === b.length && a.every((value, index) => value === b[index]);\n}\n/** Byte-wise order, a prefix first: how BIP-174 serializers sort map keys. */\nfunction compareBytes(a, b) {\n for (let i = 0; i < Math.min(a.length, b.length); i += 1) {\n if (a[i] !== b[i])\n return a[i] < b[i] ? -1 : 1;\n }\n return a.length - b.length;\n}\nfunction readU32LE(bytes) {\n return new DataView(bytes.buffer, bytes.byteOffset, 4).getUint32(0, true);\n}\nfunction hash160(bytes) {\n return ripemd160(sha256(bytes));\n}\nfunction taggedHash(tag, message) {\n const tagHash = sha256(asciiBytes(tag));\n return sha256(concatBytes(tagHash, tagHash, message));\n}\nfunction ecdsaV3Commitment(pubkey) {\n return taggedHash(AUTHSCRIPT_TAG, concatBytes(Uint8Array.of(ECDSA_WITNESS_VERSION, ECDSA_AUTH_TYPE), hash160(pubkey), sha256(OP_TRUE_SCRIPT)));\n}\nclass Reader {\n bytes;\n label;\n offset = 0;\n constructor(bytes, label) {\n this.bytes = bytes;\n this.label = label;\n }\n get finished() {\n return this.offset === this.bytes.length;\n }\n readBytes(count) {\n if (count > this.bytes.length - this.offset) {\n throw new Error(`${this.label} is truncated (need ${count} byte(s) at offset ${this.offset})`);\n }\n const out = this.bytes.subarray(this.offset, this.offset + count);\n this.offset += count;\n return out;\n }\n /** Canonical CompactSize, bounded by the bytes left (every length or count here is). */\n readCompactSize() {\n const first = this.readBytes(1)[0];\n let value = BigInt(first);\n if (first >= 0xfd) {\n const width = first === 0xfd ? 2 : first === 0xfe ? 4 : 8;\n const bytes = this.readBytes(width);\n value = 0n;\n for (let i = width - 1; i >= 0; i -= 1)\n value = (value << 8n) | BigInt(bytes[i]);\n const minimum = width === 2 ? 0xfdn : width === 4 ? 0x10000n : 0x100000000n;\n if (value < minimum)\n throw new Error(`${this.label}: non-canonical CompactSize at offset ${this.offset - width - 1}`);\n }\n if (value > BigInt(this.bytes.length - this.offset)) {\n throw new Error(`${this.label} is truncated (length ${value} at offset ${this.offset})`);\n }\n return Number(value);\n }\n readMap(mapLabel) {\n const map = [];\n const seen = new Set();\n for (;;) {\n const keyLength = this.readCompactSize();\n if (keyLength === 0)\n return map;\n const key = this.readBytes(keyLength);\n const value = this.readBytes(this.readCompactSize());\n const keyHex = bytesToHex(key);\n if (seen.has(keyHex))\n throw new Error(`PSBT ${mapLabel}: duplicate key ${keyHex}`);\n seen.add(keyHex);\n map.push({ key, value });\n }\n }\n}\nfunction encodeWitnessStack(stack) {\n if (!Array.isArray(stack))\n throw new Error('finalScriptWitness must be an array of hex strings');\n return concatBytes(compactSize(stack.length), ...stack.map((element) => {\n const bytes = hexToBytes(ensureHex(element, 'witness element'));\n return concatBytes(compactSize(bytes.length), bytes);\n }));\n}\nfunction decodeWitnessStack(bytes, label) {\n const reader = new Reader(bytes, label);\n const count = reader.readCompactSize();\n const stack = [];\n for (let i = 0; i < count; i += 1)\n stack.push(bytesToHex(reader.readBytes(reader.readCompactSize())));\n if (!reader.finished)\n throw new Error(`${label} has trailing data`);\n return stack;\n}\n// BIP-66 DER structure followed by one sighash byte.\nfunction isDerSignatureWithSighash(sig) {\n if (sig.length < 9 || sig.length > 73 || sig[0] !== 0x30 || sig[1] !== sig.length - 3)\n return false;\n const rLength = sig[3];\n if (sig[2] !== 0x02 || rLength === 0 || 5 + rLength >= sig.length)\n return false;\n const sLength = sig[5 + rLength];\n if (sig[4 + rLength] !== 0x02 || sLength === 0)\n return false;\n return rLength + sLength + 7 === sig.length;\n}\nfunction isPublicKey(pubkey) {\n return (pubkey.length === 33 && (pubkey[0] === 0x02 || pubkey[0] === 0x03)) || (pubkey.length === 65 && pubkey[0] === 0x04);\n}\nfunction encodePath(path, label) {\n if (typeof path !== 'string' || !/^m(\\/\\d+['h]?)*$/.test(path)) {\n throw new Error(`${label}: invalid derivation path \"${path}\"`);\n }\n return concatBytes(...path\n .split('/')\n .slice(1)\n .map((level) => {\n const hardened = /['h]$/.test(level);\n const index = Number(hardened ? level.slice(0, -1) : level);\n if (!Number.isSafeInteger(index) || index >= HARDENED)\n throw new Error(`${label}: derivation index out of range in \"${path}\"`);\n return u32LE(hardened ? index + HARDENED : index);\n }));\n}\nfunction decodePath(bytes) {\n let path = 'm';\n for (let offset = 0; offset < bytes.length; offset += 4) {\n const value = readU32LE(bytes.subarray(offset, offset + 4));\n path += `/${value & 0x7fffffff}${value >= HARDENED ? \"'\" : ''}`;\n }\n return path;\n}\n// ---------------------------------------------------------------------------\n// Maps\nfunction fieldName(map, key) {\n const names = map.startsWith('input') ? INPUT_FIELD_NAMES : map.startsWith('output') ? OUTPUT_FIELD_NAMES : {};\n const name = names[key[0]] ?? `key type 0x${key[0].toString(16).padStart(2, '0')}`;\n return key.length > 1 ? `${name} ${bytesToHex(key.subarray(1))}` : name;\n}\nfunction singleByteKey(entry, map) {\n if (entry.key.length !== 1)\n throw new Error(`PSBT ${map}: the ${fieldName(map, entry.key)} key has unexpected key data`);\n}\nfunction keyPublicKey(entry, map) {\n const pubkey = entry.key.subarray(1);\n if (!isPublicKey(pubkey))\n throw new Error(`PSBT ${map}: invalid public key in the ${fieldName(map, entry.key)} key`);\n return pubkey;\n}\nfunction decodeDerivation(entry, map) {\n const pubkey = keyPublicKey(entry, map);\n if (entry.value.length < 4 || entry.value.length % 4 !== 0) {\n throw new Error(`PSBT ${map}: BIP32 derivation value must be a fingerprint and 4-byte path elements`);\n }\n return { masterFingerprint: entry.value.subarray(0, 4), pubkey, path: decodePath(entry.value.subarray(4)) };\n}\nfunction decodeInputMap(map, label) {\n const view = { partialSig: [], bip32Derivation: [], unknown: [] };\n for (const entry of map) {\n const { key, value } = entry;\n switch (key[0]) {\n case PSBT_IN_NON_WITNESS_UTXO:\n singleByteKey(entry, label);\n view.previousTx = value;\n break;\n case PSBT_IN_WITNESS_UTXO: {\n singleByteKey(entry, label);\n const reader = new Reader(value, `PSBT ${label} witness UTXO`);\n const amountBytes = reader.readBytes(8);\n const amount = new DataView(amountBytes.buffer, amountBytes.byteOffset, 8).getBigInt64(0, true);\n const script = reader.readBytes(reader.readCompactSize());\n if (!reader.finished || amount < 0n)\n throw new Error(`PSBT ${label}: malformed witness UTXO`);\n view.witnessUtxo = { script, value: amount };\n break;\n }\n case PSBT_IN_PARTIAL_SIG: {\n const pubkey = keyPublicKey(entry, label);\n if (!isDerSignatureWithSighash(value)) {\n throw new Error(`PSBT ${label}: the signature for ${bytesToHex(pubkey)} is not DER followed by a sighash byte`);\n }\n view.partialSig.push({ pubkey, signature: value });\n break;\n }\n case PSBT_IN_SIGHASH_TYPE:\n singleByteKey(entry, label);\n if (value.length !== 4)\n throw new Error(`PSBT ${label}: the sighash type must be 4 bytes`);\n view.sighashType = readU32LE(value);\n break;\n case PSBT_IN_REDEEM_SCRIPT:\n singleByteKey(entry, label);\n view.redeemScript = value;\n break;\n case PSBT_IN_WITNESS_SCRIPT:\n singleByteKey(entry, label);\n view.witnessScript = value;\n break;\n case PSBT_IN_BIP32_DERIVATION:\n view.bip32Derivation.push(decodeDerivation(entry, label));\n break;\n case PSBT_IN_FINAL_SCRIPTSIG:\n singleByteKey(entry, label);\n view.finalScriptSig = value;\n break;\n case PSBT_IN_FINAL_SCRIPTWITNESS:\n singleByteKey(entry, label);\n view.finalScriptWitness = decodeWitnessStack(value, `PSBT ${label} final script witness`);\n break;\n default:\n view.unknown.push(entry);\n }\n }\n return view;\n}\nfunction decodeOutputMap(map, label) {\n const view = { bip32Derivation: [], unknown: [] };\n for (const entry of map) {\n switch (entry.key[0]) {\n case PSBT_OUT_REDEEM_SCRIPT:\n singleByteKey(entry, label);\n view.redeemScript = entry.value;\n break;\n case PSBT_OUT_WITNESS_SCRIPT:\n singleByteKey(entry, label);\n view.witnessScript = entry.value;\n break;\n case PSBT_OUT_BIP32_DERIVATION:\n view.bip32Derivation.push(decodeDerivation(entry, label));\n break;\n default:\n view.unknown.push(entry);\n }\n }\n return view;\n}\nfunction encodeDerivation(type, derivation, label) {\n const fingerprint = hexToBytes(ensureHex(derivation.masterFingerprintHex, 'masterFingerprintHex'));\n if (fingerprint.length !== 4)\n throw new Error(`${label}: the master fingerprint must be 4 bytes`);\n return {\n key: concatBytes(Uint8Array.of(type), hexToBytes(ensureHex(derivation.pubkeyHex, 'pubkeyHex'))),\n value: concatBytes(fingerprint, encodePath(derivation.path, label))\n };\n}\nfunction encodeOutputFields(fields, index) {\n if (!fields || typeof fields !== 'object')\n throw new Error(`PSBT output ${index}: fields must be an object`);\n for (const name of Object.keys(fields)) {\n if (name !== 'bip32Derivation')\n throw new Error(`PSBT output ${index}: unknown field \"${name}\"`);\n }\n return (fields.bip32Derivation ?? []).map((derivation) => encodeDerivation(PSBT_OUT_BIP32_DERIVATION, derivation, `PSBT output ${index}`));\n}\nfunction encodeInputFields(fields, index) {\n if (!fields || typeof fields !== 'object')\n throw new Error(`PSBT input ${index}: fields must be an object`);\n for (const name of Object.keys(fields)) {\n if (!UPDATE_FIELDS.has(name))\n throw new Error(`PSBT input ${index}: unknown field \"${name}\"`);\n }\n const bytes = (hex, label) => hexToBytes(ensureHex(hex, label));\n const entries = [];\n const add = (type, keyData, value) => entries.push({ key: concatBytes(Uint8Array.of(type), keyData), value });\n const none = new Uint8Array();\n if (fields.previousTx !== undefined)\n add(PSBT_IN_NON_WITNESS_UTXO, none, bytes(fields.previousTx, 'previousTx'));\n if (fields.witnessUtxo !== undefined) {\n const value = toRawInteger(fields.witnessUtxo.valueSats, 'witnessUtxo.valueSats');\n if (value < 0n)\n throw new Error(`PSBT input ${index}: negative witnessUtxo value`);\n const script = bytes(fields.witnessUtxo.scriptPubKeyHex, 'witnessUtxo.scriptPubKeyHex');\n add(PSBT_IN_WITNESS_UTXO, none, concatBytes(i64LE(value), compactSize(script.length), script));\n }\n if (fields.witnessScript !== undefined)\n add(PSBT_IN_WITNESS_SCRIPT, none, bytes(fields.witnessScript, 'witnessScript'));\n if (fields.sighashType !== undefined) {\n const type = fields.sighashType;\n if (!Number.isInteger(type) || type < 0 || type > 0xffffffff)\n throw new Error(`PSBT input ${index}: invalid sighashType ${type}`);\n add(PSBT_IN_SIGHASH_TYPE, none, u32LE(type));\n }\n for (const derivation of fields.bip32Derivation ?? []) {\n entries.push(encodeDerivation(PSBT_IN_BIP32_DERIVATION, derivation, `PSBT input ${index}`));\n }\n for (const sig of fields.partialSig ?? []) {\n add(PSBT_IN_PARTIAL_SIG, bytes(sig.pubkeyHex, 'pubkeyHex'), bytes(sig.signatureHex, 'signatureHex'));\n }\n if (fields.finalScriptSig !== undefined)\n add(PSBT_IN_FINAL_SCRIPTSIG, none, bytes(fields.finalScriptSig, 'finalScriptSig'));\n if (fields.finalScriptWitness !== undefined) {\n add(PSBT_IN_FINAL_SCRIPTWITNESS, none, encodeWitnessStack(fields.finalScriptWitness));\n }\n return entries;\n}\n// ---------------------------------------------------------------------------\n// Reading and writing\nfunction assertUnsigned(tx, label) {\n if (tx.inputs.length === 0)\n throw new Error(`${label} has no inputs`);\n tx.inputs.forEach((input, index) => {\n if (input.scriptSigHex) {\n throw new Error(`${label}: input ${index} has a scriptSig (the transaction of a PSBT is unsigned)`);\n }\n if (input.witness && input.witness.length > 0) {\n throw new Error(`${label}: input ${index} has a witness (the transaction of a PSBT is unsigned)`);\n }\n });\n}\n/** The global transaction: unsigned, in the plain (non-witness) Neurai serialization. */\nfunction parseUnsignedTransaction(bytes) {\n const hex = bytesToHex(bytes);\n let tx;\n try {\n tx = parseTransaction(hex);\n }\n catch (error) {\n throw new Error(`PSBT unsigned transaction is unreadable: ${error.message}`);\n }\n assertUnsigned(tx, 'PSBT unsigned transaction');\n if (serializeTransaction(tx, { includeWitness: false }) !== hex) {\n throw new Error('PSBT unsigned transaction is not in the plain serialization');\n }\n return tx;\n}\n/** Previous output of an input, its previous transaction checked against the outpoint. */\nfunction previousOutputOf(input, outpoint, index) {\n if (input.previousTx) {\n const previousHex = bytesToHex(input.previousTx);\n let previous;\n try {\n previous = parseTransaction(previousHex);\n }\n catch (error) {\n throw new Error(`PSBT input ${index}: unreadable previous transaction (${error.message})`);\n }\n const txid = computeTxid(previous);\n if (txid !== outpoint.txid) {\n throw new Error(`PSBT input ${index}: the previous transaction is ${txid}, but the input spends ${outpoint.txid}:${outpoint.vout}`);\n }\n const output = previous.outputs[outpoint.vout];\n if (!output)\n throw new Error(`PSBT input ${index}: the previous transaction has no output ${outpoint.vout}`);\n if (input.witnessUtxo &&\n (bytesToHex(input.witnessUtxo.script) !== output.scriptPubKeyHex || input.witnessUtxo.value !== output.valueSats)) {\n throw new Error(`PSBT input ${index}: the witness UTXO contradicts the previous transaction`);\n }\n return { scriptPubKeyHex: output.scriptPubKeyHex, valueSats: output.valueSats };\n }\n if (input.witnessUtxo) {\n return { scriptPubKeyHex: bytesToHex(input.witnessUtxo.script), valueSats: input.witnessUtxo.value };\n }\n return null;\n}\n/** Parse and validate: structure, every interpreted field, and the profile rules. */\nfunction loadPsbt(psbt) {\n const bytes = psbtBytes(psbt);\n if (bytes.length < PSBT_MAGIC.length || !equalBytes(bytes.subarray(0, PSBT_MAGIC.length), PSBT_MAGIC)) {\n throw new Error('Not a PSBT: missing the \"psbt\" magic and 0xff separator');\n }\n const reader = new Reader(bytes.subarray(PSBT_MAGIC.length), 'PSBT');\n const global = reader.readMap('global map');\n const txEntries = global.filter((entry) => entry.key[0] === PSBT_GLOBAL_UNSIGNED_TX);\n if (txEntries.length !== 1 || txEntries[0].key.length !== 1) {\n throw new Error('PSBT global map must hold exactly one unsigned transaction (PSBT version 0)');\n }\n const version = global.find((entry) => entry.key.length === 1 && entry.key[0] === PSBT_GLOBAL_VERSION);\n if (version && (version.value.length !== 4 || readU32LE(version.value) !== 0)) {\n throw new Error('Only PSBT version 0 is supported');\n }\n const tx = parseUnsignedTransaction(txEntries[0].value);\n const inputs = tx.inputs.map((_, index) => reader.readMap(`input ${index}`));\n const outputs = tx.outputs.map((_, index) => reader.readMap(`output ${index}`));\n if (!reader.finished)\n throw new Error('PSBT has data after its last output map');\n inputs.forEach((map, index) => previousOutputOf(decodeInputMap(map, `input ${index}`), tx.inputs[index], index));\n outputs.forEach((map, index) => decodeOutputMap(map, `output ${index}`));\n return { tx, global, inputs, outputs };\n}\n/** Canonical form: every map sorted by key, as BIP-174 serializers write it. */\nfunction encodePsbt(loaded) {\n const map = (entries) => concatBytes(...[...entries]\n .sort((a, b) => compareBytes(a.key, b.key))\n .flatMap(({ key, value }) => [compactSize(key.length), key, compactSize(value.length), value]), Uint8Array.of(0));\n return bytesToBase64(concatBytes(PSBT_MAGIC, map(loaded.global), ...loaded.inputs.map(map), ...loaded.outputs.map(map)));\n}\n/** Union of key-value maps; the same key with a different value is a conflict, never a choice. */\nfunction mergeMap(target, other, map) {\n for (const entry of other) {\n const existing = target.find((candidate) => equalBytes(candidate.key, entry.key));\n if (!existing) {\n target.push(entry);\n }\n else if (!equalBytes(existing.value, entry.value)) {\n throw new Error(`PSBT conflict in ${map}: ${fieldName(map, entry.key)} already holds a different value`);\n }\n }\n}\n/** Re-read after a change, so the result passes the same validation as any input. */\nfunction revalidated(loaded) {\n return encodePsbt(loadPsbt(encodePsbt(loaded)));\n}\nfunction checkIndex(index, count, kind) {\n if (!Number.isInteger(index) || index < 0 || index >= count) {\n throw new Error(`PSBT has no ${kind} ${index} (it has ${count})`);\n }\n}\n// ---------------------------------------------------------------------------\n// Public API\n/** Creator + Updater: a PSBT for an unsigned transaction, with optional fields per input and output. */\nfunction createPsbt(params) {\n const { unsignedTx } = params;\n const tx = typeof unsignedTx === 'string' ? parseTransaction(unsignedTx) : unsignedTx;\n assertUnsigned(tx, 'createPsbt: the transaction');\n const fields = params.inputs ?? [];\n if (fields.length > tx.inputs.length) {\n throw new Error(`createPsbt: fields for ${fields.length} inputs, but the transaction has ${tx.inputs.length}`);\n }\n const outputFields = params.outputs ?? [];\n if (outputFields.length > tx.outputs.length) {\n throw new Error(`createPsbt: fields for ${outputFields.length} outputs, but the transaction has ${tx.outputs.length}`);\n }\n const inputs = tx.inputs.map((_, index) => []);\n fields.forEach((inputFields, index) => {\n if (inputFields !== undefined)\n mergeMap(inputs[index], encodeInputFields(inputFields, index), `input ${index}`);\n });\n const outputs = tx.outputs.map((_, index) => []);\n outputFields.forEach((fieldsOfOutput, index) => {\n if (fieldsOfOutput !== undefined)\n mergeMap(outputs[index], encodeOutputFields(fieldsOfOutput, index), `output ${index}`);\n });\n return revalidated({\n global: [\n { key: Uint8Array.of(PSBT_GLOBAL_UNSIGNED_TX), value: hexToBytes(serializeTransaction(tx, { includeWitness: false })) }\n ],\n inputs,\n outputs\n });\n}\n/** Read a PSBT, enforcing the Neurai profile (previous transactions match their outpoints). */\nfunction decodePsbt(psbt) {\n const { tx, global, inputs, outputs } = loadPsbt(psbt);\n const keyValues = (entries) => entries.map((entry) => ({ keyHex: bytesToHex(entry.key), valueHex: bytesToHex(entry.value) }));\n const derivations = (list) => list.map((derivation) => ({\n masterFingerprintHex: bytesToHex(derivation.masterFingerprint),\n pubkeyHex: bytesToHex(derivation.pubkey),\n path: derivation.path\n }));\n const hex = (bytes) => (bytes ? bytesToHex(bytes) : undefined);\n const defined = (object) => Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined));\n return {\n unsignedTx: tx,\n txid: computeTxid(tx),\n inputs: inputs.map((map, index) => {\n const view = decodeInputMap(map, `input ${index}`);\n return defined({\n previousTx: hex(view.previousTx),\n witnessUtxo: view.witnessUtxo && {\n scriptPubKeyHex: bytesToHex(view.witnessUtxo.script),\n valueSats: view.witnessUtxo.value\n },\n partialSig: view.partialSig.map((sig) => ({\n pubkeyHex: bytesToHex(sig.pubkey),\n signatureHex: bytesToHex(sig.signature)\n })),\n sighashType: view.sighashType,\n redeemScript: hex(view.redeemScript),\n witnessScript: hex(view.witnessScript),\n bip32Derivation: derivations(view.bip32Derivation),\n finalScriptSig: hex(view.finalScriptSig),\n finalScriptWitness: view.finalScriptWitness,\n unknown: keyValues(view.unknown)\n });\n }),\n outputs: outputs.map((map, index) => {\n const view = decodeOutputMap(map, `output ${index}`);\n return defined({\n redeemScript: hex(view.redeemScript),\n witnessScript: hex(view.witnessScript),\n bip32Derivation: derivations(view.bip32Derivation),\n unknown: keyValues(view.unknown)\n });\n }),\n unknown: keyValues(global.filter((entry) => entry.key[0] !== PSBT_GLOBAL_UNSIGNED_TX))\n };\n}\n/**\n * Add fields to one input. A field already present with the same value is\n * left as is; with a different value it is a conflict and throws.\n */\nfunction updatePsbtInput(psbt, index, fields) {\n const loaded = loadPsbt(psbt);\n checkIndex(index, loaded.tx.inputs.length, 'input');\n mergeMap(loaded.inputs[index], encodeInputFields(fields, index), `input ${index}`);\n return revalidated(loaded);\n}\n/**\n * Combiner: union of PSBTs of the same transaction. Unlike BIP-174's\n * \"pick one\", a key present with different values is rejected.\n */\nfunction combinePsbts(base, ...others) {\n const merged = loadPsbt(base);\n const baseTx = serializeTransaction(merged.tx, { includeWitness: false });\n for (const other of others.map(loadPsbt)) {\n if (serializeTransaction(other.tx, { includeWitness: false }) !== baseTx) {\n throw new Error('Cannot combine PSBTs of different transactions');\n }\n mergeMap(merged.global, other.global, 'global map');\n other.inputs.forEach((map, index) => mergeMap(merged.inputs[index], map, `input ${index}`));\n other.outputs.forEach((map, index) => mergeMap(merged.outputs[index], map, `output ${index}`));\n }\n return revalidated(merged);\n}\n/** Previous output (script and value) an input spends, from its previous transaction or witness UTXO. */\nfunction getPsbtPreviousOutput(decoded, index) {\n checkIndex(index, decoded.unsignedTx.inputs.length, 'input');\n const input = decoded.inputs[index];\n const view = { };\n if (input?.previousTx)\n view.previousTx = hexToBytes(input.previousTx);\n if (input?.witnessUtxo) {\n view.witnessUtxo = { script: hexToBytes(input.witnessUtxo.scriptPubKeyHex), value: input.witnessUtxo.valueSats };\n }\n const previous = previousOutputOf(view, decoded.unsignedTx.inputs[index], index);\n if (!previous)\n throw new Error(`PSBT input ${index} carries neither its previous transaction nor a witness UTXO`);\n return previous;\n}\nfunction signatureFor(input, index, family, ownsKey) {\n if (input.partialSig.length === 0)\n throw new Error(`PSBT input ${index} (${family}) is not signed`);\n const match = input.partialSig.find((sig) => ownsKey(sig.pubkey));\n if (!match)\n throw new Error(`PSBT input ${index}: no signature from the key its ${family} previous output pays to`);\n const used = match.signature[match.signature.length - 1];\n if (input.sighashType !== undefined && used !== input.sighashType) {\n throw new Error(`PSBT input ${index}: the signature uses sighash 0x${used.toString(16).padStart(2, '0')}, ` +\n `but the input asks for 0x${input.sighashType.toString(16).padStart(2, '0')}`);\n }\n return match;\n}\n/** Final key-value pairs of one input: final scripts built (or kept), signing data cleared. */\nfunction finalizeInputMap(map, outpoint, index) {\n const input = decodeInputMap(map, `input ${index}`);\n const finals = [];\n if (!input.finalScriptSig && !input.finalScriptWitness) {\n const previous = previousOutputOf(input, outpoint, index);\n if (!previous)\n throw new Error(`PSBT input ${index} carries neither its previous transaction nor a witness UTXO`);\n const kind = classifyScriptPubKey(previous.scriptPubKeyHex);\n const program = kind.program ?? new Uint8Array();\n if (kind.type === 'p2pkh') {\n const sig = signatureFor(input, index, 'P2PKH', (pubkey) => equalBytes(hash160(pubkey), program));\n finals.push({\n key: Uint8Array.of(PSBT_IN_FINAL_SCRIPTSIG),\n value: concatBytes(pushData(sig.signature), pushData(sig.pubkey))\n });\n }\n else if (kind.type === 'ecdsa') {\n const sig = signatureFor(input, index, 'ECDSA (AuthScript v3)', (pubkey) => pubkey.length === 33 && equalBytes(ecdsaV3Commitment(pubkey), program));\n finals.push({\n key: Uint8Array.of(PSBT_IN_FINAL_SCRIPTWITNESS),\n value: encodeWitnessStack([\n bytesToHex(Uint8Array.of(ECDSA_AUTH_TYPE)),\n bytesToHex(sig.signature),\n bytesToHex(sig.pubkey),\n bytesToHex(OP_TRUE_SCRIPT)\n ])\n });\n }\n else if (kind.type === 'authscript' || kind.type === 'pq') {\n throw new Error(`PSBT input ${index}: an AuthScript v${kind.witnessVersion} input is finalized by its signer ` +\n '(final script witness), and this one has none');\n }\n else {\n throw new Error(`PSBT input ${index}: no finalization template for scriptPubKey ${previous.scriptPubKeyHex}`);\n }\n }\n return [...map.filter((entry) => !CLEARED_ON_FINALIZE.has(entry.key[0])), ...finals];\n}\n/**\n * Finalizer. P2PKH and strict ECDSA (AuthScript v3) inputs are completed from\n * their `partialSig`; inputs that already carry finalScriptSig/finalScriptWitness\n * (covenant branches, PQ) are kept. A signature whose sighash byte differs from\n * the input's `sighashType` is rejected. Finalized inputs keep only the UTXO,\n * the final scripts and the fields this module does not interpret.\n */\nfunction finalizePsbt(psbt, options = {}) {\n const loaded = loadPsbt(psbt);\n const count = loaded.tx.inputs.length;\n const selection = options.inputs ?? 'all';\n let indexes;\n if (selection === 'all') {\n indexes = loaded.tx.inputs.map((_, index) => index);\n }\n else if (Array.isArray(selection)) {\n selection.forEach((index) => checkIndex(index, count, 'input'));\n indexes = [...new Set(selection)];\n }\n else {\n throw new Error(`finalizePsbt: inputs must be 'all' or a list of indexes`);\n }\n for (const index of indexes) {\n loaded.inputs[index] = finalizeInputMap(loaded.inputs[index], loaded.tx.inputs[index], index);\n }\n return revalidated(loaded);\n}\n/**\n * Extractor: the network transaction from the final scripts. Inputs without\n * them make it throw, unless `allowIncomplete` is set: they are then left\n * empty and listed in `incomplete` (for callers that add other unlocking data).\n */\nfunction extractPsbtTransaction(psbt, options = {}) {\n const loaded = loadPsbt(psbt);\n const incomplete = [];\n const inputs = loaded.tx.inputs.map((outpoint, index) => {\n const input = decodeInputMap(loaded.inputs[index], `input ${index}`);\n if (!input.finalScriptSig && !input.finalScriptWitness) {\n incomplete.push(index);\n return { ...outpoint };\n }\n const signed = {\n ...outpoint,\n scriptSigHex: input.finalScriptSig ? bytesToHex(input.finalScriptSig) : ''\n };\n if (input.finalScriptWitness)\n signed.witness = input.finalScriptWitness;\n return signed;\n });\n if (incomplete.length > 0 && !options.allowIncomplete) {\n throw new Error(`PSBT is not finalized: input(s) ${incomplete.join(', ')} have no final scriptSig or witness`);\n }\n const hex = serializeTransaction({ ...loaded.tx, inputs });\n return { hex, txid: computeTxid(hex), incomplete };\n}\n\nexport { AUTHSCRIPT_MAINNET_HRP, AUTHSCRIPT_TESTNET_HRP, DEFAULT_ASSET_MARKER, DEPIN_MAX_NAME_LENGTH, ECDSA_MAINNET_HRP, ECDSA_TESTNET_HRP, MAX_MONEY, OWNER_ASSET_AMOUNT, PQ_MAINNET_HRP, PQ_TESTNET_HRP, REGTEST_GLOBAL_BURN_ADDRESS, SATS_PER_XNA, UNIQUE_ASSETS_REISSUABLE, UNIQUE_ASSET_AMOUNT, UNIQUE_ASSET_UNITS, WITNESS_FAMILIES, assertDepinAssetName, assertDepinNetwork, assertMoneyRange, assetPayloadPrefix, assetUnitsToRaw, classifyScriptPubKey, combinePsbts, computeTxid, computeWtxid, createAssetTransferOutput, createAssetTransferToScriptOutput, createDepinSelfRevokeTransaction, createDepinTransferTransaction, createFreezeAddressesTransaction, createFreezeAssetTransaction, createFromOperation, createGlobalRestrictionOutput, createIssueAssetOutput, createIssueAssetTransaction, createIssueDepinTransaction, createIssueQualifierTransaction, createIssueRestrictedTransaction, createIssueSubAssetTransaction, createIssueUniqueAssetTransaction, createNullAssetRestrictionOutput, createNullAssetTagOutput, createOwnerAssetIssueOutput, createOwnerAssetTransferOutput, createPaymentTransaction, createPsbt, createQualifierTagTransaction, createReissueAssetOutput, createReissueRestrictedTransaction, createReissueTransaction, createStandardAssetTransferTransaction, createTransferOutput, createTransferWithMessageOutput, createUnsignedTransaction, createVerifierStringOutput, createXnaOutput, decimalToSatoshis, decodeAddress, decodeAssetDataReferenceHex, decodePsbt, encodeAssetDataReference, encodeAssetTransferPayload, encodeAssetTransferScript, encodeAssetTransferScriptToScript, encodeAuthScriptDestinationScript, encodeDestinationScript, encodeGlobalRestrictionScript, encodeNewAssetPayload, encodeNewAssetScript, encodeNullAssetDataPayload, encodeNullAssetDestinationScript, encodeNullAssetRestrictionScript, encodeNullAssetTagPayload, encodeNullAssetTagScript, encodeOwnerAssetPayload, encodeOwnerAssetScript, encodeP2PKHScript, encodePQWitnessScript, encodeReissueAssetPayload, encodeReissueAssetScript, encodeVerifierStringPayload, encodeVerifierStringScript, encodeWitnessProgramScript, estimateTransactionSize, extractPsbtTransaction, finalizePsbt, formatAssetDataReferenceHex, getBurnAddressForOperation, getBurnAmountSats, getBurnAmountXna, getOwnerTokenName, getParentAssetName, getPsbtPreviousOutput, getUniqueAssetName, inferNetworkFromAnyAddress, isCidV0AssetReference, isDepinAssetName, isEncodedAssetDataReferenceHex, isRawAssetDataReferenceHex, isTxidAssetReference, isWitnessDestination, normalizeVerifierString, parseTransaction, resolveAddressInput, resolveAssetMarker, satoshisToDecimal, serializeInput, serializeOutput, serializeTransaction, toRawInteger, updatePsbtInput, xnaToSatoshis };\n//# sourceMappingURL=index.js.map\n","/**\n * Address helpers. Wraps `decodeAddress` from\n * `@neuraiproject/neurai-create-transaction` to produce the exact\n * scriptPubKey bytes a covenant needs to hardcode. The actual\n * scriptPubKey encoders live in `./standard/*`; this module delegates.\n *\n * Every Neurai destination type is supported for the payment output\n * (output[0]):\n * - Legacy P2PKH (base58check) → `76a914<20>88ac`\n * - Generic AuthScript witness v1 (nc1p… / tnc1p…) → `5120<32>`\n * - Strict PQ witness v2 (pq1z… / tpq1z…) → `5220<32>`\n * - Strict ECDSA witness v3 (nq1r… / tnq1r…) → `5320<32>`\n */\nimport { decodeAddress } from '@neuraiproject/neurai-create-transaction';\nimport { encodeP2PKHScriptPubKey } from './standard/p2pkh.js';\nimport { encodeAuthScriptScriptPubKey } from './standard/authscript.js';\n// Re-export for callers that imported these from `address` pre-refactor. The\n// canonical path going forward is `./standard/p2pkh` / `./standard/authscript`.\nexport { encodeP2PKHScriptPubKey, encodeAuthScriptScriptPubKey };\n/**\n * Resolve any accepted seller address string into its scriptPubKey.\n * The returned bytes are what the covenant will hardcode and later verify\n * via `OP_OUTPUTSCRIPT == <bytes>`.\n */\nexport function encodeSellerScriptPubKey(address) {\n const decoded = decodeAddress(address);\n if (decoded.type === 'p2pkh') {\n const hash = Uint8Array.from(decoded.hash);\n return {\n kind: 'p2pkh',\n bytes: encodeP2PKHScriptPubKey(hash),\n hash\n };\n }\n if (decoded.type === 'authscript' || decoded.type === 'pq' || decoded.type === 'ecdsa') {\n // The witness version is part of the destination: a pq1z… / nq1r…\n // payment must be hardcoded with OP_2 / OP_3, never with OP_1.\n const program = Uint8Array.from(decoded.program);\n return {\n kind: decoded.type,\n witnessVersion: decoded.witnessVersion,\n bytes: encodeAuthScriptScriptPubKey(program, decoded.witnessVersion),\n hash: program\n };\n }\n throw new Error(`Unsupported seller address type for \"${address}\"`);\n}\n","/**\n * Asset-transfer wrapper split helper.\n *\n * Neurai asset UTXOs have a scriptPubKey of the form\n *\n * <prefix scriptPubKey bytes> OP_XNA_ASSET <pushdata(payload)> OP_DROP\n *\n * where `prefix` is the recipient's standard script (typically a P2PKH, an\n * AuthScript `OP_1`/`OP_2`/`OP_3` witness program, or a bare covenant such\n * as the partial-fill sell order), and `payload` serializes a `CAssetTransfer`:\n *\n * payload = marker (\"rvn\" 0x72 0x76 0x6e | \"xna\" 0x78 0x6e 0x61)\n * || type_marker (0x74 transfer)\n * || VarStr(assetName)\n * || int64LE(amountRaw)\n * [ || messageRef (optional) || int64LE(expireTime) (optional) ]\n *\n * NIP-040: mainnet still emits the Ravencoin-inherited \"rvn\" marker;\n * testnet/regtest emit \"xna\" after activation. Both are accepted when\n * reading — the detected marker is surfaced on the parsed payload.\n *\n * This helper separates the two halves so consumers can validate the prefix\n * (e.g. feed it to `parsePartialFillScript`) while independently reading the\n * asset data displayed to the user. The optional payload tail\n * (`message` + `expireTime`) is tolerated but not exposed — the first\n * version only needs `assetName` and `amountRaw`.\n *\n * Bare (non-wrapped) scriptPubKeys round-trip through this helper by\n * returning `prefixHex === input` and `assetTransfer === null`.\n */\nimport { bytesToHex, hexToBytes, ensureHex } from './core/bytes.js';\nimport { OP_DROP, OP_PUSHDATA1, OP_PUSHDATA2, OP_PUSHDATA4, OP_XNA_ASSET } from './core/opcodes.js';\nconst ASSET_MAGICS = [\n { marker: 'rvn', bytes: Uint8Array.from([0x72, 0x76, 0x6e]) },\n { marker: 'xna', bytes: Uint8Array.from([0x78, 0x6e, 0x61]) },\n];\nconst TRANSFER_TYPE = 0x74;\n/**\n * Walk the script one opcode at a time, skipping pushdata payload bytes,\n * until either OP_XNA_ASSET is reached at top level or the end of the\n * script. Returns the byte offset of OP_XNA_ASSET, or -1 if not found.\n * Throws on truncated pushdata.\n */\nfunction findTopLevelAssetOpcode(bytes) {\n let i = 0;\n while (i < bytes.length) {\n const op = bytes[i];\n if (op === OP_XNA_ASSET)\n return i;\n // Short direct push: 0x01..0x4b\n if (op >= 0x01 && op <= 0x4b) {\n const len = op;\n const next = i + 1 + len;\n if (next > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: short push of ${len} bytes at offset ${i} exceeds script length`);\n }\n i = next;\n continue;\n }\n if (op === OP_PUSHDATA1) {\n if (i + 1 >= bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: truncated PUSHDATA1 length at offset ${i}`);\n }\n const len = bytes[i + 1];\n const next = i + 2 + len;\n if (next > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: PUSHDATA1 of ${len} bytes at offset ${i} exceeds script length`);\n }\n i = next;\n continue;\n }\n if (op === OP_PUSHDATA2) {\n if (i + 2 >= bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: truncated PUSHDATA2 length at offset ${i}`);\n }\n const len = bytes[i + 1] | (bytes[i + 2] << 8);\n const next = i + 3 + len;\n if (next > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: PUSHDATA2 of ${len} bytes at offset ${i} exceeds script length`);\n }\n i = next;\n continue;\n }\n if (op === OP_PUSHDATA4) {\n if (i + 4 >= bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: truncated PUSHDATA4 length at offset ${i}`);\n }\n const len = (bytes[i + 1] |\n (bytes[i + 2] << 8) |\n (bytes[i + 3] << 16) |\n (bytes[i + 4] << 24)) >>>\n 0;\n const next = i + 5 + len;\n if (next > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: PUSHDATA4 of ${len} bytes at offset ${i} exceeds script length`);\n }\n i = next;\n continue;\n }\n // Any other opcode (including OP_1..OP_16, OP_DUP, OP_HASH160, etc.) is\n // one byte wide in Neurai Script. Advance.\n i += 1;\n }\n return -1;\n}\n/**\n * Read the pushdata element that sits immediately after OP_XNA_ASSET and\n * return its payload bytes together with the cursor position after the\n * element. Only direct pushes (1..75) and PUSHDATA1 are accepted — a\n * well-formed asset transfer payload fits within 75 bytes for the common\n * case and comfortably within 255 bytes even with long names and tails.\n * PUSHDATA2 and PUSHDATA4 would signal a malformed or adversarial wrapper.\n */\nfunction readPayloadPush(bytes, start) {\n if (start >= bytes.length) {\n throw new Error('splitAssetWrappedScriptPubKey: truncated wrapper — missing payload push');\n }\n const op = bytes[start];\n if (op >= 0x01 && op <= 0x4b) {\n const len = op;\n const dataStart = start + 1;\n const dataEnd = dataStart + len;\n if (dataEnd > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload short push of ${len} bytes exceeds script length`);\n }\n return { payload: bytes.slice(dataStart, dataEnd), after: dataEnd };\n }\n if (op === OP_PUSHDATA1) {\n if (start + 1 >= bytes.length) {\n throw new Error('splitAssetWrappedScriptPubKey: truncated PUSHDATA1 in asset payload');\n }\n const len = bytes[start + 1];\n const dataStart = start + 2;\n const dataEnd = dataStart + len;\n if (dataEnd > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload PUSHDATA1 of ${len} bytes exceeds script length`);\n }\n return { payload: bytes.slice(dataStart, dataEnd), after: dataEnd };\n }\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload push opcode 0x${op.toString(16)} not accepted (expected 0x01..0x4b or PUSHDATA1)`);\n}\nfunction detectAssetMarker(payload) {\n for (const { marker, bytes } of ASSET_MAGICS) {\n if (payload[0] === bytes[0] && payload[1] === bytes[1] && payload[2] === bytes[2]) {\n return marker;\n }\n }\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload magic mismatch — expected \"rvn\" or \"xna\" got 0x${payload[0].toString(16)} 0x${payload[1].toString(16)} 0x${payload[2].toString(16)}`);\n}\nfunction parseAssetTransferPayload(payload) {\n if (payload.length < 4 + 1 + 8) {\n // 4 magic+type, 1 varstr length, 8 int64LE amount\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload of ${payload.length} bytes is too short`);\n }\n const marker = detectAssetMarker(payload);\n if (payload[3] !== TRANSFER_TYPE) {\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload type marker 0x${payload[3].toString(16)} is not a transfer (0x74)`);\n }\n const nameLen = payload[4];\n const nameStart = 5;\n const nameEnd = nameStart + nameLen;\n if (nameEnd + 8 > payload.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload truncated — name length ${nameLen} does not leave room for amount`);\n }\n let assetName = '';\n for (let i = nameStart; i < nameEnd; i += 1) {\n assetName += String.fromCharCode(payload[i]);\n }\n let amountRaw = 0n;\n for (let i = 0; i < 8; i += 1) {\n amountRaw |= BigInt(payload[nameEnd + i]) << BigInt(8 * i);\n }\n // Any bytes after nameEnd + 8 form the optional tail (message +\n // expireTime). We intentionally ignore them in this first version; the\n // raw payload remains available via `payloadHex` if a consumer later\n // needs to inspect them.\n return { assetName, amountRaw, marker };\n}\n/**\n * Parse an asset-transfer-wrapped scriptPubKey. Accepts both wrapped and\n * bare forms. Throws on structural malformation (truncated pushdata,\n * missing OP_DROP after payload, bad magic, unsupported pushdata width).\n */\nexport function splitAssetWrappedScriptPubKey(spkHex) {\n const normalized = ensureHex(spkHex, 'scriptPubKey');\n const bytes = hexToBytes(normalized);\n const assetOpAt = findTopLevelAssetOpcode(bytes);\n if (assetOpAt < 0) {\n return { prefixHex: normalized, assetTransfer: null };\n }\n const prefix = bytes.slice(0, assetOpAt);\n const { payload, after } = readPayloadPush(bytes, assetOpAt + 1);\n if (after >= bytes.length) {\n throw new Error('splitAssetWrappedScriptPubKey: asset wrapper missing trailing OP_DROP');\n }\n if (bytes[after] !== OP_DROP) {\n throw new Error(`splitAssetWrappedScriptPubKey: expected OP_DROP at offset ${after}, got 0x${bytes[after].toString(16)}`);\n }\n if (after + 1 !== bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: ${bytes.length - after - 1} trailing bytes after OP_DROP`);\n }\n const { assetName, amountRaw, marker } = parseAssetTransferPayload(payload);\n return {\n prefixHex: bytesToHex(prefix),\n assetTransfer: {\n assetName,\n amountRaw,\n marker,\n payloadHex: bytesToHex(payload),\n },\n };\n}\n","/**\n * Shared parsing primitives for strict covenant parsers. Each covenant\n * parser walks the exact byte layout emitted by its builder and fails on\n * any deviation; the primitives here centralize the cursor arithmetic,\n * pushdata decoding, and CScriptNum decoding so the legacy and PQ parsers\n * (and future covenant parsers) cannot drift in rigor.\n */\nimport { OP_1 } from './opcodes.js';\nexport function makeCursor(bytes) {\n return { bytes, pos: 0 };\n}\n/** Consume one byte and verify it equals `expected`. */\nexport function expectByte(c, expected, label) {\n if (c.pos >= c.bytes.length) {\n throw new Error(`parse: unexpected end of script while reading ${label}`);\n }\n const got = c.bytes[c.pos];\n if (got !== expected) {\n throw new Error(`parse: expected ${label} = 0x${expected.toString(16)} at offset ${c.pos}, got 0x${got.toString(16)}`);\n }\n c.pos += 1;\n}\n/** Fail if the cursor has not consumed every byte of the script. */\nexport function assertTrailing(c) {\n if (c.pos !== c.bytes.length) {\n throw new Error(`parse: ${c.bytes.length - c.pos} trailing bytes after end of script`);\n }\n}\n/**\n * Read one pushdata element from the cursor. Supports direct pushes\n * (1..75 bytes), `OP_PUSHDATA1` and `OP_PUSHDATA2`. `OP_PUSHDATA4` is not\n * supported by any current covenant script and would overflow the\n * per-element cap anyway. Truncation is checked for all length fields\n * and payload ranges.\n */\nexport function readPush(c, label) {\n if (c.pos >= c.bytes.length) {\n throw new Error(`parse: unexpected end of script while reading push for ${label}`);\n }\n const opcode = c.bytes[c.pos];\n c.pos += 1;\n // Short direct push: 1..75 bytes\n if (opcode >= 0x01 && opcode <= 0x4b) {\n const len = opcode;\n if (c.pos + len > c.bytes.length) {\n throw new Error(`parse: short push of ${len} bytes exceeds script length at ${label}`);\n }\n const data = c.bytes.slice(c.pos, c.pos + len);\n c.pos += len;\n return data;\n }\n // OP_PUSHDATA1\n if (opcode === 0x4c) {\n if (c.pos >= c.bytes.length) {\n throw new Error(`parse: truncated PUSHDATA1 length at ${label}`);\n }\n const len = c.bytes[c.pos];\n c.pos += 1;\n if (c.pos + len > c.bytes.length) {\n throw new Error(`parse: PUSHDATA1 of ${len} bytes exceeds script length at ${label}`);\n }\n const data = c.bytes.slice(c.pos, c.pos + len);\n c.pos += len;\n return data;\n }\n // OP_PUSHDATA2\n if (opcode === 0x4d) {\n if (c.pos + 2 > c.bytes.length) {\n throw new Error(`parse: truncated PUSHDATA2 length at ${label}`);\n }\n const len = c.bytes[c.pos] | (c.bytes[c.pos + 1] << 8);\n c.pos += 2;\n if (c.pos + len > c.bytes.length) {\n throw new Error(`parse: PUSHDATA2 of ${len} bytes exceeds script length at ${label}`);\n }\n const data = c.bytes.slice(c.pos, c.pos + len);\n c.pos += len;\n return data;\n }\n throw new Error(`parse: expected a pushdata opcode at ${label}, got 0x${opcode.toString(16)} at offset ${c.pos - 1}`);\n}\n/**\n * Decode a `CScriptNum` byte vector (little-endian sign-magnitude, up to\n * 8 bytes) into a BigInt. Empty vector encodes 0.\n */\nexport function decodeScriptNum(data, label) {\n if (data.length === 0)\n return 0n;\n if (data.length > 8) {\n throw new Error(`parse: CScriptNum at ${label} exceeds 8 bytes`);\n }\n let n = 0n;\n for (let i = 0; i < data.length - 1; i += 1) {\n n |= BigInt(data[i]) << BigInt(8 * i);\n }\n const last = data[data.length - 1];\n n |= BigInt(last & 0x7f) << BigInt(8 * (data.length - 1));\n if (last & 0x80) {\n n = -n;\n }\n return n;\n}\n/**\n * Read a push as a non-negative CScriptNum. Recognises OP_1..OP_16\n * shorthand. `OP_0` is not accepted because the covenant callers use this\n * only for values that are strictly positive (prices, selectors, indices).\n */\nexport function readPushPositiveInt(c, label) {\n if (c.pos >= c.bytes.length) {\n throw new Error(`parse: end of script at ${label}`);\n }\n const opcode = c.bytes[c.pos];\n if (opcode >= OP_1 && opcode <= 0x60) {\n c.pos += 1;\n return BigInt(opcode - OP_1 + 1);\n }\n const data = readPush(c, label);\n return decodeScriptNum(data, label);\n}\n/**\n * Read a one-byte unsigned selector. This accepts OP_1..OP_16 shorthand\n * and a raw one-byte push for scripts that permit either form. NIP-042\n * TXHASH masks use a separate strict two-byte parser.\n */\nexport function readPushUint8(c, label) {\n if (c.pos >= c.bytes.length) {\n throw new Error(`parse: end of script at ${label}`);\n }\n const opcode = c.bytes[c.pos];\n if (opcode >= OP_1 && opcode <= 0x60) {\n c.pos += 1;\n return opcode - OP_1 + 1;\n }\n const data = readPush(c, label);\n if (data.length !== 1) {\n throw new Error(`parse: ${label} must be a single-byte push, got ${data.length} bytes`);\n }\n return data[0];\n}\n","import { CHAINCONTEXT_HEIGHT, CHAINCONTEXT_MTP, OP_CHAINCONTEXT, OP_GREATERTHAN, OP_VERIFY } from '../../core/opcodes.js';\nimport { expectByte, readPushPositiveInt, readPushUint8 } from '../../core/script-parser.js';\nconst MAX_INT64 = 0x7fffffffffffffffn;\nfunction selectorForMode(mode) {\n if (mode === 'height')\n return CHAINCONTEXT_HEIGHT;\n if (mode === 'mtp')\n return CHAINCONTEXT_MTP;\n throw new Error('expiration.mode must be \"height\" or \"mtp\"');\n}\nfunction modeForSelector(selector) {\n if (selector === CHAINCONTEXT_HEIGHT)\n return 'height';\n if (selector === CHAINCONTEXT_MTP)\n return 'mtp';\n throw new Error('expiration OP_CHAINCONTEXT selector must be HEIGHT (0x01) or MTP (0x02)');\n}\nexport function assertExpiration(expiration) {\n if (expiration === undefined)\n return undefined;\n if (expiration === null || typeof expiration !== 'object') {\n throw new Error('expiration must be an object');\n }\n selectorForMode(expiration.mode);\n if (typeof expiration.value !== 'bigint') {\n throw new Error('expiration.value must be a bigint');\n }\n if (expiration.value <= 0n) {\n throw new Error('expiration.value must be > 0');\n }\n if (expiration.value > MAX_INT64) {\n throw new Error('expiration.value exceeds int64 range');\n }\n return expiration;\n}\nexport function appendExpirationGate(b, expiration) {\n if (!expiration)\n return;\n // Selectors 1 (HEIGHT) and 2 (MTP) must be pushed as OP_1 / OP_2 so the\n // resulting script is consensus-minimal (MINIMALDATA). `pushBytes(0x01 N)`\n // would emit `01 0N`, which the consensus rule rejects for N in 1..16.\n // Parser side stays lenient (`readPushUint8` accepts both forms) so old\n // covenants in the raw `01 0N` form keep round-tripping.\n b.pushInt(expiration.value)\n .pushInt(selectorForMode(expiration.mode))\n .op(OP_CHAINCONTEXT, OP_GREATERTHAN, OP_VERIFY);\n}\nexport function readOptionalExpirationGate(c, nextOpcodeWithoutGate, label) {\n if (c.pos >= c.bytes.length || c.bytes[c.pos] === nextOpcodeWithoutGate) {\n return undefined;\n }\n const value = readPushPositiveInt(c, `expiration value (${label})`);\n if (value <= 0n) {\n throw new Error(`parse: expiration value (${label}) must be > 0`);\n }\n const selector = readPushUint8(c, `expiration selector (${label})`);\n const mode = modeForSelector(selector);\n expectByte(c, OP_CHAINCONTEXT, `OP_CHAINCONTEXT (${label})`);\n expectByte(c, OP_GREATERTHAN, `OP_GREATERTHAN (${label})`);\n expectByte(c, OP_VERIFY, `OP_VERIFY (${label})`);\n return { mode, value };\n}\nexport function assertSameExpiration(a, b, label) {\n if (a === undefined && b === undefined)\n return;\n if (a === undefined || b === undefined || a.mode !== b.mode || a.value !== b.value) {\n throw new Error(`parse: expiration differs between ${label}`);\n }\n}\n","/**\n * Buyer fill branches shared by both Partial-Fill Sell Order variants\n * (ECDSA cancel in `./script.ts`, ML-DSA-44 cancel in `./script-pq.ts`).\n * The variants only differ in their cancel branch; everything after the\n * outer `OP_ELSE` is emitted and parsed here.\n *\n * Input-0 binding. The fill branches read the order's asset amount with\n * `<0> OP_INPUTASSETFIELD` and constrain outputs 0..2 by fixed index. Input\n * indices are absolute and Script cannot ask for the index of the input\n * being evaluated, so without a binding a buyer could:\n * - put a foreign asset UTXO at input 0 and the order at input 1: the\n * order then prices the fill by the foreign amount and the rest of the\n * order leaves through an unconstrained output;\n * - spend several identical orders together, every one of them satisfied\n * by the same payment output.\n * The fill block therefore opens with\n *\n * <0x80 0x00> OP_TXHASH <INPUT_ZERO_TXHASH> OP_EQUALVERIFY\n *\n * NIP-042 mask 0x0080 commits only to the index of the input being\n * evaluated, so the digest equals the constant exactly when this covenant\n * is spent as input 0. At most one order per transaction can take a fill\n * branch; the seller's cancel branch is not bound.\n *\n * Layout (after the variant's `OP_IF <cancel> OP_ELSE`):\n *\n * <0x80 0x00> OP_TXHASH <INPUT_ZERO_TXHASH> OP_EQUALVERIFY\n * OP_IF ← full fill, unlock <1> <0>\n * [expiration gate]\n * <0> <2> OP_INPUTASSETFIELD (N = order amount)\n * DUP <price> MUL <0> OUTPUTVALUE SWAP GE VERIFY (payment value)\n * <0> OUTPUTSCRIPT <paymentSpk> EQUALVERIFY (payment destination)\n * DUP <1> <2> OUTPUTASSETFIELD EQUALVERIFY (buyer amount == N)\n * <1> <1> OUTPUTASSETFIELD <tokenId> EQUALVERIFY (buyer asset name)\n * DROP <1>\n * OP_ELSE ← partial fill, unlock <N> <0> <0>\n * [expiration gate]\n * payment value, payment destination, buyer amount, buyer name (as above)\n * <2> OUTPUTAUTHCOMMITMENT <2> TXFIELD EQUALVERIFY (continuation, NIP-023)\n * <2> <1> OUTPUTASSETFIELD <tokenId> EQUALVERIFY (continuation name)\n * <2> <2> OUTPUTASSETFIELD OVER <0> <2> INPUTASSETFIELD SWAP SUB EQUALVERIFY\n * DROP <1>\n * OP_ENDIF\n */\nimport { bytesEqual, hexToBytes } from '../../core/bytes.js';\nimport { ASSETFIELD_AMOUNT, ASSETFIELD_NAME, OP_0, OP_1, OP_2, OP_DROP, OP_DUP, OP_ELSE, OP_ENDIF, OP_EQUALVERIFY, OP_GREATERTHANOREQUAL, OP_IF, OP_INPUTASSETFIELD, OP_MUL, OP_OUTPUTASSETFIELD, OP_OUTPUTAUTHCOMMITMENT, OP_OUTPUTSCRIPT, OP_OUTPUTVALUE, OP_OVER, OP_SUB, OP_SWAP, OP_TXFIELD, OP_TXHASH, OP_VERIFY, TXFIELD_AUTHSCRIPT_COMMITMENT, TXHASH_CURRENT_INDEX } from '../../core/opcodes.js';\nimport { expectByte, readPush, readPushPositiveInt } from '../../core/script-parser.js';\nimport { appendExpirationGate, assertSameExpiration, readOptionalExpirationGate } from './expiration.js';\n/** NIP-042 mask (two bytes, little-endian) selecting only the current input index. */\nexport const INPUT_INDEX_TXHASH_SELECTOR = Uint8Array.of(TXHASH_CURRENT_INDEX, 0x00);\n/**\n * `OP_TXHASH(0x0080)` evaluated at input 0:\n * `SHA256(tag || tag || 80 00 || 00 00 00 00)` with `tag = SHA256(\"NeuraiTxHash\")`.\n */\nexport const INPUT_ZERO_TXHASH = hexToBytes('419632cabaf8bb70b96a8c92c4601a9c2ba11e96841daebc9d98f4835eeb0e36');\nfunction appendPaymentAndBuyerChecks(b, p) {\n // output[0].value >= N * unitPriceSats [ N ]\n b.op(OP_DUP)\n .pushInt(p.unitPriceSats)\n .op(OP_MUL)\n .pushInt(0)\n .op(OP_OUTPUTVALUE)\n .op(OP_SWAP)\n .op(OP_GREATERTHANOREQUAL)\n .op(OP_VERIFY);\n // output[0].scriptPubKey == paymentScriptPubKey [ N ]\n b.pushInt(0)\n .op(OP_OUTPUTSCRIPT)\n .pushBytes(p.paymentScriptPubKey)\n .op(OP_EQUALVERIFY);\n // output[1].asset.amount == N [ N ]\n b.op(OP_DUP)\n .pushInt(1)\n .pushInt(ASSETFIELD_AMOUNT)\n .op(OP_OUTPUTASSETFIELD)\n .op(OP_EQUALVERIFY);\n // output[1].asset.name == tokenId [ N ]\n b.pushInt(1)\n .pushInt(ASSETFIELD_NAME)\n .op(OP_OUTPUTASSETFIELD)\n .pushBytes(p.tokenIdBytes)\n .op(OP_EQUALVERIFY);\n}\n/** Emit the input-0 binding and both fill branches, ending with the inner `OP_ENDIF`. */\nexport function appendFillBranches(b, p) {\n b.pushBytes(INPUT_INDEX_TXHASH_SELECTOR)\n .op(OP_TXHASH)\n .pushBytes(INPUT_ZERO_TXHASH)\n .op(OP_EQUALVERIFY);\n // ──────── Full fill: N is the whole order, no continuation ────────\n b.op(OP_IF);\n appendExpirationGate(b, p.expiration);\n b.pushInt(0)\n .pushInt(ASSETFIELD_AMOUNT)\n .op(OP_INPUTASSETFIELD); // [ N ]\n appendPaymentAndBuyerChecks(b, p);\n b.op(OP_DROP).pushInt(1);\n // ──────── Partial fill: buyer pushes N, remainder continues at output 2 ────────\n b.op(OP_ELSE);\n appendExpirationGate(b, p.expiration);\n appendPaymentAndBuyerChecks(b, p);\n // Continuation keeps the spent order's AuthScript commitment (NIP-023).\n b.pushInt(2)\n .op(OP_OUTPUTAUTHCOMMITMENT)\n .pushInt(TXFIELD_AUTHSCRIPT_COMMITMENT)\n .op(OP_TXFIELD)\n .op(OP_EQUALVERIFY);\n b.pushInt(2)\n .pushInt(ASSETFIELD_NAME)\n .op(OP_OUTPUTASSETFIELD)\n .pushBytes(p.tokenIdBytes)\n .op(OP_EQUALVERIFY);\n // output[2].asset.amount == orderAmount - N\n b.pushInt(2)\n .pushInt(ASSETFIELD_AMOUNT)\n .op(OP_OUTPUTASSETFIELD) // [ N, rem ]\n .op(OP_OVER) // [ N, rem, N ]\n .pushInt(0)\n .pushInt(ASSETFIELD_AMOUNT)\n .op(OP_INPUTASSETFIELD) // [ N, rem, N, in ]\n .op(OP_SWAP) // [ N, rem, in, N ]\n .op(OP_SUB) // [ N, rem, in - N ]\n .op(OP_EQUALVERIFY);\n b.op(OP_DROP).pushInt(1);\n b.op(OP_ENDIF);\n}\nfunction readPaymentAndBuyerChecks(c, label) {\n expectByte(c, OP_DUP, `OP_DUP (price, ${label})`);\n const unitPriceSats = readPushPositiveInt(c, `unitPriceSats (${label})`);\n expectByte(c, OP_MUL, `OP_MUL (${label})`);\n expectByte(c, OP_0, `OP_0 (payment idx, ${label})`);\n expectByte(c, OP_OUTPUTVALUE, `OP_OUTPUTVALUE (${label})`);\n expectByte(c, OP_SWAP, `OP_SWAP (${label})`);\n expectByte(c, OP_GREATERTHANOREQUAL, `OP_GREATERTHANOREQUAL (${label})`);\n expectByte(c, OP_VERIFY, `OP_VERIFY (payment, ${label})`);\n expectByte(c, OP_0, `OP_0 (spk idx, ${label})`);\n expectByte(c, OP_OUTPUTSCRIPT, `OP_OUTPUTSCRIPT (${label})`);\n const paymentScriptPubKey = readPush(c, `paymentScriptPubKey (${label})`);\n expectByte(c, OP_EQUALVERIFY, `OP_EQUALVERIFY (payment spk, ${label})`);\n expectByte(c, OP_DUP, `OP_DUP (buyer amount, ${label})`);\n expectByte(c, OP_1, `OP_1 (buyer idx, ${label})`);\n expectByte(c, OP_2, `OP_2 (AMOUNT sel, ${label})`);\n expectByte(c, OP_OUTPUTASSETFIELD, `OP_OUTPUTASSETFIELD (buyer amount, ${label})`);\n expectByte(c, OP_EQUALVERIFY, `OP_EQUALVERIFY (buyer amount, ${label})`);\n expectByte(c, OP_1, `OP_1 (buyer idx, ${label})`);\n expectByte(c, OP_1, `OP_1 (NAME sel, ${label})`);\n expectByte(c, OP_OUTPUTASSETFIELD, `OP_OUTPUTASSETFIELD (buyer name, ${label})`);\n const tokenId = readPush(c, `tokenId (${label})`);\n expectByte(c, OP_EQUALVERIFY, `OP_EQUALVERIFY (buyer name, ${label})`);\n return { unitPriceSats, paymentScriptPubKey, tokenId };\n}\n/**\n * Parse what `appendFillBranches` emits. Both branches must agree on price,\n * payment destination, tokenId and expiration; any deviation throws.\n */\nexport function readFillBranches(c) {\n const selector = readPush(c, 'input-0 binding selector');\n if (!bytesEqual(selector, INPUT_INDEX_TXHASH_SELECTOR)) {\n throw new Error('parse: fill branches must open with the input-0 binding <0x8000> OP_TXHASH (covenants without it ' +\n 'can be drained through a foreign input 0 and are not supported)');\n }\n expectByte(c, OP_TXHASH, 'OP_TXHASH (input-0 binding)');\n const digest = readPush(c, 'input-0 binding digest');\n if (!bytesEqual(digest, INPUT_ZERO_TXHASH)) {\n throw new Error('parse: input-0 binding digest is not OP_TXHASH(0x0080) at input 0');\n }\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (input-0 binding)');\n // ═════ Full fill ═════\n expectByte(c, OP_IF, 'OP_IF (full fill)');\n const expirationFull = readOptionalExpirationGate(c, OP_0, 'full');\n expectByte(c, OP_0, 'OP_0 (input idx, full)');\n expectByte(c, OP_2, 'OP_2 (AMOUNT sel, full)');\n expectByte(c, OP_INPUTASSETFIELD, 'OP_INPUTASSETFIELD (full)');\n const full = readPaymentAndBuyerChecks(c, 'full');\n expectByte(c, OP_DROP, 'OP_DROP (full)');\n expectByte(c, OP_1, 'OP_1 (true, full)');\n // ═════ Partial fill ═════\n expectByte(c, OP_ELSE, 'OP_ELSE (partial fill)');\n const expirationPartial = readOptionalExpirationGate(c, OP_DUP, 'partial');\n const partial = readPaymentAndBuyerChecks(c, 'partial');\n expectByte(c, OP_2, 'OP_2 (remainder idx)');\n expectByte(c, OP_OUTPUTAUTHCOMMITMENT, 'OP_OUTPUTAUTHCOMMITMENT (remainder)');\n expectByte(c, OP_2, 'OP_2 (TXFIELD sel: AUTHSCRIPT_COMMITMENT)');\n expectByte(c, OP_TXFIELD, 'OP_TXFIELD');\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (remainder auth)');\n expectByte(c, OP_2, 'OP_2 (remainder idx)');\n expectByte(c, OP_1, 'OP_1 (NAME sel)');\n expectByte(c, OP_OUTPUTASSETFIELD, 'OP_OUTPUTASSETFIELD (remainder name)');\n const remainderTokenId = readPush(c, 'tokenId (remainder)');\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (remainder name)');\n expectByte(c, OP_2, 'OP_2 (remainder idx)');\n expectByte(c, OP_2, 'OP_2 (AMOUNT sel)');\n expectByte(c, OP_OUTPUTASSETFIELD, 'OP_OUTPUTASSETFIELD (remainder amount)');\n expectByte(c, OP_OVER, 'OP_OVER');\n expectByte(c, OP_0, 'OP_0 (input idx)');\n expectByte(c, OP_2, 'OP_2 (AMOUNT sel)');\n expectByte(c, OP_INPUTASSETFIELD, 'OP_INPUTASSETFIELD');\n expectByte(c, OP_SWAP, 'OP_SWAP');\n expectByte(c, OP_SUB, 'OP_SUB');\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (remainder amount)');\n expectByte(c, OP_DROP, 'OP_DROP (partial)');\n expectByte(c, OP_1, 'OP_1 (true, partial)');\n expectByte(c, OP_ENDIF, 'OP_ENDIF (fill branches)');\n if (!bytesEqual(full.tokenId, partial.tokenId) || !bytesEqual(partial.tokenId, remainderTokenId)) {\n throw new Error('parse: tokenId differs between the fill checks');\n }\n if (full.unitPriceSats !== partial.unitPriceSats) {\n throw new Error('parse: unitPriceSats differs between full-fill and partial-fill branches');\n }\n if (!bytesEqual(full.paymentScriptPubKey, partial.paymentScriptPubKey)) {\n throw new Error('parse: payment scriptPubKey differs between full-fill and partial-fill branches');\n }\n assertSameExpiration(expirationFull, expirationPartial, 'full-fill and partial-fill branches');\n return {\n paymentScriptPubKey: full.paymentScriptPubKey,\n tokenId: new TextDecoder('utf-8', { fatal: true }).decode(full.tokenId),\n unitPriceSats: full.unitPriceSats,\n expiration: expirationFull\n };\n}\n","/**\n * Partial-Fill Sell Order covenant script (three-branch), ECDSA cancel.\n *\n * The covenant has three branches selected by the top of the unlock stack:\n *\n * OP_IF ← Cancel: seller signs, recovers remainder.\n * OP_ELSE OP_IF ← Full fill: buyer drains the covenant entirely.\n * No continuation output is required.\n * OP_ELSE OP_ELSE ← Partial fill: buyer takes N < total. A\n * continuation UTXO at vout[2] preserves the\n * covenant with amount = total - N.\n *\n * Output layout:\n *\n * output[0] = XNA payment to seller (value >= N * unitPriceSats)\n * output[1] = asset to buyer (tokenId, amount == N)\n * output[2] = covenant continuation (only for partial fill;\n * same AuthScript commitment,\n * amount == inputAmount - N)\n * output[3+] = optional buyer change (not constrained by the covenant)\n *\n * The order must be input 0 for either fill branch to succeed: see the\n * input-0 binding in `./fill-branches.ts`.\n *\n * Unlock stack shapes (scriptSig pushes, top → bottom):\n *\n * Cancel: <sig> <pubkey> <1>\n * Full fill: <1> <0> (full-flag=1, cancel-flag=0)\n * Partial fill: <N> <0> <0> (N, full-flag=0, cancel-flag=0)\n *\n * The cancel branch uses classical ECDSA (`OP_HASH160 + OP_CHECKSIG`)\n * against a 20-byte key hash. The payment destination is independent of\n * that key: a legacy P2PKH seller passes `sellerAddress` (both at once),\n * any other seller with a secp256k1 key — typically a strict ECDSA v3\n * `nq1r…` wallet — passes `paymentAddress` and `sellerPubKeyHash`. For\n * post-quantum cancellation use `buildPartialFillScriptPQ`.\n */\nimport { decodeAddress } from '@neuraiproject/neurai-create-transaction';\nimport { bytesToHex } from '../../core/bytes.js';\nimport { encodeSellerScriptPubKey } from '../../address.js';\nimport { encodeP2PKHScriptPubKey } from '../../standard/p2pkh.js';\nimport { OP_CHECKSIG, OP_DUP, OP_ELSE, OP_ENDIF, OP_EQUALVERIFY, OP_HASH160, OP_IF } from '../../core/opcodes.js';\nimport { ScriptBuilder } from '../../core/script-builder.js';\nimport { assertExpiration } from './expiration.js';\nimport { appendFillBranches } from './fill-branches.js';\nexport { encodeP2PKHScriptPubKey } from '../../standard/p2pkh.js';\nconst ASSET_NAME_MAX = 32;\nfunction decodeSellerAddress(sellerAddress) {\n if (typeof sellerAddress !== 'string' || sellerAddress.length === 0) {\n throw new Error('sellerAddress is required');\n }\n const decoded = decodeAddress(sellerAddress);\n if (decoded.type !== 'p2pkh') {\n throw new Error(`sellerAddress must be a legacy P2PKH address; got ${decoded.type}. A seller with another address ` +\n `type passes paymentAddress and sellerPubKeyHash, or uses buildPartialFillScriptPQ for a PQ key.`);\n }\n const pkh = Uint8Array.from(decoded.hash);\n if (pkh.length !== 20) {\n throw new Error(`decoded sellerAddress produced a ${pkh.length}-byte hash, expected 20`);\n }\n return pkh;\n}\n/** Cancel key hash and payment scriptPubKey from either form of seller params. */\nfunction resolveSeller(params) {\n const { sellerAddress, paymentAddress, sellerPubKeyHash } = params;\n if (sellerAddress !== undefined) {\n if (paymentAddress !== undefined || sellerPubKeyHash !== undefined) {\n throw new Error('pass either sellerAddress, or paymentAddress with sellerPubKeyHash, not both');\n }\n const pkh = decodeSellerAddress(sellerAddress);\n return { sellerPubKeyHash: pkh, paymentScriptPubKey: encodeP2PKHScriptPubKey(pkh) };\n }\n if (paymentAddress === undefined || sellerPubKeyHash === undefined) {\n throw new Error('sellerAddress, or paymentAddress with sellerPubKeyHash, is required');\n }\n if (!(sellerPubKeyHash instanceof Uint8Array) || sellerPubKeyHash.length !== 20) {\n throw new Error('sellerPubKeyHash must be a 20-byte Uint8Array (HASH160 of the compressed public key)');\n }\n return {\n sellerPubKeyHash: Uint8Array.from(sellerPubKeyHash),\n paymentScriptPubKey: encodeSellerScriptPubKey(paymentAddress).bytes\n };\n}\nfunction assertTokenId(tokenId) {\n if (typeof tokenId !== 'string' || tokenId.length === 0) {\n throw new Error('tokenId is required');\n }\n if (!/^[A-Z0-9._]+$/.test(tokenId)) {\n throw new Error(`tokenId \"${tokenId}\" is not a valid Neurai asset name`);\n }\n if (tokenId.length > ASSET_NAME_MAX) {\n throw new Error(`tokenId exceeds ${ASSET_NAME_MAX} bytes`);\n }\n}\nfunction assertPrice(priceSats) {\n if (typeof priceSats !== 'bigint') {\n throw new Error('unitPriceSats must be a bigint (satoshis per indivisible unit)');\n }\n if (priceSats <= 0n) {\n throw new Error('unitPriceSats must be > 0');\n }\n if (priceSats > 0x7fffffffffffffffn) {\n throw new Error('unitPriceSats exceeds int64 range');\n }\n}\n/**\n * Build the `scriptPubKey` of a Partial-Fill Sell Order covenant UTXO.\n * Returns raw bytes; wrap with `bytesToHex` for wire format.\n */\nexport function buildPartialFillScript(params) {\n const { tokenId, unitPriceSats } = params;\n const { sellerPubKeyHash, paymentScriptPubKey } = resolveSeller(params);\n assertTokenId(tokenId);\n assertPrice(unitPriceSats);\n const expiration = assertExpiration(params.expiration);\n const b = new ScriptBuilder();\n // ════════ Cancel branch (outer IF) ════════\n // scriptSig: <sig> <pubkey> <1>\n b.op(OP_IF)\n .op(OP_DUP, OP_HASH160)\n .pushBytes(sellerPubKeyHash)\n .op(OP_EQUALVERIFY, OP_CHECKSIG)\n .op(OP_ELSE);\n // ════════ Fill branches (outer ELSE) ════════\n appendFillBranches(b, {\n paymentScriptPubKey,\n tokenIdBytes: new TextEncoder().encode(tokenId),\n unitPriceSats,\n expiration\n });\n b.op(OP_ENDIF); // closes outer cancel/fill IF\n return b.build();\n}\n/** Hex convenience wrapper for `buildPartialFillScript`. */\nexport function buildPartialFillScriptHex(params) {\n return bytesToHex(buildPartialFillScript(params));\n}\n// Re-export atomic helpers so parse.ts and callers can reuse them.\nexport { pushBytes, pushInt } from '../../core/script-builder.js';\n","/**\n * PQ (post-quantum) variant of the Partial-Fill Sell Order covenant.\n *\n * Identical fill branches (full + partial) to the legacy covenant, but the\n * **cancel** branch accepts an ML-DSA-44 signature instead of an ECDSA one.\n * This requires:\n * - `SCRIPT_VERIFY_CHECKSIGFROMSTACK` (for OP_CSFS) active\n * - `SCRIPT_VERIFY_TXHASH` (for OP_TXHASH) active\n * - NIP-18 (`MAX_PQ_SCRIPT_ELEMENT_SIZE = 3072`) active, so the ~2.4 KB\n * signature and ~1.3 KB pubkey can be pushed to the script stack\n *\n * All three are active on DePIN-Test testnet.\n *\n * Cancel-branch flow (scriptSig pushes `<sig> <pubkey> OP_1`):\n *\n * 1. OP_DUP OP_SHA256 <commitment> OP_EQUALVERIFY → pubkey matches\n * 2. <selector> OP_TXHASH → message = H(tx)\n * 3. OP_SWAP OP_CHECKSIGFROMSTACK → CSFS verifies sig\n *\n * The message that gets signed is **SHA256(OP_TXHASH(selector))** — CSFS\n * single-SHA256s its message argument before verification, and OP_TXHASH\n * produces its own 32-byte NIP-042 tagged hash, so the seller computes:\n * `sign(pqSeckey, SHA256(TaggedHash(\"NeuraiTxHash\", mask || selected_tx_fields)))`\n *\n * The fill branches, including the input-0 binding, are shared with the\n * ECDSA variant — see `./fill-branches.ts`.\n */\nimport { bytesToHex } from '../../core/bytes.js';\nimport { encodeSellerScriptPubKey } from '../../address.js';\nimport { OP_CHECKSIGFROMSTACK, OP_DUP, OP_ELSE, OP_ENDIF, OP_EQUALVERIFY, OP_IF, OP_SHA256, OP_SWAP, OP_TXHASH } from '../../core/opcodes.js';\nimport { ScriptBuilder } from '../../core/script-builder.js';\nimport { assertExpiration } from './expiration.js';\nimport { appendFillBranches } from './fill-branches.js';\nconst ASSET_NAME_MAX = 32;\nexport const DEFAULT_PQ_TXHASH_SELECTOR = 0x1ff;\nfunction assertCommitment(commitment) {\n if (!(commitment instanceof Uint8Array) || commitment.length !== 32) {\n throw new Error('pubKeyCommitment must be a 32-byte Uint8Array (SHA256 of pubKey)');\n }\n}\nfunction assertTokenId(tokenId) {\n if (typeof tokenId !== 'string' || tokenId.length === 0) {\n throw new Error('tokenId is required');\n }\n if (!/^[A-Z0-9._]+$/.test(tokenId)) {\n throw new Error(`tokenId \"${tokenId}\" is not a valid Neurai asset name`);\n }\n if (tokenId.length > ASSET_NAME_MAX) {\n throw new Error(`tokenId exceeds ${ASSET_NAME_MAX} bytes`);\n }\n}\nfunction assertPrice(priceSats) {\n if (typeof priceSats !== 'bigint') {\n throw new Error('unitPriceSats must be a bigint');\n }\n if (priceSats <= 0n) {\n throw new Error('unitPriceSats must be > 0');\n }\n if (priceSats > 0x7fffffffffffffffn) {\n throw new Error('unitPriceSats exceeds int64 range');\n }\n}\nfunction assertSelector(selector) {\n if (!Number.isInteger(selector) || selector < 0 || selector > 0x1ff) {\n throw new Error('txHashSelector must be in the NIP-042 range (0x001..0x1ff)');\n }\n if (selector === 0) {\n throw new Error('txHashSelector 0x000 is rejected by OP_TXHASH');\n }\n}\n/**\n * Build the scriptPubKey of a PQ Partial-Fill Sell Order covenant UTXO.\n */\nexport function buildPartialFillScriptPQ(params) {\n const { paymentAddress, pubKeyCommitment, tokenId, unitPriceSats, txHashSelector = DEFAULT_PQ_TXHASH_SELECTOR } = params;\n assertCommitment(pubKeyCommitment);\n assertTokenId(tokenId);\n assertPrice(unitPriceSats);\n assertSelector(txHashSelector);\n const expiration = assertExpiration(params.expiration);\n const payment = encodeSellerScriptPubKey(paymentAddress);\n const tokenIdBytes = new TextEncoder().encode(tokenId);\n const b = new ScriptBuilder();\n // ════════ Cancel branch (PQ via OP_CHECKSIGFROMSTACK) ════════\n // scriptSig: <sigPQ> <pubKeyPQ> <1>\n // After OP_IF consumes the flag: [ sig, pubKey ]\n //\n // NIP-042 consumes exactly two raw little-endian bytes. CScriptNum and\n // OP_N encodings are invalid even when they represent the same mask.\n b.op(OP_IF)\n .op(OP_DUP) // [ sig, pubKey, pubKey ]\n .op(OP_SHA256) // [ sig, pubKey, H(pubKey) ]\n .pushBytes(pubKeyCommitment) // [ sig, pubKey, H(pubKey), commitment ]\n .op(OP_EQUALVERIFY) // [ sig, pubKey ]\n .pushBytes(Uint8Array.of(txHashSelector & 0xff, txHashSelector >> 8)) // [ sig, pubKey, selector ]\n .op(OP_TXHASH) // [ sig, pubKey, txHash ]\n .op(OP_SWAP) // [ sig, txHash, pubKey ]\n .op(OP_CHECKSIGFROMSTACK) // [ 1 | 0 ]\n .op(OP_ELSE);\n // ════════ Fill branches (outer ELSE) ════════\n appendFillBranches(b, {\n paymentScriptPubKey: payment.bytes,\n tokenIdBytes,\n unitPriceSats,\n expiration\n });\n b.op(OP_ENDIF); // cancel / fill\n return b.build();\n}\nexport function buildPartialFillScriptPQHex(params) {\n return bytesToHex(buildPartialFillScriptPQ(params));\n}\n","/**\n * scriptSig builders for the Partial-Fill Sell Order covenant.\n *\n * These return the raw scriptSig bytes that unlock the covenant UTXO. The\n * surrounding transaction (inputs, outputs, fees, signatures on the buyer's\n * own inputs, etc.) is the caller's responsibility — stitch them together\n * with `@neuraiproject/neurai-create-transaction`.\n */\nimport { bytesToHex } from '../../core/bytes.js';\nimport { ScriptBuilder } from '../../core/script-builder.js';\n/**\n * Unlock the covenant via the public fill branches.\n *\n * amount === total → full-fill branch. The entire covenant drains to\n * vout[1]; no vout[2] continuation is emitted.\n * amount < total → partial-fill branch. vout[2] re-locks the\n * continuation (`total - amount` units).\n *\n * Unlock stack shapes (pushed bottom → top):\n *\n * Full fill: <1> <0> ( full-flag=1, cancel-flag=0 )\n * Partial fill: <N> <0> <0> ( N, full-flag=0, cancel-flag=0 )\n *\n * @param amount units the buyer is taking. Must be > 0 and ≤ total.\n * @param total current asset amount locked in the covenant UTXO. The\n * builder reads this to decide whether to emit the full-fill\n * or partial-fill witness — consensus uses `OP_INPUTASSETFIELD`\n * inside the covenant to check it independently, so the value\n * passed here must match on-chain reality or the script fails.\n */\nexport function buildFillScriptSig(amount, total) {\n if (typeof amount !== 'bigint' || typeof total !== 'bigint') {\n throw new Error('amount and total must be bigint');\n }\n if (amount <= 0n) {\n throw new Error('fill amount must be > 0');\n }\n if (total <= 0n) {\n throw new Error('total must be > 0');\n }\n if (amount > total) {\n throw new Error('fill amount exceeds the covenant total');\n }\n const b = new ScriptBuilder();\n if (amount === total) {\n // Full fill: covenant drains entirely. Buyer does not push N — the\n // covenant reads it via OP_INPUTASSETFIELD.\n b.pushInt(1).pushInt(0);\n }\n else {\n // Partial fill: buyer pushes N, then both flag bytes.\n b.pushInt(amount).pushInt(0).pushInt(0);\n }\n return b.build();\n}\nexport function buildFillScriptSigHex(amount, total) {\n return bytesToHex(buildFillScriptSig(amount, total));\n}\n/**\n * Unlock the covenant via the seller's cancel branch.\n *\n * Stack before OP_IF (top → bottom):\n * 1 ← selects the OP_IF branch\n * pubkey ← consumed by OP_DUP OP_HASH160 … OP_EQUALVERIFY\n * sig ← consumed by OP_CHECKSIG\n *\n * so the scriptSig pushes `<sig> <pubkey> <1>`.\n *\n * The signature is on whatever sighash the caller picked; this builder does\n * not hash or sign, it only assembles the unlock script once a signature is\n * available.\n */\nexport function buildCancelScriptSig(signatureDer, pubKey) {\n if (!(signatureDer instanceof Uint8Array) || signatureDer.length === 0) {\n throw new Error('signatureDer must be a non-empty Uint8Array');\n }\n if (!(pubKey instanceof Uint8Array) || (pubKey.length !== 33 && pubKey.length !== 65)) {\n throw new Error('pubKey must be a compressed (33B) or uncompressed (65B) secp256k1 key');\n }\n return new ScriptBuilder()\n .pushBytes(signatureDer)\n .pushBytes(pubKey)\n .pushInt(1)\n .build();\n}\nexport function buildCancelScriptSigHex(signatureDer, pubKey) {\n return bytesToHex(buildCancelScriptSig(signatureDer, pubKey));\n}\n","/**\n * scriptSig builders for the PQ Partial-Fill Sell Order covenant.\n *\n * The fill branch is identical to the legacy variant (just pushes `<N> <0>`),\n * so callers reuse `buildFillScriptSig` from `./spend.ts`. Only the cancel\n * branch is different: it carries a full PQ pubkey (~1313 B) and signature\n * (~2421 B), which requires NIP-18's expanded element-size cap.\n */\nimport { bytesToHex } from '../../core/bytes.js';\nimport { ScriptBuilder } from '../../core/script-builder.js';\n/**\n * Build the scriptSig that unlocks the PQ cancel branch.\n *\n * Stack ordering pushed (bottom → top): `sig, pubkey, 1`.\n *\n * @param sigPQ ML-DSA-44 signature over `SHA256(OP_TXHASH(selector))`,\n * **with trailing sighash byte appended** (same convention as\n * OP_CHECKSIG — CSFS strips it before verification). Expected\n * length 2421 bytes for ML-DSA-44.\n * @param pubKey Versioned PQ public key bytes, 1313 bytes (1-byte prefix\n * + 1312-byte ML-DSA-44 key). Must hash (via SHA256) to the\n * `pubKeyCommitment` embedded in the covenant scriptPubKey.\n */\nexport function buildCancelScriptSigPQ(sigPQ, pubKey) {\n if (!(sigPQ instanceof Uint8Array) || sigPQ.length === 0) {\n throw new Error('sigPQ must be a non-empty Uint8Array');\n }\n if (sigPQ.length > 3072) {\n throw new Error(`sigPQ of ${sigPQ.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (3072)`);\n }\n if (!(pubKey instanceof Uint8Array) || pubKey.length === 0) {\n throw new Error('pubKey must be a non-empty Uint8Array');\n }\n if (pubKey.length > 3072) {\n throw new Error(`pubKey of ${pubKey.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (3072)`);\n }\n return new ScriptBuilder()\n .pushBytes(sigPQ)\n .pushBytes(pubKey)\n .pushInt(1)\n .build();\n}\nexport function buildCancelScriptSigPQHex(sigPQ, pubKey) {\n return bytesToHex(buildCancelScriptSigPQ(sigPQ, pubKey));\n}\n","/**\n * Witness-stack builders for the Partial-Fill Sell Order covenant.\n *\n * When the covenant lives behind an AuthScript commitment (the only\n * asset-compatible deployment since the node's OP_XNA_ASSET placement rules\n * — bare covenant outputs can no longer carry assets), the unlock data goes\n * in the witness, not the scriptSig. The scriptSig builders in `spend.ts`\n * return a serialized script that PUSHES the elements; a witness needs the\n * elements THEMSELVES, one per stack slot, so those blobs cannot be reused\n * as a single `args` entry.\n *\n * These builders return the raw `args` stack (bottom → top), mirroring the\n * shapes documented in `spend.ts`:\n *\n * Full fill: [ <1>, <0> ]\n * Partial fill: [ <N>, <0>, <0> ]\n * Cancel: [ <sig>, <pubkey>, <1> ]\n *\n * Numbers are minimal CScriptNum stack values (0 = empty element). Wrap the\n * result with `buildAuthScriptWitnessNoAuth({ args, witnessScript: covenant })`\n * (from `standard/authscript.ts`) to get the final `[0x00, ...args, covenant]`\n * witness, and serialize the spending transaction with\n * `serializeTransaction` from `@neuraiproject/neurai-create-transaction`\n * (0.5.1+, witness elements as hex strings: `witness.map(bytesToHex)`).\n */\nimport { encodeScriptNum } from '../../core/script-builder.js';\nconst MAX_PQ_SCRIPT_ELEMENT_SIZE = 3072;\n/**\n * Witness `args` for the public fill branches. Same semantics and\n * validations as `buildFillScriptSig`.\n */\nexport function buildFillWitnessStack(amount, total) {\n if (typeof amount !== 'bigint' || typeof total !== 'bigint') {\n throw new Error('amount and total must be bigint');\n }\n if (amount <= 0n) {\n throw new Error('fill amount must be > 0');\n }\n if (total <= 0n) {\n throw new Error('total must be > 0');\n }\n if (amount > total) {\n throw new Error('fill amount exceeds the covenant total');\n }\n if (amount === total) {\n // Full fill: covenant drains entirely; buyer does not push N.\n return [encodeScriptNum(1n), encodeScriptNum(0n)];\n }\n // Partial fill: N, then both flag values.\n return [encodeScriptNum(amount), encodeScriptNum(0n), encodeScriptNum(0n)];\n}\n/**\n * Witness `args` for the seller's ECDSA cancel branch. Same semantics and\n * validations as `buildCancelScriptSig`.\n */\nexport function buildCancelWitnessStack(signatureDer, pubKey) {\n if (!(signatureDer instanceof Uint8Array) || signatureDer.length === 0) {\n throw new Error('signatureDer must be a non-empty Uint8Array');\n }\n if (!(pubKey instanceof Uint8Array) || (pubKey.length !== 33 && pubKey.length !== 65)) {\n throw new Error('pubKey must be a compressed (33B) or uncompressed (65B) secp256k1 key');\n }\n return [signatureDer, pubKey, encodeScriptNum(1n)];\n}\n/**\n * Witness `args` for the seller's PQ (ML-DSA-44) cancel branch. Same\n * semantics and validations as `buildCancelScriptSigPQ`.\n */\nexport function buildCancelWitnessStackPQ(sigPQ, pubKey) {\n if (!(sigPQ instanceof Uint8Array) || sigPQ.length === 0) {\n throw new Error('sigPQ must be a non-empty Uint8Array');\n }\n if (sigPQ.length > MAX_PQ_SCRIPT_ELEMENT_SIZE) {\n throw new Error(`sigPQ of ${sigPQ.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (${MAX_PQ_SCRIPT_ELEMENT_SIZE})`);\n }\n if (!(pubKey instanceof Uint8Array) || pubKey.length === 0) {\n throw new Error('pubKey must be a non-empty Uint8Array');\n }\n if (pubKey.length > MAX_PQ_SCRIPT_ELEMENT_SIZE) {\n throw new Error(`pubKey of ${pubKey.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (${MAX_PQ_SCRIPT_ELEMENT_SIZE})`);\n }\n return [sigPQ, pubKey, encodeScriptNum(1n)];\n}\n","/**\n * Parser for the Partial-Fill Sell Order covenant (three-branch, ECDSA cancel).\n *\n * Extracts `(sellerPubKeyHash, paymentScriptPubKey, unitPriceSats, tokenId)`\n * from a scriptPubKey that was produced by `buildPartialFillScript`. Walks\n * the exact byte layout emitted by the builder and fails on any deviation —\n * this is deliberate, so a downstream indexer can unambiguously classify a\n * UTXO as \"partial-fill order\" or \"unknown script\" with no false positives.\n * Covenants built before the input-0 binding (neurai-scripts < 0.10.0) are\n * rejected: their fill branches can be drained through a foreign input 0.\n */\nimport { bytesToHex, hexToBytes } from '../../core/bytes.js';\nimport { OP_CHECKSIG, OP_DUP, OP_ELSE, OP_ENDIF, OP_EQUALVERIFY, OP_HASH160, OP_IF } from '../../core/opcodes.js';\nimport { assertTrailing, expectByte, makeCursor, readPush } from '../../core/script-parser.js';\nimport { readFillBranches } from './fill-branches.js';\n/**\n * Parse a covenant scriptPubKey and extract its parameters. Throws with a\n * descriptive message if the bytes don't match the partial-fill template.\n */\nexport function parsePartialFillScript(script, network = 'xna-test') {\n const bytes = typeof script === 'string' ? hexToBytes(script) : script;\n const c = makeCursor(bytes);\n // ═════ Outer IF — Cancel branch ═════\n expectByte(c, OP_IF, 'OP_IF (outer cancel)');\n expectByte(c, OP_DUP, 'OP_DUP (cancel)');\n expectByte(c, OP_HASH160, 'OP_HASH160');\n const sellerPubKeyHash = readPush(c, 'sellerPubKeyHash');\n if (sellerPubKeyHash.length !== 20) {\n throw new Error(`parse: sellerPubKeyHash is ${sellerPubKeyHash.length} bytes, expected 20`);\n }\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (cancel)');\n expectByte(c, OP_CHECKSIG, 'OP_CHECKSIG (cancel)');\n expectByte(c, OP_ELSE, 'OP_ELSE (outer → fill)');\n // ═════ Outer ELSE — input-0 binding + fill branches ═════\n const fill = readFillBranches(c);\n expectByte(c, OP_ENDIF, 'OP_ENDIF (outer)');\n assertTrailing(c);\n return {\n network,\n sellerPubKeyHash,\n paymentScriptPubKey: fill.paymentScriptPubKey,\n unitPriceSats: fill.unitPriceSats,\n tokenId: fill.tokenId,\n expiration: fill.expiration,\n scriptHex: bytesToHex(bytes)\n };\n}\n","/**\n * Parser for the PQ Partial-Fill Sell Order covenant (three-branch).\n * Returns the same economic parameters as the legacy parser, plus the\n * payment scriptPubKey bytes (which may be P2PKH or AuthScript) and the\n * configured TXHASH selector.\n *\n * The fill branches (and their input-0 binding) are read by the shared\n * `readFillBranches`; covenants built before the binding are rejected.\n */\nimport { bytesToHex, hexToBytes } from '../../core/bytes.js';\nimport { OP_CHECKSIGFROMSTACK, OP_DUP, OP_ELSE, OP_ENDIF, OP_EQUALVERIFY, OP_IF, OP_SHA256, OP_SWAP, OP_TXHASH } from '../../core/opcodes.js';\nimport { assertTrailing, expectByte, makeCursor, readPush } from '../../core/script-parser.js';\nimport { readFillBranches } from './fill-branches.js';\n/** Quick discriminator without throwing — useful for indexers. */\nexport function isPartialFillScriptPQ(script) {\n const bytes = typeof script === 'string' ? hexToBytes(script) : script;\n // PQ cancel starts with: OP_IF OP_DUP OP_SHA256\n return (bytes.length > 3 &&\n bytes[0] === OP_IF &&\n bytes[1] === OP_DUP &&\n bytes[2] === OP_SHA256);\n}\n/**\n * Parse a PQ partial-fill covenant. Throws if the bytes do not match the\n * exact layout produced by `buildPartialFillScriptPQ`.\n */\nexport function parsePartialFillScriptPQ(script, network = 'xna-test') {\n const bytes = typeof script === 'string' ? hexToBytes(script) : script;\n const c = makeCursor(bytes);\n // ═════ Outer IF — Cancel branch (PQ) ═════\n expectByte(c, OP_IF, 'OP_IF (outer cancel)');\n expectByte(c, OP_DUP, 'OP_DUP (cancel)');\n expectByte(c, OP_SHA256, 'OP_SHA256');\n const pubKeyCommitment = readPush(c, 'pubKeyCommitment');\n if (pubKeyCommitment.length !== 32) {\n throw new Error(`parse-pq: pubKeyCommitment must be 32 bytes, got ${pubKeyCommitment.length}`);\n }\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (cancel)');\n const selectorBytes = readPush(c, 'txHashSelector');\n if (selectorBytes.length !== 2) {\n throw new Error(`parse-pq: txHashSelector must be a two-byte LE push, got ${selectorBytes.length} bytes`);\n }\n const txHashSelector = selectorBytes[0] | (selectorBytes[1] << 8);\n if (txHashSelector === 0 || txHashSelector > 0x1ff) {\n throw new Error(`parse-pq: txHashSelector 0x${txHashSelector.toString(16)} is rejected by OP_TXHASH`);\n }\n expectByte(c, OP_TXHASH, 'OP_TXHASH');\n expectByte(c, OP_SWAP, 'OP_SWAP');\n expectByte(c, OP_CHECKSIGFROMSTACK, 'OP_CHECKSIGFROMSTACK');\n expectByte(c, OP_ELSE, 'OP_ELSE (outer → fill)');\n // ═════ Outer ELSE — input-0 binding + fill branches ═════\n const fill = readFillBranches(c);\n expectByte(c, OP_ENDIF, 'OP_ENDIF (outer)');\n assertTrailing(c);\n return {\n network,\n pubKeyCommitment,\n tokenId: fill.tokenId,\n unitPriceSats: fill.unitPriceSats,\n txHashSelector,\n expiration: fill.expiration,\n paymentScriptPubKey: fill.paymentScriptPubKey,\n scriptHex: bytesToHex(bytes)\n };\n}\n","/**\n * NIP-054 P2AH custody policy (`OP_CHECKASSETAUTH`, AuthScript only).\n *\n * The policy is the witnessScript of a generic AuthScript v1 (NoAuth)\n * address. A spend of that address needs M of the N owner-token roles of the\n * list to approve it (G of them when an owner token held by the custody\n * leaves it):\n *\n * policy: <1> <M> <G> <role_1> ... <role_n> <n> OP_CHECKASSETAUTH\n * witness: [0x00, <c>, <a>, <b>, <T>, policy]\n *\n * Build the four arguments with `buildAssetAuthArgs` and wrap them with\n * `buildAuthScriptWitnessNoAuth({ args, witnessScript: policy })`. A role\n * approves either by spending its owner token from P2PKH or a strict\n * AuthScript address with a SIGHASH_ALL signature (synchronous spend, every\n * argument 0), or by a vote (see `vote.ts` and `proposal.ts`).\n */\nimport { OP_1, OP_16, OP_CHECKASSETAUTH } from '../../core/opcodes.js';\nimport { encodeScriptNum, ScriptBuilder } from '../../core/script-builder.js';\nimport { makeCursor, readPush, readPushUint8 } from '../../core/script-parser.js';\n/** The only policy version defined by NIP-054. */\nexport const ASSETAUTH_POLICY_VERSION = 1;\n/** Highest number of roles in one policy. */\nexport const ASSETAUTH_MAX_ROLES = 16;\n/** c, a, b and T are script numbers of at most 4 bytes. */\nconst MAX_ARGUMENT = 0x7fffffff;\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\nfunction compareBytes(x, y) {\n const n = Math.min(x.length, y.length);\n for (let i = 0; i < n; i += 1) {\n if (x[i] !== y[i])\n return x[i] - y[i];\n }\n return x.length - y.length;\n}\n/** Role names as the node checks them: sorted by bytes, no duplicates. */\nfunction sortedRoles(roles) {\n if (!Array.isArray(roles) || roles.length < 1 || roles.length > ASSETAUTH_MAX_ROLES) {\n throw new Error(`roles must list 1 to ${ASSETAUTH_MAX_ROLES} owner tokens`);\n }\n const names = roles.map((role) => {\n if (typeof role !== 'string' || !role.endsWith('!')) {\n throw new Error(`role ${JSON.stringify(role)} is not an owner token name (NAME!)`);\n }\n return encoder.encode(role);\n });\n names.sort(compareBytes);\n for (let i = 1; i < names.length; i += 1) {\n if (compareBytes(names[i - 1], names[i]) === 0) {\n throw new Error(`role ${decoder.decode(names[i])} is listed twice`);\n }\n }\n return names;\n}\nfunction assertThresholds(M, G, n) {\n if (!Number.isInteger(M) || !Number.isInteger(G) || M < 1 || M > G || G > n) {\n throw new Error(`thresholds must satisfy 1 <= M <= G <= ${n} (got M=${M}, G=${G})`);\n }\n}\nexport function buildAssetAuthPolicyScript(policy) {\n const roles = sortedRoles(policy.roles);\n assertThresholds(policy.M, policy.G, roles.length);\n const b = new ScriptBuilder()\n .pushInt(ASSETAUTH_POLICY_VERSION)\n .pushInt(policy.M)\n .pushInt(policy.G);\n for (const role of roles)\n b.pushBytes(role);\n return b.pushInt(roles.length).op(OP_CHECKASSETAUTH).build();\n}\n/** Inverse of `buildAssetAuthPolicyScript`; rejects any other script. */\nexport function parseAssetAuthPolicyScript(script) {\n const end = script.length - 2;\n const nOp = script[end];\n if (script.length < 6 || script[end + 1] !== OP_CHECKASSETAUTH || nOp < OP_1 || nOp > OP_16) {\n throw new Error('parse: not an OP_CHECKASSETAUTH policy script');\n }\n const c = makeCursor(script);\n if (readPushUint8(c, 'version') !== ASSETAUTH_POLICY_VERSION) {\n throw new Error(`parse: policy version must be ${ASSETAUTH_POLICY_VERSION}`);\n }\n const M = readPushUint8(c, 'M');\n const G = readPushUint8(c, 'G');\n const names = [];\n while (c.pos < end)\n names.push(readPush(c, `role ${names.length + 1}`));\n if (c.pos !== end || names.length !== nOp - OP_1 + 1) {\n throw new Error('parse: role count does not match n');\n }\n const roles = names.map((name) => decoder.decode(name));\n const policy = { M, G, roles };\n // Strictly increasing as written: a re-sorted list would be another script.\n const rebuilt = buildAssetAuthPolicyScript(policy);\n if (compareBytes(rebuilt, script) !== 0) {\n throw new Error('parse: roles are not owner names in strictly increasing byte order');\n }\n return policy;\n}\n/**\n * Witness `args` [<c>, <a>, <b>, <T>] for the custody input: minimal script\n * numbers, 0 as the empty element. All default to 0, the synchronous spend.\n */\nexport function buildAssetAuthArgs({ c = 0, a = 0, b = 0, T = 0 } = {}) {\n for (const [name, value] of Object.entries({ c, a, b, T })) {\n if (!Number.isInteger(value) || value < 0 || value > MAX_ARGUMENT) {\n throw new Error(`${name} must be an integer from 0 to ${MAX_ARGUMENT}`);\n }\n }\n return [c, a, b, T].map((value) => encodeScriptNum(value));\n}\n","const U32_MASK64 = /* @__PURE__ */ (() => BigInt(2 ** 32 - 1))();\nconst _32n = /* @__PURE__ */ BigInt(32);\n// Split bigint into two 32-bit halves. With `le=true`, returned fields become `{ h: low, l: high\n// }` to match little-endian word order rather than the property names.\nfunction fromBig(n, le = false) {\n if (le)\n return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };\n return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };\n}\n// Split bigint list into `[highWords, lowWords]` when `le=false`; with `le=true`, the first array\n// holds the low halves because `fromBig(...)` swaps the semantic meaning of `h` and `l`.\nfunction split(lst, le = false) {\n const len = lst.length;\n let Ah = new Uint32Array(len);\n let Al = new Uint32Array(len);\n for (let i = 0; i < len; i++) {\n const { h, l } = fromBig(lst[i], le);\n [Ah[i], Al[i]] = [h, l];\n }\n return [Ah, Al];\n}\n// Combine explicit `(high, low)` 32-bit halves into a bigint; `>>> 0` normalizes signed JS\n// bitwise results back to uint32 first, and little-endian callers must swap.\nconst toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);\n// Split a JS number into u32 halves without a BigInt allocation. Exact only for integers\n// `0 <= n < 2**53`; callers use it on byte / bit counters, which JS length math caps far below\n// that (an ArrayBuffer cannot exceed 2**53 - 1 bytes).\nconst fromNumH = (n) => (n / 2 ** 32) | 0;\nconst fromNumL = (n) => n >>> 0;\n// Drop-in replacement for `view.setBigUint64(byteOffset, BigInt(n), isLE)` without the per-call\n// BigInt allocation. Same `n < 2**53` precondition as `fromNumH`/`fromNumL`.\nfunction setU64FromNum(view, byteOffset, n, isLE) {\n const h = fromNumH(n);\n const l = fromNumL(n);\n view.setUint32(byteOffset, isLE ? l : h, isLE);\n view.setUint32(byteOffset + 4, isLE ? h : l, isLE);\n}\n// High 32-bit half of a 64-bit logical right shift for `s` in `0..31`.\nconst shrSH = (h, _l, s) => h >>> s;\n// Low 32-bit half of a 64-bit logical right shift, valid for `s` in `1..31`.\nconst shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// High 32-bit half of a 64-bit right rotate, valid for `s` in `1..31`.\nconst rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));\n// Low 32-bit half of a 64-bit right rotate, valid for `s` in `1..31`.\nconst rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// High 32-bit half of a 64-bit right rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.\nconst rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));\n// Low 32-bit half of a 64-bit right rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.\nconst rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));\n// High 32-bit half of a 64-bit right rotate for `s === 32`; this is just the swapped low half.\nconst rotr32H = (_h, l) => l;\n// Low 32-bit half of a 64-bit right rotate for `s === 32`; this is just the swapped high half.\nconst rotr32L = (h, _l) => h;\n// 64-bit left rotates (rotl*) are not defined here: sha3.ts, their only consumer, keeps\n// local copies so V8 inlines them into keccakP.\n// Add two split 64-bit words and return the split `{ h, l }` sum.\n// JS uses 32-bit signed integers for bitwise operations, so we cannot simply shift the carry out\n// of the low sum and instead use division.\nfunction add(Ah, Al, Bh, Bl) {\n const l = (Al >>> 0) + (Bl >>> 0);\n return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };\n}\n// Addition with more than 2 elements\n// Unmasked low-word accumulator for 3-way addition; pass the raw result into `add3H(...)`.\nconst add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);\n// High-word finalize step for 3-way addition; `low` must be the untruncated output of `add3L(...)`.\nconst add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;\n// Unmasked low-word accumulator for 4-way addition; pass the raw result into `add4H(...)`.\nconst add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);\n// High-word finalize step for 4-way addition; `low` must be the untruncated output of `add4L(...)`.\nconst add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;\n// Unmasked low-word accumulator for 5-way addition; pass the raw result into `add5H(...)`.\nconst add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);\n// High-word finalize step for 5-way addition; `low` must be the untruncated output of `add5L(...)`.\nconst add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;\n// prettier-ignore\nexport { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, fromNumH, fromNumL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, setU64FromNum, shrSH, shrSL, split, toBig };\n","/**\n * Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.\n * @param a - value to test\n * @returns `true` when the value is a Uint8Array-compatible view.\n * @example\n * Check whether a value is a Uint8Array-compatible view.\n * ```ts\n * isBytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function isBytes(a) {\n // Plain `instanceof Uint8Array` is too strict for some Buffer / proxy / cross-realm cases.\n // The fallback still requires a real ArrayBuffer view, so plain\n // JSON-deserialized `{ constructor: ... }` spoofing is rejected, and\n // `BYTES_PER_ELEMENT === 1` keeps the fallback on byte-oriented views.\n return (a instanceof Uint8Array ||\n (ArrayBuffer.isView(a) &&\n a.constructor.name === 'Uint8Array' &&\n 'BYTES_PER_ELEMENT' in a &&\n a.BYTES_PER_ELEMENT === 1));\n}\n// Shared error-message prefix builder. Only called on throw paths, so assert\n// success paths never pay for the string concatenation.\nconst atitle = (title) => (title ? `\"${title}\" ` : '');\n/**\n * Asserts something is a non-negative integer.\n * @param n - number to validate\n * @param title - label included in thrown errors\n * @returns The validated number.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate a non-negative integer option.\n * ```ts\n * anumber(32, 'length');\n * ```\n */\nexport function anumber(n, title = '') {\n if (typeof n !== 'number')\n throw new TypeError(atitle(title) + 'expected number, got ' + typeof n);\n if (!Number.isSafeInteger(n) || n < 0)\n throw new RangeError(atitle(title) + 'expected integer >= 0, got ' + n);\n return n;\n}\n/**\n * Asserts something is a boolean.\n * @param value - value to validate\n * @param title - label included in thrown errors\n * @returns The validated boolean.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Validate a boolean option.\n * ```ts\n * abool(true, 'enableXOF');\n * ```\n */\nexport function abool(value, title = '') {\n if (typeof value !== 'boolean')\n throw new TypeError(atitle(title) + 'expected boolean, got type=' + typeof value);\n return value;\n}\n/**\n * Asserts something is Uint8Array.\n * @param value - value to validate\n * @param length - optional exact length constraint\n * @param title - label included in thrown errors\n * @returns The validated byte array.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate that a value is a byte array.\n * ```ts\n * abytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function abytes(value, length, title = '') {\n // Success path first: this runs at the start of every update() / digestInto(), and the\n // common `abytes(data)` form must not pay for length handling it does not use.\n if (isBytes(value) && (length === undefined || value.length === length))\n return value;\n // Error path: recompute freely to build the exact message.\n if (length !== undefined)\n anumber(length, 'length');\n const bytes = isBytes(value);\n const ofLen = length !== undefined ? ` of length ${length}` : '';\n const got = bytes ? `length=${value.length}` : `type=${typeof value}`;\n const message = atitle(title) + 'expected Uint8Array' + ofLen + ', got ' + got;\n if (!bytes)\n throw new TypeError(message);\n throw new RangeError(message);\n}\n/**\n * Copies bytes into a fresh Uint8Array.\n * Buffer-style slices can alias the same backing store, so callers that need ownership should copy.\n * @param bytes - source bytes to clone\n * @returns Freshly allocated copy of `bytes`.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Clone a byte array before mutating it.\n * ```ts\n * const copy = copyBytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function copyBytes(bytes) {\n // `Uint8Array.from(...)` would also accept arrays / other typed arrays. Keep this helper strict\n // because callers use it at byte-validation boundaries before mutating the detached copy.\n return Uint8Array.from(abytes(bytes));\n}\n/**\n * Asserts something is a wrapped hash constructor.\n * @param h - hash constructor to validate\n * @throws On wrong argument types or invalid hash wrapper shape. {@link TypeError}\n * @throws On invalid hash metadata ranges or values. {@link RangeError}\n * @throws If the hash metadata allows empty outputs or block sizes. {@link Error}\n * @example\n * Validate a callable hash wrapper.\n * ```ts\n * import { ahash } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * ahash(sha256);\n * ```\n */\nexport function ahash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new TypeError('expected hash wrapped by utils.createHasher');\n anumber(h.outputLen);\n anumber(h.blockLen);\n // HMAC and KDF callers treat these as real byte lengths; allowing zero lets fake wrappers pass\n // validation and can produce empty outputs instead of failing fast.\n if (h.outputLen < 1 || h.blockLen < 1)\n throw new Error('hash blockLen / outputLen must be >= 1');\n}\nconst aobject = (value, label) => {\n if (value === null || typeof value !== 'object' || Array.isArray(value))\n throw new TypeError((label === 'object' ? '' : `\"${label}\" `) + 'expected object, got type=' + typeof value);\n};\nconst aopts = (value, label) => {\n aobject(value, label);\n const proto = Object.getPrototypeOf(value);\n if (proto !== Object.prototype && proto !== null)\n throw new TypeError(`\"${label}\" expected plain object`);\n // Object.assign() treats an own \"__proto__\" source key as a write to the target's legacy\n // prototype setter. Reject it before merging so inherited option values cannot be injected.\n if (Object.hasOwn(value, '__proto__'))\n throw new TypeError(`\"${label}.__proto__\" is not allowed`);\n};\n/**\n * Asserts a hash instance has not been destroyed or finished.\n * @param instance - hash instance to validate\n * @param checkFinished - whether to reject finalized instances\n * @throws If the hash instance has already been destroyed or finalized. {@link Error}\n * @example\n * Validate that a hash instance is still usable.\n * ```ts\n * import { aexists } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const hash = sha256.create();\n * aexists(hash);\n * ```\n */\nexport function aexists(instance, checkFinished = true) {\n // Runs on every update()/digestInto(); the flags are library-owned booleans, so only their\n // truthiness is checked - re-validating their type per call was pure hot-path overhead.\n if (instance.destroyed)\n throw new Error('hash was destroyed');\n if (checkFinished && instance.finished)\n throw new Error('digest() was already called');\n}\n/**\n * Asserts output is a sufficiently-sized byte array.\n * @param out - destination buffer\n * @param instance - hash instance providing output length\n * Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate a caller-provided digest buffer.\n * ```ts\n * import { aoutput } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const hash = sha256.create();\n * aoutput(new Uint8Array(hash.outputLen), hash);\n * ```\n */\nexport function aoutput(out, instance) {\n abytes(out, undefined, 'output');\n // `outputLen` is a library-owned readonly number; the negated comparison keeps failing fast\n // when it is missing/NaN (comparisons with undefined/NaN are false) without an anumber() call.\n const min = instance.outputLen;\n if (!(out.length >= min)) {\n throw new RangeError('\"output\" expected length >= ' + min);\n }\n}\n/**\n * Casts a typed array view to Uint8Array.\n * @param arr - source typed array\n * @returns Uint8Array view over the same buffer.\n * @example\n * Reinterpret a typed array as bytes.\n * ```ts\n * u8(new Uint32Array([1, 2]));\n * ```\n */\nexport function u8(arr) {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/**\n * Casts a typed array view to Uint32Array.\n * `arr.byteOffset` must already be 4-byte aligned or the platform\n * Uint32Array constructor will throw.\n * @param arr - source typed array\n * @returns Uint32Array view over the same buffer.\n * @example\n * Reinterpret a byte array as 32-bit words.\n * ```ts\n * u32(new Uint8Array(8));\n * ```\n */\nexport function u32(arr) {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n/**\n * Zeroizes typed arrays in place. Warning: JS provides no guarantees.\n * @param arrays - arrays to overwrite with zeros\n * @example\n * Zeroize sensitive buffers in place.\n * ```ts\n * clean(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function clean(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n/**\n * Creates a DataView for byte-level manipulation.\n * @param arr - source typed array\n * @returns DataView over the same buffer region.\n * @example\n * Create a DataView over an existing buffer.\n * ```ts\n * createView(new Uint8Array(4));\n * ```\n */\nexport function createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/**\n * Rotate-right operation for uint32 values.\n * @param word - source word\n * @param shift - shift amount in bits\n * @returns Rotated word.\n * @example\n * Rotate a 32-bit word to the right.\n * ```ts\n * rotr(0x12345678, 8);\n * ```\n */\nexport function rotr(word, shift) {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/**\n * Rotate-left operation for uint32 values.\n * @param word - source word\n * @param shift - shift amount in bits\n * @returns Rotated word.\n * @example\n * Rotate a 32-bit word to the left.\n * ```ts\n * rotl(0x12345678, 8);\n * ```\n */\nexport function rotl(word, shift) {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n/** Whether the current platform is little-endian. */\nexport const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n/**\n * Byte-swap operation for uint32 values.\n * @param word - source word\n * @returns Word with reversed byte order.\n * @example\n * Reverse the byte order of a 32-bit word.\n * ```ts\n * byteSwap(0x11223344);\n * ```\n */\nexport function byteSwap(word) {\n return (((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff));\n}\n/**\n * Conditionally byte-swaps one 32-bit word on big-endian platforms.\n * @param n - source word\n * @returns Original or byte-swapped word depending on platform endianness.\n * @example\n * Normalize a 32-bit word for host endianness.\n * ```ts\n * swap8IfBE(0x11223344);\n * ```\n */\nexport const swap8IfBE = isLE\n ? (n) => n\n : (n) => byteSwap(n) >>> 0;\n/**\n * Byte-swaps every word of a Uint32Array in place.\n * @param arr - array to mutate\n * @returns The same array after mutation; callers pass live state arrays here.\n * @example\n * Reverse the byte order of every word in place.\n * ```ts\n * byteSwap32(new Uint32Array([0x11223344]));\n * ```\n */\nexport function byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n return arr;\n}\n/**\n * Conditionally byte-swaps a Uint32Array on big-endian platforms.\n * @param u - array to normalize for host endianness\n * @returns Original or byte-swapped array depending on platform endianness.\n * On big-endian runtimes this mutates `u` in place via `byteSwap32(...)`.\n * @example\n * Normalize a word array for host endianness.\n * ```ts\n * swap32IfBE(new Uint32Array([0x11223344]));\n * ```\n */\nexport const swap32IfBE = isLE\n ? (u) => u\n : byteSwap32;\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin = /* @__PURE__ */ (() => \n// @ts-ignore\ntypeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * Convert byte array to hex string.\n * Uses the built-in function when available and assumes it matches the tested\n * fallback semantics.\n * @param bytes - bytes to encode\n * @returns Lowercase hexadecimal string.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Convert bytes to lowercase hexadecimal.\n * ```ts\n * bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])); // 'cafe0123'\n * ```\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin)\n return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// Strict ASCII nibble parser: non-ASCII hex lookalikes are rejected as undefined.\n// ASCII codes: '0'..'9' = 48..57, 'A'..'F' = 65..70, 'a'..'f' = 97..102.\n// prettier-ignore\nfunction asciiToBase16(ch) {\n return ch >= 48 && ch <= 57 ? ch - 48 // '2' => 50-48\n : ch >= 65 && ch <= 70 ? ch - (65 - 10) // 'B' => 66-(65-10)\n : ch >= 97 && ch <= 102 ? ch - (97 - 10) // 'b' => 98-(97-10)\n : undefined;\n}\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @param hex - hexadecimal string to decode\n * @returns Decoded bytes.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Decode lowercase hexadecimal into bytes.\n * ```ts\n * hexToBytes('cafe0123'); // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n * ```\n */\nexport function hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new TypeError('hex string expected, got ' + typeof hex);\n if (hasHexBuiltin) {\n try {\n return Uint8Array.fromHex(hex);\n }\n catch (error) {\n if (error instanceof SyntaxError)\n throw new RangeError(error.message);\n throw error;\n }\n }\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new RangeError('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi)); // parse first char, multiply it by 16\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); // parse second char\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new RangeError('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // example: 'A9' => 10*16 + 9\n }\n return array;\n}\n/**\n * Yields to the host task scheduler so timers, I/O, and rendering can make progress.\n * Uses the Web Scheduling API when available or `setTimeout` as a cross-platform fallback.\n * Host-task yields are much slower than microtasks (roughly 1ms with the timer fallback), so\n * async loops should use `asyncTick >= 10` to amortize scheduling overhead to about 10% while\n * still allowing other event-loop work to proceed.\n * @param onReject - optional cleanup invoked only if the host yield fails\n * @example\n * Yield to the next scheduler tick.\n * ```ts\n * await nextTick();\n * ```\n */\nexport function nextTick(onReject) {\n const host = globalThis;\n if (typeof host.scheduler?.yield === 'function') {\n const promise = host.scheduler.yield();\n // Keep the original scheduler rejection; this handler exists only for cleanup.\n if (onReject)\n promise.catch(onReject);\n return promise;\n }\n return new Promise((resolve) => host.setTimeout(resolve, 0));\n}\n/**\n * Returns control to the host event loop every `tick` milliseconds to avoid blocking long loops.\n * @param iters - number of loop iterations to run\n * @param tick - maximum time slice in milliseconds\n * @param cb - callback executed on each iteration\n * @param onReject - optional cleanup invoked only if a host yield fails\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Run a loop that periodically yields back to the event loop.\n * ```ts\n * await asyncLoop(2, 0, () => {});\n * ```\n */\nexport async function asyncLoop(iters, tick, cb, onReject) {\n anumber(iters, 'iters');\n anumber(tick, 'tick');\n if (typeof cb !== 'function')\n throw new TypeError('callback must be a function');\n // Callback is synchronous by contract; asyncLoop only yields between sync work windows.\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick(onReject);\n // Track only synchronous work time; scheduler delay after yielding is outside our budget.\n ts = Date.now();\n }\n}\n/**\n * Converts string to bytes using UTF8 encoding.\n * Built-in doesn't validate input to be string: we do the check.\n * Non-ASCII details are delegated to the platform `TextEncoder`.\n * @param str - string to encode\n * @returns UTF-8 encoded bytes.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Encode a string as UTF-8 bytes.\n * ```ts\n * utf8ToBytes('abc'); // Uint8Array.from([97, 98, 99])\n * ```\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new TypeError('string expected');\n const encoded = new TextEncoder().encode(str);\n try {\n // Copy into the current realm for Firefox extension contexts. Callers that own the returned\n // buffer can then wipe it independently of TextEncoder's temporary result.\n return new Uint8Array(encoded); // https://bugzil.la/1681809\n }\n finally {\n clean(encoded);\n }\n}\n/**\n * Helper for KDFs: consumes Uint8Array or string.\n * String inputs are UTF-8 encoded; byte-array inputs stay aliased to the caller buffer.\n * @param data - user-provided KDF input\n * @param errorTitle - label included in thrown errors\n * @returns Byte representation of the input.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Normalize KDF input to bytes.\n * ```ts\n * kdfInputToBytes('password');\n * ```\n */\nexport function kdfInputToBytes(data, errorTitle = '') {\n if (typeof data === 'string')\n return utf8ToBytes(data);\n return abytes(data, undefined, errorTitle);\n}\n/**\n * Copies several Uint8Arrays into one.\n * @param arrays - arrays to concatenate\n * @returns Concatenated byte array.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Concatenate multiple byte arrays.\n * ```ts\n * concatBytes(new Uint8Array([1]), new Uint8Array([2]));\n * ```\n */\nexport function concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n/**\n * Validates declared required and optional field types on a plain object.\n * This walks field schemas and formats detailed errors, so avoid it on hot paths; use direct\n * one-line guards such as `abytes()`, `abool()`, or `anumber()` instead.\n * @param object - object to validate\n * @param fields - map of required field names to expected types\n * @param optFields - map of optional field names to expected types\n * @param title - label included in thrown errors\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Validate required and optional option fields.\n * ```ts\n * validateObject({ N: 1024, dkLen: 32 }, { N: 'number' }, { dkLen: 'number' });\n * ```\n */\nexport const validateObject = (object, fields = {}, optFields = {}, title = 'object') => {\n aobject(object, title);\n aobject(fields, 'fields');\n aobject(optFields, 'optFields');\n function checkField(fieldName, expectedType, isOpt) {\n const label = title === 'object' ? `param \"${String(fieldName)}\"` : `\"${title}.${String(fieldName)}\"`;\n // Config fields must be explicit own properties. Optional inherited values are rejected too\n // because callers keep reading the same options object after validation.\n const val = object[fieldName];\n // Runtime objects such as Field instances intentionally satisfy required method slots\n // via their shared prototype.\n if (!Object.hasOwn(object, fieldName) &&\n (isOpt ? val !== undefined : expectedType !== 'function')) {\n throw new TypeError(`${label} is invalid: expected own property`);\n }\n if (isOpt && val === undefined)\n return;\n const current = typeof val;\n if (current !== expectedType || val === null)\n throw new TypeError(`${label} is invalid: expected ${expectedType}, got ${current}`);\n }\n const iter = (f, isOpt) => Object.entries(f).forEach(([k, v]) => checkField(k, v, isOpt));\n iter(fields, false);\n iter(optFields, true);\n};\n/**\n * Merges default options and passed options.\n * @param defaults - base option object\n * @param opts - user overrides\n * @param title - label included in thrown override errors\n * @returns Fresh merged option object with a null prototype.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Merge user overrides onto default options.\n * ```ts\n * checkOpts({ dkLen: 32 }, { asyncTick: 10 });\n * ```\n */\nexport function checkOpts(defaults, opts, title = 'opts') {\n aopts(defaults, 'defaults');\n if (opts !== undefined)\n aopts(opts, title);\n // Callers read optional fields directly, so omitted values must not fall through to ambient\n // Object.prototype pollution (for example a forged `dkLen` changing SHAKE's default output).\n const merged = Object.assign(Object.create(null), defaults, opts);\n return merged;\n}\n/**\n * Creates a callable hash function from a stateful class constructor.\n * @param hashCons - hash constructor or factory\n * @param info - optional metadata such as DER OID\n * @returns Frozen callable hash wrapper with `.create()`.\n * Wrapper construction eagerly calls `hashCons(undefined)` once to read\n * `outputLen` / `blockLen`, so constructor side effects happen at module\n * init time.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Wrap a stateful hash constructor into a callable helper.\n * ```ts\n * import { createHasher } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const wrapped = createHasher(sha256.create, { oid: sha256.oid });\n * wrapped(new Uint8Array([1]));\n * ```\n */\nexport function createHasher(hashCons, info = {}) {\n if (typeof hashCons !== 'function')\n throw new TypeError('\"hashCons\" expected function, got type=' + typeof hashCons);\n info = checkOpts({}, info, 'info');\n const hashC = (msg, opts) => hashCons(opts)\n .update(msg)\n .digest();\n const tmp = hashCons(undefined);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.canXOF = tmp.canXOF;\n hashC.create = (opts) => hashCons(opts);\n Object.assign(hashC, info);\n return Object.freeze(hashC);\n}\n/**\n * Cryptographically secure PRNG backed by `crypto.getRandomValues`.\n * @param bytesLength - number of random bytes to generate\n * @returns Random bytes.\n * The platform `getRandomValues()` implementation still defines any\n * single-call length cap, and this helper rejects oversize requests\n * with a stable library `RangeError` instead of host-specific errors.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @throws If the current runtime does not provide `crypto.getRandomValues`. {@link Error}\n * @example\n * Generate a fresh random key or nonce.\n * ```ts\n * const key = randomBytes(16);\n * ```\n */\nexport function randomBytes(bytesLength = 32) {\n // Match the repo's other length-taking helpers instead of relying on Uint8Array coercion.\n anumber(bytesLength, 'bytesLength');\n const cr = typeof globalThis === 'object' ? globalThis.crypto : null;\n if (typeof cr?.getRandomValues !== 'function')\n throw new Error('crypto.getRandomValues must be defined');\n // Web Cryptography API Level 2 §10.1.1:\n // if `byteLength > 65536`, throw `QuotaExceededError`.\n // Keep the guard explicit so callers can see the quota in code\n // instead of discovering it by reading the spec or host errors.\n // This wrapper surfaces the same quota as a stable library RangeError.\n if (bytesLength > 65536)\n throw new RangeError(`\"bytesLength\" expected <= 65536, got ${bytesLength}`);\n return cr.getRandomValues(new Uint8Array(bytesLength));\n}\n/**\n * Creates OID metadata for NIST hashes with prefix `06 09 60 86 48 01 65 03 04 02`.\n * @param suffix - final OID byte for the selected hash.\n * The helper accepts any byte even though only the documented NIST hash\n * suffixes are meaningful downstream.\n * @returns Object containing the DER-encoded OID.\n * @example\n * Build OID metadata for a NIST hash.\n * ```ts\n * oidNist(0x01);\n * ```\n */\nexport const oidNist = (suffix) => ({\n // Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.\n // Larger suffix values would need base-128 OID encoding and a different length byte.\n oid: Uint8Array.from([0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, suffix]),\n});\n","/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\nimport { setU64FromNum } from \"./_u64.js\";\nimport { abytes, aexists, aoutput, createView } from \"./utils.js\";\n/**\n * Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.\n * Returns bits from `b` when `a` is set, otherwise from `c`.\n * The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never\n * set the same bit.\n * @param a - selector word\n * @param b - word chosen when selector bit is set\n * @param c - word chosen when selector bit is clear\n * @returns Mixed 32-bit word.\n * @example\n * Combine three words with the shared 32-bit choice primitive.\n * ```ts\n * Chi(0xffffffff, 0x12345678, 0x87654321);\n * ```\n */\nexport function Chi(a, b, c) {\n return (a & b) ^ (~a & c);\n}\n/**\n * Shared 32-bit majority primitive reused by SHA-256 and SHA-1.\n * Returns bits shared by at least two inputs.\n * @param a - first input word\n * @param b - second input word\n * @param c - third input word\n * @returns Mixed 32-bit word.\n * @example\n * Combine three words with the shared 32-bit majority primitive.\n * ```ts\n * Maj(0xffffffff, 0x12345678, 0x87654321);\n * ```\n */\nexport function Maj(a, b, c) {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n * Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit\n * strings with partial-byte tails.\n * @param blockLen - internal block size in bytes\n * @param outputLen - digest size in bytes\n * @param padOffset - trailing length field size in bytes\n * @param isLE - whether length and state words are encoded in little-endian\n * @example\n * Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.\n * ```ts\n * import { _SHA1 } from '@noble/hashes/legacy.js';\n * const hash = new _SHA1();\n * hash.update(new Uint8Array([97, 98, 99]));\n * hash.digest();\n * ```\n */\nexport class HashMD {\n blockLen;\n outputLen;\n canXOF = false;\n padOffset;\n isLE;\n // For partial updates less than block size\n buffer;\n view;\n finished = false;\n length = 0;\n pos = 0;\n destroyed = false;\n constructor(blockLen, outputLen, padOffset, isLE) {\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data) {\n aexists(this);\n abytes(data);\n const { view, buffer, blockLen } = this;\n const len = data.length;\n let processed = false;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path only when there is no buffered partial block: `take === blockLen` implies\n // `this.pos === 0`, so we can process full blocks directly from the input view.\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n processed = true;\n continue;\n }\n // When the whole input is buffered in one go (common for short messages), passing `data`\n // directly avoids allocating a subarray view.\n buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n processed = true;\n }\n }\n this.length += data.length;\n // Shared schedule buffers only pick up input-derived words inside process(); if everything\n // was buffered without processing, there is nothing to zero.\n if (processed)\n this.roundClean();\n return this;\n }\n digestInto(out) {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message, then zero-pad the rest of the block\n buffer[pos++] = 0b10000000;\n buffer.fill(0, pos);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n buffer.fill(0);\n }\n // `padOffset` reserves the whole length field. For SHA-384/512 the high 64 bits stay zero from\n // the padding fill above, and JS will overflow before user input can make that half non-zero.\n // So we only need to write the low 64 bits here (`length * 8` only scales the exponent of an\n // integer below 2**53, so the split inside the helper stays exact).\n setU64FromNum(view, blockLen - 8, this.length * 8, isLE);\n this.process(view, 0);\n // The final block above is processed outside update(), so the shared message-schedule\n // buffers (e.g. SHA256_W) would otherwise retain input-derived words after digest().\n this.roundClean();\n // digest() passes our own `buffer` as `out`; reuse its cached view instead of allocating one.\n const oview = out === buffer ? view : createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which must be fused in single op with modulo by JIT\n const outLen = len / 4;\n const state = this.get();\n // Subclass-misconfiguration invariant: outputLen must be 32-bit aligned and fit the state.\n if (len % 4 || outLen > state.length)\n throw new Error('invalid outputLen');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n // Copy before destroy(): subclasses wipe `buffer` during cleanup, but `digest()` must return\n // fresh bytes to the caller.\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneIntoMeta(to) {\n const { buffer, length, finished, destroyed, pos } = this;\n to.destroyed = destroyed;\n to.finished = finished;\n to.length = length;\n to.pos = pos;\n // Only partial-block bytes need copying: when `length % blockLen === 0`, `pos === 0` and\n // later `update()` / `digestInto()` overwrite `to.buffer` from the start before reading it.\n if (pos)\n to.buffer.set(buffer); // Avoid a hot modulo guard.\n return to;\n }\n clone() {\n return this._cloneInto();\n }\n}\n/**\n * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.\n * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.\n */\n/** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the\n * square roots of the first eight prime numbers. Exported as a shared table; callers must treat\n * it as read-only because constructors copy words from it by index. */\nexport const SHA256_IV = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n/** Initial SHA224 state `H(0)` from RFC 6234 §6.1. Exported as a shared table; callers must\n * treat it as read-only because constructors copy words from it by index. */\nexport const SHA224_IV = /* @__PURE__ */ Uint32Array.from([\n 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,\n]);\n/** Initial SHA384 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen\n * big-endian 32-bit halves. Derived from the fractional parts of the square roots of the ninth\n * through sixteenth prime numbers. Exported as a shared table; callers must treat it as read-only\n * because constructors copy halves from it by index. */\nexport const SHA384_IV = /* @__PURE__ */ Uint32Array.from([\n 0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939,\n 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4,\n]);\n/** Initial SHA512 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen\n * big-endian 32-bit halves. Derived from the fractional parts of the square roots of the first\n * eight prime numbers. Exported as a shared table; callers must treat it as read-only because\n * constructors copy halves from it by index. */\nexport const SHA512_IV = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,\n 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,\n]);\n","/**\n * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.\n * SHA256 is the fastest hash implementable in JS, even faster than Blake3.\n * Check out {@link https://www.rfc-editor.org/rfc/rfc4634 | RFC 4634} and\n * {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf | FIPS 180-4}.\n * @module\n */\nimport { Chi, HashMD, Maj, SHA224_IV, SHA256_IV, SHA384_IV, SHA512_IV } from \"./_md.js\";\nimport * as u64 from \"./_u64.js\";\nimport { clean, createHasher, oidNist, rotr } from \"./utils.js\";\n/**\n * SHA-224 / SHA-256 round constants from RFC 6234 §5.1: the first 32 bits\n * of the cube roots of the first 64 primes (2..311).\n */\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ Uint32Array.from([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n/** Reusable SHA-224 / SHA-256 message schedule buffer `W_t` from RFC 6234 §6.2 step 1. */\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\n/** Internal SHA-224 / SHA-256 compression engine from RFC 6234 §6.2. */\nclass SHA2_32B extends HashMD {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n // Numeric initializers matter: starting the fields as `undefined` changes\n // V8's field representation and makes sha256 3x slower (measured).\n A = 0;\n B = 0;\n C = 0;\n D = 0;\n E = 0;\n F = 0;\n G = 0;\n H = 0;\n constructor(outputLen, IV) {\n super(64, outputLen, 8, false);\n this.A = IV[0] | 0;\n this.B = IV[1] | 0;\n this.C = IV[2] | 0;\n this.D = IV[3] | 0;\n this.E = IV[4] | 0;\n this.F = IV[5] | 0;\n this.G = IV[6] | 0;\n this.H = IV[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n _cloneInto(to) {\n (to ||= new this.constructor()).set(...this.get());\n return this._cloneIntoMeta(to);\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n clean(SHA256_W);\n }\n destroy() {\n // HashMD callers route post-destroy usability through `destroyed`; zeroizing alone still leaves\n // update()/digest() callable on reused instances.\n this.destroyed = true;\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n clean(this.buffer);\n }\n}\n/** Internal SHA-256 hash class grounded in RFC 6234 §6.2. */\nexport class _SHA256 extends SHA2_32B {\n constructor() {\n super(32, SHA256_IV);\n }\n}\n/** Internal SHA-224 hash class grounded in RFC 6234 §6.2 and §8.5. */\nexport class _SHA224 extends SHA2_32B {\n constructor() {\n super(28, SHA224_IV);\n }\n}\n// SHA2-512 is slower than sha256 in js because u64 operations are slow.\n// SHA-384 / SHA-512 round constants from RFC 6234 §5.2:\n// 80 full 64-bit words split into high/low halves.\n// prettier-ignore\nconst K512 = /* @__PURE__ */ (() => u64.split([\n '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',\n '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',\n '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',\n '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',\n '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',\n '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',\n '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',\n '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',\n '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'\n].map(n => BigInt(n))))();\nconst SHA512_Kh = /* @__PURE__ */ (() => K512[0])();\nconst SHA512_Kl = /* @__PURE__ */ (() => K512[1])();\n// Reusable high-half schedule buffer for the RFC 6234 §6.4 64-bit `W_t` words.\nconst SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\n// Reusable low-half schedule buffer for the RFC 6234 §6.4 64-bit `W_t` words.\nconst SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\n/** Internal SHA-384 / SHA-512 compression engine from RFC 6234 §6.4. */\nclass SHA2_64B extends HashMD {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n // h -- high 32 bits, l -- low 32 bits\n // Numeric initializers matter: starting the fields as `undefined` changes\n // V8's field representation and slows hashing down (measured on sha256).\n Ah = 0;\n Al = 0;\n Bh = 0;\n Bl = 0;\n Ch = 0;\n Cl = 0;\n Dh = 0;\n Dl = 0;\n Eh = 0;\n El = 0;\n Fh = 0;\n Fl = 0;\n Gh = 0;\n Gl = 0;\n Hh = 0;\n Hl = 0;\n constructor(outputLen, IV) {\n super(128, outputLen, 16, false);\n this.Ah = IV[0] | 0;\n this.Al = IV[1] | 0;\n this.Bh = IV[2] | 0;\n this.Bl = IV[3] | 0;\n this.Ch = IV[4] | 0;\n this.Cl = IV[5] | 0;\n this.Dh = IV[6] | 0;\n this.Dl = IV[7] | 0;\n this.Eh = IV[8] | 0;\n this.El = IV[9] | 0;\n this.Fh = IV[10] | 0;\n this.Fl = IV[11] | 0;\n this.Gh = IV[12] | 0;\n this.Gl = IV[13] | 0;\n this.Hh = IV[14] | 0;\n this.Hl = IV[15] | 0;\n }\n // prettier-ignore\n get() {\n const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];\n }\n // prettier-ignore\n set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n _cloneInto(to) {\n (to ||= new this.constructor()).set(...this.get());\n return this._cloneIntoMeta(to);\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) {\n SHA512_W_H[i] = view.getUint32(offset);\n SHA512_W_L[i] = view.getUint32((offset += 4));\n }\n for (let i = 16; i < 80; i++) {\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = SHA512_W_H[i - 15] | 0;\n const W15l = SHA512_W_L[i - 15] | 0;\n const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);\n const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = SHA512_W_H[i - 2] | 0;\n const W2l = SHA512_W_L[i - 2] | 0;\n const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);\n const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);\n // SHA512_W[i] = s0 + s1 + SHA512_W[i - 7] + SHA512_W[i - 16];\n const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);\n const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);\n SHA512_W_H[i] = SUMh | 0;\n SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n // Compression function main loop, 80 rounds\n for (let i = 0; i < 80; i++) {\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);\n const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = (Eh & Fh) ^ (~Eh & Gh);\n const CHIl = (El & Fl) ^ (~El & Gl);\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);\n const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);\n const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);\n const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);\n const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = u64.add3L(T1l, sigma0l, MAJl);\n Ah = u64.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n roundClean() {\n clean(SHA512_W_H, SHA512_W_L);\n }\n destroy() {\n // HashMD callers route post-destroy usability through `destroyed`; zeroizing alone still leaves\n // update()/digest() callable on reused instances.\n this.destroyed = true;\n clean(this.buffer);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\n/** Internal SHA-512 hash class grounded in RFC 6234 §6.3 and §6.4. */\nexport class _SHA512 extends SHA2_64B {\n constructor() {\n super(64, SHA512_IV);\n }\n}\n/** Internal SHA-384 hash class grounded in RFC 6234 §6.3 and §6.4. */\nexport class _SHA384 extends SHA2_64B {\n constructor() {\n super(48, SHA384_IV);\n }\n}\n/**\n * Truncated SHA512/256 and SHA512/224.\n * SHA512_IV is XORed with 0xa5a5a5a5a5a5a5a5, then used as \"intermediary\" IV of SHA512/t.\n * Then t hashes string to produce result IV.\n * See the repo-side derivation recipe in `test/misc/sha2-gen-iv.js`.\n * These IV literals are checked against that script rather than a dedicated\n * local RFC section.\n */\n/** SHA-512/224 IV derived by the SHA-512/t recipe in `test/misc/sha2-gen-iv.js` and\n * stored as sixteen big-endian 32-bit halves. */\nconst T224_IV = /* @__PURE__ */ Uint32Array.from([\n 0x8c3d37c8, 0x19544da2, 0x73e19966, 0x89dcd4d6, 0x1dfab7ae, 0x32ff9c82, 0x679dd514, 0x582f9fcf,\n 0x0f6d2b69, 0x7bd44da8, 0x77e36f73, 0x04c48942, 0x3f9d85a8, 0x6a1d36c8, 0x1112e6ad, 0x91d692a1,\n]);\n/** SHA-512/256 IV derived by the SHA-512/t recipe in `test/misc/sha2-gen-iv.js` and\n * stored as sixteen big-endian 32-bit halves. */\nconst T256_IV = /* @__PURE__ */ Uint32Array.from([\n 0x22312194, 0xfc2bf72c, 0x9f555fa3, 0xc84c64c2, 0x2393b86b, 0x6f53b151, 0x96387719, 0x5940eabd,\n 0x96283ee2, 0xa88effe3, 0xbe5e1e25, 0x53863992, 0x2b0199fc, 0x2c85b8aa, 0x0eb72ddc, 0x81c52ca2,\n]);\n/** Internal SHA-512/224 hash class using the derived `T224_IV` and the shared\n * RFC 6234 §6.4 compression engine. */\nexport class _SHA512_224 extends SHA2_64B {\n constructor() {\n super(28, T224_IV);\n }\n}\n/** Internal SHA-512/256 hash class using the derived `T256_IV` and the shared\n * RFC 6234 §6.4 compression engine. */\nexport class _SHA512_256 extends SHA2_64B {\n constructor() {\n super(32, T256_IV);\n }\n}\n/**\n * SHA2-256 hash function from RFC 4634. In JS it's the fastest: even faster than Blake3. Some info:\n *\n * - Trying 2^128 hashes would get 50% chance of collision, using birthday attack.\n * - BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n * - Each sha256 hash is executing 2^18 bit operations.\n * - Good 2024 ASICs can do 200Th/sec with 3500 watts of power, corresponding to 2^36 hashes/joule.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-256.\n * ```ts\n * sha256(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(), \n/* @__PURE__ */ oidNist(0x01));\n/**\n * SHA2-224 hash function from RFC 4634.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-224.\n * ```ts\n * sha224(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha224 = /* @__PURE__ */ createHasher(() => new _SHA224(), \n/* @__PURE__ */ oidNist(0x04));\n/**\n * SHA2-512 hash function from RFC 4634.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-512.\n * ```ts\n * sha512(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha512 = /* @__PURE__ */ createHasher(() => new _SHA512(), \n/* @__PURE__ */ oidNist(0x03));\n/**\n * SHA2-384 hash function from RFC 4634.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-384.\n * ```ts\n * sha384(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha384 = /* @__PURE__ */ createHasher(() => new _SHA384(), \n/* @__PURE__ */ oidNist(0x02));\n/**\n * SHA2-512/256 \"truncated\" hash function, with improved resistance to length extension attacks.\n * See the paper on {@link https://eprint.iacr.org/2010/548.pdf | truncated SHA512}.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-512/256.\n * ```ts\n * sha512_256(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha512_256 = /* @__PURE__ */ createHasher(() => new _SHA512_256(), \n/* @__PURE__ */ oidNist(0x06));\n/**\n * SHA2-512/224 \"truncated\" hash function, with improved resistance to length extension attacks.\n * See the paper on {@link https://eprint.iacr.org/2010/548.pdf | truncated SHA512}.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-512/224.\n * ```ts\n * sha512_224(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha512_224 = /* @__PURE__ */ createHasher(() => new _SHA512_224(), \n/* @__PURE__ */ oidNist(0x05));\n","/**\n * NIP-054 proposal hash H, the message a vote carries.\n *\n * H = TaggedHash(\"NeuraiAssetAuthProposal\", m)\n * m = chainId (u8) || nVersion (i32) || nLockTime (u32) || T (u32)\n * || compact(c) || compact(a) || compact(b)\n * || (outpoint, nSequence) of inputs 0..c-1\n * || outputs 0..a-1 || the last b outputs\n * || compact(#refs) || reference inputs (version 3 only)\n *\n * Inputs from index c on and the outputs between the prefix and the suffix\n * (approvals, returns, fees, change) are left to the executor, so a skeleton\n * transaction with only the proposal inputs and outputs gives the same H as\n * the execution. Votes carry H as is, as the 32-byte (64-hex) message of\n * their owner-token transfer: `bytesToHex(hash)`.\n */\nimport { sha256 } from '@noble/hashes/sha2.js';\nimport { parseTransaction, serializeOutput } from '@neuraiproject/neurai-create-transaction';\nimport { concatBytes, hexToBytes } from '../../core/bytes.js';\n/** The chain identifier the node commits to (OP_CHAINCONTEXT selector 0x03). */\nexport const ASSETAUTH_CHAIN_IDS = Object.freeze({\n mainnet: 0,\n testnet: 1,\n regtest: 2\n});\nconst PROPOSAL_TAG = new TextEncoder().encode('NeuraiAssetAuthProposal');\nfunction u32(value) {\n const out = new Uint8Array(4);\n new DataView(out.buffer).setUint32(0, value >>> 0, true);\n return out;\n}\nfunction compactSize(value) {\n if (value < 0xfd)\n return Uint8Array.of(value);\n if (value <= 0xffff)\n return Uint8Array.of(0xfd, value & 0xff, value >> 8);\n return concatBytes(Uint8Array.of(0xfe), u32(value));\n}\n/** A display-order txid and vout as the node serializes a COutPoint. */\nfunction outpoint(txid, vout) {\n return concatBytes(hexToBytes(txid).reverse(), u32(vout));\n}\nexport function buildAssetAuthProposalMessage(proposal) {\n const { c, a, b, T } = proposal;\n const chainId = ASSETAUTH_CHAIN_IDS[proposal.chain];\n if (chainId === undefined) {\n throw new Error(`unknown chain ${JSON.stringify(proposal.chain)}`);\n }\n for (const [name, value] of Object.entries({ c, a, b, T })) {\n if (!Number.isInteger(value) || value < 0 || value > 0x7fffffff) {\n throw new Error(`${name} must be an integer from 0 to ${0x7fffffff}`);\n }\n }\n const tx = parseTransaction(proposal.rawTx);\n if (c > tx.inputs.length) {\n throw new Error(`c (${c}) exceeds the ${tx.inputs.length} inputs of the transaction`);\n }\n if (a + b > tx.outputs.length) {\n throw new Error(`a + b (${a + b}) exceeds the ${tx.outputs.length} outputs of the transaction`);\n }\n const version = new Uint8Array(4);\n new DataView(version.buffer).setInt32(0, tx.version, true);\n const parts = [Uint8Array.of(chainId), version, u32(tx.locktime), u32(T), compactSize(c), compactSize(a), compactSize(b)];\n for (const input of tx.inputs.slice(0, c)) {\n parts.push(outpoint(input.txid, input.vout), u32(input.sequence));\n }\n for (const output of [...tx.outputs.slice(0, a), ...tx.outputs.slice(tx.outputs.length - b)]) {\n parts.push(serializeOutput(output));\n }\n const refs = tx.version === 3 ? tx.vrefin : [];\n parts.push(compactSize(refs.length));\n for (const ref of refs)\n parts.push(outpoint(ref.txid, ref.vout));\n return concatBytes(...parts);\n}\n/** H: 32 bytes, in the order a vote carries it. */\nexport function assetAuthProposalHash(proposal) {\n const tag = sha256(PROPOSAL_TAG);\n return sha256(concatBytes(tag, tag, buildAssetAuthProposalMessage(proposal)));\n}\n","/**\n * NIP-054 vote lock: a wallet template (not part of the opcode) that holds a\n * role's owner token while it votes for a proposal.\n *\n * The holder sends the owner token, with the proposal hash H as its transfer\n * message, to the generic AuthScript v1 (NoAuth) address of this script:\n *\n * OP_IF execute, up to height T\n * OP_1 OP_CHAINCONTEXT <T> OP_LESSTHANOREQUAL OP_VERIFY\n * OP_SWAP OP_4 OP_INPUTFIELD <0x01 || C> OP_EQUALVERIFY\n * OP_OUTPUTSCRIPT <return> OP_EQUAL\n * OP_ELSE give it back, after T\n * OP_1 OP_CHAINCONTEXT <T> OP_GREATERTHAN OP_VERIFY\n * OP_NIP OP_OUTPUTSCRIPT <return> OP_EQUAL\n * OP_ENDIF\n *\n * Both branches send the token back to its owner (`return`, the full output\n * script). The execute branch also needs the custody, commitment C, at the\n * input it names. It must use OP_INPUTFIELD selector 04, the full\n * version-plus-commitment: selector 02 only reads the first 34 bytes of the\n * spent script, which a forged anyone-can-spend custody can match.\n */\nimport { hexToBytes, concatBytes } from '../../core/bytes.js';\nimport { CHAINCONTEXT_HEIGHT, OP_CHAINCONTEXT, OP_ELSE, OP_ENDIF, OP_EQUAL, OP_EQUALVERIFY, OP_GREATERTHAN, OP_IF, OP_INPUTFIELD, OP_LESSTHANOREQUAL, OP_NIP, OP_OUTPUTSCRIPT, OP_SWAP, OP_VERIFY } from '../../core/opcodes.js';\nimport { encodeScriptNum, ScriptBuilder } from '../../core/script-builder.js';\n/** OP_INPUTFIELD selector: the full version-plus-commitment of the spent script. */\nconst INPUTFIELD_AUTHSCRIPT_DESTINATION = 0x04;\nconst AUTHSCRIPT_V1 = 0x01;\nfunction asBytes(value) {\n return typeof value === 'string' ? hexToBytes(value) : value;\n}\nfunction assertIndex(name, value) {\n if (!Number.isInteger(value) || value < 0 || value > 0x7fffffff) {\n throw new Error(`${name} must be an integer from 0 to ${0x7fffffff}`);\n }\n}\nexport function buildAssetAuthVoteLockScript(params) {\n assertIndex('T', params.T);\n const commitment = asBytes(params.custodyCommitment);\n if (commitment.length !== 32) {\n throw new Error(`custodyCommitment must be 32 bytes (got ${commitment.length})`);\n }\n const returnScript = asBytes(params.returnScriptPubKey);\n if (returnScript.length === 0) {\n throw new Error('returnScriptPubKey must not be empty');\n }\n return new ScriptBuilder()\n .op(OP_IF)\n .pushInt(CHAINCONTEXT_HEIGHT).op(OP_CHAINCONTEXT).pushInt(params.T).op(OP_LESSTHANOREQUAL, OP_VERIFY)\n .op(OP_SWAP).pushInt(INPUTFIELD_AUTHSCRIPT_DESTINATION).op(OP_INPUTFIELD)\n .pushBytes(concatBytes(Uint8Array.of(AUTHSCRIPT_V1), commitment)).op(OP_EQUALVERIFY)\n .op(OP_OUTPUTSCRIPT).pushBytes(returnScript).op(OP_EQUAL)\n .op(OP_ELSE)\n .pushInt(CHAINCONTEXT_HEIGHT).op(OP_CHAINCONTEXT).pushInt(params.T).op(OP_GREATERTHAN, OP_VERIFY)\n .op(OP_NIP, OP_OUTPUTSCRIPT).pushBytes(returnScript).op(OP_EQUAL)\n .op(OP_ENDIF)\n .build();\n}\n/**\n * Witness `args` of the execute branch: the index of the custody input and\n * the index of the output that returns the token.\n */\nexport function buildAssetAuthVoteExecuteArgs(params) {\n assertIndex('custodyInput', params.custodyInput);\n assertIndex('returnOutput', params.returnOutput);\n return [encodeScriptNum(params.custodyInput), encodeScriptNum(params.returnOutput), encodeScriptNum(1)];\n}\n/** Witness `args` of the return branch, after T. */\nexport function buildAssetAuthVoteReturnArgs(params) {\n assertIndex('returnOutput', params.returnOutput);\n return [encodeScriptNum(0), encodeScriptNum(params.returnOutput), encodeScriptNum(0)];\n}\n"],"names":["ensureHex","hexToBytes","bytesToHex","concatBytes","toRawInteger","compactSize","ASSET_NAME_MAX","assertTokenId","assertPrice"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAS,CAAC,GAAG,EAAE,KAAK,GAAG,KAAK,EAAE;AAC9C,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;AAC7D,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;AACxE,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,iCAAiC,CAAC,CAAC;AAC5E,IAAI;AACJ,IAAI,OAAO,UAAU;AACrB;AACO,SAASC,YAAU,CAAC,GAAG,EAAE;AAChC,IAAI,MAAM,UAAU,GAAGD,WAAS,CAAC,GAAG,CAAC;AACrC,IAAI,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;AACvD,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AACnD,QAAQ,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC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AAC,CAAC,EAAE,CAAC,cAAc,EAAE,SAAS;AACxG,SAAS,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,QAAQ;AACxE,SAAS,EAAE,CAAC,QAAQ;AACpB,SAAS,KAAK,EAAE;AAChB;AACA;AACA;AACA;AACA;AACO,SAAS,6BAA6B,CAAC,MAAM,EAAE;AACtD,IAAI,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC;AACpD,IAAI,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC;AACpD,IAAI,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;AAC3G;AACA;AACO,SAAS,4BAA4B,CAAC,MAAM,EAAE;AACrD,IAAI,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC;AACpD,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;AACzF;;;;","x_google_ignoreList":[1,10,24,25,26,27]}
|
|
1
|
+
{"version":3,"file":"browser.js","sources":["../build/core/bytes.js","../node_modules/@neuraiproject/neurai-create-transaction/dist/amounts.js","../build/core/opcodes.js","../build/core/script-builder.js","../build/standard/p2pkh.js","../build/standard/p2wpkh.js","../build/standard/p2wsh.js","../build/standard/authscript.js","../build/standard/nulldata.js","../build/standard/multisig.js","../node_modules/@neuraiproject/neurai-create-transaction/dist/index.js","../build/address.js","../build/asset-wrapper.js","../build/core/script-parser.js","../build/covenants/partial-fill/expiration.js","../build/covenants/partial-fill/fill-branches.js","../build/covenants/partial-fill/script.js","../build/covenants/partial-fill/script-pq.js","../build/covenants/partial-fill/spend.js","../build/covenants/partial-fill/spend-pq.js","../build/covenants/partial-fill/witness.js","../build/covenants/partial-fill/parse.js","../build/covenants/partial-fill/parse-pq.js","../build/covenants/asset-auth/policy.js","../node_modules/@noble/hashes/_u64.js","../node_modules/@noble/hashes/utils.js","../node_modules/@noble/hashes/_md.js","../node_modules/@noble/hashes/sha2.js","../build/covenants/asset-auth/proposal.js","../build/covenants/asset-auth/vote.js"],"sourcesContent":["/**\n * Minimal byte helpers. A subset of what `neurai-create-transaction` exposes,\n * duplicated here to keep this package free of runtime coupling beyond its\n * declared `dependencies` field. All sizes are little-endian, per Neurai.\n */\nexport function ensureHex(hex, label = 'hex') {\n const normalized = String(hex || '').trim().toLowerCase();\n if (!/^[0-9a-f]*$/.test(normalized) || normalized.length % 2 !== 0) {\n throw new Error(`Invalid ${label}: expected even-length hex string`);\n }\n return normalized;\n}\nexport function hexToBytes(hex) {\n const normalized = ensureHex(hex);\n const bytes = new Uint8Array(normalized.length / 2);\n for (let i = 0; i < normalized.length; i += 2) {\n bytes[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16);\n }\n return bytes;\n}\nexport function bytesToHex(bytes) {\n return Array.from(bytes, (value) => value.toString(16).padStart(2, '0')).join('');\n}\nexport function concatBytes(...parts) {\n const total = parts.reduce((sum, part) => sum + part.length, 0);\n const out = new Uint8Array(total);\n let offset = 0;\n for (const part of parts) {\n out.set(part, offset);\n offset += part.length;\n }\n return out;\n}\nexport function bytesEqual(a, b) {\n if (a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i += 1) {\n if (a[i] !== b[i])\n return false;\n }\n return true;\n}\n","/** Exact monetary primitives. This module has no runtime dependencies. */\nconst SATS_PER_XNA = 100000000n;\nconst MAX_MONEY = 2100000000000000000n;\n/** Normalize a raw integer without preserving an already rounded number. */\nfunction toRawInteger(value, label = 'amount') {\n if (typeof value === 'bigint')\n return value;\n if (typeof value === 'number' && Number.isSafeInteger(value))\n return BigInt(value);\n if (typeof value === 'string' && /^-?\\d+$/.test(value) && value.length <= 100)\n return BigInt(value);\n throw new Error(`${label}: expected an exact integer; use bigint or an integer string for large values`);\n}\nfunction assertMoneyRange(value, label = 'amount') {\n const raw = toRawInteger(value, label);\n if (raw < 0n || raw > MAX_MONEY)\n throw new Error(`${label} outside Neurai monetary range`);\n return raw;\n}\n/** Parse decimal units exactly, including scientific notation, with at most 8 decimals. */\nfunction decimalToSatoshis(value) {\n if (typeof value !== 'string' && typeof value !== 'number')\n throw new Error('Expected decimal string or number');\n if (typeof value === 'number' && !Number.isFinite(value))\n throw new Error('Amount must be finite');\n const text = String(value);\n if (text.length > 100)\n throw new Error('Amount too long');\n const match = /^(-?)(\\d+)(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/.exec(text);\n if (!match)\n throw new Error('Invalid decimal amount');\n const exponent = Number(match[4] ?? 0);\n if (!Number.isSafeInteger(exponent) || Math.abs(exponent) > 100)\n throw new Error('Invalid decimal exponent');\n const fraction = match[3] ?? '';\n const shift = 8 + exponent - fraction.length;\n let raw = BigInt(match[2] + fraction);\n if (shift >= 0)\n raw *= 10n ** BigInt(shift);\n else {\n const divisor = 10n ** BigInt(-shift);\n if (raw % divisor !== 0n)\n throw new Error('Amount has more than 8 decimals');\n raw /= divisor;\n }\n if (typeof value === 'number' && raw > BigInt(Number.MAX_SAFE_INTEGER) && !Number.isSafeInteger(value)) {\n throw new Error('Large fractional amounts must be supplied as decimal strings');\n }\n return match[1] ? -raw : raw;\n}\n/** Format signed raw units without converting to floating point. */\nfunction satoshisToDecimal(value) {\n const raw = toRawInteger(value);\n const abs = raw < 0n ? -raw : raw;\n const fraction = (abs % SATS_PER_XNA).toString().padStart(8, '0').replace(/0+$/, '');\n return `${raw < 0n ? '-' : ''}${abs / SATS_PER_XNA}${fraction ? '.' + fraction : ''}`;\n}\n\nexport { MAX_MONEY, SATS_PER_XNA, assertMoneyRange, decimalToSatoshis, satoshisToDecimal, toRawInteger };\n","/**\n * Opcode constants for Neurai Script.\n *\n * Covers:\n * - Classic Script opcodes used by covenants.\n * - New opcodes activated in the `DePIN-Test` branch (BIP 119, BIP 347 and\n * Neurai-specific introspection / asset / arithmetic additions).\n *\n * Authority: `src/script/script.h` (enum `opcodetype`) in the Neurai repo.\n * Reference: `doc/new-opcodes-depin-branch.md`.\n *\n * Disabled in consensus and intentionally omitted: OP_SUBSTR, OP_LEFT,\n * OP_RIGHT, OP_INVERT, OP_AND, OP_OR, OP_XOR, OP_2MUL, OP_2DIV, OP_LSHIFT,\n * OP_RSHIFT. Also omitted: OP_VER / OP_VERIF / OP_VERNOTIF (reserved), the\n * template-matching pseudo-opcodes (OP_SMALLINTEGER, OP_PUBKEYS,\n * OP_PUBKEYHASH, OP_PUBKEY) and OP_INVALIDOPCODE.\n */\n// ---------- Push values ----------\nexport const OP_0 = 0x00;\nexport const OP_FALSE = OP_0;\nexport const OP_PUSHDATA1 = 0x4c;\nexport const OP_PUSHDATA2 = 0x4d;\nexport const OP_PUSHDATA4 = 0x4e;\nexport const OP_1NEGATE = 0x4f;\nexport const OP_RESERVED = 0x50;\nexport const OP_1 = 0x51;\nexport const OP_TRUE = OP_1;\nexport const OP_2 = 0x52;\nexport const OP_3 = 0x53;\nexport const OP_4 = 0x54;\nexport const OP_5 = 0x55;\nexport const OP_6 = 0x56;\nexport const OP_7 = 0x57;\nexport const OP_8 = 0x58;\nexport const OP_9 = 0x59;\nexport const OP_10 = 0x5a;\nexport const OP_11 = 0x5b;\nexport const OP_12 = 0x5c;\nexport const OP_13 = 0x5d;\nexport const OP_14 = 0x5e;\nexport const OP_15 = 0x5f;\nexport const OP_16 = 0x60;\n// ---------- Control flow ----------\nexport const OP_NOP = 0x61;\nexport const OP_IF = 0x63;\nexport const OP_NOTIF = 0x64;\nexport const OP_ELSE = 0x67;\nexport const OP_ENDIF = 0x68;\nexport const OP_VERIFY = 0x69;\nexport const OP_RETURN = 0x6a;\n// ---------- Stack ----------\nexport const OP_TOALTSTACK = 0x6b;\nexport const OP_FROMALTSTACK = 0x6c;\nexport const OP_2DROP = 0x6d;\nexport const OP_2DUP = 0x6e;\nexport const OP_3DUP = 0x6f;\nexport const OP_2OVER = 0x70;\nexport const OP_2ROT = 0x71;\nexport const OP_2SWAP = 0x72;\nexport const OP_IFDUP = 0x73;\nexport const OP_DEPTH = 0x74;\nexport const OP_DROP = 0x75;\nexport const OP_DUP = 0x76;\nexport const OP_NIP = 0x77;\nexport const OP_OVER = 0x78;\nexport const OP_PICK = 0x79;\nexport const OP_ROLL = 0x7a;\nexport const OP_ROT = 0x7b;\nexport const OP_SWAP = 0x7c;\nexport const OP_TUCK = 0x7d;\n// ---------- Splice ----------\nexport const OP_SIZE = 0x82;\n// ---------- Bitwise / comparison ----------\nexport const OP_EQUAL = 0x87;\nexport const OP_EQUALVERIFY = 0x88;\n// ---------- Unary numeric ----------\nexport const OP_1ADD = 0x8b;\nexport const OP_1SUB = 0x8c;\nexport const OP_NEGATE = 0x8f;\nexport const OP_ABS = 0x90;\nexport const OP_NOT = 0x91;\nexport const OP_0NOTEQUAL = 0x92;\n// ---------- Arithmetic (64-bit after SCRIPT_VERIFY_64BIT_INTEGERS) ----------\nexport const OP_ADD = 0x93;\nexport const OP_SUB = 0x94;\nexport const OP_MUL = 0x95;\nexport const OP_DIV = 0x96;\nexport const OP_MOD = 0x97;\n// ---------- Boolean / numeric comparison ----------\nexport const OP_BOOLAND = 0x9a;\nexport const OP_BOOLOR = 0x9b;\nexport const OP_NUMEQUAL = 0x9c;\nexport const OP_NUMEQUALVERIFY = 0x9d;\nexport const OP_NUMNOTEQUAL = 0x9e;\nexport const OP_LESSTHAN = 0x9f;\nexport const OP_GREATERTHAN = 0xa0;\nexport const OP_LESSTHANOREQUAL = 0xa1;\nexport const OP_GREATERTHANOREQUAL = 0xa2;\nexport const OP_MIN = 0xa3;\nexport const OP_MAX = 0xa4;\nexport const OP_WITHIN = 0xa5;\n// ---------- Crypto ----------\nexport const OP_RIPEMD160 = 0xa6;\nexport const OP_SHA1 = 0xa7;\nexport const OP_SHA256 = 0xa8;\nexport const OP_HASH160 = 0xa9;\nexport const OP_HASH256 = 0xaa;\nexport const OP_CODESEPARATOR = 0xab;\nexport const OP_CHECKSIG = 0xac;\nexport const OP_CHECKSIGVERIFY = 0xad;\nexport const OP_CHECKMULTISIG = 0xae;\nexport const OP_CHECKMULTISIGVERIFY = 0xaf;\n// ---------- Extended hash opcodes ----------\n// NIP-030: KECCAK256 / BLAKE2B in previously unassigned slots.\nexport const OP_KECCAK256 = 0xba;\nexport const OP_BLAKE2B = 0xbb;\n// NIP-034a: modern hash opcodes (BLAKE3, SHA3-256, SHA-512).\n// NIP-036: OP_POSEIDON — SNARK-friendly Poseidon hash over the BN254\n// scalar field. Occupies slot 0xc9.\nexport const OP_BLAKE3 = 0xc8;\nexport const OP_POSEIDON = 0xc9;\nexport const OP_SHA3_256 = 0xca;\nexport const OP_SHA512 = 0xcb;\n// ---------- Extended signature opcodes ----------\n// NIP-035: strict-profile RFC 8032 PureEd25519 verifier in slot 0xdd.\n// Stack contract: (sig64, msg, pubkey32 -- 0|1). Slots 0xd8..0xdc are\n// reserved by NIP-033 (BLS12-381 family), unassigned in current code.\nexport const OP_CHECKSIG_ED25519 = 0xdd;\n// NIP-039: generic OP_CHECKSIG-compatible signature accumulator in slot\n// 0xde. Stack contract: (sig, count, pubkey -- count + 0|1). Works with\n// both legacy secp256k1 and PQ ML-DSA-44 keys via CPubKey::Verify().\nexport const OP_CHECKSIGADD = 0xde;\n// NIP-054 (P2AH): M-of-N authorization by owner-token roles in slot 0xdf,\n// AuthScript only. Stack contract: (c a b T 1 M G role_1 .. role_n n -- 1),\n// failing the script instead of pushing 0. See covenants/asset-auth.\nexport const OP_CHECKASSETAUTH = 0xdf;\n// NIP-060: verify a compact P-256 signature over SHA-256(message).\nexport const OP_CHECKSIG_P256 = 0xe0;\n// ---------- Expansion / NOPs ----------\n// Only the NOPs not aliased by DePIN-Test opcodes are exported as NOPs.\n// OP_NOP2 == OP_CHECKLOCKTIMEVERIFY (0xb1)\n// OP_NOP3 == OP_CHECKSEQUENCEVERIFY (0xb2)\n// OP_NOP4 == OP_CHECKTEMPLATEVERIFY (0xb3)\n// OP_NOP5 == OP_CHECKSIGFROMSTACK (0xb4)\n// OP_NOP6 == OP_TXHASH (0xb5)\n// OP_NOP7 == OP_TXFIELD (0xb6)\n// OP_NOP8 == OP_SPLIT (0xb7)\nexport const OP_NOP1 = 0xb0;\nexport const OP_NOP9 = 0xb8;\nexport const OP_NOP10 = 0xb9;\n// ---------- Locktime ----------\nexport const OP_CHECKLOCKTIMEVERIFY = 0xb1;\nexport const OP_CHECKSEQUENCEVERIFY = 0xb2;\n// ---------- Covenants & templates (DePIN-Test) ----------\nexport const OP_CHECKTEMPLATEVERIFY = 0xb3; // BIP 119\nexport const OP_CHECKSIGFROMSTACK = 0xb4;\n// ---------- Transaction introspection (DePIN-Test) ----------\nexport const OP_TXHASH = 0xb5;\nexport const OP_TXFIELD = 0xb6;\nexport const OP_TXLOCKTIME = 0xc5;\nexport const OP_OUTPUTVALUE = 0xcc;\nexport const OP_OUTPUTSCRIPT = 0xcd;\nexport const OP_INPUTCOUNT = 0xd0;\nexport const OP_OUTPUTCOUNT = 0xd1;\n// ---------- Asset introspection (DePIN-Test) ----------\nexport const OP_OUTPUTASSETFIELD = 0xce;\nexport const OP_INPUTASSETFIELD = 0xcf;\nexport const OP_XNA_ASSET = 0xc0;\n// ---------- Reference inputs (DePIN-Test, NIP-017) ----------\nexport const OP_REFINPUTFIELD = 0xd2;\nexport const OP_REFINPUTASSETFIELD = 0xd3;\nexport const OP_REFINPUTCOUNT = 0xd4;\n// ---------- Output auth commitment introspection (NIP-023) ----------\n// Pushes the 32-byte AuthScript v1 commitment of a selected output's\n// scriptPubKey. Symmetric to TXFIELD_AUTHSCRIPT_COMMITMENT for inputs;\n// ignores any trailing OP_XNA_ASSET asset wrapper bytes.\nexport const OP_OUTPUTAUTHCOMMITMENT = 0xd5;\n// ---------- Input value introspection (NIP-024) ----------\n// Pushes the satoshi value of a selected input's spent prevout.\nexport const OP_INPUTVALUE = 0xd6;\n// ---------- Chain context introspection (NIP-026) ----------\n// Pushes chain-context fields (block height, median time, etc.) selected\n// by a single-byte selector consumed from the stack.\nexport const OP_CHAINCONTEXT = 0xd7;\n// ---------- Selectors for OP_CHAINCONTEXT ----------\n// Valid selector bytes consumed by OP_CHAINCONTEXT. HEIGHT is the candidate\n// confirmation block height; MTP is the previous block's median time past.\nexport const CHAINCONTEXT_HEIGHT = 0x01;\nexport const CHAINCONTEXT_MTP = 0x02;\nexport const CHAINCONTEXT_CHAIN_ID = 0x03;\n// ---------- Merkle inclusion (NIP-031) ----------\n// Native Merkle inclusion verifier. Consumes (leaf, scheme_id, proof,\n// root) and pushes a boolean. Flag off → bad-opcode.\nexport const OP_CHECKMERKLEINCLUSION = 0xc1;\n// NIP-041: (outputIndex -- witnessVersion || 32-byte program).\nexport const OP_OUTPUTAUTHDEST = 0xc2;\n// NIP-018: verifies an AuthScript proof and returns a boolean.\nexport const OP_ZKVERIFY = 0xc3;\n// NIP-043: spent-input field introspection, distinct from reference inputs.\nexport const OP_INPUTFIELD = 0xc4;\n// ---------- Byte manipulation (DePIN-Test) ----------\nexport const OP_CAT = 0x7e;\nexport const OP_SPLIT = 0xb7;\nexport const OP_REVERSEBYTES = 0xbc;\n// ---------- Selectors for OP_TXFIELD / OP_REFINPUTFIELD ----------\n// OP_TXFIELD, OP_INPUTFIELD and OP_REFINPUTFIELD share selectors 0x01..0x03.\n// NIP-041 adds 0x04 for a strict 33-byte AuthScript destination.\nexport const TXFIELD_VALUE = 0x01;\nexport const TXFIELD_AUTHSCRIPT_COMMITMENT = 0x02;\nexport const TXFIELD_SCRIPTPUBKEY = 0x03;\nexport const TXFIELD_AUTHDEST = 0x04;\n// ---------- Bitmask selectors for OP_TXHASH ----------\n// NIP-042 requires a two-byte little-endian selector, even for low masks.\n// Bits 0..8 select fields for the tagged NeuraiTxHash digest. Valid masks\n// are 0x001..0x1ff; zero and all higher bits are rejected by consensus.\nexport const TXHASH_VERSION = 0x01;\nexport const TXHASH_LOCKTIME = 0x02;\nexport const TXHASH_INPUT_PREVOUTS = 0x04;\nexport const TXHASH_INPUT_SEQUENCES = 0x08;\nexport const TXHASH_OUTPUTS = 0x10;\nexport const TXHASH_CURRENT_PREVOUT = 0x20;\nexport const TXHASH_CURRENT_SEQUENCE = 0x40;\nexport const TXHASH_CURRENT_INDEX = 0x80;\nexport const TXHASH_REFINPUTS = 0x100;\nexport const TXHASH_ALL = 0x1ff;\n// ---------- Selectors for OP_OUTPUTASSETFIELD / OP_INPUTASSETFIELD / OP_REFINPUTASSETFIELD ----------\n// All three opcodes share this selector table. 0x08 is gated by NIP-043\n// and extracts the optional transfer message from a strict asset wrapper.\nexport const ASSETFIELD_NAME = 0x01;\nexport const ASSETFIELD_AMOUNT = 0x02;\nexport const ASSETFIELD_UNITS = 0x03;\nexport const ASSETFIELD_REISSUABLE = 0x04;\nexport const ASSETFIELD_HAS_IPFS = 0x05;\nexport const ASSETFIELD_IPFS_HASH = 0x06;\nexport const ASSETFIELD_TYPE = 0x07;\nexport const ASSETFIELD_MESSAGE = 0x08;\n// NIP-031/043 Merkle inclusion scheme identifiers.\nexport const MERKLE_SCHEME_BITCOIN_NEURAI = 0x01;\nexport const MERKLE_SCHEME_SHA256_PLAIN = 0x02;\nexport const MERKLE_SCHEME_KECCAK256_PLAIN = 0x03;\nexport const MERKLE_SCHEME_BLAKE2B_PLAIN = 0x04;\nexport const MERKLE_SCHEME_POSEIDON_BN254 = 0x05;\n","import { toRawInteger } from '@neuraiproject/neurai-create-transaction/amounts';\n/**\n * Low-level Script assembler. Emits the exact byte layout expected by the\n * Neurai interpreter: pushdata prefixes follow the same rules as Bitcoin\n * (direct push for 1..75 bytes, OP_PUSHDATA1/2/4 otherwise), and integers\n * are minimally-encoded as CScriptNum.\n */\nimport { bytesToHex, concatBytes, hexToBytes } from './bytes.js';\nimport { OP_0, OP_1NEGATE, OP_1 } from './opcodes.js';\n/**\n * Minimal CScriptNum encoding (Bitcoin consensus rules).\n *\n * - 0 → empty vector\n * - 1..16 → single opcode OP_1..OP_16 (handled in `pushInt`, not here)\n * - -1 → OP_1NEGATE (handled in `pushInt`)\n * - otherwise: sign-magnitude little-endian, with a sign bit on the last byte\n */\nexport function encodeScriptNum(value) {\n let n = toRawInteger(value, 'ScriptNum');\n if (n === 0n)\n return new Uint8Array();\n const negative = n < 0n;\n if (negative)\n n = -n;\n const result = [];\n while (n > 0n) {\n result.push(Number(n & 0xffn));\n n >>= 8n;\n }\n // If the most-significant bit is set, add a padding byte so the sign bit\n // is unambiguous. If negative, flip that sign bit instead.\n if (result[result.length - 1] & 0x80) {\n result.push(negative ? 0x80 : 0x00);\n }\n else if (negative) {\n result[result.length - 1] |= 0x80;\n }\n return Uint8Array.from(result);\n}\n/**\n * Emit a pushdata opcode followed by the payload. Chooses the shortest\n * valid encoding.\n *\n * Neurai Script caps stack elements at `MAX_SCRIPT_ELEMENT_SIZE = 520`\n * bytes by default, but NIP-18 raises the cap to\n * `MAX_PQ_SCRIPT_ELEMENT_SIZE = 3072` whenever\n * `SCRIPT_VERIFY_CHECKSIGFROMSTACK` is active (testnet today, mainnet once\n * the CSFS fork lands). The builder here emits pushes up to 3072 bytes so\n * it can target either regime; legacy scripts should stay under 520 bytes\n * per push, and the node will reject anything larger if the CSFS flag is\n * not set during evaluation.\n */\nexport function pushBytes(data) {\n if (data.length === 0) {\n return Uint8Array.of(OP_0);\n }\n if (data.length <= 75) {\n return concatBytes(Uint8Array.of(data.length), data);\n }\n if (data.length <= 0xff) {\n return concatBytes(Uint8Array.of(0x4c, data.length), data);\n }\n if (data.length <= 3072) {\n return concatBytes(Uint8Array.of(0x4d, data.length & 0xff, (data.length >> 8) & 0xff), data);\n }\n throw new Error(`pushBytes: element of ${data.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (3072)`);\n}\n/**\n * Emit a minimally-encoded integer push. Uses OP_1NEGATE, OP_0 and OP_1..OP_16\n * when available to match how the node's own templates look on the wire.\n */\nexport function pushInt(value) {\n const n = toRawInteger(value, 'ScriptNum');\n if (n === -1n)\n return Uint8Array.of(OP_1NEGATE);\n if (n === 0n)\n return Uint8Array.of(OP_0);\n if (n >= 1n && n <= 16n) {\n return Uint8Array.of(OP_1 + Number(n) - 1);\n }\n return pushBytes(encodeScriptNum(n));\n}\nexport function pushHex(hex) {\n return pushBytes(hexToBytes(hex));\n}\n/** Fluent assembler for readable script definitions. */\nexport class ScriptBuilder {\n parts = [];\n op(...opcodes) {\n for (const op of opcodes) {\n if (!Number.isInteger(op) || op < 0 || op > 0xff) {\n throw new Error(`Invalid opcode byte: ${op}`);\n }\n this.parts.push(Uint8Array.of(op));\n }\n return this;\n }\n pushInt(value) {\n this.parts.push(pushInt(value));\n return this;\n }\n pushBytes(data) {\n this.parts.push(pushBytes(data));\n return this;\n }\n pushHex(hex) {\n this.parts.push(pushHex(hex));\n return this;\n }\n raw(bytes) {\n this.parts.push(bytes);\n return this;\n }\n build() {\n return concatBytes(...this.parts);\n }\n buildHex() {\n return bytesToHex(this.build());\n }\n}\n","/**\n * Pay-to-Public-Key-Hash (P2PKH) scriptPubKey.\n * Layout: OP_DUP OP_HASH160 0x14 <20-byte PKH> OP_EQUALVERIFY OP_CHECKSIG\n */\nimport { concatBytes } from '../core/bytes.js';\nimport { OP_CHECKSIG, OP_DUP, OP_EQUALVERIFY, OP_HASH160 } from '../core/opcodes.js';\nexport function encodeP2PKHScriptPubKey(pubKeyHash) {\n if (!(pubKeyHash instanceof Uint8Array) || pubKeyHash.length !== 20) {\n throw new Error('P2PKH pubKeyHash must be a 20-byte Uint8Array');\n }\n return concatBytes(Uint8Array.of(OP_DUP, OP_HASH160, 0x14), pubKeyHash, Uint8Array.of(OP_EQUALVERIFY, OP_CHECKSIG));\n}\n","/**\n * Native segwit v0 Pay-to-Witness-Public-Key-Hash (P2WPKH) scriptPubKey.\n * Layout: OP_0 0x14 <20-byte HASH160(pubKey)>\n *\n * Callers compute HASH160 externally (e.g. via neurai-key / their crypto\n * stack). This helper only encodes the scriptPubKey once the hash is known.\n */\nimport { concatBytes } from '../core/bytes.js';\nimport { OP_0 } from '../core/opcodes.js';\nexport function encodeP2WPKHScriptPubKey(pubKeyHash) {\n if (!(pubKeyHash instanceof Uint8Array) || pubKeyHash.length !== 20) {\n throw new Error('P2WPKH pubKeyHash must be a 20-byte Uint8Array');\n }\n return concatBytes(Uint8Array.of(OP_0, 0x14), pubKeyHash);\n}\n","/**\n * Native segwit v0 Pay-to-Witness-Script-Hash (P2WSH) scriptPubKey.\n * Layout: OP_0 0x20 <32-byte SHA256(witnessScript)>\n *\n * This helper takes the SHA256 digest of the witness script directly. The\n * SHA256 is computed externally by the caller's crypto stack (kept out of\n * this library to avoid a hash dependency).\n */\nimport { concatBytes } from '../core/bytes.js';\nimport { OP_0 } from '../core/opcodes.js';\nexport function encodeP2WSHScriptPubKey(witnessScriptSha256) {\n if (!(witnessScriptSha256 instanceof Uint8Array) || witnessScriptSha256.length !== 32) {\n throw new Error('P2WSH witnessScriptSha256 must be a 32-byte Uint8Array');\n }\n return concatBytes(Uint8Array.of(OP_0, 0x20), witnessScriptSha256);\n}\n","/**\n * AuthScript scriptPubKey + witness-stack builders.\n *\n * AuthScript outputs encode a 32-byte commitment in a witness program:\n * scriptPubKey = OP_n 0x20 <32-byte program>\n *\n * OP_1 generic AuthScript v1 (nc1p… / tnc1p…): any auth type, any witnessScript\n * OP_2 strict PQ v2 (pq1z… / tpq1z…): auth type 0x01, witnessScript OP_TRUE\n * OP_3 strict ECDSA v3 (nq1r… / tnq1r…): auth type 0x02, witnessScript OP_TRUE\n *\n * The witness version is also the first byte of the commitment preimage:\n * tagged_hash(\"NeuraiAuthScript\", version || auth_descriptor || SHA256(witnessScript))\n *\n * The program is `HASH160`/`SHA256` over a descriptor that depends on the\n * `auth_type` byte carried as the first witness-stack element at spend time.\n * This library only assembles the stack; computing the descriptor/commitment\n * and producing the signature live in neurai-key / neurai-sign-transaction.\n *\n * Auth type values (authoritative: Neurai `src/script/interpreter.cpp`,\n * cross-checked against `lib/neurai-key/src/shared/address.ts`):\n *\n * 0x00 NoAuth — no signature; spend gated only by witnessScript\n * 0x01 PQ — ML-DSA-44 signature (post-quantum)\n * 0x02 Legacy — secp256k1 ECDSA signature (classic)\n * 0x03 RefScript — NIP-015 reference-script spend (future)\n *\n * Witness stack (exact order consumed by the interpreter):\n * [ auth_type, sig, pubkey, arg0, ..., argN, witnessScript ]\n *\n * NoAuth and RefScript spends omit the `sig`/`pubkey` items.\n */\nimport { concatBytes } from '../core/bytes.js';\nimport { OP_1, OP_2, OP_3, OP_TRUE } from '../core/opcodes.js';\nexport const AUTHSCRIPT_NOAUTH = 0x00;\nexport const AUTHSCRIPT_PQ = 0x01;\nexport const AUTHSCRIPT_LEGACY = 0x02;\n/** NIP-015: reference-script spend mode. Not yet activated in consensus. */\nexport const AUTHSCRIPT_REF = 0x03;\n/** Cap for PQ signature / pubkey pushes under NIP-018 (3072 B). */\nconst MAX_PQ_PUSH = 3072;\nconst WITNESS_VERSION_OPCODE = {\n 1: OP_1,\n 2: OP_2,\n 3: OP_3\n};\n/**\n * `OP_n 0x20 <program>` for witness version `n`. Defaults to the generic\n * AuthScript v1 (`OP_1`), which is what every covenant commits to.\n */\nexport function encodeAuthScriptScriptPubKey(program, witnessVersion = 1) {\n if (!(program instanceof Uint8Array) || program.length !== 32) {\n throw new Error('AuthScript program must be a 32-byte Uint8Array');\n }\n const opcode = WITNESS_VERSION_OPCODE[witnessVersion];\n if (opcode === undefined) {\n throw new Error(`AuthScript witness version must be 1, 2 or 3, got ${String(witnessVersion)}`);\n }\n return concatBytes(Uint8Array.of(opcode, 0x20), program);\n}\nfunction assertWitnessScript(ws) {\n if (!(ws instanceof Uint8Array) || ws.length === 0) {\n throw new Error('witnessScript must be a non-empty Uint8Array');\n }\n}\nfunction assertArgs(args) {\n if (args == null)\n return;\n if (!Array.isArray(args)) {\n throw new Error('args must be an array of Uint8Array');\n }\n for (let i = 0; i < args.length; i += 1) {\n if (!(args[i] instanceof Uint8Array)) {\n throw new Error(`args[${i}] must be a Uint8Array`);\n }\n }\n}\n/**\n * Build the witness stack for a legacy ECDSA AuthScript spend.\n *\n * Returns an array of raw stack elements. Serialization of the witness\n * (compact-size item count + per-item length-prefixes) is the caller's\n * responsibility — neurai-create-transaction handles it at tx-assembly time.\n */\nexport function buildAuthScriptWitnessLegacy(input) {\n if (!(input.signature instanceof Uint8Array) || input.signature.length === 0) {\n throw new Error('signature must be a non-empty Uint8Array');\n }\n if (!(input.pubKey instanceof Uint8Array) ||\n (input.pubKey.length !== 33 && input.pubKey.length !== 65)) {\n throw new Error('pubKey must be a compressed (33B) or uncompressed (65B) secp256k1 key');\n }\n assertArgs(input.args);\n assertWitnessScript(input.witnessScript);\n return [\n Uint8Array.of(AUTHSCRIPT_LEGACY),\n input.signature,\n input.pubKey,\n ...(input.args ?? []),\n input.witnessScript\n ];\n}\n/**\n * Build the witness stack for a PQ (ML-DSA-44) AuthScript spend.\n * NIP-018 must be active: both signature and pubKey are pushed as single\n * stack elements and may each be up to 3072 B.\n */\nexport function buildAuthScriptWitnessPQ(input) {\n if (!(input.signature instanceof Uint8Array) || input.signature.length === 0) {\n throw new Error('signature must be a non-empty Uint8Array');\n }\n if (input.signature.length > MAX_PQ_PUSH) {\n throw new Error(`signature of ${input.signature.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (${MAX_PQ_PUSH})`);\n }\n if (!(input.pubKey instanceof Uint8Array) || input.pubKey.length === 0) {\n throw new Error('pubKey must be a non-empty Uint8Array');\n }\n if (input.pubKey.length > MAX_PQ_PUSH) {\n throw new Error(`pubKey of ${input.pubKey.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (${MAX_PQ_PUSH})`);\n }\n assertArgs(input.args);\n assertWitnessScript(input.witnessScript);\n return [\n Uint8Array.of(AUTHSCRIPT_PQ),\n input.signature,\n input.pubKey,\n ...(input.args ?? []),\n input.witnessScript\n ];\n}\n/** Length of the versioned ML-DSA-44 pubkey the node expects (0x05 prefix + 1312 B). */\nexport const STRICT_PQ_PUBKEY_LENGTH = 1313;\n/** Version prefix of an ML-DSA-44 pubkey on the witness stack. */\nexport const PQ_PUBKEY_PREFIX = 0x05;\n/**\n * Witness stack for spending a strict PQ witness v2 output (`pq1z…`):\n * exactly `[0x01, sig, pubKey, OP_TRUE]`. The node rejects any other\n * shape (extra arguments, another witnessScript) for the strict families.\n */\nexport function buildStrictWitnessPQ(input) {\n if (!(input.signature instanceof Uint8Array) || input.signature.length === 0) {\n throw new Error('signature must be a non-empty Uint8Array');\n }\n if (input.signature.length > MAX_PQ_PUSH) {\n throw new Error(`signature of ${input.signature.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (${MAX_PQ_PUSH})`);\n }\n if (!(input.pubKey instanceof Uint8Array) ||\n input.pubKey.length !== STRICT_PQ_PUBKEY_LENGTH ||\n input.pubKey[0] !== PQ_PUBKEY_PREFIX) {\n throw new Error(`pubKey must be the ${STRICT_PQ_PUBKEY_LENGTH}-byte versioned ML-DSA-44 key (0x05 prefix)`);\n }\n return [Uint8Array.of(AUTHSCRIPT_PQ), input.signature, input.pubKey, Uint8Array.of(OP_TRUE)];\n}\n/**\n * Witness stack for spending a strict ECDSA witness v3 output (`nq1r…`):\n * exactly `[0x02, sig, pubKey33, OP_TRUE]`. The node rejects uncompressed\n * keys for this family.\n */\nexport function buildStrictWitnessECDSA(input) {\n if (!(input.signature instanceof Uint8Array) || input.signature.length === 0) {\n throw new Error('signature must be a non-empty Uint8Array');\n }\n if (!(input.pubKey instanceof Uint8Array) ||\n input.pubKey.length !== 33 ||\n (input.pubKey[0] !== 0x02 && input.pubKey[0] !== 0x03)) {\n throw new Error('pubKey must be a compressed (33B) secp256k1 key for strict ECDSA witness v3');\n }\n return [Uint8Array.of(AUTHSCRIPT_LEGACY), input.signature, input.pubKey, Uint8Array.of(OP_TRUE)];\n}\n/**\n * Build the witness stack for a NoAuth AuthScript spend. The spend is gated\n * by the witnessScript alone (covenants, hash-locks, time-locks, ...); no\n * signature or public key is carried.\n */\nexport function buildAuthScriptWitnessNoAuth(input) {\n assertArgs(input.args);\n assertWitnessScript(input.witnessScript);\n return [\n Uint8Array.of(AUTHSCRIPT_NOAUTH),\n ...(input.args ?? []),\n input.witnessScript\n ];\n}\n/**\n * Build the witness stack for a NIP-015 reference-script spend. The last\n * item is the 4-byte little-endian index into `tx.vrefin` that locates the\n * reference-script carrier output; the interpreter resolves the `refScript`\n * from that carrier at validation time.\n *\n * NOTE: NIP-015 is not yet activated in consensus. This builder emits the\n * spec-conformant witness for forward compatibility and testnet experiments.\n */\nexport function buildAuthScriptWitnessRef(input) {\n if (!Number.isInteger(input.refIndex) || input.refIndex < 0 || input.refIndex > 0xffffffff) {\n throw new Error('refIndex must be a uint32 (0 .. 2^32 - 1)');\n }\n assertArgs(input.args);\n const refLocator = new Uint8Array(4);\n const dv = new DataView(refLocator.buffer);\n dv.setUint32(0, input.refIndex, /* little-endian */ true);\n return [\n Uint8Array.of(AUTHSCRIPT_REF),\n ...(input.args ?? []),\n refLocator\n ];\n}\n","/**\n * Provably-unspendable OP_RETURN (null-data) output scripts.\n * Layout: OP_RETURN <push> [<push> ...]\n *\n * Neurai inherits the Bitcoin Core standard policy cap of 80 bytes of\n * payload for a relayed null-data output. Outputs over that cap are still\n * consensus-valid but will not be relayed by default mempool policy; use\n * the `allowNonStandard` option to opt in explicitly.\n */\nimport { concatBytes } from '../core/bytes.js';\nimport { pushBytes } from '../core/script-builder.js';\nimport { OP_RETURN } from '../core/opcodes.js';\nexport const NULLDATA_STANDARD_MAX_SIZE = 80;\nexport function encodeNullDataScript(payload, options = {}) {\n const payloads = payload instanceof Uint8Array ? [payload] : payload;\n if (!Array.isArray(payloads) || payloads.length === 0) {\n throw new Error('payload must be a Uint8Array or a non-empty array of Uint8Array');\n }\n let totalPayload = 0;\n for (let i = 0; i < payloads.length; i += 1) {\n const p = payloads[i];\n if (!(p instanceof Uint8Array)) {\n throw new Error(`payload[${i}] must be a Uint8Array`);\n }\n totalPayload += p.length;\n }\n if (!options.allowNonStandard && totalPayload > NULLDATA_STANDARD_MAX_SIZE) {\n throw new Error(`nulldata payload of ${totalPayload} bytes exceeds standard cap ${NULLDATA_STANDARD_MAX_SIZE}; set allowNonStandard=true to override`);\n }\n const parts = [Uint8Array.of(OP_RETURN)];\n for (const p of payloads)\n parts.push(pushBytes(p));\n return concatBytes(...parts);\n}\n","/**\n * Classic bare m-of-n multisig via OP_CHECKMULTISIG, plus the P2SH wrapper\n * that is normally used in practice.\n *\n * redeemScript = <m> <pubkey_1> ... <pubkey_n> <n> OP_CHECKMULTISIG\n * P2SH spk = OP_HASH160 0x14 <HASH160(redeemScript)> OP_EQUAL\n *\n * OP_CHECKMULTISIG caps n at 20 pubkeys (see `MAX_PUBKEYS_PER_MULTISIG` in\n * the Neurai interpreter). Bare multisig outputs are still consensus-valid\n * but non-standard for relay; the P2SH wrapping is what mempool accepts.\n */\nimport { bytesToHex, concatBytes } from '../core/bytes.js';\nimport { pushBytes, pushInt } from '../core/script-builder.js';\nimport { OP_CHECKMULTISIG, OP_EQUAL, OP_HASH160 } from '../core/opcodes.js';\nexport const MULTISIG_MAX_PUBKEYS = 20;\nfunction assertPubKey(pk, idx) {\n if (!(pk instanceof Uint8Array) || (pk.length !== 33 && pk.length !== 65)) {\n throw new Error(`pubKey[${idx}] must be 33 or 65 bytes (got ${pk?.length})`);\n }\n}\nexport function encodeMultisigRedeemScript({ m, pubKeys }) {\n if (!Array.isArray(pubKeys) || pubKeys.length === 0) {\n throw new Error('pubKeys must be a non-empty array');\n }\n if (pubKeys.length > MULTISIG_MAX_PUBKEYS) {\n throw new Error(`pubKeys length ${pubKeys.length} exceeds OP_CHECKMULTISIG cap (${MULTISIG_MAX_PUBKEYS})`);\n }\n if (!Number.isInteger(m) || m < 1 || m > pubKeys.length) {\n throw new Error(`m must be an integer in [1, ${pubKeys.length}] (got ${m})`);\n }\n for (let i = 0; i < pubKeys.length; i += 1)\n assertPubKey(pubKeys[i], i);\n const parts = [pushInt(m)];\n for (const pk of pubKeys)\n parts.push(pushBytes(pk));\n parts.push(pushInt(pubKeys.length));\n parts.push(Uint8Array.of(OP_CHECKMULTISIG));\n return concatBytes(...parts);\n}\nexport function encodeMultisigRedeemScriptHex(params) {\n return bytesToHex(encodeMultisigRedeemScript(params));\n}\n/**\n * P2SH scriptPubKey wrapping any redeem script. Pass the 20-byte HASH160 of\n * the redeem script (RIPEMD160(SHA256(redeemScript))) — compute it\n * externally via the caller's crypto stack.\n */\nexport function encodeP2SHScriptPubKey(redeemScriptHash160) {\n if (!(redeemScriptHash160 instanceof Uint8Array) || redeemScriptHash160.length !== 20) {\n throw new Error('redeemScriptHash160 must be a 20-byte Uint8Array');\n }\n return concatBytes(Uint8Array.of(OP_HASH160, 0x14), redeemScriptHash160, Uint8Array.of(OP_EQUAL));\n}\n","/** Exact monetary primitives. This module has no runtime dependencies. */\nconst SATS_PER_XNA = 100000000n;\nconst MAX_MONEY = 2100000000000000000n;\n/** Normalize a raw integer without preserving an already rounded number. */\nfunction toRawInteger(value, label = 'amount') {\n if (typeof value === 'bigint')\n return value;\n if (typeof value === 'number' && Number.isSafeInteger(value))\n return BigInt(value);\n if (typeof value === 'string' && /^-?\\d+$/.test(value) && value.length <= 100)\n return BigInt(value);\n throw new Error(`${label}: expected an exact integer; use bigint or an integer string for large values`);\n}\nfunction assertMoneyRange(value, label = 'amount') {\n const raw = toRawInteger(value, label);\n if (raw < 0n || raw > MAX_MONEY)\n throw new Error(`${label} outside Neurai monetary range`);\n return raw;\n}\n/** Parse decimal units exactly, including scientific notation, with at most 8 decimals. */\nfunction decimalToSatoshis(value) {\n if (typeof value !== 'string' && typeof value !== 'number')\n throw new Error('Expected decimal string or number');\n if (typeof value === 'number' && !Number.isFinite(value))\n throw new Error('Amount must be finite');\n const text = String(value);\n if (text.length > 100)\n throw new Error('Amount too long');\n const match = /^(-?)(\\d+)(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/.exec(text);\n if (!match)\n throw new Error('Invalid decimal amount');\n const exponent = Number(match[4] ?? 0);\n if (!Number.isSafeInteger(exponent) || Math.abs(exponent) > 100)\n throw new Error('Invalid decimal exponent');\n const fraction = match[3] ?? '';\n const shift = 8 + exponent - fraction.length;\n let raw = BigInt(match[2] + fraction);\n if (shift >= 0)\n raw *= 10n ** BigInt(shift);\n else {\n const divisor = 10n ** BigInt(-shift);\n if (raw % divisor !== 0n)\n throw new Error('Amount has more than 8 decimals');\n raw /= divisor;\n }\n if (typeof value === 'number' && raw > BigInt(Number.MAX_SAFE_INTEGER) && !Number.isSafeInteger(value)) {\n throw new Error('Large fractional amounts must be supplied as decimal strings');\n }\n return match[1] ? -raw : raw;\n}\n/** Format signed raw units without converting to floating point. */\nfunction satoshisToDecimal(value) {\n const raw = toRawInteger(value);\n const abs = raw < 0n ? -raw : raw;\n const fraction = (abs % SATS_PER_XNA).toString().padStart(8, '0').replace(/0+$/, '');\n return `${raw < 0n ? '-' : ''}${abs / SATS_PER_XNA}${fraction ? '.' + fraction : ''}`;\n}\n\nfunction ensureHex(hex, label = 'hex') {\n const normalized = String(hex || '').trim().toLowerCase();\n if (!/^[0-9a-f]*$/.test(normalized) || normalized.length % 2 !== 0) {\n throw new Error(`Invalid ${label}: expected even-length hex string`);\n }\n return normalized;\n}\nfunction hexToBytes(hex) {\n const normalized = ensureHex(hex);\n const bytes = new Uint8Array(normalized.length / 2);\n for (let i = 0; i < normalized.length; i += 2) {\n bytes[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16);\n }\n return bytes;\n}\nfunction bytesToHex(bytes) {\n return Array.from(bytes, (value) => value.toString(16).padStart(2, '0')).join('');\n}\nfunction concatBytes(...parts) {\n const total = parts.reduce((sum, part) => sum + part.length, 0);\n const out = new Uint8Array(total);\n let offset = 0;\n for (const part of parts) {\n out.set(part, offset);\n offset += part.length;\n }\n return out;\n}\nfunction asciiBytes(text) {\n return Uint8Array.from(Array.from(text, (char) => char.charCodeAt(0)));\n}\nfunction serializeString(text) {\n const bytes = asciiBytes(text);\n return concatBytes(compactSize(bytes.length), bytes);\n}\nfunction reverseBytes(bytes) {\n return Uint8Array.from(Array.from(bytes).reverse());\n}\nfunction u32LE(value) {\n if (!Number.isInteger(value) || value < 0 || value > 0xffffffff) {\n throw new Error(`uint32 out of range: ${value}`);\n }\n const out = new Uint8Array(4);\n const view = new DataView(out.buffer);\n view.setUint32(0, value, true);\n return out;\n}\nfunction u64LE(value) {\n const bigintValue = toRawInteger(value);\n if (bigintValue < 0n || bigintValue > 0xffffffffffffffffn) {\n throw new Error(`uint64 out of range: ${bigintValue}`);\n }\n const out = new Uint8Array(8);\n let remaining = bigintValue;\n for (let i = 0; i < 8; i += 1) {\n out[i] = Number(remaining & 0xffn);\n remaining >>= 8n;\n }\n return out;\n}\nfunction i64LE(value) {\n const bigintValue = toRawInteger(value);\n if (bigintValue < -0x8000000000000000n || bigintValue > 0x7fffffffffffffffn) {\n throw new Error(`int64 out of range: ${bigintValue}`);\n }\n const out = new Uint8Array(8);\n const view = new DataView(out.buffer);\n view.setBigInt64(0, bigintValue, true);\n return out;\n}\nfunction compactSize(value) {\n const bigintValue = toRawInteger(value);\n if (bigintValue < 0n)\n throw new Error('CompactSize cannot encode negative numbers');\n if (bigintValue < 253n) {\n return Uint8Array.of(Number(bigintValue));\n }\n if (bigintValue <= 0xffffn) {\n return concatBytes(Uint8Array.of(0xfd), u16LE(Number(bigintValue)));\n }\n if (bigintValue <= 0xffffffffn) {\n return concatBytes(Uint8Array.of(0xfe), u32LE(Number(bigintValue)));\n }\n return concatBytes(Uint8Array.of(0xff), u64LE(bigintValue));\n}\nfunction u16LE(value) {\n if (!Number.isInteger(value) || value < 0 || value > 0xffff) {\n throw new Error(`uint16 out of range: ${value}`);\n }\n const out = new Uint8Array(2);\n const view = new DataView(out.buffer);\n view.setUint16(0, value, true);\n return out;\n}\nfunction pushData(data) {\n if (data.length > 0xffff) {\n throw new Error(`Pushdata too large for current implementation: ${data.length} bytes`);\n }\n if (data.length < 0x4c) {\n return concatBytes(Uint8Array.of(data.length), data);\n }\n if (data.length <= 0xff) {\n return concatBytes(Uint8Array.of(0x4c, data.length), data);\n }\n return concatBytes(Uint8Array.of(0x4d), u16LE(data.length), data);\n}\n\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\nfunction base (ALPHABET) {\n if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }\n const BASE_MAP = new Uint8Array(256);\n for (let j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255;\n }\n for (let i = 0; i < ALPHABET.length; i++) {\n const x = ALPHABET.charAt(i);\n const xc = x.charCodeAt(0);\n if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }\n BASE_MAP[xc] = i;\n }\n const BASE = ALPHABET.length;\n const LEADER = ALPHABET.charAt(0);\n const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up\n const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up\n function encode (source) {\n // eslint-disable-next-line no-empty\n if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n } else if (Array.isArray(source)) {\n source = Uint8Array.from(source);\n }\n if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }\n if (source.length === 0) { return '' }\n // Skip & count leading zeroes.\n let zeroes = 0;\n let length = 0;\n let pbegin = 0;\n const pend = source.length;\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++;\n zeroes++;\n }\n // Allocate enough space in big-endian base58 representation.\n const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;\n const b58 = new Uint8Array(size);\n // Process the bytes.\n while (pbegin !== pend) {\n let carry = source[pbegin];\n // Apply \"b58 = b58 * 256 + ch\".\n let i = 0;\n for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0;\n b58[it1] = (carry % BASE) >>> 0;\n carry = (carry / BASE) >>> 0;\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i;\n pbegin++;\n }\n // Skip leading zeroes in base58 result.\n let it2 = size - length;\n while (it2 !== size && b58[it2] === 0) {\n it2++;\n }\n // Translate the result into a string.\n let str = LEADER.repeat(zeroes);\n for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }\n return str\n }\n function decodeUnsafe (source) {\n if (typeof source !== 'string') { throw new TypeError('Expected String') }\n if (source.length === 0) { return new Uint8Array() }\n let psz = 0;\n // Skip and count leading '1's.\n let zeroes = 0;\n let length = 0;\n while (source[psz] === LEADER) {\n zeroes++;\n psz++;\n }\n // Allocate enough space in big-endian base256 representation.\n const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.\n const b256 = new Uint8Array(size);\n // Process the characters.\n while (psz < source.length) {\n // Find code of next character\n const charCode = source.charCodeAt(psz);\n // Base map can not be indexed using char code\n if (charCode > 255) { return }\n // Decode character\n let carry = BASE_MAP[charCode];\n // Invalid character\n if (carry === 255) { return }\n let i = 0;\n for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0;\n b256[it3] = (carry % 256) >>> 0;\n carry = (carry / 256) >>> 0;\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i;\n psz++;\n }\n // Skip leading zeroes in b256.\n let it4 = size - length;\n while (it4 !== size && b256[it4] === 0) {\n it4++;\n }\n const vch = new Uint8Array(zeroes + (size - it4));\n let j = zeroes;\n while (it4 !== size) {\n vch[j++] = b256[it4++];\n }\n return vch\n }\n function decode (string) {\n const buffer = decodeUnsafe(string);\n if (buffer) { return buffer }\n throw new Error('Non-base' + BASE + ' character')\n }\n return {\n encode,\n decodeUnsafe,\n decode\n }\n}\n\nvar ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\nvar base58 = base(ALPHABET);\n\nconst IPFS_LENGTH = 0x20;\nconst TXID_PREFIX = 0x54;\nfunction encodeAssetDataReference(value) {\n const normalized = String(value || '').trim();\n if (!normalized) {\n return new Uint8Array();\n }\n if (normalized.startsWith('Qm') && normalized.length === 46) {\n const decoded = Uint8Array.from(base58.decode(normalized));\n if (decoded.length !== 34) {\n throw new Error(`Invalid CIDv0 length for asset data: ${decoded.length}`);\n }\n return decoded;\n }\n if (normalized.length === 64 && /^[0-9a-fA-F]+$/.test(normalized)) {\n const txidBytes = hexToBytes(normalized);\n return Uint8Array.of(TXID_PREFIX, IPFS_LENGTH, ...txidBytes);\n }\n if (normalized.length === 68 && /^[0-9a-fA-F]+$/.test(normalized)) {\n const raw = hexToBytes(normalized);\n if (raw[1] !== IPFS_LENGTH) {\n throw new Error('Invalid raw asset data reference length prefix');\n }\n return raw;\n }\n throw new Error('Unsupported asset data reference. Expected CIDv0 (Qm...), 64-char txid, or 68-char raw hex');\n}\nfunction decodeAssetDataReferenceHex(value) {\n return bytesToHex(encodeAssetDataReference(value));\n}\nfunction isEncodedAssetDataReferenceHex(hex) {\n const normalized = ensureHex(hex);\n return normalized.length === 68 || normalized.length === 0;\n}\nfunction isCidV0AssetReference(value) {\n const normalized = String(value || '').trim();\n return normalized.startsWith('Qm') && normalized.length === 46;\n}\nfunction isTxidAssetReference(value) {\n const normalized = String(value || '').trim();\n return normalized.length === 64 && /^[0-9a-fA-F]+$/.test(normalized);\n}\nfunction isRawAssetDataReferenceHex(value) {\n const normalized = String(value || '').trim();\n return normalized.length === 68 && /^[0-9a-fA-F]+$/.test(normalized);\n}\nfunction formatAssetDataReferenceHex(value) {\n return bytesToHex(encodeAssetDataReference(value));\n}\n\nvar dist = {};\n\nvar hasRequiredDist;\n\nfunction requireDist () {\n\tif (hasRequiredDist) return dist;\n\thasRequiredDist = 1;\n\tObject.defineProperty(dist, \"__esModule\", { value: true });\n\tdist.bech32m = dist.bech32 = void 0;\n\tconst ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';\n\tconst ALPHABET_MAP = {};\n\tfor (let z = 0; z < ALPHABET.length; z++) {\n\t const x = ALPHABET.charAt(z);\n\t ALPHABET_MAP[x] = z;\n\t}\n\tfunction polymodStep(pre) {\n\t const b = pre >> 25;\n\t return (((pre & 0x1ffffff) << 5) ^\n\t (-((b >> 0) & 1) & 0x3b6a57b2) ^\n\t (-((b >> 1) & 1) & 0x26508e6d) ^\n\t (-((b >> 2) & 1) & 0x1ea119fa) ^\n\t (-((b >> 3) & 1) & 0x3d4233dd) ^\n\t (-((b >> 4) & 1) & 0x2a1462b3));\n\t}\n\tfunction prefixChk(prefix) {\n\t let chk = 1;\n\t for (let i = 0; i < prefix.length; ++i) {\n\t const c = prefix.charCodeAt(i);\n\t if (c < 33 || c > 126)\n\t return 'Invalid prefix (' + prefix + ')';\n\t chk = polymodStep(chk) ^ (c >> 5);\n\t }\n\t chk = polymodStep(chk);\n\t for (let i = 0; i < prefix.length; ++i) {\n\t const v = prefix.charCodeAt(i);\n\t chk = polymodStep(chk) ^ (v & 0x1f);\n\t }\n\t return chk;\n\t}\n\tfunction convert(data, inBits, outBits, pad) {\n\t let value = 0;\n\t let bits = 0;\n\t const maxV = (1 << outBits) - 1;\n\t const result = [];\n\t for (let i = 0; i < data.length; ++i) {\n\t value = (value << inBits) | data[i];\n\t bits += inBits;\n\t while (bits >= outBits) {\n\t bits -= outBits;\n\t result.push((value >> bits) & maxV);\n\t }\n\t }\n\t if (pad) {\n\t if (bits > 0) {\n\t result.push((value << (outBits - bits)) & maxV);\n\t }\n\t }\n\t else {\n\t if (bits >= inBits)\n\t return 'Excess padding';\n\t if ((value << (outBits - bits)) & maxV)\n\t return 'Non-zero padding';\n\t }\n\t return result;\n\t}\n\tfunction toWords(bytes) {\n\t return convert(bytes, 8, 5, true);\n\t}\n\tfunction fromWordsUnsafe(words) {\n\t const res = convert(words, 5, 8, false);\n\t if (Array.isArray(res))\n\t return res;\n\t}\n\tfunction fromWords(words) {\n\t const res = convert(words, 5, 8, false);\n\t if (Array.isArray(res))\n\t return res;\n\t throw new Error(res);\n\t}\n\tfunction getLibraryFromEncoding(encoding) {\n\t let ENCODING_CONST;\n\t if (encoding === 'bech32') {\n\t ENCODING_CONST = 1;\n\t }\n\t else {\n\t ENCODING_CONST = 0x2bc830a3;\n\t }\n\t function encode(prefix, words, LIMIT) {\n\t LIMIT = LIMIT || 90;\n\t if (prefix.length + 7 + words.length > LIMIT)\n\t throw new TypeError('Exceeds length limit');\n\t prefix = prefix.toLowerCase();\n\t // determine chk mod\n\t let chk = prefixChk(prefix);\n\t if (typeof chk === 'string')\n\t throw new Error(chk);\n\t let result = prefix + '1';\n\t for (let i = 0; i < words.length; ++i) {\n\t const x = words[i];\n\t if (x >> 5 !== 0)\n\t throw new Error('Non 5-bit word');\n\t chk = polymodStep(chk) ^ x;\n\t result += ALPHABET.charAt(x);\n\t }\n\t for (let i = 0; i < 6; ++i) {\n\t chk = polymodStep(chk);\n\t }\n\t chk ^= ENCODING_CONST;\n\t for (let i = 0; i < 6; ++i) {\n\t const v = (chk >> ((5 - i) * 5)) & 0x1f;\n\t result += ALPHABET.charAt(v);\n\t }\n\t return result;\n\t }\n\t function __decode(str, LIMIT) {\n\t LIMIT = LIMIT || 90;\n\t if (str.length < 8)\n\t return str + ' too short';\n\t if (str.length > LIMIT)\n\t return 'Exceeds length limit';\n\t // don't allow mixed case\n\t const lowered = str.toLowerCase();\n\t const uppered = str.toUpperCase();\n\t if (str !== lowered && str !== uppered)\n\t return 'Mixed-case string ' + str;\n\t str = lowered;\n\t const split = str.lastIndexOf('1');\n\t if (split === -1)\n\t return 'No separator character for ' + str;\n\t if (split === 0)\n\t return 'Missing prefix for ' + str;\n\t const prefix = str.slice(0, split);\n\t const wordChars = str.slice(split + 1);\n\t if (wordChars.length < 6)\n\t return 'Data too short';\n\t let chk = prefixChk(prefix);\n\t if (typeof chk === 'string')\n\t return chk;\n\t const words = [];\n\t for (let i = 0; i < wordChars.length; ++i) {\n\t const c = wordChars.charAt(i);\n\t const v = ALPHABET_MAP[c];\n\t if (v === undefined)\n\t return 'Unknown character ' + c;\n\t chk = polymodStep(chk) ^ v;\n\t // not in the checksum?\n\t if (i + 6 >= wordChars.length)\n\t continue;\n\t words.push(v);\n\t }\n\t if (chk !== ENCODING_CONST)\n\t return 'Invalid checksum for ' + str;\n\t return { prefix, words };\n\t }\n\t function decodeUnsafe(str, LIMIT) {\n\t const res = __decode(str, LIMIT);\n\t if (typeof res === 'object')\n\t return res;\n\t }\n\t function decode(str, LIMIT) {\n\t const res = __decode(str, LIMIT);\n\t if (typeof res === 'object')\n\t return res;\n\t throw new Error(res);\n\t }\n\t return {\n\t decodeUnsafe,\n\t decode,\n\t encode,\n\t toWords,\n\t fromWordsUnsafe,\n\t fromWords,\n\t };\n\t}\n\tdist.bech32 = getLibraryFromEncoding('bech32');\n\tdist.bech32m = getLibraryFromEncoding('bech32m');\n\treturn dist;\n}\n\nvar distExports = requireDist();\n\n/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\n/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */\nfunction isBytes$1(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n/** Asserts something is Uint8Array. */\nfunction abytes$1(b, ...lengths) {\n if (!isBytes$1(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n/** Asserts a hash instance has not been destroyed / finished */\nfunction aexists$1(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\n/** Asserts output is properly-sized byte array */\nfunction aoutput$1(out, instance) {\n abytes$1(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n/** Zeroize a byte array. Warning: JS provides no guarantees. */\nfunction clean$1(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n/** Create DataView of an array for easy byte-level manipulation. */\nfunction createView$1(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** The rotate right (circular right shift) operation for uint32 */\nfunction rotr$1(word, shift) {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/**\n * Converts string to bytes using UTF8 encoding.\n * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])\n */\nfunction utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nfunction toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes$1(data);\n return data;\n}\n/** For runtime check if class implements interface */\nclass Hash {\n}\n/** Wraps hash function, creating an interface on top of it */\nfunction createHasher$1(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\n/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\n/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */\nfunction setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n/** Choice: a ? b : c */\nfunction Chi$1(a, b, c) {\n return (a & b) ^ (~a & c);\n}\n/** Majority function, true if any two inputs is true. */\nfunction Maj$1(a, b, c) {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nlet HashMD$1 = class HashMD extends Hash {\n constructor(blockLen, outputLen, padOffset, isLE) {\n super();\n this.finished = false;\n this.length = 0;\n this.pos = 0;\n this.destroyed = false;\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView$1(this.buffer);\n }\n update(data) {\n aexists$1(this);\n data = toBytes(data);\n abytes$1(data);\n const { view, buffer, blockLen } = this;\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView$1(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n aexists$1(this);\n aoutput$1(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n clean$1(this.buffer.subarray(pos));\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView$1(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to || (to = new this.constructor());\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.destroyed = destroyed;\n to.finished = finished;\n to.length = length;\n to.pos = pos;\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n clone() {\n return this._cloneInto();\n }\n};\n/**\n * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.\n * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.\n */\n/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */\nconst SHA256_IV$1 = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n\n/**\n * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.\n * SHA256 is the fastest hash implementable in JS, even faster than Blake3.\n * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and\n * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).\n * @module\n */\n/**\n * Round constants:\n * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)\n */\n// prettier-ignore\nconst SHA256_K$1 = /* @__PURE__ */ Uint32Array.from([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n/** Reusable temporary buffer. \"W\" comes straight from spec. */\nconst SHA256_W$1 = /* @__PURE__ */ new Uint32Array(64);\nclass SHA256 extends HashMD$1 {\n constructor(outputLen = 32) {\n super(64, outputLen, 8, false);\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n this.A = SHA256_IV$1[0] | 0;\n this.B = SHA256_IV$1[1] | 0;\n this.C = SHA256_IV$1[2] | 0;\n this.D = SHA256_IV$1[3] | 0;\n this.E = SHA256_IV$1[4] | 0;\n this.F = SHA256_IV$1[5] | 0;\n this.G = SHA256_IV$1[6] | 0;\n this.H = SHA256_IV$1[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W$1[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W$1[i - 15];\n const W2 = SHA256_W$1[i - 2];\n const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ (W2 >>> 10);\n SHA256_W$1[i] = (s1 + SHA256_W$1[i - 7] + s0 + SHA256_W$1[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);\n const T1 = (H + sigma1 + Chi$1(E, F, G) + SHA256_K$1[i] + SHA256_W$1[i]) | 0;\n const sigma0 = rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22);\n const T2 = (sigma0 + Maj$1(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n clean$1(SHA256_W$1);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n clean$1(this.buffer);\n }\n}\n/**\n * SHA2-256 hash function from RFC 4634.\n *\n * It is the fastest JS hash, even faster than Blake3.\n * To break sha256 using birthday attack, attackers need to try 2^128 hashes.\n * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n */\nconst sha256$2 = /* @__PURE__ */ createHasher$1(() => new SHA256());\n\n/**\n * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.\n *\n * To break sha256 using birthday attack, attackers need to try 2^128 hashes.\n * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n *\n * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).\n * @module\n * @deprecated\n */\n/** @deprecated Use import from `noble/hashes/sha2` module */\nconst sha256$1 = sha256$2;\n\nfunction bs58checkBase (checksumFn) {\n // Encode a buffer as a base58-check encoded string\n function encode(payload) {\n var payloadU8 = Uint8Array.from(payload);\n var checksum = checksumFn(payloadU8);\n var length = payloadU8.length + 4;\n var both = new Uint8Array(length);\n both.set(payloadU8, 0);\n both.set(checksum.subarray(0, 4), payloadU8.length);\n return base58.encode(both);\n }\n function decodeRaw(buffer) {\n var payload = buffer.slice(0, -4);\n var checksum = buffer.slice(-4);\n var newChecksum = checksumFn(payload);\n // eslint-disable-next-line\n if (checksum[0] ^ newChecksum[0] |\n checksum[1] ^ newChecksum[1] |\n checksum[2] ^ newChecksum[2] |\n checksum[3] ^ newChecksum[3])\n return;\n return payload;\n }\n // Decode a base58-check encoded string to a buffer, no result if checksum is wrong\n function decodeUnsafe(str) {\n var buffer = base58.decodeUnsafe(str);\n if (buffer == null)\n return;\n return decodeRaw(buffer);\n }\n function decode(str) {\n var buffer = base58.decode(str);\n var payload = decodeRaw(buffer);\n if (payload == null)\n throw new Error('Invalid checksum');\n return payload;\n }\n return {\n encode: encode,\n decode: decode,\n decodeUnsafe: decodeUnsafe\n };\n}\n\n// SHA256(SHA256(buffer))\nfunction sha256x2(buffer) {\n return sha256$1(sha256$1(buffer));\n}\nvar bs58check = bs58checkBase(sha256x2);\n\nfunction resolveAddressInput(address) {\n if (typeof address === 'string') {\n return String(address).trim();\n }\n if (address && typeof address.address === 'string') {\n return String(address.address).trim();\n }\n throw new Error('Address must be a string or an object with an address field');\n}\n\nconst LEGACY_MAINNET_PREFIX = 53;\nconst LEGACY_TESTNET_PREFIX = 127;\nconst OP_XNA_ASSET = 0xc0;\nconst OP_DROP = 0x75;\nconst OP_1 = 0x51;\nconst OP_RESERVED = 0x50;\nconst WITNESS_FAMILIES = [\n {\n type: 'authscript',\n witnessVersion: 1,\n hrp: { mainnet: 'nc', testnet: 'tnc' },\n network: { mainnet: 'xna-authscript', testnet: 'xna-authscript-test' }\n },\n {\n type: 'pq',\n witnessVersion: 2,\n hrp: { mainnet: 'pq', testnet: 'tpq' },\n network: { mainnet: 'xna-pq', testnet: 'xna-pq-test' }\n },\n {\n type: 'ecdsa',\n witnessVersion: 3,\n hrp: { mainnet: 'nq', testnet: 'tnq' },\n network: { mainnet: 'xna', testnet: 'xna-test' }\n }\n];\nconst AUTHSCRIPT_MAINNET_HRP = 'nc';\nconst AUTHSCRIPT_TESTNET_HRP = 'tnc';\nconst PQ_MAINNET_HRP = 'pq';\nconst PQ_TESTNET_HRP = 'tpq';\nconst ECDSA_MAINNET_HRP = 'nq';\nconst ECDSA_TESTNET_HRP = 'tnq';\n/** The family that owns `hrp` (lowercase), with the chain it encodes. */\nfunction witnessFamilyByHrp(hrp) {\n for (const family of WITNESS_FAMILIES) {\n if (family.hrp.mainnet === hrp)\n return { family, chain: 'mainnet' };\n if (family.hrp.testnet === hrp)\n return { family, chain: 'testnet' };\n }\n return undefined;\n}\n/** The family encoded by `witnessVersion`, or undefined for any other version. */\nfunction witnessFamilyByVersion(witnessVersion) {\n return WITNESS_FAMILIES.find((family) => family.witnessVersion === witnessVersion);\n}\n/** `OP_1`, `OP_2` or `OP_3`: the scriptPubKey opcode of a witness version. */\nfunction witnessVersionOpcode(witnessVersion) {\n if (!witnessFamilyByVersion(witnessVersion)) {\n throw new Error(`Unsupported AuthScript witness version: ${String(witnessVersion)} (expected 1, 2 or 3)`);\n }\n return OP_1 - 1 + witnessVersion;\n}\n/**\n * NIP-040 asset payload marker.\n *\n * Every transfer / new / owner / reissue payload opens with a 3-byte marker\n * followed by the type byte. The marker is consensus: blocks below the NIP-040\n * activation height of a network only accept `rvn` on new asset outputs and\n * blocks at or above it only accept `xna` (mainnet: not scheduled; reset testnet:\n * 10; regtest: 1). This library does NOT know chain state and never\n * infers the marker from a network or an address: the caller passes the\n * value reported by the node for the next block\n * (`getblockchaininfo.asset_marker`, node commit 347362b) — or, when building\n * offline, the marker it knows to be right. Without it the default is `rvn`,\n * byte-for-byte identical to 0.6.0.\n */\nconst DEFAULT_ASSET_MARKER = 'rvn';\nconst ASSET_MARKER_BYTES = {\n rvn: [0x72, 0x76, 0x6e],\n xna: [0x78, 0x6e, 0x61]\n};\nconst ASSET_PAYLOAD_TYPE_BYTE = {\n transfer: 0x74, // 't'\n new: 0x71, // 'q'\n owner: 0x6f, // 'o'\n reissue: 0x72 // 'r'\n};\n/**\n * Applies the default only when the marker was not given at all (`undefined`)\n * and rejects anything else that is not `'rvn'` or `'xna'` — including\n * `null`, which is what a missing or null `asset_marker` in a JSON reply\n * becomes: it must fail loudly, not silently build a legacy output.\n */\nfunction resolveAssetMarker(value) {\n if (value === undefined)\n return DEFAULT_ASSET_MARKER;\n if (value === 'rvn' || value === 'xna')\n return value;\n throw new Error(`Invalid assetMarker: ${String(value)} (expected 'rvn' or 'xna', the value of getblockchaininfo.asset_marker)`);\n}\n/**\n * The only place marker bytes are assembled (mirror of the node's\n * `AppendAssetMarkerPrefix`): `<marker 3B> <type 1B>`.\n */\nfunction assetPayloadPrefix(marker, type) {\n const typeByte = ASSET_PAYLOAD_TYPE_BYTE[type];\n if (typeByte === undefined) {\n throw new Error(`Unknown asset payload type: ${String(type)}`);\n }\n const [a, b, c] = ASSET_MARKER_BYTES[resolveAssetMarker(marker)];\n return Uint8Array.of(a, b, c, typeByte);\n}\n\n// Longest Bech32m string the node's decoder accepts (bech32.cpp).\nconst BECH32M_MAX_LENGTH = 90;\nconst AUTHSCRIPT_PROGRAM_LENGTH = 32;\nfunction tryBech32mDecode(address) {\n try {\n const { prefix, words } = distExports.bech32m.decode(address, BECH32M_MAX_LENGTH);\n return { hrp: prefix.toLowerCase(), words };\n }\n catch {\n return null;\n }\n}\nfunction decodeWitnessAddress(address, parts) {\n const owner = witnessFamilyByHrp(parts.hrp);\n if (!owner) {\n throw new Error(`Unsupported Bech32m prefix \"${parts.hrp}\" for ${address}`);\n }\n if (parts.words.length === 0) {\n throw new Error(`Empty witness program in ${address}`);\n }\n const version = parts.words[0];\n const { family, chain } = owner;\n if (version !== family.witnessVersion) {\n const actual = witnessFamilyByVersion(version);\n const hint = actual\n ? `; witness v${version} addresses use the \"${actual.hrp[chain]}\" prefix`\n : '';\n const legacyHint = family.type === 'ecdsa' && version === 1\n ? ' Generic AuthScript v1 addresses are now encoded as nc1p… / tnc1p… ' +\n '(same scriptPubKey): regenerate the address (neurai-key xna-authscript networks).'\n : '';\n throw new Error(`Address ${address}: the \"${parts.hrp}\" prefix only encodes witness v${family.witnessVersion}, ` +\n `not v${version}${hint}.${legacyHint}`);\n }\n let program;\n try {\n program = Uint8Array.from(distExports.bech32m.fromWords(parts.words.slice(1)));\n }\n catch {\n throw new Error(`Invalid witness program padding in ${address}`);\n }\n if (program.length !== AUTHSCRIPT_PROGRAM_LENGTH) {\n throw new Error(`Unsupported AuthScript program length ${program.length} for ${address} (expected ${AUTHSCRIPT_PROGRAM_LENGTH})`);\n }\n return {\n address,\n type: family.type,\n witnessVersion: family.witnessVersion,\n network: family.network[chain],\n program,\n commitment: program\n };\n}\nfunction decodeLegacyAddress(address) {\n const payload = Uint8Array.from(bs58check.decode(address));\n if (payload.length !== 21) {\n throw new Error(`Unsupported legacy address payload length for ${address}`);\n }\n const prefix = payload[0];\n if (prefix !== LEGACY_MAINNET_PREFIX && prefix !== LEGACY_TESTNET_PREFIX) {\n throw new Error(`Unsupported legacy address prefix ${prefix} for ${address}`);\n }\n return {\n address,\n type: 'p2pkh',\n network: prefix === LEGACY_MAINNET_PREFIX ? 'xna-legacy' : 'xna-legacy-test',\n program: payload.slice(1),\n hash: payload.slice(1)\n };\n}\n/**\n * Decode a Neurai address the way the node does (base58.cpp\n * `DecodeDestination`): Bech32m first, Base58Check otherwise.\n *\n * - Base58 P2PKH → `type: 'p2pkh'`, network `xna-legacy` / `xna-legacy-test`\n * (an `xna-old-legacy` address is indistinguishable and reports\n * `xna-legacy`).\n * - Bech32m → `authscript` (v1, `nc`/`tnc`), `pq` (v2, `pq`/`tpq`) or\n * `ecdsa` (v3, `nq`/`tnq`), with `witnessVersion` and the 32-byte\n * commitment. Any other HRP/version pair is rejected, including the old\n * `nq1p…` / `tnq1p…` encoding of generic AuthScript v1.\n *\n * The decoder does not know whether a witness family is active on the\n * target chain: before activation the node refuses v2/v3 addresses and a\n * witness output is anyone-can-spend.\n */\nfunction decodeAddress(address) {\n const normalized = resolveAddressInput(address);\n if (!normalized)\n throw new Error('Address is required');\n const bech32mParts = tryBech32mDecode(normalized);\n if (bech32mParts) {\n return decodeWitnessAddress(normalized, bech32mParts);\n }\n try {\n return decodeLegacyAddress(normalized);\n }\n catch (legacyError) {\n // Not Base58 either. When the string carries a known Bech32m prefix the\n // Bech32m failure (bad checksum, mixed case…) is the useful diagnosis.\n const separator = normalized.lastIndexOf('1');\n const hrp = separator > 0 ? normalized.slice(0, separator).toLowerCase() : '';\n if (witnessFamilyByHrp(hrp)) {\n throw new Error(`Invalid Bech32m address ${normalized} (checksum, case or character error)`);\n }\n throw legacyError;\n }\n}\n/** Chain-family label of an address: see `decodeAddress`. */\nfunction inferNetworkFromAddress(address) {\n return decodeAddress(address).network;\n}\n/** True for the Bech32m (AuthScript v1, PQ v2, ECDSA v3) destinations. */\nfunction isWitnessDestination(destination) {\n return destination.type !== 'p2pkh';\n}\n/** `OP_n 0x20 <32-byte commitment>` for witness version `n` (1, 2 or 3). */\nfunction encodeWitnessProgramScript(witnessVersion, commitment) {\n const bytes = typeof commitment === 'string' ? hexToBytes(commitment) : commitment;\n if (bytes.length !== AUTHSCRIPT_PROGRAM_LENGTH) {\n throw new Error(`AuthScript commitment must be ${AUTHSCRIPT_PROGRAM_LENGTH} bytes, got ${bytes.length}`);\n }\n return concatBytes(Uint8Array.of(witnessVersionOpcode(witnessVersion)), pushData(bytes));\n}\nfunction encodeP2PKHScript(address) {\n const destination = decodeAddress(address);\n if (destination.type !== 'p2pkh') {\n throw new Error(`Address ${resolveAddressInput(address)} is not legacy P2PKH`);\n }\n return Uint8Array.of(0x76, 0xa9, 0x14, ...destination.hash, 0x88, 0xac);\n}\n/**\n * scriptPubKey of an AuthScript destination of any witness version:\n * `OP_1` (generic v1), `OP_2` (PQ) or `OP_3` (ECDSA) followed by the\n * 32-byte commitment.\n */\nfunction encodeAuthScriptDestinationScript(address) {\n const destination = decodeAddress(address);\n if (!isWitnessDestination(destination)) {\n throw new Error(`Address ${resolveAddressInput(address)} is not an AuthScript (witness v1, v2 or v3) address`);\n }\n return encodeWitnessProgramScript(destination.witnessVersion, destination.commitment);\n}\nfunction encodeDestinationScript(address) {\n const destination = decodeAddress(address);\n return isWitnessDestination(destination)\n ? encodeWitnessProgramScript(destination.witnessVersion, destination.commitment)\n : encodeP2PKHScript(address);\n}\nfunction encodeNullAssetDestinationScript(address, mode = 'strict') {\n const destination = decodeAddress(address);\n if (isWitnessDestination(destination)) {\n if (mode === 'hash20') {\n throw new Error('hash20 null-asset mode is not supported for AuthScript destinations');\n }\n return concatBytes(Uint8Array.of(OP_XNA_ASSET, witnessVersionOpcode(destination.witnessVersion)), pushData(destination.commitment));\n }\n return concatBytes(Uint8Array.of(OP_XNA_ASSET), pushData(destination.hash));\n}\n/**\n * @deprecated The name predates the PQ witness v2 family: it encodes every\n * AuthScript witness version. Use `encodeAuthScriptDestinationScript`.\n */\nconst encodePQWitnessScript = encodeAuthScriptDestinationScript;\n/**\n * Classify a scriptPubKey by its destination prefix, ignoring any trailing\n * asset wrapper: `76a914<20>88ac…` is P2PKH, `5120<32>…`, `5220<32>…` and\n * `5320<32>…` are AuthScript v1 (generic), v2 (PQ) and v3 (ECDSA).\n */\nfunction classifyScriptPubKey(script) {\n const bytes = typeof script === 'string' ? hexToBytes(script) : script;\n if (bytes.length >= 25 &&\n bytes[0] === 0x76 &&\n bytes[1] === 0xa9 &&\n bytes[2] === 0x14 &&\n bytes[23] === 0x88 &&\n bytes[24] === 0xac) {\n return { type: 'p2pkh', program: bytes.slice(3, 23), hasSuffix: bytes.length > 25 };\n }\n if (bytes.length >= 34 && bytes[1] === 0x20) {\n const family = witnessFamilyByVersion(bytes[0] - (OP_1 - 1));\n if (family) {\n return {\n type: family.type,\n witnessVersion: family.witnessVersion,\n program: bytes.slice(2, 34),\n hasSuffix: bytes.length > 34\n };\n }\n }\n return { type: 'unknown', hasSuffix: false };\n}\n\nconst OWNER_ASSET_AMOUNT = 100000000n;\nconst UNIQUE_ASSET_AMOUNT = 100000000n;\nconst UNIQUE_ASSET_UNITS = 0;\nconst UNIQUE_ASSETS_REISSUABLE = false;\nconst MAINNET_BURN_ADDRESSES = {\n ISSUE_ROOT: 'NbURNXXXXXXXXXXXXXXXXXXXXXXXT65Gdr',\n ISSUE_SUB: 'NXissueSubAssetXXXXXXXXXXXXXX6B2JF',\n ISSUE_UNIQUE: 'NXissueUniqueAssetXXXXXXXXXXUBzP4Z',\n ISSUE_DEPIN: 'NXissueUniqueAssetXXXXXXXXXXUBzP4Z',\n ISSUE_MSGCHANNEL: 'NXissueMsgChanneLAssetXXXXXXTUzrtJ',\n REISSUE: 'NXReissueAssetXXXXXXXXXXXXXXWLe4Ao',\n REISSUE_RESTRICTED: 'NXReissueAssetXXXXXXXXXXXXXXWLe4Ao',\n ISSUE_RESTRICTED: 'NXissueRestrictedXXXXXXXXXXXWpXx4H',\n ISSUE_QUALIFIER: 'NXissueQuaLifierXXXXXXXXXXXXWurNcU',\n ISSUE_SUB_QUALIFIER: 'NXissueSubQuaLifierXXXXXXXXXV71vM3',\n TAG_ADDRESS: 'NXaddTagBurnXXXXXXXXXXXXXXXXWucUTr',\n UNTAG_ADDRESS: 'NXaddTagBurnXXXXXXXXXXXXXXXXWucUTr'\n};\nconst TESTNET_BURN_ADDRESSES = {\n ISSUE_ROOT: 'tBURNXXXXXXXXXXXXXXXXXXXXXXXVZLroy',\n ISSUE_SUB: 'tSubAssetXXXXXXXXXXXXXXXXXXXXGTvF4',\n ISSUE_UNIQUE: 'tUniqueAssetXXXXXXXXXXXXXXXXVCgpLs',\n ISSUE_DEPIN: 'tUniqueAssetXXXXXXXXXXXXXXXXVCgpLs',\n ISSUE_MSGCHANNEL: 'tMsgChanneLAssetXXXXXXXXXXXXVsJoya',\n REISSUE: 'tAssetXXXXXXXXXXXXXXXXXXXXXXas6pz8',\n REISSUE_RESTRICTED: 'tAssetXXXXXXXXXXXXXXXXXXXXXXas6pz8',\n ISSUE_RESTRICTED: 'tRestrictedXXXXXXXXXXXXXXXXXVyPBEK',\n ISSUE_QUALIFIER: 'tQuaLifierXXXXXXXXXXXXXXXXXXT5czoV',\n ISSUE_SUB_QUALIFIER: 'tSubQuaLifierXXXXXXXXXXXXXXXW5MmGk',\n TAG_ADDRESS: 'tTagBurnXXXXXXXXXXXXXXXXXXXXYm6pxA',\n UNTAG_ADDRESS: 'tTagBurnXXXXXXXXXXXXXXXXXXXXYm6pxA'\n};\nconst BURN_COSTS_XNA = {\n ISSUE_ROOT: 1000,\n ISSUE_SUB: 200,\n ISSUE_UNIQUE: 10,\n ISSUE_DEPIN: 10,\n ISSUE_MSGCHANNEL: 200,\n ISSUE_QUALIFIER: 2000,\n ISSUE_SUB_QUALIFIER: 200,\n ISSUE_RESTRICTED: 3000,\n REISSUE: 200,\n REISSUE_RESTRICTED: 200,\n TAG_ADDRESS: 0.2,\n UNTAG_ADDRESS: 0.2\n};\n// Regtest chainparams use one global burn address for every operation\n// (node chainparams.cpp strGlobalBurnAddress). Pass it as the\n// `burnAddress` override of the issuance/reissue builders when targeting\n// regtest; `getBurnAddressForOperation` only models mainnet/testnet.\nconst REGTEST_GLOBAL_BURN_ADDRESS = 'tBURNXXXXXXXXXXXXXXXXXXXXXXXVZLroy';\n/**\n * Every value `SupportedNetwork` admits, and the chain family each belongs to.\n *\n * Written as an exhaustive map rather than a couple of comparisons so that a\n * network added to the union upstream fails to compile here instead of\n * silently defaulting to testnet.\n */\nconst NETWORK_FAMILY = {\n 'xna': 'mainnet',\n 'xna-legacy': 'mainnet',\n 'xna-old-legacy': 'mainnet',\n 'xna-pq': 'mainnet',\n 'xna-authscript': 'mainnet',\n 'xna-test': 'testnet',\n 'xna-legacy-test': 'testnet',\n 'xna-pq-test': 'testnet',\n 'xna-authscript-test': 'testnet'\n};\n/**\n * Resolve a network to its chain family, rejecting anything unrecognised.\n *\n * This used to return `'testnet'` for every value that was not explicitly\n * mainnet. TypeScript keeps its own callers honest, but a JavaScript consumer\n * passing the alias `'mainnet'` — which other libraries in the stack accept —\n * landed in the testnet branch and **slipped past the DEPIN mainnet guard**,\n * while the canonical `'xna'` triggered it. An unrecognised label is a caller\n * error, not an implicit testnet.\n *\n * Callers that speak in aliases must normalize first: `'mainnet'` to `'xna'`,\n * `'testnet'` to `'xna-test'`.\n *\n * Regtest is not a member of `SupportedNetwork` — it shares testnet's address\n * prefixes — and now throws here. That reaches `getBurnAddressForOperation`,\n * which used to answer with the TESTNET burn addresses: wrong for regtest,\n * whose chainparams use a single global burn address for every operation, so\n * only ISSUE_ROOT happened to coincide. Pass `REGTEST_GLOBAL_BURN_ADDRESS` as\n * the `burnAddress` override instead; the previous answer had to be replaced\n * anyway.\n *\n * @param network - Network label\n * @returns The chain family\n * @throws If the label is not a supported network\n */\nfunction resolveNetworkFamily(network) {\n const family = NETWORK_FAMILY[network];\n if (family === undefined) {\n throw new Error(`Unsupported network: ${JSON.stringify(network)}. Expected one of ` +\n `${Object.keys(NETWORK_FAMILY).join(', ')}. Aliases such as 'mainnet' ` +\n `or 'testnet' must be normalized by the caller ('xna', 'xna-test'); ` +\n `for regtest, pass REGTEST_GLOBAL_BURN_ADDRESS as the burnAddress override.`);\n }\n return family;\n}\nfunction getBurnAddressForOperation(network, operation) {\n const byFamily = resolveNetworkFamily(network) === 'mainnet'\n ? MAINNET_BURN_ADDRESSES\n : TESTNET_BURN_ADDRESSES;\n return byFamily[operation];\n}\nfunction getBurnAmountXna(operation, multiplier = 1) {\n return BURN_COSTS_XNA[operation] * multiplier;\n}\nfunction getBurnAmountSats(operation, multiplier = 1) {\n return assertMoneyRange(decimalToSatoshis(BURN_COSTS_XNA[operation]) * assertMoneyRange(toRawInteger(multiplier, 'burn multiplier')));\n}\n/**\n * Network label of an address, from its encoding (see `decodeAddress`):\n * `xna-legacy[-test]` for Base58, `xna-authscript[-test]` for `nc1`/`tnc1`,\n * `xna-pq[-test]` for `pq1`/`tpq1` and `xna[-test]` for `nq1`/`tnq1`.\n */\nfunction inferNetworkFromAnyAddress(address) {\n return inferNetworkFromAddress(address);\n}\nfunction getOwnerTokenName(assetName) {\n if (assetName.startsWith('$')) {\n return `${assetName.slice(1)}!`;\n }\n return `${assetName}!`;\n}\nfunction getParentAssetName(assetName) {\n // The parent is the immediate one, not the root: \"A/B/C\" is owned by \"A/B!\"\n // (node GetParentName resolves with find_last_of for SUB and DEPIN alike).\n const slashIndex = assetName.lastIndexOf('/');\n if (slashIndex === -1) {\n return null;\n }\n return assetName.slice(0, slashIndex);\n}\nfunction getUniqueAssetName(rootName, tag) {\n return `${rootName}#${tag}`;\n}\nfunction normalizeVerifierString(verifierString) {\n return String(verifierString || '')\n .replace(/\\s+/g, '')\n .replace(/#/g, '');\n}\n// The node accepts DEPIN names up to 121 chars where DePIN is enabled, but a\n// 121-char base name yields a 122-char owner token (\"&X!\") that fails the\n// global name-length check, making the asset untransferable. Capped at 120\n// here so every name this library issues keeps a nameable owner token.\nconst DEPIN_MAX_NAME_LENGTH = 120;\nfunction isDepinAssetName(assetName) {\n const normalized = String(assetName || '').trim();\n if (normalized.length > DEPIN_MAX_NAME_LENGTH) {\n return false;\n }\n if (!normalized.includes('/')) {\n return /^&[A-Z0-9._]{3,}$/.test(normalized);\n }\n if (!/^&[A-Z0-9._]+\\/[A-Z0-9._/]+$/.test(normalized)) {\n return false;\n }\n // The node parser lets the first part count its leading '&' toward the\n // 3-char minimum (\"&AB/CDE\" parses), but such an asset can never be issued:\n // its parent \"&AB\" is not a valid root, so the parent owner token \"&AB!\"\n // required at issuance cannot exist. Require 3 real chars in every segment.\n const [root, ...rest] = normalized.split('/');\n return root.length >= 4 && rest.every((part) => part.length >= 3);\n}\nfunction assertDepinAssetName(assetName) {\n if (!isDepinAssetName(assetName)) {\n throw new Error(`Invalid DEPIN asset name: ${assetName}`);\n }\n}\nfunction assertDepinNetwork(network) {\n if (network !== undefined && resolveNetworkFamily(network) === 'mainnet') {\n throw new Error(`DEPIN assets are only available on testnet/regtest networks: ${network}`);\n }\n}\n\nfunction xnaToSatoshis(amount) {\n return assertMoneyRange(decimalToSatoshis(amount));\n}\nfunction assetUnitsToRaw(amount) {\n return xnaToSatoshis(amount);\n}\nfunction encodeAssetTransferPayload(assetName, amountRaw, message, expireTime, options) {\n const payload = [\n assetPayloadPrefix(options?.assetMarker, 'transfer'),\n serializeString(assetName),\n u64LE(assertMoneyRange(amountRaw))\n ];\n const encodedMessage = encodeAssetDataReference(message);\n if (encodedMessage.length > 0) {\n payload.push(encodedMessage);\n if (expireTime !== undefined && toRawInteger(expireTime) !== 0n) {\n payload.push(i64LE(expireTime));\n }\n }\n return concatBytes(...payload);\n}\nfunction encodeAssetTransferScript(address, assetName, amountRaw, message, expireTime, options) {\n return concatBytes(encodeDestinationScript(address), Uint8Array.of(OP_XNA_ASSET), pushData(encodeAssetTransferPayload(assetName, amountRaw, message, expireTime, options)), Uint8Array.of(OP_DROP));\n}\n/**\n * True when `script` is exactly the 25-byte P2PKH form\n * `OP_DUP OP_HASH160 0x14 <20B> OP_EQUALVERIFY OP_CHECKSIG`. Consensus only\n * recognises the asset wrapper when OP_XNA_ASSET sits at byte 25 after this\n * exact prefix (node `HasAssetOpcodeInExpectedPosition`).\n */\nfunction isP2pkhScript(script) {\n return (script.length === 25 &&\n script[0] === 0x76 &&\n script[1] === 0xa9 &&\n script[2] === 0x14 &&\n script[23] === 0x88 &&\n script[24] === 0xac);\n}\n/**\n * True when `script` is exactly the 34-byte AuthScript form\n * `OP_n 0x20 <32-byte commitment>`, with `OP_1` (generic v1), `OP_2` (PQ)\n * or `OP_3` (ECDSA). Consensus only recognises the asset wrapper when\n * OP_XNA_ASSET sits at byte 34 after this exact prefix; `OP_2` / `OP_3`\n * only where the strict AuthScript families are active.\n */\nfunction isAuthScriptScript(script) {\n return (script.length === 34 &&\n (script[0] === 0x51 || script[0] === 0x52 || script[0] === 0x53) &&\n script[1] === 0x20);\n}\n/**\n * Like `encodeAssetTransferScript` but takes a raw scriptPubKey instead of\n * deriving one from an address, for callers that already hold the\n * scriptPubKey bytes.\n *\n * The recipient script must be exactly P2PKH (25 bytes) or AuthScript\n * `OP_n <32B>` (34 bytes, n = 1, 2 or 3): the node's OP_XNA_ASSET placement rules only\n * accept the asset wrapper right after one of those two prefixes, on every\n * network, so appending it to any other script (a bare covenant, P2SH, …)\n * produces a consensus-invalid output. To pay assets into an arbitrary\n * script, commit it into an AuthScript destination instead (derive the\n * address with neurai-key's `getNoAuthAddress`) and use the regular\n * address-based transfer helpers.\n *\n * The asset-transfer wrapper is appended exactly as in the address-based\n * variant: `<recipientScriptPubKey> OP_XNA_ASSET <pushdata(payload)> OP_DROP`.\n *\n * Note: this helper only builds the output. Spending an AuthScript output\n * takes a witness stack; `createUnsignedTransaction` serializes the legacy\n * pre-segwit format only, so serialize such spends with the transaction\n * codec's `serializeTransaction` (tx-codec.ts, 0.5.1+) instead.\n */\nfunction encodeAssetTransferScriptToScript(recipientScriptPubKey, assetName, amountRaw, message, expireTime, options) {\n const spkBytes = typeof recipientScriptPubKey === 'string'\n ? hexToBytes(ensureHex(recipientScriptPubKey, 'recipientScriptPubKey'))\n : recipientScriptPubKey;\n if (!isP2pkhScript(spkBytes) && !isAuthScriptScript(spkBytes)) {\n throw new Error('asset transfers to arbitrary scripts are rejected by consensus ' +\n '(OP_XNA_ASSET placement rules): the recipient scriptPubKey must be ' +\n 'exactly P2PKH (25 bytes) or AuthScript OP_1/OP_2/OP_3 <32B> (34 bytes); ' +\n 'commit the script into an AuthScript destination instead');\n }\n return concatBytes(spkBytes, Uint8Array.of(OP_XNA_ASSET), pushData(encodeAssetTransferPayload(assetName, amountRaw, message, expireTime, options)), Uint8Array.of(OP_DROP));\n}\nfunction encodeNewAssetPayload(assetName, quantityRaw, units = 0, reissuable = true, ipfsHash, options) {\n const encodedIpfs = encodeAssetDataReference(ipfsHash);\n return concatBytes(assetPayloadPrefix(options?.assetMarker, 'new'), serializeString(assetName), u64LE(assertMoneyRange(quantityRaw)), Uint8Array.of(units & 0xff, reissuable ? 1 : 0, encodedIpfs.length > 0 ? 1 : 0), encodedIpfs);\n}\nfunction encodeNewAssetScript(address, assetName, quantityRaw, units = 0, reissuable = true, ipfsHash, options) {\n return concatBytes(encodeDestinationScript(address), Uint8Array.of(OP_XNA_ASSET), pushData(encodeNewAssetPayload(assetName, quantityRaw, units, reissuable, ipfsHash, options)), Uint8Array.of(OP_DROP));\n}\nfunction encodeOwnerAssetPayload(ownerTokenName, options) {\n return concatBytes(assetPayloadPrefix(options?.assetMarker, 'owner'), serializeString(ownerTokenName));\n}\nfunction encodeOwnerAssetScript(address, ownerTokenName, options) {\n return concatBytes(encodeDestinationScript(address), Uint8Array.of(OP_XNA_ASSET), pushData(encodeOwnerAssetPayload(ownerTokenName, options)), Uint8Array.of(OP_DROP));\n}\n/** \"Keep the asset's current units\", encoded as the signed byte -1 (0xff). */\nconst REISSUE_UNITS_UNCHANGED = -1;\n/**\n * Resolve the `units` byte of a reissue payload.\n *\n * Omitting `units` means \"do not change them\", which the protocol spells `-1`\n * (`0xff`) — the value the node's own `reissue` RPC defaults to. Its\n * validation is `nNewUnits == -1 || nNewUnits >= currentUnits`, so the\n * previous default of `0` said \"set units to 0\" and was rejected outright for\n * any asset with `units > 0` (`unit must be larger than current unit\n * selection`).\n *\n * An explicit `0` still encodes `0x00`: it is legitimate for an asset that\n * already has `units=0`, and folding it into -1 would lose the distinction in\n * the other direction.\n *\n * The range is validated rather than masked. `units & 0xff` used to turn `-2`\n * into `0xfe` and `255` into `0xff` — manufacturing a valid-looking\n * \"unchanged\" byte out of an invalid input.\n *\n * @param units - Requested units, or undefined to keep the current ones\n * @returns The byte to encode\n * @throws If units is not an integer in -1..8\n */\nfunction reissueUnitsByte(units) {\n const resolved = units ?? REISSUE_UNITS_UNCHANGED;\n if (!Number.isInteger(resolved) || resolved < -1 || resolved > 8) {\n throw new Error(`Invalid reissue units: ${units}. Use an integer 0..8 to set the units, ` +\n `or -1 (or omit it) to keep the asset's current units.`);\n }\n return resolved & 0xff;\n}\nfunction encodeReissueAssetPayload(assetName, quantityRaw, units, reissuable = true, ipfsHash, options) {\n return concatBytes(assetPayloadPrefix(options?.assetMarker, 'reissue'), serializeString(assetName), u64LE(assertMoneyRange(quantityRaw)), Uint8Array.of(reissueUnitsByte(units), reissuable ? 1 : 0), encodeAssetDataReference(ipfsHash));\n}\nfunction encodeReissueAssetScript(address, assetName, quantityRaw, units, reissuable = true, ipfsHash, options) {\n return concatBytes(encodeDestinationScript(address), Uint8Array.of(OP_XNA_ASSET), pushData(encodeReissueAssetPayload(assetName, quantityRaw, units, reissuable, ipfsHash, options)), Uint8Array.of(OP_DROP));\n}\nfunction encodeNullAssetDataPayload(assetName, flag) {\n const nameBytes = asciiBytes(assetName);\n return concatBytes(compactSize(nameBytes.length), nameBytes, Uint8Array.of(flag & 0xff));\n}\nfunction encodeNullAssetTagPayload(qualifierName, operation) {\n return encodeNullAssetDataPayload(qualifierName, operation === 'tag' ? 1 : 0);\n}\nfunction encodeNullAssetTagScript(address, qualifierName, operation, mode = 'strict') {\n return concatBytes(encodeNullAssetDestinationScript(address, mode), pushData(encodeNullAssetTagPayload(qualifierName, operation)));\n}\nfunction encodeNullAssetRestrictionScript(address, assetName, freezeFlag, mode = 'strict') {\n return concatBytes(encodeNullAssetDestinationScript(address, mode), pushData(encodeNullAssetDataPayload(assetName, freezeFlag)));\n}\nfunction encodeVerifierStringPayload(verifierString) {\n return serializeString(verifierString);\n}\nfunction encodeVerifierStringScript(verifierString) {\n return concatBytes(Uint8Array.of(OP_XNA_ASSET, OP_RESERVED), pushData(encodeVerifierStringPayload(verifierString)));\n}\nfunction encodeGlobalRestrictionScript(assetName, freezeFlag) {\n return concatBytes(Uint8Array.of(OP_XNA_ASSET, OP_RESERVED, OP_RESERVED), pushData(encodeNullAssetDataPayload(assetName, freezeFlag)));\n}\nfunction createXnaOutput(address, valueSats) {\n return {\n valueSats: assertMoneyRange(valueSats),\n scriptPubKeyHex: bytesToHex(encodeDestinationScript(address))\n };\n}\nfunction createAssetTransferOutput(address, assetName, amountRaw, options) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeAssetTransferScript(address, assetName, amountRaw, undefined, undefined, options))\n };\n}\nfunction createTransferWithMessageOutput(params) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeAssetTransferScript(params.address, params.assetName, params.amountRaw, params.message, params.expireTime, { assetMarker: params.assetMarker }))\n };\n}\nfunction createOwnerAssetIssueOutput(address, ownerTokenName, options) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeOwnerAssetScript(address, ownerTokenName, options))\n };\n}\nfunction createOwnerAssetTransferOutput(address, ownerTokenName, options) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeAssetTransferScript(address, ownerTokenName, OWNER_ASSET_AMOUNT, undefined, undefined, options))\n };\n}\nfunction createIssueAssetOutput(params) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeNewAssetScript(params.address, params.assetName, params.quantityRaw, params.units ?? 0, params.reissuable ?? true, params.ipfsHash, { assetMarker: params.assetMarker }))\n };\n}\nfunction createReissueAssetOutput(params) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeReissueAssetScript(params.address, params.assetName, params.quantityRaw, \n // Omitted means \"keep the current units\" (-1); do NOT collapse to 0.\n params.units, params.reissuable ?? true, params.ipfsHash, { assetMarker: params.assetMarker }))\n };\n}\nfunction createNullAssetTagOutput(address, qualifierName, operation, mode = 'strict') {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeNullAssetTagScript(address, qualifierName, operation, mode))\n };\n}\nfunction createNullAssetRestrictionOutput(address, assetName, freezeFlag, mode = 'strict') {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeNullAssetRestrictionScript(address, assetName, freezeFlag, mode))\n };\n}\nfunction createVerifierStringOutput(verifierString) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeVerifierStringScript(verifierString))\n };\n}\nfunction createGlobalRestrictionOutput(assetName, freezeFlag) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeGlobalRestrictionScript(assetName, freezeFlag))\n };\n}\nfunction createTransferOutput(params) {\n return createAssetTransferOutput(params.address, params.assetName, params.amountRaw, {\n assetMarker: params.assetMarker\n });\n}\n/**\n * Build a SerializedTxOutput that locks `amountRaw` of `assetName` under a\n * raw P2PKH or AuthScript scriptPubKey (the only shapes consensus accepts —\n * see `encodeAssetTransferScriptToScript`; covenants go through neurai-key's\n * `getNoAuthAddress` and the address-based helpers). `valueSats` is\n * hardcoded to 0n (asset-only outputs carry no XNA; matches\n * `createAssetTransferOutput` semantics).\n */\nfunction createAssetTransferToScriptOutput(params) {\n return {\n valueSats: 0n,\n scriptPubKeyHex: bytesToHex(encodeAssetTransferScriptToScript(params.scriptPubKeyHex, params.assetName, params.amountRaw, params.message, params.expireTime, { assetMarker: params.assetMarker }))\n };\n}\n\nfunction serializeInput(input) {\n const txidBytes = reverseBytes(hexToBytes(input.txid));\n const scriptSig = input.scriptSigHex ? hexToBytes(input.scriptSigHex) : new Uint8Array();\n return concatBytes(txidBytes, u32LE(input.vout), compactSize(scriptSig.length), scriptSig, u32LE(input.sequence ?? 0xffffffff));\n}\nfunction serializeOutput(output) {\n const scriptPubKey = hexToBytes(ensureHex(output.scriptPubKeyHex, 'scriptPubKeyHex'));\n return concatBytes(u64LE(output.valueSats), compactSize(scriptPubKey.length), scriptPubKey);\n}\nfunction createUnsignedTransaction(tx) {\n let total = 0n;\n for (const output of tx.outputs)\n total += assertMoneyRange(output.valueSats, 'output');\n assertMoneyRange(total, 'total outputs');\n const version = tx.version ?? 2;\n const locktime = tx.locktime ?? 0;\n const inputs = tx.inputs.map(serializeInput);\n const outputs = tx.outputs.map(serializeOutput);\n const bytes = concatBytes(u32LE(version), compactSize(inputs.length), ...inputs, compactSize(outputs.length), ...outputs, u32LE(locktime));\n return Array.from(bytes, (value) => value.toString(16).padStart(2, '0')).join('');\n}\n\nfunction buildTransaction(version, locktime, inputs, outputs) {\n return {\n rawTx: createUnsignedTransaction({\n version: version ?? 2,\n locktime: locktime ?? 0,\n inputs,\n outputs\n }),\n outputs\n };\n}\nfunction appendXnaEnvelope(outputs, burnAddress, burnAmountSats, changeAddress, changeSats) {\n if (burnAddress && burnAmountSats !== undefined && toRawInteger(burnAmountSats) > 0n) {\n outputs.push(createXnaOutput(burnAddress, burnAmountSats));\n }\n if (changeAddress && changeSats !== undefined && toRawInteger(changeSats) > 0n) {\n outputs.push(createXnaOutput(changeAddress, changeSats));\n }\n}\nfunction appendExtraOutputs(outputs, extraOutputs) {\n if (extraOutputs?.length) {\n outputs.push(...extraOutputs);\n }\n}\n/**\n * Null-asset data flag: 1 freezes, 0 unfreezes.\n *\n * Consensus accepts nothing else. The node's `VerifyNullAssetDataFlag`\n * (`src/assets/assets.cpp`) rejects any other value with\n * `bad-txns-null-data-flag-must-be-0-or-1`, and it takes neither the network\n * nor the height, so the mapping is identical on mainnet, testnet and regtest.\n *\n * These same two values serve the per-address restriction, the qualifier\n * tag/untag AND the global restriction: `VerifyRestrictedAddressChange`,\n * `VerifyQualifierChange` and `VerifyGlobalRestrictedChange` all delegate to\n * that one check. Captured from the node's own transactions:\n *\n * freezerestrictedasset $PROBE → c0505008062450524f424501 (flag 01)\n * unfreezerestrictedasset $PROBE → c0505008062450524f424500 (flag 00)\n *\n * Until 0.7.1 the global restriction added 2 to this value, emitting 3 and 2,\n * which the node rejected outright.\n */\nfunction freezeFlagFromOperation(operation) {\n return operation === 'freeze' ? 1 : 0;\n}\n// NIP-040: the transaction-level marker reaches every asset output a builder\n// creates; an output-level marker wins. `extraOutputs` are never touched.\nfunction marker(params) {\n return { assetMarker: params.assetMarker };\n}\nfunction withMarker(output, params) {\n return output.assetMarker === undefined && params.assetMarker !== undefined\n ? { ...output, assetMarker: params.assetMarker }\n : output;\n}\n// Compare by decoded destination script, not by address text: two encodings of\n// the same destination (e.g. different Bech32 case) must count as equal.\nfunction sameDestination(a, b) {\n return bytesToHex(encodeDestinationScript(a)) === bytesToHex(encodeDestinationScript(b));\n}\nfunction createPaymentTransaction(params) {\n const outputs = [\n ...params.payments.map((payment) => createXnaOutput(payment.address, payment.valueSats)),\n ...(params.extraOutputs ?? [])\n ];\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createStandardAssetTransferTransaction(params) {\n // Output order is fixed:\n // payments → transfers → transferMessages → transfersToScript → extraOutputs.\n // Keep transfersToScript after transferMessages so indices of existing\n // callers (payments + transfers + transferMessages) remain stable.\n const outputs = [];\n for (const payment of params.payments ?? []) {\n outputs.push(createXnaOutput(payment.address, payment.valueSats));\n }\n for (const transfer of params.transfers ?? []) {\n outputs.push(createTransferOutput(withMarker(transfer, params)));\n }\n for (const transfer of params.transferMessages ?? []) {\n outputs.push(createTransferWithMessageOutput(withMarker(transfer, params)));\n }\n for (const transfer of params.transfersToScript ?? []) {\n outputs.push(createAssetTransferToScriptOutput(withMarker(transfer, params)));\n }\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueAssetTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n // Consensus locates issuance outputs positionally (issue at vout[n-1], owner\n // at vout[n-2]), so extraOutputs must come before them, not after.\n appendExtraOutputs(outputs, params.extraOutputs);\n if (params.includeOwnerOutput ?? true) {\n outputs.push(createOwnerAssetIssueOutput(params.ownerTokenAddress ?? params.toAddress, params.ownerTokenName ?? getOwnerTokenName(params.assetName), marker(params)));\n }\n outputs.push(createIssueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n units: params.units ?? 0,\n reissuable: params.reissuable ?? true,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueSubAssetTransaction(params) {\n const parentAssetName = getParentAssetName(params.assetName);\n if (!parentAssetName) {\n throw new Error(`Sub-asset name must contain '/': ${params.assetName}`);\n }\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n outputs.push(createOwnerAssetTransferOutput(params.parentOwnerAddress ?? params.xnaChangeAddress ?? params.toAddress, getOwnerTokenName(parentAssetName), marker(params)));\n outputs.push(createOwnerAssetIssueOutput(params.ownerTokenAddress ?? params.toAddress, getOwnerTokenName(params.assetName), marker(params)));\n outputs.push(createIssueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n units: params.units ?? 0,\n reissuable: params.reissuable ?? true,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueDepinTransaction(params) {\n assertDepinAssetName(params.assetName);\n assertDepinNetwork(params.network);\n if (toRawInteger(params.quantityRaw) <= 0n) {\n throw new Error('DEPIN issue quantity must be positive');\n }\n if (params.reissuable !== undefined && typeof params.reissuable !== 'boolean') {\n throw new Error('DEPIN reissuable must be boolean when provided');\n }\n // A sub-DEPIN (\"&X/Y\") must transfer the immediate parent's owner token in\n // the issuing transaction, exactly like sub-assets. It stays AssetType DEPIN\n // (same burn as the root), so only the output layout follows the sub flow.\n if (getParentAssetName(params.assetName)) {\n return createIssueSubAssetTransaction({\n ...params,\n units: 0,\n reissuable: params.reissuable ?? true,\n parentOwnerAddress: params.parentOwnerAddress,\n ownerTokenAddress: params.ownerTokenAddress ?? params.toAddress\n });\n }\n return createIssueAssetTransaction({\n ...params,\n units: 0,\n includeOwnerOutput: true,\n ownerTokenAddress: params.ownerTokenAddress ?? params.toAddress,\n reissuable: params.reissuable ?? true\n });\n}\nfunction createDepinTransferTransaction(params) {\n assertDepinNetwork(params.network);\n if (!params.transfers?.length) {\n throw new Error('DEPIN transfer requires at least one transfer');\n }\n const assetName = params.transfers[0].assetName;\n assertDepinAssetName(assetName);\n for (const transfer of params.transfers) {\n if (transfer.assetName !== assetName) {\n throw new Error(`DEPIN transfers must all move the same asset (got ${transfer.assetName} and ${assetName}); build one transaction per DEPIN asset`);\n }\n if (toRawInteger(transfer.amountRaw) <= 0n) {\n throw new Error(`DEPIN transfer amount must be positive: ${assetName}`);\n }\n }\n const outputs = [];\n for (const transfer of params.transfers) {\n outputs.push(createTransferOutput(withMarker(transfer, params)));\n }\n // Soulbound escort: consensus also requires SPENDING an \"&X!\" UTXO, which\n // must be present in params.inputs (this package does not select UTXOs).\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress, getOwnerTokenName(assetName), marker(params)));\n appendXnaEnvelope(outputs, undefined, undefined, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createDepinSelfRevokeTransaction(params) {\n assertDepinAssetName(params.assetName);\n assertDepinNetwork(params.network);\n if (toRawInteger(params.amountRaw) <= 0n) {\n throw new Error('DEPIN self-revoke amount must be positive');\n }\n // Exact consensus pattern: one self-transfer of \"&X\" back to the holder plus\n // one null-data with flag 1 (the only valid flag without the owner token).\n // No owner token, no burn. The input-side rules live on the caller — see\n // DepinSelfRevokeTransactionParams.\n const outputs = [\n createAssetTransferOutput(params.holderAddress, params.assetName, params.amountRaw, marker(params)),\n createNullAssetRestrictionOutput(params.holderAddress, params.assetName, 1, params.nullAssetDestinationMode ?? 'strict')\n ];\n appendXnaEnvelope(outputs, undefined, undefined, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueUniqueAssetTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n outputs.push(createOwnerAssetTransferOutput(params.ownerTokenAddress ?? params.toAddress, getOwnerTokenName(params.rootName), marker(params)));\n for (let index = 0; index < params.assetTags.length; index += 1) {\n outputs.push(createIssueAssetOutput({\n address: params.toAddress,\n assetName: getUniqueAssetName(params.rootName, params.assetTags[index]),\n quantityRaw: UNIQUE_ASSET_AMOUNT,\n units: UNIQUE_ASSET_UNITS,\n reissuable: UNIQUE_ASSETS_REISSUABLE,\n ipfsHash: params.ipfsHashes?.[index],\n assetMarker: params.assetMarker\n }));\n }\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueQualifierTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n const parentQualifier = getParentAssetName(params.assetName);\n if (parentQualifier) {\n outputs.push(createAssetTransferOutput(params.rootChangeAddress ?? params.xnaChangeAddress ?? params.toAddress, parentQualifier, params.changeQuantityRaw ?? OWNER_ASSET_AMOUNT, marker(params)));\n }\n outputs.push(createIssueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n units: 0,\n reissuable: false,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createIssueRestrictedTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n outputs.push(createVerifierStringOutput(normalizeVerifierString(params.verifierString)));\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress ?? params.toAddress, getOwnerTokenName(params.assetName), marker(params)));\n outputs.push(createIssueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n units: params.units ?? 0,\n reissuable: params.reissuable ?? true,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createReissueTransaction(params) {\n if (isDepinAssetName(params.assetName)) {\n // DEPIN reissue: units must stay 0 (-1 means \"keep\"), and the owner-token\n // change must return to the destination address itself.\n if (params.units !== undefined && params.units !== 0 && params.units !== -1) {\n throw new Error('DEPIN reissue units must be 0 or -1 (keep)');\n }\n if (params.ownerChangeAddress !== undefined &&\n !sameDestination(params.ownerChangeAddress, params.toAddress)) {\n throw new Error('DEPIN reissue owner change address must match the destination address');\n }\n }\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n // Consensus locates the reissue output at vout[n-1]; extraOutputs go first.\n appendExtraOutputs(outputs, params.extraOutputs);\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress ?? params.toAddress, getOwnerTokenName(params.assetName), marker(params)));\n outputs.push(createReissueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n // Omitted means \"keep the current units\" (-1); do NOT collapse to 0.\n units: params.units,\n reissuable: params.reissuable ?? true,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createReissueRestrictedTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n appendExtraOutputs(outputs, params.extraOutputs);\n if (params.verifierString) {\n outputs.push(createVerifierStringOutput(normalizeVerifierString(params.verifierString)));\n }\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress ?? params.toAddress, getOwnerTokenName(params.assetName), marker(params)));\n outputs.push(createReissueAssetOutput({\n address: params.toAddress,\n assetName: params.assetName,\n quantityRaw: params.quantityRaw,\n // Omitted means \"keep the current units\" (-1); do NOT collapse to 0.\n units: params.units,\n reissuable: params.reissuable ?? true,\n ipfsHash: params.ipfsHash,\n assetMarker: params.assetMarker\n }));\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createQualifierTagTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, params.burnAddress, params.burnAmountSats, params.xnaChangeAddress, params.xnaChangeSats);\n outputs.push(createAssetTransferOutput(params.qualifierChangeAddress, params.qualifierName, params.qualifierChangeAmountRaw, marker(params)));\n for (const address of params.targetAddresses) {\n outputs.push(createNullAssetTagOutput(address, params.qualifierName, params.operation, params.nullAssetDestinationMode ?? 'strict'));\n }\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createFreezeAddressesTransaction(params) {\n if (isDepinAssetName(params.assetName)) {\n // The address holding (or receiving) the owner token cannot be frozen or\n // revoked. The node also rejects spending an \"&X!\" UTXO that sits on a\n // target address — that input-side rule cannot be checked here (inputs\n // carry no address) and stays the caller's responsibility.\n for (const target of params.targetAddresses) {\n if (sameDestination(target, params.ownerChangeAddress)) {\n throw new Error('DEPIN owner change address cannot be one of the target addresses (owner-holder address cannot be frozen or revoked)');\n }\n }\n }\n const outputs = [];\n appendXnaEnvelope(outputs, undefined, undefined, params.xnaChangeAddress, params.xnaChangeSats);\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress, getOwnerTokenName(params.assetName), marker(params)));\n for (const address of params.targetAddresses) {\n outputs.push(createNullAssetRestrictionOutput(address, params.assetName, freezeFlagFromOperation(params.operation), params.nullAssetDestinationMode ?? 'strict'));\n }\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createFreezeAssetTransaction(params) {\n const outputs = [];\n appendXnaEnvelope(outputs, undefined, undefined, params.xnaChangeAddress, params.xnaChangeSats);\n outputs.push(createOwnerAssetTransferOutput(params.ownerChangeAddress, getOwnerTokenName(params.assetName), marker(params)));\n outputs.push(createGlobalRestrictionOutput(params.assetName, freezeFlagFromOperation(params.operation)));\n appendExtraOutputs(outputs, params.extraOutputs);\n return buildTransaction(params.version, params.locktime, params.inputs, outputs);\n}\nfunction createFromOperation(build) {\n switch (build.operationType) {\n case 'STANDARD_PAYMENT':\n return createPaymentTransaction(build.params);\n case 'STANDARD_TRANSFER':\n return createStandardAssetTransferTransaction(build.params);\n case 'ISSUE_ROOT':\n case 'ISSUE_MSGCHANNEL':\n return createIssueAssetTransaction(build.params);\n case 'ISSUE_SUB':\n return createIssueSubAssetTransaction(build.params);\n case 'ISSUE_UNIQUE':\n return createIssueUniqueAssetTransaction(build.params);\n case 'ISSUE_DEPIN':\n return createIssueDepinTransaction(build.params);\n case 'ISSUE_QUALIFIER':\n case 'ISSUE_SUB_QUALIFIER':\n return createIssueQualifierTransaction(build.params);\n case 'ISSUE_RESTRICTED':\n return createIssueRestrictedTransaction(build.params);\n case 'REISSUE':\n return createReissueTransaction(build.params);\n case 'REISSUE_RESTRICTED':\n return createReissueRestrictedTransaction(build.params);\n case 'TRANSFER_DEPIN':\n return createDepinTransferTransaction(build.params);\n case 'SELF_REVOKE_DEPIN':\n return createDepinSelfRevokeTransaction(build.params);\n case 'TAG_ADDRESSES':\n return createQualifierTagTransaction({\n ...build.params,\n operation: 'tag'\n });\n case 'UNTAG_ADDRESSES':\n return createQualifierTagTransaction({\n ...build.params,\n operation: 'untag'\n });\n case 'FREEZE_ADDRESSES':\n return createFreezeAddressesTransaction({\n ...build.params,\n operation: 'freeze'\n });\n case 'UNFREEZE_ADDRESSES':\n return createFreezeAddressesTransaction({\n ...build.params,\n operation: 'unfreeze'\n });\n case 'FREEZE_ASSET':\n return createFreezeAssetTransaction({\n ...build.params,\n operation: 'freeze'\n });\n case 'UNFREEZE_ASSET':\n return createFreezeAssetTransaction({\n ...build.params,\n operation: 'unfreeze'\n });\n default: {\n const unsupported = build;\n throw new Error(`Unsupported operation type: ${JSON.stringify(unsupported)}`);\n }\n }\n}\n\n/**\n * Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.\n * @param a - value to test\n * @returns `true` when the value is a Uint8Array-compatible view.\n * @example\n * Check whether a value is a Uint8Array-compatible view.\n * ```ts\n * isBytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nfunction isBytes(a) {\n // Plain `instanceof Uint8Array` is too strict for some Buffer / proxy / cross-realm cases.\n // The fallback still requires a real ArrayBuffer view, so plain\n // JSON-deserialized `{ constructor: ... }` spoofing is rejected, and\n // `BYTES_PER_ELEMENT === 1` keeps the fallback on byte-oriented views.\n return (a instanceof Uint8Array ||\n (ArrayBuffer.isView(a) &&\n a.constructor.name === 'Uint8Array' &&\n 'BYTES_PER_ELEMENT' in a &&\n a.BYTES_PER_ELEMENT === 1));\n}\n/**\n * Asserts something is Uint8Array.\n * @param value - value to validate\n * @param length - optional exact length constraint\n * @param title - label included in thrown errors\n * @returns The validated byte array.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate that a value is a byte array.\n * ```ts\n * abytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nfunction abytes(value, length, title = '') {\n const bytes = isBytes(value);\n const len = value?.length;\n const needsLen = length !== undefined;\n if (!bytes || (needsLen)) {\n const prefix = title && `\"${title}\" `;\n const ofLen = '';\n const got = bytes ? `length=${len}` : `type=${typeof value}`;\n const message = prefix + 'expected Uint8Array' + ofLen + ', got ' + got;\n if (!bytes)\n throw new TypeError(message);\n throw new RangeError(message);\n }\n return value;\n}\n/**\n * Asserts a hash instance has not been destroyed or finished.\n * @param instance - hash instance to validate\n * @param checkFinished - whether to reject finalized instances\n * @throws If the hash instance has already been destroyed or finalized. {@link Error}\n * @example\n * Validate that a hash instance is still usable.\n * ```ts\n * import { aexists } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const hash = sha256.create();\n * aexists(hash);\n * ```\n */\nfunction aexists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\n/**\n * Asserts output is a sufficiently-sized byte array.\n * @param out - destination buffer\n * @param instance - hash instance providing output length\n * Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate a caller-provided digest buffer.\n * ```ts\n * import { aoutput } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const hash = sha256.create();\n * aoutput(new Uint8Array(hash.outputLen), hash);\n * ```\n */\nfunction aoutput(out, instance) {\n abytes(out, undefined, 'digestInto() output');\n const min = instance.outputLen;\n if (out.length < min) {\n throw new RangeError('\"digestInto() output\" expected to be of length >=' + min);\n }\n}\n/**\n * Zeroizes typed arrays in place. Warning: JS provides no guarantees.\n * @param arrays - arrays to overwrite with zeros\n * @example\n * Zeroize sensitive buffers in place.\n * ```ts\n * clean(new Uint8Array([1, 2, 3]));\n * ```\n */\nfunction clean(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n/**\n * Creates a DataView for byte-level manipulation.\n * @param arr - source typed array\n * @returns DataView over the same buffer region.\n * @example\n * Create a DataView over an existing buffer.\n * ```ts\n * createView(new Uint8Array(4));\n * ```\n */\nfunction createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/**\n * Rotate-right operation for uint32 values.\n * @param word - source word\n * @param shift - shift amount in bits\n * @returns Rotated word.\n * @example\n * Rotate a 32-bit word to the right.\n * ```ts\n * rotr(0x12345678, 8);\n * ```\n */\nfunction rotr(word, shift) {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/**\n * Rotate-left operation for uint32 values.\n * @param word - source word\n * @param shift - shift amount in bits\n * @returns Rotated word.\n * @example\n * Rotate a 32-bit word to the left.\n * ```ts\n * rotl(0x12345678, 8);\n * ```\n */\nfunction rotl(word, shift) {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n/**\n * Creates a callable hash function from a stateful class constructor.\n * @param hashCons - hash constructor or factory\n * @param info - optional metadata such as DER OID\n * @returns Frozen callable hash wrapper with `.create()`.\n * Wrapper construction eagerly calls `hashCons(undefined)` once to read\n * `outputLen` / `blockLen`, so constructor side effects happen at module\n * init time.\n * @example\n * Wrap a stateful hash constructor into a callable helper.\n * ```ts\n * import { createHasher } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const wrapped = createHasher(sha256.create, { oid: sha256.oid });\n * wrapped(new Uint8Array([1]));\n * ```\n */\nfunction createHasher(hashCons, info = {}) {\n const hashC = (msg, opts) => hashCons(opts)\n .update(msg)\n .digest();\n const tmp = hashCons(undefined);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.canXOF = tmp.canXOF;\n hashC.create = (opts) => hashCons(opts);\n Object.assign(hashC, info);\n return Object.freeze(hashC);\n}\n/**\n * Creates OID metadata for NIST hashes with prefix `06 09 60 86 48 01 65 03 04 02`.\n * @param suffix - final OID byte for the selected hash.\n * The helper accepts any byte even though only the documented NIST hash\n * suffixes are meaningful downstream.\n * @returns Object containing the DER-encoded OID.\n * @example\n * Build OID metadata for a NIST hash.\n * ```ts\n * oidNist(0x01);\n * ```\n */\nconst oidNist = (suffix) => ({\n // Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.\n // Larger suffix values would need base-128 OID encoding and a different length byte.\n oid: Uint8Array.from([0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, suffix]),\n});\n\n/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\n/**\n * Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.\n * Returns bits from `b` when `a` is set, otherwise from `c`.\n * The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never\n * set the same bit.\n * @param a - selector word\n * @param b - word chosen when selector bit is set\n * @param c - word chosen when selector bit is clear\n * @returns Mixed 32-bit word.\n * @example\n * Combine three words with the shared 32-bit choice primitive.\n * ```ts\n * Chi(0xffffffff, 0x12345678, 0x87654321);\n * ```\n */\nfunction Chi(a, b, c) {\n return (a & b) ^ (~a & c);\n}\n/**\n * Shared 32-bit majority primitive reused by SHA-256 and SHA-1.\n * Returns bits shared by at least two inputs.\n * @param a - first input word\n * @param b - second input word\n * @param c - third input word\n * @returns Mixed 32-bit word.\n * @example\n * Combine three words with the shared 32-bit majority primitive.\n * ```ts\n * Maj(0xffffffff, 0x12345678, 0x87654321);\n * ```\n */\nfunction Maj(a, b, c) {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n * Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit\n * strings with partial-byte tails.\n * @param blockLen - internal block size in bytes\n * @param outputLen - digest size in bytes\n * @param padOffset - trailing length field size in bytes\n * @param isLE - whether length and state words are encoded in little-endian\n * @example\n * Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.\n * ```ts\n * import { _SHA1 } from '@noble/hashes/legacy.js';\n * const hash = new _SHA1();\n * hash.update(new Uint8Array([97, 98, 99]));\n * hash.digest();\n * ```\n */\nclass HashMD {\n blockLen;\n outputLen;\n canXOF = false;\n padOffset;\n isLE;\n // For partial updates less than block size\n buffer;\n view;\n finished = false;\n length = 0;\n pos = 0;\n destroyed = false;\n constructor(blockLen, outputLen, padOffset, isLE) {\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data) {\n aexists(this);\n abytes(data);\n const { view, buffer, blockLen } = this;\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path only when there is no buffered partial block: `take === blockLen` implies\n // `this.pos === 0`, so we can process full blocks directly from the input view.\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n clean(this.buffer.subarray(pos));\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // `padOffset` reserves the whole length field. For SHA-384/512 the high 64 bits stay zero from\n // the padding fill above, and JS will overflow before user input can make that half non-zero.\n // So we only need to write the low 64 bits here.\n view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which must be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen must be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n // Copy before destroy(): subclasses wipe `buffer` during cleanup, but `digest()` must return\n // fresh bytes to the caller.\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to ||= new this.constructor();\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.destroyed = destroyed;\n to.finished = finished;\n to.length = length;\n to.pos = pos;\n // Only partial-block bytes need copying: when `length % blockLen === 0`, `pos === 0` and\n // later `update()` / `digestInto()` overwrite `to.buffer` from the start before reading it.\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n clone() {\n return this._cloneInto();\n }\n}\n/**\n * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.\n * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.\n */\n/** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the\n * square roots of the first eight prime numbers. Exported as a shared table; callers must treat\n * it as read-only because constructors copy words from it by index. */\nconst SHA256_IV = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n\n/**\n * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.\n * SHA256 is the fastest hash implementable in JS, even faster than Blake3.\n * Check out {@link https://www.rfc-editor.org/rfc/rfc4634 | RFC 4634} and\n * {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf | FIPS 180-4}.\n * @module\n */\n/**\n * SHA-224 / SHA-256 round constants from RFC 6234 §5.1: the first 32 bits\n * of the cube roots of the first 64 primes (2..311).\n */\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ Uint32Array.from([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n/** Reusable SHA-224 / SHA-256 message schedule buffer `W_t` from RFC 6234 §6.2 step 1. */\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\n/** Internal SHA-224 / SHA-256 compression engine from RFC 6234 §6.2. */\nclass SHA2_32B extends HashMD {\n constructor(outputLen) {\n super(64, outputLen, 8, false);\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n clean(SHA256_W);\n }\n destroy() {\n // HashMD callers route post-destroy usability through `destroyed`; zeroizing alone still leaves\n // update()/digest() callable on reused instances.\n this.destroyed = true;\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n clean(this.buffer);\n }\n}\n/** Internal SHA-256 hash class grounded in RFC 6234 §6.2. */\nclass _SHA256 extends SHA2_32B {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n A = SHA256_IV[0] | 0;\n B = SHA256_IV[1] | 0;\n C = SHA256_IV[2] | 0;\n D = SHA256_IV[3] | 0;\n E = SHA256_IV[4] | 0;\n F = SHA256_IV[5] | 0;\n G = SHA256_IV[6] | 0;\n H = SHA256_IV[7] | 0;\n constructor() {\n super(32);\n }\n}\n/**\n * SHA2-256 hash function from RFC 4634. In JS it's the fastest: even faster than Blake3. Some info:\n *\n * - Trying 2^128 hashes would get 50% chance of collision, using birthday attack.\n * - BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n * - Each sha256 hash is executing 2^18 bit operations.\n * - Good 2024 ASICs can do 200Th/sec with 3500 watts of power, corresponding to 2^36 hashes/joule.\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-256.\n * ```ts\n * sha256(new Uint8Array([97, 98, 99]));\n * ```\n */\nconst sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(), \n/* @__PURE__ */ oidNist(0x01));\n\n// Hard deserialization bound, mirroring the node (serialize.h MAX_SIZE):\n// ReadCompactSize rejects anything above it, canonical or not.\nconst MAX_SIZE = 0x02000000;\nfunction hash256(bytes) {\n return sha256(sha256(bytes));\n}\nclass ByteReader {\n bytes;\n offset = 0;\n constructor(bytes) {\n this.bytes = bytes;\n }\n need(count) {\n if (count > this.bytes.length - this.offset) {\n throw new Error(`Transaction hex truncated: need ${count} more byte(s) at offset ${this.offset}, ` +\n `${this.bytes.length - this.offset} remaining`);\n }\n }\n readBytes(count) {\n this.need(count);\n const slice = this.bytes.subarray(this.offset, this.offset + count);\n this.offset += count;\n return slice;\n }\n readU8() {\n return this.readBytes(1)[0];\n }\n readU32() {\n const slice = this.readBytes(4);\n return (slice[0] | (slice[1] << 8) | (slice[2] << 16) | (slice[3] << 24)) >>> 0;\n }\n readU64() {\n const slice = this.readBytes(8);\n let value = 0n;\n for (let i = 7; i >= 0; i -= 1) {\n value = (value << 8n) | BigInt(slice[i]);\n }\n return value;\n }\n // Canonical CompactSize with the node's range bound: the shortest encoding\n // is mandatory and anything above MAX_SIZE throws, exactly like\n // ReadCompactSize. Lengths are validated against the remaining bytes by the\n // callers BEFORE any allocation or iteration.\n readCompactSize() {\n const first = this.readU8();\n let value;\n if (first < 0xfd) {\n value = first;\n }\n else if (first === 0xfd) {\n const slice = this.readBytes(2);\n value = slice[0] | (slice[1] << 8);\n if (value < 0xfd)\n throw new Error('Non-canonical CompactSize (0xfd form for value < 253)');\n }\n else if (first === 0xfe) {\n value = this.readU32();\n if (value < 0x10000)\n throw new Error('Non-canonical CompactSize (0xfe form for value < 0x10000)');\n }\n else {\n const big = this.readU64();\n if (big < 0x100000000n)\n throw new Error('Non-canonical CompactSize (0xff form for value < 2^32)');\n if (big > BigInt(MAX_SIZE))\n throw new Error(`CompactSize exceeds MAX_SIZE: ${big}`);\n value = Number(big);\n }\n if (value > MAX_SIZE) {\n throw new Error(`CompactSize exceeds MAX_SIZE: ${value}`);\n }\n return value;\n }\n /** Read a length prefix that must fit in the remaining bytes at `bytesPerItem`. */\n readCount(bytesPerItem, label) {\n const count = this.readCompactSize();\n if (count * bytesPerItem > this.bytes.length - this.offset) {\n throw new Error(`Declared ${label} count ${count} does not fit in the remaining ` +\n `${this.bytes.length - this.offset} byte(s)`);\n }\n return count;\n }\n get finished() {\n return this.offset === this.bytes.length;\n }\n get position() {\n return this.offset;\n }\n}\nfunction readOutpoint(reader) {\n const txid = bytesToHex(reverseBytes(reader.readBytes(32)));\n const vout = reader.readU32();\n return { txid, vout };\n}\nfunction readInput(reader) {\n const { txid, vout } = readOutpoint(reader);\n const scriptLength = reader.readCount(1, 'scriptSig');\n const scriptSigHex = bytesToHex(reader.readBytes(scriptLength));\n const sequence = reader.readU32();\n return { txid, vout, scriptSigHex, sequence };\n}\nfunction readOutput(reader) {\n const valueSats = reader.readU64();\n const scriptLength = reader.readCount(1, 'scriptPubKey');\n const scriptPubKeyHex = bytesToHex(reader.readBytes(scriptLength));\n return { valueSats, scriptPubKeyHex };\n}\n// Minimum serialized size per item, used only to bound counts before reading:\n// input = outpoint(36) + compactSize(1) + sequence(4); output = value(8) +\n// compactSize(1); witness element = compactSize(1).\nconst MIN_INPUT_SIZE = 41;\nconst MIN_OUTPUT_SIZE = 9;\nfunction parseTransaction(hex) {\n const reader = new ByteReader(hexToBytes(ensureHex(hex, 'transaction hex')));\n // nVersion is a signed int32 (negative versions exist on-chain historically).\n const version = reader.readU32() | 0;\n const inputs = [];\n const outputs = [];\n let flags = 0;\n const vinCount = reader.readCount(MIN_INPUT_SIZE, 'input');\n if (vinCount === 0) {\n // Either a dummy marker for the extended (witness) format, or a genuinely\n // empty vin. Mirrors UnserializeTransaction: a flags byte follows; when it\n // is non-zero the real vin/vout follow, when zero the vout is NOT read.\n flags = reader.readU8();\n if (flags !== 0) {\n const realVinCount = reader.readCount(MIN_INPUT_SIZE, 'input');\n for (let i = 0; i < realVinCount; i += 1)\n inputs.push(readInput(reader));\n const voutCount = reader.readCount(MIN_OUTPUT_SIZE, 'output');\n for (let i = 0; i < voutCount; i += 1)\n outputs.push(readOutput(reader));\n }\n }\n else {\n for (let i = 0; i < vinCount; i += 1)\n inputs.push(readInput(reader));\n const voutCount = reader.readCount(MIN_OUTPUT_SIZE, 'output');\n for (let i = 0; i < voutCount; i += 1)\n outputs.push(readOutput(reader));\n }\n // NIP-014: reference inputs sit between vout and witness, announced by flag\n // 0x02. Without the flag a version 3 transaction reads as 1.0.7 reads it.\n const vrefin = [];\n const hasRefInputs = (flags & 2) !== 0;\n if (hasRefInputs) {\n flags ^= 2;\n const refCount = reader.readCount(36, 'refinput');\n for (let i = 0; i < refCount; i += 1)\n vrefin.push(readOutpoint(reader));\n if (vrefin.length === 0) {\n // One encoding per transaction: the flag means some.\n throw new Error('Superfluous reference inputs record (flag 0x02 with no reference inputs)');\n }\n }\n if (flags & 1) {\n flags ^= 1;\n for (const input of inputs) {\n const stackSize = reader.readCount(1, 'witness element');\n const stack = [];\n for (let i = 0; i < stackSize; i += 1) {\n const elementLength = reader.readCount(1, 'witness bytes');\n stack.push(bytesToHex(reader.readBytes(elementLength)));\n }\n input.witness = stack;\n }\n if (hasRefInputs && !inputs.some(inputHasWitness)) {\n // With reference inputs the witness flag means some witness; 1.0.7 reads\n // an empty witness record without them, and so does the node.\n throw new Error('Superfluous witness record (flag 0x01 with no witness data)');\n }\n }\n if (flags) {\n throw new Error(`Unknown transaction optional data (flags 0x${flags.toString(16)})`);\n }\n const locktime = reader.readU32();\n if (!reader.finished) {\n throw new Error(`Trailing bytes after transaction (offset ${reader.position})`);\n }\n return { version, inputs, outputs, vrefin, locktime };\n}\nfunction serializeOutpoint(ref) {\n const txid = hexToBytes(ensureHex(ref.txid, 'txid'));\n if (txid.length !== 32) {\n throw new Error(`Invalid txid: expected 32 bytes, got ${txid.length}`);\n }\n return concatBytes(reverseBytes(txid), u32LE(ref.vout));\n}\nfunction serializeCodecInput(input) {\n const scriptSig = hexToBytes(ensureHex(input.scriptSigHex ?? '', 'scriptSigHex'));\n return concatBytes(serializeOutpoint(input), compactSize(scriptSig.length), scriptSig, u32LE(input.sequence ?? 0xffffffff));\n}\nfunction serializeCodecOutput(output) {\n const script = hexToBytes(ensureHex(output.scriptPubKeyHex, 'scriptPubKeyHex'));\n return concatBytes(u64LE(output.valueSats), compactSize(script.length), script);\n}\nfunction inputHasWitness(input) {\n return (input.witness?.length ?? 0) > 0;\n}\nfunction serializeTransaction(tx, options = {}) {\n if (!Number.isInteger(tx.version) || tx.version < -2147483648 || tx.version > 0x7fffffff) {\n throw new Error(`Transaction version out of int32 range: ${tx.version}`);\n }\n const vrefin = tx.vrefin ?? [];\n if (tx.version !== 3 && vrefin.length > 0) {\n throw new Error(`vrefin requires transaction version 3 (got version ${tx.version})`);\n }\n const withWitness = (options.includeWitness ?? true) && tx.inputs.some(inputHasWitness);\n // NIP-014: reference inputs keep the extended format without witnesses too,\n // because the txid commits to them.\n const flags = (withWitness ? 1 : 0) | (vrefin.length > 0 ? 2 : 0);\n const parts = [u32LE(tx.version >>> 0)];\n if (flags) {\n // Extended format: dummy empty vin + flags byte.\n parts.push(Uint8Array.of(0x00, flags));\n }\n parts.push(compactSize(tx.inputs.length));\n for (const input of tx.inputs)\n parts.push(serializeCodecInput(input));\n parts.push(compactSize(tx.outputs.length));\n for (const output of tx.outputs)\n parts.push(serializeCodecOutput(output));\n if (flags & 2) {\n parts.push(compactSize(vrefin.length));\n for (const ref of vrefin)\n parts.push(serializeOutpoint(ref));\n }\n if (withWitness) {\n // One stack per input, empty (CompactSize 0) where the input has none.\n for (const input of tx.inputs) {\n const stack = input.witness ?? [];\n parts.push(compactSize(stack.length));\n for (const element of stack) {\n const bytes = hexToBytes(ensureHex(element, 'witness element'));\n parts.push(compactSize(bytes.length), bytes);\n }\n }\n }\n parts.push(u32LE(tx.locktime));\n return bytesToHex(concatBytes(...parts));\n}\nfunction toDecoded(txOrHex) {\n return typeof txOrHex === 'string' ? parseTransaction(txOrHex) : txOrHex;\n}\nfunction computeTxid(txOrHex) {\n const stripped = serializeTransaction(toDecoded(txOrHex), { includeWitness: false });\n return bytesToHex(reverseBytes(hash256(hexToBytes(stripped))));\n}\nfunction computeWtxid(txOrHex) {\n const full = serializeTransaction(toDecoded(txOrHex));\n return bytesToHex(reverseBytes(hash256(hexToBytes(full))));\n}\nfunction estimateTransactionSize(txOrHex) {\n const tx = toDecoded(txOrHex);\n const size = serializeTransaction(tx).length / 2;\n const strippedSize = serializeTransaction(tx, { includeWitness: false }).length / 2;\n // consensus/validation.h: weight = stripped * (WITNESS_SCALE_FACTOR - 1) + total.\n const weight = strippedSize * 3 + size;\n return { size, strippedSize, weight, vsize: Math.ceil(weight / 4) };\n}\n\n/**\n\nSHA1 (RFC 3174), MD5 (RFC 1321), and RIPEMD160 legacy, weak hash functions.\nRFC 2286 only covers HMAC-RIPEMD160 wrapper material and test vectors,\nnot the base RIPEMD-160 compression spec.\nDon't use them in a new protocol. What \"weak\" means:\n\n- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160.\n- No practical pre-image attacks (only theoretical, 2^123.4)\n- HMAC seems kinda ok: https://www.rfc-editor.org/rfc/rfc6151\n * @module\n */\n// RIPEMD-160\n// Permutation repeatedly applied to derive the later RIPEMD-160 message-order tables.\nconst Rho160 = /* @__PURE__ */ Uint8Array.from([\n 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,\n]);\nconst Id160 = /* @__PURE__ */ (() => Uint8Array.from(new Array(16).fill(0).map((_, i) => i)))();\nconst Pi160 = /* @__PURE__ */ (() => Id160.map((i) => (9 * i + 5) % 16))();\n// Five left/right message-word orderings for the RIPEMD-160 dual-lane rounds.\nconst idxLR = /* @__PURE__ */ (() => {\n const L = [Id160];\n const R = [Pi160];\n const res = [L, R];\n for (let i = 0; i < 4; i++)\n for (let j of res)\n j.push(j[i].map((k) => Rho160[k]));\n return res;\n})();\nconst idxL = /* @__PURE__ */ (() => idxLR[0])();\nconst idxR = /* @__PURE__ */ (() => idxLR[1])();\n// const [idxL, idxR] = idxLR;\n// Base per-group shift table before the left/right message-order permutations are applied.\nconst shifts160 = /* @__PURE__ */ [\n [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],\n [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],\n [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],\n [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],\n [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5],\n].map((i) => Uint8Array.from(i));\nconst shiftsL160 = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts160[i][j]));\nconst shiftsR160 = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts160[i][j]));\n// Five left-lane additive constants for RIPEMD-160.\nconst Kl160 = /* @__PURE__ */ Uint32Array.from([\n 0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e,\n]);\n// Five right-lane additive constants for RIPEMD-160.\nconst Kr160 = /* @__PURE__ */ Uint32Array.from([\n 0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000,\n]);\n// Called `f()` in the spec; valid `group` values are 0..4, and out-of-range\n// inputs currently fall through to the group-4 branch.\nfunction ripemd_f(group, x, y, z) {\n if (group === 0)\n return x ^ y ^ z;\n if (group === 1)\n return (x & y) | (~x & z);\n if (group === 2)\n return (x | ~y) ^ z;\n if (group === 3)\n return (x & z) | (y & ~z);\n return x ^ (y | ~z);\n}\n// Reusable 16-word RIPEMD-160 message block buffer.\nconst BUF_160 = /* @__PURE__ */ new Uint32Array(16);\n/**\n * Internal RIPEMD-160 legacy hash class.\n * RFC 2286 only adds HMAC-RIPEMD160 material, not the core hash specification.\n */\nclass _RIPEMD160 extends HashMD {\n h0 = 0x67452301 | 0;\n h1 = 0xefcdab89 | 0;\n h2 = 0x98badcfe | 0;\n h3 = 0x10325476 | 0;\n h4 = 0xc3d2e1f0 | 0;\n constructor() {\n super(64, 20, 8, true);\n }\n get() {\n const { h0, h1, h2, h3, h4 } = this;\n return [h0, h1, h2, h3, h4];\n }\n set(h0, h1, h2, h3, h4) {\n this.h0 = h0 | 0;\n this.h1 = h1 | 0;\n this.h2 = h2 | 0;\n this.h3 = h3 | 0;\n this.h4 = h4 | 0;\n }\n process(view, offset) {\n for (let i = 0; i < 16; i++, offset += 4)\n BUF_160[i] = view.getUint32(offset, true);\n // prettier-ignore\n let al = this.h0 | 0, ar = al, bl = this.h1 | 0, br = bl, cl = this.h2 | 0, cr = cl, dl = this.h3 | 0, dr = dl, el = this.h4 | 0, er = el;\n // Instead of iterating 0 to 80, we split it into 5 groups\n // And use the groups in constants, functions, etc. Much simpler\n for (let group = 0; group < 5; group++) {\n const rGroup = 4 - group;\n const hbl = Kl160[group], hbr = Kr160[group]; // prettier-ignore\n const rl = idxL[group], rr = idxR[group]; // prettier-ignore\n const sl = shiftsL160[group], sr = shiftsR160[group]; // prettier-ignore\n for (let i = 0; i < 16; i++) {\n const tl = (rotl(al + ripemd_f(group, bl, cl, dl) + BUF_160[rl[i]] + hbl, sl[i]) + el) | 0;\n al = el, el = dl, dl = rotl(cl, 10) | 0, cl = bl, bl = tl; // prettier-ignore\n }\n // 2 loops are 10% faster\n for (let i = 0; i < 16; i++) {\n const tr = (rotl(ar + ripemd_f(rGroup, br, cr, dr) + BUF_160[rr[i]] + hbr, sr[i]) + er) | 0;\n ar = er, er = dr, dr = rotl(cr, 10) | 0, cr = br, br = tr; // prettier-ignore\n }\n }\n // Add the compressed chunk to the current hash value\n // Final recombination cross-adds the left/right lane accumulators into the next h0..h4 order.\n this.set((this.h1 + cl + dr) | 0, (this.h2 + dl + er) | 0, (this.h3 + el + ar) | 0, (this.h4 + al + br) | 0, (this.h0 + bl + cr) | 0);\n }\n roundClean() {\n clean(BUF_160);\n }\n destroy() {\n this.destroyed = true;\n clean(this.buffer);\n this.set(0, 0, 0, 0, 0);\n }\n}\n/**\n * RIPEMD-160 - a legacy hash function from 1990s.\n * RFC 2286 only covers HMAC-RIPEMD160 test material; the links below point\n * at the base RIPEMD-160 references.\n * * {@link https://homes.esat.kuleuven.be/~bosselae/ripemd160.html}\n * * {@link https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf}\n * @param msg - message bytes to hash\n * @returns Digest bytes.\n * @example\n * Hash a message with RIPEMD-160.\n * ```ts\n * ripemd160(new Uint8Array([97, 98, 99]));\n * ```\n */\nconst ripemd160 = /* @__PURE__ */ createHasher(() => new _RIPEMD160());\n\nconst PSBT_MAGIC = Uint8Array.of(0x70, 0x73, 0x62, 0x74, 0xff);\nconst PSBT_GLOBAL_UNSIGNED_TX = 0x00;\nconst PSBT_GLOBAL_VERSION = 0xfb;\nconst PSBT_IN_NON_WITNESS_UTXO = 0x00;\nconst PSBT_IN_WITNESS_UTXO = 0x01;\nconst PSBT_IN_PARTIAL_SIG = 0x02;\nconst PSBT_IN_SIGHASH_TYPE = 0x03;\nconst PSBT_IN_REDEEM_SCRIPT = 0x04;\nconst PSBT_IN_WITNESS_SCRIPT = 0x05;\nconst PSBT_IN_BIP32_DERIVATION = 0x06;\nconst PSBT_IN_FINAL_SCRIPTSIG = 0x07;\nconst PSBT_IN_FINAL_SCRIPTWITNESS = 0x08;\nconst PSBT_OUT_REDEEM_SCRIPT = 0x00;\nconst PSBT_OUT_WITNESS_SCRIPT = 0x01;\nconst PSBT_OUT_BIP32_DERIVATION = 0x02;\nconst INPUT_FIELD_NAMES = {\n [PSBT_IN_NON_WITNESS_UTXO]: 'previous transaction',\n [PSBT_IN_WITNESS_UTXO]: 'witness UTXO',\n [PSBT_IN_PARTIAL_SIG]: 'partial signature',\n [PSBT_IN_SIGHASH_TYPE]: 'sighash type',\n [PSBT_IN_REDEEM_SCRIPT]: 'redeem script',\n [PSBT_IN_WITNESS_SCRIPT]: 'witness script',\n [PSBT_IN_BIP32_DERIVATION]: 'BIP32 derivation',\n [PSBT_IN_FINAL_SCRIPTSIG]: 'final scriptSig',\n [PSBT_IN_FINAL_SCRIPTWITNESS]: 'final script witness'\n};\nconst OUTPUT_FIELD_NAMES = {\n [PSBT_OUT_REDEEM_SCRIPT]: 'redeem script',\n [PSBT_OUT_WITNESS_SCRIPT]: 'witness script',\n [PSBT_OUT_BIP32_DERIVATION]: 'BIP32 derivation'\n};\n// A Finalizer clears the signing data it knows about (BIP-174) and keeps the\n// UTXO, the final scripts and the fields it does not interpret.\nconst CLEARED_ON_FINALIZE = new Set([\n PSBT_IN_PARTIAL_SIG,\n PSBT_IN_SIGHASH_TYPE,\n PSBT_IN_REDEEM_SCRIPT,\n PSBT_IN_WITNESS_SCRIPT,\n PSBT_IN_BIP32_DERIVATION\n]);\nconst UPDATE_FIELDS = new Set([\n 'previousTx',\n 'witnessUtxo',\n 'witnessScript',\n 'sighashType',\n 'bip32Derivation',\n 'partialSig',\n 'finalScriptSig',\n 'finalScriptWitness'\n]);\n// Strict ECDSA (AuthScript witness v3): witness [authType 0x02, sig, pubkey, OP_TRUE]\n// against taggedHash(\"NeuraiAuthScript\", 0x03 || 0x02 || HASH160(pubkey) || SHA256(OP_TRUE)).\nconst AUTHSCRIPT_TAG = 'NeuraiAuthScript';\nconst ECDSA_WITNESS_VERSION = 0x03;\nconst ECDSA_AUTH_TYPE = 0x02;\nconst OP_TRUE_SCRIPT = Uint8Array.of(0x51);\nconst HARDENED = 0x80000000;\n// ---------------------------------------------------------------------------\n// Bytes\nconst BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nfunction bytesToBase64(bytes) {\n let out = '';\n for (let i = 0; i < bytes.length; i += 3) {\n const n = (bytes[i] << 16) | ((bytes[i + 1] ?? 0) << 8) | (bytes[i + 2] ?? 0);\n out += BASE64[(n >> 18) & 63] + BASE64[(n >> 12) & 63];\n out += i + 1 < bytes.length ? BASE64[(n >> 6) & 63] : '=';\n out += i + 2 < bytes.length ? BASE64[n & 63] : '=';\n }\n return out;\n}\nfunction base64ToBytes(text) {\n if (text.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(text)) {\n throw new Error('PSBT string is neither base64 nor hex');\n }\n const padding = text.endsWith('==') ? 2 : text.endsWith('=') ? 1 : 0;\n const out = new Uint8Array((text.length / 4) * 3 - padding);\n const digit = (char) => (char === '=' ? 0 : BASE64.indexOf(char));\n let o = 0;\n for (let i = 0; i < text.length; i += 4) {\n const n = (digit(text[i]) << 18) | (digit(text[i + 1]) << 12) | (digit(text[i + 2]) << 6) | digit(text[i + 3]);\n for (const shift of [16, 8, 0])\n if (o < out.length)\n out[o++] = (n >> shift) & 255;\n }\n return out;\n}\nfunction psbtBytes(psbt) {\n if (psbt instanceof Uint8Array)\n return psbt;\n if (typeof psbt !== 'string')\n throw new TypeError('PSBT must be a base64 or hex string, or bytes');\n const text = psbt.trim();\n return /^70736274ff/i.test(text) ? hexToBytes(text) : base64ToBytes(text);\n}\nfunction equalBytes(a, b) {\n return a.length === b.length && a.every((value, index) => value === b[index]);\n}\n/** Byte-wise order, a prefix first: how BIP-174 serializers sort map keys. */\nfunction compareBytes(a, b) {\n for (let i = 0; i < Math.min(a.length, b.length); i += 1) {\n if (a[i] !== b[i])\n return a[i] < b[i] ? -1 : 1;\n }\n return a.length - b.length;\n}\nfunction readU32LE(bytes) {\n return new DataView(bytes.buffer, bytes.byteOffset, 4).getUint32(0, true);\n}\nfunction hash160(bytes) {\n return ripemd160(sha256(bytes));\n}\nfunction taggedHash(tag, message) {\n const tagHash = sha256(asciiBytes(tag));\n return sha256(concatBytes(tagHash, tagHash, message));\n}\nfunction ecdsaV3Commitment(pubkey) {\n return taggedHash(AUTHSCRIPT_TAG, concatBytes(Uint8Array.of(ECDSA_WITNESS_VERSION, ECDSA_AUTH_TYPE), hash160(pubkey), sha256(OP_TRUE_SCRIPT)));\n}\nclass Reader {\n bytes;\n label;\n offset = 0;\n constructor(bytes, label) {\n this.bytes = bytes;\n this.label = label;\n }\n get finished() {\n return this.offset === this.bytes.length;\n }\n readBytes(count) {\n if (count > this.bytes.length - this.offset) {\n throw new Error(`${this.label} is truncated (need ${count} byte(s) at offset ${this.offset})`);\n }\n const out = this.bytes.subarray(this.offset, this.offset + count);\n this.offset += count;\n return out;\n }\n /** Canonical CompactSize, bounded by the bytes left (every length or count here is). */\n readCompactSize() {\n const first = this.readBytes(1)[0];\n let value = BigInt(first);\n if (first >= 0xfd) {\n const width = first === 0xfd ? 2 : first === 0xfe ? 4 : 8;\n const bytes = this.readBytes(width);\n value = 0n;\n for (let i = width - 1; i >= 0; i -= 1)\n value = (value << 8n) | BigInt(bytes[i]);\n const minimum = width === 2 ? 0xfdn : width === 4 ? 0x10000n : 0x100000000n;\n if (value < minimum)\n throw new Error(`${this.label}: non-canonical CompactSize at offset ${this.offset - width - 1}`);\n }\n if (value > BigInt(this.bytes.length - this.offset)) {\n throw new Error(`${this.label} is truncated (length ${value} at offset ${this.offset})`);\n }\n return Number(value);\n }\n readMap(mapLabel) {\n const map = [];\n const seen = new Set();\n for (;;) {\n const keyLength = this.readCompactSize();\n if (keyLength === 0)\n return map;\n const key = this.readBytes(keyLength);\n const value = this.readBytes(this.readCompactSize());\n const keyHex = bytesToHex(key);\n if (seen.has(keyHex))\n throw new Error(`PSBT ${mapLabel}: duplicate key ${keyHex}`);\n seen.add(keyHex);\n map.push({ key, value });\n }\n }\n}\nfunction encodeWitnessStack(stack) {\n if (!Array.isArray(stack))\n throw new Error('finalScriptWitness must be an array of hex strings');\n return concatBytes(compactSize(stack.length), ...stack.map((element) => {\n const bytes = hexToBytes(ensureHex(element, 'witness element'));\n return concatBytes(compactSize(bytes.length), bytes);\n }));\n}\nfunction decodeWitnessStack(bytes, label) {\n const reader = new Reader(bytes, label);\n const count = reader.readCompactSize();\n const stack = [];\n for (let i = 0; i < count; i += 1)\n stack.push(bytesToHex(reader.readBytes(reader.readCompactSize())));\n if (!reader.finished)\n throw new Error(`${label} has trailing data`);\n return stack;\n}\n// BIP-66 DER structure followed by one sighash byte.\nfunction isDerSignatureWithSighash(sig) {\n if (sig.length < 9 || sig.length > 73 || sig[0] !== 0x30 || sig[1] !== sig.length - 3)\n return false;\n const rLength = sig[3];\n if (sig[2] !== 0x02 || rLength === 0 || 5 + rLength >= sig.length)\n return false;\n const sLength = sig[5 + rLength];\n if (sig[4 + rLength] !== 0x02 || sLength === 0)\n return false;\n return rLength + sLength + 7 === sig.length;\n}\nfunction isPublicKey(pubkey) {\n return (pubkey.length === 33 && (pubkey[0] === 0x02 || pubkey[0] === 0x03)) || (pubkey.length === 65 && pubkey[0] === 0x04);\n}\nfunction encodePath(path, label) {\n if (typeof path !== 'string' || !/^m(\\/\\d+['h]?)*$/.test(path)) {\n throw new Error(`${label}: invalid derivation path \"${path}\"`);\n }\n return concatBytes(...path\n .split('/')\n .slice(1)\n .map((level) => {\n const hardened = /['h]$/.test(level);\n const index = Number(hardened ? level.slice(0, -1) : level);\n if (!Number.isSafeInteger(index) || index >= HARDENED)\n throw new Error(`${label}: derivation index out of range in \"${path}\"`);\n return u32LE(hardened ? index + HARDENED : index);\n }));\n}\nfunction decodePath(bytes) {\n let path = 'm';\n for (let offset = 0; offset < bytes.length; offset += 4) {\n const value = readU32LE(bytes.subarray(offset, offset + 4));\n path += `/${value & 0x7fffffff}${value >= HARDENED ? \"'\" : ''}`;\n }\n return path;\n}\n// ---------------------------------------------------------------------------\n// Maps\nfunction fieldName(map, key) {\n const names = map.startsWith('input') ? INPUT_FIELD_NAMES : map.startsWith('output') ? OUTPUT_FIELD_NAMES : {};\n const name = names[key[0]] ?? `key type 0x${key[0].toString(16).padStart(2, '0')}`;\n return key.length > 1 ? `${name} ${bytesToHex(key.subarray(1))}` : name;\n}\nfunction singleByteKey(entry, map) {\n if (entry.key.length !== 1)\n throw new Error(`PSBT ${map}: the ${fieldName(map, entry.key)} key has unexpected key data`);\n}\nfunction keyPublicKey(entry, map) {\n const pubkey = entry.key.subarray(1);\n if (!isPublicKey(pubkey))\n throw new Error(`PSBT ${map}: invalid public key in the ${fieldName(map, entry.key)} key`);\n return pubkey;\n}\nfunction decodeDerivation(entry, map) {\n const pubkey = keyPublicKey(entry, map);\n if (entry.value.length < 4 || entry.value.length % 4 !== 0) {\n throw new Error(`PSBT ${map}: BIP32 derivation value must be a fingerprint and 4-byte path elements`);\n }\n return { masterFingerprint: entry.value.subarray(0, 4), pubkey, path: decodePath(entry.value.subarray(4)) };\n}\nfunction decodeInputMap(map, label) {\n const view = { partialSig: [], bip32Derivation: [], unknown: [] };\n for (const entry of map) {\n const { key, value } = entry;\n switch (key[0]) {\n case PSBT_IN_NON_WITNESS_UTXO:\n singleByteKey(entry, label);\n view.previousTx = value;\n break;\n case PSBT_IN_WITNESS_UTXO: {\n singleByteKey(entry, label);\n const reader = new Reader(value, `PSBT ${label} witness UTXO`);\n const amountBytes = reader.readBytes(8);\n const amount = new DataView(amountBytes.buffer, amountBytes.byteOffset, 8).getBigInt64(0, true);\n const script = reader.readBytes(reader.readCompactSize());\n if (!reader.finished || amount < 0n)\n throw new Error(`PSBT ${label}: malformed witness UTXO`);\n view.witnessUtxo = { script, value: amount };\n break;\n }\n case PSBT_IN_PARTIAL_SIG: {\n const pubkey = keyPublicKey(entry, label);\n if (!isDerSignatureWithSighash(value)) {\n throw new Error(`PSBT ${label}: the signature for ${bytesToHex(pubkey)} is not DER followed by a sighash byte`);\n }\n view.partialSig.push({ pubkey, signature: value });\n break;\n }\n case PSBT_IN_SIGHASH_TYPE:\n singleByteKey(entry, label);\n if (value.length !== 4)\n throw new Error(`PSBT ${label}: the sighash type must be 4 bytes`);\n view.sighashType = readU32LE(value);\n break;\n case PSBT_IN_REDEEM_SCRIPT:\n singleByteKey(entry, label);\n view.redeemScript = value;\n break;\n case PSBT_IN_WITNESS_SCRIPT:\n singleByteKey(entry, label);\n view.witnessScript = value;\n break;\n case PSBT_IN_BIP32_DERIVATION:\n view.bip32Derivation.push(decodeDerivation(entry, label));\n break;\n case PSBT_IN_FINAL_SCRIPTSIG:\n singleByteKey(entry, label);\n view.finalScriptSig = value;\n break;\n case PSBT_IN_FINAL_SCRIPTWITNESS:\n singleByteKey(entry, label);\n view.finalScriptWitness = decodeWitnessStack(value, `PSBT ${label} final script witness`);\n break;\n default:\n view.unknown.push(entry);\n }\n }\n return view;\n}\nfunction decodeOutputMap(map, label) {\n const view = { bip32Derivation: [], unknown: [] };\n for (const entry of map) {\n switch (entry.key[0]) {\n case PSBT_OUT_REDEEM_SCRIPT:\n singleByteKey(entry, label);\n view.redeemScript = entry.value;\n break;\n case PSBT_OUT_WITNESS_SCRIPT:\n singleByteKey(entry, label);\n view.witnessScript = entry.value;\n break;\n case PSBT_OUT_BIP32_DERIVATION:\n view.bip32Derivation.push(decodeDerivation(entry, label));\n break;\n default:\n view.unknown.push(entry);\n }\n }\n return view;\n}\nfunction encodeDerivation(type, derivation, label) {\n const fingerprint = hexToBytes(ensureHex(derivation.masterFingerprintHex, 'masterFingerprintHex'));\n if (fingerprint.length !== 4)\n throw new Error(`${label}: the master fingerprint must be 4 bytes`);\n return {\n key: concatBytes(Uint8Array.of(type), hexToBytes(ensureHex(derivation.pubkeyHex, 'pubkeyHex'))),\n value: concatBytes(fingerprint, encodePath(derivation.path, label))\n };\n}\nfunction encodeOutputFields(fields, index) {\n if (!fields || typeof fields !== 'object')\n throw new Error(`PSBT output ${index}: fields must be an object`);\n for (const name of Object.keys(fields)) {\n if (name !== 'bip32Derivation')\n throw new Error(`PSBT output ${index}: unknown field \"${name}\"`);\n }\n return (fields.bip32Derivation ?? []).map((derivation) => encodeDerivation(PSBT_OUT_BIP32_DERIVATION, derivation, `PSBT output ${index}`));\n}\nfunction encodeInputFields(fields, index) {\n if (!fields || typeof fields !== 'object')\n throw new Error(`PSBT input ${index}: fields must be an object`);\n for (const name of Object.keys(fields)) {\n if (!UPDATE_FIELDS.has(name))\n throw new Error(`PSBT input ${index}: unknown field \"${name}\"`);\n }\n const bytes = (hex, label) => hexToBytes(ensureHex(hex, label));\n const entries = [];\n const add = (type, keyData, value) => entries.push({ key: concatBytes(Uint8Array.of(type), keyData), value });\n const none = new Uint8Array();\n if (fields.previousTx !== undefined)\n add(PSBT_IN_NON_WITNESS_UTXO, none, bytes(fields.previousTx, 'previousTx'));\n if (fields.witnessUtxo !== undefined) {\n const value = toRawInteger(fields.witnessUtxo.valueSats, 'witnessUtxo.valueSats');\n if (value < 0n)\n throw new Error(`PSBT input ${index}: negative witnessUtxo value`);\n const script = bytes(fields.witnessUtxo.scriptPubKeyHex, 'witnessUtxo.scriptPubKeyHex');\n add(PSBT_IN_WITNESS_UTXO, none, concatBytes(i64LE(value), compactSize(script.length), script));\n }\n if (fields.witnessScript !== undefined)\n add(PSBT_IN_WITNESS_SCRIPT, none, bytes(fields.witnessScript, 'witnessScript'));\n if (fields.sighashType !== undefined) {\n const type = fields.sighashType;\n if (!Number.isInteger(type) || type < 0 || type > 0xffffffff)\n throw new Error(`PSBT input ${index}: invalid sighashType ${type}`);\n add(PSBT_IN_SIGHASH_TYPE, none, u32LE(type));\n }\n for (const derivation of fields.bip32Derivation ?? []) {\n entries.push(encodeDerivation(PSBT_IN_BIP32_DERIVATION, derivation, `PSBT input ${index}`));\n }\n for (const sig of fields.partialSig ?? []) {\n add(PSBT_IN_PARTIAL_SIG, bytes(sig.pubkeyHex, 'pubkeyHex'), bytes(sig.signatureHex, 'signatureHex'));\n }\n if (fields.finalScriptSig !== undefined)\n add(PSBT_IN_FINAL_SCRIPTSIG, none, bytes(fields.finalScriptSig, 'finalScriptSig'));\n if (fields.finalScriptWitness !== undefined) {\n add(PSBT_IN_FINAL_SCRIPTWITNESS, none, encodeWitnessStack(fields.finalScriptWitness));\n }\n return entries;\n}\n// ---------------------------------------------------------------------------\n// Reading and writing\nfunction assertUnsigned(tx, label) {\n if (tx.inputs.length === 0)\n throw new Error(`${label} has no inputs`);\n tx.inputs.forEach((input, index) => {\n if (input.scriptSigHex) {\n throw new Error(`${label}: input ${index} has a scriptSig (the transaction of a PSBT is unsigned)`);\n }\n if (input.witness && input.witness.length > 0) {\n throw new Error(`${label}: input ${index} has a witness (the transaction of a PSBT is unsigned)`);\n }\n });\n}\n/** The global transaction: unsigned, in the plain (non-witness) Neurai serialization. */\nfunction parseUnsignedTransaction(bytes) {\n const hex = bytesToHex(bytes);\n let tx;\n try {\n tx = parseTransaction(hex);\n }\n catch (error) {\n throw new Error(`PSBT unsigned transaction is unreadable: ${error.message}`);\n }\n assertUnsigned(tx, 'PSBT unsigned transaction');\n if (serializeTransaction(tx, { includeWitness: false }) !== hex) {\n throw new Error('PSBT unsigned transaction is not in the plain serialization');\n }\n return tx;\n}\n/** Previous output of an input, its previous transaction checked against the outpoint. */\nfunction previousOutputOf(input, outpoint, index) {\n if (input.previousTx) {\n const previousHex = bytesToHex(input.previousTx);\n let previous;\n try {\n previous = parseTransaction(previousHex);\n }\n catch (error) {\n throw new Error(`PSBT input ${index}: unreadable previous transaction (${error.message})`);\n }\n const txid = computeTxid(previous);\n if (txid !== outpoint.txid) {\n throw new Error(`PSBT input ${index}: the previous transaction is ${txid}, but the input spends ${outpoint.txid}:${outpoint.vout}`);\n }\n const output = previous.outputs[outpoint.vout];\n if (!output)\n throw new Error(`PSBT input ${index}: the previous transaction has no output ${outpoint.vout}`);\n if (input.witnessUtxo &&\n (bytesToHex(input.witnessUtxo.script) !== output.scriptPubKeyHex || input.witnessUtxo.value !== output.valueSats)) {\n throw new Error(`PSBT input ${index}: the witness UTXO contradicts the previous transaction`);\n }\n return { scriptPubKeyHex: output.scriptPubKeyHex, valueSats: output.valueSats };\n }\n if (input.witnessUtxo) {\n return { scriptPubKeyHex: bytesToHex(input.witnessUtxo.script), valueSats: input.witnessUtxo.value };\n }\n return null;\n}\n/** Parse and validate: structure, every interpreted field, and the profile rules. */\nfunction loadPsbt(psbt) {\n const bytes = psbtBytes(psbt);\n if (bytes.length < PSBT_MAGIC.length || !equalBytes(bytes.subarray(0, PSBT_MAGIC.length), PSBT_MAGIC)) {\n throw new Error('Not a PSBT: missing the \"psbt\" magic and 0xff separator');\n }\n const reader = new Reader(bytes.subarray(PSBT_MAGIC.length), 'PSBT');\n const global = reader.readMap('global map');\n const txEntries = global.filter((entry) => entry.key[0] === PSBT_GLOBAL_UNSIGNED_TX);\n if (txEntries.length !== 1 || txEntries[0].key.length !== 1) {\n throw new Error('PSBT global map must hold exactly one unsigned transaction (PSBT version 0)');\n }\n const version = global.find((entry) => entry.key.length === 1 && entry.key[0] === PSBT_GLOBAL_VERSION);\n if (version && (version.value.length !== 4 || readU32LE(version.value) !== 0)) {\n throw new Error('Only PSBT version 0 is supported');\n }\n const tx = parseUnsignedTransaction(txEntries[0].value);\n const inputs = tx.inputs.map((_, index) => reader.readMap(`input ${index}`));\n const outputs = tx.outputs.map((_, index) => reader.readMap(`output ${index}`));\n if (!reader.finished)\n throw new Error('PSBT has data after its last output map');\n inputs.forEach((map, index) => previousOutputOf(decodeInputMap(map, `input ${index}`), tx.inputs[index], index));\n outputs.forEach((map, index) => decodeOutputMap(map, `output ${index}`));\n return { tx, global, inputs, outputs };\n}\n/** Canonical form: every map sorted by key, as BIP-174 serializers write it. */\nfunction encodePsbt(loaded) {\n const map = (entries) => concatBytes(...[...entries]\n .sort((a, b) => compareBytes(a.key, b.key))\n .flatMap(({ key, value }) => [compactSize(key.length), key, compactSize(value.length), value]), Uint8Array.of(0));\n return bytesToBase64(concatBytes(PSBT_MAGIC, map(loaded.global), ...loaded.inputs.map(map), ...loaded.outputs.map(map)));\n}\n/** Union of key-value maps; the same key with a different value is a conflict, never a choice. */\nfunction mergeMap(target, other, map) {\n for (const entry of other) {\n const existing = target.find((candidate) => equalBytes(candidate.key, entry.key));\n if (!existing) {\n target.push(entry);\n }\n else if (!equalBytes(existing.value, entry.value)) {\n throw new Error(`PSBT conflict in ${map}: ${fieldName(map, entry.key)} already holds a different value`);\n }\n }\n}\n/** Re-read after a change, so the result passes the same validation as any input. */\nfunction revalidated(loaded) {\n return encodePsbt(loadPsbt(encodePsbt(loaded)));\n}\nfunction checkIndex(index, count, kind) {\n if (!Number.isInteger(index) || index < 0 || index >= count) {\n throw new Error(`PSBT has no ${kind} ${index} (it has ${count})`);\n }\n}\n// ---------------------------------------------------------------------------\n// Public API\n/** Creator + Updater: a PSBT for an unsigned transaction, with optional fields per input and output. */\nfunction createPsbt(params) {\n const { unsignedTx } = params;\n const tx = typeof unsignedTx === 'string' ? parseTransaction(unsignedTx) : unsignedTx;\n assertUnsigned(tx, 'createPsbt: the transaction');\n const fields = params.inputs ?? [];\n if (fields.length > tx.inputs.length) {\n throw new Error(`createPsbt: fields for ${fields.length} inputs, but the transaction has ${tx.inputs.length}`);\n }\n const outputFields = params.outputs ?? [];\n if (outputFields.length > tx.outputs.length) {\n throw new Error(`createPsbt: fields for ${outputFields.length} outputs, but the transaction has ${tx.outputs.length}`);\n }\n const inputs = tx.inputs.map((_, index) => []);\n fields.forEach((inputFields, index) => {\n if (inputFields !== undefined)\n mergeMap(inputs[index], encodeInputFields(inputFields, index), `input ${index}`);\n });\n const outputs = tx.outputs.map((_, index) => []);\n outputFields.forEach((fieldsOfOutput, index) => {\n if (fieldsOfOutput !== undefined)\n mergeMap(outputs[index], encodeOutputFields(fieldsOfOutput, index), `output ${index}`);\n });\n return revalidated({\n global: [\n { key: Uint8Array.of(PSBT_GLOBAL_UNSIGNED_TX), value: hexToBytes(serializeTransaction(tx, { includeWitness: false })) }\n ],\n inputs,\n outputs\n });\n}\n/** Read a PSBT, enforcing the Neurai profile (previous transactions match their outpoints). */\nfunction decodePsbt(psbt) {\n const { tx, global, inputs, outputs } = loadPsbt(psbt);\n const keyValues = (entries) => entries.map((entry) => ({ keyHex: bytesToHex(entry.key), valueHex: bytesToHex(entry.value) }));\n const derivations = (list) => list.map((derivation) => ({\n masterFingerprintHex: bytesToHex(derivation.masterFingerprint),\n pubkeyHex: bytesToHex(derivation.pubkey),\n path: derivation.path\n }));\n const hex = (bytes) => (bytes ? bytesToHex(bytes) : undefined);\n const defined = (object) => Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined));\n return {\n unsignedTx: tx,\n txid: computeTxid(tx),\n inputs: inputs.map((map, index) => {\n const view = decodeInputMap(map, `input ${index}`);\n return defined({\n previousTx: hex(view.previousTx),\n witnessUtxo: view.witnessUtxo && {\n scriptPubKeyHex: bytesToHex(view.witnessUtxo.script),\n valueSats: view.witnessUtxo.value\n },\n partialSig: view.partialSig.map((sig) => ({\n pubkeyHex: bytesToHex(sig.pubkey),\n signatureHex: bytesToHex(sig.signature)\n })),\n sighashType: view.sighashType,\n redeemScript: hex(view.redeemScript),\n witnessScript: hex(view.witnessScript),\n bip32Derivation: derivations(view.bip32Derivation),\n finalScriptSig: hex(view.finalScriptSig),\n finalScriptWitness: view.finalScriptWitness,\n unknown: keyValues(view.unknown)\n });\n }),\n outputs: outputs.map((map, index) => {\n const view = decodeOutputMap(map, `output ${index}`);\n return defined({\n redeemScript: hex(view.redeemScript),\n witnessScript: hex(view.witnessScript),\n bip32Derivation: derivations(view.bip32Derivation),\n unknown: keyValues(view.unknown)\n });\n }),\n unknown: keyValues(global.filter((entry) => entry.key[0] !== PSBT_GLOBAL_UNSIGNED_TX))\n };\n}\n/**\n * Add fields to one input. A field already present with the same value is\n * left as is; with a different value it is a conflict and throws.\n */\nfunction updatePsbtInput(psbt, index, fields) {\n const loaded = loadPsbt(psbt);\n checkIndex(index, loaded.tx.inputs.length, 'input');\n mergeMap(loaded.inputs[index], encodeInputFields(fields, index), `input ${index}`);\n return revalidated(loaded);\n}\n/**\n * Combiner: union of PSBTs of the same transaction. Unlike BIP-174's\n * \"pick one\", a key present with different values is rejected.\n */\nfunction combinePsbts(base, ...others) {\n const merged = loadPsbt(base);\n const baseTx = serializeTransaction(merged.tx, { includeWitness: false });\n for (const other of others.map(loadPsbt)) {\n if (serializeTransaction(other.tx, { includeWitness: false }) !== baseTx) {\n throw new Error('Cannot combine PSBTs of different transactions');\n }\n mergeMap(merged.global, other.global, 'global map');\n other.inputs.forEach((map, index) => mergeMap(merged.inputs[index], map, `input ${index}`));\n other.outputs.forEach((map, index) => mergeMap(merged.outputs[index], map, `output ${index}`));\n }\n return revalidated(merged);\n}\n/** Previous output (script and value) an input spends, from its previous transaction or witness UTXO. */\nfunction getPsbtPreviousOutput(decoded, index) {\n checkIndex(index, decoded.unsignedTx.inputs.length, 'input');\n const input = decoded.inputs[index];\n const view = { };\n if (input?.previousTx)\n view.previousTx = hexToBytes(input.previousTx);\n if (input?.witnessUtxo) {\n view.witnessUtxo = { script: hexToBytes(input.witnessUtxo.scriptPubKeyHex), value: input.witnessUtxo.valueSats };\n }\n const previous = previousOutputOf(view, decoded.unsignedTx.inputs[index], index);\n if (!previous)\n throw new Error(`PSBT input ${index} carries neither its previous transaction nor a witness UTXO`);\n return previous;\n}\nfunction signatureFor(input, index, family, ownsKey) {\n if (input.partialSig.length === 0)\n throw new Error(`PSBT input ${index} (${family}) is not signed`);\n const match = input.partialSig.find((sig) => ownsKey(sig.pubkey));\n if (!match)\n throw new Error(`PSBT input ${index}: no signature from the key its ${family} previous output pays to`);\n const used = match.signature[match.signature.length - 1];\n if (input.sighashType !== undefined && used !== input.sighashType) {\n throw new Error(`PSBT input ${index}: the signature uses sighash 0x${used.toString(16).padStart(2, '0')}, ` +\n `but the input asks for 0x${input.sighashType.toString(16).padStart(2, '0')}`);\n }\n return match;\n}\n/** Final key-value pairs of one input: final scripts built (or kept), signing data cleared. */\nfunction finalizeInputMap(map, outpoint, index) {\n const input = decodeInputMap(map, `input ${index}`);\n const finals = [];\n if (!input.finalScriptSig && !input.finalScriptWitness) {\n const previous = previousOutputOf(input, outpoint, index);\n if (!previous)\n throw new Error(`PSBT input ${index} carries neither its previous transaction nor a witness UTXO`);\n const kind = classifyScriptPubKey(previous.scriptPubKeyHex);\n const program = kind.program ?? new Uint8Array();\n if (kind.type === 'p2pkh') {\n const sig = signatureFor(input, index, 'P2PKH', (pubkey) => equalBytes(hash160(pubkey), program));\n finals.push({\n key: Uint8Array.of(PSBT_IN_FINAL_SCRIPTSIG),\n value: concatBytes(pushData(sig.signature), pushData(sig.pubkey))\n });\n }\n else if (kind.type === 'ecdsa') {\n const sig = signatureFor(input, index, 'ECDSA (AuthScript v3)', (pubkey) => pubkey.length === 33 && equalBytes(ecdsaV3Commitment(pubkey), program));\n finals.push({\n key: Uint8Array.of(PSBT_IN_FINAL_SCRIPTWITNESS),\n value: encodeWitnessStack([\n bytesToHex(Uint8Array.of(ECDSA_AUTH_TYPE)),\n bytesToHex(sig.signature),\n bytesToHex(sig.pubkey),\n bytesToHex(OP_TRUE_SCRIPT)\n ])\n });\n }\n else if (kind.type === 'authscript' || kind.type === 'pq') {\n throw new Error(`PSBT input ${index}: an AuthScript v${kind.witnessVersion} input is finalized by its signer ` +\n '(final script witness), and this one has none');\n }\n else {\n throw new Error(`PSBT input ${index}: no finalization template for scriptPubKey ${previous.scriptPubKeyHex}`);\n }\n }\n return [...map.filter((entry) => !CLEARED_ON_FINALIZE.has(entry.key[0])), ...finals];\n}\n/**\n * Finalizer. P2PKH and strict ECDSA (AuthScript v3) inputs are completed from\n * their `partialSig`; inputs that already carry finalScriptSig/finalScriptWitness\n * (covenant branches, PQ) are kept. A signature whose sighash byte differs from\n * the input's `sighashType` is rejected. Finalized inputs keep only the UTXO,\n * the final scripts and the fields this module does not interpret.\n */\nfunction finalizePsbt(psbt, options = {}) {\n const loaded = loadPsbt(psbt);\n const count = loaded.tx.inputs.length;\n const selection = options.inputs ?? 'all';\n let indexes;\n if (selection === 'all') {\n indexes = loaded.tx.inputs.map((_, index) => index);\n }\n else if (Array.isArray(selection)) {\n selection.forEach((index) => checkIndex(index, count, 'input'));\n indexes = [...new Set(selection)];\n }\n else {\n throw new Error(`finalizePsbt: inputs must be 'all' or a list of indexes`);\n }\n for (const index of indexes) {\n loaded.inputs[index] = finalizeInputMap(loaded.inputs[index], loaded.tx.inputs[index], index);\n }\n return revalidated(loaded);\n}\n/**\n * Extractor: the network transaction from the final scripts. Inputs without\n * them make it throw, unless `allowIncomplete` is set: they are then left\n * empty and listed in `incomplete` (for callers that add other unlocking data).\n */\nfunction extractPsbtTransaction(psbt, options = {}) {\n const loaded = loadPsbt(psbt);\n const incomplete = [];\n const inputs = loaded.tx.inputs.map((outpoint, index) => {\n const input = decodeInputMap(loaded.inputs[index], `input ${index}`);\n if (!input.finalScriptSig && !input.finalScriptWitness) {\n incomplete.push(index);\n return { ...outpoint };\n }\n const signed = {\n ...outpoint,\n scriptSigHex: input.finalScriptSig ? bytesToHex(input.finalScriptSig) : ''\n };\n if (input.finalScriptWitness)\n signed.witness = input.finalScriptWitness;\n return signed;\n });\n if (incomplete.length > 0 && !options.allowIncomplete) {\n throw new Error(`PSBT is not finalized: input(s) ${incomplete.join(', ')} have no final scriptSig or witness`);\n }\n const hex = serializeTransaction({ ...loaded.tx, inputs });\n return { hex, txid: computeTxid(hex), incomplete };\n}\n\nexport { AUTHSCRIPT_MAINNET_HRP, AUTHSCRIPT_TESTNET_HRP, DEFAULT_ASSET_MARKER, DEPIN_MAX_NAME_LENGTH, ECDSA_MAINNET_HRP, ECDSA_TESTNET_HRP, MAX_MONEY, OWNER_ASSET_AMOUNT, PQ_MAINNET_HRP, PQ_TESTNET_HRP, REGTEST_GLOBAL_BURN_ADDRESS, SATS_PER_XNA, UNIQUE_ASSETS_REISSUABLE, UNIQUE_ASSET_AMOUNT, UNIQUE_ASSET_UNITS, WITNESS_FAMILIES, assertDepinAssetName, assertDepinNetwork, assertMoneyRange, assetPayloadPrefix, assetUnitsToRaw, classifyScriptPubKey, combinePsbts, computeTxid, computeWtxid, createAssetTransferOutput, createAssetTransferToScriptOutput, createDepinSelfRevokeTransaction, createDepinTransferTransaction, createFreezeAddressesTransaction, createFreezeAssetTransaction, createFromOperation, createGlobalRestrictionOutput, createIssueAssetOutput, createIssueAssetTransaction, createIssueDepinTransaction, createIssueQualifierTransaction, createIssueRestrictedTransaction, createIssueSubAssetTransaction, createIssueUniqueAssetTransaction, createNullAssetRestrictionOutput, createNullAssetTagOutput, createOwnerAssetIssueOutput, createOwnerAssetTransferOutput, createPaymentTransaction, createPsbt, createQualifierTagTransaction, createReissueAssetOutput, createReissueRestrictedTransaction, createReissueTransaction, createStandardAssetTransferTransaction, createTransferOutput, createTransferWithMessageOutput, createUnsignedTransaction, createVerifierStringOutput, createXnaOutput, decimalToSatoshis, decodeAddress, decodeAssetDataReferenceHex, decodePsbt, encodeAssetDataReference, encodeAssetTransferPayload, encodeAssetTransferScript, encodeAssetTransferScriptToScript, encodeAuthScriptDestinationScript, encodeDestinationScript, encodeGlobalRestrictionScript, encodeNewAssetPayload, encodeNewAssetScript, encodeNullAssetDataPayload, encodeNullAssetDestinationScript, encodeNullAssetRestrictionScript, encodeNullAssetTagPayload, encodeNullAssetTagScript, encodeOwnerAssetPayload, encodeOwnerAssetScript, encodeP2PKHScript, encodePQWitnessScript, encodeReissueAssetPayload, encodeReissueAssetScript, encodeVerifierStringPayload, encodeVerifierStringScript, encodeWitnessProgramScript, estimateTransactionSize, extractPsbtTransaction, finalizePsbt, formatAssetDataReferenceHex, getBurnAddressForOperation, getBurnAmountSats, getBurnAmountXna, getOwnerTokenName, getParentAssetName, getPsbtPreviousOutput, getUniqueAssetName, inferNetworkFromAnyAddress, isCidV0AssetReference, isDepinAssetName, isEncodedAssetDataReferenceHex, isRawAssetDataReferenceHex, isTxidAssetReference, isWitnessDestination, normalizeVerifierString, parseTransaction, resolveAddressInput, resolveAssetMarker, satoshisToDecimal, serializeInput, serializeOutput, serializeTransaction, toRawInteger, updatePsbtInput, xnaToSatoshis };\n//# sourceMappingURL=index.js.map\n","/**\n * Address helpers. Wraps `decodeAddress` from\n * `@neuraiproject/neurai-create-transaction` to produce the exact\n * scriptPubKey bytes a covenant needs to hardcode. The actual\n * scriptPubKey encoders live in `./standard/*`; this module delegates.\n *\n * Every Neurai destination type is supported for the payment output\n * (output[0]):\n * - Legacy P2PKH (base58check) → `76a914<20>88ac`\n * - Generic AuthScript witness v1 (nc1p… / tnc1p…) → `5120<32>`\n * - Strict PQ witness v2 (pq1z… / tpq1z…) → `5220<32>`\n * - Strict ECDSA witness v3 (nq1r… / tnq1r…) → `5320<32>`\n */\nimport { decodeAddress } from '@neuraiproject/neurai-create-transaction';\nimport { encodeP2PKHScriptPubKey } from './standard/p2pkh.js';\nimport { encodeAuthScriptScriptPubKey } from './standard/authscript.js';\n// Re-export for callers that imported these from `address` pre-refactor. The\n// canonical path going forward is `./standard/p2pkh` / `./standard/authscript`.\nexport { encodeP2PKHScriptPubKey, encodeAuthScriptScriptPubKey };\n/**\n * Resolve any accepted seller address string into its scriptPubKey.\n * The returned bytes are what the covenant will hardcode and later verify\n * via `OP_OUTPUTSCRIPT == <bytes>`.\n */\nexport function encodeSellerScriptPubKey(address) {\n const decoded = decodeAddress(address);\n if (decoded.type === 'p2pkh') {\n const hash = Uint8Array.from(decoded.hash);\n return {\n kind: 'p2pkh',\n bytes: encodeP2PKHScriptPubKey(hash),\n hash\n };\n }\n if (decoded.type === 'authscript' || decoded.type === 'pq' || decoded.type === 'ecdsa') {\n // The witness version is part of the destination: a pq1z… / nq1r…\n // payment must be hardcoded with OP_2 / OP_3, never with OP_1.\n const program = Uint8Array.from(decoded.program);\n return {\n kind: decoded.type,\n witnessVersion: decoded.witnessVersion,\n bytes: encodeAuthScriptScriptPubKey(program, decoded.witnessVersion),\n hash: program\n };\n }\n throw new Error(`Unsupported seller address type for \"${address}\"`);\n}\n","/**\n * Asset-transfer wrapper split helper.\n *\n * Neurai asset UTXOs have a scriptPubKey of the form\n *\n * <prefix scriptPubKey bytes> OP_XNA_ASSET <pushdata(payload)> OP_DROP\n *\n * where `prefix` is the recipient's standard script (typically a P2PKH, an\n * AuthScript `OP_1`/`OP_2`/`OP_3` witness program, or a bare covenant such\n * as the partial-fill sell order), and `payload` serializes a `CAssetTransfer`:\n *\n * payload = marker (\"rvn\" 0x72 0x76 0x6e | \"xna\" 0x78 0x6e 0x61)\n * || type_marker (0x74 transfer)\n * || VarStr(assetName)\n * || int64LE(amountRaw)\n * [ || messageRef (optional) || int64LE(expireTime) (optional) ]\n *\n * NIP-040: mainnet still emits the Ravencoin-inherited \"rvn\" marker;\n * testnet/regtest emit \"xna\" after activation. Both are accepted when\n * reading — the detected marker is surfaced on the parsed payload.\n *\n * This helper separates the two halves so consumers can validate the prefix\n * (e.g. feed it to `parsePartialFillScript`) while independently reading the\n * asset data displayed to the user. The optional payload tail\n * (`message` + `expireTime`) is tolerated but not exposed — the first\n * version only needs `assetName` and `amountRaw`.\n *\n * Bare (non-wrapped) scriptPubKeys round-trip through this helper by\n * returning `prefixHex === input` and `assetTransfer === null`.\n */\nimport { bytesToHex, hexToBytes, ensureHex } from './core/bytes.js';\nimport { OP_DROP, OP_PUSHDATA1, OP_PUSHDATA2, OP_PUSHDATA4, OP_XNA_ASSET } from './core/opcodes.js';\nconst ASSET_MAGICS = [\n { marker: 'rvn', bytes: Uint8Array.from([0x72, 0x76, 0x6e]) },\n { marker: 'xna', bytes: Uint8Array.from([0x78, 0x6e, 0x61]) },\n];\nconst TRANSFER_TYPE = 0x74;\n/**\n * Walk the script one opcode at a time, skipping pushdata payload bytes,\n * until either OP_XNA_ASSET is reached at top level or the end of the\n * script. Returns the byte offset of OP_XNA_ASSET, or -1 if not found.\n * Throws on truncated pushdata.\n */\nfunction findTopLevelAssetOpcode(bytes) {\n let i = 0;\n while (i < bytes.length) {\n const op = bytes[i];\n if (op === OP_XNA_ASSET)\n return i;\n // Short direct push: 0x01..0x4b\n if (op >= 0x01 && op <= 0x4b) {\n const len = op;\n const next = i + 1 + len;\n if (next > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: short push of ${len} bytes at offset ${i} exceeds script length`);\n }\n i = next;\n continue;\n }\n if (op === OP_PUSHDATA1) {\n if (i + 1 >= bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: truncated PUSHDATA1 length at offset ${i}`);\n }\n const len = bytes[i + 1];\n const next = i + 2 + len;\n if (next > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: PUSHDATA1 of ${len} bytes at offset ${i} exceeds script length`);\n }\n i = next;\n continue;\n }\n if (op === OP_PUSHDATA2) {\n if (i + 2 >= bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: truncated PUSHDATA2 length at offset ${i}`);\n }\n const len = bytes[i + 1] | (bytes[i + 2] << 8);\n const next = i + 3 + len;\n if (next > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: PUSHDATA2 of ${len} bytes at offset ${i} exceeds script length`);\n }\n i = next;\n continue;\n }\n if (op === OP_PUSHDATA4) {\n if (i + 4 >= bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: truncated PUSHDATA4 length at offset ${i}`);\n }\n const len = (bytes[i + 1] |\n (bytes[i + 2] << 8) |\n (bytes[i + 3] << 16) |\n (bytes[i + 4] << 24)) >>>\n 0;\n const next = i + 5 + len;\n if (next > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: PUSHDATA4 of ${len} bytes at offset ${i} exceeds script length`);\n }\n i = next;\n continue;\n }\n // Any other opcode (including OP_1..OP_16, OP_DUP, OP_HASH160, etc.) is\n // one byte wide in Neurai Script. Advance.\n i += 1;\n }\n return -1;\n}\n/**\n * Read the pushdata element that sits immediately after OP_XNA_ASSET and\n * return its payload bytes together with the cursor position after the\n * element. Only direct pushes (1..75) and PUSHDATA1 are accepted — a\n * well-formed asset transfer payload fits within 75 bytes for the common\n * case and comfortably within 255 bytes even with long names and tails.\n * PUSHDATA2 and PUSHDATA4 would signal a malformed or adversarial wrapper.\n */\nfunction readPayloadPush(bytes, start) {\n if (start >= bytes.length) {\n throw new Error('splitAssetWrappedScriptPubKey: truncated wrapper — missing payload push');\n }\n const op = bytes[start];\n if (op >= 0x01 && op <= 0x4b) {\n const len = op;\n const dataStart = start + 1;\n const dataEnd = dataStart + len;\n if (dataEnd > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload short push of ${len} bytes exceeds script length`);\n }\n return { payload: bytes.slice(dataStart, dataEnd), after: dataEnd };\n }\n if (op === OP_PUSHDATA1) {\n if (start + 1 >= bytes.length) {\n throw new Error('splitAssetWrappedScriptPubKey: truncated PUSHDATA1 in asset payload');\n }\n const len = bytes[start + 1];\n const dataStart = start + 2;\n const dataEnd = dataStart + len;\n if (dataEnd > bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload PUSHDATA1 of ${len} bytes exceeds script length`);\n }\n return { payload: bytes.slice(dataStart, dataEnd), after: dataEnd };\n }\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload push opcode 0x${op.toString(16)} not accepted (expected 0x01..0x4b or PUSHDATA1)`);\n}\nfunction detectAssetMarker(payload) {\n for (const { marker, bytes } of ASSET_MAGICS) {\n if (payload[0] === bytes[0] && payload[1] === bytes[1] && payload[2] === bytes[2]) {\n return marker;\n }\n }\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload magic mismatch — expected \"rvn\" or \"xna\" got 0x${payload[0].toString(16)} 0x${payload[1].toString(16)} 0x${payload[2].toString(16)}`);\n}\nfunction parseAssetTransferPayload(payload) {\n if (payload.length < 4 + 1 + 8) {\n // 4 magic+type, 1 varstr length, 8 int64LE amount\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload of ${payload.length} bytes is too short`);\n }\n const marker = detectAssetMarker(payload);\n if (payload[3] !== TRANSFER_TYPE) {\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload type marker 0x${payload[3].toString(16)} is not a transfer (0x74)`);\n }\n const nameLen = payload[4];\n const nameStart = 5;\n const nameEnd = nameStart + nameLen;\n if (nameEnd + 8 > payload.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: asset payload truncated — name length ${nameLen} does not leave room for amount`);\n }\n let assetName = '';\n for (let i = nameStart; i < nameEnd; i += 1) {\n assetName += String.fromCharCode(payload[i]);\n }\n let amountRaw = 0n;\n for (let i = 0; i < 8; i += 1) {\n amountRaw |= BigInt(payload[nameEnd + i]) << BigInt(8 * i);\n }\n // Any bytes after nameEnd + 8 form the optional tail (message +\n // expireTime). We intentionally ignore them in this first version; the\n // raw payload remains available via `payloadHex` if a consumer later\n // needs to inspect them.\n return { assetName, amountRaw, marker };\n}\n/**\n * Parse an asset-transfer-wrapped scriptPubKey. Accepts both wrapped and\n * bare forms. Throws on structural malformation (truncated pushdata,\n * missing OP_DROP after payload, bad magic, unsupported pushdata width).\n */\nexport function splitAssetWrappedScriptPubKey(spkHex) {\n const normalized = ensureHex(spkHex, 'scriptPubKey');\n const bytes = hexToBytes(normalized);\n const assetOpAt = findTopLevelAssetOpcode(bytes);\n if (assetOpAt < 0) {\n return { prefixHex: normalized, assetTransfer: null };\n }\n const prefix = bytes.slice(0, assetOpAt);\n const { payload, after } = readPayloadPush(bytes, assetOpAt + 1);\n if (after >= bytes.length) {\n throw new Error('splitAssetWrappedScriptPubKey: asset wrapper missing trailing OP_DROP');\n }\n if (bytes[after] !== OP_DROP) {\n throw new Error(`splitAssetWrappedScriptPubKey: expected OP_DROP at offset ${after}, got 0x${bytes[after].toString(16)}`);\n }\n if (after + 1 !== bytes.length) {\n throw new Error(`splitAssetWrappedScriptPubKey: ${bytes.length - after - 1} trailing bytes after OP_DROP`);\n }\n const { assetName, amountRaw, marker } = parseAssetTransferPayload(payload);\n return {\n prefixHex: bytesToHex(prefix),\n assetTransfer: {\n assetName,\n amountRaw,\n marker,\n payloadHex: bytesToHex(payload),\n },\n };\n}\n","/**\n * Shared parsing primitives for strict covenant parsers. Each covenant\n * parser walks the exact byte layout emitted by its builder and fails on\n * any deviation; the primitives here centralize the cursor arithmetic,\n * pushdata decoding, and CScriptNum decoding so the legacy and PQ parsers\n * (and future covenant parsers) cannot drift in rigor.\n */\nimport { OP_1 } from './opcodes.js';\nexport function makeCursor(bytes) {\n return { bytes, pos: 0 };\n}\n/** Consume one byte and verify it equals `expected`. */\nexport function expectByte(c, expected, label) {\n if (c.pos >= c.bytes.length) {\n throw new Error(`parse: unexpected end of script while reading ${label}`);\n }\n const got = c.bytes[c.pos];\n if (got !== expected) {\n throw new Error(`parse: expected ${label} = 0x${expected.toString(16)} at offset ${c.pos}, got 0x${got.toString(16)}`);\n }\n c.pos += 1;\n}\n/** Fail if the cursor has not consumed every byte of the script. */\nexport function assertTrailing(c) {\n if (c.pos !== c.bytes.length) {\n throw new Error(`parse: ${c.bytes.length - c.pos} trailing bytes after end of script`);\n }\n}\n/**\n * Read one pushdata element from the cursor. Supports direct pushes\n * (1..75 bytes), `OP_PUSHDATA1` and `OP_PUSHDATA2`. `OP_PUSHDATA4` is not\n * supported by any current covenant script and would overflow the\n * per-element cap anyway. Truncation is checked for all length fields\n * and payload ranges.\n */\nexport function readPush(c, label) {\n if (c.pos >= c.bytes.length) {\n throw new Error(`parse: unexpected end of script while reading push for ${label}`);\n }\n const opcode = c.bytes[c.pos];\n c.pos += 1;\n // Short direct push: 1..75 bytes\n if (opcode >= 0x01 && opcode <= 0x4b) {\n const len = opcode;\n if (c.pos + len > c.bytes.length) {\n throw new Error(`parse: short push of ${len} bytes exceeds script length at ${label}`);\n }\n const data = c.bytes.slice(c.pos, c.pos + len);\n c.pos += len;\n return data;\n }\n // OP_PUSHDATA1\n if (opcode === 0x4c) {\n if (c.pos >= c.bytes.length) {\n throw new Error(`parse: truncated PUSHDATA1 length at ${label}`);\n }\n const len = c.bytes[c.pos];\n c.pos += 1;\n if (c.pos + len > c.bytes.length) {\n throw new Error(`parse: PUSHDATA1 of ${len} bytes exceeds script length at ${label}`);\n }\n const data = c.bytes.slice(c.pos, c.pos + len);\n c.pos += len;\n return data;\n }\n // OP_PUSHDATA2\n if (opcode === 0x4d) {\n if (c.pos + 2 > c.bytes.length) {\n throw new Error(`parse: truncated PUSHDATA2 length at ${label}`);\n }\n const len = c.bytes[c.pos] | (c.bytes[c.pos + 1] << 8);\n c.pos += 2;\n if (c.pos + len > c.bytes.length) {\n throw new Error(`parse: PUSHDATA2 of ${len} bytes exceeds script length at ${label}`);\n }\n const data = c.bytes.slice(c.pos, c.pos + len);\n c.pos += len;\n return data;\n }\n throw new Error(`parse: expected a pushdata opcode at ${label}, got 0x${opcode.toString(16)} at offset ${c.pos - 1}`);\n}\n/**\n * Decode a `CScriptNum` byte vector (little-endian sign-magnitude, up to\n * 8 bytes) into a BigInt. Empty vector encodes 0.\n */\nexport function decodeScriptNum(data, label) {\n if (data.length === 0)\n return 0n;\n if (data.length > 8) {\n throw new Error(`parse: CScriptNum at ${label} exceeds 8 bytes`);\n }\n let n = 0n;\n for (let i = 0; i < data.length - 1; i += 1) {\n n |= BigInt(data[i]) << BigInt(8 * i);\n }\n const last = data[data.length - 1];\n n |= BigInt(last & 0x7f) << BigInt(8 * (data.length - 1));\n if (last & 0x80) {\n n = -n;\n }\n return n;\n}\n/**\n * Read a push as a non-negative CScriptNum. Recognises OP_1..OP_16\n * shorthand. `OP_0` is not accepted because the covenant callers use this\n * only for values that are strictly positive (prices, selectors, indices).\n */\nexport function readPushPositiveInt(c, label) {\n if (c.pos >= c.bytes.length) {\n throw new Error(`parse: end of script at ${label}`);\n }\n const opcode = c.bytes[c.pos];\n if (opcode >= OP_1 && opcode <= 0x60) {\n c.pos += 1;\n return BigInt(opcode - OP_1 + 1);\n }\n const data = readPush(c, label);\n return decodeScriptNum(data, label);\n}\n/**\n * Read a one-byte unsigned selector. This accepts OP_1..OP_16 shorthand\n * and a raw one-byte push for scripts that permit either form. NIP-042\n * TXHASH masks use a separate strict two-byte parser.\n */\nexport function readPushUint8(c, label) {\n if (c.pos >= c.bytes.length) {\n throw new Error(`parse: end of script at ${label}`);\n }\n const opcode = c.bytes[c.pos];\n if (opcode >= OP_1 && opcode <= 0x60) {\n c.pos += 1;\n return opcode - OP_1 + 1;\n }\n const data = readPush(c, label);\n if (data.length !== 1) {\n throw new Error(`parse: ${label} must be a single-byte push, got ${data.length} bytes`);\n }\n return data[0];\n}\n","import { CHAINCONTEXT_HEIGHT, CHAINCONTEXT_MTP, OP_CHAINCONTEXT, OP_GREATERTHAN, OP_VERIFY } from '../../core/opcodes.js';\nimport { expectByte, readPushPositiveInt, readPushUint8 } from '../../core/script-parser.js';\nconst MAX_INT64 = 0x7fffffffffffffffn;\nfunction selectorForMode(mode) {\n if (mode === 'height')\n return CHAINCONTEXT_HEIGHT;\n if (mode === 'mtp')\n return CHAINCONTEXT_MTP;\n throw new Error('expiration.mode must be \"height\" or \"mtp\"');\n}\nfunction modeForSelector(selector) {\n if (selector === CHAINCONTEXT_HEIGHT)\n return 'height';\n if (selector === CHAINCONTEXT_MTP)\n return 'mtp';\n throw new Error('expiration OP_CHAINCONTEXT selector must be HEIGHT (0x01) or MTP (0x02)');\n}\nexport function assertExpiration(expiration) {\n if (expiration === undefined)\n return undefined;\n if (expiration === null || typeof expiration !== 'object') {\n throw new Error('expiration must be an object');\n }\n selectorForMode(expiration.mode);\n if (typeof expiration.value !== 'bigint') {\n throw new Error('expiration.value must be a bigint');\n }\n if (expiration.value <= 0n) {\n throw new Error('expiration.value must be > 0');\n }\n if (expiration.value > MAX_INT64) {\n throw new Error('expiration.value exceeds int64 range');\n }\n return expiration;\n}\nexport function appendExpirationGate(b, expiration) {\n if (!expiration)\n return;\n // Selectors 1 (HEIGHT) and 2 (MTP) must be pushed as OP_1 / OP_2 so the\n // resulting script is consensus-minimal (MINIMALDATA). `pushBytes(0x01 N)`\n // would emit `01 0N`, which the consensus rule rejects for N in 1..16.\n // Parser side stays lenient (`readPushUint8` accepts both forms) so old\n // covenants in the raw `01 0N` form keep round-tripping.\n b.pushInt(expiration.value)\n .pushInt(selectorForMode(expiration.mode))\n .op(OP_CHAINCONTEXT, OP_GREATERTHAN, OP_VERIFY);\n}\nexport function readOptionalExpirationGate(c, nextOpcodeWithoutGate, label) {\n if (c.pos >= c.bytes.length || c.bytes[c.pos] === nextOpcodeWithoutGate) {\n return undefined;\n }\n const value = readPushPositiveInt(c, `expiration value (${label})`);\n if (value <= 0n) {\n throw new Error(`parse: expiration value (${label}) must be > 0`);\n }\n const selector = readPushUint8(c, `expiration selector (${label})`);\n const mode = modeForSelector(selector);\n expectByte(c, OP_CHAINCONTEXT, `OP_CHAINCONTEXT (${label})`);\n expectByte(c, OP_GREATERTHAN, `OP_GREATERTHAN (${label})`);\n expectByte(c, OP_VERIFY, `OP_VERIFY (${label})`);\n return { mode, value };\n}\nexport function assertSameExpiration(a, b, label) {\n if (a === undefined && b === undefined)\n return;\n if (a === undefined || b === undefined || a.mode !== b.mode || a.value !== b.value) {\n throw new Error(`parse: expiration differs between ${label}`);\n }\n}\n","/**\n * Buyer fill branches shared by both Partial-Fill Sell Order variants\n * (ECDSA cancel in `./script.ts`, ML-DSA-44 cancel in `./script-pq.ts`).\n * The variants only differ in their cancel branch; everything after the\n * outer `OP_ELSE` is emitted and parsed here.\n *\n * Input-0 binding. The fill branches read the order's asset amount with\n * `<0> OP_INPUTASSETFIELD` and constrain outputs 0..2 by fixed index. Input\n * indices are absolute and Script cannot ask for the index of the input\n * being evaluated, so without a binding a buyer could:\n * - put a foreign asset UTXO at input 0 and the order at input 1: the\n * order then prices the fill by the foreign amount and the rest of the\n * order leaves through an unconstrained output;\n * - spend several identical orders together, every one of them satisfied\n * by the same payment output.\n * The fill block therefore opens with\n *\n * <0x80 0x00> OP_TXHASH <INPUT_ZERO_TXHASH> OP_EQUALVERIFY\n *\n * NIP-042 mask 0x0080 commits only to the index of the input being\n * evaluated, so the digest equals the constant exactly when this covenant\n * is spent as input 0. At most one order per transaction can take a fill\n * branch; the seller's cancel branch is not bound.\n *\n * Layout (after the variant's `OP_IF <cancel> OP_ELSE`):\n *\n * <0x80 0x00> OP_TXHASH <INPUT_ZERO_TXHASH> OP_EQUALVERIFY\n * OP_IF ← full fill, unlock <1> <0>\n * [expiration gate]\n * <0> <2> OP_INPUTASSETFIELD (N = order amount)\n * DUP <price> MUL <0> OUTPUTVALUE SWAP GE VERIFY (payment value)\n * <0> OUTPUTSCRIPT <paymentSpk> EQUALVERIFY (payment destination)\n * DUP <1> <2> OUTPUTASSETFIELD EQUALVERIFY (buyer amount == N)\n * <1> <1> OUTPUTASSETFIELD <tokenId> EQUALVERIFY (buyer asset name)\n * DROP <1>\n * OP_ELSE ← partial fill, unlock <N> <0> <0>\n * [expiration gate]\n * payment value, payment destination, buyer amount, buyer name (as above)\n * <2> OUTPUTAUTHCOMMITMENT <2> TXFIELD EQUALVERIFY (continuation, NIP-023)\n * <2> <1> OUTPUTASSETFIELD <tokenId> EQUALVERIFY (continuation name)\n * <2> <2> OUTPUTASSETFIELD OVER <0> <2> INPUTASSETFIELD SWAP SUB EQUALVERIFY\n * DROP <1>\n * OP_ENDIF\n */\nimport { bytesEqual, hexToBytes } from '../../core/bytes.js';\nimport { ASSETFIELD_AMOUNT, ASSETFIELD_NAME, OP_0, OP_1, OP_2, OP_DROP, OP_DUP, OP_ELSE, OP_ENDIF, OP_EQUALVERIFY, OP_GREATERTHANOREQUAL, OP_IF, OP_INPUTASSETFIELD, OP_MUL, OP_OUTPUTASSETFIELD, OP_OUTPUTAUTHCOMMITMENT, OP_OUTPUTSCRIPT, OP_OUTPUTVALUE, OP_OVER, OP_SUB, OP_SWAP, OP_TXFIELD, OP_TXHASH, OP_VERIFY, TXFIELD_AUTHSCRIPT_COMMITMENT, TXHASH_CURRENT_INDEX } from '../../core/opcodes.js';\nimport { expectByte, readPush, readPushPositiveInt } from '../../core/script-parser.js';\nimport { appendExpirationGate, assertSameExpiration, readOptionalExpirationGate } from './expiration.js';\n/** NIP-042 mask (two bytes, little-endian) selecting only the current input index. */\nexport const INPUT_INDEX_TXHASH_SELECTOR = Uint8Array.of(TXHASH_CURRENT_INDEX, 0x00);\n/**\n * `OP_TXHASH(0x0080)` evaluated at input 0:\n * `SHA256(tag || tag || 80 00 || 00 00 00 00)` with `tag = SHA256(\"NeuraiTxHash\")`.\n */\nexport const INPUT_ZERO_TXHASH = hexToBytes('419632cabaf8bb70b96a8c92c4601a9c2ba11e96841daebc9d98f4835eeb0e36');\nfunction appendPaymentAndBuyerChecks(b, p) {\n // output[0].value >= N * unitPriceSats [ N ]\n b.op(OP_DUP)\n .pushInt(p.unitPriceSats)\n .op(OP_MUL)\n .pushInt(0)\n .op(OP_OUTPUTVALUE)\n .op(OP_SWAP)\n .op(OP_GREATERTHANOREQUAL)\n .op(OP_VERIFY);\n // output[0].scriptPubKey == paymentScriptPubKey [ N ]\n b.pushInt(0)\n .op(OP_OUTPUTSCRIPT)\n .pushBytes(p.paymentScriptPubKey)\n .op(OP_EQUALVERIFY);\n // output[1].asset.amount == N [ N ]\n b.op(OP_DUP)\n .pushInt(1)\n .pushInt(ASSETFIELD_AMOUNT)\n .op(OP_OUTPUTASSETFIELD)\n .op(OP_EQUALVERIFY);\n // output[1].asset.name == tokenId [ N ]\n b.pushInt(1)\n .pushInt(ASSETFIELD_NAME)\n .op(OP_OUTPUTASSETFIELD)\n .pushBytes(p.tokenIdBytes)\n .op(OP_EQUALVERIFY);\n}\n/** Emit the input-0 binding and both fill branches, ending with the inner `OP_ENDIF`. */\nexport function appendFillBranches(b, p) {\n b.pushBytes(INPUT_INDEX_TXHASH_SELECTOR)\n .op(OP_TXHASH)\n .pushBytes(INPUT_ZERO_TXHASH)\n .op(OP_EQUALVERIFY);\n // ──────── Full fill: N is the whole order, no continuation ────────\n b.op(OP_IF);\n appendExpirationGate(b, p.expiration);\n b.pushInt(0)\n .pushInt(ASSETFIELD_AMOUNT)\n .op(OP_INPUTASSETFIELD); // [ N ]\n appendPaymentAndBuyerChecks(b, p);\n b.op(OP_DROP).pushInt(1);\n // ──────── Partial fill: buyer pushes N, remainder continues at output 2 ────────\n b.op(OP_ELSE);\n appendExpirationGate(b, p.expiration);\n appendPaymentAndBuyerChecks(b, p);\n // Continuation keeps the spent order's AuthScript commitment (NIP-023).\n b.pushInt(2)\n .op(OP_OUTPUTAUTHCOMMITMENT)\n .pushInt(TXFIELD_AUTHSCRIPT_COMMITMENT)\n .op(OP_TXFIELD)\n .op(OP_EQUALVERIFY);\n b.pushInt(2)\n .pushInt(ASSETFIELD_NAME)\n .op(OP_OUTPUTASSETFIELD)\n .pushBytes(p.tokenIdBytes)\n .op(OP_EQUALVERIFY);\n // output[2].asset.amount == orderAmount - N\n b.pushInt(2)\n .pushInt(ASSETFIELD_AMOUNT)\n .op(OP_OUTPUTASSETFIELD) // [ N, rem ]\n .op(OP_OVER) // [ N, rem, N ]\n .pushInt(0)\n .pushInt(ASSETFIELD_AMOUNT)\n .op(OP_INPUTASSETFIELD) // [ N, rem, N, in ]\n .op(OP_SWAP) // [ N, rem, in, N ]\n .op(OP_SUB) // [ N, rem, in - N ]\n .op(OP_EQUALVERIFY);\n b.op(OP_DROP).pushInt(1);\n b.op(OP_ENDIF);\n}\nfunction readPaymentAndBuyerChecks(c, label) {\n expectByte(c, OP_DUP, `OP_DUP (price, ${label})`);\n const unitPriceSats = readPushPositiveInt(c, `unitPriceSats (${label})`);\n expectByte(c, OP_MUL, `OP_MUL (${label})`);\n expectByte(c, OP_0, `OP_0 (payment idx, ${label})`);\n expectByte(c, OP_OUTPUTVALUE, `OP_OUTPUTVALUE (${label})`);\n expectByte(c, OP_SWAP, `OP_SWAP (${label})`);\n expectByte(c, OP_GREATERTHANOREQUAL, `OP_GREATERTHANOREQUAL (${label})`);\n expectByte(c, OP_VERIFY, `OP_VERIFY (payment, ${label})`);\n expectByte(c, OP_0, `OP_0 (spk idx, ${label})`);\n expectByte(c, OP_OUTPUTSCRIPT, `OP_OUTPUTSCRIPT (${label})`);\n const paymentScriptPubKey = readPush(c, `paymentScriptPubKey (${label})`);\n expectByte(c, OP_EQUALVERIFY, `OP_EQUALVERIFY (payment spk, ${label})`);\n expectByte(c, OP_DUP, `OP_DUP (buyer amount, ${label})`);\n expectByte(c, OP_1, `OP_1 (buyer idx, ${label})`);\n expectByte(c, OP_2, `OP_2 (AMOUNT sel, ${label})`);\n expectByte(c, OP_OUTPUTASSETFIELD, `OP_OUTPUTASSETFIELD (buyer amount, ${label})`);\n expectByte(c, OP_EQUALVERIFY, `OP_EQUALVERIFY (buyer amount, ${label})`);\n expectByte(c, OP_1, `OP_1 (buyer idx, ${label})`);\n expectByte(c, OP_1, `OP_1 (NAME sel, ${label})`);\n expectByte(c, OP_OUTPUTASSETFIELD, `OP_OUTPUTASSETFIELD (buyer name, ${label})`);\n const tokenId = readPush(c, `tokenId (${label})`);\n expectByte(c, OP_EQUALVERIFY, `OP_EQUALVERIFY (buyer name, ${label})`);\n return { unitPriceSats, paymentScriptPubKey, tokenId };\n}\n/**\n * Parse what `appendFillBranches` emits. Both branches must agree on price,\n * payment destination, tokenId and expiration; any deviation throws.\n */\nexport function readFillBranches(c) {\n const selector = readPush(c, 'input-0 binding selector');\n if (!bytesEqual(selector, INPUT_INDEX_TXHASH_SELECTOR)) {\n throw new Error('parse: fill branches must open with the input-0 binding <0x8000> OP_TXHASH (covenants without it ' +\n 'can be drained through a foreign input 0 and are not supported)');\n }\n expectByte(c, OP_TXHASH, 'OP_TXHASH (input-0 binding)');\n const digest = readPush(c, 'input-0 binding digest');\n if (!bytesEqual(digest, INPUT_ZERO_TXHASH)) {\n throw new Error('parse: input-0 binding digest is not OP_TXHASH(0x0080) at input 0');\n }\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (input-0 binding)');\n // ═════ Full fill ═════\n expectByte(c, OP_IF, 'OP_IF (full fill)');\n const expirationFull = readOptionalExpirationGate(c, OP_0, 'full');\n expectByte(c, OP_0, 'OP_0 (input idx, full)');\n expectByte(c, OP_2, 'OP_2 (AMOUNT sel, full)');\n expectByte(c, OP_INPUTASSETFIELD, 'OP_INPUTASSETFIELD (full)');\n const full = readPaymentAndBuyerChecks(c, 'full');\n expectByte(c, OP_DROP, 'OP_DROP (full)');\n expectByte(c, OP_1, 'OP_1 (true, full)');\n // ═════ Partial fill ═════\n expectByte(c, OP_ELSE, 'OP_ELSE (partial fill)');\n const expirationPartial = readOptionalExpirationGate(c, OP_DUP, 'partial');\n const partial = readPaymentAndBuyerChecks(c, 'partial');\n expectByte(c, OP_2, 'OP_2 (remainder idx)');\n expectByte(c, OP_OUTPUTAUTHCOMMITMENT, 'OP_OUTPUTAUTHCOMMITMENT (remainder)');\n expectByte(c, OP_2, 'OP_2 (TXFIELD sel: AUTHSCRIPT_COMMITMENT)');\n expectByte(c, OP_TXFIELD, 'OP_TXFIELD');\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (remainder auth)');\n expectByte(c, OP_2, 'OP_2 (remainder idx)');\n expectByte(c, OP_1, 'OP_1 (NAME sel)');\n expectByte(c, OP_OUTPUTASSETFIELD, 'OP_OUTPUTASSETFIELD (remainder name)');\n const remainderTokenId = readPush(c, 'tokenId (remainder)');\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (remainder name)');\n expectByte(c, OP_2, 'OP_2 (remainder idx)');\n expectByte(c, OP_2, 'OP_2 (AMOUNT sel)');\n expectByte(c, OP_OUTPUTASSETFIELD, 'OP_OUTPUTASSETFIELD (remainder amount)');\n expectByte(c, OP_OVER, 'OP_OVER');\n expectByte(c, OP_0, 'OP_0 (input idx)');\n expectByte(c, OP_2, 'OP_2 (AMOUNT sel)');\n expectByte(c, OP_INPUTASSETFIELD, 'OP_INPUTASSETFIELD');\n expectByte(c, OP_SWAP, 'OP_SWAP');\n expectByte(c, OP_SUB, 'OP_SUB');\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (remainder amount)');\n expectByte(c, OP_DROP, 'OP_DROP (partial)');\n expectByte(c, OP_1, 'OP_1 (true, partial)');\n expectByte(c, OP_ENDIF, 'OP_ENDIF (fill branches)');\n if (!bytesEqual(full.tokenId, partial.tokenId) || !bytesEqual(partial.tokenId, remainderTokenId)) {\n throw new Error('parse: tokenId differs between the fill checks');\n }\n if (full.unitPriceSats !== partial.unitPriceSats) {\n throw new Error('parse: unitPriceSats differs between full-fill and partial-fill branches');\n }\n if (!bytesEqual(full.paymentScriptPubKey, partial.paymentScriptPubKey)) {\n throw new Error('parse: payment scriptPubKey differs between full-fill and partial-fill branches');\n }\n assertSameExpiration(expirationFull, expirationPartial, 'full-fill and partial-fill branches');\n return {\n paymentScriptPubKey: full.paymentScriptPubKey,\n tokenId: new TextDecoder('utf-8', { fatal: true }).decode(full.tokenId),\n unitPriceSats: full.unitPriceSats,\n expiration: expirationFull\n };\n}\n","/**\n * Partial-Fill Sell Order covenant script (three-branch), ECDSA cancel.\n *\n * The covenant has three branches selected by the top of the unlock stack:\n *\n * OP_IF ← Cancel: seller signs, recovers remainder.\n * OP_ELSE OP_IF ← Full fill: buyer drains the covenant entirely.\n * No continuation output is required.\n * OP_ELSE OP_ELSE ← Partial fill: buyer takes N < total. A\n * continuation UTXO at vout[2] preserves the\n * covenant with amount = total - N.\n *\n * Output layout:\n *\n * output[0] = XNA payment to seller (value >= N * unitPriceSats)\n * output[1] = asset to buyer (tokenId, amount == N)\n * output[2] = covenant continuation (only for partial fill;\n * same AuthScript commitment,\n * amount == inputAmount - N)\n * output[3+] = optional buyer change (not constrained by the covenant)\n *\n * The order must be input 0 for either fill branch to succeed: see the\n * input-0 binding in `./fill-branches.ts`.\n *\n * Unlock stack shapes (scriptSig pushes, top → bottom):\n *\n * Cancel: <sig> <pubkey> <1>\n * Full fill: <1> <0> (full-flag=1, cancel-flag=0)\n * Partial fill: <N> <0> <0> (N, full-flag=0, cancel-flag=0)\n *\n * The cancel branch uses classical ECDSA (`OP_HASH160 + OP_CHECKSIG`)\n * against a 20-byte key hash. The payment destination is independent of\n * that key: a legacy P2PKH seller passes `sellerAddress` (both at once),\n * any other seller with a secp256k1 key — typically a strict ECDSA v3\n * `nq1r…` wallet — passes `paymentAddress` and `sellerPubKeyHash`. For\n * post-quantum cancellation use `buildPartialFillScriptPQ`.\n */\nimport { decodeAddress } from '@neuraiproject/neurai-create-transaction';\nimport { bytesToHex } from '../../core/bytes.js';\nimport { encodeSellerScriptPubKey } from '../../address.js';\nimport { encodeP2PKHScriptPubKey } from '../../standard/p2pkh.js';\nimport { OP_CHECKSIG, OP_DUP, OP_ELSE, OP_ENDIF, OP_EQUALVERIFY, OP_HASH160, OP_IF } from '../../core/opcodes.js';\nimport { ScriptBuilder } from '../../core/script-builder.js';\nimport { assertExpiration } from './expiration.js';\nimport { appendFillBranches } from './fill-branches.js';\nexport { encodeP2PKHScriptPubKey } from '../../standard/p2pkh.js';\nconst ASSET_NAME_MAX = 32;\nfunction decodeSellerAddress(sellerAddress) {\n if (typeof sellerAddress !== 'string' || sellerAddress.length === 0) {\n throw new Error('sellerAddress is required');\n }\n const decoded = decodeAddress(sellerAddress);\n if (decoded.type !== 'p2pkh') {\n throw new Error(`sellerAddress must be a legacy P2PKH address; got ${decoded.type}. A seller with another address ` +\n `type passes paymentAddress and sellerPubKeyHash, or uses buildPartialFillScriptPQ for a PQ key.`);\n }\n const pkh = Uint8Array.from(decoded.hash);\n if (pkh.length !== 20) {\n throw new Error(`decoded sellerAddress produced a ${pkh.length}-byte hash, expected 20`);\n }\n return pkh;\n}\n/** Cancel key hash and payment scriptPubKey from either form of seller params. */\nfunction resolveSeller(params) {\n const { sellerAddress, paymentAddress, sellerPubKeyHash } = params;\n if (sellerAddress !== undefined) {\n if (paymentAddress !== undefined || sellerPubKeyHash !== undefined) {\n throw new Error('pass either sellerAddress, or paymentAddress with sellerPubKeyHash, not both');\n }\n const pkh = decodeSellerAddress(sellerAddress);\n return { sellerPubKeyHash: pkh, paymentScriptPubKey: encodeP2PKHScriptPubKey(pkh) };\n }\n if (paymentAddress === undefined || sellerPubKeyHash === undefined) {\n throw new Error('sellerAddress, or paymentAddress with sellerPubKeyHash, is required');\n }\n if (!(sellerPubKeyHash instanceof Uint8Array) || sellerPubKeyHash.length !== 20) {\n throw new Error('sellerPubKeyHash must be a 20-byte Uint8Array (HASH160 of the compressed public key)');\n }\n return {\n sellerPubKeyHash: Uint8Array.from(sellerPubKeyHash),\n paymentScriptPubKey: encodeSellerScriptPubKey(paymentAddress).bytes\n };\n}\nfunction assertTokenId(tokenId) {\n if (typeof tokenId !== 'string' || tokenId.length === 0) {\n throw new Error('tokenId is required');\n }\n if (!/^[A-Z0-9._]+$/.test(tokenId)) {\n throw new Error(`tokenId \"${tokenId}\" is not a valid Neurai asset name`);\n }\n if (tokenId.length > ASSET_NAME_MAX) {\n throw new Error(`tokenId exceeds ${ASSET_NAME_MAX} bytes`);\n }\n}\nfunction assertPrice(priceSats) {\n if (typeof priceSats !== 'bigint') {\n throw new Error('unitPriceSats must be a bigint (satoshis per indivisible unit)');\n }\n if (priceSats <= 0n) {\n throw new Error('unitPriceSats must be > 0');\n }\n if (priceSats > 0x7fffffffffffffffn) {\n throw new Error('unitPriceSats exceeds int64 range');\n }\n}\n/**\n * Build the `scriptPubKey` of a Partial-Fill Sell Order covenant UTXO.\n * Returns raw bytes; wrap with `bytesToHex` for wire format.\n */\nexport function buildPartialFillScript(params) {\n const { tokenId, unitPriceSats } = params;\n const { sellerPubKeyHash, paymentScriptPubKey } = resolveSeller(params);\n assertTokenId(tokenId);\n assertPrice(unitPriceSats);\n const expiration = assertExpiration(params.expiration);\n const b = new ScriptBuilder();\n // ════════ Cancel branch (outer IF) ════════\n // scriptSig: <sig> <pubkey> <1>\n b.op(OP_IF)\n .op(OP_DUP, OP_HASH160)\n .pushBytes(sellerPubKeyHash)\n .op(OP_EQUALVERIFY, OP_CHECKSIG)\n .op(OP_ELSE);\n // ════════ Fill branches (outer ELSE) ════════\n appendFillBranches(b, {\n paymentScriptPubKey,\n tokenIdBytes: new TextEncoder().encode(tokenId),\n unitPriceSats,\n expiration\n });\n b.op(OP_ENDIF); // closes outer cancel/fill IF\n return b.build();\n}\n/** Hex convenience wrapper for `buildPartialFillScript`. */\nexport function buildPartialFillScriptHex(params) {\n return bytesToHex(buildPartialFillScript(params));\n}\n// Re-export atomic helpers so parse.ts and callers can reuse them.\nexport { pushBytes, pushInt } from '../../core/script-builder.js';\n","/**\n * PQ (post-quantum) variant of the Partial-Fill Sell Order covenant.\n *\n * Identical fill branches (full + partial) to the legacy covenant, but the\n * **cancel** branch accepts an ML-DSA-44 signature instead of an ECDSA one.\n * This requires:\n * - `SCRIPT_VERIFY_CHECKSIGFROMSTACK` (for OP_CSFS) active\n * - `SCRIPT_VERIFY_TXHASH` (for OP_TXHASH) active\n * - NIP-18 (`MAX_PQ_SCRIPT_ELEMENT_SIZE = 3072`) active, so the ~2.4 KB\n * signature and ~1.3 KB pubkey can be pushed to the script stack\n *\n * All three are active on DePIN-Test testnet.\n *\n * Cancel-branch flow (scriptSig pushes `<sig> <pubkey> OP_1`):\n *\n * 1. OP_DUP OP_SHA256 <commitment> OP_EQUALVERIFY → pubkey matches\n * 2. <selector> OP_TXHASH → message = H(tx)\n * 3. OP_SWAP OP_CHECKSIGFROMSTACK → CSFS verifies sig\n *\n * The message that gets signed is **SHA256(OP_TXHASH(selector))** — CSFS\n * single-SHA256s its message argument before verification, and OP_TXHASH\n * produces its own 32-byte NIP-042 tagged hash, so the seller computes:\n * `sign(pqSeckey, SHA256(TaggedHash(\"NeuraiTxHash\", mask || selected_tx_fields)))`\n *\n * The fill branches, including the input-0 binding, are shared with the\n * ECDSA variant — see `./fill-branches.ts`.\n */\nimport { bytesToHex } from '../../core/bytes.js';\nimport { encodeSellerScriptPubKey } from '../../address.js';\nimport { OP_CHECKSIGFROMSTACK, OP_DUP, OP_ELSE, OP_ENDIF, OP_EQUALVERIFY, OP_IF, OP_SHA256, OP_SWAP, OP_TXHASH } from '../../core/opcodes.js';\nimport { ScriptBuilder } from '../../core/script-builder.js';\nimport { assertExpiration } from './expiration.js';\nimport { appendFillBranches } from './fill-branches.js';\nconst ASSET_NAME_MAX = 32;\nexport const DEFAULT_PQ_TXHASH_SELECTOR = 0x1ff;\nfunction assertCommitment(commitment) {\n if (!(commitment instanceof Uint8Array) || commitment.length !== 32) {\n throw new Error('pubKeyCommitment must be a 32-byte Uint8Array (SHA256 of pubKey)');\n }\n}\nfunction assertTokenId(tokenId) {\n if (typeof tokenId !== 'string' || tokenId.length === 0) {\n throw new Error('tokenId is required');\n }\n if (!/^[A-Z0-9._]+$/.test(tokenId)) {\n throw new Error(`tokenId \"${tokenId}\" is not a valid Neurai asset name`);\n }\n if (tokenId.length > ASSET_NAME_MAX) {\n throw new Error(`tokenId exceeds ${ASSET_NAME_MAX} bytes`);\n }\n}\nfunction assertPrice(priceSats) {\n if (typeof priceSats !== 'bigint') {\n throw new Error('unitPriceSats must be a bigint');\n }\n if (priceSats <= 0n) {\n throw new Error('unitPriceSats must be > 0');\n }\n if (priceSats > 0x7fffffffffffffffn) {\n throw new Error('unitPriceSats exceeds int64 range');\n }\n}\nfunction assertSelector(selector) {\n if (!Number.isInteger(selector) || selector < 0 || selector > 0x1ff) {\n throw new Error('txHashSelector must be in the NIP-042 range (0x001..0x1ff)');\n }\n if (selector === 0) {\n throw new Error('txHashSelector 0x000 is rejected by OP_TXHASH');\n }\n}\n/**\n * Build the scriptPubKey of a PQ Partial-Fill Sell Order covenant UTXO.\n */\nexport function buildPartialFillScriptPQ(params) {\n const { paymentAddress, pubKeyCommitment, tokenId, unitPriceSats, txHashSelector = DEFAULT_PQ_TXHASH_SELECTOR } = params;\n assertCommitment(pubKeyCommitment);\n assertTokenId(tokenId);\n assertPrice(unitPriceSats);\n assertSelector(txHashSelector);\n const expiration = assertExpiration(params.expiration);\n const payment = encodeSellerScriptPubKey(paymentAddress);\n const tokenIdBytes = new TextEncoder().encode(tokenId);\n const b = new ScriptBuilder();\n // ════════ Cancel branch (PQ via OP_CHECKSIGFROMSTACK) ════════\n // scriptSig: <sigPQ> <pubKeyPQ> <1>\n // After OP_IF consumes the flag: [ sig, pubKey ]\n //\n // NIP-042 consumes exactly two raw little-endian bytes. CScriptNum and\n // OP_N encodings are invalid even when they represent the same mask.\n b.op(OP_IF)\n .op(OP_DUP) // [ sig, pubKey, pubKey ]\n .op(OP_SHA256) // [ sig, pubKey, H(pubKey) ]\n .pushBytes(pubKeyCommitment) // [ sig, pubKey, H(pubKey), commitment ]\n .op(OP_EQUALVERIFY) // [ sig, pubKey ]\n .pushBytes(Uint8Array.of(txHashSelector & 0xff, txHashSelector >> 8)) // [ sig, pubKey, selector ]\n .op(OP_TXHASH) // [ sig, pubKey, txHash ]\n .op(OP_SWAP) // [ sig, txHash, pubKey ]\n .op(OP_CHECKSIGFROMSTACK) // [ 1 | 0 ]\n .op(OP_ELSE);\n // ════════ Fill branches (outer ELSE) ════════\n appendFillBranches(b, {\n paymentScriptPubKey: payment.bytes,\n tokenIdBytes,\n unitPriceSats,\n expiration\n });\n b.op(OP_ENDIF); // cancel / fill\n return b.build();\n}\nexport function buildPartialFillScriptPQHex(params) {\n return bytesToHex(buildPartialFillScriptPQ(params));\n}\n","/**\n * scriptSig builders for the Partial-Fill Sell Order covenant.\n *\n * These return the raw scriptSig bytes that unlock the covenant UTXO. The\n * surrounding transaction (inputs, outputs, fees, signatures on the buyer's\n * own inputs, etc.) is the caller's responsibility — stitch them together\n * with `@neuraiproject/neurai-create-transaction`.\n */\nimport { bytesToHex } from '../../core/bytes.js';\nimport { ScriptBuilder } from '../../core/script-builder.js';\n/**\n * Unlock the covenant via the public fill branches.\n *\n * amount === total → full-fill branch. The entire covenant drains to\n * vout[1]; no vout[2] continuation is emitted.\n * amount < total → partial-fill branch. vout[2] re-locks the\n * continuation (`total - amount` units).\n *\n * Unlock stack shapes (pushed bottom → top):\n *\n * Full fill: <1> <0> ( full-flag=1, cancel-flag=0 )\n * Partial fill: <N> <0> <0> ( N, full-flag=0, cancel-flag=0 )\n *\n * @param amount units the buyer is taking. Must be > 0 and ≤ total.\n * @param total current asset amount locked in the covenant UTXO. The\n * builder reads this to decide whether to emit the full-fill\n * or partial-fill witness — consensus uses `OP_INPUTASSETFIELD`\n * inside the covenant to check it independently, so the value\n * passed here must match on-chain reality or the script fails.\n */\nexport function buildFillScriptSig(amount, total) {\n if (typeof amount !== 'bigint' || typeof total !== 'bigint') {\n throw new Error('amount and total must be bigint');\n }\n if (amount <= 0n) {\n throw new Error('fill amount must be > 0');\n }\n if (total <= 0n) {\n throw new Error('total must be > 0');\n }\n if (amount > total) {\n throw new Error('fill amount exceeds the covenant total');\n }\n const b = new ScriptBuilder();\n if (amount === total) {\n // Full fill: covenant drains entirely. Buyer does not push N — the\n // covenant reads it via OP_INPUTASSETFIELD.\n b.pushInt(1).pushInt(0);\n }\n else {\n // Partial fill: buyer pushes N, then both flag bytes.\n b.pushInt(amount).pushInt(0).pushInt(0);\n }\n return b.build();\n}\nexport function buildFillScriptSigHex(amount, total) {\n return bytesToHex(buildFillScriptSig(amount, total));\n}\n/**\n * Unlock the covenant via the seller's cancel branch.\n *\n * Stack before OP_IF (top → bottom):\n * 1 ← selects the OP_IF branch\n * pubkey ← consumed by OP_DUP OP_HASH160 … OP_EQUALVERIFY\n * sig ← consumed by OP_CHECKSIG\n *\n * so the scriptSig pushes `<sig> <pubkey> <1>`.\n *\n * The signature is on whatever sighash the caller picked; this builder does\n * not hash or sign, it only assembles the unlock script once a signature is\n * available.\n */\nexport function buildCancelScriptSig(signatureDer, pubKey) {\n if (!(signatureDer instanceof Uint8Array) || signatureDer.length === 0) {\n throw new Error('signatureDer must be a non-empty Uint8Array');\n }\n if (!(pubKey instanceof Uint8Array) || (pubKey.length !== 33 && pubKey.length !== 65)) {\n throw new Error('pubKey must be a compressed (33B) or uncompressed (65B) secp256k1 key');\n }\n return new ScriptBuilder()\n .pushBytes(signatureDer)\n .pushBytes(pubKey)\n .pushInt(1)\n .build();\n}\nexport function buildCancelScriptSigHex(signatureDer, pubKey) {\n return bytesToHex(buildCancelScriptSig(signatureDer, pubKey));\n}\n","/**\n * scriptSig builders for the PQ Partial-Fill Sell Order covenant.\n *\n * The fill branch is identical to the legacy variant (just pushes `<N> <0>`),\n * so callers reuse `buildFillScriptSig` from `./spend.ts`. Only the cancel\n * branch is different: it carries a full PQ pubkey (~1313 B) and signature\n * (~2421 B), which requires NIP-18's expanded element-size cap.\n */\nimport { bytesToHex } from '../../core/bytes.js';\nimport { ScriptBuilder } from '../../core/script-builder.js';\n/**\n * Build the scriptSig that unlocks the PQ cancel branch.\n *\n * Stack ordering pushed (bottom → top): `sig, pubkey, 1`.\n *\n * @param sigPQ ML-DSA-44 signature over `SHA256(OP_TXHASH(selector))`,\n * **with trailing sighash byte appended** (same convention as\n * OP_CHECKSIG — CSFS strips it before verification). Expected\n * length 2421 bytes for ML-DSA-44.\n * @param pubKey Versioned PQ public key bytes, 1313 bytes (1-byte prefix\n * + 1312-byte ML-DSA-44 key). Must hash (via SHA256) to the\n * `pubKeyCommitment` embedded in the covenant scriptPubKey.\n */\nexport function buildCancelScriptSigPQ(sigPQ, pubKey) {\n if (!(sigPQ instanceof Uint8Array) || sigPQ.length === 0) {\n throw new Error('sigPQ must be a non-empty Uint8Array');\n }\n if (sigPQ.length > 3072) {\n throw new Error(`sigPQ of ${sigPQ.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (3072)`);\n }\n if (!(pubKey instanceof Uint8Array) || pubKey.length === 0) {\n throw new Error('pubKey must be a non-empty Uint8Array');\n }\n if (pubKey.length > 3072) {\n throw new Error(`pubKey of ${pubKey.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (3072)`);\n }\n return new ScriptBuilder()\n .pushBytes(sigPQ)\n .pushBytes(pubKey)\n .pushInt(1)\n .build();\n}\nexport function buildCancelScriptSigPQHex(sigPQ, pubKey) {\n return bytesToHex(buildCancelScriptSigPQ(sigPQ, pubKey));\n}\n","/**\n * Witness-stack builders for the Partial-Fill Sell Order covenant.\n *\n * When the covenant lives behind an AuthScript commitment (the only\n * asset-compatible deployment since the node's OP_XNA_ASSET placement rules\n * — bare covenant outputs can no longer carry assets), the unlock data goes\n * in the witness, not the scriptSig. The scriptSig builders in `spend.ts`\n * return a serialized script that PUSHES the elements; a witness needs the\n * elements THEMSELVES, one per stack slot, so those blobs cannot be reused\n * as a single `args` entry.\n *\n * These builders return the raw `args` stack (bottom → top), mirroring the\n * shapes documented in `spend.ts`:\n *\n * Full fill: [ <1>, <0> ]\n * Partial fill: [ <N>, <0>, <0> ]\n * Cancel: [ <sig>, <pubkey>, <1> ]\n *\n * Numbers are minimal CScriptNum stack values (0 = empty element). Wrap the\n * result with `buildAuthScriptWitnessNoAuth({ args, witnessScript: covenant })`\n * (from `standard/authscript.ts`) to get the final `[0x00, ...args, covenant]`\n * witness, and serialize the spending transaction with\n * `serializeTransaction` from `@neuraiproject/neurai-create-transaction`\n * (0.5.1+, witness elements as hex strings: `witness.map(bytesToHex)`).\n */\nimport { encodeScriptNum } from '../../core/script-builder.js';\nconst MAX_PQ_SCRIPT_ELEMENT_SIZE = 3072;\n/**\n * Witness `args` for the public fill branches. Same semantics and\n * validations as `buildFillScriptSig`.\n */\nexport function buildFillWitnessStack(amount, total) {\n if (typeof amount !== 'bigint' || typeof total !== 'bigint') {\n throw new Error('amount and total must be bigint');\n }\n if (amount <= 0n) {\n throw new Error('fill amount must be > 0');\n }\n if (total <= 0n) {\n throw new Error('total must be > 0');\n }\n if (amount > total) {\n throw new Error('fill amount exceeds the covenant total');\n }\n if (amount === total) {\n // Full fill: covenant drains entirely; buyer does not push N.\n return [encodeScriptNum(1n), encodeScriptNum(0n)];\n }\n // Partial fill: N, then both flag values.\n return [encodeScriptNum(amount), encodeScriptNum(0n), encodeScriptNum(0n)];\n}\n/**\n * Witness `args` for the seller's ECDSA cancel branch. Same semantics and\n * validations as `buildCancelScriptSig`.\n */\nexport function buildCancelWitnessStack(signatureDer, pubKey) {\n if (!(signatureDer instanceof Uint8Array) || signatureDer.length === 0) {\n throw new Error('signatureDer must be a non-empty Uint8Array');\n }\n if (!(pubKey instanceof Uint8Array) || (pubKey.length !== 33 && pubKey.length !== 65)) {\n throw new Error('pubKey must be a compressed (33B) or uncompressed (65B) secp256k1 key');\n }\n return [signatureDer, pubKey, encodeScriptNum(1n)];\n}\n/**\n * Witness `args` for the seller's PQ (ML-DSA-44) cancel branch. Same\n * semantics and validations as `buildCancelScriptSigPQ`.\n */\nexport function buildCancelWitnessStackPQ(sigPQ, pubKey) {\n if (!(sigPQ instanceof Uint8Array) || sigPQ.length === 0) {\n throw new Error('sigPQ must be a non-empty Uint8Array');\n }\n if (sigPQ.length > MAX_PQ_SCRIPT_ELEMENT_SIZE) {\n throw new Error(`sigPQ of ${sigPQ.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (${MAX_PQ_SCRIPT_ELEMENT_SIZE})`);\n }\n if (!(pubKey instanceof Uint8Array) || pubKey.length === 0) {\n throw new Error('pubKey must be a non-empty Uint8Array');\n }\n if (pubKey.length > MAX_PQ_SCRIPT_ELEMENT_SIZE) {\n throw new Error(`pubKey of ${pubKey.length} bytes exceeds MAX_PQ_SCRIPT_ELEMENT_SIZE (${MAX_PQ_SCRIPT_ELEMENT_SIZE})`);\n }\n return [sigPQ, pubKey, encodeScriptNum(1n)];\n}\n","/**\n * Parser for the Partial-Fill Sell Order covenant (three-branch, ECDSA cancel).\n *\n * Extracts `(sellerPubKeyHash, paymentScriptPubKey, unitPriceSats, tokenId)`\n * from a scriptPubKey that was produced by `buildPartialFillScript`. Walks\n * the exact byte layout emitted by the builder and fails on any deviation —\n * this is deliberate, so a downstream indexer can unambiguously classify a\n * UTXO as \"partial-fill order\" or \"unknown script\" with no false positives.\n * Covenants built before the input-0 binding (neurai-scripts < 0.10.0) are\n * rejected: their fill branches can be drained through a foreign input 0.\n */\nimport { bytesToHex, hexToBytes } from '../../core/bytes.js';\nimport { OP_CHECKSIG, OP_DUP, OP_ELSE, OP_ENDIF, OP_EQUALVERIFY, OP_HASH160, OP_IF } from '../../core/opcodes.js';\nimport { assertTrailing, expectByte, makeCursor, readPush } from '../../core/script-parser.js';\nimport { readFillBranches } from './fill-branches.js';\n/**\n * Parse a covenant scriptPubKey and extract its parameters. Throws with a\n * descriptive message if the bytes don't match the partial-fill template.\n */\nexport function parsePartialFillScript(script, network = 'xna-test') {\n const bytes = typeof script === 'string' ? hexToBytes(script) : script;\n const c = makeCursor(bytes);\n // ═════ Outer IF — Cancel branch ═════\n expectByte(c, OP_IF, 'OP_IF (outer cancel)');\n expectByte(c, OP_DUP, 'OP_DUP (cancel)');\n expectByte(c, OP_HASH160, 'OP_HASH160');\n const sellerPubKeyHash = readPush(c, 'sellerPubKeyHash');\n if (sellerPubKeyHash.length !== 20) {\n throw new Error(`parse: sellerPubKeyHash is ${sellerPubKeyHash.length} bytes, expected 20`);\n }\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (cancel)');\n expectByte(c, OP_CHECKSIG, 'OP_CHECKSIG (cancel)');\n expectByte(c, OP_ELSE, 'OP_ELSE (outer → fill)');\n // ═════ Outer ELSE — input-0 binding + fill branches ═════\n const fill = readFillBranches(c);\n expectByte(c, OP_ENDIF, 'OP_ENDIF (outer)');\n assertTrailing(c);\n return {\n network,\n sellerPubKeyHash,\n paymentScriptPubKey: fill.paymentScriptPubKey,\n unitPriceSats: fill.unitPriceSats,\n tokenId: fill.tokenId,\n expiration: fill.expiration,\n scriptHex: bytesToHex(bytes)\n };\n}\n","/**\n * Parser for the PQ Partial-Fill Sell Order covenant (three-branch).\n * Returns the same economic parameters as the legacy parser, plus the\n * payment scriptPubKey bytes (which may be P2PKH or AuthScript) and the\n * configured TXHASH selector.\n *\n * The fill branches (and their input-0 binding) are read by the shared\n * `readFillBranches`; covenants built before the binding are rejected.\n */\nimport { bytesToHex, hexToBytes } from '../../core/bytes.js';\nimport { OP_CHECKSIGFROMSTACK, OP_DUP, OP_ELSE, OP_ENDIF, OP_EQUALVERIFY, OP_IF, OP_SHA256, OP_SWAP, OP_TXHASH } from '../../core/opcodes.js';\nimport { assertTrailing, expectByte, makeCursor, readPush } from '../../core/script-parser.js';\nimport { readFillBranches } from './fill-branches.js';\n/** Quick discriminator without throwing — useful for indexers. */\nexport function isPartialFillScriptPQ(script) {\n const bytes = typeof script === 'string' ? hexToBytes(script) : script;\n // PQ cancel starts with: OP_IF OP_DUP OP_SHA256\n return (bytes.length > 3 &&\n bytes[0] === OP_IF &&\n bytes[1] === OP_DUP &&\n bytes[2] === OP_SHA256);\n}\n/**\n * Parse a PQ partial-fill covenant. Throws if the bytes do not match the\n * exact layout produced by `buildPartialFillScriptPQ`.\n */\nexport function parsePartialFillScriptPQ(script, network = 'xna-test') {\n const bytes = typeof script === 'string' ? hexToBytes(script) : script;\n const c = makeCursor(bytes);\n // ═════ Outer IF — Cancel branch (PQ) ═════\n expectByte(c, OP_IF, 'OP_IF (outer cancel)');\n expectByte(c, OP_DUP, 'OP_DUP (cancel)');\n expectByte(c, OP_SHA256, 'OP_SHA256');\n const pubKeyCommitment = readPush(c, 'pubKeyCommitment');\n if (pubKeyCommitment.length !== 32) {\n throw new Error(`parse-pq: pubKeyCommitment must be 32 bytes, got ${pubKeyCommitment.length}`);\n }\n expectByte(c, OP_EQUALVERIFY, 'OP_EQUALVERIFY (cancel)');\n const selectorBytes = readPush(c, 'txHashSelector');\n if (selectorBytes.length !== 2) {\n throw new Error(`parse-pq: txHashSelector must be a two-byte LE push, got ${selectorBytes.length} bytes`);\n }\n const txHashSelector = selectorBytes[0] | (selectorBytes[1] << 8);\n if (txHashSelector === 0 || txHashSelector > 0x1ff) {\n throw new Error(`parse-pq: txHashSelector 0x${txHashSelector.toString(16)} is rejected by OP_TXHASH`);\n }\n expectByte(c, OP_TXHASH, 'OP_TXHASH');\n expectByte(c, OP_SWAP, 'OP_SWAP');\n expectByte(c, OP_CHECKSIGFROMSTACK, 'OP_CHECKSIGFROMSTACK');\n expectByte(c, OP_ELSE, 'OP_ELSE (outer → fill)');\n // ═════ Outer ELSE — input-0 binding + fill branches ═════\n const fill = readFillBranches(c);\n expectByte(c, OP_ENDIF, 'OP_ENDIF (outer)');\n assertTrailing(c);\n return {\n network,\n pubKeyCommitment,\n tokenId: fill.tokenId,\n unitPriceSats: fill.unitPriceSats,\n txHashSelector,\n expiration: fill.expiration,\n paymentScriptPubKey: fill.paymentScriptPubKey,\n scriptHex: bytesToHex(bytes)\n };\n}\n","/**\n * NIP-054 P2AH custody policy (`OP_CHECKASSETAUTH`, AuthScript only).\n *\n * The policy is the witnessScript of a generic AuthScript v1 (NoAuth)\n * address. A spend of that address needs M of the N owner-token roles of the\n * list to approve it (G of them when an owner token held by the custody\n * leaves it):\n *\n * policy: <1> <M> <G> <role_1> ... <role_n> <n> OP_CHECKASSETAUTH\n * witness: [0x00, <c>, <a>, <b>, <T>, policy]\n *\n * Build the four arguments with `buildAssetAuthArgs` and wrap them with\n * `buildAuthScriptWitnessNoAuth({ args, witnessScript: policy })`. A role\n * approves either by spending its owner token from P2PKH or a strict\n * AuthScript address with a SIGHASH_ALL signature (synchronous spend, every\n * argument 0), or by a vote (see `vote.ts` and `proposal.ts`).\n */\nimport { OP_1, OP_16, OP_CHECKASSETAUTH } from '../../core/opcodes.js';\nimport { encodeScriptNum, ScriptBuilder } from '../../core/script-builder.js';\nimport { makeCursor, readPush, readPushUint8 } from '../../core/script-parser.js';\n/** The only policy version defined by NIP-054. */\nexport const ASSETAUTH_POLICY_VERSION = 1;\n/** Highest number of roles in one policy. */\nexport const ASSETAUTH_MAX_ROLES = 16;\n/** c, a, b and T are script numbers of at most 4 bytes. */\nconst MAX_ARGUMENT = 0x7fffffff;\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\nfunction compareBytes(x, y) {\n const n = Math.min(x.length, y.length);\n for (let i = 0; i < n; i += 1) {\n if (x[i] !== y[i])\n return x[i] - y[i];\n }\n return x.length - y.length;\n}\n/** Role names as the node checks them: sorted by bytes, no duplicates. */\nfunction sortedRoles(roles) {\n if (!Array.isArray(roles) || roles.length < 1 || roles.length > ASSETAUTH_MAX_ROLES) {\n throw new Error(`roles must list 1 to ${ASSETAUTH_MAX_ROLES} owner tokens`);\n }\n const names = roles.map((role) => {\n if (typeof role !== 'string' || !role.endsWith('!')) {\n throw new Error(`role ${JSON.stringify(role)} is not an owner token name (NAME!)`);\n }\n return encoder.encode(role);\n });\n names.sort(compareBytes);\n for (let i = 1; i < names.length; i += 1) {\n if (compareBytes(names[i - 1], names[i]) === 0) {\n throw new Error(`role ${decoder.decode(names[i])} is listed twice`);\n }\n }\n return names;\n}\nfunction assertThresholds(M, G, n) {\n if (!Number.isInteger(M) || !Number.isInteger(G) || M < 1 || M > G || G > n) {\n throw new Error(`thresholds must satisfy 1 <= M <= G <= ${n} (got M=${M}, G=${G})`);\n }\n}\nexport function buildAssetAuthPolicyScript(policy) {\n const roles = sortedRoles(policy.roles);\n assertThresholds(policy.M, policy.G, roles.length);\n const b = new ScriptBuilder()\n .pushInt(ASSETAUTH_POLICY_VERSION)\n .pushInt(policy.M)\n .pushInt(policy.G);\n for (const role of roles)\n b.pushBytes(role);\n return b.pushInt(roles.length).op(OP_CHECKASSETAUTH).build();\n}\n/** Inverse of `buildAssetAuthPolicyScript`; rejects any other script. */\nexport function parseAssetAuthPolicyScript(script) {\n const end = script.length - 2;\n const nOp = script[end];\n if (script.length < 6 || script[end + 1] !== OP_CHECKASSETAUTH || nOp < OP_1 || nOp > OP_16) {\n throw new Error('parse: not an OP_CHECKASSETAUTH policy script');\n }\n const c = makeCursor(script);\n if (readPushUint8(c, 'version') !== ASSETAUTH_POLICY_VERSION) {\n throw new Error(`parse: policy version must be ${ASSETAUTH_POLICY_VERSION}`);\n }\n const M = readPushUint8(c, 'M');\n const G = readPushUint8(c, 'G');\n const names = [];\n while (c.pos < end)\n names.push(readPush(c, `role ${names.length + 1}`));\n if (c.pos !== end || names.length !== nOp - OP_1 + 1) {\n throw new Error('parse: role count does not match n');\n }\n const roles = names.map((name) => decoder.decode(name));\n const policy = { M, G, roles };\n // Strictly increasing as written: a re-sorted list would be another script.\n const rebuilt = buildAssetAuthPolicyScript(policy);\n if (compareBytes(rebuilt, script) !== 0) {\n throw new Error('parse: roles are not owner names in strictly increasing byte order');\n }\n return policy;\n}\n/**\n * Witness `args` [<c>, <a>, <b>, <T>] for the custody input: minimal script\n * numbers, 0 as the empty element. All default to 0, the synchronous spend.\n */\nexport function buildAssetAuthArgs({ c = 0, a = 0, b = 0, T = 0 } = {}) {\n for (const [name, value] of Object.entries({ c, a, b, T })) {\n if (!Number.isInteger(value) || value < 0 || value > MAX_ARGUMENT) {\n throw new Error(`${name} must be an integer from 0 to ${MAX_ARGUMENT}`);\n }\n }\n return [c, a, b, T].map((value) => encodeScriptNum(value));\n}\n","const U32_MASK64 = /* @__PURE__ */ (() => BigInt(2 ** 32 - 1))();\nconst _32n = /* @__PURE__ */ BigInt(32);\n// Split bigint into two 32-bit halves. With `le=true`, returned fields become `{ h: low, l: high\n// }` to match little-endian word order rather than the property names.\nfunction fromBig(n, le = false) {\n if (le)\n return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };\n return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };\n}\n// Split bigint list into `[highWords, lowWords]` when `le=false`; with `le=true`, the first array\n// holds the low halves because `fromBig(...)` swaps the semantic meaning of `h` and `l`.\nfunction split(lst, le = false) {\n const len = lst.length;\n let Ah = new Uint32Array(len);\n let Al = new Uint32Array(len);\n for (let i = 0; i < len; i++) {\n const { h, l } = fromBig(lst[i], le);\n [Ah[i], Al[i]] = [h, l];\n }\n return [Ah, Al];\n}\n// Combine explicit `(high, low)` 32-bit halves into a bigint; `>>> 0` normalizes signed JS\n// bitwise results back to uint32 first, and little-endian callers must swap.\nconst toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);\n// Split a JS number into u32 halves without a BigInt allocation. Exact only for integers\n// `0 <= n < 2**53`; callers use it on byte / bit counters, which JS length math caps far below\n// that (an ArrayBuffer cannot exceed 2**53 - 1 bytes).\nconst fromNumH = (n) => (n / 2 ** 32) | 0;\nconst fromNumL = (n) => n >>> 0;\n// Drop-in replacement for `view.setBigUint64(byteOffset, BigInt(n), isLE)` without the per-call\n// BigInt allocation. Same `n < 2**53` precondition as `fromNumH`/`fromNumL`.\nfunction setU64FromNum(view, byteOffset, n, isLE) {\n const h = fromNumH(n);\n const l = fromNumL(n);\n view.setUint32(byteOffset, isLE ? l : h, isLE);\n view.setUint32(byteOffset + 4, isLE ? h : l, isLE);\n}\n// High 32-bit half of a 64-bit logical right shift for `s` in `0..31`.\nconst shrSH = (h, _l, s) => h >>> s;\n// Low 32-bit half of a 64-bit logical right shift, valid for `s` in `1..31`.\nconst shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// High 32-bit half of a 64-bit right rotate, valid for `s` in `1..31`.\nconst rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));\n// Low 32-bit half of a 64-bit right rotate, valid for `s` in `1..31`.\nconst rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// High 32-bit half of a 64-bit right rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.\nconst rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));\n// Low 32-bit half of a 64-bit right rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.\nconst rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));\n// High 32-bit half of a 64-bit right rotate for `s === 32`; this is just the swapped low half.\nconst rotr32H = (_h, l) => l;\n// Low 32-bit half of a 64-bit right rotate for `s === 32`; this is just the swapped high half.\nconst rotr32L = (h, _l) => h;\n// 64-bit left rotates (rotl*) are not defined here: sha3.ts, their only consumer, keeps\n// local copies so V8 inlines them into keccakP.\n// Add two split 64-bit words and return the split `{ h, l }` sum.\n// JS uses 32-bit signed integers for bitwise operations, so we cannot simply shift the carry out\n// of the low sum and instead use division.\nfunction add(Ah, Al, Bh, Bl) {\n const l = (Al >>> 0) + (Bl >>> 0);\n return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };\n}\n// Addition with more than 2 elements\n// Unmasked low-word accumulator for 3-way addition; pass the raw result into `add3H(...)`.\nconst add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);\n// High-word finalize step for 3-way addition; `low` must be the untruncated output of `add3L(...)`.\nconst add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;\n// Unmasked low-word accumulator for 4-way addition; pass the raw result into `add4H(...)`.\nconst add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);\n// High-word finalize step for 4-way addition; `low` must be the untruncated output of `add4L(...)`.\nconst add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;\n// Unmasked low-word accumulator for 5-way addition; pass the raw result into `add5H(...)`.\nconst add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);\n// High-word finalize step for 5-way addition; `low` must be the untruncated output of `add5L(...)`.\nconst add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;\n// prettier-ignore\nexport { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, fromNumH, fromNumL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, setU64FromNum, shrSH, shrSL, split, toBig };\n","/**\n * Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.\n * @param a - value to test\n * @returns `true` when the value is a Uint8Array-compatible view.\n * @example\n * Check whether a value is a Uint8Array-compatible view.\n * ```ts\n * isBytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function isBytes(a) {\n // Plain `instanceof Uint8Array` is too strict for some Buffer / proxy / cross-realm cases.\n // The fallback still requires a real ArrayBuffer view, so plain\n // JSON-deserialized `{ constructor: ... }` spoofing is rejected, and\n // `BYTES_PER_ELEMENT === 1` keeps the fallback on byte-oriented views.\n return (a instanceof Uint8Array ||\n (ArrayBuffer.isView(a) &&\n a.constructor.name === 'Uint8Array' &&\n 'BYTES_PER_ELEMENT' in a &&\n a.BYTES_PER_ELEMENT === 1));\n}\n// Shared error-message prefix builder. Only called on throw paths, so assert\n// success paths never pay for the string concatenation.\nconst atitle = (title) => (title ? `\"${title}\" ` : '');\n/**\n * Asserts something is a non-negative integer.\n * @param n - number to validate\n * @param title - label included in thrown errors\n * @returns The validated number.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate a non-negative integer option.\n * ```ts\n * anumber(32, 'length');\n * ```\n */\nexport function anumber(n, title = '') {\n if (typeof n !== 'number')\n throw new TypeError(atitle(title) + 'expected number, got ' + typeof n);\n if (!Number.isSafeInteger(n) || n < 0)\n throw new RangeError(atitle(title) + 'expected integer >= 0, got ' + n);\n return n;\n}\n/**\n * Asserts something is a boolean.\n * @param value - value to validate\n * @param title - label included in thrown errors\n * @returns The validated boolean.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Validate a boolean option.\n * ```ts\n * abool(true, 'enableXOF');\n * ```\n */\nexport function abool(value, title = '') {\n if (typeof value !== 'boolean')\n throw new TypeError(atitle(title) + 'expected boolean, got type=' + typeof value);\n return value;\n}\n/**\n * Asserts something is Uint8Array.\n * @param value - value to validate\n * @param length - optional exact length constraint\n * @param title - label included in thrown errors\n * @returns The validated byte array.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate that a value is a byte array.\n * ```ts\n * abytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function abytes(value, length, title = '') {\n // Success path first: this runs at the start of every update() / digestInto(), and the\n // common `abytes(data)` form must not pay for length handling it does not use.\n if (isBytes(value) && (length === undefined || value.length === length))\n return value;\n // Error path: recompute freely to build the exact message.\n if (length !== undefined)\n anumber(length, 'length');\n const bytes = isBytes(value);\n const ofLen = length !== undefined ? ` of length ${length}` : '';\n const got = bytes ? `length=${value.length}` : `type=${typeof value}`;\n const message = atitle(title) + 'expected Uint8Array' + ofLen + ', got ' + got;\n if (!bytes)\n throw new TypeError(message);\n throw new RangeError(message);\n}\n/**\n * Copies bytes into a fresh Uint8Array.\n * Buffer-style slices can alias the same backing store, so callers that need ownership should copy.\n * @param bytes - source bytes to clone\n * @returns Freshly allocated copy of `bytes`.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Clone a byte array before mutating it.\n * ```ts\n * const copy = copyBytes(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function copyBytes(bytes) {\n // `Uint8Array.from(...)` would also accept arrays / other typed arrays. Keep this helper strict\n // because callers use it at byte-validation boundaries before mutating the detached copy.\n return Uint8Array.from(abytes(bytes));\n}\n/**\n * Asserts something is a wrapped hash constructor.\n * @param h - hash constructor to validate\n * @throws On wrong argument types or invalid hash wrapper shape. {@link TypeError}\n * @throws On invalid hash metadata ranges or values. {@link RangeError}\n * @throws If the hash metadata allows empty outputs or block sizes. {@link Error}\n * @example\n * Validate a callable hash wrapper.\n * ```ts\n * import { ahash } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * ahash(sha256);\n * ```\n */\nexport function ahash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new TypeError('expected hash wrapped by utils.createHasher');\n anumber(h.outputLen);\n anumber(h.blockLen);\n // HMAC and KDF callers treat these as real byte lengths; allowing zero lets fake wrappers pass\n // validation and can produce empty outputs instead of failing fast.\n if (h.outputLen < 1 || h.blockLen < 1)\n throw new Error('hash blockLen / outputLen must be >= 1');\n}\nconst aobject = (value, label) => {\n if (value === null || typeof value !== 'object' || Array.isArray(value))\n throw new TypeError((label === 'object' ? '' : `\"${label}\" `) + 'expected object, got type=' + typeof value);\n};\nconst aopts = (value, label) => {\n aobject(value, label);\n const proto = Object.getPrototypeOf(value);\n if (proto !== Object.prototype && proto !== null)\n throw new TypeError(`\"${label}\" expected plain object`);\n // Object.assign() treats an own \"__proto__\" source key as a write to the target's legacy\n // prototype setter. Reject it before merging so inherited option values cannot be injected.\n if (Object.hasOwn(value, '__proto__'))\n throw new TypeError(`\"${label}.__proto__\" is not allowed`);\n};\n/**\n * Asserts a hash instance has not been destroyed or finished.\n * @param instance - hash instance to validate\n * @param checkFinished - whether to reject finalized instances\n * @throws If the hash instance has already been destroyed or finalized. {@link Error}\n * @example\n * Validate that a hash instance is still usable.\n * ```ts\n * import { aexists } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const hash = sha256.create();\n * aexists(hash);\n * ```\n */\nexport function aexists(instance, checkFinished = true) {\n // Runs on every update()/digestInto(); the flags are library-owned booleans, so only their\n // truthiness is checked - re-validating their type per call was pure hot-path overhead.\n if (instance.destroyed)\n throw new Error('hash was destroyed');\n if (checkFinished && instance.finished)\n throw new Error('digest() was already called');\n}\n/**\n * Asserts output is a sufficiently-sized byte array.\n * @param out - destination buffer\n * @param instance - hash instance providing output length\n * Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Validate a caller-provided digest buffer.\n * ```ts\n * import { aoutput } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const hash = sha256.create();\n * aoutput(new Uint8Array(hash.outputLen), hash);\n * ```\n */\nexport function aoutput(out, instance) {\n abytes(out, undefined, 'output');\n // `outputLen` is a library-owned readonly number; the negated comparison keeps failing fast\n // when it is missing/NaN (comparisons with undefined/NaN are false) without an anumber() call.\n const min = instance.outputLen;\n if (!(out.length >= min)) {\n throw new RangeError('\"output\" expected length >= ' + min);\n }\n}\n/**\n * Casts a typed array view to Uint8Array.\n * @param arr - source typed array\n * @returns Uint8Array view over the same buffer.\n * @example\n * Reinterpret a typed array as bytes.\n * ```ts\n * u8(new Uint32Array([1, 2]));\n * ```\n */\nexport function u8(arr) {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/**\n * Casts a typed array view to Uint32Array.\n * `arr.byteOffset` must already be 4-byte aligned or the platform\n * Uint32Array constructor will throw.\n * @param arr - source typed array\n * @returns Uint32Array view over the same buffer.\n * @example\n * Reinterpret a byte array as 32-bit words.\n * ```ts\n * u32(new Uint8Array(8));\n * ```\n */\nexport function u32(arr) {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n/**\n * Zeroizes typed arrays in place. Warning: JS provides no guarantees.\n * @param arrays - arrays to overwrite with zeros\n * @example\n * Zeroize sensitive buffers in place.\n * ```ts\n * clean(new Uint8Array([1, 2, 3]));\n * ```\n */\nexport function clean(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n/**\n * Creates a DataView for byte-level manipulation.\n * @param arr - source typed array\n * @returns DataView over the same buffer region.\n * @example\n * Create a DataView over an existing buffer.\n * ```ts\n * createView(new Uint8Array(4));\n * ```\n */\nexport function createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/**\n * Rotate-right operation for uint32 values.\n * @param word - source word\n * @param shift - shift amount in bits\n * @returns Rotated word.\n * @example\n * Rotate a 32-bit word to the right.\n * ```ts\n * rotr(0x12345678, 8);\n * ```\n */\nexport function rotr(word, shift) {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/**\n * Rotate-left operation for uint32 values.\n * @param word - source word\n * @param shift - shift amount in bits\n * @returns Rotated word.\n * @example\n * Rotate a 32-bit word to the left.\n * ```ts\n * rotl(0x12345678, 8);\n * ```\n */\nexport function rotl(word, shift) {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n/** Whether the current platform is little-endian. */\nexport const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n/**\n * Byte-swap operation for uint32 values.\n * @param word - source word\n * @returns Word with reversed byte order.\n * @example\n * Reverse the byte order of a 32-bit word.\n * ```ts\n * byteSwap(0x11223344);\n * ```\n */\nexport function byteSwap(word) {\n return (((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff));\n}\n/**\n * Conditionally byte-swaps one 32-bit word on big-endian platforms.\n * @param n - source word\n * @returns Original or byte-swapped word depending on platform endianness.\n * @example\n * Normalize a 32-bit word for host endianness.\n * ```ts\n * swap8IfBE(0x11223344);\n * ```\n */\nexport const swap8IfBE = isLE\n ? (n) => n\n : (n) => byteSwap(n) >>> 0;\n/**\n * Byte-swaps every word of a Uint32Array in place.\n * @param arr - array to mutate\n * @returns The same array after mutation; callers pass live state arrays here.\n * @example\n * Reverse the byte order of every word in place.\n * ```ts\n * byteSwap32(new Uint32Array([0x11223344]));\n * ```\n */\nexport function byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n return arr;\n}\n/**\n * Conditionally byte-swaps a Uint32Array on big-endian platforms.\n * @param u - array to normalize for host endianness\n * @returns Original or byte-swapped array depending on platform endianness.\n * On big-endian runtimes this mutates `u` in place via `byteSwap32(...)`.\n * @example\n * Normalize a word array for host endianness.\n * ```ts\n * swap32IfBE(new Uint32Array([0x11223344]));\n * ```\n */\nexport const swap32IfBE = isLE\n ? (u) => u\n : byteSwap32;\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin = /* @__PURE__ */ (() => \n// @ts-ignore\ntypeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * Convert byte array to hex string.\n * Uses the built-in function when available and assumes it matches the tested\n * fallback semantics.\n * @param bytes - bytes to encode\n * @returns Lowercase hexadecimal string.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Convert bytes to lowercase hexadecimal.\n * ```ts\n * bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])); // 'cafe0123'\n * ```\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin)\n return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// Strict ASCII nibble parser: non-ASCII hex lookalikes are rejected as undefined.\n// ASCII codes: '0'..'9' = 48..57, 'A'..'F' = 65..70, 'a'..'f' = 97..102.\n// prettier-ignore\nfunction asciiToBase16(ch) {\n return ch >= 48 && ch <= 57 ? ch - 48 // '2' => 50-48\n : ch >= 65 && ch <= 70 ? ch - (65 - 10) // 'B' => 66-(65-10)\n : ch >= 97 && ch <= 102 ? ch - (97 - 10) // 'b' => 98-(97-10)\n : undefined;\n}\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @param hex - hexadecimal string to decode\n * @returns Decoded bytes.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Decode lowercase hexadecimal into bytes.\n * ```ts\n * hexToBytes('cafe0123'); // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n * ```\n */\nexport function hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new TypeError('hex string expected, got ' + typeof hex);\n if (hasHexBuiltin) {\n try {\n return Uint8Array.fromHex(hex);\n }\n catch (error) {\n if (error instanceof SyntaxError)\n throw new RangeError(error.message);\n throw error;\n }\n }\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new RangeError('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi)); // parse first char, multiply it by 16\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); // parse second char\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new RangeError('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // example: 'A9' => 10*16 + 9\n }\n return array;\n}\n/**\n * Yields to the host task scheduler so timers, I/O, and rendering can make progress.\n * Uses the Web Scheduling API when available or `setTimeout` as a cross-platform fallback.\n * Host-task yields are much slower than microtasks (roughly 1ms with the timer fallback), so\n * async loops should use `asyncTick >= 10` to amortize scheduling overhead to about 10% while\n * still allowing other event-loop work to proceed.\n * @param onReject - optional cleanup invoked only if the host yield fails\n * @example\n * Yield to the next scheduler tick.\n * ```ts\n * await nextTick();\n * ```\n */\nexport function nextTick(onReject) {\n const host = globalThis;\n if (typeof host.scheduler?.yield === 'function') {\n const promise = host.scheduler.yield();\n // Keep the original scheduler rejection; this handler exists only for cleanup.\n if (onReject)\n promise.catch(onReject);\n return promise;\n }\n return new Promise((resolve) => host.setTimeout(resolve, 0));\n}\n/**\n * Returns control to the host event loop every `tick` milliseconds to avoid blocking long loops.\n * @param iters - number of loop iterations to run\n * @param tick - maximum time slice in milliseconds\n * @param cb - callback executed on each iteration\n * @param onReject - optional cleanup invoked only if a host yield fails\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @example\n * Run a loop that periodically yields back to the event loop.\n * ```ts\n * await asyncLoop(2, 0, () => {});\n * ```\n */\nexport async function asyncLoop(iters, tick, cb, onReject) {\n anumber(iters, 'iters');\n anumber(tick, 'tick');\n if (typeof cb !== 'function')\n throw new TypeError('callback must be a function');\n // Callback is synchronous by contract; asyncLoop only yields between sync work windows.\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick(onReject);\n // Track only synchronous work time; scheduler delay after yielding is outside our budget.\n ts = Date.now();\n }\n}\n/**\n * Converts string to bytes using UTF8 encoding.\n * Built-in doesn't validate input to be string: we do the check.\n * Non-ASCII details are delegated to the platform `TextEncoder`.\n * @param str - string to encode\n * @returns UTF-8 encoded bytes.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Encode a string as UTF-8 bytes.\n * ```ts\n * utf8ToBytes('abc'); // Uint8Array.from([97, 98, 99])\n * ```\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new TypeError('string expected');\n const encoded = new TextEncoder().encode(str);\n try {\n // Copy into the current realm for Firefox extension contexts. Callers that own the returned\n // buffer can then wipe it independently of TextEncoder's temporary result.\n return new Uint8Array(encoded); // https://bugzil.la/1681809\n }\n finally {\n clean(encoded);\n }\n}\n/**\n * Helper for KDFs: consumes Uint8Array or string.\n * String inputs are UTF-8 encoded; byte-array inputs stay aliased to the caller buffer.\n * @param data - user-provided KDF input\n * @param errorTitle - label included in thrown errors\n * @returns Byte representation of the input.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Normalize KDF input to bytes.\n * ```ts\n * kdfInputToBytes('password');\n * ```\n */\nexport function kdfInputToBytes(data, errorTitle = '') {\n if (typeof data === 'string')\n return utf8ToBytes(data);\n return abytes(data, undefined, errorTitle);\n}\n/**\n * Copies several Uint8Arrays into one.\n * @param arrays - arrays to concatenate\n * @returns Concatenated byte array.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Concatenate multiple byte arrays.\n * ```ts\n * concatBytes(new Uint8Array([1]), new Uint8Array([2]));\n * ```\n */\nexport function concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n/**\n * Validates declared required and optional field types on a plain object.\n * This walks field schemas and formats detailed errors, so avoid it on hot paths; use direct\n * one-line guards such as `abytes()`, `abool()`, or `anumber()` instead.\n * @param object - object to validate\n * @param fields - map of required field names to expected types\n * @param optFields - map of optional field names to expected types\n * @param title - label included in thrown errors\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Validate required and optional option fields.\n * ```ts\n * validateObject({ N: 1024, dkLen: 32 }, { N: 'number' }, { dkLen: 'number' });\n * ```\n */\nexport const validateObject = (object, fields = {}, optFields = {}, title = 'object') => {\n aobject(object, title);\n aobject(fields, 'fields');\n aobject(optFields, 'optFields');\n function checkField(fieldName, expectedType, isOpt) {\n const label = title === 'object' ? `param \"${String(fieldName)}\"` : `\"${title}.${String(fieldName)}\"`;\n // Config fields must be explicit own properties. Optional inherited values are rejected too\n // because callers keep reading the same options object after validation.\n const val = object[fieldName];\n // Runtime objects such as Field instances intentionally satisfy required method slots\n // via their shared prototype.\n if (!Object.hasOwn(object, fieldName) &&\n (isOpt ? val !== undefined : expectedType !== 'function')) {\n throw new TypeError(`${label} is invalid: expected own property`);\n }\n if (isOpt && val === undefined)\n return;\n const current = typeof val;\n if (current !== expectedType || val === null)\n throw new TypeError(`${label} is invalid: expected ${expectedType}, got ${current}`);\n }\n const iter = (f, isOpt) => Object.entries(f).forEach(([k, v]) => checkField(k, v, isOpt));\n iter(fields, false);\n iter(optFields, true);\n};\n/**\n * Merges default options and passed options.\n * @param defaults - base option object\n * @param opts - user overrides\n * @param title - label included in thrown override errors\n * @returns Fresh merged option object with a null prototype.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Merge user overrides onto default options.\n * ```ts\n * checkOpts({ dkLen: 32 }, { asyncTick: 10 });\n * ```\n */\nexport function checkOpts(defaults, opts, title = 'opts') {\n aopts(defaults, 'defaults');\n if (opts !== undefined)\n aopts(opts, title);\n // Callers read optional fields directly, so omitted values must not fall through to ambient\n // Object.prototype pollution (for example a forged `dkLen` changing SHAKE's default output).\n const merged = Object.assign(Object.create(null), defaults, opts);\n return merged;\n}\n/**\n * Creates a callable hash function from a stateful class constructor.\n * @param hashCons - hash constructor or factory\n * @param info - optional metadata such as DER OID\n * @returns Frozen callable hash wrapper with `.create()`.\n * Wrapper construction eagerly calls `hashCons(undefined)` once to read\n * `outputLen` / `blockLen`, so constructor side effects happen at module\n * init time.\n * @throws On wrong argument types. {@link TypeError}\n * @example\n * Wrap a stateful hash constructor into a callable helper.\n * ```ts\n * import { createHasher } from '@noble/hashes/utils.js';\n * import { sha256 } from '@noble/hashes/sha2.js';\n * const wrapped = createHasher(sha256.create, { oid: sha256.oid });\n * wrapped(new Uint8Array([1]));\n * ```\n */\nexport function createHasher(hashCons, info = {}) {\n if (typeof hashCons !== 'function')\n throw new TypeError('\"hashCons\" expected function, got type=' + typeof hashCons);\n info = checkOpts({}, info, 'info');\n const hashC = (msg, opts) => hashCons(opts)\n .update(msg)\n .digest();\n const tmp = hashCons(undefined);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.canXOF = tmp.canXOF;\n hashC.create = (opts) => hashCons(opts);\n Object.assign(hashC, info);\n return Object.freeze(hashC);\n}\n/**\n * Cryptographically secure PRNG backed by `crypto.getRandomValues`.\n * @param bytesLength - number of random bytes to generate\n * @returns Random bytes.\n * The platform `getRandomValues()` implementation still defines any\n * single-call length cap, and this helper rejects oversize requests\n * with a stable library `RangeError` instead of host-specific errors.\n * @throws On wrong argument types. {@link TypeError}\n * @throws On wrong argument ranges or values. {@link RangeError}\n * @throws If the current runtime does not provide `crypto.getRandomValues`. {@link Error}\n * @example\n * Generate a fresh random key or nonce.\n * ```ts\n * const key = randomBytes(16);\n * ```\n */\nexport function randomBytes(bytesLength = 32) {\n // Match the repo's other length-taking helpers instead of relying on Uint8Array coercion.\n anumber(bytesLength, 'bytesLength');\n const cr = typeof globalThis === 'object' ? globalThis.crypto : null;\n if (typeof cr?.getRandomValues !== 'function')\n throw new Error('crypto.getRandomValues must be defined');\n // Web Cryptography API Level 2 §10.1.1:\n // if `byteLength > 65536`, throw `QuotaExceededError`.\n // Keep the guard explicit so callers can see the quota in code\n // instead of discovering it by reading the spec or host errors.\n // This wrapper surfaces the same quota as a stable library RangeError.\n if (bytesLength > 65536)\n throw new RangeError(`\"bytesLength\" expected <= 65536, got ${bytesLength}`);\n return cr.getRandomValues(new Uint8Array(bytesLength));\n}\n/**\n * Creates OID metadata for NIST hashes with prefix `06 09 60 86 48 01 65 03 04 02`.\n * @param suffix - final OID byte for the selected hash.\n * The helper accepts any byte even though only the documented NIST hash\n * suffixes are meaningful downstream.\n * @returns Object containing the DER-encoded OID.\n * @example\n * Build OID metadata for a NIST hash.\n * ```ts\n * oidNist(0x01);\n * ```\n */\nexport const oidNist = (suffix) => ({\n // Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.\n // Larger suffix values would need base-128 OID encoding and a different length byte.\n oid: Uint8Array.from([0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, suffix]),\n});\n","/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\nimport { setU64FromNum } from \"./_u64.js\";\nimport { abytes, aexists, aoutput, createView } from \"./utils.js\";\n/**\n * Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.\n * Returns bits from `b` when `a` is set, otherwise from `c`.\n * The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never\n * set the same bit.\n * @param a - selector word\n * @param b - word chosen when selector bit is set\n * @param c - word chosen when selector bit is clear\n * @returns Mixed 32-bit word.\n * @example\n * Combine three words with the shared 32-bit choice primitive.\n * ```ts\n * Chi(0xffffffff, 0x12345678, 0x87654321);\n * ```\n */\nexport function Chi(a, b, c) {\n return (a & b) ^ (~a & c);\n}\n/**\n * Shared 32-bit majority primitive reused by SHA-256 and SHA-1.\n * Returns bits shared by at least two inputs.\n * @param a - first input word\n * @param b - second input word\n * @param c - third input word\n * @returns Mixed 32-bit word.\n * @example\n * Combine three words with the shared 32-bit majority primitive.\n * ```ts\n * Maj(0xffffffff, 0x12345678, 0x87654321);\n * ```\n */\nexport function Maj(a, b, c) {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n * Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit\n * strings with partial-byte tails.\n * @param blockLen - internal block size in bytes\n * @param outputLen - digest size in bytes\n * @param padOffset - trailing length field size in bytes\n * @param isLE - whether length and state words are encoded in little-endian\n * @example\n * Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.\n * ```ts\n * import { _SHA1 } from '@noble/hashes/legacy.js';\n * const hash = new _SHA1();\n * hash.update(new Uint8Array([97, 98, 99]));\n * hash.digest();\n * ```\n */\nexport class HashMD {\n blockLen;\n outputLen;\n canXOF = false;\n padOffset;\n isLE;\n // For partial updates less than block size\n buffer;\n view;\n finished = false;\n length = 0;\n pos = 0;\n destroyed = false;\n constructor(blockLen, outputLen, padOffset, isLE) {\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data) {\n aexists(this);\n abytes(data);\n const { view, buffer, blockLen } = this;\n const len = data.length;\n let processed = false;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path only when there is no buffered partial block: `take === blockLen` implies\n // `this.pos === 0`, so we can process full blocks directly from the input view.\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n processed = true;\n continue;\n }\n // When the whole input is buffered in one go (common for short messages), passing `data`\n // directly avoids allocating a subarray view.\n buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n processed = true;\n }\n }\n this.length += data.length;\n // Shared schedule buffers only pick up input-derived words inside process(); if everything\n // was buffered without processing, there is nothing to zero.\n if (processed)\n this.roundClean();\n return this;\n }\n digestInto(out) {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message, then zero-pad the rest of the block\n buffer[pos++] = 0b10000000;\n buffer.fill(0, pos);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n buffer.fill(0);\n }\n // `padOffset` reserves the whole length field. For SHA-384/512 the high 64 bits stay zero from\n // the padding fill above, and JS will overflow before user input can make that half non-zero.\n // So we only need to write the low 64 bits here (`length * 8` only scales the exponent of an\n // integer below 2**53, so the split inside the helper stays exact).\n setU64FromNum(view, blockLen - 8, this.length * 8, isLE);\n this.process(view, 0);\n // The final block above is processed outside update(), so the shared message-schedule\n // buffers (e.g. SHA256_W) would otherwise retain input-derived words after digest().\n this.roundClean();\n // digest() passes our own `buffer` as `out`; reuse its cached view instead of allocating one.\n const oview = out === buffer ? view : createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which must be fused in single op with modulo by JIT\n const outLen = len / 4;\n const state = this.get();\n // Subclass-misconfiguration invariant: outputLen must be 32-bit aligned and fit the state.\n if (len % 4 || outLen > state.length)\n throw new Error('invalid outputLen');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n // Copy before destroy(): subclasses wipe `buffer` during cleanup, but `digest()` must return\n // fresh bytes to the caller.\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneIntoMeta(to) {\n const { buffer, length, finished, destroyed, pos } = this;\n to.destroyed = destroyed;\n to.finished = finished;\n to.length = length;\n to.pos = pos;\n // Only partial-block bytes need copying: when `length % blockLen === 0`, `pos === 0` and\n // later `update()` / `digestInto()` overwrite `to.buffer` from the start before reading it.\n if (pos)\n to.buffer.set(buffer); // Avoid a hot modulo guard.\n return to;\n }\n clone() {\n return this._cloneInto();\n }\n}\n/**\n * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.\n * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.\n */\n/** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the\n * square roots of the first eight prime numbers. Exported as a shared table; callers must treat\n * it as read-only because constructors copy words from it by index. */\nexport const SHA256_IV = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n/** Initial SHA224 state `H(0)` from RFC 6234 §6.1. Exported as a shared table; callers must\n * treat it as read-only because constructors copy words from it by index. */\nexport const SHA224_IV = /* @__PURE__ */ Uint32Array.from([\n 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,\n]);\n/** Initial SHA384 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen\n * big-endian 32-bit halves. Derived from the fractional parts of the square roots of the ninth\n * through sixteenth prime numbers. Exported as a shared table; callers must treat it as read-only\n * because constructors copy halves from it by index. */\nexport const SHA384_IV = /* @__PURE__ */ Uint32Array.from([\n 0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939,\n 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4,\n]);\n/** Initial SHA512 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen\n * big-endian 32-bit halves. Derived from the fractional parts of the square roots of the first\n * eight prime numbers. Exported as a shared table; callers must treat it as read-only because\n * constructors copy halves from it by index. */\nexport const SHA512_IV = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,\n 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,\n]);\n","/**\n * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.\n * SHA256 is the fastest hash implementable in JS, even faster than Blake3.\n * Check out {@link https://www.rfc-editor.org/rfc/rfc4634 | RFC 4634} and\n * {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf | FIPS 180-4}.\n * @module\n */\nimport { Chi, HashMD, Maj, SHA224_IV, SHA256_IV, SHA384_IV, SHA512_IV } from \"./_md.js\";\nimport * as u64 from \"./_u64.js\";\nimport { clean, createHasher, oidNist, rotr } from \"./utils.js\";\n/**\n * SHA-224 / SHA-256 round constants from RFC 6234 §5.1: the first 32 bits\n * of the cube roots of the first 64 primes (2..311).\n */\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ Uint32Array.from([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n/** Reusable SHA-224 / SHA-256 message schedule buffer `W_t` from RFC 6234 §6.2 step 1. */\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\n/** Internal SHA-224 / SHA-256 compression engine from RFC 6234 §6.2. */\nclass SHA2_32B extends HashMD {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n // Numeric initializers matter: starting the fields as `undefined` changes\n // V8's field representation and makes sha256 3x slower (measured).\n A = 0;\n B = 0;\n C = 0;\n D = 0;\n E = 0;\n F = 0;\n G = 0;\n H = 0;\n constructor(outputLen, IV) {\n super(64, outputLen, 8, false);\n this.A = IV[0] | 0;\n this.B = IV[1] | 0;\n this.C = IV[2] | 0;\n this.D = IV[3] | 0;\n this.E = IV[4] | 0;\n this.F = IV[5] | 0;\n this.G = IV[6] | 0;\n this.H = IV[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n _cloneInto(to) {\n (to ||= new this.constructor()).set(...this.get());\n return this._cloneIntoMeta(to);\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n clean(SHA256_W);\n }\n destroy() {\n // HashMD callers route post-destroy usability through `destroyed`; zeroizing alone still leaves\n // update()/digest() callable on reused instances.\n this.destroyed = true;\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n clean(this.buffer);\n }\n}\n/** Internal SHA-256 hash class grounded in RFC 6234 §6.2. */\nexport class _SHA256 extends SHA2_32B {\n constructor() {\n super(32, SHA256_IV);\n }\n}\n/** Internal SHA-224 hash class grounded in RFC 6234 §6.2 and §8.5. */\nexport class _SHA224 extends SHA2_32B {\n constructor() {\n super(28, SHA224_IV);\n }\n}\n// SHA2-512 is slower than sha256 in js because u64 operations are slow.\n// SHA-384 / SHA-512 round constants from RFC 6234 §5.2:\n// 80 full 64-bit words split into high/low halves.\n// prettier-ignore\nconst K512 = /* @__PURE__ */ (() => u64.split([\n '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',\n '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',\n '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',\n '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',\n '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',\n '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',\n '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',\n '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',\n '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'\n].map(n => BigInt(n))))();\nconst SHA512_Kh = /* @__PURE__ */ (() => K512[0])();\nconst SHA512_Kl = /* @__PURE__ */ (() => K512[1])();\n// Reusable high-half schedule buffer for the RFC 6234 §6.4 64-bit `W_t` words.\nconst SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\n// Reusable low-half schedule buffer for the RFC 6234 §6.4 64-bit `W_t` words.\nconst SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\n/** Internal SHA-384 / SHA-512 compression engine from RFC 6234 §6.4. */\nclass SHA2_64B extends HashMD {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n // h -- high 32 bits, l -- low 32 bits\n // Numeric initializers matter: starting the fields as `undefined` changes\n // V8's field representation and slows hashing down (measured on sha256).\n Ah = 0;\n Al = 0;\n Bh = 0;\n Bl = 0;\n Ch = 0;\n Cl = 0;\n Dh = 0;\n Dl = 0;\n Eh = 0;\n El = 0;\n Fh = 0;\n Fl = 0;\n Gh = 0;\n Gl = 0;\n Hh = 0;\n Hl = 0;\n constructor(outputLen, IV) {\n super(128, outputLen, 16, false);\n this.Ah = IV[0] | 0;\n this.Al = IV[1] | 0;\n this.Bh = IV[2] | 0;\n this.Bl = IV[3] | 0;\n this.Ch = IV[4] | 0;\n this.Cl = IV[5] | 0;\n this.Dh = IV[6] | 0;\n this.Dl = IV[7] | 0;\n this.Eh = IV[8] | 0;\n this.El = IV[9] | 0;\n this.Fh = IV[10] | 0;\n this.Fl = IV[11] | 0;\n this.Gh = IV[12] | 0;\n this.Gl = IV[13] | 0;\n this.Hh = IV[14] | 0;\n this.Hl = IV[15] | 0;\n }\n // prettier-ignore\n get() {\n const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];\n }\n // prettier-ignore\n set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n _cloneInto(to) {\n (to ||= new this.constructor()).set(...this.get());\n return this._cloneIntoMeta(to);\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) {\n SHA512_W_H[i] = view.getUint32(offset);\n SHA512_W_L[i] = view.getUint32((offset += 4));\n }\n for (let i = 16; i < 80; i++) {\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = SHA512_W_H[i - 15] | 0;\n const W15l = SHA512_W_L[i - 15] | 0;\n const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);\n const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = SHA512_W_H[i - 2] | 0;\n const W2l = SHA512_W_L[i - 2] | 0;\n const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);\n const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);\n // SHA512_W[i] = s0 + s1 + SHA512_W[i - 7] + SHA512_W[i - 16];\n const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);\n const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);\n SHA512_W_H[i] = SUMh | 0;\n SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n // Compression function main loop, 80 rounds\n for (let i = 0; i < 80; i++) {\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);\n const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = (Eh & Fh) ^ (~Eh & Gh);\n const CHIl = (El & Fl) ^ (~El & Gl);\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);\n const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);\n const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);\n const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);\n const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = u64.add3L(T1l, sigma0l, MAJl);\n Ah = u64.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n roundClean() {\n clean(SHA512_W_H, SHA512_W_L);\n }\n destroy() {\n // HashMD callers route post-destroy usability through `destroyed`; zeroizing alone still leaves\n // update()/digest() callable on reused instances.\n this.destroyed = true;\n clean(this.buffer);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\n/** Internal SHA-512 hash class grounded in RFC 6234 §6.3 and §6.4. */\nexport class _SHA512 extends SHA2_64B {\n constructor() {\n super(64, SHA512_IV);\n }\n}\n/** Internal SHA-384 hash class grounded in RFC 6234 §6.3 and §6.4. */\nexport class _SHA384 extends SHA2_64B {\n constructor() {\n super(48, SHA384_IV);\n }\n}\n/**\n * Truncated SHA512/256 and SHA512/224.\n * SHA512_IV is XORed with 0xa5a5a5a5a5a5a5a5, then used as \"intermediary\" IV of SHA512/t.\n * Then t hashes string to produce result IV.\n * See the repo-side derivation recipe in `test/misc/sha2-gen-iv.js`.\n * These IV literals are checked against that script rather than a dedicated\n * local RFC section.\n */\n/** SHA-512/224 IV derived by the SHA-512/t recipe in `test/misc/sha2-gen-iv.js` and\n * stored as sixteen big-endian 32-bit halves. */\nconst T224_IV = /* @__PURE__ */ Uint32Array.from([\n 0x8c3d37c8, 0x19544da2, 0x73e19966, 0x89dcd4d6, 0x1dfab7ae, 0x32ff9c82, 0x679dd514, 0x582f9fcf,\n 0x0f6d2b69, 0x7bd44da8, 0x77e36f73, 0x04c48942, 0x3f9d85a8, 0x6a1d36c8, 0x1112e6ad, 0x91d692a1,\n]);\n/** SHA-512/256 IV derived by the SHA-512/t recipe in `test/misc/sha2-gen-iv.js` and\n * stored as sixteen big-endian 32-bit halves. */\nconst T256_IV = /* @__PURE__ */ Uint32Array.from([\n 0x22312194, 0xfc2bf72c, 0x9f555fa3, 0xc84c64c2, 0x2393b86b, 0x6f53b151, 0x96387719, 0x5940eabd,\n 0x96283ee2, 0xa88effe3, 0xbe5e1e25, 0x53863992, 0x2b0199fc, 0x2c85b8aa, 0x0eb72ddc, 0x81c52ca2,\n]);\n/** Internal SHA-512/224 hash class using the derived `T224_IV` and the shared\n * RFC 6234 §6.4 compression engine. */\nexport class _SHA512_224 extends SHA2_64B {\n constructor() {\n super(28, T224_IV);\n }\n}\n/** Internal SHA-512/256 hash class using the derived `T256_IV` and the shared\n * RFC 6234 §6.4 compression engine. */\nexport class _SHA512_256 extends SHA2_64B {\n constructor() {\n super(32, T256_IV);\n }\n}\n/**\n * SHA2-256 hash function from RFC 4634. In JS it's the fastest: even faster than Blake3. Some info:\n *\n * - Trying 2^128 hashes would get 50% chance of collision, using birthday attack.\n * - BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n * - Each sha256 hash is executing 2^18 bit operations.\n * - Good 2024 ASICs can do 200Th/sec with 3500 watts of power, corresponding to 2^36 hashes/joule.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-256.\n * ```ts\n * sha256(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(), \n/* @__PURE__ */ oidNist(0x01));\n/**\n * SHA2-224 hash function from RFC 4634.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-224.\n * ```ts\n * sha224(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha224 = /* @__PURE__ */ createHasher(() => new _SHA224(), \n/* @__PURE__ */ oidNist(0x04));\n/**\n * SHA2-512 hash function from RFC 4634.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-512.\n * ```ts\n * sha512(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha512 = /* @__PURE__ */ createHasher(() => new _SHA512(), \n/* @__PURE__ */ oidNist(0x03));\n/**\n * SHA2-384 hash function from RFC 4634.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-384.\n * ```ts\n * sha384(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha384 = /* @__PURE__ */ createHasher(() => new _SHA384(), \n/* @__PURE__ */ oidNist(0x02));\n/**\n * SHA2-512/256 \"truncated\" hash function, with improved resistance to length extension attacks.\n * See the paper on {@link https://eprint.iacr.org/2010/548.pdf | truncated SHA512}.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-512/256.\n * ```ts\n * sha512_256(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha512_256 = /* @__PURE__ */ createHasher(() => new _SHA512_256(), \n/* @__PURE__ */ oidNist(0x06));\n/**\n * SHA2-512/224 \"truncated\" hash function, with improved resistance to length extension attacks.\n * See the paper on {@link https://eprint.iacr.org/2010/548.pdf | truncated SHA512}.\n * @param msg - message bytes to hash\n * @param opts - Reserved hash options.\n * @returns Digest bytes.\n * @example\n * Hash a message with SHA2-512/224.\n * ```ts\n * sha512_224(new Uint8Array([97, 98, 99]));\n * ```\n */\nexport const sha512_224 = /* @__PURE__ */ createHasher(() => new _SHA512_224(), \n/* @__PURE__ */ oidNist(0x05));\n","/**\n * NIP-054 proposal hash H, the message a vote carries.\n *\n * H = TaggedHash(\"NeuraiAssetAuthProposal\", m)\n * m = chainId (u8) || nVersion (i32) || nLockTime (u32) || T (u32)\n * || compact(c) || compact(a) || compact(b)\n * || (outpoint, nSequence) of inputs 0..c-1\n * || outputs 0..a-1 || the last b outputs\n * || compact(#refs) || reference inputs (version 3 only)\n *\n * Inputs from index c on and the outputs between the prefix and the suffix\n * (approvals, returns, fees, change) are left to the executor, so a skeleton\n * transaction with only the proposal inputs and outputs gives the same H as\n * the execution. Votes carry H as is, as the 32-byte (64-hex) message of\n * their owner-token transfer: `bytesToHex(hash)`.\n */\nimport { sha256 } from '@noble/hashes/sha2.js';\nimport { parseTransaction, serializeOutput } from '@neuraiproject/neurai-create-transaction';\nimport { concatBytes, hexToBytes } from '../../core/bytes.js';\n/** The chain identifier the node commits to (OP_CHAINCONTEXT selector 0x03). */\nexport const ASSETAUTH_CHAIN_IDS = Object.freeze({\n mainnet: 0,\n testnet: 1,\n regtest: 2\n});\nconst PROPOSAL_TAG = new TextEncoder().encode('NeuraiAssetAuthProposal');\nfunction u32(value) {\n const out = new Uint8Array(4);\n new DataView(out.buffer).setUint32(0, value >>> 0, true);\n return out;\n}\nfunction compactSize(value) {\n if (value < 0xfd)\n return Uint8Array.of(value);\n if (value <= 0xffff)\n return Uint8Array.of(0xfd, value & 0xff, value >> 8);\n return concatBytes(Uint8Array.of(0xfe), u32(value));\n}\n/** A display-order txid and vout as the node serializes a COutPoint. */\nfunction outpoint(txid, vout) {\n return concatBytes(hexToBytes(txid).reverse(), u32(vout));\n}\nexport function buildAssetAuthProposalMessage(proposal) {\n const { c, a, b, T } = proposal;\n const chainId = ASSETAUTH_CHAIN_IDS[proposal.chain];\n if (chainId === undefined) {\n throw new Error(`unknown chain ${JSON.stringify(proposal.chain)}`);\n }\n for (const [name, value] of Object.entries({ c, a, b, T })) {\n if (!Number.isInteger(value) || value < 0 || value > 0x7fffffff) {\n throw new Error(`${name} must be an integer from 0 to ${0x7fffffff}`);\n }\n }\n const tx = parseTransaction(proposal.rawTx);\n if (c > tx.inputs.length) {\n throw new Error(`c (${c}) exceeds the ${tx.inputs.length} inputs of the transaction`);\n }\n if (a + b > tx.outputs.length) {\n throw new Error(`a + b (${a + b}) exceeds the ${tx.outputs.length} outputs of the transaction`);\n }\n const version = new Uint8Array(4);\n new DataView(version.buffer).setInt32(0, tx.version, true);\n const parts = [Uint8Array.of(chainId), version, u32(tx.locktime), u32(T), compactSize(c), compactSize(a), compactSize(b)];\n for (const input of tx.inputs.slice(0, c)) {\n parts.push(outpoint(input.txid, input.vout), u32(input.sequence));\n }\n for (const output of [...tx.outputs.slice(0, a), ...tx.outputs.slice(tx.outputs.length - b)]) {\n parts.push(serializeOutput(output));\n }\n const refs = tx.version === 3 ? tx.vrefin : [];\n parts.push(compactSize(refs.length));\n for (const ref of refs)\n parts.push(outpoint(ref.txid, ref.vout));\n return concatBytes(...parts);\n}\n/** H: 32 bytes, in the order a vote carries it. */\nexport function assetAuthProposalHash(proposal) {\n const tag = sha256(PROPOSAL_TAG);\n return sha256(concatBytes(tag, tag, buildAssetAuthProposalMessage(proposal)));\n}\n","/**\n * NIP-054 vote lock: a wallet template (not part of the opcode) that holds a\n * role's owner token while it votes for a proposal.\n *\n * The holder sends the owner token, with the proposal hash H as its transfer\n * message, to the generic AuthScript v1 (NoAuth) address of this script:\n *\n * OP_IF execute, up to height T\n * OP_1 OP_CHAINCONTEXT <T> OP_LESSTHANOREQUAL OP_VERIFY\n * OP_SWAP OP_4 OP_INPUTFIELD <0x01 || C> OP_EQUALVERIFY\n * OP_OUTPUTSCRIPT <return> OP_EQUAL\n * OP_ELSE give it back, after T\n * OP_1 OP_CHAINCONTEXT <T> OP_GREATERTHAN OP_VERIFY\n * OP_NIP OP_OUTPUTSCRIPT <return> OP_EQUAL\n * OP_ENDIF\n *\n * Both branches send the token back to its owner (`return`, the full output\n * script). The execute branch also needs the custody, commitment C, at the\n * input it names. It must use OP_INPUTFIELD selector 04, the full\n * version-plus-commitment: selector 02 only reads the first 34 bytes of the\n * spent script, which a forged anyone-can-spend custody can match.\n */\nimport { hexToBytes, concatBytes } from '../../core/bytes.js';\nimport { CHAINCONTEXT_HEIGHT, OP_CHAINCONTEXT, OP_ELSE, OP_ENDIF, OP_EQUAL, OP_EQUALVERIFY, OP_GREATERTHAN, OP_IF, OP_INPUTFIELD, OP_LESSTHANOREQUAL, OP_NIP, OP_OUTPUTSCRIPT, OP_SWAP, OP_VERIFY } from '../../core/opcodes.js';\nimport { encodeScriptNum, ScriptBuilder } from '../../core/script-builder.js';\n/** OP_INPUTFIELD selector: the full version-plus-commitment of the spent script. */\nconst INPUTFIELD_AUTHSCRIPT_DESTINATION = 0x04;\nconst AUTHSCRIPT_V1 = 0x01;\nfunction asBytes(value) {\n return typeof value === 'string' ? hexToBytes(value) : value;\n}\nfunction assertIndex(name, value) {\n if (!Number.isInteger(value) || value < 0 || value > 0x7fffffff) {\n throw new Error(`${name} must be an integer from 0 to ${0x7fffffff}`);\n }\n}\nexport function buildAssetAuthVoteLockScript(params) {\n assertIndex('T', params.T);\n const commitment = asBytes(params.custodyCommitment);\n if (commitment.length !== 32) {\n throw new Error(`custodyCommitment must be 32 bytes (got ${commitment.length})`);\n }\n const returnScript = asBytes(params.returnScriptPubKey);\n if (returnScript.length === 0) {\n throw new Error('returnScriptPubKey must not be empty');\n }\n return new ScriptBuilder()\n .op(OP_IF)\n .pushInt(CHAINCONTEXT_HEIGHT).op(OP_CHAINCONTEXT).pushInt(params.T).op(OP_LESSTHANOREQUAL, OP_VERIFY)\n .op(OP_SWAP).pushInt(INPUTFIELD_AUTHSCRIPT_DESTINATION).op(OP_INPUTFIELD)\n .pushBytes(concatBytes(Uint8Array.of(AUTHSCRIPT_V1), commitment)).op(OP_EQUALVERIFY)\n .op(OP_OUTPUTSCRIPT).pushBytes(returnScript).op(OP_EQUAL)\n .op(OP_ELSE)\n .pushInt(CHAINCONTEXT_HEIGHT).op(OP_CHAINCONTEXT).pushInt(params.T).op(OP_GREATERTHAN, OP_VERIFY)\n .op(OP_NIP, OP_OUTPUTSCRIPT).pushBytes(returnScript).op(OP_EQUAL)\n .op(OP_ENDIF)\n .build();\n}\n/**\n * Witness `args` of the execute branch: the index of the custody input and\n * the index of the output that returns the token.\n */\nexport function buildAssetAuthVoteExecuteArgs(params) {\n assertIndex('custodyInput', params.custodyInput);\n assertIndex('returnOutput', params.returnOutput);\n return [encodeScriptNum(params.custodyInput), encodeScriptNum(params.returnOutput), encodeScriptNum(1)];\n}\n/** Witness `args` of the return branch, after T. */\nexport function buildAssetAuthVoteReturnArgs(params) {\n assertIndex('returnOutput', params.returnOutput);\n return [encodeScriptNum(0), encodeScriptNum(params.returnOutput), encodeScriptNum(0)];\n}\n"],"names":["ensureHex","hexToBytes","bytesToHex","concatBytes","toRawInteger","compactSize","ASSET_NAME_MAX","assertTokenId","assertPrice"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAS,CAAC,GAAG,EAAE,KAAK,GAAG,KAAK,EAAE;AAC9C,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;AAC7D,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;AACxE,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,iCAAiC,CAAC,CAAC;AA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