@arkade-os/sdk 0.4.66 → 0.4.68
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 +71 -15
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{asyncStorageTaskQueue-BZcIN7sA.d.cts → asyncStorageTaskQueue-B2CcXIHU.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-B6SijMi3.d.ts → asyncStorageTaskQueue-DaZlVTbM.d.ts} +1 -1
- package/dist/{chunk-2JZGPXU4.js → chunk-33Q2RFET.js} +3 -3
- package/dist/{chunk-2JZGPXU4.js.map → chunk-33Q2RFET.js.map} +1 -1
- package/dist/{chunk-CYOI4PEA.js → chunk-45FKMOJH.js} +160 -114
- package/dist/chunk-45FKMOJH.js.map +1 -0
- package/dist/{chunk-J33ZEM3A.js → chunk-4CMXV5SF.js} +45 -14
- package/dist/chunk-4CMXV5SF.js.map +1 -0
- package/dist/{chunk-LL47QIHD.cjs → chunk-4KCVS4ZN.cjs} +10 -10
- package/dist/{chunk-LL47QIHD.cjs.map → chunk-4KCVS4ZN.cjs.map} +1 -1
- package/dist/{chunk-PXPPZF5K.cjs → chunk-6YUACVX4.cjs} +205 -159
- package/dist/chunk-6YUACVX4.cjs.map +1 -0
- package/dist/{chunk-ZIRFXBKL.cjs → chunk-EJOFL5WH.cjs} +47 -13
- package/dist/chunk-EJOFL5WH.cjs.map +1 -0
- package/dist/{chunk-R5POS3RS.js → chunk-G4I6PU5H.js} +4 -4
- package/dist/{chunk-R5POS3RS.js.map → chunk-G4I6PU5H.js.map} +1 -1
- package/dist/{chunk-55ZZ6RBL.js → chunk-GQ4NMQGR.js} +4 -4
- package/dist/{chunk-55ZZ6RBL.js.map → chunk-GQ4NMQGR.js.map} +1 -1
- package/dist/{chunk-IM6IKNSL.cjs → chunk-JGMSZIE4.cjs} +17 -17
- package/dist/{chunk-IM6IKNSL.cjs.map → chunk-JGMSZIE4.cjs.map} +1 -1
- package/dist/{chunk-3S3JZUEN.cjs → chunk-PJR63FTK.cjs} +17 -17
- package/dist/{chunk-3S3JZUEN.cjs.map → chunk-PJR63FTK.cjs.map} +1 -1
- package/dist/{chunk-DSC3G6QZ.js → chunk-VBHXBI7F.js} +1060 -185
- package/dist/chunk-VBHXBI7F.js.map +1 -0
- package/dist/{chunk-5E6IZNRG.cjs → chunk-WCJVKFAP.cjs} +1467 -581
- package/dist/chunk-WCJVKFAP.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-T-vgxMYZ.d.ts → delegate-AomVWxO_.d.ts} +1 -1
- package/dist/{delegate-YXupcWWJ.d.cts → delegate-Bffc5f54.d.cts} +1 -1
- package/dist/{wallet-CNibc3yJ.d.ts → hdWalletCapable-B5nRs3RH.d.cts} +318 -127
- package/dist/{wallet-DJN1QgFt.d.cts → hdWalletCapable-DZdIVa23.d.ts} +318 -127
- package/dist/{index-uUE_uQPn.d.ts → index-C7RZCfoY.d.cts} +222 -19
- package/dist/{index-uUE_uQPn.d.cts → index-C7RZCfoY.d.ts} +222 -19
- package/dist/{index-e7LYXk1d.d.cts → index-jouvy8FD.d.ts} +172 -99
- package/dist/{index-D_FgwLH9.d.ts → index-nfyQM33h.d.cts} +172 -99
- package/dist/index.cjs +326 -278
- package/dist/index.d.cts +295 -41
- package/dist/index.d.ts +295 -41
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +18 -18
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-BOVcIH1N.d.cts → taskRunner-D2vnpPBT.d.cts} +1 -1
- package/dist/{taskRunner-DNyD1kXG.d.ts → taskRunner-DuwK9t8O.d.ts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +18 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +7 -5
- package/dist/wallet/expo/index.d.ts +7 -5
- package/dist/wallet/expo/index.js +10 -6
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +3 -3
- package/dist/chunk-5E6IZNRG.cjs.map +0 -1
- package/dist/chunk-CYOI4PEA.js.map +0 -1
- package/dist/chunk-DSC3G6QZ.js.map +0 -1
- package/dist/chunk-J33ZEM3A.js.map +0 -1
- package/dist/chunk-PXPPZF5K.cjs.map +0 -1
- package/dist/chunk-ZIRFXBKL.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VtxoScript, MultisigTapscript, CSVMultisigTapscript, timelockToSequence, sequenceToTimelock, ConditionMultisigTapscript, CLTVMultisigTapscript, ConditionCSVMultisigTapscript, SCRIPT_QUERY_CHUNK_SIZE, getNormalizedVtxos, DEFAULT_PAGE_SIZE } from './chunk-
|
|
1
|
+
import { VtxoScript, MultisigTapscript, CSVMultisigTapscript, timelockToSequence, sequenceToTimelock, ConditionMultisigTapscript, CLTVMultisigTapscript, ConditionCSVMultisigTapscript, SCRIPT_QUERY_CHUNK_SIZE, getNormalizedVtxos, DEFAULT_PAGE_SIZE } from './chunk-4CMXV5SF.js';
|
|
2
2
|
import { __export } from './chunk-NSBPE2FW.js';
|
|
3
3
|
import { hex } from '@scure/base';
|
|
4
4
|
import { networks, expand } from '@bitcoinerlab/descriptors-scure';
|
|
@@ -1455,6 +1455,8 @@ var VHTLC;
|
|
|
1455
1455
|
nonInteractiveClaimArkadeScript;
|
|
1456
1456
|
nonInteractiveRefundScript;
|
|
1457
1457
|
nonInteractiveRefundArkadeScript;
|
|
1458
|
+
nonInteractiveRefundWithoutReceiverScript;
|
|
1459
|
+
nonInteractiveRefundWithoutReceiverArkadeScript;
|
|
1458
1460
|
constructor(options, preimageCondition) {
|
|
1459
1461
|
validateOptions(options);
|
|
1460
1462
|
const {
|
|
@@ -1502,42 +1504,36 @@ var VHTLC;
|
|
|
1502
1504
|
];
|
|
1503
1505
|
let arkadeScriptNic;
|
|
1504
1506
|
let nonInteractiveClaimScript;
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
);
|
|
1507
|
+
let arkadeScriptNir;
|
|
1508
|
+
let nonInteractiveRefundScript;
|
|
1509
|
+
let nonInteractiveRefundWithoutReceiverScript;
|
|
1510
|
+
const covenants = options.nonInteractiveParameters;
|
|
1511
|
+
if (covenants) {
|
|
1512
|
+
arkadeScriptNic = enforcePayToMaybeAsset(covenants.receiverPkScript, options.asset);
|
|
1511
1513
|
nonInteractiveClaimScript = ConditionMultisigTapscript.encode({
|
|
1512
1514
|
conditionScript,
|
|
1513
1515
|
pubkeys: [
|
|
1514
1516
|
server,
|
|
1515
|
-
computeArkadeScriptPublicKey(
|
|
1516
|
-
options.nonInteractiveClaim.emulatorPubkey,
|
|
1517
|
-
arkadeScriptNic
|
|
1518
|
-
)
|
|
1517
|
+
computeArkadeScriptPublicKey(covenants.emulatorPubkey, arkadeScriptNic)
|
|
1519
1518
|
]
|
|
1520
1519
|
}).script;
|
|
1521
1520
|
scripts.push(nonInteractiveClaimScript);
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
arkadeScriptNir = enforcePayToMaybeAsset(
|
|
1527
|
-
options.nonInteractiveRefund.senderPkScript,
|
|
1528
|
-
options.asset
|
|
1521
|
+
arkadeScriptNir = enforcePayToMaybeAsset(covenants.senderPkScript, options.asset);
|
|
1522
|
+
const nirCosigner = computeArkadeScriptPublicKey(
|
|
1523
|
+
covenants.emulatorPubkey,
|
|
1524
|
+
arkadeScriptNir
|
|
1529
1525
|
);
|
|
1530
1526
|
nonInteractiveRefundScript = MultisigTapscript.encode({
|
|
1531
|
-
pubkeys: [
|
|
1532
|
-
server,
|
|
1533
|
-
receiver,
|
|
1534
|
-
computeArkadeScriptPublicKey(
|
|
1535
|
-
options.nonInteractiveRefund.emulatorPubkey,
|
|
1536
|
-
arkadeScriptNir
|
|
1537
|
-
)
|
|
1538
|
-
]
|
|
1527
|
+
pubkeys: [server, receiver, nirCosigner]
|
|
1539
1528
|
}).script;
|
|
1540
1529
|
scripts.push(nonInteractiveRefundScript);
|
|
1530
|
+
if (covenants.legacy !== "preTimelockedRefund") {
|
|
1531
|
+
nonInteractiveRefundWithoutReceiverScript = CLTVMultisigTapscript.encode({
|
|
1532
|
+
absoluteTimelock: refundLocktime,
|
|
1533
|
+
pubkeys: [server, nirCosigner]
|
|
1534
|
+
}).script;
|
|
1535
|
+
scripts.push(nonInteractiveRefundWithoutReceiverScript);
|
|
1536
|
+
}
|
|
1541
1537
|
}
|
|
1542
1538
|
super(scripts);
|
|
1543
1539
|
this.options = options;
|
|
@@ -1557,6 +1553,12 @@ var VHTLC;
|
|
|
1557
1553
|
this.nonInteractiveRefundScript = hex.encode(nonInteractiveRefundScript);
|
|
1558
1554
|
this.nonInteractiveRefundArkadeScript = arkadeScriptNir;
|
|
1559
1555
|
}
|
|
1556
|
+
if (nonInteractiveRefundWithoutReceiverScript) {
|
|
1557
|
+
this.nonInteractiveRefundWithoutReceiverScript = hex.encode(
|
|
1558
|
+
nonInteractiveRefundWithoutReceiverScript
|
|
1559
|
+
);
|
|
1560
|
+
this.nonInteractiveRefundWithoutReceiverArkadeScript = arkadeScriptNir;
|
|
1561
|
+
}
|
|
1560
1562
|
}
|
|
1561
1563
|
/** Return the collaborative claim tapleaf script. */
|
|
1562
1564
|
claim() {
|
|
@@ -1602,6 +1604,67 @@ var VHTLC;
|
|
|
1602
1604
|
this.nonInteractiveRefundArkadeScript
|
|
1603
1605
|
];
|
|
1604
1606
|
}
|
|
1607
|
+
/**
|
|
1608
|
+
* Return the timelocked non-interactive refund tapleaf and its ArkadeScript.
|
|
1609
|
+
*
|
|
1610
|
+
* SPENDING THIS LEAF, CONCRETELY — confirmed from this SDK's own
|
|
1611
|
+
* emulator client and covenant-spend builder ({@link
|
|
1612
|
+
* EmulatorProvider} in `src/providers/emulator.ts`, and {@link
|
|
1613
|
+
* ArkadeTransactionBuilder} in `src/arkade/contract.ts`), which is
|
|
1614
|
+
* the general machinery every covenant leaf in this file goes
|
|
1615
|
+
* through:
|
|
1616
|
+
*
|
|
1617
|
+
* 1. Build the ark tx spending this leaf (this method's {@link
|
|
1618
|
+
* TapLeafScript} as `tapLeafScript`, this script's {@link
|
|
1619
|
+
* VtxoScript.encode} as `tapTree`), plus its checkpoint tx.
|
|
1620
|
+
* 2. Attach the ArkadeScript this method returns to the spent
|
|
1621
|
+
* input via an `EmulatorPacket` (type 1) — `{ vin, script:
|
|
1622
|
+
* <this ArkadeScript>, witness: <empty> }`, empty because the
|
|
1623
|
+
* script pushes its own input/output index with
|
|
1624
|
+
* `PUSHCURRENTINPUTINDEX` rather than reading one from the
|
|
1625
|
+
* witness — wrapped in an `Extension` OP_RETURN output on the
|
|
1626
|
+
* ark tx.
|
|
1627
|
+
* 3. Attach the spent input's OWN creating ark tx as `PrevArkTx` on
|
|
1628
|
+
* input 0 — required so the emulator can resolve that input's
|
|
1629
|
+
* prevout pkScript/value; it does not otherwise have them.
|
|
1630
|
+
* 4. POST the (base64-PSBT) ark tx and checkpoint(s) as `{ arkTx,
|
|
1631
|
+
* checkpointTxs }` to the emulator's `POST /v1/tx`.
|
|
1632
|
+
*
|
|
1633
|
+
* THE COVENANT CHECK the emulator runs against that ArkadeScript —
|
|
1634
|
+
* `enforcePayTo(senderPkScript)`, see that function above — is: the
|
|
1635
|
+
* output at this SAME input's index is a v1 P2TR output paying
|
|
1636
|
+
* `senderPkScript`, with a value at least the input's. Only on that
|
|
1637
|
+
* check passing does the emulator sign for `nirCosigner` (the
|
|
1638
|
+
* `emulatorPubkey` tweaked by this ArkadeScript's hash); the
|
|
1639
|
+
* response carries the fully co-signed `signedArkTx` and
|
|
1640
|
+
* `signedCheckpointTxs` — `ArkadeTransactionBuilder.send()`'s own
|
|
1641
|
+
* comment on this path: "the emulator executes the arkade script
|
|
1642
|
+
* and finalizes with arkd" — no separate call to arkd is made by
|
|
1643
|
+
* this SDK for a covenant spend.
|
|
1644
|
+
* Neither `server` nor `receiver` play any part in that check: this
|
|
1645
|
+
* leaf's tapscript still requires `server`'s own signature
|
|
1646
|
+
* alongside `nirCosigner`'s (see the class doc above), but that is
|
|
1647
|
+
* consensus-level multisig, not something the covenant enforces.
|
|
1648
|
+
*
|
|
1649
|
+
* NOT SPENDABLE UNTIL `refundLocktime` MATURES — the tapscript's
|
|
1650
|
+
* `OP_CHECKLOCKTIMEVERIFY` is arkd's concern, not the emulator's;
|
|
1651
|
+
* the emulator will happily co-sign an immature spend and arkd will
|
|
1652
|
+
* then refuse it. A block-height-typed `refundLocktime` (below the
|
|
1653
|
+
* standard height/timestamp boundary this SDK names
|
|
1654
|
+
* `CLTV_HEIGHT_THRESHOLD`, 500,000,000, in
|
|
1655
|
+
* `src/contracts/handlers/helpers.ts`) is refused by arkd for a
|
|
1656
|
+
* forfeit-eligible leaf independent of maturity — use a
|
|
1657
|
+
* seconds-typed (absolute Unix timestamp) value.
|
|
1658
|
+
*/
|
|
1659
|
+
nonInteractiveRefundWithoutReceiver() {
|
|
1660
|
+
if (!this.nonInteractiveRefundWithoutReceiverScript || !this.nonInteractiveRefundWithoutReceiverArkadeScript) {
|
|
1661
|
+
throw new Error("VHTLC has no non-interactive refund-without-receiver leaf");
|
|
1662
|
+
}
|
|
1663
|
+
return [
|
|
1664
|
+
this.findLeaf(this.nonInteractiveRefundWithoutReceiverScript),
|
|
1665
|
+
this.nonInteractiveRefundWithoutReceiverArkadeScript
|
|
1666
|
+
];
|
|
1667
|
+
}
|
|
1605
1668
|
}
|
|
1606
1669
|
class Script3 extends BaseScript {
|
|
1607
1670
|
constructor(options) {
|
|
@@ -1629,47 +1692,25 @@ var VHTLC;
|
|
|
1629
1692
|
if (!preimageHash || preimageHash.length !== 20) {
|
|
1630
1693
|
throw new Error("preimage hash must be 20 bytes");
|
|
1631
1694
|
}
|
|
1632
|
-
if (options.asset !== void 0 && !options.
|
|
1633
|
-
throw new Error(
|
|
1634
|
-
"asset has no effect without nonInteractiveClaim or nonInteractiveRefund"
|
|
1635
|
-
);
|
|
1636
|
-
}
|
|
1637
|
-
const strict = options.nonInteractiveClaim?.strict;
|
|
1638
|
-
if (strict !== void 0) {
|
|
1639
|
-
if (strict.amount <= 0n) {
|
|
1640
|
-
throw new Error(`strict claim amount must be positive, got ${strict.amount}`);
|
|
1641
|
-
}
|
|
1642
|
-
if (options.asset !== void 0 && strict.assetAmount === void 0) {
|
|
1643
|
-
throw new Error(
|
|
1644
|
-
"strict claim needs assetAmount when the contract is denominated in an asset: bounding only the sats would leave the asset amount unenforced"
|
|
1645
|
-
);
|
|
1646
|
-
}
|
|
1647
|
-
if (options.asset === void 0 && strict.assetAmount !== void 0) {
|
|
1648
|
-
throw new Error("strict claim assetAmount has no effect without asset");
|
|
1649
|
-
}
|
|
1650
|
-
if (strict.assetAmount !== void 0 && strict.assetAmount <= 0n) {
|
|
1651
|
-
throw new Error(
|
|
1652
|
-
`strict claim assetAmount must be positive, got ${strict.assetAmount}`
|
|
1653
|
-
);
|
|
1654
|
-
}
|
|
1695
|
+
if (options.asset !== void 0 && !options.nonInteractiveParameters) {
|
|
1696
|
+
throw new Error("asset has no effect without nonInteractiveParameters");
|
|
1655
1697
|
}
|
|
1656
|
-
if (options.
|
|
1657
|
-
const { emulatorPubkey, receiverPkScript } = options.
|
|
1698
|
+
if (options.nonInteractiveParameters) {
|
|
1699
|
+
const { emulatorPubkey, receiverPkScript, senderPkScript, legacy } = options.nonInteractiveParameters;
|
|
1658
1700
|
if (!emulatorPubkey || emulatorPubkey.length !== 32 && emulatorPubkey.length !== 33) {
|
|
1659
1701
|
throw new Error("Invalid public key length (emulator)");
|
|
1660
1702
|
}
|
|
1661
1703
|
if (!receiverPkScript || !isP2trPkScript(receiverPkScript)) {
|
|
1662
1704
|
throw new Error("Invalid P2TR script");
|
|
1663
1705
|
}
|
|
1664
|
-
}
|
|
1665
|
-
if (options.nonInteractiveRefund) {
|
|
1666
|
-
const { emulatorPubkey, senderPkScript } = options.nonInteractiveRefund;
|
|
1667
|
-
if (!emulatorPubkey || emulatorPubkey.length !== 32 && emulatorPubkey.length !== 33) {
|
|
1668
|
-
throw new Error("Invalid public key length (emulator)");
|
|
1669
|
-
}
|
|
1670
1706
|
if (!senderPkScript || !isP2trPkScript(senderPkScript)) {
|
|
1671
1707
|
throw new Error("Invalid P2TR script");
|
|
1672
1708
|
}
|
|
1709
|
+
if (legacy !== void 0 && legacy !== "preTimelockedRefund") {
|
|
1710
|
+
throw new Error(
|
|
1711
|
+
`nonInteractiveParameters.legacy must be "preTimelockedRefund" when set, got ${JSON.stringify(legacy)}`
|
|
1712
|
+
);
|
|
1713
|
+
}
|
|
1673
1714
|
}
|
|
1674
1715
|
if (!receiver || receiver.length !== 32) {
|
|
1675
1716
|
throw new Error("Invalid public key length (receiver)");
|
|
@@ -1721,7 +1762,7 @@ function preimageConditionScriptV2(preimageHash) {
|
|
|
1721
1762
|
function isP2trPkScript(pkScript) {
|
|
1722
1763
|
return pkScript.length === 34 && pkScript[0] === 81 && pkScript[1] === 32;
|
|
1723
1764
|
}
|
|
1724
|
-
function satClause(destinationPkScript
|
|
1765
|
+
function satClause(destinationPkScript) {
|
|
1725
1766
|
return [
|
|
1726
1767
|
"PUSHCURRENTINPUTINDEX",
|
|
1727
1768
|
"DUP",
|
|
@@ -1731,21 +1772,18 @@ function satClause(destinationPkScript, quotedSats) {
|
|
|
1731
1772
|
destinationPkScript.subarray(2),
|
|
1732
1773
|
"EQUALVERIFY",
|
|
1733
1774
|
"INSPECTOUTPUTVALUE",
|
|
1734
|
-
// `DUP` because the output value is needed twice: once against the
|
|
1735
|
-
// quote, once against the input.
|
|
1736
|
-
...quotedSats === void 0 ? [] : ["DUP", quotedSats, "GREATERTHANOREQUAL", "VERIFY"],
|
|
1737
1775
|
"PUSHCURRENTINPUTINDEX",
|
|
1738
1776
|
"INSPECTINPUTVALUE",
|
|
1739
1777
|
"GREATERTHANOREQUAL"
|
|
1740
1778
|
];
|
|
1741
1779
|
}
|
|
1742
|
-
function enforcePayTo(destinationPkScript
|
|
1780
|
+
function enforcePayTo(destinationPkScript) {
|
|
1743
1781
|
if (!isP2trPkScript(destinationPkScript)) {
|
|
1744
1782
|
throw new Error("invalid P2TR script");
|
|
1745
1783
|
}
|
|
1746
|
-
return ArkadeScript.encode(satClause(destinationPkScript
|
|
1784
|
+
return ArkadeScript.encode(satClause(destinationPkScript));
|
|
1747
1785
|
}
|
|
1748
|
-
function enforcePayToAsset(destinationPkScript, asset
|
|
1786
|
+
function enforcePayToAsset(destinationPkScript, asset) {
|
|
1749
1787
|
if (!isP2trPkScript(destinationPkScript)) {
|
|
1750
1788
|
throw new Error("invalid P2TR script");
|
|
1751
1789
|
}
|
|
@@ -1769,10 +1807,6 @@ function enforcePayToAsset(destinationPkScript, asset, strict) {
|
|
|
1769
1807
|
"INSPECTOUTASSETLOOKUP",
|
|
1770
1808
|
"VERIFY",
|
|
1771
1809
|
// PRESENT on the output, not merely "zero of it"
|
|
1772
|
-
// The quoted bound, when the caller opted in — added to the input
|
|
1773
|
-
// comparison below, not substituted for it. `DUP` because the output's
|
|
1774
|
-
// asset amount is needed twice.
|
|
1775
|
-
...strict?.assetAmount === void 0 ? [] : ["DUP", strict.assetAmount, "GREATERTHANOREQUAL", "VERIFY"],
|
|
1776
1810
|
"PUSHCURRENTINPUTINDEX",
|
|
1777
1811
|
inspectionTxid,
|
|
1778
1812
|
asset.groupIndex,
|
|
@@ -1787,11 +1821,11 @@ function enforcePayToAsset(destinationPkScript, asset, strict) {
|
|
|
1787
1821
|
1,
|
|
1788
1822
|
"EQUALVERIFY",
|
|
1789
1823
|
// ...then the sat covenant, the same tokens `enforcePayTo` emits.
|
|
1790
|
-
...satClause(destinationPkScript
|
|
1824
|
+
...satClause(destinationPkScript)
|
|
1791
1825
|
]);
|
|
1792
1826
|
}
|
|
1793
|
-
function enforcePayToMaybeAsset(destinationPkScript, asset
|
|
1794
|
-
return asset === void 0 ? enforcePayTo(destinationPkScript
|
|
1827
|
+
function enforcePayToMaybeAsset(destinationPkScript, asset) {
|
|
1828
|
+
return asset === void 0 ? enforcePayTo(destinationPkScript) : enforcePayToAsset(destinationPkScript, asset);
|
|
1795
1829
|
}
|
|
1796
1830
|
|
|
1797
1831
|
// src/contracts/handlers/vhtlc.ts
|
|
@@ -2063,6 +2097,7 @@ var VHTLCV2ContractHandler = {
|
|
|
2063
2097
|
return new VHTLC.ScriptV2(typed);
|
|
2064
2098
|
},
|
|
2065
2099
|
serializeParams(params) {
|
|
2100
|
+
const covenants = params.nonInteractiveParameters;
|
|
2066
2101
|
return {
|
|
2067
2102
|
sender: hex.encode(params.sender),
|
|
2068
2103
|
receiver: hex.encode(params.receiver),
|
|
@@ -2074,35 +2109,34 @@ var VHTLCV2ContractHandler = {
|
|
|
2074
2109
|
refundNoReceiverDelay: timelockToSequence(
|
|
2075
2110
|
params.unilateralRefundWithoutReceiverDelay
|
|
2076
2111
|
).toString(),
|
|
2112
|
+
// The on-disk keys keep their per-leaf names even though the typed
|
|
2113
|
+
// param is ONE group: rows written by older SDKs carry exactly
|
|
2114
|
+
// these keys, and changing the storage encoding would orphan them.
|
|
2115
|
+
// The group maps onto them without loss — one emulator key serves
|
|
2116
|
+
// both covenant destinations by construction (see the option's doc
|
|
2117
|
+
// on VHTLC.Options), so the two emulator-key columns always hold
|
|
2118
|
+
// the same value on a row written from here.
|
|
2119
|
+
//
|
|
2077
2120
|
// Spread rather than written as `undefined`: a `Record<string,
|
|
2078
2121
|
// string>` round-tripped through a repository must not gain keys
|
|
2079
2122
|
// whose value is the string "undefined".
|
|
2080
|
-
...
|
|
2081
|
-
nonInteractiveClaimReceiverPkScript: hex.encode(
|
|
2082
|
-
|
|
2083
|
-
),
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
),
|
|
2087
|
-
//
|
|
2088
|
-
//
|
|
2089
|
-
//
|
|
2090
|
-
//
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
}
|
|
2123
|
+
...covenants && {
|
|
2124
|
+
nonInteractiveClaimReceiverPkScript: hex.encode(covenants.receiverPkScript),
|
|
2125
|
+
nonInteractiveClaimEmulatorPubkey: hex.encode(covenants.emulatorPubkey),
|
|
2126
|
+
nonInteractiveRefundSenderPkScript: hex.encode(covenants.senderPkScript),
|
|
2127
|
+
nonInteractiveRefundEmulatorPubkey: hex.encode(covenants.emulatorPubkey),
|
|
2128
|
+
// The legacy marker is precisely the ABSENCE of this key: a
|
|
2129
|
+
// row carrying it re-derives the full suite (nine leaves), a
|
|
2130
|
+
// row lacking it the pre-timelocked-refund eight — the same
|
|
2131
|
+
// encoding older SDKs wrote for eight-leaf rows, so those rows
|
|
2132
|
+
// read back unchanged. Spread rather than a "false"/"undefined"
|
|
2133
|
+
// string: a dropped flag re-derives the EIGHT-leaf script, a
|
|
2134
|
+
// different pkScript, and registration dies at
|
|
2135
|
+
// `upsertContractRow` with an opaque `Script mismatch`.
|
|
2136
|
+
...covenants.legacy === void 0 && {
|
|
2137
|
+
nonInteractiveRefundWithoutReceiver: "1"
|
|
2096
2138
|
}
|
|
2097
2139
|
},
|
|
2098
|
-
...params.nonInteractiveRefund && {
|
|
2099
|
-
nonInteractiveRefundSenderPkScript: hex.encode(
|
|
2100
|
-
params.nonInteractiveRefund.senderPkScript
|
|
2101
|
-
),
|
|
2102
|
-
nonInteractiveRefundEmulatorPubkey: hex.encode(
|
|
2103
|
-
params.nonInteractiveRefund.emulatorPubkey
|
|
2104
|
-
)
|
|
2105
|
-
},
|
|
2106
2140
|
// The asset must round-trip, and its absence here used to be silent
|
|
2107
2141
|
// in the worst way. `ContractManager` re-derives a contract from
|
|
2108
2142
|
// these params; dropping the asset derives the SAT-ONLY script, so
|
|
@@ -2131,14 +2165,34 @@ var VHTLCV2ContractHandler = {
|
|
|
2131
2165
|
"nonInteractiveRefundEmulatorPubkey",
|
|
2132
2166
|
"nonInteractiveRefund"
|
|
2133
2167
|
);
|
|
2168
|
+
if (claim === void 0 !== (refund === void 0)) {
|
|
2169
|
+
throw new Error(
|
|
2170
|
+
"emulator covenant params are all-or-nothing: the claim keys (nonInteractiveClaim*) and the refund keys (nonInteractiveRefund*) must both be present or both absent \u2014 a row carrying one side was written for a leaf subset this handler no longer derives"
|
|
2171
|
+
);
|
|
2172
|
+
}
|
|
2173
|
+
if (claim && refund && hex.encode(claim.emulatorPubkey) !== hex.encode(refund.emulatorPubkey)) {
|
|
2174
|
+
throw new Error(
|
|
2175
|
+
"emulator covenant params name two different emulator pubkeys: the suite derives both covenant cosigners from ONE key, so this row cannot be rebuilt as a group"
|
|
2176
|
+
);
|
|
2177
|
+
}
|
|
2134
2178
|
if (params.assetTxid === void 0 !== (params.assetGroupIndex === void 0)) {
|
|
2135
2179
|
throw new Error(
|
|
2136
2180
|
"asset params are incomplete: assetTxid and assetGroupIndex must both be present or both absent"
|
|
2137
2181
|
);
|
|
2138
2182
|
}
|
|
2139
|
-
if (params.
|
|
2183
|
+
if (params.strictClaimAmount !== void 0 || params.strictClaimAssetAmount !== void 0) {
|
|
2140
2184
|
throw new Error(
|
|
2141
|
-
"
|
|
2185
|
+
"strict claim params on a stored row: the strict claim bound was removed and this row's lockup cannot be re-derived without it \u2014 restore it with the SDK version that wrote it"
|
|
2186
|
+
);
|
|
2187
|
+
}
|
|
2188
|
+
if (params.nonInteractiveRefundWithoutReceiver !== void 0 && !refund) {
|
|
2189
|
+
throw new Error(
|
|
2190
|
+
"nonInteractiveRefundWithoutReceiver without the emulator covenant keys it extends: reading this as 'not set' would re-derive a script without the leaf"
|
|
2191
|
+
);
|
|
2192
|
+
}
|
|
2193
|
+
if (params.nonInteractiveRefundWithoutReceiver !== void 0 && params.nonInteractiveRefundWithoutReceiver !== "1") {
|
|
2194
|
+
throw new Error(
|
|
2195
|
+
`nonInteractiveRefundWithoutReceiver must be "1" when present, got ` + JSON.stringify(params.nonInteractiveRefundWithoutReceiver)
|
|
2142
2196
|
);
|
|
2143
2197
|
}
|
|
2144
2198
|
const asset = params.assetTxid !== void 0 && params.assetGroupIndex !== void 0 ? {
|
|
@@ -2157,25 +2211,17 @@ var VHTLCV2ContractHandler = {
|
|
|
2157
2211
|
unilateralRefundWithoutReceiverDelay: sequenceToTimelock(
|
|
2158
2212
|
Number(params.refundNoReceiverDelay)
|
|
2159
2213
|
),
|
|
2160
|
-
...claim && {
|
|
2161
|
-
|
|
2214
|
+
...claim && refund && {
|
|
2215
|
+
nonInteractiveParameters: {
|
|
2162
2216
|
receiverPkScript: claim.destination,
|
|
2217
|
+
senderPkScript: refund.destination,
|
|
2163
2218
|
emulatorPubkey: claim.emulatorPubkey,
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
assetAmount: BigInt(params.strictClaimAssetAmount)
|
|
2169
|
-
}
|
|
2170
|
-
}
|
|
2219
|
+
// Absence of the flag IS the legacy marker — the same
|
|
2220
|
+
// encoding older SDKs wrote for eight-leaf rows.
|
|
2221
|
+
...params.nonInteractiveRefundWithoutReceiver !== "1" && {
|
|
2222
|
+
legacy: "preTimelockedRefund"
|
|
2171
2223
|
}
|
|
2172
2224
|
}
|
|
2173
|
-
},
|
|
2174
|
-
...refund && {
|
|
2175
|
-
nonInteractiveRefund: {
|
|
2176
|
-
senderPkScript: refund.destination,
|
|
2177
|
-
emulatorPubkey: refund.emulatorPubkey
|
|
2178
|
-
}
|
|
2179
2225
|
}
|
|
2180
2226
|
};
|
|
2181
2227
|
},
|
|
@@ -2942,5 +2988,5 @@ contractHandlers.register(BoardingContractHandler);
|
|
|
2942
2988
|
contractHandlers.register(ArkadeContractHandler);
|
|
2943
2989
|
|
|
2944
2990
|
export { ARKADE_OP, ARKADE_OPCODES, ARKADE_OPCODE_NAMES, ARKADE_OPCODE_VALUES, ARKADE_OPS, ArkadeContractHandler, ArkadeProgramScript, ArkadeScript, BoardingContractHandler, DefaultContractHandler, DefaultVtxo, DelegateContractHandler, DelegateVtxo, OPCODE_NAMES, OPCODE_VALUES, SUPPORTED_PROGRAM_VERSION, VHTLC, VHTLCContractHandler, VHTLCV2ContractHandler, WALLET_RECEIVE_SOURCE, arkadeScriptHash, arkadeWitnessHash, asmToBytes, bignum_exports, bytesToASM, computeArkadeScriptPublicKey, contractHandlers, deriveDescriptorLeafCompressedPubKey, deriveDescriptorLeafPubKey, descriptorIsOurs, deserializeArkadeContractParams, fromASM, getOpcodeName, getOpcodeValue, identityDescriptor, inputName, isCltvSatisfied, isCsvSpendable, isMainnetDescriptor, normalizeToDescriptor, parseArtifact, parseHDDescriptor, resolveAsm, serializeArkadeContractParams, speculativeReceiveMetadata, stringifyArtifact, toASM, toXOnly, validateProgram, witnessRefToBytes };
|
|
2945
|
-
//# sourceMappingURL=chunk-
|
|
2946
|
-
//# sourceMappingURL=chunk-
|
|
2991
|
+
//# sourceMappingURL=chunk-45FKMOJH.js.map
|
|
2992
|
+
//# sourceMappingURL=chunk-45FKMOJH.js.map
|