mainnet-js 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.html +1 -1
- package/dist/{mainnet-1.0.0.js → mainnet-1.0.3.js} +4 -4
- package/dist/module/network/ElectrumNetworkProvider.d.ts +0 -1
- package/dist/module/network/ElectrumNetworkProvider.d.ts.map +1 -1
- package/dist/module/network/ElectrumNetworkProvider.js +15 -39
- package/dist/module/network/ElectrumNetworkProvider.js.map +1 -1
- package/dist/module/network/constant.d.ts +2 -1
- package/dist/module/network/constant.d.ts.map +1 -1
- package/dist/module/network/constant.js +14 -11
- package/dist/module/network/constant.js.map +1 -1
- package/dist/module/network/default.d.ts.map +1 -1
- package/dist/module/network/default.js +15 -12
- package/dist/module/network/default.js.map +1 -1
- package/dist/module/network/interface.d.ts +9 -0
- package/dist/module/network/interface.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/network/ElectrumNetworkProvider.ts +16 -54
- package/src/network/constant.ts +14 -11
- package/src/network/default.ts +24 -12
- package/src/network/interface.ts +13 -0
- package/src/wallet/Cashtokens.test.ts +10 -2
package/dist/index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<title>The Empty Mainnet App</title>
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1"><script defer src="mainnet-1.0.
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1"><script defer src="mainnet-1.0.3.js"></script></head>
|
|
7
7
|
<body><script>document.addEventListener("DOMContentLoaded", async (event) => Object.assign(globalThis, await __mainnetPromise))</script>
|
|
8
8
|
</body>
|
|
9
9
|
</html>
|
|
@@ -1104,7 +1104,7 @@ eval("__webpack_require__.a(module, async (__webpack_handle_async_dependencies__
|
|
|
1104
1104
|
\************************************************/
|
|
1105
1105
|
/***/ ((module, __webpack_exports__, __webpack_require__) => {
|
|
1106
1106
|
|
|
1107
|
-
eval("__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ ElectrumNetworkProvider)\n/* harmony export */ });\n/* harmony import */ var electrum_cash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! electrum-cash */ \"../../node_modules/electrum-cash/dist/index.mjs.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../interface.js */ \"./src/interface.ts\");\n/* harmony import */ var _util_delay_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../util/delay.js */ \"./src/util/delay.ts\");\n/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! async-mutex */ \"../../node_modules/async-mutex/index.mjs\");\n/* harmony import */ var _util_transaction_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/transaction.js */ \"./src/util/transaction.ts\");\n/* harmony import */ var _bitauth_libauth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @bitauth/libauth */ \"./node_modules/@bitauth/libauth/build/lib/message/transaction-encoding.js\");\n/* harmony import */ var _bitauth_libauth__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @bitauth/libauth */ \"./node_modules/@bitauth/libauth/build/lib/format/hex.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_bitauth_libauth__WEBPACK_IMPORTED_MODULE_3__, _util_transaction_js__WEBPACK_IMPORTED_MODULE_5__]);\n([_bitauth_libauth__WEBPACK_IMPORTED_MODULE_3__, _util_transaction_js__WEBPACK_IMPORTED_MODULE_5__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);\n\n\n\n\n\n\nclass ElectrumNetworkProvider {\n constructor(electrum, network = _interface_js__WEBPACK_IMPORTED_MODULE_2__.Network.MAINNET, manualConnectionManagement) {\n this.network = network;\n this.manualConnectionManagement = manualConnectionManagement;\n this.subscriptions = 0;\n this.mutex = new async_mutex__WEBPACK_IMPORTED_MODULE_1__.Mutex();\n this.blockHeight = 0;\n if (electrum) {\n this.electrum = electrum;\n this.connectPromise = this.getConnectPromise();\n }\n else {\n throw new Error(`A electrum-cash cluster or client is required.`);\n }\n }\n async getConnectPromise(_timeout = 3000) {\n // connects to the electrum cash and waits until the connection is ready to accept requests\n let timeoutHandle;\n await Promise.race([\n new Promise(async (resolve) => {\n this.connectPromise = undefined;\n if (this.electrum instanceof electrum_cash__WEBPACK_IMPORTED_MODULE_0__.ElectrumCluster) {\n try {\n await this.connectCluster();\n }\n catch (e) {\n console.warn(`Unable to connect to one or more electrum-cash hosts: ${JSON.stringify(e)}`);\n }\n resolve(await this.readyCluster());\n }\n else {\n resolve(await this.connectClient());\n }\n }),\n // new Promise(\n // (_resolve, reject) =>\n // (timeoutHandle = setTimeout(() => {\n // reject(\n // new Error(`Timeout connecting to electrum network: ${this.network}`)\n // );\n // }, _timeout))\n // ),\n ]);\n clearTimeout(timeoutHandle);\n }\n async getUtxos(cashaddr) {\n const result = (await this.performRequest(\"blockchain.address.listunspent\", cashaddr));\n if (this.network === _interface_js__WEBPACK_IMPORTED_MODULE_2__.Network.MAINNET) {\n return result.map((utxo) => ({\n txid: utxo.tx_hash,\n vout: utxo.tx_pos,\n satoshis: utxo.value,\n height: utxo.height,\n }));\n }\n // a workaround until Fulcrum returns token info\n const uniqueTransactionHashes = result.filter((value, index, array) => array.indexOf(value) === index);\n const transactionMap = {};\n for (let { tx_hash } of uniqueTransactionHashes) {\n const key = `${this.network}-${tx_hash};`;\n // check cache\n if (ElectrumNetworkProvider.utxoTxCache[key]) {\n transactionMap[tx_hash] = ElectrumNetworkProvider.utxoTxCache[key];\n continue;\n }\n // download and decode tx from Fulcrum\n const decoded = (0,_bitauth_libauth__WEBPACK_IMPORTED_MODULE_3__.decodeTransactionBCH)((0,_bitauth_libauth__WEBPACK_IMPORTED_MODULE_4__.hexToBin)(await this.getRawTransaction(tx_hash, false)));\n if (typeof decoded === \"string\") {\n throw new Error(decoded);\n }\n transactionMap[tx_hash] = decoded;\n ElectrumNetworkProvider.utxoTxCache[key] = decoded;\n }\n const utxos = result.map((utxo) => {\n const output = transactionMap[utxo.tx_hash].outputs[utxo.tx_pos];\n return {\n txid: utxo.tx_hash,\n vout: utxo.tx_pos,\n satoshis: utxo.value,\n height: utxo.height,\n token: output.token &&\n {\n amount: Number(output.token.amount),\n tokenId: (0,_bitauth_libauth__WEBPACK_IMPORTED_MODULE_4__.binToHex)(output.token.category),\n capability: output.token.nft?.capability,\n commitment: output.token.nft?.commitment &&\n (0,_bitauth_libauth__WEBPACK_IMPORTED_MODULE_4__.binToHex)(output.token.nft?.commitment),\n },\n };\n });\n return utxos;\n }\n async getBalance(cashaddr) {\n const result = (await this.performRequest(\"blockchain.address.get_balance\", cashaddr));\n return result.confirmed + result.unconfirmed;\n }\n async getBlockHeight() {\n if (!this.blockHeight) {\n return new Promise(async (resolve) => {\n await this.subscribeToHeaders((header) => {\n this.blockHeight = header.height;\n });\n resolve(this.blockHeight);\n });\n }\n return this.blockHeight;\n }\n async getRawTransaction(txHash, verbose = false) {\n const key = `${this.network}-${txHash}-${verbose}`;\n if (ElectrumNetworkProvider.rawTransactionCache[key]) {\n return ElectrumNetworkProvider.rawTransactionCache[key];\n }\n try {\n const result = await this.performRequest(\"blockchain.transaction.get\", txHash, verbose);\n ElectrumNetworkProvider.rawTransactionCache[key] = result;\n return result;\n }\n catch (error) {\n if (error.message.indexOf(\"No such mempool or blockchain transaction.\") > -1)\n throw Error(`Could not decode transaction ${txHash}. It might not exist on the current blockchain (${this.network}).`);\n else\n throw error;\n }\n }\n // gets the decoded transaction in human readable form\n async getRawTransactionObject(txHash) {\n return (await this.getRawTransaction(txHash, true));\n }\n async sendRawTransaction(txHex, awaitPropagation = true) {\n return new Promise(async (resolve, reject) => {\n let txHash = await (0,_util_transaction_js__WEBPACK_IMPORTED_MODULE_5__.getTransactionHash)(txHex);\n if (!awaitPropagation) {\n this.performRequest(\"blockchain.transaction.broadcast\", txHex);\n resolve(txHash);\n }\n else {\n const waitForTransactionCallback = async (data) => {\n if (data && data[0] === txHash) {\n this.unsubscribeFromTransaction(txHash, waitForTransactionCallback);\n resolve(txHash);\n }\n };\n this.subscribeToTransaction(txHash, waitForTransactionCallback);\n this.performRequest(\"blockchain.transaction.broadcast\", txHex).catch((error) => {\n this.unsubscribeFromTransaction(txHash, waitForTransactionCallback);\n reject(error);\n });\n }\n });\n }\n // Get transaction history of a given cashaddr\n async getHistory(cashaddr) {\n const result = (await this.performRequest(\"blockchain.address.get_history\", cashaddr));\n return result;\n }\n // Get the minimum fee a low-priority transaction must pay in order to be accepted to the daemon's memory pool.\n async getRelayFee() {\n const result = (await this.performRequest(\"blockchain.relayfee\"));\n return result;\n }\n watchAddressStatus(cashaddr, callback) {\n const watchAddressStatusCallback = async (data) => {\n // subscription acknowledgement is the latest known status or null if no status is known\n // status is an array: [ cashaddr, statusHash ]\n if (data instanceof Array) {\n const addr = data[0];\n if (addr !== cashaddr) {\n return;\n }\n const status = data[1];\n callback(status);\n }\n };\n this.subscribeToAddress(cashaddr, watchAddressStatusCallback);\n return async () => {\n await this.unsubscribeFromAddress(cashaddr, watchAddressStatusCallback);\n };\n }\n // public watchAddress(\n // cashaddr: string,\n // callback: (txHash: string) => void\n // ): CancelWatchFn {\n // const watchAddressCallback = async (data) => {\n // // subscription acknowledgement is the latest known status or null if no status is known\n // // status is an array: [ cashaddr, [tx_hashes] ]\n // if (data instanceof Array) {\n // let addr = data[0] as string;\n // if (addr !== cashaddr) {\n // return;\n // }\n // for (const txHash of data[1]) {\n // if (!txHash) {\n // // data[1] can be null eventually if there are no tx for this address\n // continue;\n // }\n // callback(txHash);\n // }\n // }\n // };\n // this.subscribeToAddressTransactions(cashaddr, watchAddressCallback);\n // return async () => {\n // await this.unsubscribeFromAddressTransactions(\n // cashaddr,\n // watchAddressCallback\n // );\n // };\n // }\n // public watchAddressTransactions(\n // cashaddr: string,\n // callback: (tx: ElectrumRawTransaction) => void\n // ): CancelWatchFn {\n // return this.watchAddress(cashaddr, async (txHash: string) => {\n // const tx = await this.getRawTransactionObject(txHash);\n // callback(tx);\n // });\n // }\n // Wait for the next block or a block at given blockchain height.\n watchBlocks(callback) {\n let acknowledged = false;\n const waitForBlockCallback = (_header) => {\n if (!acknowledged) {\n acknowledged = true;\n return;\n }\n _header = _header instanceof Array ? _header[0] : _header;\n callback(_header);\n };\n this.subscribeToHeaders(waitForBlockCallback);\n return async () => {\n this.unsubscribeFromHeaders(waitForBlockCallback);\n };\n }\n // Wait for the next block or a block at given blockchain height.\n async waitForBlock(height) {\n return new Promise(async (resolve) => {\n const cancelWatch = this.watchBlocks(async (header) => {\n if (height === undefined || header.height >= height) {\n await cancelWatch();\n resolve(header);\n }\n });\n });\n }\n // subscribe to notifications sent when new block is found, the block header is sent to callback\n async subscribeToHeaders(callback) {\n await this.subscribeRequest(\"blockchain.headers.subscribe\", callback);\n }\n // unsubscribe to notifications sent when new block is found\n async unsubscribeFromHeaders(callback) {\n await this.unsubscribeRequest(\"blockchain.headers.subscribe\", callback);\n }\n async subscribeToAddress(cashaddr, callback) {\n await this.subscribeRequest(\"blockchain.address.subscribe\", callback, cashaddr);\n }\n async unsubscribeFromAddress(cashaddr, callback) {\n await this.unsubscribeRequest(\"blockchain.address.subscribe\", callback, cashaddr);\n }\n async subscribeToAddressTransactions(cashaddr, callback) {\n await this.subscribeRequest(\"blockchain.address.transactions.subscribe\", callback, cashaddr);\n }\n async unsubscribeFromAddressTransactions(cashaddr, callback) {\n await this.unsubscribeRequest(\"blockchain.address.transactions.subscribe\", callback, cashaddr);\n }\n async subscribeToTransaction(txHash, callback) {\n await this.subscribeRequest(\"blockchain.transaction.subscribe\", callback, txHash);\n }\n async unsubscribeFromTransaction(txHash, callback) {\n await this.unsubscribeRequest(\"blockchain.transaction.subscribe\", callback, txHash);\n }\n async performRequest(name, ...parameters) {\n await this.ready();\n const requestTimeout = new Promise(function (_resolve, reject) {\n setTimeout(function () {\n reject(\"electrum-cash request timed out, retrying\");\n }, 30000);\n }).catch(function (e) {\n throw e;\n });\n const request = this.electrum.request(name, ...parameters);\n return await Promise.race([request, requestTimeout])\n .then((value) => {\n if (value instanceof Error)\n throw value;\n let result = value;\n return result;\n })\n .catch(async () => {\n // console.warn(\n // \"initial electrum-cash request attempt timed out, retrying...\"\n // );\n return await Promise.race([request, requestTimeout])\n .then((value) => {\n if (value instanceof Error)\n throw value;\n let result = value;\n return result;\n })\n .catch(function (e) {\n throw e;\n });\n });\n }\n async subscribeRequest(methodName, callback, ...parameters) {\n await this.ready();\n const result = await this.electrum.subscribe(callback, methodName, ...parameters);\n this.subscriptions++;\n return result;\n }\n async unsubscribeRequest(methodName, callback, ...parameters) {\n await this.ready();\n const result = this.electrum.unsubscribe(callback, methodName, ...parameters);\n this.subscriptions--;\n return result;\n }\n async ready() {\n return (await this.connect());\n }\n async connect() {\n return await this.mutex.runExclusive(async () => {\n return await this.connectPromise;\n });\n }\n disconnect() {\n if (this.subscriptions > 0) {\n // console.warn(\n // `Trying to disconnect a network provider with ${this.subscriptions} active subscriptions. This is in most cases a bad idea.`\n // );\n }\n return this.isElectrumClient()\n ? this.disconnectClient()\n : this.disconnectCluster();\n }\n isElectrumClient() {\n return this.electrum.hasOwnProperty(\"connection\");\n }\n async readyClient(timeout) {\n timeout = typeof timeout !== \"undefined\" ? timeout : 3000;\n let connectPromise = async () => {\n while (this.electrum.connection.status !==\n electrum_cash__WEBPACK_IMPORTED_MODULE_0__.ConnectionStatus.CONNECTED) {\n await (0,_util_delay_js__WEBPACK_IMPORTED_MODULE_6__.delay)(100);\n }\n return true;\n };\n return connectPromise;\n }\n async readyCluster(timeout) {\n timeout;\n return this.electrum.ready();\n }\n async connectCluster() {\n return this.electrum.startup();\n }\n async connectClient() {\n let connectionPromise = async () => {\n try {\n return await this.electrum.connect();\n }\n catch (e) {\n console.warn(`Warning: Failed to connect to client on ${this.network} at ${this.electrum.connection.host}.`);\n return;\n }\n };\n return [await connectionPromise()];\n }\n async disconnectCluster() {\n return this.electrum.shutdown();\n }\n async disconnectClient() {\n return [await this.electrum.disconnect(true)];\n }\n}\nElectrumNetworkProvider.utxoTxCache = {};\nElectrumNetworkProvider.rawTransactionCache = {};\n\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://mainnet-js/./src/network/ElectrumNetworkProvider.ts?");
|
|
1107
|
+
eval("__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ ElectrumNetworkProvider)\n/* harmony export */ });\n/* harmony import */ var electrum_cash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! electrum-cash */ \"../../node_modules/electrum-cash/dist/index.mjs.js\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../interface.js */ \"./src/interface.ts\");\n/* harmony import */ var _util_delay_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/delay.js */ \"./src/util/delay.ts\");\n/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! async-mutex */ \"../../node_modules/async-mutex/index.mjs\");\n/* harmony import */ var _util_transaction_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/transaction.js */ \"./src/util/transaction.ts\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_util_transaction_js__WEBPACK_IMPORTED_MODULE_3__]);\n_util_transaction_js__WEBPACK_IMPORTED_MODULE_3__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];\n\n\n\n\n\nclass ElectrumNetworkProvider {\n constructor(electrum, network = _interface_js__WEBPACK_IMPORTED_MODULE_2__.Network.MAINNET, manualConnectionManagement) {\n this.network = network;\n this.manualConnectionManagement = manualConnectionManagement;\n this.subscriptions = 0;\n this.mutex = new async_mutex__WEBPACK_IMPORTED_MODULE_1__.Mutex();\n this.blockHeight = 0;\n if (electrum) {\n this.electrum = electrum;\n this.connectPromise = this.getConnectPromise();\n }\n else {\n throw new Error(`A electrum-cash cluster or client is required.`);\n }\n }\n async getConnectPromise(_timeout = 3000) {\n // connects to the electrum cash and waits until the connection is ready to accept requests\n let timeoutHandle;\n await Promise.race([\n new Promise(async (resolve) => {\n this.connectPromise = undefined;\n if (this.electrum instanceof electrum_cash__WEBPACK_IMPORTED_MODULE_0__.ElectrumCluster) {\n try {\n await this.connectCluster();\n }\n catch (e) {\n console.warn(`Unable to connect to one or more electrum-cash hosts: ${JSON.stringify(e)}`);\n }\n resolve(await this.readyCluster());\n }\n else {\n resolve(await this.connectClient());\n }\n }),\n // new Promise(\n // (_resolve, reject) =>\n // (timeoutHandle = setTimeout(() => {\n // reject(\n // new Error(`Timeout connecting to electrum network: ${this.network}`)\n // );\n // }, _timeout))\n // ),\n ]);\n clearTimeout(timeoutHandle);\n }\n async getUtxos(cashaddr) {\n const result = (await this.performRequest(\"blockchain.address.listunspent\", cashaddr));\n if (this.network === _interface_js__WEBPACK_IMPORTED_MODULE_2__.Network.MAINNET) {\n return result.map((utxo) => ({\n txid: utxo.tx_hash,\n vout: utxo.tx_pos,\n satoshis: utxo.value,\n height: utxo.height,\n }));\n }\n return result.map((utxo) => ({\n txid: utxo.tx_hash,\n vout: utxo.tx_pos,\n satoshis: utxo.value,\n height: utxo.height,\n token: utxo.token_data\n ? {\n amount: Number(utxo.token_data.amount),\n tokenId: utxo.token_data.category,\n capability: utxo.token_data.nft?.capability,\n commitment: utxo.token_data.nft?.commitment,\n }\n : undefined,\n }));\n }\n async getBalance(cashaddr) {\n const result = (await this.performRequest(\"blockchain.address.get_balance\", cashaddr));\n return result.confirmed + result.unconfirmed;\n }\n async getBlockHeight() {\n if (!this.blockHeight) {\n return new Promise(async (resolve) => {\n await this.subscribeToHeaders((header) => {\n this.blockHeight = header.height;\n });\n resolve(this.blockHeight);\n });\n }\n return this.blockHeight;\n }\n async getRawTransaction(txHash, verbose = false) {\n const key = `${this.network}-${txHash}-${verbose}`;\n if (ElectrumNetworkProvider.rawTransactionCache[key]) {\n return ElectrumNetworkProvider.rawTransactionCache[key];\n }\n try {\n const result = await this.performRequest(\"blockchain.transaction.get\", txHash, verbose);\n ElectrumNetworkProvider.rawTransactionCache[key] = result;\n return result;\n }\n catch (error) {\n if (error.message.indexOf(\"No such mempool or blockchain transaction.\") > -1)\n throw Error(`Could not decode transaction ${txHash}. It might not exist on the current blockchain (${this.network}).`);\n else\n throw error;\n }\n }\n // gets the decoded transaction in human readable form\n async getRawTransactionObject(txHash) {\n return (await this.getRawTransaction(txHash, true));\n }\n async sendRawTransaction(txHex, awaitPropagation = true) {\n return new Promise(async (resolve, reject) => {\n let txHash = await (0,_util_transaction_js__WEBPACK_IMPORTED_MODULE_3__.getTransactionHash)(txHex);\n if (!awaitPropagation) {\n this.performRequest(\"blockchain.transaction.broadcast\", txHex);\n resolve(txHash);\n }\n else {\n const waitForTransactionCallback = async (data) => {\n if (data && data[0] === txHash) {\n this.unsubscribeFromTransaction(txHash, waitForTransactionCallback);\n resolve(txHash);\n }\n };\n this.subscribeToTransaction(txHash, waitForTransactionCallback);\n this.performRequest(\"blockchain.transaction.broadcast\", txHex).catch((error) => {\n this.unsubscribeFromTransaction(txHash, waitForTransactionCallback);\n reject(error);\n });\n }\n });\n }\n // Get transaction history of a given cashaddr\n async getHistory(cashaddr) {\n const result = (await this.performRequest(\"blockchain.address.get_history\", cashaddr));\n return result;\n }\n // Get the minimum fee a low-priority transaction must pay in order to be accepted to the daemon's memory pool.\n async getRelayFee() {\n const result = (await this.performRequest(\"blockchain.relayfee\"));\n return result;\n }\n watchAddressStatus(cashaddr, callback) {\n const watchAddressStatusCallback = async (data) => {\n // subscription acknowledgement is the latest known status or null if no status is known\n // status is an array: [ cashaddr, statusHash ]\n if (data instanceof Array) {\n const addr = data[0];\n if (addr !== cashaddr) {\n return;\n }\n const status = data[1];\n callback(status);\n }\n };\n this.subscribeToAddress(cashaddr, watchAddressStatusCallback);\n return async () => {\n await this.unsubscribeFromAddress(cashaddr, watchAddressStatusCallback);\n };\n }\n // public watchAddress(\n // cashaddr: string,\n // callback: (txHash: string) => void\n // ): CancelWatchFn {\n // const watchAddressCallback = async (data) => {\n // // subscription acknowledgement is the latest known status or null if no status is known\n // // status is an array: [ cashaddr, [tx_hashes] ]\n // if (data instanceof Array) {\n // let addr = data[0] as string;\n // if (addr !== cashaddr) {\n // return;\n // }\n // for (const txHash of data[1]) {\n // if (!txHash) {\n // // data[1] can be null eventually if there are no tx for this address\n // continue;\n // }\n // callback(txHash);\n // }\n // }\n // };\n // this.subscribeToAddressTransactions(cashaddr, watchAddressCallback);\n // return async () => {\n // await this.unsubscribeFromAddressTransactions(\n // cashaddr,\n // watchAddressCallback\n // );\n // };\n // }\n // public watchAddressTransactions(\n // cashaddr: string,\n // callback: (tx: ElectrumRawTransaction) => void\n // ): CancelWatchFn {\n // return this.watchAddress(cashaddr, async (txHash: string) => {\n // const tx = await this.getRawTransactionObject(txHash);\n // callback(tx);\n // });\n // }\n // Wait for the next block or a block at given blockchain height.\n watchBlocks(callback) {\n let acknowledged = false;\n const waitForBlockCallback = (_header) => {\n if (!acknowledged) {\n acknowledged = true;\n return;\n }\n _header = _header instanceof Array ? _header[0] : _header;\n callback(_header);\n };\n this.subscribeToHeaders(waitForBlockCallback);\n return async () => {\n this.unsubscribeFromHeaders(waitForBlockCallback);\n };\n }\n // Wait for the next block or a block at given blockchain height.\n async waitForBlock(height) {\n return new Promise(async (resolve) => {\n const cancelWatch = this.watchBlocks(async (header) => {\n if (height === undefined || header.height >= height) {\n await cancelWatch();\n resolve(header);\n }\n });\n });\n }\n // subscribe to notifications sent when new block is found, the block header is sent to callback\n async subscribeToHeaders(callback) {\n await this.subscribeRequest(\"blockchain.headers.subscribe\", callback);\n }\n // unsubscribe to notifications sent when new block is found\n async unsubscribeFromHeaders(callback) {\n await this.unsubscribeRequest(\"blockchain.headers.subscribe\", callback);\n }\n async subscribeToAddress(cashaddr, callback) {\n await this.subscribeRequest(\"blockchain.address.subscribe\", callback, cashaddr);\n }\n async unsubscribeFromAddress(cashaddr, callback) {\n await this.unsubscribeRequest(\"blockchain.address.subscribe\", callback, cashaddr);\n }\n async subscribeToAddressTransactions(cashaddr, callback) {\n await this.subscribeRequest(\"blockchain.address.transactions.subscribe\", callback, cashaddr);\n }\n async unsubscribeFromAddressTransactions(cashaddr, callback) {\n await this.unsubscribeRequest(\"blockchain.address.transactions.subscribe\", callback, cashaddr);\n }\n async subscribeToTransaction(txHash, callback) {\n await this.subscribeRequest(\"blockchain.transaction.subscribe\", callback, txHash);\n }\n async unsubscribeFromTransaction(txHash, callback) {\n await this.unsubscribeRequest(\"blockchain.transaction.subscribe\", callback, txHash);\n }\n async performRequest(name, ...parameters) {\n await this.ready();\n const requestTimeout = new Promise(function (_resolve, reject) {\n setTimeout(function () {\n reject(\"electrum-cash request timed out, retrying\");\n }, 30000);\n }).catch(function (e) {\n throw e;\n });\n const request = this.electrum.request(name, ...parameters);\n return await Promise.race([request, requestTimeout])\n .then((value) => {\n if (value instanceof Error)\n throw value;\n let result = value;\n return result;\n })\n .catch(async () => {\n // console.warn(\n // \"initial electrum-cash request attempt timed out, retrying...\"\n // );\n return await Promise.race([request, requestTimeout])\n .then((value) => {\n if (value instanceof Error)\n throw value;\n let result = value;\n return result;\n })\n .catch(function (e) {\n throw e;\n });\n });\n }\n async subscribeRequest(methodName, callback, ...parameters) {\n await this.ready();\n const result = await this.electrum.subscribe(callback, methodName, ...parameters);\n this.subscriptions++;\n return result;\n }\n async unsubscribeRequest(methodName, callback, ...parameters) {\n await this.ready();\n const result = this.electrum.unsubscribe(callback, methodName, ...parameters);\n this.subscriptions--;\n return result;\n }\n async ready() {\n return (await this.connect());\n }\n async connect() {\n return await this.mutex.runExclusive(async () => {\n return await this.connectPromise;\n });\n }\n disconnect() {\n if (this.subscriptions > 0) {\n // console.warn(\n // `Trying to disconnect a network provider with ${this.subscriptions} active subscriptions. This is in most cases a bad idea.`\n // );\n }\n return this.isElectrumClient()\n ? this.disconnectClient()\n : this.disconnectCluster();\n }\n isElectrumClient() {\n return this.electrum.hasOwnProperty(\"connection\");\n }\n async readyClient(timeout) {\n timeout = typeof timeout !== \"undefined\" ? timeout : 3000;\n let connectPromise = async () => {\n while (this.electrum.connection.status !==\n electrum_cash__WEBPACK_IMPORTED_MODULE_0__.ConnectionStatus.CONNECTED) {\n await (0,_util_delay_js__WEBPACK_IMPORTED_MODULE_4__.delay)(100);\n }\n return true;\n };\n return connectPromise;\n }\n async readyCluster(timeout) {\n timeout;\n return this.electrum.ready();\n }\n async connectCluster() {\n return this.electrum.startup();\n }\n async connectClient() {\n let connectionPromise = async () => {\n try {\n return await this.electrum.connect();\n }\n catch (e) {\n console.warn(`Warning: Failed to connect to client on ${this.network} at ${this.electrum.connection.host}.`, e);\n return;\n }\n };\n return [await connectionPromise()];\n }\n async disconnectCluster() {\n return this.electrum.shutdown();\n }\n async disconnectClient() {\n return [await this.electrum.disconnect(true)];\n }\n}\nElectrumNetworkProvider.rawTransactionCache = {};\n\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://mainnet-js/./src/network/ElectrumNetworkProvider.ts?");
|
|
1108
1108
|
|
|
1109
1109
|
/***/ }),
|
|
1110
1110
|
|
|
@@ -1124,7 +1124,7 @@ eval("__webpack_require__.a(module, async (__webpack_handle_async_dependencies__
|
|
|
1124
1124
|
\*********************************/
|
|
1125
1125
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1126
1126
|
|
|
1127
|
-
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ELECTRUM_CASH_PROTOCOL_VERSION\": () => (/* binding */ ELECTRUM_CASH_PROTOCOL_VERSION),\n/* harmony export */ \"clusterParams\": () => (/* binding */ clusterParams),\n/* harmony export */ \"mainnetServers\": () => (/* binding */ mainnetServers),\n/* harmony export */ \"networkTickerMap\": () => (/* binding */ networkTickerMap),\n/* harmony export */ \"regtestServers\": () => (/* binding */ regtestServers),\n/* harmony export */ \"testnetServers\": () => (/* binding */ testnetServers)\n/* harmony export */ });\n/* unused harmony export defaultServers */\n/* harmony import */ var electrum_cash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! electrum-cash */ \"../../node_modules/electrum-cash/dist/index.mjs.js\");\n\nconst ELECTRUM_CASH_PROTOCOL_VERSION = \"1.4.1\";\nconst networkTickerMap = {\n mainnet: \"BCH\",\n testnet: \"tBCH\",\n regtest: \"rBCH\",\n};\nconst mainnetServers = [\n \"wss://bch.imaginary.cash:50004\",\n //\"wss://blackie.c3-soft.com:50004\",\n \"wss://electrum.imaginary.cash:50004\",\n // \"wss://fulcrum.fountainhead.cash\",\n];\
|
|
1127
|
+
eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ELECTRUM_CASH_PROTOCOL_VERSION\": () => (/* binding */ ELECTRUM_CASH_PROTOCOL_VERSION),\n/* harmony export */ \"ELECTRUM_CASH_PROTOCOL_VERSION_MAINNET\": () => (/* binding */ ELECTRUM_CASH_PROTOCOL_VERSION_MAINNET),\n/* harmony export */ \"clusterParams\": () => (/* binding */ clusterParams),\n/* harmony export */ \"mainnetServers\": () => (/* binding */ mainnetServers),\n/* harmony export */ \"networkTickerMap\": () => (/* binding */ networkTickerMap),\n/* harmony export */ \"regtestServers\": () => (/* binding */ regtestServers),\n/* harmony export */ \"testnetServers\": () => (/* binding */ testnetServers)\n/* harmony export */ });\n/* unused harmony export defaultServers */\n/* harmony import */ var electrum_cash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! electrum-cash */ \"../../node_modules/electrum-cash/dist/index.mjs.js\");\n\n// Two different protocol versions are communicated, must converge to the same one after May23 upgrade\nconst ELECTRUM_CASH_PROTOCOL_VERSION = \"1.5\";\nconst ELECTRUM_CASH_PROTOCOL_VERSION_MAINNET = \"1.4.1\";\nconst networkTickerMap = {\n mainnet: \"BCH\",\n testnet: \"tBCH\",\n regtest: \"rBCH\",\n};\nconst mainnetServers = [\n \"wss://bch.imaginary.cash:50004\",\n //\"wss://blackie.c3-soft.com:50004\",\n \"wss://electrum.imaginary.cash:50004\",\n // \"wss://fulcrum.fountainhead.cash\",\n];\n// export const testnetServers = [\n// // \"wss://tbch.loping.net:60004\",\n// \"wss://blackie.c3-soft.com:60004\",\n// // \"wss://testnet.bitcoincash.network:60004\",\n// //,\"wss://unavailable.invalid:50004\"\n// ];\n// testnet4\n// export const testnetServers = [\n// //\"wss://t4fork.c3-soft.com:61004\",\n// \"wss://testnet4.imaginary.cash:50004\",\n// //,\"wss://unavailable.invalid:50004\"\n// ];\n// chipnet\nconst testnetServers = [\n // \"wss://chipnet.imaginary.cash:50004\",\n \"wss://blackie.c3-soft.com:64004\", // chipnet with protocol 1.5.0\n];\nconst regtestServers = [\"ws://127.0.0.1:60003\"];\nconst defaultServers = {\n mainnet: mainnetServers,\n testnet: testnetServers,\n regtest: regtestServers,\n};\nconst clusterParams = {\n mainnet: {\n confidence: 1,\n distribution: 1,\n order: electrum_cash__WEBPACK_IMPORTED_MODULE_0__.ClusterOrder.RANDOM,\n timeout: 45000,\n },\n testnet: {\n confidence: 1,\n distribution: 1,\n order: electrum_cash__WEBPACK_IMPORTED_MODULE_0__.ClusterOrder.RANDOM,\n timeout: 30000,\n },\n regtest: {\n confidence: 1,\n distribution: 1,\n order: electrum_cash__WEBPACK_IMPORTED_MODULE_0__.ClusterOrder.PRIORITY,\n timeout: 3000,\n },\n};\n\n\n//# sourceURL=webpack://mainnet-js/./src/network/constant.ts?");
|
|
1128
1128
|
|
|
1129
1129
|
/***/ }),
|
|
1130
1130
|
|
|
@@ -1134,7 +1134,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
1134
1134
|
\********************************/
|
|
1135
1135
|
/***/ ((module, __webpack_exports__, __webpack_require__) => {
|
|
1136
1136
|
|
|
1137
|
-
eval("__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"getGlobalProvider\": () => (/* binding */ getGlobalProvider),\n/* harmony export */ \"getNetworkProvider\": () => (/* binding */ getNetworkProvider),\n/* harmony export */ \"removeGlobalProvider\": () => (/* binding */ removeGlobalProvider),\n/* harmony export */ \"setGlobalProvider\": () => (/* binding */ setGlobalProvider)\n/* harmony export */ });\n/* harmony import */ var _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ElectrumNetworkProvider.js */ \"./src/network/ElectrumNetworkProvider.ts\");\n/* harmony import */ var electrum_cash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! electrum-cash */ \"../../node_modules/electrum-cash/dist/index.mjs.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./configuration.js */ \"./src/network/configuration.ts\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./util.js */ \"./src/network/util.ts\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../interface.js */ \"./src/interface.ts\");\n/* harmony import */ var _constant_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constant.js */ \"./src/network/constant.ts\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_configuration_js__WEBPACK_IMPORTED_MODULE_3__, _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_4__]);\n([_configuration_js__WEBPACK_IMPORTED_MODULE_3__, _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_4__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);\n\n\n\n\n\n\
|
|
1137
|
+
eval("__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"getGlobalProvider\": () => (/* binding */ getGlobalProvider),\n/* harmony export */ \"getNetworkProvider\": () => (/* binding */ getNetworkProvider),\n/* harmony export */ \"removeGlobalProvider\": () => (/* binding */ removeGlobalProvider),\n/* harmony export */ \"setGlobalProvider\": () => (/* binding */ setGlobalProvider)\n/* harmony export */ });\n/* harmony import */ var _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ElectrumNetworkProvider.js */ \"./src/network/ElectrumNetworkProvider.ts\");\n/* harmony import */ var electrum_cash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! electrum-cash */ \"../../node_modules/electrum-cash/dist/index.mjs.js\");\n/* harmony import */ var _configuration_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./configuration.js */ \"./src/network/configuration.ts\");\n/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./util.js */ \"./src/network/util.ts\");\n/* harmony import */ var _interface_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../interface.js */ \"./src/interface.ts\");\n/* harmony import */ var _constant_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constant.js */ \"./src/network/constant.ts\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_configuration_js__WEBPACK_IMPORTED_MODULE_3__, _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_4__]);\n([_configuration_js__WEBPACK_IMPORTED_MODULE_3__, _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_4__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);\n\n\n\n\n\n\nfunction setGlobalProvider(network, provider) {\n const accessor = _constant_js__WEBPACK_IMPORTED_MODULE_1__.networkTickerMap[network];\n globalThis[accessor] = provider;\n return provider;\n}\nfunction getGlobalProvider(network) {\n const accessor = _constant_js__WEBPACK_IMPORTED_MODULE_1__.networkTickerMap[network];\n return globalThis[accessor];\n}\nfunction removeGlobalProvider(network) {\n const accessor = _constant_js__WEBPACK_IMPORTED_MODULE_1__.networkTickerMap[network];\n if (accessor in globalThis) {\n delete globalThis[accessor];\n }\n}\nfunction getNetworkProvider(network = _interface_js__WEBPACK_IMPORTED_MODULE_2__.Network.MAINNET, servers, manualConnectionManagement, options) {\n const globalContext = servers === undefined &&\n manualConnectionManagement === undefined &&\n options === undefined;\n if (globalContext) {\n const globalProvider = getGlobalProvider(network);\n if (globalProvider) {\n return globalProvider;\n }\n }\n let useCluster;\n manualConnectionManagement = manualConnectionManagement\n ? manualConnectionManagement\n : false;\n servers = servers ? servers : (0,_configuration_js__WEBPACK_IMPORTED_MODULE_3__.getDefaultServers)(network);\n // If the user has passed a single string, assume a single client connection\n if (typeof servers === \"string\") {\n servers = [servers];\n useCluster = false;\n }\n // Otherwise, assume a list of servers has been passed\n else {\n servers = servers;\n useCluster = servers.length > 1;\n }\n // There were server(s)\n if (servers) {\n let clusterOrClient;\n // There were multiple servers\n if (useCluster) {\n let clusterParam = _constant_js__WEBPACK_IMPORTED_MODULE_1__.clusterParams[network];\n clusterParam[\"confidence\"] = (0,_configuration_js__WEBPACK_IMPORTED_MODULE_3__.getConfidence)();\n clusterParam = Object.assign({}, clusterParam, options);\n clusterOrClient = getCluster(servers, clusterParam, network);\n }\n // The server is a single string in an array\n else {\n clusterOrClient = getClient(servers, network);\n }\n let provider = new _ElectrumNetworkProvider_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"](clusterOrClient, network, manualConnectionManagement);\n if (globalContext) {\n return setGlobalProvider(network, provider);\n }\n return provider;\n }\n else {\n throw Error(\"No servers provided, defaults not available.\");\n }\n}\n// Create a cluster give a list of servers and parameters\nfunction getCluster(servers, params, network) {\n let electrum = getElectrumCluster(params, network);\n for (const s of servers) {\n let url = (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.parseElectrumUrl)(s);\n try {\n electrum.addServer(url.host, url.port, url.scheme, false);\n }\n catch (error) {\n console.log(`Error connecting ${url.host}:${url.port} over ${url.scheme}`);\n }\n }\n return electrum;\n}\n// create a client with a list of servers\nfunction getClient(servers, network) {\n let url = (0,_util_js__WEBPACK_IMPORTED_MODULE_5__.parseElectrumUrl)(servers[0]);\n return getElectrumClient(url, 120000, network);\n}\nfunction getElectrumCluster(params, network) {\n return new electrum_cash__WEBPACK_IMPORTED_MODULE_0__.ElectrumCluster((0,_configuration_js__WEBPACK_IMPORTED_MODULE_3__.getUserAgent)(), network === _interface_js__WEBPACK_IMPORTED_MODULE_2__.Network.MAINNET\n ? _constant_js__WEBPACK_IMPORTED_MODULE_1__.ELECTRUM_CASH_PROTOCOL_VERSION_MAINNET\n : _constant_js__WEBPACK_IMPORTED_MODULE_1__.ELECTRUM_CASH_PROTOCOL_VERSION, params.confidence, params.distribution, params.order, params.timeout);\n}\nfunction getElectrumClient(params, timeout, network) {\n return new electrum_cash__WEBPACK_IMPORTED_MODULE_0__.ElectrumClient((0,_configuration_js__WEBPACK_IMPORTED_MODULE_3__.getUserAgent)(), network === _interface_js__WEBPACK_IMPORTED_MODULE_2__.Network.MAINNET\n ? _constant_js__WEBPACK_IMPORTED_MODULE_1__.ELECTRUM_CASH_PROTOCOL_VERSION_MAINNET\n : _constant_js__WEBPACK_IMPORTED_MODULE_1__.ELECTRUM_CASH_PROTOCOL_VERSION, params.host, params.port, params.scheme, timeout);\n}\n\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://mainnet-js/./src/network/default.ts?");
|
|
1138
1138
|
|
|
1139
1139
|
/***/ }),
|
|
1140
1140
|
|
|
@@ -2334,7 +2334,7 @@ eval("/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harm
|
|
|
2334
2334
|
\*********************************************************************************/
|
|
2335
2335
|
/***/ ((__webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
2336
2336
|
|
|
2337
|
-
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"cloneTransactionCommon\": () => (/* binding */ cloneTransactionCommon),\n/* harmony export */ \"cloneTransactionOutputsCommon\": () => (/* binding */ cloneTransactionOutputsCommon),\n/* harmony export */ \"decodeTransaction\": () => (/* binding */ decodeTransaction),\n/* harmony export */ \"decodeTransactionBCH\": () => (/* binding */ decodeTransactionBCH),\n/* harmony export */ \"encodeTokenPrefix\": () => (/* binding */ encodeTokenPrefix),\n/* harmony export */ \"encodeTransaction\": () => (/* binding */ encodeTransaction),\n/* harmony export */ \"encodeTransactionBCH\": () => (/* binding */ encodeTransactionBCH),\n/* harmony export */ \"encodeTransactionInputSequenceNumbersForSigning\": () => (/* binding */ encodeTransactionInputSequenceNumbersForSigning),\n/* harmony export */ \"encodeTransactionOutpoints\": () => (/* binding */ encodeTransactionOutpoints),\n/* harmony export */ \"encodeTransactionOutput\": () => (/* binding */ encodeTransactionOutput),\n/* harmony export */ \"encodeTransactionOutputsForSigning\": () => (/* binding */ encodeTransactionOutputsForSigning)\n/* harmony export */ });\n/* unused harmony exports encodeTransactionInput, TransactionDecodingError, readTransactionInput, encodeTransactionInputs, readTransactionInputs, nftCapabilityNumberToLabel, nftCapabilityLabelToNumber, CashTokenDecodingError, readTokenAmount, readTokenPrefix, readLockingBytecodeWithPrefix, readTransactionOutput, readTransactionOutputs, encodeTransactionOutputs, readTransactionCommon, readTransaction, readTransactionOutputNonTokenAware, readTransactionOutputsNonTokenAware, readTransactionNonTokenAware, decodeTransactionCommon, decodeTransactionUnsafeCommon, decodeTransactionUnsafeBCH, decodeTransactionUnsafe, encodeTransactionCommon, cloneTransactionInputsCommon, hashTransactionP2pOrder, hashTransactionUiOrder, hashTransaction */\n/* harmony import */ var _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../crypto/crypto.js */ \"./node_modules/@bitauth/libauth/build/lib/crypto/default-crypto-instances.js\");\n/* harmony import */ var _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../crypto/crypto.js */ \"./node_modules/@bitauth/libauth/build/lib/crypto/combinations.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../format/format.js */ \"./node_modules/@bitauth/libauth/build/lib/format/hex.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../format/format.js */ \"./node_modules/@bitauth/libauth/build/lib/format/number.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../format/format.js */ \"./node_modules/@bitauth/libauth/build/lib/format/read.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../format/format.js */ \"./node_modules/@bitauth/libauth/build/lib/format/error.js\");\n/* harmony import */ var _read_components_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./read-components.js */ \"./node_modules/@bitauth/libauth/build/lib/message/read-components.js\");\n/* harmony import */ var _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./transaction-types.js */ \"./node_modules/@bitauth/libauth/build/lib/message/transaction-types.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__, _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__]);\n([_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__, _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);\n\n\n\n\n/**\n * Encode a single input for inclusion in an encoded transaction.\n *\n * @param input - the input to encode\n */\nconst encodeTransactionInput = (input) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n input.outpointTransactionHash.slice().reverse(),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(input.outpointIndex),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(BigInt(input.unlockingBytecode.length)),\n input.unlockingBytecode,\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(input.sequenceNumber),\n]);\nvar TransactionDecodingError;\n(function (TransactionDecodingError) {\n TransactionDecodingError[\"transaction\"] = \"Error reading transaction.\";\n TransactionDecodingError[\"endsWithUnexpectedBytes\"] = \"Error decoding transaction: the provided input includes unexpected bytes after the encoded transaction.\";\n TransactionDecodingError[\"input\"] = \"Error reading transaction input.\";\n TransactionDecodingError[\"inputs\"] = \"Error reading transaction inputs.\";\n TransactionDecodingError[\"output\"] = \"Error reading transaction output.\";\n TransactionDecodingError[\"outputs\"] = \"Error reading transaction outputs.\";\n TransactionDecodingError[\"lockingBytecodeLength\"] = \"Error reading locking bytecode length.\";\n})(TransactionDecodingError || (TransactionDecodingError = {}));\n/**\n * Read a transaction {@link Input} from the provided {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Input} and the next {@link ReadPosition}.\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction output\n */\nconst readTransactionInput = (position) => {\n const inputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readBytes)(32 /* TransactionConstants.outpointTransactionHashLength */),\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactSizePrefixedBin,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof inputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.input, inputRead);\n }\n const { position: nextPosition, result: [outpointTransactionHash, outpointIndex, unlockingBytecode, sequenceNumber,], } = inputRead;\n return {\n position: nextPosition,\n result: {\n outpointIndex,\n outpointTransactionHash: outpointTransactionHash.reverse(),\n sequenceNumber,\n unlockingBytecode,\n },\n };\n};\n/**\n * Encode a set of {@link Input}s for inclusion in an encoded transaction\n * including the prefixed number of inputs.\n *\n * Format: [CompactSize: input count] [encoded inputs]\n *\n * @param inputs - the set of inputs to encode\n */\nconst encodeTransactionInputs = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(BigInt(inputs.length)),\n ...inputs.map(encodeTransactionInput),\n]);\n/**\n * Read a set of transaction {@link Input}s beginning at {@link ReadPosition}.\n * A CompactSize will be read to determine the number of inputs, and that\n * number of transaction inputs will be read and returned. Returns either an\n * error message (as a string) or an object containing the array of inputs and\n * the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction inputs\n */\nconst readTransactionInputs = (position) => {\n const inputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(position, readTransactionInput);\n if (typeof inputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.inputs, inputsRead);\n }\n return inputsRead;\n};\nconst maximumTokenAmount = 9223372036854775807n;\nconst nftCapabilityNumberToLabel = [\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none,\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.mutable,\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.minting,\n];\nconst nftCapabilityLabelToNumber = {\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none]: 0,\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.mutable]: 1,\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.minting]: 2,\n};\nvar CashTokenDecodingError;\n(function (CashTokenDecodingError) {\n CashTokenDecodingError[\"invalidPrefix\"] = \"Error reading token prefix.\";\n CashTokenDecodingError[\"insufficientLength\"] = \"Invalid token prefix: insufficient length.\";\n CashTokenDecodingError[\"reservedBit\"] = \"Invalid token prefix: reserved bit is set.\";\n CashTokenDecodingError[\"invalidCapability\"] = \"Invalid token prefix: capability must be none (0), mutable (1), or minting (2).\";\n CashTokenDecodingError[\"commitmentWithoutNft\"] = \"Invalid token prefix: commitment requires an NFT.\";\n CashTokenDecodingError[\"capabilityWithoutNft\"] = \"Invalid token prefix: capability requires an NFT.\";\n CashTokenDecodingError[\"commitmentLengthZero\"] = \"Invalid token prefix: if encoded, commitment length must be greater than 0.\";\n CashTokenDecodingError[\"invalidCommitment\"] = \"Invalid token prefix: invalid non-fungible token commitment.\";\n CashTokenDecodingError[\"invalidAmountEncoding\"] = \"Invalid token prefix: invalid fungible token amount encoding.\";\n CashTokenDecodingError[\"zeroAmount\"] = \"Invalid token prefix: if encoded, fungible token amount must be greater than 0.\";\n CashTokenDecodingError[\"excessiveAmount\"] = \"Invalid token prefix: exceeds maximum fungible token amount of 9223372036854775807.\";\n CashTokenDecodingError[\"noTokens\"] = \"Invalid token prefix: must encode at least one token.\";\n})(CashTokenDecodingError || (CashTokenDecodingError = {}));\n/**\n * Read a token amount from the provided {@link ReadPosition}, returning either\n * an error message (as a string) or an object containing the value and the next\n * {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * token amount.\n */\nconst readTokenAmount = (position) => {\n const amountRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.readCompactSizeMinimal)(position);\n if (typeof amountRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidAmountEncoding, amountRead);\n }\n if (amountRead.result > maximumTokenAmount) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.excessiveAmount, `Encoded amount: ${amountRead.result}`);\n }\n if (amountRead.result === 0n) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.zeroAmount);\n }\n return amountRead;\n};\n/**\n * Attempt to read a transaction {@link Output}'s token prefix from the provided\n * {@link ReadPosition}, returning either an error message (as a string) or an\n * object containing the (optional) token information and the\n * next {@link ReadPosition}.\n *\n * Rather than using this function directly, most applications\n * should use {@link readLockingBytecodeWithPrefix}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * token prefix\n */\n// eslint-disable-next-line complexity\nconst readTokenPrefix = (position) => {\n const { bin, index } = position;\n if (bin[index] !== 239 /* CashTokens.PREFIX_TOKEN */) {\n return { position, result: {} };\n }\n if (bin.length < index + 34 /* CashTokens.minimumPrefixLength */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.insufficientLength, `The minimum possible length is ${34 /* CashTokens.minimumPrefixLength */}. Missing bytes: ${34 /* CashTokens.minimumPrefixLength */ - (bin.length - index)}`);\n }\n const category = bin\n .slice(index + 1, index + 33 /* CashTokens.tokenBitfieldIndex */)\n .reverse();\n const tokenBitfield = bin[index + 33 /* CashTokens.tokenBitfieldIndex */]; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n /* eslint-disable no-bitwise */\n const prefixStructure = tokenBitfield & 240 /* CashTokens.tokenFormatMask */;\n if ((prefixStructure & 128 /* CashTokens.RESERVED_BIT */) !== 0) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.reservedBit, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const nftCapabilityInt = tokenBitfield & 15 /* CashTokens.nftCapabilityMask */;\n if (nftCapabilityInt > 2 /* CashTokens.maximumCapability */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidCapability, `Capability value: ${nftCapabilityInt}`);\n }\n const capability = nftCapabilityNumberToLabel[nftCapabilityInt]; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n const hasNft = (prefixStructure & 32 /* CashTokens.HAS_NFT */) !== 0;\n const hasCommitmentLength = (prefixStructure & 64 /* CashTokens.HAS_COMMITMENT_LENGTH */) !== 0;\n if (hasCommitmentLength && !hasNft) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.commitmentWithoutNft, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const hasAmount = (prefixStructure & 16 /* CashTokens.HAS_AMOUNT */) !== 0;\n /* eslint-enable no-bitwise */\n const nextPosition = {\n bin,\n index: index + 33 /* CashTokens.tokenBitfieldIndex */ + 1,\n };\n if (hasNft) {\n const commitmentRead = hasCommitmentLength\n ? (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactSizePrefixedBin)(nextPosition)\n : { position: nextPosition, result: Uint8Array.of() };\n if (typeof commitmentRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidCommitment, commitmentRead);\n }\n if (hasCommitmentLength && commitmentRead.result.length === 0) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.commitmentLengthZero);\n }\n const amountRead = hasAmount\n ? readTokenAmount(commitmentRead.position)\n : { position: commitmentRead.position, result: 0n };\n if (typeof amountRead === 'string') {\n return amountRead;\n }\n return {\n position: amountRead.position,\n result: {\n token: {\n amount: amountRead.result,\n category,\n nft: { capability, commitment: commitmentRead.result },\n },\n },\n };\n }\n if (capability !== _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.capabilityWithoutNft, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n if (!hasAmount) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.noTokens, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const amountRead = readTokenAmount(nextPosition);\n if (typeof amountRead === 'string') {\n return amountRead;\n }\n return {\n position: amountRead.position,\n result: { token: { amount: amountRead.result, category } },\n };\n};\n/**\n * Read the locking bytecode and token prefix (if present) of a transaction\n * {@link Output}, beginning at the `CompactSize` indicating the\n * combined length.\n * @param position - the {@link ReadPosition} at which to start reading the\n * optional token prefix and locking bytecode\n */\nconst readLockingBytecodeWithPrefix = (position) => {\n const bytecodeRead = (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactSizePrefixedBin)(position);\n if (typeof bytecodeRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.lockingBytecodeLength, bytecodeRead);\n }\n const { result: contents, position: nextPosition } = bytecodeRead;\n const contentsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)({ bin: contents, index: 0 }, [\n readTokenPrefix,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readRemainingBytes,\n ]);\n if (typeof contentsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidPrefix, contentsRead);\n }\n const { result: [{ token }, lockingBytecode], } = contentsRead;\n return {\n position: nextPosition,\n result: { lockingBytecode, ...(token === undefined ? {} : { token }) },\n };\n};\n/**\n * Read a transaction {@link Output} from the provided {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Output} and the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction output\n */\nconst readTransactionOutput = (position) => {\n const outputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint64LE,\n readLockingBytecodeWithPrefix,\n ]);\n if (typeof outputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.output, outputRead);\n }\n const { position: nextPosition, result: [valueSatoshis, { lockingBytecode, token }], } = outputRead;\n return {\n position: nextPosition,\n result: {\n lockingBytecode,\n ...(token === undefined ? {} : { token }),\n valueSatoshis,\n },\n };\n};\n/**\n * Given {@link Output.token} data, encode a token prefix.\n *\n * This function does not fail, but returns an empty Uint8Array if the token\n * data does not encode any tokens (even if `token.category` is set).\n *\n * @param token - the token data to encode\n */\n// eslint-disable-next-line complexity\nconst encodeTokenPrefix = (token) => {\n if (token === undefined || (token.nft === undefined && token.amount < 1n)) {\n return Uint8Array.of();\n }\n const hasNft = token.nft === undefined ? 0 : 32 /* CashTokens.HAS_NFT */;\n const capabilityInt = token.nft === undefined\n ? 0\n : nftCapabilityLabelToNumber[token.nft.capability];\n const hasCommitmentLength = token.nft !== undefined && token.nft.commitment.length > 0\n ? 64 /* CashTokens.HAS_COMMITMENT_LENGTH */\n : 0;\n const hasAmount = token.amount > 0n ? 16 /* CashTokens.HAS_AMOUNT */ : 0;\n const tokenBitfield = \n // eslint-disable-next-line no-bitwise\n hasNft | hasCommitmentLength | hasAmount | capabilityInt;\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n Uint8Array.of(239 /* CashTokens.PREFIX_TOKEN */),\n token.category.slice().reverse(),\n Uint8Array.of(tokenBitfield),\n ...(hasCommitmentLength === 0\n ? []\n : [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(BigInt(token.nft.commitment.length)),\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n token.nft.commitment,\n ]),\n ...(hasAmount === 0 ? [] : [(0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(token.amount)]),\n ]);\n};\n/**\n * Encode a single {@link Output} for inclusion in an encoded transaction.\n *\n * @param output - the output to encode\n */\nconst encodeTransactionOutput = (output) => {\n const lockingBytecodeField = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n encodeTokenPrefix(output.token),\n output.lockingBytecode,\n ]);\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.valueSatoshisToBin)(output.valueSatoshis),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(BigInt(lockingBytecodeField.length)),\n lockingBytecodeField,\n ]);\n};\n/**\n * Read a set of transaction {@link Output}s beginning at {@link ReadPosition}.\n * A CompactSize will be read to determine the number of outputs, and that\n * number of transaction outputs will be read and returned. Returns either an\n * error message (as a string) or an object containing the array of outputs and\n * the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction outputs\n */\nconst readTransactionOutputs = (position) => {\n const outputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(position, readTransactionOutput);\n if (typeof outputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.outputs, outputsRead);\n }\n return outputsRead;\n};\n/**\n * Encode a set of {@link Output}s for inclusion in an encoded transaction\n * including the prefixed number of outputs. Note, this encoding differs from\n * {@link encodeTransactionOutputsForSigning} (used for signing serializations).\n *\n * Format: [CompactSize: output count] [encoded outputs]\n *\n * @param outputs - the set of outputs to encode\n */\nconst encodeTransactionOutputs = (outputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(BigInt(outputs.length)),\n ...outputs.map(encodeTransactionOutput),\n]);\n/**\n * Read a version 1 or 2 transaction beginning at {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Transaction} and the next {@link ReadPosition}. Rather than using this\n * function directly, most applications should\n * use {@link decodeTransactionCommon}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * {@link TransactionCommon}\n */\nconst readTransactionCommon = (position) => {\n const transactionRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n readTransactionInputs,\n readTransactionOutputs,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof transactionRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.transaction, transactionRead);\n }\n const { position: nextPosition, result: [version, inputs, outputs, locktime], } = transactionRead;\n return {\n position: nextPosition,\n result: { inputs, locktime, outputs, version },\n };\n};\nconst readTransaction = readTransactionCommon;\nconst readTransactionOutputNonTokenAware = (pos) => {\n const outputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(pos, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint64LE,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactSizePrefixedBin,\n ]);\n if (typeof outputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.output, outputRead);\n }\n const { position: nextPosition, result: [valueSatoshis, lockingBytecode], } = outputRead;\n return {\n position: nextPosition,\n result: { lockingBytecode, valueSatoshis },\n };\n};\nconst readTransactionOutputsNonTokenAware = (pos) => {\n const outputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(pos, readTransactionOutputNonTokenAware);\n if (typeof outputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.outputs, outputsRead);\n }\n return outputsRead;\n};\n/**\n * Read a version 1 or 2 transaction beginning at a {@link ReadPosition} as if\n * CHIP-2022-02-CashTokens were not deployed, returning either an error message\n * (as a string) or an object containing the {@link Transaction} and the next\n * {@link ReadPosition}.\n *\n * This function emulates legacy transaction parsing to test behavior prior to\n * deployment of CHIP-2022-02-CashTokens; most applications should instead\n * use {@link readTransactionCommon}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * {@link TransactionCommon}\n */\nconst readTransactionNonTokenAware = (position) => {\n const transactionRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n readTransactionInputs,\n readTransactionOutputsNonTokenAware,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof transactionRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.transaction, transactionRead);\n }\n const { position: nextPosition, result: [version, inputs, outputs, locktime], } = transactionRead;\n return {\n position: nextPosition,\n result: { inputs, locktime, outputs, version },\n };\n};\n/**\n * Decode a {@link TransactionCommon} according to the version 1/2 P2P network\n * transaction format.\n *\n * This function verifies that the provided `bin` contains only one transaction\n * and no additional data. To read a transaction from a specific location within\n * a `Uint8Array`, use {@link readTransactionCommon}.\n *\n * @param bin - the encoded transaction to decode\n */\nconst decodeTransactionCommon = (bin) => {\n const transactionRead = readTransactionCommon({ bin, index: 0 });\n if (typeof transactionRead === 'string') {\n return transactionRead;\n }\n if (transactionRead.position.index !== bin.length) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.endsWithUnexpectedBytes, `Encoded transaction ends at index ${transactionRead.position.index - 1}, leaving ${bin.length - transactionRead.position.index} remaining bytes.`);\n }\n return transactionRead.result;\n};\nconst decodeTransactionBCH = decodeTransactionCommon;\nconst decodeTransaction = decodeTransactionBCH;\n/**\n * Decode a {@link TransactionCommon} from a trusted source according to the\n * version 1/2 P2P network transaction format.\n *\n * Note: this method throws runtime errors when attempting to decode messages\n * which do not properly follow the transaction format. If the input is\n * untrusted, use {@link decodeTransactionCommon}.\n *\n * @param bin - the raw message to decode\n */\nconst decodeTransactionUnsafeCommon = (bin) => {\n const result = decodeTransactionCommon(bin);\n if (typeof result === 'string') {\n // eslint-disable-next-line functional/no-throw-statement\n throw new Error(result);\n }\n return result;\n};\nconst decodeTransactionUnsafeBCH = decodeTransactionUnsafeCommon;\nconst decodeTransactionUnsafe = decodeTransactionUnsafeBCH;\n/**\n * Encode a {@link Transaction} using the standard P2P network format. This\n * serialization is also used when computing the transaction's hash (A.K.A.\n * \"transaction ID\" or \"TXID\").\n */\nconst encodeTransactionCommon = (tx) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(tx.version),\n encodeTransactionInputs(tx.inputs),\n encodeTransactionOutputs(tx.outputs),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(tx.locktime),\n]);\nconst encodeTransactionBCH = encodeTransactionCommon;\nconst encodeTransaction = encodeTransactionBCH;\nconst cloneTransactionInputsCommon = (inputs) => inputs.map((input) => ({\n outpointIndex: input.outpointIndex,\n outpointTransactionHash: input.outpointTransactionHash.slice(),\n sequenceNumber: input.sequenceNumber,\n unlockingBytecode: input.unlockingBytecode.slice(),\n}));\nconst cloneTransactionOutputsCommon = (outputs) => outputs.map((output) => ({\n lockingBytecode: output.lockingBytecode.slice(),\n ...(output.token === undefined\n ? {}\n : {\n token: {\n amount: output.token.amount,\n category: output.token.category.slice(),\n ...(output.token.nft === undefined\n ? {}\n : {\n nft: {\n capability: output.token.nft.capability,\n commitment: output.token.nft.commitment.slice(),\n },\n }),\n },\n }),\n valueSatoshis: output.valueSatoshis,\n}));\nconst cloneTransactionCommon = (transaction) => ({\n inputs: cloneTransactionInputsCommon(transaction.inputs),\n locktime: transaction.locktime,\n outputs: cloneTransactionOutputsCommon(transaction.outputs),\n version: transaction.version,\n});\n/**\n * Compute a transaction hash (A.K.A. \"transaction ID\" or \"TXID\") from an\n * encoded transaction in P2P network message order. This is the byte order\n * produced by most sha256 libraries and used by encoded P2P network messages.\n * It is also the byte order produced by `OP_SHA256` and `OP_HASH256` in the\n * virtual machine.\n *\n * @returns the transaction hash in P2P network message byte order\n *\n * @param transaction - the encoded transaction\n * @param sha256 - an implementation of sha256\n */\nconst hashTransactionP2pOrder = (transaction, sha256 = _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__.sha256) => (0,_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__.hash256)(transaction, sha256);\n/**\n * Compute a transaction hash (A.K.A. \"transaction ID\" or \"TXID\") from an\n * encoded transaction in user interface byte order. This is the byte order\n * typically used by block explorers, wallets, and other user interfaces.\n *\n * To return this result as a `string`, use {@link hashTransaction}.\n *\n * @returns the transaction hash in User Interface byte order\n *\n * @param transaction - the encoded transaction\n * @param sha256 - an implementation of sha256\n */\nconst hashTransactionUiOrder = (transaction, sha256 = _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__.sha256) => hashTransactionP2pOrder(transaction, sha256).reverse();\n/**\n * Return an encoded {@link Transaction}'s hash/ID as a string in user interface\n * byte order (typically used by wallets and block explorers).\n *\n * To return this result as a `Uint8Array`, use {@link hashTransactionUiOrder}.\n *\n * @param transaction - the encoded transaction\n */\nconst hashTransaction = (transaction) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.binToHex)(hashTransactionUiOrder(transaction));\n/**\n * Encode all outpoints in a series of transaction inputs. (For use in\n * {@link hashTransactionOutpoints}.)\n *\n * @param inputs - the series of inputs from which to extract the outpoints\n */\nconst encodeTransactionOutpoints = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(inputs.map((i) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n i.outpointTransactionHash.slice().reverse(),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(i.outpointIndex),\n])));\n/**\n * Encode an array of transaction {@link Output}s for use in transaction signing\n * serializations. Note, this encoding differs from\n * {@link encodeTransactionOutputs} (used for encoding full transactions).\n *\n * @param outputs - the array of outputs to encode\n */\nconst encodeTransactionOutputsForSigning = (outputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(outputs.map(encodeTransactionOutput));\n/**\n * Encode the sequence numbers of an array of transaction inputs for use in\n * transaction signing serializations.\n *\n * @param inputs - the array of inputs from which to extract the sequence\n * numbers\n */\nconst encodeTransactionInputSequenceNumbersForSigning = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(inputs.map((i) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(i.sequenceNumber)));\n//# sourceMappingURL=transaction-encoding.js.map\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://mainnet-js/./node_modules/@bitauth/libauth/build/lib/message/transaction-encoding.js?");
|
|
2337
|
+
eval("__webpack_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"cloneTransactionCommon\": () => (/* binding */ cloneTransactionCommon),\n/* harmony export */ \"cloneTransactionOutputsCommon\": () => (/* binding */ cloneTransactionOutputsCommon),\n/* harmony export */ \"decodeTransaction\": () => (/* binding */ decodeTransaction),\n/* harmony export */ \"encodeTokenPrefix\": () => (/* binding */ encodeTokenPrefix),\n/* harmony export */ \"encodeTransaction\": () => (/* binding */ encodeTransaction),\n/* harmony export */ \"encodeTransactionBCH\": () => (/* binding */ encodeTransactionBCH),\n/* harmony export */ \"encodeTransactionInputSequenceNumbersForSigning\": () => (/* binding */ encodeTransactionInputSequenceNumbersForSigning),\n/* harmony export */ \"encodeTransactionOutpoints\": () => (/* binding */ encodeTransactionOutpoints),\n/* harmony export */ \"encodeTransactionOutput\": () => (/* binding */ encodeTransactionOutput),\n/* harmony export */ \"encodeTransactionOutputsForSigning\": () => (/* binding */ encodeTransactionOutputsForSigning)\n/* harmony export */ });\n/* unused harmony exports encodeTransactionInput, TransactionDecodingError, readTransactionInput, encodeTransactionInputs, readTransactionInputs, nftCapabilityNumberToLabel, nftCapabilityLabelToNumber, CashTokenDecodingError, readTokenAmount, readTokenPrefix, readLockingBytecodeWithPrefix, readTransactionOutput, readTransactionOutputs, encodeTransactionOutputs, readTransactionCommon, readTransaction, readTransactionOutputNonTokenAware, readTransactionOutputsNonTokenAware, readTransactionNonTokenAware, decodeTransactionCommon, decodeTransactionBCH, decodeTransactionUnsafeCommon, decodeTransactionUnsafeBCH, decodeTransactionUnsafe, encodeTransactionCommon, cloneTransactionInputsCommon, hashTransactionP2pOrder, hashTransactionUiOrder, hashTransaction */\n/* harmony import */ var _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../crypto/crypto.js */ \"./node_modules/@bitauth/libauth/build/lib/crypto/default-crypto-instances.js\");\n/* harmony import */ var _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../crypto/crypto.js */ \"./node_modules/@bitauth/libauth/build/lib/crypto/combinations.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../format/format.js */ \"./node_modules/@bitauth/libauth/build/lib/format/hex.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../format/format.js */ \"./node_modules/@bitauth/libauth/build/lib/format/number.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../format/format.js */ \"./node_modules/@bitauth/libauth/build/lib/format/read.js\");\n/* harmony import */ var _format_format_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../format/format.js */ \"./node_modules/@bitauth/libauth/build/lib/format/error.js\");\n/* harmony import */ var _read_components_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./read-components.js */ \"./node_modules/@bitauth/libauth/build/lib/message/read-components.js\");\n/* harmony import */ var _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./transaction-types.js */ \"./node_modules/@bitauth/libauth/build/lib/message/transaction-types.js\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__, _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__]);\n([_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__, _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);\n\n\n\n\n/**\n * Encode a single input for inclusion in an encoded transaction.\n *\n * @param input - the input to encode\n */\nconst encodeTransactionInput = (input) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n input.outpointTransactionHash.slice().reverse(),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(input.outpointIndex),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(BigInt(input.unlockingBytecode.length)),\n input.unlockingBytecode,\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(input.sequenceNumber),\n]);\nvar TransactionDecodingError;\n(function (TransactionDecodingError) {\n TransactionDecodingError[\"transaction\"] = \"Error reading transaction.\";\n TransactionDecodingError[\"endsWithUnexpectedBytes\"] = \"Error decoding transaction: the provided input includes unexpected bytes after the encoded transaction.\";\n TransactionDecodingError[\"input\"] = \"Error reading transaction input.\";\n TransactionDecodingError[\"inputs\"] = \"Error reading transaction inputs.\";\n TransactionDecodingError[\"output\"] = \"Error reading transaction output.\";\n TransactionDecodingError[\"outputs\"] = \"Error reading transaction outputs.\";\n TransactionDecodingError[\"lockingBytecodeLength\"] = \"Error reading locking bytecode length.\";\n})(TransactionDecodingError || (TransactionDecodingError = {}));\n/**\n * Read a transaction {@link Input} from the provided {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Input} and the next {@link ReadPosition}.\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction output\n */\nconst readTransactionInput = (position) => {\n const inputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readBytes)(32 /* TransactionConstants.outpointTransactionHashLength */),\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactSizePrefixedBin,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof inputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.input, inputRead);\n }\n const { position: nextPosition, result: [outpointTransactionHash, outpointIndex, unlockingBytecode, sequenceNumber,], } = inputRead;\n return {\n position: nextPosition,\n result: {\n outpointIndex,\n outpointTransactionHash: outpointTransactionHash.reverse(),\n sequenceNumber,\n unlockingBytecode,\n },\n };\n};\n/**\n * Encode a set of {@link Input}s for inclusion in an encoded transaction\n * including the prefixed number of inputs.\n *\n * Format: [CompactSize: input count] [encoded inputs]\n *\n * @param inputs - the set of inputs to encode\n */\nconst encodeTransactionInputs = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(BigInt(inputs.length)),\n ...inputs.map(encodeTransactionInput),\n]);\n/**\n * Read a set of transaction {@link Input}s beginning at {@link ReadPosition}.\n * A CompactSize will be read to determine the number of inputs, and that\n * number of transaction inputs will be read and returned. Returns either an\n * error message (as a string) or an object containing the array of inputs and\n * the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction inputs\n */\nconst readTransactionInputs = (position) => {\n const inputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(position, readTransactionInput);\n if (typeof inputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.inputs, inputsRead);\n }\n return inputsRead;\n};\nconst maximumTokenAmount = 9223372036854775807n;\nconst nftCapabilityNumberToLabel = [\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none,\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.mutable,\n _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.minting,\n];\nconst nftCapabilityLabelToNumber = {\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none]: 0,\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.mutable]: 1,\n [_transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.minting]: 2,\n};\nvar CashTokenDecodingError;\n(function (CashTokenDecodingError) {\n CashTokenDecodingError[\"invalidPrefix\"] = \"Error reading token prefix.\";\n CashTokenDecodingError[\"insufficientLength\"] = \"Invalid token prefix: insufficient length.\";\n CashTokenDecodingError[\"reservedBit\"] = \"Invalid token prefix: reserved bit is set.\";\n CashTokenDecodingError[\"invalidCapability\"] = \"Invalid token prefix: capability must be none (0), mutable (1), or minting (2).\";\n CashTokenDecodingError[\"commitmentWithoutNft\"] = \"Invalid token prefix: commitment requires an NFT.\";\n CashTokenDecodingError[\"capabilityWithoutNft\"] = \"Invalid token prefix: capability requires an NFT.\";\n CashTokenDecodingError[\"commitmentLengthZero\"] = \"Invalid token prefix: if encoded, commitment length must be greater than 0.\";\n CashTokenDecodingError[\"invalidCommitment\"] = \"Invalid token prefix: invalid non-fungible token commitment.\";\n CashTokenDecodingError[\"invalidAmountEncoding\"] = \"Invalid token prefix: invalid fungible token amount encoding.\";\n CashTokenDecodingError[\"zeroAmount\"] = \"Invalid token prefix: if encoded, fungible token amount must be greater than 0.\";\n CashTokenDecodingError[\"excessiveAmount\"] = \"Invalid token prefix: exceeds maximum fungible token amount of 9223372036854775807.\";\n CashTokenDecodingError[\"noTokens\"] = \"Invalid token prefix: must encode at least one token.\";\n})(CashTokenDecodingError || (CashTokenDecodingError = {}));\n/**\n * Read a token amount from the provided {@link ReadPosition}, returning either\n * an error message (as a string) or an object containing the value and the next\n * {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * token amount.\n */\nconst readTokenAmount = (position) => {\n const amountRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.readCompactSizeMinimal)(position);\n if (typeof amountRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidAmountEncoding, amountRead);\n }\n if (amountRead.result > maximumTokenAmount) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.excessiveAmount, `Encoded amount: ${amountRead.result}`);\n }\n if (amountRead.result === 0n) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.zeroAmount);\n }\n return amountRead;\n};\n/**\n * Attempt to read a transaction {@link Output}'s token prefix from the provided\n * {@link ReadPosition}, returning either an error message (as a string) or an\n * object containing the (optional) token information and the\n * next {@link ReadPosition}.\n *\n * Rather than using this function directly, most applications\n * should use {@link readLockingBytecodeWithPrefix}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * token prefix\n */\n// eslint-disable-next-line complexity\nconst readTokenPrefix = (position) => {\n const { bin, index } = position;\n if (bin[index] !== 239 /* CashTokens.PREFIX_TOKEN */) {\n return { position, result: {} };\n }\n if (bin.length < index + 34 /* CashTokens.minimumPrefixLength */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.insufficientLength, `The minimum possible length is ${34 /* CashTokens.minimumPrefixLength */}. Missing bytes: ${34 /* CashTokens.minimumPrefixLength */ - (bin.length - index)}`);\n }\n const category = bin\n .slice(index + 1, index + 33 /* CashTokens.tokenBitfieldIndex */)\n .reverse();\n const tokenBitfield = bin[index + 33 /* CashTokens.tokenBitfieldIndex */]; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n /* eslint-disable no-bitwise */\n const prefixStructure = tokenBitfield & 240 /* CashTokens.tokenFormatMask */;\n if ((prefixStructure & 128 /* CashTokens.RESERVED_BIT */) !== 0) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.reservedBit, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const nftCapabilityInt = tokenBitfield & 15 /* CashTokens.nftCapabilityMask */;\n if (nftCapabilityInt > 2 /* CashTokens.maximumCapability */) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidCapability, `Capability value: ${nftCapabilityInt}`);\n }\n const capability = nftCapabilityNumberToLabel[nftCapabilityInt]; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n const hasNft = (prefixStructure & 32 /* CashTokens.HAS_NFT */) !== 0;\n const hasCommitmentLength = (prefixStructure & 64 /* CashTokens.HAS_COMMITMENT_LENGTH */) !== 0;\n if (hasCommitmentLength && !hasNft) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.commitmentWithoutNft, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const hasAmount = (prefixStructure & 16 /* CashTokens.HAS_AMOUNT */) !== 0;\n /* eslint-enable no-bitwise */\n const nextPosition = {\n bin,\n index: index + 33 /* CashTokens.tokenBitfieldIndex */ + 1,\n };\n if (hasNft) {\n const commitmentRead = hasCommitmentLength\n ? (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactSizePrefixedBin)(nextPosition)\n : { position: nextPosition, result: Uint8Array.of() };\n if (typeof commitmentRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidCommitment, commitmentRead);\n }\n if (hasCommitmentLength && commitmentRead.result.length === 0) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.commitmentLengthZero);\n }\n const amountRead = hasAmount\n ? readTokenAmount(commitmentRead.position)\n : { position: commitmentRead.position, result: 0n };\n if (typeof amountRead === 'string') {\n return amountRead;\n }\n return {\n position: amountRead.position,\n result: {\n token: {\n amount: amountRead.result,\n category,\n nft: { capability, commitment: commitmentRead.result },\n },\n },\n };\n }\n if (capability !== _transaction_types_js__WEBPACK_IMPORTED_MODULE_5__.NonFungibleTokenCapability.none) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.capabilityWithoutNft, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n if (!hasAmount) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.noTokens, `Bitfield: 0b${tokenBitfield.toString(2 /* CashTokens.useBinaryOutput */)}`);\n }\n const amountRead = readTokenAmount(nextPosition);\n if (typeof amountRead === 'string') {\n return amountRead;\n }\n return {\n position: amountRead.position,\n result: { token: { amount: amountRead.result, category } },\n };\n};\n/**\n * Read the locking bytecode and token prefix (if present) of a transaction\n * {@link Output}, beginning at the `CompactSize` indicating the\n * combined length.\n * @param position - the {@link ReadPosition} at which to start reading the\n * optional token prefix and locking bytecode\n */\nconst readLockingBytecodeWithPrefix = (position) => {\n const bytecodeRead = (0,_read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactSizePrefixedBin)(position);\n if (typeof bytecodeRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.lockingBytecodeLength, bytecodeRead);\n }\n const { result: contents, position: nextPosition } = bytecodeRead;\n const contentsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)({ bin: contents, index: 0 }, [\n readTokenPrefix,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readRemainingBytes,\n ]);\n if (typeof contentsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(CashTokenDecodingError.invalidPrefix, contentsRead);\n }\n const { result: [{ token }, lockingBytecode], } = contentsRead;\n return {\n position: nextPosition,\n result: { lockingBytecode, ...(token === undefined ? {} : { token }) },\n };\n};\n/**\n * Read a transaction {@link Output} from the provided {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Output} and the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction output\n */\nconst readTransactionOutput = (position) => {\n const outputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint64LE,\n readLockingBytecodeWithPrefix,\n ]);\n if (typeof outputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.output, outputRead);\n }\n const { position: nextPosition, result: [valueSatoshis, { lockingBytecode, token }], } = outputRead;\n return {\n position: nextPosition,\n result: {\n lockingBytecode,\n ...(token === undefined ? {} : { token }),\n valueSatoshis,\n },\n };\n};\n/**\n * Given {@link Output.token} data, encode a token prefix.\n *\n * This function does not fail, but returns an empty Uint8Array if the token\n * data does not encode any tokens (even if `token.category` is set).\n *\n * @param token - the token data to encode\n */\n// eslint-disable-next-line complexity\nconst encodeTokenPrefix = (token) => {\n if (token === undefined || (token.nft === undefined && token.amount < 1n)) {\n return Uint8Array.of();\n }\n const hasNft = token.nft === undefined ? 0 : 32 /* CashTokens.HAS_NFT */;\n const capabilityInt = token.nft === undefined\n ? 0\n : nftCapabilityLabelToNumber[token.nft.capability];\n const hasCommitmentLength = token.nft !== undefined && token.nft.commitment.length > 0\n ? 64 /* CashTokens.HAS_COMMITMENT_LENGTH */\n : 0;\n const hasAmount = token.amount > 0n ? 16 /* CashTokens.HAS_AMOUNT */ : 0;\n const tokenBitfield = \n // eslint-disable-next-line no-bitwise\n hasNft | hasCommitmentLength | hasAmount | capabilityInt;\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n Uint8Array.of(239 /* CashTokens.PREFIX_TOKEN */),\n token.category.slice().reverse(),\n Uint8Array.of(tokenBitfield),\n ...(hasCommitmentLength === 0\n ? []\n : [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(BigInt(token.nft.commitment.length)),\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n token.nft.commitment,\n ]),\n ...(hasAmount === 0 ? [] : [(0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(token.amount)]),\n ]);\n};\n/**\n * Encode a single {@link Output} for inclusion in an encoded transaction.\n *\n * @param output - the output to encode\n */\nconst encodeTransactionOutput = (output) => {\n const lockingBytecodeField = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n encodeTokenPrefix(output.token),\n output.lockingBytecode,\n ]);\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.valueSatoshisToBin)(output.valueSatoshis),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(BigInt(lockingBytecodeField.length)),\n lockingBytecodeField,\n ]);\n};\n/**\n * Read a set of transaction {@link Output}s beginning at {@link ReadPosition}.\n * A CompactSize will be read to determine the number of outputs, and that\n * number of transaction outputs will be read and returned. Returns either an\n * error message (as a string) or an object containing the array of outputs and\n * the next {@link ReadPosition}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * transaction outputs\n */\nconst readTransactionOutputs = (position) => {\n const outputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(position, readTransactionOutput);\n if (typeof outputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.outputs, outputsRead);\n }\n return outputsRead;\n};\n/**\n * Encode a set of {@link Output}s for inclusion in an encoded transaction\n * including the prefixed number of outputs. Note, this encoding differs from\n * {@link encodeTransactionOutputsForSigning} (used for signing serializations).\n *\n * Format: [CompactSize: output count] [encoded outputs]\n *\n * @param outputs - the set of outputs to encode\n */\nconst encodeTransactionOutputs = (outputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.bigIntToCompactSize)(BigInt(outputs.length)),\n ...outputs.map(encodeTransactionOutput),\n]);\n/**\n * Read a version 1 or 2 transaction beginning at {@link ReadPosition},\n * returning either an error message (as a string) or an object containing the\n * {@link Transaction} and the next {@link ReadPosition}. Rather than using this\n * function directly, most applications should\n * use {@link decodeTransactionCommon}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * {@link TransactionCommon}\n */\nconst readTransactionCommon = (position) => {\n const transactionRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n readTransactionInputs,\n readTransactionOutputs,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof transactionRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.transaction, transactionRead);\n }\n const { position: nextPosition, result: [version, inputs, outputs, locktime], } = transactionRead;\n return {\n position: nextPosition,\n result: { inputs, locktime, outputs, version },\n };\n};\nconst readTransaction = readTransactionCommon;\nconst readTransactionOutputNonTokenAware = (pos) => {\n const outputRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(pos, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint64LE,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readCompactSizePrefixedBin,\n ]);\n if (typeof outputRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.output, outputRead);\n }\n const { position: nextPosition, result: [valueSatoshis, lockingBytecode], } = outputRead;\n return {\n position: nextPosition,\n result: { lockingBytecode, valueSatoshis },\n };\n};\nconst readTransactionOutputsNonTokenAware = (pos) => {\n const outputsRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readItemCount)(pos, readTransactionOutputNonTokenAware);\n if (typeof outputsRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.outputs, outputsRead);\n }\n return outputsRead;\n};\n/**\n * Read a version 1 or 2 transaction beginning at a {@link ReadPosition} as if\n * CHIP-2022-02-CashTokens were not deployed, returning either an error message\n * (as a string) or an object containing the {@link Transaction} and the next\n * {@link ReadPosition}.\n *\n * This function emulates legacy transaction parsing to test behavior prior to\n * deployment of CHIP-2022-02-CashTokens; most applications should instead\n * use {@link readTransactionCommon}.\n *\n * @param position - the {@link ReadPosition} at which to start reading the\n * {@link TransactionCommon}\n */\nconst readTransactionNonTokenAware = (position) => {\n const transactionRead = (0,_format_format_js__WEBPACK_IMPORTED_MODULE_2__.readMultiple)(position, [\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n readTransactionInputs,\n readTransactionOutputsNonTokenAware,\n _read_components_js__WEBPACK_IMPORTED_MODULE_3__.readUint32LE,\n ]);\n if (typeof transactionRead === 'string') {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.transaction, transactionRead);\n }\n const { position: nextPosition, result: [version, inputs, outputs, locktime], } = transactionRead;\n return {\n position: nextPosition,\n result: { inputs, locktime, outputs, version },\n };\n};\n/**\n * Decode a {@link TransactionCommon} according to the version 1/2 P2P network\n * transaction format.\n *\n * This function verifies that the provided `bin` contains only one transaction\n * and no additional data. To read a transaction from a specific location within\n * a `Uint8Array`, use {@link readTransactionCommon}.\n *\n * @param bin - the encoded transaction to decode\n */\nconst decodeTransactionCommon = (bin) => {\n const transactionRead = readTransactionCommon({ bin, index: 0 });\n if (typeof transactionRead === 'string') {\n return transactionRead;\n }\n if (transactionRead.position.index !== bin.length) {\n return (0,_format_format_js__WEBPACK_IMPORTED_MODULE_4__.formatError)(TransactionDecodingError.endsWithUnexpectedBytes, `Encoded transaction ends at index ${transactionRead.position.index - 1}, leaving ${bin.length - transactionRead.position.index} remaining bytes.`);\n }\n return transactionRead.result;\n};\nconst decodeTransactionBCH = decodeTransactionCommon;\nconst decodeTransaction = decodeTransactionBCH;\n/**\n * Decode a {@link TransactionCommon} from a trusted source according to the\n * version 1/2 P2P network transaction format.\n *\n * Note: this method throws runtime errors when attempting to decode messages\n * which do not properly follow the transaction format. If the input is\n * untrusted, use {@link decodeTransactionCommon}.\n *\n * @param bin - the raw message to decode\n */\nconst decodeTransactionUnsafeCommon = (bin) => {\n const result = decodeTransactionCommon(bin);\n if (typeof result === 'string') {\n // eslint-disable-next-line functional/no-throw-statement\n throw new Error(result);\n }\n return result;\n};\nconst decodeTransactionUnsafeBCH = decodeTransactionUnsafeCommon;\nconst decodeTransactionUnsafe = decodeTransactionUnsafeBCH;\n/**\n * Encode a {@link Transaction} using the standard P2P network format. This\n * serialization is also used when computing the transaction's hash (A.K.A.\n * \"transaction ID\" or \"TXID\").\n */\nconst encodeTransactionCommon = (tx) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(tx.version),\n encodeTransactionInputs(tx.inputs),\n encodeTransactionOutputs(tx.outputs),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(tx.locktime),\n]);\nconst encodeTransactionBCH = encodeTransactionCommon;\nconst encodeTransaction = encodeTransactionBCH;\nconst cloneTransactionInputsCommon = (inputs) => inputs.map((input) => ({\n outpointIndex: input.outpointIndex,\n outpointTransactionHash: input.outpointTransactionHash.slice(),\n sequenceNumber: input.sequenceNumber,\n unlockingBytecode: input.unlockingBytecode.slice(),\n}));\nconst cloneTransactionOutputsCommon = (outputs) => outputs.map((output) => ({\n lockingBytecode: output.lockingBytecode.slice(),\n ...(output.token === undefined\n ? {}\n : {\n token: {\n amount: output.token.amount,\n category: output.token.category.slice(),\n ...(output.token.nft === undefined\n ? {}\n : {\n nft: {\n capability: output.token.nft.capability,\n commitment: output.token.nft.commitment.slice(),\n },\n }),\n },\n }),\n valueSatoshis: output.valueSatoshis,\n}));\nconst cloneTransactionCommon = (transaction) => ({\n inputs: cloneTransactionInputsCommon(transaction.inputs),\n locktime: transaction.locktime,\n outputs: cloneTransactionOutputsCommon(transaction.outputs),\n version: transaction.version,\n});\n/**\n * Compute a transaction hash (A.K.A. \"transaction ID\" or \"TXID\") from an\n * encoded transaction in P2P network message order. This is the byte order\n * produced by most sha256 libraries and used by encoded P2P network messages.\n * It is also the byte order produced by `OP_SHA256` and `OP_HASH256` in the\n * virtual machine.\n *\n * @returns the transaction hash in P2P network message byte order\n *\n * @param transaction - the encoded transaction\n * @param sha256 - an implementation of sha256\n */\nconst hashTransactionP2pOrder = (transaction, sha256 = _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__.sha256) => (0,_crypto_crypto_js__WEBPACK_IMPORTED_MODULE_7__.hash256)(transaction, sha256);\n/**\n * Compute a transaction hash (A.K.A. \"transaction ID\" or \"TXID\") from an\n * encoded transaction in user interface byte order. This is the byte order\n * typically used by block explorers, wallets, and other user interfaces.\n *\n * To return this result as a `string`, use {@link hashTransaction}.\n *\n * @returns the transaction hash in User Interface byte order\n *\n * @param transaction - the encoded transaction\n * @param sha256 - an implementation of sha256\n */\nconst hashTransactionUiOrder = (transaction, sha256 = _crypto_crypto_js__WEBPACK_IMPORTED_MODULE_6__.sha256) => hashTransactionP2pOrder(transaction, sha256).reverse();\n/**\n * Return an encoded {@link Transaction}'s hash/ID as a string in user interface\n * byte order (typically used by wallets and block explorers).\n *\n * To return this result as a `Uint8Array`, use {@link hashTransactionUiOrder}.\n *\n * @param transaction - the encoded transaction\n */\nconst hashTransaction = (transaction) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.binToHex)(hashTransactionUiOrder(transaction));\n/**\n * Encode all outpoints in a series of transaction inputs. (For use in\n * {@link hashTransactionOutpoints}.)\n *\n * @param inputs - the series of inputs from which to extract the outpoints\n */\nconst encodeTransactionOutpoints = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(inputs.map((i) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)([\n i.outpointTransactionHash.slice().reverse(),\n (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(i.outpointIndex),\n])));\n/**\n * Encode an array of transaction {@link Output}s for use in transaction signing\n * serializations. Note, this encoding differs from\n * {@link encodeTransactionOutputs} (used for encoding full transactions).\n *\n * @param outputs - the array of outputs to encode\n */\nconst encodeTransactionOutputsForSigning = (outputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(outputs.map(encodeTransactionOutput));\n/**\n * Encode the sequence numbers of an array of transaction inputs for use in\n * transaction signing serializations.\n *\n * @param inputs - the array of inputs from which to extract the sequence\n * numbers\n */\nconst encodeTransactionInputSequenceNumbersForSigning = (inputs) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_0__.flattenBinArray)(inputs.map((i) => (0,_format_format_js__WEBPACK_IMPORTED_MODULE_1__.numberToBinUint32LE)(i.sequenceNumber)));\n//# sourceMappingURL=transaction-encoding.js.map\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } });\n\n//# sourceURL=webpack://mainnet-js/./node_modules/@bitauth/libauth/build/lib/message/transaction-encoding.js?");
|
|
2338
2338
|
|
|
2339
2339
|
/***/ }),
|
|
2340
2340
|
|
|
@@ -14,7 +14,6 @@ export default class ElectrumNetworkProvider implements NetworkProvider {
|
|
|
14
14
|
private blockHeight;
|
|
15
15
|
constructor(electrum: ElectrumCluster | ElectrumClient, network?: Network, manualConnectionManagement?: boolean | undefined);
|
|
16
16
|
private getConnectPromise;
|
|
17
|
-
static utxoTxCache: {};
|
|
18
17
|
getUtxos(cashaddr: string): Promise<UtxoI[]>;
|
|
19
18
|
getBalance(cashaddr: string): Promise<number>;
|
|
20
19
|
getBlockHeight(): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElectrumNetworkProvider.d.ts","sourceRoot":"","sources":["../../../src/network/ElectrumNetworkProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EAGf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAA4B,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,sBAAsB,EAAgB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ElectrumNetworkProvider.d.ts","sourceRoot":"","sources":["../../../src/network/ElectrumNetworkProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EAGf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,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,cAAc;YAsCd,gBAAgB;YAkBhB,kBAAkB;IAkB1B,KAAK,IAAI,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAInC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAMhC,UAAU,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAWhC,gBAAgB,IAAI,OAAO;IAIrB,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAezD,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKhD,cAAc,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAIjC,aAAa,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAiBhC,iBAAiB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIvC,gBAAgB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG7C"}
|
|
@@ -3,7 +3,6 @@ import { Network } from "../interface.js";
|
|
|
3
3
|
import { delay } from "../util/delay.js";
|
|
4
4
|
import { Mutex } from "async-mutex";
|
|
5
5
|
import { getTransactionHash } from "../util/transaction.js";
|
|
6
|
-
import { binToHex, decodeTransactionBCH, hexToBin, } from "@bitauth/libauth";
|
|
7
6
|
export default class ElectrumNetworkProvider {
|
|
8
7
|
constructor(electrum, network = Network.MAINNET, manualConnectionManagement) {
|
|
9
8
|
this.network = network;
|
|
@@ -59,42 +58,20 @@ export default class ElectrumNetworkProvider {
|
|
|
59
58
|
height: utxo.height,
|
|
60
59
|
}));
|
|
61
60
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
transactionMap[tx_hash] = decoded;
|
|
78
|
-
ElectrumNetworkProvider.utxoTxCache[key] = decoded;
|
|
79
|
-
}
|
|
80
|
-
const utxos = result.map((utxo) => {
|
|
81
|
-
const output = transactionMap[utxo.tx_hash].outputs[utxo.tx_pos];
|
|
82
|
-
return {
|
|
83
|
-
txid: utxo.tx_hash,
|
|
84
|
-
vout: utxo.tx_pos,
|
|
85
|
-
satoshis: utxo.value,
|
|
86
|
-
height: utxo.height,
|
|
87
|
-
token: output.token &&
|
|
88
|
-
{
|
|
89
|
-
amount: Number(output.token.amount),
|
|
90
|
-
tokenId: binToHex(output.token.category),
|
|
91
|
-
capability: output.token.nft?.capability,
|
|
92
|
-
commitment: output.token.nft?.commitment &&
|
|
93
|
-
binToHex(output.token.nft?.commitment),
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
});
|
|
97
|
-
return utxos;
|
|
61
|
+
return result.map((utxo) => ({
|
|
62
|
+
txid: utxo.tx_hash,
|
|
63
|
+
vout: utxo.tx_pos,
|
|
64
|
+
satoshis: utxo.value,
|
|
65
|
+
height: utxo.height,
|
|
66
|
+
token: utxo.token_data
|
|
67
|
+
? {
|
|
68
|
+
amount: Number(utxo.token_data.amount),
|
|
69
|
+
tokenId: utxo.token_data.category,
|
|
70
|
+
capability: utxo.token_data.nft?.capability,
|
|
71
|
+
commitment: utxo.token_data.nft?.commitment,
|
|
72
|
+
}
|
|
73
|
+
: undefined,
|
|
74
|
+
}));
|
|
98
75
|
}
|
|
99
76
|
async getBalance(cashaddr) {
|
|
100
77
|
const result = (await this.performRequest("blockchain.address.get_balance", cashaddr));
|
|
@@ -363,7 +340,7 @@ export default class ElectrumNetworkProvider {
|
|
|
363
340
|
return await this.electrum.connect();
|
|
364
341
|
}
|
|
365
342
|
catch (e) {
|
|
366
|
-
console.warn(`Warning: Failed to connect to client on ${this.network} at ${this.electrum.connection.host}
|
|
343
|
+
console.warn(`Warning: Failed to connect to client on ${this.network} at ${this.electrum.connection.host}.`, e);
|
|
367
344
|
return;
|
|
368
345
|
}
|
|
369
346
|
};
|
|
@@ -376,6 +353,5 @@ export default class ElectrumNetworkProvider {
|
|
|
376
353
|
return [await this.electrum.disconnect(true)];
|
|
377
354
|
}
|
|
378
355
|
}
|
|
379
|
-
ElectrumNetworkProvider.utxoTxCache = {};
|
|
380
356
|
ElectrumNetworkProvider.rawTransactionCache = {};
|
|
381
357
|
//# sourceMappingURL=ElectrumNetworkProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElectrumNetworkProvider.js","sourceRoot":"","sources":["../../../src/network/ElectrumNetworkProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGf,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,QAAQ,GAET,MAAM,kBAAkB,CAAC;AAE1B,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAO1C,YACE,QAA0C,EACnC,UAAmB,OAAO,CAAC,OAAO,EACjC,0BAAoC;QADrC,YAAO,GAAP,OAAO,CAA2B;QACjC,+BAA0B,GAA1B,0BAA0B,CAAU;QARvC,kBAAa,GAAW,CAAC,CAAC;QAEzB,UAAK,GAAG,IAAI,KAAK,EAAE,CAAC;QACpB,gBAAW,GAAG,CAAC,CAAC;QAOtB,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACzB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;SAChD;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;SACnE;IACH,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAA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C,MAAO,IAAI,CAAC,QAA2B,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACpE,CAAC;;AA3ZM,2CAAmB,GAAG,EAAE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ClusterOrder } from "electrum-cash";
|
|
2
|
-
export declare const ELECTRUM_CASH_PROTOCOL_VERSION = "1.
|
|
2
|
+
export declare const ELECTRUM_CASH_PROTOCOL_VERSION = "1.5";
|
|
3
|
+
export declare const ELECTRUM_CASH_PROTOCOL_VERSION_MAINNET = "1.4.1";
|
|
3
4
|
export declare const networkTickerMap: {
|
|
4
5
|
mainnet: string;
|
|
5
6
|
testnet: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/network/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/network/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,eAAO,MAAM,8BAA8B,QAAQ,CAAC;AACpD,eAAO,MAAM,sCAAsC,UAAU,CAAC;AAE9D,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC;AAEF,eAAO,MAAM,cAAc,UAK1B,CAAC;AAiBF,eAAO,MAAM,cAAc,UAG1B,CAAC;AAEF,eAAO,MAAM,cAAc,UAA2B,CAAC;AAEvD,eAAO,MAAM,cAAc;;;;CAI1B,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;CAmBzB,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ClusterOrder } from "electrum-cash";
|
|
2
|
-
|
|
2
|
+
// Two different protocol versions are communicated, must converge to the same one after May23 upgrade
|
|
3
|
+
export const ELECTRUM_CASH_PROTOCOL_VERSION = "1.5";
|
|
4
|
+
export const ELECTRUM_CASH_PROTOCOL_VERSION_MAINNET = "1.4.1";
|
|
3
5
|
export const networkTickerMap = {
|
|
4
6
|
mainnet: "BCH",
|
|
5
7
|
testnet: "tBCH",
|
|
@@ -11,22 +13,23 @@ export const mainnetServers = [
|
|
|
11
13
|
"wss://electrum.imaginary.cash:50004",
|
|
12
14
|
// "wss://fulcrum.fountainhead.cash",
|
|
13
15
|
];
|
|
14
|
-
export const testnetServers = [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
];
|
|
16
|
+
// export const testnetServers = [
|
|
17
|
+
// // "wss://tbch.loping.net:60004",
|
|
18
|
+
// "wss://blackie.c3-soft.com:60004",
|
|
19
|
+
// // "wss://testnet.bitcoincash.network:60004",
|
|
20
|
+
// //,"wss://unavailable.invalid:50004"
|
|
21
|
+
// ];
|
|
20
22
|
// testnet4
|
|
21
23
|
// export const testnetServers = [
|
|
22
24
|
// //"wss://t4fork.c3-soft.com:61004",
|
|
23
25
|
// "wss://testnet4.imaginary.cash:50004",
|
|
24
26
|
// //,"wss://unavailable.invalid:50004"
|
|
25
27
|
// ];
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
//
|
|
28
|
+
// chipnet
|
|
29
|
+
export const testnetServers = [
|
|
30
|
+
// "wss://chipnet.imaginary.cash:50004",
|
|
31
|
+
"wss://blackie.c3-soft.com:64004", // chipnet with protocol 1.5.0
|
|
32
|
+
];
|
|
30
33
|
export const regtestServers = ["ws://127.0.0.1:60003"];
|
|
31
34
|
export const defaultServers = {
|
|
32
35
|
mainnet: mainnetServers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../src/network/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,CAAC,MAAM,8BAA8B,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"constant.js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b,YAAY,EAAE,CAAC;QACf,KAAK,EAAE,YAAY,CAAC,QAAQ;QAC5B,OAAO,EAAE,IAAI;KACd;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/network/default.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAOlE,OAAO,EAAsB,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/network/default.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAOlE,OAAO,EAAsB,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAQ1C,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,GACxB,eAAe,CAIjB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAG1E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAK7E;AAED,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,OAAyB,EAClC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAC3B,0BAA0B,CAAC,EAAE,OAAO,EACpC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,eAAe,CAyDjB"}
|