@mainnet-cash/bcmr 4.0.0-next.4 → 4.0.0-next.6
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/{BCMR-4.0.0-next.4.js → BCMR-4.0.0-next.6.js} +217 -22
- package/dist/index.html +1 -1
- package/dist/mainnet-js_dist_module_network_MockNetworkProvider_js-4.0.0-next.6.js +22 -0
- package/dist/tsconfig.browser.tsbuildinfo +1 -1
- package/dist/vendors-node_modules_bitauth_libauth_build_index_js-4.0.0-next.6.js +1222 -0
- package/dist/vendors-node_modules_bitauth_libauth_build_lib_address_locking-bytecode_js-4.0.0-next.6.js +42 -0
- package/dist/vendors-node_modules_mem-cash_electrum_dist_indexer_js-node_modules_mem-cash_electrum_dist_tr-73b153-4.0.0-next.6.js +232 -0
- package/dist/vendors-node_modules_mem-cash_validation_dist_index_js-4.0.0-next.6.js +62 -0
- package/package.json +4 -3
- package/src/Bcmr.test.browser.ts +410 -0
- package/src/Bcmr.test.ts +1 -2
- package/tsconfig.browser.json +6 -1
- package/tsconfig.json +2 -2
- package/webpack.config.cjs +4 -4
- package/src/Bcmr.test.headless.js +0 -465
|
@@ -59,7 +59,7 @@ eval("__webpack_require__.a(module, async (__webpack_handle_async_dependencies__
|
|
|
59
59
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
60
60
|
|
|
61
61
|
"use strict";
|
|
62
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"
|
|
62
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Bech32DecodingError\": () => (/* binding */ Bech32DecodingError),\n/* harmony export */ \"BitRegroupingError\": () => (/* binding */ BitRegroupingError),\n/* harmony export */ \"bech32CharacterSet\": () => (/* binding */ bech32CharacterSet),\n/* harmony export */ \"bech32CharacterSetIndex\": () => (/* binding */ bech32CharacterSetIndex),\n/* harmony export */ \"bech32PaddedToBin\": () => (/* binding */ bech32PaddedToBin),\n/* harmony export */ \"binToBech32Padded\": () => (/* binding */ binToBech32Padded),\n/* harmony export */ \"decodeBech32\": () => (/* binding */ decodeBech32),\n/* harmony export */ \"encodeBech32\": () => (/* binding */ encodeBech32),\n/* harmony export */ \"extractNonBech32Characters\": () => (/* binding */ extractNonBech32Characters),\n/* harmony export */ \"isBech32CharacterSet\": () => (/* binding */ isBech32CharacterSet),\n/* harmony export */ \"regroupBits\": () => (/* binding */ regroupBits)\n/* harmony export */ });\n/**\n * The list of 32 symbols used in Bech32 encoding.\n */\n// cspell: disable-next-line\nconst bech32CharacterSet = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';\n/**\n * An object mapping each of the 32 symbols used in Bech32 encoding to their respective index in the character set.\n */\n// prettier-ignore\nconst bech32CharacterSetIndex = { q: 0, p: 1, z: 2, r: 3, y: 4, '9': 5, x: 6, '8': 7, g: 8, f: 9, '2': 10, t: 11, v: 12, d: 13, w: 14, '0': 15, s: 16, '3': 17, j: 18, n: 19, '5': 20, '4': 21, k: 22, h: 23, c: 24, e: 25, '6': 26, m: 27, u: 28, a: 29, '7': 30, l: 31 }; // eslint-disable-line sort-keys, @typescript-eslint/naming-convention\nvar BitRegroupingError;\n(function (BitRegroupingError) {\n BitRegroupingError[\"integerOutOfRange\"] = \"An integer provided in the source array is out of the range of the specified source word length.\";\n BitRegroupingError[\"hasDisallowedPadding\"] = \"Encountered padding when padding was disallowed.\";\n BitRegroupingError[\"requiresDisallowedPadding\"] = \"Encoding requires padding while padding is disallowed.\";\n})(BitRegroupingError || (BitRegroupingError = {}));\n/* eslint-disable functional/no-let, no-bitwise, functional/no-expression-statements, functional/no-conditional-statements, complexity */\n/**\n * Given an array of integers, regroup bits from `sourceWordLength` to\n * `resultWordLength`, returning a new array of integers between 0 and\n * toWordLength^2.\n *\n * Note, if `bin` is within the range of `sourceWordLength` and `padding` is\n * `true`, this method will never error.\n *\n * A.K.A. `convertbits`\n */\n// Derived from: https://github.com/sipa/bech32\nconst regroupBits = ({ bin, sourceWordLength, resultWordLength, allowPadding = true, }) => {\n let accumulator = 0;\n let bits = 0;\n const result = [];\n const maxResultInt = (1 << resultWordLength) - 1;\n // eslint-disable-next-line functional/no-loop-statements, @typescript-eslint/prefer-for-of, no-plusplus\n for (let p = 0; p < bin.length; ++p) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const value = bin[p];\n if (value < 0 || value >> sourceWordLength !== 0) {\n return BitRegroupingError.integerOutOfRange;\n }\n accumulator = (accumulator << sourceWordLength) | value;\n bits += sourceWordLength;\n // eslint-disable-next-line functional/no-loop-statements\n while (bits >= resultWordLength) {\n bits -= resultWordLength;\n // eslint-disable-next-line functional/immutable-data\n result.push((accumulator >> bits) & maxResultInt);\n }\n }\n if (allowPadding) {\n if (bits > 0) {\n // eslint-disable-next-line functional/immutable-data\n result.push((accumulator << (resultWordLength - bits)) & maxResultInt);\n }\n }\n else if (bits >= sourceWordLength) {\n return BitRegroupingError.hasDisallowedPadding;\n }\n else if (((accumulator << (resultWordLength - bits)) & maxResultInt) > 0) {\n return BitRegroupingError.requiresDisallowedPadding;\n }\n return result;\n};\n/* eslint-enable functional/no-let, no-bitwise, functional/no-expression-statements, functional/no-conditional-statements, complexity */\n/**\n * Encode an array of numbers as a base32 string using the Bech32 character set.\n *\n * Note, this method always completes. For a valid result, all items in\n * `base32IntegerArray` must be between `0` and `32`. To prepare another array\n * type for encoding, see {@link regroupBits}.\n *\n * For the reverse, see {@link decodeBech32}.\n *\n * @param base32IntegerArray - the array of 5-bit integers to encode\n */\nconst encodeBech32 = (base32IntegerArray) => {\n // eslint-disable-next-line functional/no-let\n let result = '';\n // eslint-disable-next-line @typescript-eslint/prefer-for-of, functional/no-let, functional/no-loop-statements, no-plusplus\n for (let i = 0; i < base32IntegerArray.length; i++) {\n // eslint-disable-next-line functional/no-expression-statements, @typescript-eslint/no-non-null-assertion\n result += bech32CharacterSet[base32IntegerArray[i]];\n }\n return result;\n};\n/**\n * Decode a Bech32-encoded string into an array of 5-bit integers.\n *\n * Note, this method always completes. If `validBech32` is not valid bech32,\n * an incorrect result will be returned. If `validBech32` is potentially\n * malformed, check it with {@link isBech32CharacterSet} before calling\n * this method.\n *\n * For the reverse, see {@link encodeBech32}.\n *\n * @param validBech32 - the bech32-encoded string to decode\n */\nconst decodeBech32 = (validBech32) => {\n const result = [];\n // eslint-disable-next-line @typescript-eslint/prefer-for-of, functional/no-let, functional/no-loop-statements, no-plusplus\n for (let i = 0; i < validBech32.length; i++) {\n // eslint-disable-next-line functional/no-expression-statements, functional/immutable-data\n result.push(bech32CharacterSetIndex[validBech32[i]]);\n }\n return result;\n};\nconst nonBech32Characters = new RegExp(`[^${bech32CharacterSet}]`, 'u');\nconst base32WordLength = 5;\nconst base256WordLength = 8;\n/**\n * Validate that a string uses only characters from the bech32 character set.\n *\n * @param maybeBech32 - a string to test for valid Bech32 encoding\n */\nconst isBech32CharacterSet = (maybeBech32) => !nonBech32Characters.test(maybeBech32);\n/**\n * Returns an array of the non-Bech32 characters in the provided string; if all\n * characters are valid, an empty array is returned.\n * @param maybeBech32 - the string to test\n */\nconst extractNonBech32Characters = (maybeBech32) => [\n ...new Set([...maybeBech32].filter((character) => !bech32CharacterSet.includes(character))),\n];\nvar Bech32DecodingError;\n(function (Bech32DecodingError) {\n Bech32DecodingError[\"notBech32CharacterSet\"] = \"Bech32 decoding error: input contains characters outside of the Bech32 character set.\";\n})(Bech32DecodingError || (Bech32DecodingError = {}));\n/**\n * Convert a padded bech32-encoded string (without checksum) to a Uint8Array,\n * removing the padding. If the string is not valid Bech32, or if the array of\n * 5-bit integers would require padding to be regrouped into 8-bit bytes, this\n * method returns an error message.\n *\n * For the reverse, see {@link binToBech32Padded}.\n *\n * @param bech32Padded - the padded bech32-encoded string to decode\n */\nconst bech32PaddedToBin = (bech32Padded) => {\n const result = isBech32CharacterSet(bech32Padded)\n ? regroupBits({\n allowPadding: false,\n bin: decodeBech32(bech32Padded),\n resultWordLength: base256WordLength,\n sourceWordLength: base32WordLength,\n })\n : Bech32DecodingError.notBech32CharacterSet;\n return typeof result === 'string' ? result : Uint8Array.from(result);\n};\n/**\n * Convert a Uint8Array to a padded bech32-encoded string (without a checksum),\n * adding padding bits as necessary to convert all bytes to 5-bit integers.\n *\n * For the reverse, see {@link bech32PaddedToBin}.\n *\n * @param bytes - the Uint8Array to bech32 encode\n */\nconst binToBech32Padded = (bytes) => encodeBech32(regroupBits({\n bin: bytes,\n resultWordLength: base32WordLength,\n sourceWordLength: base256WordLength,\n}));\n//# sourceMappingURL=bech32.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/address/bech32.js?");
|
|
63
63
|
|
|
64
64
|
/***/ }),
|
|
65
65
|
|
|
@@ -70,7 +70,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
70
70
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
71
71
|
|
|
72
72
|
"use strict";
|
|
73
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"CashAddressNetworkPrefix\": () => (/* binding */ CashAddressNetworkPrefix),\n/* harmony export */ \"CashAddressType\": () => (/* binding */ CashAddressType),\n/* harmony export */ \"decodeCashAddress\": () => (/* binding */ decodeCashAddress),\n/* harmony export */ \"encodeCashAddress\": () => (/* binding */ encodeCashAddress)\n/* harmony export */ });\n/* unused harmony exports CashAddressVersionByte, CashAddressTypeBits, cashAddressTypeToTypeBits, cashAddressTypeBitsToType, cashAddressLengthBitsToLength, cashAddressLengthToLengthBits, encodeCashAddressVersionByte, CashAddressVersionByteDecodingError, decodeCashAddressVersionByte, maskCashAddressPrefix, cashAddressPolynomialModulo, cashAddressChecksumToUint5Array, CashAddressFormatEncodingError, CashAddressEncodingError, encodeCashAddressFormat, isValidCashAddressPayloadLength, encodeCashAddressNonStandard, CashAddressDecodingError, decodeCashAddressFormat, decodeCashAddressNonStandard, decodeCashAddressFormatWithoutPrefix, cashAddressPolynomialToCashAddress, CashAddressFormatCorrectionError, attemptCashAddressFormatErrorCorrection */\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/error.js\");\n/* harmony import */ var _bech32_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bech32.js */ \"../../node_modules/@bitauth/libauth/build/lib/address/bech32.js\");\n\n\nvar CashAddressNetworkPrefix;\n(function (CashAddressNetworkPrefix) {\n CashAddressNetworkPrefix[\"mainnet\"] = \"bitcoincash\";\n CashAddressNetworkPrefix[\"testnet\"] = \"bchtest\";\n CashAddressNetworkPrefix[\"regtest\"] = \"bchreg\";\n})(CashAddressNetworkPrefix || (CashAddressNetworkPrefix = {}));\n/**\n * The CashAddress specification standardizes the format of the version byte:\n * - Most significant bit: reserved, must be `0`\n * - next 4 bits: Address Type\n * - 3 least significant bits: Payload Length\n *\n * Two Address Type values are currently standardized:\n * - 0 (`0b0000`): P2PKH\n * - 1 (`0b0001`): P2SH\n *\n * And two are proposed by `CHIP-2022-02-CashTokens`:\n * - 2 (`0b0010`): P2PKH + Token Support\n * - 3 (`0b0011`): P2SH + Token Support\n *\n * The CashAddress specification standardizes expected payload length using\n * {@link CashAddressLengthBits}. Currently, two length bit values are in use by\n * standard CashAddress types:\n * - `0` (`0b000`): 20 bytes (in use by `p2pkh` and `p2sh20`)\n * - `3` (`0b011`): 32 bytes (in use by `p2sh32`)\n */\nvar CashAddressVersionByte;\n(function (CashAddressVersionByte) {\n /**\n * Pay to Public Key Hash (P2PKH): `0b00000000`\n *\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0000` (P2PKH)\n * - Length bits: `000` (20 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2pkh\"] = 0] = \"p2pkh\";\n /**\n * 20-byte Pay to Script Hash (P2SH20): `0b00001000`\n *\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0001` (P2SH)\n * - Length bits: `000` (20 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2sh20\"] = 8] = \"p2sh20\";\n /**\n * 32-byte Pay to Script Hash (P2SH20): `0b00001000`\n *\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0001` (P2SH)\n * - Length bits: `011` (32 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2sh32\"] = 11] = \"p2sh32\";\n /**\n * Pay to Public Key Hash (P2PKH) with token support: `0b00010000`\n *\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0010` (P2PKH + Tokens)\n * - Length bits: `000` (20 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2pkhWithTokens\"] = 16] = \"p2pkhWithTokens\";\n /**\n * 20-byte Pay to Script Hash (P2SH20) with token support: `0b00011000`\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0011` (P2SH + Tokens)\n * - Length bits: `000` (20 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2sh20WithTokens\"] = 24] = \"p2sh20WithTokens\";\n /**\n * 32-byte Pay to Script Hash (P2SH32) with token support: `0b00011011`\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0011` (P2SH + Tokens)\n * - Length bits: `011` (32 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2sh32WithTokens\"] = 27] = \"p2sh32WithTokens\";\n})(CashAddressVersionByte || (CashAddressVersionByte = {}));\n/**\n * The address types currently defined in the CashAddress specification. See\n * also: {@link CashAddressVersionByte}.\n */\nvar CashAddressType;\n(function (CashAddressType) {\n /**\n * Pay to Public Key Hash (P2PKH): `0b0000`\n */\n CashAddressType[\"p2pkh\"] = \"p2pkh\";\n /**\n * Pay to Script Hash (P2SH): `0b0001`\n *\n * Note, this type is used for both {@link CashAddressVersionByte.p2sh20} and\n * {@link CashAddressVersionByte.p2sh32}.\n */\n CashAddressType[\"p2sh\"] = \"p2sh\";\n /**\n * Pay to Public Key Hash (P2PKH) with token support: `0b0010`\n */\n CashAddressType[\"p2pkhWithTokens\"] = \"p2pkhWithTokens\";\n /**\n * Pay to Script Hash (P2SH) with token support: `0b0011`\n *\n * Note, this type is used for both\n * {@link CashAddressVersionByte.p2sh20WithTokens} and\n * {@link CashAddressVersionByte.p2sh32WithTokens}.\n */\n CashAddressType[\"p2shWithTokens\"] = \"p2shWithTokens\";\n})(CashAddressType || (CashAddressType = {}));\n/**\n * The address type bits currently defined in the CashAddress specification.\n * These map to: {@link CashAddressType}.\n */\nvar CashAddressTypeBits;\n(function (CashAddressTypeBits) {\n /**\n * Pay to Public Key Hash (P2PKH)\n */\n CashAddressTypeBits[CashAddressTypeBits[\"p2pkh\"] = 0] = \"p2pkh\";\n /**\n * Pay to Script Hash (P2SH)\n */\n CashAddressTypeBits[CashAddressTypeBits[\"p2sh\"] = 1] = \"p2sh\";\n /**\n * Pay to Public Key Hash (P2PKH) with token support\n */\n CashAddressTypeBits[CashAddressTypeBits[\"p2pkhWithTokens\"] = 2] = \"p2pkhWithTokens\";\n /**\n * Pay to Script Hash (P2SH) with token support\n */\n CashAddressTypeBits[CashAddressTypeBits[\"p2shWithTokens\"] = 3] = \"p2shWithTokens\";\n})(CashAddressTypeBits || (CashAddressTypeBits = {}));\nconst cashAddressTypeToTypeBits = {\n [CashAddressType.p2pkh]: CashAddressTypeBits.p2pkh,\n [CashAddressType.p2sh]: CashAddressTypeBits.p2sh,\n [CashAddressType.p2pkhWithTokens]: CashAddressTypeBits.p2pkhWithTokens,\n [CashAddressType.p2shWithTokens]: CashAddressTypeBits.p2shWithTokens,\n};\nconst cashAddressTypeBitsToType = {\n [CashAddressTypeBits.p2pkh]: CashAddressType.p2pkh,\n [CashAddressTypeBits.p2sh]: CashAddressType.p2sh,\n [CashAddressTypeBits.p2pkhWithTokens]: CashAddressType.p2pkhWithTokens,\n [CashAddressTypeBits.p2shWithTokens]: CashAddressType.p2shWithTokens,\n};\n/* eslint-disable @typescript-eslint/naming-convention */\nconst cashAddressLengthBitsToLength = {\n 0: 20,\n 1: 24,\n 2: 28,\n 3: 32,\n 4: 40,\n 5: 48,\n 6: 56,\n 7: 64,\n};\nconst cashAddressLengthToLengthBits = {\n 20: 0,\n 24: 1,\n 28: 2,\n 32: 3,\n 40: 4,\n 48: 5,\n 56: 6,\n 64: 7,\n};\n/**\n * Encode a CashAddress version byte for the given address type and payload\n * length. See {@link CashAddressVersionByte} for more information.\n *\n * The `type` parameter must be a number between `0` and `15`, and `bitLength`\n * must be one of the standardized lengths. To use the contents of a variable,\n * cast it to {@link CashAddressType} or\n * {@link CashAddressSupportedLength} respectively,\n * e.g.:\n * ```ts\n * const type = 3 as CashAddressType;\n * const length = 20 as CashAddressSupportedLength;\n * getCashAddressVersionByte(type, length);\n * ```\n *\n * For the reverse, see {@link decodeCashAddressVersionByte}.\n *\n * @param typeBits - The address type bit of the payload being encoded.\n * @param length - The length of the payload being encoded.\n */\nconst encodeCashAddressVersionByte = (typeBits, length) => \n// eslint-disable-next-line no-bitwise\n(typeBits << 3 /* Constants.cashAddressTypeBitsShift */) |\n cashAddressLengthToLengthBits[length];\nvar CashAddressVersionByteDecodingError;\n(function (CashAddressVersionByteDecodingError) {\n CashAddressVersionByteDecodingError[\"reservedBitSet\"] = \"Reserved bit is set.\";\n})(CashAddressVersionByteDecodingError || (CashAddressVersionByteDecodingError = {}));\n/**\n * Decode a CashAddress version byte. For a list of known versions, see\n * {@link CashAddressVersionByte}.\n *\n * For the reverse, see {@link encodeCashAddressVersionByte}.\n *\n * @param version - The version byte to decode.\n */\nconst decodeCashAddressVersionByte = (version) => \n// eslint-disable-next-line no-negated-condition, no-bitwise\n(version & 128 /* Constants.cashAddressReservedBitMask */) !== 0\n ? CashAddressVersionByteDecodingError.reservedBitSet\n : {\n length: cashAddressLengthBitsToLength[\n // eslint-disable-next-line no-bitwise\n (version &\n 7 /* Constants.cashAddressLengthBits */)],\n typeBits: \n // eslint-disable-next-line no-bitwise\n (version >>> 3 /* Constants.cashAddressTypeBitsShift */) &\n 15 /* Constants.cashAddressTypeBits */,\n };\n/**\n * Convert a string into an array of 5-bit numbers, representing the characters\n * in a case-insensitive way.\n *\n * @param prefix - The prefix to mask.\n */\nconst maskCashAddressPrefix = (prefix) => {\n const result = [];\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements, no-plusplus\n for (let i = 0; i < prefix.length; i++) {\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, functional/immutable-data\n result.push(prefix.charCodeAt(i) & 31 /* Constants.asciiCaseInsensitiveBits */);\n }\n return result;\n};\n// prettier-ignore\nconst bech32GeneratorMostSignificantByte = [0x98, 0x79, 0xf3, 0xae, 0x1e]; // eslint-disable-line @typescript-eslint/no-magic-numbers\n// prettier-ignore\nconst bech32GeneratorRemainingBytes = [0xf2bc8e61, 0xb76d99e2, 0x3e5fb3c4, 0x2eabe2a8, 0x4f43e470]; // eslint-disable-line @typescript-eslint/no-magic-numbers\n/**\n * Perform the CashAddress polynomial modulo operation, which is based on the\n * Bech32 polynomial modulo operation, but the returned checksum is 40 bits,\n * rather than 30.\n *\n * A.K.A. `PolyMod`\n *\n * @remarks\n * Notes from C++ implementation:\n * This function will compute what 8 5-bit values to XOR into the last 8 input\n * values, in order to make the checksum 0. These 8 values are packed together\n * in a single 40-bit integer. The higher bits correspond to earlier values.\n *\n * The input is interpreted as a list of coefficients of a polynomial over F\n * = GF(32), with an implicit 1 in front. If the input is [v0,v1,v2,v3,v4],\n * that polynomial is v(x) = 1*x^5 + v0*x^4 + v1*x^3 + v2*x^2 + v3*x + v4.\n * The implicit 1 guarantees that [v0,v1,v2,...] has a distinct checksum\n * from [0,v0,v1,v2,...].\n *\n * The output is a 40-bit integer whose 5-bit groups are the coefficients of\n * the remainder of v(x) mod g(x), where g(x) is the cashaddr generator, x^8\n * + [19]*x^7 + [3]*x^6 + [25]*x^5 + [11]*x^4 + [25]*x^3 + [3]*x^2 + [19]*x\n * + [1]. g(x) is chosen in such a way that the resulting code is a BCH\n * code, guaranteeing detection of up to 4 errors within a window of 1025\n * characters. Among the various possible BCH codes, one was selected to in\n * fact guarantee detection of up to 5 errors within a window of 160\n * characters and 6 errors within a window of 126 characters. In addition,\n * the code guarantee the detection of a burst of up to 8 errors.\n *\n * Note that the coefficients are elements of GF(32), here represented as\n * decimal numbers between []. In this finite field, addition is just XOR of\n * the corresponding numbers. For example, [27] + [13] = [27 ^ 13] = [22].\n * Multiplication is more complicated, and requires treating the bits of\n * values themselves as coefficients of a polynomial over a smaller field,\n * GF(2), and multiplying those polynomials mod a^5 + a^3 + 1. For example,\n * [5] * [26] = (a^2 + 1) * (a^4 + a^3 + a) = (a^4 + a^3 + a) * a^2 + (a^4 +\n * a^3 + a) = a^6 + a^5 + a^4 + a = a^3 + 1 (mod a^5 + a^3 + 1) = [9].\n *\n * During the course of the loop below, `c` contains the bit-packed\n * coefficients of the polynomial constructed from just the values of v that\n * were processed so far, mod g(x). In the above example, `c` initially\n * corresponds to 1 mod (x), and after processing 2 inputs of v, it\n * corresponds to x^2 + v0*x + v1 mod g(x). As 1 mod g(x) = 1, that is the\n * starting value for `c`.\n *\n * @param v - Array of 5-bit integers over which the checksum is to be computed.\n */\n// Derived from the `bitcore-lib-cash` implementation (does not require BigInt): https://github.com/bitpay/bitcore\nconst cashAddressPolynomialModulo = (v) => {\n /* eslint-disable functional/no-let, functional/no-loop-statements, functional/no-expression-statements, no-bitwise, @typescript-eslint/no-magic-numbers */\n let mostSignificantByte = 0;\n let lowerBytes = 1;\n let c = 0;\n // eslint-disable-next-line @typescript-eslint/prefer-for-of, no-plusplus\n for (let j = 0; j < v.length; j++) {\n c = mostSignificantByte >>> 3;\n mostSignificantByte &= 0x07;\n mostSignificantByte <<= 5;\n mostSignificantByte |= lowerBytes >>> 27;\n lowerBytes &= 0x07ffffff;\n lowerBytes <<= 5;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n lowerBytes ^= v[j];\n // eslint-disable-next-line no-plusplus\n for (let i = 0; i < bech32GeneratorMostSignificantByte.length; ++i) {\n // eslint-disable-next-line functional/no-conditional-statements\n if (c & (1 << i)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n mostSignificantByte ^= bech32GeneratorMostSignificantByte[i];\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n lowerBytes ^= bech32GeneratorRemainingBytes[i];\n }\n }\n }\n lowerBytes ^= 1;\n // eslint-disable-next-line functional/no-conditional-statements\n if (lowerBytes < 0) {\n lowerBytes ^= 1 << 31;\n lowerBytes += (1 << 30) * 2;\n }\n return mostSignificantByte * (1 << 30) * 4 + lowerBytes;\n /* eslint-enable functional/no-let, functional/no-loop-statements, functional/no-expression-statements, no-bitwise, @typescript-eslint/no-magic-numbers */\n};\n/**\n * Convert the checksum returned by {@link cashAddressPolynomialModulo} to an\n * array of 5-bit positive integers that can be Base32 encoded.\n * @param checksum - A 40 bit checksum returned by\n * {@link cashAddressPolynomialModulo}.\n */\nconst cashAddressChecksumToUint5Array = (checksum) => {\n const result = [];\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements, no-plusplus\n for (let i = 0; i < 8 /* Constants.base256WordLength */; ++i) {\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, @typescript-eslint/no-magic-numbers, functional/immutable-data\n result.push(checksum & 31);\n // eslint-disable-next-line functional/no-expression-statements, @typescript-eslint/no-magic-numbers, no-param-reassign\n checksum /= 32;\n }\n // eslint-disable-next-line functional/immutable-data\n return result.reverse();\n};\nvar CashAddressFormatEncodingError;\n(function (CashAddressFormatEncodingError) {\n CashAddressFormatEncodingError[\"excessiveVersion\"] = \"CashAddress format encoding error: version must be 255 or less.\";\n})(CashAddressFormatEncodingError || (CashAddressFormatEncodingError = {}));\nvar CashAddressEncodingError;\n(function (CashAddressEncodingError) {\n CashAddressEncodingError[\"noTypeBitsValueStandardizedForP2pk\"] = \"CashAddress encoding error: no CashAddress type bit has been standardized for P2PK locking bytecode.\";\n CashAddressEncodingError[\"unsupportedPayloadLength\"] = \"CashAddress encoding error: a payload of this length can not be encoded as a valid CashAddress.\";\n CashAddressEncodingError[\"unknownLockingBytecodeType\"] = \"CashAddress encoding error: unknown locking bytecode type.\";\n})(CashAddressEncodingError || (CashAddressEncodingError = {}));\n/**\n * Encode a payload as a CashAddress-like string using the CashAddress format.\n *\n * Note that this function defaults to throwing encoding errors. To handle\n * errors in a type-safe way, set `throwErrors` to `false`.\n *\n * For the reverse, see {@link decodeCashAddressFormat}.\n *\n * To encode a standard CashAddress, use {@link encodeCashAddress}.\n */\nconst encodeCashAddressFormat = ({ payload, prefix, throwErrors = true, version, }) => {\n const checksum40BitPlaceholder = [0, 0, 0, 0, 0, 0, 0, 0];\n if (version > 255 /* Constants.maximumCashAddressFormatVersion */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressFormatEncodingError.excessiveVersion, `Version: ${version}.`, throwErrors);\n }\n const payloadContents = (0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.regroupBits)({\n bin: Uint8Array.from([version, ...payload]),\n resultWordLength: 5 /* Constants.base32WordLength */,\n sourceWordLength: 8 /* Constants.base256WordLength */,\n });\n const checksumContents = [\n ...maskCashAddressPrefix(prefix),\n 0 /* Constants.payloadSeparator */,\n ...payloadContents,\n ...checksum40BitPlaceholder,\n ];\n const checksum = cashAddressPolynomialModulo(checksumContents);\n const encoded = [\n ...payloadContents,\n ...cashAddressChecksumToUint5Array(checksum),\n ];\n const address = `${prefix}:${(0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.encodeBech32)(encoded)}`;\n return { address };\n};\nconst isValidCashAddressPayloadLength = (length) => cashAddressLengthToLengthBits[length] !== undefined;\n/**\n * Encode a payload as a CashAddress. This function is similar to\n * {@link encodeCashAddress} but supports non-standard `prefix`es and `type`s.\n *\n * Note that this function defaults to throwing encoding errors. To handle\n * errors in a type-safe way, set `throwErrors` to `false`.\n *\n * For other address standards that closely follow the CashAddress\n * specification (but have alternative version byte requirements), use\n * {@link encodeCashAddressFormat}.\n *\n * For the reverse, see {@link decodeCashAddressNonStandard}.\n */\nconst encodeCashAddressNonStandard = ({ payload, prefix, throwErrors = true, typeBits, }) => {\n const { length } = payload;\n if (!isValidCashAddressPayloadLength(length)) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressEncodingError.unsupportedPayloadLength, `Payload length: ${length}.`, throwErrors);\n }\n return encodeCashAddressFormat({\n payload,\n prefix,\n throwErrors,\n version: encodeCashAddressVersionByte(typeBits, length),\n });\n};\n/**\n * Encode a payload as a CashAddress.\n *\n * Note that this function defaults to throwing encoding errors. To handle\n * errors in a type-safe way, set `throwErrors` to `false`.\n *\n * To encode a CashAddress with a custom/unknown prefix or type bit, see\n * {@link encodeCashAddressNonStandard}. For other address standards that\n * closely follow the CashAddress specification (but have alternative version\n * byte requirements), use {@link encodeCashAddressFormat}.\n *\n * To decode a CashAddress, use {@link decodeCashAddress}.\n *\n * @returns If `throwErrors` is `true`, the CashAddress as a `string`. If\n * `throwErrors` is `false`, a {@link CashAddressResult} on successful encoding\n * or an error message as a `string`.\n */\nconst encodeCashAddress = ({ payload, prefix = 'bitcoincash', throwErrors = true, type, }) => encodeCashAddressNonStandard({\n payload,\n prefix,\n throwErrors,\n typeBits: cashAddressTypeToTypeBits[type],\n});\nvar CashAddressDecodingError;\n(function (CashAddressDecodingError) {\n CashAddressDecodingError[\"improperPadding\"] = \"CashAddress decoding error: the payload is improperly padded.\";\n CashAddressDecodingError[\"invalidCharacters\"] = \"CashAddress decoding error: the payload contains unexpected characters.\";\n CashAddressDecodingError[\"invalidChecksum\"] = \"CashAddress decoding error: invalid checksum - please review the address for errors.\";\n CashAddressDecodingError[\"invalidFormat\"] = \"CashAddress decoding error: CashAddresses should be of the form \\\"prefix:payload\\\".\";\n CashAddressDecodingError[\"mismatchedPayloadLength\"] = \"CashAddress decoding error: mismatched payload length for specified address version.\";\n CashAddressDecodingError[\"reservedBit\"] = \"CashAddress decoding error: unknown CashAddress version, reserved bit set.\";\n CashAddressDecodingError[\"unknownAddressType\"] = \"CashAddress decoding error: unknown CashAddress type.\";\n})(CashAddressDecodingError || (CashAddressDecodingError = {}));\n/**\n * Decode and validate a string using the CashAddress format. This is more\n * lenient than {@link decodeCashAddress}, which also validates the contents of\n * the version byte.\n *\n * Note, this method requires `address` to include a network prefix. To\n * decode a string with an unknown prefix, try\n * {@link decodeCashAddressFormatWithoutPrefix}.\n *\n * For the reverse, see {@link encodeCashAddressFormat}.\n *\n * @param address - The CashAddress-like string to decode.\n */\n// eslint-disable-next-line complexity\nconst decodeCashAddressFormat = (address) => {\n const parts = address.toLowerCase().split(':');\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n if (parts.length !== 2 || parts[0] === '' || parts[1] === '') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.invalidFormat, `Provided address: \"${address}\".`);\n }\n const [prefix, payload] = parts;\n if (!(0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.isBech32CharacterSet)(payload)) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.invalidCharacters, `Invalid characters: ${(0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.extractNonBech32Characters)(payload).join(', ')}.`);\n }\n const decodedPayload = (0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.decodeBech32)(payload);\n const polynomial = [\n ...maskCashAddressPrefix(prefix),\n 0 /* Constants.payloadSeparator */,\n ...decodedPayload,\n ];\n if (cashAddressPolynomialModulo(polynomial) !== 0) {\n return CashAddressDecodingError.invalidChecksum;\n }\n const checksum40BitPlaceholderLength = 8;\n const payloadContents = (0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.regroupBits)({\n allowPadding: false,\n bin: decodedPayload.slice(0, -checksum40BitPlaceholderLength),\n resultWordLength: 8 /* Constants.base256WordLength */,\n sourceWordLength: 5 /* Constants.base32WordLength */,\n });\n if (typeof payloadContents === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.improperPadding, payloadContents);\n }\n const [version, ...contents] = payloadContents;\n const result = Uint8Array.from(contents);\n return { payload: result, prefix, version };\n};\n/**\n * Decode and validate a CashAddress, strictly checking the version byte\n * according to the CashAddress specification. This is important for error\n * detection in CashAddresses.\n *\n * This function is similar to {@link decodeCashAddress} but supports\n * non-standard `type`s.\n *\n * For other address-like standards that closely follow the CashAddress\n * specification (but have alternative version byte requirements), use\n * {@link decodeCashAddressFormat}.\n *\n * Note, this method requires that CashAddresses include a network prefix. To\n * decode an address with an unknown prefix, try\n * {@link decodeCashAddressFormatWithoutPrefix}.\n *\n * For the reverse, see {@link encodeCashAddressNonStandard}.\n *\n * @param address - The CashAddress to decode.\n */\nconst decodeCashAddressNonStandard = (address) => {\n const decoded = decodeCashAddressFormat(address);\n if (typeof decoded === 'string') {\n return decoded;\n }\n const info = decodeCashAddressVersionByte(decoded.version);\n if (info === CashAddressVersionByteDecodingError.reservedBitSet) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.reservedBit);\n }\n if (decoded.payload.length !== info.length) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.mismatchedPayloadLength, `Version byte indicated a byte length of ${info.length}, but the payload is ${decoded.payload.length} bytes.`);\n }\n return {\n payload: decoded.payload,\n prefix: decoded.prefix,\n typeBits: info.typeBits,\n };\n};\n/**\n * Decode and validate a CashAddress, strictly checking the version byte\n * according to the CashAddress specification. This is important for error\n * detection in CashAddresses.\n *\n * To decode CashAddresses with non-standard `type`s,\n * see {@link decodeCashAddressNonStandard}.\n *\n * For other address-like standards that closely follow the CashAddress\n * specification (but have alternative version byte requirements), use\n * {@link decodeCashAddressFormat}.\n *\n * Note, this method requires that CashAddresses include a network prefix. To\n * decode an address with an unknown prefix, try\n * {@link decodeCashAddressFormatWithoutPrefix}.\n *\n * To encode a CashAddress, use {@link encodeCashAddress}.\n *\n * @param address - The CashAddress to decode.\n */\nconst decodeCashAddress = (address) => {\n const decoded = decodeCashAddressNonStandard(address);\n if (typeof decoded === 'string') {\n return decoded;\n }\n const type = cashAddressTypeBitsToType[decoded.typeBits];\n if (type === undefined) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.unknownAddressType, `Type bit value: ${decoded.typeBits}.`);\n }\n return {\n payload: decoded.payload,\n prefix: decoded.prefix,\n type,\n };\n};\n/**\n * Attempt to decode and validate a CashAddress against a list of possible\n * prefixes. If the correct prefix is known, use {@link decodeCashAddress}.\n *\n * @param address - The CashAddress to decode.\n * @param possiblePrefixes - The network prefixes to try.\n */\n// decodeCashAddressWithoutPrefix\nconst decodeCashAddressFormatWithoutPrefix = (address, possiblePrefixes = [\n CashAddressNetworkPrefix.mainnet,\n CashAddressNetworkPrefix.testnet,\n CashAddressNetworkPrefix.regtest,\n]) => {\n // eslint-disable-next-line functional/no-loop-statements\n for (const prefix of possiblePrefixes) {\n const attempt = decodeCashAddressFormat(`${prefix}:${address}`);\n if (attempt !== CashAddressDecodingError.invalidChecksum) {\n return attempt;\n }\n }\n return CashAddressDecodingError.invalidChecksum;\n};\n/**\n * Convert a CashAddress polynomial to CashAddress string format.\n *\n * @remarks\n * CashAddress polynomials take the form:\n *\n * `[lowest 5 bits of each prefix character] 0 [payload + checksum]`\n *\n * This method remaps the 5-bit integers in the prefix location to the matching\n * ASCII lowercase characters, replaces the separator with `:`, and then Bech32\n * encodes the remaining payload and checksum.\n *\n * @param polynomial - An array of 5-bit integers representing the terms of a\n * CashAddress polynomial.\n */\nconst cashAddressPolynomialToCashAddress = (polynomial) => {\n const separatorPosition = polynomial.indexOf(0);\n const prefix = polynomial\n .slice(0, separatorPosition)\n .map((integer) => String.fromCharCode(96 /* Constants.asciiLowerCaseStart */ + integer))\n .join('');\n const contents = (0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.encodeBech32)(polynomial.slice(separatorPosition + 1));\n return `${prefix}:${contents}`;\n};\nvar CashAddressFormatCorrectionError;\n(function (CashAddressFormatCorrectionError) {\n CashAddressFormatCorrectionError[\"tooManyErrors\"] = \"CashAddress format correction error: this address cannot be corrected as it contains more than 2 errors.\";\n})(CashAddressFormatCorrectionError || (CashAddressFormatCorrectionError = {}));\n/**\n * Attempt to correct up to 2 errors in a CashAddress-formatted string. The\n * string must include the prefix and only contain Bech32 characters.\n *\n * ## **CAUTION: improper use of this function can lead to lost funds.**\n *\n * Using error correction of CashAddress-like formats degrades error detection,\n * i.e. if the payload contains more than 2 errors, it is possible that error\n * correction will \"correct\" the payload to a plausible but incorrect payload.\n *\n * For applications which proceed to take irreversible actions – like sending a\n * payment – **naive usage of CashAddress Format error correction can lead to\n * vulnerabilities and lost funds**.\n *\n * It is strongly advised that this method only be used in fail-safe\n * applications (e.g. automatic correction of CashAddress-formatted private key\n * material during wallet recovery) or under explicit user control (e.g. \"The\n * address you entered is invalid, please review the highlighted characters and\n * try again.\").\n *\n * Only 2 substitution errors can be corrected (or a single swap) – deletions\n * and insertions (errors that shift many other characters and change the\n * length of the payload) can never be safely corrected and will produce an\n * error.\n *\n * Errors can be corrected in both the prefix and the payload, but attempting to\n * correct errors in the prefix prior to this method can improve results, e.g.\n * for `bchtest:qq2azmyyv6dtgczexyalqar70q036yund53jvfde0x`, the string\n * `bchtest:qq2azmyyv6dtgczexyalqar70q036yund53jvfdecc` can be corrected, while\n * `typo:qq2azmyyv6dtgczexyalqar70q036yund53jvfdecc` can not.\n *\n * @param address - The address or formatted data to correct.\n */\n// Derived from: https://github.com/deadalnix/cashaddressed\n// eslint-disable-next-line complexity\nconst attemptCashAddressFormatErrorCorrection = (address) => {\n const parts = address.toLowerCase().split(':');\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n if (parts.length !== 2 || parts[0] === '' || parts[1] === '') {\n return CashAddressDecodingError.invalidFormat;\n }\n const [prefix, payload] = parts;\n if (!(0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.isBech32CharacterSet)(payload)) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.invalidCharacters, `Invalid characters: ${(0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.extractNonBech32Characters)(payload).join(', ')}.`);\n }\n const decodedPayload = (0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.decodeBech32)(payload);\n const polynomial = [...maskCashAddressPrefix(prefix), 0, ...decodedPayload];\n const originalChecksum = cashAddressPolynomialModulo(polynomial);\n if (originalChecksum === 0) {\n return {\n address: cashAddressPolynomialToCashAddress(polynomial),\n corrections: [],\n };\n }\n const syndromes = {};\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements, no-plusplus\n for (let term = 0; term < polynomial.length; term++) {\n // eslint-disable-next-line functional/no-loop-statements\n for (\n // eslint-disable-next-line functional/no-let\n let errorVector = 1; errorVector < 32 /* Constants.finiteFieldOrder */; \n // eslint-disable-next-line no-plusplus\n errorVector++) {\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, @typescript-eslint/no-non-null-assertion\n polynomial[term] ^= errorVector;\n const correct = cashAddressPolynomialModulo(polynomial);\n if (correct === 0) {\n return {\n address: cashAddressPolynomialToCashAddress(polynomial),\n corrections: [term],\n };\n }\n // eslint-disable-next-line no-bitwise\n const s0 = (BigInt(correct) ^ BigInt(originalChecksum)).toString();\n // eslint-disable-next-line functional/no-expression-statements, functional/immutable-data\n syndromes[s0] = term * 32 /* Constants.finiteFieldOrder */ + errorVector;\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, @typescript-eslint/no-non-null-assertion\n polynomial[term] ^= errorVector;\n }\n }\n // eslint-disable-next-line functional/no-loop-statements\n for (const [s0, pe] of Object.entries(syndromes)) {\n // eslint-disable-next-line no-bitwise\n const s1Location = (BigInt(s0) ^ BigInt(originalChecksum)).toString();\n const s1 = syndromes[s1Location];\n if (s1 !== undefined) {\n const correctionIndex1 = Math.trunc(pe / 32 /* Constants.finiteFieldOrder */);\n const correctionIndex2 = Math.trunc(s1 / 32 /* Constants.finiteFieldOrder */);\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, @typescript-eslint/no-non-null-assertion\n polynomial[correctionIndex1] ^= pe % 32 /* Constants.finiteFieldOrder */;\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, @typescript-eslint/no-non-null-assertion\n polynomial[correctionIndex2] ^= s1 % 32 /* Constants.finiteFieldOrder */;\n return {\n address: cashAddressPolynomialToCashAddress(polynomial),\n corrections: [correctionIndex1, correctionIndex2].sort((a, b) => a - b),\n };\n }\n }\n return CashAddressFormatCorrectionError.tooManyErrors;\n};\n//# sourceMappingURL=cash-address.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/address/cash-address.js?");
|
|
73
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"CashAddressDecodingError\": () => (/* binding */ CashAddressDecodingError),\n/* harmony export */ \"CashAddressEncodingError\": () => (/* binding */ CashAddressEncodingError),\n/* harmony export */ \"CashAddressFormatCorrectionError\": () => (/* binding */ CashAddressFormatCorrectionError),\n/* harmony export */ \"CashAddressFormatEncodingError\": () => (/* binding */ CashAddressFormatEncodingError),\n/* harmony export */ \"CashAddressNetworkPrefix\": () => (/* binding */ CashAddressNetworkPrefix),\n/* harmony export */ \"CashAddressType\": () => (/* binding */ CashAddressType),\n/* harmony export */ \"CashAddressTypeBits\": () => (/* binding */ CashAddressTypeBits),\n/* harmony export */ \"CashAddressVersionByte\": () => (/* binding */ CashAddressVersionByte),\n/* harmony export */ \"CashAddressVersionByteDecodingError\": () => (/* binding */ CashAddressVersionByteDecodingError),\n/* harmony export */ \"attemptCashAddressFormatErrorCorrection\": () => (/* binding */ attemptCashAddressFormatErrorCorrection),\n/* harmony export */ \"cashAddressChecksumToUint5Array\": () => (/* binding */ cashAddressChecksumToUint5Array),\n/* harmony export */ \"cashAddressLengthBitsToLength\": () => (/* binding */ cashAddressLengthBitsToLength),\n/* harmony export */ \"cashAddressLengthToLengthBits\": () => (/* binding */ cashAddressLengthToLengthBits),\n/* harmony export */ \"cashAddressPolynomialModulo\": () => (/* binding */ cashAddressPolynomialModulo),\n/* harmony export */ \"cashAddressPolynomialToCashAddress\": () => (/* binding */ cashAddressPolynomialToCashAddress),\n/* harmony export */ \"cashAddressTypeBitsToType\": () => (/* binding */ cashAddressTypeBitsToType),\n/* harmony export */ \"cashAddressTypeToTypeBits\": () => (/* binding */ cashAddressTypeToTypeBits),\n/* harmony export */ \"decodeCashAddress\": () => (/* binding */ decodeCashAddress),\n/* harmony export */ \"decodeCashAddressFormat\": () => (/* binding */ decodeCashAddressFormat),\n/* harmony export */ \"decodeCashAddressFormatWithoutPrefix\": () => (/* binding */ decodeCashAddressFormatWithoutPrefix),\n/* harmony export */ \"decodeCashAddressNonStandard\": () => (/* binding */ decodeCashAddressNonStandard),\n/* harmony export */ \"decodeCashAddressVersionByte\": () => (/* binding */ decodeCashAddressVersionByte),\n/* harmony export */ \"encodeCashAddress\": () => (/* binding */ encodeCashAddress),\n/* harmony export */ \"encodeCashAddressFormat\": () => (/* binding */ encodeCashAddressFormat),\n/* harmony export */ \"encodeCashAddressNonStandard\": () => (/* binding */ encodeCashAddressNonStandard),\n/* harmony export */ \"encodeCashAddressVersionByte\": () => (/* binding */ encodeCashAddressVersionByte),\n/* harmony export */ \"isValidCashAddressPayloadLength\": () => (/* binding */ isValidCashAddressPayloadLength),\n/* harmony export */ \"maskCashAddressPrefix\": () => (/* binding */ maskCashAddressPrefix)\n/* harmony export */ });\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/error.js\");\n/* harmony import */ var _bech32_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bech32.js */ \"../../node_modules/@bitauth/libauth/build/lib/address/bech32.js\");\n\n\nvar CashAddressNetworkPrefix;\n(function (CashAddressNetworkPrefix) {\n CashAddressNetworkPrefix[\"mainnet\"] = \"bitcoincash\";\n CashAddressNetworkPrefix[\"testnet\"] = \"bchtest\";\n CashAddressNetworkPrefix[\"regtest\"] = \"bchreg\";\n})(CashAddressNetworkPrefix || (CashAddressNetworkPrefix = {}));\n/**\n * The CashAddress specification standardizes the format of the version byte:\n * - Most significant bit: reserved, must be `0`\n * - next 4 bits: Address Type\n * - 3 least significant bits: Payload Length\n *\n * Two Address Type values are currently standardized:\n * - 0 (`0b0000`): P2PKH\n * - 1 (`0b0001`): P2SH\n *\n * And two are proposed by `CHIP-2022-02-CashTokens`:\n * - 2 (`0b0010`): P2PKH + Token Support\n * - 3 (`0b0011`): P2SH + Token Support\n *\n * The CashAddress specification standardizes expected payload length using\n * {@link CashAddressLengthBits}. Currently, two length bit values are in use by\n * standard CashAddress types:\n * - `0` (`0b000`): 20 bytes (in use by `p2pkh` and `p2sh20`)\n * - `3` (`0b011`): 32 bytes (in use by `p2sh32`)\n */\nvar CashAddressVersionByte;\n(function (CashAddressVersionByte) {\n /**\n * Pay to Public Key Hash (P2PKH): `0b00000000`\n *\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0000` (P2PKH)\n * - Length bits: `000` (20 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2pkh\"] = 0] = \"p2pkh\";\n /**\n * 20-byte Pay to Script Hash (P2SH20): `0b00001000`\n *\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0001` (P2SH)\n * - Length bits: `000` (20 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2sh20\"] = 8] = \"p2sh20\";\n /**\n * 32-byte Pay to Script Hash (P2SH20): `0b00001000`\n *\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0001` (P2SH)\n * - Length bits: `011` (32 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2sh32\"] = 11] = \"p2sh32\";\n /**\n * Pay to Public Key Hash (P2PKH) with token support: `0b00010000`\n *\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0010` (P2PKH + Tokens)\n * - Length bits: `000` (20 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2pkhWithTokens\"] = 16] = \"p2pkhWithTokens\";\n /**\n * 20-byte Pay to Script Hash (P2SH20) with token support: `0b00011000`\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0011` (P2SH + Tokens)\n * - Length bits: `000` (20 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2sh20WithTokens\"] = 24] = \"p2sh20WithTokens\";\n /**\n * 32-byte Pay to Script Hash (P2SH32) with token support: `0b00011011`\n * - Most significant bit: `0` (reserved)\n * - Address Type bits: `0011` (P2SH + Tokens)\n * - Length bits: `011` (32 bytes)\n */\n CashAddressVersionByte[CashAddressVersionByte[\"p2sh32WithTokens\"] = 27] = \"p2sh32WithTokens\";\n})(CashAddressVersionByte || (CashAddressVersionByte = {}));\n/**\n * The address types currently defined in the CashAddress specification. See\n * also: {@link CashAddressVersionByte}.\n */\nvar CashAddressType;\n(function (CashAddressType) {\n /**\n * Pay to Public Key Hash (P2PKH): `0b0000`\n */\n CashAddressType[\"p2pkh\"] = \"p2pkh\";\n /**\n * Pay to Script Hash (P2SH): `0b0001`\n *\n * Note, this type is used for both {@link CashAddressVersionByte.p2sh20} and\n * {@link CashAddressVersionByte.p2sh32}.\n */\n CashAddressType[\"p2sh\"] = \"p2sh\";\n /**\n * Pay to Public Key Hash (P2PKH) with token support: `0b0010`\n */\n CashAddressType[\"p2pkhWithTokens\"] = \"p2pkhWithTokens\";\n /**\n * Pay to Script Hash (P2SH) with token support: `0b0011`\n *\n * Note, this type is used for both\n * {@link CashAddressVersionByte.p2sh20WithTokens} and\n * {@link CashAddressVersionByte.p2sh32WithTokens}.\n */\n CashAddressType[\"p2shWithTokens\"] = \"p2shWithTokens\";\n})(CashAddressType || (CashAddressType = {}));\n/**\n * The address type bits currently defined in the CashAddress specification.\n * These map to: {@link CashAddressType}.\n */\nvar CashAddressTypeBits;\n(function (CashAddressTypeBits) {\n /**\n * Pay to Public Key Hash (P2PKH)\n */\n CashAddressTypeBits[CashAddressTypeBits[\"p2pkh\"] = 0] = \"p2pkh\";\n /**\n * Pay to Script Hash (P2SH)\n */\n CashAddressTypeBits[CashAddressTypeBits[\"p2sh\"] = 1] = \"p2sh\";\n /**\n * Pay to Public Key Hash (P2PKH) with token support\n */\n CashAddressTypeBits[CashAddressTypeBits[\"p2pkhWithTokens\"] = 2] = \"p2pkhWithTokens\";\n /**\n * Pay to Script Hash (P2SH) with token support\n */\n CashAddressTypeBits[CashAddressTypeBits[\"p2shWithTokens\"] = 3] = \"p2shWithTokens\";\n})(CashAddressTypeBits || (CashAddressTypeBits = {}));\nconst cashAddressTypeToTypeBits = {\n [CashAddressType.p2pkh]: CashAddressTypeBits.p2pkh,\n [CashAddressType.p2sh]: CashAddressTypeBits.p2sh,\n [CashAddressType.p2pkhWithTokens]: CashAddressTypeBits.p2pkhWithTokens,\n [CashAddressType.p2shWithTokens]: CashAddressTypeBits.p2shWithTokens,\n};\nconst cashAddressTypeBitsToType = {\n [CashAddressTypeBits.p2pkh]: CashAddressType.p2pkh,\n [CashAddressTypeBits.p2sh]: CashAddressType.p2sh,\n [CashAddressTypeBits.p2pkhWithTokens]: CashAddressType.p2pkhWithTokens,\n [CashAddressTypeBits.p2shWithTokens]: CashAddressType.p2shWithTokens,\n};\n/* eslint-disable @typescript-eslint/naming-convention */\nconst cashAddressLengthBitsToLength = {\n 0: 20,\n 1: 24,\n 2: 28,\n 3: 32,\n 4: 40,\n 5: 48,\n 6: 56,\n 7: 64,\n};\nconst cashAddressLengthToLengthBits = {\n 20: 0,\n 24: 1,\n 28: 2,\n 32: 3,\n 40: 4,\n 48: 5,\n 56: 6,\n 64: 7,\n};\n/**\n * Encode a CashAddress version byte for the given address type and payload\n * length. See {@link CashAddressVersionByte} for more information.\n *\n * The `type` parameter must be a number between `0` and `15`, and `bitLength`\n * must be one of the standardized lengths. To use the contents of a variable,\n * cast it to {@link CashAddressType} or\n * {@link CashAddressSupportedLength} respectively,\n * e.g.:\n * ```ts\n * const type = 3 as CashAddressType;\n * const length = 20 as CashAddressSupportedLength;\n * getCashAddressVersionByte(type, length);\n * ```\n *\n * For the reverse, see {@link decodeCashAddressVersionByte}.\n *\n * @param typeBits - The address type bit of the payload being encoded.\n * @param length - The length of the payload being encoded.\n */\nconst encodeCashAddressVersionByte = (typeBits, length) => \n// eslint-disable-next-line no-bitwise\n(typeBits << 3 /* Constants.cashAddressTypeBitsShift */) |\n cashAddressLengthToLengthBits[length];\nvar CashAddressVersionByteDecodingError;\n(function (CashAddressVersionByteDecodingError) {\n CashAddressVersionByteDecodingError[\"reservedBitSet\"] = \"Reserved bit is set.\";\n})(CashAddressVersionByteDecodingError || (CashAddressVersionByteDecodingError = {}));\n/**\n * Decode a CashAddress version byte. For a list of known versions, see\n * {@link CashAddressVersionByte}.\n *\n * For the reverse, see {@link encodeCashAddressVersionByte}.\n *\n * @param version - The version byte to decode.\n */\nconst decodeCashAddressVersionByte = (version) => \n// eslint-disable-next-line no-negated-condition, no-bitwise\n(version & 128 /* Constants.cashAddressReservedBitMask */) !== 0\n ? CashAddressVersionByteDecodingError.reservedBitSet\n : {\n length: cashAddressLengthBitsToLength[\n // eslint-disable-next-line no-bitwise\n (version &\n 7 /* Constants.cashAddressLengthBits */)],\n typeBits: \n // eslint-disable-next-line no-bitwise\n (version >>> 3 /* Constants.cashAddressTypeBitsShift */) &\n 15 /* Constants.cashAddressTypeBits */,\n };\n/**\n * Convert a string into an array of 5-bit numbers, representing the characters\n * in a case-insensitive way.\n *\n * @param prefix - The prefix to mask.\n */\nconst maskCashAddressPrefix = (prefix) => {\n const result = [];\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements, no-plusplus\n for (let i = 0; i < prefix.length; i++) {\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, functional/immutable-data\n result.push(prefix.charCodeAt(i) & 31 /* Constants.asciiCaseInsensitiveBits */);\n }\n return result;\n};\n// prettier-ignore\nconst bech32GeneratorMostSignificantByte = [0x98, 0x79, 0xf3, 0xae, 0x1e]; // eslint-disable-line @typescript-eslint/no-magic-numbers\n// prettier-ignore\nconst bech32GeneratorRemainingBytes = [0xf2bc8e61, 0xb76d99e2, 0x3e5fb3c4, 0x2eabe2a8, 0x4f43e470]; // eslint-disable-line @typescript-eslint/no-magic-numbers\n/**\n * Perform the CashAddress polynomial modulo operation, which is based on the\n * Bech32 polynomial modulo operation, but the returned checksum is 40 bits,\n * rather than 30.\n *\n * A.K.A. `PolyMod`\n *\n * @remarks\n * Notes from C++ implementation:\n * This function will compute what 8 5-bit values to XOR into the last 8 input\n * values, in order to make the checksum 0. These 8 values are packed together\n * in a single 40-bit integer. The higher bits correspond to earlier values.\n *\n * The input is interpreted as a list of coefficients of a polynomial over F\n * = GF(32), with an implicit 1 in front. If the input is [v0,v1,v2,v3,v4],\n * that polynomial is v(x) = 1*x^5 + v0*x^4 + v1*x^3 + v2*x^2 + v3*x + v4.\n * The implicit 1 guarantees that [v0,v1,v2,...] has a distinct checksum\n * from [0,v0,v1,v2,...].\n *\n * The output is a 40-bit integer whose 5-bit groups are the coefficients of\n * the remainder of v(x) mod g(x), where g(x) is the cashaddr generator, x^8\n * + [19]*x^7 + [3]*x^6 + [25]*x^5 + [11]*x^4 + [25]*x^3 + [3]*x^2 + [19]*x\n * + [1]. g(x) is chosen in such a way that the resulting code is a BCH\n * code, guaranteeing detection of up to 4 errors within a window of 1025\n * characters. Among the various possible BCH codes, one was selected to in\n * fact guarantee detection of up to 5 errors within a window of 160\n * characters and 6 errors within a window of 126 characters. In addition,\n * the code guarantee the detection of a burst of up to 8 errors.\n *\n * Note that the coefficients are elements of GF(32), here represented as\n * decimal numbers between []. In this finite field, addition is just XOR of\n * the corresponding numbers. For example, [27] + [13] = [27 ^ 13] = [22].\n * Multiplication is more complicated, and requires treating the bits of\n * values themselves as coefficients of a polynomial over a smaller field,\n * GF(2), and multiplying those polynomials mod a^5 + a^3 + 1. For example,\n * [5] * [26] = (a^2 + 1) * (a^4 + a^3 + a) = (a^4 + a^3 + a) * a^2 + (a^4 +\n * a^3 + a) = a^6 + a^5 + a^4 + a = a^3 + 1 (mod a^5 + a^3 + 1) = [9].\n *\n * During the course of the loop below, `c` contains the bit-packed\n * coefficients of the polynomial constructed from just the values of v that\n * were processed so far, mod g(x). In the above example, `c` initially\n * corresponds to 1 mod (x), and after processing 2 inputs of v, it\n * corresponds to x^2 + v0*x + v1 mod g(x). As 1 mod g(x) = 1, that is the\n * starting value for `c`.\n *\n * @param v - Array of 5-bit integers over which the checksum is to be computed.\n */\n// Derived from the `bitcore-lib-cash` implementation (does not require BigInt): https://github.com/bitpay/bitcore\nconst cashAddressPolynomialModulo = (v) => {\n /* eslint-disable functional/no-let, functional/no-loop-statements, functional/no-expression-statements, no-bitwise, @typescript-eslint/no-magic-numbers */\n let mostSignificantByte = 0;\n let lowerBytes = 1;\n let c = 0;\n // eslint-disable-next-line @typescript-eslint/prefer-for-of, no-plusplus\n for (let j = 0; j < v.length; j++) {\n c = mostSignificantByte >>> 3;\n mostSignificantByte &= 0x07;\n mostSignificantByte <<= 5;\n mostSignificantByte |= lowerBytes >>> 27;\n lowerBytes &= 0x07ffffff;\n lowerBytes <<= 5;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n lowerBytes ^= v[j];\n // eslint-disable-next-line no-plusplus\n for (let i = 0; i < bech32GeneratorMostSignificantByte.length; ++i) {\n // eslint-disable-next-line functional/no-conditional-statements\n if (c & (1 << i)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n mostSignificantByte ^= bech32GeneratorMostSignificantByte[i];\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n lowerBytes ^= bech32GeneratorRemainingBytes[i];\n }\n }\n }\n lowerBytes ^= 1;\n // eslint-disable-next-line functional/no-conditional-statements\n if (lowerBytes < 0) {\n lowerBytes ^= 1 << 31;\n lowerBytes += (1 << 30) * 2;\n }\n return mostSignificantByte * (1 << 30) * 4 + lowerBytes;\n /* eslint-enable functional/no-let, functional/no-loop-statements, functional/no-expression-statements, no-bitwise, @typescript-eslint/no-magic-numbers */\n};\n/**\n * Convert the checksum returned by {@link cashAddressPolynomialModulo} to an\n * array of 5-bit positive integers that can be Base32 encoded.\n * @param checksum - A 40 bit checksum returned by\n * {@link cashAddressPolynomialModulo}.\n */\nconst cashAddressChecksumToUint5Array = (checksum) => {\n const result = [];\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements, no-plusplus\n for (let i = 0; i < 8 /* Constants.base256WordLength */; ++i) {\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, @typescript-eslint/no-magic-numbers, functional/immutable-data\n result.push(checksum & 31);\n // eslint-disable-next-line functional/no-expression-statements, @typescript-eslint/no-magic-numbers, no-param-reassign\n checksum /= 32;\n }\n // eslint-disable-next-line functional/immutable-data\n return result.reverse();\n};\nvar CashAddressFormatEncodingError;\n(function (CashAddressFormatEncodingError) {\n CashAddressFormatEncodingError[\"excessiveVersion\"] = \"CashAddress format encoding error: version must be 255 or less.\";\n})(CashAddressFormatEncodingError || (CashAddressFormatEncodingError = {}));\nvar CashAddressEncodingError;\n(function (CashAddressEncodingError) {\n CashAddressEncodingError[\"noTypeBitsValueStandardizedForP2pk\"] = \"CashAddress encoding error: no CashAddress type bit has been standardized for P2PK locking bytecode.\";\n CashAddressEncodingError[\"unsupportedPayloadLength\"] = \"CashAddress encoding error: a payload of this length can not be encoded as a valid CashAddress.\";\n CashAddressEncodingError[\"unknownLockingBytecodeType\"] = \"CashAddress encoding error: unknown locking bytecode type.\";\n})(CashAddressEncodingError || (CashAddressEncodingError = {}));\n/**\n * Encode a payload as a CashAddress-like string using the CashAddress format.\n *\n * Note that this function defaults to throwing encoding errors. To handle\n * errors in a type-safe way, set `throwErrors` to `false`.\n *\n * For the reverse, see {@link decodeCashAddressFormat}.\n *\n * To encode a standard CashAddress, use {@link encodeCashAddress}.\n */\nconst encodeCashAddressFormat = ({ payload, prefix, throwErrors = true, version, }) => {\n const checksum40BitPlaceholder = [0, 0, 0, 0, 0, 0, 0, 0];\n if (version > 255 /* Constants.maximumCashAddressFormatVersion */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressFormatEncodingError.excessiveVersion, `Version: ${version}.`, throwErrors);\n }\n const payloadContents = (0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.regroupBits)({\n bin: Uint8Array.from([version, ...payload]),\n resultWordLength: 5 /* Constants.base32WordLength */,\n sourceWordLength: 8 /* Constants.base256WordLength */,\n });\n const checksumContents = [\n ...maskCashAddressPrefix(prefix),\n 0 /* Constants.payloadSeparator */,\n ...payloadContents,\n ...checksum40BitPlaceholder,\n ];\n const checksum = cashAddressPolynomialModulo(checksumContents);\n const encoded = [\n ...payloadContents,\n ...cashAddressChecksumToUint5Array(checksum),\n ];\n const address = `${prefix}:${(0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.encodeBech32)(encoded)}`;\n return { address };\n};\nconst isValidCashAddressPayloadLength = (length) => cashAddressLengthToLengthBits[length] !== undefined;\n/**\n * Encode a payload as a CashAddress. This function is similar to\n * {@link encodeCashAddress} but supports non-standard `prefix`es and `type`s.\n *\n * Note that this function defaults to throwing encoding errors. To handle\n * errors in a type-safe way, set `throwErrors` to `false`.\n *\n * For other address standards that closely follow the CashAddress\n * specification (but have alternative version byte requirements), use\n * {@link encodeCashAddressFormat}.\n *\n * For the reverse, see {@link decodeCashAddressNonStandard}.\n */\nconst encodeCashAddressNonStandard = ({ payload, prefix, throwErrors = true, typeBits, }) => {\n const { length } = payload;\n if (!isValidCashAddressPayloadLength(length)) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressEncodingError.unsupportedPayloadLength, `Payload length: ${length}.`, throwErrors);\n }\n return encodeCashAddressFormat({\n payload,\n prefix,\n throwErrors,\n version: encodeCashAddressVersionByte(typeBits, length),\n });\n};\n/**\n * Encode a payload as a CashAddress.\n *\n * Note that this function defaults to throwing encoding errors. To handle\n * errors in a type-safe way, set `throwErrors` to `false`.\n *\n * To encode a CashAddress with a custom/unknown prefix or type bit, see\n * {@link encodeCashAddressNonStandard}. For other address standards that\n * closely follow the CashAddress specification (but have alternative version\n * byte requirements), use {@link encodeCashAddressFormat}.\n *\n * To decode a CashAddress, use {@link decodeCashAddress}.\n *\n * @returns If `throwErrors` is `true`, the CashAddress as a `string`. If\n * `throwErrors` is `false`, a {@link CashAddressResult} on successful encoding\n * or an error message as a `string`.\n */\nconst encodeCashAddress = ({ payload, prefix = 'bitcoincash', throwErrors = true, type, }) => encodeCashAddressNonStandard({\n payload,\n prefix,\n throwErrors,\n typeBits: cashAddressTypeToTypeBits[type],\n});\nvar CashAddressDecodingError;\n(function (CashAddressDecodingError) {\n CashAddressDecodingError[\"improperPadding\"] = \"CashAddress decoding error: the payload is improperly padded.\";\n CashAddressDecodingError[\"invalidCharacters\"] = \"CashAddress decoding error: the payload contains unexpected characters.\";\n CashAddressDecodingError[\"invalidChecksum\"] = \"CashAddress decoding error: invalid checksum - please review the address for errors.\";\n CashAddressDecodingError[\"invalidFormat\"] = \"CashAddress decoding error: CashAddresses should be of the form \\\"prefix:payload\\\".\";\n CashAddressDecodingError[\"mismatchedPayloadLength\"] = \"CashAddress decoding error: mismatched payload length for specified address version.\";\n CashAddressDecodingError[\"reservedBit\"] = \"CashAddress decoding error: unknown CashAddress version, reserved bit set.\";\n CashAddressDecodingError[\"unknownAddressType\"] = \"CashAddress decoding error: unknown CashAddress type.\";\n})(CashAddressDecodingError || (CashAddressDecodingError = {}));\n/**\n * Decode and validate a string using the CashAddress format. This is more\n * lenient than {@link decodeCashAddress}, which also validates the contents of\n * the version byte.\n *\n * Note, this method requires `address` to include a network prefix. To\n * decode a string with an unknown prefix, try\n * {@link decodeCashAddressFormatWithoutPrefix}.\n *\n * For the reverse, see {@link encodeCashAddressFormat}.\n *\n * @param address - The CashAddress-like string to decode.\n */\n// eslint-disable-next-line complexity\nconst decodeCashAddressFormat = (address) => {\n const parts = address.toLowerCase().split(':');\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n if (parts.length !== 2 || parts[0] === '' || parts[1] === '') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.invalidFormat, `Provided address: \"${address}\".`);\n }\n const [prefix, payload] = parts;\n if (!(0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.isBech32CharacterSet)(payload)) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.invalidCharacters, `Invalid characters: ${(0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.extractNonBech32Characters)(payload).join(', ')}.`);\n }\n const decodedPayload = (0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.decodeBech32)(payload);\n const polynomial = [\n ...maskCashAddressPrefix(prefix),\n 0 /* Constants.payloadSeparator */,\n ...decodedPayload,\n ];\n if (cashAddressPolynomialModulo(polynomial) !== 0) {\n return CashAddressDecodingError.invalidChecksum;\n }\n const checksum40BitPlaceholderLength = 8;\n const payloadContents = (0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.regroupBits)({\n allowPadding: false,\n bin: decodedPayload.slice(0, -checksum40BitPlaceholderLength),\n resultWordLength: 8 /* Constants.base256WordLength */,\n sourceWordLength: 5 /* Constants.base32WordLength */,\n });\n if (typeof payloadContents === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.improperPadding, payloadContents);\n }\n const [version, ...contents] = payloadContents;\n const result = Uint8Array.from(contents);\n return { payload: result, prefix, version };\n};\n/**\n * Decode and validate a CashAddress, strictly checking the version byte\n * according to the CashAddress specification. This is important for error\n * detection in CashAddresses.\n *\n * This function is similar to {@link decodeCashAddress} but supports\n * non-standard `type`s.\n *\n * For other address-like standards that closely follow the CashAddress\n * specification (but have alternative version byte requirements), use\n * {@link decodeCashAddressFormat}.\n *\n * Note, this method requires that CashAddresses include a network prefix. To\n * decode an address with an unknown prefix, try\n * {@link decodeCashAddressFormatWithoutPrefix}.\n *\n * For the reverse, see {@link encodeCashAddressNonStandard}.\n *\n * @param address - The CashAddress to decode.\n */\nconst decodeCashAddressNonStandard = (address) => {\n const decoded = decodeCashAddressFormat(address);\n if (typeof decoded === 'string') {\n return decoded;\n }\n const info = decodeCashAddressVersionByte(decoded.version);\n if (info === CashAddressVersionByteDecodingError.reservedBitSet) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.reservedBit);\n }\n if (decoded.payload.length !== info.length) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.mismatchedPayloadLength, `Version byte indicated a byte length of ${info.length}, but the payload is ${decoded.payload.length} bytes.`);\n }\n return {\n payload: decoded.payload,\n prefix: decoded.prefix,\n typeBits: info.typeBits,\n };\n};\n/**\n * Decode and validate a CashAddress, strictly checking the version byte\n * according to the CashAddress specification. This is important for error\n * detection in CashAddresses.\n *\n * To decode CashAddresses with non-standard `type`s,\n * see {@link decodeCashAddressNonStandard}.\n *\n * For other address-like standards that closely follow the CashAddress\n * specification (but have alternative version byte requirements), use\n * {@link decodeCashAddressFormat}.\n *\n * Note, this method requires that CashAddresses include a network prefix. To\n * decode an address with an unknown prefix, try\n * {@link decodeCashAddressFormatWithoutPrefix}.\n *\n * To encode a CashAddress, use {@link encodeCashAddress}.\n *\n * @param address - The CashAddress to decode.\n */\nconst decodeCashAddress = (address) => {\n const decoded = decodeCashAddressNonStandard(address);\n if (typeof decoded === 'string') {\n return decoded;\n }\n const type = cashAddressTypeBitsToType[decoded.typeBits];\n if (type === undefined) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.unknownAddressType, `Type bit value: ${decoded.typeBits}.`);\n }\n return {\n payload: decoded.payload,\n prefix: decoded.prefix,\n type,\n };\n};\n/**\n * Attempt to decode and validate a CashAddress against a list of possible\n * prefixes. If the correct prefix is known, use {@link decodeCashAddress}.\n *\n * @param address - The CashAddress to decode.\n * @param possiblePrefixes - The network prefixes to try.\n */\n// decodeCashAddressWithoutPrefix\nconst decodeCashAddressFormatWithoutPrefix = (address, possiblePrefixes = [\n CashAddressNetworkPrefix.mainnet,\n CashAddressNetworkPrefix.testnet,\n CashAddressNetworkPrefix.regtest,\n]) => {\n // eslint-disable-next-line functional/no-loop-statements\n for (const prefix of possiblePrefixes) {\n const attempt = decodeCashAddressFormat(`${prefix}:${address}`);\n if (attempt !== CashAddressDecodingError.invalidChecksum) {\n return attempt;\n }\n }\n return CashAddressDecodingError.invalidChecksum;\n};\n/**\n * Convert a CashAddress polynomial to CashAddress string format.\n *\n * @remarks\n * CashAddress polynomials take the form:\n *\n * `[lowest 5 bits of each prefix character] 0 [payload + checksum]`\n *\n * This method remaps the 5-bit integers in the prefix location to the matching\n * ASCII lowercase characters, replaces the separator with `:`, and then Bech32\n * encodes the remaining payload and checksum.\n *\n * @param polynomial - An array of 5-bit integers representing the terms of a\n * CashAddress polynomial.\n */\nconst cashAddressPolynomialToCashAddress = (polynomial) => {\n const separatorPosition = polynomial.indexOf(0);\n const prefix = polynomial\n .slice(0, separatorPosition)\n .map((integer) => String.fromCharCode(96 /* Constants.asciiLowerCaseStart */ + integer))\n .join('');\n const contents = (0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.encodeBech32)(polynomial.slice(separatorPosition + 1));\n return `${prefix}:${contents}`;\n};\nvar CashAddressFormatCorrectionError;\n(function (CashAddressFormatCorrectionError) {\n CashAddressFormatCorrectionError[\"tooManyErrors\"] = \"CashAddress format correction error: this address cannot be corrected as it contains more than 2 errors.\";\n})(CashAddressFormatCorrectionError || (CashAddressFormatCorrectionError = {}));\n/**\n * Attempt to correct up to 2 errors in a CashAddress-formatted string. The\n * string must include the prefix and only contain Bech32 characters.\n *\n * ## **CAUTION: improper use of this function can lead to lost funds.**\n *\n * Using error correction of CashAddress-like formats degrades error detection,\n * i.e. if the payload contains more than 2 errors, it is possible that error\n * correction will \"correct\" the payload to a plausible but incorrect payload.\n *\n * For applications which proceed to take irreversible actions – like sending a\n * payment – **naive usage of CashAddress Format error correction can lead to\n * vulnerabilities and lost funds**.\n *\n * It is strongly advised that this method only be used in fail-safe\n * applications (e.g. automatic correction of CashAddress-formatted private key\n * material during wallet recovery) or under explicit user control (e.g. \"The\n * address you entered is invalid, please review the highlighted characters and\n * try again.\").\n *\n * Only 2 substitution errors can be corrected (or a single swap) – deletions\n * and insertions (errors that shift many other characters and change the\n * length of the payload) can never be safely corrected and will produce an\n * error.\n *\n * Errors can be corrected in both the prefix and the payload, but attempting to\n * correct errors in the prefix prior to this method can improve results, e.g.\n * for `bchtest:qq2azmyyv6dtgczexyalqar70q036yund53jvfde0x`, the string\n * `bchtest:qq2azmyyv6dtgczexyalqar70q036yund53jvfdecc` can be corrected, while\n * `typo:qq2azmyyv6dtgczexyalqar70q036yund53jvfdecc` can not.\n *\n * @param address - The address or formatted data to correct.\n */\n// Derived from: https://github.com/deadalnix/cashaddressed\n// eslint-disable-next-line complexity\nconst attemptCashAddressFormatErrorCorrection = (address) => {\n const parts = address.toLowerCase().split(':');\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n if (parts.length !== 2 || parts[0] === '' || parts[1] === '') {\n return CashAddressDecodingError.invalidFormat;\n }\n const [prefix, payload] = parts;\n if (!(0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.isBech32CharacterSet)(payload)) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CashAddressDecodingError.invalidCharacters, `Invalid characters: ${(0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.extractNonBech32Characters)(payload).join(', ')}.`);\n }\n const decodedPayload = (0,_bech32_js__WEBPACK_IMPORTED_MODULE_1__.decodeBech32)(payload);\n const polynomial = [...maskCashAddressPrefix(prefix), 0, ...decodedPayload];\n const originalChecksum = cashAddressPolynomialModulo(polynomial);\n if (originalChecksum === 0) {\n return {\n address: cashAddressPolynomialToCashAddress(polynomial),\n corrections: [],\n };\n }\n const syndromes = {};\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements, no-plusplus\n for (let term = 0; term < polynomial.length; term++) {\n // eslint-disable-next-line functional/no-loop-statements\n for (\n // eslint-disable-next-line functional/no-let\n let errorVector = 1; errorVector < 32 /* Constants.finiteFieldOrder */; \n // eslint-disable-next-line no-plusplus\n errorVector++) {\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, @typescript-eslint/no-non-null-assertion\n polynomial[term] ^= errorVector;\n const correct = cashAddressPolynomialModulo(polynomial);\n if (correct === 0) {\n return {\n address: cashAddressPolynomialToCashAddress(polynomial),\n corrections: [term],\n };\n }\n // eslint-disable-next-line no-bitwise\n const s0 = (BigInt(correct) ^ BigInt(originalChecksum)).toString();\n // eslint-disable-next-line functional/no-expression-statements, functional/immutable-data\n syndromes[s0] = term * 32 /* Constants.finiteFieldOrder */ + errorVector;\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, @typescript-eslint/no-non-null-assertion\n polynomial[term] ^= errorVector;\n }\n }\n // eslint-disable-next-line functional/no-loop-statements\n for (const [s0, pe] of Object.entries(syndromes)) {\n // eslint-disable-next-line no-bitwise\n const s1Location = (BigInt(s0) ^ BigInt(originalChecksum)).toString();\n const s1 = syndromes[s1Location];\n if (s1 !== undefined) {\n const correctionIndex1 = Math.trunc(pe / 32 /* Constants.finiteFieldOrder */);\n const correctionIndex2 = Math.trunc(s1 / 32 /* Constants.finiteFieldOrder */);\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, @typescript-eslint/no-non-null-assertion\n polynomial[correctionIndex1] ^= pe % 32 /* Constants.finiteFieldOrder */;\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, @typescript-eslint/no-non-null-assertion\n polynomial[correctionIndex2] ^= s1 % 32 /* Constants.finiteFieldOrder */;\n return {\n address: cashAddressPolynomialToCashAddress(polynomial),\n corrections: [correctionIndex1, correctionIndex2].sort((a, b) => a - b),\n };\n }\n }\n return CashAddressFormatCorrectionError.tooManyErrors;\n};\n//# sourceMappingURL=cash-address.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/address/cash-address.js?");
|
|
74
74
|
|
|
75
75
|
/***/ }),
|
|
76
76
|
|
|
@@ -114,7 +114,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
114
114
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
115
115
|
|
|
116
116
|
"use strict";
|
|
117
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"instantiateSecp256k1Wasm\": () => (/* binding */ instantiateSecp256k1Wasm),\n/* harmony export */ \"instantiateSecp256k1WasmBytes\": () => (/* binding */ instantiateSecp256k1WasmBytes)\n/* harmony export */ });\n/* unused harmony export getEmbeddedSecp256k1Binary */\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/base64.js\");\n/* harmony import */ var _secp256k1_base64_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./secp256k1.base64.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/secp256k1/secp256k1.base64.js\");\n/* eslint-disable no-underscore-dangle, @typescript-eslint/max-params, @typescript-eslint/naming-convention */\n// cSpell:ignore memcpy, anyfunc\n\n\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */\nconst wrapSecp256k1Wasm = (instance, heapU8, heapU32) => ({\n contextCreate: (context) => instance.exports._secp256k1_context_create(context),\n contextRandomize: (contextPtr, seedPtr) => instance.exports._secp256k1_context_randomize(contextPtr, seedPtr),\n free: (pointer) => instance.exports._free(pointer),\n heapU32,\n heapU8,\n instance,\n malloc: (bytes) => instance.exports._malloc(bytes),\n mallocSizeT: (num) => {\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n const pointer = instance.exports._malloc(4);\n // eslint-disable-next-line no-bitwise, @typescript-eslint/no-magic-numbers\n const pointerView32 = pointer >> 2;\n // eslint-disable-next-line functional/no-expression-statements\n heapU32.set([num], pointerView32);\n return pointer;\n },\n mallocUint8Array: (array) => {\n const pointer = instance.exports._malloc(array.length);\n // eslint-disable-next-line functional/no-expression-statements\n heapU8.set(array, pointer);\n return pointer;\n },\n privkeyTweakAdd: (contextPtr, secretKeyPtr, tweakNum256Ptr) => instance.exports._secp256k1_ec_privkey_tweak_add(contextPtr, secretKeyPtr, tweakNum256Ptr),\n privkeyTweakMul: (contextPtr, secretKeyPtr, tweakNum256Ptr) => instance.exports._secp256k1_ec_privkey_tweak_mul(contextPtr, secretKeyPtr, tweakNum256Ptr),\n pubkeyCreate: (contextPtr, publicKeyPtr, secretKeyPtr) => instance.exports._secp256k1_ec_pubkey_create(contextPtr, publicKeyPtr, secretKeyPtr),\n pubkeyParse: (contextPtr, publicKeyOutPtr, publicKeyInPtr, publicKeyInLength) => instance.exports._secp256k1_ec_pubkey_parse(contextPtr, publicKeyOutPtr, publicKeyInPtr, publicKeyInLength),\n pubkeySerialize: (contextPtr, outputPtr, outputLengthPtr, publicKeyPtr, compression) => instance.exports._secp256k1_ec_pubkey_serialize(contextPtr, outputPtr, outputLengthPtr, publicKeyPtr, compression),\n pubkeyTweakAdd: (contextPtr, publicKeyPtr, tweakNum256Ptr) => instance.exports._secp256k1_ec_pubkey_tweak_add(contextPtr, publicKeyPtr, tweakNum256Ptr),\n pubkeyTweakMul: (contextPtr, publicKeyPtr, tweakNum256Ptr) => instance.exports._secp256k1_ec_pubkey_tweak_mul(contextPtr, publicKeyPtr, tweakNum256Ptr),\n readHeapU8: (pointer, bytes) => new Uint8Array(heapU8.buffer, pointer, bytes),\n readSizeT: (pointer) => {\n // eslint-disable-next-line no-bitwise, @typescript-eslint/no-magic-numbers\n const pointerView32 = pointer >> 2;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return heapU32[pointerView32];\n },\n recover: (contextPtr, outputPubkeyPointer, rSigPtr, msg32Ptr) => instance.exports._secp256k1_ecdsa_recover(contextPtr, outputPubkeyPointer, rSigPtr, msg32Ptr),\n recoverableSignatureParse: (contextPtr, outputRSigPtr, inputSigPtr, rid) => instance.exports._secp256k1_ecdsa_recoverable_signature_parse_compact(contextPtr, outputRSigPtr, inputSigPtr, rid),\n recoverableSignatureSerialize: (contextPtr, sigOutPtr, recIDOutPtr, rSigPtr) => instance.exports._secp256k1_ecdsa_recoverable_signature_serialize_compact(contextPtr, sigOutPtr, recIDOutPtr, rSigPtr),\n schnorrSign: (contextPtr, outputSigPtr, msg32Ptr, secretKeyPtr) => instance.exports._secp256k1_schnorr_sign(contextPtr, outputSigPtr, msg32Ptr, secretKeyPtr),\n schnorrVerify: (contextPtr, sigPtr, msg32Ptr, publicKeyPtr) => instance.exports._secp256k1_schnorr_verify(contextPtr, sigPtr, msg32Ptr, publicKeyPtr),\n seckeyVerify: (contextPtr, secretKeyPtr) => instance.exports._secp256k1_ec_seckey_verify(contextPtr, secretKeyPtr),\n sign: (contextPtr, outputSigPtr, msg32Ptr, secretKeyPtr) => instance.exports._secp256k1_ecdsa_sign(contextPtr, outputSigPtr, msg32Ptr, secretKeyPtr),\n signRecoverable: (contextPtr, outputRSigPtr, msg32Ptr, secretKeyPtr) => instance.exports._secp256k1_ecdsa_sign_recoverable(contextPtr, outputRSigPtr, msg32Ptr, secretKeyPtr),\n signatureMalleate: (contextPtr, outputSigPtr, inputSigPtr) => instance.exports._secp256k1_ecdsa_signature_malleate(contextPtr, outputSigPtr, inputSigPtr),\n signatureNormalize: (contextPtr, outputSigPtr, inputSigPtr) => instance.exports._secp256k1_ecdsa_signature_normalize(contextPtr, outputSigPtr, inputSigPtr),\n signatureParseCompact: (contextPtr, sigOutPtr, compactSigInPtr) => instance.exports._secp256k1_ecdsa_signature_parse_compact(contextPtr, sigOutPtr, compactSigInPtr),\n signatureParseDER: (contextPtr, sigOutPtr, sigDERInPtr, sigDERInLength) => instance.exports._secp256k1_ecdsa_signature_parse_der(contextPtr, sigOutPtr, sigDERInPtr, sigDERInLength),\n signatureSerializeCompact: (contextPtr, outputCompactSigPtr, inputSigPtr) => instance.exports._secp256k1_ecdsa_signature_serialize_compact(contextPtr, outputCompactSigPtr, inputSigPtr),\n signatureSerializeDER: (contextPtr, outputDERSigPtr, outputDERSigLengthPtr, inputSigPtr) => instance.exports._secp256k1_ecdsa_signature_serialize_der(contextPtr, outputDERSigPtr, outputDERSigLengthPtr, inputSigPtr),\n verify: (contextPtr, sigPtr, msg32Ptr, pubkeyPtr) => instance.exports._secp256k1_ecdsa_verify(contextPtr, sigPtr, msg32Ptr, pubkeyPtr),\n});\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable functional/immutable-data, functional/no-expression-statements, @typescript-eslint/no-magic-numbers, functional/no-conditional-statements, no-bitwise, functional/no-throw-statements */\n/**\n * Method extracted from Emscripten's preamble.js\n */\nconst isLittleEndian = (buffer) => {\n const littleEndian = true;\n const notLittleEndian = false;\n const heap16 = new Int16Array(buffer);\n const heap32 = new Int32Array(buffer);\n const heapU8 = new Uint8Array(buffer);\n heap32[0] = 1668509029;\n heap16[1] = 25459;\n return heapU8[2] !== 115 || heapU8[3] !== 99\n ? /* c8 ignore next */\n notLittleEndian\n : littleEndian;\n};\n/**\n * Method derived from Emscripten's preamble.js\n */\nconst alignMemory = (factor, size) => Math.ceil(size / factor) * factor;\n/**\n * The most performant way to instantiate secp256k1 functionality. To avoid\n * using Node.js or DOM-specific APIs, you can use {@link instantiateSecp256k1}.\n *\n * Note, most of this method is translated and boiled-down from Emscripten's\n * preamble.js. Significant changes to the WASM build or breaking updates to\n * Emscripten will likely require modifications to this method.\n *\n * @param webassemblyBytes - A buffer containing the secp256k1 binary.\n */\nconst instantiateSecp256k1WasmBytes = async (webassemblyBytes) => {\n const STACK_ALIGN = 16;\n const GLOBAL_BASE = 1024;\n const WASM_PAGE_SIZE = 65536;\n const TOTAL_STACK = 5242880;\n const TOTAL_MEMORY = 16777216;\n const wasmMemory = new WebAssembly.Memory({\n initial: TOTAL_MEMORY / WASM_PAGE_SIZE,\n maximum: TOTAL_MEMORY / WASM_PAGE_SIZE,\n });\n /* c8 ignore next 9 */\n if (!isLittleEndian(wasmMemory.buffer)) {\n /*\n * note: this block is excluded from test coverage. It's A) hard to test\n * (must be either tested on big-endian hardware or a big-endian buffer\n * mock) and B) extracted from Emscripten's preamble.js, where it should\n * be tested properly.\n */\n throw new Error('Runtime error: expected the system to be little-endian.');\n }\n const STATIC_BASE = GLOBAL_BASE;\n const STATICTOP_INITIAL = STATIC_BASE + 67696 + 16;\n const DYNAMICTOP_PTR = STATICTOP_INITIAL;\n const DYNAMICTOP_PTR_SIZE = 4;\n const STATICTOP = (STATICTOP_INITIAL + DYNAMICTOP_PTR_SIZE + 15) & -16;\n const STACKTOP = alignMemory(STACK_ALIGN, STATICTOP);\n const STACK_BASE = STACKTOP;\n const STACK_MAX = STACK_BASE + TOTAL_STACK;\n const DYNAMIC_BASE = alignMemory(STACK_ALIGN, STACK_MAX);\n const heapU8 = new Uint8Array(wasmMemory.buffer);\n const heap32 = new Int32Array(wasmMemory.buffer);\n const heapU32 = new Uint32Array(wasmMemory.buffer);\n heap32[DYNAMICTOP_PTR >> 2] = DYNAMIC_BASE;\n const TABLE_SIZE = 6;\n const MAX_TABLE_SIZE = 6;\n // eslint-disable-next-line functional/no-let, @typescript-eslint/init-declarations\n let getErrNoLocation;\n /*\n * note: A number of methods below are excluded from test coverage. They are\n * a) not part of the regular usage of this library (should only be evaluated\n * if the consumer mis-implements the library and exist only to make\n * debugging easier) and B) already tested adequately in Emscripten, from\n * which this section is extracted.\n */\n const env = {\n DYNAMICTOP_PTR,\n STACKTOP,\n /* c8 ignore start */\n ___setErrNo: (value) => {\n if (getErrNoLocation !== undefined) {\n heap32[getErrNoLocation() >> 2] = value;\n }\n return value;\n },\n _abort: (err = 'Secp256k1 Error') => {\n throw new Error(err);\n },\n // eslint-disable-next-line camelcase\n _emscripten_memcpy_big: (dest, src, num) => {\n heapU8.set(heapU8.subarray(src, src + num), dest);\n return dest;\n },\n abort: (err = 'Secp256k1 Error') => {\n throw new Error(err);\n },\n abortOnCannotGrowMemory: () => {\n throw new Error('Secp256k1 Error: abortOnCannotGrowMemory was called.');\n },\n enlargeMemory: () => {\n throw new Error('Secp256k1 Error: enlargeMemory was called.');\n },\n getTotalMemory: () => TOTAL_MEMORY,\n /* c8 ignore stop */\n };\n const info = {\n env: {\n ...env,\n memory: wasmMemory,\n memoryBase: STATIC_BASE,\n table: new WebAssembly.Table({\n element: 'anyfunc',\n initial: TABLE_SIZE,\n maximum: MAX_TABLE_SIZE,\n }),\n tableBase: 0,\n },\n global: { Infinity, NaN },\n };\n return WebAssembly.instantiate(webassemblyBytes, info).then((result) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment\n getErrNoLocation = result.instance.exports['___errno_location'];\n return wrapSecp256k1Wasm(result.instance, heapU8, heapU32);\n });\n};\n/* eslint-enable functional/immutable-data, functional/no-expression-statements, @typescript-eslint/no-magic-numbers, functional/no-conditional-statements, no-bitwise, functional/no-throw-statements */\nconst getEmbeddedSecp256k1Binary = () => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.base64ToBin)(_secp256k1_base64_js__WEBPACK_IMPORTED_MODULE_1__.secp256k1Base64Bytes).buffer;\n/**\n * An ultimately-portable (but slower) version of\n * {@link instantiateSecp256k1Bytes} that does not require the consumer to\n * provide the secp256k1 binary buffer.\n */\nconst instantiateSecp256k1Wasm = async () => instantiateSecp256k1WasmBytes(getEmbeddedSecp256k1Binary());\n//# sourceMappingURL=secp256k1-wasm.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/bin/secp256k1/secp256k1-wasm.js?");
|
|
117
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"CompressionFlag\": () => (/* reexport safe */ _secp256k1_wasm_types_js__WEBPACK_IMPORTED_MODULE_0__.CompressionFlag),\n/* harmony export */ \"ContextFlag\": () => (/* reexport safe */ _secp256k1_wasm_types_js__WEBPACK_IMPORTED_MODULE_0__.ContextFlag),\n/* harmony export */ \"getEmbeddedSecp256k1Binary\": () => (/* binding */ getEmbeddedSecp256k1Binary),\n/* harmony export */ \"instantiateSecp256k1Wasm\": () => (/* binding */ instantiateSecp256k1Wasm),\n/* harmony export */ \"instantiateSecp256k1WasmBytes\": () => (/* binding */ instantiateSecp256k1WasmBytes)\n/* harmony export */ });\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/base64.js\");\n/* harmony import */ var _secp256k1_wasm_types_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./secp256k1-wasm-types.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/secp256k1/secp256k1-wasm-types.js\");\n/* harmony import */ var _secp256k1_base64_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./secp256k1.base64.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/secp256k1/secp256k1.base64.js\");\n/* eslint-disable no-underscore-dangle, @typescript-eslint/max-params, @typescript-eslint/naming-convention */\n// cSpell:ignore memcpy, anyfunc\n\n\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */\nconst wrapSecp256k1Wasm = (instance, heapU8, heapU32) => ({\n contextCreate: (context) => instance.exports._secp256k1_context_create(context),\n contextRandomize: (contextPtr, seedPtr) => instance.exports._secp256k1_context_randomize(contextPtr, seedPtr),\n free: (pointer) => instance.exports._free(pointer),\n heapU32,\n heapU8,\n instance,\n malloc: (bytes) => instance.exports._malloc(bytes),\n mallocSizeT: (num) => {\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n const pointer = instance.exports._malloc(4);\n // eslint-disable-next-line no-bitwise, @typescript-eslint/no-magic-numbers\n const pointerView32 = pointer >> 2;\n // eslint-disable-next-line functional/no-expression-statements\n heapU32.set([num], pointerView32);\n return pointer;\n },\n mallocUint8Array: (array) => {\n const pointer = instance.exports._malloc(array.length);\n // eslint-disable-next-line functional/no-expression-statements\n heapU8.set(array, pointer);\n return pointer;\n },\n privkeyTweakAdd: (contextPtr, secretKeyPtr, tweakNum256Ptr) => instance.exports._secp256k1_ec_privkey_tweak_add(contextPtr, secretKeyPtr, tweakNum256Ptr),\n privkeyTweakMul: (contextPtr, secretKeyPtr, tweakNum256Ptr) => instance.exports._secp256k1_ec_privkey_tweak_mul(contextPtr, secretKeyPtr, tweakNum256Ptr),\n pubkeyCreate: (contextPtr, publicKeyPtr, secretKeyPtr) => instance.exports._secp256k1_ec_pubkey_create(contextPtr, publicKeyPtr, secretKeyPtr),\n pubkeyParse: (contextPtr, publicKeyOutPtr, publicKeyInPtr, publicKeyInLength) => instance.exports._secp256k1_ec_pubkey_parse(contextPtr, publicKeyOutPtr, publicKeyInPtr, publicKeyInLength),\n pubkeySerialize: (contextPtr, outputPtr, outputLengthPtr, publicKeyPtr, compression) => instance.exports._secp256k1_ec_pubkey_serialize(contextPtr, outputPtr, outputLengthPtr, publicKeyPtr, compression),\n pubkeyTweakAdd: (contextPtr, publicKeyPtr, tweakNum256Ptr) => instance.exports._secp256k1_ec_pubkey_tweak_add(contextPtr, publicKeyPtr, tweakNum256Ptr),\n pubkeyTweakMul: (contextPtr, publicKeyPtr, tweakNum256Ptr) => instance.exports._secp256k1_ec_pubkey_tweak_mul(contextPtr, publicKeyPtr, tweakNum256Ptr),\n readHeapU8: (pointer, bytes) => new Uint8Array(heapU8.buffer, pointer, bytes),\n readSizeT: (pointer) => {\n // eslint-disable-next-line no-bitwise, @typescript-eslint/no-magic-numbers\n const pointerView32 = pointer >> 2;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return heapU32[pointerView32];\n },\n recover: (contextPtr, outputPubkeyPointer, rSigPtr, msg32Ptr) => instance.exports._secp256k1_ecdsa_recover(contextPtr, outputPubkeyPointer, rSigPtr, msg32Ptr),\n recoverableSignatureParse: (contextPtr, outputRSigPtr, inputSigPtr, rid) => instance.exports._secp256k1_ecdsa_recoverable_signature_parse_compact(contextPtr, outputRSigPtr, inputSigPtr, rid),\n recoverableSignatureSerialize: (contextPtr, sigOutPtr, recIDOutPtr, rSigPtr) => instance.exports._secp256k1_ecdsa_recoverable_signature_serialize_compact(contextPtr, sigOutPtr, recIDOutPtr, rSigPtr),\n schnorrSign: (contextPtr, outputSigPtr, msg32Ptr, secretKeyPtr) => instance.exports._secp256k1_schnorr_sign(contextPtr, outputSigPtr, msg32Ptr, secretKeyPtr),\n schnorrVerify: (contextPtr, sigPtr, msg32Ptr, publicKeyPtr) => instance.exports._secp256k1_schnorr_verify(contextPtr, sigPtr, msg32Ptr, publicKeyPtr),\n seckeyVerify: (contextPtr, secretKeyPtr) => instance.exports._secp256k1_ec_seckey_verify(contextPtr, secretKeyPtr),\n sign: (contextPtr, outputSigPtr, msg32Ptr, secretKeyPtr) => instance.exports._secp256k1_ecdsa_sign(contextPtr, outputSigPtr, msg32Ptr, secretKeyPtr),\n signRecoverable: (contextPtr, outputRSigPtr, msg32Ptr, secretKeyPtr) => instance.exports._secp256k1_ecdsa_sign_recoverable(contextPtr, outputRSigPtr, msg32Ptr, secretKeyPtr),\n signatureMalleate: (contextPtr, outputSigPtr, inputSigPtr) => instance.exports._secp256k1_ecdsa_signature_malleate(contextPtr, outputSigPtr, inputSigPtr),\n signatureNormalize: (contextPtr, outputSigPtr, inputSigPtr) => instance.exports._secp256k1_ecdsa_signature_normalize(contextPtr, outputSigPtr, inputSigPtr),\n signatureParseCompact: (contextPtr, sigOutPtr, compactSigInPtr) => instance.exports._secp256k1_ecdsa_signature_parse_compact(contextPtr, sigOutPtr, compactSigInPtr),\n signatureParseDER: (contextPtr, sigOutPtr, sigDERInPtr, sigDERInLength) => instance.exports._secp256k1_ecdsa_signature_parse_der(contextPtr, sigOutPtr, sigDERInPtr, sigDERInLength),\n signatureSerializeCompact: (contextPtr, outputCompactSigPtr, inputSigPtr) => instance.exports._secp256k1_ecdsa_signature_serialize_compact(contextPtr, outputCompactSigPtr, inputSigPtr),\n signatureSerializeDER: (contextPtr, outputDERSigPtr, outputDERSigLengthPtr, inputSigPtr) => instance.exports._secp256k1_ecdsa_signature_serialize_der(contextPtr, outputDERSigPtr, outputDERSigLengthPtr, inputSigPtr),\n verify: (contextPtr, sigPtr, msg32Ptr, pubkeyPtr) => instance.exports._secp256k1_ecdsa_verify(contextPtr, sigPtr, msg32Ptr, pubkeyPtr),\n});\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable functional/immutable-data, functional/no-expression-statements, @typescript-eslint/no-magic-numbers, functional/no-conditional-statements, no-bitwise, functional/no-throw-statements */\n/**\n * Method extracted from Emscripten's preamble.js\n */\nconst isLittleEndian = (buffer) => {\n const littleEndian = true;\n const notLittleEndian = false;\n const heap16 = new Int16Array(buffer);\n const heap32 = new Int32Array(buffer);\n const heapU8 = new Uint8Array(buffer);\n heap32[0] = 1668509029;\n heap16[1] = 25459;\n return heapU8[2] !== 115 || heapU8[3] !== 99\n ? /* c8 ignore next */\n notLittleEndian\n : littleEndian;\n};\n/**\n * Method derived from Emscripten's preamble.js\n */\nconst alignMemory = (factor, size) => Math.ceil(size / factor) * factor;\n/**\n * The most performant way to instantiate secp256k1 functionality. To avoid\n * using Node.js or DOM-specific APIs, you can use {@link instantiateSecp256k1}.\n *\n * Note, most of this method is translated and boiled-down from Emscripten's\n * preamble.js. Significant changes to the WASM build or breaking updates to\n * Emscripten will likely require modifications to this method.\n *\n * @param webassemblyBytes - A buffer containing the secp256k1 binary.\n */\nconst instantiateSecp256k1WasmBytes = async (webassemblyBytes) => {\n const STACK_ALIGN = 16;\n const GLOBAL_BASE = 1024;\n const WASM_PAGE_SIZE = 65536;\n const TOTAL_STACK = 5242880;\n const TOTAL_MEMORY = 16777216;\n const wasmMemory = new WebAssembly.Memory({\n initial: TOTAL_MEMORY / WASM_PAGE_SIZE,\n maximum: TOTAL_MEMORY / WASM_PAGE_SIZE,\n });\n /* c8 ignore next 9 */\n if (!isLittleEndian(wasmMemory.buffer)) {\n /*\n * note: this block is excluded from test coverage. It's A) hard to test\n * (must be either tested on big-endian hardware or a big-endian buffer\n * mock) and B) extracted from Emscripten's preamble.js, where it should\n * be tested properly.\n */\n throw new Error('Runtime error: expected the system to be little-endian.');\n }\n const STATIC_BASE = GLOBAL_BASE;\n const STATICTOP_INITIAL = STATIC_BASE + 67696 + 16;\n const DYNAMICTOP_PTR = STATICTOP_INITIAL;\n const DYNAMICTOP_PTR_SIZE = 4;\n const STATICTOP = (STATICTOP_INITIAL + DYNAMICTOP_PTR_SIZE + 15) & -16;\n const STACKTOP = alignMemory(STACK_ALIGN, STATICTOP);\n const STACK_BASE = STACKTOP;\n const STACK_MAX = STACK_BASE + TOTAL_STACK;\n const DYNAMIC_BASE = alignMemory(STACK_ALIGN, STACK_MAX);\n const heapU8 = new Uint8Array(wasmMemory.buffer);\n const heap32 = new Int32Array(wasmMemory.buffer);\n const heapU32 = new Uint32Array(wasmMemory.buffer);\n heap32[DYNAMICTOP_PTR >> 2] = DYNAMIC_BASE;\n const TABLE_SIZE = 6;\n const MAX_TABLE_SIZE = 6;\n // eslint-disable-next-line functional/no-let, @typescript-eslint/init-declarations\n let getErrNoLocation;\n /*\n * note: A number of methods below are excluded from test coverage. They are\n * a) not part of the regular usage of this library (should only be evaluated\n * if the consumer mis-implements the library and exist only to make\n * debugging easier) and B) already tested adequately in Emscripten, from\n * which this section is extracted.\n */\n const env = {\n DYNAMICTOP_PTR,\n STACKTOP,\n /* c8 ignore start */\n ___setErrNo: (value) => {\n if (getErrNoLocation !== undefined) {\n heap32[getErrNoLocation() >> 2] = value;\n }\n return value;\n },\n _abort: (err = 'Secp256k1 Error') => {\n throw new Error(err);\n },\n // eslint-disable-next-line camelcase\n _emscripten_memcpy_big: (dest, src, num) => {\n heapU8.set(heapU8.subarray(src, src + num), dest);\n return dest;\n },\n abort: (err = 'Secp256k1 Error') => {\n throw new Error(err);\n },\n abortOnCannotGrowMemory: () => {\n throw new Error('Secp256k1 Error: abortOnCannotGrowMemory was called.');\n },\n enlargeMemory: () => {\n throw new Error('Secp256k1 Error: enlargeMemory was called.');\n },\n getTotalMemory: () => TOTAL_MEMORY,\n /* c8 ignore stop */\n };\n const info = {\n env: {\n ...env,\n memory: wasmMemory,\n memoryBase: STATIC_BASE,\n table: new WebAssembly.Table({\n element: 'anyfunc',\n initial: TABLE_SIZE,\n maximum: MAX_TABLE_SIZE,\n }),\n tableBase: 0,\n },\n global: { Infinity, NaN },\n };\n return WebAssembly.instantiate(webassemblyBytes, info).then((result) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment\n getErrNoLocation = result.instance.exports['___errno_location'];\n return wrapSecp256k1Wasm(result.instance, heapU8, heapU32);\n });\n};\n/* eslint-enable functional/immutable-data, functional/no-expression-statements, @typescript-eslint/no-magic-numbers, functional/no-conditional-statements, no-bitwise, functional/no-throw-statements */\nconst getEmbeddedSecp256k1Binary = () => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.base64ToBin)(_secp256k1_base64_js__WEBPACK_IMPORTED_MODULE_2__.secp256k1Base64Bytes).buffer;\n/**\n * An ultimately-portable (but slower) version of\n * {@link instantiateSecp256k1Bytes} that does not require the consumer to\n * provide the secp256k1 binary buffer.\n */\nconst instantiateSecp256k1Wasm = async () => instantiateSecp256k1WasmBytes(getEmbeddedSecp256k1Binary());\n//# sourceMappingURL=secp256k1-wasm.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/bin/secp256k1/secp256k1-wasm.js?");
|
|
118
118
|
|
|
119
119
|
/***/ }),
|
|
120
120
|
|
|
@@ -169,7 +169,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
169
169
|
/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
170
170
|
|
|
171
171
|
"use strict";
|
|
172
|
-
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"
|
|
172
|
+
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"hash160\": () => (/* binding */ hash160),\n/* harmony export */ \"hash256\": () => (/* binding */ hash256)\n/* harmony export */ });\n/* harmony import */ var _default_crypto_instances_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./default-crypto-instances.js */ \"../../node_modules/@bitauth/libauth/build/lib/crypto/default-crypto-instances.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_default_crypto_instances_js__WEBPACK_IMPORTED_MODULE_0__]);\n_default_crypto_instances_js__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];\n\n/**\n * Hash the given payload with sha256, then hash the 32-byte result with\n * ripemd160, returning a 20-byte hash.\n *\n * This hash is used in both {@link AddressType.p2pkh} and\n * {@link AddressType.p2sh20} addresses.\n *\n * @param payload - the Uint8Array to hash\n */\nconst hash160 = (payload, crypto = { ripemd160: _default_crypto_instances_js__WEBPACK_IMPORTED_MODULE_0__.ripemd160, sha256: _default_crypto_instances_js__WEBPACK_IMPORTED_MODULE_0__.sha256 }) => crypto.ripemd160.hash(crypto.sha256.hash(payload));\n/**\n * Hash the given payload with sha256, then hash the 32-byte result with\n * one final round of sha256, returning a 32-byte hash.\n *\n * This type of hash is used to generate identifiers for transactions and blocks\n * (and therefore in block mining).\n *\n * @param payload - the Uint8Array to hash\n */\nconst hash256 = (payload, sha256 = _default_crypto_instances_js__WEBPACK_IMPORTED_MODULE_0__.sha256) => sha256.hash(sha256.hash(payload));\n//# sourceMappingURL=combinations.js.map\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/crypto/combinations.js?");
|
|
173
173
|
|
|
174
174
|
/***/ }),
|
|
175
175
|
|
|
@@ -180,7 +180,7 @@ eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_de
|
|
|
180
180
|
/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
181
181
|
|
|
182
182
|
"use strict";
|
|
183
|
-
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ripemd160\": () => (/* binding */ ripemd160),\n/* harmony export */ \"secp256k1\": () => (/* binding */ secp256k1),\n/* harmony export */ \"sha256\": () => (/* binding */ sha256)
|
|
183
|
+
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ripemd160\": () => (/* binding */ ripemd160),\n/* harmony export */ \"secp256k1\": () => (/* binding */ secp256k1),\n/* harmony export */ \"sha1\": () => (/* binding */ sha1),\n/* harmony export */ \"sha256\": () => (/* binding */ sha256),\n/* harmony export */ \"sha512\": () => (/* binding */ sha512)\n/* harmony export */ });\n/* harmony import */ var _ripemd160_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ripemd160.js */ \"../../node_modules/@bitauth/libauth/build/lib/crypto/ripemd160.js\");\n/* harmony import */ var _secp256k1_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./secp256k1.js */ \"../../node_modules/@bitauth/libauth/build/lib/crypto/secp256k1.js\");\n/* harmony import */ var _sha1_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sha1.js */ \"../../node_modules/@bitauth/libauth/build/lib/crypto/sha1.js\");\n/* harmony import */ var _sha256_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sha256.js */ \"../../node_modules/@bitauth/libauth/build/lib/crypto/sha256.js\");\n/* harmony import */ var _sha512_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sha512.js */ \"../../node_modules/@bitauth/libauth/build/lib/crypto/sha512.js\");\n\n\n\n\n\nconst [sha1, sha256, sha512, ripemd160, secp256k1] = await Promise.all([\n (0,_sha1_js__WEBPACK_IMPORTED_MODULE_0__.instantiateSha1)(),\n (0,_sha256_js__WEBPACK_IMPORTED_MODULE_1__.instantiateSha256)(),\n (0,_sha512_js__WEBPACK_IMPORTED_MODULE_2__.instantiateSha512)(),\n (0,_ripemd160_js__WEBPACK_IMPORTED_MODULE_3__.instantiateRipemd160)(),\n (0,_secp256k1_js__WEBPACK_IMPORTED_MODULE_4__.instantiateSecp256k1)(),\n]);\n\n//# sourceMappingURL=default-crypto-instances.js.map\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }, 1);\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/crypto/default-crypto-instances.js?");
|
|
184
184
|
|
|
185
185
|
/***/ }),
|
|
186
186
|
|
|
@@ -191,7 +191,7 @@ eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_de
|
|
|
191
191
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
192
192
|
|
|
193
193
|
"use strict";
|
|
194
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"
|
|
194
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"getEmbeddedRipemd160Binary\": () => (/* binding */ getEmbeddedRipemd160Binary),\n/* harmony export */ \"instantiateRipemd160\": () => (/* binding */ instantiateRipemd160),\n/* harmony export */ \"instantiateRipemd160Bytes\": () => (/* binding */ instantiateRipemd160Bytes)\n/* harmony export */ });\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/hashes.js\");\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/base64.js\");\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/ripemd160/ripemd160.base64.js\");\n\n/**\n * The most performant way to instantiate ripemd160 functionality. To avoid\n * using Node.js or DOM-specific APIs, you can use {@link instantiateRipemd160}.\n *\n * @param webassemblyBytes - A buffer containing the ripemd160 binary.\n */\nconst instantiateRipemd160Bytes = async (webassemblyBytes) => {\n const wasm = await (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_0__.instantiateRustWasm)(webassemblyBytes, './ripemd160', 'ripemd160', 'ripemd160_init', 'ripemd160_update', 'ripemd160_final');\n return {\n final: wasm.final,\n hash: wasm.hash,\n init: wasm.init,\n update: wasm.update,\n };\n};\nconst getEmbeddedRipemd160Binary = () => (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_1__.base64ToBin)(_dependencies_js__WEBPACK_IMPORTED_MODULE_2__.ripemd160Base64Bytes).buffer;\n/**\n * An ultimately-portable (but slower) version of\n * {@link instantiateRipemd160Bytes} that does not require the consumer to\n * provide the ripemd160 binary buffer.\n */\nconst instantiateRipemd160 = async () => instantiateRipemd160Bytes(getEmbeddedRipemd160Binary());\n//# sourceMappingURL=ripemd160.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/crypto/ripemd160.js?");
|
|
195
195
|
|
|
196
196
|
/***/ }),
|
|
197
197
|
|
|
@@ -202,7 +202,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
202
202
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
203
203
|
|
|
204
204
|
"use strict";
|
|
205
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"instantiateSecp256k1\": () => (/* binding */ instantiateSecp256k1)\n/* harmony export */ });\n/* unused harmony exports Secp256k1Error, instantiateSecp256k1Bytes */\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/secp256k1/secp256k1-wasm-types.js\");\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/secp256k1/secp256k1-wasm.js\");\n\n/* eslint-enable @typescript-eslint/no-duplicate-enum-values */\nvar Secp256k1Error;\n(function (Secp256k1Error) {\n Secp256k1Error[\"unparsableSignature\"] = \"Failed to parse signature.\";\n Secp256k1Error[\"unparsablePublicKey\"] = \"Failed to parse public key.\";\n Secp256k1Error[\"derivePublicKeyFromInvalidPrivateKey\"] = \"Cannot derive public key from invalid private key.\";\n Secp256k1Error[\"signWithInvalidPrivateKey\"] = \"Failed to sign message hash. The private key is not valid.\";\n Secp256k1Error[\"recoverPublicKeyWithUnparsableSignature\"] = \"Failed to recover public key. Could not parse signature.\";\n Secp256k1Error[\"recoverPublicKeyInvalidMaterial\"] = \"Failed to recover public key. The compact signature, recovery, or message hash is invalid.\";\n Secp256k1Error[\"addTweakPrivateKey\"] = \"Private key is invalid or adding failed.\";\n Secp256k1Error[\"mulTweakPrivateKey\"] = \"Private key is invalid or multiplying failed.\";\n Secp256k1Error[\"addTweakPublicKey\"] = \"Failed to tweak public key (by addition).\";\n Secp256k1Error[\"mulTweakPublicKey\"] = \"Failed to tweak public key (by multiplication).\";\n})(Secp256k1Error || (Secp256k1Error = {}));\n/**\n * @param secp256k1Wasm - a Secp256k1Wasm object\n * @param randomSeed - a 32-byte random seed used to randomize the context after\n * creation\n */\nconst wrapSecp256k1Wasm = (secp256k1Wasm, randomSeed) => {\n /**\n * Currently, this wrapper creates a context with both SIGN and VERIFY\n * capabilities. For better initialization performance, consumers could\n * re-implement a wrapper with only the capabilities they require.\n */\n const contextPtr = secp256k1Wasm.contextCreate(_dependencies_js__WEBPACK_IMPORTED_MODULE_0__.ContextFlag.BOTH);\n /**\n * Since all of these methods are single-threaded and synchronous, we can\n * reuse allocated WebAssembly memory for each method without worrying about\n * calls interfering with each other. Likewise, these spaces never need to be\n * `free`d, since we will continue using them until this entire object (and\n * with it, the entire WebAssembly instance) is garbage collected.\n *\n * If malicious javascript gained access to this object, it should be\n * considered a critical vulnerability in the consumer. However, as a best\n * practice, we zero out private keys below when we're finished with them.\n */\n const sigScratch = secp256k1Wasm.malloc(72 /* ByteLength.maxECDSASig */);\n const publicKeyScratch = secp256k1Wasm.malloc(65 /* ByteLength.maxPublicKey */);\n const messageHashScratch = secp256k1Wasm.malloc(32 /* ByteLength.messageHash */);\n const internalPublicKeyPtr = secp256k1Wasm.malloc(64 /* ByteLength.internalPublicKey */);\n const internalSigPtr = secp256k1Wasm.malloc(64 /* ByteLength.internalSig */);\n const schnorrSigPtr = secp256k1Wasm.malloc(64 /* ByteLength.schnorrSig */);\n const privateKeyPtr = secp256k1Wasm.malloc(32 /* ByteLength.privateKey */);\n const internalRSigPtr = secp256k1Wasm.malloc(65 /* ByteLength.recoverableSig */);\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n const recoveryNumPtr = secp256k1Wasm.malloc(4);\n // eslint-disable-next-line no-bitwise, @typescript-eslint/no-magic-numbers\n const recoveryNumPtrView32 = recoveryNumPtr >> 2;\n const getRecoveryNumPtr = () => secp256k1Wasm.heapU32[recoveryNumPtrView32];\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n const lengthPtr = secp256k1Wasm.malloc(4);\n // eslint-disable-next-line no-bitwise, @typescript-eslint/no-magic-numbers\n const lengthPtrView32 = lengthPtr >> 2;\n const cloneAndPad = (value, expectedLength) => {\n const zeroPaddedValue = new Uint8Array(expectedLength);\n zeroPaddedValue.set(value);\n return zeroPaddedValue;\n };\n const parsePublicKey = (publicKey) => {\n const paddedPublicKey = cloneAndPad(publicKey, 65 /* ByteLength.maxPublicKey */);\n secp256k1Wasm.heapU8.set(paddedPublicKey, publicKeyScratch);\n return (secp256k1Wasm.pubkeyParse(contextPtr, internalPublicKeyPtr, publicKeyScratch, \n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n publicKey.length) === 1);\n };\n const setLengthPtr = (value) => {\n secp256k1Wasm.heapU32.set([value], lengthPtrView32);\n };\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const getLengthPtr = () => secp256k1Wasm.heapU32[lengthPtrView32];\n const serializePublicKey = (length, flag) => {\n setLengthPtr(length);\n secp256k1Wasm.pubkeySerialize(contextPtr, publicKeyScratch, lengthPtr, internalPublicKeyPtr, flag);\n return secp256k1Wasm.readHeapU8(publicKeyScratch, getLengthPtr()).slice();\n };\n const getSerializedPublicKey = (compressed) => compressed\n ? serializePublicKey(33 /* ByteLength.compressedPublicKey */, _dependencies_js__WEBPACK_IMPORTED_MODULE_0__.CompressionFlag.COMPRESSED)\n : serializePublicKey(65 /* ByteLength.uncompressedPublicKey */, _dependencies_js__WEBPACK_IMPORTED_MODULE_0__.CompressionFlag.UNCOMPRESSED);\n const convertPublicKey = (compressed) => (publicKey) => {\n if (!parsePublicKey(publicKey)) {\n return Secp256k1Error.unparsablePublicKey;\n }\n return getSerializedPublicKey(compressed);\n };\n const parseSignature = (signature, isDer) => {\n const paddedSignature = cloneAndPad(signature, 72 /* ByteLength.maxECDSASig */);\n secp256k1Wasm.heapU8.set(paddedSignature, sigScratch);\n return isDer\n ? secp256k1Wasm.signatureParseDER(contextPtr, internalSigPtr, sigScratch, signature.length) === 1\n : secp256k1Wasm.signatureParseCompact(contextPtr, internalSigPtr, sigScratch) === 1;\n };\n const getCompactSig = () => {\n secp256k1Wasm.signatureSerializeCompact(contextPtr, sigScratch, internalSigPtr);\n return secp256k1Wasm.readHeapU8(sigScratch, 64 /* ByteLength.compactSig */).slice();\n };\n const getDERSig = () => {\n setLengthPtr(72 /* ByteLength.maxECDSASig */);\n secp256k1Wasm.signatureSerializeDER(contextPtr, sigScratch, lengthPtr, internalSigPtr);\n return secp256k1Wasm.readHeapU8(sigScratch, getLengthPtr()).slice();\n };\n const convertSignature = (wasDER) => (signature) => {\n if (!parseSignature(signature, wasDER)) {\n return Secp256k1Error.unparsableSignature;\n }\n return wasDER ? getCompactSig() : getDERSig();\n };\n const fillPrivateKeyPtr = (privateKey) => {\n const paddedPrivateKey = cloneAndPad(privateKey, 32 /* ByteLength.privateKey */);\n secp256k1Wasm.heapU8.set(paddedPrivateKey, privateKeyPtr);\n };\n const zeroOutPtr = (pointer, bytes) => {\n secp256k1Wasm.heapU8.fill(0, pointer, pointer + bytes);\n };\n const zeroOutPrivateKeyPtr = () => {\n zeroOutPtr(privateKeyPtr, 32 /* ByteLength.privateKey */);\n };\n const withPrivateKey = (privateKey, instructions) => {\n fillPrivateKeyPtr(privateKey);\n const ret = instructions();\n zeroOutPrivateKeyPtr();\n return ret;\n };\n const derivePublicKey = (compressed) => (privateKey) => {\n const invalid = withPrivateKey(privateKey, () => secp256k1Wasm.pubkeyCreate(contextPtr, internalPublicKeyPtr, privateKeyPtr) !== 1);\n if (invalid) {\n return Secp256k1Error.derivePublicKeyFromInvalidPrivateKey;\n }\n return getSerializedPublicKey(compressed);\n };\n const fillMessageHashScratch = (messageHash) => {\n const paddedMessageHash = cloneAndPad(messageHash, 32 /* ByteLength.messageHash */);\n secp256k1Wasm.heapU8.set(paddedMessageHash, messageHashScratch);\n };\n const normalizeSignature = () => {\n secp256k1Wasm.signatureNormalize(contextPtr, internalSigPtr, internalSigPtr);\n };\n const modifySignature = (isDer, normalize) => (signature) => {\n if (!parseSignature(signature, isDer)) {\n return Secp256k1Error.unparsableSignature;\n }\n if (normalize) {\n normalizeSignature();\n }\n else {\n secp256k1Wasm.signatureMalleate(contextPtr, internalSigPtr, internalSigPtr);\n }\n return isDer ? getDERSig() : getCompactSig();\n };\n const parseAndNormalizeSignature = (signature, isDer, normalize) => {\n const ret = parseSignature(signature, isDer);\n if (normalize) {\n normalizeSignature();\n }\n return ret;\n };\n const signMessageHash = (isDer) => (privateKey, messageHash) => {\n fillMessageHashScratch(messageHash);\n return withPrivateKey(privateKey, () => {\n const failed = secp256k1Wasm.sign(contextPtr, internalSigPtr, messageHashScratch, privateKeyPtr) !== 1;\n if (failed) {\n return Secp256k1Error.signWithInvalidPrivateKey;\n }\n if (isDer) {\n setLengthPtr(72 /* ByteLength.maxECDSASig */);\n secp256k1Wasm.signatureSerializeDER(contextPtr, sigScratch, lengthPtr, internalSigPtr);\n return secp256k1Wasm.readHeapU8(sigScratch, getLengthPtr()).slice();\n }\n secp256k1Wasm.signatureSerializeCompact(contextPtr, sigScratch, internalSigPtr);\n return secp256k1Wasm\n .readHeapU8(sigScratch, 64 /* ByteLength.compactSig */)\n .slice();\n });\n };\n const signMessageHashSchnorr = () => (privateKey, messageHash) => {\n fillMessageHashScratch(messageHash);\n return withPrivateKey(privateKey, () => {\n const failed = secp256k1Wasm.schnorrSign(contextPtr, schnorrSigPtr, messageHashScratch, privateKeyPtr) !== 1;\n if (failed) {\n return Secp256k1Error.signWithInvalidPrivateKey;\n }\n return secp256k1Wasm\n .readHeapU8(schnorrSigPtr, 64 /* ByteLength.schnorrSig */)\n .slice();\n });\n };\n const verifyMessage = (messageHash) => {\n fillMessageHashScratch(messageHash);\n return (secp256k1Wasm.verify(contextPtr, internalSigPtr, messageHashScratch, internalPublicKeyPtr) === 1);\n };\n const verifySignature = (isDer, normalize) => (signature, publicKey, messageHash) => parsePublicKey(publicKey) &&\n parseAndNormalizeSignature(signature, isDer, normalize) &&\n verifyMessage(messageHash);\n const verifyMessageSchnorr = (messageHash, signature) => {\n fillMessageHashScratch(messageHash);\n const paddedSignature = cloneAndPad(signature, 64 /* ByteLength.schnorrSig */);\n secp256k1Wasm.heapU8.set(paddedSignature, schnorrSigPtr);\n return (secp256k1Wasm.schnorrVerify(contextPtr, schnorrSigPtr, messageHashScratch, internalPublicKeyPtr) === 1);\n };\n const verifySignatureSchnorr = () => (signature, publicKey, messageHash) => parsePublicKey(publicKey)\n ? verifyMessageSchnorr(messageHash, signature)\n : false;\n const signMessageHashRecoverable = (privateKey, messageHash) => {\n fillMessageHashScratch(messageHash);\n return withPrivateKey(privateKey, () => {\n if (secp256k1Wasm.signRecoverable(contextPtr, internalRSigPtr, messageHashScratch, privateKeyPtr) !== 1) {\n return Secp256k1Error.signWithInvalidPrivateKey;\n }\n secp256k1Wasm.recoverableSignatureSerialize(contextPtr, sigScratch, recoveryNumPtr, internalRSigPtr);\n return {\n recoveryId: getRecoveryNumPtr(),\n signature: secp256k1Wasm\n .readHeapU8(sigScratch, 64 /* ByteLength.compactSig */)\n .slice(),\n };\n });\n };\n const recoverPublicKey = (compressed) => (signature, recoveryId, messageHash) => {\n fillMessageHashScratch(messageHash);\n const paddedSignature = cloneAndPad(signature, 72 /* ByteLength.maxECDSASig */);\n secp256k1Wasm.heapU8.set(paddedSignature, sigScratch);\n if (secp256k1Wasm.recoverableSignatureParse(contextPtr, internalRSigPtr, sigScratch, recoveryId) !== 1) {\n return Secp256k1Error.recoverPublicKeyWithUnparsableSignature;\n }\n if (secp256k1Wasm.recover(contextPtr, internalPublicKeyPtr, internalRSigPtr, messageHashScratch) !== 1) {\n return Secp256k1Error.recoverPublicKeyInvalidMaterial;\n }\n return getSerializedPublicKey(compressed);\n };\n const addTweakPrivateKey = (privateKey, tweakValue) => {\n fillMessageHashScratch(tweakValue);\n return withPrivateKey(privateKey, () => {\n if (secp256k1Wasm.privkeyTweakAdd(contextPtr, privateKeyPtr, messageHashScratch) !== 1) {\n return Secp256k1Error.addTweakPrivateKey;\n }\n return secp256k1Wasm\n .readHeapU8(privateKeyPtr, 32 /* ByteLength.privateKey */)\n .slice();\n });\n };\n const mulTweakPrivateKey = (privateKey, tweakValue) => {\n fillMessageHashScratch(tweakValue);\n return withPrivateKey(privateKey, () => {\n if (secp256k1Wasm.privkeyTweakMul(contextPtr, privateKeyPtr, messageHashScratch) !== 1) {\n return Secp256k1Error.mulTweakPrivateKey;\n }\n return secp256k1Wasm\n .readHeapU8(privateKeyPtr, 32 /* ByteLength.privateKey */)\n .slice();\n });\n };\n const addTweakPublicKey = (compressed) => (publicKey, tweakValue) => {\n if (!parsePublicKey(publicKey)) {\n return Secp256k1Error.unparsablePublicKey;\n }\n fillMessageHashScratch(tweakValue);\n if (secp256k1Wasm.pubkeyTweakAdd(contextPtr, internalPublicKeyPtr, messageHashScratch) !== 1) {\n return Secp256k1Error.addTweakPublicKey;\n }\n return getSerializedPublicKey(compressed);\n };\n const mulTweakPublicKey = (compressed) => (publicKey, tweakValue) => {\n if (!parsePublicKey(publicKey)) {\n return Secp256k1Error.unparsablePublicKey;\n }\n fillMessageHashScratch(tweakValue);\n if (secp256k1Wasm.pubkeyTweakMul(contextPtr, internalPublicKeyPtr, messageHashScratch) !== 1) {\n return Secp256k1Error.mulTweakPublicKey;\n }\n return getSerializedPublicKey(compressed);\n };\n if (randomSeed !== undefined) {\n const randomSeedPtr = messageHashScratch;\n const paddedRandomSeed = cloneAndPad(randomSeed, 32 /* ByteLength.randomSeed */);\n secp256k1Wasm.heapU8.set(paddedRandomSeed, randomSeedPtr);\n secp256k1Wasm.contextRandomize(contextPtr, randomSeedPtr);\n zeroOutPtr(randomSeedPtr, 32 /* ByteLength.randomSeed */);\n }\n return {\n addTweakPrivateKey,\n addTweakPublicKeyCompressed: addTweakPublicKey(true),\n addTweakPublicKeyUncompressed: addTweakPublicKey(false),\n compressPublicKey: convertPublicKey(true),\n derivePublicKeyCompressed: derivePublicKey(true),\n derivePublicKeyUncompressed: derivePublicKey(false),\n malleateSignatureCompact: modifySignature(false, false),\n malleateSignatureDER: modifySignature(true, false),\n mulTweakPrivateKey,\n mulTweakPublicKeyCompressed: mulTweakPublicKey(true),\n mulTweakPublicKeyUncompressed: mulTweakPublicKey(false),\n normalizeSignatureCompact: modifySignature(false, true),\n normalizeSignatureDER: modifySignature(true, true),\n recoverPublicKeyCompressed: recoverPublicKey(true),\n recoverPublicKeyUncompressed: recoverPublicKey(false),\n signMessageHashCompact: signMessageHash(false),\n signMessageHashDER: signMessageHash(true),\n signMessageHashRecoverableCompact: signMessageHashRecoverable,\n signMessageHashSchnorr: signMessageHashSchnorr(),\n signatureCompactToDER: convertSignature(false),\n signatureDERToCompact: convertSignature(true),\n uncompressPublicKey: convertPublicKey(false),\n validatePrivateKey: (privateKey) => withPrivateKey(privateKey, () => secp256k1Wasm.seckeyVerify(contextPtr, privateKeyPtr) === 1),\n validatePublicKey: parsePublicKey,\n verifySignatureCompact: verifySignature(false, true),\n verifySignatureCompactLowS: verifySignature(false, false),\n verifySignatureDER: verifySignature(true, true),\n verifySignatureDERLowS: verifySignature(true, false),\n verifySignatureSchnorr: verifySignatureSchnorr(),\n };\n};\n/**\n * This method is like {@link instantiateSecp256k1}, but requires the consumer\n * to `Window.fetch` or `fs.readFile` the `secp256k1.wasm` binary and provide it\n * to this method as `webassemblyBytes`. This skips a base64 decoding of an\n * embedded binary.\n *\n * ### Randomizing the Context with `randomSeed`\n * This method also accepts an optional, 32-byte `randomSeed`, which is passed\n * to the `contextRandomize` method in the underlying WebAssembly.\n *\n * In the secp256k1 C library, context randomization is an additional layer of\n * security from side-channel attacks that attempt to extract private key\n * information by analyzing things like a CPU's emitted radio frequencies or\n * power usage.\n *\n * As most applications also benefit from deterministic, reproducible behavior,\n * context is not randomized by default in Libauth. To randomize the context,\n * provide a 32-byte Uint8Array of cryptographically strong random values\n * (e.g. `crypto.getRandomValues(new Uint8Array(32))`).\n *\n * @param webassemblyBytes - an ArrayBuffer containing the bytes from Libauth's\n * `secp256k1.wasm` binary. Providing this buffer manually may be faster than\n * the internal base64 decode that happens in {@link instantiateSecp256k1}.\n * @param randomSeed - a 32-byte random seed used to randomize the secp256k1\n * context after creation. See above for details.\n */\nconst instantiateSecp256k1Bytes = async (webassemblyBytes, randomSeed) => wrapSecp256k1Wasm(await (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_1__.instantiateSecp256k1WasmBytes)(webassemblyBytes), randomSeed);\n/**\n * Create and wrap a Secp256k1 WebAssembly instance to expose a set of\n * purely-functional Secp256k1 methods. For slightly faster initialization, use\n * {@link instantiateSecp256k1Bytes}.\n *\n * @param randomSeed - a 32-byte random seed used to randomize the secp256k1\n * context after creation. See the description in\n * {@link instantiateSecp256k1Bytes} for details.\n */\nconst instantiateSecp256k1 = async (randomSeed) => wrapSecp256k1Wasm(await (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_1__.instantiateSecp256k1Wasm)(), randomSeed);\n//# sourceMappingURL=secp256k1.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/crypto/secp256k1.js?");
|
|
205
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Secp256k1Error\": () => (/* binding */ Secp256k1Error),\n/* harmony export */ \"instantiateSecp256k1\": () => (/* binding */ instantiateSecp256k1),\n/* harmony export */ \"instantiateSecp256k1Bytes\": () => (/* binding */ instantiateSecp256k1Bytes)\n/* harmony export */ });\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/secp256k1/secp256k1-wasm-types.js\");\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/secp256k1/secp256k1-wasm.js\");\n\n/* eslint-enable @typescript-eslint/no-duplicate-enum-values */\nvar Secp256k1Error;\n(function (Secp256k1Error) {\n Secp256k1Error[\"unparsableSignature\"] = \"Failed to parse signature.\";\n Secp256k1Error[\"unparsablePublicKey\"] = \"Failed to parse public key.\";\n Secp256k1Error[\"derivePublicKeyFromInvalidPrivateKey\"] = \"Cannot derive public key from invalid private key.\";\n Secp256k1Error[\"signWithInvalidPrivateKey\"] = \"Failed to sign message hash. The private key is not valid.\";\n Secp256k1Error[\"recoverPublicKeyWithUnparsableSignature\"] = \"Failed to recover public key. Could not parse signature.\";\n Secp256k1Error[\"recoverPublicKeyInvalidMaterial\"] = \"Failed to recover public key. The compact signature, recovery, or message hash is invalid.\";\n Secp256k1Error[\"addTweakPrivateKey\"] = \"Private key is invalid or adding failed.\";\n Secp256k1Error[\"mulTweakPrivateKey\"] = \"Private key is invalid or multiplying failed.\";\n Secp256k1Error[\"addTweakPublicKey\"] = \"Failed to tweak public key (by addition).\";\n Secp256k1Error[\"mulTweakPublicKey\"] = \"Failed to tweak public key (by multiplication).\";\n})(Secp256k1Error || (Secp256k1Error = {}));\n/**\n * @param secp256k1Wasm - a Secp256k1Wasm object\n * @param randomSeed - a 32-byte random seed used to randomize the context after\n * creation\n */\nconst wrapSecp256k1Wasm = (secp256k1Wasm, randomSeed) => {\n /**\n * Currently, this wrapper creates a context with both SIGN and VERIFY\n * capabilities. For better initialization performance, consumers could\n * re-implement a wrapper with only the capabilities they require.\n */\n const contextPtr = secp256k1Wasm.contextCreate(_dependencies_js__WEBPACK_IMPORTED_MODULE_0__.ContextFlag.BOTH);\n /**\n * Since all of these methods are single-threaded and synchronous, we can\n * reuse allocated WebAssembly memory for each method without worrying about\n * calls interfering with each other. Likewise, these spaces never need to be\n * `free`d, since we will continue using them until this entire object (and\n * with it, the entire WebAssembly instance) is garbage collected.\n *\n * If malicious javascript gained access to this object, it should be\n * considered a critical vulnerability in the consumer. However, as a best\n * practice, we zero out private keys below when we're finished with them.\n */\n const sigScratch = secp256k1Wasm.malloc(72 /* ByteLength.maxECDSASig */);\n const publicKeyScratch = secp256k1Wasm.malloc(65 /* ByteLength.maxPublicKey */);\n const messageHashScratch = secp256k1Wasm.malloc(32 /* ByteLength.messageHash */);\n const internalPublicKeyPtr = secp256k1Wasm.malloc(64 /* ByteLength.internalPublicKey */);\n const internalSigPtr = secp256k1Wasm.malloc(64 /* ByteLength.internalSig */);\n const schnorrSigPtr = secp256k1Wasm.malloc(64 /* ByteLength.schnorrSig */);\n const privateKeyPtr = secp256k1Wasm.malloc(32 /* ByteLength.privateKey */);\n const internalRSigPtr = secp256k1Wasm.malloc(65 /* ByteLength.recoverableSig */);\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n const recoveryNumPtr = secp256k1Wasm.malloc(4);\n // eslint-disable-next-line no-bitwise, @typescript-eslint/no-magic-numbers\n const recoveryNumPtrView32 = recoveryNumPtr >> 2;\n const getRecoveryNumPtr = () => secp256k1Wasm.heapU32[recoveryNumPtrView32];\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n const lengthPtr = secp256k1Wasm.malloc(4);\n // eslint-disable-next-line no-bitwise, @typescript-eslint/no-magic-numbers\n const lengthPtrView32 = lengthPtr >> 2;\n const cloneAndPad = (value, expectedLength) => {\n const zeroPaddedValue = new Uint8Array(expectedLength);\n zeroPaddedValue.set(value);\n return zeroPaddedValue;\n };\n const parsePublicKey = (publicKey) => {\n const paddedPublicKey = cloneAndPad(publicKey, 65 /* ByteLength.maxPublicKey */);\n secp256k1Wasm.heapU8.set(paddedPublicKey, publicKeyScratch);\n return (secp256k1Wasm.pubkeyParse(contextPtr, internalPublicKeyPtr, publicKeyScratch, \n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n publicKey.length) === 1);\n };\n const setLengthPtr = (value) => {\n secp256k1Wasm.heapU32.set([value], lengthPtrView32);\n };\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const getLengthPtr = () => secp256k1Wasm.heapU32[lengthPtrView32];\n const serializePublicKey = (length, flag) => {\n setLengthPtr(length);\n secp256k1Wasm.pubkeySerialize(contextPtr, publicKeyScratch, lengthPtr, internalPublicKeyPtr, flag);\n return secp256k1Wasm.readHeapU8(publicKeyScratch, getLengthPtr()).slice();\n };\n const getSerializedPublicKey = (compressed) => compressed\n ? serializePublicKey(33 /* ByteLength.compressedPublicKey */, _dependencies_js__WEBPACK_IMPORTED_MODULE_0__.CompressionFlag.COMPRESSED)\n : serializePublicKey(65 /* ByteLength.uncompressedPublicKey */, _dependencies_js__WEBPACK_IMPORTED_MODULE_0__.CompressionFlag.UNCOMPRESSED);\n const convertPublicKey = (compressed) => (publicKey) => {\n if (!parsePublicKey(publicKey)) {\n return Secp256k1Error.unparsablePublicKey;\n }\n return getSerializedPublicKey(compressed);\n };\n const parseSignature = (signature, isDer) => {\n const paddedSignature = cloneAndPad(signature, 72 /* ByteLength.maxECDSASig */);\n secp256k1Wasm.heapU8.set(paddedSignature, sigScratch);\n return isDer\n ? secp256k1Wasm.signatureParseDER(contextPtr, internalSigPtr, sigScratch, signature.length) === 1\n : secp256k1Wasm.signatureParseCompact(contextPtr, internalSigPtr, sigScratch) === 1;\n };\n const getCompactSig = () => {\n secp256k1Wasm.signatureSerializeCompact(contextPtr, sigScratch, internalSigPtr);\n return secp256k1Wasm.readHeapU8(sigScratch, 64 /* ByteLength.compactSig */).slice();\n };\n const getDERSig = () => {\n setLengthPtr(72 /* ByteLength.maxECDSASig */);\n secp256k1Wasm.signatureSerializeDER(contextPtr, sigScratch, lengthPtr, internalSigPtr);\n return secp256k1Wasm.readHeapU8(sigScratch, getLengthPtr()).slice();\n };\n const convertSignature = (wasDER) => (signature) => {\n if (!parseSignature(signature, wasDER)) {\n return Secp256k1Error.unparsableSignature;\n }\n return wasDER ? getCompactSig() : getDERSig();\n };\n const fillPrivateKeyPtr = (privateKey) => {\n const paddedPrivateKey = cloneAndPad(privateKey, 32 /* ByteLength.privateKey */);\n secp256k1Wasm.heapU8.set(paddedPrivateKey, privateKeyPtr);\n };\n const zeroOutPtr = (pointer, bytes) => {\n secp256k1Wasm.heapU8.fill(0, pointer, pointer + bytes);\n };\n const zeroOutPrivateKeyPtr = () => {\n zeroOutPtr(privateKeyPtr, 32 /* ByteLength.privateKey */);\n };\n const withPrivateKey = (privateKey, instructions) => {\n fillPrivateKeyPtr(privateKey);\n const ret = instructions();\n zeroOutPrivateKeyPtr();\n return ret;\n };\n const derivePublicKey = (compressed) => (privateKey) => {\n const invalid = withPrivateKey(privateKey, () => secp256k1Wasm.pubkeyCreate(contextPtr, internalPublicKeyPtr, privateKeyPtr) !== 1);\n if (invalid) {\n return Secp256k1Error.derivePublicKeyFromInvalidPrivateKey;\n }\n return getSerializedPublicKey(compressed);\n };\n const fillMessageHashScratch = (messageHash) => {\n const paddedMessageHash = cloneAndPad(messageHash, 32 /* ByteLength.messageHash */);\n secp256k1Wasm.heapU8.set(paddedMessageHash, messageHashScratch);\n };\n const normalizeSignature = () => {\n secp256k1Wasm.signatureNormalize(contextPtr, internalSigPtr, internalSigPtr);\n };\n const modifySignature = (isDer, normalize) => (signature) => {\n if (!parseSignature(signature, isDer)) {\n return Secp256k1Error.unparsableSignature;\n }\n if (normalize) {\n normalizeSignature();\n }\n else {\n secp256k1Wasm.signatureMalleate(contextPtr, internalSigPtr, internalSigPtr);\n }\n return isDer ? getDERSig() : getCompactSig();\n };\n const parseAndNormalizeSignature = (signature, isDer, normalize) => {\n const ret = parseSignature(signature, isDer);\n if (normalize) {\n normalizeSignature();\n }\n return ret;\n };\n const signMessageHash = (isDer) => (privateKey, messageHash) => {\n fillMessageHashScratch(messageHash);\n return withPrivateKey(privateKey, () => {\n const failed = secp256k1Wasm.sign(contextPtr, internalSigPtr, messageHashScratch, privateKeyPtr) !== 1;\n if (failed) {\n return Secp256k1Error.signWithInvalidPrivateKey;\n }\n if (isDer) {\n setLengthPtr(72 /* ByteLength.maxECDSASig */);\n secp256k1Wasm.signatureSerializeDER(contextPtr, sigScratch, lengthPtr, internalSigPtr);\n return secp256k1Wasm.readHeapU8(sigScratch, getLengthPtr()).slice();\n }\n secp256k1Wasm.signatureSerializeCompact(contextPtr, sigScratch, internalSigPtr);\n return secp256k1Wasm\n .readHeapU8(sigScratch, 64 /* ByteLength.compactSig */)\n .slice();\n });\n };\n const signMessageHashSchnorr = () => (privateKey, messageHash) => {\n fillMessageHashScratch(messageHash);\n return withPrivateKey(privateKey, () => {\n const failed = secp256k1Wasm.schnorrSign(contextPtr, schnorrSigPtr, messageHashScratch, privateKeyPtr) !== 1;\n if (failed) {\n return Secp256k1Error.signWithInvalidPrivateKey;\n }\n return secp256k1Wasm\n .readHeapU8(schnorrSigPtr, 64 /* ByteLength.schnorrSig */)\n .slice();\n });\n };\n const verifyMessage = (messageHash) => {\n fillMessageHashScratch(messageHash);\n return (secp256k1Wasm.verify(contextPtr, internalSigPtr, messageHashScratch, internalPublicKeyPtr) === 1);\n };\n const verifySignature = (isDer, normalize) => (signature, publicKey, messageHash) => parsePublicKey(publicKey) &&\n parseAndNormalizeSignature(signature, isDer, normalize) &&\n verifyMessage(messageHash);\n const verifyMessageSchnorr = (messageHash, signature) => {\n fillMessageHashScratch(messageHash);\n const paddedSignature = cloneAndPad(signature, 64 /* ByteLength.schnorrSig */);\n secp256k1Wasm.heapU8.set(paddedSignature, schnorrSigPtr);\n return (secp256k1Wasm.schnorrVerify(contextPtr, schnorrSigPtr, messageHashScratch, internalPublicKeyPtr) === 1);\n };\n const verifySignatureSchnorr = () => (signature, publicKey, messageHash) => parsePublicKey(publicKey)\n ? verifyMessageSchnorr(messageHash, signature)\n : false;\n const signMessageHashRecoverable = (privateKey, messageHash) => {\n fillMessageHashScratch(messageHash);\n return withPrivateKey(privateKey, () => {\n if (secp256k1Wasm.signRecoverable(contextPtr, internalRSigPtr, messageHashScratch, privateKeyPtr) !== 1) {\n return Secp256k1Error.signWithInvalidPrivateKey;\n }\n secp256k1Wasm.recoverableSignatureSerialize(contextPtr, sigScratch, recoveryNumPtr, internalRSigPtr);\n return {\n recoveryId: getRecoveryNumPtr(),\n signature: secp256k1Wasm\n .readHeapU8(sigScratch, 64 /* ByteLength.compactSig */)\n .slice(),\n };\n });\n };\n const recoverPublicKey = (compressed) => (signature, recoveryId, messageHash) => {\n fillMessageHashScratch(messageHash);\n const paddedSignature = cloneAndPad(signature, 72 /* ByteLength.maxECDSASig */);\n secp256k1Wasm.heapU8.set(paddedSignature, sigScratch);\n if (secp256k1Wasm.recoverableSignatureParse(contextPtr, internalRSigPtr, sigScratch, recoveryId) !== 1) {\n return Secp256k1Error.recoverPublicKeyWithUnparsableSignature;\n }\n if (secp256k1Wasm.recover(contextPtr, internalPublicKeyPtr, internalRSigPtr, messageHashScratch) !== 1) {\n return Secp256k1Error.recoverPublicKeyInvalidMaterial;\n }\n return getSerializedPublicKey(compressed);\n };\n const addTweakPrivateKey = (privateKey, tweakValue) => {\n fillMessageHashScratch(tweakValue);\n return withPrivateKey(privateKey, () => {\n if (secp256k1Wasm.privkeyTweakAdd(contextPtr, privateKeyPtr, messageHashScratch) !== 1) {\n return Secp256k1Error.addTweakPrivateKey;\n }\n return secp256k1Wasm\n .readHeapU8(privateKeyPtr, 32 /* ByteLength.privateKey */)\n .slice();\n });\n };\n const mulTweakPrivateKey = (privateKey, tweakValue) => {\n fillMessageHashScratch(tweakValue);\n return withPrivateKey(privateKey, () => {\n if (secp256k1Wasm.privkeyTweakMul(contextPtr, privateKeyPtr, messageHashScratch) !== 1) {\n return Secp256k1Error.mulTweakPrivateKey;\n }\n return secp256k1Wasm\n .readHeapU8(privateKeyPtr, 32 /* ByteLength.privateKey */)\n .slice();\n });\n };\n const addTweakPublicKey = (compressed) => (publicKey, tweakValue) => {\n if (!parsePublicKey(publicKey)) {\n return Secp256k1Error.unparsablePublicKey;\n }\n fillMessageHashScratch(tweakValue);\n if (secp256k1Wasm.pubkeyTweakAdd(contextPtr, internalPublicKeyPtr, messageHashScratch) !== 1) {\n return Secp256k1Error.addTweakPublicKey;\n }\n return getSerializedPublicKey(compressed);\n };\n const mulTweakPublicKey = (compressed) => (publicKey, tweakValue) => {\n if (!parsePublicKey(publicKey)) {\n return Secp256k1Error.unparsablePublicKey;\n }\n fillMessageHashScratch(tweakValue);\n if (secp256k1Wasm.pubkeyTweakMul(contextPtr, internalPublicKeyPtr, messageHashScratch) !== 1) {\n return Secp256k1Error.mulTweakPublicKey;\n }\n return getSerializedPublicKey(compressed);\n };\n if (randomSeed !== undefined) {\n const randomSeedPtr = messageHashScratch;\n const paddedRandomSeed = cloneAndPad(randomSeed, 32 /* ByteLength.randomSeed */);\n secp256k1Wasm.heapU8.set(paddedRandomSeed, randomSeedPtr);\n secp256k1Wasm.contextRandomize(contextPtr, randomSeedPtr);\n zeroOutPtr(randomSeedPtr, 32 /* ByteLength.randomSeed */);\n }\n return {\n addTweakPrivateKey,\n addTweakPublicKeyCompressed: addTweakPublicKey(true),\n addTweakPublicKeyUncompressed: addTweakPublicKey(false),\n compressPublicKey: convertPublicKey(true),\n derivePublicKeyCompressed: derivePublicKey(true),\n derivePublicKeyUncompressed: derivePublicKey(false),\n malleateSignatureCompact: modifySignature(false, false),\n malleateSignatureDER: modifySignature(true, false),\n mulTweakPrivateKey,\n mulTweakPublicKeyCompressed: mulTweakPublicKey(true),\n mulTweakPublicKeyUncompressed: mulTweakPublicKey(false),\n normalizeSignatureCompact: modifySignature(false, true),\n normalizeSignatureDER: modifySignature(true, true),\n recoverPublicKeyCompressed: recoverPublicKey(true),\n recoverPublicKeyUncompressed: recoverPublicKey(false),\n signMessageHashCompact: signMessageHash(false),\n signMessageHashDER: signMessageHash(true),\n signMessageHashRecoverableCompact: signMessageHashRecoverable,\n signMessageHashSchnorr: signMessageHashSchnorr(),\n signatureCompactToDER: convertSignature(false),\n signatureDERToCompact: convertSignature(true),\n uncompressPublicKey: convertPublicKey(false),\n validatePrivateKey: (privateKey) => withPrivateKey(privateKey, () => secp256k1Wasm.seckeyVerify(contextPtr, privateKeyPtr) === 1),\n validatePublicKey: parsePublicKey,\n verifySignatureCompact: verifySignature(false, true),\n verifySignatureCompactLowS: verifySignature(false, false),\n verifySignatureDER: verifySignature(true, true),\n verifySignatureDERLowS: verifySignature(true, false),\n verifySignatureSchnorr: verifySignatureSchnorr(),\n };\n};\n/**\n * This method is like {@link instantiateSecp256k1}, but requires the consumer\n * to `Window.fetch` or `fs.readFile` the `secp256k1.wasm` binary and provide it\n * to this method as `webassemblyBytes`. This skips a base64 decoding of an\n * embedded binary.\n *\n * ### Randomizing the Context with `randomSeed`\n * This method also accepts an optional, 32-byte `randomSeed`, which is passed\n * to the `contextRandomize` method in the underlying WebAssembly.\n *\n * In the secp256k1 C library, context randomization is an additional layer of\n * security from side-channel attacks that attempt to extract private key\n * information by analyzing things like a CPU's emitted radio frequencies or\n * power usage.\n *\n * As most applications also benefit from deterministic, reproducible behavior,\n * context is not randomized by default in Libauth. To randomize the context,\n * provide a 32-byte Uint8Array of cryptographically strong random values\n * (e.g. `crypto.getRandomValues(new Uint8Array(32))`).\n *\n * @param webassemblyBytes - an ArrayBuffer containing the bytes from Libauth's\n * `secp256k1.wasm` binary. Providing this buffer manually may be faster than\n * the internal base64 decode that happens in {@link instantiateSecp256k1}.\n * @param randomSeed - a 32-byte random seed used to randomize the secp256k1\n * context after creation. See above for details.\n */\nconst instantiateSecp256k1Bytes = async (webassemblyBytes, randomSeed) => wrapSecp256k1Wasm(await (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_1__.instantiateSecp256k1WasmBytes)(webassemblyBytes), randomSeed);\n/**\n * Create and wrap a Secp256k1 WebAssembly instance to expose a set of\n * purely-functional Secp256k1 methods. For slightly faster initialization, use\n * {@link instantiateSecp256k1Bytes}.\n *\n * @param randomSeed - a 32-byte random seed used to randomize the secp256k1\n * context after creation. See the description in\n * {@link instantiateSecp256k1Bytes} for details.\n */\nconst instantiateSecp256k1 = async (randomSeed) => wrapSecp256k1Wasm(await (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_1__.instantiateSecp256k1Wasm)(), randomSeed);\n//# sourceMappingURL=secp256k1.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/crypto/secp256k1.js?");
|
|
206
206
|
|
|
207
207
|
/***/ }),
|
|
208
208
|
|
|
@@ -213,7 +213,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
213
213
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
214
214
|
|
|
215
215
|
"use strict";
|
|
216
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"
|
|
216
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"getEmbeddedSha1Binary\": () => (/* binding */ getEmbeddedSha1Binary),\n/* harmony export */ \"instantiateSha1\": () => (/* binding */ instantiateSha1),\n/* harmony export */ \"instantiateSha1Bytes\": () => (/* binding */ instantiateSha1Bytes)\n/* harmony export */ });\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/hashes.js\");\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/base64.js\");\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/sha1/sha1.base64.js\");\n\n/**\n * The most performant way to instantiate sha1 functionality. To avoid\n * using Node.js or DOM-specific APIs, you can use {@link instantiateSha1}.\n *\n * @param webassemblyBytes - A buffer containing the sha1 binary.\n */\nconst instantiateSha1Bytes = async (webassemblyBytes) => {\n const wasm = await (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_0__.instantiateRustWasm)(webassemblyBytes, './sha1', 'sha1', 'sha1_init', 'sha1_update', 'sha1_final');\n return {\n final: wasm.final,\n hash: wasm.hash,\n init: wasm.init,\n update: wasm.update,\n };\n};\nconst getEmbeddedSha1Binary = () => (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_1__.base64ToBin)(_dependencies_js__WEBPACK_IMPORTED_MODULE_2__.sha1Base64Bytes).buffer;\n/**\n * An ultimately-portable (but slower) version of {@link instantiateSha1Bytes}\n * that does not require the consumer to provide the sha1 binary buffer.\n */\nconst instantiateSha1 = async () => instantiateSha1Bytes(getEmbeddedSha1Binary());\n//# sourceMappingURL=sha1.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/crypto/sha1.js?");
|
|
217
217
|
|
|
218
218
|
/***/ }),
|
|
219
219
|
|
|
@@ -224,7 +224,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
224
224
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
225
225
|
|
|
226
226
|
"use strict";
|
|
227
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"
|
|
227
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"getEmbeddedSha256Binary\": () => (/* binding */ getEmbeddedSha256Binary),\n/* harmony export */ \"instantiateSha256\": () => (/* binding */ instantiateSha256),\n/* harmony export */ \"instantiateSha256Bytes\": () => (/* binding */ instantiateSha256Bytes)\n/* harmony export */ });\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/hashes.js\");\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/base64.js\");\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/sha256/sha256.base64.js\");\n\n/**\n * The most performant way to instantiate sha256 functionality. To avoid\n * using Node.js or DOM-specific APIs, you can use {@link instantiateSha256}.\n *\n * @param webassemblyBytes - A buffer containing the sha256 binary.\n */\nconst instantiateSha256Bytes = async (webassemblyBytes) => {\n const wasm = await (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_0__.instantiateRustWasm)(webassemblyBytes, './sha256', 'sha256', 'sha256_init', 'sha256_update', 'sha256_final');\n return {\n final: wasm.final,\n hash: wasm.hash,\n init: wasm.init,\n update: wasm.update,\n };\n};\nconst getEmbeddedSha256Binary = () => (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_1__.base64ToBin)(_dependencies_js__WEBPACK_IMPORTED_MODULE_2__.sha256Base64Bytes).buffer;\n/**\n * An ultimately-portable (but possibly slower) version of\n * {@link instantiateSha256Bytes} which does not require the consumer to provide\n * the sha256 binary buffer.\n */\nconst instantiateSha256 = async () => instantiateSha256Bytes(getEmbeddedSha256Binary());\n//# sourceMappingURL=sha256.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/crypto/sha256.js?");
|
|
228
228
|
|
|
229
229
|
/***/ }),
|
|
230
230
|
|
|
@@ -235,7 +235,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
235
235
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
236
236
|
|
|
237
237
|
"use strict";
|
|
238
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"
|
|
238
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"getEmbeddedSha512Binary\": () => (/* binding */ getEmbeddedSha512Binary),\n/* harmony export */ \"instantiateSha512\": () => (/* binding */ instantiateSha512),\n/* harmony export */ \"instantiateSha512Bytes\": () => (/* binding */ instantiateSha512Bytes)\n/* harmony export */ });\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/hashes.js\");\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/base64.js\");\n/* harmony import */ var _dependencies_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dependencies.js */ \"../../node_modules/@bitauth/libauth/build/lib/bin/sha512/sha512.base64.js\");\n\n/**\n * The most performant way to instantiate sha512 functionality. To avoid\n * using Node.js or DOM-specific APIs, you can use {@link instantiateSha512}.\n *\n * @param webassemblyBytes - A buffer containing the sha512 binary.\n */\nconst instantiateSha512Bytes = async (webassemblyBytes) => {\n const wasm = await (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_0__.instantiateRustWasm)(webassemblyBytes, './sha512', 'sha512', 'sha512_init', 'sha512_update', 'sha512_final');\n return {\n final: wasm.final,\n hash: wasm.hash,\n init: wasm.init,\n update: wasm.update,\n };\n};\nconst getEmbeddedSha512Binary = () => (0,_dependencies_js__WEBPACK_IMPORTED_MODULE_1__.base64ToBin)(_dependencies_js__WEBPACK_IMPORTED_MODULE_2__.sha512Base64Bytes).buffer;\n/**\n * An ultimately-portable (but slower) version of {@link instantiateSha512Bytes}\n * that does not require the consumer to provide the sha512 binary buffer.\n */\nconst instantiateSha512 = async () => instantiateSha512Bytes(getEmbeddedSha512Binary());\n//# sourceMappingURL=sha512.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/crypto/sha512.js?");
|
|
239
239
|
|
|
240
240
|
/***/ }),
|
|
241
241
|
|
|
@@ -246,7 +246,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
246
246
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
247
247
|
|
|
248
248
|
"use strict";
|
|
249
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"base64ToBin\": () => (/* binding */ base64ToBin)
|
|
249
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"base64ToBin\": () => (/* binding */ base64ToBin),\n/* harmony export */ \"binToBase64\": () => (/* binding */ binToBase64),\n/* harmony export */ \"isBase64\": () => (/* binding */ isBase64)\n/* harmony export */ });\n// base64 encode/decode derived from: https://github.com/niklasvh/base64-arraybuffer\nconst chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nconst base64GroupLength = 4;\nconst nonBase64Chars = new RegExp(`[^${chars}=]`, 'u');\n/**\n * For use before {@link base64ToBin}. Returns true if the provided string is\n * valid base64 (length is divisible by 4, only uses base64 characters).\n * @param maybeBase64 - a string to test\n */\nconst isBase64 = (maybeBase64) => maybeBase64.length % base64GroupLength === 0 &&\n !nonBase64Chars.test(maybeBase64);\n/* eslint-disable functional/no-expression-statements, functional/immutable-data, @typescript-eslint/no-magic-numbers, no-bitwise, no-plusplus, @typescript-eslint/no-non-null-assertion */\n/**\n * Convert a base64-encoded string to a Uint8Array.\n *\n * Note, this method always completes. If `validBase64` is not valid base64, an\n * incorrect result will be returned. If `validBase64` is potentially malformed,\n * check it with {@link isBase64} before calling this method.\n *\n * For the reverse, see {@link binToBase64}.\n *\n * @param validBase64 - a valid base64-encoded string to decode\n */\nconst base64ToBin = (validBase64) => {\n const lookup = new Uint8Array(123);\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements\n for (let i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n }\n const bufferLengthEstimate = validBase64.length * 0.75;\n const stringLength = validBase64.length;\n const bufferLength = validBase64[validBase64.length - 1] === '=' // eslint-disable-line @typescript-eslint/prefer-string-starts-ends-with\n ? validBase64[validBase64.length - 2] === '='\n ? bufferLengthEstimate - 2\n : bufferLengthEstimate - 1\n : bufferLengthEstimate;\n const buffer = new ArrayBuffer(bufferLength);\n const bytes = new Uint8Array(buffer);\n // eslint-disable-next-line functional/no-let\n let p = 0;\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements\n for (let i = 0; i < stringLength; i += 4) {\n const encoded1 = lookup[validBase64.charCodeAt(i)];\n const encoded2 = lookup[validBase64.charCodeAt(i + 1)];\n const encoded3 = lookup[validBase64.charCodeAt(i + 2)];\n const encoded4 = lookup[validBase64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return bytes;\n};\n/**\n * Convert a Uint8Array to a base64-encoded string.\n *\n * For the reverse, see {@link base64ToBin}.\n *\n * @param bytes - the Uint8Array to base64 encode\n */\nconst binToBase64 = (bytes) => {\n // eslint-disable-next-line functional/no-let\n let result = '';\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements\n for (let i = 0; i < bytes.length; i += 3) {\n result += chars[bytes[i] >> 2];\n result += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n result += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n result += chars[bytes[i + 2] & 63];\n }\n const padded = bytes.length % 3 === 2\n ? `${result.substring(0, result.length - 1)}=`\n : bytes.length % 3 === 1\n ? `${result.substring(0, result.length - 2)}==`\n : result;\n return padded;\n};\n/* eslint-enable functional/no-expression-statements, functional/immutable-data, @typescript-eslint/no-magic-numbers, no-bitwise, no-plusplus, @typescript-eslint/no-non-null-assertion */\n//# sourceMappingURL=base64.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/format/base64.js?");
|
|
250
250
|
|
|
251
251
|
/***/ }),
|
|
252
252
|
|
|
@@ -257,7 +257,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
257
257
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
258
258
|
|
|
259
259
|
"use strict";
|
|
260
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"assertSuccess\": () => (/* binding */ assertSuccess),\n/* harmony export */ \"formatError\": () => (/* binding */ formatError)
|
|
260
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"assertNonNull\": () => (/* binding */ assertNonNull),\n/* harmony export */ \"assertSuccess\": () => (/* binding */ assertSuccess),\n/* harmony export */ \"formatError\": () => (/* binding */ formatError),\n/* harmony export */ \"unknownValue\": () => (/* binding */ unknownValue)\n/* harmony export */ });\n/**\n * A simple method used throughout Libauth to format error messages. By\n * formatting errors this way, downstream consumers can detect specific error\n * types by matching the `errorType`. For example, the error:\n *\n * ```ts\n * formatError(SomeTypeOfError.exceedsMaximum, `Provided value: ${value}`);\n * ```\n *\n * Can be detected with `String.includes()`, even if the\n * `SomeTypeOfError.exceedsMaximum` error message changes:\n * ```ts\n * error.includes(SomeTypeOfError.exceedsMaximum);\n * // => true\n * ```\n *\n * Using this method ensures consistency across the library.\n *\n * @remarks\n * In Libauth, expected errors use the type `string` rather than `Error` (or\n * other objects that inherit from `Error`) to simplify the resulting types and\n * typechecking requirements. This ensures consistency of returned errors in all\n * environments, avoids exposing internal details like stack traces and line\n * numbers, and allows error messages to be recorded or used as text without an\n * intermediate `toString()` method.\n *\n * @param errorType - the error enum member representing this error type\n * @param errorDetails - optional, additional details to include in the error\n * message\n * @param throwError - if `true`, the function will throw an `Error` rather than\n * returning the string (defaults to `false`).\n */\nconst formatError = (errorType, errorDetails, throwError = false) => {\n const message = `${errorType}${errorDetails === undefined ? '' : ` ${errorDetails}`}`;\n if (throwError) {\n // eslint-disable-next-line functional/no-throw-statements\n throw new Error(message);\n }\n return message;\n};\n/**\n *\n * @param value - the unexpected value\n * @param message - an optional error message\n */\nconst unknownValue = (value, message = `Received an unknown value; this should have been caught by TypeScript - are your types correct?`) => formatError(message, String(value), true);\n/**\n * A utility to handle error results by throwing an `Error` object.\n *\n * If the provided value is of type `string`, the contents of the string are\n * thrown as a new `Error`, otherwise, the value is returned unmodified.\n *\n * This method is useful for eliminating `string` as a possible type from a\n * resulting value, particularly in places where an error is never expected to\n * occur in practice (i.e. no user or runtime input is involved), e.g.:\n *\n * ```ts\n * import { assertSuccess, decodeCashAddress, binToHex } from '@bitauth/libauth';\n * const address = 'bitcoincash:zq2azmyyv6dtgczexyalqar70q036yund5j2mspghf';\n *\n * // Might be either a string or a decoded address:\n * const decoded = decodeCashAddress(address);\n * // Now guaranteed to be a decoded address (error messages are thrown):\n * const tokenAddress = assertSuccess(decoded);\n * // The result can be used immediately:\n * console.log(binToHex(tokenAddress.payload));\n * ```\n *\n * @param result - A result which might be a string.\n * @param expectation - An optional, descriptive prefix for the error message\n * thrown in failure cases. By default,\n * `Expected a successful result, but encountered an error: `.\n */\nconst assertSuccess = (result, expectation = 'Expected a successful result, but encountered an error: ') => {\n // eslint-disable-next-line functional/no-throw-statements\n if (typeof result === 'string')\n throw new Error(`${expectation}${result}`);\n return result;\n};\nconst assertNonNull = (value, expectation = 'Expected a non-null value, but encountered: ') => {\n if (value === null || value === undefined) {\n // eslint-disable-next-line functional/no-throw-statements\n throw new Error(`${expectation}${String(value)}`);\n }\n return value;\n};\n//# sourceMappingURL=error.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/format/error.js?");
|
|
261
261
|
|
|
262
262
|
/***/ }),
|
|
263
263
|
|
|
@@ -268,7 +268,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
268
268
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
269
269
|
|
|
270
270
|
"use strict";
|
|
271
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"binToHex\": () => (/* binding */ binToHex),\n/* harmony export */ \"flattenBinArray\": () => (/* binding */ flattenBinArray),\n/* harmony export */ \"hexToBin\": () => (/* binding */ hexToBin)
|
|
271
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"binToHex\": () => (/* binding */ binToHex),\n/* harmony export */ \"binsAreEqual\": () => (/* binding */ binsAreEqual),\n/* harmony export */ \"flattenBinArray\": () => (/* binding */ flattenBinArray),\n/* harmony export */ \"hexToBin\": () => (/* binding */ hexToBin),\n/* harmony export */ \"isHex\": () => (/* binding */ isHex),\n/* harmony export */ \"range\": () => (/* binding */ range),\n/* harmony export */ \"splitEvery\": () => (/* binding */ splitEvery),\n/* harmony export */ \"swapEndianness\": () => (/* binding */ swapEndianness)\n/* harmony export */ });\n/**\n * Returns an array of incrementing values starting at `begin` and incrementing\n * by one for `length`.\n *\n * E.g.: `range(3)` → `[0, 1, 2]` and `range(3, 1)` → `[1, 2, 3]`\n *\n * @param length - the number of elements in the array\n * @param begin - the index at which the range starts (default: `0`)\n */\nconst range = (length, begin = 0) => Array.from({ length }, (_, index) => begin + index);\n/**\n * Split a string into an array of `chunkLength` strings. The final string may\n * have a length between 1 and `chunkLength`.\n *\n * E.g.: `splitEvery('abcde', 2)` → `['ab', 'cd', 'e']`\n */\nconst splitEvery = (input, chunkLength) => range(Math.ceil(input.length / chunkLength))\n .map((index) => index * chunkLength)\n .map((begin) => input.slice(begin, begin + chunkLength));\nconst hexByteWidth = 2;\nconst hexadecimal = 16;\n/**\n * Decode a hexadecimal-encoded string into a Uint8Array.\n *\n * E.g.: `hexToBin('2a64ff')` → `new Uint8Array([42, 100, 255])`\n *\n * Note, this method always completes. If `validHex` is not divisible by 2,\n * the final byte will be parsed as if it were prepended with a `0` (e.g. `aaa`\n * is interpreted as `aa0a`). If `validHex` is potentially malformed, check\n * it with {@link isHex} before calling this method.\n *\n * For the reverse, see {@link binToHex}.\n *\n * @param validHex - a string of valid, hexadecimal-encoded data\n */\nconst hexToBin = (validHex) => Uint8Array.from(splitEvery(validHex, hexByteWidth).map((byte) => parseInt(byte, hexadecimal)));\n/**\n * For use before {@link hexToBin}. Returns true if the provided string is valid\n * hexadecimal (length is divisible by 2, only uses hexadecimal characters).\n * @param maybeHex - a string to test\n */\nconst isHex = (maybeHex) => maybeHex.length % hexByteWidth === 0 && !/[^a-fA-F0-9]/u.test(maybeHex);\n/**\n * Encode a Uint8Array into a hexadecimal-encoded string.\n *\n * E.g.: `binToHex(new Uint8Array([42, 100, 255]))` → `'2a64ff'`\n *\n * For the reverse, see {@link hexToBin}.\n *\n * @param bytes - a Uint8Array to encode\n */\nconst binToHex = (bytes) => bytes.reduce((str, byte) => str + byte.toString(hexadecimal).padStart(hexByteWidth, '0'), '');\n/**\n * Decode a hexadecimal-encoded string into bytes, reverse it, then re-encode.\n *\n * @param validHex - a string of valid, hexadecimal-encoded data. See\n * {@link hexToBin} for more information.\n */\nconst swapEndianness = (validHex) => binToHex(hexToBin(validHex).reverse());\n/**\n * Reduce an array of `Uint8Array`s into a single `Uint8Array`.\n * @param array - the array of `Uint8Array`s to flatten\n */\nconst flattenBinArray = (array) => {\n const totalLength = array.reduce((total, bin) => total + bin.length, 0);\n const flattened = new Uint8Array(totalLength);\n // eslint-disable-next-line functional/no-expression-statements\n array.reduce((index, bin) => {\n // eslint-disable-next-line functional/no-expression-statements\n flattened.set(bin, index);\n return index + bin.length;\n }, 0);\n return flattened;\n};\n/**\n * Compare to `Uint8Array`s, return true if their contents are exactly the same,\n * otherwise return false.\n * @param a - the first Uint8Array\n * @param b - the second Uint8Array\n */\nconst binsAreEqual = (a, b) => {\n if (a.length !== b.length) {\n return false;\n }\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements, no-plusplus\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n};\n//# sourceMappingURL=hex.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/format/hex.js?");
|
|
272
272
|
|
|
273
273
|
/***/ }),
|
|
274
274
|
|
|
@@ -279,7 +279,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
279
279
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
280
280
|
|
|
281
281
|
"use strict";
|
|
282
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"bigIntToCompactUint\": () => (/* binding */ bigIntToCompactUint),\n/* harmony export */ \"binToBigIntUint64LE\": () => (/* binding */ binToBigIntUint64LE),\n/* harmony export */ \"binToNumberUint16LE\": () => (/* binding */ binToNumberUint16LE),\n/* harmony export */ \"binToNumberUint32LE\": () => (/* binding */ binToNumberUint32LE),\n/* harmony export */ \"numberToBinUint32LE\": () => (/* binding */ numberToBinUint32LE),\n/* harmony export */ \"readCompactUintMinimal\": () => (/* binding */ readCompactUintMinimal),\n/* harmony export */ \"valueSatoshisToBin\": () => (/* binding */ valueSatoshisToBin)\n/* harmony export */ });\n/* unused harmony exports numberToBinUintLE, binToFixedLength, numberToBinUint16LEClamped, numberToBinUint32LEClamped, numberToBinUint16LE, numberToBinInt16LE, numberToBinInt32LE, binToNumberInt16LE, binToNumberInt32LE, numberToBinUint16BE, numberToBinUint32BE, bigIntToBinUintLE, bigIntToBinUint64LEClamped, bigIntToBinUint64LE, numberToBinInt32TwosCompliment, binToNumberUintLE, binToBigIntUintBE, bigIntToBinUintBE, binToBigIntUint256BE, bigIntToBinUint256BEClamped, binToBigIntUintLE, binToValueSatoshis, compactUintPrefixToLength, CompactUintError, readCompactUint, compactUintToBigInt, int32SignedToUnsigned, int32UnsignedToSigned */\n/* harmony import */ var _error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./error.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/error.js\");\n\n/**\n * Encode a positive integer as a little-endian Uint8Array. For values exceeding\n * `Number.MAX_SAFE_INTEGER` (`9007199254740991`),\n * use {@link bigIntToBinUintLE}.\n *\n * Negative values will return the same result as `0`.\n *\n * For the reverse, see {@link binToNumberUintLE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUintLE = (value) => {\n const baseUint8Array = 256;\n const result = [];\n // eslint-disable-next-line functional/no-let\n let remaining = value;\n // eslint-disable-next-line functional/no-loop-statements\n while (remaining >= baseUint8Array) {\n // eslint-disable-next-line functional/no-expression-statements, functional/immutable-data\n result.push(remaining % baseUint8Array);\n // eslint-disable-next-line functional/no-expression-statements\n remaining = Math.floor(remaining / baseUint8Array);\n }\n // eslint-disable-next-line functional/no-conditional-statements, functional/no-expression-statements, functional/immutable-data\n if (remaining > 0)\n result.push(remaining);\n return Uint8Array.from(result);\n};\n/**\n * Fill a new Uint8Array of a specific byte-length with the contents of a given\n * Uint8Array, truncating or padding the Uint8Array with zeros.\n *\n * @param bin - the Uint8Array to resize\n * @param bytes - the desired byte-length\n */\nconst binToFixedLength = (bin, bytes) => {\n const fixedBytes = new Uint8Array(bytes);\n const maxValue = 255;\n // eslint-disable-next-line functional/no-expression-statements, @typescript-eslint/no-unused-expressions\n bin.length > bytes ? fixedBytes.fill(maxValue) : fixedBytes.set(bin);\n return fixedBytes;\n};\n/**\n * Encode a positive integer as a 2-byte Uint16LE Uint8Array, clamping the\n * results – values exceeding `0xffff` (`65535`) return the same result as\n * `0xffff`, negative values will return the same result as `0`.\n *\n * For an alternative overflow behavior, see {@link numberToBinUint16LE}.\n *\n * For the reverse, see {@link binToNumberUint16LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint16LEClamped = (value) => {\n const uint16 = 2;\n return binToFixedLength(numberToBinUintLE(value), uint16);\n};\n/**\n * Encode a positive integer as a 4-byte Uint32LE Uint8Array, clamping the\n * results – values exceeding `0xffffffff` (`4294967295`) return the same result\n * as `0xffffffff`, negative values will return the same result as `0`.\n *\n * For an alternative overflow behavior, see {@link numberToBinUint32LE}.\n *\n * For the reverse, see {@link binToNumberUint32LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint32LEClamped = (value) => {\n const uint32 = 4;\n return binToFixedLength(numberToBinUintLE(value), uint32);\n};\n/**\n * Encode a positive integer as a 2-byte Uint16LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0` to `0xffff` (`65535`). If applicable, applications should handle such\n * cases prior to calling this method.\n *\n * For an alternative overflow behavior, see {@link numberToBinUint16LEClamped}.\n *\n * For the reverse, see {@link binToNumberUint16LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint16LE = (value) => {\n const uint16Length = 2;\n const bin = new Uint8Array(uint16Length);\n const writeAsLittleEndian = true;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setUint16(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Encode an integer as a 2-byte Int16LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0x0000` to `0xffff` (`65535`). If applicable, applications should handle\n * such cases prior to calling this method.\n *\n * For the reverse, see {@link binToNumberInt16LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinInt16LE = (value) => {\n const int16Length = 2;\n const bin = new Uint8Array(int16Length);\n const writeAsLittleEndian = true;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setInt16(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Encode an integer as a 4-byte Uint32LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0x00000000` to `0xffffffff` (`4294967295`). If applicable, applications\n * should handle such cases prior to calling this method.\n *\n * For the reverse, see {@link binToNumberInt32LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinInt32LE = (value) => {\n const int32Length = 4;\n const bin = new Uint8Array(int32Length);\n const writeAsLittleEndian = true;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setInt32(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Decode a 2-byte Int16LE Uint8Array into a number.\n *\n * Throws if `bin` is shorter than 2 bytes.\n *\n * For the reverse, see {@link numberToBinInt16LE}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToNumberInt16LE = (bin) => {\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n const readAsLittleEndian = true;\n return view.getInt16(0, readAsLittleEndian);\n};\n/**\n * Decode a 4-byte Int32LE Uint8Array into a number.\n *\n * Throws if `bin` is shorter than 4 bytes.\n *\n * For the reverse, see {@link numberToBinInt32LE}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToNumberInt32LE = (bin) => {\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n const readAsLittleEndian = true;\n return view.getInt32(0, readAsLittleEndian);\n};\n/**\n * Encode a positive integer as a 2-byte Uint16LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0` to `0xffff` (`65535`). If applicable, applications should handle such\n * cases prior to calling this method.\n *\n * For the reverse, reverse the result of {@link binToNumberUint16LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint16BE = (value) => {\n const uint16Length = 2;\n const bin = new Uint8Array(uint16Length);\n const writeAsLittleEndian = false;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setUint16(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Encode a positive number as a 4-byte Uint32LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0` to `0xffffffff` (`4294967295`). If applicable, applications should handle\n * such cases prior to calling this method.\n *\n * For an alternative overflow behavior, see {@link numberToBinUint32LEClamped}.\n *\n * For the reverse, see {@link binToNumberUint32LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint32LE = (value) => {\n const uint32Length = 4;\n const bin = new Uint8Array(uint32Length);\n const writeAsLittleEndian = true;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setUint32(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Encode a positive number as a 4-byte Uint32BE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0` to `0xffffffff` (`4294967295`). If applicable, applications should handle\n * such cases prior to calling this method.\n *\n * For the reverse, reverse the result of {@link binToNumberUint32LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint32BE = (value) => {\n const uint32Length = 4;\n const bin = new Uint8Array(uint32Length);\n const writeAsLittleEndian = false;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setUint32(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Encode a positive BigInt as little-endian Uint8Array. Negative values will\n * return the same result as `0`.\n *\n * For the reverse, see {@link binToBigIntUintLE}.\n *\n * @param value - the number to encode\n */\nconst bigIntToBinUintLE = (value) => {\n const baseUint8Array = 256;\n const base = BigInt(baseUint8Array);\n const result = [];\n // eslint-disable-next-line functional/no-let\n let remaining = value;\n // eslint-disable-next-line functional/no-loop-statements\n while (remaining >= base) {\n // eslint-disable-next-line functional/no-expression-statements, functional/immutable-data\n result.push(Number(remaining % base));\n // eslint-disable-next-line functional/no-expression-statements\n remaining /= base;\n }\n // eslint-disable-next-line functional/no-conditional-statements, functional/no-expression-statements, functional/immutable-data\n if (remaining > 0n)\n result.push(Number(remaining));\n return Uint8Array.from(result.length > 0 ? result : [0]);\n};\n/**\n * Encode a positive BigInt as an 8-byte Uint64LE Uint8Array, clamping the\n * results – values exceeding `0xffff_ffff_ffff_ffff` (`18446744073709551615`)\n * return the same result as `0xffff_ffff_ffff_ffff`, negative values return the\n * same result as `0`.\n *\n * For an alternative overflow behavior, see {@link bigIntToBinUint64LE}.\n *\n * For the reverse, see {@link binToBigIntUint64LE}.\n *\n * @param value - the number to encode\n */\nconst bigIntToBinUint64LEClamped = (value) => {\n const uint64 = 8;\n return binToFixedLength(bigIntToBinUintLE(value), uint64);\n};\n/**\n * Encode a positive BigInt as an 8-byte Uint64LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0` to `0xffff_ffff_ffff_ffff` (`18446744073709551615`).\n *\n * For an alternative overflow behavior, see {@link bigIntToBinUint64LEClamped}.\n *\n * For the reverse, see {@link binToBigIntUint64LE}.\n *\n * @param value - the number to encode\n */\nconst bigIntToBinUint64LE = (value) => {\n const uint64LengthInBits = 64;\n const valueAsUint64 = BigInt.asUintN(uint64LengthInBits, value);\n const fixedLengthBin = bigIntToBinUint64LEClamped(valueAsUint64);\n return fixedLengthBin;\n};\n/**\n * Encode an integer as a 4-byte, little-endian Uint8Array using the number's\n * two's compliment representation (the format used by JavaScript's bitwise\n * operators).\n *\n * @remarks\n * The C++ bitcoin implementations sometimes represent short vectors using\n * signed 32-bit integers (e.g. `sighashType`). This method can be used to test\n * compatibility with those implementations.\n *\n * @param value - the number to encode\n */\nconst numberToBinInt32TwosCompliment = (value) => {\n const bytes = 4;\n const bitsInAByte = 8;\n const bin = new Uint8Array(bytes);\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements, no-plusplus\n for (let index = 0; index < bytes; index++) {\n // eslint-disable-next-line functional/no-expression-statements, functional/immutable-data\n bin[index] = value;\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, no-param-reassign\n value >>>= bitsInAByte;\n }\n return bin;\n};\n/**\n * Decode a little-endian Uint8Array of any length into a number. For numbers\n * larger than `Number.MAX_SAFE_INTEGER` (`9007199254740991`), use\n * `binToBigIntUintLE`.\n *\n * The `bytes` parameter can be set to constrain the expected length (default:\n * `bin.length`). This method throws if `bin.length` is not equal to `bytes`.\n *\n * For the reverse, see {@link numberToBinUintLE}.\n *\n * @privateRemarks\n * We avoid a bitwise strategy here because JavaScript uses 32-bit signed\n * integers for bitwise math, so larger numbers are converted incorrectly. E.g.\n * `2147483648 << 8` is `0`, while `2147483648n << 8n` is `549755813888n`.\n *\n * @param bin - the Uint8Array to decode\n * @param bytes - the number of bytes to read (default: `bin.length`)\n */\nconst binToNumberUintLE = (bin, bytes = bin.length) => {\n const base = 2;\n const bitsInAByte = 8;\n if (bin.length !== bytes) {\n // eslint-disable-next-line functional/no-throw-statements\n throw new TypeError(`Bin length must be ${bytes}.`);\n }\n return new Uint8Array(bin.buffer, bin.byteOffset, bin.length).reduce((accumulated, byte, i) => accumulated + byte * base ** (bitsInAByte * i), 0);\n};\n/**\n * Decode a 2-byte Uint16LE Uint8Array into a number.\n *\n * Throws if `bin` is shorter than 2 bytes.\n *\n * For the reverse, see {@link numberToBinUint16LE}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToNumberUint16LE = (bin) => {\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n const readAsLittleEndian = true;\n return view.getUint16(0, readAsLittleEndian);\n};\n/**\n * Decode a 4-byte Uint32LE Uint8Array into a number.\n *\n * Throws if `bin` is shorter than 4 bytes.\n *\n * For the reverse, see {@link numberToBinUint32LE}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToNumberUint32LE = (bin) => {\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n const readAsLittleEndian = true;\n return view.getUint32(0, readAsLittleEndian);\n};\n/**\n * Decode a big-endian Uint8Array of any length into a BigInt. If starting from\n * a hex value, consider using the BigInt constructor instead:\n * ```\n * BigInt(`0x${hex}`)\n * ```\n *\n * The `bytes` parameter can be set to constrain the expected length (default:\n * `bin.length`). This method throws if `bin.length` is not equal to `bytes`.\n *\n * For the reverse, see {@link bigIntToBinUintBE}.\n *\n * @param bin - the Uint8Array to decode\n * @param bytes - the number of bytes to read (default: `bin.length`)\n */\nconst binToBigIntUintBE = (bin, bytes = bin.length) => {\n const bitsInAByte = 8;\n const shift = BigInt(bitsInAByte);\n if (bin.length !== bytes) {\n // eslint-disable-next-line functional/no-throw-statements\n throw new TypeError(`Bin length must be ${bytes}.`);\n }\n return new Uint8Array(bin.buffer, bin.byteOffset, bin.length).reduce(\n // eslint-disable-next-line no-bitwise\n (accumulated, byte) => (accumulated << shift) | BigInt(byte), 0n);\n};\n/**\n * Encode a positive BigInt as big-endian Uint8Array. Negative values will\n * return the same result as `0`.\n *\n * For the reverse, see {@link binToBigIntUintBE}.\n *\n * @param value - the number to encode\n */\nconst bigIntToBinUintBE = (value) => bigIntToBinUintLE(value).reverse();\n/**\n * Decode an unsigned, 32-byte big-endian Uint8Array into a BigInt. This can be\n * used to decode Uint8Array-encoded cryptographic primitives like private\n * keys, public keys, curve parameters, and signature points.\n *\n * If starting from a hex value, consider using the BigInt constructor instead:\n * ```\n * BigInt(`0x${hex}`)\n * ```\n *\n * For the reverse, see {@link bigIntToBinUint256BEClamped}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToBigIntUint256BE = (bin) => {\n const uint256Bytes = 32;\n return binToBigIntUintBE(bin, uint256Bytes);\n};\n/**\n * Encode a positive BigInt into an unsigned 32-byte big-endian Uint8Array. This\n * can be used to encoded numbers for cryptographic primitives like private\n * keys, public keys, curve parameters, and signature points.\n *\n * Negative values will return the same result as `0`, values higher than\n * 2^256-1 will return the maximum expressible unsigned 256-bit value\n * (`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`).\n *\n * For the reverse, see {@link binToBigIntUint256BE}.\n *\n * @param value - the BigInt to encode\n */\nconst bigIntToBinUint256BEClamped = (value) => {\n const uint256Bytes = 32;\n return binToFixedLength(bigIntToBinUintLE(value), uint256Bytes).reverse();\n};\n/**\n * Decode a little-endian Uint8Array of any length into a BigInt.\n *\n * The `bytes` parameter can be set to constrain the expected length (default:\n * `bin.length`). This method throws if `bin.length` is not equal to `bytes`.\n *\n * For the reverse, see {@link bigIntToBinUintLE}.\n *\n * @param bin - the Uint8Array to decode\n * @param bytes - the number of bytes to read (default: `bin.length`)\n */\nconst binToBigIntUintLE = (bin, bytes = bin.length) => {\n const bitsInAByte = 8;\n if (bin.length !== bytes) {\n // eslint-disable-next-line functional/no-throw-statements\n throw new TypeError(`Bin length must be ${bytes}.`);\n }\n return new Uint8Array(bin.buffer, bin.byteOffset, bin.length).reduceRight(\n // eslint-disable-next-line no-bitwise\n (accumulated, byte) => (accumulated << BigInt(bitsInAByte)) | BigInt(byte), 0n);\n};\n/**\n * Decode an 8-byte Uint64LE Uint8Array into a BigInt.\n *\n * Throws if `bin` is shorter than 8 bytes.\n *\n * For the reverse, see {@link bigIntToBinUint64LE}\n * or {@link bigIntToBinUint64LEClamped}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToBigIntUint64LE = (bin) => {\n const uint64LengthInBytes = 8;\n const truncatedBin = bin.length > uint64LengthInBytes ? bin.slice(0, uint64LengthInBytes) : bin;\n return binToBigIntUintLE(truncatedBin, uint64LengthInBytes);\n};\n/**\n * Decode an {@link Output.valueSatoshis} into a `BigInt`. This is an alias for\n * {@link binToBigIntUint64LE}.\n *\n * Throws if the provided value is shorter than 8 bytes.\n *\n * For the reverse, see {@link valueSatoshisToBin}.\n */\nconst binToValueSatoshis = binToBigIntUint64LE;\n/**\n * Encode a `BigInt` into an {@link Output.valueSatoshis}. This is an alias for\n * {@link bigIntToBinUint64LE}.\n *\n * This method will return an incorrect result for values outside of the range 0\n * to 0xffff_ffff_ffff_ffff (`18446744073709551615`).\n *\n * For the reverse, see {@link binToValueSatoshis}.\n */\nconst valueSatoshisToBin = bigIntToBinUint64LE;\n/**\n * Get the expected byte length of a CompactUint given a first byte.\n *\n * @param firstByte - the first byte of the CompactUint\n */\nconst compactUintPrefixToLength = (firstByte) => {\n switch (firstByte) {\n case 253 /* CompactUint.uint16Prefix */:\n return 2 /* CompactUint.uint16 */ + 1;\n case 254 /* CompactUint.uint32Prefix */:\n return 4 /* CompactUint.uint32 */ + 1;\n case 255 /* CompactUint.uint64Prefix */:\n return 8 /* CompactUint.uint64 */ + 1;\n default:\n return 1 /* CompactUint.uint8 */;\n }\n};\nvar CompactUintError;\n(function (CompactUintError) {\n CompactUintError[\"noPrefix\"] = \"Error reading CompactUint: requires at least one byte.\";\n CompactUintError[\"insufficientBytes\"] = \"Error reading CompactUint: insufficient bytes.\";\n CompactUintError[\"nonMinimal\"] = \"Error reading CompactUint: CompactUint is not minimally encoded.\";\n CompactUintError[\"excessiveBytes\"] = \"Error decoding CompactUint: unexpected bytes after CompactUint.\";\n})(CompactUintError || (CompactUintError = {}));\n/**\n * Read a non-minimally-encoded `CompactUint` (see {@link bigIntToCompactUint})\n * from the provided {@link ReadPosition}, returning either an error message (as\n * a string) or an object containing the value and the\n * next {@link ReadPosition}.\n *\n * Rather than this function, most applications should\n * use {@link readCompactUintMinimal}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * `CompactUint`\n */\nconst readCompactUint = (position) => {\n const { bin, index } = position;\n const prefix = bin[index];\n if (prefix === undefined) {\n return (0,_error_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CompactUintError.noPrefix);\n }\n const bytes = compactUintPrefixToLength(prefix);\n if (bin.length - index < bytes) {\n return (0,_error_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CompactUintError.insufficientBytes, `CompactUint prefix ${prefix} requires at least ${bytes} bytes. Remaining bytes: ${bin.length - index}`);\n }\n const hasPrefix = bytes !== 1;\n const contents = hasPrefix\n ? bin.subarray(index + 1, index + bytes)\n : bin.subarray(index, index + bytes);\n return {\n position: { bin, index: index + bytes },\n result: binToBigIntUintLE(contents),\n };\n};\n/**\n * Encode a positive BigInt as a `CompactUint` (Satoshi's variable-length,\n * positive integer format).\n *\n * Note: the maximum value of a CompactUint is `0xffff_ffff_ffff_ffff`\n * (`18446744073709551615`). This method will return an incorrect result for\n * values outside of the range `0` to `0xffff_ffff_ffff_ffff`. If applicable,\n * applications should handle such cases prior to calling this method.\n *\n * For the reverse, see {@link compactUintToBigInt}.\n *\n * @param value - the BigInt to encode (must be no larger than\n * `0xffff_ffff_ffff_ffff`)\n */\nconst bigIntToCompactUint = (value) => value <= BigInt(252 /* CompactUint.uint8MaxValue */)\n ? Uint8Array.of(Number(value))\n : value <= BigInt(65535 /* CompactUint.uint16MaxValue */)\n ? Uint8Array.from([\n 253 /* CompactUint.uint16Prefix */,\n ...numberToBinUint16LE(Number(value)),\n ])\n : value <= BigInt(4294967295 /* CompactUint.uint32MaxValue */)\n ? Uint8Array.from([\n 254 /* CompactUint.uint32Prefix */,\n ...numberToBinUint32LE(Number(value)),\n ])\n : Uint8Array.from([\n 255 /* CompactUint.uint64Prefix */,\n ...bigIntToBinUint64LE(value),\n ]);\n/**\n * Read a minimally-encoded `CompactUint` from the provided\n * {@link ReadPosition}, returning either an error message (as a string) or an\n * object containing the value and the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * `CompactUint`\n */\nconst readCompactUintMinimal = (position) => {\n const read = readCompactUint(position);\n if (typeof read === 'string') {\n return read;\n }\n const readLength = read.position.index - position.index;\n const canonicalEncoding = bigIntToCompactUint(read.result);\n if (readLength !== canonicalEncoding.length) {\n return (0,_error_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CompactUintError.nonMinimal, `Value: ${read.result.toString()}, encoded length: ${readLength}, canonical length: ${canonicalEncoding.length}`);\n }\n return read;\n};\n/**\n * Decode a minimally-encoded `CompactUint` (Satoshi's variable-length, positive\n * integer format) from a Uint8Array, returning the value as a BigInt. This\n * function returns an error if the entire input is not consumed – to read a\n * `CompactUint` from a position within a larger `Uint8Array`,\n * use {@link readCompactUintMinimal} or {@link readCompactUint}.\n *\n * For the reverse, see {@link bigIntToCompactUint}.\n *\n * @param bin - the Uint8Array from which to read the CompactUint\n */\nconst compactUintToBigInt = (bin) => {\n const read = readCompactUintMinimal({ bin, index: 0 });\n if (typeof read === 'string') {\n return read;\n }\n if (read.position.index !== bin.length) {\n return (0,_error_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CompactUintError.excessiveBytes, `CompactUint ends at index ${read.position.index}, but input includes ${bin.length} bytes.`);\n }\n return read.result;\n};\n/**\n * Convert a signed integer into it's two's compliment unsigned equivalent, e.g.\n * `0b11111111111111111111111111111110` is `-2` as a signed integer or\n * `4294967294` as an unsigned integer.\n *\n * For the reverse, see {@link int32UnsignedToSigned}.\n *\n * @param int32 - the number to convert\n */\nconst int32SignedToUnsigned = (int32) => \n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\nUint32Array.from(Int32Array.of(int32))[0];\n/**\n * Convert an unsigned integer into it's two's compliment signed equivalent,\n * e.g. `0b11111111111111111111111111111110` is `4294967294` as an unsigned\n * integer or `-2` as a signed integer.\n *\n * For the reverse, see {@link int32SignedToUnsigned}.\n *\n * @param int32 - the number to convert\n */\nconst int32UnsignedToSigned = (int32) => \n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\nInt32Array.from(Uint32Array.of(int32))[0];\n//# sourceMappingURL=number.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/format/number.js?");
|
|
282
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"CompactUintError\": () => (/* binding */ CompactUintError),\n/* harmony export */ \"bigIntToBinUint256BEClamped\": () => (/* binding */ bigIntToBinUint256BEClamped),\n/* harmony export */ \"bigIntToBinUint64LE\": () => (/* binding */ bigIntToBinUint64LE),\n/* harmony export */ \"bigIntToBinUint64LEClamped\": () => (/* binding */ bigIntToBinUint64LEClamped),\n/* harmony export */ \"bigIntToBinUintBE\": () => (/* binding */ bigIntToBinUintBE),\n/* harmony export */ \"bigIntToBinUintLE\": () => (/* binding */ bigIntToBinUintLE),\n/* harmony export */ \"bigIntToCompactUint\": () => (/* binding */ bigIntToCompactUint),\n/* harmony export */ \"binToBigIntUint256BE\": () => (/* binding */ binToBigIntUint256BE),\n/* harmony export */ \"binToBigIntUint64LE\": () => (/* binding */ binToBigIntUint64LE),\n/* harmony export */ \"binToBigIntUintBE\": () => (/* binding */ binToBigIntUintBE),\n/* harmony export */ \"binToBigIntUintLE\": () => (/* binding */ binToBigIntUintLE),\n/* harmony export */ \"binToFixedLength\": () => (/* binding */ binToFixedLength),\n/* harmony export */ \"binToNumberInt16LE\": () => (/* binding */ binToNumberInt16LE),\n/* harmony export */ \"binToNumberInt32LE\": () => (/* binding */ binToNumberInt32LE),\n/* harmony export */ \"binToNumberUint16LE\": () => (/* binding */ binToNumberUint16LE),\n/* harmony export */ \"binToNumberUint32LE\": () => (/* binding */ binToNumberUint32LE),\n/* harmony export */ \"binToNumberUintLE\": () => (/* binding */ binToNumberUintLE),\n/* harmony export */ \"binToValueSatoshis\": () => (/* binding */ binToValueSatoshis),\n/* harmony export */ \"compactUintPrefixToLength\": () => (/* binding */ compactUintPrefixToLength),\n/* harmony export */ \"compactUintToBigInt\": () => (/* binding */ compactUintToBigInt),\n/* harmony export */ \"int32SignedToUnsigned\": () => (/* binding */ int32SignedToUnsigned),\n/* harmony export */ \"int32UnsignedToSigned\": () => (/* binding */ int32UnsignedToSigned),\n/* harmony export */ \"numberToBinInt16LE\": () => (/* binding */ numberToBinInt16LE),\n/* harmony export */ \"numberToBinInt32LE\": () => (/* binding */ numberToBinInt32LE),\n/* harmony export */ \"numberToBinInt32TwosCompliment\": () => (/* binding */ numberToBinInt32TwosCompliment),\n/* harmony export */ \"numberToBinUint16BE\": () => (/* binding */ numberToBinUint16BE),\n/* harmony export */ \"numberToBinUint16LE\": () => (/* binding */ numberToBinUint16LE),\n/* harmony export */ \"numberToBinUint16LEClamped\": () => (/* binding */ numberToBinUint16LEClamped),\n/* harmony export */ \"numberToBinUint32BE\": () => (/* binding */ numberToBinUint32BE),\n/* harmony export */ \"numberToBinUint32LE\": () => (/* binding */ numberToBinUint32LE),\n/* harmony export */ \"numberToBinUint32LEClamped\": () => (/* binding */ numberToBinUint32LEClamped),\n/* harmony export */ \"numberToBinUintLE\": () => (/* binding */ numberToBinUintLE),\n/* harmony export */ \"readCompactUint\": () => (/* binding */ readCompactUint),\n/* harmony export */ \"readCompactUintMinimal\": () => (/* binding */ readCompactUintMinimal),\n/* harmony export */ \"valueSatoshisToBin\": () => (/* binding */ valueSatoshisToBin)\n/* harmony export */ });\n/* harmony import */ var _error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./error.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/error.js\");\n\n/**\n * Encode a positive integer as a little-endian Uint8Array. For values exceeding\n * `Number.MAX_SAFE_INTEGER` (`9007199254740991`),\n * use {@link bigIntToBinUintLE}.\n *\n * Negative values will return the same result as `0`.\n *\n * For the reverse, see {@link binToNumberUintLE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUintLE = (value) => {\n const baseUint8Array = 256;\n const result = [];\n // eslint-disable-next-line functional/no-let\n let remaining = value;\n // eslint-disable-next-line functional/no-loop-statements\n while (remaining >= baseUint8Array) {\n // eslint-disable-next-line functional/no-expression-statements, functional/immutable-data\n result.push(remaining % baseUint8Array);\n // eslint-disable-next-line functional/no-expression-statements\n remaining = Math.floor(remaining / baseUint8Array);\n }\n // eslint-disable-next-line functional/no-conditional-statements, functional/no-expression-statements, functional/immutable-data\n if (remaining > 0)\n result.push(remaining);\n return Uint8Array.from(result);\n};\n/**\n * Fill a new Uint8Array of a specific byte-length with the contents of a given\n * Uint8Array, truncating or padding the Uint8Array with zeros.\n *\n * @param bin - the Uint8Array to resize\n * @param bytes - the desired byte-length\n */\nconst binToFixedLength = (bin, bytes) => {\n const fixedBytes = new Uint8Array(bytes);\n const maxValue = 255;\n // eslint-disable-next-line functional/no-expression-statements, @typescript-eslint/no-unused-expressions\n bin.length > bytes ? fixedBytes.fill(maxValue) : fixedBytes.set(bin);\n return fixedBytes;\n};\n/**\n * Encode a positive integer as a 2-byte Uint16LE Uint8Array, clamping the\n * results – values exceeding `0xffff` (`65535`) return the same result as\n * `0xffff`, negative values will return the same result as `0`.\n *\n * For an alternative overflow behavior, see {@link numberToBinUint16LE}.\n *\n * For the reverse, see {@link binToNumberUint16LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint16LEClamped = (value) => {\n const uint16 = 2;\n return binToFixedLength(numberToBinUintLE(value), uint16);\n};\n/**\n * Encode a positive integer as a 4-byte Uint32LE Uint8Array, clamping the\n * results – values exceeding `0xffffffff` (`4294967295`) return the same result\n * as `0xffffffff`, negative values will return the same result as `0`.\n *\n * For an alternative overflow behavior, see {@link numberToBinUint32LE}.\n *\n * For the reverse, see {@link binToNumberUint32LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint32LEClamped = (value) => {\n const uint32 = 4;\n return binToFixedLength(numberToBinUintLE(value), uint32);\n};\n/**\n * Encode a positive integer as a 2-byte Uint16LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0` to `0xffff` (`65535`). If applicable, applications should handle such\n * cases prior to calling this method.\n *\n * For an alternative overflow behavior, see {@link numberToBinUint16LEClamped}.\n *\n * For the reverse, see {@link binToNumberUint16LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint16LE = (value) => {\n const uint16Length = 2;\n const bin = new Uint8Array(uint16Length);\n const writeAsLittleEndian = true;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setUint16(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Encode an integer as a 2-byte Int16LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0x0000` to `0xffff` (`65535`). If applicable, applications should handle\n * such cases prior to calling this method.\n *\n * For the reverse, see {@link binToNumberInt16LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinInt16LE = (value) => {\n const int16Length = 2;\n const bin = new Uint8Array(int16Length);\n const writeAsLittleEndian = true;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setInt16(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Encode an integer as a 4-byte Uint32LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0x00000000` to `0xffffffff` (`4294967295`). If applicable, applications\n * should handle such cases prior to calling this method.\n *\n * For the reverse, see {@link binToNumberInt32LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinInt32LE = (value) => {\n const int32Length = 4;\n const bin = new Uint8Array(int32Length);\n const writeAsLittleEndian = true;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setInt32(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Decode a 2-byte Int16LE Uint8Array into a number.\n *\n * Throws if `bin` is shorter than 2 bytes.\n *\n * For the reverse, see {@link numberToBinInt16LE}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToNumberInt16LE = (bin) => {\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n const readAsLittleEndian = true;\n return view.getInt16(0, readAsLittleEndian);\n};\n/**\n * Decode a 4-byte Int32LE Uint8Array into a number.\n *\n * Throws if `bin` is shorter than 4 bytes.\n *\n * For the reverse, see {@link numberToBinInt32LE}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToNumberInt32LE = (bin) => {\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n const readAsLittleEndian = true;\n return view.getInt32(0, readAsLittleEndian);\n};\n/**\n * Encode a positive integer as a 2-byte Uint16LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0` to `0xffff` (`65535`). If applicable, applications should handle such\n * cases prior to calling this method.\n *\n * For the reverse, reverse the result of {@link binToNumberUint16LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint16BE = (value) => {\n const uint16Length = 2;\n const bin = new Uint8Array(uint16Length);\n const writeAsLittleEndian = false;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setUint16(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Encode a positive number as a 4-byte Uint32LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0` to `0xffffffff` (`4294967295`). If applicable, applications should handle\n * such cases prior to calling this method.\n *\n * For an alternative overflow behavior, see {@link numberToBinUint32LEClamped}.\n *\n * For the reverse, see {@link binToNumberUint32LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint32LE = (value) => {\n const uint32Length = 4;\n const bin = new Uint8Array(uint32Length);\n const writeAsLittleEndian = true;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setUint32(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Encode a positive number as a 4-byte Uint32BE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0` to `0xffffffff` (`4294967295`). If applicable, applications should handle\n * such cases prior to calling this method.\n *\n * For the reverse, reverse the result of {@link binToNumberUint32LE}.\n *\n * @param value - the number to encode\n */\nconst numberToBinUint32BE = (value) => {\n const uint32Length = 4;\n const bin = new Uint8Array(uint32Length);\n const writeAsLittleEndian = false;\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n // eslint-disable-next-line functional/no-expression-statements\n view.setUint32(0, value, writeAsLittleEndian);\n return bin;\n};\n/**\n * Encode a positive BigInt as little-endian Uint8Array. Negative values will\n * return the same result as `0`.\n *\n * For the reverse, see {@link binToBigIntUintLE}.\n *\n * @param value - the number to encode\n */\nconst bigIntToBinUintLE = (value) => {\n const baseUint8Array = 256;\n const base = BigInt(baseUint8Array);\n const result = [];\n // eslint-disable-next-line functional/no-let\n let remaining = value;\n // eslint-disable-next-line functional/no-loop-statements\n while (remaining >= base) {\n // eslint-disable-next-line functional/no-expression-statements, functional/immutable-data\n result.push(Number(remaining % base));\n // eslint-disable-next-line functional/no-expression-statements\n remaining /= base;\n }\n // eslint-disable-next-line functional/no-conditional-statements, functional/no-expression-statements, functional/immutable-data\n if (remaining > 0n)\n result.push(Number(remaining));\n return Uint8Array.from(result.length > 0 ? result : [0]);\n};\n/**\n * Encode a positive BigInt as an 8-byte Uint64LE Uint8Array, clamping the\n * results – values exceeding `0xffff_ffff_ffff_ffff` (`18446744073709551615`)\n * return the same result as `0xffff_ffff_ffff_ffff`, negative values return the\n * same result as `0`.\n *\n * For an alternative overflow behavior, see {@link bigIntToBinUint64LE}.\n *\n * For the reverse, see {@link binToBigIntUint64LE}.\n *\n * @param value - the number to encode\n */\nconst bigIntToBinUint64LEClamped = (value) => {\n const uint64 = 8;\n return binToFixedLength(bigIntToBinUintLE(value), uint64);\n};\n/**\n * Encode a positive BigInt as an 8-byte Uint64LE Uint8Array.\n *\n * This method will return an incorrect result for values outside of the range\n * `0` to `0xffff_ffff_ffff_ffff` (`18446744073709551615`).\n *\n * For an alternative overflow behavior, see {@link bigIntToBinUint64LEClamped}.\n *\n * For the reverse, see {@link binToBigIntUint64LE}.\n *\n * @param value - the number to encode\n */\nconst bigIntToBinUint64LE = (value) => {\n const uint64LengthInBits = 64;\n const valueAsUint64 = BigInt.asUintN(uint64LengthInBits, value);\n const fixedLengthBin = bigIntToBinUint64LEClamped(valueAsUint64);\n return fixedLengthBin;\n};\n/**\n * Encode an integer as a 4-byte, little-endian Uint8Array using the number's\n * two's compliment representation (the format used by JavaScript's bitwise\n * operators).\n *\n * @remarks\n * The C++ bitcoin implementations sometimes represent short vectors using\n * signed 32-bit integers (e.g. `sighashType`). This method can be used to test\n * compatibility with those implementations.\n *\n * @param value - the number to encode\n */\nconst numberToBinInt32TwosCompliment = (value) => {\n const bytes = 4;\n const bitsInAByte = 8;\n const bin = new Uint8Array(bytes);\n // eslint-disable-next-line functional/no-let, functional/no-loop-statements, no-plusplus\n for (let index = 0; index < bytes; index++) {\n // eslint-disable-next-line functional/no-expression-statements, functional/immutable-data\n bin[index] = value;\n // eslint-disable-next-line functional/no-expression-statements, no-bitwise, no-param-reassign\n value >>>= bitsInAByte;\n }\n return bin;\n};\n/**\n * Decode a little-endian Uint8Array of any length into a number. For numbers\n * larger than `Number.MAX_SAFE_INTEGER` (`9007199254740991`), use\n * `binToBigIntUintLE`.\n *\n * The `bytes` parameter can be set to constrain the expected length (default:\n * `bin.length`). This method throws if `bin.length` is not equal to `bytes`.\n *\n * For the reverse, see {@link numberToBinUintLE}.\n *\n * @privateRemarks\n * We avoid a bitwise strategy here because JavaScript uses 32-bit signed\n * integers for bitwise math, so larger numbers are converted incorrectly. E.g.\n * `2147483648 << 8` is `0`, while `2147483648n << 8n` is `549755813888n`.\n *\n * @param bin - the Uint8Array to decode\n * @param bytes - the number of bytes to read (default: `bin.length`)\n */\nconst binToNumberUintLE = (bin, bytes = bin.length) => {\n const base = 2;\n const bitsInAByte = 8;\n if (bin.length !== bytes) {\n // eslint-disable-next-line functional/no-throw-statements\n throw new TypeError(`Bin length must be ${bytes}.`);\n }\n return new Uint8Array(bin.buffer, bin.byteOffset, bin.length).reduce((accumulated, byte, i) => accumulated + byte * base ** (bitsInAByte * i), 0);\n};\n/**\n * Decode a 2-byte Uint16LE Uint8Array into a number.\n *\n * Throws if `bin` is shorter than 2 bytes.\n *\n * For the reverse, see {@link numberToBinUint16LE}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToNumberUint16LE = (bin) => {\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n const readAsLittleEndian = true;\n return view.getUint16(0, readAsLittleEndian);\n};\n/**\n * Decode a 4-byte Uint32LE Uint8Array into a number.\n *\n * Throws if `bin` is shorter than 4 bytes.\n *\n * For the reverse, see {@link numberToBinUint32LE}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToNumberUint32LE = (bin) => {\n const view = new DataView(bin.buffer, bin.byteOffset, bin.byteLength);\n const readAsLittleEndian = true;\n return view.getUint32(0, readAsLittleEndian);\n};\n/**\n * Decode a big-endian Uint8Array of any length into a BigInt. If starting from\n * a hex value, consider using the BigInt constructor instead:\n * ```\n * BigInt(`0x${hex}`)\n * ```\n *\n * The `bytes` parameter can be set to constrain the expected length (default:\n * `bin.length`). This method throws if `bin.length` is not equal to `bytes`.\n *\n * For the reverse, see {@link bigIntToBinUintBE}.\n *\n * @param bin - the Uint8Array to decode\n * @param bytes - the number of bytes to read (default: `bin.length`)\n */\nconst binToBigIntUintBE = (bin, bytes = bin.length) => {\n const bitsInAByte = 8;\n const shift = BigInt(bitsInAByte);\n if (bin.length !== bytes) {\n // eslint-disable-next-line functional/no-throw-statements\n throw new TypeError(`Bin length must be ${bytes}.`);\n }\n return new Uint8Array(bin.buffer, bin.byteOffset, bin.length).reduce(\n // eslint-disable-next-line no-bitwise\n (accumulated, byte) => (accumulated << shift) | BigInt(byte), 0n);\n};\n/**\n * Encode a positive BigInt as big-endian Uint8Array. Negative values will\n * return the same result as `0`.\n *\n * For the reverse, see {@link binToBigIntUintBE}.\n *\n * @param value - the number to encode\n */\nconst bigIntToBinUintBE = (value) => bigIntToBinUintLE(value).reverse();\n/**\n * Decode an unsigned, 32-byte big-endian Uint8Array into a BigInt. This can be\n * used to decode Uint8Array-encoded cryptographic primitives like private\n * keys, public keys, curve parameters, and signature points.\n *\n * If starting from a hex value, consider using the BigInt constructor instead:\n * ```\n * BigInt(`0x${hex}`)\n * ```\n *\n * For the reverse, see {@link bigIntToBinUint256BEClamped}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToBigIntUint256BE = (bin) => {\n const uint256Bytes = 32;\n return binToBigIntUintBE(bin, uint256Bytes);\n};\n/**\n * Encode a positive BigInt into an unsigned 32-byte big-endian Uint8Array. This\n * can be used to encoded numbers for cryptographic primitives like private\n * keys, public keys, curve parameters, and signature points.\n *\n * Negative values will return the same result as `0`, values higher than\n * 2^256-1 will return the maximum expressible unsigned 256-bit value\n * (`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`).\n *\n * For the reverse, see {@link binToBigIntUint256BE}.\n *\n * @param value - the BigInt to encode\n */\nconst bigIntToBinUint256BEClamped = (value) => {\n const uint256Bytes = 32;\n return binToFixedLength(bigIntToBinUintLE(value), uint256Bytes).reverse();\n};\n/**\n * Decode a little-endian Uint8Array of any length into a BigInt.\n *\n * The `bytes` parameter can be set to constrain the expected length (default:\n * `bin.length`). This method throws if `bin.length` is not equal to `bytes`.\n *\n * For the reverse, see {@link bigIntToBinUintLE}.\n *\n * @param bin - the Uint8Array to decode\n * @param bytes - the number of bytes to read (default: `bin.length`)\n */\nconst binToBigIntUintLE = (bin, bytes = bin.length) => {\n const bitsInAByte = 8;\n if (bin.length !== bytes) {\n // eslint-disable-next-line functional/no-throw-statements\n throw new TypeError(`Bin length must be ${bytes}.`);\n }\n return new Uint8Array(bin.buffer, bin.byteOffset, bin.length).reduceRight(\n // eslint-disable-next-line no-bitwise\n (accumulated, byte) => (accumulated << BigInt(bitsInAByte)) | BigInt(byte), 0n);\n};\n/**\n * Decode an 8-byte Uint64LE Uint8Array into a BigInt.\n *\n * Throws if `bin` is shorter than 8 bytes.\n *\n * For the reverse, see {@link bigIntToBinUint64LE}\n * or {@link bigIntToBinUint64LEClamped}.\n *\n * @param bin - the Uint8Array to decode\n */\nconst binToBigIntUint64LE = (bin) => {\n const uint64LengthInBytes = 8;\n const truncatedBin = bin.length > uint64LengthInBytes ? bin.slice(0, uint64LengthInBytes) : bin;\n return binToBigIntUintLE(truncatedBin, uint64LengthInBytes);\n};\n/**\n * Decode an {@link Output.valueSatoshis} into a `BigInt`. This is an alias for\n * {@link binToBigIntUint64LE}.\n *\n * Throws if the provided value is shorter than 8 bytes.\n *\n * For the reverse, see {@link valueSatoshisToBin}.\n */\nconst binToValueSatoshis = binToBigIntUint64LE;\n/**\n * Encode a `BigInt` into an {@link Output.valueSatoshis}. This is an alias for\n * {@link bigIntToBinUint64LE}.\n *\n * This method will return an incorrect result for values outside of the range 0\n * to 0xffff_ffff_ffff_ffff (`18446744073709551615`).\n *\n * For the reverse, see {@link binToValueSatoshis}.\n */\nconst valueSatoshisToBin = bigIntToBinUint64LE;\n/**\n * Get the expected byte length of a CompactUint given a first byte.\n *\n * @param firstByte - the first byte of the CompactUint\n */\nconst compactUintPrefixToLength = (firstByte) => {\n switch (firstByte) {\n case 253 /* CompactUint.uint16Prefix */:\n return 2 /* CompactUint.uint16 */ + 1;\n case 254 /* CompactUint.uint32Prefix */:\n return 4 /* CompactUint.uint32 */ + 1;\n case 255 /* CompactUint.uint64Prefix */:\n return 8 /* CompactUint.uint64 */ + 1;\n default:\n return 1 /* CompactUint.uint8 */;\n }\n};\nvar CompactUintError;\n(function (CompactUintError) {\n CompactUintError[\"noPrefix\"] = \"Error reading CompactUint: requires at least one byte.\";\n CompactUintError[\"insufficientBytes\"] = \"Error reading CompactUint: insufficient bytes.\";\n CompactUintError[\"nonMinimal\"] = \"Error reading CompactUint: CompactUint is not minimally encoded.\";\n CompactUintError[\"excessiveBytes\"] = \"Error decoding CompactUint: unexpected bytes after CompactUint.\";\n})(CompactUintError || (CompactUintError = {}));\n/**\n * Read a non-minimally-encoded `CompactUint` (see {@link bigIntToCompactUint})\n * from the provided {@link ReadPosition}, returning either an error message (as\n * a string) or an object containing the value and the\n * next {@link ReadPosition}.\n *\n * Rather than this function, most applications should\n * use {@link readCompactUintMinimal}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * `CompactUint`\n */\nconst readCompactUint = (position) => {\n const { bin, index } = position;\n const prefix = bin[index];\n if (prefix === undefined) {\n return (0,_error_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CompactUintError.noPrefix);\n }\n const bytes = compactUintPrefixToLength(prefix);\n if (bin.length - index < bytes) {\n return (0,_error_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CompactUintError.insufficientBytes, `CompactUint prefix ${prefix} requires at least ${bytes} bytes. Remaining bytes: ${bin.length - index}`);\n }\n const hasPrefix = bytes !== 1;\n const contents = hasPrefix\n ? bin.subarray(index + 1, index + bytes)\n : bin.subarray(index, index + bytes);\n return {\n position: { bin, index: index + bytes },\n result: binToBigIntUintLE(contents),\n };\n};\n/**\n * Encode a positive BigInt as a `CompactUint` (Satoshi's variable-length,\n * positive integer format).\n *\n * Note: the maximum value of a CompactUint is `0xffff_ffff_ffff_ffff`\n * (`18446744073709551615`). This method will return an incorrect result for\n * values outside of the range `0` to `0xffff_ffff_ffff_ffff`. If applicable,\n * applications should handle such cases prior to calling this method.\n *\n * For the reverse, see {@link compactUintToBigInt}.\n *\n * @param value - the BigInt to encode (must be no larger than\n * `0xffff_ffff_ffff_ffff`)\n */\nconst bigIntToCompactUint = (value) => value <= BigInt(252 /* CompactUint.uint8MaxValue */)\n ? Uint8Array.of(Number(value))\n : value <= BigInt(65535 /* CompactUint.uint16MaxValue */)\n ? Uint8Array.from([\n 253 /* CompactUint.uint16Prefix */,\n ...numberToBinUint16LE(Number(value)),\n ])\n : value <= BigInt(4294967295 /* CompactUint.uint32MaxValue */)\n ? Uint8Array.from([\n 254 /* CompactUint.uint32Prefix */,\n ...numberToBinUint32LE(Number(value)),\n ])\n : Uint8Array.from([\n 255 /* CompactUint.uint64Prefix */,\n ...bigIntToBinUint64LE(value),\n ]);\n/**\n * Read a minimally-encoded `CompactUint` from the provided\n * {@link ReadPosition}, returning either an error message (as a string) or an\n * object containing the value and the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * `CompactUint`\n */\nconst readCompactUintMinimal = (position) => {\n const read = readCompactUint(position);\n if (typeof read === 'string') {\n return read;\n }\n const readLength = read.position.index - position.index;\n const canonicalEncoding = bigIntToCompactUint(read.result);\n if (readLength !== canonicalEncoding.length) {\n return (0,_error_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CompactUintError.nonMinimal, `Value: ${read.result.toString()}, encoded length: ${readLength}, canonical length: ${canonicalEncoding.length}`);\n }\n return read;\n};\n/**\n * Decode a minimally-encoded `CompactUint` (Satoshi's variable-length, positive\n * integer format) from a Uint8Array, returning the value as a BigInt. This\n * function returns an error if the entire input is not consumed – to read a\n * `CompactUint` from a position within a larger `Uint8Array`,\n * use {@link readCompactUintMinimal} or {@link readCompactUint}.\n *\n * For the reverse, see {@link bigIntToCompactUint}.\n *\n * @param bin - the Uint8Array from which to read the CompactUint\n */\nconst compactUintToBigInt = (bin) => {\n const read = readCompactUintMinimal({ bin, index: 0 });\n if (typeof read === 'string') {\n return read;\n }\n if (read.position.index !== bin.length) {\n return (0,_error_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CompactUintError.excessiveBytes, `CompactUint ends at index ${read.position.index}, but input includes ${bin.length} bytes.`);\n }\n return read.result;\n};\n/**\n * Convert a signed integer into it's two's compliment unsigned equivalent, e.g.\n * `0b11111111111111111111111111111110` is `-2` as a signed integer or\n * `4294967294` as an unsigned integer.\n *\n * For the reverse, see {@link int32UnsignedToSigned}.\n *\n * @param int32 - the number to convert\n */\nconst int32SignedToUnsigned = (int32) => \n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\nUint32Array.from(Int32Array.of(int32))[0];\n/**\n * Convert an unsigned integer into it's two's compliment signed equivalent,\n * e.g. `0b11111111111111111111111111111110` is `4294967294` as an unsigned\n * integer or `-2` as a signed integer.\n *\n * For the reverse, see {@link int32SignedToUnsigned}.\n *\n * @param int32 - the number to convert\n */\nconst int32UnsignedToSigned = (int32) => \n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\nInt32Array.from(Uint32Array.of(int32))[0];\n//# sourceMappingURL=number.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/format/number.js?");
|
|
283
283
|
|
|
284
284
|
/***/ }),
|
|
285
285
|
|
|
@@ -290,7 +290,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
290
290
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
291
291
|
|
|
292
292
|
"use strict";
|
|
293
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"
|
|
293
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ReadItemCountError\": () => (/* binding */ ReadItemCountError),\n/* harmony export */ \"readItemCount\": () => (/* binding */ readItemCount),\n/* harmony export */ \"readMultiple\": () => (/* binding */ readMultiple)\n/* harmony export */ });\n/* harmony import */ var _error_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./error.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/error.js\");\n/* harmony import */ var _number_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./number.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/number.js\");\n\n\n/**\n * Given an initial {@link ReadPosition} and a list of {@link ReadFunction}s,\n * apply each {@link ReadFunction} in order, aggregating each result and passing\n * the next {@link ReadPosition} into the next {@link ReadFunction}. If an error\n * occurs, immediately return the error message (`string`), otherwise, return\n * the array of results.\n *\n * @param position - the {@link ReadPosition} at which to start the first read\n * @param readFunctions - the ordered list of {@link ReadFunction}s to apply to\n * the {@link ReadPosition}\n */\nconst readMultiple = (position, readFunctions) => {\n // eslint-disable-next-line functional/no-let\n let nextPosition = position;\n const results = [];\n // eslint-disable-next-line functional/no-loop-statements\n for (const readFunction of readFunctions) {\n const out = readFunction(nextPosition);\n if (typeof out === 'string') {\n return out;\n }\n // eslint-disable-next-line functional/no-expression-statements, functional/immutable-data\n results.push(out.result);\n // eslint-disable-next-line functional/no-expression-statements\n nextPosition = out.position;\n }\n return {\n position: nextPosition,\n result: results,\n };\n};\nvar ReadItemCountError;\n(function (ReadItemCountError) {\n ReadItemCountError[\"itemCount\"] = \"Error reading item count.\";\n ReadItemCountError[\"item\"] = \"Error reading item.\";\n})(ReadItemCountError || (ReadItemCountError = {}));\n/**\n * Read a count of items indicated by the CompactUint at {@link ReadPosition}.\n * The CompactUint will be read to determine the number of items, and the read\n * function will be applied in series, aggregated each result and passing the\n * next {@link ReadPosition} into each iteration. If an error occurs,\n * immediately return the error message (`string`), otherwise, return the array\n * of results.\n */\nconst readItemCount = (position, readFunction) => {\n const countRead = (0,_number_js__WEBPACK_IMPORTED_MODULE_0__.readCompactUintMinimal)(position);\n if (typeof countRead === 'string') {\n return (0,_error_js__WEBPACK_IMPORTED_MODULE_1__.formatError)(ReadItemCountError.itemCount, countRead);\n }\n // eslint-disable-next-line functional/no-let\n let nextPosition = countRead.position;\n const result = [];\n // eslint-disable-next-line functional/no-loop-statements, functional/no-let, no-plusplus\n for (let remaining = Number(countRead.result); remaining > 0; remaining--) {\n const read = readFunction(nextPosition);\n if (typeof read === 'string') {\n return (0,_error_js__WEBPACK_IMPORTED_MODULE_1__.formatError)(ReadItemCountError.item, read);\n }\n // eslint-disable-next-line functional/no-expression-statements, functional/immutable-data\n result.push(read.result);\n // eslint-disable-next-line functional/no-expression-statements\n nextPosition = read.position;\n }\n return { position: nextPosition, result };\n};\n//# sourceMappingURL=read.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/format/read.js?");
|
|
294
294
|
|
|
295
295
|
/***/ }),
|
|
296
296
|
|
|
@@ -301,7 +301,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
301
301
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
302
302
|
|
|
303
303
|
"use strict";
|
|
304
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"binToUtf8\": () => (/* binding */ binToUtf8),\n/* harmony export */ \"
|
|
304
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"binToUtf8\": () => (/* binding */ binToUtf8),\n/* harmony export */ \"length\": () => (/* binding */ length),\n/* harmony export */ \"lossyNormalize\": () => (/* binding */ lossyNormalize),\n/* harmony export */ \"segment\": () => (/* binding */ segment),\n/* harmony export */ \"utf8ToBin\": () => (/* binding */ utf8ToBin)\n/* harmony export */ });\nconst utf8Encoder = new TextEncoder();\n/**\n * Interpret a string as UTF-8 and encode it as a Uint8Array.\n *\n * For the reverse, see {@link binToUtf8}.\n *\n * @param utf8 - the string to encode\n */\nconst utf8ToBin = (utf8) => utf8Encoder.encode(utf8);\nconst utf8Decoder = new TextDecoder();\n/**\n * Decode a Uint8Array as a UTF-8 string.\n *\n * For the reverse, see {@link utf8ToBin}.\n *\n * @param bytes - the Uint8Array to decode\n */\nconst binToUtf8 = (bytes) => utf8Decoder.decode(bytes);\n/**\n * Normalize a string using Unicode Normalization Form KC (NFKC): compatibility\n * decomposition, followed by canonical composition. NFKC is the preferred form\n * for applications in which disambiguation between characters is critical. In\n * Libauth, all message formats designed for transmission between trust centers\n * are NFKC-normalized to hinder exploits in which lookalike characters are used\n * to deceive counterparties.\n *\n * E.g.:\n * ```\n * console.log(lossyNormalize('fit🚀👫👨👩👧👦')); // 'fit🚀👫👨👩👧👦'\n * ```\n */\nconst lossyNormalize = (utf8) => utf8.normalize('NFKC');\n/**\n * Return the user-perceived character segments of the given string, e.g.:\n *\n * ```js\n * const test = 'fit🚀👫👨👩👧👦';\n * console.log([...test]); // '[\"fi\",\"t\",\"🚀\",\"👫\",\"👨\",\"\",\"👩\",\"\",\"👧\",\"\",\"👦\"]'\n * console.log(segment(test)); // '[\"fi\",\"t\",\"🚀\",\"👫\",\"👨👩👧👦\"]'\n * ```\n *\n * Note, this utility segments the string into grapheme clusters using\n * `Intl.Segmenter`, a TC39 proposal which reached stage 4 in 2022, and may not\n * be supported in older environments.\n *\n * @param utf8 - the string for which to segment characters.\n */\nconst segment = (utf8) => [...new Intl.Segmenter('en', { granularity: 'grapheme' }).segment(utf8)].map((item) => item.segment);\n/**\n * Return the user-perceived character length of the given string, e.g.:\n *\n * ```js\n * const test = 'fit🚀👫👨👩👧👦'\n * console.log(test.length); // 17\n * console.log(length(test)); // 5\n * ```\n *\n * Note, this utility segments the string into grapheme clusters using\n * `Intl.Segmenter`, a TC39 proposal which reached stage 4 in 2022, and may not\n * be supported in older environments.\n *\n * @param utf8 - the string for which to count the character length.\n */\nconst length = (utf8) => segment(utf8).length;\n//# sourceMappingURL=utf8.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/format/utf8.js?");
|
|
305
305
|
|
|
306
306
|
/***/ }),
|
|
307
307
|
|
|
@@ -312,7 +312,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
312
312
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
313
313
|
|
|
314
314
|
"use strict";
|
|
315
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"readBytes\": () => (/* binding */ readBytes),\n/* harmony export */ \"readCompactUintPrefixedBin\": () => (/* binding */ readCompactUintPrefixedBin),\n/* harmony export */ \"readRemainingBytes\": () => (/* binding */ readRemainingBytes),\n/* harmony export */ \"readUint32LE\": () => (/* binding */ readUint32LE),\n/* harmony export */ \"readUint64LE\": () => (/* binding */ readUint64LE)\n/* harmony export */ });\n/*
|
|
315
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"CompactUintPrefixedBinError\": () => (/* binding */ CompactUintPrefixedBinError),\n/* harmony export */ \"ReadBytesError\": () => (/* binding */ ReadBytesError),\n/* harmony export */ \"ReadUint32LEError\": () => (/* binding */ ReadUint32LEError),\n/* harmony export */ \"ReadUint64LEError\": () => (/* binding */ ReadUint64LEError),\n/* harmony export */ \"readBytes\": () => (/* binding */ readBytes),\n/* harmony export */ \"readCompactUintPrefixedBin\": () => (/* binding */ readCompactUintPrefixedBin),\n/* harmony export */ \"readRemainingBytes\": () => (/* binding */ readRemainingBytes),\n/* harmony export */ \"readUint32LE\": () => (/* binding */ readUint32LE),\n/* harmony export */ \"readUint64LE\": () => (/* binding */ readUint64LE)\n/* harmony export */ });\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/error.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/number.js\");\n\nvar ReadBytesError;\n(function (ReadBytesError) {\n ReadBytesError[\"insufficientLength\"] = \"Error reading bytes: insufficient length.\";\n})(ReadBytesError || (ReadBytesError = {}));\n/**\n * Returns a function that reads the requested number of bytes from a\n * {@link ReadPosition}, returning either an error message (as a string) or an\n * object containing the `Uint8Array` and the next {@link ReadPosition}.\n *\n * @param length - the number of bytes to read\n */\nconst readBytes = (length) => (\n/**\n * the {@link ReadPosition} at which to start reading the bytes.\n */\nposition) => {\n const nextPosition = {\n bin: position.bin,\n index: position.index + length,\n };\n const result = position.bin.slice(position.index, nextPosition.index);\n if (result.length !== length) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(ReadBytesError.insufficientLength, `Bytes requested: ${length}; remaining bytes: ${result.length}`);\n }\n return { position: nextPosition, result };\n};\nvar ReadUint32LEError;\n(function (ReadUint32LEError) {\n ReadUint32LEError[\"insufficientBytes\"] = \"Error reading Uint32LE: requires 4 bytes.\";\n})(ReadUint32LEError || (ReadUint32LEError = {}));\n/**\n * Read a 4-byte, Uint32LE from the provided {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * number and the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading\n */\nconst readUint32LE = (position) => {\n const nextPosition = {\n bin: position.bin,\n index: position.index + 4 /* ReadConstants.bytesPerUint32 */,\n };\n const uint32LEBin = position.bin.subarray(position.index, nextPosition.index);\n if (uint32LEBin.length !== 4 /* ReadConstants.bytesPerUint32 */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(ReadUint32LEError.insufficientBytes, `Remaining bytes: ${uint32LEBin.length}`);\n }\n const result = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.binToNumberUint32LE)(uint32LEBin);\n return { position: nextPosition, result };\n};\nvar ReadUint64LEError;\n(function (ReadUint64LEError) {\n ReadUint64LEError[\"insufficientBytes\"] = \"Error reading Uint64LE: requires 8 bytes.\";\n})(ReadUint64LEError || (ReadUint64LEError = {}));\n/**\n * Read {@link Output.valueSatoshis} from the provided {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Output.valueSatoshis} and the next {@link ReadPosition}.\n * @param position - the {@link ReadPosition} at which to start reading\n * {@link Output.valueSatoshis}\n */\nconst readUint64LE = (position) => {\n const nextPosition = {\n bin: position.bin,\n index: position.index + 8 /* ReadConstants.bytesPerUint64 */,\n };\n const uint64LEBin = position.bin.subarray(position.index, nextPosition.index);\n if (uint64LEBin.length !== 8 /* ReadConstants.bytesPerUint64 */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(ReadUint64LEError.insufficientBytes, `Remaining bytes: ${uint64LEBin.length}`);\n }\n const result = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.binToBigIntUint64LE)(uint64LEBin);\n return { position: nextPosition, result };\n};\nvar CompactUintPrefixedBinError;\n(function (CompactUintPrefixedBinError) {\n CompactUintPrefixedBinError[\"invalidCompactUint\"] = \"Error reading CompactUint-prefixed bin: invalid CompactUint.\";\n CompactUintPrefixedBinError[\"insufficientBytes\"] = \"Error reading CompactUint-prefixed bin: insufficient bytes.\";\n})(CompactUintPrefixedBinError || (CompactUintPrefixedBinError = {}));\n/**\n * Read a bin (`Uint8Array`) that is prefixed by a minimally-encoded\n * `CompactUint` starting at the provided {@link ReadPosition}, returning either\n * an error message (as a string) or an object containing the `Uint8Array` and\n * the next {@link ReadPosition}. (In the transaction format,\n * `CompactUint`-prefixes are used to indicate the length of unlocking bytecode,\n * locking bytecode, and non-fungible token commitments.)\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * `CompactUint`-prefixed bin (`Uint8Array`)\n */\nconst readCompactUintPrefixedBin = (position) => {\n const read = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.readCompactUintMinimal)(position);\n if (typeof read === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CompactUintPrefixedBinError.invalidCompactUint, read);\n }\n const { result, position: p2 } = read;\n const length = Number(result);\n const nextPosition = { bin: position.bin, index: p2.index + length };\n const contents = position.bin.slice(p2.index, nextPosition.index);\n if (contents.length !== length) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.formatError)(CompactUintPrefixedBinError.insufficientBytes, `Required bytes: ${length}, remaining bytes: ${contents.length}`);\n }\n return { position: nextPosition, result: contents };\n};\n/**\n * Read the remaining bytes from the provided {@link ReadPosition}, returning\n * an object containing the `Uint8Array` and the next {@link ReadPosition}\n * (with `index === bin.length`).\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * remaining bytes\n */\nconst readRemainingBytes = (position) => {\n const nextPosition = {\n bin: position.bin,\n index: position.bin.length,\n };\n const result = position.bin.subarray(position.index, nextPosition.index);\n return { position: nextPosition, result };\n};\n//# sourceMappingURL=read-components.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/message/read-components.js?");
|
|
316
316
|
|
|
317
317
|
/***/ }),
|
|
318
318
|
|
|
@@ -323,7 +323,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
323
323
|
/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
324
324
|
|
|
325
325
|
"use strict";
|
|
326
|
-
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeTransaction\": () => (/* binding */ decodeTransaction)\n/* harmony export */ });\n/* unused harmony exports encodeTransactionInput, TransactionDecodingError, readTransactionInput, encodeTransactionInputs, readTransactionInputs, nftCapabilityNumberToLabel, nftCapabilityLabelToNumber, CashTokenDecodingError, readTokenAmount, readTokenPrefix, readLockingBytecodeWithPrefix, readTransactionOutput, encodeTokenPrefix, encodeTransactionOutput, readTransactionOutputs, decodeTransactionOutputs, encodeTransactionOutputs, readTransactionCommon, readTransaction, readTransactionOutputNonTokenAware, readTransactionOutputsNonTokenAware, readTransactionNonTokenAware, decodeTransactionCommon, decodeTransactionBch, decodeTransactionBCH, decodeTransactionUnsafeCommon, decodeTransactionUnsafeBch, decodeTransactionUnsafe, decodeTransactionUnsafeBCH, encodeTransactionCommon, encodeTransactionBch, encodeTransaction, encodeTransactionBCH, hashTransactionP2pOrder, hashTransactionUiOrder, hashTransaction, encodeTransactionOutpoints, encodeTransactionOutputsForSigning, encodeTransactionInputSequenceNumbersForSigning */\n/* harmony import */ var _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../crypto/crypto.js */ \"../../node_modules/@bitauth/libauth/build/lib/crypto/default-crypto-instances.js\");\n/* harmony import */ var _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../crypto/crypto.js */ \"../../node_modules/@bitauth/libauth/build/lib/crypto/combinations.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/hex.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/number.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/read.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/error.js\");\n/* harmony import */ var _read_components_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./read-components.js */ \"../../node_modules/@bitauth/libauth/build/lib/message/read-components.js\");\n/* harmony import */ var _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./transaction-types.js */ \"../../node_modules/@bitauth/libauth/build/lib/message/transaction-types.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__, _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__]);\n([_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__, _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);\n\n\n\n\n/**\n * Encode a single input for inclusion in an encoded transaction.\n *\n * @param input - the input to encode\n */\nconst encodeTransactionInput = (input) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n input.outpointTransactionHash.slice().reverse(),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(input.outpointIndex),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(BigInt(input.unlockingBytecode.length)),\n input.unlockingBytecode,\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(input.sequenceNumber),\n]);\nvar TransactionDecodingError;\n(function (TransactionDecodingError) {\n TransactionDecodingError[\"transaction\"] = \"Error reading transaction.\";\n TransactionDecodingError[\"endsWithUnexpectedBytes\"] = \"Error decoding transaction: the provided input includes unexpected bytes after the encoded transaction.\";\n TransactionDecodingError[\"input\"] = \"Error reading transaction input.\";\n TransactionDecodingError[\"inputs\"] = \"Error reading transaction inputs.\";\n TransactionDecodingError[\"output\"] = \"Error reading transaction output.\";\n TransactionDecodingError[\"outputs\"] = \"Error reading transaction outputs.\";\n TransactionDecodingError[\"outputsEndWithUnexpectedBytes\"] = \"Error decoding transaction outputs: the provided serialization includes unexpected bytes after the encoded transaction outputs.\";\n TransactionDecodingError[\"lockingBytecodeLength\"] = \"Error reading locking bytecode length.\";\n})(TransactionDecodingError || (TransactionDecodingError = {}));\n/**\n * Read a transaction {@link Input} from the provided {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Input} and the next {@link ReadPosition}.\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction output\n */\nconst readTransactionInput = (position) => {\n const inputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readBytes)(32 /* TransactionConstants.outpointTransactionHashLength */),\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactUintPrefixedBin,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof inputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.input, inputRead);\n }\n const { position: nextPosition, result: [outpointTransactionHash, outpointIndex, unlockingBytecode, sequenceNumber,], } = inputRead;\n return {\n position: nextPosition,\n result: {\n outpointIndex,\n outpointTransactionHash: outpointTransactionHash.reverse(),\n sequenceNumber,\n unlockingBytecode,\n },\n };\n};\n/**\n * Encode a set of {@link Input}s for inclusion in an encoded transaction\n * including the prefixed number of inputs.\n *\n * Format: [CompactUint: input count] [encoded inputs]\n *\n * @param inputs - the set of inputs to encode\n */\nconst encodeTransactionInputs = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(BigInt(inputs.length)),\n ...inputs.map(encodeTransactionInput),\n]);\n/**\n * Read a set of transaction {@link Input}s beginning at {@link ReadPosition}.\n * A CompactUint will be read to determine the number of inputs, and that\n * number of transaction inputs will be read and returned. Returns either an\n * error message (as a string) or an object containing the array of inputs and\n * the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction inputs\n */\nconst readTransactionInputs = (position) => {\n const inputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(position, readTransactionInput);\n if (typeof inputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.inputs, inputsRead);\n }\n return inputsRead;\n};\nconst maximumTokenAmount = 9223372036854775807n;\nconst nftCapabilityNumberToLabel = [\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none,\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.mutable,\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.minting,\n];\nconst nftCapabilityLabelToNumber = {\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none]: 0,\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.mutable]: 1,\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.minting]: 2,\n};\nvar CashTokenDecodingError;\n(function (CashTokenDecodingError) {\n CashTokenDecodingError[\"invalidPrefix\"] = \"Error reading token prefix.\";\n CashTokenDecodingError[\"insufficientLength\"] = \"Invalid token prefix: insufficient length.\";\n CashTokenDecodingError[\"reservedBit\"] = \"Invalid token prefix: reserved bit is set.\";\n CashTokenDecodingError[\"invalidCapability\"] = \"Invalid token prefix: capability must be none (0), mutable (1), or minting (2).\";\n CashTokenDecodingError[\"commitmentWithoutNft\"] = \"Invalid token prefix: commitment requires an NFT.\";\n CashTokenDecodingError[\"capabilityWithoutNft\"] = \"Invalid token prefix: capability requires an NFT.\";\n CashTokenDecodingError[\"commitmentLengthZero\"] = \"Invalid token prefix: if encoded, commitment length must be greater than 0.\";\n CashTokenDecodingError[\"invalidCommitment\"] = \"Invalid token prefix: invalid non-fungible token commitment.\";\n CashTokenDecodingError[\"invalidAmountEncoding\"] = \"Invalid token prefix: invalid fungible token amount encoding.\";\n CashTokenDecodingError[\"zeroAmount\"] = \"Invalid token prefix: if encoded, fungible token amount must be greater than 0.\";\n CashTokenDecodingError[\"excessiveAmount\"] = \"Invalid token prefix: exceeds maximum fungible token amount of 9223372036854775807.\";\n CashTokenDecodingError[\"noTokens\"] = \"Invalid token prefix: must encode at least one token.\";\n})(CashTokenDecodingError || (CashTokenDecodingError = {}));\n/**\n * Read a token amount from the provided {@link ReadPosition}, returning either\n * an error message (as a string) or an object containing the value and the next\n * {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * token amount.\n */\nconst readTokenAmount = (position) => {\n const amountRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.readCompactUintMinimal)(position);\n if (typeof amountRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidAmountEncoding, amountRead);\n }\n if (amountRead.result > maximumTokenAmount) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.excessiveAmount, `Encoded amount: ${amountRead.result}`);\n }\n if (amountRead.result === 0n) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.zeroAmount);\n }\n return amountRead;\n};\n/**\n * Attempt to read a transaction {@link Output}'s token prefix from the provided\n * {@link ReadPosition}, returning either an error message (as a string) or an\n * object containing the (optional) token information and the\n * next {@link ReadPosition}.\n *\n * Rather than using this function directly, most applications\n * should use {@link readLockingBytecodeWithPrefix}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * token prefix\n */\n// eslint-disable-next-line complexity\nconst readTokenPrefix = (position) => {\n const { bin, index } = position;\n if (bin[index] !== 239 /* CashTokens.PREFIX_TOKEN */) {\n return { position, result: {} };\n }\n if (bin.length < index + 34 /* CashTokens.minimumPrefixLength */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.insufficientLength, `The minimum possible length is ${34 /* CashTokens.minimumPrefixLength */}. Missing bytes: ${34 /* CashTokens.minimumPrefixLength */ - (bin.length - index)}`);\n }\n const category = bin\n .slice(index + 1, index + 33 /* CashTokens.tokenBitfieldIndex */)\n .reverse();\n const tokenBitfield = bin[index + 33 /* CashTokens.tokenBitfieldIndex */]; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n /* eslint-disable no-bitwise */\n const prefixStructure = tokenBitfield & 240 /* CashTokens.tokenFormatMask */;\n if ((prefixStructure & 128 /* CashTokens.RESERVED_BIT */) !== 0) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.reservedBit, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const nftCapabilityInt = tokenBitfield & 15 /* CashTokens.nftCapabilityMask */;\n if (nftCapabilityInt > 2 /* CashTokens.maximumCapability */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidCapability, `Capability value: ${nftCapabilityInt}`);\n }\n const capability = nftCapabilityNumberToLabel[nftCapabilityInt]; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n const hasNft = (prefixStructure & 32 /* CashTokens.HAS_NFT */) !== 0;\n const hasCommitmentLength = (prefixStructure & 64 /* CashTokens.HAS_COMMITMENT_LENGTH */) !== 0;\n if (hasCommitmentLength && !hasNft) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.commitmentWithoutNft, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const hasAmount = (prefixStructure & 16 /* CashTokens.HAS_AMOUNT */) !== 0;\n /* eslint-enable no-bitwise */\n const nextPosition = {\n bin,\n index: index + 33 /* CashTokens.tokenBitfieldIndex */ + 1,\n };\n if (hasNft) {\n const commitmentRead = hasCommitmentLength\n ? (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactUintPrefixedBin)(nextPosition)\n : { position: nextPosition, result: Uint8Array.of() };\n if (typeof commitmentRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidCommitment, commitmentRead);\n }\n if (hasCommitmentLength && commitmentRead.result.length === 0) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.commitmentLengthZero);\n }\n const amountRead = hasAmount\n ? readTokenAmount(commitmentRead.position)\n : { position: commitmentRead.position, result: 0n };\n if (typeof amountRead === 'string') {\n return amountRead;\n }\n return {\n position: amountRead.position,\n result: {\n token: {\n amount: amountRead.result,\n category,\n nft: { capability, commitment: commitmentRead.result },\n },\n },\n };\n }\n if (capability !== _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.capabilityWithoutNft, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n if (!hasAmount) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.noTokens, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const amountRead = readTokenAmount(nextPosition);\n if (typeof amountRead === 'string') {\n return amountRead;\n }\n return {\n position: amountRead.position,\n result: { token: { amount: amountRead.result, category } },\n };\n};\n/**\n * Read the locking bytecode and token prefix (if present) of a transaction\n * {@link Output}, beginning at the `CompactUint` indicating the\n * combined length.\n * @param position - the {@link ReadPosition} at which to start reading the\n * optional token prefix and locking bytecode\n */\nconst readLockingBytecodeWithPrefix = (position) => {\n const bytecodeRead = (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactUintPrefixedBin)(position);\n if (typeof bytecodeRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.lockingBytecodeLength, bytecodeRead);\n }\n const { result: contents, position: nextPosition } = bytecodeRead;\n const contentsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)({ bin: contents, index: 0 }, [\n readTokenPrefix,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readRemainingBytes,\n ]);\n if (typeof contentsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidPrefix, contentsRead);\n }\n const { result: [{ token }, lockingBytecode], } = contentsRead;\n return {\n position: nextPosition,\n result: { lockingBytecode, ...(token === undefined ? {} : { token }) },\n };\n};\n/**\n * Read a transaction {@link Output} from the provided {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Output} and the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction output\n */\nconst readTransactionOutput = (position) => {\n const outputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint64LE,\n readLockingBytecodeWithPrefix,\n ]);\n if (typeof outputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.output, outputRead);\n }\n const { position: nextPosition, result: [valueSatoshis, { lockingBytecode, token }], } = outputRead;\n return {\n position: nextPosition,\n result: {\n lockingBytecode,\n ...(token === undefined ? {} : { token }),\n valueSatoshis,\n },\n };\n};\n/**\n * Given {@link Output.token} data, encode a token prefix.\n *\n * This function does not fail, but returns an empty Uint8Array if the token\n * data does not encode any tokens (even if `token.category` is set).\n *\n * @param token - the token data to encode\n */\n// eslint-disable-next-line complexity\nconst encodeTokenPrefix = (token) => {\n if (token === undefined || (token.nft === undefined && token.amount < 1n)) {\n return Uint8Array.of();\n }\n const hasNft = token.nft === undefined ? 0 : 32 /* CashTokens.HAS_NFT */;\n const capabilityInt = token.nft === undefined\n ? 0\n : nftCapabilityLabelToNumber[token.nft.capability];\n const hasCommitmentLength = token.nft !== undefined && token.nft.commitment.length > 0\n ? 64 /* CashTokens.HAS_COMMITMENT_LENGTH */\n : 0;\n const hasAmount = token.amount > 0n ? 16 /* CashTokens.HAS_AMOUNT */ : 0;\n const tokenBitfield = \n // eslint-disable-next-line no-bitwise\n hasNft | hasCommitmentLength | hasAmount | capabilityInt;\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n Uint8Array.of(239 /* CashTokens.PREFIX_TOKEN */),\n token.category.slice().reverse(),\n Uint8Array.of(tokenBitfield),\n ...(hasCommitmentLength === 0\n ? []\n : [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(BigInt(token.nft.commitment.length)),\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n token.nft.commitment,\n ]),\n ...(hasAmount === 0 ? [] : [(0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(token.amount)]),\n ]);\n};\n/**\n * Encode a single {@link Output} for inclusion in an encoded transaction.\n *\n * @param output - the output to encode\n */\nconst encodeTransactionOutput = (output) => {\n const lockingBytecodeField = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n encodeTokenPrefix(output.token),\n output.lockingBytecode,\n ]);\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.valueSatoshisToBin)(output.valueSatoshis),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(BigInt(lockingBytecodeField.length)),\n lockingBytecodeField,\n ]);\n};\n/**\n * Read a set of transaction {@link Output}s beginning at {@link ReadPosition}.\n * A CompactUint will be read to determine the number of outputs, and that\n * number of transaction outputs will be read and returned. Returns either an\n * error message (as a string) or an object containing the array of outputs and\n * the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction outputs\n */\nconst readTransactionOutputs = (position) => {\n const outputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(position, readTransactionOutput);\n if (typeof outputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.outputs, outputsRead);\n }\n return outputsRead;\n};\n/**\n * Decode a CompactUint-prefixed series of Transaction {@link Output}s\n * according to the version 1/2 P2P network transaction format.\n *\n * This function verifies that the provided `bin` contains one `CompactUint`\n * followed by the indicated number of serialized transaction outputs with no\n * additional data. To read a transaction from a\n * specific location within a `Uint8Array`, use {@link readTransactionCommon}.\n *\n * For the reverse, see {@link encodeTransactionOutputs}.\n *\n * @param bin - the encoded transaction to decode\n */\nconst decodeTransactionOutputs = (bin) => {\n const outputsRead = readTransactionOutputs({ bin, index: 0 });\n if (typeof outputsRead === 'string') {\n return outputsRead;\n }\n if (outputsRead.position.index !== bin.length) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.outputsEndWithUnexpectedBytes, `Last encoded transaction output ends at index ${outputsRead.position.index - 1}, leaving ${bin.length - outputsRead.position.index} remaining byte(s).`);\n }\n return outputsRead.result;\n};\n/**\n * Encode a set of {@link Output}s for inclusion in an encoded transaction\n * including the prefixed number of outputs. Note, this encoding differs from\n * {@link encodeTransactionOutputsForSigning} (used for signing serializations).\n *\n * Format: `[CompactUint: output count] [encoded outputs]`\n *\n * For the reverse, see {@link decodeTransactionOutputs}.\n *\n * @param outputs - the set of outputs to encode\n */\nconst encodeTransactionOutputs = (outputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(BigInt(outputs.length)),\n ...outputs.map(encodeTransactionOutput),\n]);\n/**\n * Read a version 1 or 2 transaction beginning at {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Transaction} and the next {@link ReadPosition}. Rather than using this\n * function directly, most applications should\n * use {@link decodeTransactionCommon}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * {@link TransactionCommon}\n */\nconst readTransactionCommon = (position) => {\n const transactionRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n readTransactionInputs,\n readTransactionOutputs,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof transactionRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.transaction, transactionRead);\n }\n const { position: nextPosition, result: [version, inputs, outputs, locktime], } = transactionRead;\n return {\n position: nextPosition,\n result: { inputs, locktime, outputs, version },\n };\n};\nconst readTransaction = readTransactionCommon;\nconst readTransactionOutputNonTokenAware = (pos) => {\n const outputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(pos, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint64LE,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactUintPrefixedBin,\n ]);\n if (typeof outputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.output, outputRead);\n }\n const { position: nextPosition, result: [valueSatoshis, lockingBytecode], } = outputRead;\n return {\n position: nextPosition,\n result: { lockingBytecode, valueSatoshis },\n };\n};\nconst readTransactionOutputsNonTokenAware = (pos) => {\n const outputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(pos, readTransactionOutputNonTokenAware);\n if (typeof outputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.outputs, outputsRead);\n }\n return outputsRead;\n};\n/**\n * Read a version 1 or 2 transaction beginning at a {@link ReadPosition} as if\n * CHIP-2022-02-CashTokens were not deployed, returning either an error message\n * (as a string) or an object containing the {@link Transaction} and the next\n * {@link ReadPosition}.\n *\n * This function emulates legacy transaction parsing to test behavior prior to\n * deployment of CHIP-2022-02-CashTokens; most applications should instead\n * use {@link readTransactionCommon}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * {@link TransactionCommon}\n */\nconst readTransactionNonTokenAware = (position) => {\n const transactionRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n readTransactionInputs,\n readTransactionOutputsNonTokenAware,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof transactionRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.transaction, transactionRead);\n }\n const { position: nextPosition, result: [version, inputs, outputs, locktime], } = transactionRead;\n return {\n position: nextPosition,\n result: { inputs, locktime, outputs, version },\n };\n};\n/**\n * Decode a {@link TransactionCommon} according to the version 1/2 P2P network\n * transaction format.\n *\n * This function verifies that the provided `bin` contains only one transaction\n * and no additional data. To read a transaction from a specific location within\n * a `Uint8Array`, use {@link readTransactionCommon}.\n *\n * For the reverse, see {@link encodeTransactionCommon}.\n *\n * @param bin - the encoded transaction to decode\n */\nconst decodeTransactionCommon = (bin) => {\n const transactionRead = readTransactionCommon({ bin, index: 0 });\n if (typeof transactionRead === 'string') {\n return transactionRead;\n }\n if (transactionRead.position.index !== bin.length) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.endsWithUnexpectedBytes, `Encoded transaction ends at index ${transactionRead.position.index - 1}, leaving ${bin.length - transactionRead.position.index} remaining bytes.`);\n }\n return transactionRead.result;\n};\nconst decodeTransactionBch = decodeTransactionCommon;\nconst decodeTransaction = decodeTransactionBch;\n/**\n * @deprecated Alias of `decodeTransactionBch` for backwards-compatibility.\n */\nconst decodeTransactionBCH = decodeTransactionBch;\n/**\n * Decode a {@link TransactionCommon} from a trusted source according to the\n * version 1/2 P2P network transaction format.\n *\n * Note: this method throws runtime errors when attempting to decode messages\n * which do not properly follow the transaction format. If the input is\n * untrusted, use {@link decodeTransactionCommon}.\n *\n * @param bin - the raw message to decode\n */\nconst decodeTransactionUnsafeCommon = (bin) => {\n const result = decodeTransactionCommon(bin);\n if (typeof result === 'string') {\n // eslint-disable-next-line functional/no-throw-statements\n throw new Error(result);\n }\n return result;\n};\nconst decodeTransactionUnsafeBch = decodeTransactionUnsafeCommon;\nconst decodeTransactionUnsafe = decodeTransactionUnsafeBch;\n/**\n * @deprecated Alias of `decodeTransactionUnsafeBch` for backwards-compatibility.\n */\nconst decodeTransactionUnsafeBCH = decodeTransactionUnsafeBch;\n/**\n * Encode a {@link Transaction} using the standard P2P network format. This\n * serialization is also used when computing the transaction's hash (A.K.A.\n * \"transaction ID\" or \"TXID\").\n *\n * For the reverse, see {@link decodeTransactionCommon}.\n */\nconst encodeTransactionCommon = (tx) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(tx.version),\n encodeTransactionInputs(tx.inputs),\n encodeTransactionOutputs(tx.outputs),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(tx.locktime),\n]);\nconst encodeTransactionBch = encodeTransactionCommon;\nconst encodeTransaction = encodeTransactionBch;\n/**\n * @deprecated Alias of `decodeTransactionUnsafeBch` for backwards-compatibility.\n */\nconst encodeTransactionBCH = encodeTransactionBch;\n/**\n * Compute a transaction hash (A.K.A. \"transaction ID\" or \"TXID\") from an\n * encoded transaction in P2P network message order. This is the byte order\n * produced by most sha256 libraries and used by encoded P2P network messages.\n * It is also the byte order produced by `OP_SHA256` and `OP_HASH256` in the\n * virtual machine.\n *\n * @returns the transaction hash in P2P network message byte order\n *\n * @param transaction - the encoded transaction\n * @param sha256 - an implementation of sha256\n */\nconst hashTransactionP2pOrder = (transaction, sha256 = _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__.sha256) => (0,_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__.hash256)(transaction, sha256);\n/**\n * Compute a transaction hash (A.K.A. \"transaction ID\" or \"TXID\") from an\n * encoded transaction in user interface byte order. This is the byte order\n * typically used by block explorers, wallets, and other user interfaces.\n *\n * To return this result as a `string`, use {@link hashTransaction}.\n *\n * @returns the transaction hash in User Interface byte order\n *\n * @param transaction - the encoded transaction\n * @param sha256 - an implementation of sha256\n */\nconst hashTransactionUiOrder = (transaction, sha256 = _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__.sha256) => hashTransactionP2pOrder(transaction, sha256).reverse();\n/**\n * Return an encoded {@link Transaction}'s hash/ID as a string in user interface\n * byte order (typically used by wallets and block explorers).\n *\n * To return this result as a `Uint8Array`, use {@link hashTransactionUiOrder}.\n *\n * @param transaction - the encoded transaction\n */\nconst hashTransaction = (transaction) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.binToHex)(hashTransactionUiOrder(transaction));\n/**\n * Encode all outpoints in a series of transaction inputs. (For use in\n * {@link hashTransactionOutpoints}.)\n *\n * @param inputs - the series of inputs from which to extract the outpoints\n */\nconst encodeTransactionOutpoints = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(inputs.map((i) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n i.outpointTransactionHash.slice().reverse(),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(i.outpointIndex),\n])));\n/**\n * Encode an array of transaction {@link Output}s for use in transaction signing\n * serializations. Note, this encoding differs from\n * {@link encodeTransactionOutputs} (used for encoding full transactions).\n *\n * @param outputs - the array of outputs to encode\n */\nconst encodeTransactionOutputsForSigning = (outputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(outputs.map(encodeTransactionOutput));\n/**\n * Encode the sequence numbers of an array of transaction inputs for use in\n * transaction signing serializations.\n *\n * @param inputs - the array of inputs from which to extract the sequence\n * numbers\n */\nconst encodeTransactionInputSequenceNumbersForSigning = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(inputs.map((i) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(i.sequenceNumber)));\n//# sourceMappingURL=transaction-encoding.js.map\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/message/transaction-encoding.js?");
|
|
326
|
+
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"CashTokenDecodingError\": () => (/* binding */ CashTokenDecodingError),\n/* harmony export */ \"TransactionDecodingError\": () => (/* binding */ TransactionDecodingError),\n/* harmony export */ \"decodeTransaction\": () => (/* binding */ decodeTransaction),\n/* harmony export */ \"decodeTransactionBCH\": () => (/* binding */ decodeTransactionBCH),\n/* harmony export */ \"decodeTransactionBch\": () => (/* binding */ decodeTransactionBch),\n/* harmony export */ \"decodeTransactionCommon\": () => (/* binding */ decodeTransactionCommon),\n/* harmony export */ \"decodeTransactionOutputs\": () => (/* binding */ decodeTransactionOutputs),\n/* harmony export */ \"decodeTransactionUnsafe\": () => (/* binding */ decodeTransactionUnsafe),\n/* harmony export */ \"decodeTransactionUnsafeBCH\": () => (/* binding */ decodeTransactionUnsafeBCH),\n/* harmony export */ \"decodeTransactionUnsafeBch\": () => (/* binding */ decodeTransactionUnsafeBch),\n/* harmony export */ \"decodeTransactionUnsafeCommon\": () => (/* binding */ decodeTransactionUnsafeCommon),\n/* harmony export */ \"encodeTokenPrefix\": () => (/* binding */ encodeTokenPrefix),\n/* harmony export */ \"encodeTransaction\": () => (/* binding */ encodeTransaction),\n/* harmony export */ \"encodeTransactionBCH\": () => (/* binding */ encodeTransactionBCH),\n/* harmony export */ \"encodeTransactionBch\": () => (/* binding */ encodeTransactionBch),\n/* harmony export */ \"encodeTransactionCommon\": () => (/* binding */ encodeTransactionCommon),\n/* harmony export */ \"encodeTransactionInput\": () => (/* binding */ encodeTransactionInput),\n/* harmony export */ \"encodeTransactionInputSequenceNumbersForSigning\": () => (/* binding */ encodeTransactionInputSequenceNumbersForSigning),\n/* harmony export */ \"encodeTransactionInputs\": () => (/* binding */ encodeTransactionInputs),\n/* harmony export */ \"encodeTransactionOutpoints\": () => (/* binding */ encodeTransactionOutpoints),\n/* harmony export */ \"encodeTransactionOutput\": () => (/* binding */ encodeTransactionOutput),\n/* harmony export */ \"encodeTransactionOutputs\": () => (/* binding */ encodeTransactionOutputs),\n/* harmony export */ \"encodeTransactionOutputsForSigning\": () => (/* binding */ encodeTransactionOutputsForSigning),\n/* harmony export */ \"hashTransaction\": () => (/* binding */ hashTransaction),\n/* harmony export */ \"hashTransactionP2pOrder\": () => (/* binding */ hashTransactionP2pOrder),\n/* harmony export */ \"hashTransactionUiOrder\": () => (/* binding */ hashTransactionUiOrder),\n/* harmony export */ \"nftCapabilityLabelToNumber\": () => (/* binding */ nftCapabilityLabelToNumber),\n/* harmony export */ \"nftCapabilityNumberToLabel\": () => (/* binding */ nftCapabilityNumberToLabel),\n/* harmony export */ \"readLockingBytecodeWithPrefix\": () => (/* binding */ readLockingBytecodeWithPrefix),\n/* harmony export */ \"readTokenAmount\": () => (/* binding */ readTokenAmount),\n/* harmony export */ \"readTokenPrefix\": () => (/* binding */ readTokenPrefix),\n/* harmony export */ \"readTransaction\": () => (/* binding */ readTransaction),\n/* harmony export */ \"readTransactionCommon\": () => (/* binding */ readTransactionCommon),\n/* harmony export */ \"readTransactionInput\": () => (/* binding */ readTransactionInput),\n/* harmony export */ \"readTransactionInputs\": () => (/* binding */ readTransactionInputs),\n/* harmony export */ \"readTransactionNonTokenAware\": () => (/* binding */ readTransactionNonTokenAware),\n/* harmony export */ \"readTransactionOutput\": () => (/* binding */ readTransactionOutput),\n/* harmony export */ \"readTransactionOutputNonTokenAware\": () => (/* binding */ readTransactionOutputNonTokenAware),\n/* harmony export */ \"readTransactionOutputs\": () => (/* binding */ readTransactionOutputs),\n/* harmony export */ \"readTransactionOutputsNonTokenAware\": () => (/* binding */ readTransactionOutputsNonTokenAware)\n/* harmony export */ });\n/* harmony import */ var _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../crypto/crypto.js */ \"../../node_modules/@bitauth/libauth/build/lib/crypto/default-crypto-instances.js\");\n/* harmony import */ var _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../crypto/crypto.js */ \"../../node_modules/@bitauth/libauth/build/lib/crypto/combinations.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/hex.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/number.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/read.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../format/format.js */ \"../../node_modules/@bitauth/libauth/build/lib/format/error.js\");\n/* harmony import */ var _read_components_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./read-components.js */ \"../../node_modules/@bitauth/libauth/build/lib/message/read-components.js\");\n/* harmony import */ var _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./transaction-types.js */ \"../../node_modules/@bitauth/libauth/build/lib/message/transaction-types.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__, _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__]);\n([_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__, _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);\n\n\n\n\n/**\n * Encode a single input for inclusion in an encoded transaction.\n *\n * @param input - the input to encode\n */\nconst encodeTransactionInput = (input) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n input.outpointTransactionHash.slice().reverse(),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(input.outpointIndex),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(BigInt(input.unlockingBytecode.length)),\n input.unlockingBytecode,\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(input.sequenceNumber),\n]);\nvar TransactionDecodingError;\n(function (TransactionDecodingError) {\n TransactionDecodingError[\"transaction\"] = \"Error reading transaction.\";\n TransactionDecodingError[\"endsWithUnexpectedBytes\"] = \"Error decoding transaction: the provided input includes unexpected bytes after the encoded transaction.\";\n TransactionDecodingError[\"input\"] = \"Error reading transaction input.\";\n TransactionDecodingError[\"inputs\"] = \"Error reading transaction inputs.\";\n TransactionDecodingError[\"output\"] = \"Error reading transaction output.\";\n TransactionDecodingError[\"outputs\"] = \"Error reading transaction outputs.\";\n TransactionDecodingError[\"outputsEndWithUnexpectedBytes\"] = \"Error decoding transaction outputs: the provided serialization includes unexpected bytes after the encoded transaction outputs.\";\n TransactionDecodingError[\"lockingBytecodeLength\"] = \"Error reading locking bytecode length.\";\n})(TransactionDecodingError || (TransactionDecodingError = {}));\n/**\n * Read a transaction {@link Input} from the provided {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Input} and the next {@link ReadPosition}.\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction output\n */\nconst readTransactionInput = (position) => {\n const inputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readBytes)(32 /* TransactionConstants.outpointTransactionHashLength */),\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactUintPrefixedBin,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof inputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.input, inputRead);\n }\n const { position: nextPosition, result: [outpointTransactionHash, outpointIndex, unlockingBytecode, sequenceNumber,], } = inputRead;\n return {\n position: nextPosition,\n result: {\n outpointIndex,\n outpointTransactionHash: outpointTransactionHash.reverse(),\n sequenceNumber,\n unlockingBytecode,\n },\n };\n};\n/**\n * Encode a set of {@link Input}s for inclusion in an encoded transaction\n * including the prefixed number of inputs.\n *\n * Format: [CompactUint: input count] [encoded inputs]\n *\n * @param inputs - the set of inputs to encode\n */\nconst encodeTransactionInputs = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(BigInt(inputs.length)),\n ...inputs.map(encodeTransactionInput),\n]);\n/**\n * Read a set of transaction {@link Input}s beginning at {@link ReadPosition}.\n * A CompactUint will be read to determine the number of inputs, and that\n * number of transaction inputs will be read and returned. Returns either an\n * error message (as a string) or an object containing the array of inputs and\n * the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction inputs\n */\nconst readTransactionInputs = (position) => {\n const inputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(position, readTransactionInput);\n if (typeof inputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.inputs, inputsRead);\n }\n return inputsRead;\n};\nconst maximumTokenAmount = 9223372036854775807n;\nconst nftCapabilityNumberToLabel = [\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none,\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.mutable,\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.minting,\n];\nconst nftCapabilityLabelToNumber = {\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none]: 0,\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.mutable]: 1,\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.minting]: 2,\n};\nvar CashTokenDecodingError;\n(function (CashTokenDecodingError) {\n CashTokenDecodingError[\"invalidPrefix\"] = \"Error reading token prefix.\";\n CashTokenDecodingError[\"insufficientLength\"] = \"Invalid token prefix: insufficient length.\";\n CashTokenDecodingError[\"reservedBit\"] = \"Invalid token prefix: reserved bit is set.\";\n CashTokenDecodingError[\"invalidCapability\"] = \"Invalid token prefix: capability must be none (0), mutable (1), or minting (2).\";\n CashTokenDecodingError[\"commitmentWithoutNft\"] = \"Invalid token prefix: commitment requires an NFT.\";\n CashTokenDecodingError[\"capabilityWithoutNft\"] = \"Invalid token prefix: capability requires an NFT.\";\n CashTokenDecodingError[\"commitmentLengthZero\"] = \"Invalid token prefix: if encoded, commitment length must be greater than 0.\";\n CashTokenDecodingError[\"invalidCommitment\"] = \"Invalid token prefix: invalid non-fungible token commitment.\";\n CashTokenDecodingError[\"invalidAmountEncoding\"] = \"Invalid token prefix: invalid fungible token amount encoding.\";\n CashTokenDecodingError[\"zeroAmount\"] = \"Invalid token prefix: if encoded, fungible token amount must be greater than 0.\";\n CashTokenDecodingError[\"excessiveAmount\"] = \"Invalid token prefix: exceeds maximum fungible token amount of 9223372036854775807.\";\n CashTokenDecodingError[\"noTokens\"] = \"Invalid token prefix: must encode at least one token.\";\n})(CashTokenDecodingError || (CashTokenDecodingError = {}));\n/**\n * Read a token amount from the provided {@link ReadPosition}, returning either\n * an error message (as a string) or an object containing the value and the next\n * {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * token amount.\n */\nconst readTokenAmount = (position) => {\n const amountRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.readCompactUintMinimal)(position);\n if (typeof amountRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidAmountEncoding, amountRead);\n }\n if (amountRead.result > maximumTokenAmount) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.excessiveAmount, `Encoded amount: ${amountRead.result}`);\n }\n if (amountRead.result === 0n) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.zeroAmount);\n }\n return amountRead;\n};\n/**\n * Attempt to read a transaction {@link Output}'s token prefix from the provided\n * {@link ReadPosition}, returning either an error message (as a string) or an\n * object containing the (optional) token information and the\n * next {@link ReadPosition}.\n *\n * Rather than using this function directly, most applications\n * should use {@link readLockingBytecodeWithPrefix}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * token prefix\n */\n// eslint-disable-next-line complexity\nconst readTokenPrefix = (position) => {\n const { bin, index } = position;\n if (bin[index] !== 239 /* CashTokens.PREFIX_TOKEN */) {\n return { position, result: {} };\n }\n if (bin.length < index + 34 /* CashTokens.minimumPrefixLength */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.insufficientLength, `The minimum possible length is ${34 /* CashTokens.minimumPrefixLength */}. Missing bytes: ${34 /* CashTokens.minimumPrefixLength */ - (bin.length - index)}`);\n }\n const category = bin\n .slice(index + 1, index + 33 /* CashTokens.tokenBitfieldIndex */)\n .reverse();\n const tokenBitfield = bin[index + 33 /* CashTokens.tokenBitfieldIndex */]; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n /* eslint-disable no-bitwise */\n const prefixStructure = tokenBitfield & 240 /* CashTokens.tokenFormatMask */;\n if ((prefixStructure & 128 /* CashTokens.RESERVED_BIT */) !== 0) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.reservedBit, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const nftCapabilityInt = tokenBitfield & 15 /* CashTokens.nftCapabilityMask */;\n if (nftCapabilityInt > 2 /* CashTokens.maximumCapability */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidCapability, `Capability value: ${nftCapabilityInt}`);\n }\n const capability = nftCapabilityNumberToLabel[nftCapabilityInt]; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n const hasNft = (prefixStructure & 32 /* CashTokens.HAS_NFT */) !== 0;\n const hasCommitmentLength = (prefixStructure & 64 /* CashTokens.HAS_COMMITMENT_LENGTH */) !== 0;\n if (hasCommitmentLength && !hasNft) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.commitmentWithoutNft, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const hasAmount = (prefixStructure & 16 /* CashTokens.HAS_AMOUNT */) !== 0;\n /* eslint-enable no-bitwise */\n const nextPosition = {\n bin,\n index: index + 33 /* CashTokens.tokenBitfieldIndex */ + 1,\n };\n if (hasNft) {\n const commitmentRead = hasCommitmentLength\n ? (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactUintPrefixedBin)(nextPosition)\n : { position: nextPosition, result: Uint8Array.of() };\n if (typeof commitmentRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidCommitment, commitmentRead);\n }\n if (hasCommitmentLength && commitmentRead.result.length === 0) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.commitmentLengthZero);\n }\n const amountRead = hasAmount\n ? readTokenAmount(commitmentRead.position)\n : { position: commitmentRead.position, result: 0n };\n if (typeof amountRead === 'string') {\n return amountRead;\n }\n return {\n position: amountRead.position,\n result: {\n token: {\n amount: amountRead.result,\n category,\n nft: { capability, commitment: commitmentRead.result },\n },\n },\n };\n }\n if (capability !== _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.capabilityWithoutNft, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n if (!hasAmount) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.noTokens, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const amountRead = readTokenAmount(nextPosition);\n if (typeof amountRead === 'string') {\n return amountRead;\n }\n return {\n position: amountRead.position,\n result: { token: { amount: amountRead.result, category } },\n };\n};\n/**\n * Read the locking bytecode and token prefix (if present) of a transaction\n * {@link Output}, beginning at the `CompactUint` indicating the\n * combined length.\n * @param position - the {@link ReadPosition} at which to start reading the\n * optional token prefix and locking bytecode\n */\nconst readLockingBytecodeWithPrefix = (position) => {\n const bytecodeRead = (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactUintPrefixedBin)(position);\n if (typeof bytecodeRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.lockingBytecodeLength, bytecodeRead);\n }\n const { result: contents, position: nextPosition } = bytecodeRead;\n const contentsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)({ bin: contents, index: 0 }, [\n readTokenPrefix,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readRemainingBytes,\n ]);\n if (typeof contentsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidPrefix, contentsRead);\n }\n const { result: [{ token }, lockingBytecode], } = contentsRead;\n return {\n position: nextPosition,\n result: { lockingBytecode, ...(token === undefined ? {} : { token }) },\n };\n};\n/**\n * Read a transaction {@link Output} from the provided {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Output} and the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction output\n */\nconst readTransactionOutput = (position) => {\n const outputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint64LE,\n readLockingBytecodeWithPrefix,\n ]);\n if (typeof outputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.output, outputRead);\n }\n const { position: nextPosition, result: [valueSatoshis, { lockingBytecode, token }], } = outputRead;\n return {\n position: nextPosition,\n result: {\n lockingBytecode,\n ...(token === undefined ? {} : { token }),\n valueSatoshis,\n },\n };\n};\n/**\n * Given {@link Output.token} data, encode a token prefix.\n *\n * This function does not fail, but returns an empty Uint8Array if the token\n * data does not encode any tokens (even if `token.category` is set).\n *\n * @param token - the token data to encode\n */\n// eslint-disable-next-line complexity\nconst encodeTokenPrefix = (token) => {\n if (token === undefined || (token.nft === undefined && token.amount < 1n)) {\n return Uint8Array.of();\n }\n const hasNft = token.nft === undefined ? 0 : 32 /* CashTokens.HAS_NFT */;\n const capabilityInt = token.nft === undefined\n ? 0\n : nftCapabilityLabelToNumber[token.nft.capability];\n const hasCommitmentLength = token.nft !== undefined && token.nft.commitment.length > 0\n ? 64 /* CashTokens.HAS_COMMITMENT_LENGTH */\n : 0;\n const hasAmount = token.amount > 0n ? 16 /* CashTokens.HAS_AMOUNT */ : 0;\n const tokenBitfield = \n // eslint-disable-next-line no-bitwise\n hasNft | hasCommitmentLength | hasAmount | capabilityInt;\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n Uint8Array.of(239 /* CashTokens.PREFIX_TOKEN */),\n token.category.slice().reverse(),\n Uint8Array.of(tokenBitfield),\n ...(hasCommitmentLength === 0\n ? []\n : [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(BigInt(token.nft.commitment.length)),\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n token.nft.commitment,\n ]),\n ...(hasAmount === 0 ? [] : [(0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(token.amount)]),\n ]);\n};\n/**\n * Encode a single {@link Output} for inclusion in an encoded transaction.\n *\n * @param output - the output to encode\n */\nconst encodeTransactionOutput = (output) => {\n const lockingBytecodeField = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n encodeTokenPrefix(output.token),\n output.lockingBytecode,\n ]);\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.valueSatoshisToBin)(output.valueSatoshis),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(BigInt(lockingBytecodeField.length)),\n lockingBytecodeField,\n ]);\n};\n/**\n * Read a set of transaction {@link Output}s beginning at {@link ReadPosition}.\n * A CompactUint will be read to determine the number of outputs, and that\n * number of transaction outputs will be read and returned. Returns either an\n * error message (as a string) or an object containing the array of outputs and\n * the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction outputs\n */\nconst readTransactionOutputs = (position) => {\n const outputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(position, readTransactionOutput);\n if (typeof outputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.outputs, outputsRead);\n }\n return outputsRead;\n};\n/**\n * Decode a CompactUint-prefixed series of Transaction {@link Output}s\n * according to the version 1/2 P2P network transaction format.\n *\n * This function verifies that the provided `bin` contains one `CompactUint`\n * followed by the indicated number of serialized transaction outputs with no\n * additional data. To read a transaction from a\n * specific location within a `Uint8Array`, use {@link readTransactionCommon}.\n *\n * For the reverse, see {@link encodeTransactionOutputs}.\n *\n * @param bin - the encoded transaction to decode\n */\nconst decodeTransactionOutputs = (bin) => {\n const outputsRead = readTransactionOutputs({ bin, index: 0 });\n if (typeof outputsRead === 'string') {\n return outputsRead;\n }\n if (outputsRead.position.index !== bin.length) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.outputsEndWithUnexpectedBytes, `Last encoded transaction output ends at index ${outputsRead.position.index - 1}, leaving ${bin.length - outputsRead.position.index} remaining byte(s).`);\n }\n return outputsRead.result;\n};\n/**\n * Encode a set of {@link Output}s for inclusion in an encoded transaction\n * including the prefixed number of outputs. Note, this encoding differs from\n * {@link encodeTransactionOutputsForSigning} (used for signing serializations).\n *\n * Format: `[CompactUint: output count] [encoded outputs]`\n *\n * For the reverse, see {@link decodeTransactionOutputs}.\n *\n * @param outputs - the set of outputs to encode\n */\nconst encodeTransactionOutputs = (outputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactUint)(BigInt(outputs.length)),\n ...outputs.map(encodeTransactionOutput),\n]);\n/**\n * Read a version 1 or 2 transaction beginning at {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Transaction} and the next {@link ReadPosition}. Rather than using this\n * function directly, most applications should\n * use {@link decodeTransactionCommon}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * {@link TransactionCommon}\n */\nconst readTransactionCommon = (position) => {\n const transactionRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n readTransactionInputs,\n readTransactionOutputs,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof transactionRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.transaction, transactionRead);\n }\n const { position: nextPosition, result: [version, inputs, outputs, locktime], } = transactionRead;\n return {\n position: nextPosition,\n result: { inputs, locktime, outputs, version },\n };\n};\nconst readTransaction = readTransactionCommon;\nconst readTransactionOutputNonTokenAware = (pos) => {\n const outputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(pos, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint64LE,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactUintPrefixedBin,\n ]);\n if (typeof outputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.output, outputRead);\n }\n const { position: nextPosition, result: [valueSatoshis, lockingBytecode], } = outputRead;\n return {\n position: nextPosition,\n result: { lockingBytecode, valueSatoshis },\n };\n};\nconst readTransactionOutputsNonTokenAware = (pos) => {\n const outputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(pos, readTransactionOutputNonTokenAware);\n if (typeof outputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.outputs, outputsRead);\n }\n return outputsRead;\n};\n/**\n * Read a version 1 or 2 transaction beginning at a {@link ReadPosition} as if\n * CHIP-2022-02-CashTokens were not deployed, returning either an error message\n * (as a string) or an object containing the {@link Transaction} and the next\n * {@link ReadPosition}.\n *\n * This function emulates legacy transaction parsing to test behavior prior to\n * deployment of CHIP-2022-02-CashTokens; most applications should instead\n * use {@link readTransactionCommon}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * {@link TransactionCommon}\n */\nconst readTransactionNonTokenAware = (position) => {\n const transactionRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n readTransactionInputs,\n readTransactionOutputsNonTokenAware,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof transactionRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.transaction, transactionRead);\n }\n const { position: nextPosition, result: [version, inputs, outputs, locktime], } = transactionRead;\n return {\n position: nextPosition,\n result: { inputs, locktime, outputs, version },\n };\n};\n/**\n * Decode a {@link TransactionCommon} according to the version 1/2 P2P network\n * transaction format.\n *\n * This function verifies that the provided `bin` contains only one transaction\n * and no additional data. To read a transaction from a specific location within\n * a `Uint8Array`, use {@link readTransactionCommon}.\n *\n * For the reverse, see {@link encodeTransactionCommon}.\n *\n * @param bin - the encoded transaction to decode\n */\nconst decodeTransactionCommon = (bin) => {\n const transactionRead = readTransactionCommon({ bin, index: 0 });\n if (typeof transactionRead === 'string') {\n return transactionRead;\n }\n if (transactionRead.position.index !== bin.length) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.endsWithUnexpectedBytes, `Encoded transaction ends at index ${transactionRead.position.index - 1}, leaving ${bin.length - transactionRead.position.index} remaining bytes.`);\n }\n return transactionRead.result;\n};\nconst decodeTransactionBch = decodeTransactionCommon;\nconst decodeTransaction = decodeTransactionBch;\n/**\n * @deprecated Alias of `decodeTransactionBch` for backwards-compatibility.\n */\nconst decodeTransactionBCH = decodeTransactionBch;\n/**\n * Decode a {@link TransactionCommon} from a trusted source according to the\n * version 1/2 P2P network transaction format.\n *\n * Note: this method throws runtime errors when attempting to decode messages\n * which do not properly follow the transaction format. If the input is\n * untrusted, use {@link decodeTransactionCommon}.\n *\n * @param bin - the raw message to decode\n */\nconst decodeTransactionUnsafeCommon = (bin) => {\n const result = decodeTransactionCommon(bin);\n if (typeof result === 'string') {\n // eslint-disable-next-line functional/no-throw-statements\n throw new Error(result);\n }\n return result;\n};\nconst decodeTransactionUnsafeBch = decodeTransactionUnsafeCommon;\nconst decodeTransactionUnsafe = decodeTransactionUnsafeBch;\n/**\n * @deprecated Alias of `decodeTransactionUnsafeBch` for backwards-compatibility.\n */\nconst decodeTransactionUnsafeBCH = decodeTransactionUnsafeBch;\n/**\n * Encode a {@link Transaction} using the standard P2P network format. This\n * serialization is also used when computing the transaction's hash (A.K.A.\n * \"transaction ID\" or \"TXID\").\n *\n * For the reverse, see {@link decodeTransactionCommon}.\n */\nconst encodeTransactionCommon = (tx) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(tx.version),\n encodeTransactionInputs(tx.inputs),\n encodeTransactionOutputs(tx.outputs),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(tx.locktime),\n]);\nconst encodeTransactionBch = encodeTransactionCommon;\nconst encodeTransaction = encodeTransactionBch;\n/**\n * @deprecated Alias of `decodeTransactionUnsafeBch` for backwards-compatibility.\n */\nconst encodeTransactionBCH = encodeTransactionBch;\n/**\n * Compute a transaction hash (A.K.A. \"transaction ID\" or \"TXID\") from an\n * encoded transaction in P2P network message order. This is the byte order\n * produced by most sha256 libraries and used by encoded P2P network messages.\n * It is also the byte order produced by `OP_SHA256` and `OP_HASH256` in the\n * virtual machine.\n *\n * @returns the transaction hash in P2P network message byte order\n *\n * @param transaction - the encoded transaction\n * @param sha256 - an implementation of sha256\n */\nconst hashTransactionP2pOrder = (transaction, sha256 = _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__.sha256) => (0,_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__.hash256)(transaction, sha256);\n/**\n * Compute a transaction hash (A.K.A. \"transaction ID\" or \"TXID\") from an\n * encoded transaction in user interface byte order. This is the byte order\n * typically used by block explorers, wallets, and other user interfaces.\n *\n * To return this result as a `string`, use {@link hashTransaction}.\n *\n * @returns the transaction hash in User Interface byte order\n *\n * @param transaction - the encoded transaction\n * @param sha256 - an implementation of sha256\n */\nconst hashTransactionUiOrder = (transaction, sha256 = _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__.sha256) => hashTransactionP2pOrder(transaction, sha256).reverse();\n/**\n * Return an encoded {@link Transaction}'s hash/ID as a string in user interface\n * byte order (typically used by wallets and block explorers).\n *\n * To return this result as a `Uint8Array`, use {@link hashTransactionUiOrder}.\n *\n * @param transaction - the encoded transaction\n */\nconst hashTransaction = (transaction) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.binToHex)(hashTransactionUiOrder(transaction));\n/**\n * Encode all outpoints in a series of transaction inputs. (For use in\n * {@link hashTransactionOutpoints}.)\n *\n * @param inputs - the series of inputs from which to extract the outpoints\n */\nconst encodeTransactionOutpoints = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(inputs.map((i) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n i.outpointTransactionHash.slice().reverse(),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(i.outpointIndex),\n])));\n/**\n * Encode an array of transaction {@link Output}s for use in transaction signing\n * serializations. Note, this encoding differs from\n * {@link encodeTransactionOutputs} (used for encoding full transactions).\n *\n * @param outputs - the array of outputs to encode\n */\nconst encodeTransactionOutputsForSigning = (outputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(outputs.map(encodeTransactionOutput));\n/**\n * Encode the sequence numbers of an array of transaction inputs for use in\n * transaction signing serializations.\n *\n * @param inputs - the array of inputs from which to extract the sequence\n * numbers\n */\nconst encodeTransactionInputSequenceNumbersForSigning = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(inputs.map((i) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(i.sequenceNumber)));\n//# sourceMappingURL=transaction-encoding.js.map\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/message/transaction-encoding.js?");
|
|
327
327
|
|
|
328
328
|
/***/ }),
|
|
329
329
|
|
|
@@ -334,7 +334,7 @@ eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_de
|
|
|
334
334
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
335
335
|
|
|
336
336
|
"use strict";
|
|
337
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"NonFungibleTokenCapability\": () => (/* binding */ NonFungibleTokenCapability)
|
|
337
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"NonFungibleTokenCapability\": () => (/* binding */ NonFungibleTokenCapability),\n/* harmony export */ \"excessiveSatoshis\": () => (/* binding */ excessiveSatoshis)\n/* harmony export */ });\n/**\n * The capability assigned to a particular non-fungible token.\n */\nvar NonFungibleTokenCapability;\n(function (NonFungibleTokenCapability) {\n /**\n * No capability, i.e. the token is an **immutable token**.\n */\n NonFungibleTokenCapability[\"none\"] = \"none\";\n /**\n * The mutable capability (`0x01`), i.e. the token is a **mutable token**.\n */\n NonFungibleTokenCapability[\"mutable\"] = \"mutable\";\n /**\n * The minting capability (`0x02`), i.e. the token is a **minting token**.\n */\n NonFungibleTokenCapability[\"minting\"] = \"minting\";\n})(NonFungibleTokenCapability || (NonFungibleTokenCapability = {}));\n/**\n * The maximum uint64 value – an impossibly large, intentionally invalid value\n * for `valueSatoshis`. See {@link Transaction.valueSatoshis} for details.\n */\n// prettier-ignore\n// eslint-disable-next-line @typescript-eslint/no-magic-numbers\nconst excessiveSatoshis = Uint8Array.from([255, 255, 255, 255, 255, 255, 255, 255]);\n//# sourceMappingURL=transaction-types.js.map\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../../node_modules/@bitauth/libauth/build/lib/message/transaction-types.js?");
|
|
338
338
|
|
|
339
339
|
/***/ }),
|
|
340
340
|
|
|
@@ -521,7 +521,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
521
521
|
/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
522
522
|
|
|
523
523
|
"use strict";
|
|
524
|
-
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"initProvider\": () => (/* binding */ initProvider)\n/* harmony export */ });\n/* unused harmony exports initProviders, disconnectProviders */\n/* harmony import */ var _default_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./default.js */ \"../mainnet-js/dist/module/network/default.js\");\n/* harmony import */ var
|
|
524
|
+
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"initProvider\": () => (/* binding */ initProvider)\n/* harmony export */ });\n/* unused harmony exports initProviders, disconnectProviders */\n/* harmony import */ var _default_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./default.js */ \"../mainnet-js/dist/module/network/default.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../interface.js */ \"../mainnet-js/dist/module/interface.js\");\n/* harmony import */ var _constant_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constant.js */ \"../mainnet-js/dist/module/network/constant.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_default_js__WEBPACK_IMPORTED_MODULE_0__]);\n_default_js__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];\n\n\n\nasync function initProvider(network) {\n if (!(0,_default_js__WEBPACK_IMPORTED_MODULE_0__.getGlobalProvider)(network)) {\n if (process.env.USE_MOCK_PROVIDER) {\n if (network !== _interface_js__WEBPACK_IMPORTED_MODULE_1__.Network.REGTEST)\n return;\n const provider = (await (0,_default_js__WEBPACK_IMPORTED_MODULE_0__.createMockProvider)());\n await provider.ready();\n await provider.seedAlice();\n (0,_default_js__WEBPACK_IMPORTED_MODULE_0__.setGlobalProvider)(network, provider);\n return provider;\n }\n const provider = await (0,_default_js__WEBPACK_IMPORTED_MODULE_0__.createProvider)(network);\n await provider.connect();\n (0,_default_js__WEBPACK_IMPORTED_MODULE_0__.setGlobalProvider)(network, provider);\n return provider;\n }\n return (0,_default_js__WEBPACK_IMPORTED_MODULE_0__.getGlobalProvider)(network);\n}\nasync function initProviders(networks) {\n networks = networks ? networks : Object.keys(_constant_js__WEBPACK_IMPORTED_MODULE_2__.networkTickerMap);\n const results = await Promise.allSettled(networks.map((n) => initProvider(n)));\n for (let i = 0; i < results.length; i++) {\n if (results[i].status === \"rejected\") {\n const { reason } = results[i];\n const message = reason instanceof Error ? reason.message : reason;\n console.warn(`Warning, couldn't establish a connection for ${networks[i]}: ${message}`);\n }\n }\n}\nasync function disconnectProvider(network) {\n if (process.env.USE_MOCK_PROVIDER)\n return;\n const provider = (0,_default_js__WEBPACK_IMPORTED_MODULE_0__.getGlobalProvider)(network);\n if (provider) {\n await provider.disconnect();\n (0,_default_js__WEBPACK_IMPORTED_MODULE_0__.removeGlobalProvider)(network);\n }\n}\nasync function disconnectProviders(networks) {\n networks = networks ? networks : Object.keys(_constant_js__WEBPACK_IMPORTED_MODULE_2__.networkTickerMap);\n await Promise.all(networks.map((n) => disconnectProvider(n)));\n}\n//# sourceMappingURL=Connection.js.map\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../mainnet-js/dist/module/network/Connection.js?");
|
|
525
525
|
|
|
526
526
|
/***/ }),
|
|
527
527
|
|
|
@@ -532,7 +532,7 @@ eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_de
|
|
|
532
532
|
/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
533
533
|
|
|
534
534
|
"use strict";
|
|
535
|
-
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ ElectrumNetworkProvider)\n/* harmony export */ });\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../interface.js */ \"../mainnet-js/dist/module/interface.js\");\n/* harmony import */ var _util_transaction_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../util/transaction.js */ \"../mainnet-js/dist/module/util/transaction.js\");\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../config.js */ \"../mainnet-js/dist/module/config.js\");\n/* harmony import */ var _util_header_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/header.js */ \"../mainnet-js/dist/module/util/header.js\");\n/* harmony import */ var _cache_IndexedDbCache_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../cache/IndexedDbCache.js */ \"../mainnet-js/dist/module/cache/IndexedDbCache.js\");\n/* harmony import */ var _cache_WebStorageCache_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../cache/WebStorageCache.js */ \"../mainnet-js/dist/module/cache/WebStorageCache.js\");\n/* harmony import */ var _cache_MemoryCache_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../cache/MemoryCache.js */ \"../mainnet-js/dist/module/cache/MemoryCache.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_util_header_js__WEBPACK_IMPORTED_MODULE_5__, _util_transaction_js__WEBPACK_IMPORTED_MODULE_6__]);\n([_util_header_js__WEBPACK_IMPORTED_MODULE_5__, _util_transaction_js__WEBPACK_IMPORTED_MODULE_6__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);\n\n\n\n\n\n\n\nclass ElectrumNetworkProvider {\n get cache() {\n if (!_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseMemoryCache &&\n !_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseLocalStorageCache &&\n !_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseIndexedDBCache) {\n this._cache = undefined;\n return this._cache;\n }\n if (_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseMemoryCache && !(this._cache instanceof _cache_MemoryCache_js__WEBPACK_IMPORTED_MODULE_1__.MemoryCache)) {\n this._cache = new _cache_MemoryCache_js__WEBPACK_IMPORTED_MODULE_1__.MemoryCache();\n return this._cache;\n }\n if (_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseLocalStorageCache &&\n !(this._cache instanceof _cache_WebStorageCache_js__WEBPACK_IMPORTED_MODULE_2__.WebStorageCache)) {\n this._cache = new _cache_WebStorageCache_js__WEBPACK_IMPORTED_MODULE_2__.WebStorageCache();\n return this._cache;\n }\n if (_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseIndexedDBCache && !(this._cache instanceof _cache_IndexedDbCache_js__WEBPACK_IMPORTED_MODULE_3__.IndexedDbCache)) {\n this._cache = new _cache_IndexedDbCache_js__WEBPACK_IMPORTED_MODULE_3__.IndexedDbCache();\n return this._cache;\n }\n return this._cache;\n }\n constructor(transport, network = _interface_js__WEBPACK_IMPORTED_MODULE_4__.Network.MAINNET) {\n this.network = network;\n this.subscriptions = 0;\n this.currentHeight = 0;\n if (transport) {\n this.transport = transport;\n }\n else {\n throw new Error(`A transport is required.`);\n }\n }\n async getUtxos(cashaddr) {\n const result = await this.performRequest(\"blockchain.address.listunspent\", [\n cashaddr,\n \"include_tokens\",\n ]);\n return result.map((utxo) => ({\n address: cashaddr,\n txid: utxo.tx_hash,\n vout: utxo.tx_pos,\n satoshis: BigInt(utxo.value),\n height: utxo.height,\n token: utxo.token_data\n ? {\n ...utxo.token_data,\n amount: BigInt(utxo.token_data.amount),\n }\n : undefined,\n }));\n }\n async getBalance(cashaddr) {\n const result = await this.performRequest(\"blockchain.address.get_balance\", [\n cashaddr,\n ]);\n return BigInt(result.confirmed) + BigInt(result.unconfirmed);\n }\n async getHeader(height, verbose = false) {\n const key = `header-${this.network}-${height}-${verbose}`;\n if (this.cache) {\n const cached = await this.cache.getItem(key);\n if (cached) {\n return verbose ? (0,_util_header_js__WEBPACK_IMPORTED_MODULE_5__.decodeHeader)(JSON.parse(cached)) : JSON.parse(cached);\n }\n }\n const result = await this.performRequest(\"blockchain.header.get\", [height]);\n if (this.cache) {\n await this.cache.setItem(key, JSON.stringify(result));\n }\n return verbose ? (0,_util_header_js__WEBPACK_IMPORTED_MODULE_5__.decodeHeader)(result) : result;\n }\n async getRawTransactions(hashes) {\n if (hashes.length === 0)\n return new Map();\n const results = new Map();\n const keys = hashes.map((hash) => `txraw-${this.network}-${hash}`);\n // batch cache read\n let cached;\n if (this.cache) {\n cached = await this.cache.getItems(keys);\n }\n const misses = [];\n for (let i = 0; i < hashes.length; i++) {\n const val = cached?.get(keys[i]);\n if (val) {\n results.set(hashes[i], val);\n }\n else {\n misses.push(hashes[i]);\n }\n }\n if (misses.length > 0) {\n // rpckit automatically batches concurrent requests via BatchScheduler\n const fetched = await Promise.all(misses.map(async (hash) => {\n const tx = await this.performRequest(\"blockchain.transaction.get\", [\n hash,\n false,\n ]);\n return [hash, tx];\n }));\n // batch cache write\n if (this.cache) {\n const entries = fetched.map(([hash, tx]) => [\n `txraw-${this.network}-${hash}`,\n tx,\n ]);\n await this.cache.setItems(entries);\n }\n for (const [hash, tx] of fetched) {\n results.set(hash, tx);\n }\n }\n return results;\n }\n async getHeaders(heights) {\n if (heights.length === 0)\n return new Map();\n const results = new Map();\n const keys = heights.map((height) => `header-${this.network}-${height}-true`);\n // batch cache read\n let cached;\n if (this.cache) {\n cached = await this.cache.getItems(keys);\n }\n const misses = [];\n for (let i = 0; i < heights.length; i++) {\n const val = cached?.get(keys[i]);\n if (val) {\n results.set(heights[i], (0,_util_header_js__WEBPACK_IMPORTED_MODULE_5__.decodeHeader)(JSON.parse(val)));\n }\n else {\n misses.push(heights[i]);\n }\n }\n if (misses.length > 0) {\n // rpckit automatically batches concurrent requests via BatchScheduler\n const fetched = await Promise.all(misses.map(async (height) => {\n const result = await this.performRequest(\"blockchain.header.get\", [\n height,\n ]);\n return [height, result];\n }));\n // batch cache write\n if (this.cache) {\n const entries = fetched.map(([height, result]) => [\n `header-${this.network}-${height}-true`,\n JSON.stringify(result),\n ]);\n await this.cache.setItems(entries);\n }\n for (const [height, result] of fetched) {\n results.set(height, (0,_util_header_js__WEBPACK_IMPORTED_MODULE_5__.decodeHeader)(result));\n }\n }\n return results;\n }\n async getBlockHeight() {\n if (!this.headerCancelFn) {\n this.headerCancelFn = await this.subscribeToHeaders((header) => {\n if (header.height > this.currentHeight) {\n this.currentHeight = header.height;\n }\n });\n }\n if (!this.currentHeight) {\n throw new Error(\"Check failed for eventual inconsistency in subscription implementations.\");\n }\n return this.currentHeight;\n }\n async getRawTransaction(txHash, verbose = false, loadInputValues = false) {\n const nonVerboseKey = `txraw-${this.network}-${txHash}`;\n const verboseKey = `tx-${this.network}-${txHash}`;\n const key = verbose ? verboseKey : nonVerboseKey;\n if (this.cache) {\n const cached = await this.cache.getItem(key);\n if (cached) {\n if (!verbose) {\n return cached;\n }\n const cachedTx = JSON.parse(cached);\n if (cachedTx.confirmations > 0) {\n const currentHeight = await this.getBlockHeight();\n cachedTx.confirmations += currentHeight - cachedTx.fetchHeight;\n }\n const { fetchHeight: _, ...transaction } = cachedTx;\n if (loadInputValues) {\n return this.enrichWithInputValues(transaction);\n }\n return transaction;\n }\n }\n try {\n const result = await this.performRequest(\"blockchain.transaction.get\", [\n txHash,\n verbose,\n ]);\n if (!verbose) {\n const hex = result;\n if (this.cache) {\n await this.cache.setItem(key, hex);\n }\n return hex;\n }\n const cachedTx = result;\n cachedTx.confirmations ??= 0;\n cachedTx.fetchHeight = await this.getBlockHeight();\n if (this.cache) {\n await this.cache.setItem(key, JSON.stringify(cachedTx));\n }\n const { fetchHeight: _, ...transaction } = cachedTx;\n if (loadInputValues) {\n return this.enrichWithInputValues(transaction);\n }\n return transaction;\n }\n catch (error) {\n if (error.message.indexOf(\"No such mempool or blockchain transaction\") > -1)\n throw Error(`Could not decode transaction ${txHash}. It might not exist on the current blockchain (${this.network}).`);\n else\n throw error;\n }\n }\n async enrichWithInputValues(transaction) {\n const hashes = [...new Set(transaction.vin.map((val) => val.txid))];\n const transactions = await Promise.all(hashes.map((hash) => this.getRawTransactionObject(hash, false)));\n const transactionMap = new Map();\n transactions.forEach((val) => transactionMap.set(val.hash, val));\n const enrichedVin = transaction.vin.map((input) => {\n const output = transactionMap\n .get(input.txid)\n .vout.find((val) => val.n === input.vout);\n return { ...input, ...output };\n });\n return { ...transaction, vin: enrichedVin };\n }\n async getRawTransactionObject(txHash, loadInputValues = false) {\n if (loadInputValues) {\n return this.getRawTransaction(txHash, true, true);\n }\n return this.getRawTransaction(txHash, true);\n }\n async sendRawTransaction(txHex, awaitPropagation = true) {\n return new Promise(async (resolve, reject) => {\n let txHash = await (0,_util_transaction_js__WEBPACK_IMPORTED_MODULE_6__.getTransactionHash)(txHex);\n if (!awaitPropagation) {\n this.performRequest(\"blockchain.transaction.broadcast\", [txHex]).catch(() => { });\n resolve(txHash);\n }\n else {\n let cancel;\n const waitForTransactionCallback = async (data) => {\n if (data && data[0] === txHash && data[1] !== null) {\n await cancel?.();\n resolve(txHash);\n }\n };\n cancel = await this.subscribeToTransaction(txHash, waitForTransactionCallback);\n this.performRequest(\"blockchain.transaction.broadcast\", [txHex]).catch(async (error) => {\n await cancel?.();\n reject(error);\n });\n }\n });\n }\n // Get transaction history of a given cashaddr\n async getHistory(cashaddr, fromHeight = 0, toHeight = -1) {\n return this.performRequest(\"blockchain.address.get_history\", [\n cashaddr,\n fromHeight,\n toHeight,\n ]);\n }\n // Get the minimum fee a low-priority transaction must pay in order to be accepted to the daemon's memory pool.\n async getRelayFee() {\n return this.performRequest(\"blockchain.relayfee\");\n }\n async watchAddressStatus(cashaddr, callback) {\n const watchAddressStatusCallback = async (data) => {\n // subscription acknowledgement is the latest known status or null if no status is known\n // status is an array: [ cashaddr, statusHash ]\n if (data instanceof Array) {\n if (data[0] !== cashaddr) {\n return;\n }\n callback(data[1]);\n }\n };\n return this.subscribeToAddress(cashaddr, watchAddressStatusCallback);\n }\n // watch for block headers and block height, if `skipCurrentHeight` is set, the notification about current block will not arrive\n async watchBlocks(callback, skipCurrentHeight = true) {\n let acknowledged = !skipCurrentHeight;\n const waitForBlockCallback = (_header) => {\n if (!acknowledged) {\n acknowledged = true;\n return;\n }\n _header = _header instanceof Array ? _header[0] : _header;\n callback(_header);\n };\n return this.subscribeToHeaders(waitForBlockCallback);\n }\n // Wait for the next block or a block at given blockchain height.\n async waitForBlock(height) {\n return new Promise(async (resolve) => {\n let cancelWatch;\n if (this.currentHeight && !height) {\n height = this.currentHeight + 1;\n }\n cancelWatch = await this.watchBlocks(async (header) => {\n if (!height) {\n height = header.height + 1;\n return;\n }\n if (header.height >= height) {\n await cancelWatch?.();\n resolve(header);\n return;\n }\n });\n });\n }\n // subscribe to notifications sent when new block is found, the block header is sent to callback\n async subscribeToHeaders(callback) {\n return this.subscribeRequest(\"blockchain.headers.subscribe\", [], (data) => {\n callback(data[0]);\n });\n }\n async subscribeToAddress(cashaddr, callback) {\n return this.subscribeRequest(\"blockchain.address.subscribe\", [cashaddr], callback);\n }\n async subscribeToTransaction(txHash, callback) {\n return this.subscribeRequest(\"blockchain.transaction.subscribe\", [txHash], callback);\n }\n async subscribeToDsproof(txHash, callback) {\n return this.subscribeRequest(\"blockchain.transaction.dsproof.subscribe\", [txHash], callback);\n }\n async daemonPassthrough(method, params = []) {\n await this.ready();\n return this.transport.request(\"daemon.passthrough\", {\n method,\n params,\n });\n }\n async performRequest(method, parameters) {\n await this.ready();\n const TIMEOUT_MSG = \"electrum-cash request timed out, retrying\";\n const makeTimeout = () => new Promise(function (_resolve, reject) {\n setTimeout(function () {\n reject(TIMEOUT_MSG);\n }, 30000);\n });\n const ensureError = (e) => {\n if (e instanceof Error)\n return e;\n if (typeof e === \"object\" && e !== null && \"message\" in e)\n return Object.assign(new Error(e.message), e);\n return new Error(typeof e === \"string\" ? e : String(e));\n };\n const request = this.transport.request(method, parameters);\n try {\n const value = await Promise.race([request, makeTimeout()]);\n if (value instanceof Error)\n throw value;\n return value;\n }\n catch (e) {\n const error = ensureError(e);\n // Only retry on timeout, not on server errors\n if (error.message !== TIMEOUT_MSG)\n throw error;\n try {\n const value = await Promise.race([request, makeTimeout()]);\n if (value instanceof Error)\n throw value;\n return value;\n }\n catch (e2) {\n throw ensureError(e2);\n }\n }\n }\n async subscribeRequest(method, parameters, callback) {\n await this.ready();\n const unsubscribe = await this.transport.subscribe(method, parameters, callback);\n this.subscriptions++;\n return async () => {\n await unsubscribe();\n this.subscriptions--;\n };\n }\n async ready() {\n return this.connect();\n }\n async connect() {\n await this.cache?.init();\n await this.transport.connect();\n }\n async disconnect() {\n await this.headerCancelFn?.();\n await this.transport.close();\n return true;\n }\n}\n//# sourceMappingURL=ElectrumNetworkProvider.js.map\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../mainnet-js/dist/module/network/ElectrumNetworkProvider.js?");
|
|
535
|
+
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ ElectrumNetworkProvider)\n/* harmony export */ });\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../interface.js */ \"../mainnet-js/dist/module/interface.js\");\n/* harmony import */ var _util_transaction_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../util/transaction.js */ \"../mainnet-js/dist/module/util/transaction.js\");\n/* harmony import */ var _config_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../config.js */ \"../mainnet-js/dist/module/config.js\");\n/* harmony import */ var _util_header_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/header.js */ \"../mainnet-js/dist/module/util/header.js\");\n/* harmony import */ var _cache_IndexedDbCache_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../cache/IndexedDbCache.js */ \"../mainnet-js/dist/module/cache/IndexedDbCache.js\");\n/* harmony import */ var _cache_WebStorageCache_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../cache/WebStorageCache.js */ \"../mainnet-js/dist/module/cache/WebStorageCache.js\");\n/* harmony import */ var _cache_MemoryCache_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../cache/MemoryCache.js */ \"../mainnet-js/dist/module/cache/MemoryCache.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_util_header_js__WEBPACK_IMPORTED_MODULE_5__, _util_transaction_js__WEBPACK_IMPORTED_MODULE_6__]);\n([_util_header_js__WEBPACK_IMPORTED_MODULE_5__, _util_transaction_js__WEBPACK_IMPORTED_MODULE_6__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);\n\n\n\n\n\n\n\nclass ElectrumNetworkProvider {\n get cache() {\n if (!_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseMemoryCache &&\n !_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseLocalStorageCache &&\n !_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseIndexedDBCache) {\n this._cache = undefined;\n return this._cache;\n }\n if (_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseMemoryCache && !(this._cache instanceof _cache_MemoryCache_js__WEBPACK_IMPORTED_MODULE_1__.MemoryCache)) {\n this._cache = new _cache_MemoryCache_js__WEBPACK_IMPORTED_MODULE_1__.MemoryCache();\n return this._cache;\n }\n if (_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseLocalStorageCache &&\n !(this._cache instanceof _cache_WebStorageCache_js__WEBPACK_IMPORTED_MODULE_2__.WebStorageCache)) {\n this._cache = new _cache_WebStorageCache_js__WEBPACK_IMPORTED_MODULE_2__.WebStorageCache();\n return this._cache;\n }\n if (_config_js__WEBPACK_IMPORTED_MODULE_0__.Config.UseIndexedDBCache && !(this._cache instanceof _cache_IndexedDbCache_js__WEBPACK_IMPORTED_MODULE_3__.IndexedDbCache)) {\n this._cache = new _cache_IndexedDbCache_js__WEBPACK_IMPORTED_MODULE_3__.IndexedDbCache();\n return this._cache;\n }\n return this._cache;\n }\n constructor(transport, network = _interface_js__WEBPACK_IMPORTED_MODULE_4__.Network.MAINNET) {\n this.network = network;\n this.subscriptions = 0;\n this.currentHeight = 0;\n if (transport) {\n this.transport = transport;\n }\n else {\n throw new Error(`A transport is required.`);\n }\n }\n async getUtxos(cashaddr) {\n const result = await this.performRequest(\"blockchain.address.listunspent\", [\n cashaddr,\n \"include_tokens\",\n ]);\n return result.map((utxo) => ({\n address: cashaddr,\n txid: utxo.tx_hash,\n vout: utxo.tx_pos,\n satoshis: BigInt(utxo.value),\n height: utxo.height,\n token: utxo.token_data\n ? {\n ...utxo.token_data,\n amount: BigInt(utxo.token_data.amount),\n }\n : undefined,\n }));\n }\n async getBalance(cashaddr) {\n const result = await this.performRequest(\"blockchain.address.get_balance\", [\n cashaddr,\n ]);\n return BigInt(result.confirmed) + BigInt(result.unconfirmed);\n }\n async getHeader(height, verbose = false) {\n const key = `header-${this.network}-${height}-${verbose}`;\n if (this.cache) {\n const cached = await this.cache.getItem(key);\n if (cached) {\n return verbose ? (0,_util_header_js__WEBPACK_IMPORTED_MODULE_5__.decodeHeader)(JSON.parse(cached)) : JSON.parse(cached);\n }\n }\n const result = await this.performRequest(\"blockchain.header.get\", [height]);\n if (this.cache) {\n await this.cache.setItem(key, JSON.stringify(result));\n }\n return verbose ? (0,_util_header_js__WEBPACK_IMPORTED_MODULE_5__.decodeHeader)(result) : result;\n }\n async getRawTransactions(hashes) {\n if (hashes.length === 0)\n return new Map();\n const results = new Map();\n const keys = hashes.map((hash) => `txraw-${this.network}-${hash}`);\n // batch cache read\n let cached;\n if (this.cache) {\n cached = await this.cache.getItems(keys);\n }\n const misses = [];\n for (let i = 0; i < hashes.length; i++) {\n const val = cached?.get(keys[i]);\n if (val) {\n results.set(hashes[i], val);\n }\n else {\n misses.push(hashes[i]);\n }\n }\n if (misses.length > 0) {\n // rpckit automatically batches concurrent requests via BatchScheduler\n const fetched = await Promise.all(misses.map(async (hash) => {\n const tx = await this.performRequest(\"blockchain.transaction.get\", [\n hash,\n false,\n ]);\n return [hash, tx];\n }));\n // batch cache write\n if (this.cache) {\n const entries = fetched.map(([hash, tx]) => [\n `txraw-${this.network}-${hash}`,\n tx,\n ]);\n await this.cache.setItems(entries);\n }\n for (const [hash, tx] of fetched) {\n results.set(hash, tx);\n }\n }\n return results;\n }\n async getHeaders(heights) {\n if (heights.length === 0)\n return new Map();\n const results = new Map();\n const keys = heights.map((height) => `header-${this.network}-${height}-true`);\n // batch cache read\n let cached;\n if (this.cache) {\n cached = await this.cache.getItems(keys);\n }\n const misses = [];\n for (let i = 0; i < heights.length; i++) {\n const val = cached?.get(keys[i]);\n if (val) {\n results.set(heights[i], (0,_util_header_js__WEBPACK_IMPORTED_MODULE_5__.decodeHeader)(JSON.parse(val)));\n }\n else {\n misses.push(heights[i]);\n }\n }\n if (misses.length > 0) {\n // rpckit automatically batches concurrent requests via BatchScheduler\n const fetched = await Promise.all(misses.map(async (height) => {\n const result = await this.performRequest(\"blockchain.header.get\", [\n height,\n ]);\n return [height, result];\n }));\n // batch cache write\n if (this.cache) {\n const entries = fetched.map(([height, result]) => [\n `header-${this.network}-${height}-true`,\n JSON.stringify(result),\n ]);\n await this.cache.setItems(entries);\n }\n for (const [height, result] of fetched) {\n results.set(height, (0,_util_header_js__WEBPACK_IMPORTED_MODULE_5__.decodeHeader)(result));\n }\n }\n return results;\n }\n async getBlockHeight() {\n if (!this.headerCancelFn) {\n this.headerCancelFn = await this.subscribeToHeaders((header) => {\n if (header.height > this.currentHeight) {\n this.currentHeight = header.height;\n }\n });\n }\n if (!this.currentHeight) {\n throw new Error(\"Check failed for eventual inconsistency in subscription implementations.\");\n }\n return this.currentHeight;\n }\n async getRawTransaction(txHash, verbose = false, loadInputValues = false) {\n const nonVerboseKey = `txraw-${this.network}-${txHash}`;\n const verboseKey = `tx-${this.network}-${txHash}`;\n const key = verbose ? verboseKey : nonVerboseKey;\n if (this.cache) {\n const cached = await this.cache.getItem(key);\n if (cached) {\n if (!verbose) {\n return cached;\n }\n const cachedTx = JSON.parse(cached);\n if (cachedTx.confirmations > 0) {\n const currentHeight = await this.getBlockHeight();\n cachedTx.confirmations += currentHeight - cachedTx.fetchHeight;\n }\n const { fetchHeight: _, ...transaction } = cachedTx;\n if (loadInputValues) {\n return this.enrichWithInputValues(transaction);\n }\n return transaction;\n }\n }\n try {\n const result = await this.performRequest(\"blockchain.transaction.get\", [\n txHash,\n verbose,\n ]);\n if (!verbose) {\n const hex = result;\n if (this.cache) {\n await this.cache.setItem(key, hex);\n }\n return hex;\n }\n const cachedTx = result;\n cachedTx.confirmations ??= 0;\n cachedTx.fetchHeight = await this.getBlockHeight();\n if (this.cache) {\n await this.cache.setItem(key, JSON.stringify(cachedTx));\n }\n const { fetchHeight: _, ...transaction } = cachedTx;\n if (loadInputValues) {\n return this.enrichWithInputValues(transaction);\n }\n return transaction;\n }\n catch (error) {\n if (error.message.indexOf(\"No such mempool or blockchain transaction\") > -1)\n throw Error(`Could not decode transaction ${txHash}. It might not exist on the current blockchain (${this.network}).`);\n else\n throw error;\n }\n }\n async enrichWithInputValues(transaction) {\n const hashes = [...new Set(transaction.vin.map((val) => val.txid))];\n const transactions = await Promise.all(hashes.map((hash) => this.getRawTransactionObject(hash, false)));\n const transactionMap = new Map();\n transactions.forEach((val) => transactionMap.set(val.hash, val));\n const enrichedVin = transaction.vin.map((input) => {\n const output = transactionMap\n .get(input.txid)\n .vout.find((val) => val.n === input.vout);\n return { ...input, ...output };\n });\n return { ...transaction, vin: enrichedVin };\n }\n async getRawTransactionObject(txHash, loadInputValues = false) {\n if (loadInputValues) {\n return this.getRawTransaction(txHash, true, true);\n }\n return this.getRawTransaction(txHash, true);\n }\n async sendRawTransaction(txHex, awaitPropagation = true) {\n return new Promise(async (resolve, reject) => {\n let txHash = await (0,_util_transaction_js__WEBPACK_IMPORTED_MODULE_6__.getTransactionHash)(txHex);\n if (!awaitPropagation) {\n this.performRequest(\"blockchain.transaction.broadcast\", [txHex]).catch(() => { });\n resolve(txHash);\n }\n else {\n let cancel;\n const waitForTransactionCallback = async (data) => {\n if (data && data[0] === txHash && data[1] !== null) {\n await cancel?.();\n resolve(txHash);\n }\n };\n cancel = await this.subscribeToTransaction(txHash, waitForTransactionCallback);\n this.performRequest(\"blockchain.transaction.broadcast\", [txHex]).catch(async (error) => {\n await cancel?.();\n reject(error);\n });\n }\n });\n }\n // Get transaction history of a given cashaddr\n async getHistory(cashaddr, fromHeight = 0, toHeight = -1) {\n return this.performRequest(\"blockchain.address.get_history\", [\n cashaddr,\n fromHeight,\n toHeight,\n ]);\n }\n // Get the minimum fee a low-priority transaction must pay in order to be accepted to the daemon's memory pool.\n async getRelayFee() {\n return this.performRequest(\"blockchain.relayfee\");\n }\n async watchAddressStatus(cashaddr, callback) {\n const watchAddressStatusCallback = async (data) => {\n // subscription acknowledgement is the latest known status or null if no status is known\n // status is an array: [ cashaddr, statusHash ]\n if (data instanceof Array) {\n if (data[0] !== cashaddr) {\n return;\n }\n callback(data[1]);\n }\n };\n return this.subscribeToAddress(cashaddr, watchAddressStatusCallback);\n }\n // watch for block headers and block height, if `skipCurrentHeight` is set, the notification about current block will not arrive\n async watchBlocks(callback, skipCurrentHeight = true) {\n let acknowledged = !skipCurrentHeight;\n const waitForBlockCallback = (_header) => {\n if (!acknowledged) {\n acknowledged = true;\n return;\n }\n _header = _header instanceof Array ? _header[0] : _header;\n callback(_header);\n };\n return this.subscribeToHeaders(waitForBlockCallback);\n }\n // Wait for the next block or a block at given blockchain height.\n async waitForBlock(height) {\n return new Promise(async (resolve) => {\n let cancelWatch;\n if (this.currentHeight && !height) {\n height = this.currentHeight + 1;\n }\n cancelWatch = await this.watchBlocks(async (header) => {\n if (!height) {\n height = header.height + 1;\n return;\n }\n if (header.height >= height) {\n await cancelWatch?.();\n resolve(header);\n return;\n }\n });\n });\n }\n // subscribe to notifications sent when new block is found, the block header is sent to callback\n async subscribeToHeaders(callback) {\n return this.subscribeRequest(\"blockchain.headers.subscribe\", [], (data) => {\n callback(data[0]);\n });\n }\n async subscribeToAddress(cashaddr, callback) {\n return this.subscribeRequest(\"blockchain.address.subscribe\", [cashaddr], callback);\n }\n async subscribeToTransaction(txHash, callback) {\n return this.subscribeRequest(\"blockchain.transaction.subscribe\", [txHash], callback);\n }\n async subscribeToDsproof(txHash, callback) {\n return this.subscribeRequest(\"blockchain.transaction.dsproof.subscribe\", [txHash], callback);\n }\n async daemonPassthrough(method, params = []) {\n await this.ready();\n return this.transport.request(\"daemon.passthrough\", {\n method,\n params,\n });\n }\n async mine(cashaddr, blocks) {\n return this.daemonPassthrough(\"generatetoaddress\", [blocks, cashaddr]);\n }\n async performRequest(method, parameters) {\n await this.ready();\n const TIMEOUT_MSG = \"electrum-cash request timed out, retrying\";\n const makeTimeout = () => new Promise(function (_resolve, reject) {\n setTimeout(function () {\n reject(TIMEOUT_MSG);\n }, 30000);\n });\n const ensureError = (e) => {\n if (e instanceof Error)\n return e;\n if (typeof e === \"object\" && e !== null && \"message\" in e)\n return Object.assign(new Error(e.message), e);\n return new Error(typeof e === \"string\" ? e : String(e));\n };\n const request = this.transport.request(method, parameters);\n try {\n const value = await Promise.race([request, makeTimeout()]);\n if (value instanceof Error)\n throw value;\n return value;\n }\n catch (e) {\n const error = ensureError(e);\n // Only retry on timeout, not on server errors\n if (error.message !== TIMEOUT_MSG)\n throw error;\n try {\n const value = await Promise.race([request, makeTimeout()]);\n if (value instanceof Error)\n throw value;\n return value;\n }\n catch (e2) {\n throw ensureError(e2);\n }\n }\n }\n async subscribeRequest(method, parameters, callback) {\n await this.ready();\n const unsubscribe = await this.transport.subscribe(method, parameters, callback);\n this.subscriptions++;\n return async () => {\n await unsubscribe();\n this.subscriptions--;\n };\n }\n async ready() {\n return this.connect();\n }\n async connect() {\n await this.cache?.init();\n await this.transport.connect();\n }\n async disconnect() {\n await this.headerCancelFn?.();\n await this.transport.close();\n return true;\n }\n}\n//# sourceMappingURL=ElectrumNetworkProvider.js.map\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../mainnet-js/dist/module/network/ElectrumNetworkProvider.js?");
|
|
536
536
|
|
|
537
537
|
/***/ }),
|
|
538
538
|
|
|
@@ -565,7 +565,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
565
565
|
/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
566
566
|
|
|
567
567
|
"use strict";
|
|
568
|
-
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"createProvider\": () => (/* binding */ createProvider),\n/* harmony export */ \"getGlobalProvider\": () => (/* binding */ getGlobalProvider),\n/* harmony export */ \"removeGlobalProvider\": () => (/* binding */ removeGlobalProvider),\n/* harmony export */ \"setGlobalProvider\": () => (/* binding */ setGlobalProvider)\n/* harmony export */ });\n/* unused harmony export getNetworkProvider */\n/* harmony import */ var _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ElectrumNetworkProvider.js */ \"../mainnet-js/dist/module/network/ElectrumNetworkProvider.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./configuration.js */ \"../mainnet-js/dist/module/network/configuration.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../interface.js */ \"../mainnet-js/dist/module/interface.js\");\n/* harmony import */ var _constant_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constant.js */ \"../mainnet-js/dist/module/network/constant.js\");\n/* harmony import */ var _rpckit_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @rpckit/core */ \"../../node_modules/@rpckit/core/dist/parse.js\");\n/* harmony import */ var _rpckit_websocket_electrum_cash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @rpckit/websocket/electrum-cash */ \"../../node_modules/@rpckit/websocket/dist/electrum-cash/webSocket.js\");\n/* harmony import */ var _rpckit_fallback_electrum_cash__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @rpckit/fallback/electrum-cash */ \"../../node_modules/@rpckit/fallback/dist/electrum-cash/fallback.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_configuration_js__WEBPACK_IMPORTED_MODULE_5__, _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_6__]);\n([_configuration_js__WEBPACK_IMPORTED_MODULE_5__, _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_6__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);\n\n\n\n\n\n\n\nconst parseSync = (0,_rpckit_core__WEBPACK_IMPORTED_MODULE_0__.createParseSync)({ webSocket: _rpckit_websocket_electrum_cash__WEBPACK_IMPORTED_MODULE_1__.webSocket, fallback: _rpckit_fallback_electrum_cash__WEBPACK_IMPORTED_MODULE_2__.fallback });\nfunction setGlobalProvider(network, provider) {\n const accessor = _constant_js__WEBPACK_IMPORTED_MODULE_3__.networkTickerMap[network];\n globalThis[accessor] = provider;\n return provider;\n}\nfunction getGlobalProvider(network) {\n const accessor = _constant_js__WEBPACK_IMPORTED_MODULE_3__.networkTickerMap[network];\n return globalThis[accessor];\n}\nfunction removeGlobalProvider(network) {\n const accessor = _constant_js__WEBPACK_IMPORTED_MODULE_3__.networkTickerMap[network];\n if (accessor in globalThis) {\n delete globalThis[accessor];\n }\n}\nasync function createProvider(network = _interface_js__WEBPACK_IMPORTED_MODULE_4__.Network.MAINNET, servers) {\n const serverStr = servers ?? (0,_configuration_js__WEBPACK_IMPORTED_MODULE_5__.getDefaultServers)(network);\n const transport = parseSync(serverStr);\n return new _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"](transport, network);\n}\nfunction getNetworkProvider(network = _interface_js__WEBPACK_IMPORTED_MODULE_4__.Network.MAINNET) {\n const globalProvider = getGlobalProvider(network);\n if (globalProvider) {\n return globalProvider;\n }\n const serverStr = (0,_configuration_js__WEBPACK_IMPORTED_MODULE_5__.getDefaultServers)(network);\n const transport = parseSync(serverStr);\n const provider = new _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"](transport, network);\n setGlobalProvider(network, provider);\n return provider;\n}\n//# sourceMappingURL=default.js.map\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../mainnet-js/dist/module/network/default.js?");
|
|
568
|
+
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"createMockProvider\": () => (/* binding */ createMockProvider),\n/* harmony export */ \"createProvider\": () => (/* binding */ createProvider),\n/* harmony export */ \"getGlobalProvider\": () => (/* binding */ getGlobalProvider),\n/* harmony export */ \"removeGlobalProvider\": () => (/* binding */ removeGlobalProvider),\n/* harmony export */ \"setGlobalProvider\": () => (/* binding */ setGlobalProvider)\n/* harmony export */ });\n/* unused harmony export getNetworkProvider */\n/* harmony import */ var _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ElectrumNetworkProvider.js */ \"../mainnet-js/dist/module/network/ElectrumNetworkProvider.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./configuration.js */ \"../mainnet-js/dist/module/network/configuration.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../interface.js */ \"../mainnet-js/dist/module/interface.js\");\n/* harmony import */ var _constant_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constant.js */ \"../mainnet-js/dist/module/network/constant.js\");\n/* harmony import */ var _rpckit_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @rpckit/core */ \"../../node_modules/@rpckit/core/dist/parse.js\");\n/* harmony import */ var _rpckit_websocket_electrum_cash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @rpckit/websocket/electrum-cash */ \"../../node_modules/@rpckit/websocket/dist/electrum-cash/webSocket.js\");\n/* harmony import */ var _rpckit_fallback_electrum_cash__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @rpckit/fallback/electrum-cash */ \"../../node_modules/@rpckit/fallback/dist/electrum-cash/fallback.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_configuration_js__WEBPACK_IMPORTED_MODULE_5__, _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_6__]);\n([_configuration_js__WEBPACK_IMPORTED_MODULE_5__, _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_6__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);\n\n\n\n\n\n\n\nconst parseSync = (0,_rpckit_core__WEBPACK_IMPORTED_MODULE_0__.createParseSync)({ webSocket: _rpckit_websocket_electrum_cash__WEBPACK_IMPORTED_MODULE_1__.webSocket, fallback: _rpckit_fallback_electrum_cash__WEBPACK_IMPORTED_MODULE_2__.fallback });\nfunction setGlobalProvider(network, provider) {\n const accessor = _constant_js__WEBPACK_IMPORTED_MODULE_3__.networkTickerMap[network];\n globalThis[accessor] = provider;\n return provider;\n}\nfunction getGlobalProvider(network) {\n const accessor = _constant_js__WEBPACK_IMPORTED_MODULE_3__.networkTickerMap[network];\n return globalThis[accessor];\n}\nfunction removeGlobalProvider(network) {\n const accessor = _constant_js__WEBPACK_IMPORTED_MODULE_3__.networkTickerMap[network];\n if (accessor in globalThis) {\n delete globalThis[accessor];\n }\n}\nasync function createProvider(network = _interface_js__WEBPACK_IMPORTED_MODULE_4__.Network.MAINNET, servers) {\n const serverStr = servers ?? (0,_configuration_js__WEBPACK_IMPORTED_MODULE_5__.getDefaultServers)(network);\n const transport = parseSync(serverStr);\n return new _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"](transport, network);\n}\n/**\n * Create a MockNetworkProvider via dynamic import.\n * Keeps @mem-cash/electrum out of the production bundle.\n */\nasync function createMockProvider() {\n const { MockNetworkProvider } = await Promise.all(/*! import() */[__webpack_require__.e(\"vendors-node_modules_bitauth_libauth_build_lib_address_locking-bytecode_js\"), __webpack_require__.e(\"vendors-node_modules_mem-cash_electrum_dist_indexer_js-node_modules_mem-cash_electrum_dist_tr-73b153\"), __webpack_require__.e(\"mainnet-js_dist_module_network_MockNetworkProvider_js\")]).then(__webpack_require__.bind(__webpack_require__, /*! ./MockNetworkProvider.js */ \"../mainnet-js/dist/module/network/MockNetworkProvider.js\"));\n let verifier;\n try {\n const { createTxVerifier } = await __webpack_require__.e(/*! import() */ \"vendors-node_modules_mem-cash_validation_dist_index_js\").then(__webpack_require__.bind(__webpack_require__, /*! @mem-cash/validation */ \"../../node_modules/@mem-cash/validation/dist/index.js\"));\n verifier = await createTxVerifier();\n }\n catch { }\n return new MockNetworkProvider({ indexerConfig: { verifier } });\n}\nfunction getNetworkProvider(network = _interface_js__WEBPACK_IMPORTED_MODULE_4__.Network.MAINNET) {\n const globalProvider = getGlobalProvider(network);\n if (globalProvider) {\n return globalProvider;\n }\n const serverStr = (0,_configuration_js__WEBPACK_IMPORTED_MODULE_5__.getDefaultServers)(network);\n const transport = parseSync(serverStr);\n const provider = new _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"](transport, network);\n setGlobalProvider(network, provider);\n return provider;\n}\n//# sourceMappingURL=default.js.map\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://@mainnet-cash/bcmr/../mainnet-js/dist/module/network/default.js?");
|
|
569
569
|
|
|
570
570
|
/***/ }),
|
|
571
571
|
|
|
@@ -661,6 +661,9 @@ eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_de
|
|
|
661
661
|
/******/ return module.exports;
|
|
662
662
|
/******/ }
|
|
663
663
|
/******/
|
|
664
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
665
|
+
/******/ __webpack_require__.m = __webpack_modules__;
|
|
666
|
+
/******/
|
|
664
667
|
/************************************************************************/
|
|
665
668
|
/******/ /* webpack/runtime/async module */
|
|
666
669
|
/******/ (() => {
|
|
@@ -743,11 +746,93 @@ eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_de
|
|
|
743
746
|
/******/ };
|
|
744
747
|
/******/ })();
|
|
745
748
|
/******/
|
|
749
|
+
/******/ /* webpack/runtime/ensure chunk */
|
|
750
|
+
/******/ (() => {
|
|
751
|
+
/******/ __webpack_require__.f = {};
|
|
752
|
+
/******/ // This file contains only the entry chunk.
|
|
753
|
+
/******/ // The chunk loading function for additional chunks
|
|
754
|
+
/******/ __webpack_require__.e = (chunkId) => {
|
|
755
|
+
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
|
|
756
|
+
/******/ __webpack_require__.f[key](chunkId, promises);
|
|
757
|
+
/******/ return promises;
|
|
758
|
+
/******/ }, []));
|
|
759
|
+
/******/ };
|
|
760
|
+
/******/ })();
|
|
761
|
+
/******/
|
|
762
|
+
/******/ /* webpack/runtime/get javascript chunk filename */
|
|
763
|
+
/******/ (() => {
|
|
764
|
+
/******/ // This function allow to reference async chunks
|
|
765
|
+
/******/ __webpack_require__.u = (chunkId) => {
|
|
766
|
+
/******/ // return url for filenames based on template
|
|
767
|
+
/******/ return "" + chunkId + "-4.0.0-next.6.js";
|
|
768
|
+
/******/ };
|
|
769
|
+
/******/ })();
|
|
770
|
+
/******/
|
|
771
|
+
/******/ /* webpack/runtime/global */
|
|
772
|
+
/******/ (() => {
|
|
773
|
+
/******/ __webpack_require__.g = (function() {
|
|
774
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
775
|
+
/******/ try {
|
|
776
|
+
/******/ return this || new Function('return this')();
|
|
777
|
+
/******/ } catch (e) {
|
|
778
|
+
/******/ if (typeof window === 'object') return window;
|
|
779
|
+
/******/ }
|
|
780
|
+
/******/ })();
|
|
781
|
+
/******/ })();
|
|
782
|
+
/******/
|
|
746
783
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
747
784
|
/******/ (() => {
|
|
748
785
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
749
786
|
/******/ })();
|
|
750
787
|
/******/
|
|
788
|
+
/******/ /* webpack/runtime/load script */
|
|
789
|
+
/******/ (() => {
|
|
790
|
+
/******/ var inProgress = {};
|
|
791
|
+
/******/ var dataWebpackPrefix = "@mainnet-cash/bcmr:";
|
|
792
|
+
/******/ // loadScript function to load a script via script tag
|
|
793
|
+
/******/ __webpack_require__.l = (url, done, key, chunkId) => {
|
|
794
|
+
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
|
|
795
|
+
/******/ var script, needAttach;
|
|
796
|
+
/******/ if(key !== undefined) {
|
|
797
|
+
/******/ var scripts = document.getElementsByTagName("script");
|
|
798
|
+
/******/ for(var i = 0; i < scripts.length; i++) {
|
|
799
|
+
/******/ var s = scripts[i];
|
|
800
|
+
/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
|
|
801
|
+
/******/ }
|
|
802
|
+
/******/ }
|
|
803
|
+
/******/ if(!script) {
|
|
804
|
+
/******/ needAttach = true;
|
|
805
|
+
/******/ script = document.createElement('script');
|
|
806
|
+
/******/
|
|
807
|
+
/******/ script.charset = 'utf-8';
|
|
808
|
+
/******/ script.timeout = 120;
|
|
809
|
+
/******/ if (__webpack_require__.nc) {
|
|
810
|
+
/******/ script.setAttribute("nonce", __webpack_require__.nc);
|
|
811
|
+
/******/ }
|
|
812
|
+
/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
|
|
813
|
+
/******/ script.src = url;
|
|
814
|
+
/******/ if (script.src.indexOf(window.location.origin + '/') !== 0) {
|
|
815
|
+
/******/ script.crossOrigin = "anonymous";
|
|
816
|
+
/******/ }
|
|
817
|
+
/******/ }
|
|
818
|
+
/******/ inProgress[url] = [done];
|
|
819
|
+
/******/ var onScriptComplete = (prev, event) => {
|
|
820
|
+
/******/ // avoid mem leaks in IE.
|
|
821
|
+
/******/ script.onerror = script.onload = null;
|
|
822
|
+
/******/ clearTimeout(timeout);
|
|
823
|
+
/******/ var doneFns = inProgress[url];
|
|
824
|
+
/******/ delete inProgress[url];
|
|
825
|
+
/******/ script.parentNode && script.parentNode.removeChild(script);
|
|
826
|
+
/******/ doneFns && doneFns.forEach((fn) => (fn(event)));
|
|
827
|
+
/******/ if(prev) return prev(event);
|
|
828
|
+
/******/ };
|
|
829
|
+
/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
|
|
830
|
+
/******/ script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
831
|
+
/******/ script.onload = onScriptComplete.bind(null, script.onload);
|
|
832
|
+
/******/ needAttach && document.head.appendChild(script);
|
|
833
|
+
/******/ };
|
|
834
|
+
/******/ })();
|
|
835
|
+
/******/
|
|
751
836
|
/******/ /* webpack/runtime/make namespace object */
|
|
752
837
|
/******/ (() => {
|
|
753
838
|
/******/ // define __esModule on exports
|
|
@@ -759,6 +844,116 @@ eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_de
|
|
|
759
844
|
/******/ };
|
|
760
845
|
/******/ })();
|
|
761
846
|
/******/
|
|
847
|
+
/******/ /* webpack/runtime/publicPath */
|
|
848
|
+
/******/ (() => {
|
|
849
|
+
/******/ var scriptUrl;
|
|
850
|
+
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
|
851
|
+
/******/ var document = __webpack_require__.g.document;
|
|
852
|
+
/******/ if (!scriptUrl && document) {
|
|
853
|
+
/******/ if (document.currentScript)
|
|
854
|
+
/******/ scriptUrl = document.currentScript.src
|
|
855
|
+
/******/ if (!scriptUrl) {
|
|
856
|
+
/******/ var scripts = document.getElementsByTagName("script");
|
|
857
|
+
/******/ if(scripts.length) scriptUrl = scripts[scripts.length - 1].src
|
|
858
|
+
/******/ }
|
|
859
|
+
/******/ }
|
|
860
|
+
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
|
|
861
|
+
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
|
|
862
|
+
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
|
|
863
|
+
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
864
|
+
/******/ __webpack_require__.p = scriptUrl;
|
|
865
|
+
/******/ })();
|
|
866
|
+
/******/
|
|
867
|
+
/******/ /* webpack/runtime/jsonp chunk loading */
|
|
868
|
+
/******/ (() => {
|
|
869
|
+
/******/ // no baseURI
|
|
870
|
+
/******/
|
|
871
|
+
/******/ // object to store loaded and loading chunks
|
|
872
|
+
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
|
873
|
+
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
|
874
|
+
/******/ var installedChunks = {
|
|
875
|
+
/******/ "BCMR": 0
|
|
876
|
+
/******/ };
|
|
877
|
+
/******/
|
|
878
|
+
/******/ __webpack_require__.f.j = (chunkId, promises) => {
|
|
879
|
+
/******/ // JSONP chunk loading for javascript
|
|
880
|
+
/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
|
|
881
|
+
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
|
|
882
|
+
/******/
|
|
883
|
+
/******/ // a Promise means "currently loading".
|
|
884
|
+
/******/ if(installedChunkData) {
|
|
885
|
+
/******/ promises.push(installedChunkData[2]);
|
|
886
|
+
/******/ } else {
|
|
887
|
+
/******/ if(true) { // all chunks have JS
|
|
888
|
+
/******/ // setup Promise in chunk cache
|
|
889
|
+
/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
|
|
890
|
+
/******/ promises.push(installedChunkData[2] = promise);
|
|
891
|
+
/******/
|
|
892
|
+
/******/ // start chunk loading
|
|
893
|
+
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
|
|
894
|
+
/******/ // create error before stack unwound to get useful stacktrace later
|
|
895
|
+
/******/ var error = new Error();
|
|
896
|
+
/******/ var loadingEnded = (event) => {
|
|
897
|
+
/******/ if(__webpack_require__.o(installedChunks, chunkId)) {
|
|
898
|
+
/******/ installedChunkData = installedChunks[chunkId];
|
|
899
|
+
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
|
|
900
|
+
/******/ if(installedChunkData) {
|
|
901
|
+
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
902
|
+
/******/ var realSrc = event && event.target && event.target.src;
|
|
903
|
+
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
|
|
904
|
+
/******/ error.name = 'ChunkLoadError';
|
|
905
|
+
/******/ error.type = errorType;
|
|
906
|
+
/******/ error.request = realSrc;
|
|
907
|
+
/******/ installedChunkData[1](error);
|
|
908
|
+
/******/ }
|
|
909
|
+
/******/ }
|
|
910
|
+
/******/ };
|
|
911
|
+
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
|
|
912
|
+
/******/ } else installedChunks[chunkId] = 0;
|
|
913
|
+
/******/ }
|
|
914
|
+
/******/ }
|
|
915
|
+
/******/ };
|
|
916
|
+
/******/
|
|
917
|
+
/******/ // no prefetching
|
|
918
|
+
/******/
|
|
919
|
+
/******/ // no preloaded
|
|
920
|
+
/******/
|
|
921
|
+
/******/ // no HMR
|
|
922
|
+
/******/
|
|
923
|
+
/******/ // no HMR manifest
|
|
924
|
+
/******/
|
|
925
|
+
/******/ // no on chunks loaded
|
|
926
|
+
/******/
|
|
927
|
+
/******/ // install a JSONP callback for chunk loading
|
|
928
|
+
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
|
|
929
|
+
/******/ var [chunkIds, moreModules, runtime] = data;
|
|
930
|
+
/******/ // add "moreModules" to the modules object,
|
|
931
|
+
/******/ // then flag all "chunkIds" as loaded and fire callback
|
|
932
|
+
/******/ var moduleId, chunkId, i = 0;
|
|
933
|
+
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
|
|
934
|
+
/******/ for(moduleId in moreModules) {
|
|
935
|
+
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
|
|
936
|
+
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
|
|
937
|
+
/******/ }
|
|
938
|
+
/******/ }
|
|
939
|
+
/******/ if(runtime) var result = runtime(__webpack_require__);
|
|
940
|
+
/******/ }
|
|
941
|
+
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
|
|
942
|
+
/******/ for(;i < chunkIds.length; i++) {
|
|
943
|
+
/******/ chunkId = chunkIds[i];
|
|
944
|
+
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
|
|
945
|
+
/******/ installedChunks[chunkId][0]();
|
|
946
|
+
/******/ }
|
|
947
|
+
/******/ installedChunks[chunkId] = 0;
|
|
948
|
+
/******/ }
|
|
949
|
+
/******/
|
|
950
|
+
/******/ }
|
|
951
|
+
/******/
|
|
952
|
+
/******/ var chunkLoadingGlobal = self["webpackChunk_mainnet_cash_bcmr"] = self["webpackChunk_mainnet_cash_bcmr"] || [];
|
|
953
|
+
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
|
954
|
+
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
|
955
|
+
/******/ })();
|
|
956
|
+
/******/
|
|
762
957
|
/************************************************************************/
|
|
763
958
|
/******/
|
|
764
959
|
/******/ // startup
|