@gvnrdao/dh-sdk 0.0.150 → 0.0.151
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/README.md +45 -0
- package/browser/dist/20.browser.js +1 -0
- package/browser/dist/397.browser.js +1 -1
- package/browser/dist/833.browser.js +1 -1
- package/browser/dist/browser.js +3 -3
- package/dist/index.d.mts +310 -223
- package/dist/index.d.ts +310 -223
- package/dist/index.js +1239 -3926
- package/dist/index.mjs +1239 -3926
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,6 +58,7 @@ if (result.success) {
|
|
|
58
58
|
- ✅ **PKP Integration**: Secure key management with LIT Protocol
|
|
59
59
|
- ✅ **Smart Contract Integration**: Direct interaction with Diamond Hands contracts
|
|
60
60
|
- ✅ **Bitcoin Operations**: Support for Bitcoin deposit verification
|
|
61
|
+
- ✅ **Telegram Notifications**: Optional event notifications (Node.js only)
|
|
61
62
|
|
|
62
63
|
## API Reference
|
|
63
64
|
|
|
@@ -72,6 +73,50 @@ if (result.success) {
|
|
|
72
73
|
|
|
73
74
|
See the full API documentation for detailed configuration options and method signatures.
|
|
74
75
|
|
|
76
|
+
## Telegram Notifications
|
|
77
|
+
|
|
78
|
+
The SDK supports optional Telegram notifications for loan events (minting, payments, renewals, etc.). These notifications only work in Node.js environments due to browser security restrictions.
|
|
79
|
+
|
|
80
|
+
### Enabling Telegram Notifications
|
|
81
|
+
|
|
82
|
+
Add the `telegram` configuration when initializing the SDK:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
const sdk = new DiamondHandsSDK({
|
|
86
|
+
mode: "service",
|
|
87
|
+
serviceEndpoint: "http://localhost:3001",
|
|
88
|
+
telegram: {
|
|
89
|
+
chatId: "your-chat-id",
|
|
90
|
+
chatToken: "your-bot-token",
|
|
91
|
+
threadId: 123 // Optional: for group threads
|
|
92
|
+
},
|
|
93
|
+
// ... other config
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Browser Behavior
|
|
98
|
+
|
|
99
|
+
**Important**: Telegram notifications are automatically disabled in browser environments to avoid CORS errors. The SDK detects browser environments and silently skips notification attempts without breaking your application flow.
|
|
100
|
+
|
|
101
|
+
- ✅ **Node.js**: Notifications sent via Telegram Bot API
|
|
102
|
+
- ✅ **Browser**: Notifications silently skipped (no errors)
|
|
103
|
+
- ✅ **Development**: Console logs in localhost for debugging
|
|
104
|
+
|
|
105
|
+
### Supported Events
|
|
106
|
+
|
|
107
|
+
The SDK sends notifications for:
|
|
108
|
+
- Loan creation
|
|
109
|
+
- UCD minting
|
|
110
|
+
- Partial payments
|
|
111
|
+
- Loan renewals
|
|
112
|
+
- Balance confirmations
|
|
113
|
+
- BTC withdrawals
|
|
114
|
+
- Operation failures
|
|
115
|
+
|
|
116
|
+
### Security Note
|
|
117
|
+
|
|
118
|
+
Never expose your Telegram bot token in frontend code. If you need notifications from browser applications, use a backend webhook endpoint instead.
|
|
119
|
+
|
|
75
120
|
## License
|
|
76
121
|
|
|
77
122
|
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const __webpack_esm_id__=20;export const __webpack_esm_ids__=[20];export const __webpack_esm_modules__={2681:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DH_LIT_ACTIONS_REGISTRY=void 0;const r=o(89852);t.DH_LIT_ACTIONS_REGISTRY={packageName:"dh-lit-actions",packageVersion:"0.1.0",buildTime:Date.now(),totalActions:Object.keys(r.DH_LIT_ACTIONS_DATIL).length,actions:r.DH_LIT_ACTIONS_DATIL}},9006:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},9877:function(e,t,o){var r,i=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[t.length]=o);return t},r(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o=r(e),a=0;a<o.length;a++)"default"!==o[a]&&i(t,e,o[a]);return n(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.NETWORK_TIMEOUTS=t.DEFAULT_RETRY_CONFIG=void 0,t.sleep=d,t.isRetryableError=function(e,o=t.DEFAULT_RETRY_CONFIG.retryableErrors){if(!e)return!1;const r=(0,s.classifyError)(e);if(void 0!==r.isRetryable)return(0,c.debugInfo)("ERROR_CLASSIFICATION",`Error classified as: ${r.category} (retryable: ${r.isRetryable})`),r.isRetryable;const i=(e.message||e.toString()||"").toLowerCase();return o.some(e=>i.includes(e.toLowerCase()))},t.calculateDelay=f,t.withRetry=u,t.connectLitNodeClient=async function(e,o={}){const r=e?.config?.litNetwork||"unknown";return u(async()=>{if(!e)throw new Error("LIT Node Client is null or undefined");const i=Date.now();(0,c.logConnectionAttempt)(r,1,o.maxAttempts||t.DEFAULT_RETRY_CONFIG.maxAttempts),await e.connect(),(0,c.debugInfo)("CONNECTION","⏳ Waiting for LIT Node Client to be ready...");const n=Date.now();for(;!e.ready&&Date.now()-n<3e4;)await d(500);if(!e.ready)throw new Error("LIT Node Client failed to become ready within 30000ms");const a=Date.now()-i;(0,c.debugInfo)("CONNECTION",`✅ LIT Node Client is ready (${e.ready})`),(0,c.logConnectionSuccess)(r,a)},o,"LIT Node Client Connection")},t.connectLitContracts=async function(e,t={}){return u(async()=>{if(!e)throw new Error("LIT Contracts is null or undefined");console.log(`🔗 Connecting to LIT Contracts: ${e.network||"unknown"}`),await e.connect(),console.log("✅ LIT Contracts connected successfully")},t,"LIT Contracts Connection")},t.validateLitNodeConnection=async function(e){try{const t=Date.now();return e?(await e.getLatestBlockhash(),{isValid:!0,latencyMs:Date.now()-t}):{isValid:!1,error:"LIT Node Client is null or undefined"}}catch(e){return{isValid:!1,error:e?.message||e?.toString()||"Unknown validation error"}}},t.generateSessionSignatures=async function(e,t,r={},i,n,s,d="datil"){if(i&&n&&s){const{sessionSignatureCache:e}=await Promise.resolve().then(()=>a(o(62133))),t=e.get(i,n,s,d);if(t){const e=Object.keys(t).length;return(0,c.debugInfo)("SESSION",`🔄 Using cached session signatures (${e} sigs)`),t}}return u(async()=>{(0,c.debugInfo)("SESSION","🔐 Generating new session signatures...");const r=await e.getSessionSigs(t),f=Object.keys(r).length;if(i&&n&&s){const{sessionSignatureCache:e}=await Promise.resolve().then(()=>a(o(62133))),c=new Date(t.expiration);e.set(i,n,s,d,r,c)}return(0,c.debugInfo)("SESSION",`✅ Generated ${f} session signatures`),r},r,"Session Signature Generation")},t.validateLitNodeReadiness=l,t.executeLitAction=async function(e,t,o={}){const r=t.ipfsId;return u(async()=>{const o=Date.now();await l(e),(0,c.logLitActionExecution)(r,t.jsParams),(0,c.logRequest)("LIT_ACTION","executeJs",t);const i=await e.executeJs(t),n=Date.now()-o;if(!i.response)throw(0,c.logError)("LIT_ACTION","executeJs",new Error("No response from LIT Action"),n),new Error("No response from LIT Action");return(0,c.logResponse)("LIT_ACTION","executeJs",i,n),(0,c.logLitActionResult)(r,!0,n,i),i},o,"LIT Action Execution")},t.executePkpOperation=async function(e,o,r={}){return u(e,{...t.DEFAULT_RETRY_CONFIG,...r,retryableErrors:[...t.DEFAULT_RETRY_CONFIG.retryableErrors,"pkp validation","signing shares","resource validation","ipfs propagation"]},`PKP ${o}`)},t.getNetworkTimeouts=function(e){return t.NETWORK_TIMEOUTS[e]||t.NETWORK_TIMEOUTS.datil};const c=o(83623),s=o(41020);function d(e){return new Promise(t=>setTimeout(t,e))}function f(e,t){const o=Math.min(t.initialDelayMs*Math.pow(t.backoffMultiplier,e-1),t.maxDelayMs),r=.25*o*(Math.random()-.5);return Math.max(100,o+r)}async function u(e,o={},r="operation"){let i={...t.DEFAULT_RETRY_CONFIG,...o};const n=new c.PerformanceTracker(`Retry ${r}`);let a,u=null;for(let t=1;t<=i.maxAttempts;t++)try{(0,c.debugInfo)("RETRY",`🔄 [${r}] Attempt ${t}/${i.maxAttempts}`);const o=Date.now(),a=await e(),s=Date.now()-o;return(0,c.debugInfo)("RETRY",`✅ [${r}] Success after ${s}ms (attempt ${t})`),c.networkMetrics.recordRequest(r,!0,s),n.end(!0),a}catch(e){a=e;const o=e?.message||e?.toString()||"Unknown error";if(u=(0,s.classifyError)(e),1===t&&u){const e=(0,s.getRetryConfigFromClassification)(u);i={...i,...e,maxAttempts:Math.min(i.maxAttempts,e.maxAttempts)},(0,c.debugInfo)("RETRY",`🧠 Intelligent retry strategy applied: ${u.category} (${u.retryStrategy})`),(0,c.debugInfo)("RETRY",`📊 Adjusted config: max=${i.maxAttempts}, delay=${i.initialDelayMs}ms`)}if((0,c.debugWarn)("RETRY",`⚠️ [${r}] Attempt ${t} failed:`,{error:o,attempt:t,category:u.category,retryable:u.isRetryable}),c.networkMetrics.recordRequest(r,!1,0,o),t>=i.maxAttempts){if((0,c.debugError)("RETRY",`❌ [${r}] All attempts failed. Last error:`,{error:o}),u){const t=(0,s.createErrorReport)(e);(0,c.debugError)("RETRY",`📋 Error Analysis Report:\n${t}`)}n.end(!1);break}if(!u.isRetryable){(0,c.debugError)("RETRY",`🚫 [${r}] Non-retryable error (${u.category}):`,{error:o}),u.troubleshooting&&(0,c.debugInfo)("RETRY",`💡 Troubleshooting suggestions:\n ${u.troubleshooting.join("\n ")}`),n.end(!1);break}const l=f(t,i);(0,c.debugInfo)("RETRY",`⏳ [${r}] Waiting ${l}ms before retry... (${u.retryStrategy} strategy)`),await d(l)}throw a}async function l(e){if(!e)throw new Error("LIT Node Client is null or undefined");if(!e.ready){(0,c.debugWarn)("CONNECTION","⚠️ LIT Node Client not ready, attempting to reconnect..."),await e.connect();const t=15e3,o=Date.now();for(;!e.ready&&Date.now()-o<t;)await d(500);if(!e.ready)throw new Error("LIT Node Client is not ready for operations")}(0,c.debugInfo)("CONNECTION","✅ LIT Node Client readiness validated")}t.DEFAULT_RETRY_CONFIG={maxAttempts:5,initialDelayMs:2e3,maxDelayMs:6e4,backoffMultiplier:2,retryableErrors:["request_timeout","network error","connection failed","ENOTFOUND","ECONNREFUSED","ETIMEDOUT","socket hang up","timeout","signing shares","There was an error getting the signing shares","PKP validation","pkp validation failed","resource validation","ipfs propagation","session.*expired","NodeError","Response from the nodes","consensus","threshold"]},t.NETWORK_TIMEOUTS={datil:{connection:6e4,operation:12e4,pkpValidation:18e4},"datil-test":{connection:3e4,operation:6e4,pkpValidation:9e4}}},13525:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||r(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),i(o(55297),t),i(o(9006),t),i(o(18888),t),i(o(66099),t)},16326:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||r(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),i(o(72287),t),i(o(39882),t),i(o(70809),t),i(o(9877),t),i(o(83623),t),i(o(41020),t),i(o(62133),t)},18888:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},39882:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getPKPValidatorSetup=function(e="datil"){return{litAction:"datil"===e?r.DH_LIT_ACTIONS_DATIL.pkpValidator:(()=>{throw new Error("Unsupported LIT network")})(),pkp:"datil"===e?r.DH_LIT_ACTIONS_DATIL.pkpValidator.pkp:(()=>{throw new Error("Unsupported LIT network")})()}};const r=o(89852)},41020:(e,t)=>{var o,r;Object.defineProperty(t,"__esModule",{value:!0}),t.litProtocolErrors=t.RetryStrategy=t.ErrorCategory=void 0,t.classifyError=c,t.getRetryConfigFromClassification=s,t.analyzeError=d,t.createErrorReport=function(e){const t=d(e),o=["🔍 Error Analysis Report","=====================================",`Category: ${t.category.toUpperCase()}`,"Retryable: "+(t.isRetryable?"✅ Yes":"❌ No"),`Strategy: ${t.retryStrategy}`,`Max Attempts: ${t.maxAttempts}`,`Description: ${t.description}`,`Timestamp: ${t.timestamp}`,"",`Original Error: ${t.errorMessage}`,""];return t.troubleshooting&&t.troubleshooting.length>0&&(o.push("🛠️ Troubleshooting Steps:"),t.troubleshooting.forEach((e,t)=>{o.push(` ${t+1}. ${e}`)}),o.push("")),o.join("\n")},function(e){e.NETWORK="network",e.PROTOCOL="protocol",e.AUTHENTICATION="authentication",e.RESOURCE="resource",e.VALIDATION="validation",e.TIMEOUT="timeout",e.RATE_LIMIT="rate_limit",e.CONFIGURATION="configuration",e.UNKNOWN="unknown"}(o||(t.ErrorCategory=o={})),function(e){e.AGGRESSIVE="aggressive",e.CONSERVATIVE="conservative",e.EXPONENTIAL="exponential",e.LINEAR="linear",e.NONE="none"}(r||(t.RetryStrategy=r={}));const i={network:[/network error/i,/connection failed/i,/connection refused/i,/connection timeout/i,/socket hang up/i,/enotfound/i,/econnrefused/i,/etimedout/i,/dns resolution failed/i,/request failed/i],protocol:[/lit protocol/i,/lit node/i,/signing shares/i,/node communication/i,/consensus/i,/threshold/i,/decryption/i,/signature verification/i,/There was an error getting the signing shares/i,/Response from the nodes/i,/NodeError/i,/PKP validation/i,/pkp validation failed/i],authentication:[/authentication/i,/authorization/i,/session.*expired/i,/invalid.*signature/i,/unauthorized/i,/access.*denied/i,/permission/i,/auth.*failed/i,/siwe/i,/session.*sig/i],resource:[/resource.*not.*found/i,/ipfs.*not.*found/i,/cid.*invalid/i,/pkp.*not.*found/i,/pkp.*validation/i,/resource.*validation/i,/action.*not.*permitted/i,/lit.*action.*not.*found/i],validation:[/validation.*failed/i,/invalid.*input/i,/invalid.*parameter/i,/malformed/i,/schema.*validation/i,/type.*error/i,/missing.*required/i],timeout:[/timeout/i,/request.*timed.*out/i,/operation.*timed.*out/i,/deadline.*exceeded/i,/time.*limit.*exceeded/i],rateLimit:[/rate.*limit/i,/too.*many.*requests/i,/quota.*exceeded/i,/throttled/i,/429/,/rate.*exceeded/i],configuration:[/configuration/i,/config.*error/i,/environment/i,/missing.*env/i,/invalid.*config/i,/setup.*error/i]},n={[r.AGGRESSIVE]:{maxAttempts:5,baseDelayMs:500,maxDelayMs:5e3,multiplier:1.5},[r.CONSERVATIVE]:{maxAttempts:3,baseDelayMs:3e3,maxDelayMs:3e4,multiplier:2.5},[r.EXPONENTIAL]:{maxAttempts:4,baseDelayMs:1e3,maxDelayMs:15e3,multiplier:2},[r.LINEAR]:{maxAttempts:3,baseDelayMs:2e3,maxDelayMs:1e4,multiplier:1},[r.NONE]:{maxAttempts:1,baseDelayMs:0,maxDelayMs:0,multiplier:1}},a={[o.NETWORK]:{category:o.NETWORK,retryStrategy:r.AGGRESSIVE,isRetryable:!0,...n[r.AGGRESSIVE],description:"Network connectivity or communication error",troubleshooting:["Check internet connection","Verify LIT Protocol network status","Check firewall and proxy settings","Try connecting to different node endpoints"]},[o.PROTOCOL]:{category:o.PROTOCOL,retryStrategy:r.CONSERVATIVE,isRetryable:!0,...n[r.CONSERVATIVE],description:"LIT Protocol specific operational error",troubleshooting:["Check LIT Protocol network status","Verify PKP configuration","Check signing shares availability","Wait for network consensus"]},[o.AUTHENTICATION]:{category:o.AUTHENTICATION,retryStrategy:r.EXPONENTIAL,isRetryable:!0,...n[r.EXPONENTIAL],maxAttempts:2,description:"Authentication or authorization error",troubleshooting:["Check session signatures validity","Regenerate authentication tokens","Verify wallet permissions","Check PKP authorization status"]},[o.RESOURCE]:{category:o.RESOURCE,retryStrategy:r.LINEAR,isRetryable:!0,...n[r.LINEAR],maxAttempts:2,description:"Resource not found or validation error",troubleshooting:["Verify resource CIDs are correct","Check IPFS availability","Confirm PKP exists and is accessible","Wait for resource propagation"]},[o.VALIDATION]:{category:o.VALIDATION,retryStrategy:r.NONE,isRetryable:!1,...n[r.NONE],description:"Input validation or schema error",troubleshooting:["Check input parameters format","Verify required fields are provided","Validate data types and ranges","Review API documentation"]},[o.TIMEOUT]:{category:o.TIMEOUT,retryStrategy:r.CONSERVATIVE,isRetryable:!0,...n[r.CONSERVATIVE],description:"Operation timeout error",troubleshooting:["Increase timeout values","Check network latency","Verify system resources","Split operations into smaller chunks"]},[o.RATE_LIMIT]:{category:o.RATE_LIMIT,retryStrategy:r.CONSERVATIVE,isRetryable:!0,...n[r.CONSERVATIVE],maxAttempts:2,baseDelayMs:5e3,description:"Rate limit or quota exceeded",troubleshooting:["Reduce request frequency","Implement request batching","Check rate limit headers","Wait for quota reset"]},[o.CONFIGURATION]:{category:o.CONFIGURATION,retryStrategy:r.NONE,isRetryable:!1,...n[r.NONE],description:"Configuration or setup error",troubleshooting:["Check environment variables","Verify configuration files","Review setup documentation","Check required dependencies"]},[o.UNKNOWN]:{category:o.UNKNOWN,retryStrategy:r.EXPONENTIAL,isRetryable:!0,...n[r.EXPONENTIAL],maxAttempts:2,description:"Unknown or unclassified error",troubleshooting:["Check logs for more details","Verify system status","Try again with debug logging","Contact support if persists"]}};function c(e){const t=e?.message||e?.toString()||"",r=t.toLowerCase();for(const[e,o]of Object.entries(i))for(const i of o)if(i.test(t)||i.test(r)){const o=a[e];return{...o,description:`${o.description}: ${t.slice(0,100)}`}}const n=a[o.UNKNOWN];return{...n,description:`${n.description}: ${t.slice(0,100)}`}}function s(e){return{maxAttempts:e.maxAttempts,initialDelayMs:e.baseDelayMs,maxDelayMs:e.maxDelayMs,backoffMultiplier:n[e.retryStrategy].multiplier,retryableErrors:["*"]}}function d(e){const t=c(e);return{...t,originalError:e,errorMessage:e?.message||e?.toString()||"Unknown error",errorStack:e?.stack,timestamp:(new Date).toISOString(),retryConfig:s(t)}}t.litProtocolErrors={isNetworkError:e=>c(e).category===o.NETWORK,isProtocolError:e=>c(e).category===o.PROTOCOL,isAuthenticationError:e=>c(e).category===o.AUTHENTICATION,isResourceError:e=>c(e).category===o.RESOURCE,isTimeoutError:e=>c(e).category===o.TIMEOUT,isRateLimitError:e=>c(e).category===o.RATE_LIMIT,isConfigurationError:e=>c(e).category===o.CONFIGURATION,isRetryable:e=>c(e).isRetryable}},54897:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let o=0;o<e.length;o++){const r=e.charAt(o),i=r.charCodeAt(0);if(255!==t[i])throw new TypeError(r+" is ambiguous");t[i]=o}const o=e.length,r=e.charAt(0),i=Math.log(o)/Math.log(256),n=Math.log(256)/Math.log(o);function a(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;let n=0,a=0,c=0;for(;e[n]===r;)a++,n++;const s=(e.length-n)*i+1>>>0,d=new Uint8Array(s);for(;n<e.length;){const r=e.charCodeAt(n);if(r>255)return;let i=t[r];if(255===i)return;let a=0;for(let e=s-1;(0!==i||a<c)&&-1!==e;e--,a++)i+=o*d[e]>>>0,d[e]=i%256>>>0,i=i/256>>>0;if(0!==i)throw new Error("Non-zero carry");c=a,n++}let f=s-c;for(;f!==s&&0===d[f];)f++;const u=new Uint8Array(a+(s-f));let l=a;for(;f!==s;)u[l++]=d[f++];return u}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";let i=0,a=0,c=0;const s=t.length;for(;c!==s&&0===t[c];)c++,i++;const d=(s-c)*n+1>>>0,f=new Uint8Array(d);for(;c!==s;){let e=t[c],r=0;for(let t=d-1;(0!==e||r<a)&&-1!==t;t--,r++)e+=256*f[t]>>>0,f[t]=e%o>>>0,e=e/o>>>0;if(0!==e)throw new Error("Non-zero carry");a=r,c++}let u=d-a;for(;u!==d&&0===f[u];)u++;let l=r.repeat(i);for(;u<d;++u)l+=e.charAt(f[u]);return l},decodeUnsafe:a,decode:function(e){const t=a(e);if(t)return t;throw new Error("Non-base"+o+" character")}}}},55297:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},56018:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||r(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),i(o(89852),t),i(o(2681),t)},61407:function(e,t,o){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(o(54897));t.default=(0,i.default)("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},62133:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sessionSignatureCache=t.DEFAULT_CACHE_CONFIG=void 0,t.generateSessionSignaturesWithCache=async function(e,o,i,n,a,c="datil"){const s=t.sessionSignatureCache.get(i,n,a,c);if(s)return s;(0,r.debugInfo)("CACHE","🔐 Generating new session signatures (cache miss)...");const d=await e.getSessionSigs(o),f=new Date(o.expiration);t.sessionSignatureCache.set(i,n,a,c,d,f);const u=Object.keys(d).length;return(0,r.debugInfo)("CACHE",`✅ Generated and cached ${u} session signatures`),d},t.configureSessionSignatureCache=function(e){Object.assign(t.sessionSignatureCache.config,e)},t.clearSessionSignatureCache=function(){t.sessionSignatureCache.clear()},t.getSessionSignatureCacheStats=function(){return t.sessionSignatureCache.getStats()};const r=o(83623);t.DEFAULT_CACHE_CONFIG={maxEntries:50,bufferTimeMs:6e4,enableLogging:!0},t.sessionSignatureCache=new class{constructor(e={}){this.cache=new Map,this.config={...t.DEFAULT_CACHE_CONFIG,...e}}generateCacheKey(e,t,o,r){return`${o}-${r}-${e}-${t}`}isEntryValid(e){return new Date<new Date(e.expiration.getTime()-this.config.bufferTimeMs)}cleanExpiredEntries(){const e=new Date;let t=0;for(const[o,r]of this.cache.entries())e>=r.expiration&&(this.cache.delete(o),t++);t>0&&this.config.enableLogging&&(0,r.debugInfo)("CACHE",`🧹 Cleaned ${t} expired session signature entries`)}enforceCacheSize(){if(this.cache.size<=this.config.maxEntries)return;const e=Array.from(this.cache.entries()).sort(([,e],[,t])=>e.createdAt.getTime()-t.createdAt.getTime()).slice(0,this.cache.size-this.config.maxEntries);for(const[t]of e)this.cache.delete(t);this.config.enableLogging&&(0,r.debugInfo)("CACHE",`📦 Removed ${e.length} oldest cache entries to maintain size limit`)}get(e,t,o,i){this.cleanExpiredEntries();const n=this.generateCacheKey(e,t,o,i),a=this.cache.get(n);if(!a)return this.config.enableLogging&&(0,r.debugLog)("CACHE",`❌ Session signatures cache miss: ${n}`),null;if(!this.isEntryValid(a))return this.cache.delete(n),this.config.enableLogging&&(0,r.debugWarn)("CACHE",`⏰ Session signatures expired: ${n}`),null;if(this.config.enableLogging){const e=a.expiration.getTime()-Date.now();(0,r.debugInfo)("CACHE",`✅ Session signatures cache hit: ${n} (expires in ${Math.round(e/1e3)}s)`)}return a.sessionSigs}set(e,t,o,i,n,a){const c=this.generateCacheKey(e,t,o,i),s={sessionSigs:n,expiration:a,pkpTokenId:e,litActionCid:t,signerAddress:o,network:i,createdAt:new Date};if(this.cache.set(c,s),this.config.enableLogging){const e=a.getTime()-Date.now();(0,r.debugInfo)("CACHE",`💾 Cached session signatures: ${c} (expires in ${Math.round(e/1e3)}s)`)}this.enforceCacheSize()}clear(){const e=this.cache.size;this.cache.clear(),this.config.enableLogging&&(0,r.debugInfo)("CACHE",`🗑️ Cleared ${e} cached session signature entries`)}getStats(){return this.cleanExpiredEntries(),{size:this.cache.size,maxEntries:this.config.maxEntries,utilizationPercent:Math.round(this.cache.size/this.config.maxEntries*100)}}delete(e,t,o,i){const n=this.generateCacheKey(e,t,o,i),a=this.cache.delete(n);return a&&this.config.enableLogging&&(0,r.debugInfo)("CACHE",`🗑️ Removed session signatures from cache: ${n}`),a}}},66099:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},70809:function(e,t,o){var r=o(38891).Buffer,i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cidToHex=function(e){try{if(e.startsWith("Qm")){const t=n.default.decode(e);return"0x"+r.from(t).toString("hex")}if(e.startsWith("0x"))return e;throw new Error(`Unsupported CID format: ${e}. Only CIDv0 (Qm...) and hex (0x...) formats are supported.`)}catch(t){if(t instanceof Error&&t.message.includes("Unsupported CID format"))throw t;throw new Error(`Failed to convert CID ${e} to hex: ${t instanceof Error?t.message:String(t)}`)}};const n=i(o(61407))},72287:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getLitActionCID=function(e="datil",t){const o="datil"===e?r.DH_LIT_ACTIONS_DATIL[t]:(()=>{throw new Error("Unsupported LIT network")})();if(!o.deployed||!o.cid)throw new Error(`LIT Action '${t}' not deployed. Check deployment status.`);return o.cid},t.getLitActionConfig=function(e,t="datil"){const o=("datil"===t?r.DH_LIT_ACTIONS_DATIL:(()=>{throw new Error("Unsupported LIT network")})())[e];if(!o)throw new Error(`LIT Action '${e}' not found in registry for network '${t}'.`);return o},t.isLitActionDeployed=i,t.validateDeployedActions=function(e,t="datil"){return e.every(e=>i(e,t))},t.getDeployedActions=function(e="datil"){const t="datil"===e?r.DH_LIT_ACTIONS_DATIL:(()=>{throw new Error("Unsupported LIT network")})();return Object.values(t).filter(e=>e.deployed)};const r=o(56018);function i(e,t="datil"){const o=("datil"===t?r.DH_LIT_ACTIONS_DATIL:(()=>{throw new Error("Unsupported LIT network")})())[e];return!!(o&&o.deployed&&o.cid)}},77639:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||r(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),t.DH_LIT_ACTIONS_DATIL=void 0,i(o(13525),t),i(o(89852),t),i(o(16326),t);var n=o(89852);Object.defineProperty(t,"DH_LIT_ACTIONS_DATIL",{enumerable:!0,get:function(){return n.DH_LIT_ACTIONS_DATIL}})},83623:(e,t)=>{var o;Object.defineProperty(t,"__esModule",{value:!0}),t.networkMetrics=t.PerformanceTracker=t.DEFAULT_DEBUG_CONFIG=t.LogLevel=void 0,t.configureDebugLogging=function(e){r={...r,...e}},t.debugError=a,t.debugWarn=function(e,t,n){r.level>=o.WARN&&console.warn(i("WARN",e,t,n))},t.debugInfo=c,t.debugLog=s,t.debugTrace=function(e,t,n){r.level>=o.TRACE&&console.log(i("TRACE",e,t,n))},t.logRequest=function(e,t,o){r.enableRequestLogging&&s(e,`🔄 Request: ${t}`,{operation:t,params:JSON.stringify(o,null,2)})},t.logResponse=function(e,t,o,i){r.enableRequestLogging&&s(e,`✅ Response: ${t} (${i}ms)`,{operation:t,duration:i,response:"object"==typeof o?JSON.stringify(o,null,2):o})},t.logError=function(e,t,o,r){a(e,`❌ Error: ${t}${r?` (${r}ms)`:""}`,{operation:t,duration:r,error:o?.message||o?.toString()||"Unknown error",stack:o?.stack})},t.logConnectionAttempt=function(e,t,o){c("CONNECTION",`🔗 Connecting to ${e} (attempt ${t}/${o})`)},t.logConnectionSuccess=function(e,o){c("CONNECTION",`✅ Connected to ${e} (${o}ms)`),t.networkMetrics.recordRequest(`connection-${e}`,!0,o)},t.logConnectionFailure=function(e,o,r){a("CONNECTION",`❌ Connection failed to ${e} (attempt ${r})`,{error:o}),t.networkMetrics.recordRequest(`connection-${e}`,!1,0,o)},t.logPkpOperation=function(e,t,o){c("PKP",`🔑 ${e}${t?` (PKP: ${t.slice(0,8)}...)`:""}`,o)},t.logSessionSignatures=function(e,t){c("SESSION",`🔐 Generated ${e} session signatures (expires: ${t})`)},t.logLitActionExecution=function(e,t){c("LIT_ACTION",`⚡ Executing LIT Action: ${e}`,{cid:e,params:t})},t.logLitActionResult=function(e,t,o,r){c("LIT_ACTION",`${t?"✅":"❌"} LIT Action completed: ${e} (${o}ms)`,{cid:e,success:t,duration:o,result:t&&r?JSON.stringify(r,null,2):void 0})},t.logTestStart=function(e){return c("TEST",`🧪 Starting test: ${e}`),new n(e)},t.logTestEnd=function(e,o,r){c("TEST",`${o?"✅":"❌"} Test completed: ${e} (${r}ms)`),t.networkMetrics.printSummary()},function(e){e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e[e.TRACE=4]="TRACE"}(o||(t.LogLevel=o={})),t.DEFAULT_DEBUG_CONFIG={level:o.INFO,enableTimestamps:!0,enablePerformanceMetrics:!0,enableRequestLogging:!0,enableNetworkMetrics:!0};let r={...t.DEFAULT_DEBUG_CONFIG};function i(e,t,o,i){return`${r.enableTimestamps?`[${(new Date).toISOString()}] `:""}[${e}] [${t}] ${o}${i?` ${JSON.stringify(i)}`:""}`}class n{constructor(e){this.operationName=e,this.markers=new Map,this.startTime=Date.now(),this.log("PERF",`Started: ${e}`)}mark(e){const t=Date.now()-this.startTime;this.markers.set(e,t),this.log("PERF",`${this.operationName} - ${e}: ${t}ms`)}end(e=!0){const t=Date.now()-this.startTime,o=e?"SUCCESS":"FAILED";if(this.log("PERF",`${this.operationName} - ${o}: ${t}ms`),r.enablePerformanceMetrics&&this.markers.size>0){console.log(`📊 Performance Breakdown for ${this.operationName}:`);for(const[e,t]of this.markers)console.log(` ${e}: ${t}ms`);console.log(` Total: ${t}ms`)}return t}log(e,t){r.enablePerformanceMetrics&&console.log(i(e,"PERFORMANCE",t))}}function a(e,t,n){r.level>=o.ERROR&&console.error(i("ERROR",e,t,n))}function c(e,t,n){r.level>=o.INFO&&console.log(i("INFO",e,t,n))}function s(e,t,n){r.level>=o.DEBUG&&console.log(i("DEBUG",e,t,n))}t.PerformanceTracker=n,t.networkMetrics=new class{constructor(){this.metrics=new Map}getMetrics(e){return this.metrics.has(e)||this.metrics.set(e,{requestCount:0,successCount:0,failureCount:0,averageLatency:0,startTime:Date.now()}),this.metrics.get(e)}recordRequest(e,t,o,i){const n=this.getMetrics(e);n.requestCount++,t?(n.successCount++,n.averageLatency=(n.averageLatency*(n.successCount-1)+o)/n.successCount):(n.failureCount++,i&&(n.lastError=i)),r.enableNetworkMetrics&&s("NETWORK",`${e} - Success: ${t}, Latency: ${o}ms, Success Rate: ${(n.successCount/n.requestCount*100).toFixed(1)}%`)}printSummary(){if(r.enableNetworkMetrics){console.log("\n📈 Network Metrics Summary:");for(const[e,t]of this.metrics){const o=(t.successCount/t.requestCount*100).toFixed(1),r=Date.now()-t.startTime;console.log(` ${e}:`),console.log(` Requests: ${t.requestCount}`),console.log(` Success Rate: ${o}%`),console.log(` Avg Latency: ${t.averageLatency.toFixed(0)}ms`),console.log(` Runtime: ${r}ms`),t.lastError&&console.log(` Last Error: ${t.lastError}`)}}}}},89852:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DATIL_PKP_VALIDATOR_CID=t.DATIL_AUTHORIZATION_DUMMY_B_CID=t.DATIL_AUTHORIZATION_DUMMY_CID=t.DATIL_DEPLOYMENTS=t.DH_LIT_ACTIONS_DATIL=void 0,t.getDeploymentsForNetwork=function(e){return t.DH_LIT_ACTIONS_DATIL};const r=o(70809);t.DH_LIT_ACTIONS_DATIL={authorizationDummy:{cid:"QmcTXaXwne4VTE8uwhnc7VZs4xdWUx3hiMcvA325bhSDdv",authorizedCidHex:(0,r.cidToHex)("QmcTXaXwne4VTE8uwhnc7VZs4xdWUx3hiMcvA325bhSDdv"),name:"Authorization Dummy",description:"Production Authorization Dummy",version:"1.0.0",deployed:!0,deployedAt:1764014691199,size:1016,hash:"95667ee17f242a874f4f7f12020711cec84d3a3aea726aa0978590b79cdc58e4"},authorizationDummyB:{cid:"QmRM8Hd2sW1MZJ6yTGcL1uAj1DrQNgDX741PqyofphKF9n",authorizedCidHex:(0,r.cidToHex)("QmZYwYmVfGzA3Xax8P3ZtPomkHAxhuLHBkxLwzHzsu164k"),name:"Authorization Dummy B (Test)",description:"Development second dummy authorization LIT Action for testing failed authorization scenarios on datil-test",version:"0.1.0",deployed:!0,deployedAt:1761427363915,size:723,hash:"6262c9467961c661d212b8c60806e499ed5e7d0fe8456e2455e536d40eb4c672"},pkpValidator:{cid:"QmV9hhs7mB6Sq4VwjctecYWn8yCtRktRHbwnMP3pymParp",authorizedCidHex:(0,r.cidToHex)("QmV9hhs7mB6Sq4VwjctecYWn8yCtRktRHbwnMP3pymParp"),name:"Pkp Validator Datil",description:"Production Pkp Validator Datil",version:"1.0.0",deployed:!0,deployedAt:1767905423227,size:9061,hash:"acd53f3f9d1ced662461bd5d461b83826bdf6fde8275da81069acd8ade2cd76e",pkp:{tokenId:"22544487681068775241637935551968274935828006096917056373558607845799537896739",publicKey:"0x04ea1e6a63e86fbcf792dfa0f74ed7b49169bbd100eb62a5348a25a64fb4cf067020ab57a06a239d8e949e00674809c1fd183a94566e4698d84c7b08202d417ac5",ethAddress:"0x9624C46073E1d1F5AB975c67Fc899536d599bb57",mintTxHash:"0x05c63030f3bd15437aef80523b7542d58f108f02bca947ac542c03fb4e48df94",authTxHash:"0x6b0042708679e68da58fe17c23b2ffe5a77fc8afd2303b6daa4e2ba618b9df83",burnTxHash:"0x703a2ad58fb65b1d41f03cfc65ec183d94ea15c7bdb6dd89785aa851a6197b62",immutable:!0,authorizedCidHex:(0,r.cidToHex)("QmV9hhs7mB6Sq4VwjctecYWn8yCtRktRHbwnMP3pymParp"),createdAt:1767905423197}},ucdMintValidator:{cid:"QmYsnDbZn1HK3JoTLKiMsMjZoZdfm8LDBjbJPkfF4STH9D",authorizedCidHex:(0,r.cidToHex)("QmYsnDbZn1HK3JoTLKiMsMjZoZdfm8LDBjbJPkfF4STH9D"),name:"Ucd Mint Validator",description:"Production Ucd Mint Validator",version:"1.0.0",deployed:!0,deployedAt:1768575000342,size:53434,hash:"ee32013d5ca91c427420c45f71a3399c8db2c2811f8824c65361fef3bbe6a942",pkp:{tokenId:"10511973771163455425173672886432352521003716138921449126793312723064336606752",publicKey:"0x045514ecab89e2f30f8f8373b2816277b06cfb3532cfcfc9a9b9eb1efa4304345d9450994de0c7fe3d8195328dbb1a820e093c07a25c54039ace292b1105c4c90f",ethAddress:"0x6DC6e140ad11465ee4Ea8a3727eB44aA8D9b9d2d",mintTxHash:"0x78a6ca4a9d60eff462ab9c878e6251a3b448517111169a4bddf4006bc8816f41",authTxHash:"0x08cc1bce316450799ef63cc8f3ab2012a6cdd5e2b376a0def24d395709b025a1",burnTxHash:"0xdb2198ca53d402a2c4a3bd90673e0bb03875d165dd3a94d3ec7f25b36d756394",immutable:!0,authorizedCidHex:(0,r.cidToHex)("QmYsnDbZn1HK3JoTLKiMsMjZoZdfm8LDBjbJPkfF4STH9D"),createdAt:1768575000253}},priceOracle:{cid:"Qmf1gQmjAoWeYPsq7d4F23okJcJFUyFqWz4BgoohstvW7Y",authorizedCidHex:(0,r.cidToHex)("Qmf1gQmjAoWeYPsq7d4F23okJcJFUyFqWz4BgoohstvW7Y"),name:"Price Oracle",description:"Production Price Oracle",version:"1.0.0",deployed:!0,deployedAt:1761814899848,size:5272,hash:"2967f706242a7f3d9dc01853041cde24324999ed9dd15a592c7129c0cf8f25f9"},loanVaultBtcBalance:{cid:"QmSoJFpWbTTABPxzq7JvWkf2ZqaBzkUoyKDa27GoxEaFpH",authorizedCidHex:(0,r.cidToHex)("QmSoJFpWbTTABPxzq7JvWkf2ZqaBzkUoyKDa27GoxEaFpH"),name:"Loan Vault Btc Balance",description:"Production Loan Vault Btc Balance",version:"1.0.0",deployed:!0,deployedAt:1768571068696,size:35032,hash:"1312b8532d1a4bcfa58600d709bda9a2473126b98c27c62f82cb6df3a43969f4",pkp:{tokenId:"101638307363134678913173260680422514704529537590916601209667221514221697984707",publicKey:"0x04d5f25c355bb416a27a40178e087d5c2edb8f513ebc3bc96327e6452d25b0d5089f91060d0be31ee8ea7fbac5d59d4fe9473a72ec5efca3a771c62122d09018f9",ethAddress:"0x8A40C22B03348bc10df9ae0dc54346b4AE8e909c",mintTxHash:"0xb9b62acac5cf378d2cdcc4cb447b27dd79d3a124c523121f3333537a9f4343cd",authTxHash:"0x855f77530063a07db908fc8e56d39d40a51b63b56698141661761bd12d93d8ff",burnTxHash:"0xb73d259512a378a840066f734a36b7926b97f5ae203c3b1a5f7fd8a2ae7012ee",immutable:!0,authorizedCidHex:(0,r.cidToHex)("QmSoJFpWbTTABPxzq7JvWkf2ZqaBzkUoyKDa27GoxEaFpH"),createdAt:1768571068655}},btcWithdrawal:{cid:"QmbjzEuoKLje3jyQPnsurTSbnjm1QnMF5LD9awxnPYQLf4",authorizedCidHex:(0,r.cidToHex)("QmbjzEuoKLje3jyQPnsurTSbnjm1QnMF5LD9awxnPYQLf4"),name:"Btc Withdrawal",description:"Production Btc Withdrawal",version:"1.0.0",deployed:!0,deployedAt:1768575445383,size:54621,hash:"170950072f0e9f4fc9f1893ba9972b9757346c96dfd6aadae28f2c875ec970da",pkp:{tokenId:"88083666045978600299009521816300852427581971702809904885496796285668335015424",publicKey:"0x0483c6d94ae748fa581c3a4935e7d392a0270ed0d2b92b016ad30c3226c3faad2e476c3df1b33c7a067158083b9bacf43d1be6fa85b488ec57abb1f18b2c10139f",ethAddress:"0x1b9d9C0fFB991a7a2812d070657D8EEC610e8E82",mintTxHash:"0x8f724cee7dbf572a9bb347ea909d7e2f5ca12fb3f16db811409fed75819d44d5",authTxHash:"0x30b0333375a2b4c7ca4ad41ecba4d87229a85e56a2ddcb1fd2b79e2c2bca28cd",burnTxHash:"0xcf480ad89be4ceb2a2d3fa5546517f4b03d2d764115da29388026ec8e2d213b2",immutable:!0,authorizedCidHex:(0,r.cidToHex)("QmbjzEuoKLje3jyQPnsurTSbnjm1QnMF5LD9awxnPYQLf4"),createdAt:1768575445344}},liquidationValidator:{cid:"QmcZxzUGbYY9o7jS1kXVRkcBDKWYqYsJems12rT3fY6KD3",authorizedCidHex:(0,r.cidToHex)("QmcZxzUGbYY9o7jS1kXVRkcBDKWYqYsJems12rT3fY6KD3"),name:"Liquidation Validator",description:"Production Liquidation Validator",version:"1.0.0",deployed:!0,deployedAt:1768236947519,size:35221,hash:"1836dc3de51790e761756806e50686604df87d9c4edcb1c6f2d8ca01c649cead",pkp:{tokenId:"77164277440579836599337676668864162316346328150028059005112783614109550487087",publicKey:"0x04a2e860975b44b255fb121a3082efcc0f6ecc719fb7c192edc162b64b54b48e3e3f989ad3aac52641c7a6b88cfce7a7840835040d089d6957cd96600ac1d4f597",ethAddress:"0xD2bBd384CfeDdbB64A0bd59CdCffD47B5581e930",mintTxHash:"0x6770e7a027977d2a4c85512ed63e886d151dca147133757e6590c3cce298fb8b",authTxHash:"0x64364ddbef502e8f02d66b330ff4a97e6b4036951e033af9ffca68f2c21dba7f",burnTxHash:"0xc81680d2d4b6ffc4564384d553b3fd06efc44bf63e3fbf69bfdb8ef45bf46ab5",immutable:!0,authorizedCidHex:(0,r.cidToHex)("QmcZxzUGbYY9o7jS1kXVRkcBDKWYqYsJems12rT3fY6KD3"),createdAt:1768236947489}},adminLiquidationValidator:{cid:"QmVHqT2cRVqY2ysRQiwVJxQCpNhjaAgrP92UMsNciKvXpQ",authorizedCidHex:(0,r.cidToHex)("QmVHqT2cRVqY2ysRQiwVJxQCpNhjaAgrP92UMsNciKvXpQ"),name:"Admin Liquidation Validator",description:"Production Admin Liquidation Validator",version:"1.0.0",deployed:!0,deployedAt:1768236991190,size:36197,hash:"aaaa731b7ad39489824dc8fca1243247d6b6e6ae49c5ad68ec728d4ca916f5f9",pkp:{tokenId:"4324403275047082381124795898056756947829065434501788352600302296446020253129",publicKey:"0x048b9f304b236cd1ffb8afa0928e250bba5d43680d0e2c122a3dd1ae93f9d6c80362767b321ef48bdc4a314132207e8c76e9d2693c96cf71407bc3c0aaa25e487c",ethAddress:"0xa78D2FBb03BF69a84d9ECb6B3C054aC6406a6499",mintTxHash:"0x66ee2d82f3f88d44484780cd35ca0b9dac9594c348eb594351244d0c4f812d25",authTxHash:"0x4059e91d9a2f2b6e15593ad131e2173d781093f9163ba40ecd9f23c2874e0443",burnTxHash:"0x0c8bd1209bda5f7c2de6bf5945c93f78d0bc43de3fe566edc2fa688e20bdd18b",immutable:!0,authorizedCidHex:(0,r.cidToHex)("QmVHqT2cRVqY2ysRQiwVJxQCpNhjaAgrP92UMsNciKvXpQ"),createdAt:1768236991158}},processPaymentValidator:{cid:"QmSecsocNZP3XBfgJgsHt978rwkiaQ8XCeCosdkeXCWAmn",authorizedCidHex:(0,r.cidToHex)("QmSecsocNZP3XBfgJgsHt978rwkiaQ8XCeCosdkeXCWAmn"),name:"Process Payment Validator",description:"Production Process Payment Validator",version:"1.0.0",deployed:!0,deployedAt:1767658630625,size:18933,hash:"86ad472fb3688abd46cc672726fa3ab731fcd6bcfc87bca06c096169bdf5c399",pkp:{tokenId:"74990016119215743227969573377073952058355559322313433528552485497564142347513",publicKey:"0x04accb047e1cdca2d986cb8cc57665180df997c6fb79beb8143cc72bd3a20e7dcfcaab524f1b3378fec0edfde3768d86d03259d1b2800fface4baafa65aa0fe88a",ethAddress:"0x47082981f223e25F2c4168B92c0AC7691b0DF84b",mintTxHash:"0x5df4a1d961faeafa995254e0bf5456697ed260c689a72aede960092f76e96003",authTxHash:"0x37f036e134540e7b12139377a5fefb8f5eee6d41ac5cb246634848e6bb23c1ce",burnTxHash:"0x08ba26d45848945cc2182d18d15202f3c1829b72b057706b4d05377ddd0ee432",immutable:!0,authorizedCidHex:(0,r.cidToHex)("QmSecsocNZP3XBfgJgsHt978rwkiaQ8XCeCosdkeXCWAmn"),createdAt:1767658630573}},extendPositionValidator:{cid:"QmctLkGzeWaGDjJBjurQbwjCzf3KJwHmJBvsUHLX1m7JDi",authorizedCidHex:(0,r.cidToHex)("QmctLkGzeWaGDjJBjurQbwjCzf3KJwHmJBvsUHLX1m7JDi"),name:"Extend Position Validator",description:"Production Extend Position Validator",version:"1.0.0",deployed:!0,deployedAt:1766092826486,size:40577,hash:"a49b6eceaffa5fd794b584c7dc2099c9de3293afdb069347f05b17439ba419cb",pkp:{tokenId:"14003304110809475594012046981645475111654513452694278085120775875434807826562",publicKey:"0x04ae90da9ecafde23094c751072f34243173ddf101d4e6b512a469cd26a85a213e8d2bab57d56f692a8e2d312bc5b2cfed3cc95deabfc04930a02a4a3a32f0c353",ethAddress:"0x5962F1342d4C8d7eE54EE968CB2404B76fFDDA97",mintTxHash:"0x991b1c4dd5d904d7be859a4a126a745081cde0fe08872916e08c622a160bc250",authTxHash:"0x5760adac53b737107f83b03539343be4d2f952efcc16f2b0cd03089447954d2e",burnTxHash:"0xdbe59e67d569bbfcdf93d31b45a20471fe9672f6db72d0d27941015b82d9c07d",immutable:!0,authorizedCidHex:(0,r.cidToHex)("QmctLkGzeWaGDjJBjurQbwjCzf3KJwHmJBvsUHLX1m7JDi"),createdAt:1766092826447}},alwaysSigner:{cid:"QmRcQTDiZJq5arXngdxCX1LPnTW1fvx78tBD9vZmMXg8Ly",authorizedCidHex:(0,r.cidToHex)("QmRcQTDiZJq5arXngdxCX1LPnTW1fvx78tBD9vZmMXg8Ly"),name:"Always Signer",description:"Production Always Signer",version:"1.0.0",deployed:!0,deployedAt:1764104607523,size:3229,hash:"e903d3f22e062aeb98bffadb925f939dc05f4c6307f938e4f708309216231141",pkp:{tokenId:"103478053481671592175363349032091940459278914221144113534034390533668468479857",publicKey:"0x04fe7418bab47369abe95d029e2d83e91dd52e1c7faa33cdfe701e326635678637f32619ddc539080474e864296af61fe2eb43ffc174d7f852439c1976478dae1a",ethAddress:"0x0C990Dad4ed87C94FCFc7724152213eEA26C7465",mintTxHash:"0xd2af8e7f4b401812e02b8c7459af2694e9196456f2db4ee0768ba16a833721fd",authTxHash:"0x16a5849c4209e8aa3eb444e27118208bb30edfd623e0bbd55a63261421fd28a4",burnTxHash:"0x8a0e0d3da03d6c2985a1cbb3569aac66e38971cb20f5af1f932bf3a6c3a2a552",immutable:!0,authorizedCidHex:(0,r.cidToHex)("QmRcQTDiZJq5arXngdxCX1LPnTW1fvx78tBD9vZmMXg8Ly"),createdAt:1764104607484}},btcTransactionSigner:{cid:"QmeGk33k4wnxignSmwNBxiYSStxgsosBpdwk5Le8bDCoMj",authorizedCidHex:(0,r.cidToHex)("QmeGk33k4wnxignSmwNBxiYSStxgsosBpdwk5Le8bDCoMj"),name:"Btc Transaction Signer",description:"Production Btc Transaction Signer",version:"1.0.0",deployed:!0,deployedAt:1767905470734,size:20804,hash:"dbf23063b3c267c3e104958c0072c9d26f1e2f8bcc46a0726cbfff300fa3fb0c",pkp:{tokenId:"90386569693924187626090156578239327853198345844839249291128798357629538740112",publicKey:"0x04ca638e425a59e6d4a0d5b8c5b6123d93f345f11b73399bf16b8574c7c2762c8682a88c607122001fccd9644abcf86466521d3d7919264d58da6323304b9a1a37",ethAddress:"0xf48325C29541D1Ea49971c74A7877497C698650A",mintTxHash:"0x43473b68cf416fa531981c8b826338f0a536fc6f15fb50732032071caae4ddd2",authTxHash:"0x9e911679d2233e14ffb889ccbb6c63c081f27ba3e927d6d9542f9cb1af8b73a3",burnTxHash:"0xab65a52c87790726589245a3f96483c512791ffd1e6ebbc7d7dc9a6ce748589c",immutable:!0,authorizedCidHex:(0,r.cidToHex)("QmeGk33k4wnxignSmwNBxiYSStxgsosBpdwk5Le8bDCoMj"),createdAt:1767905470703}}},t.DATIL_DEPLOYMENTS=t.DH_LIT_ACTIONS_DATIL,t.DATIL_AUTHORIZATION_DUMMY_CID=t.DH_LIT_ACTIONS_DATIL.authorizationDummy.cid,t.DATIL_AUTHORIZATION_DUMMY_B_CID=t.DH_LIT_ACTIONS_DATIL.authorizationDummyB.cid,t.DATIL_PKP_VALIDATOR_CID=t.DH_LIT_ACTIONS_DATIL.pkpValidator.cid}};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 397.browser.js.LICENSE.txt */
|
|
2
|
-
export const __webpack_esm_id__=397;export const __webpack_esm_ids__=[397];export const __webpack_esm_modules__={204:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.p2data=void 0;const n=r(1834),i=r(94778),o=r(92992),s=r(96887),f=i.OPS;t.p2data=function(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),data:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer))},e);const r={name:"embed",network:e.network||n.bitcoin};if(s.prop(r,"output",()=>{if(e.data)return i.compile([f.OP_RETURN].concat(e.data))}),s.prop(r,"data",()=>{if(e.output)return i.decompile(e.output).slice(1)}),t.validate&&e.output){const t=i.decompile(e.output);if(t[0]!==f.OP_RETURN)throw new TypeError("Output is invalid");if(!t.slice(1).every(o.typeforce.Buffer))throw new TypeError("Output is invalid");if(e.data&&!(0,o.stacksEqual)(e.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,e)}},920:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.getEccLib=t.initEccLib=void 0;const i={};t.initEccLib=function(e,t){var r;e?e!==i.eccLib&&(t?.DANGER_DO_NOT_VERIFY_ECCLIB||(s("function"==typeof(r=e).isXOnlyPoint),s(r.isXOnlyPoint(o("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),s(r.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),s(r.isXOnlyPoint(o("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),s(r.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000001"))),s(!r.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000000"))),s(!r.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),s("function"==typeof r.xOnlyPointAddTweak),f.forEach(e=>{const t=r.xOnlyPointAddTweak(o(e.pubkey),o(e.tweak));null===e.result?s(null===t):(s(null!==t),s(t.parity===e.parity),s(n.from(t.xOnlyPubkey).equals(o(e.result))))})),i.eccLib=e):i.eccLib=e},t.getEccLib=function(){if(!i.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return i.eccLib};const o=e=>n.from(e,"hex");function s(e){if(!e)throw new Error("ecc library invalid")}const f=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}]},1834:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.testnet=t.regtest=t.bitcoin=void 0,t.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},t.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},t.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},1920:(e,t,r)=>{var n=r(35601),i=r(31677),o=n.tfJSON,s=n.TfTypeError,f=n.TfPropertyTypeError,u=n.tfSubError,a=n.getValueTypeName,c={arrayOf:function(e,t){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==t.minLength&&r.length<t.minLength)&&!(void 0!==t.maxLength&&r.length>t.maxLength)&&(void 0===t.length||r.length===t.length)&&r.every(function(t,r){try{return h(e,t,n)}catch(e){throw u(e,r)}})}return e=p(e),t=t||{},r.toJSON=function(){var r="["+o(e)+"]";return void 0!==t.length?r+="{"+t.length+"}":void 0===t.minLength&&void 0===t.maxLength||(r+="{"+(void 0===t.minLength?0:t.minLength)+","+(void 0===t.maxLength?1/0:t.maxLength)+"}"),r},r},maybe:function e(t){function r(r,n){return i.Nil(r)||t(r,n,e)}return t=p(t),r.toJSON=function(){return"?"+o(t)},r},map:function(e,t){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{t&&h(t,o,n)}catch(e){throw u(e,o,"key")}try{var s=r[o];h(e,s,n)}catch(e){throw u(e,o)}}return!0}return e=p(e),t&&(t=p(t)),r.toJSON=t?function(){return"{"+o(t)+": "+o(e)+"}"}:function(){return"{"+o(e)+"}"},r},object:function(e){var t={};for(var r in e)t[r]=p(e[r]);function n(e,r){if(!i.Object(e))return!1;if(i.Nil(e))return!1;var n;try{for(n in t)h(t[n],e[n],r)}catch(e){throw u(e,n)}if(r)for(n in e)if(!t[n])throw new f(void 0,n);return!0}return n.toJSON=function(){return o(t)},n},anyOf:function(){var e=[].slice.call(arguments).map(p);function t(t,r){return e.some(function(e){try{return h(e,t,r)}catch(e){return!1}})}return t.toJSON=function(){return e.map(o).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(p);function t(t,r){return e.every(function(e){try{return h(e,t,r)}catch(e){return!1}})}return t.toJSON=function(){return e.map(o).join(" & ")},t},quacksLike:function(e){function t(t){return e===a(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(p);function t(t,r){return!i.Nil(t)&&!i.Nil(t.length)&&(!r||t.length===e.length)&&e.every(function(e,n){try{return h(e,t[n],r)}catch(e){throw u(e,n)}})}return t.toJSON=function(){return"("+e.map(o).join(", ")+")"},t},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function p(e){if(i.String(e))return"?"===e[0]?c.maybe(e.slice(1)):i[e]||c.quacksLike(e);if(e&&i.Object(e)){if(i.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return c.arrayOf(e[0])}return c.object(e)}return i.Function(e)?e:c.value(e)}function h(e,t,r,n){if(i.Function(e)){if(e(t,r))return!0;throw new s(n||e,t)}return h(p(e),t,r)}for(var l in c.oneOf=c.anyOf,i)h[l]=i[l];for(l in c)h[l]=c[l];var d=r(13274);for(l in d)h[l]=d[l];h.compile=p,h.TfTypeError=s,h.TfPropertyTypeError=f,e.exports=h},12820:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=t.encodingLength=void 0;const n=r(45029);function i(e){return e<n.OPS.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}t.encodingLength=i,t.encode=function(e,t,r){const o=i(t);return 1===o?e.writeUInt8(t,r):2===o?(e.writeUInt8(n.OPS.OP_PUSHDATA1,r),e.writeUInt8(t,r+1)):3===o?(e.writeUInt8(n.OPS.OP_PUSHDATA2,r),e.writeUInt16LE(t,r+1)):(e.writeUInt8(n.OPS.OP_PUSHDATA4,r),e.writeUInt32LE(t,r+1)),o},t.decode=function(e,t){const r=e.readUInt8(t);let i,o;if(r<n.OPS.OP_PUSHDATA1)i=r,o=1;else if(r===n.OPS.OP_PUSHDATA1){if(t+2>e.length)return null;i=e.readUInt8(t+1),o=2}else if(r===n.OPS.OP_PUSHDATA2){if(t+3>e.length)return null;i=e.readUInt16LE(t+1),o=3}else{if(t+5>e.length)return null;if(r!==n.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");i=e.readUInt32LE(t+1),o=5}return{opcode:r,number:i,size:o}}},13274:(e,t,r)=>{var n=r(38891).Buffer,i=r(31677),o=r(35601);function s(e){return n.isBuffer(e)}function f(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function u(e,t){var r=e.toJSON();function n(n){if(!e(n))return!1;if(n.length===t)return!0;throw o.tfCustomError(r+"(Length: "+t+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var a=u.bind(null,i.Array),c=u.bind(null,s),p=u.bind(null,f),h=u.bind(null,i.String),l=Math.pow(2,53)-1,d={ArrayN:a,Buffer:s,BufferN:c,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:f,HexN:p,Int8:function(e){return e<<24>>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},Int53:function(e){return"number"==typeof e&&e>=-l&&e<=l&&Math.floor(e)===e},Range:function(e,t,r){function n(n,i){return r(n,i)&&n>e&&n<t}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${e}, ${t}]`},n},StringN:h,UInt8:function(e){return(255&e)===e},UInt16:function(e){return(65535&e)===e},UInt32:function(e){return e>>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=l&&Math.floor(e)===e}};for(var y in d)d[y].toJSON=function(e){return e}.bind(null,y);e.exports=d},26236:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2pkh=void 0;const i=r(58892),o=r(1834),s=r(94778),f=r(92992),u=r(96887),a=r(60709),c=s.OPS;t.p2pkh=function(e,t){if(!(e.address||e.hash||e.output||e.pubkey||e.input))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,f.typeforce)({network:f.typeforce.maybe(f.typeforce.Object),address:f.typeforce.maybe(f.typeforce.String),hash:f.typeforce.maybe(f.typeforce.BufferN(20)),output:f.typeforce.maybe(f.typeforce.BufferN(25)),pubkey:f.typeforce.maybe(f.isPoint),signature:f.typeforce.maybe(s.isCanonicalScriptSignature),input:f.typeforce.maybe(f.typeforce.Buffer)},e);const r=u.value(()=>{const t=n.from(a.decode(e.address));return{version:t.readUInt8(0),hash:t.slice(1)}}),p=u.value(()=>s.decompile(e.input)),h=e.network||o.bitcoin,l={name:"p2pkh",network:h};if(u.prop(l,"address",()=>{if(!l.hash)return;const e=n.allocUnsafe(21);return e.writeUInt8(h.pubKeyHash,0),l.hash.copy(e,1),a.encode(e)}),u.prop(l,"hash",()=>e.output?e.output.slice(3,23):e.address?r().hash:e.pubkey||l.pubkey?i.hash160(e.pubkey||l.pubkey):void 0),u.prop(l,"output",()=>{if(l.hash)return s.compile([c.OP_DUP,c.OP_HASH160,l.hash,c.OP_EQUALVERIFY,c.OP_CHECKSIG])}),u.prop(l,"pubkey",()=>{if(e.input)return p()[1]}),u.prop(l,"signature",()=>{if(e.input)return p()[0]}),u.prop(l,"input",()=>{if(e.pubkey&&e.signature)return s.compile([e.signature,e.pubkey])}),u.prop(l,"witness",()=>{if(l.input)return[]}),t.validate){let t=n.from([]);if(e.address){if(r().version!==h.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");t=r().hash}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(25!==e.output.length||e.output[0]!==c.OP_DUP||e.output[1]!==c.OP_HASH160||20!==e.output[2]||e.output[23]!==c.OP_EQUALVERIFY||e.output[24]!==c.OP_CHECKSIG)throw new TypeError("Output is invalid");const r=e.output.slice(3,23);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}if(e.pubkey){const r=i.hash160(e.pubkey);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}if(e.input){const r=p();if(2!==r.length)throw new TypeError("Input is invalid");if(!s.isCanonicalScriptSignature(r[0]))throw new TypeError("Input has invalid signature");if(!(0,f.isPoint)(r[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&!e.signature.equals(r[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(r[1]))throw new TypeError("Pubkey mismatch");const n=i.hash160(r[1]);if(t.length>0&&!t.equals(n))throw new TypeError("Hash mismatch")}}return Object.assign(l,e)}},31677:e=>{var t={Array:function(e){return null!=e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return null==e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var r in t.Null=t.Nil,t)t[r].toJSON=function(e){return e}.bind(null,r);e.exports=t},31817:(e,t,r)=>{var n=r(38891),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,t),t.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},34538:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.encode=t.decode=t.check=void 0,t.check=function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;const t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;const r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},t.decode=function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");const t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");const r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},t.encode=function(e,t){const r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");const o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}},35601:(e,t,r)=>{var n=r(31677);function i(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function o(e){return n.Nil(e)?"":i(e.constructor)}function s(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function f(e){return n.Function(e)?e.toJSON?e.toJSON():i(e):n.Array(e)?"Array":e&&n.Object(e)?"Object":void 0!==e?e:""}function u(e,t,r){var i=function(e){return n.Function(e)?"":n.String(e)?JSON.stringify(e):e&&n.Object(e)?"":e}(t);return"Expected "+f(e)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function a(e,t,r){r=r||o(t),this.message=u(e,t,r),s(this,a),this.__type=e,this.__value=t,this.__valueTypeName=r}function c(e,t,r,n,i){e?(i=i||o(n),this.message=function(e,t,r,n,i){var o='" of type ';return"key"===t&&(o='" with key type '),u('property "'+f(r)+o+f(e),n,i)}(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',s(this,a),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}a.prototype=Object.create(Error.prototype),a.prototype.constructor=a,c.prototype=Object.create(Error.prototype),c.prototype.constructor=a,e.exports={TfTypeError:a,TfPropertyTypeError:c,tfCustomError:function(e,t){return new a(e,{},t)},tfSubError:function(e,t,r){return e instanceof c?(t=t+"."+e.__property,e=new c(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof a&&(e=new c(e.__type,t,r,e.__value,e.__valueTypeName)),s(e),e},tfJSON:f,getValueTypeName:o}},38191:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.encode=t.decode=void 0;const i=r(34538),o=r(94778),s=r(92992),{typeforce:f}=s,u=n.alloc(1,0);function a(e){let t=0;for(;0===e[t];)++t;return t===e.length?u:128&(e=e.slice(t))[0]?n.concat([u,e],1+e.length):e}function c(e){0===e[0]&&(e=e.slice(1));const t=n.alloc(32,0),r=Math.max(0,32-e.length);return e.copy(t,r),t}t.decode=function(e){const t=e.readUInt8(e.length-1);if(!(0,o.isDefinedHashType)(t))throw new Error("Invalid hashType "+t);const r=i.decode(e.slice(0,-1)),s=c(r.r),f=c(r.s);return{signature:n.concat([s,f],64),hashType:t}},t.encode=function(e,t){if(f({signature:s.BufferN(64),hashType:s.UInt8},{signature:e,hashType:t}),!(0,o.isDefinedHashType)(t))throw new Error("Invalid hashType "+t);const r=n.allocUnsafe(1);r.writeUInt8(t,0);const u=a(e.slice(0,32)),c=a(e.slice(32,64));return n.concat([i.encode(u,c),r])}},38381:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.toOutputScript=t.fromOutputScript=t.toBech32=t.toBase58Check=t.fromBech32=t.fromBase58Check=void 0;const i=r(1834),o=r(70393),s=r(94778),f=r(92992),u=r(39771),a=r(60709),c="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function p(e){const t=n.from(a.decode(e));if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");return{version:t.readUInt8(0),hash:t.slice(1)}}function h(e){let t,r;try{t=u.bech32.decode(e)}catch(e){}if(t){if(r=t.words[0],0!==r)throw new TypeError(e+" uses wrong encoding")}else if(t=u.bech32m.decode(e),r=t.words[0],0===r)throw new TypeError(e+" uses wrong encoding");const i=u.bech32.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:n.from(i)}}function l(e,t,r){const n=u.bech32.toWords(e);return n.unshift(t),0===t?u.bech32.encode(r,n):u.bech32m.encode(r,n)}t.fromBase58Check=p,t.fromBech32=h,t.toBase58Check=function(e,t){(0,f.typeforce)((0,f.tuple)(f.Hash160bit,f.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(t,0),e.copy(r,1),a.encode(r)},t.toBech32=l,t.fromOutputScript=function(e,t){t=t||i.bitcoin;try{return o.p2pkh({output:e,network:t}).address}catch(e){}try{return o.p2sh({output:e,network:t}).address}catch(e){}try{return o.p2wpkh({output:e,network:t}).address}catch(e){}try{return o.p2wsh({output:e,network:t}).address}catch(e){}try{return o.p2tr({output:e,network:t}).address}catch(e){}try{return function(e,t){const r=e.slice(2);if(r.length<2||r.length>40)throw new TypeError("Invalid program length for segwit address");const n=e[0]-80;if(n<2||n>16)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(c),l(r,n,t.bech32)}(e,t)}catch(e){}throw new Error(s.toASM(e)+" has no matching Address")},t.toOutputScript=function(e,t){let r,n;t=t||i.bitcoin;try{r=p(e)}catch(e){}if(r){if(r.version===t.pubKeyHash)return o.p2pkh({hash:r.hash}).output;if(r.version===t.scriptHash)return o.p2sh({hash:r.hash}).output}else{try{n=h(e)}catch(e){}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return o.p2wpkh({hash:n.data}).output;if(32===n.data.length)return o.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return o.p2tr({pubkey:n.data}).output}else if(n.version>=2&&n.version<=16&&n.data.length>=2&&n.data.length<=40)return console.warn(c),s.compile([n.version+80,n.data])}}throw new Error(e+" has no matching Script")}},43881:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.p2tr=void 0;const n=r(38891),i=r(1834),o=r(94778),s=r(92992),f=r(920),u=r(50102),a=r(96887),c=r(39771),p=r(38381),h=o.OPS;t.p2tr=function(e,t){if(!(e.address||e.output||e.pubkey||e.internalPubkey||e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(34)),internalPubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),pubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),signature:s.typeforce.maybe(s.typeforce.anyOf(s.typeforce.BufferN(64),s.typeforce.BufferN(65))),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer)),scriptTree:s.typeforce.maybe(s.isTaptree),redeem:s.typeforce.maybe({output:s.typeforce.maybe(s.typeforce.Buffer),redeemVersion:s.typeforce.maybe(s.typeforce.Number),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),redeemVersion:s.typeforce.maybe(s.typeforce.Number)},e);const r=a.value(()=>(0,p.fromBech32)(e.address)),l=a.value(()=>{if(e.witness&&e.witness.length)return e.witness.length>=2&&80===e.witness[e.witness.length-1][0]?e.witness.slice(0,-1):e.witness.slice()}),d=a.value(()=>e.scriptTree?(0,u.toHashTree)(e.scriptTree):e.hash?{hash:e.hash}:void 0),y=e.network||i.bitcoin,w={name:"p2tr",network:y};if(a.prop(w,"address",()=>{if(!w.pubkey)return;const e=c.bech32m.toWords(w.pubkey);return e.unshift(1),c.bech32m.encode(y.bech32,e)}),a.prop(w,"hash",()=>{const e=d();if(e)return e.hash;const t=l();if(t&&t.length>1){const e=t[t.length-1],r=e[0]&s.TAPLEAF_VERSION_MASK,n=t[t.length-2],i=(0,u.tapleafHash)({output:n,version:r});return(0,u.rootHashFromPath)(e,i)}return null}),a.prop(w,"output",()=>{if(w.pubkey)return o.compile([h.OP_1,w.pubkey])}),a.prop(w,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&void 0!==e.redeem.redeemVersion&&null!==e.redeem.redeemVersion?e.redeem.redeemVersion:u.LEAF_VERSION_TAPSCRIPT),a.prop(w,"redeem",()=>{const e=l();if(e&&!(e.length<2))return{output:e[e.length-2],witness:e.slice(0,-2),redeemVersion:e[e.length-1][0]&s.TAPLEAF_VERSION_MASK}}),a.prop(w,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(w.internalPubkey){const e=(0,u.tweakKey)(w.internalPubkey,w.hash);if(e)return e.x}}),a.prop(w,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const t=l();return t&&t.length>1?t[t.length-1].slice(1,33):void 0}),a.prop(w,"signature",()=>{if(e.signature)return e.signature;const t=l();return t&&1===t.length?t[0]:void 0}),a.prop(w,"witness",()=>{if(e.witness)return e.witness;const t=d();if(t&&e.redeem&&e.redeem.output&&e.internalPubkey){const r=(0,u.tapleafHash)({output:e.redeem.output,version:w.redeemVersion}),i=(0,u.findScriptPath)(t,r);if(!i)return;const o=(0,u.tweakKey)(e.internalPubkey,t.hash);if(!o)return;const s=n.Buffer.concat([n.Buffer.from([w.redeemVersion|o.parity]),e.internalPubkey].concat(i));return[e.redeem.output,s]}return e.signature?[e.signature]:void 0}),t.validate){let t=n.Buffer.from([]);if(e.address){if(y&&y.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(1!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");t=r().data}if(e.pubkey){if(t.length>0&&!t.equals(e.pubkey))throw new TypeError("Pubkey mismatch");t=e.pubkey}if(e.output){if(34!==e.output.length||e.output[0]!==h.OP_1||32!==e.output[1])throw new TypeError("Output is invalid");if(t.length>0&&!t.equals(e.output.slice(2)))throw new TypeError("Pubkey mismatch");t=e.output.slice(2)}if(e.internalPubkey){const r=(0,u.tweakKey)(e.internalPubkey,w.hash);if(t.length>0&&!t.equals(r.x))throw new TypeError("Pubkey mismatch");t=r.x}if(t&&t.length&&!(0,f.getEccLib)().isXOnlyPoint(t))throw new TypeError("Invalid pubkey for p2tr");const i=d();if(e.hash&&i&&!e.hash.equals(i.hash))throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&i){const t=(0,u.tapleafHash)({output:e.redeem.output,version:w.redeemVersion});if(!(0,u.findScriptPath)(i,t))throw new TypeError("Redeem script not in tree")}const a=l();if(e.redeem&&w.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==w.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(0===o.decompile(e.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(w.redeem.output&&!e.redeem.output.equals(w.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&w.redeem.witness&&!(0,s.stacksEqual)(e.redeem.witness,w.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(a&&a.length)if(1===a.length){if(e.signature&&!e.signature.equals(a[0]))throw new TypeError("Signature mismatch")}else{const r=a[a.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(e.internalPubkey&&!e.internalPubkey.equals(i))throw new TypeError("Internal pubkey mismatch");if(!(0,f.getEccLib)().isXOnlyPoint(i))throw new TypeError("Invalid internalPubkey for p2tr witness");const o=r[0]&s.TAPLEAF_VERSION_MASK,c=a[a.length-2],p=(0,u.tapleafHash)({output:c,version:o}),h=(0,u.rootHashFromPath)(r,p),l=(0,u.tweakKey)(i,h);if(!l)throw new TypeError("Invalid outputKey for p2tr witness");if(t.length&&!t.equals(l.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(l.parity!==(1&r[0]))throw new Error("Incorrect parity")}}return Object.assign(w,e)}},45029:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.REVERSE_OPS=t.OPS=void 0;const r={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};t.OPS=r;const n={};t.REVERSE_OPS=n;for(const e of Object.keys(r))n[r[e]]=e},50102:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tweakKey=t.tapTweakHash=t.tapleafHash=t.findScriptPath=t.toHashTree=t.rootHashFromPath=t.MAX_TAPTREE_DEPTH=t.LEAF_VERSION_TAPSCRIPT=void 0;const n=r(38891),i=r(920),o=r(58892),s=r(85666),f=r(92992);function u(e){const r=e.version||t.LEAF_VERSION_TAPSCRIPT;return o.taggedHash("TapLeaf",n.Buffer.concat([n.Buffer.from([r]),p(e.output)]))}function a(e,t){return o.taggedHash("TapTweak",n.Buffer.concat(t?[e,t]:[e]))}function c(e,t){return o.taggedHash("TapBranch",n.Buffer.concat([e,t]))}function p(e){const t=s.varuint.encodingLength(e.length),r=n.Buffer.allocUnsafe(t);return s.varuint.encode(e.length,r),n.Buffer.concat([r,e])}t.LEAF_VERSION_TAPSCRIPT=192,t.MAX_TAPTREE_DEPTH=128,t.rootHashFromPath=function(e,t){if(e.length<33)throw new TypeError(`The control-block length is too small. Got ${e.length}, expected min 33.`);const r=(e.length-33)/32;let n=t;for(let t=0;t<r;t++){const r=e.slice(33+32*t,65+32*t);n=n.compare(r)<0?c(n,r):c(r,n)}return n},t.toHashTree=function e(t){if((0,f.isTapleaf)(t))return{hash:u(t)};const r=[e(t[0]),e(t[1])];r.sort((e,t)=>e.hash.compare(t.hash));const[n,i]=r;return{hash:c(n.hash,i.hash),left:n,right:i}},t.findScriptPath=function e(t,r){if("left"in(n=t)&&"right"in n){const n=e(t.left,r);if(void 0!==n)return[...n,t.right.hash];const i=e(t.right,r);if(void 0!==i)return[...i,t.left.hash]}else if(t.hash.equals(r))return[];var n},t.tapleafHash=u,t.tapTweakHash=a,t.tweakKey=function(e,t){if(!n.Buffer.isBuffer(e))return null;if(32!==e.length)return null;if(t&&32!==t.length)return null;const r=a(e,t),o=(0,i.getEccLib)().xOnlyPointAddTweak(e,r);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:n.Buffer.from(o.xOnlyPubkey)}:null}},50463:(e,t,r)=>{const n=r(91736);e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},57828:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2sh=void 0;const i=r(58892),o=r(1834),s=r(94778),f=r(92992),u=r(96887),a=r(60709),c=s.OPS;t.p2sh=function(e,t){if(!(e.address||e.hash||e.output||e.redeem||e.input))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,f.typeforce)({network:f.typeforce.maybe(f.typeforce.Object),address:f.typeforce.maybe(f.typeforce.String),hash:f.typeforce.maybe(f.typeforce.BufferN(20)),output:f.typeforce.maybe(f.typeforce.BufferN(23)),redeem:f.typeforce.maybe({network:f.typeforce.maybe(f.typeforce.Object),output:f.typeforce.maybe(f.typeforce.Buffer),input:f.typeforce.maybe(f.typeforce.Buffer),witness:f.typeforce.maybe(f.typeforce.arrayOf(f.typeforce.Buffer))}),input:f.typeforce.maybe(f.typeforce.Buffer),witness:f.typeforce.maybe(f.typeforce.arrayOf(f.typeforce.Buffer))},e);let r=e.network;r||(r=e.redeem&&e.redeem.network||o.bitcoin);const p={network:r},h=u.value(()=>{const t=n.from(a.decode(e.address));return{version:t.readUInt8(0),hash:t.slice(1)}}),l=u.value(()=>s.decompile(e.input)),d=u.value(()=>{const t=l(),i=t[t.length-1];return{network:r,output:i===c.OP_FALSE?n.from([]):i,input:s.compile(t.slice(0,-1)),witness:e.witness||[]}});if(u.prop(p,"address",()=>{if(!p.hash)return;const e=n.allocUnsafe(21);return e.writeUInt8(p.network.scriptHash,0),p.hash.copy(e,1),a.encode(e)}),u.prop(p,"hash",()=>e.output?e.output.slice(2,22):e.address?h().hash:p.redeem&&p.redeem.output?i.hash160(p.redeem.output):void 0),u.prop(p,"output",()=>{if(p.hash)return s.compile([c.OP_HASH160,p.hash,c.OP_EQUAL])}),u.prop(p,"redeem",()=>{if(e.input)return d()}),u.prop(p,"input",()=>{if(e.redeem&&e.redeem.input&&e.redeem.output)return s.compile([].concat(s.decompile(e.redeem.input),e.redeem.output))}),u.prop(p,"witness",()=>p.redeem&&p.redeem.witness?p.redeem.witness:p.input?[]:void 0),u.prop(p,"name",()=>{const e=["p2sh"];return void 0!==p.redeem&&void 0!==p.redeem.name&&e.push(p.redeem.name),e.join("-")}),t.validate){let t=n.from([]);if(e.address){if(h().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==h().hash.length)throw new TypeError("Invalid address");t=h().hash}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(23!==e.output.length||e.output[0]!==c.OP_HASH160||20!==e.output[1]||e.output[22]!==c.OP_EQUAL)throw new TypeError("Output is invalid");const r=e.output.slice(2,22);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}const o=e=>{if(e.output){const r=s.decompile(e.output);if(!r||r.length<1)throw new TypeError("Redeem.output too short");if(e.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.hash160(e.output);if(t.length>0&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.input){const t=e.input.length>0,r=e.witness&&e.witness.length>0;if(!t&&!r)throw new TypeError("Empty input");if(t&&r)throw new TypeError("Input and witness provided");if(t){const t=s.decompile(e.input);if(!s.isPushOnly(t))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const e=l();if(!e||e.length<1)throw new TypeError("Input too short");if(!n.isBuffer(d().output))throw new TypeError("Input is invalid");o(d())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const t=d();if(e.redeem.output&&!e.redeem.output.equals(t.output))throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&!e.redeem.input.equals(t.input))throw new TypeError("Redeem.input mismatch")}o(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!(0,f.stacksEqual)(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(p,e)}},58892:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.taggedHash=t.TAGGED_HASH_PREFIXES=t.TAGS=t.hash256=t.hash160=t.sha256=t.sha1=t.ripemd160=void 0;const i=r(74290),o=r(93553),s=r(7811);function f(e){return n.from((0,s.sha256)(Uint8Array.from(e)))}t.ripemd160=function(e){return n.from((0,i.ripemd160)(Uint8Array.from(e)))},t.sha1=function(e){return n.from((0,o.sha1)(Uint8Array.from(e)))},t.sha256=f,t.hash160=function(e){return n.from((0,i.ripemd160)((0,s.sha256)(Uint8Array.from(e))))},t.hash256=function(e){return n.from((0,s.sha256)((0,s.sha256)(Uint8Array.from(e))))},t.TAGS=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],t.TAGGED_HASH_PREFIXES={"BIP0340/challenge":n.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":n.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":n.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:n.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:n.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:n.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:n.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":n.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":n.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},t.taggedHash=function(e,r){return f(n.concat([t.TAGGED_HASH_PREFIXES[e],r]))}},60709:(e,t,r)=>{var{sha256:n}=r(7811),i=r(73088);e.exports=i(function(e){return n(n(e))})},62329:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.Transaction=void 0;const i=r(85666),o=r(58892),s=r(94778),f=r(94778),u=r(92992),{typeforce:a}=u;function c(e){const t=e.length;return i.varuint.encodingLength(t)+t}const p=n.allocUnsafe(0),h=[],l=n.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),d=n.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),y=n.from("ffffffffffffffff","hex"),w={script:p,valueBuffer:y};class m{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(e,t){const r=new i.BufferReader(e),n=new m;n.version=r.readInt32();const o=r.readUInt8(),s=r.readUInt8();let f=!1;o===m.ADVANCED_TRANSACTION_MARKER&&s===m.ADVANCED_TRANSACTION_FLAG?f=!0:r.offset-=2;const u=r.readVarInt();for(let e=0;e<u;++e)n.ins.push({hash:r.readSlice(32),index:r.readUInt32(),script:r.readVarSlice(),sequence:r.readUInt32(),witness:h});const a=r.readVarInt();for(let e=0;e<a;++e)n.outs.push({value:r.readUInt64(),script:r.readVarSlice()});if(f){for(let e=0;e<u;++e)n.ins[e].witness=r.readVector();if(!n.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(n.locktime=r.readUInt32(),t)return n;if(r.offset!==e.length)throw new Error("Transaction has unexpected data");return n}static fromHex(e){return m.fromBuffer(n.from(e,"hex"),!1)}static isCoinbaseHash(e){a(u.Hash256bit,e);for(let t=0;t<32;++t)if(0!==e[t])return!1;return!0}isCoinbase(){return 1===this.ins.length&&m.isCoinbaseHash(this.ins[0].hash)}addInput(e,t,r,n){return a(u.tuple(u.Hash256bit,u.UInt32,u.maybe(u.UInt32),u.maybe(u.Buffer)),arguments),u.Null(r)&&(r=m.DEFAULT_SEQUENCE),this.ins.push({hash:e,index:t,script:n||p,sequence:r,witness:h})-1}addOutput(e,t){return a(u.tuple(u.Buffer,u.Satoshi),arguments),this.outs.push({script:e,value:t})-1}hasWitnesses(){return this.ins.some(e=>0!==e.witness.length)}stripWitnesses(){this.ins.forEach(e=>{e.witness=h})}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(e=!0){const t=e&&this.hasWitnesses();return(t?10:8)+i.varuint.encodingLength(this.ins.length)+i.varuint.encodingLength(this.outs.length)+this.ins.reduce((e,t)=>e+40+c(t.script),0)+this.outs.reduce((e,t)=>e+8+c(t.script),0)+(t?this.ins.reduce((e,t)=>e+function(e){const t=e.length;return i.varuint.encodingLength(t)+e.reduce((e,t)=>e+c(t),0)}(t.witness),0):0)}clone(){const e=new m;return e.version=this.version,e.locktime=this.locktime,e.ins=this.ins.map(e=>({hash:e.hash,index:e.index,script:e.script,sequence:e.sequence,witness:e.witness})),e.outs=this.outs.map(e=>({script:e.script,value:e.value})),e}hashForSignature(e,t,r){if(a(u.tuple(u.UInt32,u.Buffer,u.Number),arguments),e>=this.ins.length)return d;const i=s.compile(s.decompile(t).filter(e=>e!==f.OPS.OP_CODESEPARATOR)),c=this.clone();if((31&r)===m.SIGHASH_NONE)c.outs=[],c.ins.forEach((t,r)=>{r!==e&&(t.sequence=0)});else if((31&r)===m.SIGHASH_SINGLE){if(e>=this.outs.length)return d;c.outs.length=e+1;for(let t=0;t<e;t++)c.outs[t]=w;c.ins.forEach((t,r)=>{r!==e&&(t.sequence=0)})}r&m.SIGHASH_ANYONECANPAY?(c.ins=[c.ins[e]],c.ins[0].script=i):(c.ins.forEach(e=>{e.script=p}),c.ins[e].script=i);const h=n.allocUnsafe(c.byteLength(!1)+4);return h.writeInt32LE(r,h.length-4),c.__toBuffer(h,0,!1),o.hash256(h)}hashForWitnessV1(e,t,r,s,f,h){if(a(u.tuple(u.UInt32,a.arrayOf(u.Buffer),a.arrayOf(u.Satoshi),u.UInt32),arguments),r.length!==this.ins.length||t.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const l=s===m.SIGHASH_DEFAULT?m.SIGHASH_ALL:s&m.SIGHASH_OUTPUT_MASK,d=(s&m.SIGHASH_INPUT_MASK)===m.SIGHASH_ANYONECANPAY,y=l===m.SIGHASH_NONE,w=l===m.SIGHASH_SINGLE;let b=p,g=p,E=p,O=p,P=p;if(!d){let e=i.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach(t=>{e.writeSlice(t.hash),e.writeUInt32(t.index)}),b=o.sha256(e.end()),e=i.BufferWriter.withCapacity(8*this.ins.length),r.forEach(t=>e.writeUInt64(t)),g=o.sha256(e.end()),e=i.BufferWriter.withCapacity(t.map(c).reduce((e,t)=>e+t)),t.forEach(t=>e.writeVarSlice(t)),E=o.sha256(e.end()),e=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach(t=>e.writeUInt32(t.sequence)),O=o.sha256(e.end())}if(y||w){if(w&&e<this.outs.length){const t=this.outs[e],r=i.BufferWriter.withCapacity(8+c(t.script));r.writeUInt64(t.value),r.writeVarSlice(t.script),P=o.sha256(r.end())}}else{const e=this.outs.map(e=>8+c(e.script)).reduce((e,t)=>e+t),t=i.BufferWriter.withCapacity(e);this.outs.forEach(e=>{t.writeUInt64(e.value),t.writeVarSlice(e.script)}),P=o.sha256(t.end())}const S=(f?2:0)+(h?1:0),v=174-(d?49:0)-(y?32:0)+(h?32:0)+(f?37:0),_=i.BufferWriter.withCapacity(v);if(_.writeUInt8(s),_.writeInt32(this.version),_.writeUInt32(this.locktime),_.writeSlice(b),_.writeSlice(g),_.writeSlice(E),_.writeSlice(O),y||w||_.writeSlice(P),_.writeUInt8(S),d){const n=this.ins[e];_.writeSlice(n.hash),_.writeUInt32(n.index),_.writeUInt64(r[e]),_.writeVarSlice(t[e]),_.writeUInt32(n.sequence)}else _.writeUInt32(e);if(h){const e=i.BufferWriter.withCapacity(c(h));e.writeVarSlice(h),_.writeSlice(o.sha256(e.end()))}return w&&_.writeSlice(P),f&&(_.writeSlice(f),_.writeUInt8(0),_.writeUInt32(4294967295)),o.taggedHash("TapSighash",n.concat([n.from([0]),_.end()]))}hashForWitnessV0(e,t,r,s){a(u.tuple(u.UInt32,u.Buffer,u.Satoshi,u.UInt32),arguments);let f,p=n.from([]),h=l,d=l,y=l;if(s&m.SIGHASH_ANYONECANPAY||(p=n.allocUnsafe(36*this.ins.length),f=new i.BufferWriter(p,0),this.ins.forEach(e=>{f.writeSlice(e.hash),f.writeUInt32(e.index)}),d=o.hash256(p)),s&m.SIGHASH_ANYONECANPAY||(31&s)===m.SIGHASH_SINGLE||(31&s)===m.SIGHASH_NONE||(p=n.allocUnsafe(4*this.ins.length),f=new i.BufferWriter(p,0),this.ins.forEach(e=>{f.writeUInt32(e.sequence)}),y=o.hash256(p)),(31&s)!==m.SIGHASH_SINGLE&&(31&s)!==m.SIGHASH_NONE){const e=this.outs.reduce((e,t)=>e+8+c(t.script),0);p=n.allocUnsafe(e),f=new i.BufferWriter(p,0),this.outs.forEach(e=>{f.writeUInt64(e.value),f.writeVarSlice(e.script)}),h=o.hash256(p)}else if((31&s)===m.SIGHASH_SINGLE&&e<this.outs.length){const t=this.outs[e];p=n.allocUnsafe(8+c(t.script)),f=new i.BufferWriter(p,0),f.writeUInt64(t.value),f.writeVarSlice(t.script),h=o.hash256(p)}p=n.allocUnsafe(156+c(t)),f=new i.BufferWriter(p,0);const w=this.ins[e];return f.writeInt32(this.version),f.writeSlice(d),f.writeSlice(y),f.writeSlice(w.hash),f.writeUInt32(w.index),f.writeVarSlice(t),f.writeUInt64(r),f.writeUInt32(w.sequence),f.writeSlice(h),f.writeUInt32(this.locktime),f.writeUInt32(s),o.hash256(p)}getHash(e){return e&&this.isCoinbase()?n.alloc(32,0):o.hash256(this.__toBuffer(void 0,void 0,e))}getId(){return(0,i.reverseBuffer)(this.getHash(!1)).toString("hex")}toBuffer(e,t){return this.__toBuffer(e,t,!0)}toHex(){return this.toBuffer(void 0,void 0).toString("hex")}setInputScript(e,t){a(u.tuple(u.Number,u.Buffer),arguments),this.ins[e].script=t}setWitness(e,t){a(u.tuple(u.Number,[u.Buffer]),arguments),this.ins[e].witness=t}__toBuffer(e,t,r=!1){e||(e=n.allocUnsafe(this.byteLength(r)));const o=new i.BufferWriter(e,t||0);o.writeInt32(this.version);const s=r&&this.hasWitnesses();return s&&(o.writeUInt8(m.ADVANCED_TRANSACTION_MARKER),o.writeUInt8(m.ADVANCED_TRANSACTION_FLAG)),o.writeVarInt(this.ins.length),this.ins.forEach(e=>{o.writeSlice(e.hash),o.writeUInt32(e.index),o.writeVarSlice(e.script),o.writeUInt32(e.sequence)}),o.writeVarInt(this.outs.length),this.outs.forEach(e=>{void 0!==e.value?o.writeUInt64(e.value):o.writeSlice(e.valueBuffer),o.writeVarSlice(e.script)}),s&&this.ins.forEach(e=>{o.writeVector(e.witness)}),o.writeUInt32(this.locktime),void 0!==t?e.slice(t,o.offset):e}}t.Transaction=m,m.DEFAULT_SEQUENCE=4294967295,m.SIGHASH_DEFAULT=0,m.SIGHASH_ALL=1,m.SIGHASH_NONE=2,m.SIGHASH_SINGLE=3,m.SIGHASH_ANYONECANPAY=128,m.SIGHASH_OUTPUT_MASK=3,m.SIGHASH_INPUT_MASK=128,m.ADVANCED_TRANSACTION_MARKER=0,m.ADVANCED_TRANSACTION_FLAG=1},63929:(e,t,r)=>{var n=r(31817).Buffer;function i(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function o(e){return i(e),e<253?1:e<=65535?3:e<=4294967295?5:9}e.exports={encode:function e(t,r,s){if(i(t),r||(r=n.allocUnsafe(o(t))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return s||(s=0),t<253?(r.writeUInt8(t,s),e.bytes=1):t<=65535?(r.writeUInt8(253,s),r.writeUInt16LE(t,s+1),e.bytes=3):t<=4294967295?(r.writeUInt8(254,s),r.writeUInt32LE(t,s+1),e.bytes=5):(r.writeUInt8(255,s),r.writeUInt32LE(t>>>0,s+1),r.writeUInt32LE(t/4294967296|0,s+5),e.bytes=9),r},decode:function e(t,r){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var o=t.readUInt8(r);if(o<253)return e.bytes=1,o;if(253===o)return e.bytes=3,t.readUInt16LE(r+1);if(254===o)return e.bytes=5,t.readUInt32LE(r+1);e.bytes=9;var s=t.readUInt32LE(r+1),f=4294967296*t.readUInt32LE(r+5)+s;return i(f),f},encodingLength:o}},70393:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.p2tr=t.p2wsh=t.p2wpkh=t.p2sh=t.p2pkh=t.p2pk=t.p2ms=t.embed=void 0;const n=r(204);Object.defineProperty(t,"embed",{enumerable:!0,get:function(){return n.p2data}});const i=r(85391);Object.defineProperty(t,"p2ms",{enumerable:!0,get:function(){return i.p2ms}});const o=r(72854);Object.defineProperty(t,"p2pk",{enumerable:!0,get:function(){return o.p2pk}});const s=r(26236);Object.defineProperty(t,"p2pkh",{enumerable:!0,get:function(){return s.p2pkh}});const f=r(57828);Object.defineProperty(t,"p2sh",{enumerable:!0,get:function(){return f.p2sh}});const u=r(87135);Object.defineProperty(t,"p2wpkh",{enumerable:!0,get:function(){return u.p2wpkh}});const a=r(76693);Object.defineProperty(t,"p2wsh",{enumerable:!0,get:function(){return a.p2wsh}});const c=r(43881);Object.defineProperty(t,"p2tr",{enumerable:!0,get:function(){return c.p2tr}})},72854:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.p2pk=void 0;const n=r(1834),i=r(94778),o=r(92992),s=r(96887),f=i.OPS;t.p2pk=function(e,t){if(!(e.input||e.output||e.pubkey||e.input||e.signature))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),pubkey:o.typeforce.maybe(o.isPoint),signature:o.typeforce.maybe(i.isCanonicalScriptSignature),input:o.typeforce.maybe(o.typeforce.Buffer)},e);const r=s.value(()=>i.decompile(e.input)),u={name:"p2pk",network:e.network||n.bitcoin};if(s.prop(u,"output",()=>{if(e.pubkey)return i.compile([e.pubkey,f.OP_CHECKSIG])}),s.prop(u,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),s.prop(u,"signature",()=>{if(e.input)return r()[0]}),s.prop(u,"input",()=>{if(e.signature)return i.compile([e.signature])}),s.prop(u,"witness",()=>{if(u.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==f.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,o.isPoint)(u.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(u.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(u.input))throw new TypeError("Signature mismatch");if(e.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!i.isCanonicalScriptSignature(u.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(u,e)}},73088:(e,t,r)=>{var n=r(50463);e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=Uint8Array.from(t),i=e(r),o=r.length+4,s=new Uint8Array(o);return s.set(r,0),s.set(i.subarray(0,4),r.length),n.encode(s,o)},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},76693:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2wsh=void 0;const i=r(58892),o=r(1834),s=r(94778),f=r(92992),u=r(96887),a=r(39771),c=s.OPS,p=n.alloc(0);function h(e){return!(!n.isBuffer(e)||65!==e.length||4!==e[0]||!(0,f.isPoint)(e))}t.p2wsh=function(e,t){if(!(e.address||e.hash||e.output||e.redeem||e.witness))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,f.typeforce)({network:f.typeforce.maybe(f.typeforce.Object),address:f.typeforce.maybe(f.typeforce.String),hash:f.typeforce.maybe(f.typeforce.BufferN(32)),output:f.typeforce.maybe(f.typeforce.BufferN(34)),redeem:f.typeforce.maybe({input:f.typeforce.maybe(f.typeforce.Buffer),network:f.typeforce.maybe(f.typeforce.Object),output:f.typeforce.maybe(f.typeforce.Buffer),witness:f.typeforce.maybe(f.typeforce.arrayOf(f.typeforce.Buffer))}),input:f.typeforce.maybe(f.typeforce.BufferN(0)),witness:f.typeforce.maybe(f.typeforce.arrayOf(f.typeforce.Buffer))},e);const r=u.value(()=>{const t=a.bech32.decode(e.address),r=t.words.shift(),i=a.bech32.fromWords(t.words);return{version:r,prefix:t.prefix,data:n.from(i)}}),l=u.value(()=>s.decompile(e.redeem.input));let d=e.network;d||(d=e.redeem&&e.redeem.network||o.bitcoin);const y={network:d};if(u.prop(y,"address",()=>{if(!y.hash)return;const e=a.bech32.toWords(y.hash);return e.unshift(0),a.bech32.encode(d.bech32,e)}),u.prop(y,"hash",()=>e.output?e.output.slice(2):e.address?r().data:y.redeem&&y.redeem.output?i.sha256(y.redeem.output):void 0),u.prop(y,"output",()=>{if(y.hash)return s.compile([c.OP_0,y.hash])}),u.prop(y,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:p,witness:e.witness.slice(0,-1)}}),u.prop(y,"input",()=>{if(y.witness)return p}),u.prop(y,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const t=s.toStack(l());return y.redeem=Object.assign({witness:t},e.redeem),y.redeem.input=p,[].concat(t,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),u.prop(y,"name",()=>{const e=["p2wsh"];return void 0!==y.redeem&&void 0!==y.redeem.name&&e.push(y.redeem.name),e.join("-")}),t.validate){let t=n.from([]);if(e.address){if(r().prefix!==d.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");t=r().data}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(34!==e.output.length||e.output[0]!==c.OP_0||32!==e.output[1])throw new TypeError("Output is invalid");const r=e.output.slice(2);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}if(e.redeem){if(e.redeem.network&&e.redeem.network!==d)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const r=s.decompile(e.redeem.output);if(!r||r.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.sha256(e.redeem.output);if(t.length>0&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.redeem.input&&!s.isPushOnly(l()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!(0,f.stacksEqual)(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&l().some(h)||e.redeem.output&&(s.decompile(e.redeem.output)||[]).some(h))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const t=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&!e.redeem.output.equals(t))throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(h)||(s.decompile(t)||[]).some(h))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(y,e)}},77397:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.signatureBlocksAction=t.checkInputForSig=t.pubkeyInScript=t.pubkeyPositionInScript=t.witnessStackToScriptWitness=t.isP2TR=t.isP2SHScript=t.isP2WSHScript=t.isP2WPKH=t.isP2PKH=t.isP2PK=t.isP2MS=void 0;const i=r(80862),o=r(94778),s=r(62329),f=r(58892),u=r(70393);function a(e){return t=>{try{return e({output:t}),!0}catch(e){return!1}}}function c(e,t){const r=(0,f.hash160)(e),n=e.slice(1,33),i=o.decompile(t);if(null===i)throw new Error("Unknown script error");return i.findIndex(t=>"number"!=typeof t&&(t.equals(e)||t.equals(r)||t.equals(n)))}function p(e,t,r){const{hashType:n}=t(e),i=[];switch(n&s.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case s.Transaction.SIGHASH_ALL:break;case s.Transaction.SIGHASH_SINGLE:case s.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}t.isP2MS=a(u.p2ms),t.isP2PK=a(u.p2pk),t.isP2PKH=a(u.p2pkh),t.isP2WPKH=a(u.p2wpkh),t.isP2WSHScript=a(u.p2wsh),t.isP2SHScript=a(u.p2sh),t.isP2TR=a(u.p2tr),t.witnessStackToScriptWitness=function(e){let t=n.allocUnsafe(0);function r(e){const r=t.length,o=i.encodingLength(e);t=n.concat([t,n.allocUnsafe(o)]),i.encode(e,t,r)}var o;return r((o=e).length),o.forEach(function(e){r(e.length),function(e){t=n.concat([t,n.from(e)])}(e)}),t},t.pubkeyPositionInScript=c,t.pubkeyInScript=function(e,t){return-1!==c(e,t)},t.checkInputForSig=function(e,t){return function(e){let t=[];if(0===(e.partialSig||[]).length){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=function(e){const t=e.finalScriptSig&&o.decompile(e.finalScriptSig)||[],r=e.finalScriptWitness&&o.decompile(e.finalScriptWitness)||[];return t.concat(r).filter(e=>n.isBuffer(e)&&o.isCanonicalScriptSignature(e)).map(e=>({signature:e}))}(e)}else t=e.partialSig;return t.map(e=>e.signature)}(e).some(e=>p(e,o.signature.decode,t))},t.signatureBlocksAction=p},80862:(e,t,r)=>{var n=r(38891).Buffer;function i(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function o(e){return i(e),e<253?1:e<=65535?3:e<=4294967295?5:9}Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function e(t,r,s){if(i(t),r||(r=n.allocUnsafe(o(t))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return s||(s=0),t<253?(r.writeUInt8(t,s),Object.assign(e,{bytes:1})):t<=65535?(r.writeUInt8(253,s),r.writeUInt16LE(t,s+1),Object.assign(e,{bytes:3})):t<=4294967295?(r.writeUInt8(254,s),r.writeUInt32LE(t,s+1),Object.assign(e,{bytes:5})):(r.writeUInt8(255,s),r.writeUInt32LE(t>>>0,s+1),r.writeUInt32LE(t/4294967296|0,s+5),Object.assign(e,{bytes:9})),r},t.decode=function e(t,r){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);const o=t.readUInt8(r);if(o<253)return Object.assign(e,{bytes:1}),o;if(253===o)return Object.assign(e,{bytes:3}),t.readUInt16LE(r+1);if(254===o)return Object.assign(e,{bytes:5}),t.readUInt32LE(r+1);{Object.assign(e,{bytes:9});const n=t.readUInt32LE(r+1),o=4294967296*t.readUInt32LE(r+5)+n;return i(o),o}},t.encodingLength=o},84068:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.encode=t.decode=void 0,t.decode=function(e,t,r){t=t||4,r=void 0===r||r;const n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&!(127&e[n-1]||!(n<=1)&&128&e[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){const t=e.readUInt32LE(0),r=e.readUInt8(4);return 128&r?-(4294967296*(-129&r)+t):4294967296*r+t}let i=0;for(let t=0;t<n;++t)i|=e[t]<<8*t;return 128&e[n-1]?-(i&~(128<<8*(n-1))):i},t.encode=function(e){let t=Math.abs(e);const r=(i=t)>2147483647?5:i>8388607?4:i>32767?3:i>127?2:i>0?1:0;var i;const o=n.allocUnsafe(r),s=e<0;for(let e=0;e<r;++e)o.writeUInt8(255&t,e),t>>=8;return 128&o[r-1]?o.writeUInt8(s?128:0,r-1):s&&(o[r-1]|=128),o}},85391:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.p2ms=void 0;const n=r(1834),i=r(94778),o=r(92992),s=r(96887),f=i.OPS,u=f.OP_RESERVED;t.p2ms=function(e,t){if(!(e.input||e.output||e.pubkeys&&void 0!==e.m||e.signatures))throw new TypeError("Not enough data");function r(e){return i.isCanonicalScriptSignature(e)||void 0!==(t.allowIncomplete&&e===f.OP_0)}t=Object.assign({validate:!0},t||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),m:o.typeforce.maybe(o.typeforce.Number),n:o.typeforce.maybe(o.typeforce.Number),output:o.typeforce.maybe(o.typeforce.Buffer),pubkeys:o.typeforce.maybe(o.typeforce.arrayOf(o.isPoint)),signatures:o.typeforce.maybe(o.typeforce.arrayOf(r)),input:o.typeforce.maybe(o.typeforce.Buffer)},e);const a={network:e.network||n.bitcoin};let c=[],p=!1;function h(e){p||(p=!0,c=i.decompile(e),a.m=c[0]-u,a.n=c[c.length-2]-u,a.pubkeys=c.slice(1,-2))}if(s.prop(a,"output",()=>{if(e.m&&a.n&&e.pubkeys)return i.compile([].concat(u+e.m,e.pubkeys,u+a.n,f.OP_CHECKMULTISIG))}),s.prop(a,"m",()=>{if(a.output)return h(a.output),a.m}),s.prop(a,"n",()=>{if(a.pubkeys)return a.pubkeys.length}),s.prop(a,"pubkeys",()=>{if(e.output)return h(e.output),a.pubkeys}),s.prop(a,"signatures",()=>{if(e.input)return i.decompile(e.input).slice(1)}),s.prop(a,"input",()=>{if(e.signatures)return i.compile([f.OP_0].concat(e.signatures))}),s.prop(a,"witness",()=>{if(a.input)return[]}),s.prop(a,"name",()=>{if(a.m&&a.n)return`p2ms(${a.m} of ${a.n})`}),t.validate){if(e.output){if(h(e.output),!o.typeforce.Number(c[0]))throw new TypeError("Output is invalid");if(!o.typeforce.Number(c[c.length-2]))throw new TypeError("Output is invalid");if(c[c.length-1]!==f.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(a.m<=0||a.n>16||a.m>a.n||a.n!==c.length-3)throw new TypeError("Output is invalid");if(!a.pubkeys.every(e=>(0,o.isPoint)(e)))throw new TypeError("Output is invalid");if(void 0!==e.m&&e.m!==a.m)throw new TypeError("m mismatch");if(void 0!==e.n&&e.n!==a.n)throw new TypeError("n mismatch");if(e.pubkeys&&!(0,o.stacksEqual)(e.pubkeys,a.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(void 0!==e.n&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(a.n=e.pubkeys.length,a.n<a.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<a.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>a.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==f.OP_0)throw new TypeError("Input is invalid");if(0===a.signatures.length||!a.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!(0,o.stacksEqual)(e.signatures,a.signatures))throw new TypeError("Signature mismatch");if(void 0!==e.m&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(a,e)}},85666:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.BufferReader=t.BufferWriter=t.cloneBuffer=t.reverseBuffer=t.writeUInt64LE=t.readUInt64LE=t.varuint=void 0;const i=r(92992),{typeforce:o}=i,s=r(63929);function f(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}function u(e,t){const r=e.readUInt32LE(t);let n=e.readUInt32LE(t+4);return n*=4294967296,f(n+r,9007199254740991),n+r}function a(e,t,r){return f(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8}t.varuint=s,t.readUInt64LE=u,t.writeUInt64LE=a,t.reverseBuffer=function(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;n<e.length/2;n++)r=e[n],e[n]=e[t],e[t]=r,t--;return e},t.cloneBuffer=function(e){const t=n.allocUnsafe(e.length);return e.copy(t),t};class c{static withCapacity(e){return new c(n.alloc(e))}constructor(e,t=0){this.buffer=e,this.offset=t,o(i.tuple(i.Buffer,i.UInt32),[e,t])}writeUInt8(e){this.offset=this.buffer.writeUInt8(e,this.offset)}writeInt32(e){this.offset=this.buffer.writeInt32LE(e,this.offset)}writeUInt32(e){this.offset=this.buffer.writeUInt32LE(e,this.offset)}writeUInt64(e){this.offset=a(this.buffer,e,this.offset)}writeVarInt(e){s.encode(e,this.buffer,this.offset),this.offset+=s.encode.bytes}writeSlice(e){if(this.buffer.length<this.offset+e.length)throw new Error("Cannot write slice out of bounds");this.offset+=e.copy(this.buffer,this.offset)}writeVarSlice(e){this.writeVarInt(e.length),this.writeSlice(e)}writeVector(e){this.writeVarInt(e.length),e.forEach(e=>this.writeVarSlice(e))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}t.BufferWriter=c,t.BufferReader=class{constructor(e,t=0){this.buffer=e,this.offset=t,o(i.tuple(i.Buffer,i.UInt32),[e,t])}readUInt8(){const e=this.buffer.readUInt8(this.offset);return this.offset++,e}readInt32(){const e=this.buffer.readInt32LE(this.offset);return this.offset+=4,e}readUInt32(){const e=this.buffer.readUInt32LE(this.offset);return this.offset+=4,e}readUInt64(){const e=u(this.buffer,this.offset);return this.offset+=8,e}readVarInt(){const e=s.decode(this.buffer,this.offset);return this.offset+=s.decode.bytes,e}readSlice(e){if(this.buffer.length<this.offset+e)throw new Error("Cannot read slice out of bounds");const t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const e=this.readVarInt(),t=[];for(let r=0;r<e;r++)t.push(this.readVarSlice());return t}}},87135:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2wpkh=void 0;const i=r(58892),o=r(1834),s=r(94778),f=r(92992),u=r(96887),a=r(39771),c=s.OPS,p=n.alloc(0);t.p2wpkh=function(e,t){if(!(e.address||e.hash||e.output||e.pubkey||e.witness))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,f.typeforce)({address:f.typeforce.maybe(f.typeforce.String),hash:f.typeforce.maybe(f.typeforce.BufferN(20)),input:f.typeforce.maybe(f.typeforce.BufferN(0)),network:f.typeforce.maybe(f.typeforce.Object),output:f.typeforce.maybe(f.typeforce.BufferN(22)),pubkey:f.typeforce.maybe(f.isPoint),signature:f.typeforce.maybe(s.isCanonicalScriptSignature),witness:f.typeforce.maybe(f.typeforce.arrayOf(f.typeforce.Buffer))},e);const r=u.value(()=>{const t=a.bech32.decode(e.address),r=t.words.shift(),i=a.bech32.fromWords(t.words);return{version:r,prefix:t.prefix,data:n.from(i)}}),h=e.network||o.bitcoin,l={name:"p2wpkh",network:h};if(u.prop(l,"address",()=>{if(!l.hash)return;const e=a.bech32.toWords(l.hash);return e.unshift(0),a.bech32.encode(h.bech32,e)}),u.prop(l,"hash",()=>e.output?e.output.slice(2,22):e.address?r().data:e.pubkey||l.pubkey?i.hash160(e.pubkey||l.pubkey):void 0),u.prop(l,"output",()=>{if(l.hash)return s.compile([c.OP_0,l.hash])}),u.prop(l,"pubkey",()=>e.pubkey?e.pubkey:e.witness?e.witness[1]:void 0),u.prop(l,"signature",()=>{if(e.witness)return e.witness[0]}),u.prop(l,"input",()=>{if(l.witness)return p}),u.prop(l,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let t=n.from([]);if(e.address){if(h&&h.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(20!==r().data.length)throw new TypeError("Invalid address data");t=r().data}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(22!==e.output.length||e.output[0]!==c.OP_0||20!==e.output[1])throw new TypeError("Output is invalid");if(t.length>0&&!t.equals(e.output.slice(2)))throw new TypeError("Hash mismatch");t=e.output.slice(2)}if(e.pubkey){const r=i.hash160(e.pubkey);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");if(t=r,!(0,f.isPoint)(e.pubkey)||33!==e.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(2!==e.witness.length)throw new TypeError("Witness is invalid");if(!s.isCanonicalScriptSignature(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,f.isPoint)(e.witness[1])||33!==e.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(e.signature&&!e.signature.equals(e.witness[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(e.witness[1]))throw new TypeError("Pubkey mismatch");const r=i.hash160(e.witness[1]);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch")}}return Object.assign(l,e)}},91736:e=>{e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var i=e.charAt(n),o=i.charCodeAt(0);if(255!==t[o])throw new TypeError(i+" is ambiguous");t[o]=n}var s=e.length,f=e.charAt(0),u=Math.log(s)/Math.log(256),a=Math.log(256)/Math.log(s);function c(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,n=0,i=0;e[r]===f;)n++,r++;for(var o=(e.length-r)*u+1>>>0,a=new Uint8Array(o);e[r];){var c=e.charCodeAt(r);if(c>255)return;var p=t[c];if(255===p)return;for(var h=0,l=o-1;(0!==p||h<i)&&-1!==l;l--,h++)p+=s*a[l]>>>0,a[l]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=h,r++}for(var d=o-i;d!==o&&0===a[d];)d++;for(var y=new Uint8Array(n+(o-d)),w=n;d!==o;)y[w++]=a[d++];return y}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var u=(o-i)*a+1>>>0,c=new Uint8Array(u);i!==o;){for(var p=t[i],h=0,l=u-1;(0!==p||h<n)&&-1!==l;l--,h++)p+=256*c[l]>>>0,c[l]=p%s>>>0,p=p/s>>>0;if(0!==p)throw new Error("Non-zero carry");n=h,i++}for(var d=u-n;d!==u&&0===c[d];)d++;for(var y=f.repeat(r);d<u;++d)y+=e.charAt(c[d]);return y},decodeUnsafe:c,decode:function(e){var t=c(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}},92992:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.oneOf=t.Null=t.BufferN=t.Function=t.UInt32=t.UInt8=t.tuple=t.maybe=t.Hex=t.Buffer=t.String=t.Boolean=t.Array=t.Number=t.Hash256bit=t.Hash160bit=t.Buffer256bit=t.isTaptree=t.isTapleaf=t.TAPLEAF_VERSION_MASK=t.Satoshi=t.isPoint=t.stacksEqual=t.typeforce=void 0;const n=r(38891);t.typeforce=r(1920);const i=n.Buffer.alloc(32,0),o=n.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");function s(e){return!(!e||!("output"in e)||!n.Buffer.isBuffer(e.output)||void 0!==e.version&&(e.version&t.TAPLEAF_VERSION_MASK)!==e.version)}t.stacksEqual=function(e,t){return e.length===t.length&&e.every((e,r)=>e.equals(t[r]))},t.isPoint=function(e){if(!n.Buffer.isBuffer(e))return!1;if(e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(0===r.compare(i))return!1;if(r.compare(o)>=0)return!1;if((2===t||3===t)&&33===e.length)return!0;const s=e.slice(33);return 0!==s.compare(i)&&!(s.compare(o)>=0)&&4===t&&65===e.length},t.Satoshi=function(e){return t.typeforce.UInt53(e)&&e<=21e14},t.TAPLEAF_VERSION_MASK=254,t.isTapleaf=s,t.isTaptree=function e(r){return(0,t.Array)(r)?2===r.length&&r.every(t=>e(t)):s(r)},t.Buffer256bit=t.typeforce.BufferN(32),t.Hash160bit=t.typeforce.BufferN(20),t.Hash256bit=t.typeforce.BufferN(32),t.Number=t.typeforce.Number,t.Array=t.typeforce.Array,t.Boolean=t.typeforce.Boolean,t.String=t.typeforce.String,t.Buffer=t.typeforce.Buffer,t.Hex=t.typeforce.Hex,t.maybe=t.typeforce.maybe,t.tuple=t.typeforce.tuple,t.UInt8=t.typeforce.UInt8,t.UInt32=t.typeforce.UInt32,t.Function=t.typeforce.Function,t.BufferN=t.typeforce.BufferN,t.Null=t.typeforce.Null,t.oneOf=t.typeforce.oneOf},93553:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sha1=t.SHA1=void 0;const n=r(29403);t.SHA1=n.SHA1,t.sha1=n.sha1},94778:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.signature=t.number=t.isCanonicalScriptSignature=t.isDefinedHashType=t.isCanonicalPubKey=t.toStack=t.fromASM=t.toASM=t.decompile=t.compile=t.countNonPushOnlyOPs=t.isPushOnly=t.OPS=void 0;const i=r(34538),o=r(45029);Object.defineProperty(t,"OPS",{enumerable:!0,get:function(){return o.OPS}});const s=r(12820),f=r(84068),u=r(38191),a=r(92992),{typeforce:c}=a,p=o.OPS.OP_RESERVED;function h(e){return a.Buffer(e)||function(e){return a.Number(e)&&(e===o.OPS.OP_0||e>=o.OPS.OP_1&&e<=o.OPS.OP_16||e===o.OPS.OP_1NEGATE)}(e)}function l(e){return a.Array(e)&&e.every(h)}function d(e){return 0===e.length?o.OPS.OP_0:1===e.length?e[0]>=1&&e[0]<=16?p+e[0]:129===e[0]?o.OPS.OP_1NEGATE:void 0:void 0}function y(e){return n.isBuffer(e)}function w(e){return n.isBuffer(e)}function m(e){if(y(e))return e;c(a.Array,e);const t=e.reduce((e,t)=>w(t)?1===t.length&&void 0!==d(t)?e+1:e+s.encodingLength(t.length)+t.length:e+1,0),r=n.allocUnsafe(t);let i=0;if(e.forEach(e=>{if(w(e)){const t=d(e);if(void 0!==t)return r.writeUInt8(t,i),void(i+=1);i+=s.encode(r,e.length,i),e.copy(r,i),i+=e.length}else r.writeUInt8(e,i),i+=1}),i!==r.length)throw new Error("Could not decode chunks");return r}function b(e){if(t=e,a.Array(t))return e;var t;c(a.Buffer,e);const r=[];let n=0;for(;n<e.length;){const t=e[n];if(t>o.OPS.OP_0&&t<=o.OPS.OP_PUSHDATA4){const t=s.decode(e,n);if(null===t)return null;if(n+=t.size,n+t.number>e.length)return null;const i=e.slice(n,n+t.number);n+=t.number;const o=d(i);void 0!==o?r.push(o):r.push(i)}else r.push(t),n+=1}return r}function g(e){const t=-129&e;return t>0&&t<4}t.isPushOnly=l,t.countNonPushOnlyOPs=function(e){return e.length-e.filter(h).length},t.compile=m,t.decompile=b,t.toASM=function(e){if(y(e)&&(e=b(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return e.map(e=>{if(w(e)){const t=d(e);if(void 0===t)return e.toString("hex");e=t}return o.REVERSE_OPS[e]}).join(" ")},t.fromASM=function(e){return c(a.String,e),m(e.split(" ").map(e=>void 0!==o.OPS[e]?o.OPS[e]:(c(a.Hex,e),n.from(e,"hex"))))},t.toStack=function(e){return e=b(e),c(l,e),e.map(e=>w(e)?e:e===o.OPS.OP_0?n.allocUnsafe(0):f.encode(e-p))},t.isCanonicalPubKey=function(e){return a.isPoint(e)},t.isDefinedHashType=g,t.isCanonicalScriptSignature=function(e){return!!n.isBuffer(e)&&!!g(e[e.length-1])&&i.check(e.slice(0,-1))},t.number=f,t.signature=u},96887:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.value=t.prop=void 0,t.prop=function(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const e=r.call(this);return this[t]=e,e},set(e){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:e,writable:!0})}})},t.value=function(e){let t;return()=>(void 0!==t||(t=e()),t)}}};
|
|
2
|
+
export const __webpack_esm_id__=397;export const __webpack_esm_ids__=[397];export const __webpack_esm_modules__={204:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.p2data=void 0;const n=r(1834),i=r(94778),o=r(92992),s=r(96887),f=i.OPS;t.p2data=function(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),data:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer))},e);const r={name:"embed",network:e.network||n.bitcoin};if(s.prop(r,"output",()=>{if(e.data)return i.compile([f.OP_RETURN].concat(e.data))}),s.prop(r,"data",()=>{if(e.output)return i.decompile(e.output).slice(1)}),t.validate&&e.output){const t=i.decompile(e.output);if(t[0]!==f.OP_RETURN)throw new TypeError("Output is invalid");if(!t.slice(1).every(o.typeforce.Buffer))throw new TypeError("Output is invalid");if(e.data&&!(0,o.stacksEqual)(e.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,e)}},920:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.getEccLib=t.initEccLib=void 0;const i={};t.initEccLib=function(e,t){var r;e?e!==i.eccLib&&(t?.DANGER_DO_NOT_VERIFY_ECCLIB||(s("function"==typeof(r=e).isXOnlyPoint),s(r.isXOnlyPoint(o("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),s(r.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),s(r.isXOnlyPoint(o("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),s(r.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000001"))),s(!r.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000000"))),s(!r.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),s("function"==typeof r.xOnlyPointAddTweak),f.forEach(e=>{const t=r.xOnlyPointAddTweak(o(e.pubkey),o(e.tweak));null===e.result?s(null===t):(s(null!==t),s(t.parity===e.parity),s(n.from(t.xOnlyPubkey).equals(o(e.result))))})),i.eccLib=e):i.eccLib=e},t.getEccLib=function(){if(!i.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return i.eccLib};const o=e=>n.from(e,"hex");function s(e){if(!e)throw new Error("ecc library invalid")}const f=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}]},1834:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.testnet=t.regtest=t.bitcoin=void 0,t.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},t.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},t.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},1920:(e,t,r)=>{var n=r(35601),i=r(31677),o=n.tfJSON,s=n.TfTypeError,f=n.TfPropertyTypeError,u=n.tfSubError,a=n.getValueTypeName,c={arrayOf:function(e,t){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==t.minLength&&r.length<t.minLength)&&!(void 0!==t.maxLength&&r.length>t.maxLength)&&(void 0===t.length||r.length===t.length)&&r.every(function(t,r){try{return h(e,t,n)}catch(e){throw u(e,r)}})}return e=p(e),t=t||{},r.toJSON=function(){var r="["+o(e)+"]";return void 0!==t.length?r+="{"+t.length+"}":void 0===t.minLength&&void 0===t.maxLength||(r+="{"+(void 0===t.minLength?0:t.minLength)+","+(void 0===t.maxLength?1/0:t.maxLength)+"}"),r},r},maybe:function e(t){function r(r,n){return i.Nil(r)||t(r,n,e)}return t=p(t),r.toJSON=function(){return"?"+o(t)},r},map:function(e,t){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{t&&h(t,o,n)}catch(e){throw u(e,o,"key")}try{var s=r[o];h(e,s,n)}catch(e){throw u(e,o)}}return!0}return e=p(e),t&&(t=p(t)),r.toJSON=t?function(){return"{"+o(t)+": "+o(e)+"}"}:function(){return"{"+o(e)+"}"},r},object:function(e){var t={};for(var r in e)t[r]=p(e[r]);function n(e,r){if(!i.Object(e))return!1;if(i.Nil(e))return!1;var n;try{for(n in t)h(t[n],e[n],r)}catch(e){throw u(e,n)}if(r)for(n in e)if(!t[n])throw new f(void 0,n);return!0}return n.toJSON=function(){return o(t)},n},anyOf:function(){var e=[].slice.call(arguments).map(p);function t(t,r){return e.some(function(e){try{return h(e,t,r)}catch(e){return!1}})}return t.toJSON=function(){return e.map(o).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(p);function t(t,r){return e.every(function(e){try{return h(e,t,r)}catch(e){return!1}})}return t.toJSON=function(){return e.map(o).join(" & ")},t},quacksLike:function(e){function t(t){return e===a(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(p);function t(t,r){return!i.Nil(t)&&!i.Nil(t.length)&&(!r||t.length===e.length)&&e.every(function(e,n){try{return h(e,t[n],r)}catch(e){throw u(e,n)}})}return t.toJSON=function(){return"("+e.map(o).join(", ")+")"},t},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function p(e){if(i.String(e))return"?"===e[0]?c.maybe(e.slice(1)):i[e]||c.quacksLike(e);if(e&&i.Object(e)){if(i.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return c.arrayOf(e[0])}return c.object(e)}return i.Function(e)?e:c.value(e)}function h(e,t,r,n){if(i.Function(e)){if(e(t,r))return!0;throw new s(n||e,t)}return h(p(e),t,r)}for(var l in c.oneOf=c.anyOf,i)h[l]=i[l];for(l in c)h[l]=c[l];var d=r(13274);for(l in d)h[l]=d[l];h.compile=p,h.TfTypeError=s,h.TfPropertyTypeError=f,e.exports=h},10148:e=>{e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var i=e.charAt(n),o=i.charCodeAt(0);if(255!==t[o])throw new TypeError(i+" is ambiguous");t[o]=n}var s=e.length,f=e.charAt(0),u=Math.log(s)/Math.log(256),a=Math.log(256)/Math.log(s);function c(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,n=0,i=0;e[r]===f;)n++,r++;for(var o=(e.length-r)*u+1>>>0,a=new Uint8Array(o);e[r];){var c=e.charCodeAt(r);if(c>255)return;var p=t[c];if(255===p)return;for(var h=0,l=o-1;(0!==p||h<i)&&-1!==l;l--,h++)p+=s*a[l]>>>0,a[l]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=h,r++}for(var d=o-i;d!==o&&0===a[d];)d++;for(var y=new Uint8Array(n+(o-d)),w=n;d!==o;)y[w++]=a[d++];return y}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var u=(o-i)*a+1>>>0,c=new Uint8Array(u);i!==o;){for(var p=t[i],h=0,l=u-1;(0!==p||h<n)&&-1!==l;l--,h++)p+=256*c[l]>>>0,c[l]=p%s>>>0,p=p/s>>>0;if(0!==p)throw new Error("Non-zero carry");n=h,i++}for(var d=u-n;d!==u&&0===c[d];)d++;for(var y=f.repeat(r);d<u;++d)y+=e.charAt(c[d]);return y},decodeUnsafe:c,decode:function(e){var t=c(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}},11643:(e,t,r)=>{const n=r(10148);e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},12820:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=t.encodingLength=void 0;const n=r(45029);function i(e){return e<n.OPS.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}t.encodingLength=i,t.encode=function(e,t,r){const o=i(t);return 1===o?e.writeUInt8(t,r):2===o?(e.writeUInt8(n.OPS.OP_PUSHDATA1,r),e.writeUInt8(t,r+1)):3===o?(e.writeUInt8(n.OPS.OP_PUSHDATA2,r),e.writeUInt16LE(t,r+1)):(e.writeUInt8(n.OPS.OP_PUSHDATA4,r),e.writeUInt32LE(t,r+1)),o},t.decode=function(e,t){const r=e.readUInt8(t);let i,o;if(r<n.OPS.OP_PUSHDATA1)i=r,o=1;else if(r===n.OPS.OP_PUSHDATA1){if(t+2>e.length)return null;i=e.readUInt8(t+1),o=2}else if(r===n.OPS.OP_PUSHDATA2){if(t+3>e.length)return null;i=e.readUInt16LE(t+1),o=3}else{if(t+5>e.length)return null;if(r!==n.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");i=e.readUInt32LE(t+1),o=5}return{opcode:r,number:i,size:o}}},13274:(e,t,r)=>{var n=r(38891).Buffer,i=r(31677),o=r(35601);function s(e){return n.isBuffer(e)}function f(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function u(e,t){var r=e.toJSON();function n(n){if(!e(n))return!1;if(n.length===t)return!0;throw o.tfCustomError(r+"(Length: "+t+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var a=u.bind(null,i.Array),c=u.bind(null,s),p=u.bind(null,f),h=u.bind(null,i.String),l=Math.pow(2,53)-1,d={ArrayN:a,Buffer:s,BufferN:c,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:f,HexN:p,Int8:function(e){return e<<24>>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},Int53:function(e){return"number"==typeof e&&e>=-l&&e<=l&&Math.floor(e)===e},Range:function(e,t,r){function n(n,i){return r(n,i)&&n>e&&n<t}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${e}, ${t}]`},n},StringN:h,UInt8:function(e){return(255&e)===e},UInt16:function(e){return(65535&e)===e},UInt32:function(e){return e>>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=l&&Math.floor(e)===e}};for(var y in d)d[y].toJSON=function(e){return e}.bind(null,y);e.exports=d},26236:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2pkh=void 0;const i=r(58892),o=r(1834),s=r(94778),f=r(92992),u=r(96887),a=r(60709),c=s.OPS;t.p2pkh=function(e,t){if(!(e.address||e.hash||e.output||e.pubkey||e.input))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,f.typeforce)({network:f.typeforce.maybe(f.typeforce.Object),address:f.typeforce.maybe(f.typeforce.String),hash:f.typeforce.maybe(f.typeforce.BufferN(20)),output:f.typeforce.maybe(f.typeforce.BufferN(25)),pubkey:f.typeforce.maybe(f.isPoint),signature:f.typeforce.maybe(s.isCanonicalScriptSignature),input:f.typeforce.maybe(f.typeforce.Buffer)},e);const r=u.value(()=>{const t=n.from(a.decode(e.address));return{version:t.readUInt8(0),hash:t.slice(1)}}),p=u.value(()=>s.decompile(e.input)),h=e.network||o.bitcoin,l={name:"p2pkh",network:h};if(u.prop(l,"address",()=>{if(!l.hash)return;const e=n.allocUnsafe(21);return e.writeUInt8(h.pubKeyHash,0),l.hash.copy(e,1),a.encode(e)}),u.prop(l,"hash",()=>e.output?e.output.slice(3,23):e.address?r().hash:e.pubkey||l.pubkey?i.hash160(e.pubkey||l.pubkey):void 0),u.prop(l,"output",()=>{if(l.hash)return s.compile([c.OP_DUP,c.OP_HASH160,l.hash,c.OP_EQUALVERIFY,c.OP_CHECKSIG])}),u.prop(l,"pubkey",()=>{if(e.input)return p()[1]}),u.prop(l,"signature",()=>{if(e.input)return p()[0]}),u.prop(l,"input",()=>{if(e.pubkey&&e.signature)return s.compile([e.signature,e.pubkey])}),u.prop(l,"witness",()=>{if(l.input)return[]}),t.validate){let t=n.from([]);if(e.address){if(r().version!==h.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");t=r().hash}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(25!==e.output.length||e.output[0]!==c.OP_DUP||e.output[1]!==c.OP_HASH160||20!==e.output[2]||e.output[23]!==c.OP_EQUALVERIFY||e.output[24]!==c.OP_CHECKSIG)throw new TypeError("Output is invalid");const r=e.output.slice(3,23);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}if(e.pubkey){const r=i.hash160(e.pubkey);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}if(e.input){const r=p();if(2!==r.length)throw new TypeError("Input is invalid");if(!s.isCanonicalScriptSignature(r[0]))throw new TypeError("Input has invalid signature");if(!(0,f.isPoint)(r[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&!e.signature.equals(r[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(r[1]))throw new TypeError("Pubkey mismatch");const n=i.hash160(r[1]);if(t.length>0&&!t.equals(n))throw new TypeError("Hash mismatch")}}return Object.assign(l,e)}},31677:e=>{var t={Array:function(e){return null!=e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return null==e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var r in t.Null=t.Nil,t)t[r].toJSON=function(e){return e}.bind(null,r);e.exports=t},31817:(e,t,r)=>{var n=r(38891),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,t),t.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},34538:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.encode=t.decode=t.check=void 0,t.check=function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;const t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;const r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},t.decode=function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");const t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");const r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},t.encode=function(e,t){const r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");const o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}},35601:(e,t,r)=>{var n=r(31677);function i(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function o(e){return n.Nil(e)?"":i(e.constructor)}function s(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function f(e){return n.Function(e)?e.toJSON?e.toJSON():i(e):n.Array(e)?"Array":e&&n.Object(e)?"Object":void 0!==e?e:""}function u(e,t,r){var i=function(e){return n.Function(e)?"":n.String(e)?JSON.stringify(e):e&&n.Object(e)?"":e}(t);return"Expected "+f(e)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function a(e,t,r){r=r||o(t),this.message=u(e,t,r),s(this,a),this.__type=e,this.__value=t,this.__valueTypeName=r}function c(e,t,r,n,i){e?(i=i||o(n),this.message=function(e,t,r,n,i){var o='" of type ';return"key"===t&&(o='" with key type '),u('property "'+f(r)+o+f(e),n,i)}(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',s(this,a),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}a.prototype=Object.create(Error.prototype),a.prototype.constructor=a,c.prototype=Object.create(Error.prototype),c.prototype.constructor=a,e.exports={TfTypeError:a,TfPropertyTypeError:c,tfCustomError:function(e,t){return new a(e,{},t)},tfSubError:function(e,t,r){return e instanceof c?(t=t+"."+e.__property,e=new c(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof a&&(e=new c(e.__type,t,r,e.__value,e.__valueTypeName)),s(e),e},tfJSON:f,getValueTypeName:o}},38191:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.encode=t.decode=void 0;const i=r(34538),o=r(94778),s=r(92992),{typeforce:f}=s,u=n.alloc(1,0);function a(e){let t=0;for(;0===e[t];)++t;return t===e.length?u:128&(e=e.slice(t))[0]?n.concat([u,e],1+e.length):e}function c(e){0===e[0]&&(e=e.slice(1));const t=n.alloc(32,0),r=Math.max(0,32-e.length);return e.copy(t,r),t}t.decode=function(e){const t=e.readUInt8(e.length-1);if(!(0,o.isDefinedHashType)(t))throw new Error("Invalid hashType "+t);const r=i.decode(e.slice(0,-1)),s=c(r.r),f=c(r.s);return{signature:n.concat([s,f],64),hashType:t}},t.encode=function(e,t){if(f({signature:s.BufferN(64),hashType:s.UInt8},{signature:e,hashType:t}),!(0,o.isDefinedHashType)(t))throw new Error("Invalid hashType "+t);const r=n.allocUnsafe(1);r.writeUInt8(t,0);const u=a(e.slice(0,32)),c=a(e.slice(32,64));return n.concat([i.encode(u,c),r])}},38381:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.toOutputScript=t.fromOutputScript=t.toBech32=t.toBase58Check=t.fromBech32=t.fromBase58Check=void 0;const i=r(1834),o=r(70393),s=r(94778),f=r(92992),u=r(39771),a=r(60709),c="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function p(e){const t=n.from(a.decode(e));if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");return{version:t.readUInt8(0),hash:t.slice(1)}}function h(e){let t,r;try{t=u.bech32.decode(e)}catch(e){}if(t){if(r=t.words[0],0!==r)throw new TypeError(e+" uses wrong encoding")}else if(t=u.bech32m.decode(e),r=t.words[0],0===r)throw new TypeError(e+" uses wrong encoding");const i=u.bech32.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:n.from(i)}}function l(e,t,r){const n=u.bech32.toWords(e);return n.unshift(t),0===t?u.bech32.encode(r,n):u.bech32m.encode(r,n)}t.fromBase58Check=p,t.fromBech32=h,t.toBase58Check=function(e,t){(0,f.typeforce)((0,f.tuple)(f.Hash160bit,f.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(t,0),e.copy(r,1),a.encode(r)},t.toBech32=l,t.fromOutputScript=function(e,t){t=t||i.bitcoin;try{return o.p2pkh({output:e,network:t}).address}catch(e){}try{return o.p2sh({output:e,network:t}).address}catch(e){}try{return o.p2wpkh({output:e,network:t}).address}catch(e){}try{return o.p2wsh({output:e,network:t}).address}catch(e){}try{return o.p2tr({output:e,network:t}).address}catch(e){}try{return function(e,t){const r=e.slice(2);if(r.length<2||r.length>40)throw new TypeError("Invalid program length for segwit address");const n=e[0]-80;if(n<2||n>16)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(c),l(r,n,t.bech32)}(e,t)}catch(e){}throw new Error(s.toASM(e)+" has no matching Address")},t.toOutputScript=function(e,t){let r,n;t=t||i.bitcoin;try{r=p(e)}catch(e){}if(r){if(r.version===t.pubKeyHash)return o.p2pkh({hash:r.hash}).output;if(r.version===t.scriptHash)return o.p2sh({hash:r.hash}).output}else{try{n=h(e)}catch(e){}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return o.p2wpkh({hash:n.data}).output;if(32===n.data.length)return o.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return o.p2tr({pubkey:n.data}).output}else if(n.version>=2&&n.version<=16&&n.data.length>=2&&n.data.length<=40)return console.warn(c),s.compile([n.version+80,n.data])}}throw new Error(e+" has no matching Script")}},43881:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.p2tr=void 0;const n=r(38891),i=r(1834),o=r(94778),s=r(92992),f=r(920),u=r(50102),a=r(96887),c=r(39771),p=r(38381),h=o.OPS;t.p2tr=function(e,t){if(!(e.address||e.output||e.pubkey||e.internalPubkey||e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(34)),internalPubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),pubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),signature:s.typeforce.maybe(s.typeforce.anyOf(s.typeforce.BufferN(64),s.typeforce.BufferN(65))),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer)),scriptTree:s.typeforce.maybe(s.isTaptree),redeem:s.typeforce.maybe({output:s.typeforce.maybe(s.typeforce.Buffer),redeemVersion:s.typeforce.maybe(s.typeforce.Number),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),redeemVersion:s.typeforce.maybe(s.typeforce.Number)},e);const r=a.value(()=>(0,p.fromBech32)(e.address)),l=a.value(()=>{if(e.witness&&e.witness.length)return e.witness.length>=2&&80===e.witness[e.witness.length-1][0]?e.witness.slice(0,-1):e.witness.slice()}),d=a.value(()=>e.scriptTree?(0,u.toHashTree)(e.scriptTree):e.hash?{hash:e.hash}:void 0),y=e.network||i.bitcoin,w={name:"p2tr",network:y};if(a.prop(w,"address",()=>{if(!w.pubkey)return;const e=c.bech32m.toWords(w.pubkey);return e.unshift(1),c.bech32m.encode(y.bech32,e)}),a.prop(w,"hash",()=>{const e=d();if(e)return e.hash;const t=l();if(t&&t.length>1){const e=t[t.length-1],r=e[0]&s.TAPLEAF_VERSION_MASK,n=t[t.length-2],i=(0,u.tapleafHash)({output:n,version:r});return(0,u.rootHashFromPath)(e,i)}return null}),a.prop(w,"output",()=>{if(w.pubkey)return o.compile([h.OP_1,w.pubkey])}),a.prop(w,"redeemVersion",()=>e.redeemVersion?e.redeemVersion:e.redeem&&void 0!==e.redeem.redeemVersion&&null!==e.redeem.redeemVersion?e.redeem.redeemVersion:u.LEAF_VERSION_TAPSCRIPT),a.prop(w,"redeem",()=>{const e=l();if(e&&!(e.length<2))return{output:e[e.length-2],witness:e.slice(0,-2),redeemVersion:e[e.length-1][0]&s.TAPLEAF_VERSION_MASK}}),a.prop(w,"pubkey",()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(w.internalPubkey){const e=(0,u.tweakKey)(w.internalPubkey,w.hash);if(e)return e.x}}),a.prop(w,"internalPubkey",()=>{if(e.internalPubkey)return e.internalPubkey;const t=l();return t&&t.length>1?t[t.length-1].slice(1,33):void 0}),a.prop(w,"signature",()=>{if(e.signature)return e.signature;const t=l();return t&&1===t.length?t[0]:void 0}),a.prop(w,"witness",()=>{if(e.witness)return e.witness;const t=d();if(t&&e.redeem&&e.redeem.output&&e.internalPubkey){const r=(0,u.tapleafHash)({output:e.redeem.output,version:w.redeemVersion}),i=(0,u.findScriptPath)(t,r);if(!i)return;const o=(0,u.tweakKey)(e.internalPubkey,t.hash);if(!o)return;const s=n.Buffer.concat([n.Buffer.from([w.redeemVersion|o.parity]),e.internalPubkey].concat(i));return[e.redeem.output,s]}return e.signature?[e.signature]:void 0}),t.validate){let t=n.Buffer.from([]);if(e.address){if(y&&y.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(1!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");t=r().data}if(e.pubkey){if(t.length>0&&!t.equals(e.pubkey))throw new TypeError("Pubkey mismatch");t=e.pubkey}if(e.output){if(34!==e.output.length||e.output[0]!==h.OP_1||32!==e.output[1])throw new TypeError("Output is invalid");if(t.length>0&&!t.equals(e.output.slice(2)))throw new TypeError("Pubkey mismatch");t=e.output.slice(2)}if(e.internalPubkey){const r=(0,u.tweakKey)(e.internalPubkey,w.hash);if(t.length>0&&!t.equals(r.x))throw new TypeError("Pubkey mismatch");t=r.x}if(t&&t.length&&!(0,f.getEccLib)().isXOnlyPoint(t))throw new TypeError("Invalid pubkey for p2tr");const i=d();if(e.hash&&i&&!e.hash.equals(i.hash))throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&i){const t=(0,u.tapleafHash)({output:e.redeem.output,version:w.redeemVersion});if(!(0,u.findScriptPath)(i,t))throw new TypeError("Redeem script not in tree")}const a=l();if(e.redeem&&w.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==w.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(0===o.decompile(e.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(w.redeem.output&&!e.redeem.output.equals(w.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&w.redeem.witness&&!(0,s.stacksEqual)(e.redeem.witness,w.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(a&&a.length)if(1===a.length){if(e.signature&&!e.signature.equals(a[0]))throw new TypeError("Signature mismatch")}else{const r=a[a.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(e.internalPubkey&&!e.internalPubkey.equals(i))throw new TypeError("Internal pubkey mismatch");if(!(0,f.getEccLib)().isXOnlyPoint(i))throw new TypeError("Invalid internalPubkey for p2tr witness");const o=r[0]&s.TAPLEAF_VERSION_MASK,c=a[a.length-2],p=(0,u.tapleafHash)({output:c,version:o}),h=(0,u.rootHashFromPath)(r,p),l=(0,u.tweakKey)(i,h);if(!l)throw new TypeError("Invalid outputKey for p2tr witness");if(t.length&&!t.equals(l.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(l.parity!==(1&r[0]))throw new Error("Incorrect parity")}}return Object.assign(w,e)}},45029:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.REVERSE_OPS=t.OPS=void 0;const r={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};t.OPS=r;const n={};t.REVERSE_OPS=n;for(const e of Object.keys(r))n[r[e]]=e},50102:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tweakKey=t.tapTweakHash=t.tapleafHash=t.findScriptPath=t.toHashTree=t.rootHashFromPath=t.MAX_TAPTREE_DEPTH=t.LEAF_VERSION_TAPSCRIPT=void 0;const n=r(38891),i=r(920),o=r(58892),s=r(85666),f=r(92992);function u(e){const r=e.version||t.LEAF_VERSION_TAPSCRIPT;return o.taggedHash("TapLeaf",n.Buffer.concat([n.Buffer.from([r]),p(e.output)]))}function a(e,t){return o.taggedHash("TapTweak",n.Buffer.concat(t?[e,t]:[e]))}function c(e,t){return o.taggedHash("TapBranch",n.Buffer.concat([e,t]))}function p(e){const t=s.varuint.encodingLength(e.length),r=n.Buffer.allocUnsafe(t);return s.varuint.encode(e.length,r),n.Buffer.concat([r,e])}t.LEAF_VERSION_TAPSCRIPT=192,t.MAX_TAPTREE_DEPTH=128,t.rootHashFromPath=function(e,t){if(e.length<33)throw new TypeError(`The control-block length is too small. Got ${e.length}, expected min 33.`);const r=(e.length-33)/32;let n=t;for(let t=0;t<r;t++){const r=e.slice(33+32*t,65+32*t);n=n.compare(r)<0?c(n,r):c(r,n)}return n},t.toHashTree=function e(t){if((0,f.isTapleaf)(t))return{hash:u(t)};const r=[e(t[0]),e(t[1])];r.sort((e,t)=>e.hash.compare(t.hash));const[n,i]=r;return{hash:c(n.hash,i.hash),left:n,right:i}},t.findScriptPath=function e(t,r){if("left"in(n=t)&&"right"in n){const n=e(t.left,r);if(void 0!==n)return[...n,t.right.hash];const i=e(t.right,r);if(void 0!==i)return[...i,t.left.hash]}else if(t.hash.equals(r))return[];var n},t.tapleafHash=u,t.tapTweakHash=a,t.tweakKey=function(e,t){if(!n.Buffer.isBuffer(e))return null;if(32!==e.length)return null;if(t&&32!==t.length)return null;const r=a(e,t),o=(0,i.getEccLib)().xOnlyPointAddTweak(e,r);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:n.Buffer.from(o.xOnlyPubkey)}:null}},57828:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2sh=void 0;const i=r(58892),o=r(1834),s=r(94778),f=r(92992),u=r(96887),a=r(60709),c=s.OPS;t.p2sh=function(e,t){if(!(e.address||e.hash||e.output||e.redeem||e.input))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,f.typeforce)({network:f.typeforce.maybe(f.typeforce.Object),address:f.typeforce.maybe(f.typeforce.String),hash:f.typeforce.maybe(f.typeforce.BufferN(20)),output:f.typeforce.maybe(f.typeforce.BufferN(23)),redeem:f.typeforce.maybe({network:f.typeforce.maybe(f.typeforce.Object),output:f.typeforce.maybe(f.typeforce.Buffer),input:f.typeforce.maybe(f.typeforce.Buffer),witness:f.typeforce.maybe(f.typeforce.arrayOf(f.typeforce.Buffer))}),input:f.typeforce.maybe(f.typeforce.Buffer),witness:f.typeforce.maybe(f.typeforce.arrayOf(f.typeforce.Buffer))},e);let r=e.network;r||(r=e.redeem&&e.redeem.network||o.bitcoin);const p={network:r},h=u.value(()=>{const t=n.from(a.decode(e.address));return{version:t.readUInt8(0),hash:t.slice(1)}}),l=u.value(()=>s.decompile(e.input)),d=u.value(()=>{const t=l(),i=t[t.length-1];return{network:r,output:i===c.OP_FALSE?n.from([]):i,input:s.compile(t.slice(0,-1)),witness:e.witness||[]}});if(u.prop(p,"address",()=>{if(!p.hash)return;const e=n.allocUnsafe(21);return e.writeUInt8(p.network.scriptHash,0),p.hash.copy(e,1),a.encode(e)}),u.prop(p,"hash",()=>e.output?e.output.slice(2,22):e.address?h().hash:p.redeem&&p.redeem.output?i.hash160(p.redeem.output):void 0),u.prop(p,"output",()=>{if(p.hash)return s.compile([c.OP_HASH160,p.hash,c.OP_EQUAL])}),u.prop(p,"redeem",()=>{if(e.input)return d()}),u.prop(p,"input",()=>{if(e.redeem&&e.redeem.input&&e.redeem.output)return s.compile([].concat(s.decompile(e.redeem.input),e.redeem.output))}),u.prop(p,"witness",()=>p.redeem&&p.redeem.witness?p.redeem.witness:p.input?[]:void 0),u.prop(p,"name",()=>{const e=["p2sh"];return void 0!==p.redeem&&void 0!==p.redeem.name&&e.push(p.redeem.name),e.join("-")}),t.validate){let t=n.from([]);if(e.address){if(h().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==h().hash.length)throw new TypeError("Invalid address");t=h().hash}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(23!==e.output.length||e.output[0]!==c.OP_HASH160||20!==e.output[1]||e.output[22]!==c.OP_EQUAL)throw new TypeError("Output is invalid");const r=e.output.slice(2,22);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}const o=e=>{if(e.output){const r=s.decompile(e.output);if(!r||r.length<1)throw new TypeError("Redeem.output too short");if(e.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.hash160(e.output);if(t.length>0&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.input){const t=e.input.length>0,r=e.witness&&e.witness.length>0;if(!t&&!r)throw new TypeError("Empty input");if(t&&r)throw new TypeError("Input and witness provided");if(t){const t=s.decompile(e.input);if(!s.isPushOnly(t))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const e=l();if(!e||e.length<1)throw new TypeError("Input too short");if(!n.isBuffer(d().output))throw new TypeError("Input is invalid");o(d())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const t=d();if(e.redeem.output&&!e.redeem.output.equals(t.output))throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&!e.redeem.input.equals(t.input))throw new TypeError("Redeem.input mismatch")}o(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!(0,f.stacksEqual)(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(p,e)}},58892:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.taggedHash=t.TAGGED_HASH_PREFIXES=t.TAGS=t.hash256=t.hash160=t.sha256=t.sha1=t.ripemd160=void 0;const i=r(74290),o=r(93553),s=r(7811);function f(e){return n.from((0,s.sha256)(Uint8Array.from(e)))}t.ripemd160=function(e){return n.from((0,i.ripemd160)(Uint8Array.from(e)))},t.sha1=function(e){return n.from((0,o.sha1)(Uint8Array.from(e)))},t.sha256=f,t.hash160=function(e){return n.from((0,i.ripemd160)((0,s.sha256)(Uint8Array.from(e))))},t.hash256=function(e){return n.from((0,s.sha256)((0,s.sha256)(Uint8Array.from(e))))},t.TAGS=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],t.TAGGED_HASH_PREFIXES={"BIP0340/challenge":n.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":n.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":n.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:n.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:n.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:n.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:n.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":n.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":n.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},t.taggedHash=function(e,r){return f(n.concat([t.TAGGED_HASH_PREFIXES[e],r]))}},60709:(e,t,r)=>{var{sha256:n}=r(7811),i=r(73088);e.exports=i(function(e){return n(n(e))})},62329:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.Transaction=void 0;const i=r(85666),o=r(58892),s=r(94778),f=r(94778),u=r(92992),{typeforce:a}=u;function c(e){const t=e.length;return i.varuint.encodingLength(t)+t}const p=n.allocUnsafe(0),h=[],l=n.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),d=n.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),y=n.from("ffffffffffffffff","hex"),w={script:p,valueBuffer:y};class m{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(e,t){const r=new i.BufferReader(e),n=new m;n.version=r.readInt32();const o=r.readUInt8(),s=r.readUInt8();let f=!1;o===m.ADVANCED_TRANSACTION_MARKER&&s===m.ADVANCED_TRANSACTION_FLAG?f=!0:r.offset-=2;const u=r.readVarInt();for(let e=0;e<u;++e)n.ins.push({hash:r.readSlice(32),index:r.readUInt32(),script:r.readVarSlice(),sequence:r.readUInt32(),witness:h});const a=r.readVarInt();for(let e=0;e<a;++e)n.outs.push({value:r.readUInt64(),script:r.readVarSlice()});if(f){for(let e=0;e<u;++e)n.ins[e].witness=r.readVector();if(!n.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(n.locktime=r.readUInt32(),t)return n;if(r.offset!==e.length)throw new Error("Transaction has unexpected data");return n}static fromHex(e){return m.fromBuffer(n.from(e,"hex"),!1)}static isCoinbaseHash(e){a(u.Hash256bit,e);for(let t=0;t<32;++t)if(0!==e[t])return!1;return!0}isCoinbase(){return 1===this.ins.length&&m.isCoinbaseHash(this.ins[0].hash)}addInput(e,t,r,n){return a(u.tuple(u.Hash256bit,u.UInt32,u.maybe(u.UInt32),u.maybe(u.Buffer)),arguments),u.Null(r)&&(r=m.DEFAULT_SEQUENCE),this.ins.push({hash:e,index:t,script:n||p,sequence:r,witness:h})-1}addOutput(e,t){return a(u.tuple(u.Buffer,u.Satoshi),arguments),this.outs.push({script:e,value:t})-1}hasWitnesses(){return this.ins.some(e=>0!==e.witness.length)}stripWitnesses(){this.ins.forEach(e=>{e.witness=h})}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(e=!0){const t=e&&this.hasWitnesses();return(t?10:8)+i.varuint.encodingLength(this.ins.length)+i.varuint.encodingLength(this.outs.length)+this.ins.reduce((e,t)=>e+40+c(t.script),0)+this.outs.reduce((e,t)=>e+8+c(t.script),0)+(t?this.ins.reduce((e,t)=>e+function(e){const t=e.length;return i.varuint.encodingLength(t)+e.reduce((e,t)=>e+c(t),0)}(t.witness),0):0)}clone(){const e=new m;return e.version=this.version,e.locktime=this.locktime,e.ins=this.ins.map(e=>({hash:e.hash,index:e.index,script:e.script,sequence:e.sequence,witness:e.witness})),e.outs=this.outs.map(e=>({script:e.script,value:e.value})),e}hashForSignature(e,t,r){if(a(u.tuple(u.UInt32,u.Buffer,u.Number),arguments),e>=this.ins.length)return d;const i=s.compile(s.decompile(t).filter(e=>e!==f.OPS.OP_CODESEPARATOR)),c=this.clone();if((31&r)===m.SIGHASH_NONE)c.outs=[],c.ins.forEach((t,r)=>{r!==e&&(t.sequence=0)});else if((31&r)===m.SIGHASH_SINGLE){if(e>=this.outs.length)return d;c.outs.length=e+1;for(let t=0;t<e;t++)c.outs[t]=w;c.ins.forEach((t,r)=>{r!==e&&(t.sequence=0)})}r&m.SIGHASH_ANYONECANPAY?(c.ins=[c.ins[e]],c.ins[0].script=i):(c.ins.forEach(e=>{e.script=p}),c.ins[e].script=i);const h=n.allocUnsafe(c.byteLength(!1)+4);return h.writeInt32LE(r,h.length-4),c.__toBuffer(h,0,!1),o.hash256(h)}hashForWitnessV1(e,t,r,s,f,h){if(a(u.tuple(u.UInt32,a.arrayOf(u.Buffer),a.arrayOf(u.Satoshi),u.UInt32),arguments),r.length!==this.ins.length||t.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const l=s===m.SIGHASH_DEFAULT?m.SIGHASH_ALL:s&m.SIGHASH_OUTPUT_MASK,d=(s&m.SIGHASH_INPUT_MASK)===m.SIGHASH_ANYONECANPAY,y=l===m.SIGHASH_NONE,w=l===m.SIGHASH_SINGLE;let b=p,g=p,E=p,O=p,P=p;if(!d){let e=i.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach(t=>{e.writeSlice(t.hash),e.writeUInt32(t.index)}),b=o.sha256(e.end()),e=i.BufferWriter.withCapacity(8*this.ins.length),r.forEach(t=>e.writeUInt64(t)),g=o.sha256(e.end()),e=i.BufferWriter.withCapacity(t.map(c).reduce((e,t)=>e+t)),t.forEach(t=>e.writeVarSlice(t)),E=o.sha256(e.end()),e=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach(t=>e.writeUInt32(t.sequence)),O=o.sha256(e.end())}if(y||w){if(w&&e<this.outs.length){const t=this.outs[e],r=i.BufferWriter.withCapacity(8+c(t.script));r.writeUInt64(t.value),r.writeVarSlice(t.script),P=o.sha256(r.end())}}else{const e=this.outs.map(e=>8+c(e.script)).reduce((e,t)=>e+t),t=i.BufferWriter.withCapacity(e);this.outs.forEach(e=>{t.writeUInt64(e.value),t.writeVarSlice(e.script)}),P=o.sha256(t.end())}const S=(f?2:0)+(h?1:0),v=174-(d?49:0)-(y?32:0)+(h?32:0)+(f?37:0),_=i.BufferWriter.withCapacity(v);if(_.writeUInt8(s),_.writeInt32(this.version),_.writeUInt32(this.locktime),_.writeSlice(b),_.writeSlice(g),_.writeSlice(E),_.writeSlice(O),y||w||_.writeSlice(P),_.writeUInt8(S),d){const n=this.ins[e];_.writeSlice(n.hash),_.writeUInt32(n.index),_.writeUInt64(r[e]),_.writeVarSlice(t[e]),_.writeUInt32(n.sequence)}else _.writeUInt32(e);if(h){const e=i.BufferWriter.withCapacity(c(h));e.writeVarSlice(h),_.writeSlice(o.sha256(e.end()))}return w&&_.writeSlice(P),f&&(_.writeSlice(f),_.writeUInt8(0),_.writeUInt32(4294967295)),o.taggedHash("TapSighash",n.concat([n.from([0]),_.end()]))}hashForWitnessV0(e,t,r,s){a(u.tuple(u.UInt32,u.Buffer,u.Satoshi,u.UInt32),arguments);let f,p=n.from([]),h=l,d=l,y=l;if(s&m.SIGHASH_ANYONECANPAY||(p=n.allocUnsafe(36*this.ins.length),f=new i.BufferWriter(p,0),this.ins.forEach(e=>{f.writeSlice(e.hash),f.writeUInt32(e.index)}),d=o.hash256(p)),s&m.SIGHASH_ANYONECANPAY||(31&s)===m.SIGHASH_SINGLE||(31&s)===m.SIGHASH_NONE||(p=n.allocUnsafe(4*this.ins.length),f=new i.BufferWriter(p,0),this.ins.forEach(e=>{f.writeUInt32(e.sequence)}),y=o.hash256(p)),(31&s)!==m.SIGHASH_SINGLE&&(31&s)!==m.SIGHASH_NONE){const e=this.outs.reduce((e,t)=>e+8+c(t.script),0);p=n.allocUnsafe(e),f=new i.BufferWriter(p,0),this.outs.forEach(e=>{f.writeUInt64(e.value),f.writeVarSlice(e.script)}),h=o.hash256(p)}else if((31&s)===m.SIGHASH_SINGLE&&e<this.outs.length){const t=this.outs[e];p=n.allocUnsafe(8+c(t.script)),f=new i.BufferWriter(p,0),f.writeUInt64(t.value),f.writeVarSlice(t.script),h=o.hash256(p)}p=n.allocUnsafe(156+c(t)),f=new i.BufferWriter(p,0);const w=this.ins[e];return f.writeInt32(this.version),f.writeSlice(d),f.writeSlice(y),f.writeSlice(w.hash),f.writeUInt32(w.index),f.writeVarSlice(t),f.writeUInt64(r),f.writeUInt32(w.sequence),f.writeSlice(h),f.writeUInt32(this.locktime),f.writeUInt32(s),o.hash256(p)}getHash(e){return e&&this.isCoinbase()?n.alloc(32,0):o.hash256(this.__toBuffer(void 0,void 0,e))}getId(){return(0,i.reverseBuffer)(this.getHash(!1)).toString("hex")}toBuffer(e,t){return this.__toBuffer(e,t,!0)}toHex(){return this.toBuffer(void 0,void 0).toString("hex")}setInputScript(e,t){a(u.tuple(u.Number,u.Buffer),arguments),this.ins[e].script=t}setWitness(e,t){a(u.tuple(u.Number,[u.Buffer]),arguments),this.ins[e].witness=t}__toBuffer(e,t,r=!1){e||(e=n.allocUnsafe(this.byteLength(r)));const o=new i.BufferWriter(e,t||0);o.writeInt32(this.version);const s=r&&this.hasWitnesses();return s&&(o.writeUInt8(m.ADVANCED_TRANSACTION_MARKER),o.writeUInt8(m.ADVANCED_TRANSACTION_FLAG)),o.writeVarInt(this.ins.length),this.ins.forEach(e=>{o.writeSlice(e.hash),o.writeUInt32(e.index),o.writeVarSlice(e.script),o.writeUInt32(e.sequence)}),o.writeVarInt(this.outs.length),this.outs.forEach(e=>{void 0!==e.value?o.writeUInt64(e.value):o.writeSlice(e.valueBuffer),o.writeVarSlice(e.script)}),s&&this.ins.forEach(e=>{o.writeVector(e.witness)}),o.writeUInt32(this.locktime),void 0!==t?e.slice(t,o.offset):e}}t.Transaction=m,m.DEFAULT_SEQUENCE=4294967295,m.SIGHASH_DEFAULT=0,m.SIGHASH_ALL=1,m.SIGHASH_NONE=2,m.SIGHASH_SINGLE=3,m.SIGHASH_ANYONECANPAY=128,m.SIGHASH_OUTPUT_MASK=3,m.SIGHASH_INPUT_MASK=128,m.ADVANCED_TRANSACTION_MARKER=0,m.ADVANCED_TRANSACTION_FLAG=1},63929:(e,t,r)=>{var n=r(31817).Buffer;function i(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function o(e){return i(e),e<253?1:e<=65535?3:e<=4294967295?5:9}e.exports={encode:function e(t,r,s){if(i(t),r||(r=n.allocUnsafe(o(t))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return s||(s=0),t<253?(r.writeUInt8(t,s),e.bytes=1):t<=65535?(r.writeUInt8(253,s),r.writeUInt16LE(t,s+1),e.bytes=3):t<=4294967295?(r.writeUInt8(254,s),r.writeUInt32LE(t,s+1),e.bytes=5):(r.writeUInt8(255,s),r.writeUInt32LE(t>>>0,s+1),r.writeUInt32LE(t/4294967296|0,s+5),e.bytes=9),r},decode:function e(t,r){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var o=t.readUInt8(r);if(o<253)return e.bytes=1,o;if(253===o)return e.bytes=3,t.readUInt16LE(r+1);if(254===o)return e.bytes=5,t.readUInt32LE(r+1);e.bytes=9;var s=t.readUInt32LE(r+1),f=4294967296*t.readUInt32LE(r+5)+s;return i(f),f},encodingLength:o}},70393:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.p2tr=t.p2wsh=t.p2wpkh=t.p2sh=t.p2pkh=t.p2pk=t.p2ms=t.embed=void 0;const n=r(204);Object.defineProperty(t,"embed",{enumerable:!0,get:function(){return n.p2data}});const i=r(85391);Object.defineProperty(t,"p2ms",{enumerable:!0,get:function(){return i.p2ms}});const o=r(72854);Object.defineProperty(t,"p2pk",{enumerable:!0,get:function(){return o.p2pk}});const s=r(26236);Object.defineProperty(t,"p2pkh",{enumerable:!0,get:function(){return s.p2pkh}});const f=r(57828);Object.defineProperty(t,"p2sh",{enumerable:!0,get:function(){return f.p2sh}});const u=r(87135);Object.defineProperty(t,"p2wpkh",{enumerable:!0,get:function(){return u.p2wpkh}});const a=r(76693);Object.defineProperty(t,"p2wsh",{enumerable:!0,get:function(){return a.p2wsh}});const c=r(43881);Object.defineProperty(t,"p2tr",{enumerable:!0,get:function(){return c.p2tr}})},72854:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.p2pk=void 0;const n=r(1834),i=r(94778),o=r(92992),s=r(96887),f=i.OPS;t.p2pk=function(e,t){if(!(e.input||e.output||e.pubkey||e.input||e.signature))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),pubkey:o.typeforce.maybe(o.isPoint),signature:o.typeforce.maybe(i.isCanonicalScriptSignature),input:o.typeforce.maybe(o.typeforce.Buffer)},e);const r=s.value(()=>i.decompile(e.input)),u={name:"p2pk",network:e.network||n.bitcoin};if(s.prop(u,"output",()=>{if(e.pubkey)return i.compile([e.pubkey,f.OP_CHECKSIG])}),s.prop(u,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),s.prop(u,"signature",()=>{if(e.input)return r()[0]}),s.prop(u,"input",()=>{if(e.signature)return i.compile([e.signature])}),s.prop(u,"witness",()=>{if(u.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==f.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,o.isPoint)(u.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(u.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(u.input))throw new TypeError("Signature mismatch");if(e.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!i.isCanonicalScriptSignature(u.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(u,e)}},73088:(e,t,r)=>{var n=r(11643);e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=Uint8Array.from(t),i=e(r),o=r.length+4,s=new Uint8Array(o);return s.set(r,0),s.set(i.subarray(0,4),r.length),n.encode(s,o)},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},76693:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2wsh=void 0;const i=r(58892),o=r(1834),s=r(94778),f=r(92992),u=r(96887),a=r(39771),c=s.OPS,p=n.alloc(0);function h(e){return!(!n.isBuffer(e)||65!==e.length||4!==e[0]||!(0,f.isPoint)(e))}t.p2wsh=function(e,t){if(!(e.address||e.hash||e.output||e.redeem||e.witness))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,f.typeforce)({network:f.typeforce.maybe(f.typeforce.Object),address:f.typeforce.maybe(f.typeforce.String),hash:f.typeforce.maybe(f.typeforce.BufferN(32)),output:f.typeforce.maybe(f.typeforce.BufferN(34)),redeem:f.typeforce.maybe({input:f.typeforce.maybe(f.typeforce.Buffer),network:f.typeforce.maybe(f.typeforce.Object),output:f.typeforce.maybe(f.typeforce.Buffer),witness:f.typeforce.maybe(f.typeforce.arrayOf(f.typeforce.Buffer))}),input:f.typeforce.maybe(f.typeforce.BufferN(0)),witness:f.typeforce.maybe(f.typeforce.arrayOf(f.typeforce.Buffer))},e);const r=u.value(()=>{const t=a.bech32.decode(e.address),r=t.words.shift(),i=a.bech32.fromWords(t.words);return{version:r,prefix:t.prefix,data:n.from(i)}}),l=u.value(()=>s.decompile(e.redeem.input));let d=e.network;d||(d=e.redeem&&e.redeem.network||o.bitcoin);const y={network:d};if(u.prop(y,"address",()=>{if(!y.hash)return;const e=a.bech32.toWords(y.hash);return e.unshift(0),a.bech32.encode(d.bech32,e)}),u.prop(y,"hash",()=>e.output?e.output.slice(2):e.address?r().data:y.redeem&&y.redeem.output?i.sha256(y.redeem.output):void 0),u.prop(y,"output",()=>{if(y.hash)return s.compile([c.OP_0,y.hash])}),u.prop(y,"redeem",()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:p,witness:e.witness.slice(0,-1)}}),u.prop(y,"input",()=>{if(y.witness)return p}),u.prop(y,"witness",()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const t=s.toStack(l());return y.redeem=Object.assign({witness:t},e.redeem),y.redeem.input=p,[].concat(t,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)}),u.prop(y,"name",()=>{const e=["p2wsh"];return void 0!==y.redeem&&void 0!==y.redeem.name&&e.push(y.redeem.name),e.join("-")}),t.validate){let t=n.from([]);if(e.address){if(r().prefix!==d.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");t=r().data}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(34!==e.output.length||e.output[0]!==c.OP_0||32!==e.output[1])throw new TypeError("Output is invalid");const r=e.output.slice(2);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}if(e.redeem){if(e.redeem.network&&e.redeem.network!==d)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const r=s.decompile(e.redeem.output);if(!r||r.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.sha256(e.redeem.output);if(t.length>0&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.redeem.input&&!s.isPushOnly(l()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!(0,f.stacksEqual)(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&l().some(h)||e.redeem.output&&(s.decompile(e.redeem.output)||[]).some(h))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const t=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&!e.redeem.output.equals(t))throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(h)||(s.decompile(t)||[]).some(h))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(y,e)}},77397:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.signatureBlocksAction=t.checkInputForSig=t.pubkeyInScript=t.pubkeyPositionInScript=t.witnessStackToScriptWitness=t.isP2TR=t.isP2SHScript=t.isP2WSHScript=t.isP2WPKH=t.isP2PKH=t.isP2PK=t.isP2MS=void 0;const i=r(80862),o=r(94778),s=r(62329),f=r(58892),u=r(70393);function a(e){return t=>{try{return e({output:t}),!0}catch(e){return!1}}}function c(e,t){const r=(0,f.hash160)(e),n=e.slice(1,33),i=o.decompile(t);if(null===i)throw new Error("Unknown script error");return i.findIndex(t=>"number"!=typeof t&&(t.equals(e)||t.equals(r)||t.equals(n)))}function p(e,t,r){const{hashType:n}=t(e),i=[];switch(n&s.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case s.Transaction.SIGHASH_ALL:break;case s.Transaction.SIGHASH_SINGLE:case s.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}t.isP2MS=a(u.p2ms),t.isP2PK=a(u.p2pk),t.isP2PKH=a(u.p2pkh),t.isP2WPKH=a(u.p2wpkh),t.isP2WSHScript=a(u.p2wsh),t.isP2SHScript=a(u.p2sh),t.isP2TR=a(u.p2tr),t.witnessStackToScriptWitness=function(e){let t=n.allocUnsafe(0);function r(e){const r=t.length,o=i.encodingLength(e);t=n.concat([t,n.allocUnsafe(o)]),i.encode(e,t,r)}var o;return r((o=e).length),o.forEach(function(e){r(e.length),function(e){t=n.concat([t,n.from(e)])}(e)}),t},t.pubkeyPositionInScript=c,t.pubkeyInScript=function(e,t){return-1!==c(e,t)},t.checkInputForSig=function(e,t){return function(e){let t=[];if(0===(e.partialSig||[]).length){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=function(e){const t=e.finalScriptSig&&o.decompile(e.finalScriptSig)||[],r=e.finalScriptWitness&&o.decompile(e.finalScriptWitness)||[];return t.concat(r).filter(e=>n.isBuffer(e)&&o.isCanonicalScriptSignature(e)).map(e=>({signature:e}))}(e)}else t=e.partialSig;return t.map(e=>e.signature)}(e).some(e=>p(e,o.signature.decode,t))},t.signatureBlocksAction=p},80862:(e,t,r)=>{var n=r(38891).Buffer;function i(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function o(e){return i(e),e<253?1:e<=65535?3:e<=4294967295?5:9}Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function e(t,r,s){if(i(t),r||(r=n.allocUnsafe(o(t))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return s||(s=0),t<253?(r.writeUInt8(t,s),Object.assign(e,{bytes:1})):t<=65535?(r.writeUInt8(253,s),r.writeUInt16LE(t,s+1),Object.assign(e,{bytes:3})):t<=4294967295?(r.writeUInt8(254,s),r.writeUInt32LE(t,s+1),Object.assign(e,{bytes:5})):(r.writeUInt8(255,s),r.writeUInt32LE(t>>>0,s+1),r.writeUInt32LE(t/4294967296|0,s+5),Object.assign(e,{bytes:9})),r},t.decode=function e(t,r){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);const o=t.readUInt8(r);if(o<253)return Object.assign(e,{bytes:1}),o;if(253===o)return Object.assign(e,{bytes:3}),t.readUInt16LE(r+1);if(254===o)return Object.assign(e,{bytes:5}),t.readUInt32LE(r+1);{Object.assign(e,{bytes:9});const n=t.readUInt32LE(r+1),o=4294967296*t.readUInt32LE(r+5)+n;return i(o),o}},t.encodingLength=o},84068:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.encode=t.decode=void 0,t.decode=function(e,t,r){t=t||4,r=void 0===r||r;const n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&!(127&e[n-1]||!(n<=1)&&128&e[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){const t=e.readUInt32LE(0),r=e.readUInt8(4);return 128&r?-(4294967296*(-129&r)+t):4294967296*r+t}let i=0;for(let t=0;t<n;++t)i|=e[t]<<8*t;return 128&e[n-1]?-(i&~(128<<8*(n-1))):i},t.encode=function(e){let t=Math.abs(e);const r=(i=t)>2147483647?5:i>8388607?4:i>32767?3:i>127?2:i>0?1:0;var i;const o=n.allocUnsafe(r),s=e<0;for(let e=0;e<r;++e)o.writeUInt8(255&t,e),t>>=8;return 128&o[r-1]?o.writeUInt8(s?128:0,r-1):s&&(o[r-1]|=128),o}},85391:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.p2ms=void 0;const n=r(1834),i=r(94778),o=r(92992),s=r(96887),f=i.OPS,u=f.OP_RESERVED;t.p2ms=function(e,t){if(!(e.input||e.output||e.pubkeys&&void 0!==e.m||e.signatures))throw new TypeError("Not enough data");function r(e){return i.isCanonicalScriptSignature(e)||void 0!==(t.allowIncomplete&&e===f.OP_0)}t=Object.assign({validate:!0},t||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),m:o.typeforce.maybe(o.typeforce.Number),n:o.typeforce.maybe(o.typeforce.Number),output:o.typeforce.maybe(o.typeforce.Buffer),pubkeys:o.typeforce.maybe(o.typeforce.arrayOf(o.isPoint)),signatures:o.typeforce.maybe(o.typeforce.arrayOf(r)),input:o.typeforce.maybe(o.typeforce.Buffer)},e);const a={network:e.network||n.bitcoin};let c=[],p=!1;function h(e){p||(p=!0,c=i.decompile(e),a.m=c[0]-u,a.n=c[c.length-2]-u,a.pubkeys=c.slice(1,-2))}if(s.prop(a,"output",()=>{if(e.m&&a.n&&e.pubkeys)return i.compile([].concat(u+e.m,e.pubkeys,u+a.n,f.OP_CHECKMULTISIG))}),s.prop(a,"m",()=>{if(a.output)return h(a.output),a.m}),s.prop(a,"n",()=>{if(a.pubkeys)return a.pubkeys.length}),s.prop(a,"pubkeys",()=>{if(e.output)return h(e.output),a.pubkeys}),s.prop(a,"signatures",()=>{if(e.input)return i.decompile(e.input).slice(1)}),s.prop(a,"input",()=>{if(e.signatures)return i.compile([f.OP_0].concat(e.signatures))}),s.prop(a,"witness",()=>{if(a.input)return[]}),s.prop(a,"name",()=>{if(a.m&&a.n)return`p2ms(${a.m} of ${a.n})`}),t.validate){if(e.output){if(h(e.output),!o.typeforce.Number(c[0]))throw new TypeError("Output is invalid");if(!o.typeforce.Number(c[c.length-2]))throw new TypeError("Output is invalid");if(c[c.length-1]!==f.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(a.m<=0||a.n>16||a.m>a.n||a.n!==c.length-3)throw new TypeError("Output is invalid");if(!a.pubkeys.every(e=>(0,o.isPoint)(e)))throw new TypeError("Output is invalid");if(void 0!==e.m&&e.m!==a.m)throw new TypeError("m mismatch");if(void 0!==e.n&&e.n!==a.n)throw new TypeError("n mismatch");if(e.pubkeys&&!(0,o.stacksEqual)(e.pubkeys,a.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(void 0!==e.n&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(a.n=e.pubkeys.length,a.n<a.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<a.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>a.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==f.OP_0)throw new TypeError("Input is invalid");if(0===a.signatures.length||!a.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!(0,o.stacksEqual)(e.signatures,a.signatures))throw new TypeError("Signature mismatch");if(void 0!==e.m&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(a,e)}},85666:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.BufferReader=t.BufferWriter=t.cloneBuffer=t.reverseBuffer=t.writeUInt64LE=t.readUInt64LE=t.varuint=void 0;const i=r(92992),{typeforce:o}=i,s=r(63929);function f(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}function u(e,t){const r=e.readUInt32LE(t);let n=e.readUInt32LE(t+4);return n*=4294967296,f(n+r,9007199254740991),n+r}function a(e,t,r){return f(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8}t.varuint=s,t.readUInt64LE=u,t.writeUInt64LE=a,t.reverseBuffer=function(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;n<e.length/2;n++)r=e[n],e[n]=e[t],e[t]=r,t--;return e},t.cloneBuffer=function(e){const t=n.allocUnsafe(e.length);return e.copy(t),t};class c{static withCapacity(e){return new c(n.alloc(e))}constructor(e,t=0){this.buffer=e,this.offset=t,o(i.tuple(i.Buffer,i.UInt32),[e,t])}writeUInt8(e){this.offset=this.buffer.writeUInt8(e,this.offset)}writeInt32(e){this.offset=this.buffer.writeInt32LE(e,this.offset)}writeUInt32(e){this.offset=this.buffer.writeUInt32LE(e,this.offset)}writeUInt64(e){this.offset=a(this.buffer,e,this.offset)}writeVarInt(e){s.encode(e,this.buffer,this.offset),this.offset+=s.encode.bytes}writeSlice(e){if(this.buffer.length<this.offset+e.length)throw new Error("Cannot write slice out of bounds");this.offset+=e.copy(this.buffer,this.offset)}writeVarSlice(e){this.writeVarInt(e.length),this.writeSlice(e)}writeVector(e){this.writeVarInt(e.length),e.forEach(e=>this.writeVarSlice(e))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}t.BufferWriter=c,t.BufferReader=class{constructor(e,t=0){this.buffer=e,this.offset=t,o(i.tuple(i.Buffer,i.UInt32),[e,t])}readUInt8(){const e=this.buffer.readUInt8(this.offset);return this.offset++,e}readInt32(){const e=this.buffer.readInt32LE(this.offset);return this.offset+=4,e}readUInt32(){const e=this.buffer.readUInt32LE(this.offset);return this.offset+=4,e}readUInt64(){const e=u(this.buffer,this.offset);return this.offset+=8,e}readVarInt(){const e=s.decode(this.buffer,this.offset);return this.offset+=s.decode.bytes,e}readSlice(e){if(this.buffer.length<this.offset+e)throw new Error("Cannot read slice out of bounds");const t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const e=this.readVarInt(),t=[];for(let r=0;r<e;r++)t.push(this.readVarSlice());return t}}},87135:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2wpkh=void 0;const i=r(58892),o=r(1834),s=r(94778),f=r(92992),u=r(96887),a=r(39771),c=s.OPS,p=n.alloc(0);t.p2wpkh=function(e,t){if(!(e.address||e.hash||e.output||e.pubkey||e.witness))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,f.typeforce)({address:f.typeforce.maybe(f.typeforce.String),hash:f.typeforce.maybe(f.typeforce.BufferN(20)),input:f.typeforce.maybe(f.typeforce.BufferN(0)),network:f.typeforce.maybe(f.typeforce.Object),output:f.typeforce.maybe(f.typeforce.BufferN(22)),pubkey:f.typeforce.maybe(f.isPoint),signature:f.typeforce.maybe(s.isCanonicalScriptSignature),witness:f.typeforce.maybe(f.typeforce.arrayOf(f.typeforce.Buffer))},e);const r=u.value(()=>{const t=a.bech32.decode(e.address),r=t.words.shift(),i=a.bech32.fromWords(t.words);return{version:r,prefix:t.prefix,data:n.from(i)}}),h=e.network||o.bitcoin,l={name:"p2wpkh",network:h};if(u.prop(l,"address",()=>{if(!l.hash)return;const e=a.bech32.toWords(l.hash);return e.unshift(0),a.bech32.encode(h.bech32,e)}),u.prop(l,"hash",()=>e.output?e.output.slice(2,22):e.address?r().data:e.pubkey||l.pubkey?i.hash160(e.pubkey||l.pubkey):void 0),u.prop(l,"output",()=>{if(l.hash)return s.compile([c.OP_0,l.hash])}),u.prop(l,"pubkey",()=>e.pubkey?e.pubkey:e.witness?e.witness[1]:void 0),u.prop(l,"signature",()=>{if(e.witness)return e.witness[0]}),u.prop(l,"input",()=>{if(l.witness)return p}),u.prop(l,"witness",()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]}),t.validate){let t=n.from([]);if(e.address){if(h&&h.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(20!==r().data.length)throw new TypeError("Invalid address data");t=r().data}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(22!==e.output.length||e.output[0]!==c.OP_0||20!==e.output[1])throw new TypeError("Output is invalid");if(t.length>0&&!t.equals(e.output.slice(2)))throw new TypeError("Hash mismatch");t=e.output.slice(2)}if(e.pubkey){const r=i.hash160(e.pubkey);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");if(t=r,!(0,f.isPoint)(e.pubkey)||33!==e.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(2!==e.witness.length)throw new TypeError("Witness is invalid");if(!s.isCanonicalScriptSignature(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,f.isPoint)(e.witness[1])||33!==e.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(e.signature&&!e.signature.equals(e.witness[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(e.witness[1]))throw new TypeError("Pubkey mismatch");const r=i.hash160(e.witness[1]);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch")}}return Object.assign(l,e)}},92992:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.oneOf=t.Null=t.BufferN=t.Function=t.UInt32=t.UInt8=t.tuple=t.maybe=t.Hex=t.Buffer=t.String=t.Boolean=t.Array=t.Number=t.Hash256bit=t.Hash160bit=t.Buffer256bit=t.isTaptree=t.isTapleaf=t.TAPLEAF_VERSION_MASK=t.Satoshi=t.isPoint=t.stacksEqual=t.typeforce=void 0;const n=r(38891);t.typeforce=r(1920);const i=n.Buffer.alloc(32,0),o=n.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");function s(e){return!(!e||!("output"in e)||!n.Buffer.isBuffer(e.output)||void 0!==e.version&&(e.version&t.TAPLEAF_VERSION_MASK)!==e.version)}t.stacksEqual=function(e,t){return e.length===t.length&&e.every((e,r)=>e.equals(t[r]))},t.isPoint=function(e){if(!n.Buffer.isBuffer(e))return!1;if(e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(0===r.compare(i))return!1;if(r.compare(o)>=0)return!1;if((2===t||3===t)&&33===e.length)return!0;const s=e.slice(33);return 0!==s.compare(i)&&!(s.compare(o)>=0)&&4===t&&65===e.length},t.Satoshi=function(e){return t.typeforce.UInt53(e)&&e<=21e14},t.TAPLEAF_VERSION_MASK=254,t.isTapleaf=s,t.isTaptree=function e(r){return(0,t.Array)(r)?2===r.length&&r.every(t=>e(t)):s(r)},t.Buffer256bit=t.typeforce.BufferN(32),t.Hash160bit=t.typeforce.BufferN(20),t.Hash256bit=t.typeforce.BufferN(32),t.Number=t.typeforce.Number,t.Array=t.typeforce.Array,t.Boolean=t.typeforce.Boolean,t.String=t.typeforce.String,t.Buffer=t.typeforce.Buffer,t.Hex=t.typeforce.Hex,t.maybe=t.typeforce.maybe,t.tuple=t.typeforce.tuple,t.UInt8=t.typeforce.UInt8,t.UInt32=t.typeforce.UInt32,t.Function=t.typeforce.Function,t.BufferN=t.typeforce.BufferN,t.Null=t.typeforce.Null,t.oneOf=t.typeforce.oneOf},93553:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sha1=t.SHA1=void 0;const n=r(29403);t.SHA1=n.SHA1,t.sha1=n.sha1},94778:(e,t,r)=>{var n=r(38891).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.signature=t.number=t.isCanonicalScriptSignature=t.isDefinedHashType=t.isCanonicalPubKey=t.toStack=t.fromASM=t.toASM=t.decompile=t.compile=t.countNonPushOnlyOPs=t.isPushOnly=t.OPS=void 0;const i=r(34538),o=r(45029);Object.defineProperty(t,"OPS",{enumerable:!0,get:function(){return o.OPS}});const s=r(12820),f=r(84068),u=r(38191),a=r(92992),{typeforce:c}=a,p=o.OPS.OP_RESERVED;function h(e){return a.Buffer(e)||function(e){return a.Number(e)&&(e===o.OPS.OP_0||e>=o.OPS.OP_1&&e<=o.OPS.OP_16||e===o.OPS.OP_1NEGATE)}(e)}function l(e){return a.Array(e)&&e.every(h)}function d(e){return 0===e.length?o.OPS.OP_0:1===e.length?e[0]>=1&&e[0]<=16?p+e[0]:129===e[0]?o.OPS.OP_1NEGATE:void 0:void 0}function y(e){return n.isBuffer(e)}function w(e){return n.isBuffer(e)}function m(e){if(y(e))return e;c(a.Array,e);const t=e.reduce((e,t)=>w(t)?1===t.length&&void 0!==d(t)?e+1:e+s.encodingLength(t.length)+t.length:e+1,0),r=n.allocUnsafe(t);let i=0;if(e.forEach(e=>{if(w(e)){const t=d(e);if(void 0!==t)return r.writeUInt8(t,i),void(i+=1);i+=s.encode(r,e.length,i),e.copy(r,i),i+=e.length}else r.writeUInt8(e,i),i+=1}),i!==r.length)throw new Error("Could not decode chunks");return r}function b(e){if(t=e,a.Array(t))return e;var t;c(a.Buffer,e);const r=[];let n=0;for(;n<e.length;){const t=e[n];if(t>o.OPS.OP_0&&t<=o.OPS.OP_PUSHDATA4){const t=s.decode(e,n);if(null===t)return null;if(n+=t.size,n+t.number>e.length)return null;const i=e.slice(n,n+t.number);n+=t.number;const o=d(i);void 0!==o?r.push(o):r.push(i)}else r.push(t),n+=1}return r}function g(e){const t=-129&e;return t>0&&t<4}t.isPushOnly=l,t.countNonPushOnlyOPs=function(e){return e.length-e.filter(h).length},t.compile=m,t.decompile=b,t.toASM=function(e){if(y(e)&&(e=b(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return e.map(e=>{if(w(e)){const t=d(e);if(void 0===t)return e.toString("hex");e=t}return o.REVERSE_OPS[e]}).join(" ")},t.fromASM=function(e){return c(a.String,e),m(e.split(" ").map(e=>void 0!==o.OPS[e]?o.OPS[e]:(c(a.Hex,e),n.from(e,"hex"))))},t.toStack=function(e){return e=b(e),c(l,e),e.map(e=>w(e)?e:e===o.OPS.OP_0?n.allocUnsafe(0):f.encode(e-p))},t.isCanonicalPubKey=function(e){return a.isPoint(e)},t.isDefinedHashType=g,t.isCanonicalScriptSignature=function(e){return!!n.isBuffer(e)&&!!g(e[e.length-1])&&i.check(e.slice(0,-1))},t.number=f,t.signature=u},96887:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.value=t.prop=void 0,t.prop=function(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const e=r.call(this);return this[t]=e,e},set(e){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:e,writable:!0})}})},t.value=function(e){let t;return()=>(void 0!==t||(t=e()),t)}}};
|