@arkade-os/sdk 0.5.11 → 0.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/expo.cjs +7 -7
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +4 -4
- package/dist/{asyncStorageTaskQueue-C0irgPwJ.d.ts → asyncStorageTaskQueue-Dhbe00Ya.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-B6rFkXzW.d.cts → asyncStorageTaskQueue-Y4BlVm41.d.cts} +1 -1
- package/dist/{chunk-WIZCF5IX.cjs → chunk-6TBTL42M.cjs} +92 -5
- package/dist/chunk-6TBTL42M.cjs.map +1 -0
- package/dist/{chunk-DMYHAUTA.cjs → chunk-6WPP4UGN.cjs} +9962 -8635
- package/dist/chunk-6WPP4UGN.cjs.map +1 -0
- package/dist/{chunk-WZ2UHHQ7.cjs → chunk-6XVTGWQK.cjs} +20 -20
- package/dist/{chunk-WZ2UHHQ7.cjs.map → chunk-6XVTGWQK.cjs.map} +1 -1
- package/dist/{chunk-UPIQZRNJ.cjs → chunk-ACIQZLWL.cjs} +379 -20
- package/dist/chunk-ACIQZLWL.cjs.map +1 -0
- package/dist/{chunk-KRKREYKT.js → chunk-BA36SQY2.js} +4 -4
- package/dist/{chunk-KRKREYKT.js.map → chunk-BA36SQY2.js.map} +1 -1
- package/dist/{chunk-VJQMUKPZ.js → chunk-BP4NA7HK.js} +5 -5
- package/dist/{chunk-VJQMUKPZ.js.map → chunk-BP4NA7HK.js.map} +1 -1
- package/dist/{chunk-LKVVWCIW.js → chunk-D4QH6L54.js} +4 -4
- package/dist/{chunk-LKVVWCIW.js.map → chunk-D4QH6L54.js.map} +1 -1
- package/dist/{chunk-DPFD5KBK.js → chunk-GB67AGXG.js} +86 -6
- package/dist/chunk-GB67AGXG.js.map +1 -0
- package/dist/{chunk-5HCDXBBG.cjs → chunk-HS7TKVOZ.cjs} +30 -21
- package/dist/chunk-HS7TKVOZ.cjs.map +1 -0
- package/dist/{chunk-SS5BPVQL.js → chunk-LHLRG2BE.js} +23 -15
- package/dist/chunk-LHLRG2BE.js.map +1 -0
- package/dist/{chunk-HRFWODLP.js → chunk-QSERJPTT.js} +628 -23
- package/dist/chunk-QSERJPTT.js.map +1 -0
- package/dist/{chunk-VLO3JAP3.cjs → chunk-TD4PKK2I.cjs} +680 -68
- package/dist/chunk-TD4PKK2I.cjs.map +1 -0
- package/dist/{chunk-NC6TEEHZ.cjs → chunk-TYSUFG2K.cjs} +11 -11
- package/dist/{chunk-NC6TEEHZ.cjs.map → chunk-TYSUFG2K.cjs.map} +1 -1
- package/dist/{chunk-GEK6QBSY.cjs → chunk-WFJPLXOE.cjs} +21 -21
- package/dist/{chunk-GEK6QBSY.cjs.map → chunk-WFJPLXOE.cjs.map} +1 -1
- package/dist/{chunk-4DUTRRXF.js → chunk-X57WKONW.js} +369 -10
- package/dist/chunk-X57WKONW.js.map +1 -0
- package/dist/{chunk-W2C3KDQA.js → chunk-Y3AWLHQP.js} +9520 -8196
- package/dist/chunk-Y3AWLHQP.js.map +1 -0
- package/dist/compiler.cjs +3 -4
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.js +2 -3
- package/dist/compiler.js.map +1 -1
- package/dist/contracts/handlers/index.cjs +15 -11
- package/dist/contracts/handlers/index.d.cts +5 -5
- package/dist/contracts/handlers/index.d.ts +5 -5
- package/dist/contracts/handlers/index.js +4 -4
- package/dist/{index-Bq349_ly.d.cts → index-BQwrHcOh.d.cts} +524 -23
- package/dist/{index-D4ahI0W6.d.cts → index-BaTItxPx.d.cts} +1 -1
- package/dist/{index-Yh5y9G4E.d.ts → index-BapVvuoI.d.ts} +1 -1
- package/dist/{index-Mn2POBPj.d.ts → index-DuXylQrN.d.ts} +524 -23
- package/dist/index.cjs +403 -368
- package/dist/index.d.cts +82 -71
- package/dist/index.d.ts +82 -71
- package/dist/index.js +6 -7
- package/dist/repositories/realm/index.cjs +39 -40
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +7 -8
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +37 -38
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +7 -8
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-BYxEgwM5.d.ts → taskRunner-BxOmg-O6.d.ts} +1 -1
- package/dist/{taskRunner-Z3LnHfgs.d.cts → taskRunner-D2itCXf6.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +16 -17
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +8 -9
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +17 -18
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +2 -2
- package/dist/wallet/expo/index.d.ts +2 -2
- package/dist/wallet/expo/index.js +7 -8
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/worker/expo/index.cjs +11 -12
- package/dist/worker/expo/index.cjs.map +1 -1
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +7 -8
- package/dist/worker/expo/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4DUTRRXF.js.map +0 -1
- package/dist/chunk-5HCDXBBG.cjs.map +0 -1
- package/dist/chunk-DMYHAUTA.cjs.map +0 -1
- package/dist/chunk-DPFD5KBK.js.map +0 -1
- package/dist/chunk-HRFWODLP.js.map +0 -1
- package/dist/chunk-OMZZQTDM.cjs +0 -376
- package/dist/chunk-OMZZQTDM.cjs.map +0 -1
- package/dist/chunk-PXEFYEKL.js +0 -373
- package/dist/chunk-PXEFYEKL.js.map +0 -1
- package/dist/chunk-SS5BPVQL.js.map +0 -1
- package/dist/chunk-UPIQZRNJ.cjs.map +0 -1
- package/dist/chunk-VLO3JAP3.cjs.map +0 -1
- package/dist/chunk-W2C3KDQA.js.map +0 -1
- package/dist/chunk-WIZCF5IX.cjs.map +0 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkACIQZLWL_cjs = require('./chunk-ACIQZLWL.cjs');
|
|
4
|
+
var chunkHS7TKVOZ_cjs = require('./chunk-HS7TKVOZ.cjs');
|
|
5
|
+
var chunk6TBTL42M_cjs = require('./chunk-6TBTL42M.cjs');
|
|
6
6
|
var base = require('@scure/base');
|
|
7
7
|
var descriptorsScure = require('@bitcoinerlab/descriptors-scure');
|
|
8
8
|
var btcSigner = require('@scure/btc-signer');
|
|
9
|
+
var utils_js = require('@scure/btc-signer/utils.js');
|
|
9
10
|
|
|
10
11
|
// src/contracts/handlers/registry.ts
|
|
11
12
|
var ContractHandlerRegistry = class {
|
|
@@ -46,18 +47,22 @@ var ContractHandlerRegistry = class {
|
|
|
46
47
|
var contractHandlers = new ContractHandlerRegistry();
|
|
47
48
|
exports.DefaultVtxo = void 0;
|
|
48
49
|
((DefaultVtxo2) => {
|
|
49
|
-
class Script2 extends
|
|
50
|
-
/**
|
|
51
|
-
|
|
50
|
+
class Script2 extends chunk6TBTL42M_cjs.VtxoScript {
|
|
51
|
+
/**
|
|
52
|
+
* Create the default virtual output script with one forfeit path and one exit path.
|
|
53
|
+
* @param extraLeaves leaves after forfeit and exit, e.g. the Executor's emulator-enforced
|
|
54
|
+
* renewal leaf, which keeps the wallet's paths and adds one it never signs.
|
|
55
|
+
*/
|
|
56
|
+
constructor(options, extraLeaves = []) {
|
|
52
57
|
const { pubKey, serverPubKey, csvTimelock } = options;
|
|
53
|
-
const forfeitScript =
|
|
58
|
+
const forfeitScript = chunk6TBTL42M_cjs.MultisigTapscript.encode({
|
|
54
59
|
pubkeys: [pubKey, serverPubKey]
|
|
55
60
|
}).script;
|
|
56
|
-
const exitScript =
|
|
61
|
+
const exitScript = chunk6TBTL42M_cjs.CSVMultisigTapscript.encode({
|
|
57
62
|
timelock: csvTimelock,
|
|
58
63
|
pubkeys: [pubKey]
|
|
59
64
|
}).script;
|
|
60
|
-
super([forfeitScript, exitScript]);
|
|
65
|
+
super([forfeitScript, exitScript, ...extraLeaves]);
|
|
61
66
|
this.options = options;
|
|
62
67
|
this.forfeitScript = base.hex.encode(forfeitScript);
|
|
63
68
|
this.exitScript = base.hex.encode(exitScript);
|
|
@@ -245,7 +250,7 @@ function extractPubKeyBytes(value) {
|
|
|
245
250
|
return base.hex.decode(extractPubKey(normalizeToDescriptor(value)));
|
|
246
251
|
}
|
|
247
252
|
function deserializeCsvTimelock(value) {
|
|
248
|
-
return value !== void 0 && value !== "" ?
|
|
253
|
+
return value !== void 0 && value !== "" ? chunk6TBTL42M_cjs.sequenceToTimelock(Number(value)) : exports.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
249
254
|
}
|
|
250
255
|
var CLTV_HEIGHT_THRESHOLD = 500000000n;
|
|
251
256
|
function isCltvSatisfied(context, locktime) {
|
|
@@ -416,7 +421,7 @@ function deriveVhtlcTapscripts(script) {
|
|
|
416
421
|
function isCsvSpendable(context, sequence) {
|
|
417
422
|
if (sequence === void 0) return true;
|
|
418
423
|
if (!context.vtxo) return false;
|
|
419
|
-
const timelock =
|
|
424
|
+
const timelock = chunk6TBTL42M_cjs.sequenceToTimelock(sequence);
|
|
420
425
|
if (timelock.type === "blocks") {
|
|
421
426
|
if (context.blockHeight === void 0 || context.vtxo.status.block_height === void 0) {
|
|
422
427
|
return false;
|
|
@@ -431,6 +436,22 @@ function isCsvSpendable(context, sequence) {
|
|
|
431
436
|
return false;
|
|
432
437
|
}
|
|
433
438
|
function exitSequence(contract) {
|
|
439
|
+
if (contract.type === "executor") {
|
|
440
|
+
const { template } = contract.params;
|
|
441
|
+
if (template !== "renewal" && template !== "boarding") {
|
|
442
|
+
throw new Error(`unknown Executor template ${template}`);
|
|
443
|
+
}
|
|
444
|
+
const name = template === "boarding" ? "boardingExitDelay" : "exitDelay";
|
|
445
|
+
const raw = contract.params[name];
|
|
446
|
+
const sequence = Number(raw);
|
|
447
|
+
if (!/^[0-9]+$/.test(raw ?? "") || !Number.isSafeInteger(sequence)) {
|
|
448
|
+
throw new Error(`${name} must be a non-negative integer`);
|
|
449
|
+
}
|
|
450
|
+
if (!chunk6TBTL42M_cjs.sequenceToCanonicalTimelock(BigInt(sequence))) {
|
|
451
|
+
throw new Error(`${name} must be a canonical BIP68 sequence`);
|
|
452
|
+
}
|
|
453
|
+
return sequence;
|
|
454
|
+
}
|
|
434
455
|
return contract.params.csvTimelock ? Number(contract.params.csvTimelock) : void 0;
|
|
435
456
|
}
|
|
436
457
|
function selectForfeitOrExitPath(script, contract, context) {
|
|
@@ -474,14 +495,14 @@ function forfeitExitSpendablePaths(script, contract, context) {
|
|
|
474
495
|
async function detectUsedScripts(indexerProvider, scriptHexes) {
|
|
475
496
|
const used = /* @__PURE__ */ new Set();
|
|
476
497
|
const unique = [...new Set(scriptHexes)];
|
|
477
|
-
for (let offset = 0; offset < unique.length; offset +=
|
|
478
|
-
const scripts = unique.slice(offset, offset +
|
|
498
|
+
for (let offset = 0; offset < unique.length; offset += chunkHS7TKVOZ_cjs.SCRIPT_QUERY_CHUNK_SIZE) {
|
|
499
|
+
const scripts = unique.slice(offset, offset + chunkHS7TKVOZ_cjs.SCRIPT_QUERY_CHUNK_SIZE);
|
|
479
500
|
const remaining = new Set(scripts);
|
|
480
|
-
for await (const { vtxos } of
|
|
481
|
-
(pageIndex) =>
|
|
501
|
+
for await (const { vtxos } of chunkHS7TKVOZ_cjs.indexerPages(
|
|
502
|
+
(pageIndex) => chunkHS7TKVOZ_cjs.getNormalizedVtxos(indexerProvider, {
|
|
482
503
|
scripts,
|
|
483
504
|
pageIndex,
|
|
484
|
-
pageSize:
|
|
505
|
+
pageSize: chunkHS7TKVOZ_cjs.DEFAULT_PAGE_SIZE
|
|
485
506
|
})
|
|
486
507
|
)) {
|
|
487
508
|
for (const vtxo of vtxos) {
|
|
@@ -547,7 +568,7 @@ var DefaultContractHandler = {
|
|
|
547
568
|
return {
|
|
548
569
|
pubKey: base.hex.encode(params.pubKey),
|
|
549
570
|
serverPubKey: base.hex.encode(params.serverPubKey),
|
|
550
|
-
csvTimelock:
|
|
571
|
+
csvTimelock: chunk6TBTL42M_cjs.timelockToSequence(params.csvTimelock).toString()
|
|
551
572
|
};
|
|
552
573
|
},
|
|
553
574
|
deserializeParams(params) {
|
|
@@ -594,12 +615,12 @@ function discoverDefaultRange(entries, deps) {
|
|
|
594
615
|
}
|
|
595
616
|
exports.DelegateVtxo = void 0;
|
|
596
617
|
((DelegateVtxo2) => {
|
|
597
|
-
class Script2 extends
|
|
618
|
+
class Script2 extends chunk6TBTL42M_cjs.VtxoScript {
|
|
598
619
|
/** Create a delegated virtual output script with forfeit, exit, and delegate paths. */
|
|
599
620
|
constructor(options) {
|
|
600
621
|
const defaultVtxo = new exports.DefaultVtxo.Script(options);
|
|
601
622
|
const { delegatePubKey, pubKey, serverPubKey } = options;
|
|
602
|
-
const delegateScript =
|
|
623
|
+
const delegateScript = chunk6TBTL42M_cjs.MultisigTapscript.encode({
|
|
603
624
|
pubkeys: [pubKey, delegatePubKey, serverPubKey]
|
|
604
625
|
}).script;
|
|
605
626
|
super([...defaultVtxo.scripts, delegateScript]);
|
|
@@ -638,7 +659,7 @@ var DelegateContractHandler = {
|
|
|
638
659
|
pubKey: base.hex.encode(params.pubKey),
|
|
639
660
|
serverPubKey: base.hex.encode(params.serverPubKey),
|
|
640
661
|
delegatePubKey: base.hex.encode(params.delegatePubKey),
|
|
641
|
-
csvTimelock:
|
|
662
|
+
csvTimelock: chunk6TBTL42M_cjs.timelockToSequence(params.csvTimelock).toString()
|
|
642
663
|
};
|
|
643
664
|
},
|
|
644
665
|
deserializeParams(params) {
|
|
@@ -669,22 +690,33 @@ var DelegateContractHandler = {
|
|
|
669
690
|
discoverRange: discoverDelegateRange,
|
|
670
691
|
candidatesAt: delegateCandidatesAt
|
|
671
692
|
};
|
|
693
|
+
function delegateDiscoveryKeys(deps) {
|
|
694
|
+
const keys = /* @__PURE__ */ new Map();
|
|
695
|
+
for (const key of [
|
|
696
|
+
...deps.delegatePubKey ? [deps.delegatePubKey] : [],
|
|
697
|
+
...deps.retiredDelegatePubKeys ?? []
|
|
698
|
+
]) {
|
|
699
|
+
const id = base.hex.encode(key);
|
|
700
|
+
if (!keys.has(id)) keys.set(id, key);
|
|
701
|
+
}
|
|
702
|
+
return [...keys.values()];
|
|
703
|
+
}
|
|
672
704
|
function delegateCandidatesAt(_index, descriptor, deps) {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
(
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
705
|
+
return delegateDiscoveryKeys(deps).flatMap(
|
|
706
|
+
(delegatePubKey) => buildSignerTimelockCandidates(
|
|
707
|
+
descriptor,
|
|
708
|
+
deps,
|
|
709
|
+
(opts) => new exports.DelegateVtxo.Script({ ...opts, delegatePubKey })
|
|
710
|
+
).map((c) => ({
|
|
711
|
+
type: "delegate",
|
|
712
|
+
params: DelegateContractHandler.serializeParams({ ...c, delegatePubKey }),
|
|
713
|
+
script: c.scriptHex,
|
|
714
|
+
address: c.script.address(deps.network.hrp, c.serverPubKey).encode()
|
|
715
|
+
}))
|
|
716
|
+
);
|
|
685
717
|
}
|
|
686
718
|
function discoverDelegateRange(entries, deps) {
|
|
687
|
-
if (
|
|
719
|
+
if (delegateDiscoveryKeys(deps).length === 0) {
|
|
688
720
|
return Promise.resolve(new Map(entries.map((e) => [e.index, []])));
|
|
689
721
|
}
|
|
690
722
|
return discoverIndexerCandidates(
|
|
@@ -696,7 +728,7 @@ function discoverDelegateRange(entries, deps) {
|
|
|
696
728
|
}
|
|
697
729
|
exports.VHTLC = void 0;
|
|
698
730
|
((VHTLC2) => {
|
|
699
|
-
class BaseScript extends
|
|
731
|
+
class BaseScript extends chunk6TBTL42M_cjs.VtxoScript {
|
|
700
732
|
options;
|
|
701
733
|
claimScript;
|
|
702
734
|
refundScript;
|
|
@@ -723,27 +755,27 @@ exports.VHTLC = void 0;
|
|
|
723
755
|
unilateralRefundWithoutReceiverDelay
|
|
724
756
|
} = options;
|
|
725
757
|
const conditionScript = preimageCondition(preimageHash);
|
|
726
|
-
const claimScript =
|
|
758
|
+
const claimScript = chunk6TBTL42M_cjs.ConditionMultisigTapscript.encode({
|
|
727
759
|
conditionScript,
|
|
728
760
|
pubkeys: [receiver, server]
|
|
729
761
|
}).script;
|
|
730
|
-
const refundScript =
|
|
762
|
+
const refundScript = chunk6TBTL42M_cjs.MultisigTapscript.encode({
|
|
731
763
|
pubkeys: [sender, receiver, server]
|
|
732
764
|
}).script;
|
|
733
|
-
const refundWithoutReceiverScript =
|
|
765
|
+
const refundWithoutReceiverScript = chunk6TBTL42M_cjs.CLTVMultisigTapscript.encode({
|
|
734
766
|
absoluteTimelock: refundLocktime,
|
|
735
767
|
pubkeys: [sender, server]
|
|
736
768
|
}).script;
|
|
737
|
-
const unilateralClaimScript =
|
|
769
|
+
const unilateralClaimScript = chunk6TBTL42M_cjs.ConditionCSVMultisigTapscript.encode({
|
|
738
770
|
conditionScript,
|
|
739
771
|
timelock: unilateralClaimDelay,
|
|
740
772
|
pubkeys: [receiver]
|
|
741
773
|
}).script;
|
|
742
|
-
const unilateralRefundScript =
|
|
774
|
+
const unilateralRefundScript = chunk6TBTL42M_cjs.CSVMultisigTapscript.encode({
|
|
743
775
|
timelock: unilateralRefundDelay,
|
|
744
776
|
pubkeys: [sender, receiver]
|
|
745
777
|
}).script;
|
|
746
|
-
const unilateralRefundWithoutReceiverScript =
|
|
778
|
+
const unilateralRefundWithoutReceiverScript = chunk6TBTL42M_cjs.CSVMultisigTapscript.encode({
|
|
747
779
|
timelock: unilateralRefundWithoutReceiverDelay,
|
|
748
780
|
pubkeys: [sender]
|
|
749
781
|
}).script;
|
|
@@ -763,25 +795,25 @@ exports.VHTLC = void 0;
|
|
|
763
795
|
const covenants = options.nonInteractiveParameters;
|
|
764
796
|
if (covenants) {
|
|
765
797
|
arkadeScriptNic = enforcePayToMaybeAsset(covenants.receiverPkScript, options.asset);
|
|
766
|
-
nonInteractiveClaimScript =
|
|
798
|
+
nonInteractiveClaimScript = chunk6TBTL42M_cjs.ConditionMultisigTapscript.encode({
|
|
767
799
|
conditionScript,
|
|
768
800
|
pubkeys: [
|
|
769
801
|
server,
|
|
770
|
-
|
|
802
|
+
chunkACIQZLWL_cjs.computeArkadeScriptPublicKey(covenants.emulatorPubkey, arkadeScriptNic)
|
|
771
803
|
]
|
|
772
804
|
}).script;
|
|
773
805
|
scripts.push(nonInteractiveClaimScript);
|
|
774
806
|
arkadeScriptNir = enforcePayToMaybeAsset(covenants.senderPkScript, options.asset);
|
|
775
|
-
const nirCosigner =
|
|
807
|
+
const nirCosigner = chunkACIQZLWL_cjs.computeArkadeScriptPublicKey(
|
|
776
808
|
covenants.emulatorPubkey,
|
|
777
809
|
arkadeScriptNir
|
|
778
810
|
);
|
|
779
|
-
nonInteractiveRefundScript =
|
|
811
|
+
nonInteractiveRefundScript = chunk6TBTL42M_cjs.MultisigTapscript.encode({
|
|
780
812
|
pubkeys: [server, receiver, nirCosigner]
|
|
781
813
|
}).script;
|
|
782
814
|
scripts.push(nonInteractiveRefundScript);
|
|
783
815
|
if (covenants.legacy !== "preTimelockedRefund") {
|
|
784
|
-
nonInteractiveRefundWithoutReceiverScript =
|
|
816
|
+
nonInteractiveRefundWithoutReceiverScript = chunk6TBTL42M_cjs.CLTVMultisigTapscript.encode({
|
|
785
817
|
absoluteTimelock: refundLocktime,
|
|
786
818
|
pubkeys: [server, nirCosigner]
|
|
787
819
|
}).script;
|
|
@@ -999,7 +1031,7 @@ function enforcePayTo(destinationPkScript) {
|
|
|
999
1031
|
if (!isP2trPkScript(destinationPkScript)) {
|
|
1000
1032
|
throw new Error("invalid P2TR script");
|
|
1001
1033
|
}
|
|
1002
|
-
return
|
|
1034
|
+
return chunkACIQZLWL_cjs.ArkadeScript.encode(satClause(destinationPkScript));
|
|
1003
1035
|
}
|
|
1004
1036
|
function enforcePayToAsset(destinationPkScript, asset) {
|
|
1005
1037
|
if (!isP2trPkScript(destinationPkScript)) {
|
|
@@ -1014,7 +1046,7 @@ function enforcePayToAsset(destinationPkScript, asset) {
|
|
|
1014
1046
|
);
|
|
1015
1047
|
}
|
|
1016
1048
|
const inspectionTxid = Uint8Array.from(asset.txid).reverse();
|
|
1017
|
-
return
|
|
1049
|
+
return chunkACIQZLWL_cjs.ArkadeScript.encode([
|
|
1018
1050
|
// The output at the input's index carries at least the input's amount of the asset.
|
|
1019
1051
|
"PUSHCURRENTINPUTINDEX",
|
|
1020
1052
|
inspectionTxid,
|
|
@@ -1057,9 +1089,9 @@ var VHTLCContractHandler = {
|
|
|
1057
1089
|
server: base.hex.encode(params.server),
|
|
1058
1090
|
hash: base.hex.encode(params.preimageHash),
|
|
1059
1091
|
refundLocktime: params.refundLocktime.toString(),
|
|
1060
|
-
claimDelay:
|
|
1061
|
-
refundDelay:
|
|
1062
|
-
refundNoReceiverDelay:
|
|
1092
|
+
claimDelay: chunk6TBTL42M_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
|
|
1093
|
+
refundDelay: chunk6TBTL42M_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
|
|
1094
|
+
refundNoReceiverDelay: chunk6TBTL42M_cjs.timelockToSequence(
|
|
1063
1095
|
params.unilateralRefundWithoutReceiverDelay
|
|
1064
1096
|
).toString()
|
|
1065
1097
|
};
|
|
@@ -1071,9 +1103,9 @@ var VHTLCContractHandler = {
|
|
|
1071
1103
|
server: base.hex.decode(params.server),
|
|
1072
1104
|
preimageHash: base.hex.decode(params.hash),
|
|
1073
1105
|
refundLocktime: BigInt(params.refundLocktime),
|
|
1074
|
-
unilateralClaimDelay:
|
|
1075
|
-
unilateralRefundDelay:
|
|
1076
|
-
unilateralRefundWithoutReceiverDelay:
|
|
1106
|
+
unilateralClaimDelay: chunk6TBTL42M_cjs.sequenceToTimelock(Number(params.claimDelay)),
|
|
1107
|
+
unilateralRefundDelay: chunk6TBTL42M_cjs.sequenceToTimelock(Number(params.refundDelay)),
|
|
1108
|
+
unilateralRefundWithoutReceiverDelay: chunk6TBTL42M_cjs.sequenceToTimelock(
|
|
1077
1109
|
Number(params.refundNoReceiverDelay)
|
|
1078
1110
|
)
|
|
1079
1111
|
};
|
|
@@ -1166,9 +1198,9 @@ var VHTLCV2ContractHandler = {
|
|
|
1166
1198
|
server: base.hex.encode(params.server),
|
|
1167
1199
|
hash: base.hex.encode(params.preimageHash),
|
|
1168
1200
|
refundLocktime: params.refundLocktime.toString(),
|
|
1169
|
-
claimDelay:
|
|
1170
|
-
refundDelay:
|
|
1171
|
-
refundNoReceiverDelay:
|
|
1201
|
+
claimDelay: chunk6TBTL42M_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
|
|
1202
|
+
refundDelay: chunk6TBTL42M_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
|
|
1203
|
+
refundNoReceiverDelay: chunk6TBTL42M_cjs.timelockToSequence(
|
|
1172
1204
|
params.unilateralRefundWithoutReceiverDelay
|
|
1173
1205
|
).toString(),
|
|
1174
1206
|
// Per-leaf on-disk keys predate the grouped param and older rows carry exactly these;
|
|
@@ -1246,9 +1278,9 @@ var VHTLCV2ContractHandler = {
|
|
|
1246
1278
|
preimageHash: base.hex.decode(params.hash),
|
|
1247
1279
|
refundLocktime: BigInt(params.refundLocktime),
|
|
1248
1280
|
...asset && { asset },
|
|
1249
|
-
unilateralClaimDelay:
|
|
1250
|
-
unilateralRefundDelay:
|
|
1251
|
-
unilateralRefundWithoutReceiverDelay:
|
|
1281
|
+
unilateralClaimDelay: chunk6TBTL42M_cjs.sequenceToTimelock(Number(params.claimDelay)),
|
|
1282
|
+
unilateralRefundDelay: chunk6TBTL42M_cjs.sequenceToTimelock(Number(params.refundDelay)),
|
|
1283
|
+
unilateralRefundWithoutReceiverDelay: chunk6TBTL42M_cjs.sequenceToTimelock(
|
|
1252
1284
|
Number(params.refundNoReceiverDelay)
|
|
1253
1285
|
),
|
|
1254
1286
|
...claim && refund && {
|
|
@@ -1382,7 +1414,7 @@ function pathsFor(script, context, opts) {
|
|
|
1382
1414
|
const paths = [];
|
|
1383
1415
|
for (const fn of script.compiled) {
|
|
1384
1416
|
if (fn.arkadeScript) continue;
|
|
1385
|
-
const witness =
|
|
1417
|
+
const witness = chunkACIQZLWL_cjs.staticWitness(fn.def.tapscript.witness, script.args);
|
|
1386
1418
|
if (witness === null) continue;
|
|
1387
1419
|
const signerHexes = fn.signerKeys.map((s) => base.hex.encode(s));
|
|
1388
1420
|
const requiresServer = signerHexes.includes(serverHex);
|
|
@@ -1391,8 +1423,8 @@ function pathsFor(script, context, opts) {
|
|
|
1391
1423
|
continue;
|
|
1392
1424
|
}
|
|
1393
1425
|
const csvDef = fn.def.tapscript.csv;
|
|
1394
|
-
const csv = csvDef ?
|
|
1395
|
-
const cltv = fn.def.tapscript.cltv !== void 0 ?
|
|
1426
|
+
const csv = csvDef ? chunkACIQZLWL_cjs.resolveCsvTimelock(csvDef, script.args) : void 0;
|
|
1427
|
+
const cltv = fn.def.tapscript.cltv !== void 0 ? chunkACIQZLWL_cjs.resolveTimelockValue(fn.def.tapscript.cltv, script.args) : void 0;
|
|
1396
1428
|
if (context.collaborative) {
|
|
1397
1429
|
if (csv) continue;
|
|
1398
1430
|
if (opts.checkTimelocks && cltv !== void 0 && !isCltvSatisfied(context, cltv)) {
|
|
@@ -1405,7 +1437,7 @@ function pathsFor(script, context, opts) {
|
|
|
1405
1437
|
continue;
|
|
1406
1438
|
}
|
|
1407
1439
|
if (requiresServer) continue;
|
|
1408
|
-
const sequence = csv ? Number(
|
|
1440
|
+
const sequence = csv ? Number(chunk6TBTL42M_cjs.timelockToSequence(csv)) : void 0;
|
|
1409
1441
|
if (opts.checkTimelocks && csv && !isCsvSpendable(context, sequence)) continue;
|
|
1410
1442
|
if (opts.checkTimelocks && cltv !== void 0 && !isCltvSatisfied(context, cltv)) {
|
|
1411
1443
|
continue;
|
|
@@ -1422,17 +1454,17 @@ var ArkadeContractHandler = {
|
|
|
1422
1454
|
type: "arkade",
|
|
1423
1455
|
createScript(params) {
|
|
1424
1456
|
const typed = this.deserializeParams(params);
|
|
1425
|
-
return new
|
|
1457
|
+
return new chunkACIQZLWL_cjs.ArkadeProgramScript(typed.program, typed.args, {
|
|
1426
1458
|
serverKey: typed.serverKey,
|
|
1427
1459
|
userKey: typed.userKey,
|
|
1428
1460
|
emulatorKey: typed.emulatorKey
|
|
1429
1461
|
});
|
|
1430
1462
|
},
|
|
1431
1463
|
serializeParams(params) {
|
|
1432
|
-
return
|
|
1464
|
+
return chunkACIQZLWL_cjs.serializeArkadeContractParams(params);
|
|
1433
1465
|
},
|
|
1434
1466
|
deserializeParams(params) {
|
|
1435
|
-
return
|
|
1467
|
+
return chunkACIQZLWL_cjs.deserializeArkadeContractParams(params);
|
|
1436
1468
|
},
|
|
1437
1469
|
selectPath(script, _contract, context) {
|
|
1438
1470
|
const paths = pathsFor(script, context, { checkTimelocks: true });
|
|
@@ -1479,6 +1511,578 @@ var ArkadeContractHandler = {
|
|
|
1479
1511
|
}
|
|
1480
1512
|
};
|
|
1481
1513
|
|
|
1514
|
+
// src/script/executor/board.json
|
|
1515
|
+
var board_default = {
|
|
1516
|
+
format: "template/v1",
|
|
1517
|
+
type: "proof",
|
|
1518
|
+
variables: {
|
|
1519
|
+
owner: "pubkey",
|
|
1520
|
+
boarding_exit_delay: "int",
|
|
1521
|
+
exit_delay: "int",
|
|
1522
|
+
renewal_window: "int",
|
|
1523
|
+
max_fee: "int"
|
|
1524
|
+
},
|
|
1525
|
+
inputs: [
|
|
1526
|
+
{
|
|
1527
|
+
name: "deposit",
|
|
1528
|
+
type: "onchain",
|
|
1529
|
+
contract: {
|
|
1530
|
+
definition: {
|
|
1531
|
+
artifact: "e3c0fa053fbb529a252a1025e3453a41f01949f4e49d50de7dfe5d3510470ed3"
|
|
1532
|
+
},
|
|
1533
|
+
arguments: {
|
|
1534
|
+
owner: "<owner>",
|
|
1535
|
+
boardingExitDelay: "<boarding_exit_delay>",
|
|
1536
|
+
renewalProgram: { program: "funds" },
|
|
1537
|
+
maxFee: "<max_fee>"
|
|
1538
|
+
}
|
|
1539
|
+
},
|
|
1540
|
+
spend: { function: "board", leaf: "board" }
|
|
1541
|
+
}
|
|
1542
|
+
],
|
|
1543
|
+
outputs: [
|
|
1544
|
+
{
|
|
1545
|
+
name: "funds",
|
|
1546
|
+
value: { from: "deposit" },
|
|
1547
|
+
locking: {
|
|
1548
|
+
contract: {
|
|
1549
|
+
definition: {
|
|
1550
|
+
artifact: "faa3249b8a28e999963994e4020e832285351eb7ce3b4821bcb3b4498f5b8ef3"
|
|
1551
|
+
},
|
|
1552
|
+
arguments: {
|
|
1553
|
+
owner: "<owner>",
|
|
1554
|
+
exitDelay: "<exit_delay>",
|
|
1555
|
+
renewalWindow: "<renewal_window>",
|
|
1556
|
+
maxFee: "<max_fee>"
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
],
|
|
1562
|
+
fees: { from: "deposit", max: "<max_fee>" },
|
|
1563
|
+
delegation: { schedule: { deposit: { min_confirmations: 1 } } }
|
|
1564
|
+
};
|
|
1565
|
+
|
|
1566
|
+
// src/script/executor/delegated_boarding.json
|
|
1567
|
+
var delegated_boarding_default = {
|
|
1568
|
+
contractName: "DelegatedBoarding",
|
|
1569
|
+
constructorInputs: [
|
|
1570
|
+
{
|
|
1571
|
+
name: "owner",
|
|
1572
|
+
type: "pubkey"
|
|
1573
|
+
},
|
|
1574
|
+
{
|
|
1575
|
+
name: "boardingExitDelay",
|
|
1576
|
+
type: "int"
|
|
1577
|
+
},
|
|
1578
|
+
{
|
|
1579
|
+
name: "renewalProgram",
|
|
1580
|
+
type: "bytes32"
|
|
1581
|
+
},
|
|
1582
|
+
{
|
|
1583
|
+
name: "maxFee",
|
|
1584
|
+
type: "int"
|
|
1585
|
+
}
|
|
1586
|
+
],
|
|
1587
|
+
structs: [],
|
|
1588
|
+
functions: [
|
|
1589
|
+
{
|
|
1590
|
+
name: "forfeit",
|
|
1591
|
+
leaves: [
|
|
1592
|
+
{
|
|
1593
|
+
name: "forfeit",
|
|
1594
|
+
asm: ["<owner>", "OP_CHECKSIGVERIFY", "<SERVER_KEY>", "OP_CHECKSIG"],
|
|
1595
|
+
witness: [
|
|
1596
|
+
{
|
|
1597
|
+
name: "ownerSig",
|
|
1598
|
+
type: "signature",
|
|
1599
|
+
encoding: "schnorr-64"
|
|
1600
|
+
},
|
|
1601
|
+
{
|
|
1602
|
+
name: "serverSig",
|
|
1603
|
+
type: "signature",
|
|
1604
|
+
encoding: "schnorr-64",
|
|
1605
|
+
injected: true
|
|
1606
|
+
}
|
|
1607
|
+
]
|
|
1608
|
+
}
|
|
1609
|
+
]
|
|
1610
|
+
},
|
|
1611
|
+
{
|
|
1612
|
+
name: "exit",
|
|
1613
|
+
leaves: [
|
|
1614
|
+
{
|
|
1615
|
+
name: "exit",
|
|
1616
|
+
asm: [
|
|
1617
|
+
"<boardingExitDelay>",
|
|
1618
|
+
"OP_CHECKSEQUENCEVERIFY",
|
|
1619
|
+
"OP_DROP",
|
|
1620
|
+
"<owner>",
|
|
1621
|
+
"OP_CHECKSIG"
|
|
1622
|
+
],
|
|
1623
|
+
witness: [
|
|
1624
|
+
{
|
|
1625
|
+
name: "ownerSig",
|
|
1626
|
+
type: "signature",
|
|
1627
|
+
encoding: "schnorr-64"
|
|
1628
|
+
}
|
|
1629
|
+
]
|
|
1630
|
+
}
|
|
1631
|
+
]
|
|
1632
|
+
},
|
|
1633
|
+
{
|
|
1634
|
+
name: "board",
|
|
1635
|
+
arkade: {
|
|
1636
|
+
inputs: [],
|
|
1637
|
+
asm: [
|
|
1638
|
+
"0x74797065",
|
|
1639
|
+
"OP_INSPECTINTENTMESSAGE",
|
|
1640
|
+
"OP_VERIFY",
|
|
1641
|
+
"0x7265676973746572",
|
|
1642
|
+
"OP_EQUALVERIFY",
|
|
1643
|
+
"0x6f6e636861696e5f6f75747075745f696e6465786573",
|
|
1644
|
+
"OP_INSPECTINTENTMESSAGE",
|
|
1645
|
+
"OP_VERIFY",
|
|
1646
|
+
"0x5b5d",
|
|
1647
|
+
"OP_EQUALVERIFY",
|
|
1648
|
+
"OP_PUSHCURRENTINPUTINDEX",
|
|
1649
|
+
"OP_1SUB",
|
|
1650
|
+
"OP_INSPECTOUTPUTSCRIPTPUBKEY",
|
|
1651
|
+
"1",
|
|
1652
|
+
"OP_EQUALVERIFY",
|
|
1653
|
+
"<renewalProgram>",
|
|
1654
|
+
"OP_EQUALVERIFY",
|
|
1655
|
+
"OP_PUSHCURRENTINPUTINDEX",
|
|
1656
|
+
"OP_1SUB",
|
|
1657
|
+
"OP_INSPECTOUTPUTVALUE",
|
|
1658
|
+
"<maxFee>",
|
|
1659
|
+
"OP_ADD",
|
|
1660
|
+
"OP_PUSHCURRENTINPUTINDEX",
|
|
1661
|
+
"OP_INSPECTINPUTVALUE",
|
|
1662
|
+
"OP_GREATERTHANOREQUAL"
|
|
1663
|
+
]
|
|
1664
|
+
},
|
|
1665
|
+
leaves: [
|
|
1666
|
+
{
|
|
1667
|
+
name: "board",
|
|
1668
|
+
asm: [
|
|
1669
|
+
"<SERVER_KEY>",
|
|
1670
|
+
"OP_CHECKSIGVERIFY",
|
|
1671
|
+
"<EMULATOR_KEY:board>",
|
|
1672
|
+
"OP_CHECKSIG"
|
|
1673
|
+
],
|
|
1674
|
+
witness: [
|
|
1675
|
+
{
|
|
1676
|
+
name: "serverSig",
|
|
1677
|
+
type: "signature",
|
|
1678
|
+
encoding: "schnorr-64",
|
|
1679
|
+
injected: true
|
|
1680
|
+
},
|
|
1681
|
+
{
|
|
1682
|
+
name: "emulatorSig",
|
|
1683
|
+
type: "signature",
|
|
1684
|
+
encoding: "schnorr-64",
|
|
1685
|
+
injected: true
|
|
1686
|
+
}
|
|
1687
|
+
]
|
|
1688
|
+
}
|
|
1689
|
+
]
|
|
1690
|
+
}
|
|
1691
|
+
]
|
|
1692
|
+
};
|
|
1693
|
+
|
|
1694
|
+
// src/script/executor/delegated_vtxo.json
|
|
1695
|
+
var delegated_vtxo_default = {
|
|
1696
|
+
contractName: "DelegatedVtxo",
|
|
1697
|
+
constructorInputs: [
|
|
1698
|
+
{
|
|
1699
|
+
name: "owner",
|
|
1700
|
+
type: "pubkey"
|
|
1701
|
+
},
|
|
1702
|
+
{
|
|
1703
|
+
name: "exitDelay",
|
|
1704
|
+
type: "int"
|
|
1705
|
+
},
|
|
1706
|
+
{
|
|
1707
|
+
name: "renewalWindow",
|
|
1708
|
+
type: "int"
|
|
1709
|
+
},
|
|
1710
|
+
{
|
|
1711
|
+
name: "maxFee",
|
|
1712
|
+
type: "int"
|
|
1713
|
+
}
|
|
1714
|
+
],
|
|
1715
|
+
structs: [],
|
|
1716
|
+
functions: [
|
|
1717
|
+
{
|
|
1718
|
+
name: "forfeit",
|
|
1719
|
+
leaves: [
|
|
1720
|
+
{
|
|
1721
|
+
name: "forfeit",
|
|
1722
|
+
asm: ["<owner>", "OP_CHECKSIGVERIFY", "<SERVER_KEY>", "OP_CHECKSIG"],
|
|
1723
|
+
witness: [
|
|
1724
|
+
{
|
|
1725
|
+
name: "ownerSig",
|
|
1726
|
+
type: "signature",
|
|
1727
|
+
encoding: "schnorr-64"
|
|
1728
|
+
},
|
|
1729
|
+
{
|
|
1730
|
+
name: "serverSig",
|
|
1731
|
+
type: "signature",
|
|
1732
|
+
encoding: "schnorr-64",
|
|
1733
|
+
injected: true
|
|
1734
|
+
}
|
|
1735
|
+
]
|
|
1736
|
+
}
|
|
1737
|
+
]
|
|
1738
|
+
},
|
|
1739
|
+
{
|
|
1740
|
+
name: "exit",
|
|
1741
|
+
leaves: [
|
|
1742
|
+
{
|
|
1743
|
+
name: "exit",
|
|
1744
|
+
asm: [
|
|
1745
|
+
"<exitDelay>",
|
|
1746
|
+
"OP_CHECKSEQUENCEVERIFY",
|
|
1747
|
+
"OP_DROP",
|
|
1748
|
+
"<owner>",
|
|
1749
|
+
"OP_CHECKSIG"
|
|
1750
|
+
],
|
|
1751
|
+
witness: [
|
|
1752
|
+
{
|
|
1753
|
+
name: "ownerSig",
|
|
1754
|
+
type: "signature",
|
|
1755
|
+
encoding: "schnorr-64"
|
|
1756
|
+
}
|
|
1757
|
+
]
|
|
1758
|
+
}
|
|
1759
|
+
]
|
|
1760
|
+
},
|
|
1761
|
+
{
|
|
1762
|
+
name: "renew",
|
|
1763
|
+
arkade: {
|
|
1764
|
+
inputs: [],
|
|
1765
|
+
asm: [
|
|
1766
|
+
"OP_PUSHEXPIRY",
|
|
1767
|
+
"<renewalWindow>",
|
|
1768
|
+
"OP_SUB",
|
|
1769
|
+
"OP_CHECKTIME",
|
|
1770
|
+
"OP_VERIFY",
|
|
1771
|
+
"0x74797065",
|
|
1772
|
+
"OP_INSPECTINTENTMESSAGE",
|
|
1773
|
+
"OP_VERIFY",
|
|
1774
|
+
"0x7265676973746572",
|
|
1775
|
+
"OP_EQUALVERIFY",
|
|
1776
|
+
"0x6f6e636861696e5f6f75747075745f696e6465786573",
|
|
1777
|
+
"OP_INSPECTINTENTMESSAGE",
|
|
1778
|
+
"OP_VERIFY",
|
|
1779
|
+
"0x5b5d",
|
|
1780
|
+
"OP_EQUALVERIFY",
|
|
1781
|
+
"OP_PUSHCURRENTINPUTINDEX",
|
|
1782
|
+
"OP_1SUB",
|
|
1783
|
+
"OP_INSPECTOUTPUTVALUE",
|
|
1784
|
+
"<maxFee>",
|
|
1785
|
+
"OP_ADD",
|
|
1786
|
+
"OP_PUSHCURRENTINPUTINDEX",
|
|
1787
|
+
"OP_INSPECTINPUTVALUE",
|
|
1788
|
+
"OP_GREATERTHANOREQUAL",
|
|
1789
|
+
"OP_VERIFY",
|
|
1790
|
+
"OP_PUSHCURRENTINPUTINDEX",
|
|
1791
|
+
"OP_1SUB",
|
|
1792
|
+
"5",
|
|
1793
|
+
"0",
|
|
1794
|
+
"OP_TUNNEL"
|
|
1795
|
+
]
|
|
1796
|
+
},
|
|
1797
|
+
leaves: [
|
|
1798
|
+
{
|
|
1799
|
+
name: "renew",
|
|
1800
|
+
asm: [
|
|
1801
|
+
"<SERVER_KEY>",
|
|
1802
|
+
"OP_CHECKSIGVERIFY",
|
|
1803
|
+
"<EMULATOR_KEY:renew>",
|
|
1804
|
+
"OP_CHECKSIG"
|
|
1805
|
+
],
|
|
1806
|
+
witness: [
|
|
1807
|
+
{
|
|
1808
|
+
name: "serverSig",
|
|
1809
|
+
type: "signature",
|
|
1810
|
+
encoding: "schnorr-64",
|
|
1811
|
+
injected: true
|
|
1812
|
+
},
|
|
1813
|
+
{
|
|
1814
|
+
name: "emulatorSig",
|
|
1815
|
+
type: "signature",
|
|
1816
|
+
encoding: "schnorr-64",
|
|
1817
|
+
injected: true
|
|
1818
|
+
}
|
|
1819
|
+
]
|
|
1820
|
+
}
|
|
1821
|
+
]
|
|
1822
|
+
}
|
|
1823
|
+
]
|
|
1824
|
+
};
|
|
1825
|
+
|
|
1826
|
+
// src/script/executor/renew.json
|
|
1827
|
+
var renew_default = {
|
|
1828
|
+
format: "template/v1",
|
|
1829
|
+
type: "proof",
|
|
1830
|
+
variables: {
|
|
1831
|
+
owner: "pubkey",
|
|
1832
|
+
exit_delay: "int",
|
|
1833
|
+
renewal_window: "int",
|
|
1834
|
+
max_fee: "int"
|
|
1835
|
+
},
|
|
1836
|
+
inputs: [
|
|
1837
|
+
{
|
|
1838
|
+
name: "funds",
|
|
1839
|
+
contract: {
|
|
1840
|
+
definition: {
|
|
1841
|
+
artifact: "faa3249b8a28e999963994e4020e832285351eb7ce3b4821bcb3b4498f5b8ef3"
|
|
1842
|
+
},
|
|
1843
|
+
arguments: {
|
|
1844
|
+
owner: "<owner>",
|
|
1845
|
+
exitDelay: "<exit_delay>",
|
|
1846
|
+
renewalWindow: "<renewal_window>",
|
|
1847
|
+
maxFee: "<max_fee>"
|
|
1848
|
+
}
|
|
1849
|
+
},
|
|
1850
|
+
spend: { function: "renew", leaf: "renew" }
|
|
1851
|
+
}
|
|
1852
|
+
],
|
|
1853
|
+
outputs: [
|
|
1854
|
+
{
|
|
1855
|
+
name: "renewed",
|
|
1856
|
+
value: { from: "funds" },
|
|
1857
|
+
locking: { from: "funds" },
|
|
1858
|
+
assets: [{ from: "funds" }]
|
|
1859
|
+
}
|
|
1860
|
+
],
|
|
1861
|
+
fees: { from: "funds", max: "<max_fee>" },
|
|
1862
|
+
delegation: { schedule: { funds: { before_expiry_seconds: "<renewal_window>" } } }
|
|
1863
|
+
};
|
|
1864
|
+
|
|
1865
|
+
// src/script/executor/executorTemplate.ts
|
|
1866
|
+
var EXECUTOR_TEMPLATES = {
|
|
1867
|
+
renewal: renew_default,
|
|
1868
|
+
boarding: board_default
|
|
1869
|
+
};
|
|
1870
|
+
var EXECUTOR_ARTIFACTS = {
|
|
1871
|
+
faa3249b8a28e999963994e4020e832285351eb7ce3b4821bcb3b4498f5b8ef3: delegated_vtxo_default,
|
|
1872
|
+
e3c0fa053fbb529a252a1025e3453a41f01949f4e49d50de7dfe5d3510470ed3: delegated_boarding_default
|
|
1873
|
+
};
|
|
1874
|
+
var DEFAULT_TEMPLATE_IDS = {
|
|
1875
|
+
renewal: "d78996bc48dca7d9cc6da69bf2ee8d8feaa521c4aa5998c410e3e9ba2dc69297",
|
|
1876
|
+
boarding: "2f8b8761c3d98230cbb170814643f591c29f737c0cf68f600f81920024dccbf8"
|
|
1877
|
+
};
|
|
1878
|
+
function variablesOf(kind, owner, params) {
|
|
1879
|
+
if (owner.length !== 33) throw new Error("owner must be a compressed public key");
|
|
1880
|
+
const variables = {
|
|
1881
|
+
owner,
|
|
1882
|
+
exit_delay: params.exitDelay,
|
|
1883
|
+
renewal_window: params.renewalWindow,
|
|
1884
|
+
max_fee: params.maxFee
|
|
1885
|
+
};
|
|
1886
|
+
if (kind === "boarding") {
|
|
1887
|
+
if (params.boardingExitDelay === void 0) throw new Error("boarding needs an exit delay");
|
|
1888
|
+
variables.boarding_exit_delay = params.boardingExitDelay;
|
|
1889
|
+
}
|
|
1890
|
+
return variables;
|
|
1891
|
+
}
|
|
1892
|
+
function defaultVariables(kind, owner, params) {
|
|
1893
|
+
const variables = variablesOf(kind, owner, params);
|
|
1894
|
+
return Object.fromEntries(
|
|
1895
|
+
Object.entries(variables).map(([name, v]) => [
|
|
1896
|
+
name,
|
|
1897
|
+
base.hex.encode(typeof v === "number" ? btcSigner.ScriptNum().encode(BigInt(v)) : v)
|
|
1898
|
+
])
|
|
1899
|
+
);
|
|
1900
|
+
}
|
|
1901
|
+
function defaultContract(kind, keys, owner, params) {
|
|
1902
|
+
const doc = EXECUTOR_TEMPLATES[kind];
|
|
1903
|
+
return instantiate(doc, doc.inputs[0].contract, variablesOf(kind, owner, params), keys);
|
|
1904
|
+
}
|
|
1905
|
+
function instantiate(doc, construction, variables, keys) {
|
|
1906
|
+
const def = "artifact" in construction.definition ? EXECUTOR_ARTIFACTS[construction.definition.artifact] : construction.definition;
|
|
1907
|
+
if (!def)
|
|
1908
|
+
throw new Error(
|
|
1909
|
+
`unknown artifact ${construction.definition.artifact}`
|
|
1910
|
+
);
|
|
1911
|
+
const serverKey = base.hex.decode(keys.serverPubkey).subarray(1);
|
|
1912
|
+
const args = { server: serverKey };
|
|
1913
|
+
for (const [field, binding] of Object.entries(construction.arguments)) {
|
|
1914
|
+
if (typeof binding === "string") {
|
|
1915
|
+
const value = variables[binding.slice(1, -1)];
|
|
1916
|
+
if (value === void 0) throw new Error(`missing constructor value ${field}`);
|
|
1917
|
+
args[field] = value;
|
|
1918
|
+
} else {
|
|
1919
|
+
const output = doc.outputs.find((o) => o.name === binding.program)?.locking.contract;
|
|
1920
|
+
if (!output) throw new Error(`program ${binding.program} names no contract output`);
|
|
1921
|
+
args[field] = instantiate(doc, output, variables, keys).pkScript.subarray(2);
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
for (const field of def.constructorInputs) {
|
|
1925
|
+
const value = args[field.name];
|
|
1926
|
+
if (value === void 0) throw new Error(`missing constructor value ${field.name}`);
|
|
1927
|
+
if (field.type === "pubkey") args[field.name] = value.subarray(1);
|
|
1928
|
+
}
|
|
1929
|
+
return new chunkACIQZLWL_cjs.ArkadeProgramScript(chunkACIQZLWL_cjs.programFromArtifact(def), args, {
|
|
1930
|
+
serverKey,
|
|
1931
|
+
emulatorKey: base.hex.decode(keys.emulatorPubkey)
|
|
1932
|
+
});
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
// src/contracts/handlers/executor.ts
|
|
1936
|
+
var TEMPLATES = ["renewal", "boarding"];
|
|
1937
|
+
function compressed(value, name) {
|
|
1938
|
+
const key = base.hex.decode(value ?? "");
|
|
1939
|
+
if (key.length !== 33) throw new Error(`${name} must be a compressed public key`);
|
|
1940
|
+
return key;
|
|
1941
|
+
}
|
|
1942
|
+
function integer(value, name) {
|
|
1943
|
+
const n = Number(value);
|
|
1944
|
+
if (!/^[0-9]+$/.test(value ?? "") || !Number.isSafeInteger(n)) {
|
|
1945
|
+
throw new Error(`${name} must be a non-negative integer`);
|
|
1946
|
+
}
|
|
1947
|
+
return n;
|
|
1948
|
+
}
|
|
1949
|
+
function evenOwnerKey(xOnly) {
|
|
1950
|
+
const key = new Uint8Array(33);
|
|
1951
|
+
key[0] = 2;
|
|
1952
|
+
key.set(xOnly, 1);
|
|
1953
|
+
return key;
|
|
1954
|
+
}
|
|
1955
|
+
function executorContractParams(template, owner, keys, params) {
|
|
1956
|
+
return ExecutorContractHandler.serializeParams({
|
|
1957
|
+
template,
|
|
1958
|
+
owner,
|
|
1959
|
+
exitDelay: params.exitDelay,
|
|
1960
|
+
renewalWindow: params.renewalWindow,
|
|
1961
|
+
maxFee: params.maxFee,
|
|
1962
|
+
...template === "boarding" ? { boardingExitDelay: params.boardingExitDelay } : {},
|
|
1963
|
+
cosignerPubKey: base.hex.decode(keys.cosignerPubkey),
|
|
1964
|
+
serverPubKey: base.hex.decode(keys.serverPubkey),
|
|
1965
|
+
emulatorPubKey: base.hex.decode(keys.emulatorPubkey)
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
function executorKeysOf(p) {
|
|
1969
|
+
return {
|
|
1970
|
+
cosignerPubkey: base.hex.encode(p.cosignerPubKey),
|
|
1971
|
+
serverPubkey: base.hex.encode(p.serverPubKey),
|
|
1972
|
+
emulatorPubkey: base.hex.encode(p.emulatorPubKey)
|
|
1973
|
+
};
|
|
1974
|
+
}
|
|
1975
|
+
var ExecutorContractHandler = {
|
|
1976
|
+
type: "executor",
|
|
1977
|
+
/** The default script of the owner with the emulator-enforced leaf after forfeit and exit. */
|
|
1978
|
+
createScript(params) {
|
|
1979
|
+
const p = this.deserializeParams(params);
|
|
1980
|
+
const derived = defaultContract(p.template, executorKeysOf(p), p.owner, p);
|
|
1981
|
+
const script = new exports.DefaultVtxo.Script(
|
|
1982
|
+
{
|
|
1983
|
+
pubKey: p.owner.subarray(1),
|
|
1984
|
+
serverPubKey: p.serverPubKey.subarray(1),
|
|
1985
|
+
csvTimelock: chunk6TBTL42M_cjs.sequenceToTimelock(p.boardingExitDelay ?? p.exitDelay)
|
|
1986
|
+
},
|
|
1987
|
+
derived.scripts.slice(2)
|
|
1988
|
+
);
|
|
1989
|
+
if (!utils_js.equalBytes(script.pkScript, derived.pkScript)) {
|
|
1990
|
+
throw new Error(
|
|
1991
|
+
`delegated ${p.template} contract is not forfeit, exit and an emulator-enforced leaf`
|
|
1992
|
+
);
|
|
1993
|
+
}
|
|
1994
|
+
return script;
|
|
1995
|
+
},
|
|
1996
|
+
serializeParams(params) {
|
|
1997
|
+
return {
|
|
1998
|
+
template: params.template,
|
|
1999
|
+
owner: base.hex.encode(params.owner),
|
|
2000
|
+
exitDelay: params.exitDelay.toString(),
|
|
2001
|
+
renewalWindow: params.renewalWindow.toString(),
|
|
2002
|
+
maxFee: params.maxFee.toString(),
|
|
2003
|
+
...params.boardingExitDelay !== void 0 ? { boardingExitDelay: params.boardingExitDelay.toString() } : {},
|
|
2004
|
+
cosignerPubKey: base.hex.encode(params.cosignerPubKey),
|
|
2005
|
+
serverPubKey: base.hex.encode(params.serverPubKey),
|
|
2006
|
+
emulatorPubKey: base.hex.encode(params.emulatorPubKey)
|
|
2007
|
+
};
|
|
2008
|
+
},
|
|
2009
|
+
deserializeParams(params) {
|
|
2010
|
+
if (!TEMPLATES.includes(params.template)) {
|
|
2011
|
+
throw new Error(`unknown Executor template ${params.template}`);
|
|
2012
|
+
}
|
|
2013
|
+
return {
|
|
2014
|
+
template: params.template,
|
|
2015
|
+
owner: compressed(params.owner, "owner"),
|
|
2016
|
+
exitDelay: integer(params.exitDelay, "exitDelay"),
|
|
2017
|
+
renewalWindow: integer(params.renewalWindow, "renewalWindow"),
|
|
2018
|
+
maxFee: integer(params.maxFee, "maxFee"),
|
|
2019
|
+
...params.template === "boarding" ? { boardingExitDelay: integer(params.boardingExitDelay, "boardingExitDelay") } : {},
|
|
2020
|
+
cosignerPubKey: compressed(params.cosignerPubKey, "cosignerPubKey"),
|
|
2021
|
+
serverPubKey: compressed(params.serverPubKey, "serverPubKey"),
|
|
2022
|
+
emulatorPubKey: compressed(params.emulatorPubKey, "emulatorPubKey")
|
|
2023
|
+
};
|
|
2024
|
+
},
|
|
2025
|
+
selectPath(script, contract, context) {
|
|
2026
|
+
return selectForfeitOrExitPath(script, contract, context);
|
|
2027
|
+
},
|
|
2028
|
+
getAllSpendingPaths(script, contract, context) {
|
|
2029
|
+
return forfeitExitAllPaths(script, contract, context);
|
|
2030
|
+
},
|
|
2031
|
+
getSpendablePaths(script, contract, context) {
|
|
2032
|
+
return forfeitExitSpendablePaths(script, contract, context);
|
|
2033
|
+
},
|
|
2034
|
+
/** The wallet's own money, renewed by the service. */
|
|
2035
|
+
isGenericallySpendable: () => true,
|
|
2036
|
+
discoverAt: discoverAtViaRange(discoverExecutorRange),
|
|
2037
|
+
discoverRange: discoverExecutorRange
|
|
2038
|
+
};
|
|
2039
|
+
async function discoverExecutorRange(entries, deps) {
|
|
2040
|
+
const out = new Map(entries.map((e) => [e.index, []]));
|
|
2041
|
+
const watches = deps.executorWatches ?? [];
|
|
2042
|
+
if (watches.length === 0) return out;
|
|
2043
|
+
const pairs = entries.flatMap(
|
|
2044
|
+
({ index, descriptor }) => watches.map((watch) => ({
|
|
2045
|
+
index,
|
|
2046
|
+
renewal: discovered("renewal", descriptor, watch, deps),
|
|
2047
|
+
boarding: watch.params.boardingExitDelay === void 0 ? void 0 : discovered("boarding", descriptor, watch, deps)
|
|
2048
|
+
}))
|
|
2049
|
+
);
|
|
2050
|
+
const onchain = deps.onchainNetwork;
|
|
2051
|
+
const [used, funded] = await Promise.all([
|
|
2052
|
+
detectUsedScripts(
|
|
2053
|
+
deps.indexerProvider,
|
|
2054
|
+
pairs.map((p) => p.renewal.contract.script)
|
|
2055
|
+
),
|
|
2056
|
+
Promise.all(
|
|
2057
|
+
pairs.map(
|
|
2058
|
+
async ({ boarding }) => boarding && onchain ? (await deps.onchainProvider.getCoins(boarding.script.onchainAddress(onchain))).length > 0 : false
|
|
2059
|
+
)
|
|
2060
|
+
)
|
|
2061
|
+
]);
|
|
2062
|
+
pairs.forEach(({ index, renewal, boarding }, i) => {
|
|
2063
|
+
if (!used.has(renewal.contract.script) && !funded[i]) return;
|
|
2064
|
+
out.get(index).push(renewal.contract, ...boarding ? [boarding.contract] : []);
|
|
2065
|
+
});
|
|
2066
|
+
return out;
|
|
2067
|
+
}
|
|
2068
|
+
function discovered(template, descriptor, { keys, params }, deps) {
|
|
2069
|
+
const owner = evenOwnerKey(deriveDescriptorLeafPubKey(descriptor));
|
|
2070
|
+
const serialized = executorContractParams(template, owner, keys, params);
|
|
2071
|
+
const script = ExecutorContractHandler.createScript(serialized);
|
|
2072
|
+
return {
|
|
2073
|
+
script,
|
|
2074
|
+
contract: {
|
|
2075
|
+
type: ExecutorContractHandler.type,
|
|
2076
|
+
params: serialized,
|
|
2077
|
+
script: base.hex.encode(script.pkScript),
|
|
2078
|
+
address: script.address(deps.network.hrp, base.hex.decode(keys.serverPubkey).subarray(1)).encode(),
|
|
2079
|
+
scope: template === "boarding" ? "onchain" : "offchain",
|
|
2080
|
+
label: template === "renewal" ? "Delegated renewal" : "Delegated boarding",
|
|
2081
|
+
metadata: { signingDescriptor: descriptor }
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
2084
|
+
}
|
|
2085
|
+
|
|
1482
2086
|
// src/contracts/handlers/index.ts
|
|
1483
2087
|
contractHandlers.register(DefaultContractHandler);
|
|
1484
2088
|
contractHandlers.register(DelegateContractHandler);
|
|
@@ -1486,18 +2090,26 @@ contractHandlers.register(VHTLCContractHandler);
|
|
|
1486
2090
|
contractHandlers.register(VHTLCV2ContractHandler);
|
|
1487
2091
|
contractHandlers.register(BoardingContractHandler);
|
|
1488
2092
|
contractHandlers.register(ArkadeContractHandler);
|
|
2093
|
+
contractHandlers.register(ExecutorContractHandler);
|
|
1489
2094
|
|
|
1490
2095
|
exports.ArkadeContractHandler = ArkadeContractHandler;
|
|
1491
2096
|
exports.BoardingContractHandler = BoardingContractHandler;
|
|
2097
|
+
exports.DEFAULT_TEMPLATE_IDS = DEFAULT_TEMPLATE_IDS;
|
|
1492
2098
|
exports.DefaultContractHandler = DefaultContractHandler;
|
|
1493
2099
|
exports.DelegateContractHandler = DelegateContractHandler;
|
|
2100
|
+
exports.ExecutorContractHandler = ExecutorContractHandler;
|
|
1494
2101
|
exports.VHTLCContractHandler = VHTLCContractHandler;
|
|
1495
2102
|
exports.VHTLCV2ContractHandler = VHTLCV2ContractHandler;
|
|
1496
2103
|
exports.WALLET_RECEIVE_SOURCE = WALLET_RECEIVE_SOURCE;
|
|
1497
2104
|
exports.contractHandlers = contractHandlers;
|
|
2105
|
+
exports.defaultVariables = defaultVariables;
|
|
2106
|
+
exports.delegateDiscoveryKeys = delegateDiscoveryKeys;
|
|
1498
2107
|
exports.deriveDescriptorLeafCompressedPubKey = deriveDescriptorLeafCompressedPubKey;
|
|
1499
2108
|
exports.deriveDescriptorLeafPubKey = deriveDescriptorLeafPubKey;
|
|
1500
2109
|
exports.descriptorIsOurs = descriptorIsOurs;
|
|
2110
|
+
exports.evenOwnerKey = evenOwnerKey;
|
|
2111
|
+
exports.executorContractParams = executorContractParams;
|
|
2112
|
+
exports.executorKeysOf = executorKeysOf;
|
|
1501
2113
|
exports.exitSequence = exitSequence;
|
|
1502
2114
|
exports.extractPubKey = extractPubKey;
|
|
1503
2115
|
exports.identityDescriptor = identityDescriptor;
|
|
@@ -1507,5 +2119,5 @@ exports.isMainnetDescriptor = isMainnetDescriptor;
|
|
|
1507
2119
|
exports.normalizeToDescriptor = normalizeToDescriptor;
|
|
1508
2120
|
exports.parseHDDescriptor = parseHDDescriptor;
|
|
1509
2121
|
exports.speculativeReceiveMetadata = speculativeReceiveMetadata;
|
|
1510
|
-
//# sourceMappingURL=chunk-
|
|
1511
|
-
//# sourceMappingURL=chunk-
|
|
2122
|
+
//# sourceMappingURL=chunk-TD4PKK2I.cjs.map
|
|
2123
|
+
//# sourceMappingURL=chunk-TD4PKK2I.cjs.map
|