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;AAKO,MAAM,4CAAW,CAAA,GAAA,wCAAa,EAAE,WAAW;AAElD,MAAM,gCAAU;kBACd;IACA,SAAS,CAAC,CAAC,EAAE,CAAA,GAAA,iCAAM,GAAG;YACtB;cACA;WACA;UACA;QACA;IACA,UAAU,CAAA,GAAA,wCAAa,EAAE,WAAW;YACpC;YACA;mBACA;kBACA;aACA;aACA;wBACA;WACA;iBACA;gBACA;AACF;IAEA,2CAAe","sources":["node_modules/lodash-es/isBuffer.js","node_modules/lodash-es/_root.js","node_modules/lodash-es/_freeGlobal.js","node_modules/lodash-es/stubFalse.js","node_modules/lodash-es/_nodeUtil.js","src/index.ts","package.json","src/crypto/hash.ts","src/utils/buffer.utils.ts","src/utils/validation.utils.ts","node_modules/lodash-es/isString.js","node_modules/lodash-es/_baseGetTag.js","node_modules/lodash-es/_Symbol.js","node_modules/lodash-es/_getRawTag.js","node_modules/lodash-es/_objectToString.js","node_modules/lodash-es/isArray.js","node_modules/lodash-es/isObjectLike.js","src/utils/common.utils.ts","src/crypto/bn.extension.ts","node_modules/lodash-es/isNumber.js","src/encoding/bufferreader.ts","node_modules/lodash-es/isUndefined.js","node_modules/lodash-es/isObject.js","src/encoding/bufferwriter.ts","src/utils/unit.utils.ts","node_modules/lodash-es/isNil.js","node_modules/lodash-es/isInteger.js","node_modules/lodash-es/toInteger.js","node_modules/lodash-es/toFinite.js","node_modules/lodash-es/toNumber.js","node_modules/lodash-es/_baseTrim.js","node_modules/lodash-es/_trimmedEndIndex.js","node_modules/lodash-es/isSymbol.js","src/core/network/network-manager.ts","src/core/network/network.ts","src/crypto/ecdsa.ts","src/crypto/digital-signature.ts","src/crypto/signature.ts","src/crypto/point.ts","src/keys/publickey.ts","src/crypto/schnorr.ts","src/keys/privatekey.ts","src/encoding/base58check.ts","src/encoding/base58.ts","src/core/address/address.ts","src/core/address/address-formatter.ts","src/encoding/base32.ts","src/core/script/script.ts","node_modules/lodash-es/inRange.js","node_modules/lodash-es/_baseInRange.js","src/core/script/opcode.ts","src/keys/hdprivatekey.ts","src/keys/hdkey.utils.ts","node_modules/lodash-es/isNull.js","src/keys/exceptions.ts","src/keys/hdpublickey.ts","src/core/script/script.factory.ts","node_modules/lodash-es/isEmpty.js","node_modules/lodash-es/_baseKeys.js","node_modules/lodash-es/_isPrototype.js","node_modules/lodash-es/_nativeKeys.js","node_modules/lodash-es/_overArg.js","node_modules/lodash-es/_getTag.js","node_modules/lodash-es/_DataView.js","node_modules/lodash-es/_getNative.js","node_modules/lodash-es/_baseIsNative.js","node_modules/lodash-es/isFunction.js","node_modules/lodash-es/_isMasked.js","node_modules/lodash-es/_coreJsData.js","node_modules/lodash-es/_toSource.js","node_modules/lodash-es/_getValue.js","node_modules/lodash-es/_Map.js","node_modules/lodash-es/_Promise.js","node_modules/lodash-es/_Set.js","node_modules/lodash-es/_WeakMap.js","node_modules/lodash-es/isArguments.js","node_modules/lodash-es/_baseIsArguments.js","node_modules/lodash-es/isArrayLike.js","node_modules/lodash-es/isLength.js","node_modules/lodash-es/isTypedArray.js","node_modules/lodash-es/_baseIsTypedArray.js","node_modules/lodash-es/_baseUnary.js","src/core/grouptoken.ts","src/core/message.ts","src/core/transaction/sighashtype.ts","src/core/transaction/transaction.ts","src/core/transaction/input/input.ts","src/core/transaction/output.ts","src/core/transaction/input/publickeyhash.ts","src/core/transaction/input/publickeytemplate.ts","src/core/transaction/input/scripttemplate.ts","src/core/transaction/unspentoutput.ts","src/core/transaction/txsignature.ts","src/core/transaction/txsigner.ts","src/core/transaction/txbuilder.ts","node_modules/lodash-es/isDate.js","node_modules/lodash-es/_baseIsDate.js","src/core/block/block.ts","src/core/block/blockheader.ts"],"sourcesContent":["import root from './_root.js';\nimport stubFalse from './stubFalse.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;\n\n/**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\nvar isBuffer = nativeIsBuffer || stubFalse;\n\nexport default isBuffer;\n","import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nexport default root;\n","/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nexport default freeGlobal;\n","/**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\nfunction stubFalse() {\n  return false;\n}\n\nexport default stubFalse;\n","import freeGlobal from './_freeGlobal.js';\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = (function() {\n  try {\n    // Use `util.types` for Node.js 10+.\n    var types = freeModule && freeModule.require && freeModule.require('util').types;\n\n    if (types) {\n      return types;\n    }\n\n    // Legacy `process.binding('util')` for Node.js < 10.\n    return freeProcess && freeProcess.binding && freeProcess.binding('util');\n  } catch (e) {}\n}());\n\nexport default nodeUtil;\n","import { version } from \"../package.json\";\nimport Hash from \"./crypto/hash\";\nimport BufferUtils from \"./utils/buffer.utils\";\nimport CommonUtils from \"./utils/common.utils\";\nimport BNExtended from \"./crypto/bn.extension\";\nimport BufferReader from \"./encoding/bufferreader\";\nimport BufferWriter from \"./encoding/bufferwriter\";\nimport UnitUtils from \"./utils/unit.utils\";\nimport NetworkManager from \"./core/network/network-manager\";\nimport ECDSA from \"./crypto/ecdsa\";\nimport Schnorr from \"./crypto/schnorr\";\nimport PrivateKey from \"./keys/privatekey\";\nimport PublicKey from \"./keys/publickey\";\nimport Signature from \"./crypto/signature\";\nimport ScriptOpcode, { Opcode } from \"./core/script/opcode\";\nimport HDPrivateKey from \"./keys/hdprivatekey\";\nimport HDPublicKey from \"./keys/hdpublickey\";\nimport Script from \"./core/script/script\";\nimport Address from \"./core/address/address\";\nimport ScriptFactory from \"./core/script/script.factory\";\nimport Message from \"./core/message\";\nimport SighashType from \"./core/transaction/sighashtype\";\nimport Transaction from \"./core/transaction/transaction\";\nimport Output from \"./core/transaction/output\";\nimport Input from \"./core/transaction/input/input\";\nimport PublicKeyHashInput from \"./core/transaction/input/publickeyhash\";\nimport PublicKeyTemplateInput from \"./core/transaction/input/publickeytemplate\";\nimport ScriptTemplateInput from \"./core/transaction/input/scripttemplate\";\nimport UnspentOutput from \"./core/transaction/unspentoutput\";\nimport TxSignature from \"./core/transaction/txsignature\";\nimport TxSigner from \"./core/transaction/txsigner\";\nimport TransactionBuilder from \"./core/transaction/txbuilder\";\nimport Block from \"./core/block/block\";\nimport BlockHeader from \"./core/block/blockheader\";\nimport GroupToken from \"./core/grouptoken\";\n\nfunction versionGuard(version: string): void {\n  if (version !== undefined) {\n    let message = 'More than one instance of libnexa found. ' +\n      'Please make sure to require libnexa and check that submodules do' +\n      ' not also include their own libnexa dependency.';\n    throw new Error(message);\n  }\n};\n\nversionGuard(global._libnexa_ver);\nglobal._libnexa_ver = `v${version}`;\n\nconst crypto = {\n  BN: BNExtended,\n  Hash,\n  ECDSA,\n  Schnorr,\n  Signature\n}\n\nconst encoding = {\n  BufferReader,\n  BufferWriter,\n}\n\nconst utils = {\n  BufferUtils,\n  CommonUtils,\n  UnitUtils,\n}\n\nconst keys = {\n  PrivateKey,\n  PublicKey,\n  HDPrivateKey,\n  HDPublicKey\n}\n\nconst tx = {\n  Transaction,\n  Input,\n  PublicKeyHashInput,\n  PublicKeyTemplateInput,\n  ScriptTemplateInput,\n  Output,\n  UnspentOutput,\n  TxSignature,\n  TxSigner,\n  SighashType,\n}\n\n/**\n * Singleton instance of {@link NetworkManager}\n */\nexport const Networks = NetworkManager.getInstance();\n\nconst libnexa = {\n  versionGuard,\n  version: `v${version}`,\n  crypto,\n  encoding,\n  utils,\n  keys,\n  tx,\n  Networks: NetworkManager.getInstance(),\n  Opcode,\n  Script,\n  ScriptFactory,\n  ScriptOpcode,\n  Address,\n  Message,\n  TransactionBuilder,\n  Block,\n  BlockHeader,\n  GroupToken,\n};\n\nexport default libnexa;\n\nexport type * from \"./common/types\";\nexport type * from \"./common/interfaces\";\nexport type * from \"./core/transaction/interfaces\";\nexport type { ITxSignature } from \"./core/transaction/txsignature\";\nexport type { ScriptElement } from \"./core/script/script\";\nexport type { PrivateKeyVariants } from \"./keys/privatekey\";\nexport type { PublicKeyVariants } from \"./keys/publickey\";\n\nexport { default as BNExtended } from \"./crypto/bn.extension\";\nexport { default as Point } from \"./crypto/point\";\nexport { default as Hash } from \"./crypto/hash\";\nexport { default as Signature } from \"./crypto/signature\";\nexport { default as DigitalSignature} from \"./crypto/digital-signature\"\nexport { default as ECDSA } from \"./crypto/ecdsa\";\nexport { default as Schnorr } from \"./crypto/schnorr\";\n\nexport { default as BufferReader } from \"./encoding/bufferreader\";\nexport { default as BufferWriter } from \"./encoding/bufferwriter\";\n\nexport { Network } from \"./core/network/network\";\nexport { default as NetworkManager } from \"./core/network/network-manager\";\n\nexport { UnitType, default as UnitUtils } from \"./utils/unit.utils\";\nexport { default as BufferUtils } from \"./utils/buffer.utils\";\nexport { default as CommonUtils } from \"./utils/common.utils\";\n\nexport { default as PrivateKey } from \"./keys/privatekey\";\nexport { default as PublicKey } from \"./keys/publickey\";\nexport { default as HDPrivateKey } from \"./keys/hdprivatekey\";\nexport { default as HDPublicKey } from \"./keys/hdpublickey\";\n\nexport { Opcode, default as ScriptOpcode } from \"./core/script/opcode\";\nexport { default as Script } from \"./core/script/script\";\nexport { default as ScriptFactory } from \"./core/script/script.factory\";\n\nexport { default as Address } from \"./core/address/address\";\nexport { AddressType } from \"./core/address/address-formatter\";\n\nexport { default as Block } from \"./core/block/block\";\nexport { default as BlockHeader } from \"./core/block/blockheader\";\n\nexport { default as SighashType, InputSighashType, OutputSighashType } from \"./core/transaction/sighashtype\";\nexport { default as Transaction } from \"./core/transaction/transaction\";\nexport { default as UnspentOutput } from \"./core/transaction/unspentoutput\";\nexport { default as Output, OutputType } from \"./core/transaction/output\";\nexport { default as Input, InputType } from \"./core/transaction/input/input\";\nexport { default as PublicKeyTemplateInput } from \"./core/transaction/input/publickeytemplate\";\nexport { default as ScriptTemplateInput } from \"./core/transaction/input/scripttemplate\";\nexport { default as PublicKeyHashInput } from \"./core/transaction/input/publickeyhash\";\nexport { default as TxSigner } from \"./core/transaction/txsigner\";\nexport { default as TxSignature } from \"./core/transaction/txsignature\";\nexport { default as TransactionBuilder } from \"./core/transaction/txbuilder\";\n\nexport { default as Message } from \"./core/message\";\nexport { default as GroupToken, GroupIdFlag, GroupIdType } from \"./core/grouptoken\";\n","{\n  \"name\": \"libnexa-ts\",\n  \"version\": \"1.0.5\",\n  \"description\": \"A pure and powerful Nexa SDK library.\",\n  \"type\": \"module\",\n  \"source\": \"src/index.ts\",\n  \"types\": \"dist/index.d.ts\",\n  \"main\": \"dist/index.cjs\",\n  \"module\": \"dist/index.mjs\",\n  \"browser\": \"dist/index.web.mjs\",\n  \"exports\": {\n    \"types\": \"./dist/index.d.ts\",\n    \"node\": {\n      \"import\": \"./dist/index.mjs\",\n      \"require\": \"./dist/index.cjs\"\n    },\n    \"browser\": \"./dist/index.web.mjs\",\n    \"default\": \"./dist/index.mjs\"\n  },\n  \"targets\": {\n    \"main\": {\n      \"context\": \"node\",\n      \"outputFormat\": \"commonjs\",\n      \"distDir\": \"dist\",\n      \"isLibrary\": true,\n      \"includeNodeModules\": [\n        \"lodash-es\"\n      ]\n    },\n    \"module\": {\n      \"context\": \"node\",\n      \"outputFormat\": \"esmodule\",\n      \"distDir\": \"dist\",\n      \"isLibrary\": true\n    },\n    \"browser\": {\n      \"context\": \"browser\",\n      \"outputFormat\": \"esmodule\",\n      \"distDir\": \"dist\",\n      \"isLibrary\": true\n    }\n  },\n  \"files\": [\n    \"dist\"\n  ],\n  \"scripts\": {\n    \"check\": \"tsc --noEmit && npm run madge\",\n    \"build\": \"del-cli ./dist && parcel build\",\n    \"lint\": \"eslint .\",\n    \"madge\": \"madge --circular src/index.ts\",\n    \"test\": \"vitest run --dir tests\",\n    \"coverage\": \"del-cli ./coverage && npm test -- --coverage --reporter=verbose --reporter=junit\",\n    \"docs\": \"typedoc\"\n  },\n  \"keywords\": [\n    \"nexa\",\n    \"blockchain\"\n  ],\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://gitlab.com/nexa/libnexa-ts\"\n  },\n  \"author\": \"vgrunner\",\n  \"license\": \"MIT\",\n  \"dependencies\": {\n    \"bn.js\": \"^5.2.1\",\n    \"bs58\": \"^6.0.0\",\n    \"elliptic\": \"^6.6.1\",\n    \"js-big-decimal\": \"^2.2.0\",\n    \"lodash-es\": \"^4.17.21\"\n  },\n  \"devDependencies\": {\n    \"@parcel/packager-ts\": \"^2.13.3\",\n    \"@parcel/transformer-typescript-types\": \"^2.13.3\",\n    \"@types/bn.js\": \"^5.1.6\",\n    \"@types/elliptic\": \"^6.4.18\",\n    \"@types/lodash-es\": \"^4.17.12\",\n    \"@types/node\": \"^22.13.4\",\n    \"@vitest/coverage-v8\": \"^3.0.6\",\n    \"del-cli\": \"^6.0.0\",\n    \"eslint\": \"^9.20.1\",\n    \"madge\": \"^8.0.0\",\n    \"parcel\": \"^2.13.3\",\n    \"typedoc\": \"^0.27.7\",\n    \"typedoc-plugin-markdown\": \"^4.4.2\",\n    \"typedoc-plugin-rename-defaults\": \"^0.7.2\",\n    \"typescript\": \"^5.7.3\",\n    \"typescript-eslint\": \"^8.24.1\",\n    \"vitest\": \"^3.0.6\"\n  },\n  \"@parcel/resolver-default\": {\n    \"packageExports\": true\n  },\n  \"madge\": {\n    \"detectiveOptions\": {\n      \"ts\": {\n        \"skipTypeImports\": true\n      }\n    }\n  }\n}\n","import crypto from \"crypto\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport ValidationUtils from \"../utils/validation.utils\";\n\nenum SHA_BLOCKSIZE {\n  SHA256 = 512,\n  SHA512 = 1024,\n}\n\nexport default class Hash {\n\n  public static sha1(buf: Buffer): Buffer {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), \"buf\", \"Must be Buffer\");\n    return crypto.createHash('sha1').update(buf).digest();\n  }\n\n  public static sha256(buf: Buffer): Buffer {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), \"buf\", \"Must be Buffer\");\n    return crypto.createHash('sha256').update(buf).digest();\n  }\n\n  public static sha512(buf: Buffer): Buffer {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), \"buf\", \"Must be Buffer\");\n    return crypto.createHash('sha512').update(buf).digest();\n  }\n\n  public static ripemd160(buf: Buffer): Buffer {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), \"buf\", \"Must be Buffer\");\n    return crypto.createHash('ripemd160').update(buf).digest();\n  }\n\n  public static sha256sha256(buf: Buffer): Buffer {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), \"buf\", \"Must be Buffer\");\n    return this.sha256(this.sha256(buf));\n  }\n  \n  public static sha256ripemd160(buf: Buffer): Buffer {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), \"buf\", \"Must be Buffer\");\n    return this.ripemd160(this.sha256(buf));\n  }\n\n  public static sha256hmac(data: Buffer, key: Buffer): Buffer {\n    return Hash.hmac(Hash.sha256, SHA_BLOCKSIZE.SHA256, data, key);\n  };\n  \n  public static sha512hmac(data: Buffer, key: Buffer): Buffer {\n    return Hash.hmac(Hash.sha512, SHA_BLOCKSIZE.SHA512, data, key);\n  };\n\n  private static hmac(hashf: (buf: Buffer) => Buffer, size: SHA_BLOCKSIZE, data: Buffer, key: Buffer): Buffer {\n    //http://en.wikipedia.org/wiki/Hash-based_message_authentication_code\n    //http://tools.ietf.org/html/rfc4868#section-2\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(data), \"data\", \"Must be Buffer\");\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(key), \"key\", \"Must be Buffer\");\n  \n    let blocksize = size / 8;\n  \n    if (key.length > blocksize) {\n      key = hashf(key);\n    } else if (key.length < blocksize) {\n      let fill = Buffer.alloc(blocksize);\n      fill.fill(0);\n      key.copy(fill);\n      key = fill;\n    }\n  \n    let o_key = Buffer.alloc(blocksize);\n    o_key.fill(0x5c);\n  \n    let i_key = Buffer.alloc(blocksize);\n    i_key.fill(0x36);\n  \n    let o_key_pad = Buffer.alloc(blocksize);\n    let i_key_pad = Buffer.alloc(blocksize);\n    for (let i = 0; i < blocksize; i++) {\n      o_key_pad[i] = o_key[i] ^ key[i];\n      i_key_pad[i] = i_key[i] ^ key[i];\n    }\n  \n    return hashf(Buffer.concat([o_key_pad, hashf(Buffer.concat([i_key_pad, data]))]));\n  }\n}","import crypto from \"crypto\";\nimport ValidationUtils from \"./validation.utils\";\n\nexport default class BufferUtils {\n\n  /**\n   * Fill a buffer with a value.\n   *\n   * @param buffer\n   * @param value\n   * @return filled buffer\n   * \n   * @deprecated use `buffer.fill(value)`\n   */\n  public static fill(buffer: Buffer, value: number): Buffer {\n    ValidationUtils.validateArgumentType(buffer, 'Buffer', 'buffer');\n    ValidationUtils.validateArgumentType(value, 'number', 'value');\n\n    return buffer.fill(value);\n  }\n\n  /**\n   *\n   * @param original buffer\n   * @return Return a copy of a buffer\n   * \n   * @deprecated use `Buffer.from(original) or Buffer.copyBytesFrom(original)`\n   */\n  public static copy(original: Buffer): Buffer {\n    let buffer = Buffer.alloc(original.length);\n    original.copy(buffer);\n    return buffer;\n  }\n\n  /**\n   * Tests for both node's Buffer and Uint8Array\n   *\n   * @param arg\n   * @return Returns true if the given argument is an instance of a buffer. \n   */\n  public static isBuffer(arg: unknown): arg is Buffer {\n    return Buffer.isBuffer(arg) || arg instanceof Uint8Array;\n  }\n\n  /**\n   * Tests for both node's Buffer and Uint8Array\n   *\n   * @param arg\n   * @return Returns true if the given argument is an instance of a hash160 or hash256 buffer. \n   */\n  public static isHashBuffer(arg: unknown): boolean {\n    return this.isBuffer(arg) && (arg.length === 20 || arg.length === 32);\n  }\n\n  /**\n   * Returns a zero-filled byte array\n   *\n   * @param length\n   * \n   * @deprecated use `Buffer.alloc(length)`\n   */\n  public static emptyBuffer(length: number): Buffer {\n    ValidationUtils.validateArgumentType(length, 'number', 'length');\n    return Buffer.alloc(length);\n  }\n\n  /**\n   * Reverse a buffer\n   * @param param\n   * @return new reversed buffer\n   */\n  public static reverse(param: Buffer): Buffer {\n    return (Buffer.from(param)).reverse();\n  }\n\n  /**\n   * Transforms a buffer into a string with a number in hexa representation\n   *\n   * Shorthand for <tt>buffer.toString('hex')</tt>\n   *\n   * @param buffer\n   * @return string\n   */\n  public static bufferToHex(buffer: Buffer): string {\n    ValidationUtils.validateArgumentType(buffer, 'Buffer', 'buffer');\n    return buffer.toString('hex');\n  }\n\n  /**\n   * Transforms a number from 0 to 255 into a Buffer of size 1 with that value\n   *\n   * @param integer\n   * @return Buffer\n   */\n  public static integerAsSingleByteBuffer(integer: number): Buffer {\n    ValidationUtils.validateArgumentType(integer, 'number', 'integer');\n    return Buffer.from([integer & 0xff]);\n  }\n\n  \n  /**\n   * Transforms the first byte of an array into a number ranging from -128 to 127\n   * \n   * @param buffer\n   * @return number\n   */\n  public static integerFromSingleByteBuffer(buffer: Buffer): number {\n    ValidationUtils.validateArgumentType(buffer, 'Buffer', 'buffer');\n    return buffer[0];\n  }\n\n  /**\n   * Transform a 4-byte integer into a Buffer of length 4.\n   *\n   * @param integer\n   * @return Buffer\n   */\n  public static integerAsBuffer(integer: number): Buffer {\n    ValidationUtils.validateArgumentType(integer, 'number', 'integer');\n    let bytes = [];\n    bytes.push((integer >> 24) & 0xff);\n    bytes.push((integer >> 16) & 0xff);\n    bytes.push((integer >> 8) & 0xff);\n    bytes.push(integer & 0xff);\n    return Buffer.from(bytes);\n  }\n\n  /**\n   * Transform the first 4 values of a Buffer into a number, in little endian encoding\n   *\n   * @param buffer\n   * @return integer\n   */\n  public static integerFromBuffer(buffer: Buffer): number {\n    ValidationUtils.validateArgumentType(buffer, 'Buffer', 'buffer');\n    return buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3];\n  }\n\n  /* secure random bytes that sometimes throws an error due to lack of entropy */\n  public static getRandomBuffer(size: number): Buffer {\n    return crypto.randomBytes(size);\n  }\n}","import { isString } from 'lodash-es';\n\ntype Class<T> = new (...args: any[]) => T; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport default class ValidationUtils {\n\n  public static validateState(condition: boolean, message: string): void {\n    if (!condition) {\n      throw new Error(`Invalid State: ${message}`);\n    }\n  }\n\n  public static validateArgument(condition: boolean, argumentName: string, message = \"\"): void {\n    if (!condition) {\n      throw new Error(`Invalid Argument: ${argumentName}. ${message}`);\n    }\n  }\n\n  public static validateArgumentType<T>(argument: unknown, type: string | Class<T>, argumentName?: string): void {\n    argumentName = argumentName || '(unknown name)';\n    if (isString(type)) {\n      if (type === 'Buffer') {\n        if (!Buffer.isBuffer(argument)) {        \n            throw new TypeError(`Invalid Argument for ${argumentName}, expected ${type} but got ${typeof argument}`);\n        }\n      } else if (typeof argument !== type) {\n        throw new TypeError(`Invalid Argument for ${argumentName}, expected ${type} but got ${typeof argument}`);\n      }\n    } else {\n      if (!(argument instanceof type)) {\n        throw new TypeError(`Invalid Argument for ${argumentName}, expected ${type} but got ${typeof argument}`);\n      }\n    }\n  }\n}\n","import baseGetTag from './_baseGetTag.js';\nimport isArray from './isArray.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar stringTag = '[object String]';\n\n/**\n * Checks if `value` is classified as a `String` primitive or object.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a string, else `false`.\n * @example\n *\n * _.isString('abc');\n * // => true\n *\n * _.isString(1);\n * // => false\n */\nfunction isString(value) {\n  return typeof value == 'string' ||\n    (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);\n}\n\nexport default isString;\n","import Symbol from './_Symbol.js';\nimport getRawTag from './_getRawTag.js';\nimport objectToString from './_objectToString.js';\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n    undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n  if (value == null) {\n    return value === undefined ? undefinedTag : nullTag;\n  }\n  return (symToStringTag && symToStringTag in Object(value))\n    ? getRawTag(value)\n    : objectToString(value);\n}\n\nexport default baseGetTag;\n","import root from './_root.js';\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nexport default Symbol;\n","import Symbol from './_Symbol.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n  var isOwn = hasOwnProperty.call(value, symToStringTag),\n      tag = value[symToStringTag];\n\n  try {\n    value[symToStringTag] = undefined;\n    var unmasked = true;\n  } catch (e) {}\n\n  var result = nativeObjectToString.call(value);\n  if (unmasked) {\n    if (isOwn) {\n      value[symToStringTag] = tag;\n    } else {\n      delete value[symToStringTag];\n    }\n  }\n  return result;\n}\n\nexport default getRawTag;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n  return nativeObjectToString.call(value);\n}\n\nexport default objectToString;\n","/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\nexport default isArray;\n","/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n  return value != null && typeof value == 'object';\n}\n\nexport default isObjectLike;\n","import { isString } from \"lodash-es\";\n\nexport default class CommonUtils {\n\n  /**\n   * Determines whether a string contains only hexadecimal values\n   * \n   * @param value\n   * @returns true if the string is the hexa representation of a number\n   */\n  public static isHexa(value: unknown): boolean {\n    return isString(value) && value.length % 2 === 0 && /^[0-9a-fA-F]+$/.test(value);\n  }\n\n  /**\n   * Test if an argument is a valid JSON object. If it is, returns a truthy\n   * value (the json object decoded), so no double JSON.parse call is necessary\n   *\n   * @param arg\n   * @return false if the argument is not a JSON string.\n   */\n  public static isValidJSON(arg: string): object | boolean {\n    if (!isString(arg)) {\n      return false;\n    }\n\n    try {\n      return JSON.parse(arg);\n    } catch {\n      return false;\n    }\n  }\n\n  public static cloneArray<T>(array: T[]): T[] {\n    return [...array];\n  }\n\n  /**\n   * Checks that a value is a natural number.\n   *\n   * @param value\n   * @return true if a positive integer or zero.\n   */\n  public static isNaturalNumber(value: number): boolean {\n    return typeof value === 'number' &&\n      isFinite(value) &&\n      Math.floor(value) === value &&\n      value >= 0;\n  }\n\n  /**\n   * Checks that a value is a natural number.\n   *\n   * @param value\n   * @return true if a positive integer or zero.\n   */\n  public static isNaturalBigInt(value: bigint): boolean {\n    return typeof value === 'bigint' && value >= 0n;\n  }\n}","import BN from \"bn.js\";\nimport ValidationUtils from \"../utils/validation.utils\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport { isNumber, isString } from \"lodash-es\";\nimport type { BNOptions } from \"../common/interfaces\";\n\nexport default class BNExtended extends BN {\n\n  public static Zero = new BNExtended(0);\n  public static One = new BNExtended(1);\n  public static Minus1 = new BNExtended(-1);\n\n  public static fromNumber(num: number): BNExtended {\n    ValidationUtils.validateArgument(isNumber(num), \"num\");\n    return new BNExtended(num);\n  }\n\n  public static fromBigInt(num: bigint): BNExtended {\n    ValidationUtils.validateArgument(typeof num === 'bigint', \"num\");\n    return new BNExtended(num.toString());\n  }\n  \n  public static fromString(str: string, base?: number | \"hex\"): BNExtended {\n    ValidationUtils.validateArgument(isString(str), \"str\");\n    return new BNExtended(str, base);\n  }\n  \n  public static fromBuffer(buf: Buffer, opts?: BNOptions): BNExtended {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), \"buf\");\n    if (opts?.endian === 'little') {\n      buf = BufferUtils.reverse(buf);\n    }\n    return new BNExtended(buf.toString('hex'), 16);\n  }\n\n  /**\n   * Create a BN from a \"ScriptNum\":\n   * This is analogous to the constructor for CScriptNum in nexad. Many ops in\n   * nexad's script interpreter use CScriptNum, which is not really a proper\n   * bignum. Instead, an error is thrown if trying to input a number bigger than\n   * 4 bytes. We copy that behavior here. A third argument, `size`, is provided to\n   * extend the hard limit of 4 bytes, as some usages require more than 4 bytes.\n   */\n  public static fromScriptNumBuffer(buf: Buffer, fRequireMinimal?: boolean, size?: number): BNExtended {\n    let nMaxNumSize = size || 4;\n    ValidationUtils.validateArgument(buf.length <= nMaxNumSize, 'script number overflow');\n    if (fRequireMinimal && buf.length > 0) {\n      // Check that the number is encoded with the minimum possible\n      // number of bytes.\n      //\n      // If the most-significant-byte - excluding the sign bit - is zero\n      // then we're not minimal. Note how this test also rejects the\n      // negative-zero encoding, 0x80.\n      if ((buf[buf.length - 1] & 0x7f) === 0) {\n        // One exception: if there's more than one byte and the most\n        // significant bit of the second-most-significant-byte is set\n        // it would conflict with the sign bit. An example of this case\n        // is +-255, which encode to 0xff00 and 0xff80 respectively.\n        // (big-endian).\n        if (buf.length <= 1 || (buf[buf.length - 2] & 0x80) === 0) {\n          throw new Error('non-minimally encoded script number');\n        }\n      }\n    }\n    return BNExtended.fromSM(buf, { endian: 'little' });\n  }\n\n  // Override arithmetic methods to ensure they return BNExtended instances\n  public override add(b: BN): BNExtended {\n    const result = super.add(b).toString();\n    return new BNExtended(result);\n  }\n\n  public override sub(b: BN): BNExtended {\n    const result = super.sub(b).toString();\n    return new BNExtended(result);\n  }\n\n  public override mul(b: BN): BNExtended {\n    const result = super.mul(b).toString();\n    return new BNExtended(result);\n  }\n\n  public override mod(b: BN): BNExtended {\n    const result = super.mod(b).toString();\n    return new BNExtended(result);\n  }\n\n  public override umod(b: BN): BNExtended {\n    const result = super.umod(b).toString();\n    return new BNExtended(result);\n  }\n\n  public override toNumber(): number {\n    return parseInt(this.toString(10), 10);\n  }\n  \n  public toBigInt(): bigint {\n    return BigInt(this.toString(10))\n  }\n  \n  public override toBuffer(opts?: BN.Endianness | BNOptions, length?: number): Buffer {\n    if (isString(opts)) {\n      // compatability with override\n      return super.toBuffer(opts, length);\n    }\n\n    let hex = this.toString(16, 2);\n    let buf: Buffer = Buffer.from(hex, 'hex');\n\n    if (opts?.size) {\n      let natlen = hex.length / 2;\n      if (natlen > opts.size) {\n        buf = BNExtended.trim(buf, natlen);\n      } else if (natlen < opts.size) {\n        buf = BNExtended.pad(buf, natlen, opts.size);\n      }\n    }\n  \n    if (opts?.endian === 'little') {\n      buf = BufferUtils.reverse(buf);\n    }\n  \n    return buf;\n  }\n\n  /**\n   * The corollary to the above, with the notable exception that we do not throw\n   * an error if the output is larger than four bytes. (Which can happen if\n   * performing a numerical operation that results in an overflow to more than 4\n   * bytes).\n   */\n  public toScriptNumBuffer(): Buffer {\n    return this.toSM({  endian: 'little' });\n  }\n\n  public toScriptBigNumBuffer(): Buffer {\n    return this.toSM({ endian: 'little', bignum: true });\n  }\n\n  public getSize(): number {\n    const bin = this.toString(2).replace('-', '');\n    const numBits = bin.length + 1;\n    return numBits / 8;\n  }\n  \n  public safeAdd(bigNumToAdd: BNExtended, maxSize: number): BNExtended {\n    const sum = this.add(bigNumToAdd);\n    this.checkOperationForOverflow(bigNumToAdd, sum, maxSize);\n    return sum;\n  }\n  \n  public safeSub(bigNumToSubtract: BNExtended, maxSize: number): BNExtended {\n    const difference = this.sub(bigNumToSubtract);\n    this.checkOperationForOverflow(bigNumToSubtract, difference, maxSize);\n    return difference;\n  }\n  \n  public safeMul(bigNumToMultiply: BNExtended, maxSize: number): BNExtended {\n    const product = this.mul(bigNumToMultiply);\n    this.checkOperationForOverflow(bigNumToMultiply, product, maxSize);\n    return product;\n  }\n\n  private checkOperationForOverflow(operand: BNExtended, result: BNExtended, maxSize: number): void {\n    if (this.getSize() > maxSize || operand.getSize() > maxSize || result.getSize() > 8) {\n      throw new Error('overflow');\n    }\n  }\n  \n  private toSMBigEndian(): Buffer {\n    let buf;\n    if (this.cmp(BNExtended.Zero) === -1) {\n      buf = this.neg().toBuffer();\n      if (buf[0] & 0x80) {\n        buf = Buffer.concat([Buffer.from([0x80]), buf]);\n      } else {\n        buf[0] = buf[0] | 0x80;\n      }\n    } else {\n      buf = this.toBuffer();\n      if (buf[0] & 0x80) {\n        buf = Buffer.concat([Buffer.from([0x00]), buf]);\n      }\n    }\n  \n    if (buf.length === 1 && buf[0] === 0) {\n      buf = Buffer.from([]);\n    }\n    return buf;\n  }\n  \n  private toBigNumSMBigEndian(): Buffer {\n    let buf;\n    if (this.cmp(BNExtended.Zero) === -1) {\n      buf = this.neg().toBuffer();\n      buf = Buffer.concat([Buffer.from([0x80]), buf]);\n    } else {\n      buf = this.toBuffer();\n      buf = Buffer.concat([Buffer.from([0x00]), buf]);\n    }\n\n    return buf;\n  }\n  \n  private toSM(opts: BNOptions): Buffer {\n    let buf = opts?.bignum ? this.toBigNumSMBigEndian() : this.toSMBigEndian();\n  \n    if (opts?.endian === 'little') {\n      buf = BufferUtils.reverse(buf);\n    }\n\n    return buf;\n  }\n\n  /**\n * Instantiate a BigNumber from a \"signed magnitude buffer\"\n * (a buffer where the most significant bit represents the sign (0 = positive, -1 = negative))\n */\n  private static fromSM(buf: Buffer, opts?: BNOptions): BNExtended {\n    if (buf.length === 0) {\n      return this.fromBuffer(Buffer.from([0]));\n    }\n\n    if (opts?.endian === 'little') {\n      buf = BufferUtils.reverse(buf);\n    }\n\n    let ret;\n    if (buf[0] & 0x80) {\n      buf[0] = buf[0] & 0x7f;\n      ret = this.fromBuffer(buf);\n      ret.neg().copy(ret);\n    } else {\n      ret = this.fromBuffer(buf);\n    }\n    return ret;\n  }\n\n  private static trim(buf: Buffer, natlen: number): Buffer {\n    return buf.subarray(natlen - buf.length, natlen);\n  }\n  \n  private static pad(buf: Buffer, natlen: number, size: number): Buffer {\n    let rbuf = Buffer.alloc(size);\n    for (let i = 0; i < buf.length; i++) {\n      rbuf[rbuf.length - 1 - i] = buf[buf.length - 1 - i];\n    }\n    for (let i = 0; i < size - natlen; i++) {\n      rbuf[i] = 0;\n    }\n    return rbuf;\n  }\n}","import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar numberTag = '[object Number]';\n\n/**\n * Checks if `value` is classified as a `Number` primitive or object.\n *\n * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are\n * classified as numbers, use the `_.isFinite` method.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a number, else `false`.\n * @example\n *\n * _.isNumber(3);\n * // => true\n *\n * _.isNumber(Number.MIN_VALUE);\n * // => true\n *\n * _.isNumber(Infinity);\n * // => true\n *\n * _.isNumber('3');\n * // => false\n */\nfunction isNumber(value) {\n  return typeof value == 'number' ||\n    (isObjectLike(value) && baseGetTag(value) == numberTag);\n}\n\nexport default isNumber;\n","import ValidationUtils from \"../utils/validation.utils\";\nimport BN from \"../crypto/bn.extension\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport type { BufferParams } from \"../common/interfaces\";\nimport { isObject, isString, isUndefined } from \"lodash-es\";\n\nexport default class BufferReader {\n\n  public buf: Buffer;\n  public pos: number;\n\n  constructor(buf?: Buffer | string | BufferParams) {\n    this.buf = Buffer.from([]);\n    this.pos = 0;\n\n    if (isUndefined(buf)) {\n      return;\n    }\n    \n    if (Buffer.isBuffer(buf)) {\n      this.set({ buf: buf });\n    } else if (isString(buf)) {\n      let b = Buffer.from(buf, 'hex');\n      if (b.length * 2 != buf.length)  {\n        throw new TypeError('Invalid hex string');\n      }\n      this.set({ buf: b });\n    } else if (isObject(buf)) {\n      let obj = buf;\n      this.set(obj);\n    } else {\n      throw new TypeError('Unrecognized argument for BufferReader');\n    }\n  }\n\n  public set(obj: BufferParams): this {\n    this.buf = obj.buf || this.buf;\n    this.pos = obj.pos || this.pos || 0;\n    return this;\n  }\n\n  public eof(): boolean {\n    return this.pos >= this.buf.length;\n  }\n  \n  public finished = this.eof;\n\n  public read(len: number): Buffer {\n    ValidationUtils.validateArgument(!isUndefined(len), 'Must specify a length');\n    let buf = this.buf!.subarray(this.pos, this.pos + len);\n    this.pos = this.pos + len;\n    return buf;\n  }\n  \n  public readAll(): Buffer {\n    let buf = this.buf.subarray(this.pos, this.buf.length);\n    this.pos = this.buf.length;\n    return buf;\n  }\n  \n  public readUInt8(): number {\n    let val = this.buf.readUInt8(this.pos);\n    this.pos = this.pos + 1;\n    return val;\n  }\n\n  public readUInt16BE(): number {\n    let val = this.buf.readUInt16BE(this.pos);\n    this.pos = this.pos + 2;\n    return val;\n  }\n  \n  public readUInt16LE(): number {\n    let val = this.buf.readUInt16LE(this.pos);\n    this.pos = this.pos + 2;\n    return val;\n  }\n  \n  public readUInt32BE(): number {\n    let val = this.buf.readUInt32BE(this.pos);\n    this.pos = this.pos + 4;\n    return val;\n  }\n  \n  public readUInt32LE(): number {\n    let val = this.buf.readUInt32LE(this.pos);\n    this.pos = this.pos + 4;\n    return val;\n  }\n  \n  public readInt32LE(): number {\n    let val = this.buf.readInt32LE(this.pos);\n    this.pos = this.pos + 4;\n    return val;\n  }\n\n  public readUInt64BEBN(): BN {\n    let buf = this.buf.subarray(this.pos, this.pos + 8);\n    let bn = BN.fromBuffer(buf);\n    this.pos = this.pos + 8;\n    return bn;\n  }\n  \n  public readUInt64LEBN(): BN {\n    let second = this.buf.readUInt32LE(this.pos);\n    let first = this.buf.readUInt32LE(this.pos + 4);\n    let combined = (first * 0x100000000) + second;\n    // Instantiating an instance of BN with a number is faster than with an\n    // array or string. However, the maximum safe number for a double precision\n    // floating point is 2 ^ 52 - 1 (0x1fffffffffffff), thus we can safely use\n    // non-floating point numbers less than this amount (52 bits). And in the case\n    // that the number is larger, we can instatiate an instance of BN by passing\n    // an array from the buffer (slower) and specifying the endianness.\n    let bn;\n    if (combined <= 0x1fffffffffffff) {\n      bn = new BN(combined);\n    } else {\n      let data = this.buf.subarray(this.pos, this.pos + 8);\n      bn = new BN(data, 10, 'le');\n    }\n    this.pos = this.pos + 8;\n    return bn;\n  }\n  \n  public readVarintNum(): number {\n    let first = this.readUInt8();\n    switch (first) {\n      case 0xFD:\n        return this.readUInt16LE();\n      case 0xFE:\n        return this.readUInt32LE();\n      case 0xFF:\n        let bn = this.readUInt64LEBN();\n        let n = bn.toNumber();\n        if (n <= Math.pow(2, 53)) {\n          return n;\n        } else {\n          throw new Error('number too large to retain precision - use readVarintBN');\n        }\n    }\n    return first;\n  }\n  \n  /**\n   * reads a length prepended buffer\n   */\n  public readVarLengthBuffer(): Buffer {\n    let len = this.readVarintNum();\n    let buf = this.read(len);\n    ValidationUtils.validateState(buf.length === len, 'Invalid length while reading varlength buffer. ' +\n      'Expected to read: ' + len + ' and read ' + buf.length);\n    return buf;\n  }\n  \n  public readVarintBuf(): Buffer {\n    let first = this.buf.readUInt8(this.pos);\n    switch (first) {\n      case 0xFD:\n        return this.read(1 + 2);\n      case 0xFE:\n        return this.read(1 + 4);\n      case 0xFF:\n        return this.read(1 + 8);\n      default:\n        return this.read(1);\n    }\n  }\n  \n  public readVarintBN(): BN {\n    let first = this.readUInt8();\n    switch (first) {\n      case 0xFD:\n        return new BN(this.readUInt16LE());\n      case 0xFE:\n        return new BN(this.readUInt32LE());\n      case 0xFF:\n        return this.readUInt64LEBN();\n      default:\n        return new BN(first);\n    }\n  }\n  \n  public reverse(): this {\n    let buf = BufferUtils.reverse(this.buf);\n    this.buf = buf;\n    return this;\n  }\n\n  public readReverse(len?: number): Buffer {\n    if (isUndefined(len)) {\n      len = this.buf.length;\n    }\n    let buf = this.buf.subarray(this.pos, this.pos + len);\n    this.pos = this.pos + len;\n    return BufferUtils.reverse(buf);\n  };\n  \n  public readCoreVarintNum(): number {\n    let n = 0;\n    while (true) {\n      let chData = this.readUInt8();\n      n = (n << 7) | (chData & 0x7F);\n      if (chData & 0x80) {\n        n++;\n      } else {\n        return n;\n      }\n    }\n  }\n}","/**\n * Checks if `value` is `undefined`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.\n * @example\n *\n * _.isUndefined(void 0);\n * // => true\n *\n * _.isUndefined(null);\n * // => false\n */\nfunction isUndefined(value) {\n  return value === undefined;\n}\n\nexport default isUndefined;\n","/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n  var type = typeof value;\n  return value != null && (type == 'object' || type == 'function');\n}\n\nexport default isObject;\n","import type { BufferWriterOptions } from \"../common/interfaces\";\nimport type BN from \"../crypto/bn.extension\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport ValidationUtils from \"../utils/validation.utils\";\n\nexport default class BufferWriter {\n\n  private bufs: Buffer[];\n  private bufLen: number;\n  \n  constructor(obj?: BufferWriterOptions) {\n    this.bufs = [];\n    this.bufLen = 0;\n    \n    if (obj) {\n      this.set(obj); \n    }\n  }\n\n  public set(obj: BufferWriterOptions): this {\n    this.bufs = obj.bufs || this.bufs;\n    this.bufLen = this.bufs.reduce((prev, buf) => prev + buf.length, 0);\n    return this;\n  }\n\n  public toBuffer(): Buffer {\n    return this.concat();\n  }\n  \n  public concat(): Buffer {\n    return Buffer.concat(this.bufs, this.bufLen);\n  }\n\n  public write(buf: Buffer): this {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), \"buf\");\n    this.bufs.push(buf);\n    this.bufLen += buf.length;\n    return this;\n  }\n\n  public writeReverse(buf: Buffer): this {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), \"buf\");\n    this.bufs.push(BufferUtils.reverse(buf));\n    this.bufLen += buf.length;\n    return this;\n  }\n\n  public writeUInt8(n: number): this {\n    let buf = Buffer.alloc(1);\n    buf.writeUInt8(n, 0);\n    this.write(buf);\n    return this;\n  }\n\n  public writeUInt16BE(n: number): this {\n    let buf = Buffer.alloc(2);\n    buf.writeUInt16BE(n, 0);\n    this.write(buf);\n    return this;\n  }\n\n  public writeUInt16LE(n: number): this {\n    let buf = Buffer.alloc(2);\n    buf.writeUInt16LE(n, 0);\n    this.write(buf);\n    return this;\n  }\n\n  public writeUInt32BE(n: number): this {\n    let buf = Buffer.alloc(4);\n    buf.writeUInt32BE(n, 0);\n    this.write(buf);\n    return this;\n  }\n\n  public writeInt32LE(n: number): this {\n    let buf = Buffer.alloc(4);\n    buf.writeInt32LE(n, 0);\n    this.write(buf);\n    return this;\n  }\n\n  public writeUInt32LE(n: number): this {\n    let buf = Buffer.alloc(4);\n    buf.writeUInt32LE(n, 0);\n    this.write(buf);\n    return this;\n  }\n\n  public writeUInt64BEBN(bn: BN): this {\n    let buf = bn.toBuffer({size: 8});\n    this.write(buf);\n    return this;\n  }\n\n  public writeUInt64LEBN(bn: BN): this {\n    let buf = bn.toBuffer({size: 8});\n    this.writeReverse(buf);\n    return this;\n  }\n\n  public writeVarintNum(n: number): this {\n    let buf = BufferWriter.varintBufNum(n);\n    this.write(buf);\n    return this;\n  }\n\n  public writeVarintBN(bn: BN): this {\n    let buf = BufferWriter.varintBufBN(bn);\n    this.write(buf);\n    return this;\n  }\n\n  public writeVarLengthBuf(buf: Buffer): this {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), \"buf\");\n    this.writeVarintNum(buf.length);\n    this.write(buf);\n    return this;\n  }\n\n  public writeCoreVarintNum(n: number): this {\n    let tmp = [];\n    let len = 0;\n\n    while (true)\n    {\n      tmp.push((n & 0x7F) | (len ? 0x80 : 0x00));\n      if (n <= 0x7F)\n          break;\n      n = (n >> 7) - 1;\n      len++;\n    }\n\n    this.write(Buffer.from(tmp).reverse());\n    return this;\n  }\n\n  public static varintBufNum(n: number): Buffer {\n    let buf = undefined;\n    if (n < 253) {\n      buf = Buffer.alloc(1);\n      buf.writeUInt8(n, 0);\n    } else if (n < 0x10000) {\n      buf = Buffer.alloc(1 + 2);\n      buf.writeUInt8(253, 0);\n      buf.writeUInt16LE(n, 1);\n    } else if (n < 0x100000000) {\n      buf = Buffer.alloc(1 + 4);\n      buf.writeUInt8(254, 0);\n      buf.writeUInt32LE(n, 1);\n    } else {\n      buf = Buffer.alloc(1 + 8);\n      buf.writeUInt8(255, 0);\n      buf.writeInt32LE(n & -1, 1);\n      buf.writeUInt32LE(Math.floor(n / 0x100000000), 5);\n    }\n    return buf;\n  }\n\n  public static varintBufBN(bn: BN): Buffer {\n    let buf = undefined;\n    let n = bn.toNumber();\n    if (n < 253) {\n      buf = Buffer.alloc(1);\n      buf.writeUInt8(n, 0);\n    } else if (n < 0x10000) {\n      buf = Buffer.alloc(1 + 2);\n      buf.writeUInt8(253, 0);\n      buf.writeUInt16LE(n, 1);\n    } else if (n < 0x100000000) {\n      buf = Buffer.alloc(1 + 4);\n      buf.writeUInt8(254, 0);\n      buf.writeUInt32LE(n, 1);\n    } else {\n      let bw = new BufferWriter();\n      bw.writeUInt8(255);\n      bw.writeUInt64LEBN(bn);\n      buf = bw.concat();\n    }\n    return buf;\n  }\n}","import { isInteger, isNil, isString } from \"lodash-es\";\nimport type { BigNumberish } from \"../common/types\";\nimport ValidationUtils from \"./validation.utils\";\nimport bigDecimal from \"js-big-decimal\";\n\nexport enum UnitType {\n  MEX = 8,\n  KEX = 5,\n  NEXA = 2\n}\n\n/**\n * Utility for handling and converting nexa units.\n * You can consult for different representation of a unit using it's\n * {format} method or the fixed unit methods like {parse}.\n *\n * @example\n * ```ts\n * let nex = UnitUtils.formatNEXA(546); // \"5.46\"\n * let sats = UnitUtils.parseNEXA(\"5.46\"); // 546n\n * let mex = UnitUtils.formatUnits(100000000, UnitType.MEX) // \"1.00000000\";\n * let units = UnitUtils.parseUnits('1.0', 5); // 100000n\n * ```\n */\nexport default class UnitUtils {\n\n  /**\n   *  Converts `value` into a decimal string, assuming `unit` decimal\n   *  places. The `unit` may be the number of decimal places or the enum of\n   *  a unit (e.g. ``UnitType.MEX`` for 8 decimal places).\n   *\n   */\n  public static formatUnits(value: BigNumberish, unit?: UnitType | number): string {\n    let decimals = 2;\n    if (!isNil(unit)) {\n      ValidationUtils.validateArgument(isInteger(unit) && unit >= 0, \"unit\", \"invalid unit\");\n      decimals = unit;\n    }\n\n    return bigDecimal.divide(value, Math.pow(10, decimals), decimals);\n  }\n\n  /**\n  *  Converts the decimal string `value` to a BigInt, assuming\n  *  `unit` decimal places. The `unit` may the number of decimal places\n  *  or the name of a unit (e.g. ``UnitType.KEX`` for 5 decimal places).\n  */\n  public static parseUnits(value: string, unit?: UnitType | number): bigint {\n    ValidationUtils.validateArgument(isString(value), \"value\", \"must be a string\");\n    let decimals = 2;\n    if (!isNil(unit)) {\n      ValidationUtils.validateArgument(isInteger(unit) && unit >= 0, \"unit\", \"invalid unit\");\n      decimals = unit;\n    }\n\n    return BigInt(bigDecimal.multiply(value, Math.pow(10, decimals)));\n  }\n\n  /**\n  *  Converts `value` into a decimal string using 2 decimal places.\n  */\n  public static formatNEXA(sats: BigNumberish): string {\n    return this.formatUnits(sats, UnitType.NEXA);\n  }\n\n  /**\n  *  Converts the decimal string `NEXA` to a BigInt, using 2 decimal places.\n  */\n  public static parseNEXA(nexa: string): bigint {\n    return this.parseUnits(nexa, UnitType.NEXA);\n  }\n}","/**\n * Checks if `value` is `null` or `undefined`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is nullish, else `false`.\n * @example\n *\n * _.isNil(null);\n * // => true\n *\n * _.isNil(void 0);\n * // => true\n *\n * _.isNil(NaN);\n * // => false\n */\nfunction isNil(value) {\n  return value == null;\n}\n\nexport default isNil;\n","import toInteger from './toInteger.js';\n\n/**\n * Checks if `value` is an integer.\n *\n * **Note:** This method is based on\n * [`Number.isInteger`](https://mdn.io/Number/isInteger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an integer, else `false`.\n * @example\n *\n * _.isInteger(3);\n * // => true\n *\n * _.isInteger(Number.MIN_VALUE);\n * // => false\n *\n * _.isInteger(Infinity);\n * // => false\n *\n * _.isInteger('3');\n * // => false\n */\nfunction isInteger(value) {\n  return typeof value == 'number' && value == toInteger(value);\n}\n\nexport default isInteger;\n","import toFinite from './toFinite.js';\n\n/**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\nfunction toInteger(value) {\n  var result = toFinite(value),\n      remainder = result % 1;\n\n  return result === result ? (remainder ? result - remainder : result) : 0;\n}\n\nexport default toInteger;\n","import toNumber from './toNumber.js';\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0,\n    MAX_INTEGER = 1.7976931348623157e+308;\n\n/**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\nfunction toFinite(value) {\n  if (!value) {\n    return value === 0 ? value : 0;\n  }\n  value = toNumber(value);\n  if (value === INFINITY || value === -INFINITY) {\n    var sign = (value < 0 ? -1 : 1);\n    return sign * MAX_INTEGER;\n  }\n  return value === value ? value : 0;\n}\n\nexport default toFinite;\n","import baseTrim from './_baseTrim.js';\nimport isObject from './isObject.js';\nimport isSymbol from './isSymbol.js';\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n  if (typeof value == 'number') {\n    return value;\n  }\n  if (isSymbol(value)) {\n    return NAN;\n  }\n  if (isObject(value)) {\n    var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n    value = isObject(other) ? (other + '') : other;\n  }\n  if (typeof value != 'string') {\n    return value === 0 ? value : +value;\n  }\n  value = baseTrim(value);\n  var isBinary = reIsBinary.test(value);\n  return (isBinary || reIsOctal.test(value))\n    ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n    : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nexport default toNumber;\n","import trimmedEndIndex from './_trimmedEndIndex.js';\n\n/** Used to match leading whitespace. */\nvar reTrimStart = /^\\s+/;\n\n/**\n * The base implementation of `_.trim`.\n *\n * @private\n * @param {string} string The string to trim.\n * @returns {string} Returns the trimmed string.\n */\nfunction baseTrim(string) {\n  return string\n    ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')\n    : string;\n}\n\nexport default baseTrim;\n","/** Used to match a single whitespace character. */\nvar reWhitespace = /\\s/;\n\n/**\n * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace\n * character of `string`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {number} Returns the index of the last non-whitespace character.\n */\nfunction trimmedEndIndex(string) {\n  var index = string.length;\n\n  while (index-- && reWhitespace.test(string.charAt(index))) {}\n  return index;\n}\n\nexport default trimmedEndIndex;\n","import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n  return typeof value == 'symbol' ||\n    (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nexport default isSymbol;\n","import type { Networkish } from \"../../common/types\";\nimport type { NetworkParams} from \"../../common/interfaces\";\nimport BufferUtils from \"../../utils/buffer.utils\";\nimport { liveNetwork, Network, testNetwork } from \"./network\";\n\n/**\n * NetworkManager is a singleton service, containing map values that correspond to version\n * numbers for each nexa network. Currently only supporting \"mainnet\"\n * (a.k.a. \"livenet\") and \"testnet\", with option to add custom networks.\n * \n * @remarks should be used as singletone. \n * \n * @see {@linkcode NetworkManager.getInstance}\n */\nexport default class NetworkManager {\n\n  private static readonly _instance = new NetworkManager();\n\n  private networks = [ liveNetwork, testNetwork ];\n\n  private _defaultNetwork = liveNetwork;\n\n  public get mainnet(): Network {\n    return liveNetwork;\n  }\n\n  /** @deprecated use mainnet */\n  public get livenet(): Network {\n    return liveNetwork;\n  }\n\n  public get testnet(): Network {\n    return testNetwork;\n  }\n\n  public get defaultNetwork(): Network {\n    return this._defaultNetwork;\n  }\n\n  public set defaultNetwork(network: Network) {\n    this._defaultNetwork = network;\n  }\n\n  /**\n   * @returns the singleton instance of NetworkManager\n   */\n  public static getInstance(): NetworkManager {\n    return this._instance;\n  }\n\n  public get(arg?: Networkish | number, key?: keyof Network): Network | undefined {\n    if (arg instanceof Network) {\n      if (this.networks.includes(arg)) {\n        return arg;\n      }\n      if (this.networks.map(n => n.name).includes(arg.name)) {\n        return this.networks.find(n => n.name == arg.name);\n      }\n    }\n  \n    if (key) {\n      return this.networks.find(network => {\n        if (key == 'networkMagic') {\n          return BufferUtils.integerFromBuffer(network[key]) == arg;\n        } else {\n          return network[key] == arg;\n        }\n      });\n    } else {\n      return this.networks.find(network => Object.keys(network).some(prop => {\n        let _prop = prop as keyof Network;\n        if (_prop == 'networkMagic') {\n          return BufferUtils.integerFromBuffer(network[_prop]) == arg;\n        } else {\n          return network[_prop] == arg;\n        }\n      }));\n    }\n  }\n\n  public create(network: NetworkParams): Network {\n    return new Network(network);\n  }\n  \n  public add(network: Network | NetworkParams): void {\n    if (!(network instanceof Network)) {\n      network = new Network(network);\n    }\n    this.networks.push(network);\n  }\n  \n  public remove(network: Networkish | NetworkParams): void {\n    if (typeof network !== 'object') {\n      network = this.get(network)!;\n      if (!network) {\n        return;\n      }\n    }\n    for (let i = 0; i < this.networks.length; i++) {\n      if (this.networks[i] === network || JSON.stringify(this.networks[i]) == JSON.stringify(network)) {\n        this.networks.splice(i, 1);\n      }\n    }\n  }\n}\n\n/** @internal */\nexport const networks = NetworkManager.getInstance();","import type { NetworkParams } from \"../../common/interfaces\";\nimport BufferUtils from \"../../utils/buffer.utils\";\n\nexport class Network {\n  public name: string;\n  public alias: string;\n  public prefix: string;\n  public pubkeyhash: number;\n  public privatekey: number;\n  public scripthash: number;\n  public xpubkey: number;\n  public xprivkey: number;\n  public networkMagic: Buffer;\n  public port: number;\n  public dnsSeeds: string[];\n\n  constructor(params: NetworkParams) {\n    this.name = params.name;\n    this.alias = params.alias;\n    this.prefix = params.prefix;\n    this.pubkeyhash = params.pubkeyhash;\n    this.privatekey = params.privatekey;\n    this.scripthash = params.scripthash;\n    this.xpubkey = params.xpubkey;\n    this.xprivkey = params.xprivkey;\n    this.networkMagic = BufferUtils.integerAsBuffer(params.networkMagic);\n    this.port = params.port;\n    this.dnsSeeds = params.dnsSeeds;\n  }\n\n  public toString(): string {\n    return this.name;\n  }\n}\n\nexport const liveNetwork = new Network({\n  name: 'mainnet',\n  alias: 'livenet',\n  prefix: 'nexa',\n  pubkeyhash: 0x19,\n  privatekey: 0x23,\n  scripthash: 0x44,\n  xpubkey: 0x42696720,\n  xprivkey: 0x426c6b73,\n  networkMagic: 0x72271221,\n  port: 7228,\n  dnsSeeds: [ // from https://gitlab.com/nexa/nexa/-/blob/dev/src/chainparams.cpp#L592\n    'seed.nextchain.cash',\n    'seeder.nexa.org',\n    'nexa-seeder.bitcoinunlimited.info'\n  ]\n});\n\nexport const testNetwork = new Network({\n  name: 'testnet',\n  alias: 'testnet',\n  prefix: 'nexatest',\n  pubkeyhash: 0x6f,\n  privatekey: 0xef,\n  scripthash: 0xc4,\n  xpubkey: 0x043587cf,\n  xprivkey: 0x04358394,\n  networkMagic: 0x72271222,\n  port: 7230,\n  dnsSeeds: [\n    'nexa-testnet-seeder.bitcoinunlimited.info',\n    'testnetseeder.nexa.org'\n  ]\n});","import { isUndefined } from \"lodash-es\";\nimport type { IPrivateKey, IPublicKey, ISignature } from \"../common/interfaces\";\nimport type { EndianType } from \"../common/types\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport BN from \"./bn.extension\";\nimport DigitalSignature from \"./digital-signature\";\nimport Point from \"./point\";\nimport Hash from \"./hash\";\nimport ValidationUtils from \"../utils/validation.utils\";\nimport PublicKey from \"../keys/publickey\";\n\n/**\n * IMPORTANT: ECDSA only used for compact message signing.\n * for transactions signing, use Schnorr.\n */\nexport default class ECDSA extends DigitalSignature {\n\n  k?: BN;\n\n  public override set(obj: Partial<ECDSA>): this {\n    this.k = obj.k || this.k;\n    return super.set(obj);\n  }\n\n  public override sigError(): boolean | string {\n    if (!BufferUtils.isBuffer(this.hashbuf) || this.hashbuf.length !== 32) {\n      return 'hashbuf must be a 32 byte buffer';\n    }\n  \n    let r = this.sig!.r;\n    let s = this.sig!.s;\n    if (!(r.gt(BN.Zero) && r.lt(Point.getN())) || !(s.gt(BN.Zero) && s.lt(Point.getN()))) {\n      return 'r and s not in range';\n    }\n  \n    let e = BN.fromBuffer(this.hashbuf, this.endian ? { endian: this.endian } : undefined);\n    let n = Point.getN();\n    let sinv = s.invm(n);\n    let u1 = sinv.mul(e).umod(n);\n    let u2 = sinv.mul(r).umod(n);\n  \n    let p = Point.getG().mulAdd(new BN(u1), this.pubkey.point, new BN(u2));\n\n    /* c8 ignore start */\n    if (p.ecPoint.isInfinity()) {\n      return 'p is infinity';\n    }\n    /* c8 ignore stop */\n\n    if (p.getX().umod(n).cmp(r) !== 0) {\n      return 'Invalid signature';\n    } else {\n      return false;\n    }\n  }\n\n  protected override _findSignature(d: BN, e: BN): Partial<ISignature> {\n    let N = Point.getN();\n    let G = Point.getG();\n    // try different values of k until r, s are valid\n    let badrs = 0;\n    let k, Q, r, s;\n    do {\n      if (!this.k || badrs > 0) {\n        this.deterministicK(badrs);\n      }\n      badrs++;\n      k = this.k;\n      Q = G.mul(k!);\n      r = Q.ecPoint.x!.umod(N);\n      s = k!.invm(N).mul(e.add(d.mul(r))).umod(N);\n    } while (r.cmp(BN.Zero) <= 0 || s.cmp(BN.Zero) <= 0);\n\n    s = ECDSA.toLowS(new BN(s));\n    return { s: s, r: new BN(r) };\n  }\n\n  private static toLowS(s: BN): BN {\n    //enforce low s\n    //see BIP 62, \"low S values in signatures\"\n    if (s.gt(BN.fromBuffer(Buffer.from('7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0', 'hex')))) {\n      s = Point.getN().sub(s);\n    }\n    return s;\n  }\n\n  public calcI(): this {\n    for (let i = 0; i < 4; i++) {\n      this.sig!.i = i;\n      let Qprime;\n      try {\n        Qprime = this.toPublicKey();\n        /* c8 ignore next 3 */\n      } catch {\n        continue;\n      }\n  \n      if (Qprime.point.eq(this.pubkey.point)) {\n        this.sig!.compressed = this.pubkey.compressed;\n        return this;\n      }\n    /* c8 ignore next 4 */\n    }\n   \n    this.sig!.i = undefined;\n    throw new Error(`Unable to find valid recovery factor`);\n  }\n\n  public randomK(): this {\n    let N = Point.getN();\n    let k;\n    do {\n      k = BN.fromBuffer(BufferUtils.getRandomBuffer(32));\n    } while (!(k.lt(N) && k.gt(BN.Zero)));\n    this.k = k;\n    return this;\n  }\n  \n  // https://tools.ietf.org/html/rfc6979#section-3.2\n  public deterministicK(badrs?: number): this {\n    // if r or s were invalid when this function was used in signing,\n    // we do not want to actually compute r, s here for efficiency, so,\n    // we can increment badrs. explained at end of RFC 6979 section 3.2\n    if (isUndefined(badrs)) {\n      badrs = 0;\n    }\n    let v: Buffer = Buffer.alloc(32);\n    v.fill(0x01);\n    let k: Buffer = Buffer.alloc(32);\n    k.fill(0x00);\n    let x = this.privkey.bn.toBuffer({ size: 32 });\n    let hashbuf = this.endian === 'little' ? BufferUtils.reverse(this.hashbuf) : this.hashbuf\n    k = Hash.sha256hmac(Buffer.concat([v, Buffer.from([0x00]), x, hashbuf]), k);\n    v = Hash.sha256hmac(v, k);\n    k = Hash.sha256hmac(Buffer.concat([v, Buffer.from([0x01]), x, hashbuf]), k);\n    v = Hash.sha256hmac(v, k);\n    v = Hash.sha256hmac(v, k);\n    let T = BN.fromBuffer(v);\n    let N = Point.getN();\n  \n    // also explained in 3.2, we must ensure T is in the proper range (0, N)\n    for (let i = 0; i < badrs || !(T.lt(N) && T.gt(BN.Zero)); i++) {\n      k = Hash.sha256hmac(Buffer.concat([v, Buffer.from([0x00])]), k);\n      v = Hash.sha256hmac(v, k);\n      v = Hash.sha256hmac(v, k);\n      T = BN.fromBuffer(v);\n    }\n  \n    this.k = T;\n    return this;\n  }\n\n  public signRandomK(): this {\n    this.randomK();\n    return this.sign();\n  }\n  \n  public toString(): string {\n    let obj: Record<string, string> = {};\n    if (this.hashbuf) {\n      obj.hashbuf = this.hashbuf.toString('hex');\n    }\n    if (this.privkey) {\n      obj.privkey = this.privkey.toString();\n    }\n    if (this.pubkey) {\n      obj.pubkey = this.pubkey.toString();\n    }\n    if (this.sig) {\n      obj.sig = this.sig.toString();\n    }\n    if (this.k) {\n      obj.k = this.k.toString();\n    }\n    return JSON.stringify(obj);\n  }\n\n  // Information about public key recovery:\n  // https://bitcointalk.org/index.php?topic=6430.0\n  // http://stackoverflow.com/questions/19665491/how-do-i-get-an-ecdsa-public-key-from-just-a-bitcoin-signature-sec1-4-1-6-k\n  public override toPublicKey(): PublicKey {\n    let i = this.sig!.i!;\n    ValidationUtils.validateArgument(i === 0 || i === 1 || i === 2 || i === 3, 'i must be equal to 0, 1, 2, or 3');\n\n    let e = BN.fromBuffer(this.hashbuf);\n    let r = this.sig!.r;\n    let s = this.sig!.s;\n\n    // A set LSB signifies that the y-coordinate is odd\n    let isYOdd = i & 1;\n\n    // The more significant bit specifies whether we should use the\n    // first or second candidate key.\n    let isSecondKey = i >> 1;\n\n    let n = Point.getN();\n    let G = Point.getG();\n\n    // 1.1 Let x = r + jn\n    let x = isSecondKey ? r.add(n) : r;\n    let R = Point.ecPointFromX(!!isYOdd, x);\n\n    // 1.4 Check that nR is at infinity\n    let nR = R.mul(n);\n\n    /* c8 ignore start */\n    if (!nR.ecPoint.isInfinity()) {\n      throw new Error('nR is not a valid curve point');\n    }\n    /* c8 ignore stop */\n\n    // Compute -e from e\n    let eNeg = e.neg().umod(n);\n\n    // 1.6.1 Compute Q = r^-1 (sR - eG)\n    // Q = r^-1 (sR + -eG)\n    let rInv = r.invm(n);\n\n    //let Q = R.multiplyTwo(s, G, eNeg).mul(rInv);\n    let Q = R.mul(s).add(G.mul(new BN(eNeg))).mul(new BN(rInv));\n\n    let pubkey = PublicKey.fromPoint(Q, this.sig!.compressed);\n\n    return pubkey;\n  }\n    \n  public static fromString(str: string): ECDSA {\n    let obj = JSON.parse(str);\n    return new ECDSA(obj);\n  }\n  \n  public static sign(hashbuf: Buffer, privkey: IPrivateKey, endian?: EndianType): ISignature {\n    return new ECDSA({\n      hashbuf: hashbuf,\n      endian: endian,\n      privkey: privkey\n    }).sign().sig!;\n  }\n  \n  public static verify(hashbuf: Buffer, sig: ISignature, pubkey: IPublicKey, endian?: EndianType): boolean {\n    return new ECDSA({\n      hashbuf: hashbuf,\n      endian: endian,\n      sig: sig,\n      pubkey: pubkey\n    }).verify().verified!;\n  }\n}","import { isNil } from \"lodash-es\";\nimport type { IDigitalSignature, IPrivateKey, IPublicKey, ISignature } from \"../common/interfaces\";\nimport type { EndianType } from \"../common/types\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport ValidationUtils from \"../utils/validation.utils\";\nimport BN from \"./bn.extension\";\nimport Signature from \"./signature\";\n\nexport default abstract class DigitalSignature implements IDigitalSignature {\n  \n  hashbuf!: Buffer;\n  endian?: EndianType;\n  privkey!: IPrivateKey;\n  pubkey!: IPublicKey;\n  sig?: ISignature;\n  verified?: boolean;\n\n  constructor(obj?: Partial<IDigitalSignature>) {\n    if (obj) {\n      this.set(obj);\n    }\n  }\n\n  protected set(obj: Partial<IDigitalSignature>): this {\n    this.hashbuf = obj.hashbuf || this.hashbuf;\n    this.endian = obj.endian || this.endian;\n    this.privkey = obj.privkey || this.privkey;\n    this.pubkey = obj.pubkey || (this.privkey ? this.privkey.publicKey : this.pubkey);\n    this.sig = obj.sig || this.sig;\n    this.verified = obj.verified || this.verified;\n    return this;\n  }\n\n  protected abstract _findSignature(d: BN, e: BN): Partial<ISignature>;\n\n  public abstract sigError(): boolean | string;\n\n  public sign(): this {\n    let hashbuf = this.hashbuf;\n    let privkey = this.privkey;\n    let d = privkey.bn;\n  \n    ValidationUtils.validateState(!isNil(hashbuf) && !isNil(privkey) && !isNil(d), 'invalid parameters');\n    ValidationUtils.validateState(BufferUtils.isBuffer(hashbuf) && hashbuf.length === 32, 'hashbuf must be a 32 byte buffer');\n\n    let e = BN.fromBuffer(hashbuf, this.endian ? { endian: this.endian } : undefined);\n    \n    let obj = this._findSignature(d, e);\n    obj.compressed = this.pubkey!.compressed;\n    \n    this.sig = new Signature(obj);\n    return this;\n  }\n\n  public verify(): this {\n    this.verified = !this.sigError();\n    return this;\n  }\n\n  public toPublicKey(): IPublicKey {\n    return this.privkey.toPublicKey();\n  }\n\n  public privkey2pubkey(): void {\n    this.pubkey = this.privkey.toPublicKey();\n  }\n}","import { isUndefined } from \"lodash-es\";\nimport type { ISignature } from \"../common/interfaces\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport ValidationUtils from \"../utils/validation.utils\";\nimport BN from \"./bn.extension\";\n\nexport default class Signature implements ISignature {\n\n  public r: BN;\n  public s: BN;\n  public i?: number;\n  public compressed?: boolean;\n\n  constructor(params: Partial<ISignature>) {\n    this.r = params.r!;\n    this.s = params.s!;\n    this.i = params.i;\n    this.compressed = params.compressed;\n  }\n\n  public toBuffer(isSchnorr = true): Buffer {\n    if (isSchnorr) {\n      // Schnorr signatures use a 64 byte r,s format.\n      return Buffer.concat([this.r.toBuffer({size: 32}), this.s.toBuffer({size: 32})]);\n    }\n    \n    let rnbuf = this.r.toBuffer();\n    let snbuf = this.s.toBuffer();\n    \n    let rneg = rnbuf[0] & 0x80 ? true : false;\n    /* c8 ignore next */\n    let sneg = snbuf[0] & 0x80 ? true : false;\n\n    let rbuf = rneg ? Buffer.concat([Buffer.from([0x00]), rnbuf]) : rnbuf;\n    /* c8 ignore next */\n    let sbuf = sneg ? Buffer.concat([Buffer.from([0x00]), snbuf]) : snbuf;\n\n    let rlength = rbuf.length;\n    let slength = sbuf.length;\n    let length = 2 + rlength + 2 + slength;\n    let rheader = 0x02;\n    let sheader = 0x02;\n    let header = 0x30;\n\n    let der = Buffer.concat([Buffer.from([header, length, rheader, rlength]), rbuf, Buffer.from([sheader, slength]), sbuf]);\n    return der;\n  }\n\n  public toTxFormat(sighashBuf?: Buffer): Buffer {\n    let sigbuf = this.toBuffer();\n    if (BufferUtils.isBuffer(sighashBuf)) {\n      return Buffer.concat([sigbuf, sighashBuf]);\n    }\n    return sigbuf;\n  }\n\n  public toString(): string {\n    return this.toBuffer().toString('hex');\n  }\n\n  /**\n   * Schnorr signatures are 64 bytes: r [len] 32 || s [len] 32.\n   * \n   * There can be a few more bytes that is the sighashtype. It needs to be trimmed before calling this.\n   */\n  public static fromBuffer(buf: Buffer, strict?: boolean): Signature {\n    if (buf.length === 64) {\n      let params = this.parseSchnorrEncodedSig(buf);\n      return new Signature(params);\n    }\n    \n    let obj = Signature.parseDER(buf, strict);\n    return new Signature({ r: obj.r as BN, s: obj.s as BN });\n  }\n\n  /**\n   * The format used in a tx.\n   * schnorr is 64 bytes, the rest are sighashtype bytes\n   * \n   * @param buf \n   */\n  public static fromTxFormat(buf: Buffer): Signature {\n    let sigbuf = buf.subarray(0, 64);\n    return Signature.fromBuffer(sigbuf);\n  }\n\n  /**\n   * This assumes the str is a raw signature and does not have sighashtype.\n   * Use {@link Signature.fromTxString} when decoding a tx\n   * \n   * @param str the signature hex string\n   * @see fromTxString\n   */\n  public static fromString(str: string): Signature {\n    let buf = Buffer.from(str, 'hex');\n    return Signature.fromBuffer(buf);\n  }\n\n  /**\n   * This assumes the str might have sighashtype bytes and will trim it if needed.\n   * Use this when decoding a tx signature string\n   * \n   * @param str the tx signature hex string\n   */\n  public static fromTxString(str: string, encoding: BufferEncoding = 'hex'): Signature {\n    return Signature.fromTxFormat(Buffer.from(str, encoding))\n  }\n\n  private static parseSchnorrEncodedSig(buf: Buffer): Partial<ISignature> {\n    let r = buf.subarray(0,32);\n    let s = buf.subarray(32, 64);\n\n    return {\n      r: BN.fromBuffer(r),\n      s: BN.fromBuffer(s),\n    };\n  }\n\n  /**\n   * For ECDSA. In order to mimic the non-strict DER encoding of OpenSSL, set strict = false.\n   */\n  public static parseDER(buf: Buffer, strict?: boolean): Record<string, unknown> {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), 'DER formatted signature should be a buffer');\n    if (isUndefined(strict)) {\n      strict = true;\n    }\n\n    let header = buf[0];\n    ValidationUtils.validateArgument(header === 0x30, 'Header byte should be 0x30');\n\n    let length = buf[1];\n    let buflength = buf.subarray(2).length;\n    ValidationUtils.validateArgument(!strict || length === buflength, 'Length byte should length of what follows');\n\n    length = length < buflength ? length : buflength;\n\n    let rheader = buf[2 + 0];\n    ValidationUtils.validateArgument(rheader === 0x02, 'Integer byte for r should be 0x02');\n\n    let rlength = buf[2 + 1];\n    let rbuf = buf.subarray(2 + 2, 2 + 2 + rlength);\n    let r = BN.fromBuffer(rbuf);\n    let rneg = buf[2 + 1 + 1] === 0x00 ? true : false;\n    ValidationUtils.validateArgument(rlength === rbuf.length, 'Length of r incorrect');\n\n    let sheader = buf[2 + 2 + rlength + 0];\n    ValidationUtils.validateArgument(sheader === 0x02, 'Integer byte for s should be 0x02');\n\n    let slength = buf[2 + 2 + rlength + 1];\n    let sbuf = buf.subarray(2 + 2 + rlength + 2, 2 + 2 + rlength + 2 + slength);\n    let s = BN.fromBuffer(sbuf);\n    /* c8 ignore next */\n    let sneg = buf[2 + 2 + rlength + 2 + 2] === 0x00 ? true : false;\n    ValidationUtils.validateArgument(slength === sbuf.length, 'Length of s incorrect');\n\n    let sumlength = 2 + 2 + rlength + 2 + slength;\n    ValidationUtils.validateArgument(length === sumlength - 2, 'Length of signature incorrect');\n\n    let obj = {\n      header: header,\n      length: length,\n      rheader: rheader,\n      rlength: rlength,\n      rneg: rneg,\n      rbuf: rbuf,\n      r: r,\n      sheader: sheader,\n      slength: slength,\n      sneg: sneg,\n      sbuf: sbuf,\n      s: s\n    };\n\n    return obj;\n  }\n\n  /**\n   * ECDSA format. used for sign messages\n   */\n  public toCompact(i?: number, compressed?: boolean): Buffer {\n    i = typeof i === 'number' ? i : this.i;\n    compressed = typeof compressed === 'boolean' ? compressed : this.compressed;\n\n    ValidationUtils.validateArgument(i === 0 || i === 1 || i === 2 || i === 3, 'i must be equal to 0, 1, 2, or 3');\n\n    let val = i! + 27 + 4;\n    if (compressed === false) {\n      val = val - 4;\n    }\n    let b1 = Buffer.from([val]);\n    let b2 = this.r.toBuffer({ size: 32 });\n    let b3 = this.s.toBuffer({ size: 32 });\n\n    return Buffer.concat([b1, b2, b3]);\n  }\n\n  public static fromCompact(buf: Buffer): Signature {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), 'Argument is expected to be a Buffer');\n\n    let compressed = true;\n    let i = buf.subarray(0, 1)[0] - 27 - 4;\n    if (i < 0) {\n      compressed = false;\n      i = i + 4;\n    }\n\n    let b2 = buf.subarray(1, 33);\n    let b3 = buf.subarray(33, 65);\n\n    ValidationUtils.validateArgument(i === 0 || i === 1 || i === 2 || i === 3, 'i must be 0, 1, 2, or 3');\n    ValidationUtils.validateArgument(b2.length === 32, 'r must be 32 bytes');\n    ValidationUtils.validateArgument(b3.length === 32, 's must be 32 bytes');\n\n    return new Signature({ r: BN.fromBuffer(b2), s: BN.fromBuffer(b3), i: i, compressed: compressed });\n  };\n}","import BN from \"../crypto/bn.extension\";\nimport type { curve, BNInput } from 'elliptic';\nimport elliptic from 'elliptic';\nconst EC = elliptic.ec;\n\nexport default class Point {\n\n  private static readonly ec = new EC('secp256k1').curve as curve.short;\n\n  public ecPoint: curve.short.ShortPoint;\n\n  private static _g: Point = new Point(this.ec.g);\n\n  constructor(point: curve.short.ShortPoint, skipValidation = false) {\n    this.ecPoint = point;\n    if (!skipValidation) {\n      this.validate();\n    }\n  }\n\n  /**\n   * Will return the X coordinate of the Point\n   *\n   * @returns A BN instance of the X coordinate\n   */\n  public getX(): BN {\n    return new BN(this.ecPoint.getX().toArray());\n  }\n\n  /**\n   * Will return the Y coordinate of the Point\n   *\n   * @returns A BN instance of the Y coordinate\n   */\n  public getY(): BN {\n    return new BN(this.ecPoint.getY().toArray());\n  }\n\n  public add(p: Point): Point {\n    return new Point(this.ecPoint.add(p.ecPoint) as curve.short.ShortPoint, true);\n  }\n\n  public mul(k: BN): Point {\n    let p = this.ecPoint.mul(k);\n    return new Point(p as curve.short.ShortPoint, true);\n  }\n\n  public mulAdd(k1: BN, p2: Point, k2: BN): Point {\n    let p = (this.ecPoint as any).mulAdd(k1, p2.ecPoint, k2); // eslint-disable-line @typescript-eslint/no-explicit-any\n    return new Point(p as curve.short.ShortPoint, true);\n  }\n\n  public eq(p: Point): boolean {\n    return this.ecPoint.eq(p.ecPoint);\n  }\n\n  /**\n   * Will determine if the point is valid\n   *\n   * @see {@link https://www.iacr.org/archive/pkc2003/25670211/25670211.pdf}\n   * @throws A validation error if exists\n   * @returns An instance of the same Point\n   */\n  public validate(): this {\n    if (this.ecPoint.isInfinity()){\n      throw new Error('Point cannot be equal to Infinity');\n    }\n  \n    let p2;\n    try {\n      p2 = Point.ec.pointFromX(this.getX(), this.getY().isOdd());\n    } catch {\n      throw new Error('Point does not lie on the curve');\n    }\n  \n    if (p2.y!.cmp(this.ecPoint.y!) !== 0) {\n      throw new Error('Invalid y value for curve.');\n    }\n  \n    if (!(this.ecPoint.mul(Point.getN()).isInfinity())) {\n      throw new Error('Point times N must be infinity');\n    }\n  \n    return this;\n  }\n\n  public hasSquare(): boolean {\n    return !this.ecPoint.isInfinity() && Point.isSquare(this.getY());\n  }\n\n  private static isSquare(x: BN): boolean {\n    let p = new BN('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F', 'hex');\n    let x0 = new BN(x);\n    let base = x0.toRed(BN.red(p));\n    let res = base.redPow(p.sub(BN.One).div(new BN(2))).fromRed();\n    return res.eq(new BN(1));\n  }\n\n  /**\n   * Instantiate a valid secp256k1 Point from the X and Y coordinates.\n   *\n   * @param x - The X coordinate\n   * @param y - The Y coordinate\n   * @see {@link https://github.com/indutny/elliptic}\n   * @throws A validation error if exists\n   */\n  public static ecPoint(x: BNInput, y: BNInput, isRed?: boolean): Point {\n    return new Point(this.ec.point(x, y, isRed));\n  }\n\n  /**\n   *\n   * Instantiate a valid secp256k1 Point from only the X coordinate\n   * \n   * @param odd - If the Y coordinate is odd\n   * @param x - The X coordinate\n   * @throws A validation error if exists\n   */\n  public static ecPointFromX(odd: boolean, x: BNInput): Point {\n    let point;\n    try {\n      point = this.ec.pointFromX(x, odd);\n    } catch {\n      throw new Error('Invalid X');\n    }\n    return new Point(point);\n  }\n\n  /**\n   *\n   * Will return a secp256k1 ECDSA base point.\n   *\n   * @see {@link https://en.bitcoin.it/wiki/Secp256k1}\n   * @returns An instance of the base point.\n   */\n  public static getG(): Point {\n    return this._g;\n  };\n\n  /**\n   *\n   * Will return the max of range of valid private keys as governed by the secp256k1 ECDSA standard.\n   *\n   * @see {@link https://en.bitcoin.it/wiki/Private_key#Range_of_valid_ECDSA_private_keys}\n   * @returns A BN instance of the number of points on the curve\n   */\n  public static getN(): BN {\n    return new BN(this.ec.n.toArray());\n  };\n\n  public static pointToCompressed(point: Point): Buffer {\n    let xbuf = point.getX().toBuffer({size: 32});\n    let ybuf = point.getY().toBuffer({size: 32});\n  \n    let odd = ybuf[ybuf.length - 1] % 2;\n    let prefix = Buffer.from(odd ? [0x03] : [0x02]);\n\n    return Buffer.concat([prefix, xbuf]);\n  };\n}","import { isNil, isObject, isString, isUndefined } from \"lodash-es\";\nimport ValidationUtils from \"../utils/validation.utils\";\nimport Point from \"../crypto/point\";\nimport type { Network } from \"../core/network/network\";\nimport { networks } from \"../core/network/network-manager\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport BN from \"../crypto/bn.extension\";\nimport CommonUtils from \"../utils/common.utils\";\nimport type { IPrivateKey, IPublicKey, PublicKeyDto } from \"../common/interfaces\";\n\nexport type PublicKeyVariants = PublicKey | Point | Partial<IPrivateKey> | Partial<IPublicKey> | PublicKeyDto | Buffer | string;\n\n/**\n * Instantiate new PublicKey.\n *\n * There are two internal properties, `network` and `compressed`, that deal with importing\n * a PublicKey from a PrivateKey in WIF format.\n * \n * @remarks Better to use {@linkcode PublicKey.from} method to init public key from various formats if the formart unknown.\n *\n * @example\n * ```ts\n * // export to as a DER hex encoded string\n * let exported = key.toString();\n *\n * // import the public key\n * let imported = PublicKey.fromString(exported);\n * //or\n * let imported = PublicKey.from(exported);\n * ```\n */\nexport default class PublicKey implements IPublicKey {\n\n  public point!: Point;\n  public compressed!: boolean;\n  public network!: Network;\n\n  /**\n   * @param data - The pubkey data\n   */\n  constructor(data: Partial<IPublicKey>) {\n    ValidationUtils.validateArgument(!isNil(data), 'First argument is required, please include public key data.');\n\n    if (data instanceof PublicKey) {\n      // Return copy, but as it's an immutable object, return same argument\n      return data;\n    }\n\n    if (PublicKey._isPublicKeyData(data)) {\n      data.point.validate();\n      this.point = data.point;\n      this.compressed = isUndefined(data.compressed) || data.compressed;\n      this.network = data.network || networks.defaultNetwork;\n    } else {\n      throw new TypeError('First argument is an unrecognized data format.');\n    }\n  }\n\n  public toObject = this.toJSON;\n  public toDER = this.toBuffer;\n\n  /**\n   * @returns A plain object of the PublicKey\n   */\n  public toJSON(): PublicKeyDto {\n    return {\n      x: this.point.getX().toString('hex', 2),\n      y: this.point.getY().toString('hex', 2),\n      compressed: this.compressed,\n      network: this.network.toString()\n    };\n  }\n\n  /**\n   * Will output the PublicKey to a DER Buffer\n   *\n   * @returns  A DER hex encoded buffer\n   */\n  public toBuffer(): Buffer {\n    let x = this.point.getX();\n    let y = this.point.getY();\n\n    let xbuf = x.toBuffer({ size: 32 });\n    let ybuf = y.toBuffer({ size: 32 });\n\n    let prefix: Buffer;\n    if (!this.compressed) {\n      prefix = Buffer.from([0x04]);\n      return Buffer.concat([prefix, xbuf, ybuf]);\n    } else {\n      let odd = ybuf[ybuf.length - 1] % 2;\n      if (odd) {\n        prefix = Buffer.from([0x03]);\n      } else {\n        prefix = Buffer.from([0x02]);\n      }\n      return Buffer.concat([prefix, xbuf]);\n    }\n  }\n\n  /**\n   * Will output the PublicKey to a DER encoded hex string\n   *\n   * @returns A DER hex encoded string\n   */\n  public toString(): string {\n    return this.toBuffer().toString('hex');\n  }\n\n  /**\n   * Will return a string formatted for the console\n   *\n   * @returns Public key string inspection\n   */\n  public inspect(): string {\n    return '<PublicKey: ' + this.toString() + (this.compressed ? '' : ', uncompressed') + '>';\n  }\n\n  /**\n   * Instantiate a PublicKey from various formats\n   * \n   * @param data The encoded data in various formats\n   * @param compressed If the public key is compressed\n   * @param network The key network\n   * @returns New PublicKey instance\n   */\n  public static from(data: PublicKeyVariants, compressed?: boolean, network?: Network): PublicKey {\n    // detect type of data\n    if (data instanceof PublicKey) {\n      return data;\n    } else if (data instanceof Point) {\n      return this.fromPoint(data, compressed, network);\n    } else if (this._isPublicKeyDto(data)) {\n      return this.fromObject(data);\n    } else if (this._isPublicKeyData(data)) {\n      return new PublicKey(data);\n    } else if (this._isPrivateKeyData(data)) {\n      return this.fromPrivateKey(data);\n    } else if (BufferUtils.isBuffer(data)) {\n      return this.fromBuffer(data, true, network);\n    } else if (CommonUtils.isHexa(data as string)) {\n      return this.fromString(data as string, \"hex\", network);\n    } else {\n      throw new TypeError('First argument is an unrecognized data format.');\n    }\n  }\n\n  public static fromDER = this.fromBuffer;\n  public static fromObject = this.fromJSON;\n  \n  /**\n   * Instantiate a PublicKey from a Buffer\n   * \n   * @param buf - A DER hex buffer\n   * @param strict - if set to false, will loosen some conditions\n   * @param network - the network of the key\n   * @returns A new valid instance of PublicKey\n   */\n  public static fromBuffer(buf: Buffer, strict?: boolean, network?: Network): PublicKey {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), 'Must be a hex buffer of DER encoded public key');\n    let info = PublicKey._transformDER(buf, strict);\n    return new PublicKey({ point: info.point, compressed: info.compressed, network: network });\n  }\n\n  /**\n   * Instantiate a PublicKey from a Point\n   *\n   * @param point - A Point instance\n   * @param compressed - whether to store this public key as compressed format\n   * @param network - the network of the key\n   * @returns A new valid instance of PublicKey\n   */\n  public static fromPoint(point: Point, compressed?: boolean, network?: Network): PublicKey {\n    ValidationUtils.validateArgument(point instanceof Point, 'First argument must be an instance of Point.');\n    return new PublicKey({ point: point, compressed: compressed, network: network });\n  }\n\n  /**\n   * Instantiate a PublicKey from a DER hex encoded string\n   *\n   * @param str - A DER hex string\n   * @param encoding - The type of string encoding\n   * @param network - the network of the key\n   * @returns A new valid instance of PublicKey\n   */\n  public static fromString(str: string, encoding?: BufferEncoding, network?: Network): PublicKey {\n    let buf = Buffer.from(str, encoding || 'hex');\n    let info = PublicKey._transformDER(buf);\n    return new PublicKey({ point: info.point, compressed: info.compressed, network: network });\n  }\n\n  /**\n   * Instantiate a PublicKey from PrivateKey data\n   *\n   * @param data - Object contains data of PrivateKey\n   * @returns A new valid instance of PublicKey\n   */\n  public static fromPrivateKey(data: IPrivateKey): PublicKey {\n    ValidationUtils.validateArgument(this._isPrivateKeyData(data), 'data', 'Must be data of PrivateKey');\n    let point = Point.getG().mul(data.bn);\n    return new PublicKey({ point: point, compressed: data.compressed, network: data.network });\n  }\n\n  public static fromJSON(data: PublicKeyDto): PublicKey {\n    let info = PublicKey._transformObject(data);\n    return new PublicKey(info);\n  }\n\n  /**\n   * Check if there would be any errors when initializing a PublicKey\n   *\n   * @param data - The encoded data in various formats\n   * @returns An error if exists\n   */\n  public static getValidationError(data: PublicKeyVariants): Error | undefined {\n    try {\n      this.from(data);\n    } catch (e) {\n      return e as Error;\n    }\n    return undefined;\n  }\n\n  /**\n   * Check if the parameters are valid\n   *\n   * @param data - The encoded data in various formats\n   * @returns true If the public key would be valid\n   */\n  public static isValid(data: PublicKeyVariants): boolean {\n    return !PublicKey.getValidationError(data);\n  }\n\n  private static _isPublicKeyData(data: unknown): data is IPublicKey {\n    return isObject(data) && 'point' in data && data.point instanceof Point;\n  }\n\n  private static _isPublicKeyDto(data: unknown): data is PublicKeyDto {\n    return isObject(data) && 'x' in data && 'y' in data;\n  }\n\n  private static _isPrivateKeyData(data: unknown): data is IPrivateKey {\n    return isObject(data) && 'bn' in data && 'network' in data\n  }\n\n  /**\n   * Internal function to transform DER into a public key point\n   *\n   * @param buf - An hex encoded buffer\n   * @param strict - if set to false, will loosen some conditions\n   * @returns An object with keys: point and compressed\n   */\n  private static _transformDER(buf: Buffer, strict?: boolean): Partial<IPublicKey> {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), 'Must be a hex buffer of DER encoded public key');\n\n    strict = isUndefined(strict) ? true : strict;\n\n    if (buf[0] === 0x04 || (!strict && (buf[0] === 0x06 || buf[0] === 0x07))) {\n      let xbuf = buf.subarray(1, 33);\n      let ybuf = buf.subarray(33, 65);\n      if (xbuf.length !== 32 || ybuf.length !== 32 || buf.length !== 65) {\n        throw new TypeError('Length of x and y must be 32 bytes');\n      }\n      let x = new BN(xbuf);\n      let y = new BN(ybuf);\n      return { point: Point.ecPoint(x, y), compressed: false };\n    } else if (buf[0] === 0x03) {\n      let xbuf = buf.subarray(1);\n      let x = new BN(xbuf);\n      return { point: Point.ecPointFromX(true, x), compressed: true };\n    } else if (buf[0] === 0x02) {\n      let xbuf = buf.subarray(1);\n      let x = new BN(xbuf);\n      return { point: Point.ecPointFromX(false, x), compressed: true };\n    } else {\n      throw new TypeError('Invalid DER format public key');\n    }\n  }\n\n  /**\n   * Internal function to transform a JSON into a public key point\n   */\n  private static _transformObject(json: PublicKeyDto): Partial<IPublicKey> {\n    ValidationUtils.validateArgument(isString(json.x), 'x', 'must be a hex string');\n    ValidationUtils.validateArgument(isString(json.y), 'y', 'must be a hex string');\n    let x = new BN(json.x, 'hex');\n    let y = new BN(json.y, 'hex');\n    let point = Point.ecPoint(x, y);\n    return { point: point, compressed: json.compressed, network: networks.get(json.network) };\n  }\n}","import type { IPrivateKey, IPublicKey, ISignature } from \"../common/interfaces\";\nimport type { EndianType } from \"../common/types\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport ValidationUtils from \"../utils/validation.utils\";\nimport BN from \"./bn.extension\";\nimport DigitalSignature from \"./digital-signature\";\nimport Point from \"./point\";\nimport Hash from \"./hash\";\n\nexport default class Schnorr extends DigitalSignature {\n\n  public override sigError(): boolean | string {\n    if (!BufferUtils.isBuffer(this.hashbuf) || this.hashbuf.length !== 32) {\n      return 'hashbuf must be a 32 byte buffer';\n    }\n\n    let sigLength = Schnorr.getProperSizeBuffer(this.sig!.r).length + Schnorr.getProperSizeBuffer(this.sig!.s).length;\n    \n    if(!(sigLength === 64 || sigLength === 65)) {\n      return 'signature must be a 64 byte or 65 byte array';\n    } \n\n    let hashbuf = this.endian === 'little' ? BufferUtils.reverse(this.hashbuf) : this.hashbuf\n    \n    let P = this.pubkey.point;\n    let G = Point.getG();\n\n    if(P.ecPoint.isInfinity()) return true; /* c8 ignore next */\n    \n    let r = this.sig!.r;\n    let s = this.sig!.s;\n\n    let p = new BN('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F', 'hex');\n    let n = Point.getN();\n\n    if(r.gte(p) || s.gte(n)) {\n      // (\"Failed >= condition\") \n      return true;\n    }\n    \n    let Br = Schnorr.getProperSizeBuffer(this.sig!.r);\n    let Bp = Point.pointToCompressed(P);\n    \n    let hash = Hash.sha256(Buffer.concat([Br, Bp, hashbuf]));\n    let e = BN.fromBuffer(hash, { endian: 'big' }).umod(n);\n    \n    let sG = G.mul(s);\n    let eP = P.mul(n.sub(e));\n    let R = sG.add(eP);\n    \n    if(R.ecPoint.isInfinity() || !R.hasSquare() || !R.getX().eq(r)) {\n      return true;\n    } \n    return false;\n  }\n\n  /**\n   * RFC6979 deterministic nonce generation used from https://reviews.bitcoinabc.org/D2501\n   * \n   * @param privkeybuf \n   * @param msgbuf \n   * @return BN nonce\n   */\n  public nonceFunctionRFC6979(privkeybuf: Buffer, msgbuf: Buffer): BN {\n    let V: Buffer = Buffer.from(\"0101010101010101010101010101010101010101010101010101010101010101\",\"hex\");\n    let K: Buffer = Buffer.from(\"0000000000000000000000000000000000000000000000000000000000000000\",\"hex\");\n\n    let blob = Buffer.concat([privkeybuf, msgbuf, Buffer.from(\"\", \"ascii\"), Buffer.from(\"Schnorr+SHA256  \", \"ascii\")]);\n\n    K = Hash.sha256hmac(Buffer.concat([V, Buffer.from('00', 'hex'), blob]), K);\n    V = Hash.sha256hmac(V,K); \n\n    K = Hash.sha256hmac(Buffer.concat([V,Buffer.from('01','hex'), blob]), K);\n    V = Hash.sha256hmac(V,K);\n\n    let k = new BN(0);\n    let T;\n    while (true) {\n      V = Hash.sha256hmac(V,K);\n      T = BN.fromBuffer(V);\n      k = T;\n\n      ValidationUtils.validateState(V.length >= 32, \"V length should be >= 32\");\n\n      if (k.gt(new BN(0)) && k.lt(Point.getN())) {\n        break;\n      }/* c8 ignore start */\n\n      K = Hash.sha256hmac(Buffer.concat([V, Buffer.from(\"00\", 'hex')]), K);\n      V = Hash.sha256hmac(V, K);\n    }/* c8 ignore stop */\n\n    return k;\n  }\n\n  /**\n   * @remarks\n   * Important references for schnorr implementation {@link https://spec.nexa.org/forks/2019-05-15-schnorr/}\n   * \n   * @param d the private key\n   * @param e the message to be signed\n   */\n  protected override _findSignature(d: BN, e: BN): Partial<ISignature> {\n    let n = Point.getN();\n    let G = Point.getG();\n\n    ValidationUtils.validateState(!d.lte(new BN(0)), 'privkey out of field of curve');\n    ValidationUtils.validateState(!d.gte(n), 'privkey out of field of curve');\n\n    \n    let k = this.nonceFunctionRFC6979(d.toBuffer({ size: 32 }), e.toBuffer({ size: 32 }));\n\n    let P = G.mul(d);\n    let R = G.mul(k);\n\n    // Find deterministic k\n    if(R.hasSquare()) {\n      k = k;\n    } else {\n      k = n.sub(k);\n    }\n    \n    let r = R.getX();\n    let e0 = BN.fromBuffer(Hash.sha256(Buffer.concat([Schnorr.getProperSizeBuffer(r), Point.pointToCompressed(P), e.toBuffer({ size: 32 })])));\n    \n    let s = ((e0.mul(d)).add(k)).mod(n);\n\n    return { r: r, s: s };\n  }\n\n  /**\n   * Function written to ensure s or r parts of signature is at least 32 bytes, when converting \n   * from a BN to type Buffer.\n   * The BN type naturally cuts off leading zeros, e.g.\n   * <BN: 4f92d8094f710bc11b93935ac157730dda26c5c2a856650dbd8ebcd730d2d4> 31 bytes\n   * Buffer <00 4f 92 d8 09 4f 71 0b c1 1b 93 93 5a c1 57 73 0d da 26 c5 c2 a8 56 65 0d bd 8e bc d7 30 d2 d4> 32 bytes\n   * Both types are equal, however Schnorr signatures must be a minimum of 64 bytes.\n   * In a previous implementation of this schnorr module, was resulting in 63 byte signatures. \n   * (Although it would have been verified, it's proper to ensure the min requirement)\n   * \n   * @param buf the r or s signature part\n   */\n  private static getProperSizeBuffer(buf: BN): Buffer {\n    if (buf.toBuffer().length < 32) {\n      return buf.toBuffer({size: 32});\n    }\n    return buf.toBuffer();\n  }\n\n  public static sign(hashbuf: Buffer, privkey: IPrivateKey, endian: EndianType): ISignature {\n    return new Schnorr({\n      hashbuf: hashbuf,\n      endian: endian,\n      privkey: privkey\n    }).sign().sig!;\n  }\n  \n  public static verify(hashbuf: Buffer, sig: ISignature, pubkey: IPublicKey, endian: EndianType): boolean {\n    return new Schnorr({\n      hashbuf: hashbuf,\n      endian: endian,\n      sig: sig,\n      pubkey: pubkey\n    }).verify().verified!;\n  }\n}","import { isNil, isObject, isString, isUndefined } from \"lodash-es\";\nimport type { Bufferish, Networkish } from \"../common/types\";\nimport type { IPrivateKey, PrivateKeyDto } from \"../common/interfaces\";\nimport type { Network } from \"../core/network/network\";\nimport { networks } from \"../core/network/network-manager\";\nimport BN from \"../crypto/bn.extension\";\nimport CommonUtils from \"../utils/common.utils\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport Point from \"../crypto/point\";\nimport Base58Check from \"../encoding/base58check\";\nimport ValidationUtils from \"../utils/validation.utils\";\nimport PublicKey from \"./publickey\";\nimport Address from \"../core/address/address\";\nimport { AddressType } from \"../core/address/address-formatter\";\n\nexport type PrivateKeyVariants = BN | string | Bufferish | PrivateKey | IPrivateKey | PrivateKeyDto | null;\n\nexport default class PrivateKey implements IPrivateKey {\n\n  private _pubkey?: PublicKey;\n\n  public bn!: BN;\n  public compressed!: boolean;\n  public network!: Network;\n\n  /**\n   * Instantiate a PrivateKey.\n   * \n   * @param data The private key data\n   * \n   * @remarks Better to use {@linkcode PrivateKey.from} method to init private key from various formats if the formart unknown.\n   *\n   * @example\n   * ```ts\n   * // generate a new random key\n   * let key = new PrivateKey();\n   *\n   * // encode into wallet import format\n   * let exported = key.toWIF();\n   *\n   * // instantiate from the exported (and saved) private key\n   * let imported = PrivateKey.fromWIF(exported);\n   * ```\n   */\n  constructor(data?: Partial<IPrivateKey>) {\n    if (data instanceof PrivateKey) {\n      return data;\n    }\n\n    if (isNil(data)) {\n      data = {\n        bn: PrivateKey._getRandomBN(),\n        compressed: true,\n        network: networks.defaultNetwork\n      };\n    }\n\n    if (!PrivateKey._isPrivateKeyParams(data)) {\n      throw new TypeError('First argument is an unrecognized data type.');\n    }\n\n    // validation\n    if (!data.bn || data.bn.cmp(new BN(0)) === 0){\n      throw new TypeError('Number can not be equal to zero, undefined, null or false');\n    }\n    if (!data.bn.lt(Point.getN())) {\n      throw new TypeError('Number must be less than N');\n    }\n\n    this.bn = data.bn;\n    this.compressed = isUndefined(data.compressed) ? true : data.compressed;\n    this.network = data.network || networks.defaultNetwork;\n  }\n\n  public get publicKey(): PublicKey {\n    return this.toPublicKey();\n  }\n\n  /**\n   * Will return an address for the private key with its defined network\n   * \n   * @param type - optional parameter specifying the desired type of the address.\n   *  default {@link AddressType.PayToScriptTemplate}\n   * \n   * @returns An address generated from the private key\n   */\n  public toAddress(type = AddressType.PayToScriptTemplate): Address {\n    return Address.fromPublicKey(this.publicKey, this.network, type);\n  }\n\n  /**\n   * Will output the PrivateKey encoded as hex string\n   */\n  public toString(): string {\n    return this.toBuffer().toString('hex');\n  }\n\n  /**\n   * Will encode the PrivateKey to a WIF string\n   *\n   * @returns A WIF representation of the private key\n   */\n  public toWIF(): string {\n    let buf: Buffer;\n    if (this.compressed) {\n      buf = Buffer.concat([Buffer.from([this.network.privatekey]),\n                          this.bn.toBuffer({size: 32}),\n                          Buffer.from([0x01])]);\n    } else {\n      buf = Buffer.concat([Buffer.from([this.network.privatekey]),\n                          this.bn.toBuffer({size: 32})]);\n    }\n\n    return Base58Check.encode(buf);\n  }\n\n  /**\n   * Will return the private key as a BN instance\n   *\n   * @returns A BN instance of the private key\n   */\n  public toBigNumber(): BN {\n    return this.bn;\n  }\n\n  /**\n   * Will return the private key as a BN buffer\n   *\n   * @returns A buffer of the private key\n   */\n  public toBuffer(): Buffer {\n    return this.bn.toBuffer({size: 32});\n  }\n\n  /**\n   * Will return the private key as a BN buffer without leading zero padding\n   *\n   * @returns A buffer of the private key\n   */\n  public toBufferNoPadding(): Buffer {\n    return this.bn.toBuffer();\n  }\n\n  /**\n   * Will return the corresponding public key\n   *\n   * @returns A public key generated from the private key\n   */\n  public toPublicKey(): PublicKey {\n    if (!this._pubkey) {\n      this._pubkey = PublicKey.fromPrivateKey(this);\n    }\n    return this._pubkey;\n  }\n\n  public toObject = this.toJSON;\n\n  /**\n   * @returns A plain object representation\n   */\n  public toJSON(): PrivateKeyDto {\n    return {\n      bn: this.bn.toString('hex'),\n      compressed: this.compressed,\n      network: this.network.toString()\n    };\n  }\n\n  /**\n   * Will return a string formatted for the console\n   *\n   * @returns Private key details\n   */\n  public inspect(): string {\n    let uncompressed = !this.compressed ? ', uncompressed' : '';\n    return `<PrivateKey: ${this.toString()}, network: ${this.network}${uncompressed}>`;\n  }\n\n  /**\n   * Instantiate a PrivateKey from a Buffer with the DER or WIF representation\n   */\n  public static fromBuffer(buf: Buffer, network?: Networkish): PrivateKey {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), 'First argument is expected to be a buffer.');\n    let data = this._transformBuffer(buf, network);\n    return new PrivateKey(data);\n  }\n\n  public static fromString = this.fromWIF;\n\n  /**\n   * Instantiate a PrivateKey from a WIF string\n   *\n   * @param str - The WIF encoded private key string\n   * @returns A new valid instance of PrivateKey\n   */\n  public static fromWIF(str: string, network?: Networkish): PrivateKey {\n    ValidationUtils.validateArgument(isString(str), 'First argument is expected to be a string.');\n\n    let data: Partial<IPrivateKey>;\n    if (CommonUtils.isHexa(str)) {\n      data = {\n        bn: new BN(Buffer.from(str, 'hex')),\n        compressed: true,\n        network: networks.get(network) || networks.defaultNetwork\n      };\n    } else {\n      data = PrivateKey._transformWIF(str, network);\n    }\n    return new PrivateKey(data);\n  }\n\n  public static fromObject = this.fromJSON;\n\n  /**\n   * Instantiate a PrivateKey from a plain JavaScript object\n   *\n   * @param obj - The output from privateKey.toObject()\n   */\n  public static fromJSON(obj: PrivateKeyDto): PrivateKey {\n    ValidationUtils.validateArgument(isObject(obj), 'First argument is expected to be an object.');\n    let data = this._transformObject(obj);\n    return new PrivateKey(data);\n  }\n\n  /**\n   * Instantiate a PrivateKey from random bytes\n   *\n   * @param network - Either \"mainnet\" or \"testnet\"\n   * @returns A new valid instance of PrivateKey\n   */\n  public static fromRandom(network?: Networkish): PrivateKey {\n    let data = {\n      bn: PrivateKey._getRandomBN(),\n      compressed: true,\n      network: networks.get(network) || networks.defaultNetwork\n    }\n    return new PrivateKey(data);\n  }\n\n  /**\n   * Check if there would be any errors when initializing a PrivateKey\n   *\n   * @param data - The encoded data in various formats\n   * @param network - Either \"mainnet\" or \"testnet\"\n   * @returns An error if exists\n   */\n\n  public static getValidationError(data: PrivateKeyVariants, network?: Networkish): Error | undefined {\n    try {\n      this.from(data, network);\n    } catch (e) {\n      return e as Error;\n    }\n    return undefined;\n  }\n\n  /**\n   * Check if the parameters are valid\n   *\n   * @param data - The encoded data in various formats\n   * @param network - Either \"mainnet\" or \"testnet\"\n   * @returns true If the private key would be valid\n   */\n  public static isValid(data?: PrivateKeyVariants, network?: Networkish): boolean {\n    if (!data) {\n      return false;\n    }\n    return !this.getValidationError(data, network);\n  }\n\n  /**\n   * Helper to instantiate PrivateKey from different kinds of arguments.\n   */\n  public static from(data?: PrivateKeyVariants, network?: Networkish): PrivateKey {\n    // detect type of data\n    if (isNil(data)){\n      return this.fromRandom(network);\n    } else if (data instanceof PrivateKey) {\n      return data;\n    } else if (data instanceof BN) {\n      let info: Partial<IPrivateKey> = {\n        bn: data,\n        compressed: true,\n        network: networks.get(network) || networks.defaultNetwork\n      }\n      return new PrivateKey(info);\n    } else if (BufferUtils.isBuffer(data)) {\n      return this.fromBuffer(data, network);\n    } else if (this._isPrivateKeyParams(data) && data.bn && data.network){\n      return this.fromObject(data);\n    } else if (isString(data)) {\n      return this.fromString(data, network);\n    } else {\n      throw new TypeError('First argument is an unrecognized data type.');\n    }\n  }\n\n  private static _isPrivateKeyParams(data: unknown): data is PrivateKeyDto {\n    return isObject(data) && 'bn' in data && 'network' in data;\n  }\n\n  private static _getRandomBN(): BN {\n    let bn: BN;\n    do {\n      let privbuf = BufferUtils.getRandomBuffer(32);\n      bn = BN.fromBuffer(privbuf);\n    } while (!bn.lt(Point.getN()));\n    return bn;\n  }\n\n  /**\n   * Internal function to transform a WIF Buffer into a private key\n   */\n  private static _transformBuffer(buf: Buffer, network?: Networkish): IPrivateKey {\n    if (buf.length === 32) {\n      return {\n        network: networks.get(network) || networks.defaultNetwork,\n        bn: BN.fromBuffer(buf),\n        compressed: false,\n      } as IPrivateKey;\n    }\n\n    let info: Partial<IPrivateKey> = {};\n\n    info.network = networks.get(buf[0], 'privatekey');\n    if (!info.network) {\n      throw new Error(`Invalid network`);\n    }\n    if (network && info.network !== networks.get(network)) {\n      throw new TypeError('Private key network mismatch');\n    }\n\n    if (buf.length === 1 + 32 + 1 && buf[1 + 32 + 1 - 1] === 1) {\n      info.compressed = true;\n    } else if (buf.length === 1 + 32) {\n      info.compressed = false;\n    } else {\n      throw new Error('Length of buffer must be 33 (uncompressed) or 34 (compressed)');\n    }\n\n    info.bn = BN.fromBuffer(buf.subarray(1, 32 + 1));\n\n    return info as IPrivateKey;\n  }\n\n  /**\n   * Internal function to transform a JSON object into a private key\n   */\n  private static _transformObject(data: PrivateKeyDto): IPrivateKey {\n    return {\n      bn: new BN(data.bn, 'hex'),\n      network: networks.get(data.network) || networks.defaultNetwork,\n      compressed: data.compressed\n    } as IPrivateKey;\n  }\n\n  /**\n   * Internal function to transform a WIF string into a private key\n   */\n  private static _transformWIF(str: string, network?: Networkish): IPrivateKey {\n    return this._transformBuffer(Base58Check.decode(str), network);\n  }\n}","import Hash from \"../crypto/hash\";\nimport Base58 from \"./base58\";\nimport type { BufferParams } from \"../common/interfaces\";\nimport { isString } from \"lodash-es\";\n\nexport default class Base58Check {\n\n  private buf?: Buffer;\n\n  constructor(obj?: Buffer | string | BufferParams) {\n    if (Buffer.isBuffer(obj)) {\n      let buf = obj;\n      this.fromBuffer(buf);\n    } else if (typeof obj === 'string') {\n      let str = obj;\n      this.fromString(str);\n    } else if (obj) {\n      this.set(obj);\n    }\n  }\n\n  public static validChecksum(data: string | Buffer, checksum?: string | Buffer): boolean {\n    if (isString(data)) {\n      data = Buffer.from(Base58.decode(data));\n    }\n    if (isString(checksum)) {\n      checksum =  Buffer.from(Base58.decode(checksum));\n    }\n    if (!checksum) {\n      checksum = data.subarray(-4);\n      data = data.subarray(0, -4);\n    }\n    return Base58Check.checksum(data).toString('hex') === checksum.toString('hex');\n  };\n  \n  public static decode(s: string): Buffer {\n    if (typeof s !== 'string') {\n      throw new Error('Input must be a string');\n    }\n  \n    let buf = Buffer.from(Base58.decode(s));\n  \n    if (buf.length < 4) {\n      throw new Error(\"Input string too short\");\n    }\n\n    let data = buf.subarray(0, -4);\n    let csum = buf.subarray(-4);\n  \n    let hash = Hash.sha256sha256(data);\n    let hash4 = hash.subarray(0, 4);\n  \n    if (csum.toString('hex') !== hash4.toString('hex')) {\n      throw new Error(\"Checksum mismatch\");\n    }\n  \n    return data;\n  }\n  \n  public static checksum(buffer: Buffer): Buffer {\n    return Hash.sha256sha256(buffer).subarray(0, 4);\n  }\n  \n  public static encode(buf: Buffer): string {\n    if (!Buffer.isBuffer(buf))\n      throw new Error('Input must be a buffer');\n    let checkedBuf = Buffer.alloc(buf.length + 4);\n    let hash = Base58Check.checksum(buf);\n    buf.copy(checkedBuf);\n    hash.copy(checkedBuf, buf.length);\n    return Base58.encode(checkedBuf);\n  }\n\n  public toBuffer(): Buffer | undefined {\n    return this.buf;\n  }\n  \n  public toString(): string {\n    return this.buf ? Base58Check.encode(this.buf) : \"\";\n  }\n\n  private fromBuffer(buf: Buffer): this {\n    this.buf = buf;\n    return this;\n  }\n  \n  private fromString(str: string): this {\n    let buf = Base58Check.decode(str);\n    this.buf = buf;\n    return this;\n  }\n\n  private set(obj: BufferParams): this {\n    this.buf = obj.buf || this.buf || undefined;\n    return this;\n  }\n}","import bs58 from 'bs58';\nimport type { BufferParams } from \"../common/interfaces\";\n\nexport default class Base58 {\n\n  private static readonly ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'.split('');\n\n  private buf?: Buffer;\n\n  constructor(obj?: string | Buffer | BufferParams) {\n    if (Buffer.isBuffer(obj)) {\n      let buf = obj;\n      this.fromBuffer(buf);\n    } else if (typeof obj === 'string') {\n      let str = obj;\n      this.fromString(str);\n    } else if (obj) {\n      this.set(obj);\n    }\n  }\n\n  public toBuffer(): Buffer | undefined {\n    return this.buf;\n  }\n  \n  public toString(): string {\n    return this.buf ? Base58.encode(this.buf) : \"\";\n  }\n\n  private fromBuffer(buf: Buffer): this {\n    this.buf = buf;\n    return this;\n  }\n  \n  private fromString(str: string): this {\n    let buf = Base58.decode(str);\n    this.buf = buf;\n    return this;\n  }\n\n  private set(obj: BufferParams): this {\n    this.buf = obj.buf || this.buf || undefined;\n    return this;\n  }\n\n  public static encode(buf: Buffer): string {\n    if (!Buffer.isBuffer(buf)) {\n      throw new Error('Input should be a buffer');\n    }\n    return bs58.encode(buf);\n  }\n\n  public static decode(str: string): Buffer {\n    if (typeof str !== 'string') {\n      throw new Error('Input should be a string');\n    }\n    return Buffer.from(bs58.decode(str));\n  }\n\n  \n  public static validCharacters(chars: Buffer | string): boolean {\n    if (Buffer.isBuffer(chars)) {\n      chars = chars.toString();\n    }\n\n    return chars.split(\"\").every(char => Base58.ALPHABET.includes(char));\n  }\n}","import { isArray, isNil, isString } from \"lodash-es\";\nimport type { Networkish } from \"../../common/types\";\nimport ValidationUtils from \"../../utils/validation.utils\";\nimport { networks } from \"../network/network-manager\";\nimport AddressFormatter, { AddressType } from \"./address-formatter\";\nimport type { Network } from \"../network/network\";\nimport type { AddressDto } from \"../../common/interfaces\";\nimport CommonUtils from \"../../utils/common.utils\";\nimport PublicKey from \"../../keys/publickey\";\nimport Hash from \"../../crypto/hash\";\nimport Script from \"../script/script\";\nimport type { ScriptElement } from \"../script/script\";\nimport { Opcode } from \"../script/opcode\";\nimport BufferUtils from \"../../utils/buffer.utils\";\nimport BufferWriter from \"../../encoding/bufferwriter\";\n\nexport default class Address {\n\n  public readonly data!: Buffer;\n  public readonly network!: Network;\n  public readonly type!: AddressType;\n\n  /* c8 ignore start */\n  /** @deprecated use data */\n  public get hashBuffer(): Buffer {\n    return this.data;\n  }\n  /* c8 ignore stop */\n\n  /**\n   * Instantiate an address from an address String or Buffer, a public key or script hash Buffer,\n   * or an instance of {@link PublicKey} or {@link Script}.\n   *\n   * This is an immutable class, and if the first parameter provided to this constructor is an\n   * `Address` instance, the same argument will be returned.\n   *\n   * An address has two key properties: `network` and `type`. The type is either\n   * `AddressType.PayToPublicKeyHash` (value is the `'P2PKH'` string)\n   * or `AddressType.PayToScriptTemplate` (the string `'P2ST'`). The network is an instance of {@link Network} or network name.\n   * You can quickly check whether an address is of a given kind by using the methods\n   * `isPayToPublicKeyHash` and `isPayToScriptTemplate`\n   *\n   * @example\n   * ```javascript\n   * // validate that an input field is valid\n   * let error = Address.getValidationError(input, 'testnet');\n   * if (!error) {\n   *   let address = new Address(input, 'testnet');\n   * } else {\n   *   // invalid network or checksum (typo?)\n   *   let message = error.messsage;\n   * }\n   *\n   * // get an address from a public key\n   * let address = Address.fromPublicKey(publicKey, 'testnet').toString();\n   * ```\n   *\n   * @param data The encoded data in various formats\n   * @param network The network: 'mainnet' (default) or 'testnet'\n   * @param type The type of address: 'P2ST' (default) or 'P2PKH' or 'GROUP'\n   * @returns A new valid and frozen instance of an Address\n   */\n  constructor(data: Address | string | Buffer, network?: Networkish, type?: AddressType) {\n    ValidationUtils.validateArgument(!isNil(data), 'First argument is required, please include address data.');\n\n    if (data instanceof Address) {\n      return data; // Immutable instance\n    }\n\n    if (isString(data)) {\n      return Address.fromString(data);\n    }\n\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(data), \"data must be Address, string or Buffer\");\n\n    Address.validateParams(network, type);\n\n    this.data = data;\n    this.network = networks.get(network) || networks.defaultNetwork;\n    this.type = type || AddressType.PayToScriptTemplate;\n  }\n\n  public static validateParams(network?: Networkish, type?: AddressType): void {\n    if (network && !networks.get(network)) {\n      throw new TypeError('Second argument must be \"mainnet\" or \"testnet\".');\n    }\n  \n    if (type && (type !== AddressType.PayToScriptTemplate && type !== AddressType.GroupIdAddress && type !== AddressType.PayToPublicKeyHash)) {\n      throw new TypeError('Third argument must be \"P2ST\", \"P2PKH\" or \"GROUP\"');\n    }\n  }\n\n  /**\n   * @param address string\n   * \n   * @returns A new valid and frozen instance of an Address\n   */\n  public static fromString(address: string): Address {\n    ValidationUtils.validateArgument(isString(address), 'parameter supplied is not a string.');\n    ValidationUtils.validateArgument(address.length > 34, 'Invalid Address string provided');\n\n    let parts = AddressFormatter.decode(address);\n    let network = networks.get(parts.prefix, 'prefix');\n    return new Address(parts.data, network, parts.type);\n  }\n\n  /** @deprecated use fromString */\n  public static decodeNexaAddress = this.fromString;\n\n  /**\n   * Will return a cashaddr representation of the address. Always return lower case\n   * Can be converted by the caller to uppercase is needed (still valid).\n   *\n   * @returns Nexa address\n   */\n  public toString(): string {\n    return AddressFormatter.encode(this.network.prefix, this.type, this.data);\n  }\n\n  /** @deprecated use toString */\n  public toNexaAddress = this.toString;\n\n  /**\n   * Will return a string formatted for the console\n   *\n   * @returns {string} Bitcoin address\n   */\n  public inspect(): string {\n    return `<Address: ${this}, type: ${this.type}, network: ${this.network}>`;\n  }\n\n  /**\n   * Instantiate an address from an Object\n   *\n   * @param obj - A JSON object with keys: data, network and type\n   * @returns A new valid instance of an Address\n   */\n  public static fromObject(obj: AddressDto): Address {\n    ValidationUtils.validateArgument(isString(obj?.data), 'Must provide a `data` property');\n    ValidationUtils.validateArgument(isString(obj?.type), 'Must provide a `type` property');\n    ValidationUtils.validateState(CommonUtils.isHexa(obj.data), `Unexpected data property, expected to be hex.`);\n\n    let hashBuffer = Buffer.from(obj.data, 'hex');\n    return new Address(hashBuffer, obj.network, obj.type as AddressType);\n  }\n\n  /**\n   * @returns A plain object with the address information\n   */\n  public toJSON(): AddressDto {\n    return {\n      data: this.data.toString('hex'),\n      type: this.type,\n      network: this.network.toString()\n    };\n  }\n\n  public toObject = this.toJSON;\n\n  /**\n   * @return true if an address is of pay to public key hash type\n   */\n  public isPayToPublicKeyHash(): boolean {\n    return this.type === AddressType.PayToPublicKeyHash;\n  }\n\n  /**\n   * @return true if an address is of pay to script template type\n   */\n  public isPayToScriptTemplate(): boolean {\n    return this.type === AddressType.PayToScriptTemplate;\n  }\n\n  /**\n   * @return true if an address is a group token address\n   */\n  public isGroupIdentifierAddress(): boolean {\n    return this.type === AddressType.GroupIdAddress;\n  }\n\n  /**\n   * Will return a validation error if exists\n   *\n   * @example\n   * ```javascript\n   * // a network mismatch error\n   * let error = Address.getValidationError('nexatest:nqtsq5g567x44x5g54t2wsxz60zwqmyks63rkrddl4stwnzu', 'testnet');\n   * ```\n   *\n   * @param data The encoded data\n   * @param network either a Network instance, 'mainnet', or 'testnet'\n   * @param type The type of address: 'P2ST' or 'GROUP' or 'P2PKH'\n   * @returns The corresponding error message\n   */\n  public static getValidationError(data: string | Buffer, network?: Networkish, type?: AddressType): Error | undefined {\n    try {\n      if (isString(data)) {\n        let addr = Address.fromString(data);\n        data = addr.data;\n\n        if (network && networks.get(network)?.prefix !== addr.network.prefix) {\n          throw new Error('Address has mismatched network type.');\n        }\n        network = addr.network;\n\n        if (type && type !== addr.type) {\n          throw new Error('Address has mismatched type.');\n        }\n        type = addr.type;\n      }\n      this.validateParams(network, type);\n      AddressFormatter.encode(networks.get(network)?.prefix || networks.defaultNetwork.prefix, type || AddressType.PayToScriptTemplate, data);\n    } catch (e) {\n      return e as Error;\n    }\n  }\n\n  /**\n   * Will return a boolean if an address is valid\n   *\n   * @example\n   * ```javascript\n   * assert(Address.isValid('nexa:nqtsq5g567x44x5g54t2wsxz60zwqmyks63rkrddsfq94pd2', 'mainned'));\n   * ```\n   *\n   * @param data The encoded data\n   * @param network either a Network instance, 'mainnet', or 'testnet'\n   * @param type The type of address: 'P2ST' or 'GROUP' or 'P2PKH'\n   * @returns true if valid\n   */\n  public static isValid(data: string | Buffer, network?: Networkish, type?: AddressType): boolean {\n    return !Address.getValidationError(data, network, type);\n  }\n\n  /**\n   * Instantiate an address from a PublicKey instance\n   *\n   * @param pubkey the public key instance\n   * @param network either a Network instance, 'mainnet' or 'testnet'\n   * @param type address encoding type\n   * @returns A new valid and frozen instance of an Address\n   */\n  public static fromPublicKey(pubkey: PublicKey, network?: Networkish, type?: AddressType): Address {\n    let data = this._transformPublicKey(pubkey, type);\n    return new Address(data, network, type);\n  }\n\n  /**\n   * Instantiate an address from a non grouped script template\n   *\n   * @param templateHash An instance of a template hash Buffer\n   * @param constraintHash An instance of a constraint hash Buffer\n   * @param visibleArgs An array of push-only args, or hex string represent script buffer, or Script with push args\n   * @param network either a Network instance, 'mainnet' or 'testnet'\n   * @returns A new valid and frozen instance of an Address\n   */\n  public static fromScriptTemplate(templateHash: Buffer | Opcode, constraintHash: Buffer | Opcode, visibleArgs?: string | Script | ScriptElement[], network?: Networkish): Address {\n    let data = Address._transformScriptTemplate(templateHash, constraintHash, visibleArgs);\n    return new Address(data, network, AddressType.PayToScriptTemplate);\n  }\n\n  /**\n   * Internal function to transform a {@link PublicKey}\n   */\n  private static _transformPublicKey(pubkey: PublicKey, type = AddressType.PayToScriptTemplate): Buffer {\n    ValidationUtils.validateArgument(pubkey instanceof PublicKey, 'Address must be an instance of PublicKey.')\n\n    if (type === AddressType.PayToPublicKeyHash) {\n      return Hash.sha256ripemd160(pubkey.toBuffer());\n    } else if (type === AddressType.PayToScriptTemplate) {\n      let constraint = Script.empty().add(pubkey.toBuffer());\n      let constraintHash = Hash.sha256ripemd160(constraint.toBuffer());\n      return Address._transformScriptTemplate(Opcode.OP_1, constraintHash);\n    } else {\n      throw new Error(\"type must be P2ST or P2PKH\");\n    }\n  }\n\n  /**\n   * Internal function to transform a Script Template params\n   */\n  private static _transformScriptTemplate(templateHash: Buffer | Opcode, constraintHash: Buffer | Opcode, visibleArgs?: string | Script | ScriptElement[]): Buffer {\n    if (templateHash != Opcode.OP_1 && !BufferUtils.isHashBuffer(templateHash)) {\n      throw new TypeError('templateHash supplied is not a hash buffer or well-known OP_1.');\n    }\n    if (constraintHash != Opcode.OP_FALSE && !BufferUtils.isHashBuffer(constraintHash)) {\n      throw new TypeError('constraintHash supplied is not a hash buffer or OP_FALSE.');\n    }\n\n    let scriptTemplate = Script.empty().add(Opcode.OP_FALSE).add(templateHash).add(constraintHash);\n    if (visibleArgs) {\n      if (isArray(visibleArgs)) {\n        visibleArgs.forEach(arg => scriptTemplate.add(arg));\n      } else if (visibleArgs instanceof Script) {\n        scriptTemplate.add(visibleArgs);\n      } else if (CommonUtils.isHexa(visibleArgs)) {\n        scriptTemplate.add(Script.fromHex(visibleArgs));\n      }\n    }\n\n    return new BufferWriter().writeVarLengthBuf(scriptTemplate.toBuffer()).toBuffer();\n  }\n\n  /**\n   * Will return the transaction output type by the address type\n   * \n   * @param address as string\n   * @returns 1 - Template, 0 - otherwise\n   */\n  public static getOutputType(address: string): number {\n    return this.fromString(address).getOutputType();\n  }\n\n  /**\n   * Will return the transaction output type by the address type\n   * \n   * @returns 1 - Template, 0 - otherwise\n   */\n  public getOutputType(): number {\n    return this.isPayToScriptTemplate() ? 1 : 0;\n  }\n}","import Base32 from \"../../encoding/base32\";\nimport BufferUtils from \"../../utils/buffer.utils\";\nimport ValidationUtils from \"../../utils/validation.utils\";\n\nexport enum AddressType {\n  PayToPublicKeyHash = 'P2PKH',\n  PayToScriptTemplate = 'P2ST',\n  GroupIdAddress = 'GROUP'\n}\n\ninterface AddressParts {\n  prefix: string;\n  type: AddressType;\n  data: Buffer;\n}\n\nexport default class AddressFormatter {\n\n  private static readonly VALID_PREFIXES = ['nexa', 'nexatest'];\n  \n  /** @see encodeAddress */\n  public static encode(prefix: string, type: AddressType, data: Buffer): string {\n    return this.encodeAddress({ prefix, type, data })\n  }\n\n  /**\n   * Encodes a hash from a given type into a Nexa address with the given prefix.\n   *\n   * @param address Object contains Network prefix (E.g.: 'nexa'), Type of address to generate and data to encode.\n   */\n  public static encodeAddress(address: AddressParts): string {\n    ValidationUtils.validateArgument(typeof address.prefix === 'string' && this.isValidPrefix(address.prefix), 'Invalid prefix: ' + address.prefix + '.');\n    ValidationUtils.validateArgument(typeof address.type === 'string', 'Invalid type: ' + address.type + '.');\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(address.data), 'Invalid data: ' + address.data + '.');\n\n    let eight0 = [0,0,0,0, 0,0,0,0];\n    let prefixData = this.prefixToArray(address.prefix).concat([0]);\n    let versionByte = this.getTypeBits(address.type);\n    let payloadData = this.convertBits(Buffer.concat([Buffer.from([versionByte]), address.data]), 8, 5);\n    let checksumData = prefixData.concat(payloadData).concat(eight0);\n    let payload = payloadData.concat(this.checksumToArray(this.polymod(checksumData)));\n    return address.prefix + ':' + Base32.encode(payload);\n  }\n\n  /**\n   * Decodes the given address into its constituting prefix, type and data. See {@link encodeAddress}.\n   *\n   * @param {string} address Address to decode. E.g.: 'nexa:qpm2qsznhks23z7629mms6s4cwef74vcwvgpsey0xy'.\n   */\n  public static decode(address: string): AddressParts {\n    ValidationUtils.validateArgument(typeof address === 'string' && this.hasSingleCase(address), 'Invalid address: ' + address + '.');\n\n    let pieces = address.toLowerCase().split(':');\n    ValidationUtils.validateState(pieces.length === 2, 'Missing prefix: ' + address + '.');\n    \n    let prefix = pieces[0];\n    let payload = Base32.decode(pieces[1]);\n    ValidationUtils.validateState(this.validChecksum(prefix, payload), 'Invalid checksum: ' + address + '.');\n\n    let convertedBits = this.convertBits(payload.slice(0, -8), 5, 8, true);\n    let versionByte = convertedBits.shift();\n    let hash = convertedBits;\n    // no length limits in nexa: validate(getHashSize(versionByte) === hash.length * 8, 'Invalid hash size: ' + address + '.');\n    let type = this.getType(versionByte!);\n    \n    return {\n      prefix: prefix,\n      type: type,\n      data: Buffer.from(hash),\n    };\n  }\n\n  /**\n   * Checks whether a string is a valid prefix; ie., it has a single letter case\n   * and is one of the above.\n   * \n   * @param prefix\n   */\n  private static isValidPrefix(prefix: string): boolean {\n    return this.hasSingleCase(prefix) && this.VALID_PREFIXES.includes(prefix.toLowerCase());\n  }\n\n  /**\n   * Derives an array from the given prefix to be used in the computation\n   * of the address' checksum.\n   *\n   * @param prefix Network prefix. E.g.: 'nexa'.\n   */\n  private static prefixToArray(prefix: string): number[] {\n    let result: number[] = [];\n    for (let i = 0; i < prefix.length; ++i) {\n      result.push(prefix.charCodeAt(i) & 31);\n    }\n    return result;\n  }\n\n  /**\n   * Returns an array representation of the given checksum to be encoded\n   * within the address' payload.\n   *\n   * @param checksum Computed checksum.\n   */\n  private static checksumToArray(checksum: number): number[] {\n    let result: number[] = [];\n    for (let i = 0; i < 8; ++i) {\n      result.push(checksum & 31);\n      checksum /= 32;\n    }\n    return result.reverse();\n  }\n\n  /**\n   * Returns the bit representation of the given type within the version byte.\n   *\n   * @param type Address type. Either 'P2PKH' or 'P2SH'.\n   */\n  private static getTypeBits(type: AddressType): number {\n    switch (type) {\n      case AddressType.PayToPublicKeyHash:\n        return 0;\n      case AddressType.PayToScriptTemplate:\n        return 19<<3;\n      case AddressType.GroupIdAddress:\n        return 11<<3;\n      default:\n        throw new TypeError('Invalid type: ' + type + '.');\n    }\n  }\n\n  /**\n   * Retrieves the address type from its bit representation within the\n   * version byte.\n   *\n   * @param versionByte\n   */\n  private static getType(versionByte: number): AddressType {\n    switch (versionByte & 248) {\n      case 0:\n        return AddressType.PayToPublicKeyHash;\n      case 19<<3:\n        return AddressType.PayToScriptTemplate;\n      case 11<<3:\n        return AddressType.GroupIdAddress;\n      default:\n        throw new Error('Invalid address type in version byte: ' + versionByte + '.');\n    }\n  }\n\n  /**\n   * Returns true if, and only if, the given string contains either uppercase\n   * or lowercase letters, but not both.\n   *\n   * @param string Input string.\n   */\n  private static hasSingleCase(string: string): boolean {\n    return string === string.toLowerCase() || string === string.toUpperCase();\n  }\n\n  /**\n  * Verify that the payload has not been corrupted by checking that the\n  * checksum is valid.\n  *\n  * @param prefix Network prefix. E.g.: 'nexa'.\n  * @param payload Array of 5-bit integers containing the address' payload.\n  */\n  private static validChecksum(prefix: string, payload: number[]): boolean {\n    let prefixData = this.prefixToArray(prefix).concat([0]);\n    return this.polymod(prefixData.concat(payload)) === 0;\n  }\n\n  /**\n   * Computes a checksum from the given input data as specified for the CashAddr\n   * format: https://github.com/Bitcoin-UAHF/spec/blob/master/cashaddr.md.\n   *\n   * @param data Array of 5-bit integers over which the checksum is to be computed.\n   */\n  private static polymod(data: number[]): number {\n    let GENERATOR1 = [0x98, 0x79, 0xf3, 0xae, 0x1e];\n    let GENERATOR2 = [0xf2bc8e61, 0xb76d99e2, 0x3e5fb3c4, 0x2eabe2a8, 0x4f43e470];\n    // Treat c as 8 bits + 32 bits\n    let c0 = 0, c1 = 1, C = 0;\n    for (let j = 0; j < data.length; j++) {\n      // Set C to c shifted by 35\n      C = c0 >>> 3;\n      // 0x[07]ffffffff\n      c0 &= 0x07;\n      // Shift as a whole number\n      c0 <<= 5;\n      c0 |= c1 >>> 27;\n      // 0xffffffff >>> 5\n      c1 &= 0x07ffffff;\n      c1 <<= 5;\n      // xor the last 5 bits\n      c1 ^= data[j];\n      for (let i = 0; i < GENERATOR1.length; ++i) {\n        if (C & (1 << i)) {\n          c0 ^= GENERATOR1[i];\n          c1 ^= GENERATOR2[i];\n        }\n      }\n    }\n    c1 ^= 1;\n    // Negative numbers -> large positive numbers\n    if (c1 < 0) {\n      c1 ^= 1 << 31;\n      c1 += (1 << 30) * 2;\n    }\n    // Unless bitwise operations are used,\n    // numbers are consisting of 52 bits, except\n    // the sign bit. The result is max 40 bits,\n    // so it fits perfectly in one number!\n    return c0 * (1 << 30) * 4 + c1;\n  }\n\n  /**\n   * Converts an array of integers made up of `from` bits into an\n   * array of integers made up of `to` bits. The output array is\n   * zero-padded if necessary, unless strict mode is true.\n   * Original by Pieter Wuille: https://github.com/sipa/bech32.\n   *\n   * @param data Array of integers made up of `from` bits.\n   * @param from Length in bits of elements in the input array.\n   * @param to Length in bits of elements in the output array.\n   * @param strict Require the conversion to be completed without padding.\n   */\n  private static convertBits(data: Buffer | number[], from: number, to: number, strict = false): number[] {\n    let accumulator = 0;\n    let bits = 0;\n    let result = [];\n    let mask = (1 << to) - 1;\n    for (let i=0; i<data.length; i++) {\n      let value = data[i];\n      ValidationUtils.validateArgument(!(value < 0 || (value >> from) !== 0), 'value ' + value);\n  \n      accumulator = (accumulator << from) | value;\n      bits += from;\n      while (bits >= to) {\n        bits -= to;\n        result.push((accumulator >> bits) & mask);\n      }\n    }\n    if (!strict) {\n      if (bits > 0) {\n        result.push((accumulator << (to - bits)) & mask);\n      }\n    } else {\n      ValidationUtils.validateState(!(bits >= from || ((accumulator << (to - bits)) & mask)),  'Conversion requires padding but strict mode was used');\n    }\n    return result;\n  }\n}","import ValidationUtils from \"../utils/validation.utils\";\n\nexport default class Base32 {\n  /***\n   * Charset containing the 32 symbols used in the base32 encoding.\n   */\n  private static readonly CHARSET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';\n\n  /***\n   * Inverted index mapping each symbol into its index within the charset.\n   */\n  private static readonly CHARSET_INVERSE_INDEX = {\n    'q': 0, 'p': 1, 'z': 2, 'r': 3, 'y': 4, '9': 5, 'x': 6, '8': 7,\n    'g': 8, 'f': 9, '2': 10, 't': 11, 'v': 12, 'd': 13, 'w': 14, '0': 15,\n    's': 16, '3': 17, 'j': 18, 'n': 19, '5': 20, '4': 21, 'k': 22, 'h': 23,\n    'c': 24, 'e': 25, '6': 26, 'm': 27, 'u': 28, 'a': 29, '7': 30, 'l': 31,\n  }\n\n  /***\n   * Encodes the given array of 5-bit integers as a base32-encoded string.\n   *\n   * @param data Array of integers between 0 and 31 inclusive.\n   */\n  public static encode(data: number[]): string {\n    ValidationUtils.validateArgument(data instanceof Array, 'Must be Array');\n    let base32 = '';\n    data.forEach(value => {\n      ValidationUtils.validateArgument(0 <= value && value < 32, 'value ' + value);\n      base32 += this.CHARSET[value];\n    });\n    return base32;\n  }\n\n  /***\n   * Decodes the given base32-encoded string into an array of 5-bit integers.\n   *\n   * @param base32 \n   */\n  public static decode(base32: string): number[] {\n    ValidationUtils.validateArgument(typeof base32 === 'string', 'Must be base32-encoded string');\n    let data: number[] = [];\n    for (let value of base32) {\n      ValidationUtils.validateArgument(value in this.CHARSET_INVERSE_INDEX, 'value '+ value);\n      data.push(this.CHARSET_INVERSE_INDEX[value as keyof typeof this.CHARSET_INVERSE_INDEX]);\n    }\n    return data;\n  }\n}","import { inRange, isArray, isObject, isString, isUndefined } from \"lodash-es\";\nimport type { IScript, ScriptChunk } from \"../../common/interfaces\";\nimport BufferUtils from \"../../utils/buffer.utils\";\nimport ValidationUtils from \"../../utils/validation.utils\";\nimport BufferReader from \"../../encoding/bufferreader\";\nimport BufferWriter from \"../../encoding/bufferwriter\";\nimport ScriptOpcode, { Opcode } from \"./opcode\";\nimport CommonUtils from \"../../utils/common.utils\";\nimport BN from \"../../crypto/bn.extension\";\n\nexport type ScriptElement = string | number | bigint | boolean | Buffer | ScriptOpcode | ScriptChunk | Script;\n\n/**\n * A nexa transaction script. Each transaction's inputs and outputs\n * has a script that is evaluated to validate it's spending.\n *\n * @see {@link https://spec.nexa.org/script/1script/}\n */\nexport default class Script implements IScript {\n\n  chunks: ScriptChunk[];\n\n  constructor(from?: Buffer | string | IScript) {\n    this.chunks = [];\n\n    if (!from) {\n      return;\n    }\n\n    if (BufferUtils.isBuffer(from)) {\n      return Script.fromBuffer(from);\n    } else if (from instanceof Script) {\n      return Script.fromBuffer(from.toBuffer());\n    } else if (isString(from)) {\n      return Script.fromString(from);\n    } else if (Script._isScriptObject(from)) {\n      this.set(from);\n    }\n  }\n\n  private static _isScriptObject(obj: unknown): obj is IScript {\n    return isObject(obj) && 'chunks' in obj && isArray(obj.chunks);\n  }\n\n  private static _isScriptChunk(obj: unknown): obj is ScriptChunk {\n    return isObject(obj) && 'opcodenum' in obj;\n  }\n\n  public set(obj: IScript): this {\n    ValidationUtils.validateArgument(Script._isScriptObject(obj), 'obj');\n    this.chunks = obj.chunks;\n    return this;\n  }\n\n  /**\n  * @returns a new empty script\n  */\n  public static empty(): Script {\n   return new Script();\n  }\n\n  public static fromBuffer(buffer: Buffer): Script {\n    let script = new Script();\n    script.chunks = [];\n  \n    let br = new BufferReader(buffer);\n    while (!br.finished()) {\n      try {\n        let opcodenum = br.readUInt8();\n  \n        let len, buf;\n        if (opcodenum > 0 && opcodenum < Opcode.OP_PUSHDATA1) {\n          len = opcodenum;\n          script.chunks.push({\n            buf: br.read(len),\n            len: len,\n            opcodenum: opcodenum\n          });\n        } else if (opcodenum === Opcode.OP_PUSHDATA1) {\n          len = br.readUInt8();\n          buf = br.read(len);\n          script.chunks.push({\n            buf: buf,\n            len: len,\n            opcodenum: opcodenum\n          });\n        } else if (opcodenum === Opcode.OP_PUSHDATA2) {\n          len = br.readUInt16LE();\n          buf = br.read(len);\n          script.chunks.push({\n            buf: buf,\n            len: len,\n            opcodenum: opcodenum\n          });\n        } else if (opcodenum === Opcode.OP_PUSHDATA4) {\n          len = br.readUInt32LE();\n          buf = br.read(len);\n          script.chunks.push({\n            buf: buf,\n            len: len,\n            opcodenum: opcodenum\n          });\n        } else {\n          script.chunks.push({\n            opcodenum: opcodenum\n          });\n        }\n      } catch (e) {\n        throw e instanceof RangeError ? new Error(`Invalid script buffer: can't parse valid script from given buffer ${buffer.toString('hex')}`) : e;\n      }\n    }\n  \n    return script;\n  }\n  \n  public toBuffer(): Buffer {\n    let bw = new BufferWriter();\n\n    this.chunks.forEach(chunk => {\n      bw.writeUInt8(chunk.opcodenum);\n      if (chunk.buf) {\n        if (chunk.opcodenum < Opcode.OP_PUSHDATA1) {\n          bw.write(chunk.buf);\n        } else if (chunk.opcodenum === Opcode.OP_PUSHDATA1) {\n          bw.writeUInt8(chunk.len!);\n          bw.write(chunk.buf);\n        } else if (chunk.opcodenum === Opcode.OP_PUSHDATA2) {\n          bw.writeUInt16LE(chunk.len!);\n          bw.write(chunk.buf);\n        } else if (chunk.opcodenum === Opcode.OP_PUSHDATA4) {\n          bw.writeUInt32LE(chunk.len!);\n          bw.write(chunk.buf);\n        }\n      }\n    });\n  \n    return bw.concat();\n  }\n\n  public static fromHex(str: string): Script {\n    return new Script(Buffer.from(str, 'hex'));\n  }\n\n  public static fromString(str: string): Script {\n    if (CommonUtils.isHexa(str) || str.length === 0) {\n      return this.fromHex(str);\n    }\n\n    let script = new Script();\n    script.chunks = [];\n  \n    let tokens = str.split(' ');\n    let i = 0;\n    while (i < tokens.length) {\n      let token = tokens[i];\n      let opcode = new ScriptOpcode(token);\n      let opcodenum = opcode.toNumber();\n  \n      if (isUndefined(opcodenum)) {\n        opcodenum = parseInt(token);\n        if (opcodenum > 0 && opcodenum < Opcode.OP_PUSHDATA1) {\n          script.chunks.push({\n            buf: Buffer.from(tokens[i + 1].slice(2), 'hex'),\n            len: opcodenum,\n            opcodenum: opcodenum\n          });\n          i = i + 2;\n        } else {\n          throw new Error('Invalid script: ' + JSON.stringify(str));\n        }\n      } else if (opcodenum === Opcode.OP_PUSHDATA1 ||\n        opcodenum === Opcode.OP_PUSHDATA2 ||\n        opcodenum === Opcode.OP_PUSHDATA4) {\n        if (tokens[i + 2].slice(0, 2) !== '0x') {\n          throw new Error('Pushdata data must start with 0x');\n        }\n        script.chunks.push({\n          buf: Buffer.from(tokens[i + 2].slice(2), 'hex'),\n          len: parseInt(tokens[i + 1]),\n          opcodenum: opcodenum\n        });\n        i = i + 3;\n      } else {\n        script.chunks.push({\n          opcodenum: opcodenum\n        });\n        i = i + 1;\n      }\n    }\n    return script;\n  }\n\n  public static fromASM(str: string): Script {\n    let script = new Script();\n    script.chunks = [];\n  \n    let tokens = str.split(' ');\n    let i = 0;\n    while (i < tokens.length) {\n      let token = tokens[i];\n      let opcode = new ScriptOpcode(token);\n      let opcodenum = opcode.toNumber();\n  \n      if (isUndefined(opcodenum)) {\n        let buf = Buffer.from(tokens[i], 'hex');\n        let len = buf.length;\n        if (len >= 0 && len < Opcode.OP_PUSHDATA1) {\n          opcodenum = len;\n        } else if (len < Math.pow(2, 8)) {\n          opcodenum = Opcode.OP_PUSHDATA1;\n        } else if (len < Math.pow(2, 16)) {\n          opcodenum = Opcode.OP_PUSHDATA2;\n        } else if (len < Math.pow(2, 32)) {\n          opcodenum = Opcode.OP_PUSHDATA4;\n        }\n        script.chunks.push({\n          buf: buf,\n          len: buf.length,\n          opcodenum: opcodenum\n        });\n        i = i + 1;\n      } else {\n        script.chunks.push({\n          opcodenum: opcodenum\n        });\n        i = i + 1;\n      }\n    }\n    return script;\n  }\n\n  private static _chunkToString(chunk: ScriptChunk, toASM = false): string {\n    let opcodenum = chunk.opcodenum;\n    let str = '';\n    if (!chunk.buf) {\n      // no data chunk\n      if (typeof Opcode[opcodenum] !== 'undefined') {\n        if (toASM) {\n          // A few cases where the opcode name differs from reverseMap\n          // aside from 1 to 16 data pushes.\n          if (opcodenum === 0) {\n            // OP_0 -> 0\n            str = str + ' 0';\n          } else if(opcodenum === 79) {\n            // OP_1NEGATE -> 1\n            str = str + ' -1';\n          } else {\n            str = str + ' ' + new ScriptOpcode(opcodenum).toString();\n          }\n        } else {\n          str = str + ' ' + new ScriptOpcode(opcodenum).toString();\n        }\n      } else {\n        let numstr = opcodenum.toString(16);\n        if (numstr.length % 2 !== 0) {\n          numstr = '0' + numstr;\n        }\n        if (toASM) {\n          str = str + ' ' + numstr;\n        } else {\n          str = str + ' ' + '0x' + numstr;\n        }\n      }\n    } else {\n      // data chunk\n      if (!toASM && (opcodenum === Opcode.OP_PUSHDATA1 ||\n        opcodenum === Opcode.OP_PUSHDATA2 ||\n        opcodenum === Opcode.OP_PUSHDATA4)) {\n        str = str + ' ' + new ScriptOpcode(opcodenum).toString();\n      }\n      if (chunk.len! > 0) {\n        if (toASM) {\n          str = str + ' ' + chunk.buf.toString('hex');\n        } else {\n          str = str + ' ' + chunk.len + ' ' + '0x' + chunk.buf.toString('hex');\n        }\n      }\n    }\n    return str;\n  }\n\n  public toASM(): string {\n    return this.chunks.map(chunk => Script._chunkToString(chunk, true)).join('').substring(1);\n  }\n  \n  public toString(): string {\n    return this.chunks.map(chunk => Script._chunkToString(chunk)).join('').substring(1);\n  }\n  \n  public toHex(): string {\n    return this.toBuffer().toString('hex');\n  }\n  \n  public inspect(): string {\n    return `<Script: ${this}>`;\n  }\n\n  /**\n   * Adds a script element to the end of the script.\n   *\n   * @param param a script element to add\n   * @returns this script instance\n   *\n   */\n  public add(param: ScriptElement): this {\n    this._addByType(param, false);\n    return this;\n  }\n\n  public append = this.add;\n\n  /**\n   * Adds a script element at the start of the script.\n   * @param param a script element to add\n   * @returns this script instance\n   */\n  public prepend(param: ScriptElement): this {\n    this._addByType(param, true);\n    return this;\n  }\n\n  private _addByType(obj: ScriptElement, prepend: boolean): void {\n    if (typeof obj === 'string') {\n      this._addOpcode(obj, prepend);\n    } else if (typeof obj === 'number') {\n      this._addOpcode(obj, prepend);\n    } else if (obj instanceof ScriptOpcode) {\n      this._addOpcode(obj, prepend);\n    } else if (typeof obj === 'bigint') {\n      if (obj <= 16n) {\n        this._addOpcode(ScriptOpcode.smallInt(Number(obj)), prepend);\n      } else if (obj === 0x81n) {\n        this._addOpcode(Opcode.OP_1NEGATE, prepend);\n      } else {\n        this._addBuffer(new BN(obj.toString()).toScriptNumBuffer(), prepend);\n      }\n    } else if (typeof obj === 'boolean') {\n      this._addOpcode(obj ? Opcode.OP_TRUE : Opcode.OP_FALSE, prepend);\n    } else if (BufferUtils.isBuffer(obj)) {\n      this._addBuffer(obj, prepend);\n    } else if (obj instanceof Script) {\n      this.chunks = this.chunks.concat(obj.chunks);\n    } else if (Script._isScriptChunk(obj)) {\n      this._insertAtPosition(obj, prepend);\n    } else {\n      throw new Error('Invalid script chunk');\n    }\n  }\n\n  private _insertAtPosition(chunk: ScriptChunk, prepend: boolean): void {\n    if (prepend) {\n      this.chunks.unshift(chunk);\n    } else {\n      this.chunks.push(chunk);\n    }\n  }\n\n  private _addOpcode(opcode: string | number | ScriptOpcode, prepend: boolean): this {\n    let op: number;\n    if (typeof opcode === 'number') {\n      op = opcode;\n    } else if (opcode instanceof ScriptOpcode) {\n      op = opcode.toNumber();\n    } else {\n      op = new ScriptOpcode(opcode).toNumber();\n    }\n    this._insertAtPosition({ opcodenum: op }, prepend);\n    return this;\n  }\n  \n  private _addBuffer(buf: Buffer, prepend: boolean): this {\n    let opcodenum;\n    let len = buf.length;\n    if (len >= 0 && len < Opcode.OP_PUSHDATA1) {\n      opcodenum = len;\n    } else if (len < Math.pow(2, 8)) {\n      opcodenum = Opcode.OP_PUSHDATA1;\n    } else if (len < Math.pow(2, 16)) {\n      opcodenum = Opcode.OP_PUSHDATA2;\n    } else if (len < Math.pow(2, 32)) {\n      opcodenum = Opcode.OP_PUSHDATA4;\n    } else {\n      throw new Error(\"You can't push that much data\");\n    }\n    this._insertAtPosition({\n      buf: buf,\n      len: len,\n      opcodenum: opcodenum\n    }, prepend);\n    return this;\n  }\n\n  /**\n   * Compares a script with another script\n   */\n  public equals(script: Script): boolean {\n    ValidationUtils.validateState(script instanceof Script, 'Must provide another script');\n    if (this.chunks.length !== script.chunks.length) {\n      return false;\n    }\n\n    for (let i = 0; i < this.chunks.length; i++) {\n      if (BufferUtils.isBuffer(this.chunks[i].buf) && !BufferUtils.isBuffer(script.chunks[i].buf)) {\n        return false;\n      }\n      if (BufferUtils.isBuffer(this.chunks[i].buf) && !this.chunks[i].buf!.equals(script.chunks[i].buf!)) {\n        return false;\n      } else if (this.chunks[i].opcodenum !== script.chunks[i].opcodenum) {\n        return false;\n      }\n    }\n    return true;\n  }\n\n  /**\n   * Analogous to nexad's FindAndDelete. Find and delete equivalent chunks,\n   * typically used with push data chunks. Note that this will find and delete\n   * not just the same data, but the same data with the same push data op as\n   * produced by default. i.e., if a pushdata in a tx does not use the minimal\n   * pushdata op, then when you try to remove the data it is pushing, it will not\n   * be removed, because they do not use the same pushdata op.\n   */\n  public findAndDelete(script: Script): this {\n    let buf = script.toBuffer();\n    let hex = buf.toString('hex');\n    for (let i = 0; i < this.chunks.length; i++) {\n      let script2 = new Script({ chunks: [this.chunks[i]] });\n      let buf2 = script2.toBuffer();\n      let hex2 = buf2.toString('hex');\n      if (hex === hex2) {\n        this.chunks.splice(i, 1);\n      }\n    }\n    return this\n  }\n\n  /**\n   * Comes from nexad's script interpreter CheckMinimalPush function\n   * @returns true if the chunk {i} is the smallest way to push that particular data.\n   */\n  public checkMinimalPush(i: number): boolean {\n    let chunk = this.chunks[i];\n    let buf = chunk.buf;\n    let opcodenum = chunk.opcodenum;\n    if (!buf) {\n      return true;\n    }\n    if (buf.length === 0) {\n      // Could have used OP_0.\n      return opcodenum === Opcode.OP_0;\n    } else if (buf.length === 1 && buf[0] >= 1 && buf[0] <= 16) {\n      // Could have used OP_1 .. OP_16.\n      // return opcodenum === Opcode.OP_1 + (buf[0] - 1);\n      return false;\n    } else if (buf.length === 1 && buf[0] === 0x81) {\n      // Could have used OP_1NEGATE\n      return false;\n    } else if (buf.length <= 75) {\n      // Could have used a direct push (opcode indicating number of bytes pushed + those bytes).\n      return opcodenum === buf.length;\n    } else if (buf.length <= 255) {\n      // Could have used OP_PUSHDATA.\n      return opcodenum === Opcode.OP_PUSHDATA1;\n    } else if (buf.length <= 65535) {\n      // Could have used OP_PUSHDATA2.\n      return opcodenum === Opcode.OP_PUSHDATA2;\n    }\n    return true;\n  }\n\n  /**\n   * Comes from bitcoind's script GetSigOpCount(boolean) function\n   * @param accurate default true\n   * @returns number of signature operations required by this script\n   */\n  public getSignatureOperationsCount(accurate = true): number {\n    let n = 0;\n    let lastOpcode = Opcode.OP_INVALIDOPCODE;\n\n    this.chunks.forEach(chunk => {\n      let opcode = chunk.opcodenum;\n      if (opcode == Opcode.OP_CHECKSIG || opcode == Opcode.OP_CHECKSIGVERIFY) {\n        n++;\n      } else if (opcode == Opcode.OP_CHECKMULTISIG || opcode == Opcode.OP_CHECKMULTISIGVERIFY) {\n        if (accurate && lastOpcode >= Opcode.OP_1 && lastOpcode <= Opcode.OP_16) {\n          n += ScriptOpcode.decodeOP_N(lastOpcode);\n        } else {\n          n += 20;\n        }\n      }\n      lastOpcode = opcode;\n    });\n    \n    return n;\n  }\n\n  /**\n   * @returns true if the script is only composed of data pushing\n   * opcodes or small int opcodes (OP_0, OP_1, ..., OP_16)\n   */\n  public isPushOnly(): boolean {\n    return this.chunks.every(chunk => \n      chunk.opcodenum <= Opcode.OP_16 ||\n      chunk.opcodenum === Opcode.OP_PUSHDATA1 ||\n      chunk.opcodenum === Opcode.OP_PUSHDATA2 ||\n      chunk.opcodenum === Opcode.OP_PUSHDATA4\n    );\n  }\n\n  /**\n   * @returns true if this is a pay to script template output script\n   * @remarks for well-known-1 template use {@link isPublicKeyTemplateOut}\n   */\n  public isScriptTemplateOut(): boolean {\n    if (this.chunks.length < 3) {\n      return false;\n    }\n    \n    let hasGroup = this.chunks[0].opcodenum !== Opcode.OP_0;\n    let minLength = hasGroup ? 4 : 3;\n    let templateIndex = hasGroup ? 2 : 1;\n    let constraintIndex = hasGroup ? 3 : 2;\n\n    let isTemplate = this.chunks.length >= minLength\n      && BufferUtils.isHashBuffer(this.chunks[templateIndex].buf)\n      && (BufferUtils.isHashBuffer(this.chunks[constraintIndex].buf) || this.chunks[constraintIndex].opcodenum === Opcode.OP_FALSE);\n\n    if (hasGroup) {\n      isTemplate &&= !!(\n        this.chunks[0].buf && this.chunks[0].buf.length >= 32 && // group id\n        this.chunks[1].buf && this.chunks[1].buf.length >= 2 && this.chunks[1].buf.length <= 8 // group amount\n      );\n    }\n\n    if (isTemplate && this.chunks.length > minLength) {\n      let visibleArgs = new Script({chunks: this.chunks.slice(minLength)});\n      isTemplate = visibleArgs.isPushOnly();\n    }\n    return isTemplate;\n  }\n\n  /**\n   * Checks if this script is a valid pay to script template input script\n   * \n   * @returns true if this is a pay to script template form input script\n   * @remarks for well-known-1 template use {@link isPublicKeyTemplateIn}\n   */\n  public isScriptTemplateIn(): boolean {\n    // we do not know the length or content of satisfier / template / costraint scripts,\n    // only that must be push-only and template must exist\n    return this.chunks.length > 1\n      && BufferUtils.isBuffer(this.chunks[0].buf)\n      && this.isPushOnly()\n  }\n\n  /**\n   * @returns true if this is a pay to pubkey template output script (well-known-1, p2pkt)\n   */\n  public isPublicKeyTemplateOut(): boolean {\n    if (this.chunks.length < 3) {\n      return false;\n    }\n\n    let hasGroup = this.chunks[0].opcodenum !== Opcode.OP_0;\n    let minLength = hasGroup ? 4 : 3;\n    let templateIndex = hasGroup ? 2 : 1;\n    let constraintIndex = hasGroup ? 3 : 2;\n\n    let isTemplate = this.chunks.length === minLength\n      && this.chunks[templateIndex].opcodenum === Opcode.OP_1\n      && (BufferUtils.isHashBuffer(this.chunks[constraintIndex].buf));\n\n    if (hasGroup) {\n      isTemplate &&= !!(\n        this.chunks[0].buf && this.chunks[0].buf.length >= 32 && // group id\n        this.chunks[1].buf && this.chunks[1].buf.length >= 2 && this.chunks[1].buf.length <= 8 // group amount\n      );\n    }\n\n    return isTemplate;\n  }\n\n  /**\n   * @returns true if this is a pay to public key template input script\n   */\n  public isPublicKeyTemplateIn(): boolean {\n    if (this.chunks.length != 2) {\n      return false;\n    }\n\n    let pubkeyPushBuf = this.chunks[0].buf;\n    let signatureBuf = this.chunks[1].buf;\n    if (signatureBuf && signatureBuf.length >= 64 && signatureBuf.length <= 68 && pubkeyPushBuf?.length === 34) {\n      let pubkeyBuf = Script.fromBuffer(pubkeyPushBuf).chunks[0].buf;\n      return pubkeyBuf?.length === 33 && (pubkeyBuf[0] === 0x03 || pubkeyBuf[0] === 0x02);\n    }\n\n    return false;\n  }\n  \n  /**\n   * @returns true if this is a pay to pubkey hash output script\n   */\n  public isPublicKeyHashOut(): boolean {\n    return !!(this.chunks.length === 5 &&\n      this.chunks[0].opcodenum === Opcode.OP_DUP &&\n      this.chunks[1].opcodenum === Opcode.OP_HASH160 &&\n      this.chunks[2].buf &&\n      this.chunks[2].buf.length === 20 &&\n      this.chunks[3].opcodenum === Opcode.OP_EQUALVERIFY &&\n      this.chunks[4].opcodenum === Opcode.OP_CHECKSIG);\n  }\n\n  /**\n   * @returns {boolean} if this is a pay to public key hash input script\n   */\n  public isPublicKeyHashIn(): boolean {\n    if (this.chunks.length != 2) {\n      return false;\n    }\n\n    let signatureBuf = this.chunks[0].buf;\n    let pubkeyBuf = this.chunks[1].buf;\n    if (signatureBuf && signatureBuf.length && pubkeyBuf && pubkeyBuf.length) {\n      let version = pubkeyBuf[0];\n      if ((version === 0x04 || version === 0x06 || version === 0x07) && pubkeyBuf.length === 65) {\n        return true;\n      } else if ((version === 0x03 || version === 0x02) && pubkeyBuf.length === 33) {\n        return true;\n      }\n    }\n\n    return false;\n  }\n\n  /**\n   * @returns true if this is a valid standard OP_RETURN output\n   */\n  public isDataOut(): boolean {\n    let step1 = this.chunks.length >= 1 &&\n      this.chunks[0].opcodenum === Opcode.OP_RETURN &&\n      this.toBuffer().length <= 223; // 223 instead of 220 because (+1 for OP_RETURN, +2 for the pushdata opcodes)\n    if (!step1) return false;\n    let chunks = this.chunks.slice(1);\n    let script2 = new Script({chunks: chunks});\n    return script2.isPushOnly();\n  }\n\n  /**\n   * @returns true if this is a valid Token Description OP_RETURN output\n   */\n  public isTokenDescriptionOut(): boolean {\n    let step1 = inRange(this.chunks.length, 2, 8) &&\n      this.chunks[0].opcodenum === Opcode.OP_RETURN &&\n      this.chunks[1].len === 4;\n    \n    return step1 && new Script({chunks: this.chunks.slice(1)}).isPushOnly();\n  }\n\n  /**\n   * Will retrieve the Public Key buffer from p2pkt/p2pkh input scriptSig\n   */\n  public getPublicKey(): Buffer {\n    ValidationUtils.validateState(this.isPublicKeyHashIn() || this.isPublicKeyTemplateIn(), \"Can't retrieve PublicKey from a non-PKT or non-PKH input\");\n    return this.isPublicKeyHashIn() ? this.chunks[1].buf! : Script.fromBuffer(this.chunks[0].buf!).chunks[0].buf!;\n  }\n\n  /**\n   * Will retrieve the Public Key Hash buffer from p2pkh output scriptPubKey\n   */\n  public getPublicKeyHash(): Buffer {\n    ValidationUtils.validateState(this.isPublicKeyHashOut(), \"Can't retrieve PublicKeyHash from a non-PKH output\");\n    return this.chunks[2].buf!;\n  }\n\n  /**\n   * Will retrieve the Template Hash from p2pkt/p2st output scriptPubKey\n   * \n   * @returns OP_1 if its p2pkt, otherwise the template hash buffer\n   */\n  public getTemplateHash(): Buffer | Opcode.OP_1 {\n    ValidationUtils.validateState(this.isPublicKeyTemplateOut() || this.isScriptTemplateOut(), \"Can't retrieve TemplateHash from a non-PST output\");\n    if (this.isPublicKeyTemplateOut()) {\n      return Opcode.OP_1;\n    }\n    let hasGroup = this.chunks[0].opcodenum !== Opcode.OP_0;\n    return hasGroup ? this.chunks[2].buf! : this.chunks[1].buf!;\n  }\n  \n  /**\n   * Will retrieve the Constraint Hash from p2pkt/p2st output scriptPubKey\n   * \n   * @returns The constraint hash buffer, or OP_FALSE if not included\n   */\n  public getConstraintHash(): Buffer | Opcode.OP_FALSE {\n    ValidationUtils.validateState(this.isPublicKeyTemplateOut() || this.isScriptTemplateOut(), \"Can't retrieve ConstraintHash from a non-PST output\");\n    let hasGroup = this.chunks[0].opcodenum !== Opcode.OP_0;\n    let constraintIndex = hasGroup ? 3 : 2;\n    if (this.isPublicKeyTemplateOut()) {\n      return this.chunks[constraintIndex].buf!;\n    }\n    return this.chunks[constraintIndex].opcodenum === Opcode.OP_FALSE ? Opcode.OP_FALSE : this.chunks[constraintIndex].buf!;\n  }\n\n  /**\n   * Will retrieve the Group Identifier number from Token Description OP_RETURN output\n   * \n   * @remarks This method doesn't check if the group id number is fit to NRC1/NRC2 etc. \n   */\n  public getGroupIdType(): number {\n    ValidationUtils.validateState(this.isTokenDescriptionOut(), \"Can't retrieve GroupIdType from a non Token Description output\");\n    return BN.fromScriptNumBuffer(this.chunks[1].buf!).toNumber();\n  }\n}","import baseInRange from './_baseInRange.js';\nimport toFinite from './toFinite.js';\nimport toNumber from './toNumber.js';\n\n/**\n * Checks if `n` is between `start` and up to, but not including, `end`. If\n * `end` is not specified, it's set to `start` with `start` then set to `0`.\n * If `start` is greater than `end` the params are swapped to support\n * negative ranges.\n *\n * @static\n * @memberOf _\n * @since 3.3.0\n * @category Number\n * @param {number} number The number to check.\n * @param {number} [start=0] The start of the range.\n * @param {number} end The end of the range.\n * @returns {boolean} Returns `true` if `number` is in the range, else `false`.\n * @see _.range, _.rangeRight\n * @example\n *\n * _.inRange(3, 2, 4);\n * // => true\n *\n * _.inRange(4, 8);\n * // => true\n *\n * _.inRange(4, 2);\n * // => false\n *\n * _.inRange(2, 2);\n * // => false\n *\n * _.inRange(1.2, 2);\n * // => true\n *\n * _.inRange(5.2, 4);\n * // => false\n *\n * _.inRange(-3, -2, -6);\n * // => true\n */\nfunction inRange(number, start, end) {\n  start = toFinite(start);\n  if (end === undefined) {\n    end = start;\n    start = 0;\n  } else {\n    end = toFinite(end);\n  }\n  number = toNumber(number);\n  return baseInRange(number, start, end);\n}\n\nexport default inRange;\n","/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max,\n    nativeMin = Math.min;\n\n/**\n * The base implementation of `_.inRange` which doesn't coerce arguments.\n *\n * @private\n * @param {number} number The number to check.\n * @param {number} start The start of the range.\n * @param {number} end The end of the range.\n * @returns {boolean} Returns `true` if `number` is in the range, else `false`.\n */\nfunction baseInRange(number, start, end) {\n  return number >= nativeMin(start, end) && number < nativeMax(start, end);\n}\n\nexport default baseInRange;\n","import { isNumber, isString } from \"lodash-es\";\nimport BufferUtils from \"../../utils/buffer.utils\";\nimport ValidationUtils from \"../../utils/validation.utils\";\n\nexport enum Opcode {\n  // push value\n  OP_FALSE = 0,\n  OP_0 = OP_FALSE,\n  OP_PUSHDATA1 = 76,\n  OP_PUSHDATA2 = 77,\n  OP_PUSHDATA4 = 78,\n  OP_1NEGATE = 79,\n  OP_RESERVED = 80,\n  OP_TRUE = 81,\n  OP_1 = OP_TRUE,\n  OP_2 = 82,\n  OP_3 = 83,\n  OP_4 = 84,\n  OP_5 = 85,\n  OP_6 = 86,\n  OP_7 = 87,\n  OP_8 = 88,\n  OP_9 = 89,\n  OP_10 = 90,\n  OP_11 = 91,\n  OP_12 = 92,\n  OP_13 = 93,\n  OP_14 = 94,\n  OP_15 = 95,\n  OP_16 = 96,\n\n  // control\n  OP_NOP = 97,\n  OP_INVALID_CONTROL1 = 98,\n  OP_IF = 99,\n  OP_NOTIF = 100,\n  OP_JUMP = 101,\n  OP_INVALID_CONTROL2 = 102,\n  OP_ELSE = 103,\n  OP_ENDIF = 104,\n  OP_VERIFY = 105,\n  OP_RETURN = 106,\n\n  // stack ops\n  OP_TOALTSTACK = 107,\n  OP_FROMALTSTACK = 108,\n  OP_2DROP = 109,\n  OP_2DUP = 110,\n  OP_3DUP = 111,\n  OP_2OVER = 112,\n  OP_2ROT = 113,\n  OP_2SWAP = 114,\n  OP_IFDUP = 115,\n  OP_DEPTH = 116,\n  OP_DROP = 117,\n  OP_DUP = 118,\n  OP_NIP = 119,\n  OP_OVER = 120,\n  OP_PICK = 121,\n  OP_ROLL = 122,\n  OP_ROT = 123,\n  OP_SWAP = 124,\n  OP_TUCK = 125,\n\n  // splice ops\n  OP_CAT = 126,\n  OP_SPLIT = 127,\n  OP_NUM2BIN = 128,\n  OP_BIN2NUM = 129,\n  OP_SIZE = 130,\n\n  // bit logic\n  OP_INVERT = 131,\n  OP_AND = 132,\n  OP_OR = 133,\n  OP_XOR = 134,\n  OP_EQUAL = 135,\n  OP_EQUALVERIFY = 136,\n  OP_RESERVED1 = 137,\n  OP_RESERVED2 = 138,\n\n  // numeric\n  OP_1ADD = 139,\n  OP_1SUB = 140,\n  OP_2MUL = 141,\n  OP_2DIV = 142,\n  OP_NEGATE = 143,\n  OP_ABS = 144,\n  OP_NOT = 145,\n  OP_0NOTEQUAL = 146,\n\n  OP_ADD = 147,\n  OP_SUB = 148,\n  OP_MUL = 149,\n  OP_DIV = 150,\n  OP_MOD = 151,\n  OP_LSHIFT = 152,\n  OP_RSHIFT = 153,\n\n  OP_BOOLAND = 154,\n  OP_BOOLOR = 155,\n  OP_NUMEQUAL = 156,\n  OP_NUMEQUALVERIFY = 157,\n  OP_NUMNOTEQUAL = 158,\n  OP_LESSTHAN = 159,\n  OP_GREATERTHAN = 160,\n  OP_LESSTHANOREQUAL = 161,\n  OP_GREATERTHANOREQUAL = 162,\n  OP_MIN = 163,\n  OP_MAX = 164,\n\n  OP_WITHIN = 165,\n\n  // crypto\n  OP_RIPEMD160 = 166,\n  OP_SHA1 = 167,\n  OP_SHA256 = 168,\n  OP_HASH160 = 169,\n  OP_HASH256 = 170,\n  OP_CODESEPARATOR = 171,\n  OP_CHECKSIG = 172,\n  OP_CHECKSIGVERIFY = 173,\n  OP_CHECKMULTISIG = 174,\n  OP_CHECKMULTISIGVERIFY = 175,\n\n  // timelocks\n  OP_NOP2 = 177,\n  OP_CHECKLOCKTIMEVERIFY = OP_NOP2,\n  OP_NOP3 = 178,\n  OP_CHECKSEQUENCEVERIFY = OP_NOP3,\n\n  // expansion\n  OP_NOP1 = 176,\n  OP_NOP4 = 179,\n  OP_NOP5 = 180,\n  OP_NOP6 = 181,\n  OP_NOP7 = 182,\n  OP_NOP8 = 183,\n  OP_NOP9 = 184,\n  OP_NOP10 = 185,\n\n  // More crypto\n  OP_CHECKDATASIG = 186,\n  OP_CHECKDATASIGVERIFY = 187,\n\n  // additional byte string operations\n  OP_REVERSEBYTES = 188,\n\n  // Transaction Introspection Opcodes\n  OP_INPUTINDEX = 192,\n  OP_ACTIVEBYTECODE = 193,\n  OP_TXVERSION = 194,\n  OP_TXINPUTCOUNT = 195,\n  OP_TXOUTPUTCOUNT = 196,\n  OP_TXLOCKTIME = 197,\n  OP_UTXOVALUE = 198,\n  OP_UTXOBYTECODE = 199,\n  OP_OUTPOINTHASH = 200,\n  OP_INPUTBYTECODE = 202,\n  OP_INPUTSEQUENCENUMBER = 203,\n  OP_OUTPUTVALUE = 204,\n  OP_OUTPUTBYTECODE = 205,\n  OP_INPUTTYPE = 206,\n  OP_OUTPUTTYPE = 207,\n  OP_INPUTVALUE = 208,\n\n  // NEXA opcodes\n  OP_PARSE = 230,\n  OP_STORE = 231,\n  OP_LOAD = 232,\n  OP_PLACE = 233,\n  OP_PUSH_TX_STATE = 234,\n  OP_SETBMD = 235,\n  OP_BIN2BIGNUM = 236,\n  OP_EXEC = 237,\n  // OP_GROUPDATA = 238,\n\n  // The first op_code value after all defined opcodes\n  FIRST_UNDEFINED_OP_VALUE,\n\n  OP_INVALIDOPCODE = 255,\n}\n\ntype OpcodeKey = keyof typeof Opcode;\n\nexport default class ScriptOpcode {\n\n  num: number;\n\n  constructor(val: number | string) {\n    if (isNumber(val)) {\n      this.num = val;\n    } else if (isString(val)) {\n      this.num = Opcode[val as OpcodeKey];\n    } else {\n      throw new TypeError('Unrecognized val type: \"' + typeof(val) + '\" for Opcode');\n    }\n  }\n\n  public static fromBuffer(buf: Buffer): ScriptOpcode {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), 'buf must be Buffer');\n    return new ScriptOpcode(Number('0x' + buf.toString('hex')));\n  }\n  \n  public static fromNumber(num: number): ScriptOpcode {\n    ValidationUtils.validateArgument(isNumber(num), 'num must be number');\n    return new ScriptOpcode(num);\n  }\n  \n  public static fromString(str: string): ScriptOpcode {\n    ValidationUtils.validateArgument(isString(str), 'str must be string');\n\n    let value = Opcode[str as OpcodeKey];\n    if (typeof value === 'undefined') {\n      throw new TypeError('Invalid opcodestr');\n    }\n    return new ScriptOpcode(value);\n  }\n\n  public static smallInt(n: number): ScriptOpcode {\n    ValidationUtils.validateArgument(isNumber(n), 'n should be number');\n    ValidationUtils.validateArgument(n >= 0 && n <= 16, 'n must be between 0 and 16');\n\n    if (n === 0) {\n      return new ScriptOpcode('OP_0');\n    }\n    return new ScriptOpcode(Opcode.OP_1 + n - 1);\n  }\n\n  /**\n   * @returns true if opcode is one of OP_0, OP_1, ..., OP_16\n   */\n  public static isSmallIntOp(opcode: ScriptOpcode | number): boolean {\n    if (opcode instanceof ScriptOpcode) {\n      opcode = opcode.toNumber();\n    }\n    return opcode === Opcode.OP_0 || (opcode >= Opcode.OP_1 && opcode <= Opcode.OP_16);\n  }\n\n  public toHex(): string {\n    return this.num.toString(16);\n  }\n  \n  public toBuffer(): Buffer {\n    return Buffer.from(this.toHex(), 'hex');\n  }\n  \n  public toNumber(): number {\n    return this.num;\n  }\n  \n  public toString(): string {\n    let str = Opcode[this.num];\n    if (typeof str === 'undefined') {\n      throw new Error('Opcode does not have a string representation');\n    }\n    return str;\n  }\n\n  /**\n   * Will return a string formatted for the console\n   *\n   * @returns Script opcode\n   */\n  public inspect(): string {\n    return '<Opcode: ' + this.toString() + ', hex: '+this.toHex()+', decimal: '+this.num+'>';\n  }\n\n  /**\n   * Comes from nexad's script DecodeOP_N function\n   * @param opcode\n   * @returns numeric value in range of 0 to 16\n   */\n  public static decodeOP_N(opcode: number): number {\n    if (opcode === Opcode.OP_0) {\n      return 0;\n    } else if (opcode >= Opcode.OP_1 && opcode <= Opcode.OP_16) {\n      return opcode - (Opcode.OP_1 - 1);\n    } else {\n      throw new Error('Invalid opcode: ' + JSON.stringify(opcode));\n    }\n  }\n}","import { isNumber, isObject, isString } from \"lodash-es\";\nimport HDKeyUtils from \"./hdkey.utils\";\nimport { InvalidB58Checksum, InvalidDerivationArgument, InvalidEntropyArgument, InvalidPath, NotEnoughEntropy, TooMuchEntropy } from \"./exceptions\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport ValidationUtils from \"../utils/validation.utils\";\nimport type { HDPrivateKeyBuffers, HDPrivateKeyDto, HDPrivateKeyMinimalDto, IHDPrivateKey } from \"../common/interfaces\";\nimport type { Networkish } from \"../common/types\";\nimport Hash from \"../crypto/hash\";\nimport PrivateKey from \"./privatekey\";\nimport type PublicKey from \"./publickey\";\nimport BN from \"../crypto/bn.extension\";\nimport Point from \"../crypto/point\";\nimport type { Network } from \"../core/network/network\";\nimport { networks } from \"../core/network/network-manager\";\nimport Base58Check from \"../encoding/base58check\";\nimport CommonUtils from \"../utils/common.utils\";\nimport HDPublicKey from \"./hdpublickey\";\n\nexport default class HDPrivateKey implements IHDPrivateKey {\n\n  private static readonly MINIMUM_ENTROPY_BITS = 128;\n  private static readonly BITS_TO_BYTES = 1 / 8;\n  private static readonly MAXIMUM_ENTROPY_BITS = 512;\n\n  private static readonly PrivateKeySize = 32;\n  private static readonly PrivateKeyStart = HDKeyUtils.ChainCodeEnd + 1;\n  private static readonly PrivateKeyEnd = this.PrivateKeyStart + this.PrivateKeySize;\n  private static readonly ChecksumStart = this.PrivateKeyEnd;\n  private static readonly ChecksumEnd = this.ChecksumStart + HDKeyUtils.CheckSumSize;\n\n  private _hdPublicKey?: HDPublicKey;\n\n  readonly privateKey!: PrivateKey;\n  readonly publicKey!: PublicKey;\n  readonly network!: Network;\n  readonly depth!: number;\n  readonly parentFingerPrint!: Buffer;\n  readonly fingerPrint!: Buffer;\n  readonly chainCode!: Buffer;\n  readonly childIndex!: number;\n  readonly checksum!: Buffer;\n  readonly xprivkey!: string;\n\n  /**\n   * Represents an instance of an hierarchically derived private key.\n   *\n   * More info on https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki\n   */\n  constructor(arg?: string | Buffer | IHDPrivateKey | HDPrivateKeyDto | HDPrivateKeyMinimalDto | Networkish) {\n    if (arg instanceof HDPrivateKey) {\n      return arg;\n    }\n\n    let params = HDPrivateKey._classifyArgument(arg);\n\n    this.privateKey = params.privateKey as PrivateKey;\n    this.publicKey = (params.publicKey ?? params.privateKey.toPublicKey()) as PublicKey;\n    this.network = params.network;\n    this.depth = params.depth;\n    this.parentFingerPrint = params.parentFingerPrint;\n    this.fingerPrint = params.fingerPrint;\n    this.chainCode = params.chainCode;\n    this.childIndex = params.childIndex;\n    this.xprivkey = params.xprivkey;\n    this.checksum = params.checksum;\n  }\n\n  private static _classifyArgument(arg?: string | Buffer | IHDPrivateKey | HDPrivateKeyDto | HDPrivateKeyMinimalDto | Networkish): IHDPrivateKey {\n    if (!arg) {\n      return this._generateRandomly();\n    }\n    if (networks.get(arg as Networkish)) {\n      return this._generateRandomly(arg as Networkish);\n    }\n\n    if (isString(arg) || BufferUtils.isBuffer(arg)) {\n      let xprivkey = arg.toString();\n      if (HDKeyUtils.isValidSerialized(xprivkey, undefined, true)) {\n        return this._buildFromSerialized(xprivkey);\n      }\n      if (CommonUtils.isValidJSON(arg as string)) {\n        return this._buildFromObject(JSON.parse(arg as string));\n      }\n      throw HDKeyUtils.getSerializedError(arg, undefined, true);\n    }\n\n    if (this._isIHDPrivKey(arg)) {\n      return arg;\n    }\n    if (this._isMinimalDtoObject(arg)) {\n      return this._buildFromMinimalObject(arg);\n    }\n    if (this._isDtoObject(arg)) {\n      return this._buildFromObject(arg);\n    }\n  \n    throw new TypeError('Invalid argument type for creation, must be string, json, buffer, or object');\n  }\n\n  public get hdPublicKey(): HDPublicKey {\n    return this.getHDPublicKey();\n  }\n\n  public get xpubkey(): string {\n    return this.getHDPublicKey().xpubkey;\n  }\n\n  private static _isDtoObject(data: unknown): data is HDPrivateKeyDto {\n    return isObject(data) && 'xprivkey' in data && 'privateKey' in data && isString(data.privateKey);\n  }\n\n  private static _isMinimalDtoObject(data: unknown): data is HDPrivateKeyMinimalDto {\n    return isObject(data) && !('xprivkey' in data) && 'privateKey' in data && isString(data.privateKey);\n  }\n\n  private static _isIHDPrivKey(data: unknown): data is IHDPrivateKey {\n    return isObject(data) && 'xprivkey' in data && 'privateKey' in data && data.privateKey instanceof PrivateKey;\n  }\n\n  /**\n   * Verifies that a given path is valid.\n   *\n   * @param arg\n   * @param hardened\n   */\n  public static isValidPath(arg: string | number, hardened?: boolean): boolean {\n    if (isString(arg)) {\n      let indexes = HDKeyUtils.getDerivationIndexes(arg);\n      return indexes !== null && indexes.every(i => this.isValidPath(i));\n    }\n\n    if (isNumber(arg)) {\n      if (arg < HDKeyUtils.Hardened && hardened === true) {\n        arg += HDKeyUtils.Hardened;\n      }\n      return arg >= 0 && arg < HDKeyUtils.MaxIndex;\n    }\n\n    return false;\n  }\n\n  public static fromString(xprivkey: string): HDPrivateKey {\n    ValidationUtils.validateArgument(isString(xprivkey), 'No valid string was provided');\n    return new HDPrivateKey(xprivkey);\n  }\n\n  /**\n   * Returns the string representation of this private key (ext privkey).\n   */\n  public toString(): string {\n    return this.xprivkey;\n  }\n\n  /**\n   * Build a HDPrivateKey from a buffer\n   *\n   * @param {Buffer} buf\n   */\n  public static fromBuffer(buf: Buffer): HDPrivateKey {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), 'No valid Buffer was provided');\n    return new HDPrivateKey(buf);\n  }\n\n  /**\n   * Returns a buffer representation of the HDPrivateKey\n   */\n  public toBuffer(): Buffer {\n    return Buffer.from(this.xprivkey);\n  }\n\n  public toJSON = this.toObject;\n\n  /**\n   * Returns a plain object with a representation of this private key.\n   */\n  public toObject(): HDPrivateKeyDto {\n    return {\n      network: this.network.name,\n      depth: this.depth,\n      fingerPrint: BufferUtils.integerFromBuffer(this.fingerPrint),\n      parentFingerPrint: BufferUtils.integerFromBuffer(this.parentFingerPrint),\n      childIndex: this.childIndex,\n      chainCode: this.chainCode.toString('hex'),\n      privateKey: this.privateKey.toString(),\n      checksum: BufferUtils.integerFromBuffer(this.checksum),\n      xprivkey: this.xprivkey,\n    };\n  }\n\n  public static fromObject(arg: HDPrivateKeyDto): HDPrivateKey {\n    ValidationUtils.validateArgument(isObject(arg), 'No valid argument was provided');\n    return new HDPrivateKey(arg);\n  }\n\n  public static fromMinimalObject(arg: HDPrivateKeyMinimalDto): HDPrivateKey {\n    ValidationUtils.validateArgument(isObject(arg), 'No valid argument was provided');\n    let params = this._buildFromMinimalObject(arg);\n    return new HDPrivateKey(params);\n  }\n\n  /**\n   * Generate a private key from a seed, as described in BIP32\n   *\n   * @param seed\n   * @param network\n   * @return HDPrivateKey\n   */\n  public static fromSeed(seed: string | Buffer, network: Networkish = networks.defaultNetwork): HDPrivateKey {\n    let params = this._buildFromSeed(seed, network);\n    return new HDPrivateKey(params);\n  }\n  \n  /**\n   * Get a derived child based on a string or number.\n   *\n   * If the first argument is a string, it's parsed as the full path of\n   * derivation. Valid values for this argument include \"m\" (which returns the\n   * same private key), \"m/0/1/40/2'/1000\", where the ' quote means a hardened\n   * derivation.\n   *\n   * If the first argument is a number, the child with that index will be\n   * derived. If the second argument is truthy, the hardened version will be\n   * derived. See the example usage for clarification.\n   *\n   * @example\n   * ```javascript\n   * let parent = new HDPrivateKey('xprv...');\n   * let child_0_1_2h = parent.deriveChild(0).deriveChild(1).deriveChild(2, true);\n   * let copy_of_child_0_1_2h = parent.deriveChild(\"m/0/1/2'\");\n   * assert(child_0_1_2h.xprivkey === copy_of_child_0_1_2h.xprivkey);\n   * ```\n   *\n   * @param arg\n   * @param hardened\n   * @return HDPrivateKey\n   */\n  public deriveChild(arg: string | number, hardened?: boolean): HDPrivateKey {\n    if (isNumber(arg)) {\n      return this._deriveWithNumber(arg, hardened);\n    }\n    if (isString(arg)) {\n      return this._deriveFromString(arg);\n    }\n    throw new InvalidDerivationArgument(arg);\n  }\n\n  private _deriveWithNumber(index: number, hardened?: boolean): HDPrivateKey {\n    if (!HDPrivateKey.isValidPath(index, hardened)) {\n      throw new InvalidPath(index);\n    }\n  \n    hardened = index >= HDKeyUtils.Hardened ? true : hardened;\n    if (index < HDKeyUtils.Hardened && hardened === true) {\n      index += HDKeyUtils.Hardened;\n    }\n  \n    let indexBuffer = BufferUtils.integerAsBuffer(index);\n    let data;\n    if (hardened) {\n      // This will use a 32 byte zero padded serialization of the private key\n      let privateKeyBuffer = this.privateKey.toBuffer();\n      ValidationUtils.validateState(privateKeyBuffer.length === 32, 'length of private key buffer is expected to be 32 bytes');\n      data = Buffer.concat([Buffer.from([0]), privateKeyBuffer, indexBuffer]);\n    } else {\n      data = Buffer.concat([this.publicKey.toBuffer(), indexBuffer]);\n    }\n    let hash = Hash.sha512hmac(data, this.chainCode);\n    let leftPart = BN.fromBuffer(hash.subarray(0, 32), { size: 32 });\n    let chainCode = hash.subarray(32, 64);\n  \n    let privateKey = leftPart.add(this.privateKey.toBigNumber()).umod(Point.getN()).toBuffer({ size: 32 });\n  \n    if (!PrivateKey.isValid(privateKey)) {\n      // Index at this point is already hardened, we can pass null as the hardened arg\n      return this._deriveWithNumber(index + 1);\n    }\n\n    let buffers: HDPrivateKeyBuffers = {\n      version: BufferUtils.integerAsBuffer(this.network.xprivkey),\n      depth: BufferUtils.integerAsSingleByteBuffer(this.depth + 1),\n      parentFingerPrint: this.fingerPrint,\n      childIndex: BufferUtils.integerAsBuffer(index),\n      privateKey: privateKey,\n      chainCode: chainCode,\n    };\n    let derived = HDPrivateKey._buildFromBuffers(buffers);\n  \n    return new HDPrivateKey(derived);\n  }\n  \n  private _deriveFromString(path: string): HDPrivateKey {\n    if (!HDPrivateKey.isValidPath(path)) {\n      throw new InvalidPath(path);\n    }\n\n    const deriveKeys = (baseKey: HDPrivateKey, indexes: number[]): HDPrivateKey => {\n      return indexes.reduce((prev, idx) => prev._deriveWithNumber(idx), baseKey);\n    }\n  \n    let indexes = HDKeyUtils.getDerivationIndexes(path);\n    return deriveKeys(this, indexes!);\n  }\n\n  private static _buildFromSeed(seed: string | Buffer, network: Networkish = networks.defaultNetwork): IHDPrivateKey {\n    if (CommonUtils.isHexa(seed as string)) {\n      seed = Buffer.from(seed as string, 'hex');\n    }\n    if (!Buffer.isBuffer(seed)) {\n      throw new InvalidEntropyArgument(seed);\n    }\n    if (seed.length < this.MINIMUM_ENTROPY_BITS * this.BITS_TO_BYTES) {\n      throw new NotEnoughEntropy(seed);\n    }\n    if (seed.length > this.MAXIMUM_ENTROPY_BITS * this.BITS_TO_BYTES) {\n      throw new TooMuchEntropy(seed);\n    }\n    let hash = Hash.sha512hmac(seed, Buffer.from('Bitcoin seed'));\n\n    let buffers: HDPrivateKeyBuffers = {\n      version: BufferUtils.integerAsBuffer((networks.get(network) || networks.defaultNetwork).xprivkey),\n      depth: BufferUtils.integerAsSingleByteBuffer(0),\n      parentFingerPrint: BufferUtils.integerAsBuffer(0),\n      childIndex: BufferUtils.integerAsBuffer(0),\n      privateKey: hash.subarray(0, 32),\n      chainCode: hash.subarray(32, 64),\n    };\n\n    return this._buildFromBuffers(buffers);\n  }\n\n  private static _buildFromObject(arg: HDPrivateKeyDto): IHDPrivateKey {\n    return {\n      network: networks.get(arg.network)!,\n      depth: arg.depth,\n      fingerPrint: BufferUtils.integerAsBuffer(arg.fingerPrint),\n      parentFingerPrint: BufferUtils.integerAsBuffer(arg.parentFingerPrint),\n      childIndex: arg.childIndex,\n      chainCode: Buffer.from(arg.chainCode, 'hex'),\n      xprivkey: arg.xprivkey,\n      checksum: BufferUtils.integerAsBuffer(arg.checksum),\n      privateKey: PrivateKey.fromString(arg.privateKey, arg.network)\n    }\n  }\n\n  private static _buildFromMinimalObject(arg: HDPrivateKeyMinimalDto): IHDPrivateKey {\n    let buffers = {\n      version: BufferUtils.integerAsBuffer(networks.get(arg.network)!.xprivkey),\n      depth: BufferUtils.integerAsSingleByteBuffer(arg.depth),\n      parentFingerPrint: BufferUtils.integerAsBuffer(arg.parentFingerPrint),\n      childIndex: BufferUtils.integerAsBuffer(arg.childIndex),\n      chainCode: Buffer.from(arg.chainCode, 'hex'),\n      privateKey: Buffer.from(arg.privateKey,'hex'),\n    };\n    return this._buildFromBuffers(buffers);\n  }\n\n  private static _buildFromSerialized(xprivkey: string): IHDPrivateKey {\n    let decoded = Base58Check.decode(xprivkey);\n    let buffers: HDPrivateKeyBuffers = {\n      version: decoded.subarray(HDKeyUtils.VersionStart, HDKeyUtils.VersionEnd),\n      depth: decoded.subarray(HDKeyUtils.DepthStart, HDKeyUtils.DepthEnd),\n      parentFingerPrint: decoded.subarray(HDKeyUtils.ParentFingerPrintStart, HDKeyUtils.ParentFingerPrintEnd),\n      childIndex: decoded.subarray(HDKeyUtils.ChildIndexStart, HDKeyUtils.ChildIndexEnd),\n      chainCode: decoded.subarray(HDKeyUtils.ChainCodeStart, HDKeyUtils.ChainCodeEnd),\n      privateKey: decoded.subarray(this.PrivateKeyStart, this.PrivateKeyEnd),\n      checksum: decoded.subarray(this.ChecksumStart, this.ChecksumEnd),\n    }\n    return this._buildFromBuffers(buffers);\n  }\n\n  /**\n   * Receives a object with buffers in all the properties and populates the\n   * internal structure\n   */\n  private static _buildFromBuffers(arg: HDPrivateKeyBuffers): IHDPrivateKey {\n    HDPrivateKey._validateBufferArguments(arg);\n\n    let sequence = [\n      arg.version, arg.depth, arg.parentFingerPrint, arg.childIndex, arg.chainCode,\n      Buffer.alloc(1), arg.privateKey\n    ];\n    let concat = Buffer.concat(sequence);\n\n    if (!arg.checksum?.length) {\n      arg.checksum = Base58Check.checksum(concat);\n    } else if (arg.checksum.toString() !== Base58Check.checksum(concat).toString()) {\n      throw new InvalidB58Checksum(concat);\n    }\n\n    let network = networks.get(BufferUtils.integerFromBuffer(arg.version))!;\n    let privateKey = PrivateKey.from(BN.fromBuffer(arg.privateKey), network);\n    let publicKey = privateKey.toPublicKey();\n\n    return {\n      xprivkey: Base58Check.encode(concat),\n      network: network,\n      depth: BufferUtils.integerFromSingleByteBuffer(arg.depth),\n      privateKey: privateKey,\n      publicKey: publicKey,\n      fingerPrint: Hash.sha256ripemd160(publicKey.toBuffer()).subarray(0, HDKeyUtils.ParentFingerPrintSize),\n      chainCode: arg.chainCode,\n      childIndex: BufferUtils.integerFromBuffer(arg.childIndex),\n      parentFingerPrint: arg.parentFingerPrint,\n      checksum: arg.checksum\n    }\n  }\n\n  private static _validateBufferArguments(arg: HDPrivateKeyBuffers): void {\n    const checkBuffer = (name: string, size: number): void => {\n      let buff = arg[name as keyof HDPrivateKeyBuffers];\n      ValidationUtils.validateArgument(BufferUtils.isBuffer(buff), name + ' argument is not a buffer');\n      ValidationUtils.validateArgument(buff!.length === size, name + ' has not the expected size: found ' + buff!.length + ', expected ' + size);\n    };\n\n    checkBuffer('version', HDKeyUtils.VersionSize);\n    checkBuffer('depth', HDKeyUtils.DepthSize);\n    checkBuffer('parentFingerPrint', HDKeyUtils.ParentFingerPrintSize);\n    checkBuffer('childIndex', HDKeyUtils.ChildIndexSize);\n    checkBuffer('chainCode', HDKeyUtils.ChainCodeSize);\n    checkBuffer('privateKey', this.PrivateKeySize);\n    if (arg.checksum?.length) {\n      checkBuffer('checksum', HDKeyUtils.CheckSumSize);\n    }\n  }\n\n  private static _generateRandomly(network?: Networkish): IHDPrivateKey {\n    return this._buildFromSeed(BufferUtils.getRandomBuffer(64), network);\n  }\n\n  /**\n   * Will return the corresponding hd public key\n   *\n   * @returns An extended public key generated from the hd private key\n   */\n  public getHDPublicKey(): HDPublicKey {\n    if (!this._hdPublicKey) {\n      this._hdPublicKey = new HDPublicKey(this);\n    }\n    return this._hdPublicKey;\n  }\n\n  /**\n   * Returns the console representation of this extended private key.\n   */\n  public inspect(): string {\n    return `<HDPrivateKey: ${this}>`;\n  }\n}","import { isNull, isString, isUndefined } from \"lodash-es\";\nimport type { Networkish } from \"../common/types\";\nimport { networks } from \"../core/network/network-manager\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport { ArgumentIsPrivateExtended, InvalidB58Char, InvalidB58Checksum, InvalidLength, InvalidNetwork, InvalidNetworkArgument } from \"./exceptions\";\nimport Base58 from \"../encoding/base58\";\nimport Base58Check from \"../encoding/base58check\";\n\nexport default class HDKeyUtils {\n\n  public static readonly Hardened = 0x80000000;\n  public static readonly MaxIndex = 2 * HDKeyUtils.Hardened;\n\n  public static readonly RootElementAlias = ['m', 'M', 'm\\'', 'M\\''];\n\n  public static readonly VersionSize = 4;\n  public static readonly DepthSize = 1;\n  public static readonly ParentFingerPrintSize = 4;\n  public static readonly ChildIndexSize = 4;\n  public static readonly ChainCodeSize = 32;\n  public static readonly CheckSumSize = 4;\n\n  public static readonly DataSize = 78;\n  public static readonly SerializedByteSize = 82;\n\n  public static readonly VersionStart = 0;\n  public static readonly VersionEnd = HDKeyUtils.VersionStart + HDKeyUtils.VersionSize;\n  public static readonly DepthStart = HDKeyUtils.VersionEnd;\n  public static readonly DepthEnd = HDKeyUtils.DepthStart + HDKeyUtils.DepthSize;\n  public static readonly ParentFingerPrintStart = HDKeyUtils.DepthEnd;\n  public static readonly ParentFingerPrintEnd = HDKeyUtils.ParentFingerPrintStart + HDKeyUtils.ParentFingerPrintSize;\n  public static readonly ChildIndexStart = HDKeyUtils.ParentFingerPrintEnd;\n  public static readonly ChildIndexEnd = HDKeyUtils.ChildIndexStart + HDKeyUtils.ChildIndexSize;\n  public static readonly ChainCodeStart = HDKeyUtils.ChildIndexEnd;\n  public static readonly ChainCodeEnd = HDKeyUtils.ChainCodeStart + HDKeyUtils.ChainCodeSize;\n\n  /**\n  * Util function that splits a string path into a derivation index array.\n  * It will return null if the string path is malformed.\n  * It does not validate if indexes are in bounds.\n  *\n  * @param path\n  */\n  public static getDerivationIndexes(path: string): number[] | null {\n    // Special cases:\n    if (this.RootElementAlias.includes(path)) {\n      return [];\n    }\n\n    let steps = path.split('/');\n    if (!this.RootElementAlias.includes(steps[0])) {\n      return null;\n    }\n\n    let indexes = steps.slice(1).map(step => {\n      let isHardened = step.slice(-1) === \"'\";\n      if (isHardened) {\n        step = step.slice(0, -1);\n      }\n\n      if (!step || step[0] === '-') {\n        return NaN;\n      }\n\n      let index = +step; // cast to number\n      if (isHardened) {\n        index += this.Hardened;\n      }\n\n      return index;\n    });\n\n    return indexes.some(isNaN) ? null : indexes;\n  }\n\n  private static _validateNetwork(data: Buffer, networkArg: Networkish, isPrivate = false): Error | null {\n    let network = networks.get(networkArg);\n    if (!network) {\n      return new InvalidNetworkArgument(networkArg);\n    }\n    let version = data.subarray(this.VersionStart, this.VersionEnd);\n    if (BufferUtils.integerFromBuffer(version) !== (isPrivate ? network.xprivkey : network.xpubkey)) {\n      return new InvalidNetwork(version);\n    }\n    return null;\n  }\n\n  /**\n   * Verifies that a given serialized hd key in base58 with checksum format\n   * is valid.\n   *\n   * @param data - the serialized hd key\n   * @param network - optional, if present, checks that the network provided matches the network serialized.\n   */\n  public static isValidSerialized(data: Buffer | string, network?: Networkish, isPrivate = false): boolean {\n    return isNull(this.getSerializedError(data, network, isPrivate));\n  }\n\n  /**\n   * Checks what's the error that causes the validation of a serialized public key\n   * in base58 with checksum to fail.\n   *\n   * @param data - the serialized hd key\n   * @param network - optional, if present, checks that the network provided matches the network serialized.\n   */\n  public static getSerializedError(data: string | Buffer, network?: Networkish, isPrivate = false): Error | null {\n    if (!(isString(data) || BufferUtils.isBuffer(data))) {\n      return new TypeError('Expected string or buffer')\n    }\n\n    if (!Base58.validCharacters(data)) {\n      return new InvalidB58Char('(unknown)', data);\n    }\n\n    try {\n      data = Base58Check.decode(data as string);\n    } catch {\n      return new InvalidB58Checksum(data);\n    }\n\n    if (data.length !== HDKeyUtils.DataSize) {\n      return new InvalidLength(data);\n    }\n\n    if (!isUndefined(network)) {\n      let error = this._validateNetwork(data, network, isPrivate);\n      if (error) {\n        return error;\n      }\n    }\n    \n    if (!isPrivate) {\n      let version = BufferUtils.integerFromBuffer(data.subarray(0, 4));\n      if (version === networks.mainnet.xprivkey || version === networks.testnet.xprivkey ) {\n        return new ArgumentIsPrivateExtended();\n      }\n    }\n    \n    return null;\n  }\n}","/**\n * Checks if `value` is `null`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `null`, else `false`.\n * @example\n *\n * _.isNull(null);\n * // => true\n *\n * _.isNull(void 0);\n * // => false\n */\nfunction isNull(value) {\n  return value === null;\n}\n\nexport default isNull;\n","export class InvalidDerivationArgument extends Error {\n  constructor(arg: unknown) {\n    super(`Invalid derivation argument: got ${arg}`);\n  }\n}\n\nexport class InvalidPath extends Error {\n  constructor(arg: unknown) {\n    super(`Invalid derivation path, it should look like: \"m/1/100\", got \"${arg}\"`);\n  }\n}\n\nexport class InvalidB58Char extends Error {\n  constructor(char: unknown, data: unknown) {\n    super(`Invalid Base58 character: ${char} in ${data}`);\n  }\n}\n\nexport class InvalidB58Checksum extends Error {\n  constructor(arg: unknown) {\n    super(`Invalid Base58 checksum for ${arg}`);\n  }\n}\n\nexport class InvalidLength extends Error {\n  constructor(arg: unknown) {\n    super(`Invalid length for xprivkey string in ${arg}`);\n  }\n}\n\nexport class InvalidNetwork extends Error {\n  constructor(arg: unknown) {\n    super(`Invalid version for network: got ${arg}`);\n  }\n}\n\nexport class InvalidNetworkArgument extends Error {\n  constructor(arg: unknown) {\n    super(`Invalid network: must be \"mainnet\" or \"testnet\", got ${arg}`);\n  }\n}\n\nexport class InvalidEntropyArgument extends Error {\n  constructor(arg: unknown) {\n    super(`Invalid entropy: must be an hexa string or binary buffer, got ${arg}`);\n  }\n}\n\nexport class TooMuchEntropy extends Error {\n  constructor(arg: unknown) {\n    super(`Invalid entropy: more than 512 bits is non standard, got ${arg}`);\n  }\n}\n\nexport class NotEnoughEntropy extends Error {\n  constructor(arg: unknown) {\n    super(`Invalid entropy: at least 128 bits needed, got ${arg}`);\n  }\n}\n\nexport class ArgumentIsPrivateExtended extends Error {\n  constructor() {\n    super(`Argument is an extended private key`);\n  }\n}\n\nexport class InvalidHardenedIndex extends Error {\n  constructor() {\n    super(`Invalid argument: creating a hardened path requires an HDPrivateKey`);\n  }\n}","import { isNil, isNumber, isObject, isString } from \"lodash-es\";\nimport type { HDPublicKeyBuffers, HDPublicKeyDto, HDPublicKeyMinimalDto, IHDPrivateKey, IHDPublicKey } from \"../common/interfaces\";\nimport HDKeyUtils from \"./hdkey.utils\";\nimport { networks } from \"../core/network/network-manager\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport type { Network } from \"../core/network/network\";\nimport ValidationUtils from \"../utils/validation.utils\";\nimport { InvalidB58Checksum, InvalidDerivationArgument, InvalidHardenedIndex, InvalidPath } from \"./exceptions\";\nimport Base58Check from \"../encoding/base58check\";\nimport PublicKey from \"./publickey\";\nimport Hash from \"../crypto/hash\";\nimport BN from \"../crypto/bn.extension\";\nimport Point from \"../crypto/point\";\nimport { AddressType } from \"../core/address/address-formatter\";\nimport Address from \"../core/address/address\";\n\nexport default class HDPublicKey implements IHDPublicKey {\n\n  private static readonly PublicKeySize = 33;\n  private static readonly PublicKeyStart = HDKeyUtils.ChainCodeEnd;\n  private static readonly PublicKeyEnd = this.PublicKeyStart + this.PublicKeySize;\n  private static readonly ChecksumStart = this.PublicKeyEnd;\n  private static readonly ChecksumEnd = this.ChecksumStart + HDKeyUtils.CheckSumSize;\n\n  readonly publicKey!: PublicKey;\n  readonly network!: Network;\n  readonly depth!: number;\n  readonly parentFingerPrint!: Buffer;\n  readonly fingerPrint!: Buffer;\n  readonly chainCode!: Buffer;\n  readonly childIndex!: number;\n  readonly checksum!: Buffer;\n  readonly xpubkey!: string;\n\n  /**\n   * The representation of an hierarchically derived public key.\n   *\n   * See https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki\n   *\n   * @param arg\n   */\n  constructor(arg: string | Buffer | HDPublicKeyDto | HDPublicKeyMinimalDto | IHDPublicKey | IHDPrivateKey) {\n    if (isNil(arg)) {\n      throw new TypeError(\"Must supply an argument to create a HDPublicKey\");\n    }\n    if (arg instanceof HDPublicKey) {\n      return arg;\n    }\n\n    let params = HDPublicKey._classifyArgument(arg);\n\n    this.publicKey = params.publicKey as PublicKey;\n    this.network = params.network;\n    this.depth = params.depth;\n    this.parentFingerPrint = params.parentFingerPrint;\n    this.fingerPrint = params.fingerPrint;\n    this.chainCode = params.chainCode;\n    this.childIndex = params.childIndex;\n    this.xpubkey = params.xpubkey;\n    this.checksum = params.checksum;\n  }\n\n  private static _classifyArgument(arg: string | Buffer | HDPublicKeyDto | HDPublicKeyMinimalDto | IHDPublicKey | IHDPrivateKey): IHDPublicKey {\n    if (isString(arg) || BufferUtils.isBuffer(arg)) {\n      let xpubkey = arg.toString();\n      if (HDKeyUtils.isValidSerialized(xpubkey)) {\n        return this._buildFromSerialized(xpubkey);\n      }\n      throw HDKeyUtils.getSerializedError(arg);\n    }\n\n    if (this._isIHDPubKey(arg)) {\n      return arg;\n    }\n    if (this._isMinimalDtoObject(arg)) {\n      return this._buildFromMinimalObject(arg);\n    }\n    if (this._isDtoObject(arg)) {\n      return this._buildFromObject(arg);\n    }\n    if (this._isIHDPrivKey(arg)) {\n      return this._buildFromHDPrivateKey(arg);\n    }\n\n    throw new TypeError('Invalid argument type for creation, must be string, json, buffer, or object');\n  }\n\n  private static _isDtoObject(data: unknown): data is HDPublicKeyDto {\n    return isObject(data) && 'xpubkey' in data && !('privateKey' in data) && 'publicKey' in data && isString(data.publicKey);\n  }\n\n  private static _isMinimalDtoObject(data: unknown): data is HDPublicKeyMinimalDto {\n    return isObject(data) && !('xpubkey' in data) && !('privateKey' in data) && 'publicKey' in data && isString(data.publicKey);\n  }\n\n  private static _isIHDPubKey(data: unknown): data is IHDPublicKey {\n    return isObject(data) && 'xpubkey' in data && !('privateKey' in data) && 'publicKey' in data && data.publicKey instanceof PublicKey;\n  }\n\n  private static _isIHDPrivKey(data: unknown): data is IHDPrivateKey {\n    return isObject(data) && 'privateKey' in data && isObject(data.privateKey) && 'bn' in data.privateKey;\n  }\n  \n  /**\n   * Verifies that a given path is valid.\n   *\n   * @param arg\n   * @return {boolean}\n   */\n  public static isValidPath(arg: string | number): boolean {\n    if (isString(arg)) {\n      let indexes = HDKeyUtils.getDerivationIndexes(arg);\n      return indexes !== null && indexes.every(HDPublicKey.isValidPath);\n    }\n\n    if (isNumber(arg)) {\n      return arg >= 0 && arg < HDKeyUtils.Hardened;\n    }\n\n    return false;\n  }\n\n  /**\n   * Create a HDPublicKey from a buffer argument\n   *\n   * @param buf\n   */\n  public static fromBuffer(buf: Buffer): HDPublicKey {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), 'No valid Buffer was provided');\n    return new HDPublicKey(buf);\n  }\n\n  /**\n   * Return a buffer representation of the xpubkey\n   */\n  public toBuffer(): Buffer {\n    return Buffer.from(this.xpubkey);\n  }\n\n  public static fromString(xpubkey: string): HDPublicKey {\n    ValidationUtils.validateArgument(isString(xpubkey), 'No valid string was provided');\n    return new HDPublicKey(xpubkey);\n  }\n  \n  /**\n   * Returns the base58 checked representation of the public key\n   * @return a string starting with \"xpub...\" in livenet\n   */\n  public toString(): string {\n    return this.xpubkey;\n  }\n\n  /**\n   * Returns the console representation of this extended public key.\n   */\n  public inspect(): string {\n    return `<HDPublicKey: ${this}>`;\n  }\n\n  public static fromObject(arg: HDPublicKeyDto): HDPublicKey {\n    ValidationUtils.validateArgument(isObject(arg), 'No valid argument was provided');\n    return new HDPublicKey(arg);\n  }\n\n  public static fromMinimalObject(arg: HDPublicKeyMinimalDto): HDPublicKey {\n    ValidationUtils.validateArgument(isObject(arg), 'No valid argument was provided');\n    let params = this._buildFromMinimalObject(arg);\n    return new HDPublicKey(params);\n  }\n\n  public toJSON = this.toObject;\n\n  /**\n   * Returns a plain JavaScript object with information to reconstruct a key.\n   */\n  public toObject(): HDPublicKeyDto {\n    return {\n      network: this.network.name,\n      depth: this.depth,\n      fingerPrint: BufferUtils.integerFromBuffer(this.fingerPrint),\n      parentFingerPrint: BufferUtils.integerFromBuffer(this.parentFingerPrint),\n      childIndex: this.childIndex,\n      chainCode: this.chainCode.toString('hex'),\n      publicKey: this.publicKey.toString(),\n      checksum: BufferUtils.integerFromBuffer(this.checksum),\n      xpubkey: this.xpubkey\n    };\n  }\n\n  /**\n   * Will return an address for the hdpubkey with its defined network\n   * \n   * @param type - optional parameter specifying the desired type of the address.\n   *  default {@link AddressType.PayToScriptTemplate}\n   * \n   * @returns An address generated from the hd public key\n   */\n  public toAddress(type = AddressType.PayToScriptTemplate): Address {\n    return Address.fromPublicKey(this.publicKey, this.network, type);\n  }\n\n  /**\n   * Get a derivated child based on a string or number.\n   *\n   * If the first argument is a string, it's parsed as the full path of\n   * derivation. Valid values for this argument include \"m\" (which returns the\n   * same public key), \"m/0/1/40/2/1000\".\n   *\n   * Note that hardened keys can't be derived from a public extended key.\n   *\n   * If the first argument is a number, the child with that index will be\n   * derived. See the example usage for clarification.\n   *\n   * @example\n   * ```javascript\n   * let parent = new HDPublicKey('xpub...');\n   * let child_0_1_2 = parent.deriveChild(0).deriveChild(1).deriveChild(2);\n   * let copy_of_child_0_1_2 = parent.deriveChild(\"m/0/1/2\");\n   * assert(child_0_1_2.xpubkey === copy_of_child_0_1_2.xpubkey);\n   * ```\n   *\n   * @param {string|number} arg\n   */\n  public deriveChild(arg: string | number, hardened?: boolean): HDPublicKey {\n    if (isNumber(arg)) {\n      return this._deriveWithNumber(arg, hardened);\n    } \n    if (isString(arg)) {\n      return this._deriveFromString(arg);\n    } \n    throw new InvalidDerivationArgument(arg);\n  }\n\n  private _deriveWithNumber(index: number, hardened?: boolean): HDPublicKey {\n    if (index >= HDKeyUtils.Hardened || hardened) {\n      throw new InvalidHardenedIndex();\n    }\n    if (index < 0) {\n      throw new InvalidPath(index);\n    }\n  \n    let indexBuffer = BufferUtils.integerAsBuffer(index);\n    let data = Buffer.concat([this.publicKey.toBuffer(), indexBuffer]);\n    let hash = Hash.sha512hmac(data, this.chainCode);\n    let leftPart = BN.fromBuffer(hash.subarray(0, 32), {size: 32});\n    let chainCode = hash.subarray(32, 64);\n  \n    let publicKey: PublicKey;\n    try {\n      publicKey = PublicKey.fromPoint(Point.getG().mul(leftPart).add(this.publicKey.point));\n    } catch {\n      return this._deriveWithNumber(index + 1);\n    }\n\n    let buffers: HDPublicKeyBuffers = {\n      version: BufferUtils.integerAsBuffer(this.network.xpubkey),\n      depth: BufferUtils.integerAsSingleByteBuffer(this.depth + 1),\n      parentFingerPrint: this.fingerPrint,\n      childIndex: BufferUtils.integerAsBuffer(index),\n      publicKey: publicKey.toBuffer(),\n      chainCode: chainCode\n    };\n    let derived = HDPublicKey._buildFromBuffers(buffers);\n  \n    return new HDPublicKey(derived);\n  }\n\n  private _deriveFromString(path: string): HDPublicKey {\n    if (path.includes(\"'\")) {\n      throw new InvalidHardenedIndex();\n    }\n    if (!HDPublicKey.isValidPath(path)) {\n      throw new InvalidPath(path);\n    }\n\n    const deriveKeys = (baseKey: HDPublicKey, indexes: number[]): HDPublicKey => {\n      return indexes.reduce((prev, idx) => prev._deriveWithNumber(idx), baseKey);\n    }\n  \n    let indexes = HDKeyUtils.getDerivationIndexes(path);\n    return deriveKeys(this, indexes!);\n  }\n\n  private static _buildFromObject(arg: HDPublicKeyDto): IHDPublicKey {\n    return {\n      network: networks.get(arg.network)!,\n      depth: arg.depth,\n      fingerPrint: BufferUtils.integerAsBuffer(arg.fingerPrint),\n      parentFingerPrint: BufferUtils.integerAsBuffer(arg.parentFingerPrint),\n      childIndex: arg.childIndex,\n      chainCode: Buffer.from(arg.chainCode, 'hex'),\n      xpubkey: arg.xpubkey,\n      checksum: BufferUtils.integerAsBuffer(arg.checksum),\n      publicKey: PublicKey.fromString(arg.publicKey, undefined, networks.get(arg.network)!)\n    }\n  }\n\n  private static _buildFromMinimalObject(arg: HDPublicKeyMinimalDto): IHDPublicKey {\n    let buffers = {\n      version: BufferUtils.integerAsBuffer(networks.get(arg.network)!.xpubkey),\n      depth: BufferUtils.integerAsSingleByteBuffer(arg.depth),\n      parentFingerPrint: BufferUtils.integerAsBuffer(arg.parentFingerPrint),\n      childIndex: BufferUtils.integerAsBuffer(arg.childIndex),\n      chainCode: Buffer.from(arg.chainCode, 'hex'),\n      publicKey: Buffer.from(arg.publicKey,'hex'),\n    };\n    return this._buildFromBuffers(buffers);\n  }\n\n  private static _buildFromHDPrivateKey(hdPrivateKey: IHDPrivateKey): IHDPublicKey {\n    let point = Point.getG().mul(hdPrivateKey.privateKey.bn);\n    let buffers: HDPublicKeyBuffers = {\n      version: BufferUtils.integerAsBuffer(hdPrivateKey.network.xpubkey),\n      depth: BufferUtils.integerAsSingleByteBuffer(hdPrivateKey.depth),\n      parentFingerPrint: hdPrivateKey.parentFingerPrint,\n      childIndex: BufferUtils.integerAsBuffer(hdPrivateKey.childIndex),\n      chainCode: hdPrivateKey.chainCode,\n      publicKey: Point.pointToCompressed(point),\n    };\n\n    return this._buildFromBuffers(buffers);\n  }\n\n  private static _buildFromSerialized(xpubkey: string): IHDPublicKey {\n    let decoded = Base58Check.decode(xpubkey);\n    let buffers: HDPublicKeyBuffers = {\n      version: decoded.subarray(HDKeyUtils.VersionStart, HDKeyUtils.VersionEnd),\n      depth: decoded.subarray(HDKeyUtils.DepthStart, HDKeyUtils.DepthEnd),\n      parentFingerPrint: decoded.subarray(HDKeyUtils.ParentFingerPrintStart, HDKeyUtils.ParentFingerPrintEnd),\n      childIndex: decoded.subarray(HDKeyUtils.ChildIndexStart, HDKeyUtils.ChildIndexEnd),\n      chainCode: decoded.subarray(HDKeyUtils.ChainCodeStart, HDKeyUtils.ChainCodeEnd),\n      publicKey: decoded.subarray(this.PublicKeyStart, this.PublicKeyEnd),\n      checksum: decoded.subarray(this.ChecksumStart, this.ChecksumEnd),\n    };\n\n    return this._buildFromBuffers(buffers);\n  }\n  \n  /**\n   * Receives a object with buffers in all the properties and populates the\n   * internal structure\n   *\n   * @param arg\n   */\n  private static _buildFromBuffers(arg: HDPublicKeyBuffers): IHDPublicKey {\n    HDPublicKey._validateBufferArguments(arg);\n\n    let sequence = [ arg.version, arg.depth, arg.parentFingerPrint, arg.childIndex, arg.chainCode, arg.publicKey ];\n    let concat = Buffer.concat(sequence);\n    let checksum = Base58Check.checksum(concat);\n\n    if (!arg.checksum || !arg.checksum.length) {\n      arg.checksum = checksum;\n    } else if (arg.checksum.toString('hex') !== checksum.toString('hex')) {\n      throw new InvalidB58Checksum(concat);\n    }\n\n    let network = networks.get(BufferUtils.integerFromBuffer(arg.version))!;\n    let publicKey = PublicKey.fromBuffer(arg.publicKey, true, network);\n\n    return {\n      xpubkey: Base58Check.encode(concat),\n      network: network,\n      depth: BufferUtils.integerFromSingleByteBuffer(arg.depth),\n      publicKey: publicKey,\n      fingerPrint: Hash.sha256ripemd160(publicKey.toBuffer()).subarray(0, HDKeyUtils.ParentFingerPrintSize),\n      chainCode: arg.chainCode,\n      childIndex: BufferUtils.integerFromBuffer(arg.childIndex),\n      parentFingerPrint: arg.parentFingerPrint,\n      checksum: arg.checksum\n    };\n  }\n\n  private static _validateBufferArguments(arg: HDPublicKeyBuffers): void {\n    const checkBuffer = (name: string, size: number): void => {\n      let buff = arg[name as keyof HDPublicKeyBuffers];\n      ValidationUtils.validateArgument(BufferUtils.isBuffer(buff), name + ` argument is not a buffer, it\\'s ${typeof buff}`);\n      ValidationUtils.validateArgument(buff!.length === size, name + ' has not the expected size: found ' + buff!.length + ', expected ' + size);\n    };\n    \n    checkBuffer('version', HDKeyUtils.VersionSize);\n    checkBuffer('depth', HDKeyUtils.DepthSize);\n    checkBuffer('parentFingerPrint', HDKeyUtils.ParentFingerPrintSize);\n    checkBuffer('childIndex', HDKeyUtils.ChildIndexSize);\n    checkBuffer('chainCode', HDKeyUtils.ChainCodeSize);\n    checkBuffer('publicKey', HDPublicKey.PublicKeySize);\n    if (arg.checksum?.length) {\n      checkBuffer('checksum', HDKeyUtils.CheckSumSize);\n    }\n  }\n}","import { inRange, isEmpty, isNil, isNumber, isString, isUndefined } from \"lodash-es\";\nimport PublicKey from \"../../keys/publickey\";\nimport ValidationUtils from \"../../utils/validation.utils\";\nimport Address from \"../address/address\";\nimport Script from \"./script\";\nimport ScriptOpcode, { Opcode } from \"./opcode\";\nimport CommonUtils from \"../../utils/common.utils\";\nimport BN from \"../../crypto/bn.extension\";\nimport BufferReader from \"../../encoding/bufferreader\";\nimport BufferUtils from \"../../utils/buffer.utils\";\nimport Signature from \"../../crypto/signature\";\nimport { AddressType } from \"../address/address-formatter\";\nimport GroupToken, { GroupIdType } from \"../grouptoken\";\n\n/**\n * A factory class for creating scripts with predefined configurations and flags.\n */\nexport default class ScriptFactory {\n\n  /**\n   * @param to destination address or public key\n   * @param groupId group id buffer or group address or hex id - only if its token output script\n   * @param groupAmount optional. quantity amount buffer or bigint - only if its token output script\n   * \n   * @returns a new pay to public key / script template output for the given address or public key\n   */\n  public static buildScriptTemplateOut(to: string | Address | PublicKey, groupId?: string | Address | Buffer, groupAmount?: Buffer | bigint): Script {\n    ValidationUtils.validateArgument(!isUndefined(to), \"to\", \"must provide an argument\");\n    ValidationUtils.validateArgument(to instanceof PublicKey || to instanceof Address || isString(to), \"to\", \"must be address or pubkey\");\n    ValidationUtils.validateArgument((isNil(groupId) && isNil(groupAmount)) || (!isNil(groupId) && !isNil(groupAmount)), \"group data\", \"both must present or both not present\");\n\n    to = this.parseAddress(to);\n    ValidationUtils.validateArgument(to.isPayToScriptTemplate(), 'Invalid destination address (not a script template)');\n\n    if (isString(groupId)) {\n      if (CommonUtils.isHexa(groupId)) {\n        groupId = Buffer.from(groupId, 'hex');\n      } else {\n        let groupIdAddr = Address.fromString(groupId);\n        ValidationUtils.validateArgument(groupIdAddr.isGroupIdentifierAddress(), 'Invalid group id address (not a group)');\n        groupId = groupIdAddr.data;\n      }\n    } else if (groupId instanceof Address) {\n      ValidationUtils.validateArgument(groupId.isGroupIdentifierAddress(), 'Invalid group id address (not a group)');\n      groupId = groupId.data;\n    }\n\n    if (typeof groupAmount === 'bigint') {\n      groupAmount = GroupToken.getAmountBuffer(groupAmount);\n    }\n    \n    let bfr = new BufferReader(to.data).readVarLengthBuffer();\n    let s = Script.fromBuffer(bfr);\n\n    if (!isNil(groupId) && !isNil(groupAmount)) {\n      ValidationUtils.validateArgument(BufferUtils.isBuffer(groupId), 'groupId');\n      ValidationUtils.validateArgument(BufferUtils.isBuffer(groupAmount), 'groupAmount');\n      // replace OP_0 with group data\n      s.chunks = s.chunks.slice(1);\n      s.prepend(groupAmount).prepend(groupId);\n    }\n\n    return s;\n  }\n\n  /**\n   * @param data the data to embed in the output\n   * @param encoding the type of encoding of the string\n   * \n   * @returns a new OP_RETURN script with data\n   */\n  public static buildDataOut(data?: string | Buffer | Script, encoding?: BufferEncoding): Script {\n    ValidationUtils.validateArgument(isUndefined(data) || isString(data) || BufferUtils.isBuffer(data) || data instanceof Script, \"data\");\n    if (isString(data)) {\n      data = Buffer.from(data, encoding);\n    }\n\n    let s = Script.empty().add(Opcode.OP_RETURN);\n    if (!isUndefined(data)) {\n      s.add(data);\n    }\n    return s;\n  }\n\n  /**\n   * @param address the pay to address\n   * @param groupId optional. only for p2st addresses\n   * @param groupAmount optional. only for p2st addresses\n   * \n   * @return an output script built from the address\n   */\n  public static buildOutFromAddress(address: Address | string, groupId?: string | Address | Buffer, groupAmount?: Buffer | bigint): Script {\n    if (isString(address)) {\n      address = Address.fromString(address);\n    }\n    \n    if (address.isPayToPublicKeyHash()) {\n      return this.buildPublicKeyHashOut(address);\n    } else if (address.isPayToScriptTemplate()) {\n      return this.buildScriptTemplateOut(address, groupId, groupAmount);\n    }\n    throw new Error(`Invalid address type: ${address.type}`);\n  }\n\n  /**\n   * Builds a scriptSig (a script for an input) that signs a script template\n   * output script.\n   *\n   * @param template the template script or OP_1 for well-known\n   * @param constraint the constraint script or OP_FALSE\n   * @param satisfier the satisfier script or buffer\n   */\n  public static buildScriptTemplateIn(template: Script | Opcode, constraint: Script | Opcode, satisfier: Buffer | Script): Script {\n    ValidationUtils.validateArgument(template instanceof Script || template === Opcode.OP_1, \"template\");\n    ValidationUtils.validateArgument(constraint instanceof Script || constraint === Opcode.OP_FALSE, \"constraint\");\n    ValidationUtils.validateArgument(satisfier instanceof Script || BufferUtils.isBuffer(satisfier), \"satisfier\");\n\n    let script = Script.empty()\n    if (template instanceof Script) {\n      script.add(template.toBuffer());\n    }\n    if (constraint instanceof Script) {\n      script.add(constraint.toBuffer());\n    }\n    if (BufferUtils.isBuffer(satisfier)) {\n      satisfier = Script.fromBuffer(satisfier);\n    }\n    script.add(satisfier);\n\n    return script;\n  }\n\n  private static parseAddress(address: string | Address | PublicKey, type?: AddressType): Address {\n    if (isString(address)) {\n      return Address.fromString(address);\n    } else if (address instanceof PublicKey) {\n      return Address.fromPublicKey(address, address.network, type);\n    }\n    return address;\n  }\n\n  /**\n   * @param to - destination address or public key\n   * \n   * @returns a new pay to public key hash output for the given\n   * address or public key\n   */\n  public static buildPublicKeyHashOut(to: string | Address | PublicKey): Script {\n    ValidationUtils.validateArgument(!isUndefined(to), \"to\", \"must provide an argument\");\n    ValidationUtils.validateArgument(to instanceof PublicKey || to instanceof Address || isString(to), \"to\", \"must be address or pubkey\");\n\n    to = this.parseAddress(to, AddressType.PayToPublicKeyHash);\n    return Script.empty().add(Opcode.OP_DUP).add(Opcode.OP_HASH160).add(to.data).add(Opcode.OP_EQUALVERIFY).add(Opcode.OP_CHECKSIG);\n  }\n\n  /**\n   * Builds a scriptSig (a script for an input) that signs a public key hash\n   * output script. (SIGHASH_ALL only)\n   *\n   * @param publicKey\n   * @param signature a Signature object, or the signature in DER canonical encoding\n   */\n  public static buildPublicKeyHashIn(publicKey: PublicKey, signature: Signature | Buffer): Script {\n    ValidationUtils.validateArgument(publicKey instanceof PublicKey, \"publicKey\");\n    ValidationUtils.validateArgument(signature instanceof Signature || BufferUtils.isBuffer(signature), \"signature\");\n\n    if (signature instanceof Signature) {\n      signature = signature.toBuffer();\n    }\n\n    let script = Script.empty()\n      .add(signature)\n      .add(publicKey.toBuffer());\n    return script;\n  }\n\n  /**\n   * Build OP_RETURN output script for Legacy Token Description\n   *\n   * @param ticker the ticker as utf8.\n   * @param name the ticker as utf8.\n   * @param docUrl optional. the description document url\n   * @param docHash optional. the document hash hex.\n   * @param decimals optional. the decimals for the token amount.\n   * \n   * @throws Error if docUrl provided and is invalid\n   * \n   * @returns the output OP_RETURN script\n   */\n  public static buildTokenDescriptionLegacy(ticker: string, name: string, docUrl?: string, docHash?: string, decimals?: number): Script {\n    ValidationUtils.validateArgument(isString(ticker) && inRange(ticker.length, 1, 9), 'Ticker must be between 1-8 chars');\n    ValidationUtils.validateArgument(isString(name) && !isEmpty(name), 'Name is missing');\n\n    let s = Script.empty()\n      .add(Opcode.OP_RETURN)\n      .add(BN.fromNumber(GroupIdType.LEGACY).toScriptNumBuffer())\n      .add(Buffer.from(ticker))\n      .add(Buffer.from(name));\n\n    if (docUrl && docUrl.length > 0) {\n      new URL(docUrl); // exception thrown if not valide\n      ValidationUtils.validateArgument(isString(docHash) && !isEmpty(docHash), 'You must include document hash if you set document url');\n      s.add(Buffer.from(docUrl)).add(Buffer.from(docHash as string, 'hex').reverse());\n    } else {\n      s.add(Opcode.OP_FALSE).add(Opcode.OP_FALSE);\n    }\n\n    if (isNumber(decimals)) {\n      ValidationUtils.validateArgument(inRange(decimals, 0, 19), 'decimals must be between 0 and 18');\n      s.add(decimals <= 16 ? ScriptOpcode.smallInt(decimals) : BN.fromNumber(decimals).toScriptNumBuffer());\n    }\n\n    return s;\n  }\n\n  /**\n   * Build OP_RETURN output script for NRC1 Token Description\n   *\n   * @param ticker the ticker as utf8.\n   * @param name the ticker as utf8.\n   * @param zipURL the zip file url.\n   * @param zipHash the zip file hash hex.\n   * @param decimals the decimals for the token amount.\n   * \n   * @throws Error if zipURL invalid\n   * \n   * @returns the output OP_RETURN script\n   */\n  public static buildTokenDescription(ticker: string, name: string, zipURL: string, zipHash: string, decimals: number): Script {\n    ValidationUtils.validateArgument(isString(ticker) && inRange(ticker.length, 2, 9), 'Ticker must be 2-8 chars');\n    ValidationUtils.validateArgument(isString(name) && inRange(name.length, 2, 26), 'Name must be 2-25 chars');\n    ValidationUtils.validateArgument(isString(zipURL) && !isEmpty(zipURL), 'Zip URL is missing');\n    ValidationUtils.validateArgument(isString(zipHash) && !isEmpty(zipHash), 'Zip hash is missing');\n    ValidationUtils.validateArgument(isNumber(decimals) && inRange(decimals, 0, 19), 'Decimals must be a number 0-18');\n    new URL(zipURL); // exception thrown if not valid\n\n    return Script.empty()\n      .add(Opcode.OP_RETURN)\n      .add(BN.fromNumber(GroupIdType.NRC1).toScriptNumBuffer())\n      .add(Buffer.from(ticker))\n      .add(Buffer.from(name))\n      .add(Buffer.from(zipURL))\n      .add(Buffer.from(zipHash, 'hex').reverse())\n      .add(decimals <= 16 ? ScriptOpcode.smallInt(decimals) : BN.fromNumber(decimals).toScriptNumBuffer());\n  }\n\n  /**\n   * Build OP_RETURN output script for an NFT Collection Description (NRC2)\n   *\n   * @param ticker the ticker as utf8.\n   * @param name the ticker as utf8.\n   * @param zipURL the zip file url.\n   * @param zipHash the zip file hash hex.\n   * \n   * @throws Error if zipURL invalid \n   * \n   * @returns the output OP_RETURN script\n   */\n  public static buildNFTCollectionDescription(ticker: string, name: string, zipURL: string, zipHash: string): Script {\n    ValidationUtils.validateArgument(isString(ticker) && inRange(ticker.length, 2, 9), 'Ticker must be 2-8 chars');\n    ValidationUtils.validateArgument(isString(name) && inRange(name.length, 2, 26), 'Name must be 2-25 chars');\n    ValidationUtils.validateArgument(isString(zipURL) && !isEmpty(zipURL), 'Zip URL is missing');\n    ValidationUtils.validateArgument(isString(zipHash) && !isEmpty(zipHash), 'Zip hash is missing');\n    new URL(zipURL); // exception thrown if not valid\n\n    return Script.empty()\n      .add(Opcode.OP_RETURN)\n      .add(BN.fromNumber(GroupIdType.NRC2).toScriptNumBuffer())\n      .add(Buffer.from(ticker))\n      .add(Buffer.from(name))\n      .add(Buffer.from(zipURL))\n      .add(Buffer.from(zipHash, 'hex').reverse())\n      .add(ScriptOpcode.smallInt(0));\n  }\n\n  /**\n   * Build OP_RETURN output script for an NFT that belongs to an NFT Collection (NRC3)\n   *\n   * @param zipURL the zip file url.\n   * @param zipHash the zip file hash hex.\n   * \n   * @throws Error if zipURL invalid \n   * \n   * @returns the output OP_RETURN script\n   */\n  public static buildNFTDescription(zipURL: string, zipHash: string): Script {\n    ValidationUtils.validateArgument(isString(zipURL) && !isEmpty(zipURL), 'Zip URL is missing');\n    ValidationUtils.validateArgument(isString(zipHash) && !isEmpty(zipHash), 'Zip hash is missing');\n    new URL(zipURL); // exception thrown if not valid\n\n    return Script.empty()\n      .add(Opcode.OP_RETURN)\n      .add(BN.fromNumber(GroupIdType.NRC3).toScriptNumBuffer())\n      .add(Buffer.from(zipURL))\n      .add(Buffer.from(zipHash, 'hex').reverse());\n  }\n}","import baseKeys from './_baseKeys.js';\nimport getTag from './_getTag.js';\nimport isArguments from './isArguments.js';\nimport isArray from './isArray.js';\nimport isArrayLike from './isArrayLike.js';\nimport isBuffer from './isBuffer.js';\nimport isPrototype from './_isPrototype.js';\nimport isTypedArray from './isTypedArray.js';\n\n/** `Object#toString` result references. */\nvar mapTag = '[object Map]',\n    setTag = '[object Set]';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Checks if `value` is an empty object, collection, map, or set.\n *\n * Objects are considered empty if they have no own enumerable string keyed\n * properties.\n *\n * Array-like values such as `arguments` objects, arrays, buffers, strings, or\n * jQuery-like collections are considered empty if they have a `length` of `0`.\n * Similarly, maps and sets are considered empty if they have a `size` of `0`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is empty, else `false`.\n * @example\n *\n * _.isEmpty(null);\n * // => true\n *\n * _.isEmpty(true);\n * // => true\n *\n * _.isEmpty(1);\n * // => true\n *\n * _.isEmpty([1, 2, 3]);\n * // => false\n *\n * _.isEmpty({ 'a': 1 });\n * // => false\n */\nfunction isEmpty(value) {\n  if (value == null) {\n    return true;\n  }\n  if (isArrayLike(value) &&\n      (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||\n        isBuffer(value) || isTypedArray(value) || isArguments(value))) {\n    return !value.length;\n  }\n  var tag = getTag(value);\n  if (tag == mapTag || tag == setTag) {\n    return !value.size;\n  }\n  if (isPrototype(value)) {\n    return !baseKeys(value).length;\n  }\n  for (var key in value) {\n    if (hasOwnProperty.call(value, key)) {\n      return false;\n    }\n  }\n  return true;\n}\n\nexport default isEmpty;\n","import isPrototype from './_isPrototype.js';\nimport nativeKeys from './_nativeKeys.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeys(object) {\n  if (!isPrototype(object)) {\n    return nativeKeys(object);\n  }\n  var result = [];\n  for (var key in Object(object)) {\n    if (hasOwnProperty.call(object, key) && key != 'constructor') {\n      result.push(key);\n    }\n  }\n  return result;\n}\n\nexport default baseKeys;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n  var Ctor = value && value.constructor,\n      proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n  return value === proto;\n}\n\nexport default isPrototype;\n","import overArg from './_overArg.js';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeKeys = overArg(Object.keys, Object);\n\nexport default nativeKeys;\n","/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n  return function(arg) {\n    return func(transform(arg));\n  };\n}\n\nexport default overArg;\n","import DataView from './_DataView.js';\nimport Map from './_Map.js';\nimport Promise from './_Promise.js';\nimport Set from './_Set.js';\nimport WeakMap from './_WeakMap.js';\nimport baseGetTag from './_baseGetTag.js';\nimport toSource from './_toSource.js';\n\n/** `Object#toString` result references. */\nvar mapTag = '[object Map]',\n    objectTag = '[object Object]',\n    promiseTag = '[object Promise]',\n    setTag = '[object Set]',\n    weakMapTag = '[object WeakMap]';\n\nvar dataViewTag = '[object DataView]';\n\n/** Used to detect maps, sets, and weakmaps. */\nvar dataViewCtorString = toSource(DataView),\n    mapCtorString = toSource(Map),\n    promiseCtorString = toSource(Promise),\n    setCtorString = toSource(Set),\n    weakMapCtorString = toSource(WeakMap);\n\n/**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nvar getTag = baseGetTag;\n\n// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.\nif ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n    (Map && getTag(new Map) != mapTag) ||\n    (Promise && getTag(Promise.resolve()) != promiseTag) ||\n    (Set && getTag(new Set) != setTag) ||\n    (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n  getTag = function(value) {\n    var result = baseGetTag(value),\n        Ctor = result == objectTag ? value.constructor : undefined,\n        ctorString = Ctor ? toSource(Ctor) : '';\n\n    if (ctorString) {\n      switch (ctorString) {\n        case dataViewCtorString: return dataViewTag;\n        case mapCtorString: return mapTag;\n        case promiseCtorString: return promiseTag;\n        case setCtorString: return setTag;\n        case weakMapCtorString: return weakMapTag;\n      }\n    }\n    return result;\n  };\n}\n\nexport default getTag;\n","import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar DataView = getNative(root, 'DataView');\n\nexport default DataView;\n","import baseIsNative from './_baseIsNative.js';\nimport getValue from './_getValue.js';\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n  var value = getValue(object, key);\n  return baseIsNative(value) ? value : undefined;\n}\n\nexport default getNative;\n","import isFunction from './isFunction.js';\nimport isMasked from './_isMasked.js';\nimport isObject from './isObject.js';\nimport toSource from './_toSource.js';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n    objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n  funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n  .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n *  else `false`.\n */\nfunction baseIsNative(value) {\n  if (!isObject(value) || isMasked(value)) {\n    return false;\n  }\n  var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n  return pattern.test(toSource(value));\n}\n\nexport default baseIsNative;\n","import baseGetTag from './_baseGetTag.js';\nimport isObject from './isObject.js';\n\n/** `Object#toString` result references. */\nvar asyncTag = '[object AsyncFunction]',\n    funcTag = '[object Function]',\n    genTag = '[object GeneratorFunction]',\n    proxyTag = '[object Proxy]';\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n  if (!isObject(value)) {\n    return false;\n  }\n  // The use of `Object#toString` avoids issues with the `typeof` operator\n  // in Safari 9 which returns 'object' for typed arrays and other constructors.\n  var tag = baseGetTag(value);\n  return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\nexport default isFunction;\n","import coreJsData from './_coreJsData.js';\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n  var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n  return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n  return !!maskSrcKey && (maskSrcKey in func);\n}\n\nexport default isMasked;\n","import root from './_root.js';\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\nexport default coreJsData;\n","/** Used for built-in method references. */\nvar funcProto = Function.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n  if (func != null) {\n    try {\n      return funcToString.call(func);\n    } catch (e) {}\n    try {\n      return (func + '');\n    } catch (e) {}\n  }\n  return '';\n}\n\nexport default toSource;\n","/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n  return object == null ? undefined : object[key];\n}\n\nexport default getValue;\n","import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map');\n\nexport default Map;\n","import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Promise = getNative(root, 'Promise');\n\nexport default Promise;\n","import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar Set = getNative(root, 'Set');\n\nexport default Set;\n","import getNative from './_getNative.js';\nimport root from './_root.js';\n\n/* Built-in method references that are verified to be native. */\nvar WeakMap = getNative(root, 'WeakMap');\n\nexport default WeakMap;\n","import baseIsArguments from './_baseIsArguments.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n *  else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nvar isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n  return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n    !propertyIsEnumerable.call(value, 'callee');\n};\n\nexport default isArguments;\n","import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]';\n\n/**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\nfunction baseIsArguments(value) {\n  return isObjectLike(value) && baseGetTag(value) == argsTag;\n}\n\nexport default baseIsArguments;\n","import isFunction from './isFunction.js';\nimport isLength from './isLength.js';\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n  return value != null && isLength(value.length) && !isFunction(value);\n}\n\nexport default isArrayLike;\n","/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n  return typeof value == 'number' &&\n    value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\nexport default isLength;\n","import baseIsTypedArray from './_baseIsTypedArray.js';\nimport baseUnary from './_baseUnary.js';\nimport nodeUtil from './_nodeUtil.js';\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\nexport default isTypedArray;\n","import baseGetTag from './_baseGetTag.js';\nimport isLength from './isLength.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n    arrayTag = '[object Array]',\n    boolTag = '[object Boolean]',\n    dateTag = '[object Date]',\n    errorTag = '[object Error]',\n    funcTag = '[object Function]',\n    mapTag = '[object Map]',\n    numberTag = '[object Number]',\n    objectTag = '[object Object]',\n    regexpTag = '[object RegExp]',\n    setTag = '[object Set]',\n    stringTag = '[object String]',\n    weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n    dataViewTag = '[object DataView]',\n    float32Tag = '[object Float32Array]',\n    float64Tag = '[object Float64Array]',\n    int8Tag = '[object Int8Array]',\n    int16Tag = '[object Int16Array]',\n    int32Tag = '[object Int32Array]',\n    uint8Tag = '[object Uint8Array]',\n    uint8ClampedTag = '[object Uint8ClampedArray]',\n    uint16Tag = '[object Uint16Array]',\n    uint32Tag = '[object Uint32Array]';\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\ntypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\ntypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\ntypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\ntypedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] =\ntypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\ntypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\ntypedArrayTags[errorTag] = typedArrayTags[funcTag] =\ntypedArrayTags[mapTag] = typedArrayTags[numberTag] =\ntypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\ntypedArrayTags[setTag] = typedArrayTags[stringTag] =\ntypedArrayTags[weakMapTag] = false;\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n  return isObjectLike(value) &&\n    isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n}\n\nexport default baseIsTypedArray;\n","/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n  return function(value) {\n    return func(value);\n  };\n}\n\nexport default baseUnary;\n","import BufferWriter from \"../encoding/bufferwriter\";\nimport { isEmpty, isNumber, isString, isUndefined } from \"lodash-es\";\nimport Script from \"./script/script\";\nimport BN from \"../crypto/bn.extension\";\nimport Hash from \"../crypto/hash\";\nimport type { GroupIdData } from \"../common/interfaces\";\nimport Address from \"./address/address\";\nimport BufferUtils from \"../utils/buffer.utils\";\nimport ValidationUtils from \"../utils/validation.utils\";\nimport CommonUtils from \"../utils/common.utils\";\nimport Message from \"./message\";\nimport type PrivateKey from \"../keys/privatekey\";\n\nexport enum GroupIdFlag {\n  NONE = 0,\n  COVENANT = 1, // covenants/encumberances -- output script template must match input\n  HOLDS_NEX = 2, // group inputs and outputs must balance NEX, token quantity MUST be 0\n  GROUP_RESERVED_BITS = 0xFFFF & ~(COVENANT | HOLDS_NEX),\n  DEFAULT = NONE,\n}\n\n/**\n * Represent Group creation id type in OP_RETURN script\n */\nexport enum GroupIdType {\n  /** Legacy token */\n  LEGACY = 88888888,\n  /** Token */\n  NRC1 = 88888890,\n  /** NFT Collection */\n  NRC2 = 88888891,\n  /** NFT that belongs to a collection */\n  NRC3 = 88888892,\n}\n\n// ts/js does not support enums with bigint, so we use const object for now\nconst AUTH_FLAGS = {\n  /** Is this a controller utxo (forces negative number in amount) */\n  AUTHORITY: 1n << 63n,\n  /** Can mint tokens */\n  MINT: 1n << 62n,\n  /** Can melt tokens */\n  MELT: 1n << 61n,\n  /** Can create authorities */\n  BATON: 1n << 60n,\n  /** Can change the redeem script */\n  RESCRIPT: 1n << 59n,\n  /** Can create subgroups */\n  SUBGROUP: 1n << 58n,\n  NONE: 0n,\n  ALL_FLAG_BITS: 0xffffn << (64n - 16n),\n}\n\nconst ACTIVE_FLAG_BITS = AUTH_FLAGS.AUTHORITY | AUTH_FLAGS.MINT | AUTH_FLAGS.MELT | AUTH_FLAGS.BATON | AUTH_FLAGS.RESCRIPT | AUTH_FLAGS.SUBGROUP;\n\n/**\n * A util class with methods for group tokenization.\n */\nexport default class GroupToken {\n\n  public static readonly PARENT_GROUP_ID_SIZE = 32;\n\n  public static readonly authFlags = {\n    ...AUTH_FLAGS,\n    /** Has all permissions */\n    ACTIVE_FLAG_BITS,\n    RESERVED_FLAG_BITS: ACTIVE_FLAG_BITS & ~AUTH_FLAGS.ALL_FLAG_BITS\n  };\n\n  /**\n   * Calculate a group ID based on the provided inputs. Pass 'null' to opReturnScript if there is not\n   * going to be an OP_RETURN output in the transaction.\n   *\n   * @param outpoint The input outpoint hash hex or buffer\n   * @param opReturnScript opReturn output script\n   * @param authFlag group authority flag (use {@link GroupToken.authFlags})\n   * @param idFlag group id flag\n   * \n   * @returns Object with group id hash buffer and the nonce bigint\n   */\n  public static findGroupId(outpoint: string | Buffer, opReturnScript: Script | Buffer | null, authFlag: bigint, idFlag = GroupIdFlag.DEFAULT): GroupIdData {\n    let hash: Buffer;\n    let groupFlags = 0;\n    let nonce = 0n;\n\n    if (isString(outpoint)) {\n      outpoint = Buffer.from(outpoint, 'hex').reverse();\n    }\n    if (opReturnScript instanceof Script) {\n      opReturnScript = opReturnScript.toBuffer();\n    }\n\n    do {\n      let writer = new BufferWriter();\n      nonce += 1n;\n      nonce = (nonce & ~this.authFlags.ALL_FLAG_BITS) | authFlag;\n\n      writer.write(outpoint);\n      if (opReturnScript != null) {\n        writer.writeVarLengthBuf(opReturnScript);\n      }\n      writer.writeUInt64LEBN(BN.fromBigInt(nonce));\n\n      hash = Hash.sha256sha256(writer.toBuffer());\n      groupFlags = (hash[30] << 8) | hash[31];\n    } while (groupFlags != idFlag);\n\n    return {hashBuffer: hash, nonce: nonce};\n  }\n\n  private static _getGroupAddressBuffer(group: Address | string | Buffer): Buffer {\n    if (BufferUtils.isBuffer(group)) {\n      return group;\n    }\n    if (CommonUtils.isHexa(group)) {\n      return Buffer.from(group as string, 'hex');\n    }\n    \n    let groupAddress = new Address(group);\n    ValidationUtils.validateArgument(groupAddress.isGroupIdentifierAddress(), 'Invalid group address');\n    return groupAddress.data;\n  }\n\n  /**\n   * Translates a group and additional data into a subgroup identifier\n   *\n   * @param group the group/token address or data buffer\n   * @param data the additional data\n   * \n   * @returns the subgroup id buffer\n   */\n  public static generateSubgroupId(group: Address | string | Buffer, data: number | string | Buffer): Buffer {\n    ValidationUtils.validateArgument(!isUndefined(group), 'group is missing');\n    ValidationUtils.validateArgument(!isUndefined(data), 'data is missing');\n\n    group = this._getGroupAddressBuffer(group);\n\n    if (BufferUtils.isBuffer(data)) {\n      return Buffer.concat([group, data]);\n    }\n\n    if (isNumber(data)) {\n      let bn = BN.fromNumber(data).toBuffer({ size: 8, endian: \"little\" });\n      return Buffer.concat([group, bn]);\n    }\n\n    if (CommonUtils.isHexa(data)) {\n      return Buffer.concat([group, Buffer.from(data, 'hex')]);\n    }\n\n    return Buffer.concat([group, Buffer.from(data)]);\n  }\n\n  /**\n   * Extract the parent group from the provided subgroup.\n   * \n   * @remarks\n   * If the input is a group but not subgroup, the group itself return.\n   * \n   * @param subgroup the subgroup address or data buffer\n   * @returns the GroupId buffer\n   */\n  public static getParentGroupId(subgroup: Address | string | Buffer): Buffer {\n    let buf = this._getGroupAddressBuffer(subgroup);\n    if (buf.length < this.PARENT_GROUP_ID_SIZE) {\n      throw new Error(\"Invalid subgroup\");\n    }\n    return Buffer.from(buf.subarray(0, 32));\n  }\n\n  /**\n   * Get group amount buffer from BigInt to include in output script\n   *\n   * @param amount\n   */\n  public static getAmountBuffer(amount: bigint): Buffer {\n    let bw = new BufferWriter();\n    if (amount < 0n) {\n      let bn = BN.fromBigInt(BigInt.asUintN(64, amount));\n      bw.writeUInt64LEBN(bn);\n    } else if (amount < 0x10000n) {\n      bw.writeUInt16LE(Number(amount));\n    } else if (amount < 0x100000000n) {\n      bw.writeUInt32LE(Number(amount));\n    } else {\n      let bn = BN.fromBigInt(amount);\n      bw.writeUInt64LEBN(bn);\n    }\n    return bw.toBuffer();\n  }\n\n  /**\n   * Get group amount value from Buffer\n   *\n   * @param amountBuf the amount buffer\n   * @param unsigned return value as unsigned bigint, default to false\n   */\n  public static getAmountValue(amountBuf: Buffer, unsigned = false): bigint {\n    let amount = BN.fromBuffer(amountBuf, { endian: 'little' }).toBigInt();\n    return unsigned ? amount : BigInt.asIntN(64, amount);\n  }\n\n  /**\n   * @param authFlag the utxo group quantity/authority\n   * @returns the nonce\n   */\n   public static getNonce(authFlag: bigint): bigint {\n    authFlag = BigInt.asUintN(64, authFlag);\n    return authFlag & ~this.authFlags.ALL_FLAG_BITS;\n  }\n\n  /**\n   * Check if the group id has the flag\n   * \n   * @param groupId the group id address or data buffer\n   * @param groupIdFlag the group id flag\n   * @returns true if this group id has the flag\n   */\n   public static hasIdFlag(groupId: Address | string | Buffer, groupIdFlag: GroupIdFlag): boolean {\n    groupId = this._getGroupAddressBuffer(groupId);\n    return groupId.length >= this.PARENT_GROUP_ID_SIZE ? (((groupId[30] << 8) | groupId[31]) & groupIdFlag) == groupIdFlag : false;\n  }\n\n  /**\n   * Check if this authority and flag fit to this group creation\n   * \n   * @param groupId the group id address or data buffer\n   * @param authFlag the output group quantity/authority\n   * @param groupIdFlag optional. the group id flag\n   * @returns true if this is group creation data\n   */\n   public static isGroupCreation(groupId: Address | string | Buffer, authFlag: bigint, groupIdFlag = GroupIdFlag.DEFAULT): boolean {\n    groupId = this._getGroupAddressBuffer(groupId);\n    authFlag = BigInt.asUintN(64, authFlag);\n    let hasNonce = this.getNonce(authFlag) != 0n;\n    let isAuth = this.isAuthority(authFlag);\n    let hasFlag = this.hasIdFlag(groupId, groupIdFlag);\n    return isAuth && hasNonce && hasFlag;\n  }\n\n  /**\n   * Check if this group is is subgroup\n   * \n   * @param groupId the group id address or data buffer\n   * @returns true if this group id is subgroup\n   */\n   public static isSubgroup(groupId: Address | string | Buffer): boolean {\n    groupId = this._getGroupAddressBuffer(groupId);\n    return groupId.length > this.PARENT_GROUP_ID_SIZE;\n  }\n\n  /**\n   * Check if the group quantity/authority is Authority flag\n   * \n   * @param authFlag the output group quantity/authority\n   * @returns true if this is authority flag\n   */\n  public static isAuthority(authFlag: bigint): boolean {\n    return (authFlag & this.authFlags.AUTHORITY) == this.authFlags.AUTHORITY;\n  }\n\n  /**\n   * Check if the group quantity/authority allows minting\n   * \n   * @param authFlag the output group quantity/authority\n   * @returns true if this flag allows minting.\n   */\n  public static allowsMint(authFlag: bigint): boolean {\n    return (authFlag & (GroupToken.authFlags.AUTHORITY | GroupToken.authFlags.MINT)) == (GroupToken.authFlags.AUTHORITY | GroupToken.authFlags.MINT);\n  }\n\n  /**\n   * Check if the group quantity/authority allows melting\n   * \n   * @param authFlag the output group quantity/authority\n   * @returns true if this flag allows melting.\n   */\n  public static allowsMelt(authFlag: bigint): boolean {\n    return (authFlag & (GroupToken.authFlags.AUTHORITY | GroupToken.authFlags.MELT)) == (GroupToken.authFlags.AUTHORITY | GroupToken.authFlags.MELT);\n  }\n\n  /**\n   * Check if the group quantity/authority allows creation of new authorities\n   * \n   * @param authFlag the output group quantity/authority\n   * @returns true if this flag allows creation of authorities.\n   */\n  public static allowsRenew(authFlag: bigint): boolean {\n    return (authFlag & (GroupToken.authFlags.AUTHORITY | GroupToken.authFlags.BATON)) == (GroupToken.authFlags.AUTHORITY | GroupToken.authFlags.BATON);\n  }\n\n  /**\n   * Check if the group quantity/authority allows rescript\n   * \n   * @param authFlag the output group quantity/authority\n   * @returns true if this flag allows rescripting.\n   */\n  public static allowsRescript(authFlag: bigint): boolean {\n    return (authFlag & (GroupToken.authFlags.AUTHORITY | GroupToken.authFlags.RESCRIPT)) == (GroupToken.authFlags.AUTHORITY | GroupToken.authFlags.RESCRIPT);\n  }\n\n  /**\n   * Check if the group quantity/authority allows creation of subgroups\n   * \n   * @param authFlag the output group quantity/authority\n   * @returns true if this flag allows subgroups\n   */\n  public static allowsSubgroup(authFlag: bigint): boolean {\n    return (authFlag & (GroupToken.authFlags.AUTHORITY | GroupToken.authFlags.SUBGROUP)) == (GroupToken.authFlags.AUTHORITY | GroupToken.authFlags.SUBGROUP);\n  }\n\n  /**\n  * Verify token description document json signature\n  *\n  * @param jsonDoc the json TDD as string\n  * @param address nexa address that signed the doc\n  * @param signature the signature string. optional - if empty, extract from jsonDoc\n  * \n  * @returns true if signature match\n  */\n  public static verifyJsonDoc(jsonDoc: string, address: Address | string, signature?: string): boolean {\n    ValidationUtils.validateArgument(!isEmpty(jsonDoc), 'jsonDoc is missing');\n    ValidationUtils.validateArgument(!isEmpty(address), 'group is missing');\n\n    let json = jsonDoc.substring(jsonDoc.indexOf('{'), jsonDoc.lastIndexOf('}') + 1);\n    if (isUndefined(signature) || isEmpty(signature)) {\n      signature = JSON.parse(jsonDoc)[1];\n    }\n    let msg = new Message(json);\n    return msg.verify(address, signature as string);\n  }\n\n  /**\n   * Sign token description document json\n   *\n   * @param jsonDoc the json TDD as string\n   * @param privKey private key to sign on the doc\n   * \n   * @returns the signature string\n   */\n  public static signJsonDoc(jsonDoc: string, privKey: PrivateKey): string {\n    ValidationUtils.validateArgument(!isEmpty(jsonDoc), 'jsonDoc is missing');\n    let json = jsonDoc.substring(jsonDoc.indexOf('{'), jsonDoc.lastIndexOf('}') + 1); // trimming\n    let msg = new Message(json);\n    return msg.sign(privKey);\n  }\n}","import { isNil, isString } from \"lodash-es\";\nimport ValidationUtils from \"../utils/validation.utils\";\nimport BufferWriter from \"../encoding/bufferwriter\";\nimport Hash from \"../crypto/hash\";\nimport PrivateKey from \"../keys/privatekey\";\nimport ECDSA from \"../crypto/ecdsa\";\nimport Signature from \"../crypto/signature\";\nimport PublicKey from \"../keys/publickey\";\nimport Address from \"./address/address\";\nimport CommonUtils from \"../utils/common.utils\";\nimport type { IMessage } from \"../common/interfaces\";\n\nexport default class Message implements IMessage {\n\n  public static readonly MAGIC_BYTES = Buffer.from('Bitcoin Signed Message:\\n');\n\n  message: string;\n  error?: string;\n\n  constructor(message: string) {\n    ValidationUtils.validateArgument(isString(message), 'First argument should be a string');\n    this.message = message;\n  }\n\n  /**\n   * Will sign a message with a given private key.\n   *\n   * @param privateKey An instance of PrivateKey\n   * @returns A base64 encoded compact signature\n   */\n  public sign(privateKey: PrivateKey): string {\n    let signature = this._sign(privateKey);\n    return signature.toCompact().toString('base64');\n  }\n\n  /**\n   * Will return a boolean of the signature is valid for a given nexa address.\n   * If it isn't valid, the specific reason is accessible via the \"error\" member.\n   *\n   * @param nexaAddress A nexa address\n   * @param signatureString A base64 encoded compact signature\n   */\n  public verify(nexaAddress: Address | string, signatureString: string): boolean {\n    ValidationUtils.validateArgument(!isNil(nexaAddress), 'nexaAddress');\n    ValidationUtils.validateArgument(isString(signatureString) && signatureString.length > 0, 'signatureString');\n\n    if (isString(nexaAddress)) {\n      nexaAddress = Address.fromString(nexaAddress);\n    }\n\n    let signature = Signature.fromCompact(Buffer.from(signatureString, 'base64'));\n\n    // recover the public key\n    let ecdsa = new ECDSA();\n    ecdsa.hashbuf = this._magicHash();\n    ecdsa.sig = signature;\n    let publicKey = ecdsa.toPublicKey();\n\n    let signatureAddress = Address.fromPublicKey(publicKey, nexaAddress.network, nexaAddress.type);\n\n    // check that the recovered address and specified address match\n    if (nexaAddress.toString() !== signatureAddress.toString()) {\n      this.error = 'The signature did not match the message digest';\n      return false;\n    }\n\n    return this._verify(publicKey, signature);\n  }\n\n  private _sign(privateKey: PrivateKey): Signature {\n    ValidationUtils.validateArgument(privateKey instanceof PrivateKey, 'First argument should be an instance of PrivateKey');\n    let hash = this._magicHash();\n    let ecdsa = new ECDSA();\n    ecdsa.hashbuf = hash;\n    ecdsa.privkey = privateKey;\n    ecdsa.pubkey = privateKey.toPublicKey();\n    ecdsa.signRandomK();\n    ecdsa.calcI();\n    return ecdsa.sig as Signature;\n  }\n\n  private _magicHash(): Buffer {\n    let prefix1 = BufferWriter.varintBufNum(Message.MAGIC_BYTES.length);\n    let messageBuffer = Buffer.from(this.message);\n    let prefix2 = BufferWriter.varintBufNum(messageBuffer.length);\n    let buf = Buffer.concat([prefix1, Message.MAGIC_BYTES, prefix2, messageBuffer]);\n    let hash = Hash.sha256sha256(buf);\n    return hash;\n  }\n\n  private _verify(publicKey: PublicKey, signature: Signature): boolean {\n    ValidationUtils.validateArgument(publicKey instanceof PublicKey, 'First argument should be an instance of PublicKey');\n    ValidationUtils.validateArgument(signature instanceof Signature, 'Second argument should be an instance of Signature');\n    let hash = this._magicHash();\n    let verified = ECDSA.verify(hash, signature, publicKey);\n    if (!verified) {\n      this.error = 'The signature was invalid';\n    }\n    return verified;\n  }\n\n  /**\n   * Instantiate a message from a message string\n   *\n   * @param str A string of the message\n   * @returns A new instance of a Message\n   */\n  public static fromString(str: string): Message {\n    return new Message(str);\n  }\n\n  /**\n   * Instantiate a message from JSON\n   *\n   * @param json An JSON string or Object with keys: message\n   * @returns A new instance of a Message\n   */\n  public static fromJSON(json: string | IMessage): Message {\n    if (CommonUtils.isValidJSON(json as string)) {\n      json = JSON.parse(json as string);\n    }\n    return new Message((json as IMessage).message);\n  }\n\n  /**\n   * @returns A plain object with the message information\n   */\n  public toObject(): IMessage {\n    return { message: this.message };\n  }\n\n  /**\n   * @returns A JSON representation as string of the message information\n   */\n  public toJSON(): string {\n    return JSON.stringify(this.toObject());\n  }\n\n  /**\n   * Will return a the string representation of the message\n   */\n  public toString(): string {\n    return this.message;\n  }\n\n  /**\n   * Will return a string formatted for the console\n   */\n  public inspect(): string {\n    return `<Message: ${this}>`;\n  }\n}","import { isNil, isString } from \"lodash-es\";\nimport BufferReader from \"../../encoding/bufferreader\";\nimport BufferWriter from \"../../encoding/bufferwriter\";\nimport BufferUtils from \"../../utils/buffer.utils\";\nimport CommonUtils from \"../../utils/common.utils\";\nimport ValidationUtils from \"../../utils/validation.utils\";\n\nexport enum InputSighashType {\n  ALL = 0,\n  FIRSTN = 1,\n  THISIN = 2,\n  LAST_VALID = THISIN, // end indicator\n}\n\nexport enum OutputSighashType {\n  ALL = 0,\n  FIRSTN = 1,\n  TWO = 2,\n  LAST_VALID = TWO, // end indicator\n}\n\nexport default class SighashType {\n\n  /**\n   * the longest sighashtype in bytes \n   * (for use in calculating tx fees by tx length estimation) \n   */\n  public static readonly MAX_SIZE = 4;\n\n  inType: InputSighashType;\n  outType: OutputSighashType;\n\n  inData: number[];\n  outData: number[];\n\n  constructor() {\n    this.inType = InputSighashType.ALL;\n    this.outType = OutputSighashType.ALL;\n    this.inData = [];\n    this.outData = [];\n  }\n\n  /**\n   * creates a sighash that is the most restrictive -- it signs all inputs and outputs\n   */\n  public static get ALL(): SighashType {\n    return new SighashType();\n  }\n\n  public hasAll(): boolean {\n    return this.inType == InputSighashType.ALL && this.outType == OutputSighashType.ALL;\n  }\n\n  public isInvalid(): boolean {\n    return this.inType > InputSighashType.LAST_VALID || this.outType > OutputSighashType.LAST_VALID\n  }\n\n  /** \n   * Anyone can pay signs only the current input, so other entities can add addtl inputs to complete the partial tx\n   */\n  public setAnyoneCanPay(): this {\n    this.inType = InputSighashType.THISIN;\n    this.inData = [];\n    return this;\n  }\n\n  /**\n   * Include only the n first inputs in the preimage sighash\n   * \n   * @param n The first inputs to include\n   */\n  public setFirstNIn(n: number): this {\n    ValidationUtils.validateArgument(n >= 0 && n < 256, \"n\", \"out of range (0-255).\");\n    this.inType = InputSighashType.FIRSTN;\n    this.inData = [n];\n    return this;\n  }\n\n  /**\n   * Include only the n first outputs in the preimage sighash\n   * \n   * @param n The first outputs to include\n   */\n  public setFirstNOut(n: number): this {\n    ValidationUtils.validateArgument(n >= 0 && n < 256, \"n\", \"out of range (0-255).\");\n    this.outType = OutputSighashType.FIRSTN;\n    this.outData = [n];\n    return this;\n  }\n\n  /**\n   * Include specific 2 outputs in the preimage sighash\n   * \n   * @param a The 1st output to include\n   * @param b The 2nd output to include\n   */\n  public set2Out(a: number, b: number): this {\n    ValidationUtils.validateArgument(a >= 0 && a < 256, \"a\", \"out of range (0-255).\");\n    ValidationUtils.validateArgument(b >= 0 && b < 256, \"b\", \"out of range (0-255).\");\n    this.outType = OutputSighashType.TWO;\n    this.outData = [a, b];\n    return this;\n  }\n\n  public toBuffer(): Buffer {\n    if (this.hasAll()) {\n      return Buffer.alloc(0);\n    }\n\n    let bw = new BufferWriter();\n    let sigtype = (this.inType << 4) | this.outType;\n    bw.writeUInt8(sigtype);\n\n    switch (this.inType) {\n      case InputSighashType.FIRSTN:\n        ValidationUtils.validateState(this.inData.length > 0, \"Missing input data\");\n        bw.writeUInt8(this.inData[0]);\n        break;\n      case InputSighashType.THISIN:\n      case InputSighashType.ALL:\n        break;\n      default:\n        throw new Error(\"Malformed sighash type\");\n    }\n\n    switch (this.outType)  {\n      case OutputSighashType.TWO:\n        ValidationUtils.validateState(this.outData.length > 1, \"Missing output data\");\n        bw.writeUInt8(this.outData[0]);\n        bw.writeUInt8(this.outData[1]);\n        break;\n      case OutputSighashType.FIRSTN:\n        ValidationUtils.validateState(this.outData.length > 0, \"Missing output data\");\n        bw.writeUInt8(this.outData[0]);\n      break;\n      case OutputSighashType.ALL:\n        break;\n      default:\n        throw new Error(\"Malformed sighash type\");\n    }\n\n    return bw.toBuffer();\n  }\n\n  public static fromBuffer(buf: Buffer): SighashType {\n    ValidationUtils.validateArgument(BufferUtils.isBuffer(buf), \"buf\");\n    if (buf.length == 0) {\n      return this.ALL;\n    }\n\n    let sighash = new SighashType();\n    let br = new BufferReader(buf);\n    let type = br.readUInt8();\n\n    sighash.outType = type & 0x0f;\n    sighash.inType = type >> 4;\n\n    if (sighash.isInvalid()) {\n      throw new Error(\"Invalid sighash buffer\");\n    }\n\n    const safeRead = (br: BufferReader): number => {\n      if (br.finished()) {\n        throw new Error(\"Invalid sighash buffer\");\n      }\n      return br.readUInt8();\n    }\n\n    if (sighash.inType == InputSighashType.FIRSTN) {\n      sighash.inData.push(safeRead(br));\n    }\n\n    if (sighash.outType == OutputSighashType.FIRSTN) {\n      sighash.outData.push(safeRead(br));\n    } else if (sighash.outType == OutputSighashType.TWO) {\n      sighash.outData.push(safeRead(br));\n      sighash.outData.push(safeRead(br));\n    }\n\n    if (!br.finished()) {\n      throw new Error(\"Invalid sighash buffer\");\n    }\n\n    return sighash;\n  }\n\n  /**\n   * Convert to a hex representation of the sighash\n   */\n  public toHex(): string {\n    return this.toBuffer().toString('hex');\n  }\n\n  /**\n   * Create sighash for hex represantation\n   * @see toHex \n   */\n  public static fromHex(hex: string): SighashType {\n    if(typeof hex === 'string' && hex.length === 0) {\n      return this.ALL;\n    }\n    ValidationUtils.validateArgument(CommonUtils.isHexa(hex), \"Not a hex string\");\n    return this.fromBuffer(Buffer.from(hex, 'hex'));\n  }\n\n  /** \n   * Convert to a human readable representation of the sighash\n   */\n  public toString(): string {\n    if (this.hasAll()) {\n      return \"ALL\";\n    }\n\n    let ret = \"\";\n\n    switch (this.inType) {\n      case InputSighashType.ALL:\n        ret += \"ALL_IN\";\n        break;\n      case InputSighashType.THISIN:\n        ret += \"THIS_IN\";\n        break;\n      case InputSighashType.FIRSTN:\n        ret += `FIRST_${this.inData[0]}_IN`;\n        break;\n      default:\n        return \"INVALID\";\n    }\n\n    ret += \"|\";\n\n    switch (this.outType) {\n      case OutputSighashType.ALL:\n        ret += \"ALL_OUT\";\n        break;\n      case OutputSighashType.TWO:\n        ret += `${this.outData[0]}_${this.outData[1]}_OUT`;\n        break;\n      case OutputSighashType.FIRSTN:\n        ret += `FIRST_${this.outData[0]}_OUT`;\n        break;\n      default:\n        return \"INVALID\";\n    }\n    \n    return ret;\n  }\n\n  /**\n   * Create sighash from human readable represantation\n   * @see toString \n   */\n  public static fromString(str: string): SighashType {\n    ValidationUtils.validateArgument(isString(str), \"Not a string\");\n    if (str == \"ALL\") {\n      return this.ALL;\n    }\n\n    ValidationUtils.validateArgument(str.includes(\"|\"), \"Not a sighash string\");\n    let sighash = new SighashType();\n    let [inStr, outStr] = str.split(\"|\");\n\n    if (inStr == \"THIS_IN\") {\n      sighash.inType = InputSighashType.THISIN;\n    } else if (inStr != \"ALL_IN\") {\n      let match = inStr.match(/^FIRST_(\\d+)_IN$/);\n      ValidationUtils.validateState(!isNil(match), \"Not a sighash string\");\n      sighash.setFirstNIn(parseInt(match![1]));\n    }\n\n    if (outStr != \"ALL_OUT\") {\n      let fnMatch = outStr.match(/^FIRST_(\\d+)_OUT$/);\n      let twMatch = outStr.match(/^(\\d+)_(\\d+)_OUT$/);\n      if (fnMatch) {\n        sighash.setFirstNOut(parseInt(fnMatch[1]));\n      } else if (twMatch) {\n        sighash.set2Out(parseInt(twMatch[1]), parseInt(twMatch[2]));\n      } else {\n        throw new Error(\"Not a sighash string\");\n      }\n    }\n\n    return sighash;\n  }\n}","import { isNil, isNumber, isObject, isUndefined } from \"lodash-es\";\nimport BufferUtils from \"../../utils/buffer.utils\";\nimport CommonUtils from \"../../utils/common.utils\";\nimport Script from \"../script/script\";\nimport Input from \"./input/input\";\nimport Output from \"./output\";\nimport type { ITransaction, TxVerifyOptions } from \"./interfaces\";\nimport BufferWriter from \"../../encoding/bufferwriter\";\nimport { Opcode } from \"../script/opcode\";\nimport Hash from \"../../crypto/hash\";\nimport ValidationUtils from \"../../utils/validation.utils\";\nimport type Address from \"../address/address\";\nimport ScriptFactory from \"../script/script.factory\";\nimport type { IScript } from \"../../common/interfaces\";\nimport BufferReader from \"../../encoding/bufferreader\";\nimport PublicKeyHashInput from \"./input/publickeyhash\";\nimport PublicKeyTemplateInput from \"./input/publickeytemplate\";\nimport ScriptTemplateInput from \"./input/scripttemplate\";\n\n/**\n * Represents a transaction, a set of inputs and outputs to change ownership of tokens\n */\nexport default class Transaction implements ITransaction {\n\n  public static readonly CURRENT_VERSION = 0;\n  public static readonly FEE_PER_BYTE = 3;\n\n  // Minimum amount for an output for it not to be considered a dust output\n  public static readonly DUST_AMOUNT = 546;\n\n  // Max amount of satoshis in circulation\n  public static readonly MAX_MONEY = 21000000 * 1e8;\n\n  // nlocktime limit to be considered block height rather than a timestamp\n  public static readonly NLOCKTIME_BLOCKHEIGHT_LIMIT = 5e8;\n\n  // Max value for an unsigned 32 bit value\n  public static readonly NLOCKTIME_MAX_VALUE = 4294967295;\n\n  public version: number;\n  public inputs: Input[];\n  public outputs: Output[];\n  public nLockTime: number;\n\n  private _feePerByte?: number;\n  private _fee?: number\n  private _changeIndex?: number;\n  private _changeScript?: Script;\n\n  constructor(serializedTx?: ITransaction | string | Buffer) {\n    this.version = Transaction.CURRENT_VERSION;\n    this.inputs = [];\n    this.outputs = [];\n    this.nLockTime = 0;\n\n    if (serializedTx) {\n      if (BufferUtils.isBuffer(serializedTx)) {\n        this.fromBuffer(serializedTx);\n      } else if (CommonUtils.isHexa(serializedTx as string)) {\n        this.fromString(serializedTx as string);\n      } else if (isObject(serializedTx)) {\n        this.fromObject(serializedTx);\n      } else {\n        throw new TypeError(\"Must provide an object or string to deserialize a transaction\");\n      }\n    }\n  }\n\n  public get id(): string {\n    let buf = new BufferWriter().write(this._getTxIdem()).write(this._getTxSatisfier()).toBuffer();\n    return Hash.sha256sha256(buf).reverse().toString('hex');\n  }\n\n  public get idem(): string {\n    return this._getTxIdem().reverse().toString('hex');\n  }\n\n  public get outputAmount(): bigint {\n    return this.outputs.reduce((total, output) => total + output.value, 0n);\n  }\n\n  public get inputAmount(): bigint {\n    return this.inputs.reduce((total, input) => total + input.amount, 0n);\n  }\n\n  private _getTxIdem(): Buffer {\n    return Hash.sha256sha256(this._toIdemBuffer());\n  }\n  \n  private _getTxSatisfier(): Buffer {\n    return Hash.sha256sha256(this._toSatisfierBuffer());\n  }\n\n  /**\n   * Create a 'shallow' copy of the transaction, by serializing and deserializing.\n   * it dropping any additional information that inputs and outputs may have hold\n   *\n   * @param transaction\n   */\n  public static shallowCopy(transaction: Transaction): Transaction {\n    return new Transaction(transaction.toBuffer());\n  }\n\n  /**\n   * Analogous to nexad's IsCoinBase function in transaction.h\n   */\n  public isCoinbase(): boolean {\n    return this.inputs.length === 0;\n  }\n\n  /**\n   * Retrieve a possible error that could appear when trying to serialize and\n   * broadcast this transaction.\n   *\n   * @param opts allows to skip certain tests.\n   */\n  public getSerializationError(opts?: TxVerifyOptions): Error | undefined {\n    if (this._invalidAmount()) {\n      return new Error('Output satoshis are invalid');\n    }\n\n    if (this.outputs.length > 256) {\n      return new Error('Too many outputs (> 256)');\n    }\n    if (this.inputs.length > 256) {\n      return new Error('Too many inputs (> 256)');\n    }\n\n    let unspent = this.getUnspentValue();\n    let unspentError: Error | undefined;\n    if (unspent < 0) {\n      if (!opts?.disableMoreOutputThanInput) {\n        unspentError = new Error('Invalid outputs amount sum');\n      }\n    } else {\n      unspentError = this._hasFeeError(unspent);\n    }\n\n    return unspentError ||\n      this._hasDustOutputs(opts) ||\n      this._isMissingSignatures(opts);\n  }\n\n  private _invalidAmount(): boolean {\n    return this.outputs.some(out => out.invalidValue());\n  }\n  \n  private _hasDustOutputs(opts?: TxVerifyOptions): Error | undefined {\n    if (opts?.disableDustOutputs) {\n      return;\n    }\n    \n    let hasDust = this.outputs.some(output => output.value < Transaction.DUST_AMOUNT && !output.scriptPubKey.isDataOut());\n    return hasDust ? new Error('Dust amount detected in one output') : undefined;\n  }\n\n  private _hasFeeError(unspent: bigint): Error | undefined {\n    if (!isUndefined(this._fee) && BigInt(this._fee) !== unspent) {\n      return new Error(`Unspent value is ${unspent} but specified fee is ${this._fee}`);\n    }\n  }\n\n  private _estimateFee(): number {\n    let estimatedSize = this._estimateSize();\n    let available = this.getUnspentValue();\n    let feeRate = this._feePerByte || Transaction.FEE_PER_BYTE;\n    const calcFee = (size: number): number => {\n      return size * feeRate;\n    }\n    let feeWithChange = Math.ceil(calcFee(estimatedSize) + calcFee(this._estimateSizeOfChangeOutput()));\n    if (!this._changeScript || available <= feeWithChange || available - BigInt(feeWithChange) < Transaction.DUST_AMOUNT) {\n      return Number(available);\n    }\n    return feeWithChange;\n  }\n\n  private _estimateSizeOfChangeOutput(): number {\n    /* c8 ignore start */\n    if (!this._changeScript) {\n      return 0; // should not reach here\n    }\n    /* c8 ignore stop */\n\n    let scriptLen = this._changeScript.toBuffer().length;\n    // 1 byte for type + 8 bytes for amount + script size + actual script size\n    return 1 + 8 + BufferWriter.varintBufNum(scriptLen).length + scriptLen;\n  }\n\n  private _estimateSize(): number {\n    let result = 4 + 1; // locktime + version\n\n    result += this.inputs.length < 253 ? 1 : 3;\n    this.inputs.forEach(input => {\n      result += input.estimateSize();\n    });\n    \n    result += this.outputs.length < 253 ? 1 : 3;\n    this.outputs.forEach(output => {\n      result += output.toBufferWriter().toBuffer().length;\n    });\n  \n    return result;\n  }\n  \n  private _isMissingSignatures(opts?: TxVerifyOptions): Error | undefined {\n    if (opts?.disableIsFullySigned) {\n      return;\n    }\n    if (!this.isFullySigned()) {\n      return new Error('Some inputs have not been fully signed');\n    }\n  }\n\n  public isFullySigned(): boolean {\n    if (this.inputs.some(input => input.isFullySigned === Input.prototype.isFullySigned)) {\n      throw new Error(\"Unable to verify signature: Unrecognized script kind, or not enough information to execute script.\"\n         + \" This usually happens when creating a transaction from a serialized transaction\")\n    }\n    return this.inputs.every(input => input.isFullySigned());\n  }\n\n  /**\n   * @returns true if the transaction has enough info on all inputs to be correctly validated\n   */\n  public hasAllUtxoInfo(): boolean {\n    return this.inputs.every(input => !isUndefined(input.output));\n  }\n\n  public getUnspentValue(): bigint {\n    return this.inputAmount - this.outputAmount;\n  }\n\n  /**\n   * Calculates the fee of the transaction.\n   *\n   * If there's a fixed fee set, return that.\n   *\n   * If there is no change output set, the fee is the\n   * total value of the outputs minus inputs. Note that\n   * a serialized transaction only specifies the value\n   * of its outputs. (The value of inputs are recorded\n   * in the previous transaction outputs being spent.)\n   * This method therefore raises a \"MissingPreviousOutput\"\n   * error when called on a serialized transaction.\n   *\n   * If there's no fee set and no change address,\n   * estimate the fee based on size.\n   *\n   * @return fee of this transaction in satoshis\n   */\n  public getFee(): number {\n    if (this.isCoinbase()) {\n      return 0;\n    }\n    if (!isUndefined(this._fee)) {\n      return this._fee;\n    }\n    // if no change output is set, fees should equal all the unspent amount\n    if (!this._changeScript) {\n      return Number(this.getUnspentValue());\n    }\n    return this._estimateFee();\n  }\n\n  /**\n   * Calculates the required fee of the transaction.\n   * \n   * @remarks this method is different than getFee.\n   *  while getFee return the current fee estimation, this method return how much fee is required according to the fee rate.\n   * \n   * @returns the required fees of this transaction in satoshis\n   */\n  public estimateRequiredFee(): number {\n    let feeRate = this._feePerByte || Transaction.FEE_PER_BYTE;\n    return feeRate * this._estimateSize();\n  }\n\n  public clearSignatures(): void {\n    this.inputs.forEach(input => input.clearSignatures());\n  }\n\n  /**\n   * Retrieve a hexa string that can be used with nexad's CLI interface\n   * (decoderawtransaction, sendrawtransaction)\n   *\n   * @param opts allows to skip certain tests.\n   */\n  public checkedSerialize(opts?: TxVerifyOptions): string {\n    let serializationError = this.getSerializationError(opts);\n    if (serializationError) {\n      throw serializationError;\n    }\n    return this.toString();\n  }\n\n  public uncheckedSerialize = this.toString;\n\n  public toString(): string {\n    return this.toBuffer().toString('hex');\n  }\n\n  public inspect(): string {\n    return `<Transaction: ${this}>`;\n  }\n\n  public fromString(string: string): this {\n    return this.fromBuffer(Buffer.from(string, 'hex'));\n  }\n\n  /**\n   * Retrieve a hexa string that can be used with nexad's CLI interface\n   * (decoderawtransaction, sendrawtransaction)\n   *\n   * @param unsafe if true, skip all tests. if it's an object,\n   * it's expected to contain a set of flags to skip certain tests.\n   * \n   * @see {@link TxVerifyOptions}\n   */\n  public serialize(unsafe?: boolean | TxVerifyOptions): string {\n    if (true === unsafe || (isObject(unsafe) && unsafe.disableAll)) {\n      return this.uncheckedSerialize();\n    } else {\n      return this.checkedSerialize(isObject(unsafe) ? unsafe : undefined);\n    }\n  }\n\n  /**\n   * Manually set the fee for this transaction. Beware that this resets all the signatures\n   * for inputs.\n   *\n   * @param amount satoshis to be set as fees\n   * @return this, for chaining\n   */\n  public setFee(amount: number): this {\n    ValidationUtils.validateArgument(isNumber(amount), 'amount must be a number');\n    this._fee = amount;\n    this._updateChangeOutput();\n    return this;\n  }\n\n  /**\n   * Manually set the fee per Byte for this transaction. Beware that this resets all the signatures\n   * for inputs.\n   * fee per Byte will be ignored if fee property was set manually\n   *\n   * @param amount satoshis per Byte to be used as fee rate\n   * @return this, for chaining\n   */\n  public setFeePerByte(amount: number): this {\n    ValidationUtils.validateArgument(isNumber(amount), 'amount must be a number');\n    this._feePerByte = amount;\n    this._updateChangeOutput();\n    return this;\n  }\n\n  /**\n   * Add an output to the transaction.\n   *\n   * @param output the output to add.\n   * @return this, for chaining\n   */\n  public addOutput(output: Output): this {\n    ValidationUtils.validateArgumentType(output, Output, 'output');\n    this.outputs.push(output);\n    this._updateChangeOutput();\n    return this;\n  }\n\n  public removeOutput(index: number): this {\n    this._removeOutput(index);\n    this._updateChangeOutput();\n    return this;\n  }\n\n  private _removeOutput(index: number): void {\n    this.outputs = this.outputs.filter((_, i) => i !== index);\n  }\n\n  /**\n   * Remove all outputs from the transaction.\n   *\n   * @return this, for chaining\n   */\n  public clearOutputs(): this {\n    this.outputs = [];\n    this.clearSignatures();\n    this._updateChangeOutput();\n    return this;\n  }\n\n  public updateOutputAmount(index: number, sats: bigint | number): void {\n    this.outputs[index].value = BigInt(sats);\n    this._updateChangeOutput();\n  }\n\n  /**\n   * Set the change address for this transaction\n   *\n   * Beware that this resets all the signatures for inputs.\n   *\n   * @param address An address for change to be sent to.\n   * @return this, for chaining\n   */\n  public setChangeOutput(address: string | Address): this {\n    ValidationUtils.validateArgument(!isNil(address), 'address is required.');\n    this._changeScript = ScriptFactory.buildOutFromAddress(address);\n    this._updateChangeOutput();\n    return this;\n  }\n\n  /**\n   * @returns change output, if it exists\n   */\n  public getChangeOutput(): Output | undefined {\n    if (!isUndefined(this._changeIndex)) {\n      return this.outputs[this._changeIndex];\n    }\n    return undefined;\n  }\n\n  private _updateChangeOutput(): void {\n    if (!this._changeScript) {\n      return;\n    }\n    this.clearSignatures();\n    if (!isUndefined(this._changeIndex)) {\n      this._removeOutput(this._changeIndex);\n    }\n    let available = this.getUnspentValue();\n    let fee = this.getFee();\n    let changeAmount = available - BigInt(fee);\n\n    if (changeAmount >= Transaction.DUST_AMOUNT) {\n      this._changeIndex = this.outputs.length;\n      this.outputs.push(new Output(changeAmount, this._changeScript));\n    } else {\n      this._changeIndex = undefined;\n    }\n  }\n\n  /**\n   * Add an input to this transaction, without checking that the input has information about\n   * the output that it's spending.\n   *\n   * @param input the input to add\n   * @return this, for chaining\n   */\n  public uncheckedAddInput(input: Input): this {\n    ValidationUtils.validateArgumentType(input, Input, 'input');\n    this.inputs.push(input);\n    this._updateChangeOutput();\n    return this;\n  }\n\n  /**\n   * Add an input to this transaction. The input must be an instance of the `Input` class.\n   * It should have information about the Output that it's spending, but if it's not already\n   * set, two additional parameters, `outputScript` and `amount` can be provided.\n   *\n   * @param input\n   * @param outputScript\n   * @param amount\n   * @return this, for chaining\n   */\n  public addInput(input: Input, outputScript?: IScript | Buffer | string, amount?: bigint | number): this {\n    ValidationUtils.validateArgumentType(input, Input, 'input');\n    if (isUndefined(input.output) && (isUndefined(outputScript) || isUndefined(amount))) {\n      throw new Error('Need information about the UTXO script and amount');\n    }\n    if (isUndefined(input.output) && !isUndefined(outputScript) && !isUndefined(amount)) {\n      let scriptPubKey = outputScript instanceof Script ? outputScript : new Script(outputScript);\n      input.output = new Output(BigInt(amount), scriptPubKey);\n    }\n    return this.uncheckedAddInput(input);\n  }\n\n  public removeInput(outpoint: string): this {\n    this.inputs = this.inputs.filter(input => input.outpoint.toString('hex') != outpoint);\n    this._updateChangeOutput();\n    return this;\n  }\n\n  /**\n   * Sets nLockTime so that transaction is not valid until the desired date or height.\n   * Beware that this method will also set the inputs sequence number to max_int - 1\n   * \n   * @remarks nLockTime considered as height if the value is between 0 - 499,999,999.\n   *  above that considered as date (unix timestamp).\n   * \n   * @see {@link NLOCKTIME_BLOCKHEIGHT_LIMIT}\n   * \n   * @param locktime \n   * @returns \n   */\n  public setLockTime(locktime: number): this {\n    ValidationUtils.validateArgument(isNumber(locktime), 'locktime', 'must be a number');\n\n    this.inputs.forEach(input => {\n      if (input.sequenceNumber === Input.SEQUENCE_FINAL) {\n        input.sequenceNumber = Input.SEQUENCE_FINAL - 1;\n      }\n    });\n\n    this.nLockTime = locktime;\n    return this;\n  }\n\n  /**\n   *  Returns a semantic version of the transaction's nLockTime.\n   *  If nLockTime is 0, it returns null,\n   *  if it is < 500000000, it returns a block height (number)\n   *  else it returns a Date object.\n   */\n  public getLockTime(): number | Date | null {\n    if (!this.nLockTime) {\n      return null;\n    }\n    if (this.nLockTime < Transaction.NLOCKTIME_BLOCKHEIGHT_LIMIT) {\n      return this.nLockTime;\n    }\n    return new Date(1000 * this.nLockTime);\n  }\n\n  public toBuffer(): Buffer {\n    return this.toBufferWriter().toBuffer();\n  }\n\n  public toBufferWriter(writer?: BufferWriter, withInputsScripts = true): BufferWriter {\n    if (!writer) {\n      writer = new BufferWriter();\n    }\n    writer.writeUInt8(this.version);\n\n    writer.writeVarintNum(this.inputs.length);\n    this.inputs.forEach(input => input.toBufferWriter(writer, withInputsScripts));\n\n    writer.writeVarintNum(this.outputs.length);\n    this.outputs.forEach(output => output.toBufferWriter(writer));\n\n    writer.writeUInt32LE(this.nLockTime);\n    return writer;\n  }\n\n  private _toIdemBuffer(): Buffer {\n    let writer = new BufferWriter();\n    return this.toBufferWriter(writer, false).toBuffer();\n  }\n\n  private _toSatisfierBuffer(): Buffer {\n    let writer = new BufferWriter();\n\n    writer.writeInt32LE(this.inputs.length);\n    this.inputs.forEach(input => {\n      writer.write(input.scriptSig.toBuffer());\n      writer.writeUInt8(Opcode.OP_INVALIDOPCODE);\n    });\n\n    return writer.toBuffer();\n  }\n\n  public fromBuffer(buffer: Buffer): this {\n    let reader = new BufferReader(buffer);\n    return this.fromBufferReader(reader);\n  }\n  \n  public fromBufferReader(reader: BufferReader): this {\n    ValidationUtils.validateState(!reader.finished(), 'No transaction data received');\n  \n    this.version = reader.readUInt8();\n    let sizeTxIns = reader.readVarintNum();\n    for (let i = 0; i < sizeTxIns; i++) {\n      this.inputs.push(Input.fromBufferReader(reader));\n    }\n    let sizeTxOuts = reader.readVarintNum();\n    for (let i = 0; i < sizeTxOuts; i++) {\n      this.outputs.push(Output.fromBufferReader(reader));\n    }\n    this.nLockTime = reader.readUInt32LE();\n    return this;\n  }\n\n  public toJSON = this.toObject;\n\n  public toObject(): ITransaction {\n    let obj: ITransaction = {\n      id: this.id,\n      idem: this.idem,\n      version: this.version,\n      inputs: this.inputs.map(input => input.toObject()),\n      outputs: this.outputs.map(output => output.toObject()),\n      nLockTime: this.nLockTime\n    };\n    if (!isUndefined(this._changeScript)) {\n      obj.changeScript = this._changeScript.toHex();\n    }\n    if (!isUndefined(this._changeIndex)) {\n      obj.changeIndex = this._changeIndex;\n    }\n    if (!isUndefined(this._fee)) {\n      obj.fee = this._fee;\n    }\n    if (!isUndefined(this._feePerByte)) {\n      obj.feePerByte = this._feePerByte;\n    }\n    return obj;\n  }\n\n  public fromObject(transaction: ITransaction): this {\n    ValidationUtils.validateArgument(isObject(transaction), 'transaction');\n    if (transaction instanceof Transaction) {\n      transaction = transaction.toObject();\n    }\n\n    this.nLockTime = transaction.nLockTime;\n    this.version = transaction.version;\n\n    for (let input of transaction.inputs) {\n      if (isUndefined(input.output?.scriptPubKey)) {\n        this.uncheckedAddInput(new Input(input));\n        continue;\n      }\n\n      let script = new Script(input.output.scriptPubKey);\n      let txin: Input;\n      if (script.isPublicKeyHashOut()) {\n        txin = new PublicKeyHashInput(input);\n      } else if (script.isPublicKeyTemplateOut()) {\n        txin = new PublicKeyTemplateInput(input);\n      } else if (script.isScriptTemplateOut()) {\n        if ('templateData' in input) {\n          txin = new ScriptTemplateInput(input);\n        } else {\n          txin = new Input(input);\n        }\n      } else {\n        throw new Error(`Unsupported input script type: ${script}`);\n      }\n      this.addInput(txin);\n    }\n\n    for(let output of transaction.outputs) {\n      this.addOutput(Output.fromObject(output));\n    }\n\n    if (!isUndefined(transaction.changeIndex)) {\n      this._changeIndex = transaction.changeIndex;\n    }\n    if (!isUndefined(transaction.changeScript)) {\n      this._changeScript = new Script(transaction.changeScript);\n    }\n    if (!isUndefined(transaction.fee)) {\n      this._fee = transaction.fee;\n    }\n    if (!isUndefined(transaction.feePerByte)) {\n      this._feePerByte = transaction.feePerByte;\n    }\n    this._checkConsistency(transaction);\n    return this;\n  }\n\n  private _checkConsistency(transaction: ITransaction): void {\n    if (!isUndefined(this._changeIndex)) {\n      ValidationUtils.validateState(!isUndefined(this._changeScript), 'Change script is expected.');\n      ValidationUtils.validateState(!isUndefined(this.outputs[this._changeIndex]), 'Change index points to undefined output.');\n      ValidationUtils.validateState(this.outputs[this._changeIndex].scriptPubKey.toHex() ===\n        this._changeScript?.toHex(), 'Change output has an unexpected script.');\n    }\n    if (transaction?.id) {\n      ValidationUtils.validateState(transaction.id === this.id, 'Id in object does not match transaction id.');\n    }\n  }\n}","import { isNil, isObject, isString, isUndefined } from \"lodash-es\";\nimport Script from \"../../script/script\";\nimport Output from \"../output\";\nimport type { IInput } from \"../interfaces\";\nimport BufferUtils from \"../../../utils/buffer.utils\";\nimport ValidationUtils from \"../../../utils/validation.utils\";\nimport type BufferReader from \"../../../encoding/bufferreader\";\nimport BufferWriter from \"../../../encoding/bufferwriter\";\nimport BN from \"../../../crypto/bn.extension\";\nimport type PrivateKey from \"../../../keys/privatekey\";\nimport type TxSignature from \"../txsignature\";\n\nexport enum  InputType {\n  UTXO = 0,\n  READ_ONLY = 1\n}\n\nexport default class Input implements IInput {\n\n  public static readonly SEQUENCE_FINAL = 0xffffffff;\n\n  public type!: InputType;\n  public outpoint!: Buffer;\n  public amount!: bigint;\n  public sequenceNumber!: number\n  public output?: Output;\n\n  private _scriptSig!: Script;\n\n  constructor(params?: IInput) {\n    if (params) {\n      this._set(params);\n    }    \n  }\n\n  public get scriptSig(): Script {\n    return this._scriptSig;\n  }\n\n  public set scriptSig(script: string | Script) {\n    if (script instanceof Script) {\n      this._scriptSig = script;\n    } else if (isString(script)) {\n      this._scriptSig = Script.fromString(script);\n    } else {\n      throw new TypeError('Invalid argument type: script');\n    }\n  }\n\n  private _set(params: IInput): void {\n    this.type = InputType.UTXO;\n    if (isNil(params.scriptSig)) {\n      throw new TypeError('Need a script to create an input');\n    }\n    this.scriptSig = params.scriptSig;\n    this.outpoint = BufferUtils.isBuffer(params.outpoint) ? params.outpoint : Buffer.from(params.outpoint, 'hex');\n    this.amount = BigInt(params.amount);\n    this.sequenceNumber = isUndefined(params.sequenceNumber) ? Input.SEQUENCE_FINAL : params.sequenceNumber;\n    if (params.output) {\n      this.output = params.output instanceof Output ? params.output : Output.fromObject(params.output);\n    }\n  }\n\n  public static fromObject(obj: IInput): Input {\n    ValidationUtils.validateArgument(isObject(obj), \"obj\");\n    return new Input(obj);\n  }\n\n  public toJSON = this.toObject;\n\n  public toObject(): IInput {\n    return {\n      type: this.type,\n      outpoint: this.outpoint.toString('hex'),\n      amount: this.amount.toString(),\n      sequenceNumber: this.sequenceNumber,\n      scriptSig: this.scriptSig.toHex(),\n      output: this.output?.toObject()\n    };\n  }\n\n  public static fromBufferReader(br: BufferReader): Input {\n    let input = new Input();\n    input.type = br.readUInt8();\n    input.outpoint = br.readReverse(32);\n    input.scriptSig = Script.fromBuffer(br.readVarLengthBuffer());\n    input.sequenceNumber = br.readUInt32LE();\n    input.amount = br.readUInt64LEBN().toBigInt();\n    return input;\n  }\n  \n  public toBufferWriter(writer?: BufferWriter, includeScript = true): BufferWriter {\n    if (!writer) {\n      writer = new BufferWriter();\n    }\n    writer.writeUInt8(this.type);\n    writer.writeReverse(this.outpoint);\n    if (includeScript) {\n      writer.writeVarLengthBuf(this.scriptSig.toBuffer());\n    }\n    writer.writeUInt32LE(this.sequenceNumber);\n    writer.writeUInt64LEBN(BN.fromBigInt(this.amount));\n    return writer;\n  }\n\n  public estimateSize(): number {\n    return this.toBufferWriter().toBuffer().length;\n  }\n\n  public isFinal(): boolean {\n    return this.sequenceNumber !== Input.SEQUENCE_FINAL;\n  }\n\n  public clearSignatures(): this {\n    this.scriptSig = Script.empty();\n    return this;\n  }\n\n  public getSubscript(): Script {\n    throw Error(`Abstract Method Invocation: Input#getSubscript`);\n  }\n\n  /**\n   * @returns true if the provided private key can sign this input\n   */\n  public canSign(_privateKey: PrivateKey): boolean {\n    throw Error(`Abstract Method Invocation: Input#canSign`);\n  }\n  \n  public isFullySigned(): boolean {\n    throw Error(`Abstract Method Invocation: Input#isFullySigned`);\n  }\n\n  public addSignature(_signature: TxSignature): this {\n    throw Error(`Abstract Method Invocation: Input#addSignature`);\n  }\n}","import { isObject, isString, isUndefined } from \"lodash-es\";\nimport BN from \"../../crypto/bn.extension\";\nimport CommonUtils from \"../../utils/common.utils\";\nimport ValidationUtils from \"../../utils/validation.utils\";\nimport Script from \"../script/script\";\nimport type BufferReader from \"../../encoding/bufferreader\";\nimport BufferWriter from \"../../encoding/bufferwriter\";\nimport type { IOutput } from \"./interfaces\";\n\nexport enum  OutputType {\n  SATOSCRIPT = 0,\n  TEMPLATE = 1,\n  INFER = 0x8000 // Not a real type: implies the type should be infered from the script at construction time\n}\n\nexport default class Output implements IOutput {\n\n  public type: OutputType;\n\n  private _value!: bigint;\n  private _scriptPubKey!: Script;\n\n  constructor(value: bigint | number | string, scriptPubKey: Script | string, type = OutputType.INFER) {\n    this.type = type;\n    this.value = value;\n    this.scriptPubKey = scriptPubKey;\n  }\n\n  public get value(): bigint {\n    return this._value;\n  }\n\n  public set value(sats: bigint | number | string) {\n    sats = BigInt(sats);\n    ValidationUtils.validateArgument(CommonUtils.isNaturalBigInt(sats), \"Output value is not a natural bigint\");\n    this._value = sats;\n  }\n\n  public get scriptPubKey(): Script {\n    return this._scriptPubKey;\n  }\n\n  public set scriptPubKey(script: Script | string) {\n    if (!isUndefined(this._scriptPubKey)) {\n      this.type = OutputType.INFER;\n    }\n\n    if (script instanceof Script) {\n      this._scriptPubKey = script;\n    } else if (isString(script)) {\n      this._scriptPubKey = Script.fromString(script);\n    } else {\n      throw new TypeError('Invalid argument type: script');\n    }\n\n    // in case we replace script or type wasn't passed in c'tor, we need to define the output type\n    if (this.type == OutputType.INFER) {\n      this.type = this._scriptPubKey.isPublicKeyTemplateOut() || this._scriptPubKey.isScriptTemplateOut()\n              ? OutputType.TEMPLATE : OutputType.SATOSCRIPT;\n    }\n  }\n\n  public invalidValue(): string | false {\n    if (this.value > BigInt(Number.MAX_SAFE_INTEGER)) {\n      return 'transaction txout value greater than max safe integer';\n    }\n    if (this.value < 0n) {\n      return 'transaction txout negative';\n    }\n    return false;\n  }\n\n  public toObject(): IOutput {\n    return {\n      type: this.type,\n      value: this.value.toString(),\n      scriptPubKey: this.scriptPubKey.toHex()\n    };\n  }\n\n  public toJSON = this.toObject;\n  \n  public static fromObject(data: IOutput): Output {\n    ValidationUtils.validateArgument(isObject(data), \"data\", \"Unrecognized argument for Output\")\n    return new Output(data.value, data.scriptPubKey, data.type);\n  }\n\n  public inspect(): string {\n    return `<Output (type: ${this.type}) (${this.value.toString()} sats) ${this.scriptPubKey.inspect()}>`;\n  }\n\n  public static fromBufferReader(br: BufferReader): Output {\n    let type = br.readVarintNum();\n    let value = br.readUInt64LEBN();\n  \n    let size = br.readVarintNum();\n    let scriptBuf = size !== 0 ? br.read(size) : Buffer.from([]);\n\n    return new Output(value.toBigInt(), Script.fromBuffer(scriptBuf), type);\n  }\n\n  public toBufferWriter(writer?: BufferWriter): BufferWriter {\n    if (!writer) {\n      writer = new BufferWriter();\n    }\n    writer.writeUInt8(this.type);\n    writer.writeUInt64LEBN(BN.fromBigInt(this.value));\n    writer.writeVarLengthBuf(this.scriptPubKey.toBuffer());\n    \n    return writer;\n  }\n}","import Hash from \"../../../crypto/hash\";\nimport type PrivateKey from \"../../../keys/privatekey\";\nimport ValidationUtils from \"../../../utils/validation.utils\";\nimport type Script from \"../../script/script\";\nimport ScriptFactory from \"../../script/script.factory\";\nimport Output from \"../output\";\nimport type TxSignature from \"../txsignature\";\nimport Input from \"./input\";\n\n/**\n * Represents a special kind of input of PayToPublicKeyHash kind.\n */\nexport default class PublicKeyHashInput extends Input {\n\n  public static readonly SCRIPT_SIZE = 99; // pubkey (1 + 33) + sigsize (1 + 64)\n\n  public override getSubscript(): Script {\n    ValidationUtils.validateState(this.output instanceof Output, \"missing associated output\");\n    return this.output!.scriptPubKey;\n  }\n\n  public override canSign(privateKey: PrivateKey): boolean {\n    if (!(this.output instanceof Output)) {\n      return false;\n    }\n    let pkh = Hash.sha256ripemd160(privateKey.publicKey.toBuffer());\n    return pkh.equals(this.output.scriptPubKey.getPublicKeyHash());\n  }\n\n  public override isFullySigned(): boolean {\n    return this.scriptSig.isPublicKeyHashIn();\n  }\n\n  public override addSignature(signature: TxSignature): this {\n    this.scriptSig = ScriptFactory.buildPublicKeyHashIn(signature.publicKey, signature.signature);\n    return this;\n  }\n\n  public override estimateSize(): number {\n    if (this.isFullySigned()) {\n      return super.estimateSize();\n    }\n    // type + outpoint + scriptlen + script + sequence + amount\n    return 1 + 32 + 1 + PublicKeyHashInput.SCRIPT_SIZE + 4 + 8;\n  }\n}","import Hash from \"../../../crypto/hash\";\nimport type PrivateKey from \"../../../keys/privatekey\";\nimport { Opcode } from \"../../script/opcode\";\nimport Script from \"../../script/script\";\nimport ScriptFactory from \"../../script/script.factory\";\nimport Output from \"../output\";\nimport type TxSignature from \"../txsignature\";\nimport Input from \"./input\";\n\n/**\n * Represents a special kind of input of PayToPublicKeyTemplate kind.\n */\nexport default class PublicKeyTemplateInput extends Input {\n\n  public static readonly SCRIPT_SIZE = 100; // pubkey push script (1 + 34) + sigsize (1 + 64)\n\n  public override getSubscript(): Script {\n    return Script.empty().add(Opcode.OP_FROMALTSTACK).add(Opcode.OP_CHECKSIGVERIFY);\n  }\n\n  public override canSign(privateKey: PrivateKey): boolean {\n    if (!(this.output instanceof Output)) {\n      return false;\n    }\n    let constraintHash = Hash.sha256ripemd160(Script.empty().add(privateKey.publicKey.toBuffer()).toBuffer());\n    return constraintHash.equals(this.output.scriptPubKey.getConstraintHash() as Buffer);\n  }\n\n  public override isFullySigned(): boolean {\n    return this.scriptSig.isPublicKeyTemplateIn();\n  }\n\n  public override addSignature(signature: TxSignature): this {\n    let constraint = Script.empty().add(signature.publicKey.toBuffer());\n    let satisfier = Script.empty().add(signature.toTxSatisfier());\n    this.scriptSig = ScriptFactory.buildScriptTemplateIn(Opcode.OP_1, constraint, satisfier);\n    return this;\n  }\n\n  public override estimateSize(): number {\n    if (this.isFullySigned()) {\n      return super.estimateSize();\n    }\n    // type + outpoint + scriptlen + script + sequence + amount\n    return 1 + 32 + 1 + PublicKeyTemplateInput.SCRIPT_SIZE + 4 + 8;\n  }\n}","import { isObject, isString, isUndefined } from \"lodash-es\";\nimport PublicKey from \"../../../keys/publickey\";\nimport ValidationUtils from \"../../../utils/validation.utils\";\nimport { Opcode } from \"../../script/opcode\";\nimport Script from \"../../script/script\";\nimport Input from \"./input\";\nimport type PrivateKey from \"../../../keys/privatekey\";\nimport type TxSignature from \"../txsignature\";\nimport ScriptFactory from \"../../script/script.factory\";\nimport Hash from \"../../../crypto/hash\";\nimport BufferUtils from \"../../../utils/buffer.utils\";\nimport type { IInput } from \"../interfaces\";\n\nexport default class ScriptTemplateInput extends Input {\n\n  public templateScript: Script;\n  public constraintScript: Script | Opcode.OP_FALSE;\n  public publicKey?: PublicKey;\n\n  /**\n   * Represents a special kind of input of generic ScriptTemplate kind.\n   * \n   * WARNING: this is a general case where the signature is similar to p2pkt and added to scriptSig as push signature data.\n   * If you have complex smart contract, consider extending this class (or Input class) and implement the necessary logic,\n   * or sign it manually.\n   */\n  constructor(arg: IInput) {\n    ValidationUtils.validateArgument(isObject(arg?.templateData), 'Missing template object');\n    ValidationUtils.validateArgument(isObject(arg?.output), 'Missing associated utxo');\n\n    let td = arg.templateData!;\n    ValidationUtils.validateArgument(td.templateScript instanceof Script || isString(td.templateScript), 'Invalid template');\n    ValidationUtils.validateArgument(td.constraintScript instanceof Script || isString(td.constraintScript) || td.constraintScript === Opcode.OP_FALSE, 'Invalid constraint');\n    ValidationUtils.validateArgument(isUndefined(td.publicKey) || td.publicKey instanceof PublicKey || isString(td.publicKey), 'Invalid pubkey');\n\n    super(arg);\n    this.templateScript = isString(td.templateScript) ? Script.fromString(td.templateScript) : td.templateScript;\n    this.constraintScript = isString(td.constraintScript) ? Script.fromString(td.constraintScript) : td.constraintScript;\n    this.publicKey = isString(td.publicKey) ? PublicKey.fromString(td.publicKey) : td.publicKey;\n\n    let templateHash = this.output!.scriptPubKey.getTemplateHash();\n    ValidationUtils.validateState(BufferUtils.isBuffer(templateHash) && templateHash.equals(Hash.sha256ripemd160(this.templateScript.toBuffer())), \"Provided template doesn't match to the provided output\");\n\n    let constraintHash = this.output!.scriptPubKey.getConstraintHash();\n    let isScriptMatch = this.constraintScript instanceof Script && BufferUtils.isBuffer(constraintHash)\n                    && constraintHash.equals(Hash.sha256ripemd160(this.constraintScript.toBuffer()));\n    ValidationUtils.validateState(constraintHash === this.constraintScript || isScriptMatch, \"Provided constraint doesn't match to the provided output\"); \n  }\n\n  public override toJSON = this.toObject;\n\n  public override toObject(): IInput {\n    let input = super.toObject()\n    return {\n      ...input,\n      templateData: {\n        templateScript: this.templateScript.toHex(),\n        constraintScript: this.constraintScript === Opcode.OP_FALSE ? Opcode.OP_FALSE : this.constraintScript.toHex(),\n        publicKey: this.publicKey?.toString()\n      }\n    }\n  }\n\n  public static override fromObject(obj: IInput): ScriptTemplateInput {\n    ValidationUtils.validateArgument(isObject(obj), \"obj\");\n    return new ScriptTemplateInput(obj);\n  }\n\n  public override getSubscript(): Script {\n    return this.templateScript;\n  }\n\n  public override canSign(privateKey: PrivateKey): boolean {\n    return this.publicKey?.toString() === privateKey.publicKey.toString();\n  }\n\n  public override isFullySigned(): boolean {\n    return this.scriptSig.isScriptTemplateIn()\n          && this.templateScript.equals(Script.fromBuffer(this.scriptSig.chunks[0].buf!))\n          && (!(this.constraintScript instanceof Script) || this.constraintScript.equals(Script.fromBuffer(this.scriptSig.chunks[1].buf!)));\n  }\n\n  public override addSignature(signature: TxSignature): this {\n    let satisfier = Script.empty().add(signature.toTxSatisfier());\n    this.scriptSig = ScriptFactory.buildScriptTemplateIn(this.templateScript, this.constraintScript, satisfier);\n    return this;\n  }\n\n  public override estimateSize(): number {\n    if (this.isFullySigned()) {\n      return super.estimateSize();\n    }\n    let scriptSize = this._estimateScriptSize();\n\n    // type + outpoint + scriptlen + script + sequence + amount\n    return 1 + 32 + (scriptSize < 253 ? 1 : 3) + scriptSize + 4 + 8;\n  }\n\n  protected _estimateScriptSize(): number {\n    // here we calculate by template size, constraint size if not op_false, and satisfier size as sigsize (1 + 64)\n    let s = Script.empty().add(this.templateScript.toBuffer());\n    if (this.constraintScript instanceof Script) {\n      s.add(this.constraintScript.toBuffer());\n    }\n    return s.toBuffer().length + 1 + 64;\n  }\n}","import { isObject, isUndefined } from \"lodash-es\";\nimport Script from \"../script/script\";\nimport UnitUtils from \"../../utils/unit.utils\";\nimport ValidationUtils from \"../../utils/validation.utils\";\nimport CommonUtils from \"../../utils/common.utils\";\nimport ScriptFactory from \"../script/script.factory\";\nimport type { UTXO } from \"./interfaces\";\n\nexport default class UnspentOutput {\n\n  public outpoint: string;\n  public scriptPubKey: Script;\n  public satoshis: bigint;\n\n  /**\n   * Represents an unspent output information: its outpoint hash, associated amount/sats,\n   * associated script or address with optional group info,\n   *\n   * @param utxo the utxo object\n   * @param utxo.outpoint the outpoint hash\n   * @param utxo.amount amount of nexa associated as string or number\n   * @param utxo.satoshis alias for `amount`, but expressed in satoshis (1 NEXA = 100 satoshis) as bigint, string or number\n   * @param utxo.scriptPubKey the script that must be resolved to release the funds\n   * @param utxo.address optional. can be used instead of the full script\n   * @param utxo.groupId optional. can be used instead of the full script\n   * @param utxo.groupAmount optional. can be used instead of the full script\n   */\n  constructor(utxo: UTXO) {\n    ValidationUtils.validateArgument(isObject(utxo), 'Must provide an object from where to extract data');\n    ValidationUtils.validateArgument(CommonUtils.isHexa(utxo.outpoint), 'Invalid outpoint hash');\n    ValidationUtils.validateArgument(!isUndefined(utxo.satoshis) || !isUndefined(utxo.amount), 'Must provide satoshis or amount');\n    ValidationUtils.validateArgument(!isUndefined(utxo.scriptPubKey) || !isUndefined(utxo.address), 'Must provide script or address');\n\n    this.outpoint = utxo.outpoint;\n    this.satoshis = !isUndefined(utxo.satoshis) ? BigInt(utxo.satoshis) : UnitUtils.parseNEXA(utxo.amount!.toString());\n    this.scriptPubKey = !isUndefined(utxo.scriptPubKey) ? new Script(utxo.scriptPubKey) : ScriptFactory.buildOutFromAddress(utxo.address!, utxo.groupId, utxo.groupAmount);\n  }\n\n  /**\n   * String representation: just the outpoint hash\n   */\n  public toString(): string {\n    return this.outpoint;\n  }\n\n  /**\n   * Provide an informative output when displaying this object in the console\n   */\n  public inspect(): string {\n    return `<UnspentOutput: ${this}, satoshis: ${this.satoshis}, script: ${this.scriptPubKey}>`;\n  }\n\n  /**\n   * Deserialize an UnspentOutput from an object\n   * @param data\n   */\n  public static fromObject(data: UTXO): UnspentOutput {\n    return new UnspentOutput(data);\n  }\n\n  /**\n   * Returns a plain object (no prototype or methods) with the associated info for this utxo\n   */\n  public toObject(): UTXO {\n    return {\n      outpoint: this.outpoint,\n      scriptPubKey: this.scriptPubKey.toHex(),\n      amount: UnitUtils.formatNEXA(this.satoshis),\n    };\n  }\n\n  public toJSON = this.toObject;\n}","import { isNil, isNumber, isObject, isString } from \"lodash-es\";\nimport Signature from \"../../crypto/signature\";\nimport PublicKey from \"../../keys/publickey\";\nimport Script from \"../script/script\";\nimport ValidationUtils from \"../../utils/validation.utils\";\nimport SighashType from \"./sighashtype\";\nimport CommonUtils from \"../../utils/common.utils\";\n\nexport interface ITxSignature {\n  inputIndex: number;\n  publicKey: PublicKey | string;\n  subscript: Script | string;\n  signature: Signature | string;\n  sigType: SighashType | string;\n}\n\nexport default class TxSignature implements ITxSignature {\n\n  public inputIndex: number;\n  public publicKey: PublicKey;\n  public subscript: Script;\n  public signature: Signature;\n  public sigType: SighashType;\n\n  /**\n   * Wrapper around Signature with fields related to signing a transaction specifically\n   */\n  constructor(arg: ITxSignature) {\n    TxSignature._validateArgs(arg);\n\n    this.inputIndex = arg.inputIndex;\n    this.publicKey = isString(arg.publicKey) ? PublicKey.fromString(arg.publicKey) : arg.publicKey;\n    this.subscript = isString(arg.subscript) ? Script.fromHex(arg.subscript) : arg.subscript;\n    this.signature = isString(arg.signature) ? Signature.fromString(arg.signature) : arg.signature;\n    this.sigType = isString(arg.sigType) ? SighashType.fromString(arg.sigType) : arg.sigType;\n  }\n\n  private static _validateArgs(arg: ITxSignature): void {\n    ValidationUtils.validateArgument(isObject(arg), 'TxSignature must be instantiated from an object');\n    ValidationUtils.validateArgument(!isNil(arg.publicKey) && !!PublicKey.from(arg.publicKey), 'publicKey');\n    ValidationUtils.validateArgument(!isNil(arg.inputIndex), 'inputIndex');\n    ValidationUtils.validateState(isNumber(arg.inputIndex), 'inputIndex must be a number');\n    ValidationUtils.validateArgument(!isNil(arg.subscript), 'subscript');\n    ValidationUtils.validateState(arg.subscript instanceof Script || CommonUtils.isHexa(arg.subscript!), 'subscript must be an object or hexa value');\n    ValidationUtils.validateArgument(!isNil(arg.signature), 'signature');\n    ValidationUtils.validateState(arg.signature instanceof Signature || CommonUtils.isHexa(arg.signature!), 'signature must be an object or hexa value');\n    ValidationUtils.validateState(arg.sigType instanceof SighashType || isString(arg.sigType), 'sigtype must be a sigtype object or string');\n  }\n\n  public toJSON = this.toObject;\n\n  public toObject(): ITxSignature {\n    return {\n      inputIndex: this.inputIndex,\n      publicKey: this.publicKey.toString(),\n      subscript: this.subscript.toHex(),\n      signature: this.signature.toString(),\n      sigType: this.sigType.toString()\n    }\n  }\n\n  public static fromObject(arg: ITxSignature): TxSignature {\n    return new TxSignature(arg);\n  }\n\n  public toTxSatisfier(): Buffer {\n    return this.signature.toTxFormat(this.sigType.toBuffer());\n  }\n}","import { isUndefined } from \"lodash-es\";\nimport Schnorr from \"../../crypto/schnorr\";\nimport type Signature from \"../../crypto/signature\";\nimport type PrivateKey from \"../../keys/privatekey\";\nimport ValidationUtils from \"../../utils/validation.utils\";\nimport type Script from \"../script/script\";\nimport type SighashType from \"./sighashtype\";\nimport { InputSighashType, OutputSighashType } from \"./sighashtype\";\nimport type Transaction from \"./transaction\";\nimport type PublicKey from \"../../keys/publickey\";\nimport BufferWriter from \"../../encoding/bufferwriter\";\nimport Hash from \"../../crypto/hash\";\nimport BN from \"../../crypto/bn.extension\";\n\ninterface SighashComponents {\n  hashPrevouts: Buffer;\n  hashSequence: Buffer;\n  hashInputAmounts: Buffer;\n  hashOutputs: Buffer;\n}\n\nexport default class TxSigner {\n\n  /**\n   * Create a signature\n   * \n   * @param transaction the transaction to sign\n   * @param inputNumber the input index for the signature\n   * @param sighashType the sighash type\n   * @param subscript the script that will be signed\n   * @param privateKey the privkey to sign with\n   * @returns The signature\n   */\n  public static sign(transaction: Transaction, inputNumber: number, sighashType: SighashType, subscript: Script, privateKey: PrivateKey): Signature {\n    let hashbuf = this.buildSighash(transaction, inputNumber, sighashType, subscript);\n    return Schnorr.sign(hashbuf, privateKey, 'little') as Signature;\n  }\n\n  /**\n   * Verify a signature\n   * \n   * @param transaction the transaction to verify\n   * @param inputNumber the input index for the signature\n   * @param signature the signature to verify\n   * @param sighashType the sighash type\n   * @param subscript the script that will be verified\n   * @param publicKey the pubkey that correspond to the signing privkey\n   * @returns true if signature is valid\n   */\n  public static verify(transaction: Transaction, inputNumber: number, signature: Signature, sighashType: SighashType, subscript: Script, publicKey: PublicKey): boolean {\n    ValidationUtils.validateArgument(!isUndefined(transaction), 'transaction');\n    ValidationUtils.validateArgument(!isUndefined(signature), 'signature');\n    ValidationUtils.validateArgument(!isUndefined(sighashType), 'sighashType');\n\n    let hashbuf = this.buildSighash(transaction, inputNumber, sighashType, subscript);\n    return Schnorr.verify(hashbuf, signature, publicKey, 'little');\n  }\n\n  /**\n   * Returns a buffer of length 32 bytes with the hash that needs to be signed for OP_CHECKSIG(VERIFY).\n   *\n   * @param transaction the transaction to sign\n   * @param inputNumber the input index for the signature\n   * @param sighashType the sighash type\n   * @param subscript the script that will be signed\n   */\n  public static buildSighash(transaction: Transaction, inputNumber: number, sighashType: SighashType, subscript: Script): Buffer {\n    let components = this._getSighashComponents(transaction, inputNumber, sighashType);\n    let writer = new BufferWriter();\n\n    // Version\n    writer.writeUInt8(transaction.version);\n\n    // Input prevouts/nSequence (none/all, depending on flags)\n    writer.write(components.hashPrevouts);\n    writer.write(components.hashInputAmounts);\n    writer.write(components.hashSequence);\n\n    // scriptCode of the input (serialized as scripts inside CTxOuts)\n    writer.writeVarLengthBuf(subscript.toBuffer());\n\n    // Outputs (none/one/all, depending on flags)\n    writer.write(components.hashOutputs);\n\n    // Locktime\n    writer.writeUInt32LE(transaction.nLockTime);\n\n    // sighashType \n    writer.writeVarLengthBuf(sighashType.toBuffer());\n\n    let buf = writer.toBuffer();\n    return Hash.sha256sha256(buf).reverse();\n  }\n\n  private static _getSighashComponents(transaction: Transaction, inputNumber: number, sighashType: SighashType): SighashComponents {\n    ValidationUtils.validateArgument(!sighashType.isInvalid(), 'sighashType');\n    let hashPrevouts: Buffer, hashSequence: Buffer, hashInputAmounts: Buffer, hashOutputs: Buffer;\n\n    switch (sighashType.inType) {\n      case InputSighashType.FIRSTN:\n        let firstN = sighashType.inData[0];\n        ValidationUtils.validateArgument(firstN <= transaction.inputs.length, 'firstN out of range');\n        hashPrevouts = this._getPrevoutHash(transaction, firstN);\n        hashSequence = this._getSequenceHash(transaction, firstN);\n        hashInputAmounts = this._getInputAmountHash(transaction, firstN);\n        break;\n      case InputSighashType.THISIN:\n        ValidationUtils.validateArgument(inputNumber < transaction.inputs.length, 'inputNumber out of range');\n        hashPrevouts = this._getPrevoutHashOf(transaction, inputNumber);\n        hashSequence = this._getSequenceHashOf(transaction, inputNumber);\n        hashInputAmounts = this._getInputAmountHashOf(transaction, inputNumber);\n        break;\n      default: // ALL\n        hashPrevouts = this._getPrevoutHash(transaction, transaction.inputs.length);\n        hashSequence = this._getSequenceHash(transaction, transaction.inputs.length);\n        hashInputAmounts = this._getInputAmountHash(transaction, transaction.inputs.length);\n        break;\n    }\n\n    switch (sighashType.outType) {\n      case OutputSighashType.FIRSTN:\n        let firstN = sighashType.outData[0];\n        ValidationUtils.validateArgument(firstN <= transaction.outputs.length, 'firstN out of range');\n        hashOutputs = this._getOutputsHash(transaction, firstN);\n        break;\n      case OutputSighashType.TWO:\n        let [out1, out2] = sighashType.outData;\n        ValidationUtils.validateArgument(out1 < transaction.outputs.length, 'out1 out of range');\n        ValidationUtils.validateArgument(out2 < transaction.outputs.length, 'out2 out of range');\n        hashOutputs = this._getOutputsHashOf(transaction, out1, out2);\n        break;\n      default: // ALL\n        hashOutputs = this._getOutputsHash(transaction, transaction.outputs.length);\n        break;\n    }\n\n    return { hashPrevouts, hashSequence, hashInputAmounts, hashOutputs };\n  }\n\n  private static _getPrevoutHash(tx: Transaction, firstN: number): Buffer {\n    let writer = new BufferWriter();\n    for (let i = 0; i < firstN; i++) { \n      writer.writeUInt8(tx.inputs[i].type);\n      writer.writeReverse(tx.inputs[i].outpoint);\n    }\n    let buf = writer.toBuffer();\n    return Hash.sha256sha256(buf);\n  }\n\n  private static _getPrevoutHashOf(tx: Transaction, inputNumber: number): Buffer {\n    let writer = new BufferWriter();\n    writer.writeUInt8(tx.inputs[inputNumber].type);\n    writer.writeReverse(tx.inputs[inputNumber].outpoint);\n    let buf = writer.toBuffer();\n    return Hash.sha256sha256(buf);\n  }\n\n  private static _getSequenceHash(tx: Transaction, firstN: number): Buffer {\n    let writer = new BufferWriter();\n    for (let i = 0; i < firstN; i++) { \n      writer.writeUInt32LE(tx.inputs[i].sequenceNumber);\n    }\n    let buf = writer.toBuffer();\n    return Hash.sha256sha256(buf);\n  }\n\n  private static _getSequenceHashOf(tx: Transaction, inputNumber: number): Buffer {\n    let writer = new BufferWriter();\n    writer.writeUInt32LE(tx.inputs[inputNumber].sequenceNumber);\n    let buf = writer.toBuffer();\n    return Hash.sha256sha256(buf);\n  }\n\n  private static _getInputAmountHash(tx: Transaction, firstN: number): Buffer {\n    let writer = new BufferWriter();\n    for (let i = 0; i < firstN; i++) { \n      writer.writeUInt64LEBN(BN.fromBigInt(tx.inputs[i].amount));\n    }\n    let buf = writer.toBuffer();\n    return Hash.sha256sha256(buf);\n  }\n\n  private static _getInputAmountHashOf(tx: Transaction, inputNumber: number): Buffer {\n    let writer = new BufferWriter();\n    writer.writeUInt64LEBN(BN.fromBigInt(tx.inputs[inputNumber].amount));\n    let buf = writer.toBuffer();\n    return Hash.sha256sha256(buf);\n  }\n\n  private static _getOutputsHash(tx: Transaction, firstN: number): Buffer {\n    let writer = new BufferWriter();\n    for (let i = 0; i < firstN; i++) { \n      tx.outputs[i].toBufferWriter(writer);\n    }\n    let buf = writer.toBuffer();\n    return Hash.sha256sha256(buf);\n  }\n\n  private static _getOutputsHashOf(tx: Transaction, out1: number, out2: number): Buffer {\n    let writer = new BufferWriter();\n    tx.outputs[out1].toBufferWriter(writer);\n    tx.outputs[out2].toBufferWriter(writer);\n    let buf = writer.toBuffer();\n    return Hash.sha256sha256(buf);\n  }\n}","import { isArray, isDate, isNumber, isObject, isString, isUndefined } from \"lodash-es\";\nimport Transaction from \"./transaction\";\nimport type { ITransaction, ScriptTemplateObject, UTXO } from \"./interfaces\";\nimport UnspentOutput from \"./unspentoutput\";\nimport PublicKeyHashInput from \"./input/publickeyhash\";\nimport PublicKeyTemplateInput from \"./input/publickeytemplate\";\nimport Input from \"./input/input\";\nimport Output from \"./output\";\nimport Script from \"../script/script\";\nimport ScriptTemplateInput from \"./input/scripttemplate\";\nimport type Address from \"../address/address\";\nimport ScriptFactory from \"../script/script.factory\";\nimport ValidationUtils from \"../../utils/validation.utils\";\nimport PrivateKey from \"../../keys/privatekey\";\nimport SighashType from \"./sighashtype\";\nimport TxSignature from \"./txsignature\";\nimport TxSigner from \"./txsigner\";\n\nexport default class TransactionBuilder {\n\n  public transaction: Transaction;\n\n  constructor(tx?: ITransaction | string | Buffer) {\n    if (tx instanceof Transaction) {\n      this.transaction = tx;\n    } else {\n      this.transaction = new Transaction(tx);\n    }\n  }\n\n  public build(): Transaction {\n    return this.transaction;\n  }\n\n  /**\n   * Add an input to this transaction. This is a high level interface\n   * to add an input, for more control, use {@link Transaction.addInput}.\n   *\n   * Can receive, as output information, the output of nexad's `listunspent` command,\n   * with a slightly fancier format recognized by this sdk:\n   *\n   * ```json\n   * {\n   *  outpoint: \"fcf7d303d67f19568cf4ab72d36d583baac461e0f62f289b3dff68da96c2117c\"\n   *  scriptPubKey: \"005114891c4b19cbcaefc31770a938ebd6b1fafabb1be6\",\n   *  satoshis: 181998351\n   * }\n   * // or alternative:\n   * {\n   *  outpoint: \"fcf7d303d67f19568cf4ab72d36d583baac461e0f62f289b3dff68da96c2117c\"\n   *  address: \"nexa:nqtsq5g53ywykxwtethux9ms4yuwh443ltatkxlx3s5pnvwh\",\n   *  amount: 1819983.51\n   *  groupId: <token address if relevant>\n   *  groupAmount: <token amount if relevant>\n   * }\n   * ```\n   * Where `address` can be either a string or a nexcore Address object. The\n   * same is true for `script`, which can be a string or a nexcore Script.\n   * \n   * @see {@link UTXO}\n   *\n   * Beware that this resets all the signatures for inputs.\n   *\n   * @example\n   * ```javascript\n   * let builder = new TransactionBuilder();\n   *\n   * // From a pay to public key template output from nexad's listunspent\n   * builder.from({'outpoint': '0000...', amount: 123.23, scriptPubKey: 'OP_0 OP_1 ...'});\n   *\n   * // From a pay to public key template output (with optional group data)\n   * builder.from({'outpoint': '0000...', satoshis: 12323, address: 'nexa:nqtsq5g...', groupId? 'nexa:tnq...', groupAmount: 56446n });\n   *\n   * // From a script template output\n   * builder.from({'outpoint': '0000...', satoshis: 1000, scriptPubKey: '...', templateData: { templateScript: '...', constraintScript: '...' }};\n   * \n   * let transaction = builder.build();\n   * ```\n   * \n   * @param utxo details on the utxo\n   * @returns this, for chaining\n   */\n  public from(utxo: UTXO | UTXO[]): this {\n    if (isArray(utxo)) {\n      utxo.forEach(u => this.from(u));\n      return this;\n    }\n\n    let exist = this.transaction.inputs.some(input => input.outpoint.toString('hex') === utxo.outpoint);\n    if (exist) {\n      return this;\n    }\n\n    return this._fromUtxo(new UnspentOutput(utxo), utxo.templateData);\n  }\n\n  private _fromUtxo(utxo: UnspentOutput, templateData?: ScriptTemplateObject): this {\n    let clazz;\n    if (utxo.scriptPubKey.isPublicKeyHashOut()) {\n      clazz = PublicKeyHashInput;\n    } else if (utxo.scriptPubKey.isPublicKeyTemplateOut()) {\n      clazz = PublicKeyTemplateInput;\n    } else if (utxo.scriptPubKey.isScriptTemplateOut() && isObject(templateData)) {\n      clazz = ScriptTemplateInput;\n    } else {\n      clazz = Input;\n    }\n\n    let input = new clazz({\n      output: new Output(utxo.satoshis, utxo.scriptPubKey),\n      outpoint: utxo.outpoint,\n      scriptSig: Script.empty(),\n      amount: utxo.satoshis,\n      templateData: templateData\n    });\n    this.transaction.addInput(input);\n    return this;\n  }\n\n  /**\n   * Add an output to the transaction.\n   *\n   * Beware that this resets all the signatures for inputs.\n   *\n   * @param address the destination address\n   * @param amount in satoshis, the nexa amount\n   * @param groupId optional. the token address if sending tokens\n   * @param groupAmount optional. the token amount if sending tokens\n   * \n   * @remarks if sending token, the nexa amount is usually {@link Transaction.DUST_AMOUNT}\n   * \n   * @returns this, for chaining\n   */\n  public to(address: string | Address, amount: number | string | bigint, groupId?: string | Address, groupAmount?: bigint): this {\n    let script = ScriptFactory.buildOutFromAddress(address, groupId, groupAmount);\n    let output = new Output(amount, script);\n    this.transaction.addOutput(output);\n    return this;\n  }\n\n  /**\n   * Add an OP_RETURN output to the transaction.\n   *\n   * Beware that this resets all the signatures for inputs.\n   *\n   * @param data the data to be stored in the OP_RETURN output.\n   *    In case of a string, the UTF-8 representation will be stored\n   * @param isFullScript if the provided data is already an op_return script. default false.\n   * @returns this, for chaining\n   */\n  public addData(data: Buffer | string | Script, isFullScript = false): this {\n    let script = isFullScript ? new Script(data) : ScriptFactory.buildDataOut(data);\n    let output = new Output(0, script);\n    this.transaction.addOutput(output);\n    return this;\n  }\n\n  /**\n   * Set the change address for this transaction\n   *\n   * Beware that this resets all the signatures for inputs.\n   *\n   * @param address An address for change to be sent to.\n   * @returns this, for chaining\n   */\n  public change(address: Address | string): this {\n    this.transaction.setChangeOutput(address);\n    return this;\n  }\n\n  /**\n   * Manually set the fee for this transaction. \n   * \n   * Beware that this resets all the signatures for inputs.\n   *\n   * @param amount satoshis to be used as fee\n   * @returns this, for chaining\n   */\n  public fee(amount: number): this {\n    this.transaction.setFee(amount);\n    return this;\n  }\n\n  /**\n   * Manually set the fee per Byte rate for this transaction.\n   * \n   * Beware that this resets all the signatures for inputs.\n   * \n   * @remarks fee per Byte will be ignored if fee property was set manually\n   *\n   * @param amount satoshis per Byte to be used as fee rate\n   * @returns this, for chaining\n   */\n  public feePerByte(amount: number): this {\n    this.transaction.setFeePerByte(amount);\n    return this;\n  }\n\n  /**\n   * Sets nLockTime so that transaction is not valid until the desired date\n   * \n   * (a timestamp in seconds since UNIX epoch is also accepted)\n   *\n   * @param datetime Date object or unix timestamp number\n   * @returns this, for chaining\n   */\n  public lockUntilDate(datetime: number | Date): this {\n    ValidationUtils.validateArgument(!isUndefined(datetime), 'datetime');\n    if (isNumber(datetime) && datetime < Transaction.NLOCKTIME_BLOCKHEIGHT_LIMIT) {\n      throw new Error(\"Lock Time can't be earlier than UNIX date 500 000 000\");\n    }\n    if (isDate(datetime)) {\n      datetime = datetime.getTime() / 1000;\n    }\n\n    this.transaction.setLockTime(datetime);\n    return this;\n  };\n\n  /**\n   * Sets nLockTime so that transaction is not valid until the desired block height.\n   *\n   * @param height the block height\n   * @returns this, for chaining\n   */\n  public lockUntilBlockHeight(height: number): this {\n    if (height >= Transaction.NLOCKTIME_BLOCKHEIGHT_LIMIT) {\n      throw new Error(\"Block Height can be at most 2^32 - 1\");\n    }\n    if (height < 0) {\n      throw new Error(\"Block Height cannot be negative\");\n    }\n\n    this.transaction.setLockTime(height);\n    return this;\n  }\n\n  /**\n   * Sign the transaction using one or more private keys.\n   *\n   * It tries to sign each input, verifying that the signature will be valid\n   * (matches a public key). Usually this is the last step that should be used with the builder.\n   * \n   * @remarks this method sign all inputs and outputs (sighash type ALL).\n   *  \n   * if you need to sign a specific input or partial transaction\n   *  (create new or complete existing one), use {@link signInput} method.\n   *\n   * @param privateKey private key(s) that be used to sign\n   * @returns this, for chaining\n   */\n  public sign(privateKey: PrivateKey | PrivateKey[]): this {\n    ValidationUtils.validateState(this.transaction.hasAllUtxoInfo(), 'Not all utxo information is available to sign the transaction.');\n\n    if (isArray(privateKey)) {\n      privateKey.forEach(key => this.sign(key));\n      return this;\n    }\n\n    this._getSignatures(privateKey, SighashType.ALL).forEach(sig => this._applySignature(sig));\n    return this;\n  }\n\n  /**\n   * Sign specific input using private key and sighash type.\n   * \n   * Use sigtype to determine which parts of the transaction to sign.\n   * \n   * @param input The input to sign. can be input index (number) or input outpoint hash (string)\n   * @param privateKey private key that be used to sign\n   * @param sigtype the sighash type to define which parts to include in the sighash\n   * @returns this, for chaining\n   */\n  public signInput(input: number | string, privateKey: PrivateKey, sigtype: SighashType): this {\n    if (isString(input)) {\n      input = this.transaction.inputs.findIndex(inp => inp.outpoint.toString('hex') === input);\n    }\n    ValidationUtils.validateArgument(input >= 0 && input < this.transaction.inputs.length, 'input', 'out of range.');\n    ValidationUtils.validateState(this.transaction.inputs[input].canSign(privateKey), 'The provided key cannot sign this input');\n\n    let txSig = this._getSignature(input, privateKey, sigtype);\n    this._applySignature(txSig);\n    return this;\n  }\n\n  private _getSignatures(privKey: PrivateKey, sigtype: SighashType): TxSignature[] {\n    ValidationUtils.validateArgument(privKey instanceof PrivateKey, 'privKey', 'not a private key');\n\n    let signatures: TxSignature[] = [];\n    for (let i = 0; i < this.transaction.inputs.length; i++) {\n      if (!this.transaction.inputs[i].canSign(privKey)) {\n        continue;\n      }\n      let txSig = this._getSignature(i, privKey, sigtype);\n      signatures.push(txSig);\n    }\n\n    return signatures;\n  }\n\n  private _getSignature(index: number, privKey: PrivateKey, sigtype: SighashType): TxSignature {\n    let subscript = this.transaction.inputs[index].getSubscript();\n    return new TxSignature({\n      inputIndex: index,\n      publicKey: privKey.publicKey,\n      subscript: subscript,\n      signature: TxSigner.sign(this.transaction, index, sigtype, subscript, privKey),\n      sigType: sigtype\n    });\n  }\n\n  private _applySignature(signature: TxSignature): void {\n    let isValid = TxSigner.verify(this.transaction, signature.inputIndex, signature.signature, signature.sigType, signature.subscript, signature.publicKey);\n    ValidationUtils.validateState(isValid, 'Signature is invalid');\n\n    this.transaction.inputs[signature.inputIndex].addSignature(signature);\n  }\n}","import baseIsDate from './_baseIsDate.js';\nimport baseUnary from './_baseUnary.js';\nimport nodeUtil from './_nodeUtil.js';\n\n/* Node.js helper references. */\nvar nodeIsDate = nodeUtil && nodeUtil.isDate;\n\n/**\n * Checks if `value` is classified as a `Date` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a date object, else `false`.\n * @example\n *\n * _.isDate(new Date);\n * // => true\n *\n * _.isDate('Mon April 23 2012');\n * // => false\n */\nvar isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;\n\nexport default isDate;\n","import baseGetTag from './_baseGetTag.js';\nimport isObjectLike from './isObjectLike.js';\n\n/** `Object#toString` result references. */\nvar dateTag = '[object Date]';\n\n/**\n * The base implementation of `_.isDate` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a date object, else `false`.\n */\nfunction baseIsDate(value) {\n  return isObjectLike(value) && baseGetTag(value) == dateTag;\n}\n\nexport default baseIsDate;\n","import { isNil, isObject } from \"lodash-es\";\nimport type { IBlock } from \"../../common/interfaces\";\nimport ValidationUtils from \"../../utils/validation.utils\";\nimport Transaction from \"../transaction/transaction\";\nimport BlockHeader from \"./blockheader\";\nimport BufferUtils from \"../../utils/buffer.utils\";\nimport BufferReader from \"../../encoding/bufferreader\";\nimport BufferWriter from \"../../encoding/bufferwriter\";\nimport Hash from \"../../crypto/hash\";\nimport BN from \"../../crypto/bn.extension\";\n\nexport default class Block implements IBlock {\n\n  public header: BlockHeader;\n  public transactions: Transaction[];\n\n  constructor(data: Buffer | IBlock) {\n    ValidationUtils.validateArgument(!isNil(data), 'data is required');\n\n    if (BufferUtils.isBuffer(data)) {\n      data = Block._fromBufferReader(new BufferReader(data));\n    } else if (!isObject(data)) {\n      throw new TypeError('Unrecognized argument for Block');\n    }\n\n    this.header = data.header instanceof BlockHeader \n      ? data.header \n      : BlockHeader.fromObject(data.header);\n\n    this.transactions = [];\n    data.transactions.forEach(tx => {\n      if (tx instanceof Transaction) {\n        this.transactions.push(tx);\n      } else {\n        this.transactions.push(new Transaction().fromObject(tx));\n      }\n    });\n  }\n\n  public get hash(): string {\n    return this.header.hash;\n  }\n\n  /**\n   * @param obj A plain JavaScript object\n   * @returns An instance of block\n   */\n  public static fromObject(obj: IBlock): Block {\n    return new Block(obj);\n  }\n\n  /**\n   * @param br A BufferReader of the block\n   * @returns An object representing the block data\n   */\n  private static _fromBufferReader(br: BufferReader): IBlock {\n    ValidationUtils.validateState(!br.finished(), 'No block data received');\n    let header = BlockHeader.fromBufferReader(br);\n    let txNum = br.readVarintNum();\n    let transactions: Transaction[] = [];\n    for (let i = 0; i < txNum; i++) {\n      transactions.push(new Transaction().fromBufferReader(br));\n    }\n    return { header, transactions };\n  }\n\n  /**\n   * @param br A buffer reader of the block\n   * @returns An instance of block\n   */\n  public static fromBufferReader(br: BufferReader): Block {\n    ValidationUtils.validateArgument(!isNil(br), 'br is required');\n    let info = Block._fromBufferReader(br);\n    return new Block(info);\n  }\n\n  /**\n   * @param buf A buffer of the block\n   * @returns An instance of block\n   */\n  public static fromBuffer(buf: Buffer): Block {\n    return Block.fromBufferReader(new BufferReader(buf));\n  }\n\n  /**\n   * @param str A hex encoded string of the block\n   * @returns A hex encoded string of the block\n   */\n  public static fromString(str: string): Block {\n    let buf = Buffer.from(str, 'hex');\n    return Block.fromBuffer(buf);\n  }\n\n  public toJSON = this.toObject;\n\n  /**\n   * @returns A plain object with the block properties\n   */\n  public toObject(): IBlock {\n    return {\n      header: this.header.toObject(),\n      transactions: this.transactions.map(tx => tx.toObject())\n    };\n  }\n\n  /**\n   * @param bw An existing instance of BufferWriter (optional)\n   * @returns An instance of BufferWriter representation of the Block\n   */\n  public toBufferWriter(bw?: BufferWriter): BufferWriter {\n    if (!bw) {\n      bw = new BufferWriter();\n    }\n    bw.write(this.header.toBuffer());\n    bw.writeVarintNum(this.transactions.length);\n    for (let tx of this.transactions) {\n      tx.toBufferWriter(bw);\n    }\n    return bw;\n  }\n\n  /**\n   * @returns A buffer of the block\n   */\n  public toBuffer(): Buffer {\n    return this.toBufferWriter().toBuffer();\n  }\n\n  /**\n   * @returns A hex encoded string of the block\n   */\n  public toString(): string {\n    return this.toBuffer().toString('hex');\n  }\n\n  /**\n   * @returns A string formatted for the console\n   */\n  public inspect(): string {\n    return `<Block ${this.hash}>`;\n  }\n\n  /**\n   * Will iterate through each transaction and return an array of hashes\n   * @returns An array with transaction hashes\n   */\n  public getTransactionHashes(): Buffer[] {\n    return this.transactions.map(tx => Buffer.from(tx.id, 'hex').reverse());\n  }\n\n  /**\n   * Will build a merkle tree of all the transactions, ultimately arriving at\n   * a single point, the merkle root.\n   * \n   * @see {@link https://spec.nexa.org/blocks/merkle-tree/}\n   * @returns An array with each level of the tree after the other.\n   */\n  public getMerkleTree(): Buffer[] {\n    let tree = this.getTransactionHashes();\n\n    let j = 0;\n    for (let size = this.transactions.length; size > 1; size = Math.floor((size + 1) / 2)) {\n      for (let i = 0; i < size; i += 2) {\n        let i2 = Math.min(i + 1, size - 1);\n        let buf = Buffer.concat([tree[j + i], tree[j + i2]]);\n        tree.push(Hash.sha256sha256(buf));\n      }\n      j += size;\n    }\n\n    return tree;\n  }\n\n  /**\n   * Calculates the merkleRoot from the transactions.\n   * \n   * @returns A buffer of the merkle root hash\n   */\n  public getMerkleRoot(): Buffer {\n    let tree = this.getMerkleTree();\n    return tree[tree.length - 1];\n  }\n\n  /**\n   * Verifies that the transactions in the block match the header merkle root\n   * \n   * @returns true If the merkle roots match\n   */\n  public validMerkleRoot(): boolean {\n    let h = BN.fromString(BufferUtils.reverse(this.header.merkleRoot).toString('hex'), 'hex');\n    let c = BN.fromString(this.getMerkleRoot().toString('hex'), 'hex');\n\n    return h.eq(c);\n  }\n}","import { isNil, isObject, isString } from \"lodash-es\";\nimport type { IBlockHeader } from \"../../common/interfaces\";\nimport BN from \"../../crypto/bn.extension\";\nimport BufferReader from \"../../encoding/bufferreader\";\nimport BufferUtils from \"../../utils/buffer.utils\";\nimport ValidationUtils from \"../../utils/validation.utils\";\nimport BufferWriter from \"../../encoding/bufferwriter\";\nimport Hash from \"../../crypto/hash\";\n\nexport default class BlockHeader implements IBlockHeader {\n\n  public static readonly MAX_TIME_OFFSET = 2 * 60 * 60;\n\n  public prevHash: Buffer;\n  public bits: number;\n  public ancestorHash: Buffer;\n  public merkleRoot: Buffer;\n  public txFilter: Buffer;\n  public time: number;\n  public height: number;\n  public chainWork: Buffer;\n  public size: number;\n  public txCount: number;\n  public poolFee: number;\n  public utxoCommitment: Buffer;\n  public minerData: Buffer;\n  public nonce: Buffer;\n\n  constructor(data: Buffer | IBlockHeader) {\n    ValidationUtils.validateArgument(!isNil(data), 'data is required');\n\n    if (BufferUtils.isBuffer(data)) {\n      data = BlockHeader._fromBufferReader(new BufferReader(data));\n    } else if (!isObject(data)) {\n      throw new TypeError('Unrecognized argument for BlockHeader');\n    }\n  \n    this.prevHash = isString(data.prevHash) ? Buffer.from(data.prevHash, 'hex') : data.prevHash;\n    this.bits = data.bits;\n    this.ancestorHash = isString(data.ancestorHash) ? Buffer.from(data.ancestorHash, 'hex') : data.ancestorHash;\n    this.merkleRoot = isString(data.merkleRoot) ? Buffer.from(data.merkleRoot, 'hex') : data.merkleRoot;\n    this.txFilter = isString(data.txFilter) ? Buffer.from(data.txFilter, 'hex') : data.txFilter;\n    this.time = data.time;\n    this.height = data.height;\n    this.chainWork = isString(data.chainWork) ? Buffer.from(data.chainWork, 'hex') : data.chainWork;\n    this.size = data.size;\n    this.txCount = data.txCount;\n    this.poolFee = data.poolFee;\n    this.utxoCommitment = isString(data.utxoCommitment) ? Buffer.from(data.utxoCommitment, 'hex') : data.utxoCommitment;\n    this.minerData = isString(data.minerData) ? Buffer.from(data.minerData, 'hex') : data.minerData;\n    this.nonce = isString(data.nonce) ? Buffer.from(data.nonce, 'hex') : data.nonce;\n\n    if (data.hash) {\n      ValidationUtils.validateState(this.hash === data.hash,\n        'Argument object hash property does not match block hash.'\n      );\n    }\n  }\n\n  public get hash(): string {\n    return this._getHash().reverse().toString('hex');\n  }\n\n  /**\n   * @returns The little endian hash buffer of the header\n   */\n  private _getHash(): Buffer {\n    let miniHeader = new BufferWriter();\n    miniHeader.writeReverse(this.prevHash);\n    miniHeader.writeInt32LE(this.bits);\n\n    let miniHash = Hash.sha256(miniHeader.toBuffer())\n\n    let extHeader = new BufferWriter();\n    extHeader.writeReverse(this.ancestorHash);\n    extHeader.writeReverse(this.txFilter);\n    extHeader.writeReverse(this.merkleRoot);\n    extHeader.writeInt32LE(this.time);\n    extHeader.writeUInt64LEBN(BN.fromNumber(this.height));\n    extHeader.writeReverse(this.chainWork);\n    extHeader.writeUInt64LEBN(BN.fromNumber(this.size));\n    extHeader.writeUInt64LEBN(BN.fromNumber(this.txCount));\n    extHeader.writeUInt64LEBN(BN.fromNumber(this.poolFee));\n    extHeader.writeVarLengthBuf(this.utxoCommitment);\n    extHeader.writeVarLengthBuf(this.minerData);\n    extHeader.writeVarLengthBuf(this.nonce);\n\n    let extHash = Hash.sha256(extHeader.toBuffer());\n\n    let commintment = new BufferWriter();\n    commintment.write(miniHash);\n    commintment.write(extHash);\n\n    return Hash.sha256(commintment.toBuffer());\n  }\n\n  /**\n   * @param br A BufferReader of the block header\n   * @returns An object representing block header data\n   */\n  private static _fromBufferReader(br: BufferReader): IBlockHeader {\n    return {\n      prevHash: br.readReverse(32),\n      bits: br.readUInt32LE(),\n      ancestorHash: br.readReverse(32),\n      merkleRoot: br.readReverse(32),\n      txFilter: br.readReverse(32),\n      time: br.readUInt32LE(),\n      height: br.readCoreVarintNum(),\n      chainWork: br.readReverse(32),\n      size: br.readUInt64LEBN().toNumber(),\n      txCount: br.readCoreVarintNum(),\n      poolFee: br.readCoreVarintNum(),\n      utxoCommitment: br.readVarLengthBuffer(),\n      minerData: br.readVarLengthBuffer(),\n      nonce: br.readVarLengthBuffer(),\n    };\n  }\n\n  /**\n   * This method is useful for hex that represent concatination of multiple headers\n   * so it able to serve in a loop.\n   * \n   * @param br A BufferReader of the block header\n   * @returns An instance of block header\n   */\n  public static fromBufferReader(br: BufferReader): BlockHeader {\n    let info = this._fromBufferReader(br);\n    return new BlockHeader(info);\n  }\n\n  /**\n   * @param header A plain JavaScript block header object\n   * @returns An instance of block header\n   */\n  public static fromObject(header: IBlockHeader): BlockHeader {\n    return new BlockHeader(header);\n  }\n\n  /**\n   * @param buf A buffer of the block header\n   * @returns An instance of block header\n   */\n  public static fromBuffer(buf: Buffer): BlockHeader {\n    return this.fromBufferReader(new BufferReader(buf));\n  }\n\n  /**\n   * @param hex A hex encoded buffer of the block header\n   * @returns An instance of block header\n   */\n  public static fromString(hex: string): BlockHeader {\n    let buf = Buffer.from(hex, 'hex');\n    return this.fromBuffer(buf);\n  }\n\n  public toJSON = this.toObject;\n\n  /**\n   * @returns A plain object of the BlockHeader\n   */\n  public toObject(): IBlockHeader {\n    return {\n      hash: this.hash,\n      prevHash: this.prevHash.toString('hex'),\n      bits: this.bits,\n      ancestorHash: this.ancestorHash.toString('hex'),\n      merkleRoot: this.merkleRoot.toString('hex'),\n      txFilter: this.txFilter.toString('hex'),\n      time: this.time,\n      height: this.height,\n      chainWork: this.chainWork.toString('hex'),\n      size: this.size,\n      txCount: this.txCount,\n      poolFee: this.poolFee,\n      utxoCommitment: this.utxoCommitment.toString('hex'),\n      minerData: this.minerData.toString('hex'),\n      nonce: this.nonce.toString('hex'),\n    };\n  }\n\n  /**\n   * @param bw - An existing instance BufferWriter\n   * @returns An instance of BufferWriter representation of the BlockHeader\n   */\n  public toBufferWriter(bw?: BufferWriter): BufferWriter {\n    if (!bw) {\n      bw = new BufferWriter();\n    }\n    bw.writeReverse(this.prevHash);\n    bw.writeInt32LE(this.bits);\n    bw.writeReverse(this.ancestorHash);\n    bw.writeReverse(this.merkleRoot);\n    bw.writeReverse(this.txFilter);\n    bw.writeInt32LE(this.time);\n    bw.writeCoreVarintNum(this.height);\n    bw.writeReverse(this.chainWork);\n    bw.writeUInt64LEBN(BN.fromNumber(this.size));\n    bw.writeCoreVarintNum(this.txCount);\n    bw.writeCoreVarintNum(this.poolFee);\n    bw.writeVarLengthBuf(this.utxoCommitment);\n    bw.writeVarLengthBuf(this.minerData);\n    bw.writeVarLengthBuf(this.nonce);\n    return bw;\n  }\n\n  /**\n   * @returns A Buffer of the BlockHeader\n   */\n  public toBuffer(): Buffer {\n    return this.toBufferWriter().toBuffer();\n  }\n\n  /**\n   * @returns A hex encoded string of the BlockHeader\n   */\n  public toString(): string {\n    return this.toBuffer().toString('hex');\n  }\n\n  /**\n   * @returns A string formatted for the console\n   */\n  public inspect(): string {\n    return `<BlockHeader ${this.hash}>`;\n  }\n\n  /**\n   * Returns the target difficulty for this block\n   * \n   * @param bits the bits number\n   * @returns An instance of BN with the decoded difficulty bits\n   */\n  public getTargetDifficulty(bits?: number): BN {\n    let bitsBuf = BN.fromNumber(bits || this.bits).toBuffer({ size: 4, endian: 'little' });\n\n    let exponent = BN.fromBuffer(Buffer.from([bitsBuf[0]]));\n    let significand = BN.fromBuffer(bitsBuf.subarray(1));\n\n    let target = significand.toBigInt() * (2n ** (8n * (exponent.toBigInt() - 3n)));\n    \n    return new BN(target.toString());\n  }\n\n  /**\n   * @returns the target difficulty for this block\n   */\n  public getDifficulty(): number {\n    let nShift = (this.bits >> 24) & 0xff;\n\n    let dDiff = 0x0000ffff / (this.bits & 0x00ffffff);\n\n    while (nShift < 29)\n    {\n        dDiff *= 256.0;\n        nShift++;\n    }\n    while (nShift > 29)\n    {\n        dDiff /= 256.0;\n        nShift--;\n    }\n\n    return dDiff;\n  }\n\n  /**\n   * @returns true If timestamp is not too far in the future\n   */\n  public validTimestamp(): boolean {\n    let currentTime = Math.round(new Date().getTime() / 1000);\n    return this.time <= currentTime + BlockHeader.MAX_TIME_OFFSET\n  }\n\n  /**\n   * @returns true If the proof-of-work hash satisfies the target difficulty\n   */\n  public validProofOfWork(): boolean {\n    let pow = BN.fromString(this.hash, 'hex');\n    let target = this.getTargetDifficulty();\n\n    return pow.lte(target)\n  }\n}"],"names":[],"version":3,"file":"index.cjs.map","sourceRoot":"../"}