gamegold 5.6.7 → 5.6.9
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/lib/gamegold-worker.js +1 -1
- package/lib/gamegold.js +3 -3
- package/package.json +1 -1
package/lib/gamegold-worker.js
CHANGED
|
@@ -201,7 +201,7 @@ let r=[];[i(558),i(559),i(560),i(561),i(562),i(563),i(564),i(565),i(566),i(567),
|
|
|
201
201
|
* pkg.js - package constants
|
|
202
202
|
* Copyright (c) 2019-2022, Bookman Software (MIT License).
|
|
203
203
|
* https://github.com/bookmansoft/gamegold
|
|
204
|
-
*/t.protocol="vallnet",t.version="5.6.
|
|
204
|
+
*/t.protocol="vallnet",t.version="5.6.9",t.url="https://github.com/bookmansoft/gamegold"},function(e,t,i){"use strict";
|
|
205
205
|
/*!
|
|
206
206
|
* common.js - p2p constants for vallnet
|
|
207
207
|
* Copyright (c) 2019-2022, Bookman Software (MIT License).
|
package/lib/gamegold.js
CHANGED
|
@@ -211,7 +211,7 @@ let r=[];[i(558),i(559),i(560),i(561),i(562),i(563),i(564),i(565),i(566),i(567),
|
|
|
211
211
|
* pkg.js - package constants
|
|
212
212
|
* Copyright (c) 2019-2022, Bookman Software (MIT License).
|
|
213
213
|
* https://github.com/bookmansoft/gamegold
|
|
214
|
-
*/t.protocol="vallnet",t.version="5.6.
|
|
214
|
+
*/t.protocol="vallnet",t.version="5.6.9",t.url="https://github.com/bookmansoft/gamegold"},function(e,t,i){"use strict";
|
|
215
215
|
/*!
|
|
216
216
|
* common.js - p2p constants for vallnet
|
|
217
217
|
* Copyright (c) 2019-2022, Bookman Software (MIT License).
|
|
@@ -1240,7 +1240,7 @@ e.exports=i(478)},function(e){e.exports=JSON.parse('{"application/1d-interleaved
|
|
|
1240
1240
|
* Copyright(c) 2014 Jonathan Ong
|
|
1241
1241
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
1242
1242
|
* MIT Licensed
|
|
1243
|
-
*/var r=i(737),s=i(225);function n(e){if(!(this instanceof n))return new n(e);this.headers=e.headers,this.negotiator=new r(e)}function a(e){return-1===e.indexOf("/")?s.lookup(e):e}function o(e){return"string"==typeof e}(e.exports=n).prototype.type=n.prototype.types=function(e){var t;if((i=e)&&!Array.isArray(i))for(var i=new Array(arguments.length),r=0;r<i.length;r++)i[r]=arguments[r];return i&&0!==i.length?this.headers.accept?(e=i.map(a),!!(t=this.negotiator.mediaTypes(e.filter(o))[0])&&i[e.indexOf(t)]):i[0]:this.negotiator.mediaTypes()},n.prototype.encoding=n.prototype.encodings=function(e){if((t=e)&&!Array.isArray(t))for(var t=new Array(arguments.length),i=0;i<t.length;i++)t[i]=arguments[i];return t&&0!==t.length?this.negotiator.encodings(t)[0]||!1:this.negotiator.encodings()},n.prototype.charset=n.prototype.charsets=function(e){if((t=e)&&!Array.isArray(t))for(var t=new Array(arguments.length),i=0;i<t.length;i++)t[i]=arguments[i];return t&&0!==t.length?this.negotiator.charsets(t)[0]||!1:this.negotiator.charsets()},n.prototype.lang=n.prototype.langs=n.prototype.language=n.prototype.languages=function(e){if((t=e)&&!Array.isArray(t))for(var t=new Array(arguments.length),i=0;i<t.length;i++)t[i]=arguments[i];return t&&0!==t.length?this.negotiator.languages(t)[0]||!1:this.negotiator.languages()}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StrictEventEmitter=void 0;class r extends i(16).EventEmitter{on(e,t){return super.on(e,t)}once(e,t){return super.once(e,t)}emit(e,...t){return super.emit(e,...t)}emitReserved(e,...t){return super.emit(e,...t)}emitUntyped(e,...t){return super.emit(e,...t)}listeners(e){return super.listeners(e)}}t.StrictEventEmitter=r},function(e,t){e.exports=require("string_decoder")},function(e,t,i){"use strict";var r=i(682),s=i(63);const n=i(2),a=i(77),o=i(78).errors;var c=i(13),h=i(33);const u=i(42);i=i(776);var l={};i.forEach((function(e){e.searchStrings.forEach((function(t){l[t]={poolName:e.poolName,url:e.url}}))}));var p=new s(1e6),d=new s(1e3);function f(e){var t=0;return e.outputs.forEach((function(e){t+=e.value})),h.fromSatoshis(t).toBTC()}function m(e,t){e?e.code?t.send(400,e.message+". Code:"+e.code):t.send(503,e.message):t.send(404,"Not found")}function g(e){if(e){var t,i=e.inputs[0].script.raw;for(t in l)if(i.toString("utf-8").match(t))return l[t]}return{}}async function y(e,t,i){var r=d.get(t);if(r){var s=e.chain.height;r.confirmations=s-r.height+1}else{if(!(s=await e.chain.getBlock(t))){if(e.chain.options.spv)throw new a(o.MISC_ERROR,"Block not available (spv mode)");if(e.chain.options.prune)throw new a(o.MISC_ERROR,"Block not available (pruned data)");throw new a(o.DATABASE_ERROR,"Can't read block from disk")}try{var n=await e.rpc.execute({corba:!0,method:"block.header",params:[s.rhash()]}),c=v(s,n);6<=c.confirmations&&d.set(t,c),r=c}catch(e){r=null,m(e,i)}}return r}function v(e,t){var i=e.txs.map((function(e){return e.txid()}));return t.previousblockhash=t.previousblockhash?n.revHex(t.previousblockhash):"",t.nextblockhash=t.nextblockhash&&0<t.nextblockhash.length?n.revHex(t.nextblockhash):"",{hash:e.hash().toString("hex"),size:e.getSize(),height:t.height,version:e.version,merkleroot:e.merkleRoot,tx:i,time:e.time,timeNormalized:e.time,transactioncount:i.length,nonce:e.nonce,bits:e.bits,difficulty:t.difficulty,chainwork:t.chainwork,confirmations:t.confirmations,previousblockhash:t.previousblockhash,nextblockhash:t.nextblockhash,reward:f(e.txs[0]),isMainChain:!0,minedby:"",poolInfo:g(e.txs[0])}}function b(e,t){if(e=e.address)return e.network=t,e.toString()}async function w(e,t,i=!1){var r,s=t.tx;s.__height=t.height,s.__blockhash=t.block,s.__timestamp=t.time;for(let t=s.outputSatoshis=0;t<s.outputs.length;t++){var n,a=s.outputs[t];s.outputSatoshis+=a.value,i&&(n=await e.chain.db.getSpender(s.hash("hex"),t))&&(a.spentTxId=n.txid,a.spentIndex=n.inputIndex,a.spentHeight=n.blockHeight,a.spentBlockHash=n.blockHash)}for(r of(s.inputSatoshis=0,s.__inputValues=[],s.inputs)){var o=await e.getTXFromAll(r.prevout.hash);o&&(s.__inputValues.push(o.outputs[r.prevout.index].value),s.inputSatoshis+=o.outputs[r.prevout.index].value)}return s.feeSatoshis=s.inputSatoshis-s.outputSatoshis,s.__confirmations=e.chain.height-s.__height+1,s.confirmations=s.__confirmations,s.height=s.__height,s.blockhash=s.__blockhash,s}function k(e,t,i){e=e||{};var r={txid:t.prevout.txid(),vout:t.prevout.index,sequence:t.sequence,n:i};return(t=(e.noScriptSig||(r.scriptSig={hex:t.script.toJSON()},e.noAsm)||(r.scriptSig.asm=t.script.toASM()),t.getAddress()))?(t.network=this.network.type,r.addr=t.toString()):r.addr=null,r.valueSat=e.inputValues[i],r.value=r.valueSat/1e8,r.doubleSpentTxID=null,r.isConfirmed=null,r.confirmations=null,r.unconfirmedInput=null,r}function x(e,t,i){return e=e||{},i={value:(t.value/1e8).toFixed(8),n:i,scriptPubKey:{hex:t.script.toJSON()}},e.noAsm||(i.scriptPubKey.asm=t.script.toASM()),e.noSpent||(i.spentTxId=t.spentTxId||null,t.spentIndex?i.spentIndex=t.spentIndex:i.spentIndex=null,t.spentHeight?i.spentHeight=t.spentHeight:i.spentHeight=null,t.spentBlockHash?i.spentBlockHash=t.spentBlockHash:i.spentBlockHash=null),(e=t.getAddress())&&(e.network=this.network.type,i.scriptPubKey.addresses=[e.toString()],i.scriptPubKey.type=e.getType()),i}t.getBlockReward=f,t.handleErrors=m,t.formatTimestamp=function(e){var t=e.getUTCFullYear().toString(),i=(e.getUTCMonth()+1).toString();e=e.getUTCDate().toString();return t+"-"+(i[1]?i:"0"+i[0])+"-"+(e[1]?e:"0"+e[0])},t.getPoolInfo=g,t.translateInputAddresses=function(e){if(e){var t=e=r.isArray(e)?e:[e];if(t)for(var i=0;i<t.length;i++)try{new c(t[i])}catch(e){throw t[i]}return e}},t.translateOutputAddress=function(e){return e},t.getBlockByHash=y,t.transformBlock=v,t.getBlockSummary=async function(e,t,i){function r(e){return i>e.time&&(i=e.time),e}var s,n=p.get(t);if(n)return r(n);if(n=await e.chain.getBlock(t))return n={height:(s=await e.rpc.execute({corba:!0,method:"block.header",params:[n.rhash()]})).height,size:n.getSize(),virtualSize:n.getVirtualSize(),hash:t,time:s.times,txlength:n.txs.length,poolInfo:g(n.txs[0])},6<=s.confirmations&&p.set(t,n),r(n);if(e.chain.options.spv)throw new a(o.MISC_ERROR,"Block not available (spv mode)");if(e.chain.options.prune)throw new a(o.MISC_ERROR,"Block not available (pruned data)");throw new a(o.DATABASE_ERROR,"Can't read block from disk")},t.getAddress=b,t.getBlockOverview=async function(e,t,i){return(e=await y(e,t,i))?{hash:e.hash,version:e.version,confirmations:e.confirmations,height:e.height,chainWork:e.chainwork,prevHash:e.previousblockhash,nextHash:e.nextblockhash,merkleRoot:e.merkleroot,time:e.time,medianTime:null,nonce:e.nonce,bits:e.bits,difficulty:e.difficulty,txids:e.tx}:null},t.getDetailedTransaction=async function(e,t,i=!1){return(t=await e.getMeta(t))?w(e,t,i):null},t.getDetailFromMeta=w,t.transformTransaction=async function(e,t,i){i=i||{};var r=0,s=(0<=t.__height&&(r=e.chain.height-t.__height+1),{txid:t.txid(),version:t.version,locktime:t.locktime});return t.inputs[0].isCoinbase()?(s.isCoinBase=!0,s.vin=[{coinbase:t.inputs[0].script.toJSON(),sequence:t.inputs[0].sequence,n:0}]):(i.inputValues=t.__inputValues,s.vin=t.inputs.map(k.bind(e,i)),s.valueIn=t.inputSatoshis/1e8,s.fees=t.feeSatoshis/1e8),s.vout=t.outputs.map(x.bind(e,i)),s.blockhash=t.blockhash,s.blockheight=t.__height,s.confirmations=r,s.time=t.__timestamp||Math.round(Date.now()/1e3),s.confirmations&&(s.blocktime=s.time),s.valueOut=t.outputSatoshis/1e8,s.size=t.getSize(),(i=await u.FactoryOfContract({env:e.chain.db,tx:t})).data&&(s.clsData=i.data),s},t.transformInput=k,t.transformOutput=x,t._setOutputResults=function(e,t,i,r){for(var s=0;s<t.outputs.length;s++){var n=t.outputs[s];b(n,e.network.type)===i&&(r.txApperances++,r.totalReceivedSat+=n.value,r.balanceSat+=n.value,0===t.confirmations)&&(r.unconfirmedTxApperances++,r.unconfirmedBalanceSat+=n.value)}return r},t._setInputResults=function(e,t,i,r){for(var s=0;s<t.inputs.length;s++)b(t.inputs[s],e.network.type)===i&&(r.totalSentSat+=t.__inputValues[s],r.balanceSat-=t.__inputValues[s],0===t.confirmations)&&(r.unconfirmedBalanceSat-=t.__inputValues[s])},t.utxo=async function(e,t){return(await e.getCoinsByAddress(t)).map(t=>({address:c.fromScript(t.script).toString(),txid:t.hash,vout:t.index,coinbase:t.coinbase,timestamp:0,scriptPubKey:{hex:t.script.toJSON(),asm:t.script.toASM()},amount:h.fromSatoshis(t.value).toBTC(),height:t.height,satoshis:t.value,confirmations:e.chain.height-t.height+1}))}},function(e,t,i){"use strict";
|
|
1243
|
+
*/var r=i(737),s=i(225);function n(e){if(!(this instanceof n))return new n(e);this.headers=e.headers,this.negotiator=new r(e)}function a(e){return-1===e.indexOf("/")?s.lookup(e):e}function o(e){return"string"==typeof e}(e.exports=n).prototype.type=n.prototype.types=function(e){var t;if((i=e)&&!Array.isArray(i))for(var i=new Array(arguments.length),r=0;r<i.length;r++)i[r]=arguments[r];return i&&0!==i.length?this.headers.accept?(e=i.map(a),!!(t=this.negotiator.mediaTypes(e.filter(o))[0])&&i[e.indexOf(t)]):i[0]:this.negotiator.mediaTypes()},n.prototype.encoding=n.prototype.encodings=function(e){if((t=e)&&!Array.isArray(t))for(var t=new Array(arguments.length),i=0;i<t.length;i++)t[i]=arguments[i];return t&&0!==t.length?this.negotiator.encodings(t)[0]||!1:this.negotiator.encodings()},n.prototype.charset=n.prototype.charsets=function(e){if((t=e)&&!Array.isArray(t))for(var t=new Array(arguments.length),i=0;i<t.length;i++)t[i]=arguments[i];return t&&0!==t.length?this.negotiator.charsets(t)[0]||!1:this.negotiator.charsets()},n.prototype.lang=n.prototype.langs=n.prototype.language=n.prototype.languages=function(e){if((t=e)&&!Array.isArray(t))for(var t=new Array(arguments.length),i=0;i<t.length;i++)t[i]=arguments[i];return t&&0!==t.length?this.negotiator.languages(t)[0]||!1:this.negotiator.languages()}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StrictEventEmitter=void 0;class r extends i(16).EventEmitter{on(e,t){return super.on(e,t)}once(e,t){return super.once(e,t)}emit(e,...t){return super.emit(e,...t)}emitReserved(e,...t){return super.emit(e,...t)}emitUntyped(e,...t){return super.emit(e,...t)}listeners(e){return super.listeners(e)}}t.StrictEventEmitter=r},function(e,t){e.exports=require("string_decoder")},function(e,t,i){"use strict";var r=i(682),s=i(63);const n=i(2),a=i(77),o=i(78).errors;var c=i(13),h=i(33);const u=i(42);i=i(776);var l={};i.forEach((function(e){e.searchStrings.forEach((function(t){l[t]={poolName:e.poolName,url:e.url}}))}));var p=new s(1e6),d=new s(1e3);function f(e){var t=0;return e.outputs.forEach((function(e){t+=e.value})),h.fromSatoshis(t).toBTC()}function m(e,t){e?e.code?t.send(400,e.message+". Code:"+e.code):t.send(503,e.message):t.send(404,"Not found")}function g(e){if(e){var t,i=e.inputs[0].script.raw;for(t in l)if(i.toString("utf-8").match(t))return l[t]}return{}}async function y(e,t,i){var r=d.get(t);if(r){var s=e.chain.height;r.confirmations=s-r.height+1}else{if(!(s=await e.chain.getBlock(t))){if(e.chain.options.spv)throw new a(o.MISC_ERROR,"Block not available (spv mode)");if(e.chain.options.prune)throw new a(o.MISC_ERROR,"Block not available (pruned data)");throw new a(o.DATABASE_ERROR,"Can't read block from disk")}try{var n=await e.rpc.execute({corba:!0,method:"block.header",params:[s.rhash()]}),c=v(s,n);6<=c.confirmations&&d.set(t,c),r=c}catch(e){r=null,m(e,i)}}return r}function v(e,t){var i=e.txs.map((function(e){return e.txid()}));return t.previousblockhash=t.previousblockhash?n.revHex(t.previousblockhash):"",t.nextblockhash=t.nextblockhash&&0<t.nextblockhash.length?n.revHex(t.nextblockhash):"",{hash:e.hash().toString("hex"),size:e.getSize(),height:t.height,version:e.version,merkleroot:e.merkleRoot,tx:i,time:e.time,timeNormalized:e.time,transactioncount:i.length,nonce:e.nonce,bits:e.bits,difficulty:t.difficulty,chainwork:t.chainwork,confirmations:t.confirmations,previousblockhash:t.previousblockhash,nextblockhash:t.nextblockhash,reward:f(e.txs[0]),isMainChain:!0,minedby:"",poolInfo:g(e.txs[0])}}function b(e,t){if(e=e.address)return e.network=t,e.toString()}async function w(e,t,i=!1){var r,s=t.tx;s.__height=t.height,s.__blockhash=t.block,s.__timestamp=t.time;for(let t=s.outputSatoshis=0;t<s.outputs.length;t++){var n,a=s.outputs[t];s.outputSatoshis+=a.value,i&&(n=await e.chain.db.getSpender(s.hash("hex"),t))&&(a.spentTxId=n.txid,a.spentIndex=n.inputIndex,a.spentHeight=n.blockHeight,a.spentBlockHash=n.blockHash)}for(r of(s.inputSatoshis=0,s.__inputValues=[],s.inputs)){var o=await e.getTXFromAll(r.prevout.hash);o&&(s.__inputValues.push(o.outputs[r.prevout.index].value),s.inputSatoshis+=o.outputs[r.prevout.index].value)}return s.feeSatoshis=s.inputSatoshis-s.outputSatoshis,s.__confirmations=e.chain.height-s.__height+1,s.confirmations=s.__confirmations,s.height=s.__height,s.blockhash=s.__blockhash,s}function k(e,t,i){e=e||{};var r={txid:t.prevout.txid(),vout:t.prevout.index,sequence:t.sequence,n:i};return(t=(e.noScriptSig||(r.scriptSig={hex:t.script.toJSON()},e.noAsm)||(r.scriptSig.asm=t.script.toASM()),t.getAddress()))?(t.network=this.network.type,r.addr=t.toString()):r.addr=null,r.valueSat=e.inputValues[i],r.value=r.valueSat/1e8,r.doubleSpentTxID=null,r.isConfirmed=null,r.confirmations=null,r.unconfirmedInput=null,r}function x(e,t,i){return e=e||{},i={value:(t.value/1e8).toFixed(8),n:i,scriptPubKey:{hex:t.script.toJSON()}},e.noAsm||(i.scriptPubKey.asm=t.script.toASM()),e.noSpent||(i.spentTxId=t.spentTxId||null,t.spentIndex?i.spentIndex=t.spentIndex:i.spentIndex=null,t.spentHeight?i.spentHeight=t.spentHeight:i.spentHeight=null,t.spentBlockHash?i.spentBlockHash=t.spentBlockHash:i.spentBlockHash=null),(e=t.getAddress())&&(e.network=this.network.type,i.scriptPubKey.addresses=[e.toString()],i.scriptPubKey.type=e.getType()),i}t.getBlockReward=f,t.handleErrors=m,t.formatTimestamp=function(e){var t=e.getUTCFullYear().toString(),i=(e.getUTCMonth()+1).toString();e=e.getUTCDate().toString();return t+"-"+(i[1]?i:"0"+i[0])+"-"+(e[1]?e:"0"+e[0])},t.getPoolInfo=g,t.translateInputAddresses=function(e){if(e){var t=e=r.isArray(e)?e:[e];if(t)for(var i=0;i<t.length;i++)try{new c(t[i])}catch(e){throw t[i]}return e}},t.translateOutputAddress=function(e){return e},t.getBlockByHash=y,t.transformBlock=v,t.getBlockSummary=async function(e,t,i){function r(e){return i>e.time&&(i=e.time),e}var s,n=p.get(t);if(n)return r(n);if(n=await e.chain.getBlock(t))return n={height:(s=await e.rpc.execute({corba:!0,method:"block.header",params:[n.rhash()]})).height,size:n.getSize(),virtualSize:n.getVirtualSize(),hash:t,time:s.times,txlength:n.txs.length,poolInfo:g(n.txs[0])},6<=s.confirmations&&p.set(t,n),r(n);if(e.chain.options.spv)throw new a(o.MISC_ERROR,"Block not available (spv mode)");if(e.chain.options.prune)throw new a(o.MISC_ERROR,"Block not available (pruned data)");throw new a(o.DATABASE_ERROR,"Can't read block from disk")},t.getAddress=b,t.getBlockOverview=async function(e,t,i){return(e=await y(e,t,i))?{hash:e.hash,version:e.version,confirmations:e.confirmations,height:e.height,chainWork:e.chainwork,prevHash:e.previousblockhash,nextHash:e.nextblockhash,merkleRoot:e.merkleroot,time:e.time,medianTime:null,nonce:e.nonce,bits:e.bits,difficulty:e.difficulty,txids:e.tx}:null},t.getDetailedTransaction=async function(e,t,i=!1){return(t=await e.getMeta(t))?w(e,t,i):null},t.getDetailFromMeta=w,t.transformTransaction=async function(e,t,i){i=i||{};var r=0,s=(0<=t.__height&&(r=e.chain.height-t.__height+1),{txid:t.txid(),version:t.version,locktime:t.locktime});return t.inputs[0].isCoinbase()?(s.isCoinBase=!0,s.vin=[{coinbase:t.inputs[0].script.toJSON(),sequence:t.inputs[0].sequence,n:0}]):(i.inputValues=t.__inputValues,s.vin=t.inputs.map(k.bind(e,i)),s.valueIn=t.inputSatoshis/1e8,s.fees=t.feeSatoshis/1e8),s.vout=t.outputs.map(x.bind(e,i)),s.blockhash=t.blockhash,s.blockheight=t.__height,s.confirmations=r,s.time=t.__timestamp||Math.round(Date.now()/1e3),s.confirmations&&(s.blocktime=s.time),s.valueOut=t.outputSatoshis/1e8,s.size=t.getSize(),(i=await u.FactoryOfContract({env:e.chain.db,tx:t})).data&&(s.clsData=i.data),s},t.transformInput=k,t.transformOutput=x,t._setOutputResults=function(e,t,i,r){for(var s=0;s<t.outputs.length;s++){var n=t.outputs[s];b(n,e.network.type)===i&&(r.txApperances++,r.totalReceivedSat+=n.value,r.balanceSat+=n.value,0===t.confirmations)&&(r.unconfirmedTxApperances++,r.unconfirmedBalanceSat+=n.value)}return r},t._setInputResults=function(e,t,i,r){for(var s=0;s<t.inputs.length;s++)b(t.inputs[s],e.network.type)===i&&(r.totalSentSat+=t.__inputValues[s],r.balanceSat-=t.__inputValues[s],0===t.confirmations)&&(r.unconfirmedBalanceSat-=t.__inputValues[s])},t.utxo=async function(e,t){return(await e.getCoinsByAddress(t)).map(t=>({address:c.fromScript(t.script).toString(),txid:t.hash,vout:t.index,coinbase:t.coinbase,timestamp:0,scriptPubKey:{hex:t.script.toJSON(),asm:t.script.toASM()},amount:h.fromSatoshis(t.value).toBTC(),height:t.height,satoshis:t.value,confirmations:0<t.height?e.chain.height-t.height+1:0}))}},function(e,t,i){"use strict";
|
|
1244
1244
|
/*!
|
|
1245
1245
|
* 配置管理:负责配置文件的读入解析、动态修改、持久化
|
|
1246
1246
|
*/const r=i(0),s=i(34),n=i(59),a=i(2),o=i(143),c=i(29);class h{constructor(e){r("string"==typeof e.module),r(0<e.module.length),this.module=e.module,this.spv=e.spv,this.nodeType=e.nodeType,this.options=Object.create(null),this.data=Object.create(null),this.env=Object.create(null),this.args=Object.create(null),this.argv=[],this.pass=[],this.query=Object.create(null),this.hash=Object.create(null),this.setDefaultValue()}set nodeType(e){switch(this.$nodeType=e){case"spv":this.conf="spv";break;case"wallet":this.conf="wallet";break;default:this.conf="gamegold"}}get nodeType(){return this.$nodeType}changeParams(e){for(var t of Object.keys(e))this[t]=e[t];this.parseConfig(this.content)}save(){n.unsupported||(n.existsSync(this.prefix)||n.mkdirSync(this.prefix),n.writeFileSync(`${this.prefix}/${this.conf}.conf`,this.content,"utf8"))}heapDump(){}async saveAsync(){if(await this.ensure(),!n.unsupported)return n.writeFile(`${this.prefix}/${this.conf}.conf`,this.content,"utf8")}inject(e){for(const i of Object.keys(e)){var t=e[i];switch(i){case"hash":case"query":case"env":case"argv":case"config":continue}this.set(i,t)}}hasValue(e){return void 0!==e&&null!=e}setValidValue(e,t){this.hasValue(t)&&(this[e]=t)}setDefaultValue(){for(var e of(this.network="testnet",this.version="v1.0.0",this.prefix=s.join("./","."+this.module),this.db="leveldb",this.maxFiles=128,this.cacheSize=256,this.workers=!1,this.workersSize=4,this.workersTimeout=1e4,this.logLevel="debug",this.logConsole=!0,this.logFile=!1,this.prune=!1,this.checkpoints=!0,this.coinCache=800,this.entryCache=800,this.indexTx=!0,this.indexAddress=!0,o.types))this[e+"Addresses"]=o[e].genesis.addresses;this.mempoolSize=c.MEMPOOL_MAX_SIZE,this.limitFree=!0,this.limitFreerRelay=15,this.rejectAbsurdFees=!0,this.replaceByFee=!1,this.persistentMempool=!1,this.selfish=!1,this.compact=!0,this.bip37=!0,this.listen=!0,this.maxOutbound=16,this.maxInbound=32,this.abandon=!1,this.bip151=!1,this.bip150=!1,this.identityKey="",this.knownPeers=[],this.alliances=[],this.walletCheckpoints=!1,this.walletLanguage="english",this.walletId="primary",this.contractCheckpoints=!1,this.contractLanguage="english",this.contractId="primary",this.mining=!1,this.coinbaseFlags="mined by gamegold",this.coinbaseAddress="",this.notifyAddress="",this.preverify=!0,this.reservedBlockWeight=4e3,this.reservedBlockSigops=400,this.devMode=!0,this.groupPrefix={sys:[],coin:[],wallet:[],key:[],account:[],address:[]},this.groupSuffix={admin:[]},this.hmacSalt="1111111111111111111111111111111111111111111111111111111111111111",this.hmacConnection=[],this.remotenotify="",this.remotesecret="",this.seeds=[],this.nodes=[],this.only=[],this.host="::",this.port=0,this.httpHost="::",this.httpPort=2102,this.httpRemoteHost="127.0.0.1",this.httpRemotePort=2102,this.proxy="foo:bar@127.0.0.1:9050",this.onion=!1,this.upnp=!1,this.wshost="127.0.0.1",this.publicHost="1.2.3.4",this.publicPort=0,this.wsport=0,this.apiKey="bookmansoft",this.ssl=!1,this.sslCert="@/ssl/server-cert.pem",this.sslKey="@/ssl/server-key.pem",this.stratumHost="127.0.0.1",this.stratumPort=0,this.stratumPublicHost="127.0.0.1",this.stratumPublicPort=0,this.stratumMaxInbound=16,this.stratumDifficulty=0,this.stratumDynamic=!1,this.stratumPassword=""}readConfigValues(){this.network=this.getNetwork(),this.prefix=this.getPrefix(),this.coinbaseAddress=o[this.network].coinbaseAddress,this.setValidValue("version",this.str("version")),this.setValidValue("db",this.str("db")),this.setValidValue("maxFiles",this.uint("max-files")),this.setValidValue("cacheSize",this.uint("cache-size")),this.setValidValue("workers",this.bool("workers")),this.setValidValue("workersSize",this.uint("workers-size")),this.setValidValue("workersTimeout",this.uint("workers-timeout")),this.setValidValue("logLevel",this.str("log-level")),this.setValidValue("logConsole",this.bool("log-console")),this.setValidValue("logFile",this.bool("log-file")),this.setValidValue("prune",this.bool("prune")),this.setValidValue("checkpoints",this.bool("checkpoints")),this.setValidValue("coinCache",this.uint("coin-cache")),this.setValidValue("entryCache",this.uint("entry-cache")),this.setValidValue("indexTx",this.bool("index-tx")),this.setValidValue("indexAddress",this.bool("index-address"));for(const e of o.types)this.setValidValue(e+"Addresses",this.str(e+"-addresses"));var e,t;if(this.setValidValue("selfish",this.bool("selfish")),this.setValidValue("compact",this.bool("compact")),this.setValidValue("bip37",this.bool("bip37")),this.setValidValue("listen",this.bool("listen")),this.setValidValue("maxOutbound",this.uint("max-outbound")),this.setValidValue("maxInbound",this.uint("max-inbound")),this.setValidValue("mempoolSize",this.uint("mempool-size")),this.setValidValue("limitFree",this.bool("limit-free")),this.setValidValue("limitFreerRelay",this.uint("limit-free-relay")),this.setValidValue("rejectAbsurdFees",this.bool("reject-absurd-fees")),this.setValidValue("replaceByFee",this.bool("replace-by-fee")),this.setValidValue("persistentMempool",this.bool("persistent-mempool")),this.setValidValue("abandon",this.bool("abandon")),this.setValidValue("bip151",this.bool("bip151")),this.setValidValue("bip150",this.bool("bip150")),this.setValidValue("identityKey",this.str("identity-key")),this.setValidValue("knownPeers",this.array("known-peers")),this.setValidValue("alliances",this.array("alliances")),this.setValidValue("walletCheckpoints",this.bool("wallet-checkpoints")),this.setValidValue("walletLanguage",this.str("wallet-language")),this.setValidValue("walletId",this.str("wallet-id")),this.setValidValue("contractLanguage",this.str("contract-language")),this.setValidValue("contractId",this.str("contract-id")),this.setValidValue("mining",this.bool("mining")),this.setValidValue("coinbaseFlags",this.str("coinbase-flags")),this.setValidValue("coinbaseAddress",this.str("coinbase-address")),this.setValidValue("notifyAddress",this.str("notify-address")),this.setValidValue("preverify",this.bool("preverify")),this.setValidValue("reservedBlockWeight",this.uint("reserved-block-weight")),this.setValidValue("reservedBlockSigops",this.uint("reserved-block-sigops")),this.setValidValue("hmacSalt",this.str("hmac-salt")),this.setValidValue("hmacConnection",this.array("hmac-connection")),this.setValidValue("remotenotify",this.str("remotenotify")),this.setValidValue("remotesecret",this.str("remotesecret")),this.setValidValue("seeds",this.array("seeds")),this.setValidValue("nodes",this.array("nodes")),this.setValidValue("only",this.array("only")),this.setValidValue("host",this.str("host")),this.setValidValue("port",this.str("port")),this.setValidValue("devMode",this.bool("dev-mode")),this.hasValue(this.array("group-prefix")))for(e of this.array("group-prefix"))this.hasValue(this.array("group-prefix-"+e))?this.groupPrefix[e]=this.array("group-prefix-"+e):this.groupPrefix[e]=[];if(this.hasValue(this.array("group-suffix")))for(t of this.array("group-suffix"))this.hasValue(this.array("group-suffix-"+t))?this.groupSuffix[t]=this.array("group-suffix-"+t):this.groupSuffix[t]=[];this.setValidValue("proxy",this.str("proxy")),this.setValidValue("onion",this.bool("onion")),this.setValidValue("upnp",this.bool("upnp")),this.setValidValue("wshost",this.str("wshost")),this.setValidValue("wsport",this.str("wsport")),this.setValidValue("publicHost",this.str("public-host")),this.setValidValue("publicPort",this.str("public-port")),this.setValidValue("httpHost",this.str("http-host")),this.setValidValue("httpPort",this.str("http-port")),this.setValidValue("httpRemoteHost",this.str("http-remote-host")),this.setValidValue("httpRemotePort",this.str("http-remote-port")),this.setValidValue("apiKey",this.str("api-key")),this.setValidValue("ssl",this.bool("ssl")),this.setValidValue("sslCert",this.str("ssl-cert")),this.setValidValue("sslKey",this.str("ssl-key")),this.setValidValue("stratumHost",this.str("stratum-host")),this.setValidValue("stratumPort",this.uint("stratum-port")),this.setValidValue("stratumMaxInbound",this.uint("stratum-max-inbound")),this.setValidValue("stratumDifficulty",this.uint("stratum-difficulty")),this.setValidValue("stratumDynamic",this.bool("stratum-dynamic")),this.setValidValue("stratumPassword",this.str("stratum-password"))}load(e){e.hash&&this.parseHash(e.hash),e.query&&this.parseQuery(e.query),e.env&&this.parseEnv(e.env),e.argv&&this.parseArg(e.argv),this.readConfigValues()}open(){if(!n.unsupported){var e=this.getFile(this.conf+".conf");let t;try{n.existsSync(e)||this.save(),t=n.readFileSync(e,"utf8")}catch(e){if("ENOENT"===e.code)return;throw e}this.parseConfig(t),this.readConfigValues()}}get content(){return`# config file (${this.prefix}/${this.conf}.conf)\n\n#\n# Options\n#\n\nnetwork: ${this.network}\n\n#\n# Node\n#\n\nversion: ${this.version}\nprefix: ${this.prefix}\ndb: ${this.db}\nmax-files: ${this.maxFiles}\ncache-size: ${this.cacheSize}\n\n#\n# Workers\n#\n\n# true 独立进程验证 false 当前进程内验证(适用于Debug阶段).\nworkers: ${this.workers}\nworkers-size: ${this.workersSize}\nworkers-timeout: ${this.workersTimeout}\n\n#\n# Logger\n#\n\nlog-level: ${this.logLevel}\nlog-console: ${this.logConsole}\nlog-file: ${this.logFile}\n\n#\n# Chain\n#\n\nprune: ${this.prune}\ncheckpoints: ${this.checkpoints}\ncoin-cache: ${this.coinCache}\nentry-cache: ${this.entryCache}\nindex-tx: ${this.indexTx}\nindex-address: ${this.indexAddress}\n# 创世地址\n${o.types.reduce((e,t)=>(e+="\r\n")+t+"-addresses:"+this[t+"Addresses"],"")}\n\n#\n# Mempool\n#\n\nmempool-size: ${this.mempoolSize}\nlimit-free: ${this.limitFree}\nlimit-free-relay: ${this.limitFreerRelay}\nreject-absurd-fees: ${this.rejectAbsurdFees}\nreplace-by-fee: ${this.replaceByFee}\npersistent-mempool: ${this.persistentMempool}\n\n#\n# Pool\n#\n\nselfish: ${this.selfish}\ncompact: ${this.compact}\nbip37: ${this.bip37}\nlisten: ${this.listen}\nmax-outbound: ${this.maxOutbound}\nmax-inbound: ${this.maxInbound}\n\n#\n# BIP151 AuthDB and Identity Key(64位HEX字符串), bip151 是 bip150 的前提\n#\n\nabandon:${this.abandon} \nbip151: ${this.bip151}\nbip150: ${this.bip150}\nidentity-key: ${this.identityKey}\nalliances: ${this.alliances}\nknown-peers: ${this.knownPeers}\n\n#\n# Peer\n#\n\n# Custom list of DNS seeds\nseeds: ${this.seeds}\n# Always try to connect to these nodes.\nnodes: ${this.nodes}\n# Only try to connect to these nodes.\nonly: ${this.only}\n# P2P网络的基础TCP服务 Local Host & Port (to listen on)\nhost: ${this.host}\n\n# \n# Stratum\n#\n\nstratum-host: ${this.stratumHost}\nstratum-max-inbound: ${this.stratumMaxInbound}\nstratum-difficulty: ${this.stratumDifficulty}\nstratum-dynamic: ${this.stratumDynamic}\nstratum-password: ${this.stratumPassword}\n\n#\n# HTTP\n# @note: IP地址配置主要有三种方式\n# 1、:: - 表示自动监听多个网络地址,包括公网IP、localhost,同时支持远程、本地访问 !!!慎重使用\n# 2、Public Ip - 配置为公网IP,只支持远程访问 !!!慎重使用\n# 3、localhost - 只支持本地访问,也可以配置为 127.0.0.1\n#\n\n# Proxy Server (browser=websockets, node=socks)\n# proxy: ${this.proxy}\nonion: ${this.onion}\nupnp: ${this.upnp}\n# 为SPV钱包提供的、基于WS协议的代理服务的地址和端口\nwshost: ${this.wshost}\n\n# Public Host & Port (to advertise to peers)\n# public-host: ${this.publicHost}\n\n# RPC服务器监听地址。全节点必须配置外部地址,才能对外提供RPC服务 !!!一定要慎重并仔细评估对外开放RPC端口的必要性\nhttp-host: ${this.httpHost}\n# RPC服务器监听端口\n# 静态配置的远程全节点地址,在对等网络管理器无法给出合适的远程节点时启用\nhttp-remote-host: ${this.httpRemoteHost}\nhttp-remote-port: ${this.httpRemotePort}\n# 基本校验密码\napi-key: ${this.apiKey}\nssl: ${this.ssl}\nssl-cert: ${this.sslCert}\nssl-key: ${this.sslKey}\n\n#\n# Wallet\n#\n\nwallet-checkpoints: ${this.walletCheckpoints}\nwallet-language: ${this.walletLanguage}\nwallet-id: ${this.walletId}\n\n#\n# Contract\n#\n\ncontract-language: ${this.contractLanguage}\ncontract-id: ${this.contractId}\n\n#\n# Miner\n#\n\n# 自动挖矿\nmining: ${this.mining}\ncoinbase-flags: ${this.coinbaseFlags}\n# 矿工的奖励接收地址\ncoinbase-address: ${this.coinbaseAddress}\n# 创世通告地址\nnotify-address: ${this.notifyAddress}\npreverify: ${this.preverify}\nreserved-block-weight: ${this.reservedBlockWeight}\nreserved-block-sigops: ${this.reservedBlockSigops}\n\n#\n# manage: 设置管理全节点和生产者之间的特约关系\n#\n\n# 用于制备授权节点令牌固定量的链码, 长度64的HEX字符串\nhmac-salt: ${this.hmacSalt}\n# 特约CP编码,支持逗分\nhmac-connection: ${this.hmacConnection.reduce((e,t)=>e+(e?","+t:""+t),"")}\nremotenotify: ${this.remotenotify}\nremotesecret: ${this.remotesecret}\n\n#\n# acl: 访问控制\n#\n\n# 开发模式(跳过部分权限验证)\ndev-mode: ${this.devMode}\n\n# RPC命令前缀访问组, 只有组成员才能访问含有对应前缀的命令\ngroup-prefix: ${Object.keys(this.groupPrefix).reduce((e,t)=>(""!=e&&(e+=","),e+t),"")}\n# RPC命令后缀访问组, 只有组成员才能访问含有对应后缀的命令\ngroup-suffix: ${Object.keys(this.groupSuffix).reduce((e,t)=>(""!=e&&(e+=","),e+t),"")}\n\n# 各访问组成员\n${Object.keys(this.groupPrefix).reduce((e,t)=>(e=e+"\r\n"+`group-prefix-${t}:`)+this.groupPrefix[t].reduce((e,t)=>(""!=e&&(e+=","),e+t),""),"")}\n\n${Object.keys(this.groupSuffix).reduce((e,t)=>(e=e+"\r\n"+`group-suffix-${t}:`)+this.groupSuffix[t].reduce((e,t)=>(""!=e&&(e+=","),e+t),""),"")}\n`}set(e,t){r("string"==typeof e,"Key must be a string."),null!=t&&(e=(e=e.replace(/-/g,"")).toLowerCase(),this.options[e]=t)}has(e){return"number"==typeof e?(r(0<=e,"Index must be positive."),!(e>=this.argv.length)):(r("string"==typeof e,"Key must be a string."),e=(e=e.replace(/-/g,"")).toLowerCase(),null!=this.hash[e]||null!=this.query[e]||null!=this.args[e]||null!=this.env[e]||null!=this.data[e]||null!=this.options[e])}get(e,t){if(void 0===t&&(t=null),Array.isArray(e)){var i=e;for(const e of i){var s=this.get(e);if(null!==s)return s}return t}return"number"==typeof e?(r(0<=e,"Index must be positive."),e>=this.argv.length||null==this.argv[e]?t:this.argv[e]):(r("string"==typeof e,"Key must be a string."),e=(e=e.replace(/-/g,"")).toLowerCase(),null!=this.hash[e]?this.hash[e]:null!=this.query[e]?this.query[e]:null!=this.args[e]?this.args[e]:null!=this.env[e]?this.env[e]:null!=this.data[e]?this.data[e]:null!=this.options[e]?this.options[e]:t)}typeOf(e){return null===(e=this.get(e))?"null":typeof e}str(e,t){var i=this.get(e);if(void 0===t&&(t=null),null===i)return t;if("string"!=typeof i)throw new Error(u(e)+" must be a string.");return i}int(e,t){var i=this.get(e);if(void 0===t&&(t=null),null===i)return t;if("string"!=typeof i){if("number"==typeof i&&Number.isSafeInteger(i))return i}else if(/^\-?\d+$/.test(i)&&(i=parseInt(i,10),Number.isSafeInteger(i)))return i;throw new Error(u(e)+" must be an int.")}uint(e,t){var i=this.int(e);if(void 0===t&&(t=null),null===i)return t;if(i<0)throw new Error(u(e)+" must be a uint.");return i}float(e,t){var i=this.get(e);if(void 0===t&&(t=null),null===i)return t;if("string"!=typeof i){if("number"==typeof i&&isFinite(i))return i}else if(/^\-?\d*(?:\.\d*)?$/.test(i)&&/\d/.test(i)&&(i=parseFloat(i),isFinite(i)))return i;throw new Error(u(e)+" must be a float.")}ufloat(e,t){var i=this.float(e);if(void 0===t&&(t=null),null===i)return t;if(i<0)throw new Error(u(e)+" must be a positive float.");return i}fixed(e,t,i){var r=this.float(e);if(void 0===i&&(i=null),null===r)return i;try{return a.fromFloat(r,t||0)}catch(t){throw new Error(u(e)+" must be a fixed number.")}}ufixed(e,t,i){if(void 0===i&&(i=null),null===(t=this.fixed(e,t)))return i;if(t<0)throw new Error(u(e)+" must be a positive fixed number.");return t}bool(e,t){var i=this.get(e);if(void 0===t&&(t=null),null===i)return t;if("number"==typeof i){if(1===i)return!0;if(0===i)return!1}if("string"!=typeof i){if("boolean"!=typeof i)throw new Error(u(e)+" must be a boolean.");return i}if("true"===i||"1"===i)return!0;if("false"===i||"0"===i)return!1;throw new Error(u(e)+" must be a boolean.")}buf(e,t,i){var r=this.get(e);if(i=i||"hex",void 0===t&&(t=null),null===r)return t;if("string"!=typeof r){if(Buffer.isBuffer(r))return r;throw new Error(u(e)+" must be a buffer.")}if((t=Buffer.from(r,i)).length!==Buffer.byteLength(r,i))throw new Error(u(e)+` must be a ${i} string.`);return t}array(e,t){var i=this.get(e);if(void 0===t&&(t=null),null===i)return t;if("string"!=typeof i){if(Array.isArray(i))return i;throw new Error(u(e)+" must be an array.")}var r=[];for(const e of i.trim().split(/\s*,\s*/))0!==e.length&&r.push(e);return r}obj(e,t){let i=this.get(e);if(void 0===t&&(t=null),null===i)return t;if("object"!=typeof i){if("string"!=typeof i)throw new Error(u(e)+" must be an object.");try{i=JSON.parse(i.replace(/\'/g,'"'))}catch(e){throw e}}return i}func(e,t){var i=this.get(e);if(void 0===t&&(t=null),null===i)return t;if("function"!=typeof i)throw new Error(u(e)+" must be a function.");return i}path(e,t){let i=this.str(e);if(void 0===t&&(t=null),null===i)return t;switch(i[0]){case"~":i=s.join("./",i.substring(1));break;case"@":i=s.join(this.prefix,i.substring(1))}return s.normalize(i)}mb(e,t){return void 0===t&&(t=null),null===(e=this.uint(e))?t:1024*e*1024}getNetwork(){let e=this.str("network");return e=e||"testnet",r(p(e),"Bad network."),e}getPrefix(){let e=this.str("prefix");if(e)return"~"===e[0]?s.join("./",e.substring(1)):e;e=s.join("./","."+this.module);var t=this.str("network");return e=t?(r(p(t),"Bad network."),s.join(e,t)):s.join(e,"testnet"),s.normalize(e)}getFile(e){return this.str("config")||s.join(this.prefix,e)}ensure(){return n.unsupported?Promise.resolve():n.mkdirp(this.prefix)}location(e){return s.join(this.prefix,e)}parseConfig(e){r("string"==typeof e,"Config must be text.");let t=!0,i=!1,s=0;for(const r of(e=(e=(e=(e=65279===e.charCodeAt(0)?e.substring(1):e).replace(/\r\n/g,"\n")).replace(/\r/g,"\n")).replace(/\\\n/g,"")).split("\n")){var n=r.trim();if(s+=1,0!==n.length&&"#"!==n[0]){var a=n.indexOf("="),o=n.indexOf(":");let e=-1;if(-1!==o&&(o<a||-1===a)){if(i&&!t)throw new Error(`Expected '=' on line ${s}: "${n}".`);e=o,i=!0,t=!0}else{if(-1===a)throw o=t?":":"=",new Error(`Expected '${o}' on line ${s}: "${n}".`);if(i&&t)throw new Error(`Expected ':' on line ${s}: "${n}".`);e=a,i=!0,t=!1}let r=n.substring(0,e).trim();if(!f(r=r.replace(/\-/g,"")))throw new Error(`Invalid option on line ${s}: ${r}.`);0!==(o=n.substring(e+1).trim()).length&&((a=h.alias[r])&&(r=a),this.data[r]=o)}}}parseArg(e){e&&"object"==typeof e||(e=process.argv),r(Array.isArray(e));let t=null,i=!1;for(let o=2;o<e.length;o++){var s=e[o];if(r("string"==typeof s),"--"===s)i=!0;else if(i)this.pass.push(s);else if(0===s.length)t=null;else if(0===s.indexOf("--")){var n=s.indexOf("=");let e=null,i=null,r=!1;if(r=-1!==n?(e=s.substring(2,n),i=s.substring(n+1),t=null,!1):(e=s.substring(2),i="true",!(t=null)),!f(e=e.replace(/\-/g,"")))throw new Error(`Invalid argument: --${e}.`);if(0===i.length)continue;1<e.length&&(n=h.alias[e])&&(e=n),this.args[e]=i,r&&(t=e)}else if("-"===s[0]){t=null;for(let e=1;e<s.length;e++){let i=s[e];if((i<"a"||"z"<i)&&(i<"A"||"Z"<i)&&(i<"0"||"9"<i)&&"?"!==i)throw new Error(`Invalid argument: -${i}.`);var a=h.alias[i];a&&(i=a),this.args[i]="true",t=i}}else 0===(n=s).length?t=null:t?(this.args[t]=n,t=null):this.argv.push(n)}}parseEnv(e){let t=this.module;t=(t=t.toUpperCase()).replace(/-/g,"_"),t+="_",e&&"object"==typeof e||(e=process.env),r(e&&"object"==typeof e);for(let n of Object.keys(e)){var i=e[n];r("string"==typeof i),a.startsWith(n,t)&&(n=(n=n.substring(t.length)).replace(/_/g,""),d(s=n))&&!/[a-z]/.test(s)&&0!==i.length&&(1<(n=n.toLowerCase()).length&&(s=h.alias[n])&&(n=s),this.env[n]=i)}var s}parseQuery(e){if("string"!=typeof e){if(!global.location)return{};if("string"!=typeof(e=global.location.search))return{}}return this.parseForm(e,this.query)}parseHash(e){if("string"!=typeof e){if(!global.location)return{};if("string"!=typeof(e=global.location.hash))return{}}return this.parseForm(e,this.hash)}parseForm(e,t){if(r("string"==typeof e),0!==e.length){let r="?";t===this.hash&&(r="#");for(const s of(e=e[0]===r?e.substring(1):e).split("&")){var i=s.indexOf("=");let e,r;r=-1!==i?(e=s.substring(0,i),s.substring(i+1)):(e=s,"true"),f(e=(e=l(e)).replace(/\-/g,""))&&0!==(r=l(r)).length&&(t[e=(i=h.alias[e])||e]=r)}}}}function u(e){return"number"==typeof(e=Array.isArray(e)?e[0]:e)?"Argument #"+e:e}function l(e){try{e=(e=decodeURIComponent(e)).replace(/\+/g," ")}catch(e){}return e.replace(/\0/g,"")}function p(e){return/^[a-z0-9]+$/.test(e)}function d(e){return/^[a-zA-Z0-9]+$/.test(e)}function f(e){return d(e)&&!/[A-Z]/.test(e)}h.alias={seed:"seeds",node:"nodes",n:"network"},e.exports=h},function(e,t,i){"use strict";
|
|
@@ -1690,7 +1690,7 @@ object-assign
|
|
|
1690
1690
|
* vary
|
|
1691
1691
|
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
|
1692
1692
|
* MIT Licensed
|
|
1693
|
-
*/e.exports=function(e,t){if(!e||!e.getHeader||!e.setHeader)throw new TypeError("res argument is required");var i=e.getHeader("Vary")||"";(i=s(Array.isArray(i)?i.join(", "):String(i),t))&&e.setHeader("Vary",i)},e.exports.append=s;var r=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function s(e,t){if("string"!=typeof e)throw new TypeError("header argument is required");if(!t)throw new TypeError("field argument is required");for(var i=Array.isArray(t)?t:n(String(t)),s=0;s<i.length;s++)if(!r.test(i[s]))throw new TypeError("field argument contains an invalid header name");if("*"===e)return e;var a=e,o=n(e.toLowerCase());if(-1!==i.indexOf("*")||-1!==o.indexOf("*"))return"*";for(var c=0;c<i.length;c++){var h=i[c].toLowerCase();-1===o.indexOf(h)&&(o.push(h),a=a?a+", "+i[c]:i[c])}return a}function n(e){for(var t=0,i=[],r=0,s=0,n=e.length;s<n;s++)switch(e.charCodeAt(s)){case 32:r===t&&(r=t=s+1);break;case 44:i.push(e.substring(r,t)),r=t=s+1;break;default:t=s+1}return i.push(e.substring(r,t)),i}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uServer=void 0;var r=i(93);const s=i(664),n=i(762),a=(0,r.default)("engine:uws");class o extends s.BaseServer{init(){}cleanup(){}prepare(e,t){e.method=e.getMethod().toUpperCase();var i=new URLSearchParams(e.getQuery());e._query=Object.fromEntries(i.entries()),e.headers={},e.forEach((t,i)=>{e.headers[t]=i}),e.connection={remoteAddress:Buffer.from(t.getRemoteAddressAsText()).toString()},t.onAborted(()=>{a("response has been aborted")})}createTransport(e,t){return new n.default[e](t)}attach(e,t={}){var i=(t.path||"/engine.io").replace(/\/$/,"")+"/";e.any(i,this.handleRequest.bind(this)).ws(i,{compression:t.compression,idleTimeout:t.idleTimeout,maxBackpressure:t.maxBackpressure,maxPayloadLength:this.opts.maxHttpBufferSize,upgrade:this.handleUpgrade.bind(this),open:e=>{(e.transport.socket=e).transport.writable=!0,e.transport.emit("drain")},message:(e,t,i)=>{e.transport.onData(i?t:Buffer.from(t).toString())},close:(e,t,i)=>{e.transport.onClose(t,i)}})}handleRequest(e,t){a('handling "%s" http request "%s"',t.getMethod(),t.getUrl()),this.prepare(t,e),t.res=e;const i=(i,r)=>{void 0!==i?(this.emit("connection_error",{req:t,code:i,message:s.Server.errorMessages[i],context:r}),this.abortRequest(t.res,i,r)):t._query.sid?(a("setting new request for existing client"),this.clients[t._query.sid].transport.onRequest(t)):this.handshake(t._query.transport,t,(t,i)=>this.abortRequest(e,t,i))};this.corsMiddleware?(t.res=new c(e),this.corsMiddleware.call(null,t,t.res,()=>{this.verify(t,!1,i)})):this.verify(t,!1,i)}handleUpgrade(e,t,i){a("on upgrade"),this.prepare(t,e),t.res=e,this.verify(t,!0,async(r,n)=>{if(r)this.emit("connection_error",{req:t,code:r,message:s.Server.errorMessages[r],context:n}),this.abortRequest(e,r,n);else{let s;if(r=t._query.sid)(n=this.clients[r])?n.upgrading?(a("transport has already been trying to upgrade"),e.close()):n.upgraded?(a("transport had already been upgraded"),e.close()):(a("upgrading existing transport"),s=this.createTransport(t._query.transport,t),n.maybeUpgrade(s)):(a("upgrade attempt for closed client"),e.close());else if(!(s=await this.handshake(t._query.transport,t,(t,i)=>this.abortRequest(e,t,i))))return;e.upgrade({transport:s},t.getHeader("sec-websocket-key"),t.getHeader("sec-websocket-protocol"),t.getHeader("sec-websocket-extensions"),i)}})}abortRequest(e,t,i){var r=t===s.Server.errors.FORBIDDEN?"403 Forbidden":"400 Bad Request";i=i&&i.message?i.message:s.Server.errorMessages[t];e.writeStatus(r),e.writeHeader("Content-Type","application/json"),e.end(JSON.stringify({code:t,message:i}))}}t.uServer=o;class c{constructor(e){this.res=e,this.statusWritten=!1,this.headers=[]}set statusCode(e){this.writeStatus(200===e?"200 OK":"204 No Content")}setHeader(e,t){this.writeHeader(e,t)}getHeader(){}writeStatus(e){this.res.writeStatus(e),this.statusWritten=!0,this.writeBufferedHeaders()}writeHeader(e,t){"Content-Length"!==e&&(this.statusWritten?this.res.writeHeader(e,t):this.headers.push([e,t]))}writeBufferedHeaders(){this.headers.forEach(([e,t])=>{this.res.writeHeader(e,t)})}end(e){this.statusWritten||this.writeBufferedHeaders(),this.res.end(e)}onData(e){this.res.onData(e)}onAborted(e){this.res.onAborted(e)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(763);i=i(764);t.default={polling:r.Polling,websocket:i.WebSocket}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Polling=void 0;var r=i(315),s=i(174);const n=i(623),a=(0,i(93).default)("engine:polling"),o={gzip:s.createGzip,deflate:s.createDeflate};class c extends r.Transport{constructor(e){super(e),this.closeTimeout=3e4}get name(){return"polling"}get supportsFraming(){return!1}onRequest(e){var t=e.res;"get"===e.getMethod()?this.onPollRequest(e,t):"post"===e.getMethod()?this.onDataRequest(e,t):(t.writeStatus("500 Internal Server Error"),t.end())}onPollRequest(e,t){this.req?(a("request overlap"),this.onError("overlap from client"),t.writeStatus("500 Internal Server Error"),t.end()):(a("setting request"),this.req=e,this.res=t,e.cleanup=()=>{this.req=this.res=null},t.onAborted(()=>{this.writable=!1,this.onError("poll connection closed prematurely")}),this.writable=!0,this.emit("drain"),this.writable&&this.shouldClose&&(a("triggering empty send to append close packet"),this.send([{type:"noop"}])))}onDataRequest(e,t){if(this.dataReq)this.onError("data request overlap from client"),t.writeStatus("500 Internal Server Error"),t.end();else{const s=Number(e.headers["content-length"]);if(s)if(s>this.maxHttpBufferSize)this.onError("payload too large"),t.writeStatus("413 Payload Too Large").end();else{if("application/octet-stream"===e.headers["content-type"]&&4===this.protocol)return this.onError("invalid content");this.dataReq=e,this.dataRes=t;let n,a=0;var i,r={"Content-Type":"text/html"};for(i in this.headers(e,r),r)t.writeHeader(i,String(r[i]));const o=e=>{this.onData(e.toString()),this.onDataRequestCleanup(),t.end("ok")};t.onAborted(()=>{this.onDataRequestCleanup(),this.onError("data request connection closed prematurely")}),t.onData((e,i)=>{var r=a+e.byteLength;if(r>s)this.onError("content-length mismatch"),t.close();else{if(!n){if(i)return void o(Buffer.from(e));n=Buffer.allocUnsafe(s)}if(Buffer.from(e).copy(n,a),i)return r!=s?(this.onError("content-length mismatch"),t.writeStatus("400 Content-Length Mismatch").end(),void this.onDataRequestCleanup()):void o(n);a=r}})}else this.onError("content-length header required"),t.writeStatus("411 Length Required").end()}}onDataRequestCleanup(){this.dataReq=this.dataRes=null}onData(e){a('received "%s"',e);var t=e=>{if("close"===e.type)return a("got xhr close packet"),this.onClose(),!1;this.onPacket(e)};3===this.protocol?this.parser.decodePayload(e,t):this.parser.decodePayload(e).forEach(t)}onClose(){this.writable&&this.send([{type:"noop"}]),super.onClose()}send(e){this.writable=!1,this.shouldClose&&(a("appending close packet to payload"),e.push({type:"close"}),this.shouldClose(),this.shouldClose=null);var t=t=>{var i=e.some(e=>e.options&&e.options.compress);this.write(t,{compress:i})};3===this.protocol?this.parser.encodePayload(e,this.supportsBinary,t):this.parser.encodePayload(e,t)}write(e,t){a('writing "%s"',e),this.doWrite(e,t,()=>{this.req.cleanup()})}doWrite(e,t,i){var r="string"==typeof e;const s={"Content-Type":r?"text/plain; charset=UTF-8":"application/octet-stream"},a=e=>{this.headers(this.req,s),Object.keys(s).forEach(e=>{this.res.writeHeader(e,String(s[e]))}),this.res.end(e),i()};if(this.httpCompression&&t.compress)if((r?Buffer.byteLength(e):e.length)<this.httpCompression.threshold)a(e);else{const t=n(this.req).encodings(["gzip","deflate"]);t?this.compress(e,t,(e,r)=>{e?(this.res.writeStatus("500 Internal Server Error"),this.res.end(),i(e)):(s["Content-Encoding"]=t,a(r))}):a(e)}else a(e)}compress(e,t,i){a("compressing");const r=[];let s=0;o[t](this.httpCompression).on("error",i).on("data",(function(e){r.push(e),s+=e.length})).on("end",(function(){i(null,Buffer.concat(r,s))})).end(e)}doClose(e){let t;a("closing");var i=()=>{clearTimeout(t),e(),this.onClose()};this.writable?(a("transport writable - closing right away"),this.send([{type:"close"}]),i()):this.discarded?(a("transport discarded - closing right away"),i()):(a("transport not writable - buffering orderly close"),this.shouldClose=i,t=setTimeout(i,this.closeTimeout))}headers(e,t){t=t||{};var i=e.headers["user-agent"];return i&&(~i.indexOf(";MSIE")||~i.indexOf("Trident/"))&&(t["X-XSS-Protection"]="0"),this.emit("headers",t,e),t}}t.Polling=c},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocket=void 0;var r=i(315);const s=(0,i(93).default)("engine:ws");class n extends r.Transport{constructor(e){super(e),this.writable=!1,this.perMessageDeflate=null}get name(){return"websocket"}get handlesUpgrades(){return!0}get supportsFraming(){return!0}send(e){var t,i=e.shift();void 0===i?(this.writable=!0,this.emit("drain")):(i.options&&i.options.compress,t=t=>{var i="string"!=typeof t,r=this.perMessageDeflate&&Buffer.byteLength(t)>this.perMessageDeflate.threshold;s('writing "%s"',t),this.writable=!1,this.socket.send(t,i,r),this.send(e)},i.options&&"string"==typeof i.options.wsPreEncoded?t(i.options.wsPreEncoded):this.parser.encodePacket(i,this.supportsBinary,t))}doClose(e){s("closing"),e&&e(),this.socket.close()}}t.WebSocket=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Client=void 0;const r=i(53);var s=i(93);const n=i(43),a=s("socket.io:client");t.Client=class{constructor(e,t){this.sockets=new Map,this.nsps=new Map,this.server=e,this.conn=t,this.encoder=e.encoder,this.decoder=new e._parser.Decoder,this.id=t.id,this.setup()}get request(){return this.conn.request}setup(){this.onclose=this.onclose.bind(this),this.ondata=this.ondata.bind(this),this.onerror=this.onerror.bind(this),this.ondecoded=this.ondecoded.bind(this),this.decoder.on("decoded",this.ondecoded),this.conn.on("data",this.ondata),this.conn.on("error",this.onerror),this.conn.on("close",this.onclose),this.connectTimeout=setTimeout(()=>{0===this.nsps.size?(a("no namespace joined yet, close the client"),this.close()):a("the client has already joined a namespace, nothing to do")},this.server._connectTimeout)}connect(e,t={}){if(this.server._nsps.has(e))return a("connecting to namespace %s",e),this.doConnect(e,t);this.server._checkNamespace(e,t,i=>{i?this.doConnect(e,t):(a("creation of namespace %s was denied",e),this._packet({type:r.PacketType.CONNECT_ERROR,nsp:e,data:{message:"Invalid namespace"}}))})}doConnect(e,t){const i=this.server.of(e),r=i._add(this,t,()=>{this.sockets.set(r.id,r),this.nsps.set(i.name,r),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0)})}_disconnect(){for(const e of this.sockets.values())e.disconnect();this.sockets.clear(),this.close()}_remove(e){var t;this.sockets.has(e.id)?(t=this.sockets.get(e.id).nsp.name,this.sockets.delete(e.id),this.nsps.delete(t)):a("ignoring remove for %s",e.id)}close(){"open"===this.conn.readyState&&(a("forcing transport close"),this.conn.close(),this.onclose("forced server close"))}_packet(e,t={}){"open"!==this.conn.readyState?a("ignoring packet write %j",e):(e=t.preEncoded?e:this.encoder.encode(e),this.writeToEngine(e,t))}writeToEngine(e,t){if(t.volatile&&!this.conn.transport.writable)a("volatile packet is discarded since the transport is not currently writable");else for(const i of Array.isArray(e)?e:[e])this.conn.write(i,t)}ondata(e){try{this.decoder.add(e)}catch(e){a("invalid packet format"),this.onerror(e)}}ondecoded(e){let t,i;var s;i=3===this.conn.protocol?(t=(s=n.parse(e.nsp,!0)).pathname,s.query):(t=e.nsp,e.data);const o=this.nsps.get(t);o||e.type!==r.PacketType.CONNECT?o&&e.type!==r.PacketType.CONNECT&&e.type!==r.PacketType.CONNECT_ERROR?process.nextTick((function(){o._onpacket(e)})):(a("invalid state (packet type: %s)",e.type),this.close()):this.connect(t,i)}onerror(e){for(const t of this.sockets.values())t._onerror(e);this.conn.close()}onclose(e){a("client close with reason %s",e),this.destroy();for(const t of this.sockets.values())t._onclose(e);this.sockets.clear(),this.decoder.destroy()}destroy(){this.conn.removeListener("data",this.ondata),this.conn.removeListener("error",this.onerror),this.conn.removeListener("close",this.onclose),this.decoder.removeListener("decoded",this.ondecoded),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParentNamespace=void 0;const r=i(674);class s extends r.Namespace{constructor(e){super(e,"/_"+s.count++),this.children=new Set}_initAdapter(){this.adapter={broadcast:(e,t)=>{this.children.forEach(i=>{i.adapter.broadcast(e,t)})}}}emit(e,...t){return this.children.forEach(i=>{i.emit(e,...t)}),!0}createChild(e){const t=new r.Namespace(this.server,e);return t._fns=this._fns.slice(0),this.listeners("connect").forEach(e=>t.on("connect",e)),this.listeners("connection").forEach(e=>t.on("connection",e)),this.children.add(t),this.server._nsps.set(e,t),t}fetchSockets(){throw new Error("fetchSockets() is not supported on parent namespaces")}}(t.ParentNamespace=s).count=0},function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.serveFile=t.restoreAdapter=t.patchAdapter=void 0;const s=i(676),n=i(88),a=(0,r(i(93)).default)("socket.io:adapter-uws"),{addAll:o,del:c,broadcast:h}=s.Adapter.prototype;function u(e,t,i,r){const s=t.conn.id,n=t.conn.transport.socket;i&&(a("subscribe connection %s to topic %s",s,e),n.subscribe(e)),r.forEach(t=>{a("subscribe connection %s to topic %s",s,t=e+""+t),n.subscribe(t)})}t.patchAdapter=function(e){s.Adapter.prototype.addAll=function(e,t){const i=!this.sids.has(e),r=(o.call(this,e,t),this.nsp.sockets.get(e));r&&("websocket"===r.conn.transport.name?u(this.nsp.name,r,i,t):i&&r.conn.on("upgrade",()=>{var t=this.sids.get(e);t&&u(this.nsp.name,r,i,t)}))},s.Adapter.prototype.del=function(e,t){var i;c.call(this,e,t),(e=this.nsp.sockets.get(e))&&"websocket"===e.conn.transport.name&&(i=e.conn.id,e=e.conn.transport.socket,t=this.nsp.name+""+t,a("unsubscribe connection %s from topic %s",i,t),e.unsubscribe(t))},s.Adapter.prototype.broadcast=function(t,i){if(i.rooms.size<=1&&0===i.except.size){var r=i.flags||{};const s={preEncoded:!0,volatile:r.volatile,compress:r.compress},n=(t.nsp=this.nsp.name,this.encoder.encode(t)),o=0===i.rooms.size?this.nsp.name:this.nsp.name+""+i.rooms.keys().next().value;a("fast publish to %s",o),n.forEach(t=>{var i="string"!=typeof t;e.publish(o,i?t:"4"+t,i)}),this.apply(i,e=>{"websocket"!==e.conn.transport.name&&e.client.writeToEngine(n,s)})}else h.call(this,t,i)}},t.restoreAdapter=function(){s.Adapter.prototype.addAll=o,s.Adapter.prototype.del=c,s.Adapter.prototype.broadcast=h};t.serveFile=function(e,t){const i=(0,n.statSync)(t).size,r=(0,n.createReadStream)(t),s=()=>!r.destroyed&&r.destroy();e.onAborted(s),r.on("data",t=>{const s=(e=>{var{buffer:e,byteOffset:t,byteLength:i}=e;return e.slice(t,t+i)})(t),n=e.getWriteOffset();var[t,a]=e.tryEnd(s,i);a||t||(r.pause(),e.onWritable(t=>{var[t,a]=e.tryEnd(s.slice(t-n),i);return!a&&t&&r.resume(),t}))}).on("error",e=>{throw s(),e}).on("end",s)}},function(e){e.exports=JSON.parse('{"name":"socket.io","version":"4.5.4","description":"node.js realtime framework server","keywords":["realtime","framework","websocket","tcp","events","socket","io"],"files":["dist/","client-dist/","wrapper.mjs","!**/*.tsbuildinfo"],"directories":{"doc":"docs/","example":"example/","lib":"lib/","test":"test/"},"type":"commonjs","main":"./dist/index.js","exports":{"import":"./wrapper.mjs","require":"./dist/index.js","types":"./dist/index.d.ts"},"types":"./dist/index.d.ts","license":"MIT","repository":{"type":"git","url":"git://github.com/socketio/socket.io"},"scripts":{"compile":"rimraf ./dist && tsc","test":"npm run format:check && npm run compile && npm run test:types && npm run test:unit","test:types":"tsd","test:unit":"nyc mocha --require ts-node/register --reporter spec --slow 200 --bail --timeout 10000 test/index.ts","format:check":"prettier --check \\"lib/**/*.ts\\" \\"test/**/*.ts\\"","format:fix":"prettier --write \\"lib/**/*.ts\\" \\"test/**/*.ts\\"","prepack":"npm run compile"},"dependencies":{"accepts":"~1.3.4","base64id":"~2.0.0","debug":"~4.3.2","engine.io":"~6.2.1","socket.io-adapter":"~2.4.0","socket.io-parser":"~4.2.1"},"devDependencies":{"@types/mocha":"^9.0.0","expect.js":"0.3.1","mocha":"^10.0.0","nyc":"^15.1.0","prettier":"^2.3.2","rimraf":"^3.0.2","socket.io-client":"4.5.4","socket.io-client-v2":"npm:socket.io-client@^2.4.0","superagent":"^8.0.0","supertest":"^6.1.6","ts-node":"^10.2.1","tsd":"^0.21.0","typescript":"^4.4.2","uWebSockets.js":"github:uNetworking/uWebSockets.js#v20.0.0"},"contributors":[{"name":"Guillermo Rauch","email":"rauchg@gmail.com"},{"name":"Arnout Kazemier","email":"info@3rd-eden.com"},{"name":"Vladimir Dronnikov","email":"dronnikov@gmail.com"},{"name":"Einar Otto Stangvik","email":"einaros@gmail.com"}],"engines":{"node":">=10.0.0"},"tsd":{"directory":"test"}}')},function(e,t,i){const r=i(0);e.exports=class{constructor(e){this.keyLimit=100,this.bodyLimit=20<<20,this.contentType=null,this.timeout=1e4,e&&this.fromOptions(e)}fromOptions(e){return r(e),null!=e.keyLimit&&(r("number"==typeof e.keyLimit),this.keyLimit=e.keyLimit),null!=e.bodyLimit&&(r("number"==typeof e.bodyLimit),this.bodyLimit=e.bodyLimit),null!=e.contentType&&(r("string"==typeof e.contentType),this.contentType=e.contentType),this}}},function(e,t,i){const r=i(679),s=i(625).StringDecoder;e.exports=async function(e,t){let i=Object.create(null);if("GET"!==e.method){let h=e.contentType;if("bin"!==(h=t.contentType?t.contentType:h)){var n=await(a=e,o="utf8",c=t,new Promise((e,t)=>{{var i=a,r=c,n=e,h=t;const u=new s(o);let l=!1,p=0,d="";const f=()=>{i.removeListener("data",m),i.removeListener("error",g),i.removeListener("end",y),null!=v&&(v=null,clearTimeout(v))},m=e=>{p+=e.length,l=!0,p>r.bodyLimit?h(new Error("Request body overflow.")):d+=u.write(e)},g=e=>{f(),h(e)},y=()=>{f(),n(l?d:null)};let v=setTimeout(()=>{v=null,f(),h(new Error("Request body timed out."))},r.timeout);i.on("data",m),i.on("error",g),i.on("end",y)}}));if(n)switch(h){case"json":if(!(i=JSON.parse(n))||"object"!=typeof i||Array.isArray(i))throw new Error("JSON body must be an object.");break;case"form":i=r.parsePairs(n,t.keyLimit)}}}var a,o,c;return i}},function(e,t,i){const{generateKey:r,verifyObj:s}=i(72),n=i(67),a=i(6);e.exports=class{constructor(e){this.wdb=e}async call(e,t,i){try{var o,c=t.body.sig,h=n.getHmac(t.options.cid||"",this.wdb.keys.hmacSalt).token,u=r(a.hash256(Buffer.from(h)));if(!this.wdb.options.devMode&&!s({method:t.body.method,params:t.body.params,cid:t.body.cid,wid:t.body.wid},c,u.public))return o={result:null,code:404,error:{type:"HmacError",message:"Verify Error"}},i.send(404,o,"json"),{interrupt:!0,result:null};if(!(t.options.auth&&t.options.authWid==t.options.wid||(this.wdb.options.devMode||await this.wdb.auth(t.options.cid,t.options.token),t.body.method&&"wallet.create"===t.body.method))){var l=await this.wdb.get(t.options.wid);if(!l)return i.send(404,{result:null,code:404,error:{type:"HmacError",message:"Not Found Wallet"}},"json"),{interrupt:!0,result:null};this.wdb.logger.info("Successful auth for %s on %s.",t.options.cid,t.options.wid),t.options.auth=!0,t.options.authWid=t.options.wid,t.wallet=l}return{interrupt:!1}}catch(e){return this.wdb.logger.info("Auth failure for %s on %s: %s.",t.options.cid,t.options.wid,e.message),i.send(403,{result:null,code:403,error:{type:"HmacError",message:"Hmac Auth failure."}},"json"),{interrupt:!0,result:null}}}}},function(e,t){e.exports=class{async call(e,t,i){return e.node.config.devMode||e.node.acl.canAccess(t.body.method,t.options.cid)?{interrupt:!1}:(i.send(407,{result:null,code:407,error:{type:"ACLError",message:"TerminalNo Authentication Required."}},"json"),{interrupt:!0,result:null})}}},function(e,t){e.exports=class{constructor(e,t){this.routes=e,this.openapi=t}async call(e,t,i){switch(t.options.mode){case"web":if(0===t.pathname.indexOf("/public/")){var r=this.routes.getHandlers(t.method);if(!r)return{interrupt:!0,result:null};for(const n of r){var s=n.match(t.pathname);if(s){t.params=s;try{return{interrupt:!0,result:{code:0,error:null,result:await n.call(t,i)}}}catch(e){i.error(500,e)}return{interrupt:!0,result:null}}}}else if(r=this.openapi[t.body.method]){try{return{interrupt:!0,result:{code:0,error:null,result:await e.node.conn_s2local.execute(r.name,t.body.params,t)}}}catch(e){i.error(500,e)}return{interrupt:!0,result:null}}break;case"ws":if(r=this.openapi[t.body.method])return{interrupt:!0,result:{code:0,error:null,result:await e.node.conn_s2local.execute(r.name,t.body.params,t)}}}return{interrupt:!1}}}},function(e,t,i){const r=i(0),s=i(2),n=i(6),a=i(158);e.exports=class{constructor(e){r(e,"Basic auth requires options."),this.user=e.username,this.pass=e.password,this.realm=e.realm,null!=this.user&&(r("string"==typeof this.user),r(this.user.length<=255,"Username too long."),r(s.isAscii(this.user),"Username must be ASCII."),this.user=n.hash256(Buffer.from(this.user,"ascii"))),r("string"==typeof this.pass),r(this.pass.length<=255,"Password too long."),r(s.isAscii(this.pass),"Password must be ASCII."),this.pass=n.hash256(Buffer.from(this.pass,"ascii")),this.realm||(this.realm="server"),r("string"==typeof this.realm)}fail(e){e.setHeader("WWW-Authenticate",`Basic realm="${this.realm}"`),e.send(401,{result:null,code:401,error:{type:"AuthError",message:"Unauthorized."}},"json"),e.end()}async call(e,t,i){if(!e.node.config.devMode&&!t.options.auth){if(this.user){if(255<t.options.user.username.length)return this.fail(i),{interrupt:!0,result:null};const e=Buffer.from(t.options.user.username,"ascii"),r=n.hash256(e);if(!a(r,this.user))return this.fail(i),{interrupt:!0,result:null}}if(!t.options.user||!t.options.user.password||255<t.options.user.password.length)return this.fail(i),{interrupt:!0,result:null};const e=Buffer.from(t.options.user.password,"ascii"),r=n.hash256(e);if(!a(r,this.pass))return this.fail(i),{interrupt:!0,result:null};t.options.auth=!0}return{interrupt:!1}}}},function(e,t,i){const r=i(2),s=i(77),n=i(78).errors,a=i(80),o=i(121),{getBlockOverview:c,getBlockByHash:h,formatTimestamp:u}=i(626);async function l(e,t){if(e.valid(),!(e=await this.chain.tip))throw new s(n.MISC_ERROR,"Block not found");if(e=await h(this.node,e.hash,t))return e.chain="VNS",e.network="main"===this.node.network.type?"mainnet":"testnet",e}e.exports=[{name:"blocks",method:"get",path:"/public/block",callback:async function(e,t){var i,r=this,s=(e=e.valid()).str("blockDate"),n=e.str("startTimestamp",""),a=(e=e.uint("limit",10),u(new Date));if(s){if(!/\d{4}-\d{2}-\d{2}/.test(s))throw new Error("Please use yyyy-mm-dd format");i=s===a}else s=a,i=!0;a=Math.round(new Date(s).getTime()/1e3),n=parseInt(n)||a+86400;var o=u(new Date(1e3*(a-86400))),c=n?u(new Date(1e3*n)):null,l=(e=parseInt(e||200),!1),p=n;try{var d,f=await r.chain.db.getTimestampHashes(n,a);let u=[];for(d of f)u.push(d.hash);u.reverse(),u.length>e&&(l=!0,u=u.slice(0,e));var m,g={blocks:[],length:u.length,pagination:{next:c,prev:o,currentTs:n-1,current:s,isToday:i,more:l,moreTs:l?p:void 0}};for(m of u){var y=await h(r,m,t);y.chain="VNS",y.network="main"===r.node.network.type?"mainnet":"testnet",g.blocks.push(y)}return g.blocks.sort((e,t)=>t.height-e.height),g.blocks}catch(e){throw e}}},{name:"block-tip",method:"get",path:"/public/block/tip",callback:l},{name:"blocks",method:"get",path:"/public/blocks",callback:async function(e,t){var i,r=(e=e.valid()).str("blockDate"),s=e.str("startTimestamp",""),n=(e=e.uint("limit",10),u(new Date));if(r){if(!/\d{4}-\d{2}-\d{2}/.test(r))throw new Error("Please use yyyy-mm-dd format");i=r===n}else r=n,i=!0;n=Math.round(new Date(r).getTime()/1e3),s=parseInt(s)||n+86400;var a=u(new Date(1e3*(n-86400))),o=s?u(new Date(1e3*s)):null,c=(e=parseInt(e||200),!1),l=s;try{var p,d=await this.chain.db.getTimestampHashes(s,n);let u=[];for(p of d)u.push(p.hash);u.reverse(),u.length>e&&(c=!0,u=u.slice(0,e));var f,m={blocks:[],length:u.length,pagination:{next:o,prev:a,currentTs:s-1,current:r,isToday:i,more:c,moreTs:c?l:void 0}};for(f of u){var g=await h(this,f,t);m.blocks.push(g)}return m.blocks.sort((e,t)=>t.height-e.height),m}catch(e){throw e}}},{name:"block-index",method:"get",path:"/public/block-index/:height",callback:async function(e,t){var i=this;if(-1===(e=(e=e.valid()).uint("height")))throw new s(n.TYPE_ERROR,"Invalid block height.");if(!(e=await i.chain.getEntry(e)))throw new s(n.MISC_ERROR,"Block not found");if(i=await h(i.node,e.hash,t))return i}},{name:"block-tip",method:"get",path:"/public/block-tip",callback:l},{name:"block",method:"get",path:"/public/block/:blockHash",callback:async function(e,t){if(e=(e=e.valid()).str("blockHash"),e=await h(this.node,e,t))return e.chain="VNS",e.network="main"===this.node.network.type?"mainnet":"testnet",e}},{name:"getBlock",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new a([t])).str(0),h(e,t)}},{name:"rawblock",method:"get",path:"/public/rawblock/:param",callback:async function(e,t){var i=this;let a=(e=e.valid()).str("param");if(a=r.checkNum(a)?parseInt(a):r.revHex(a),e=await i.chain.getBlock(a))return e.toRaw().toString("hex");if(i.chain.options.spv)throw new s(n.MISC_ERROR,"Block not available (spv mode)");if(i.chain.options.prune)throw new s(n.MISC_ERROR,"Block not available (pruned data)");throw new s(n.DATABASE_ERROR,"Can't read block from disk")}},{name:"getRawBlock",method:"jsonp",path:"/",callback:async function(e,t){let i=(t=new a([t])).str(0);return r.checkNum(i)&&(i=parseInt(i)),(t=await e.chain.getBlock(i))?t.toRaw().toString("hex"):null}},{name:"isSynced",method:"jsonp",path:"/",callback:async function(e,t){return e.chain.synced}},{name:"getBlockOverview",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new a([t])).str(0),c(e,t)}},{name:"getInfo",method:"jsonp",path:"/",callback:async function(e,t){var i=await e.rpc.execute({corba:!0,method:"miner.difficulty"});return{blocks:e.chain.height,connections:e.pool.peers.size(),timeoffset:0,proxy:"",testnet:"main"!==e.network.type,errors:"",network:e.network.type,relayFee:0,version:"bitcore-1.1.2",protocolversion:700001,difficulty:i}}},{name:"getBestHeight",method:"jsonp",path:"/",callback:async function(e,t){return e.chain.height}},{name:"getBlockHeader",method:"jsonp",path:"/",callback:async function(e,t){var i=(t=new a([t])).hash(0);t=t.bool(1,!0);if(!i)throw new s(n.MISC_ERROR,"Invalid block hash.");if(!(i=await e.chain.getEntry(i)))throw new s(n.MISC_ERROR,"Block not found");if(!t)return i.toRaw().toString("hex",0,80);t=await e.chain.getMedianTime(i);var c=await e.chain.getNextHash(i.hash);return{hash:i.rhash(),confirmations:e.chain.height-i.height+1,height:i.height,version:i.version,versionHex:r.hex32(i.version),merkleroot:r.revHex(i.merkleRoot),time:i.time,mediantime:t,bits:i.bits,difficulty:o.bits2Diff(i.bits),chainwork:i.chainwork.toString("hex",64),previousblockhash:i.prevBlock!==encoding.NULL_HASH?r.revHex(i.prevBlock):null,nextblockhash:c?r.revHex(c):null}}}]},function(e){e.exports=JSON.parse('[{"poolName":"50BTC","url":"https://50btc.com/","searchStrings":["50BTC.com","50btc.com"]},{"poolName":"175btc","url":"http://www.175btc.com/","searchStrings":["Mined By 175btc.com"]},{"poolName":"ASICminer","url":"https://bitcointalk.org/index.php?topic=99497.0","searchStrings":["Mined By ASICMiner"]},{"poolName":"AntMiner","url":"https://bitmaintech.com/","searchStrings":["AntPool"]},{"poolName":"agentD","url":"http://","searchStrings":["agentD"]},{"poolName":"Bitfury","url":"http://bitfury.org/","searchStrings":["2av0id51pct"]},{"poolName":"BitMinter","url":"https://bitminter.com/","searchStrings":["BitMinter"]},{"poolName":"Bitparking","url":"http://bitparking.com/","searchStrings":["bitparking"]},{"poolName":"BTC Guild","url":"https://www.btcguild.com/","searchStrings":["Mined by BTC Guild","BTC Guild"]},{"poolName":"bcpool.io","url":"https://bcpool.io/","searchStrings":["bcpool"]},{"poolName":"Discus Fish","url":"http://f2pool.com/","searchStrings":["七彩神仙鱼","Made in China","Mined by user"]},{"poolName":"Discus Fish Solo","url":"http://f2pool.com/","searchStrings":["For Pierce and Paul"]},{"poolName":"Cointerra","url":"http://cointerra.com/","searchStrings":["cointerra"]},{"poolName":"Eligius","url":"http://eligius.st/","searchStrings":["Eligius"]},{"poolName":"EclipseMC","url":"https://eclipsemc.com/","searchStrings":["Josh Zerlan was here!","EclipseMC","Aluminum Falcon"]},{"poolName":"GIVE-ME-COINS","url":"https://give-me-coins.com/","searchStrings":["Mined at GIVE-ME-COINS.com"]},{"poolName":"ghash.io","url":"https://ghash.io/","searchStrings":["ghash.io","GHash.IO"]},{"poolName":"HHTT","url":"http://hhtt.1209k.com/","searchStrings":["HHTT"]},{"poolName":"KNCminer","url":"https://www.kncminer.com/","searchStrings":["KnCMiner"]},{"poolName":"Megabigpower","url":"http://megabigpower.com/","searchStrings":["megabigpower.com"]},{"poolName":"MultiCoin","url":"https://multicoin.co/","searchStrings":["MultiCoin.co"]},{"poolName":"Mt Red","url":"https://mtred.com/","searchStrings":["/mtred/"]},{"poolName":"MaxBTC","url":"https://www.maxbtc.com","searchStrings":["MaxBTC"]},{"poolName":"NMCbit","url":"http://nmcbit.com/","searchStrings":["nmcbit.com"]},{"poolName":"ozcoin","url":"https://ozco.in/","searchStrings":["ozco.in","ozcoin"]},{"poolName":"Polmine.pl","url":"https://polmine.pl","searchStrings":["by polmine.pl"]},{"poolName":"simplecoin","url":"http://simplecoin.us/","searchStrings":["simplecoin.us ftw"]},{"poolName":"SlushPool","url":"https://slushpool.com/","searchStrings":["/slush/"]},{"poolName":"TripleMining","url":"https://www.triplemining.com/","searchStrings":["Triplemining.com"]},{"poolName":"wizkid057","url":"http://wizkid057.com/btc","searchStrings":["wizkid057"]},{"poolName":"Yourbtc.net","url":"http://yourbtc.net/","searchStrings":["yourbtc.net"]},{"poolName":"BTCChina Pool","url":"https://pool.btcchina.com/","searchStrings":["BTCChina Pool","btcchina.com"]},{"poolName":"BTCC Pool","url":"https://pool.btcc.com/","searchStrings":["/BTCC/"]}]')},function(e,t,i){const{utxo:r,_setOutputResults:s,_setInputResults:n,transformTransaction:a,getDetailFromMeta:o,translateOutputAddress:c}=i(626),h=i(33),u=i(80),l=i(2);async function p(e,t){var i=(t=new u([t])).array(0,[]),r=t.obj(1,{}),s=(r.from=r.from||0,r.to=r.to||4294967295,[]);t=await e.getMetaByAddress(i);let n=0;for(const i of t){if(n<r.from);else{if(n>=r.to)break;var a=await o(e,i);s.push(a)}n++}return{totalCount:t.length,items:s}}async function d(e,t){let i=(r=e.valid()).str("addr");i=i||r.str("addrs");var r,s=((r={from:parseInt(e.query.from)||parseInt(e.body.from)||0}).to=parseInt(e.query.to)||parseInt(e.body.to)||parseInt(r.from)+10,e=e,{noAsm:!!parseInt(e.query.noAsm),noScriptSig:!!parseInt(e.query.noScriptSig),noSpent:!!parseInt(e.query.noSpent)});try{var n,c=await this.node.getMetaByAddress(i.split(",")),h=[];for(n of c){var u=await o(this.node,n);h.push(await a(this.node,u,s))}return{totalItems:c.length,from:r.from,to:Math.min(r.to,c.length),items:h}}catch(e){throw e}}async function f(e,t){var i=e.valid();let s=i.str("addr");s=s||i.str("addrs"),e.query.from&&e.query.to&&(parseInt(e.query.from),parseInt(e.query.to));try{var n,a=[];for(n of await r(this.node,s.split(",")))a.push(function(e,t){var i={address:c(t.address),txid:l.revHex(t.txid),vout:t.vout,scriptPubKey:t.scriptPubKey,amount:t.satoshis/1e8,satoshis:t.satoshis};return t.height&&0<t.height?(i.height=t.height,i.confirmations=e.chain.height-t.height+1):i.confirmations=0,t.timestamp&&(i.ts=t.timestamp),i.chain="VNS",i.network="main"===e.node.network.type?"mainnet":"testnet",i.coinbase=t.coinbase,i.mintTxid=i.txid,i.value=i.satoshis,i.mintIndex=i.vout,i.mintHeight=i.height,i.spentTxid="",i.spentHeight=-2,i.script=i.scriptPubKey,i}(this,n));return a}catch(e){throw e}}async function m(e,t){var i=(e=e.valid()).str("id"),r=(e=e.uint("index",1),this.node.require("walletdb"));if(r&&(r=await r.get("primary"),await r.ensureAccount({name:i,witness:!0}),r=await r.createReceive(i,e)))return r.toJSON().address}async function g(e,t,i){i=i||{};var r={totalCount:0,items:[]};let a=0;for(const s of await e.node.getMetaByAddress(t)){if(i.from&&a<i.from);else{if(i.to&&a>=i.to)break;var u=await o(e.node,s);r.items.push(u)}a++}r.totalCount=r.items.length;for(var p={addrStr:t,balance:0,balanceSat:0,totalReceived:0,totalReceivedSat:0,totalSent:0,totalSentSat:0,unconfirmedBalance:0,unconfirmedBalanceSat:0,unconfirmedTxApperances:0,txApperances:0},d=0;d<r.items.length;d++){var f=r.items[d];s(e,f,t,p),n(e,f,t,p),i.noTxList||(p.transactions||(p.transactions=[]),p.transactions.push(l.revHex(f.txid())))}return p.balance=h.fromSatoshis(p.balanceSat).toBTC(),p.totalReceived=h.fromSatoshis(p.totalReceivedSat).toBTC(),p.totalSent=h.fromSatoshis(p.totalSentSat).toBTC(),p.unconfirmedBalance=h.fromSatoshis(p.unconfirmedBalanceSat).toBTC(),p.addrStr&&(p.addrStr=c(p.addrStr)),p}e.exports=[{name:"address.reflect",method:"get",path:"/public/addr/reflect/:id",callback:m},{name:"address.reflect.index",method:"get",path:"/public/addr/reflect/:id/:index",callback:m},{name:"getInfo",method:"get",path:"/public/addr/:addr",callback:async function(e,t){var i=(i=e.valid()).str("addr"),r={noTxList:parseInt(e.query.noTxList)};e.query.from&&e.query.to?(r.from=parseInt(e.query.from),r.to=parseInt(e.query.to)):(r.from=0,r.to=10);try{return await g(this,i,r)}catch(e){throw e}}},{name:"getUTXOByAddress",method:"get",path:"/public/addr/:addr/utxo",callback:f},{name:"getUTXOByAddress",method:"get",path:"/public/address/:addr/txs",callback:f},{name:"getUTXOByAddresses",method:"get",path:"/public/addrs/:addr/utxo",callback:f},{name:"postUTXOByAddresses",method:"post",path:"/public/addrs/utxo",callback:f},{name:"getTXSByAddresses",method:"get",path:"/public/addrs/:addrs/txs",callback:d},{name:"postTXSByAddresses",method:"post",path:"/public/addrs/txs",callback:d},{name:"getBalanceByAddress",method:"get",path:"/public/addr/:addr/balance",callback:async function(e,t){var i=this;let r=(e=e.valid()).str("addr");r=r||e.str("addrs"),e=await i.node.getCoinsByAddress(r.split(","));var s=(i=e.reduce((e,t)=>e+t.value,0))-(e=e.reduce((e,t)=>(-1==t.height&&(e+=t.value),e),0));return{confirmed:h.fromSatoshis(s).toBTC(),unconfirmed:h.fromSatoshis(e).toBTC(),balance:h.fromSatoshis(i).toBTC()}}},{name:"getBalanceByAddress",method:"get",path:"/public/address/:addr/balance",callback:async function(e,t){var i=this;let r=(e=e.valid()).str("addr");return r=r||e.str("addrs"),e=await i.node.getCoinsByAddress(r.split(",")),{confirmed:(i=e.reduce((e,t)=>e+t.value,0))-(e=e.reduce((e,t)=>(-1==t.height&&(e+=t.value),e),0)),unconfirmed:e,balance:i}}},{name:"getUnconfirmedBalance",method:"get",path:"/public/addr/:addr/unconfirmedBalance",callback:async function(e,t){var i=this;let r=(e=e.valid()).str("addr");return r=r||e.str("addrs"),e=await i.node.getCoinsByAddress(r.split(",")),i=e.reduce((e,t)=>(-1==t.height&&(e+=t.value),e),0),h.fromSatoshis(i).toBTC()}},{name:"getTotalReceived",method:"get",path:"/public/addr/:addr/totalReceived",callback:async function(e,t){let i=(e=e.valid()).str("addr");i=i||e.str("addrs");try{return(await g(this,i)).totalReceivedSat}catch(e){throw e}}},{name:"getTotalSent",method:"get",path:"/public/addr/:addr/totalSent",callback:async function(e,t){let i=(e=e.valid()).str("addr");i=i||e.str("addrs");try{return(await g(this,i)).totalSent}catch(e){throw e}}},{name:"getAddressHistory",method:"jsonp",path:"/",callback:p},{name:"getAddressSummary",method:"jsonp",path:"/",callback:async function(e,t){var i=new u([t]),r=i.array(0,[]),a=i.obj(1,{});a.from=a.from||0,a.to=a.to||4294967295;for(var o={addrStr:r,balance:0,balanceSat:0,totalReceived:0,totalReceivedSat:0,totalSent:0,totalSentSat:0,unconfirmedBalance:0,unconfirmedBalanceSat:0,unconfirmedTxApperances:0,txApperances:0},c=(i=await p(e,t)).items,l=0;l<c.length;l++){var d=c[l];s(e,d,r,o),n(e,d,r,o),a.noTxList||(o.transactions||(o.transactions=[]),o.transactions.push(d.txid()))}return o.balance=h.fromSatoshis(o.balanceSat).toBTC(),o.totalReceived=h.fromSatoshis(o.totalReceivedSat).toBTC(),o.totalSent=h.fromSatoshis(o.totalSentSat).toBTC(),o.unconfirmedBalance=h.fromSatoshis(o.unconfirmedBalanceSat).toBTC(),o}},{name:"getAddressUnspentOutputs",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new u([t])).array(0,[]),e=await r(e,t)}},{name:"getTxidsByAddress",method:"jsonp",path:"/",callback:async function(e,t){var i=(t=new u([t])).array(0);t=t.str(1,"both");return e.chain.getHashesByAddress(i,t)}}]},function(e,t,i){var r=i(83);const s=i(33),n=i(80);var a=i(331),o=0,c=Date.now();async function h(e){var t=await e.rpc.execute({corba:!0,method:"miner.difficulty"});return{blocks:e.chain.height,connections:e.node.pool.peers.size,timeoffset:0,proxy:"",testnet:"main"!==e.node.network.type,errors:"",network:e.node.network.type,relayFee:0,version:"gamegold-"+r.version,protocolversion:700001,difficulty:t}}e.exports=[{name:"getStatus",method:"get",path:"/public/status",callback:async function(e,t){switch(e.query.q){case"getDifficulty":try{return{difficulty:(await h(this)).difficulty}}catch(e){throw e}break;case"getLastBlockHash":var i=await this.chain.db.getTip();return{syncTipHash:i.hash,lastblockhash:i.hash};case"getBestBlockHash":try{return{bestblockhash:await this.rpc.execute({corba:!0,method:"block.best"})}}catch(e){throw e}break;default:try{return{info:await h(this)}}catch(e){throw e}}}},{name:"getSync",method:"get",path:"/public/sync",callback:async function(e,t){var i="syncing";try{this.chain.synced&&(i="finished");var r=(100*this.chain.getProgress()).toFixed(2);return{status:i,blockChainHeight:this.chain.height,syncPercentage:Math.round(r),height:this.chain.height,error:null,type:"gamegold node"}}catch(e){throw e}}},{name:"getVersion",method:"get",path:"/public/version",callback:async function(e,t){return{version:r.version}}},{name:"getPeer",method:"get",path:"/public/peer",callback:function(e,t){var i=this.pool.getLoader()||{connected:!1,address:{host:null,port:null}};return{connected:i.connected,host:i.address.host,port:i.address.port}}},{name:"getPeers",method:"get",path:"/public/peers",callback:async function(e,t){return this.rpc.execute({corba:!0,method:"sys.peerinfo"})}},{name:"getEstimateFee",method:"get",path:"/public/utils/estimatefee",callback:function(e,t){e=(e.query.nbBlocks||"2").split(",");try{var i,r={};for(i of e){var n=parseInt(i);let e=this.fees.estimateFee(n,!1);0===e&&(e=-1),e=s.btc(e,!0),r[n]=e}return r}catch(e){throw e}}},{name:"estimateFee",method:"jsonp",path:"/",callback:function(e,t){t=(t=new n([t])).array(0,["2"]);try{var i,r={};for(i of t){var a=parseInt(i);let t=e.fees.estimateFee(a,!1);0===t&&(t=-1),t=s.btc(t,!0),r[a]=t}return r}catch(t){throw t}}},{name:"currency",method:"get",path:"/public/currency",callback:async function(e,t){var i=Date.now();if(!(0===o||c+6e5<=i))return{status:200,data:{bitstamp:o}};c=i;try{var r=await new Promise((e,t)=>{a("https://www.bitstamp.net/api/ticker/",(function(i,r,s){i&&t(i),i||200!==r.statusCode||e(s)}))});return{status:200,data:{bitstamp:o=parseFloat(JSON.parse(r).last)}}}catch(e){throw e}}},{name:"explorers",method:"get",path:"/public/explorers",callback:async function(e,t){return[{name:"gamegold",ticker:"GG",url:"https://insight.gamegold.xin"}]}},{name:"syncPercentage",method:"jsonp",path:"/",callback:async function(e,t){return Math.round((100*e.chain.getProgress()).toFixed(2))}},{name:"sysEcho",method:"jsonp",path:"/",callback:function(e,t){return 0}},{name:"getBestBlockHash",method:"jsonp",path:"/",callback:async function(e,t){return{bestblockhash:e=await e.rpc.execute({corba:!0,method:"block.best"})}}}]},function(e,t,i){const r=i(682),s=i(0),n=i(2),{handleErrors:a,getDetailedTransaction:o,transformTransaction:c,getDetailFromMeta:h,getBlockOverview:u,translateInputAddresses:l}=i(626),p=i(80),d=i(19).opcodes,f=i(6);e.exports=[{name:"getTx",method:"get",path:"/public/tx/:txid",callback:async function(e,t){var i,r=this;return e=(e=e.valid()).hash("txid"),(e=await o(r.node,e))?((i=await c(r.node,e,{})).chain="VNS",i.coinbase=e.isCoinbase(),i.network="main"===r.node.network.type?"mainnet":"testnet",i.blockTime=i.blocktime,i.blockTimeNormalized=i.blockTime,i.fee=i.fees*Math.pow(10,8),i.blockHash=i.blockhash,i.blockHeight=i.blockheight,i.coinbase=!1,i.inputCount=i.vin.length,i.outputCount=i.vout.length,i.value=i.valueIn*Math.pow(10,8),i):null}},{name:"getTx",method:"get",path:"/public/tx/:txid/coins",callback:async function(e,t){let i=this;const r=e.valid().hash("txid");let s=await o(i.node,r),a=null;if(s){a=await c(i.node,s,{});let e={inputs:[],outputs:[]},t=0;return s.inputs.map(o=>{var c=a.vin[t];c.coinbase=o.isCoinbase(),c.chain="VNS",c.network="main"===i.node.network.type?"mainnet":"testnet",c.sequenceNumber=o.sequence,c.address=a.vin[t].address||"",c.value=a.vin[t].valueSat||0,c.mintHeight=a.vin[t].mintHeight||0,c.mintTxid=n.revHex(o.prevout.hash),c.mintIndex=o.prevout.index,c.spentTxid=r,c.spentHeight=s.height,c.confirmations=s.confirmations,c.script=o.script.raw.toString("hex"),e.inputs.push(c),t++}),t=0,s.outputs.map(n=>{var o=a.vout[t];o.chain="VNS",o.network="main"===i.node.network.type?"mainnet":"testnet",o.coinbase=s.isCoinbase(),o.mintTxid=r,o.address=a.vout[t].scriptPubKey.addresses?a.vout[t].scriptPubKey.addresses[0]:"",o.spentTxid=a.vout[t].spentTxid||"",o.spentHeight=a.vout[t].spentHeight||0,o.mintIndex=t,o.mintHeight=s.height,o.value=n.value,o.confirmations=s.confirmations,o.script=n.script.raw.toString("hex"),e.outputs.push(o),t++}),e}return null}},{name:"getRawTx",method:"get",path:"/public/rawtx/:txid",callback:async function(e,t){return e=(e=e.valid()).str("txid"),{rawtx:e=await this.rpc.execute({method:"tx.raw.get",params:[e]})}}},{name:"getBlob",method:"get",path:"/public/blob/:txid/:index",callback:async function(e,t){var i=(e=e.valid()).hash("txid");e=e.uint("index");if(!(i=await this.node.getMeta(i))||!i.tx)return null;if(!(i=i.tx.outputs[e]))return null;if(!(e=i.getReturnData([d.OP_PROPEXCHANGE,d.OP_PROPCREATE]))||!e.oid)return null;if(!(i=await this.node.chain.db.erList.query([["erid",e.oid]]))||!i.list||!i.list[0].erid)return null;let r=i.list[0].source.blob;return"string"==typeof r&&(r=JSON.parse(r)),t.setHeader("content-type",r.type),{data:r}}},{name:"notify",method:"post",path:"/public/notify",callback:async function(e,t){return e.body.sign==(delete e.body.sign,e.body.secret=this.node.config.remotesecret,f.hash256(Buffer.from(JSON.stringify(e.body))).toString("hex"))?(delete e.body.secret,console.log("remote notify:",JSON.stringify(e.body)),{code:0}):{code:-1}}},{name:"getList",method:"get",path:"/public/txs",callback:async function(e,t){s(!this.chain.options.spv,"Cannot get TX in SPV mode.");var i,p=e.query.blockHash,d=l(e.query.address),f=(e=parseInt(e.query.pageNum)||0,1);if(p){if(!(p=await u(this.node,p,t)))return a(null,t);t=p.txids.length;var m,g,y=(r.isUndefined(e)?i=p.txids:(m=10*e,i=p.txids.slice(m,10+m),f=Math.ceil(t/10)),[]);for(g of i){var v=await o(this.node,n.revHex(g));v&&y.push(await c(this.node,v,{}))}return{pagesTotal:f,txs:y}}if(d){var b=10*e,w=10*(e+1),k=[];p=await this.node.getMetaByAddress(d);let t=0;for(const e of p){if(t<b);else{if(t>=w)break;var x=await h(this.node,e);k.push(await c(this.node,x,{}))}t++}return{pagesTotal:Math.ceil(p.length/10),txs:k}}throw new Error("Block hash or address expected")}},{name:"block",method:"get",path:"/public/block/:blockHash/coins/:pageSize/:pageNum",callback:async function(e,t){var i=this,p=(s(!i.chain.options.spv,"Cannot get TX in SPV mode."),e.query.blockHash),d=e.params.pageSize?parseInt(e.params.pageSize):100,f=l(e.query.address),m=parseInt(e.params.pageNum)-1||0,g=1;if(p=p||e.params.blockHash){if(!(e=await u(i.node,p,t)))return a(null,t);t=e.txids.length;var y,v=[],b=[],w=(r.isUndefined(m)?y=e.txids:(E=m*d,y=e.txids.slice(E,E+d),g=Math.ceil(t/d)),[]);for(let e of y){let t=await o(i.node,n.revHex(e),!0),r=null;if(t){r=await c(i.node,t,{}),w.push(r);let s=0;t.inputs.map(a=>{a.isCoinbase()||v.push({coinbase:!1,chain:"VNS",network:"main"===i.node.network.type?"mainnet":"testnet",mintTxid:n.revHex(a.prevout.hash),mintIndex:a.prevout.index,spentTxid:e,spentHeight:t.height,confirmations:t.confirmations,sequenceNumber:a.sequence,script:a.script.raw.toString("hex"),address:r.vin[s].addr||"",mintHeight:r.vin[s].mintHeight||0,value:r.vin[s].valueSat||0}),s++}),s=0,t.outputs.map(n=>{b.push({coinbase:t.isCoinbase(),chain:"VNS",network:"main"===i.node.network.type?"mainnet":"testnet",mintTxid:e,address:r.vout[s].scriptPubKey.addresses?r.vout[s].scriptPubKey.addresses[0]:"",spentTxid:r.vout[s].spentTxid||"",spentHeight:r.vout[s].spentHeight||0,mintIndex:s,mintHeight:t.height,value:n.value,confirmations:t.confirmations,script:n.script.raw.toString("hex")}),s++})}}return{txids:y,previous:"",next:m+1<g?`/block/${p}/coins/${d}/`+(m+2):"",inputs:v,outputs:b}}if(f){var k=m*d,x=(m+1)*d,S=[];e=await i.node.getMetaByAddress(f);let t=0;for(const r of e){if(t<k);else{if(t>=x)break;var _=await h(i.node,r);S.push(await c(i.node,_,{}))}t++}var E=Math.ceil(e.length/d);return{txids:y,previous:"",next:`/block/${p}/coins/${d}/`+((m+1)%E+1),pagesTotal:E,inputs:[],outputs:[],txs:S}}throw new Error("Block hash or address expected")}},{name:"getTxSend",method:"get",path:"/public/rawsend/:tx",callback:async function(e,t){return e=(e=e.valid()).str("tx"),e=await this.rpc.execute({method:"tx.raw.send",params:[e]})}},{name:"getDetailedTransaction",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new p([t])).hash(0),o(e,t,!0)}},{name:"getTransaction",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new p([t])).hash(0),e=await o(e,t,!1)}},{name:"getRawTransaction",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new p([t])).str(0),e=await e.rpc.execute({method:"tx.raw.get",params:[t]})}},{name:"getMempoolTransaction",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new p([t])).hash(0),e.mempool.getTX(t)}}]},function(e,t,i){const r=i(19).opcodes,s=i(31),n=i(2).revHex,a=i(80);e.exports=[{name:"prop.byaddress",method:"get",path:"/public/props/address/:address",callback:async function(e,t){return e=e.valid().str("address"),this.node.chain.db.getVpByAddress(e)}},{name:"prop.bidlist",method:"jsonp",path:"/",callback:async function(e,t){e.bidList||(e.bidList=new s);t=new a([t]);var i=Math.max(0,t.uint(0));return 0==i?(t=t.str(1))?e.bidList.query([["pid",t],["size",e.bidList.getSize()],["page",1]]):e.bidList.query([["size",e.bidList.getSize()],["page",1]]):e.bidList.query([["size",10],["page",i]])}},{name:"propBidlist",method:"get",path:"/public/prop/bidlist/:page",callback:async function(e,t){return this.node.bidList||(this.node.bidList=new s),e=e.valid(),(e=Math.max(0,e.uint("page",0)))?this.node.bidList.query([["size",10],["page",e]]):this.node.bidList.query([["size",this.node.bidList.getSize()],["page",1]])}},{name:"propBidOne",method:"get",path:"/public/prop/bidone/:pid",callback:async function(e,t){return this.node.bidList||(this.node.bidList=new s),(e=e.valid().str("pid"))?this.node.bidList.query([["pid",e],["page",1]]):[]}},{name:"prop.get",method:"get",path:"/public/prop/:pid",callback:async function(e,t){var i=[],s=(e=e.valid().str("pid"),await this.node.chain.db.propList.getVp(e));if(s){let e=[s.current.hash,s.current.index];for(;;){var a=await this.node.getMeta(e[0]),o=a.tx;if(!o)break;if(!(o=o.outputs[e[1]]))break;var c=o.getReturnData([r.OP_PROPCREATE,r.OP_PROPEXCHANGE]);if(!c)break;if(c.current={hash:n(e[0]),index:e[1],address:o.getAddress().toString()},c.height=a.height,c.status=s.pst,c.pst=s.pst,c.gold=s.gold,0==i.length&&s.bid&&(c.bid=s.bid),i.push(c),!c.prev)break;e=[c.prev.hash,c.prev.index]}}return i}}]},function(e,t,i){const r=i(80);e.exports=[{name:"cp.remoteQuery",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new r([t])).array(0,[]),e.chain.db.cpList.query(t)},remoteCb:async function(e){if(e&&Array.isArray(e.list))for(var t of e.list)this.wdb.cpList.getItem(t.cid)||await this.wdb.cpList.addItem(t);return e}},{name:"cps",method:"get",path:"/public/cps",callback:async function(e,t){return e={page:e.valid().u32("page",1),pageCount:0},{list:this.chain.db.cpList.getCPList([],e),cur:e.page,page:e.pageCount}}},{name:"cpById",method:"get",path:"/public/cp/:id",callback:async function(e,t){var i=(e=e.valid()).u32("page",1);e=e.str("id");return(e=this.chain.db.cpList.getCPList(e?[e]:[],{page:i}))&&0<e.length?e[0]:null}},{name:"cpByName",method:"get",path:"/public/cp/name/:name",callback:async function(e,t){var i=(e=e.valid()).u32("page",1);e=decodeURIComponent(e.str("name"));return(e=this.chain.db.cpList.getCPListByName(e?[e]:[],{page:i}))&&0<e.length?e[0]:null}}]},function(e,t,i){const r=i(80),s=i(100),n=i(77),a=i(78).errors,o=i(67),c=i(5).ContractStatus,h=i(20),u=i(33);e.exports=[{name:"token.random",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){if(1!==t.length)throw new n(a.MISC_ERROR,"token.random clientNo: 生成令牌随机量 终端编码");return t=new r([t]).str(0),t=o.getHmac(t,e.keys.hmacSalt).random}},{name:"mempool.watch",method:"jsonp",path:"/",callback:async function(e,t,i){i&&i.join("mempool")}},{name:"mempool.unwatch",method:"jsonp",path:"/",callback:async function(e,t,i){i&&i.leave("mempool")}},{name:"chain.watch",method:"jsonp",path:"/",callback:async function(e,t,i){i&&i.join("chain")}},{name:"chain.unwatch",method:"jsonp",path:"/",callback:async function(e,t,i){i&&i.leave("chain")}},{name:"chain.rescan",method:"jsonp",path:"/",callback:async function(e,t,i){if(null==(t=new r([t]).numhash(0)))throw new Error("Invalid parameter.");return e.http.scan(i,t)}},{name:"subscribe",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){if(i&&Array.isArray(t))for(var r of t)i.bus.subscribe(r);return!0}},{name:"unsubscribe",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){if(i&&Array.isArray(t))for(var r of t)i.bus.unsubscribe(r);return!0}},{name:"filter.set",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){if(i){if(t=new r([t]).buf(0))return i.filter=s.fromRaw(t),null;throw new Error("Invalid parameter.")}}},{name:"filter.reset",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){i&&(i.filter=null)}},{name:"filter.add",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){if(i){var s=new r([t]).array(0);if(!s)throw new Error("Invalid parameter.");if(!i.filter)throw new Error("No filter set.");for(let t=0;t<s.length;t++){var n=s[t];if(!n)throw new Error("Bad data chunk.");i.filter.add(n),e.spv&&e.pool.watch(n)}}}},{name:"canExecute",method:"jsonp",path:"/",callback:async function(e,t){return(t=new r([t]).obj(0,{})).confirm||"cpChange"==t.oper?e.chain.db.cpList.canExecute(t):await e.mempool.cpMemList.canExecute(t)&&await e.chain.db.cpList.canExecute(t)}},{name:"contract.list",method:"jsonp",path:"/",callback:async function(e,t){var i,s,n,a;return 0==t.length?"contract.list type page ids size: 查询并返回交易对 交易类型 指定查询的ID数组 页码":(a=(t=new r([t])).uint(0,1),i=t.uint(1,1),s=t.array(2,[]),t=t.int(3,10),(n=[]).push(["transStatus",c.CreatedOnMem]),a&&n.push(["type",a]),0<s.length&&n.push(["id","include",s]),{pageNum:(a=e.chain.db.transactionList.where(n).paginate(t,i)).pageNum,pageCur:a.pageCur,list:a.records()})},remoteCb:async function(e){if(e&&Array.isArray(e.list))for(var t of e.list)this.wdb.transactionList.saveContract(t,!0);return e}},{name:"block.tip",method:"jsonp",path:"/",callback:async function(e,t){return e.chain.tip.toRaw()}},{name:"block.entry",method:"jsonp",path:"/",callback:async function(e,t){if(null==(t=new r([t]).numhash(0)))throw new Error("Invalid parameter.");return(t=await e.chain.getEntry(t))&&await e.chain.isMainChain(t)?t.toRaw():null}},{name:"$tx.broadcast",method:"jsonp",path:"/",callback:async function(e,t,i){t=new r([t]).buf(0),t=h.fromRaw(t),await e.sendTX(t)}},{name:"$estimate.fee",method:"jsonp",path:"/",callback:async function(e,t){if(t=new r([t]).u32(0,1),e.fees)return 0===(e=e.fees.estimateFee(t,!1))?-1:u.btc(e,!0);throw new n(a.MISC_ERROR,"Fee estimation not available.")}}]},function(e,t,i){const r=i(80),s=i(784);e.exports=[{name:"ca.get",method:"get",path:"/public/ca/:erid",callback:async function(e,t){return e=e.valid().str("erid"),(e=await this.node.chain.db.erList.query([["erid",e]])).height=this.node.chain.height,e}},{name:"ca.byId",method:"jsonp",path:"/",callback:async function(e,t){return t=new r([t]).str(0),e.chain.db.erList.getEr(t)}},{name:"ca.rank",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new r([t])).str(0,""),(e=await(async e=>new Promise((t,i)=>{s(e,.85,1e-4,(function(e,r){e?i(e):t(r)}))}))(e.chain.db.enCpList.rank))[t]},remoteCb:async function(e){return e}},{name:"ca.list",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new r([t])).array(0,[]),(t=await e.chain.db.erList.query(t)).height=e.chain.height,t}},{name:"ca.verify",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new r([t])).str(0,""),(t=await e.chain.db.caVerify(t))&&(t.curHeight=e.chain.height),t},remoteCb:async function(e){return e}},{name:"ca.list.ab",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new r([t])).array(0,[]),e.chain.db.erAbList.query(t)},remoteCb:async function(e){return e}}]},function(e,t,i){"use strict";class r{constructor(e,t,i,r,s){this.outgoingNodes=e,this.linkProb=t,this.tolerance=i,this.callback=r,this.pageCount=Object.keys(this.outgoingNodes).length,this.coeff=(1-t)/this.pageCount,this.probabilityNodes=e instanceof Array?[]:{},this.incomingNodes=e instanceof Array?[]:{},this.debug=s,this.startRanking()}startRanking(){var e,t,i,r=1/this.pageCount,s=this.outgoingNodes;for(e in s)for(t in this.probabilityNodes[e]=r,s[e])i=s[e][t],this.incomingNodes[i]||(this.incomingNodes[i]=[]),this.incomingNodes[i].push(e);this.debug&&this.reportDebug(1),this.iterate(1)}reportDebug(e){console.log("____ITERATION "+e+"____"),console.log("Pages: "+Object.keys(this.outgoingNodes).length),console.log("outgoing %j",this.outgoingNodes),console.log("incoming %j",this.incomingNodes),console.log("probability %j",this.probabilityNodes)}iterate(e){var t,i,r,s,n,a=[],o={};for(t in this.probabilityNodes){if(r=0,this.incomingNodes[t])for(i=0;i<this.incomingNodes[t].length;i++)r+=this.probabilityNodes[this.incomingNodes[t][i]]/this.outgoingNodes[this.incomingNodes[t][i]].length;s=this.coeff+this.linkProb*r,n=this.probabilityNodes[t]+this.tolerance,this.probabilityNodes[t]-this.tolerance<=s&&s<=n&&a.push(o[t]=s),this.probabilityNodes[t]=s}return a.length==this.pageCount?this.outgoingNodes instanceof Array?this.callback(null,a):this.callback(null,o):(this.debug&&this.reportDebug(e),this.iterate(++e))}}e.exports=function(e,t,i,s,n=!1){if(e&&t&&i&&s)return new r(e,t,i,s,n);throw new Error("Provide 4 arguments: nodeMatrix, link probability, tolerance, callback")}},function(e,t,i){"use strict";e.exports=class{constructor(e){this.config=e,this.hmacConnection=this.config.array("hmac-connection")||[],this.config.hmacConnection=this.hmacConnection}add(e){-1==this.hmacConnection.indexOf(e)&&this.hmacConnection.push(e),this.config.hmacConnection=this.hmacConnection}del(e){-1!=(e=this.hmacConnection.indexOf(e))&&(this.hmacConnection.splice(e,1),this.config.hmacConnection=this.hmacConnection)}clear(){this.hmacConnection=[],this.config.hmacConnection=this.hmacConnection}content(){return this.hmacConnection}has(e){return-1!=this.hmacConnection.indexOf(e)}}},function(e,t,i){"use strict";
|
|
1693
|
+
*/e.exports=function(e,t){if(!e||!e.getHeader||!e.setHeader)throw new TypeError("res argument is required");var i=e.getHeader("Vary")||"";(i=s(Array.isArray(i)?i.join(", "):String(i),t))&&e.setHeader("Vary",i)},e.exports.append=s;var r=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function s(e,t){if("string"!=typeof e)throw new TypeError("header argument is required");if(!t)throw new TypeError("field argument is required");for(var i=Array.isArray(t)?t:n(String(t)),s=0;s<i.length;s++)if(!r.test(i[s]))throw new TypeError("field argument contains an invalid header name");if("*"===e)return e;var a=e,o=n(e.toLowerCase());if(-1!==i.indexOf("*")||-1!==o.indexOf("*"))return"*";for(var c=0;c<i.length;c++){var h=i[c].toLowerCase();-1===o.indexOf(h)&&(o.push(h),a=a?a+", "+i[c]:i[c])}return a}function n(e){for(var t=0,i=[],r=0,s=0,n=e.length;s<n;s++)switch(e.charCodeAt(s)){case 32:r===t&&(r=t=s+1);break;case 44:i.push(e.substring(r,t)),r=t=s+1;break;default:t=s+1}return i.push(e.substring(r,t)),i}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uServer=void 0;var r=i(93);const s=i(664),n=i(762),a=(0,r.default)("engine:uws");class o extends s.BaseServer{init(){}cleanup(){}prepare(e,t){e.method=e.getMethod().toUpperCase();var i=new URLSearchParams(e.getQuery());e._query=Object.fromEntries(i.entries()),e.headers={},e.forEach((t,i)=>{e.headers[t]=i}),e.connection={remoteAddress:Buffer.from(t.getRemoteAddressAsText()).toString()},t.onAborted(()=>{a("response has been aborted")})}createTransport(e,t){return new n.default[e](t)}attach(e,t={}){var i=(t.path||"/engine.io").replace(/\/$/,"")+"/";e.any(i,this.handleRequest.bind(this)).ws(i,{compression:t.compression,idleTimeout:t.idleTimeout,maxBackpressure:t.maxBackpressure,maxPayloadLength:this.opts.maxHttpBufferSize,upgrade:this.handleUpgrade.bind(this),open:e=>{(e.transport.socket=e).transport.writable=!0,e.transport.emit("drain")},message:(e,t,i)=>{e.transport.onData(i?t:Buffer.from(t).toString())},close:(e,t,i)=>{e.transport.onClose(t,i)}})}handleRequest(e,t){a('handling "%s" http request "%s"',t.getMethod(),t.getUrl()),this.prepare(t,e),t.res=e;const i=(i,r)=>{void 0!==i?(this.emit("connection_error",{req:t,code:i,message:s.Server.errorMessages[i],context:r}),this.abortRequest(t.res,i,r)):t._query.sid?(a("setting new request for existing client"),this.clients[t._query.sid].transport.onRequest(t)):this.handshake(t._query.transport,t,(t,i)=>this.abortRequest(e,t,i))};this.corsMiddleware?(t.res=new c(e),this.corsMiddleware.call(null,t,t.res,()=>{this.verify(t,!1,i)})):this.verify(t,!1,i)}handleUpgrade(e,t,i){a("on upgrade"),this.prepare(t,e),t.res=e,this.verify(t,!0,async(r,n)=>{if(r)this.emit("connection_error",{req:t,code:r,message:s.Server.errorMessages[r],context:n}),this.abortRequest(e,r,n);else{let s;if(r=t._query.sid)(n=this.clients[r])?n.upgrading?(a("transport has already been trying to upgrade"),e.close()):n.upgraded?(a("transport had already been upgraded"),e.close()):(a("upgrading existing transport"),s=this.createTransport(t._query.transport,t),n.maybeUpgrade(s)):(a("upgrade attempt for closed client"),e.close());else if(!(s=await this.handshake(t._query.transport,t,(t,i)=>this.abortRequest(e,t,i))))return;e.upgrade({transport:s},t.getHeader("sec-websocket-key"),t.getHeader("sec-websocket-protocol"),t.getHeader("sec-websocket-extensions"),i)}})}abortRequest(e,t,i){var r=t===s.Server.errors.FORBIDDEN?"403 Forbidden":"400 Bad Request";i=i&&i.message?i.message:s.Server.errorMessages[t];e.writeStatus(r),e.writeHeader("Content-Type","application/json"),e.end(JSON.stringify({code:t,message:i}))}}t.uServer=o;class c{constructor(e){this.res=e,this.statusWritten=!1,this.headers=[]}set statusCode(e){this.writeStatus(200===e?"200 OK":"204 No Content")}setHeader(e,t){this.writeHeader(e,t)}getHeader(){}writeStatus(e){this.res.writeStatus(e),this.statusWritten=!0,this.writeBufferedHeaders()}writeHeader(e,t){"Content-Length"!==e&&(this.statusWritten?this.res.writeHeader(e,t):this.headers.push([e,t]))}writeBufferedHeaders(){this.headers.forEach(([e,t])=>{this.res.writeHeader(e,t)})}end(e){this.statusWritten||this.writeBufferedHeaders(),this.res.end(e)}onData(e){this.res.onData(e)}onAborted(e){this.res.onAborted(e)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(763);i=i(764);t.default={polling:r.Polling,websocket:i.WebSocket}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Polling=void 0;var r=i(315),s=i(174);const n=i(623),a=(0,i(93).default)("engine:polling"),o={gzip:s.createGzip,deflate:s.createDeflate};class c extends r.Transport{constructor(e){super(e),this.closeTimeout=3e4}get name(){return"polling"}get supportsFraming(){return!1}onRequest(e){var t=e.res;"get"===e.getMethod()?this.onPollRequest(e,t):"post"===e.getMethod()?this.onDataRequest(e,t):(t.writeStatus("500 Internal Server Error"),t.end())}onPollRequest(e,t){this.req?(a("request overlap"),this.onError("overlap from client"),t.writeStatus("500 Internal Server Error"),t.end()):(a("setting request"),this.req=e,this.res=t,e.cleanup=()=>{this.req=this.res=null},t.onAborted(()=>{this.writable=!1,this.onError("poll connection closed prematurely")}),this.writable=!0,this.emit("drain"),this.writable&&this.shouldClose&&(a("triggering empty send to append close packet"),this.send([{type:"noop"}])))}onDataRequest(e,t){if(this.dataReq)this.onError("data request overlap from client"),t.writeStatus("500 Internal Server Error"),t.end();else{const s=Number(e.headers["content-length"]);if(s)if(s>this.maxHttpBufferSize)this.onError("payload too large"),t.writeStatus("413 Payload Too Large").end();else{if("application/octet-stream"===e.headers["content-type"]&&4===this.protocol)return this.onError("invalid content");this.dataReq=e,this.dataRes=t;let n,a=0;var i,r={"Content-Type":"text/html"};for(i in this.headers(e,r),r)t.writeHeader(i,String(r[i]));const o=e=>{this.onData(e.toString()),this.onDataRequestCleanup(),t.end("ok")};t.onAborted(()=>{this.onDataRequestCleanup(),this.onError("data request connection closed prematurely")}),t.onData((e,i)=>{var r=a+e.byteLength;if(r>s)this.onError("content-length mismatch"),t.close();else{if(!n){if(i)return void o(Buffer.from(e));n=Buffer.allocUnsafe(s)}if(Buffer.from(e).copy(n,a),i)return r!=s?(this.onError("content-length mismatch"),t.writeStatus("400 Content-Length Mismatch").end(),void this.onDataRequestCleanup()):void o(n);a=r}})}else this.onError("content-length header required"),t.writeStatus("411 Length Required").end()}}onDataRequestCleanup(){this.dataReq=this.dataRes=null}onData(e){a('received "%s"',e);var t=e=>{if("close"===e.type)return a("got xhr close packet"),this.onClose(),!1;this.onPacket(e)};3===this.protocol?this.parser.decodePayload(e,t):this.parser.decodePayload(e).forEach(t)}onClose(){this.writable&&this.send([{type:"noop"}]),super.onClose()}send(e){this.writable=!1,this.shouldClose&&(a("appending close packet to payload"),e.push({type:"close"}),this.shouldClose(),this.shouldClose=null);var t=t=>{var i=e.some(e=>e.options&&e.options.compress);this.write(t,{compress:i})};3===this.protocol?this.parser.encodePayload(e,this.supportsBinary,t):this.parser.encodePayload(e,t)}write(e,t){a('writing "%s"',e),this.doWrite(e,t,()=>{this.req.cleanup()})}doWrite(e,t,i){var r="string"==typeof e;const s={"Content-Type":r?"text/plain; charset=UTF-8":"application/octet-stream"},a=e=>{this.headers(this.req,s),Object.keys(s).forEach(e=>{this.res.writeHeader(e,String(s[e]))}),this.res.end(e),i()};if(this.httpCompression&&t.compress)if((r?Buffer.byteLength(e):e.length)<this.httpCompression.threshold)a(e);else{const t=n(this.req).encodings(["gzip","deflate"]);t?this.compress(e,t,(e,r)=>{e?(this.res.writeStatus("500 Internal Server Error"),this.res.end(),i(e)):(s["Content-Encoding"]=t,a(r))}):a(e)}else a(e)}compress(e,t,i){a("compressing");const r=[];let s=0;o[t](this.httpCompression).on("error",i).on("data",(function(e){r.push(e),s+=e.length})).on("end",(function(){i(null,Buffer.concat(r,s))})).end(e)}doClose(e){let t;a("closing");var i=()=>{clearTimeout(t),e(),this.onClose()};this.writable?(a("transport writable - closing right away"),this.send([{type:"close"}]),i()):this.discarded?(a("transport discarded - closing right away"),i()):(a("transport not writable - buffering orderly close"),this.shouldClose=i,t=setTimeout(i,this.closeTimeout))}headers(e,t){t=t||{};var i=e.headers["user-agent"];return i&&(~i.indexOf(";MSIE")||~i.indexOf("Trident/"))&&(t["X-XSS-Protection"]="0"),this.emit("headers",t,e),t}}t.Polling=c},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocket=void 0;var r=i(315);const s=(0,i(93).default)("engine:ws");class n extends r.Transport{constructor(e){super(e),this.writable=!1,this.perMessageDeflate=null}get name(){return"websocket"}get handlesUpgrades(){return!0}get supportsFraming(){return!0}send(e){var t,i=e.shift();void 0===i?(this.writable=!0,this.emit("drain")):(i.options&&i.options.compress,t=t=>{var i="string"!=typeof t,r=this.perMessageDeflate&&Buffer.byteLength(t)>this.perMessageDeflate.threshold;s('writing "%s"',t),this.writable=!1,this.socket.send(t,i,r),this.send(e)},i.options&&"string"==typeof i.options.wsPreEncoded?t(i.options.wsPreEncoded):this.parser.encodePacket(i,this.supportsBinary,t))}doClose(e){s("closing"),e&&e(),this.socket.close()}}t.WebSocket=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Client=void 0;const r=i(53);var s=i(93);const n=i(43),a=s("socket.io:client");t.Client=class{constructor(e,t){this.sockets=new Map,this.nsps=new Map,this.server=e,this.conn=t,this.encoder=e.encoder,this.decoder=new e._parser.Decoder,this.id=t.id,this.setup()}get request(){return this.conn.request}setup(){this.onclose=this.onclose.bind(this),this.ondata=this.ondata.bind(this),this.onerror=this.onerror.bind(this),this.ondecoded=this.ondecoded.bind(this),this.decoder.on("decoded",this.ondecoded),this.conn.on("data",this.ondata),this.conn.on("error",this.onerror),this.conn.on("close",this.onclose),this.connectTimeout=setTimeout(()=>{0===this.nsps.size?(a("no namespace joined yet, close the client"),this.close()):a("the client has already joined a namespace, nothing to do")},this.server._connectTimeout)}connect(e,t={}){if(this.server._nsps.has(e))return a("connecting to namespace %s",e),this.doConnect(e,t);this.server._checkNamespace(e,t,i=>{i?this.doConnect(e,t):(a("creation of namespace %s was denied",e),this._packet({type:r.PacketType.CONNECT_ERROR,nsp:e,data:{message:"Invalid namespace"}}))})}doConnect(e,t){const i=this.server.of(e),r=i._add(this,t,()=>{this.sockets.set(r.id,r),this.nsps.set(i.name,r),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0)})}_disconnect(){for(const e of this.sockets.values())e.disconnect();this.sockets.clear(),this.close()}_remove(e){var t;this.sockets.has(e.id)?(t=this.sockets.get(e.id).nsp.name,this.sockets.delete(e.id),this.nsps.delete(t)):a("ignoring remove for %s",e.id)}close(){"open"===this.conn.readyState&&(a("forcing transport close"),this.conn.close(),this.onclose("forced server close"))}_packet(e,t={}){"open"!==this.conn.readyState?a("ignoring packet write %j",e):(e=t.preEncoded?e:this.encoder.encode(e),this.writeToEngine(e,t))}writeToEngine(e,t){if(t.volatile&&!this.conn.transport.writable)a("volatile packet is discarded since the transport is not currently writable");else for(const i of Array.isArray(e)?e:[e])this.conn.write(i,t)}ondata(e){try{this.decoder.add(e)}catch(e){a("invalid packet format"),this.onerror(e)}}ondecoded(e){let t,i;var s;i=3===this.conn.protocol?(t=(s=n.parse(e.nsp,!0)).pathname,s.query):(t=e.nsp,e.data);const o=this.nsps.get(t);o||e.type!==r.PacketType.CONNECT?o&&e.type!==r.PacketType.CONNECT&&e.type!==r.PacketType.CONNECT_ERROR?process.nextTick((function(){o._onpacket(e)})):(a("invalid state (packet type: %s)",e.type),this.close()):this.connect(t,i)}onerror(e){for(const t of this.sockets.values())t._onerror(e);this.conn.close()}onclose(e){a("client close with reason %s",e),this.destroy();for(const t of this.sockets.values())t._onclose(e);this.sockets.clear(),this.decoder.destroy()}destroy(){this.conn.removeListener("data",this.ondata),this.conn.removeListener("error",this.onerror),this.conn.removeListener("close",this.onclose),this.decoder.removeListener("decoded",this.ondecoded),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0)}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParentNamespace=void 0;const r=i(674);class s extends r.Namespace{constructor(e){super(e,"/_"+s.count++),this.children=new Set}_initAdapter(){this.adapter={broadcast:(e,t)=>{this.children.forEach(i=>{i.adapter.broadcast(e,t)})}}}emit(e,...t){return this.children.forEach(i=>{i.emit(e,...t)}),!0}createChild(e){const t=new r.Namespace(this.server,e);return t._fns=this._fns.slice(0),this.listeners("connect").forEach(e=>t.on("connect",e)),this.listeners("connection").forEach(e=>t.on("connection",e)),this.children.add(t),this.server._nsps.set(e,t),t}fetchSockets(){throw new Error("fetchSockets() is not supported on parent namespaces")}}(t.ParentNamespace=s).count=0},function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.serveFile=t.restoreAdapter=t.patchAdapter=void 0;const s=i(676),n=i(88),a=(0,r(i(93)).default)("socket.io:adapter-uws"),{addAll:o,del:c,broadcast:h}=s.Adapter.prototype;function u(e,t,i,r){const s=t.conn.id,n=t.conn.transport.socket;i&&(a("subscribe connection %s to topic %s",s,e),n.subscribe(e)),r.forEach(t=>{a("subscribe connection %s to topic %s",s,t=e+""+t),n.subscribe(t)})}t.patchAdapter=function(e){s.Adapter.prototype.addAll=function(e,t){const i=!this.sids.has(e),r=(o.call(this,e,t),this.nsp.sockets.get(e));r&&("websocket"===r.conn.transport.name?u(this.nsp.name,r,i,t):i&&r.conn.on("upgrade",()=>{var t=this.sids.get(e);t&&u(this.nsp.name,r,i,t)}))},s.Adapter.prototype.del=function(e,t){var i;c.call(this,e,t),(e=this.nsp.sockets.get(e))&&"websocket"===e.conn.transport.name&&(i=e.conn.id,e=e.conn.transport.socket,t=this.nsp.name+""+t,a("unsubscribe connection %s from topic %s",i,t),e.unsubscribe(t))},s.Adapter.prototype.broadcast=function(t,i){if(i.rooms.size<=1&&0===i.except.size){var r=i.flags||{};const s={preEncoded:!0,volatile:r.volatile,compress:r.compress},n=(t.nsp=this.nsp.name,this.encoder.encode(t)),o=0===i.rooms.size?this.nsp.name:this.nsp.name+""+i.rooms.keys().next().value;a("fast publish to %s",o),n.forEach(t=>{var i="string"!=typeof t;e.publish(o,i?t:"4"+t,i)}),this.apply(i,e=>{"websocket"!==e.conn.transport.name&&e.client.writeToEngine(n,s)})}else h.call(this,t,i)}},t.restoreAdapter=function(){s.Adapter.prototype.addAll=o,s.Adapter.prototype.del=c,s.Adapter.prototype.broadcast=h};t.serveFile=function(e,t){const i=(0,n.statSync)(t).size,r=(0,n.createReadStream)(t),s=()=>!r.destroyed&&r.destroy();e.onAborted(s),r.on("data",t=>{const s=(e=>{var{buffer:e,byteOffset:t,byteLength:i}=e;return e.slice(t,t+i)})(t),n=e.getWriteOffset();var[t,a]=e.tryEnd(s,i);a||t||(r.pause(),e.onWritable(t=>{var[t,a]=e.tryEnd(s.slice(t-n),i);return!a&&t&&r.resume(),t}))}).on("error",e=>{throw s(),e}).on("end",s)}},function(e){e.exports=JSON.parse('{"name":"socket.io","version":"4.5.4","description":"node.js realtime framework server","keywords":["realtime","framework","websocket","tcp","events","socket","io"],"files":["dist/","client-dist/","wrapper.mjs","!**/*.tsbuildinfo"],"directories":{"doc":"docs/","example":"example/","lib":"lib/","test":"test/"},"type":"commonjs","main":"./dist/index.js","exports":{"import":"./wrapper.mjs","require":"./dist/index.js","types":"./dist/index.d.ts"},"types":"./dist/index.d.ts","license":"MIT","repository":{"type":"git","url":"git://github.com/socketio/socket.io"},"scripts":{"compile":"rimraf ./dist && tsc","test":"npm run format:check && npm run compile && npm run test:types && npm run test:unit","test:types":"tsd","test:unit":"nyc mocha --require ts-node/register --reporter spec --slow 200 --bail --timeout 10000 test/index.ts","format:check":"prettier --check \\"lib/**/*.ts\\" \\"test/**/*.ts\\"","format:fix":"prettier --write \\"lib/**/*.ts\\" \\"test/**/*.ts\\"","prepack":"npm run compile"},"dependencies":{"accepts":"~1.3.4","base64id":"~2.0.0","debug":"~4.3.2","engine.io":"~6.2.1","socket.io-adapter":"~2.4.0","socket.io-parser":"~4.2.1"},"devDependencies":{"@types/mocha":"^9.0.0","expect.js":"0.3.1","mocha":"^10.0.0","nyc":"^15.1.0","prettier":"^2.3.2","rimraf":"^3.0.2","socket.io-client":"4.5.4","socket.io-client-v2":"npm:socket.io-client@^2.4.0","superagent":"^8.0.0","supertest":"^6.1.6","ts-node":"^10.2.1","tsd":"^0.21.0","typescript":"^4.4.2","uWebSockets.js":"github:uNetworking/uWebSockets.js#v20.0.0"},"contributors":[{"name":"Guillermo Rauch","email":"rauchg@gmail.com"},{"name":"Arnout Kazemier","email":"info@3rd-eden.com"},{"name":"Vladimir Dronnikov","email":"dronnikov@gmail.com"},{"name":"Einar Otto Stangvik","email":"einaros@gmail.com"}],"engines":{"node":">=10.0.0"},"tsd":{"directory":"test"}}')},function(e,t,i){const r=i(0);e.exports=class{constructor(e){this.keyLimit=100,this.bodyLimit=20<<20,this.contentType=null,this.timeout=1e4,e&&this.fromOptions(e)}fromOptions(e){return r(e),null!=e.keyLimit&&(r("number"==typeof e.keyLimit),this.keyLimit=e.keyLimit),null!=e.bodyLimit&&(r("number"==typeof e.bodyLimit),this.bodyLimit=e.bodyLimit),null!=e.contentType&&(r("string"==typeof e.contentType),this.contentType=e.contentType),this}}},function(e,t,i){const r=i(679),s=i(625).StringDecoder;e.exports=async function(e,t){let i=Object.create(null);if("GET"!==e.method){let h=e.contentType;if("bin"!==(h=t.contentType?t.contentType:h)){var n=await(a=e,o="utf8",c=t,new Promise((e,t)=>{{var i=a,r=c,n=e,h=t;const u=new s(o);let l=!1,p=0,d="";const f=()=>{i.removeListener("data",m),i.removeListener("error",g),i.removeListener("end",y),null!=v&&(v=null,clearTimeout(v))},m=e=>{p+=e.length,l=!0,p>r.bodyLimit?h(new Error("Request body overflow.")):d+=u.write(e)},g=e=>{f(),h(e)},y=()=>{f(),n(l?d:null)};let v=setTimeout(()=>{v=null,f(),h(new Error("Request body timed out."))},r.timeout);i.on("data",m),i.on("error",g),i.on("end",y)}}));if(n)switch(h){case"json":if(!(i=JSON.parse(n))||"object"!=typeof i||Array.isArray(i))throw new Error("JSON body must be an object.");break;case"form":i=r.parsePairs(n,t.keyLimit)}}}var a,o,c;return i}},function(e,t,i){const{generateKey:r,verifyObj:s}=i(72),n=i(67),a=i(6);e.exports=class{constructor(e){this.wdb=e}async call(e,t,i){try{var o,c=t.body.sig,h=n.getHmac(t.options.cid||"",this.wdb.keys.hmacSalt).token,u=r(a.hash256(Buffer.from(h)));if(!this.wdb.options.devMode&&!s({method:t.body.method,params:t.body.params,cid:t.body.cid,wid:t.body.wid},c,u.public))return o={result:null,code:404,error:{type:"HmacError",message:"Verify Error"}},i.send(404,o,"json"),{interrupt:!0,result:null};if(!(t.options.auth&&t.options.authWid==t.options.wid||(this.wdb.options.devMode||await this.wdb.auth(t.options.cid,t.options.token),t.body.method&&"wallet.create"===t.body.method))){var l=await this.wdb.get(t.options.wid);if(!l)return i.send(404,{result:null,code:404,error:{type:"HmacError",message:"Not Found Wallet"}},"json"),{interrupt:!0,result:null};this.wdb.logger.info("Successful auth for %s on %s.",t.options.cid,t.options.wid),t.options.auth=!0,t.options.authWid=t.options.wid,t.wallet=l}return{interrupt:!1}}catch(e){return this.wdb.logger.info("Auth failure for %s on %s: %s.",t.options.cid,t.options.wid,e.message),i.send(403,{result:null,code:403,error:{type:"HmacError",message:"Hmac Auth failure."}},"json"),{interrupt:!0,result:null}}}}},function(e,t){e.exports=class{async call(e,t,i){return e.node.config.devMode||e.node.acl.canAccess(t.body.method,t.options.cid)?{interrupt:!1}:(i.send(407,{result:null,code:407,error:{type:"ACLError",message:"TerminalNo Authentication Required."}},"json"),{interrupt:!0,result:null})}}},function(e,t){e.exports=class{constructor(e,t){this.routes=e,this.openapi=t}async call(e,t,i){switch(t.options.mode){case"web":if(0===t.pathname.indexOf("/public/")){var r=this.routes.getHandlers(t.method);if(!r)return{interrupt:!0,result:null};for(const n of r){var s=n.match(t.pathname);if(s){t.params=s;try{return{interrupt:!0,result:{code:0,error:null,result:await n.call(t,i)}}}catch(e){i.error(500,e)}return{interrupt:!0,result:null}}}}else if(r=this.openapi[t.body.method]){try{return{interrupt:!0,result:{code:0,error:null,result:await e.node.conn_s2local.execute(r.name,t.body.params,t)}}}catch(e){i.error(500,e)}return{interrupt:!0,result:null}}break;case"ws":if(r=this.openapi[t.body.method])return{interrupt:!0,result:{code:0,error:null,result:await e.node.conn_s2local.execute(r.name,t.body.params,t)}}}return{interrupt:!1}}}},function(e,t,i){const r=i(0),s=i(2),n=i(6),a=i(158);e.exports=class{constructor(e){r(e,"Basic auth requires options."),this.user=e.username,this.pass=e.password,this.realm=e.realm,null!=this.user&&(r("string"==typeof this.user),r(this.user.length<=255,"Username too long."),r(s.isAscii(this.user),"Username must be ASCII."),this.user=n.hash256(Buffer.from(this.user,"ascii"))),r("string"==typeof this.pass),r(this.pass.length<=255,"Password too long."),r(s.isAscii(this.pass),"Password must be ASCII."),this.pass=n.hash256(Buffer.from(this.pass,"ascii")),this.realm||(this.realm="server"),r("string"==typeof this.realm)}fail(e){e.setHeader("WWW-Authenticate",`Basic realm="${this.realm}"`),e.send(401,{result:null,code:401,error:{type:"AuthError",message:"Unauthorized."}},"json"),e.end()}async call(e,t,i){if(!e.node.config.devMode&&!t.options.auth){if(this.user){if(255<t.options.user.username.length)return this.fail(i),{interrupt:!0,result:null};const e=Buffer.from(t.options.user.username,"ascii"),r=n.hash256(e);if(!a(r,this.user))return this.fail(i),{interrupt:!0,result:null}}if(!t.options.user||!t.options.user.password||255<t.options.user.password.length)return this.fail(i),{interrupt:!0,result:null};const e=Buffer.from(t.options.user.password,"ascii"),r=n.hash256(e);if(!a(r,this.pass))return this.fail(i),{interrupt:!0,result:null};t.options.auth=!0}return{interrupt:!1}}}},function(e,t,i){const r=i(2),s=i(77),n=i(78).errors,a=i(80),o=i(121),{getBlockOverview:c,getBlockByHash:h,formatTimestamp:u}=i(626);async function l(e,t){if(e.valid(),!(e=await this.chain.tip))throw new s(n.MISC_ERROR,"Block not found");if(e=await h(this.node,e.hash,t))return e.chain="VNS",e.network="main"===this.node.network.type?"mainnet":"testnet",e}e.exports=[{name:"blocks",method:"get",path:"/public/block",callback:async function(e,t){var i,r=this,s=(e=e.valid()).str("blockDate"),n=e.str("startTimestamp",""),a=(e=e.uint("limit",10),u(new Date));if(s){if(!/\d{4}-\d{2}-\d{2}/.test(s))throw new Error("Please use yyyy-mm-dd format");i=s===a}else s=a,i=!0;a=Math.round(new Date(s).getTime()/1e3),n=parseInt(n)||a+86400;var o=u(new Date(1e3*(a-86400))),c=n?u(new Date(1e3*n)):null,l=(e=parseInt(e||200),!1),p=n;try{var d,f=await r.chain.db.getTimestampHashes(n,a);let u=[];for(d of f)u.push(d.hash);u.reverse(),u.length>e&&(l=!0,u=u.slice(0,e));var m,g={blocks:[],length:u.length,pagination:{next:c,prev:o,currentTs:n-1,current:s,isToday:i,more:l,moreTs:l?p:void 0}};for(m of u){var y=await h(r,m,t);y.chain="VNS",y.network="main"===r.node.network.type?"mainnet":"testnet",g.blocks.push(y)}return g.blocks.sort((e,t)=>t.height-e.height),g.blocks}catch(e){throw e}}},{name:"block-tip",method:"get",path:"/public/block/tip",callback:l},{name:"blocks",method:"get",path:"/public/blocks",callback:async function(e,t){var i,r=(e=e.valid()).str("blockDate"),s=e.str("startTimestamp",""),n=(e=e.uint("limit",10),u(new Date));if(r){if(!/\d{4}-\d{2}-\d{2}/.test(r))throw new Error("Please use yyyy-mm-dd format");i=r===n}else r=n,i=!0;n=Math.round(new Date(r).getTime()/1e3),s=parseInt(s)||n+86400;var a=u(new Date(1e3*(n-86400))),o=s?u(new Date(1e3*s)):null,c=(e=parseInt(e||200),!1),l=s;try{var p,d=await this.chain.db.getTimestampHashes(s,n);let u=[];for(p of d)u.push(p.hash);u.reverse(),u.length>e&&(c=!0,u=u.slice(0,e));var f,m={blocks:[],length:u.length,pagination:{next:o,prev:a,currentTs:s-1,current:r,isToday:i,more:c,moreTs:c?l:void 0}};for(f of u){var g=await h(this,f,t);m.blocks.push(g)}return m.blocks.sort((e,t)=>t.height-e.height),m}catch(e){throw e}}},{name:"block-index",method:"get",path:"/public/block-index/:height",callback:async function(e,t){var i=this;if(-1===(e=(e=e.valid()).uint("height")))throw new s(n.TYPE_ERROR,"Invalid block height.");if(!(e=await i.chain.getEntry(e)))throw new s(n.MISC_ERROR,"Block not found");if(i=await h(i.node,e.hash,t))return i}},{name:"block-tip",method:"get",path:"/public/block-tip",callback:l},{name:"block",method:"get",path:"/public/block/:blockHash",callback:async function(e,t){if(e=(e=e.valid()).str("blockHash"),e=await h(this.node,e,t))return e.chain="VNS",e.network="main"===this.node.network.type?"mainnet":"testnet",e}},{name:"getBlock",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new a([t])).str(0),h(e,t)}},{name:"rawblock",method:"get",path:"/public/rawblock/:param",callback:async function(e,t){var i=this;let a=(e=e.valid()).str("param");if(a=r.checkNum(a)?parseInt(a):r.revHex(a),e=await i.chain.getBlock(a))return e.toRaw().toString("hex");if(i.chain.options.spv)throw new s(n.MISC_ERROR,"Block not available (spv mode)");if(i.chain.options.prune)throw new s(n.MISC_ERROR,"Block not available (pruned data)");throw new s(n.DATABASE_ERROR,"Can't read block from disk")}},{name:"getRawBlock",method:"jsonp",path:"/",callback:async function(e,t){let i=(t=new a([t])).str(0);return r.checkNum(i)&&(i=parseInt(i)),(t=await e.chain.getBlock(i))?t.toRaw().toString("hex"):null}},{name:"isSynced",method:"jsonp",path:"/",callback:async function(e,t){return e.chain.synced}},{name:"getBlockOverview",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new a([t])).str(0),c(e,t)}},{name:"getInfo",method:"jsonp",path:"/",callback:async function(e,t){var i=await e.rpc.execute({corba:!0,method:"miner.difficulty"});return{blocks:e.chain.height,connections:e.pool.peers.size(),timeoffset:0,proxy:"",testnet:"main"!==e.network.type,errors:"",network:e.network.type,relayFee:0,version:"bitcore-1.1.2",protocolversion:700001,difficulty:i}}},{name:"getBestHeight",method:"jsonp",path:"/",callback:async function(e,t){return e.chain.height}},{name:"getBlockHeader",method:"jsonp",path:"/",callback:async function(e,t){var i=(t=new a([t])).hash(0);t=t.bool(1,!0);if(!i)throw new s(n.MISC_ERROR,"Invalid block hash.");if(!(i=await e.chain.getEntry(i)))throw new s(n.MISC_ERROR,"Block not found");if(!t)return i.toRaw().toString("hex",0,80);t=await e.chain.getMedianTime(i);var c=await e.chain.getNextHash(i.hash);return{hash:i.rhash(),confirmations:e.chain.height-i.height+1,height:i.height,version:i.version,versionHex:r.hex32(i.version),merkleroot:r.revHex(i.merkleRoot),time:i.time,mediantime:t,bits:i.bits,difficulty:o.bits2Diff(i.bits),chainwork:i.chainwork.toString("hex",64),previousblockhash:i.prevBlock!==encoding.NULL_HASH?r.revHex(i.prevBlock):null,nextblockhash:c?r.revHex(c):null}}}]},function(e){e.exports=JSON.parse('[{"poolName":"50BTC","url":"https://50btc.com/","searchStrings":["50BTC.com","50btc.com"]},{"poolName":"175btc","url":"http://www.175btc.com/","searchStrings":["Mined By 175btc.com"]},{"poolName":"ASICminer","url":"https://bitcointalk.org/index.php?topic=99497.0","searchStrings":["Mined By ASICMiner"]},{"poolName":"AntMiner","url":"https://bitmaintech.com/","searchStrings":["AntPool"]},{"poolName":"agentD","url":"http://","searchStrings":["agentD"]},{"poolName":"Bitfury","url":"http://bitfury.org/","searchStrings":["2av0id51pct"]},{"poolName":"BitMinter","url":"https://bitminter.com/","searchStrings":["BitMinter"]},{"poolName":"Bitparking","url":"http://bitparking.com/","searchStrings":["bitparking"]},{"poolName":"BTC Guild","url":"https://www.btcguild.com/","searchStrings":["Mined by BTC Guild","BTC Guild"]},{"poolName":"bcpool.io","url":"https://bcpool.io/","searchStrings":["bcpool"]},{"poolName":"Discus Fish","url":"http://f2pool.com/","searchStrings":["七彩神仙鱼","Made in China","Mined by user"]},{"poolName":"Discus Fish Solo","url":"http://f2pool.com/","searchStrings":["For Pierce and Paul"]},{"poolName":"Cointerra","url":"http://cointerra.com/","searchStrings":["cointerra"]},{"poolName":"Eligius","url":"http://eligius.st/","searchStrings":["Eligius"]},{"poolName":"EclipseMC","url":"https://eclipsemc.com/","searchStrings":["Josh Zerlan was here!","EclipseMC","Aluminum Falcon"]},{"poolName":"GIVE-ME-COINS","url":"https://give-me-coins.com/","searchStrings":["Mined at GIVE-ME-COINS.com"]},{"poolName":"ghash.io","url":"https://ghash.io/","searchStrings":["ghash.io","GHash.IO"]},{"poolName":"HHTT","url":"http://hhtt.1209k.com/","searchStrings":["HHTT"]},{"poolName":"KNCminer","url":"https://www.kncminer.com/","searchStrings":["KnCMiner"]},{"poolName":"Megabigpower","url":"http://megabigpower.com/","searchStrings":["megabigpower.com"]},{"poolName":"MultiCoin","url":"https://multicoin.co/","searchStrings":["MultiCoin.co"]},{"poolName":"Mt Red","url":"https://mtred.com/","searchStrings":["/mtred/"]},{"poolName":"MaxBTC","url":"https://www.maxbtc.com","searchStrings":["MaxBTC"]},{"poolName":"NMCbit","url":"http://nmcbit.com/","searchStrings":["nmcbit.com"]},{"poolName":"ozcoin","url":"https://ozco.in/","searchStrings":["ozco.in","ozcoin"]},{"poolName":"Polmine.pl","url":"https://polmine.pl","searchStrings":["by polmine.pl"]},{"poolName":"simplecoin","url":"http://simplecoin.us/","searchStrings":["simplecoin.us ftw"]},{"poolName":"SlushPool","url":"https://slushpool.com/","searchStrings":["/slush/"]},{"poolName":"TripleMining","url":"https://www.triplemining.com/","searchStrings":["Triplemining.com"]},{"poolName":"wizkid057","url":"http://wizkid057.com/btc","searchStrings":["wizkid057"]},{"poolName":"Yourbtc.net","url":"http://yourbtc.net/","searchStrings":["yourbtc.net"]},{"poolName":"BTCChina Pool","url":"https://pool.btcchina.com/","searchStrings":["BTCChina Pool","btcchina.com"]},{"poolName":"BTCC Pool","url":"https://pool.btcc.com/","searchStrings":["/BTCC/"]}]')},function(e,t,i){const{utxo:r,_setOutputResults:s,_setInputResults:n,transformTransaction:a,getDetailFromMeta:o,translateOutputAddress:c}=i(626),h=i(33),u=i(80),l=i(2);async function p(e,t){var i=(t=new u([t])).array(0,[]),r=t.obj(1,{}),s=(r.from=r.from||0,r.to=r.to||4294967295,[]);t=await e.getMetaByAddress(i);let n=0;for(const i of t){if(n<r.from);else{if(n>=r.to)break;var a=await o(e,i);s.push(a)}n++}return{totalCount:t.length,items:s}}async function d(e,t){let i=(e=e.valid()).str("addr");i=i||e.str("addrs");var r=(e=await this.node.getCoinsByAddress(i.split(","))).reduce((e,t)=>e+t.value,0);return{confirmed:r-(e=e.reduce((e,t)=>(-1==t.height&&(e+=t.value),e),0)),unconfirmed:e,balance:r}}async function f(e,t){let i=(e=e.valid()).str("addr");var r,s=[];for(r of(i=i||e.str("addrs")).split(",")){var n=(a=await this.node.getCoinsByAddress(r)).reduce((e,t)=>e+t.value,0),a=a.reduce((e,t)=>(-1==t.height&&(e+=t.value),e),0);s.push({param:r,result:{confirmed:n-a,unconfirmed:a,balance:n}})}return s}async function m(e,t){let i=(r=e.valid()).str("addr");i=i||r.str("addrs");var r,s=((r={from:parseInt(e.query.from)||parseInt(e.body.from)||0}).to=parseInt(e.query.to)||parseInt(e.body.to)||parseInt(r.from)+10,y(e));try{var n,c=await this.node.getMetaByAddress(i.split(",")),h=[];for(n of c){var u=await o(this.node,n);h.push(await a(this.node,u,s))}return{totalItems:c.length,from:r.from,to:Math.min(r.to,c.length),items:h}}catch(e){throw e}}async function g(e,t){var i=e.valid();let r=i.str("addr");r=r||i.str("addrs");var s=y(e),n=[];try{for(var c of r.split(",")){var h,u=await this.node.getMetaByAddress(c),l=[];for(h of u){var p=await o(this.node,h);l.push(await a(this.node,p,s))}n.push({param:c,result:l})}return n}catch(e){throw e}}function y(e){return{noAsm:!!parseInt(e.query.noAsm),noScriptSig:!!parseInt(e.query.noScriptSig),noSpent:!!parseInt(e.query.noSpent)}}async function v(e,t){let i=(e=e.valid()).str("addrs");i=i||e.str("addr","");try{var s,n=[];for(s of await r(this.node,i.split(",")))n.push(w(this,s));return n}catch(e){throw e}}async function b(e,t){let i=(e=e.valid()).str("addrs");i=i||e.str("addr","");try{var s,n=[];for(s of i.split(",")){var a,o=[];for(a of await r(this.node,s))o.push(w(this,a));n.push({param:s,result:o})}return n}catch(e){throw e}}function w(e,t){var i={address:c(t.address),txid:l.revHex(t.txid),vout:t.vout,scriptPubKey:t.scriptPubKey,amount:t.satoshis/1e8,satoshis:t.satoshis};return t.height&&0<t.height?(i.height=t.height,i.confirmations=e.chain.height-t.height+1):i.confirmations=0,t.timestamp&&(i.ts=t.timestamp),i.chain="VNS",i.network="main"===e.node.network.type?"mainnet":"testnet",i.coinbase=t.coinbase,i.mintTxid=i.txid,i.value=i.satoshis,i.mintIndex=i.vout,i.mintHeight=i.height,i.spentTxid="",i.spentHeight=-2,i.script=i.scriptPubKey,i}async function k(e,t){var i=(e=e.valid()).str("id"),r=(e=e.uint("index",1),this.node.require("walletdb"));if(r&&(r=await r.get("primary"),await r.ensureAccount({name:i,witness:!0}),r=await r.createReceive(i,e)))return r.toJSON().address}async function x(e,t,i){i=i||{};var r={totalCount:0,items:[]};let a=0;for(const s of await e.node.getMetaByAddress(t)){if(i.from&&a<i.from);else{if(i.to&&a>=i.to)break;var u=await o(e.node,s);r.items.push(u)}a++}r.totalCount=r.items.length;for(var p={addrStr:t,balance:0,balanceSat:0,totalReceived:0,totalReceivedSat:0,totalSent:0,totalSentSat:0,unconfirmedBalance:0,unconfirmedBalanceSat:0,unconfirmedTxApperances:0,txApperances:0},d=0;d<r.items.length;d++){var f=r.items[d];s(e,f,t,p),n(e,f,t,p),i.noTxList||(p.transactions||(p.transactions=[]),p.transactions.push(l.revHex(f.txid())))}return p.balance=h.fromSatoshis(p.balanceSat).toBTC(),p.totalReceived=h.fromSatoshis(p.totalReceivedSat).toBTC(),p.totalSent=h.fromSatoshis(p.totalSentSat).toBTC(),p.unconfirmedBalance=h.fromSatoshis(p.unconfirmedBalanceSat).toBTC(),p.addrStr&&(p.addrStr=c(p.addrStr)),p}e.exports=[{name:"address.reflect",method:"get",path:"/public/addr/reflect/:id",callback:k},{name:"address.reflect.index",method:"get",path:"/public/addr/reflect/:id/:index",callback:k},{name:"getInfo",method:"get",path:"/public/addr/:addr",callback:async function(e,t){var i=(i=e.valid()).str("addr"),r={noTxList:parseInt(e.query.noTxList)};e.query.from&&e.query.to?(r.from=parseInt(e.query.from),r.to=parseInt(e.query.to)):(r.from=0,r.to=10);try{return await x(this,i,r)}catch(e){throw e}}},{name:"getUTXOByAddress",method:"get",path:"/public/addr/:addr/utxo",callback:v},{name:"getTXSByAddress",method:"get",path:"/public/address/:addr/txs",callback:m},{name:"getUTXOByAddress",method:"get",path:"/public/address/:addr/utxo",callback:v},{name:"getUTXOByAddresses",method:"get",path:"/public/addrs/:addrs/utxo",callback:v},{name:"postUTXOByAddresses",method:"post",path:"/public/addrs/utxo",callback:v},{name:"getUTXOGroupAddresses",method:"get",path:"/public/addrs/:addrs/grouputxo",callback:b},{name:"postUTXOGroupAddresses",method:"post",path:"/public/addrs/grouputxo",callback:b},{name:"getTXSByAddresses",method:"get",path:"/public/addrs/:addrs/txs",callback:m},{name:"postTXSByAddresses",method:"post",path:"/public/addrs/txs",callback:m},{name:"getTXSGroupAddresses",method:"get",path:"/public/addrs/:addrs/grouptxs",callback:g},{name:"postTXSGroupAddresses",method:"post",path:"/public/addrs/grouptxs",callback:g},{name:"getBalanceByAddress",method:"get",path:"/public/addrs/:addrs/balance",callback:d},{name:"postBalanceByAddress",method:"post",path:"/public/addrs/balance",callback:d},{name:"getBalanceGroupAddress",method:"get",path:"/public/addrs/:addrs/groupbalance",callback:f},{name:"postBalanceGroupAddress",method:"post",path:"/public/addrs/groupbalance",callback:f},{name:"getBalanceByAddress",method:"get",path:"/public/addr/:addr/balance",callback:async function(e,t){var i=this;let r=(e=e.valid()).str("addr");r=r||e.str("addrs"),e=await i.node.getCoinsByAddress(r.split(","));var s=(i=e.reduce((e,t)=>e+t.value,0))-(e=e.reduce((e,t)=>(-1==t.height&&(e+=t.value),e),0));return{confirmed:h.fromSatoshis(s).toBTC(),unconfirmed:h.fromSatoshis(e).toBTC(),balance:h.fromSatoshis(i).toBTC()}}},{name:"getBalanceByAddress",method:"get",path:"/public/address/:addr/balance",callback:d},{name:"getUnconfirmedBalance",method:"get",path:"/public/addr/:addr/unconfirmedBalance",callback:async function(e,t){var i=this;let r=(e=e.valid()).str("addr");return r=r||e.str("addrs"),e=await i.node.getCoinsByAddress(r.split(",")),i=e.reduce((e,t)=>(-1==t.height&&(e+=t.value),e),0),h.fromSatoshis(i).toBTC()}},{name:"getTotalReceived",method:"get",path:"/public/addr/:addr/totalReceived",callback:async function(e,t){let i=(e=e.valid()).str("addr");i=i||e.str("addrs");try{return(await x(this,i)).totalReceivedSat}catch(e){throw e}}},{name:"getTotalSent",method:"get",path:"/public/addr/:addr/totalSent",callback:async function(e,t){let i=(e=e.valid()).str("addr");i=i||e.str("addrs");try{return(await x(this,i)).totalSent}catch(e){throw e}}},{name:"getAddressHistory",method:"jsonp",path:"/",callback:p},{name:"getAddressSummary",method:"jsonp",path:"/",callback:async function(e,t){var i=new u([t]),r=i.array(0,[]),a=i.obj(1,{});a.from=a.from||0,a.to=a.to||4294967295;for(var o={addrStr:r,balance:0,balanceSat:0,totalReceived:0,totalReceivedSat:0,totalSent:0,totalSentSat:0,unconfirmedBalance:0,unconfirmedBalanceSat:0,unconfirmedTxApperances:0,txApperances:0},c=(i=await p(e,t)).items,l=0;l<c.length;l++){var d=c[l];s(e,d,r,o),n(e,d,r,o),a.noTxList||(o.transactions||(o.transactions=[]),o.transactions.push(d.txid()))}return o.balance=h.fromSatoshis(o.balanceSat).toBTC(),o.totalReceived=h.fromSatoshis(o.totalReceivedSat).toBTC(),o.totalSent=h.fromSatoshis(o.totalSentSat).toBTC(),o.unconfirmedBalance=h.fromSatoshis(o.unconfirmedBalanceSat).toBTC(),o}},{name:"getAddressUnspentOutputs",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new u([t])).array(0,[]),e=await r(e,t)}},{name:"getTxidsByAddress",method:"jsonp",path:"/",callback:async function(e,t){var i=(t=new u([t])).array(0);t=t.str(1,"both");return e.chain.getHashesByAddress(i,t)}}]},function(e,t,i){var r=i(83);const s=i(33),n=i(80);var a=i(331),o=0,c=Date.now();async function h(e){var t=await e.rpc.execute({corba:!0,method:"miner.difficulty"});return{blocks:e.chain.height,connections:e.node.pool.peers.size,timeoffset:0,proxy:"",testnet:"main"!==e.node.network.type,errors:"",network:e.node.network.type,relayFee:0,version:"gamegold-"+r.version,protocolversion:700001,difficulty:t}}e.exports=[{name:"getStatus",method:"get",path:"/public/status",callback:async function(e,t){switch(e.query.q){case"getDifficulty":try{return{difficulty:(await h(this)).difficulty}}catch(e){throw e}break;case"getLastBlockHash":var i=await this.chain.db.getTip();return{syncTipHash:i.hash,lastblockhash:i.hash};case"getBestBlockHash":try{return{bestblockhash:await this.rpc.execute({corba:!0,method:"block.best"})}}catch(e){throw e}break;default:try{return{info:await h(this)}}catch(e){throw e}}}},{name:"getSync",method:"get",path:"/public/sync",callback:async function(e,t){var i="syncing";try{this.chain.synced&&(i="finished");var r=(100*this.chain.getProgress()).toFixed(2);return{status:i,blockChainHeight:this.chain.height,syncPercentage:Math.round(r),height:this.chain.height,error:null,type:"gamegold node"}}catch(e){throw e}}},{name:"getVersion",method:"get",path:"/public/version",callback:async function(e,t){return{version:r.version}}},{name:"getPeer",method:"get",path:"/public/peer",callback:function(e,t){var i=this.pool.getLoader()||{connected:!1,address:{host:null,port:null}};return{connected:i.connected,host:i.address.host,port:i.address.port}}},{name:"getPeers",method:"get",path:"/public/peers",callback:async function(e,t){return this.rpc.execute({corba:!0,method:"sys.peerinfo"})}},{name:"getEstimateFee",method:"get",path:"/public/utils/estimatefee",callback:function(e,t){e=(e.query.nbBlocks||"2").split(",");try{var i,r={};for(i of e){var n=parseInt(i);let e=this.fees.estimateFee(n,!1);0===e&&(e=-1),e=s.btc(e,!0),r[n]=e}return r}catch(e){throw e}}},{name:"estimateFee",method:"jsonp",path:"/",callback:function(e,t){t=(t=new n([t])).array(0,["2"]);try{var i,r={};for(i of t){var a=parseInt(i);let t=e.fees.estimateFee(a,!1);0===t&&(t=-1),t=s.btc(t,!0),r[a]=t}return r}catch(t){throw t}}},{name:"currency",method:"get",path:"/public/currency",callback:async function(e,t){var i=Date.now();if(!(0===o||c+6e5<=i))return{status:200,data:{bitstamp:o}};c=i;try{var r=await new Promise((e,t)=>{a("https://www.bitstamp.net/api/ticker/",(function(i,r,s){i&&t(i),i||200!==r.statusCode||e(s)}))});return{status:200,data:{bitstamp:o=parseFloat(JSON.parse(r).last)}}}catch(e){throw e}}},{name:"explorers",method:"get",path:"/public/explorers",callback:async function(e,t){return[{name:"gamegold",ticker:"GG",url:"https://insight.gamegold.xin"}]}},{name:"syncPercentage",method:"jsonp",path:"/",callback:async function(e,t){return Math.round((100*e.chain.getProgress()).toFixed(2))}},{name:"sysEcho",method:"jsonp",path:"/",callback:function(e,t){return 0}},{name:"getBestBlockHash",method:"jsonp",path:"/",callback:async function(e,t){return{bestblockhash:e=await e.rpc.execute({corba:!0,method:"block.best"})}}}]},function(e,t,i){const r=i(682),s=i(0),n=i(2),{handleErrors:a,getDetailedTransaction:o,transformTransaction:c,getDetailFromMeta:h,getBlockOverview:u,translateInputAddresses:l}=i(626),p=i(80),d=i(19).opcodes,f=i(6);e.exports=[{name:"getTx",method:"get",path:"/public/tx/:txid",callback:async function(e,t){var i,r=this;return e=(e=e.valid()).hash("txid"),(e=await o(r.node,e))?((i=await c(r.node,e,{})).chain="VNS",i.coinbase=e.isCoinbase(),i.network="main"===r.node.network.type?"mainnet":"testnet",i.blockTime=i.blocktime,i.blockTimeNormalized=i.blockTime,i.fee=i.fees*Math.pow(10,8),i.blockHash=i.blockhash,i.blockHeight=i.blockheight,i.coinbase=!1,i.inputCount=i.vin.length,i.outputCount=i.vout.length,i.value=i.valueIn*Math.pow(10,8),i):null}},{name:"getSpender",method:"get",path:"/public/tx/:txid/spender/:index",callback:async function(e,t){var i=this,r=(e=e.valid()).hash("txid");e=e.u32("index",0);return s(r,"Hash is required."),s(null!=e,"Index is required."),(i=await i.node.chain.db.getSpender(r,e))&&(i.txid=n.revHex(i.txid)),i}},{name:"getTx",method:"get",path:"/public/tx/:txid/coins",callback:async function(e,t){let i=this;const r=e.valid().hash("txid");let s=await o(i.node,r),a=null;if(s){a=await c(i.node,s,{});let e={inputs:[],outputs:[]},t=0;return s.inputs.map(o=>{var c=a.vin[t];c.coinbase=o.isCoinbase(),c.chain="VNS",c.network="main"===i.node.network.type?"mainnet":"testnet",c.sequenceNumber=o.sequence,c.address=a.vin[t].address||"",c.value=a.vin[t].valueSat||0,c.mintHeight=a.vin[t].mintHeight||0,c.mintTxid=n.revHex(o.prevout.hash),c.mintIndex=o.prevout.index,c.spentTxid=r,c.spentHeight=s.height,c.confirmations=s.confirmations,c.script=o.script.raw.toString("hex"),e.inputs.push(c),t++}),t=0,s.outputs.map(n=>{var o=a.vout[t];o.chain="VNS",o.network="main"===i.node.network.type?"mainnet":"testnet",o.coinbase=s.isCoinbase(),o.mintTxid=r,o.address=a.vout[t].scriptPubKey.addresses?a.vout[t].scriptPubKey.addresses[0]:"",o.spentTxid=a.vout[t].spentTxid||"",o.spentHeight=a.vout[t].spentHeight||0,o.mintIndex=t,o.mintHeight=s.height,o.value=n.value,o.confirmations=s.confirmations,o.script=n.script.raw.toString("hex"),e.outputs.push(o),t++}),e}return null}},{name:"getRawTx",method:"get",path:"/public/rawtx/:txid",callback:async function(e,t){return e=(e=e.valid()).str("txid"),{rawtx:e=await this.rpc.execute({method:"tx.raw.get",params:[e]})}}},{name:"getBlob",method:"get",path:"/public/blob/:txid/:index",callback:async function(e,t){var i=(e=e.valid()).hash("txid");e=e.uint("index");if(!(i=await this.node.getMeta(i))||!i.tx)return null;if(!(i=i.tx.outputs[e]))return null;if(!(e=i.getReturnData([d.OP_PROPEXCHANGE,d.OP_PROPCREATE]))||!e.oid)return null;if(!(i=await this.node.chain.db.erList.query([["erid",e.oid]]))||!i.list||!i.list[0].erid)return null;let r=i.list[0].source.blob;return"string"==typeof r&&(r=JSON.parse(r)),t.setHeader("content-type",r.type),{data:r}}},{name:"notify",method:"post",path:"/public/notify",callback:async function(e,t){return e.body.sign==(delete e.body.sign,e.body.secret=this.node.config.remotesecret,f.hash256(Buffer.from(JSON.stringify(e.body))).toString("hex"))?(delete e.body.secret,console.log("remote notify:",JSON.stringify(e.body)),{code:0}):{code:-1}}},{name:"getList",method:"get",path:"/public/txs",callback:async function(e,t){s(!this.chain.options.spv,"Cannot get TX in SPV mode.");var i,p=e.query.blockHash,d=l(e.query.address),f=(e=parseInt(e.query.pageNum)||0,1);if(p){if(!(p=await u(this.node,p,t)))return a(null,t);t=p.txids.length;var m,g,y=(r.isUndefined(e)?i=p.txids:(m=10*e,i=p.txids.slice(m,10+m),f=Math.ceil(t/10)),[]);for(g of i){var v=await o(this.node,n.revHex(g));v&&y.push(await c(this.node,v,{}))}return{pagesTotal:f,txs:y}}if(d){var b=10*e,w=10*(e+1),k=[];p=await this.node.getMetaByAddress(d);let t=0;for(const e of p){if(t<b);else{if(t>=w)break;var x=await h(this.node,e);k.push(await c(this.node,x,{}))}t++}return{pagesTotal:Math.ceil(p.length/10),txs:k}}throw new Error("Block hash or address expected")}},{name:"block",method:"get",path:"/public/block/:blockHash/coins/:pageSize/:pageNum",callback:async function(e,t){var i=this,p=(s(!i.chain.options.spv,"Cannot get TX in SPV mode."),e.query.blockHash),d=e.params.pageSize?parseInt(e.params.pageSize):100,f=l(e.query.address),m=parseInt(e.params.pageNum)-1||0,g=1;if(p=p||e.params.blockHash){if(!(e=await u(i.node,p,t)))return a(null,t);t=e.txids.length;var y,v=[],b=[],w=(r.isUndefined(m)?y=e.txids:(E=m*d,y=e.txids.slice(E,E+d),g=Math.ceil(t/d)),[]);for(let e of y){let t=await o(i.node,n.revHex(e),!0),r=null;if(t){r=await c(i.node,t,{}),w.push(r);let s=0;t.inputs.map(a=>{a.isCoinbase()||v.push({coinbase:!1,chain:"VNS",network:"main"===i.node.network.type?"mainnet":"testnet",mintTxid:n.revHex(a.prevout.hash),mintIndex:a.prevout.index,spentTxid:e,spentHeight:t.height,confirmations:t.confirmations,sequenceNumber:a.sequence,script:a.script.raw.toString("hex"),address:r.vin[s].addr||"",mintHeight:r.vin[s].mintHeight||0,value:r.vin[s].valueSat||0}),s++}),s=0,t.outputs.map(n=>{b.push({coinbase:t.isCoinbase(),chain:"VNS",network:"main"===i.node.network.type?"mainnet":"testnet",mintTxid:e,address:r.vout[s].scriptPubKey.addresses?r.vout[s].scriptPubKey.addresses[0]:"",spentTxid:r.vout[s].spentTxid||"",spentHeight:r.vout[s].spentHeight||0,mintIndex:s,mintHeight:t.height,value:n.value,confirmations:t.confirmations,script:n.script.raw.toString("hex")}),s++})}}return{txids:y,previous:"",next:m+1<g?`/block/${p}/coins/${d}/`+(m+2):"",inputs:v,outputs:b}}if(f){var k=m*d,x=(m+1)*d,S=[];e=await i.node.getMetaByAddress(f);let t=0;for(const r of e){if(t<k);else{if(t>=x)break;var _=await h(i.node,r);S.push(await c(i.node,_,{}))}t++}var E=Math.ceil(e.length/d);return{txids:y,previous:"",next:`/block/${p}/coins/${d}/`+((m+1)%E+1),pagesTotal:E,inputs:[],outputs:[],txs:S}}throw new Error("Block hash or address expected")}},{name:"getTxSend",method:"get",path:"/public/rawsend/:tx",callback:async function(e,t){return e=(e=e.valid()).str("tx"),e=await this.rpc.execute({method:"tx.raw.send",params:[e]})}},{name:"getDetailedTransaction",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new p([t])).hash(0),o(e,t,!0)}},{name:"getTransaction",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new p([t])).hash(0),e=await o(e,t,!1)}},{name:"getRawTransaction",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new p([t])).str(0),e=await e.rpc.execute({method:"tx.raw.get",params:[t]})}},{name:"getMempoolTransaction",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new p([t])).hash(0),e.mempool.getTX(t)}}]},function(e,t,i){const r=i(19).opcodes,s=i(31),n=i(2).revHex,a=i(80);e.exports=[{name:"prop.byaddress",method:"get",path:"/public/props/address/:address",callback:async function(e,t){return e=e.valid().str("address"),this.node.chain.db.getVpByAddress(e)}},{name:"prop.bidlist",method:"jsonp",path:"/",callback:async function(e,t){e.bidList||(e.bidList=new s);t=new a([t]);var i=Math.max(0,t.uint(0));return 0==i?(t=t.str(1))?e.bidList.query([["pid",t],["size",e.bidList.getSize()],["page",1]]):e.bidList.query([["size",e.bidList.getSize()],["page",1]]):e.bidList.query([["size",10],["page",i]])}},{name:"propBidlist",method:"get",path:"/public/prop/bidlist/:page",callback:async function(e,t){return this.node.bidList||(this.node.bidList=new s),e=e.valid(),(e=Math.max(0,e.uint("page",0)))?this.node.bidList.query([["size",10],["page",e]]):this.node.bidList.query([["size",this.node.bidList.getSize()],["page",1]])}},{name:"propBidOne",method:"get",path:"/public/prop/bidone/:pid",callback:async function(e,t){return this.node.bidList||(this.node.bidList=new s),(e=e.valid().str("pid"))?this.node.bidList.query([["pid",e],["page",1]]):[]}},{name:"prop.get",method:"get",path:"/public/prop/:pid",callback:async function(e,t){var i=[],s=(e=e.valid().str("pid"),await this.node.chain.db.propList.getVp(e));if(s){let e=[s.current.hash,s.current.index];for(;;){var a=await this.node.getMeta(e[0]),o=a.tx;if(!o)break;if(!(o=o.outputs[e[1]]))break;var c=o.getReturnData([r.OP_PROPCREATE,r.OP_PROPEXCHANGE]);if(!c)break;if(c.current={hash:n(e[0]),index:e[1],address:o.getAddress().toString()},c.height=a.height,c.status=s.pst,c.pst=s.pst,c.gold=s.gold,0==i.length&&s.bid&&(c.bid=s.bid),i.push(c),!c.prev)break;e=[c.prev.hash,c.prev.index]}}return i}}]},function(e,t,i){const r=i(80);e.exports=[{name:"cp.remoteQuery",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new r([t])).array(0,[]),e.chain.db.cpList.query(t)},remoteCb:async function(e){if(e&&Array.isArray(e.list))for(var t of e.list)this.wdb.cpList.getItem(t.cid)||await this.wdb.cpList.addItem(t);return e}},{name:"cps",method:"get",path:"/public/cps",callback:async function(e,t){return e={page:e.valid().u32("page",1),pageCount:0},{list:this.chain.db.cpList.getCPList([],e),cur:e.page,page:e.pageCount}}},{name:"cpById",method:"get",path:"/public/cp/:id",callback:async function(e,t){var i=(e=e.valid()).u32("page",1);e=e.str("id");return(e=this.chain.db.cpList.getCPList(e?[e]:[],{page:i}))&&0<e.length?e[0]:null}},{name:"cpByName",method:"get",path:"/public/cp/name/:name",callback:async function(e,t){var i=(e=e.valid()).u32("page",1);e=decodeURIComponent(e.str("name"));return(e=this.chain.db.cpList.getCPListByName(e?[e]:[],{page:i}))&&0<e.length?e[0]:null}}]},function(e,t,i){const r=i(80),s=i(100),n=i(77),a=i(78).errors,o=i(67),c=i(5).ContractStatus,h=i(20),u=i(33);e.exports=[{name:"token.random",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){if(1!==t.length)throw new n(a.MISC_ERROR,"token.random clientNo: 生成令牌随机量 终端编码");return t=new r([t]).str(0),t=o.getHmac(t,e.keys.hmacSalt).random}},{name:"mempool.watch",method:"jsonp",path:"/",callback:async function(e,t,i){i&&i.join("mempool")}},{name:"mempool.unwatch",method:"jsonp",path:"/",callback:async function(e,t,i){i&&i.leave("mempool")}},{name:"chain.watch",method:"jsonp",path:"/",callback:async function(e,t,i){i&&i.join("chain")}},{name:"chain.unwatch",method:"jsonp",path:"/",callback:async function(e,t,i){i&&i.leave("chain")}},{name:"chain.rescan",method:"jsonp",path:"/",callback:async function(e,t,i){if(null==(t=new r([t]).numhash(0)))throw new Error("Invalid parameter.");return e.http.scan(i,t)}},{name:"subscribe",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){if(i&&Array.isArray(t))for(var r of t)i.bus.subscribe(r);return!0}},{name:"unsubscribe",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){if(i&&Array.isArray(t))for(var r of t)i.bus.unsubscribe(r);return!0}},{name:"filter.set",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){if(i){if(t=new r([t]).buf(0))return i.filter=s.fromRaw(t),null;throw new Error("Invalid parameter.")}}},{name:"filter.reset",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){i&&(i.filter=null)}},{name:"filter.add",local:!0,method:"jsonp",path:"/",callback:async function(e,t,i){if(i){var s=new r([t]).array(0);if(!s)throw new Error("Invalid parameter.");if(!i.filter)throw new Error("No filter set.");for(let t=0;t<s.length;t++){var n=s[t];if(!n)throw new Error("Bad data chunk.");i.filter.add(n),e.spv&&e.pool.watch(n)}}}},{name:"canExecute",method:"jsonp",path:"/",callback:async function(e,t){return(t=new r([t]).obj(0,{})).confirm||"cpChange"==t.oper?e.chain.db.cpList.canExecute(t):await e.mempool.cpMemList.canExecute(t)&&await e.chain.db.cpList.canExecute(t)}},{name:"contract.list",method:"jsonp",path:"/",callback:async function(e,t){var i,s,n,a;return 0==t.length?"contract.list type page ids size: 查询并返回交易对 交易类型 指定查询的ID数组 页码":(a=(t=new r([t])).uint(0,1),i=t.uint(1,1),s=t.array(2,[]),t=t.int(3,10),(n=[]).push(["transStatus",c.CreatedOnMem]),a&&n.push(["type",a]),0<s.length&&n.push(["id","include",s]),{pageNum:(a=e.chain.db.transactionList.where(n).paginate(t,i)).pageNum,pageCur:a.pageCur,list:a.records()})},remoteCb:async function(e){if(e&&Array.isArray(e.list))for(var t of e.list)this.wdb.transactionList.saveContract(t,!0);return e}},{name:"block.tip",method:"jsonp",path:"/",callback:async function(e,t){return e.chain.tip.toRaw()}},{name:"block.entry",method:"jsonp",path:"/",callback:async function(e,t){if(null==(t=new r([t]).numhash(0)))throw new Error("Invalid parameter.");return(t=await e.chain.getEntry(t))&&await e.chain.isMainChain(t)?t.toRaw():null}},{name:"$tx.broadcast",method:"jsonp",path:"/",callback:async function(e,t,i){t=new r([t]).buf(0),t=h.fromRaw(t),await e.sendTX(t)}},{name:"$estimate.fee",method:"jsonp",path:"/",callback:async function(e,t){if(t=new r([t]).u32(0,1),e.fees)return 0===(e=e.fees.estimateFee(t,!1))?-1:u.btc(e,!0);throw new n(a.MISC_ERROR,"Fee estimation not available.")}}]},function(e,t,i){const r=i(80),s=i(784);e.exports=[{name:"ca.get",method:"get",path:"/public/ca/:erid",callback:async function(e,t){return e=e.valid().str("erid"),(e=await this.node.chain.db.erList.query([["erid",e]])).height=this.node.chain.height,e}},{name:"ca.byId",method:"jsonp",path:"/",callback:async function(e,t){return t=new r([t]).str(0),e.chain.db.erList.getEr(t)}},{name:"ca.rank",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new r([t])).str(0,""),(e=await(async e=>new Promise((t,i)=>{s(e,.85,1e-4,(function(e,r){e?i(e):t(r)}))}))(e.chain.db.enCpList.rank))[t]},remoteCb:async function(e){return e}},{name:"ca.list",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new r([t])).array(0,[]),(t=await e.chain.db.erList.query(t)).height=e.chain.height,t}},{name:"ca.verify",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new r([t])).str(0,""),(t=await e.chain.db.caVerify(t))&&(t.curHeight=e.chain.height),t},remoteCb:async function(e){return e}},{name:"ca.list.ab",method:"jsonp",path:"/",callback:async function(e,t){return t=(t=new r([t])).array(0,[]),e.chain.db.erAbList.query(t)},remoteCb:async function(e){return e}}]},function(e,t,i){"use strict";class r{constructor(e,t,i,r,s){this.outgoingNodes=e,this.linkProb=t,this.tolerance=i,this.callback=r,this.pageCount=Object.keys(this.outgoingNodes).length,this.coeff=(1-t)/this.pageCount,this.probabilityNodes=e instanceof Array?[]:{},this.incomingNodes=e instanceof Array?[]:{},this.debug=s,this.startRanking()}startRanking(){var e,t,i,r=1/this.pageCount,s=this.outgoingNodes;for(e in s)for(t in this.probabilityNodes[e]=r,s[e])i=s[e][t],this.incomingNodes[i]||(this.incomingNodes[i]=[]),this.incomingNodes[i].push(e);this.debug&&this.reportDebug(1),this.iterate(1)}reportDebug(e){console.log("____ITERATION "+e+"____"),console.log("Pages: "+Object.keys(this.outgoingNodes).length),console.log("outgoing %j",this.outgoingNodes),console.log("incoming %j",this.incomingNodes),console.log("probability %j",this.probabilityNodes)}iterate(e){var t,i,r,s,n,a=[],o={};for(t in this.probabilityNodes){if(r=0,this.incomingNodes[t])for(i=0;i<this.incomingNodes[t].length;i++)r+=this.probabilityNodes[this.incomingNodes[t][i]]/this.outgoingNodes[this.incomingNodes[t][i]].length;s=this.coeff+this.linkProb*r,n=this.probabilityNodes[t]+this.tolerance,this.probabilityNodes[t]-this.tolerance<=s&&s<=n&&a.push(o[t]=s),this.probabilityNodes[t]=s}return a.length==this.pageCount?this.outgoingNodes instanceof Array?this.callback(null,a):this.callback(null,o):(this.debug&&this.reportDebug(e),this.iterate(++e))}}e.exports=function(e,t,i,s,n=!1){if(e&&t&&i&&s)return new r(e,t,i,s,n);throw new Error("Provide 4 arguments: nodeMatrix, link probability, tolerance, callback")}},function(e,t,i){"use strict";e.exports=class{constructor(e){this.config=e,this.hmacConnection=this.config.array("hmac-connection")||[],this.config.hmacConnection=this.hmacConnection}add(e){-1==this.hmacConnection.indexOf(e)&&this.hmacConnection.push(e),this.config.hmacConnection=this.hmacConnection}del(e){-1!=(e=this.hmacConnection.indexOf(e))&&(this.hmacConnection.splice(e,1),this.config.hmacConnection=this.hmacConnection)}clear(){this.hmacConnection=[],this.config.hmacConnection=this.hmacConnection}content(){return this.hmacConnection}has(e){return-1!=this.hmacConnection.indexOf(e)}}},function(e,t,i){"use strict";
|
|
1694
1694
|
/*!
|
|
1695
1695
|
* mempool/index.js - mempool for vallnet
|
|
1696
1696
|
* Copyright (c) 2019-2022, Bookman Software (MIT License).
|