@arkade-os/sdk 0.4.77 → 0.4.79
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 +1 -1
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +3 -3
- package/dist/adapters/expo.d.ts +3 -3
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-DTl0WM7E.d.ts → asyncStorageTaskQueue-C5yQLJhm.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-MmJyAnu-.d.cts → asyncStorageTaskQueue-Shsih-1l.d.cts} +2 -2
- package/dist/{chunk-ACPANSOX.js → chunk-4MXW2NDN.js} +10 -515
- package/dist/chunk-4MXW2NDN.js.map +1 -0
- package/dist/{chunk-Y4YK44IM.cjs → chunk-54FXLZ3T.cjs} +10 -10
- package/dist/{chunk-Y4YK44IM.cjs.map → chunk-54FXLZ3T.cjs.map} +1 -1
- package/dist/{chunk-CJN4CUEU.cjs → chunk-DAYCCIRO.cjs} +377 -198
- package/dist/chunk-DAYCCIRO.cjs.map +1 -0
- package/dist/{chunk-LUWSY2QO.cjs → chunk-FUW3OM5X.cjs} +76 -561
- package/dist/chunk-FUW3OM5X.cjs.map +1 -0
- package/dist/{chunk-YJEWWLOQ.cjs → chunk-HAM3SHBV.cjs} +650 -548
- package/dist/chunk-HAM3SHBV.cjs.map +1 -0
- package/dist/{chunk-52OA3UIC.js → chunk-JCPVP7TJ.js} +377 -201
- package/dist/chunk-JCPVP7TJ.js.map +1 -0
- package/dist/{chunk-4LP6XOMW.cjs → chunk-LASRYLMQ.cjs} +17 -17
- package/dist/{chunk-4LP6XOMW.cjs.map → chunk-LASRYLMQ.cjs.map} +1 -1
- package/dist/{chunk-HKOFYHZP.js → chunk-QDXOTONI.js} +3 -3
- package/dist/{chunk-HKOFYHZP.js.map → chunk-QDXOTONI.js.map} +1 -1
- package/dist/{chunk-H62OOAS4.cjs → chunk-SJPPBR2V.cjs} +17 -17
- package/dist/{chunk-H62OOAS4.cjs.map → chunk-SJPPBR2V.cjs.map} +1 -1
- package/dist/{chunk-T6MGH4V4.js → chunk-SK4OZRMB.js} +4 -4
- package/dist/{chunk-T6MGH4V4.js.map → chunk-SK4OZRMB.js.map} +1 -1
- package/dist/{chunk-YKNTUOUG.js → chunk-VAFNWP3I.js} +4 -4
- package/dist/{chunk-YKNTUOUG.js.map → chunk-VAFNWP3I.js.map} +1 -1
- package/dist/{chunk-MLOZHTBN.js → chunk-YPQ37P3H.js} +210 -108
- package/dist/chunk-YPQ37P3H.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +4 -4
- package/dist/contracts/handlers/index.d.ts +4 -4
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-QPCGaD_z.d.cts → delegate-B4bKASut.d.cts} +1 -1
- package/dist/{delegate-CjcysR7s.d.ts → delegate-C9lpdrb0.d.ts} +1 -1
- package/dist/{hdWalletCapable--pMncWbC.d.ts → hdWalletCapable-CUJDKRKO.d.cts} +2 -3
- package/dist/{hdWalletCapable-Bp_p0WLj.d.cts → hdWalletCapable-DJClhYMC.d.ts} +2 -3
- package/dist/{index-Ie_ak2zY.d.ts → index-Ctul0N3Y.d.cts} +28 -6
- package/dist/{index-Ie_ak2zY.d.cts → index-Ctul0N3Y.d.ts} +28 -6
- package/dist/{index-m-EM-e8D.d.ts → index-D0qe2qVY.d.ts} +2 -2
- package/dist/{index-BMY272ns.d.cts → index-YBFmScVS.d.cts} +2 -2
- package/dist/index.cjs +304 -304
- package/dist/index.d.cts +123 -123
- package/dist/index.d.ts +123 -123
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +20 -20
- package/dist/repositories/realm/index.d.cts +3 -3
- package/dist/repositories/realm/index.d.ts +3 -3
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +19 -19
- package/dist/repositories/sqlite/index.d.cts +3 -3
- package/dist/repositories/sqlite/index.d.ts +3 -3
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-CqrlrJEt.d.ts → taskRunner-C08egG5a.d.ts} +2 -2
- package/dist/{taskRunner-BgRowCqB.d.cts → taskRunner-DB17db5n.d.cts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +4 -4
- package/dist/wallet/expo/background.d.ts +4 -4
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.d.cts +5 -5
- package/dist/wallet/expo/index.d.ts +5 -5
- package/dist/wallet/expo/index.js +5 -5
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +5 -5
- package/dist/worker/expo/index.d.ts +5 -5
- package/dist/worker/expo/index.js +5 -5
- package/package.json +6 -5
- package/dist/chunk-52OA3UIC.js.map +0 -1
- package/dist/chunk-ACPANSOX.js.map +0 -1
- package/dist/chunk-CJN4CUEU.cjs.map +0 -1
- package/dist/chunk-LUWSY2QO.cjs.map +0 -1
- package/dist/chunk-MLOZHTBN.js.map +0 -1
- package/dist/chunk-YJEWWLOQ.cjs.map +0 -1
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDAYCCIRO_cjs = require('./chunk-DAYCCIRO.cjs');
|
|
4
4
|
var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
|
|
5
5
|
var base = require('@scure/base');
|
|
6
6
|
var descriptorsScure = require('@bitcoinerlab/descriptors-scure');
|
|
7
7
|
var btcSigner = require('@scure/btc-signer');
|
|
8
|
+
var P = require('micro-packed');
|
|
8
9
|
var secp256k1_js = require('@noble/curves/secp256k1.js');
|
|
9
10
|
var utils_js = require('@noble/curves/utils.js');
|
|
10
11
|
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var P__namespace = /*#__PURE__*/_interopNamespace(P);
|
|
31
|
+
|
|
11
32
|
// src/contracts/handlers/registry.ts
|
|
12
33
|
var ContractHandlerRegistry = class {
|
|
13
34
|
handlers = /* @__PURE__ */ new Map();
|
|
@@ -76,14 +97,14 @@ var ContractHandlerRegistry = class {
|
|
|
76
97
|
var contractHandlers = new ContractHandlerRegistry();
|
|
77
98
|
exports.DefaultVtxo = void 0;
|
|
78
99
|
((DefaultVtxo2) => {
|
|
79
|
-
class Script3 extends
|
|
100
|
+
class Script3 extends chunkDAYCCIRO_cjs.VtxoScript {
|
|
80
101
|
/** Create the default virtual output script with one forfeit path and one exit path. */
|
|
81
102
|
constructor(options) {
|
|
82
103
|
const { pubKey, serverPubKey, csvTimelock } = options;
|
|
83
|
-
const forfeitScript =
|
|
104
|
+
const forfeitScript = chunkDAYCCIRO_cjs.MultisigTapscript.encode({
|
|
84
105
|
pubkeys: [pubKey, serverPubKey]
|
|
85
106
|
}).script;
|
|
86
|
-
const exitScript =
|
|
107
|
+
const exitScript = chunkDAYCCIRO_cjs.CSVMultisigTapscript.encode({
|
|
87
108
|
timelock: csvTimelock,
|
|
88
109
|
pubkeys: [pubKey]
|
|
89
110
|
}).script;
|
|
@@ -288,7 +309,7 @@ function extractPubKeyBytes(value) {
|
|
|
288
309
|
return base.hex.decode(extractPubKey(normalizeToDescriptor(value)));
|
|
289
310
|
}
|
|
290
311
|
function deserializeCsvTimelock(value) {
|
|
291
|
-
return value !== void 0 && value !== "" ?
|
|
312
|
+
return value !== void 0 && value !== "" ? chunkDAYCCIRO_cjs.sequenceToTimelock(Number(value)) : exports.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
292
313
|
}
|
|
293
314
|
var CLTV_HEIGHT_THRESHOLD = 500000000n;
|
|
294
315
|
function isCltvSatisfied(context, locktime) {
|
|
@@ -330,7 +351,7 @@ function assertVhtlcSpendableNow(contract, context) {
|
|
|
330
351
|
function isCsvSpendable(context, sequence) {
|
|
331
352
|
if (sequence === void 0) return true;
|
|
332
353
|
if (!context.vtxo) return false;
|
|
333
|
-
const timelock =
|
|
354
|
+
const timelock = chunkDAYCCIRO_cjs.sequenceToTimelock(sequence);
|
|
334
355
|
if (timelock.type === "blocks") {
|
|
335
356
|
if (context.blockHeight === void 0 || context.vtxo.status.block_height === void 0) {
|
|
336
357
|
return false;
|
|
@@ -388,21 +409,21 @@ function forfeitExitSpendablePaths(script, contract, context) {
|
|
|
388
409
|
async function detectUsedScripts(indexerProvider, scriptHexes) {
|
|
389
410
|
const used = /* @__PURE__ */ new Set();
|
|
390
411
|
const unique = [...new Set(scriptHexes)];
|
|
391
|
-
for (let offset = 0; offset < unique.length; offset +=
|
|
392
|
-
const scripts = unique.slice(offset, offset +
|
|
412
|
+
for (let offset = 0; offset < unique.length; offset += chunkDAYCCIRO_cjs.SCRIPT_QUERY_CHUNK_SIZE) {
|
|
413
|
+
const scripts = unique.slice(offset, offset + chunkDAYCCIRO_cjs.SCRIPT_QUERY_CHUNK_SIZE);
|
|
393
414
|
const remaining = new Set(scripts);
|
|
394
415
|
let pageIndex = 0;
|
|
395
416
|
let hasMore = true;
|
|
396
417
|
while (hasMore && remaining.size > 0) {
|
|
397
|
-
const { vtxos, page } = await
|
|
418
|
+
const { vtxos, page } = await chunkDAYCCIRO_cjs.getNormalizedVtxos(indexerProvider, {
|
|
398
419
|
scripts,
|
|
399
420
|
pageIndex,
|
|
400
|
-
pageSize:
|
|
421
|
+
pageSize: chunkDAYCCIRO_cjs.DEFAULT_PAGE_SIZE
|
|
401
422
|
});
|
|
402
423
|
for (const vtxo of vtxos) {
|
|
403
424
|
if (remaining.delete(vtxo.script)) used.add(vtxo.script);
|
|
404
425
|
}
|
|
405
|
-
hasMore = page ? vtxos.length ===
|
|
426
|
+
hasMore = page ? vtxos.length === chunkDAYCCIRO_cjs.DEFAULT_PAGE_SIZE : false;
|
|
406
427
|
pageIndex++;
|
|
407
428
|
}
|
|
408
429
|
}
|
|
@@ -463,7 +484,7 @@ var DefaultContractHandler = {
|
|
|
463
484
|
return {
|
|
464
485
|
pubKey: base.hex.encode(params.pubKey),
|
|
465
486
|
serverPubKey: base.hex.encode(params.serverPubKey),
|
|
466
|
-
csvTimelock:
|
|
487
|
+
csvTimelock: chunkDAYCCIRO_cjs.timelockToSequence(params.csvTimelock).toString()
|
|
467
488
|
};
|
|
468
489
|
},
|
|
469
490
|
deserializeParams(params) {
|
|
@@ -498,7 +519,7 @@ function defaultCandidatesAt(_index, descriptor, deps) {
|
|
|
498
519
|
params: {
|
|
499
520
|
pubKey: base.hex.encode(c.pubKey),
|
|
500
521
|
serverPubKey: base.hex.encode(c.serverPubKey),
|
|
501
|
-
csvTimelock:
|
|
522
|
+
csvTimelock: chunkDAYCCIRO_cjs.timelockToSequence(c.csvTimelock).toString()
|
|
502
523
|
},
|
|
503
524
|
script: c.scriptHex,
|
|
504
525
|
address: c.script.address(deps.network.hrp, c.serverPubKey).encode()
|
|
@@ -514,12 +535,12 @@ function discoverDefaultRange(entries, deps) {
|
|
|
514
535
|
}
|
|
515
536
|
exports.DelegateVtxo = void 0;
|
|
516
537
|
((DelegateVtxo2) => {
|
|
517
|
-
class Script3 extends
|
|
538
|
+
class Script3 extends chunkDAYCCIRO_cjs.VtxoScript {
|
|
518
539
|
/** Create a delegated virtual output script with forfeit, exit, and delegate paths. */
|
|
519
540
|
constructor(options) {
|
|
520
541
|
const defaultVtxo = new exports.DefaultVtxo.Script(options);
|
|
521
542
|
const { delegatePubKey, pubKey, serverPubKey } = options;
|
|
522
|
-
const delegateScript =
|
|
543
|
+
const delegateScript = chunkDAYCCIRO_cjs.MultisigTapscript.encode({
|
|
523
544
|
pubkeys: [pubKey, delegatePubKey, serverPubKey]
|
|
524
545
|
}).script;
|
|
525
546
|
super([...defaultVtxo.scripts, delegateScript]);
|
|
@@ -558,7 +579,7 @@ var DelegateContractHandler = {
|
|
|
558
579
|
pubKey: base.hex.encode(params.pubKey),
|
|
559
580
|
serverPubKey: base.hex.encode(params.serverPubKey),
|
|
560
581
|
delegatePubKey: base.hex.encode(params.delegatePubKey),
|
|
561
|
-
csvTimelock:
|
|
582
|
+
csvTimelock: chunkDAYCCIRO_cjs.timelockToSequence(params.csvTimelock).toString()
|
|
562
583
|
};
|
|
563
584
|
},
|
|
564
585
|
deserializeParams(params) {
|
|
@@ -602,7 +623,7 @@ function delegateCandidatesAt(_index, descriptor, deps) {
|
|
|
602
623
|
pubKey: base.hex.encode(c.pubKey),
|
|
603
624
|
serverPubKey: base.hex.encode(c.serverPubKey),
|
|
604
625
|
delegatePubKey: base.hex.encode(delegatePubKey),
|
|
605
|
-
csvTimelock:
|
|
626
|
+
csvTimelock: chunkDAYCCIRO_cjs.timelockToSequence(c.csvTimelock).toString()
|
|
606
627
|
},
|
|
607
628
|
script: c.scriptHex,
|
|
608
629
|
address: c.script.address(deps.network.hrp, c.serverPubKey).encode()
|
|
@@ -619,512 +640,6 @@ function discoverDelegateRange(entries, deps) {
|
|
|
619
640
|
(c, index, descriptor) => ({ ...c, ...rotatedReceiveMetadata(index, descriptor) })
|
|
620
641
|
);
|
|
621
642
|
}
|
|
622
|
-
function equalBytes(a, b) {
|
|
623
|
-
if (a.length !== b.length)
|
|
624
|
-
return false;
|
|
625
|
-
for (let i = 0; i < a.length; i++)
|
|
626
|
-
if (a[i] !== b[i])
|
|
627
|
-
return false;
|
|
628
|
-
return true;
|
|
629
|
-
}
|
|
630
|
-
function isBytes(a) {
|
|
631
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
632
|
-
}
|
|
633
|
-
var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
634
|
-
function isPlainObject(obj) {
|
|
635
|
-
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
636
|
-
}
|
|
637
|
-
function isNum(num) {
|
|
638
|
-
return Number.isSafeInteger(num);
|
|
639
|
-
}
|
|
640
|
-
var Bitset = {
|
|
641
|
-
BITS: 32,
|
|
642
|
-
FULL_MASK: -1 >>> 0,
|
|
643
|
-
// 1<<32 will overflow
|
|
644
|
-
len: (len) => Math.ceil(len / 32),
|
|
645
|
-
create: (len) => new Uint32Array(Bitset.len(len)),
|
|
646
|
-
clean: (bs) => bs.fill(0),
|
|
647
|
-
debug: (bs) => Array.from(bs).map((i) => (i >>> 0).toString(2).padStart(32, "0")),
|
|
648
|
-
checkLen: (bs, len) => {
|
|
649
|
-
if (Bitset.len(len) === bs.length)
|
|
650
|
-
return;
|
|
651
|
-
throw new Error(`wrong length=${bs.length}. Expected: ${Bitset.len(len)}`);
|
|
652
|
-
},
|
|
653
|
-
chunkLen: (bsLen, pos, len) => {
|
|
654
|
-
if (pos < 0)
|
|
655
|
-
throw new Error(`wrong pos=${pos}`);
|
|
656
|
-
if (pos + len > bsLen)
|
|
657
|
-
throw new Error(`wrong range=${pos}/${len} of ${bsLen}`);
|
|
658
|
-
},
|
|
659
|
-
set: (bs, chunk, value, allowRewrite = true) => {
|
|
660
|
-
if (!allowRewrite && (bs[chunk] & value) !== 0)
|
|
661
|
-
return false;
|
|
662
|
-
bs[chunk] |= value;
|
|
663
|
-
return true;
|
|
664
|
-
},
|
|
665
|
-
pos: (pos, i) => ({
|
|
666
|
-
chunk: Math.floor((pos + i) / 32),
|
|
667
|
-
mask: 1 << 32 - (pos + i) % 32 - 1
|
|
668
|
-
}),
|
|
669
|
-
indices: (bs, len, invert = false) => {
|
|
670
|
-
Bitset.checkLen(bs, len);
|
|
671
|
-
const { FULL_MASK, BITS } = Bitset;
|
|
672
|
-
const left = BITS - len % BITS;
|
|
673
|
-
const lastMask = left ? FULL_MASK >>> left << left : FULL_MASK;
|
|
674
|
-
const res = [];
|
|
675
|
-
for (let i = 0; i < bs.length; i++) {
|
|
676
|
-
let c = bs[i];
|
|
677
|
-
if (invert)
|
|
678
|
-
c = ~c;
|
|
679
|
-
if (i === bs.length - 1)
|
|
680
|
-
c &= lastMask;
|
|
681
|
-
if (c === 0)
|
|
682
|
-
continue;
|
|
683
|
-
for (let j = 0; j < BITS; j++) {
|
|
684
|
-
const m = 1 << BITS - j - 1;
|
|
685
|
-
if (c & m)
|
|
686
|
-
res.push(i * BITS + j);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
return res;
|
|
690
|
-
},
|
|
691
|
-
range: (arr) => {
|
|
692
|
-
const res = [];
|
|
693
|
-
let cur;
|
|
694
|
-
for (const i of arr) {
|
|
695
|
-
if (cur === void 0 || i !== cur.pos + cur.length)
|
|
696
|
-
res.push(cur = { pos: i, length: 1 });
|
|
697
|
-
else
|
|
698
|
-
cur.length += 1;
|
|
699
|
-
}
|
|
700
|
-
return res;
|
|
701
|
-
},
|
|
702
|
-
rangeDebug: (bs, len, invert = false) => `[${Bitset.range(Bitset.indices(bs, len, invert)).map((i) => `(${i.pos}/${i.length})`).join(", ")}]`,
|
|
703
|
-
setRange: (bs, bsLen, pos, len, allowRewrite = true) => {
|
|
704
|
-
Bitset.chunkLen(bsLen, pos, len);
|
|
705
|
-
const { FULL_MASK, BITS } = Bitset;
|
|
706
|
-
const first = pos % BITS ? Math.floor(pos / BITS) : void 0;
|
|
707
|
-
const lastPos = pos + len;
|
|
708
|
-
const last = lastPos % BITS ? Math.floor(lastPos / BITS) : void 0;
|
|
709
|
-
if (first !== void 0 && first === last)
|
|
710
|
-
return Bitset.set(bs, first, FULL_MASK >>> BITS - len << BITS - len - pos, allowRewrite);
|
|
711
|
-
if (first !== void 0) {
|
|
712
|
-
if (!Bitset.set(bs, first, FULL_MASK >>> pos % BITS, allowRewrite))
|
|
713
|
-
return false;
|
|
714
|
-
}
|
|
715
|
-
const start = first !== void 0 ? first + 1 : pos / BITS;
|
|
716
|
-
const end = last !== void 0 ? last : lastPos / BITS;
|
|
717
|
-
for (let i = start; i < end; i++)
|
|
718
|
-
if (!Bitset.set(bs, i, FULL_MASK, allowRewrite))
|
|
719
|
-
return false;
|
|
720
|
-
if (last !== void 0 && first !== last) {
|
|
721
|
-
if (!Bitset.set(bs, last, FULL_MASK << BITS - lastPos % BITS, allowRewrite))
|
|
722
|
-
return false;
|
|
723
|
-
}
|
|
724
|
-
return true;
|
|
725
|
-
}
|
|
726
|
-
};
|
|
727
|
-
var Path = {
|
|
728
|
-
/**
|
|
729
|
-
* Internal method for handling stack of paths (debug, errors, dynamic fields via path)
|
|
730
|
-
* This is looks ugly (callback), but allows us to force stack cleaning by construction (.pop always after function).
|
|
731
|
-
* Also, this makes impossible:
|
|
732
|
-
* - pushing field when stack is empty
|
|
733
|
-
* - pushing field inside of field (real bug)
|
|
734
|
-
* NOTE: we don't want to do '.pop' on error!
|
|
735
|
-
*/
|
|
736
|
-
pushObj: (stack, obj, objFn) => {
|
|
737
|
-
const last = { obj };
|
|
738
|
-
stack.push(last);
|
|
739
|
-
objFn((field, fieldFn) => {
|
|
740
|
-
last.field = field;
|
|
741
|
-
fieldFn();
|
|
742
|
-
last.field = void 0;
|
|
743
|
-
});
|
|
744
|
-
stack.pop();
|
|
745
|
-
},
|
|
746
|
-
path: (stack) => {
|
|
747
|
-
const res = [];
|
|
748
|
-
for (const i of stack)
|
|
749
|
-
if (i.field !== void 0)
|
|
750
|
-
res.push(i.field);
|
|
751
|
-
return res.join("/");
|
|
752
|
-
},
|
|
753
|
-
err: (name, stack, msg) => {
|
|
754
|
-
const err = new Error(`${name}(${Path.path(stack)}): ${typeof msg === "string" ? msg : msg.message}`);
|
|
755
|
-
if (msg instanceof Error && msg.stack)
|
|
756
|
-
err.stack = msg.stack;
|
|
757
|
-
return err;
|
|
758
|
-
},
|
|
759
|
-
resolve: (stack, path) => {
|
|
760
|
-
const parts = path.split("/");
|
|
761
|
-
const objPath = stack.map((i2) => i2.obj);
|
|
762
|
-
let i = 0;
|
|
763
|
-
for (; i < parts.length; i++) {
|
|
764
|
-
if (parts[i] === "..")
|
|
765
|
-
objPath.pop();
|
|
766
|
-
else
|
|
767
|
-
break;
|
|
768
|
-
}
|
|
769
|
-
let cur = objPath.pop();
|
|
770
|
-
for (; i < parts.length; i++) {
|
|
771
|
-
if (!cur || cur[parts[i]] === void 0)
|
|
772
|
-
return void 0;
|
|
773
|
-
cur = cur[parts[i]];
|
|
774
|
-
}
|
|
775
|
-
return cur;
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
var _Reader = class __Reader {
|
|
779
|
-
pos = 0;
|
|
780
|
-
data;
|
|
781
|
-
opts;
|
|
782
|
-
stack;
|
|
783
|
-
parent;
|
|
784
|
-
parentOffset;
|
|
785
|
-
bitBuf = 0;
|
|
786
|
-
bitPos = 0;
|
|
787
|
-
bs;
|
|
788
|
-
// bitset
|
|
789
|
-
view;
|
|
790
|
-
constructor(data, opts = {}, stack = [], parent = void 0, parentOffset = 0) {
|
|
791
|
-
this.data = data;
|
|
792
|
-
this.opts = opts;
|
|
793
|
-
this.stack = stack;
|
|
794
|
-
this.parent = parent;
|
|
795
|
-
this.parentOffset = parentOffset;
|
|
796
|
-
this.view = createView(data);
|
|
797
|
-
}
|
|
798
|
-
/** Internal method for pointers. */
|
|
799
|
-
_enablePointers() {
|
|
800
|
-
if (this.parent)
|
|
801
|
-
return this.parent._enablePointers();
|
|
802
|
-
if (this.bs)
|
|
803
|
-
return;
|
|
804
|
-
this.bs = Bitset.create(this.data.length);
|
|
805
|
-
Bitset.setRange(this.bs, this.data.length, 0, this.pos, this.opts.allowMultipleReads);
|
|
806
|
-
}
|
|
807
|
-
markBytesBS(pos, len) {
|
|
808
|
-
if (this.parent)
|
|
809
|
-
return this.parent.markBytesBS(this.parentOffset + pos, len);
|
|
810
|
-
if (!len)
|
|
811
|
-
return true;
|
|
812
|
-
if (!this.bs)
|
|
813
|
-
return true;
|
|
814
|
-
return Bitset.setRange(this.bs, this.data.length, pos, len, false);
|
|
815
|
-
}
|
|
816
|
-
markBytes(len) {
|
|
817
|
-
const pos = this.pos;
|
|
818
|
-
this.pos += len;
|
|
819
|
-
const res = this.markBytesBS(pos, len);
|
|
820
|
-
if (!this.opts.allowMultipleReads && !res)
|
|
821
|
-
throw this.err(`multiple read pos=${this.pos} len=${len}`);
|
|
822
|
-
return res;
|
|
823
|
-
}
|
|
824
|
-
pushObj(obj, objFn) {
|
|
825
|
-
return Path.pushObj(this.stack, obj, objFn);
|
|
826
|
-
}
|
|
827
|
-
readView(n, fn) {
|
|
828
|
-
if (!Number.isFinite(n))
|
|
829
|
-
throw this.err(`readView: wrong length=${n}`);
|
|
830
|
-
if (this.pos + n > this.data.length)
|
|
831
|
-
throw this.err("readView: Unexpected end of buffer");
|
|
832
|
-
const res = fn(this.view, this.pos);
|
|
833
|
-
this.markBytes(n);
|
|
834
|
-
return res;
|
|
835
|
-
}
|
|
836
|
-
// read bytes by absolute offset
|
|
837
|
-
absBytes(n) {
|
|
838
|
-
if (n > this.data.length)
|
|
839
|
-
throw new Error("Unexpected end of buffer");
|
|
840
|
-
return this.data.subarray(n);
|
|
841
|
-
}
|
|
842
|
-
finish() {
|
|
843
|
-
if (this.opts.allowUnreadBytes)
|
|
844
|
-
return;
|
|
845
|
-
if (this.bitPos) {
|
|
846
|
-
throw this.err(`${this.bitPos} bits left after unpack: ${base.hex.encode(this.data.slice(this.pos))}`);
|
|
847
|
-
}
|
|
848
|
-
if (this.bs && !this.parent) {
|
|
849
|
-
const notRead = Bitset.indices(this.bs, this.data.length, true);
|
|
850
|
-
if (notRead.length) {
|
|
851
|
-
const formatted = Bitset.range(notRead).map(({ pos, length }) => `(${pos}/${length})[${base.hex.encode(this.data.subarray(pos, pos + length))}]`).join(", ");
|
|
852
|
-
throw this.err(`unread byte ranges: ${formatted} (total=${this.data.length})`);
|
|
853
|
-
} else
|
|
854
|
-
return;
|
|
855
|
-
}
|
|
856
|
-
if (!this.isEnd()) {
|
|
857
|
-
throw this.err(`${this.leftBytes} bytes ${this.bitPos} bits left after unpack: ${base.hex.encode(this.data.slice(this.pos))}`);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
// User methods
|
|
861
|
-
err(msg) {
|
|
862
|
-
return Path.err("Reader", this.stack, msg);
|
|
863
|
-
}
|
|
864
|
-
offsetReader(n) {
|
|
865
|
-
if (n > this.data.length)
|
|
866
|
-
throw this.err("offsetReader: Unexpected end of buffer");
|
|
867
|
-
return new __Reader(this.absBytes(n), this.opts, this.stack, this, n);
|
|
868
|
-
}
|
|
869
|
-
bytes(n, peek = false) {
|
|
870
|
-
if (this.bitPos)
|
|
871
|
-
throw this.err("readBytes: bitPos not empty");
|
|
872
|
-
if (!Number.isFinite(n))
|
|
873
|
-
throw this.err(`readBytes: wrong length=${n}`);
|
|
874
|
-
if (this.pos + n > this.data.length)
|
|
875
|
-
throw this.err("readBytes: Unexpected end of buffer");
|
|
876
|
-
const slice = this.data.subarray(this.pos, this.pos + n);
|
|
877
|
-
if (!peek)
|
|
878
|
-
this.markBytes(n);
|
|
879
|
-
return slice;
|
|
880
|
-
}
|
|
881
|
-
byte(peek = false) {
|
|
882
|
-
if (this.bitPos)
|
|
883
|
-
throw this.err("readByte: bitPos not empty");
|
|
884
|
-
if (this.pos + 1 > this.data.length)
|
|
885
|
-
throw this.err("readBytes: Unexpected end of buffer");
|
|
886
|
-
const data = this.data[this.pos];
|
|
887
|
-
if (!peek)
|
|
888
|
-
this.markBytes(1);
|
|
889
|
-
return data;
|
|
890
|
-
}
|
|
891
|
-
get leftBytes() {
|
|
892
|
-
return this.data.length - this.pos;
|
|
893
|
-
}
|
|
894
|
-
get totalBytes() {
|
|
895
|
-
return this.data.length;
|
|
896
|
-
}
|
|
897
|
-
isEnd() {
|
|
898
|
-
return this.pos >= this.data.length && !this.bitPos;
|
|
899
|
-
}
|
|
900
|
-
// bits are read in BE mode (left to right): (0b1000_0000).readBits(1) == 1
|
|
901
|
-
bits(bits) {
|
|
902
|
-
if (bits > 32)
|
|
903
|
-
throw this.err("BitReader: cannot read more than 32 bits in single call");
|
|
904
|
-
let out = 0;
|
|
905
|
-
while (bits) {
|
|
906
|
-
if (!this.bitPos) {
|
|
907
|
-
this.bitBuf = this.byte();
|
|
908
|
-
this.bitPos = 8;
|
|
909
|
-
}
|
|
910
|
-
const take = Math.min(bits, this.bitPos);
|
|
911
|
-
this.bitPos -= take;
|
|
912
|
-
out = out << take | this.bitBuf >> this.bitPos & 2 ** take - 1;
|
|
913
|
-
this.bitBuf &= 2 ** this.bitPos - 1;
|
|
914
|
-
bits -= take;
|
|
915
|
-
}
|
|
916
|
-
return out >>> 0;
|
|
917
|
-
}
|
|
918
|
-
find(needle, pos = this.pos) {
|
|
919
|
-
if (!isBytes(needle))
|
|
920
|
-
throw this.err(`find: needle is not bytes! ${needle}`);
|
|
921
|
-
if (this.bitPos)
|
|
922
|
-
throw this.err("findByte: bitPos not empty");
|
|
923
|
-
if (!needle.length)
|
|
924
|
-
throw this.err(`find: needle is empty`);
|
|
925
|
-
for (let idx = pos; (idx = this.data.indexOf(needle[0], idx)) !== -1; idx++) {
|
|
926
|
-
if (idx === -1)
|
|
927
|
-
return;
|
|
928
|
-
const leftBytes = this.data.length - idx;
|
|
929
|
-
if (leftBytes < needle.length)
|
|
930
|
-
return;
|
|
931
|
-
if (equalBytes(needle, this.data.subarray(idx, idx + needle.length)))
|
|
932
|
-
return idx;
|
|
933
|
-
}
|
|
934
|
-
return;
|
|
935
|
-
}
|
|
936
|
-
};
|
|
937
|
-
var _Writer = class {
|
|
938
|
-
pos = 0;
|
|
939
|
-
stack;
|
|
940
|
-
// We could have a single buffer here and re-alloc it with
|
|
941
|
-
// x1.5-2 size each time it full, but it will be slower:
|
|
942
|
-
// basic/encode bench: 395ns -> 560ns
|
|
943
|
-
buffers = [];
|
|
944
|
-
ptrs = [];
|
|
945
|
-
bitBuf = 0;
|
|
946
|
-
bitPos = 0;
|
|
947
|
-
viewBuf = new Uint8Array(8);
|
|
948
|
-
view;
|
|
949
|
-
finished = false;
|
|
950
|
-
constructor(stack = []) {
|
|
951
|
-
this.stack = stack;
|
|
952
|
-
this.view = createView(this.viewBuf);
|
|
953
|
-
}
|
|
954
|
-
pushObj(obj, objFn) {
|
|
955
|
-
return Path.pushObj(this.stack, obj, objFn);
|
|
956
|
-
}
|
|
957
|
-
writeView(len, fn) {
|
|
958
|
-
if (this.finished)
|
|
959
|
-
throw this.err("buffer: finished");
|
|
960
|
-
if (!isNum(len) || len > 8)
|
|
961
|
-
throw new Error(`wrong writeView length=${len}`);
|
|
962
|
-
fn(this.view);
|
|
963
|
-
this.bytes(this.viewBuf.slice(0, len));
|
|
964
|
-
this.viewBuf.fill(0);
|
|
965
|
-
}
|
|
966
|
-
// User methods
|
|
967
|
-
err(msg) {
|
|
968
|
-
if (this.finished)
|
|
969
|
-
throw this.err("buffer: finished");
|
|
970
|
-
return Path.err("Reader", this.stack, msg);
|
|
971
|
-
}
|
|
972
|
-
bytes(b) {
|
|
973
|
-
if (this.finished)
|
|
974
|
-
throw this.err("buffer: finished");
|
|
975
|
-
if (this.bitPos)
|
|
976
|
-
throw this.err("writeBytes: ends with non-empty bit buffer");
|
|
977
|
-
this.buffers.push(b);
|
|
978
|
-
this.pos += b.length;
|
|
979
|
-
}
|
|
980
|
-
byte(b) {
|
|
981
|
-
if (this.finished)
|
|
982
|
-
throw this.err("buffer: finished");
|
|
983
|
-
if (this.bitPos)
|
|
984
|
-
throw this.err("writeByte: ends with non-empty bit buffer");
|
|
985
|
-
this.buffers.push(new Uint8Array([b]));
|
|
986
|
-
this.pos++;
|
|
987
|
-
}
|
|
988
|
-
finish(clean = true) {
|
|
989
|
-
if (this.finished)
|
|
990
|
-
throw this.err("buffer: finished");
|
|
991
|
-
if (this.bitPos)
|
|
992
|
-
throw this.err("buffer: ends with non-empty bit buffer");
|
|
993
|
-
const buffers = this.buffers.concat(this.ptrs.map((i) => i.buffer));
|
|
994
|
-
const sum = buffers.map((b) => b.length).reduce((a, b) => a + b, 0);
|
|
995
|
-
const buf = new Uint8Array(sum);
|
|
996
|
-
for (let i = 0, pad = 0; i < buffers.length; i++) {
|
|
997
|
-
const a = buffers[i];
|
|
998
|
-
buf.set(a, pad);
|
|
999
|
-
pad += a.length;
|
|
1000
|
-
}
|
|
1001
|
-
for (let pos = this.pos, i = 0; i < this.ptrs.length; i++) {
|
|
1002
|
-
const ptr = this.ptrs[i];
|
|
1003
|
-
buf.set(ptr.ptr.encode(pos), ptr.pos);
|
|
1004
|
-
pos += ptr.buffer.length;
|
|
1005
|
-
}
|
|
1006
|
-
if (clean) {
|
|
1007
|
-
this.buffers = [];
|
|
1008
|
-
for (const p of this.ptrs)
|
|
1009
|
-
p.buffer.fill(0);
|
|
1010
|
-
this.ptrs = [];
|
|
1011
|
-
this.finished = true;
|
|
1012
|
-
this.bitBuf = 0;
|
|
1013
|
-
}
|
|
1014
|
-
return buf;
|
|
1015
|
-
}
|
|
1016
|
-
bits(value, bits) {
|
|
1017
|
-
if (bits > 32)
|
|
1018
|
-
throw this.err("writeBits: cannot write more than 32 bits in single call");
|
|
1019
|
-
if (value >= 2 ** bits)
|
|
1020
|
-
throw this.err(`writeBits: value (${value}) >= 2**bits (${bits})`);
|
|
1021
|
-
while (bits) {
|
|
1022
|
-
const take = Math.min(bits, 8 - this.bitPos);
|
|
1023
|
-
this.bitBuf = this.bitBuf << take | value >> bits - take;
|
|
1024
|
-
this.bitPos += take;
|
|
1025
|
-
bits -= take;
|
|
1026
|
-
value &= 2 ** bits - 1;
|
|
1027
|
-
if (this.bitPos === 8) {
|
|
1028
|
-
this.bitPos = 0;
|
|
1029
|
-
this.buffers.push(new Uint8Array([this.bitBuf]));
|
|
1030
|
-
this.pos++;
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
};
|
|
1035
|
-
function _wrap(inner) {
|
|
1036
|
-
return {
|
|
1037
|
-
// NOTE: we cannot export validate here, since it is likely mistake.
|
|
1038
|
-
encodeStream: inner.encodeStream,
|
|
1039
|
-
decodeStream: inner.decodeStream,
|
|
1040
|
-
size: inner.size,
|
|
1041
|
-
encode: (value) => {
|
|
1042
|
-
const w = new _Writer();
|
|
1043
|
-
inner.encodeStream(w, value);
|
|
1044
|
-
return w.finish();
|
|
1045
|
-
},
|
|
1046
|
-
decode: (data, opts = {}) => {
|
|
1047
|
-
const r = new _Reader(data, opts);
|
|
1048
|
-
const res = inner.decodeStream(r);
|
|
1049
|
-
r.finish();
|
|
1050
|
-
return res;
|
|
1051
|
-
}
|
|
1052
|
-
};
|
|
1053
|
-
}
|
|
1054
|
-
function validate(inner, fn) {
|
|
1055
|
-
if (!isCoder(inner))
|
|
1056
|
-
throw new Error(`validate: invalid inner value ${inner}`);
|
|
1057
|
-
if (typeof fn !== "function")
|
|
1058
|
-
throw new Error("validate: fn should be function");
|
|
1059
|
-
return _wrap({
|
|
1060
|
-
size: inner.size,
|
|
1061
|
-
encodeStream: (w, value) => {
|
|
1062
|
-
let res;
|
|
1063
|
-
try {
|
|
1064
|
-
res = fn(value);
|
|
1065
|
-
} catch (e) {
|
|
1066
|
-
throw w.err(e);
|
|
1067
|
-
}
|
|
1068
|
-
inner.encodeStream(w, res);
|
|
1069
|
-
},
|
|
1070
|
-
decodeStream: (r) => {
|
|
1071
|
-
const res = inner.decodeStream(r);
|
|
1072
|
-
try {
|
|
1073
|
-
return fn(res);
|
|
1074
|
-
} catch (e) {
|
|
1075
|
-
throw r.err(e);
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
});
|
|
1079
|
-
}
|
|
1080
|
-
var wrap = (inner) => {
|
|
1081
|
-
const res = _wrap(inner);
|
|
1082
|
-
return inner.validate ? validate(res, inner.validate) : res;
|
|
1083
|
-
};
|
|
1084
|
-
var isBaseCoder = (elm) => isPlainObject(elm) && typeof elm.decode === "function" && typeof elm.encode === "function";
|
|
1085
|
-
function isCoder(elm) {
|
|
1086
|
-
return isPlainObject(elm) && isBaseCoder(elm) && typeof elm.encodeStream === "function" && typeof elm.decodeStream === "function" && (elm.size === void 0 || isNum(elm.size));
|
|
1087
|
-
}
|
|
1088
|
-
var view = (len, opts) => wrap({
|
|
1089
|
-
size: len,
|
|
1090
|
-
encodeStream: (w, value) => w.writeView(len, (view2) => opts.write(view2, value)),
|
|
1091
|
-
decodeStream: (r) => r.readView(len, opts.read),
|
|
1092
|
-
validate: (value) => {
|
|
1093
|
-
if (typeof value !== "number")
|
|
1094
|
-
throw new Error(`viewCoder: expected number, got ${typeof value}`);
|
|
1095
|
-
if (opts.validate)
|
|
1096
|
-
opts.validate(value);
|
|
1097
|
-
return value;
|
|
1098
|
-
}
|
|
1099
|
-
});
|
|
1100
|
-
var intView = (len, signed, opts) => {
|
|
1101
|
-
const bits = len * 8;
|
|
1102
|
-
const maxVal = 2 ** bits;
|
|
1103
|
-
const validateUnsigned = (value) => {
|
|
1104
|
-
if (!isNum(value))
|
|
1105
|
-
throw new Error(`uintView: value is not safe integer: ${value}`);
|
|
1106
|
-
if (0 > value || value >= maxVal) {
|
|
1107
|
-
throw new Error(`uintView: value out of bounds. Expected 0 <= ${value} < ${maxVal}`);
|
|
1108
|
-
}
|
|
1109
|
-
};
|
|
1110
|
-
return view(len, {
|
|
1111
|
-
write: opts.write,
|
|
1112
|
-
read: opts.read,
|
|
1113
|
-
validate: validateUnsigned
|
|
1114
|
-
});
|
|
1115
|
-
};
|
|
1116
|
-
var U32LE = /* @__PURE__ */ intView(4, false, {
|
|
1117
|
-
read: (view2, pos) => view2.getUint32(pos, true),
|
|
1118
|
-
write: (view2, value) => view2.setUint32(0, value, true)
|
|
1119
|
-
});
|
|
1120
|
-
var U16LE = /* @__PURE__ */ intView(2, false, {
|
|
1121
|
-
read: (view2, pos) => view2.getUint16(pos, true),
|
|
1122
|
-
write: (view2, value) => view2.setUint16(0, value, true)
|
|
1123
|
-
});
|
|
1124
|
-
var U8 = /* @__PURE__ */ intView(1, false, {
|
|
1125
|
-
read: (view2, pos) => view2.getUint8(pos),
|
|
1126
|
-
write: (view2, value) => view2.setUint8(0, value)
|
|
1127
|
-
});
|
|
1128
643
|
var ARKADE_OP = {
|
|
1129
644
|
// Merkle Branch Verification (0xb3 — repurposed NOP4 slot)
|
|
1130
645
|
MERKLEBRANCHVERIFY: 179,
|
|
@@ -1290,7 +805,7 @@ var ArkadeOPNames = {};
|
|
|
1290
805
|
for (const [k, v] of Object.entries(ARKADE_OPS)) {
|
|
1291
806
|
if (typeof v === "number") ArkadeOPNames[v] = k;
|
|
1292
807
|
}
|
|
1293
|
-
var ArkadeScript = wrap({
|
|
808
|
+
var ArkadeScript = P__namespace.wrap({
|
|
1294
809
|
encodeStream: (w, value) => {
|
|
1295
810
|
for (let o of value) {
|
|
1296
811
|
if (typeof o === "string") {
|
|
@@ -1316,10 +831,10 @@ var ArkadeScript = wrap({
|
|
|
1316
831
|
w.byte(len);
|
|
1317
832
|
} else if (len <= 65535) {
|
|
1318
833
|
w.byte(btcSigner.OP.PUSHDATA2);
|
|
1319
|
-
w.bytes(U16LE.encode(len));
|
|
834
|
+
w.bytes(P__namespace.U16LE.encode(len));
|
|
1320
835
|
} else {
|
|
1321
836
|
w.byte(btcSigner.OP.PUSHDATA4);
|
|
1322
|
-
w.bytes(U32LE.encode(len));
|
|
837
|
+
w.bytes(P__namespace.U32LE.encode(len));
|
|
1323
838
|
}
|
|
1324
839
|
w.bytes(o);
|
|
1325
840
|
}
|
|
@@ -1331,9 +846,9 @@ var ArkadeScript = wrap({
|
|
|
1331
846
|
if (btcSigner.OP.OP_0 < cur && cur <= btcSigner.OP.PUSHDATA4) {
|
|
1332
847
|
let len;
|
|
1333
848
|
if (cur < btcSigner.OP.PUSHDATA1) len = cur;
|
|
1334
|
-
else if (cur === btcSigner.OP.PUSHDATA1) len = U8.decodeStream(r);
|
|
1335
|
-
else if (cur === btcSigner.OP.PUSHDATA2) len = U16LE.decodeStream(r);
|
|
1336
|
-
else if (cur === btcSigner.OP.PUSHDATA4) len = U32LE.decodeStream(r);
|
|
849
|
+
else if (cur === btcSigner.OP.PUSHDATA1) len = P__namespace.U8.decodeStream(r);
|
|
850
|
+
else if (cur === btcSigner.OP.PUSHDATA2) len = P__namespace.U16LE.decodeStream(r);
|
|
851
|
+
else if (cur === btcSigner.OP.PUSHDATA4) len = P__namespace.U32LE.decodeStream(r);
|
|
1337
852
|
else throw new Error("Should be not possible");
|
|
1338
853
|
out.push(r.bytes(len));
|
|
1339
854
|
} else if (cur === 0) {
|
|
@@ -1451,7 +966,7 @@ function computeArkadeScriptPublicKey(pubKey, script) {
|
|
|
1451
966
|
// src/script/vhtlc.ts
|
|
1452
967
|
exports.VHTLC = void 0;
|
|
1453
968
|
((VHTLC2) => {
|
|
1454
|
-
class BaseScript extends
|
|
969
|
+
class BaseScript extends chunkDAYCCIRO_cjs.VtxoScript {
|
|
1455
970
|
options;
|
|
1456
971
|
claimScript;
|
|
1457
972
|
refundScript;
|
|
@@ -1478,27 +993,27 @@ exports.VHTLC = void 0;
|
|
|
1478
993
|
unilateralRefundWithoutReceiverDelay
|
|
1479
994
|
} = options;
|
|
1480
995
|
const conditionScript = preimageCondition(preimageHash);
|
|
1481
|
-
const claimScript =
|
|
996
|
+
const claimScript = chunkDAYCCIRO_cjs.ConditionMultisigTapscript.encode({
|
|
1482
997
|
conditionScript,
|
|
1483
998
|
pubkeys: [receiver, server]
|
|
1484
999
|
}).script;
|
|
1485
|
-
const refundScript =
|
|
1000
|
+
const refundScript = chunkDAYCCIRO_cjs.MultisigTapscript.encode({
|
|
1486
1001
|
pubkeys: [sender, receiver, server]
|
|
1487
1002
|
}).script;
|
|
1488
|
-
const refundWithoutReceiverScript =
|
|
1003
|
+
const refundWithoutReceiverScript = chunkDAYCCIRO_cjs.CLTVMultisigTapscript.encode({
|
|
1489
1004
|
absoluteTimelock: refundLocktime,
|
|
1490
1005
|
pubkeys: [sender, server]
|
|
1491
1006
|
}).script;
|
|
1492
|
-
const unilateralClaimScript =
|
|
1007
|
+
const unilateralClaimScript = chunkDAYCCIRO_cjs.ConditionCSVMultisigTapscript.encode({
|
|
1493
1008
|
conditionScript,
|
|
1494
1009
|
timelock: unilateralClaimDelay,
|
|
1495
1010
|
pubkeys: [receiver]
|
|
1496
1011
|
}).script;
|
|
1497
|
-
const unilateralRefundScript =
|
|
1012
|
+
const unilateralRefundScript = chunkDAYCCIRO_cjs.CSVMultisigTapscript.encode({
|
|
1498
1013
|
timelock: unilateralRefundDelay,
|
|
1499
1014
|
pubkeys: [sender, receiver]
|
|
1500
1015
|
}).script;
|
|
1501
|
-
const unilateralRefundWithoutReceiverScript =
|
|
1016
|
+
const unilateralRefundWithoutReceiverScript = chunkDAYCCIRO_cjs.CSVMultisigTapscript.encode({
|
|
1502
1017
|
timelock: unilateralRefundWithoutReceiverDelay,
|
|
1503
1018
|
pubkeys: [sender]
|
|
1504
1019
|
}).script;
|
|
@@ -1518,7 +1033,7 @@ exports.VHTLC = void 0;
|
|
|
1518
1033
|
const covenants = options.nonInteractiveParameters;
|
|
1519
1034
|
if (covenants) {
|
|
1520
1035
|
arkadeScriptNic = enforcePayToMaybeAsset(covenants.receiverPkScript, options.asset);
|
|
1521
|
-
nonInteractiveClaimScript =
|
|
1036
|
+
nonInteractiveClaimScript = chunkDAYCCIRO_cjs.ConditionMultisigTapscript.encode({
|
|
1522
1037
|
conditionScript,
|
|
1523
1038
|
pubkeys: [
|
|
1524
1039
|
server,
|
|
@@ -1531,12 +1046,12 @@ exports.VHTLC = void 0;
|
|
|
1531
1046
|
covenants.emulatorPubkey,
|
|
1532
1047
|
arkadeScriptNir
|
|
1533
1048
|
);
|
|
1534
|
-
nonInteractiveRefundScript =
|
|
1049
|
+
nonInteractiveRefundScript = chunkDAYCCIRO_cjs.MultisigTapscript.encode({
|
|
1535
1050
|
pubkeys: [server, receiver, nirCosigner]
|
|
1536
1051
|
}).script;
|
|
1537
1052
|
scripts.push(nonInteractiveRefundScript);
|
|
1538
1053
|
if (covenants.legacy !== "preTimelockedRefund") {
|
|
1539
|
-
nonInteractiveRefundWithoutReceiverScript =
|
|
1054
|
+
nonInteractiveRefundWithoutReceiverScript = chunkDAYCCIRO_cjs.CLTVMultisigTapscript.encode({
|
|
1540
1055
|
absoluteTimelock: refundLocktime,
|
|
1541
1056
|
pubkeys: [server, nirCosigner]
|
|
1542
1057
|
}).script;
|
|
@@ -1850,9 +1365,9 @@ var VHTLCContractHandler = {
|
|
|
1850
1365
|
server: base.hex.encode(params.server),
|
|
1851
1366
|
hash: base.hex.encode(params.preimageHash),
|
|
1852
1367
|
refundLocktime: params.refundLocktime.toString(),
|
|
1853
|
-
claimDelay:
|
|
1854
|
-
refundDelay:
|
|
1855
|
-
refundNoReceiverDelay:
|
|
1368
|
+
claimDelay: chunkDAYCCIRO_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
|
|
1369
|
+
refundDelay: chunkDAYCCIRO_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
|
|
1370
|
+
refundNoReceiverDelay: chunkDAYCCIRO_cjs.timelockToSequence(
|
|
1856
1371
|
params.unilateralRefundWithoutReceiverDelay
|
|
1857
1372
|
).toString()
|
|
1858
1373
|
};
|
|
@@ -1864,9 +1379,9 @@ var VHTLCContractHandler = {
|
|
|
1864
1379
|
server: base.hex.decode(params.server),
|
|
1865
1380
|
preimageHash: base.hex.decode(params.hash),
|
|
1866
1381
|
refundLocktime: BigInt(params.refundLocktime),
|
|
1867
|
-
unilateralClaimDelay:
|
|
1868
|
-
unilateralRefundDelay:
|
|
1869
|
-
unilateralRefundWithoutReceiverDelay:
|
|
1382
|
+
unilateralClaimDelay: chunkDAYCCIRO_cjs.sequenceToTimelock(Number(params.claimDelay)),
|
|
1383
|
+
unilateralRefundDelay: chunkDAYCCIRO_cjs.sequenceToTimelock(Number(params.refundDelay)),
|
|
1384
|
+
unilateralRefundWithoutReceiverDelay: chunkDAYCCIRO_cjs.sequenceToTimelock(
|
|
1870
1385
|
Number(params.refundNoReceiverDelay)
|
|
1871
1386
|
)
|
|
1872
1387
|
};
|
|
@@ -2112,9 +1627,9 @@ var VHTLCV2ContractHandler = {
|
|
|
2112
1627
|
server: base.hex.encode(params.server),
|
|
2113
1628
|
hash: base.hex.encode(params.preimageHash),
|
|
2114
1629
|
refundLocktime: params.refundLocktime.toString(),
|
|
2115
|
-
claimDelay:
|
|
2116
|
-
refundDelay:
|
|
2117
|
-
refundNoReceiverDelay:
|
|
1630
|
+
claimDelay: chunkDAYCCIRO_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
|
|
1631
|
+
refundDelay: chunkDAYCCIRO_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
|
|
1632
|
+
refundNoReceiverDelay: chunkDAYCCIRO_cjs.timelockToSequence(
|
|
2118
1633
|
params.unilateralRefundWithoutReceiverDelay
|
|
2119
1634
|
).toString(),
|
|
2120
1635
|
// The on-disk keys keep their per-leaf names even though the typed
|
|
@@ -2214,9 +1729,9 @@ var VHTLCV2ContractHandler = {
|
|
|
2214
1729
|
preimageHash: base.hex.decode(params.hash),
|
|
2215
1730
|
refundLocktime: BigInt(params.refundLocktime),
|
|
2216
1731
|
...asset && { asset },
|
|
2217
|
-
unilateralClaimDelay:
|
|
2218
|
-
unilateralRefundDelay:
|
|
2219
|
-
unilateralRefundWithoutReceiverDelay:
|
|
1732
|
+
unilateralClaimDelay: chunkDAYCCIRO_cjs.sequenceToTimelock(Number(params.claimDelay)),
|
|
1733
|
+
unilateralRefundDelay: chunkDAYCCIRO_cjs.sequenceToTimelock(Number(params.refundDelay)),
|
|
1734
|
+
unilateralRefundWithoutReceiverDelay: chunkDAYCCIRO_cjs.sequenceToTimelock(
|
|
2220
1735
|
Number(params.refundNoReceiverDelay)
|
|
2221
1736
|
),
|
|
2222
1737
|
...claim && refund && {
|
|
@@ -2489,7 +2004,7 @@ var BoardingContractHandler = {
|
|
|
2489
2004
|
const coins = await deps.onchainProvider.getCoins(onchainAddress);
|
|
2490
2005
|
if (coins.length === 0) return [];
|
|
2491
2006
|
const scriptHex = base.hex.encode(script.pkScript);
|
|
2492
|
-
const boardingSeq =
|
|
2007
|
+
const boardingSeq = chunkDAYCCIRO_cjs.timelockToSequence(deps.boardingTimelock);
|
|
2493
2008
|
return [
|
|
2494
2009
|
{
|
|
2495
2010
|
type: "boarding",
|
|
@@ -2656,27 +2171,27 @@ function encodeTapscriptSegment(seg, pubkeys, args) {
|
|
|
2656
2171
|
if (seg.csv) {
|
|
2657
2172
|
const timelock = { type: seg.csv.type, value: resolveTimelockValue(seg.csv.value, args) };
|
|
2658
2173
|
if (seg.asm) {
|
|
2659
|
-
return
|
|
2174
|
+
return chunkDAYCCIRO_cjs.ConditionCSVMultisigTapscript.encode({
|
|
2660
2175
|
conditionScript: resolveAsm(seg.asm, args),
|
|
2661
2176
|
timelock,
|
|
2662
2177
|
pubkeys
|
|
2663
2178
|
});
|
|
2664
2179
|
}
|
|
2665
|
-
return
|
|
2180
|
+
return chunkDAYCCIRO_cjs.CSVMultisigTapscript.encode({ timelock, pubkeys });
|
|
2666
2181
|
}
|
|
2667
2182
|
if (seg.cltv !== void 0) {
|
|
2668
|
-
return
|
|
2183
|
+
return chunkDAYCCIRO_cjs.CLTVMultisigTapscript.encode({
|
|
2669
2184
|
absoluteTimelock: resolveTimelockValue(seg.cltv, args),
|
|
2670
2185
|
pubkeys
|
|
2671
2186
|
});
|
|
2672
2187
|
}
|
|
2673
2188
|
if (seg.asm) {
|
|
2674
|
-
return
|
|
2189
|
+
return chunkDAYCCIRO_cjs.ConditionMultisigTapscript.encode({
|
|
2675
2190
|
conditionScript: resolveAsm(seg.asm, args),
|
|
2676
2191
|
pubkeys
|
|
2677
2192
|
});
|
|
2678
2193
|
}
|
|
2679
|
-
return
|
|
2194
|
+
return chunkDAYCCIRO_cjs.MultisigTapscript.encode({ pubkeys });
|
|
2680
2195
|
}
|
|
2681
2196
|
function compileFunctions(program, args, keys) {
|
|
2682
2197
|
if (program.version !== SUPPORTED_PROGRAM_VERSION) {
|
|
@@ -2718,7 +2233,7 @@ function compileFunctions(program, args, keys) {
|
|
|
2718
2233
|
return { name: names[i], def, leafScript, arkadeScript, signerKeys: pubkeys };
|
|
2719
2234
|
});
|
|
2720
2235
|
}
|
|
2721
|
-
var ArkadeProgramScript = class extends
|
|
2236
|
+
var ArkadeProgramScript = class extends chunkDAYCCIRO_cjs.VtxoScript {
|
|
2722
2237
|
constructor(program, args, keys) {
|
|
2723
2238
|
const partial = compileFunctions(program, args, keys);
|
|
2724
2239
|
super(partial.map((p) => p.leafScript));
|
|
@@ -2946,7 +2461,7 @@ function pathsFor(script, context, opts) {
|
|
|
2946
2461
|
continue;
|
|
2947
2462
|
}
|
|
2948
2463
|
if (requiresServer) continue;
|
|
2949
|
-
const sequence = csv ? Number(
|
|
2464
|
+
const sequence = csv ? Number(chunkDAYCCIRO_cjs.timelockToSequence(csv)) : void 0;
|
|
2950
2465
|
if (opts.checkTimelocks && csv && !isCsvSpendable(context, sequence)) continue;
|
|
2951
2466
|
if (opts.checkTimelocks && cltv !== void 0 && !isCltvSatisfied(context, cltv)) {
|
|
2952
2467
|
continue;
|
|
@@ -3075,5 +2590,5 @@ exports.toASM = toASM;
|
|
|
3075
2590
|
exports.toXOnly = toXOnly;
|
|
3076
2591
|
exports.validateProgram = validateProgram;
|
|
3077
2592
|
exports.witnessRefToBytes = witnessRefToBytes;
|
|
3078
|
-
//# sourceMappingURL=chunk-
|
|
3079
|
-
//# sourceMappingURL=chunk-
|
|
2593
|
+
//# sourceMappingURL=chunk-FUW3OM5X.cjs.map
|
|
2594
|
+
//# sourceMappingURL=chunk-FUW3OM5X.cjs.map
|