@arkade-os/sdk 0.4.77 → 0.4.78
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 +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/{asyncStorageTaskQueue-MmJyAnu-.d.cts → asyncStorageTaskQueue-DiXxP-nQ.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-DTl0WM7E.d.ts → asyncStorageTaskQueue-YW2t31_o.d.ts} +2 -2
- package/dist/{chunk-52OA3UIC.js → chunk-7KIGEOYT.js} +8 -4
- package/dist/chunk-7KIGEOYT.js.map +1 -0
- package/dist/{chunk-HKOFYHZP.js → chunk-CTFYT24G.js} +3 -3
- package/dist/{chunk-HKOFYHZP.js.map → chunk-CTFYT24G.js.map} +1 -1
- package/dist/{chunk-4LP6XOMW.cjs → chunk-DFWLP3MD.cjs} +17 -17
- package/dist/{chunk-4LP6XOMW.cjs.map → chunk-DFWLP3MD.cjs.map} +1 -1
- package/dist/{chunk-H62OOAS4.cjs → chunk-IAM5IEVT.cjs} +17 -17
- package/dist/{chunk-H62OOAS4.cjs.map → chunk-IAM5IEVT.cjs.map} +1 -1
- package/dist/{chunk-Y4YK44IM.cjs → chunk-KEEZSFLI.cjs} +10 -10
- package/dist/{chunk-Y4YK44IM.cjs.map → chunk-KEEZSFLI.cjs.map} +1 -1
- package/dist/{chunk-MLOZHTBN.js → chunk-LKAASQTL.js} +87 -40
- package/dist/chunk-LKAASQTL.js.map +1 -0
- package/dist/{chunk-YKNTUOUG.js → chunk-OUHUC26M.js} +4 -4
- package/dist/{chunk-YKNTUOUG.js.map → chunk-OUHUC26M.js.map} +1 -1
- package/dist/{chunk-T6MGH4V4.js → chunk-P766MOPU.js} +4 -4
- package/dist/{chunk-T6MGH4V4.js.map → chunk-P766MOPU.js.map} +1 -1
- package/dist/{chunk-CJN4CUEU.cjs → chunk-PWIESIO6.cjs} +8 -3
- package/dist/chunk-PWIESIO6.cjs.map +1 -0
- package/dist/{chunk-YJEWWLOQ.cjs → chunk-VJ7M6WKB.cjs} +535 -488
- package/dist/chunk-VJ7M6WKB.cjs.map +1 -0
- package/dist/{chunk-LUWSY2QO.cjs → chunk-Y7BVR6SQ.cjs} +49 -49
- package/dist/{chunk-LUWSY2QO.cjs.map → chunk-Y7BVR6SQ.cjs.map} +1 -1
- package/dist/{chunk-ACPANSOX.js → chunk-ZOCJ7E6M.js} +3 -3
- package/dist/{chunk-ACPANSOX.js.map → chunk-ZOCJ7E6M.js.map} +1 -1
- 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-QPCGaD_z.d.cts → delegate-DaNNUI_B.d.cts} +1 -1
- package/dist/{delegate-CjcysR7s.d.ts → delegate-b2Wiymoj.d.ts} +1 -1
- package/dist/{hdWalletCapable--pMncWbC.d.ts → hdWalletCapable-B2XVTOvu.d.ts} +2 -2
- package/dist/{hdWalletCapable-Bp_p0WLj.d.cts → hdWalletCapable-D6PqWpuW.d.cts} +2 -2
- package/dist/{index-BMY272ns.d.cts → index-BlB97fYl.d.cts} +2 -2
- package/dist/{index-Ie_ak2zY.d.ts → index-CAS4GyN-.d.cts} +1 -0
- package/dist/{index-Ie_ak2zY.d.cts → index-CAS4GyN-.d.ts} +1 -0
- package/dist/{index-m-EM-e8D.d.ts → index-CYsKAXog.d.ts} +2 -2
- package/dist/index.cjs +304 -304
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +20 -20
- 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 +19 -19
- 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-CqrlrJEt.d.ts → taskRunner-BJj7xe35.d.ts} +2 -2
- package/dist/{taskRunner-BgRowCqB.d.cts → taskRunner-HS2d2oda.d.cts} +2 -2
- 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 +14 -14
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +5 -5
- 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 +1 -1
- package/dist/chunk-52OA3UIC.js.map +0 -1
- package/dist/chunk-CJN4CUEU.cjs.map +0 -1
- package/dist/chunk-MLOZHTBN.js.map +0 -1
- package/dist/chunk-YJEWWLOQ.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkIAM5IEVT_cjs = require('./chunk-IAM5IEVT.cjs');
|
|
4
|
+
var chunkY7BVR6SQ_cjs = require('./chunk-Y7BVR6SQ.cjs');
|
|
5
|
+
var chunkPWIESIO6_cjs = require('./chunk-PWIESIO6.cjs');
|
|
6
6
|
var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
|
|
7
7
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
8
8
|
var btcSigner = require('@scure/btc-signer');
|
|
@@ -188,7 +188,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
188
188
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
189
189
|
const tx = this.graph.find(txid);
|
|
190
190
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
191
|
-
const cosigners =
|
|
191
|
+
const cosigners = chunkPWIESIO6_cjs.getArkPsbtFields(tx.root, 0, chunkPWIESIO6_cjs.CosignerPublicKey).map(
|
|
192
192
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
193
193
|
// xonly pubkey
|
|
194
194
|
);
|
|
@@ -240,7 +240,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
240
240
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
241
241
|
const prevoutAmounts = [];
|
|
242
242
|
const prevoutScripts = [];
|
|
243
|
-
const cosigners =
|
|
243
|
+
const cosigners = chunkPWIESIO6_cjs.getArkPsbtFields(g.root, 0, chunkPWIESIO6_cjs.CosignerPublicKey).map((c) => c.key);
|
|
244
244
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
245
245
|
taprootTweak: this.scriptRoot
|
|
246
246
|
});
|
|
@@ -323,7 +323,7 @@ var SingleKey = class _SingleKey {
|
|
|
323
323
|
async sign(tx, inputIndexes) {
|
|
324
324
|
const txCpy = tx.clone();
|
|
325
325
|
if (!inputIndexes) {
|
|
326
|
-
|
|
326
|
+
chunkPWIESIO6_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
|
|
327
327
|
try {
|
|
328
328
|
if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
|
|
329
329
|
throw new Error("Failed to sign transaction");
|
|
@@ -432,7 +432,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
432
432
|
let network;
|
|
433
433
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
434
434
|
descriptor = opts.descriptor;
|
|
435
|
-
network =
|
|
435
|
+
network = chunkY7BVR6SQ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
436
436
|
} else {
|
|
437
437
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
438
438
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -530,7 +530,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
530
530
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
531
531
|
*/
|
|
532
532
|
isOurs(descriptor) {
|
|
533
|
-
return
|
|
533
|
+
return chunkY7BVR6SQ_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
534
534
|
}
|
|
535
535
|
/**
|
|
536
536
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -579,7 +579,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
579
579
|
}
|
|
580
580
|
// ── internal helpers ─────────────────────────────────────────────
|
|
581
581
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
582
|
-
const network =
|
|
582
|
+
const network = chunkY7BVR6SQ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
583
583
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
584
584
|
if (expansion.isRanged) {
|
|
585
585
|
throw new Error(
|
|
@@ -604,7 +604,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
604
604
|
signTxWithKey(tx, key, inputIndexes) {
|
|
605
605
|
const txCpy = tx.clone();
|
|
606
606
|
if (!inputIndexes) {
|
|
607
|
-
|
|
607
|
+
chunkPWIESIO6_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
|
|
608
608
|
try {
|
|
609
609
|
if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
|
|
610
610
|
throw new Error("Failed to sign transaction");
|
|
@@ -666,7 +666,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
666
666
|
*/
|
|
667
667
|
descriptor;
|
|
668
668
|
constructor(descriptor) {
|
|
669
|
-
const network =
|
|
669
|
+
const network = chunkY7BVR6SQ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
670
670
|
let expansion;
|
|
671
671
|
try {
|
|
672
672
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -716,7 +716,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
716
716
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
717
717
|
*/
|
|
718
718
|
isOurs(descriptor) {
|
|
719
|
-
return
|
|
719
|
+
return chunkY7BVR6SQ_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
720
720
|
}
|
|
721
721
|
};
|
|
722
722
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -878,10 +878,10 @@ var DescriptorIdentity = class {
|
|
|
878
878
|
this.base = base;
|
|
879
879
|
}
|
|
880
880
|
async xOnlyPublicKey() {
|
|
881
|
-
return
|
|
881
|
+
return chunkY7BVR6SQ_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
882
882
|
}
|
|
883
883
|
async compressedPublicKey() {
|
|
884
|
-
return
|
|
884
|
+
return chunkY7BVR6SQ_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
885
885
|
}
|
|
886
886
|
async sign(tx, inputIndexes) {
|
|
887
887
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -949,12 +949,12 @@ var WalletCannotAllocateAddressError = class extends Error {
|
|
|
949
949
|
};
|
|
950
950
|
async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
951
951
|
const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
|
|
952
|
-
if (owner &&
|
|
952
|
+
if (owner && chunkY7BVR6SQ_cjs.parseHDDescriptor(descriptor)) {
|
|
953
953
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
954
954
|
}
|
|
955
955
|
let key;
|
|
956
956
|
try {
|
|
957
|
-
key =
|
|
957
|
+
key = chunkY7BVR6SQ_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
958
958
|
} catch {
|
|
959
959
|
throw new ForeignDescriptorError(descriptor);
|
|
960
960
|
}
|
|
@@ -1329,14 +1329,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1329
1329
|
}
|
|
1330
1330
|
var PREIMAGE_INDEX = 0;
|
|
1331
1331
|
function isPerArtifactDescriptor(descriptor) {
|
|
1332
|
-
return
|
|
1332
|
+
return chunkY7BVR6SQ_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1333
1333
|
}
|
|
1334
1334
|
async function provisionDescriptor(wallet) {
|
|
1335
1335
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1336
|
-
return allocated ?? await
|
|
1336
|
+
return allocated ?? await chunkY7BVR6SQ_cjs.identityDescriptor(wallet.identity);
|
|
1337
1337
|
}
|
|
1338
1338
|
async function provisionRefundKey(wallet) {
|
|
1339
|
-
const descriptor = await
|
|
1339
|
+
const descriptor = await chunkY7BVR6SQ_cjs.identityDescriptor(wallet.identity);
|
|
1340
1340
|
const signer = await contractSigner(wallet, descriptor);
|
|
1341
1341
|
const pubkey = await signer.xOnlyPublicKey();
|
|
1342
1342
|
const identityPubkey = await wallet.identity.xOnlyPublicKey();
|
|
@@ -1346,7 +1346,7 @@ async function provisionRefundKey(wallet) {
|
|
|
1346
1346
|
);
|
|
1347
1347
|
}
|
|
1348
1348
|
const address = await wallet.getAddress();
|
|
1349
|
-
const { pkScript } =
|
|
1349
|
+
const { pkScript } = chunkPWIESIO6_cjs.ArkAddress.decode(address);
|
|
1350
1350
|
return { descriptor, pubkey, pkScript, address };
|
|
1351
1351
|
}
|
|
1352
1352
|
async function provisionClaimSecret(wallet, opts = {}) {
|
|
@@ -1392,7 +1392,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1392
1392
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1393
1393
|
let expected;
|
|
1394
1394
|
try {
|
|
1395
|
-
expected =
|
|
1395
|
+
expected = chunkY7BVR6SQ_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1396
1396
|
} catch (cause) {
|
|
1397
1397
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1398
1398
|
}
|
|
@@ -1611,14 +1611,14 @@ var RestDelegateProvider = class {
|
|
|
1611
1611
|
*/
|
|
1612
1612
|
async delegate(intent, forfeitTxs, options) {
|
|
1613
1613
|
const url = `${this.url}/v1/delegate`;
|
|
1614
|
-
const response = await
|
|
1614
|
+
const response = await chunkPWIESIO6_cjs.baseFetch(url, {
|
|
1615
1615
|
method: "POST",
|
|
1616
1616
|
headers: {
|
|
1617
1617
|
"Content-Type": "application/json"
|
|
1618
1618
|
},
|
|
1619
1619
|
body: JSON.stringify({
|
|
1620
1620
|
intent: {
|
|
1621
|
-
message:
|
|
1621
|
+
message: chunkPWIESIO6_cjs.Intent.encodeMessage(intent.message),
|
|
1622
1622
|
proof: intent.proof
|
|
1623
1623
|
},
|
|
1624
1624
|
forfeit_txs: forfeitTxs,
|
|
@@ -1638,7 +1638,7 @@ var RestDelegateProvider = class {
|
|
|
1638
1638
|
*/
|
|
1639
1639
|
async getDelegateInfo() {
|
|
1640
1640
|
const url = `${this.url}/v1/delegator/info`;
|
|
1641
|
-
const response = await
|
|
1641
|
+
const response = await chunkPWIESIO6_cjs.rateGate.runHttp(url, () => chunkPWIESIO6_cjs.baseFetch(url));
|
|
1642
1642
|
if (!response.ok) {
|
|
1643
1643
|
const errorText2 = await response.text();
|
|
1644
1644
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1663,7 +1663,7 @@ var ESPLORA_URL = {
|
|
|
1663
1663
|
regtest: "http://localhost:3000/api"
|
|
1664
1664
|
};
|
|
1665
1665
|
var EsploraProvider = class {
|
|
1666
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1666
|
+
constructor(baseUrl = ESPLORA_URL[chunkPWIESIO6_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1667
1667
|
this.baseUrl = baseUrl;
|
|
1668
1668
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1669
1669
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1682,14 +1682,14 @@ var EsploraProvider = class {
|
|
|
1682
1682
|
*/
|
|
1683
1683
|
addressWatches = /* @__PURE__ */ new Map();
|
|
1684
1684
|
async getCoins(address) {
|
|
1685
|
-
const response = await
|
|
1685
|
+
const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1686
1686
|
if (!response.ok) {
|
|
1687
1687
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1688
1688
|
}
|
|
1689
1689
|
return response.json();
|
|
1690
1690
|
}
|
|
1691
1691
|
async getFeeRate() {
|
|
1692
|
-
const response = await
|
|
1692
|
+
const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1693
1693
|
if (response.status === 404) {
|
|
1694
1694
|
return void 0;
|
|
1695
1695
|
}
|
|
@@ -1710,7 +1710,7 @@ var EsploraProvider = class {
|
|
|
1710
1710
|
}
|
|
1711
1711
|
}
|
|
1712
1712
|
async getTxOutspends(txid) {
|
|
1713
|
-
const response = await
|
|
1713
|
+
const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1714
1714
|
if (!response.ok) {
|
|
1715
1715
|
const error = await response.text();
|
|
1716
1716
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1718,7 +1718,7 @@ var EsploraProvider = class {
|
|
|
1718
1718
|
return response.json();
|
|
1719
1719
|
}
|
|
1720
1720
|
async getTransactions(address) {
|
|
1721
|
-
const response = await
|
|
1721
|
+
const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1722
1722
|
if (!response.ok) {
|
|
1723
1723
|
const error = await response.text();
|
|
1724
1724
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1731,14 +1731,14 @@ var EsploraProvider = class {
|
|
|
1731
1731
|
* usable as a change probe for the polling fallback.
|
|
1732
1732
|
*/
|
|
1733
1733
|
async getAddressStats(address) {
|
|
1734
|
-
const response = await
|
|
1734
|
+
const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
|
|
1735
1735
|
if (!response.ok) {
|
|
1736
1736
|
throw new Error(`Failed to get address stats: ${response.statusText}`);
|
|
1737
1737
|
}
|
|
1738
1738
|
return response.json();
|
|
1739
1739
|
}
|
|
1740
1740
|
async getRawTransaction(txid) {
|
|
1741
|
-
const response = await
|
|
1741
|
+
const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
1742
1742
|
if (!response.ok) {
|
|
1743
1743
|
const error = await response.text();
|
|
1744
1744
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -1746,7 +1746,7 @@ var EsploraProvider = class {
|
|
|
1746
1746
|
return base.hex.decode((await response.text()).trim());
|
|
1747
1747
|
}
|
|
1748
1748
|
async getTxStatus(txid) {
|
|
1749
|
-
const txresponse = await
|
|
1749
|
+
const txresponse = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1750
1750
|
if (!txresponse.ok) {
|
|
1751
1751
|
throw new Error(txresponse.statusText);
|
|
1752
1752
|
}
|
|
@@ -1754,7 +1754,7 @@ var EsploraProvider = class {
|
|
|
1754
1754
|
if (!tx.status.confirmed) {
|
|
1755
1755
|
return { confirmed: false };
|
|
1756
1756
|
}
|
|
1757
|
-
const response = await
|
|
1757
|
+
const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1758
1758
|
if (!response.ok) {
|
|
1759
1759
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1760
1760
|
}
|
|
@@ -2038,9 +2038,9 @@ var EsploraProvider = class {
|
|
|
2038
2038
|
return { subscribers, teardown, started };
|
|
2039
2039
|
}
|
|
2040
2040
|
async getChainTip() {
|
|
2041
|
-
let tipBlocks = await
|
|
2041
|
+
let tipBlocks = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
2042
2042
|
if (tipBlocks.status === 404) {
|
|
2043
|
-
tipBlocks = await
|
|
2043
|
+
tipBlocks = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
|
|
2044
2044
|
}
|
|
2045
2045
|
if (!tipBlocks.ok) {
|
|
2046
2046
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
@@ -2062,7 +2062,7 @@ var EsploraProvider = class {
|
|
|
2062
2062
|
};
|
|
2063
2063
|
}
|
|
2064
2064
|
async broadcastPackage(parent, child) {
|
|
2065
|
-
const response = await
|
|
2065
|
+
const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
2066
2066
|
method: "POST",
|
|
2067
2067
|
headers: {
|
|
2068
2068
|
"Content-Type": "application/json"
|
|
@@ -2078,7 +2078,7 @@ var EsploraProvider = class {
|
|
|
2078
2078
|
return result;
|
|
2079
2079
|
}
|
|
2080
2080
|
async broadcastTx(tx) {
|
|
2081
|
-
const response = await
|
|
2081
|
+
const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
2082
2082
|
method: "POST",
|
|
2083
2083
|
headers: {
|
|
2084
2084
|
"Content-Type": "text/plain"
|
|
@@ -2261,7 +2261,7 @@ function findP2AOutput(tx) {
|
|
|
2261
2261
|
var CHILD_DUST_AMOUNT = 546;
|
|
2262
2262
|
function buildAnchorChild(params) {
|
|
2263
2263
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2264
|
-
const child = new
|
|
2264
|
+
const child = new chunkPWIESIO6_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2265
2265
|
child.addInput(findP2AOutput(parent));
|
|
2266
2266
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
2267
2267
|
for (const _ of fundingCoins) {
|
|
@@ -2309,7 +2309,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2309
2309
|
);
|
|
2310
2310
|
}
|
|
2311
2311
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2312
|
-
const tx = new
|
|
2312
|
+
const tx = new chunkPWIESIO6_cjs.Transaction({
|
|
2313
2313
|
version: 3,
|
|
2314
2314
|
lockTime: txLocktime
|
|
2315
2315
|
});
|
|
@@ -2385,7 +2385,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2385
2385
|
if (previousScriptKey.length !== 32) {
|
|
2386
2386
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2387
2387
|
}
|
|
2388
|
-
const cosigners =
|
|
2388
|
+
const cosigners = chunkPWIESIO6_cjs.getArkPsbtFields(child.root, 0, chunkPWIESIO6_cjs.CosignerPublicKey);
|
|
2389
2389
|
if (cosigners.length === 0) {
|
|
2390
2390
|
throw ErrMissingCosignersPublicKeys;
|
|
2391
2391
|
}
|
|
@@ -2443,7 +2443,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2443
2443
|
return new _EmulatorPacket(entries);
|
|
2444
2444
|
}
|
|
2445
2445
|
static fromBytes(data) {
|
|
2446
|
-
const reader = new
|
|
2446
|
+
const reader = new chunkIAM5IEVT_cjs.BufferReader(data);
|
|
2447
2447
|
const entryCount = reader.readCompactSize();
|
|
2448
2448
|
const entries = [];
|
|
2449
2449
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2461,7 +2461,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2461
2461
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2462
2462
|
}
|
|
2463
2463
|
serialize() {
|
|
2464
|
-
const writer = new
|
|
2464
|
+
const writer = new chunkIAM5IEVT_cjs.BufferWriter();
|
|
2465
2465
|
writer.writeCompactSize(this.entries.length);
|
|
2466
2466
|
for (const entry of this.entries) {
|
|
2467
2467
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2548,7 +2548,7 @@ var Extension = class _Extension {
|
|
|
2548
2548
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2549
2549
|
);
|
|
2550
2550
|
}
|
|
2551
|
-
const reader = new
|
|
2551
|
+
const reader = new chunkIAM5IEVT_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2552
2552
|
const packets = [];
|
|
2553
2553
|
while (reader.remaining() > 0) {
|
|
2554
2554
|
const packetType = reader.readByte();
|
|
@@ -2622,7 +2622,7 @@ var Extension = class _Extension {
|
|
|
2622
2622
|
*/
|
|
2623
2623
|
getAssetPacket() {
|
|
2624
2624
|
for (const p of this.packets) {
|
|
2625
|
-
if (p instanceof
|
|
2625
|
+
if (p instanceof chunkIAM5IEVT_cjs.Packet) {
|
|
2626
2626
|
return p;
|
|
2627
2627
|
}
|
|
2628
2628
|
}
|
|
@@ -2660,8 +2660,8 @@ var Extension = class _Extension {
|
|
|
2660
2660
|
};
|
|
2661
2661
|
function parsePacket(packetType, data) {
|
|
2662
2662
|
switch (packetType) {
|
|
2663
|
-
case
|
|
2664
|
-
return
|
|
2663
|
+
case chunkIAM5IEVT_cjs.Packet.PACKET_TYPE:
|
|
2664
|
+
return chunkIAM5IEVT_cjs.Packet.fromBytes(data);
|
|
2665
2665
|
case EmulatorPacket.PACKET_TYPE:
|
|
2666
2666
|
return EmulatorPacket.fromBytes(data);
|
|
2667
2667
|
default:
|
|
@@ -2708,22 +2708,22 @@ function buildOpReturnScript(data) {
|
|
|
2708
2708
|
}
|
|
2709
2709
|
return script;
|
|
2710
2710
|
}
|
|
2711
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2712
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2711
|
+
var ErrOffchainOutputNotFound = (address) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2712
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
2713
2713
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2714
2714
|
);
|
|
2715
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2716
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2715
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2716
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
2717
2717
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2718
2718
|
);
|
|
2719
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2720
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2719
|
+
var ErrOnchainOutputNotFound = (address) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2720
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
2721
2721
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2722
2722
|
);
|
|
2723
|
-
var ErrIntentOutputNotFound = (index, kind) => new
|
|
2723
|
+
var ErrIntentOutputNotFound = (index, kind) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
2724
2724
|
`${kind} output ${index} of the intent proof is not present in what the server built`
|
|
2725
2725
|
);
|
|
2726
|
-
var ErrUnvalidatedIntentOutput = (index) => new
|
|
2726
|
+
var ErrUnvalidatedIntentOutput = (index) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
2727
2727
|
`offchain output ${index} of the intent proof cannot be validated: virtual output tree signing did not run`
|
|
2728
2728
|
);
|
|
2729
2729
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2732,7 +2732,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2732
2732
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2733
2733
|
if (!validatedCommitmentTxid) return;
|
|
2734
2734
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2735
|
-
throw new
|
|
2735
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
2736
2736
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2737
2737
|
);
|
|
2738
2738
|
}
|
|
@@ -2742,7 +2742,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2742
2742
|
for (const recipient of recipients) {
|
|
2743
2743
|
let arkAddress;
|
|
2744
2744
|
try {
|
|
2745
|
-
arkAddress =
|
|
2745
|
+
arkAddress = chunkPWIESIO6_cjs.ArkAddress.decode(recipient.address);
|
|
2746
2746
|
} catch {
|
|
2747
2747
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2748
2748
|
continue;
|
|
@@ -2754,7 +2754,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2754
2754
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2755
2755
|
for (const recipient of recipients) {
|
|
2756
2756
|
try {
|
|
2757
|
-
|
|
2757
|
+
chunkPWIESIO6_cjs.ArkAddress.decode(recipient.address);
|
|
2758
2758
|
} catch {
|
|
2759
2759
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2760
2760
|
continue;
|
|
@@ -2763,7 +2763,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2763
2763
|
}
|
|
2764
2764
|
}
|
|
2765
2765
|
function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
|
|
2766
|
-
const proof =
|
|
2766
|
+
const proof = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
|
|
2767
2767
|
const onchain = new Set(onchainOutputIndexes);
|
|
2768
2768
|
const declared = [];
|
|
2769
2769
|
for (let i = 0; i < proof.outputsLength; i++) {
|
|
@@ -3055,7 +3055,7 @@ function assetMintResolver() {
|
|
|
3055
3055
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
3056
3056
|
const minted = tx.assets.filter((a) => {
|
|
3057
3057
|
try {
|
|
3058
|
-
return base.hex.encode(
|
|
3058
|
+
return base.hex.encode(chunkIAM5IEVT_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
3059
3059
|
} catch {
|
|
3060
3060
|
return false;
|
|
3061
3061
|
}
|
|
@@ -3131,7 +3131,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3131
3131
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
3132
3132
|
inputsByAssetId.set(asset.assetId, [
|
|
3133
3133
|
...existing ?? [],
|
|
3134
|
-
|
|
3134
|
+
chunkIAM5IEVT_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
3135
3135
|
]);
|
|
3136
3136
|
}
|
|
3137
3137
|
}
|
|
@@ -3143,7 +3143,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3143
3143
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3144
3144
|
outputsByAssetId.set(asset.assetId, [
|
|
3145
3145
|
...existing ?? [],
|
|
3146
|
-
|
|
3146
|
+
chunkIAM5IEVT_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3147
3147
|
]);
|
|
3148
3148
|
}
|
|
3149
3149
|
}
|
|
@@ -3154,7 +3154,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3154
3154
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3155
3155
|
outputsByAssetId.set(asset.assetId, [
|
|
3156
3156
|
...existing ?? [],
|
|
3157
|
-
|
|
3157
|
+
chunkIAM5IEVT_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3158
3158
|
]);
|
|
3159
3159
|
}
|
|
3160
3160
|
}
|
|
@@ -3163,11 +3163,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3163
3163
|
for (const assetIdStr of allAssetIds) {
|
|
3164
3164
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
3165
3165
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
3166
|
-
const assetId =
|
|
3167
|
-
const group =
|
|
3166
|
+
const assetId = chunkIAM5IEVT_cjs.AssetId.fromString(assetIdStr);
|
|
3167
|
+
const group = chunkIAM5IEVT_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
3168
3168
|
groups.push(group);
|
|
3169
3169
|
}
|
|
3170
|
-
return
|
|
3170
|
+
return chunkIAM5IEVT_cjs.Packet.create(groups);
|
|
3171
3171
|
}
|
|
3172
3172
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
3173
3173
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -3204,7 +3204,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
|
|
|
3204
3204
|
}
|
|
3205
3205
|
function toXOnlySignerHex(pubkeyHex) {
|
|
3206
3206
|
const bytes = base.hex.decode(pubkeyHex);
|
|
3207
|
-
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(
|
|
3207
|
+
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkY7BVR6SQ_cjs.toXOnly(bytes, "signer key"));
|
|
3208
3208
|
throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
|
|
3209
3209
|
}
|
|
3210
3210
|
function signerSetFromInfo(info) {
|
|
@@ -3251,13 +3251,13 @@ var toTimelock = (value) => ({
|
|
|
3251
3251
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
3252
3252
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
3253
3253
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
3254
|
-
throw new
|
|
3254
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3255
3255
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
3256
3256
|
);
|
|
3257
3257
|
}
|
|
3258
3258
|
const seconds = toSeconds(timelock);
|
|
3259
3259
|
if (seconds < policy.minSeconds) {
|
|
3260
|
-
throw new
|
|
3260
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3261
3261
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
3262
3262
|
);
|
|
3263
3263
|
}
|
|
@@ -3278,7 +3278,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
3278
3278
|
}
|
|
3279
3279
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
3280
3280
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
3281
|
-
throw new
|
|
3281
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3282
3282
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
3283
3283
|
);
|
|
3284
3284
|
}
|
|
@@ -3308,21 +3308,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
3308
3308
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
3309
3309
|
let script;
|
|
3310
3310
|
try {
|
|
3311
|
-
script =
|
|
3311
|
+
script = chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
3312
3312
|
} catch (e) {
|
|
3313
|
-
throw new
|
|
3313
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3314
3314
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
3315
3315
|
);
|
|
3316
3316
|
}
|
|
3317
3317
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
3318
3318
|
const { pubkeys } = script.params;
|
|
3319
3319
|
if (pubkeys.length !== 1) {
|
|
3320
|
-
throw new
|
|
3320
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3321
3321
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
3322
3322
|
);
|
|
3323
3323
|
}
|
|
3324
3324
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
3325
|
-
throw new
|
|
3325
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3326
3326
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
3327
3327
|
);
|
|
3328
3328
|
}
|
|
@@ -3366,8 +3366,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
3366
3366
|
function buildVirtualTx(inputs, outputs) {
|
|
3367
3367
|
let lockTime = 0n;
|
|
3368
3368
|
for (const input of inputs) {
|
|
3369
|
-
const tapscript =
|
|
3370
|
-
if (
|
|
3369
|
+
const tapscript = chunkPWIESIO6_cjs.decodeTapscript(chunkPWIESIO6_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
3370
|
+
if (chunkPWIESIO6_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
3371
3371
|
if (lockTime !== 0n) {
|
|
3372
3372
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
3373
3373
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -3378,7 +3378,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3378
3378
|
}
|
|
3379
3379
|
}
|
|
3380
3380
|
}
|
|
3381
|
-
const tx = new
|
|
3381
|
+
const tx = new chunkPWIESIO6_cjs.Transaction({
|
|
3382
3382
|
version: 3,
|
|
3383
3383
|
lockTime: Number(lockTime)
|
|
3384
3384
|
});
|
|
@@ -3388,12 +3388,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3388
3388
|
index: input.vout,
|
|
3389
3389
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3390
3390
|
witnessUtxo: {
|
|
3391
|
-
script:
|
|
3391
|
+
script: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3392
3392
|
amount: BigInt(input.value)
|
|
3393
3393
|
},
|
|
3394
3394
|
tapLeafScript: [input.tapLeafScript]
|
|
3395
3395
|
});
|
|
3396
|
-
|
|
3396
|
+
chunkPWIESIO6_cjs.setArkPsbtField(tx, i, chunkPWIESIO6_cjs.VtxoTaprootTree, input.tapTree);
|
|
3397
3397
|
}
|
|
3398
3398
|
for (const output of outputs) {
|
|
3399
3399
|
tx.addOutput(output);
|
|
@@ -3402,8 +3402,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3402
3402
|
return tx;
|
|
3403
3403
|
}
|
|
3404
3404
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3405
|
-
const collaborativeClosure =
|
|
3406
|
-
const checkpointVtxoScript = new
|
|
3405
|
+
const collaborativeClosure = chunkPWIESIO6_cjs.decodeTapscript(chunkPWIESIO6_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3406
|
+
const checkpointVtxoScript = new chunkPWIESIO6_cjs.VtxoScript([
|
|
3407
3407
|
serverUnrollScript.script,
|
|
3408
3408
|
collaborativeClosure.script
|
|
3409
3409
|
]);
|
|
@@ -3479,7 +3479,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3479
3479
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3480
3480
|
const sig = signature.subarray(0, 64);
|
|
3481
3481
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3482
|
-
const sighashName =
|
|
3482
|
+
const sighashName = chunkPWIESIO6_cjs.formatSighash(sighashType);
|
|
3483
3483
|
throw new Error(
|
|
3484
3484
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3485
3485
|
);
|
|
@@ -3553,7 +3553,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3553
3553
|
}
|
|
3554
3554
|
function isValidArkAddress(address) {
|
|
3555
3555
|
try {
|
|
3556
|
-
|
|
3556
|
+
chunkPWIESIO6_cjs.ArkAddress.decode(address);
|
|
3557
3557
|
return true;
|
|
3558
3558
|
} catch (e) {
|
|
3559
3559
|
return false;
|
|
@@ -3561,16 +3561,16 @@ function isValidArkAddress(address) {
|
|
|
3561
3561
|
}
|
|
3562
3562
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3563
3563
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3564
|
-
throw new
|
|
3564
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3565
3565
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3566
3566
|
);
|
|
3567
3567
|
}
|
|
3568
3568
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3569
3569
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3570
|
-
const server =
|
|
3570
|
+
const server = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3571
3571
|
const local = byTxid.get(server.id);
|
|
3572
3572
|
if (!local) {
|
|
3573
|
-
throw new
|
|
3573
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3574
3574
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3575
3575
|
);
|
|
3576
3576
|
}
|
|
@@ -3580,14 +3580,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3580
3580
|
}
|
|
3581
3581
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3582
3582
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3583
|
-
throw new
|
|
3583
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3584
3584
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3585
3585
|
);
|
|
3586
3586
|
}
|
|
3587
3587
|
if (response.finalArkTx === void 0) return;
|
|
3588
|
-
const finalTxid =
|
|
3588
|
+
const finalTxid = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3589
3589
|
if (finalTxid !== signedArkTx.id) {
|
|
3590
|
-
throw new
|
|
3590
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3591
3591
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3592
3592
|
);
|
|
3593
3593
|
}
|
|
@@ -3599,20 +3599,20 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3599
3599
|
`${context}: input ${inputIndex} carries no spend leaf to verify the server signature against`
|
|
3600
3600
|
);
|
|
3601
3601
|
}
|
|
3602
|
-
const script =
|
|
3602
|
+
const script = chunkPWIESIO6_cjs.scriptFromTapLeafScript(leaf);
|
|
3603
3603
|
let leafPubkeys;
|
|
3604
3604
|
try {
|
|
3605
|
-
leafPubkeys =
|
|
3606
|
-
(key) => base.hex.encode(
|
|
3605
|
+
leafPubkeys = chunkPWIESIO6_cjs.decodeTapscript(script).params.pubkeys.map(
|
|
3606
|
+
(key) => base.hex.encode(chunkY7BVR6SQ_cjs.toXOnly(key, "leaf key"))
|
|
3607
3607
|
);
|
|
3608
3608
|
} catch (error) {
|
|
3609
|
-
throw new
|
|
3609
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3610
3610
|
`${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
|
|
3611
3611
|
);
|
|
3612
3612
|
}
|
|
3613
3613
|
const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
|
|
3614
3614
|
if (!signer) {
|
|
3615
|
-
throw new
|
|
3615
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3616
3616
|
`${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
|
|
3617
3617
|
);
|
|
3618
3618
|
}
|
|
@@ -3626,7 +3626,7 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3626
3626
|
payment_js.tapLeafHash(script)
|
|
3627
3627
|
);
|
|
3628
3628
|
} catch (error) {
|
|
3629
|
-
throw new
|
|
3629
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3630
3630
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3631
3631
|
);
|
|
3632
3632
|
}
|
|
@@ -3635,20 +3635,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3635
3635
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3636
3636
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3637
3637
|
if (checkpoint.inputsLength !== 1) {
|
|
3638
|
-
throw new
|
|
3638
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3639
3639
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3640
3640
|
);
|
|
3641
3641
|
}
|
|
3642
3642
|
const spent = checkpoint.getInput(0);
|
|
3643
3643
|
if (!spent.txid || spent.index === void 0) {
|
|
3644
|
-
throw new
|
|
3644
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3645
3645
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3646
3646
|
);
|
|
3647
3647
|
}
|
|
3648
3648
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3649
3649
|
const input = byOutpoint.get(outpoint);
|
|
3650
3650
|
if (!input) {
|
|
3651
|
-
throw new
|
|
3651
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3652
3652
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3653
3653
|
);
|
|
3654
3654
|
}
|
|
@@ -3656,7 +3656,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3656
3656
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3657
3657
|
);
|
|
3658
3658
|
if (!rebuilt) {
|
|
3659
|
-
throw new
|
|
3659
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3660
3660
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3661
3661
|
);
|
|
3662
3662
|
}
|
|
@@ -3682,9 +3682,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3682
3682
|
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
3683
3683
|
matched.forEach(({ server }, index) => {
|
|
3684
3684
|
try {
|
|
3685
|
-
|
|
3685
|
+
chunkPWIESIO6_cjs.assertAllowedSighashTypes(server);
|
|
3686
3686
|
} catch (error) {
|
|
3687
|
-
throw new
|
|
3687
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3688
3688
|
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
3689
3689
|
);
|
|
3690
3690
|
}
|
|
@@ -3692,14 +3692,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3692
3692
|
const verify = options?.verifyServerSignatures;
|
|
3693
3693
|
if (verify) {
|
|
3694
3694
|
if (response.finalArkTx === void 0) {
|
|
3695
|
-
throw new
|
|
3695
|
+
throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
|
|
3696
3696
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3697
3697
|
);
|
|
3698
3698
|
}
|
|
3699
|
-
const finalArkTx =
|
|
3699
|
+
const finalArkTx = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3700
3700
|
const serverPubkeys = new Set(
|
|
3701
3701
|
[verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
|
|
3702
|
-
(key) => base.hex.encode(
|
|
3702
|
+
(key) => base.hex.encode(chunkY7BVR6SQ_cjs.toXOnly(key, "server key"))
|
|
3703
3703
|
)
|
|
3704
3704
|
);
|
|
3705
3705
|
for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
|
|
@@ -3751,12 +3751,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3751
3751
|
return {
|
|
3752
3752
|
...identity,
|
|
3753
3753
|
sign: async (tx, inputIndexes) => {
|
|
3754
|
-
const signed =
|
|
3754
|
+
const signed = chunkPWIESIO6_cjs.Transaction.fromPSBT(
|
|
3755
3755
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3756
3756
|
);
|
|
3757
3757
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3758
3758
|
for (const index of indexes) {
|
|
3759
|
-
|
|
3759
|
+
chunkPWIESIO6_cjs.setArkPsbtField(signed, index, chunkPWIESIO6_cjs.ConditionWitness, [preimage]);
|
|
3760
3760
|
}
|
|
3761
3761
|
return signed;
|
|
3762
3762
|
}
|
|
@@ -3951,7 +3951,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
3951
3951
|
};
|
|
3952
3952
|
}
|
|
3953
3953
|
function deriveContractTapscripts(contract) {
|
|
3954
|
-
const handler =
|
|
3954
|
+
const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
|
|
3955
3955
|
if (!handler) {
|
|
3956
3956
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3957
3957
|
}
|
|
@@ -4022,7 +4022,7 @@ function getRandomId() {
|
|
|
4022
4022
|
}
|
|
4023
4023
|
function isValidArkAddress2(address) {
|
|
4024
4024
|
try {
|
|
4025
|
-
|
|
4025
|
+
chunkPWIESIO6_cjs.ArkAddress.decode(address);
|
|
4026
4026
|
return true;
|
|
4027
4027
|
} catch (e) {
|
|
4028
4028
|
return false;
|
|
@@ -4050,7 +4050,7 @@ function assertRecipientArkAddress(encoded, address, context) {
|
|
|
4050
4050
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
4051
4051
|
let derived;
|
|
4052
4052
|
try {
|
|
4053
|
-
derived =
|
|
4053
|
+
derived = chunkPWIESIO6_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
4054
4054
|
} catch (e) {
|
|
4055
4055
|
throw new Error(
|
|
4056
4056
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -4067,7 +4067,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4067
4067
|
for (const recipient of recipients) {
|
|
4068
4068
|
let address;
|
|
4069
4069
|
try {
|
|
4070
|
-
address =
|
|
4070
|
+
address = chunkPWIESIO6_cjs.ArkAddress.decode(recipient.address);
|
|
4071
4071
|
} catch (e) {
|
|
4072
4072
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
4073
4073
|
}
|
|
@@ -4092,7 +4092,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4092
4092
|
|
|
4093
4093
|
// src/contracts/spendability.ts
|
|
4094
4094
|
function isContractGenericallySpendable(contract) {
|
|
4095
|
-
return
|
|
4095
|
+
return chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
4096
4096
|
}
|
|
4097
4097
|
function gatedContracts(contracts) {
|
|
4098
4098
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -4114,7 +4114,7 @@ function gateExclusion(gated) {
|
|
|
4114
4114
|
return (vtxo) => {
|
|
4115
4115
|
const type = gatedTypeOf(vtxo, gated);
|
|
4116
4116
|
if (type === void 0) return void 0;
|
|
4117
|
-
if (!
|
|
4117
|
+
if (!chunkY7BVR6SQ_cjs.contractHandlers.has(type)) {
|
|
4118
4118
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
4119
4119
|
}
|
|
4120
4120
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -4150,7 +4150,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
4150
4150
|
continue;
|
|
4151
4151
|
}
|
|
4152
4152
|
for (const v of vtxos) {
|
|
4153
|
-
if (!
|
|
4153
|
+
if (!chunkPWIESIO6_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
|
|
4154
4154
|
out.add(`${v.txid}:${v.vout}`);
|
|
4155
4155
|
}
|
|
4156
4156
|
}
|
|
@@ -4185,10 +4185,10 @@ function byValueDescending(vtxos) {
|
|
|
4185
4185
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
4186
4186
|
}
|
|
4187
4187
|
async function fetchTimeHeight(wallet) {
|
|
4188
|
-
return
|
|
4188
|
+
return chunkPWIESIO6_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
4189
4189
|
}
|
|
4190
4190
|
function canMigrateBySend(vtxo, now) {
|
|
4191
|
-
if (!
|
|
4191
|
+
if (!chunkPWIESIO6_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
4192
4192
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
4193
4193
|
}
|
|
4194
4194
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -4196,7 +4196,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
4196
4196
|
if (vtxo.isSwept) return -Infinity;
|
|
4197
4197
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
4198
4198
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
4199
|
-
return
|
|
4199
|
+
return chunkPWIESIO6_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
4200
4200
|
}
|
|
4201
4201
|
return Infinity;
|
|
4202
4202
|
};
|
|
@@ -4223,7 +4223,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
4223
4223
|
const payable = [];
|
|
4224
4224
|
const net = /* @__PURE__ */ new Map();
|
|
4225
4225
|
for (const vtxo of vtxos) {
|
|
4226
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4226
|
+
const inputFee = estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(vtxo));
|
|
4227
4227
|
if (inputFee.satoshis >= vtxo.value) {
|
|
4228
4228
|
continue;
|
|
4229
4229
|
}
|
|
@@ -4249,7 +4249,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
4249
4249
|
}
|
|
4250
4250
|
const outputFee = estimator.evalOffchainOutput({
|
|
4251
4251
|
amount: subtotal,
|
|
4252
|
-
script: base.hex.encode(
|
|
4252
|
+
script: base.hex.encode(chunkPWIESIO6_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4253
4253
|
});
|
|
4254
4254
|
return subtotal - BigInt(outputFee.satoshis);
|
|
4255
4255
|
}
|
|
@@ -4267,10 +4267,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
4267
4267
|
};
|
|
4268
4268
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
4269
4269
|
return vtxos.filter((vtxo) => {
|
|
4270
|
-
if (
|
|
4270
|
+
if (chunkPWIESIO6_cjs.canRecoverOnchain(vtxo, now)) {
|
|
4271
4271
|
return true;
|
|
4272
4272
|
}
|
|
4273
|
-
if (
|
|
4273
|
+
if (chunkPWIESIO6_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
4274
4274
|
return true;
|
|
4275
4275
|
}
|
|
4276
4276
|
return false;
|
|
@@ -4302,7 +4302,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
4302
4302
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
4303
4303
|
if (vtxo.isUnrolled) return false;
|
|
4304
4304
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
4305
|
-
const expiresAt =
|
|
4305
|
+
const expiresAt = chunkPWIESIO6_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
4306
4306
|
if (expiresAt === void 0) return false;
|
|
4307
4307
|
const now = Date.now();
|
|
4308
4308
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -4313,7 +4313,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
4313
4313
|
return vtxos.filter(
|
|
4314
4314
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
4315
4315
|
// property and would otherwise re-admit an exited coin on its own.
|
|
4316
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
4316
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkPWIESIO6_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
4317
4317
|
);
|
|
4318
4318
|
}
|
|
4319
4319
|
function isMigrationCapable(wallet) {
|
|
@@ -4915,11 +4915,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
4915
4915
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
4916
4916
|
);
|
|
4917
4917
|
}
|
|
4918
|
-
const tx = new
|
|
4918
|
+
const tx = new chunkPWIESIO6_cjs.Transaction();
|
|
4919
4919
|
for (const utxo of expiredUtxos) {
|
|
4920
|
-
const utxoScript =
|
|
4920
|
+
const utxoScript = chunkPWIESIO6_cjs.VtxoScript.decode(utxo.tapTree);
|
|
4921
4921
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
4922
|
-
(leaf) =>
|
|
4922
|
+
(leaf) => chunkPWIESIO6_cjs.CSVMultisigTapscript.isScriptValid(chunkPWIESIO6_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
4923
4923
|
);
|
|
4924
4924
|
if (!utxoExitLeaf) {
|
|
4925
4925
|
throw new Error(
|
|
@@ -4934,7 +4934,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4934
4934
|
amount: BigInt(utxo.value)
|
|
4935
4935
|
},
|
|
4936
4936
|
tapLeafScript: [utxoExitLeaf],
|
|
4937
|
-
sequence:
|
|
4937
|
+
sequence: chunkPWIESIO6_cjs.getSequence(utxoExitLeaf)
|
|
4938
4938
|
});
|
|
4939
4939
|
}
|
|
4940
4940
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -5177,8 +5177,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5177
5177
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
5178
5178
|
if (cls.status === "CURRENT") continue;
|
|
5179
5179
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
5180
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
5181
|
-
const spendable = live.filter((v) => !
|
|
5180
|
+
const recoverable = live.filter((v) => v.isSwept && !chunkPWIESIO6_cjs.isVtxoSpent(v));
|
|
5181
|
+
const spendable = live.filter((v) => !chunkPWIESIO6_cjs.isVtxoSpent(v) && !v.isSwept);
|
|
5182
5182
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
5183
5183
|
let recoverableCount = 0;
|
|
5184
5184
|
let recoverableValue = 0;
|
|
@@ -5191,7 +5191,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5191
5191
|
awaitingSweepCount = spendable.length;
|
|
5192
5192
|
awaitingSweepValue = value;
|
|
5193
5193
|
for (const v of spendable) {
|
|
5194
|
-
const exp =
|
|
5194
|
+
const exp = chunkPWIESIO6_cjs.toBatchExpiry(v);
|
|
5195
5195
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
5196
5196
|
nextSweepEta = exp;
|
|
5197
5197
|
}
|
|
@@ -5452,7 +5452,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5452
5452
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
5453
5453
|
getBoardingTimelock() {
|
|
5454
5454
|
const wallet = this.getSweepWallet();
|
|
5455
|
-
const exitScript =
|
|
5455
|
+
const exitScript = chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(
|
|
5456
5456
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5457
5457
|
);
|
|
5458
5458
|
return exitScript.params.timelock;
|
|
@@ -5583,8 +5583,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5583
5583
|
* or doesn't carry the metadata.
|
|
5584
5584
|
*/
|
|
5585
5585
|
extractSpentOutpoint(error) {
|
|
5586
|
-
const ark =
|
|
5587
|
-
if (!
|
|
5586
|
+
const ark = chunkPWIESIO6_cjs.maybeArkError(error);
|
|
5587
|
+
if (!chunkPWIESIO6_cjs.isArkError(ark, chunkPWIESIO6_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5588
5588
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5589
5589
|
if (typeof raw !== "string") return void 0;
|
|
5590
5590
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -5774,7 +5774,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5774
5774
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
5775
5775
|
break;
|
|
5776
5776
|
}
|
|
5777
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5777
|
+
const inputFee = estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(v));
|
|
5778
5778
|
if (inputFee.satoshis >= v.value) {
|
|
5779
5779
|
continue;
|
|
5780
5780
|
}
|
|
@@ -5794,7 +5794,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5794
5794
|
const arkAddress = await this.wallet.getAddress();
|
|
5795
5795
|
const outputFee = estimator.evalOffchainOutput({
|
|
5796
5796
|
amount: totalAmount,
|
|
5797
|
-
script: base.hex.encode(
|
|
5797
|
+
script: base.hex.encode(chunkPWIESIO6_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
5798
5798
|
});
|
|
5799
5799
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
5800
5800
|
if (totalAmount < dustAmount) return;
|
|
@@ -5874,7 +5874,7 @@ var ArkNote = class _ArkNote {
|
|
|
5874
5874
|
this.value = value;
|
|
5875
5875
|
this.HRP = HRP;
|
|
5876
5876
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
5877
|
-
this.vtxoScript = new
|
|
5877
|
+
this.vtxoScript = new chunkPWIESIO6_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
5878
5878
|
const leaf = this.vtxoScript.leaves[0];
|
|
5879
5879
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
5880
5880
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -5979,8 +5979,8 @@ function noteTapscript(preimageHash) {
|
|
|
5979
5979
|
return btcSigner.Script.encode(["SHA256", preimageHash, "EQUAL"]);
|
|
5980
5980
|
}
|
|
5981
5981
|
var ArkadeCash = class _ArkadeCash {
|
|
5982
|
-
constructor(privateKey, serverPubKey,
|
|
5983
|
-
this.csvTimelock =
|
|
5982
|
+
constructor(privateKey, serverPubKey, csvTimelock2, hrp = _ArkadeCash.DefaultHRP) {
|
|
5983
|
+
this.csvTimelock = csvTimelock2;
|
|
5984
5984
|
this.hrp = hrp;
|
|
5985
5985
|
if (privateKey.length !== 32) {
|
|
5986
5986
|
throw new Error(
|
|
@@ -6020,8 +6020,8 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6020
6020
|
get publicKey() {
|
|
6021
6021
|
return this._publicKey.slice();
|
|
6022
6022
|
}
|
|
6023
|
-
static generate(serverPubKey,
|
|
6024
|
-
return new _ArkadeCash(utils_js.randomPrivateKeyBytes(), serverPubKey,
|
|
6023
|
+
static generate(serverPubKey, csvTimelock2, hrp) {
|
|
6024
|
+
return new _ArkadeCash(utils_js.randomPrivateKeyBytes(), serverPubKey, csvTimelock2, hrp);
|
|
6025
6025
|
}
|
|
6026
6026
|
static fromString(encoded) {
|
|
6027
6027
|
const decoded = base.bech32m.decodeUnsafe(encoded.trim().toLowerCase(), 1023);
|
|
@@ -6041,15 +6041,15 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6041
6041
|
const privateKey = data.slice(1, 33);
|
|
6042
6042
|
const serverPubKey = data.slice(33, 65);
|
|
6043
6043
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
6044
|
-
const
|
|
6045
|
-
return new _ArkadeCash(privateKey, serverPubKey,
|
|
6044
|
+
const csvTimelock2 = chunkPWIESIO6_cjs.sequenceToTimelock(sequence);
|
|
6045
|
+
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock2, decoded.prefix);
|
|
6046
6046
|
}
|
|
6047
6047
|
toString() {
|
|
6048
6048
|
const data = new Uint8Array(_ArkadeCash.PayloadLength);
|
|
6049
6049
|
data[0] = _ArkadeCash.Version;
|
|
6050
6050
|
data.set(this._privateKey, 1);
|
|
6051
6051
|
data.set(this._serverPubKey, 33);
|
|
6052
|
-
const sequence =
|
|
6052
|
+
const sequence = chunkPWIESIO6_cjs.timelockToSequence(this.csvTimelock);
|
|
6053
6053
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
6054
6054
|
const words = base.bech32m.toWords(data);
|
|
6055
6055
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -6058,7 +6058,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6058
6058
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
6059
6059
|
}
|
|
6060
6060
|
get vtxoScript() {
|
|
6061
|
-
return new
|
|
6061
|
+
return new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
|
|
6062
6062
|
pubKey: this._publicKey,
|
|
6063
6063
|
serverPubKey: this._serverPubKey,
|
|
6064
6064
|
csvTimelock: this.csvTimelock
|
|
@@ -6319,7 +6319,7 @@ async function captureExitBranch(params) {
|
|
|
6319
6319
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
6320
6320
|
if (nonCommitment.length > 0) {
|
|
6321
6321
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
6322
|
-
psbtByTxid.set(
|
|
6322
|
+
psbtByTxid.set(chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6323
6323
|
}
|
|
6324
6324
|
}
|
|
6325
6325
|
}
|
|
@@ -6362,10 +6362,10 @@ var IndexerExitDataSource = class {
|
|
|
6362
6362
|
while (hasMore) {
|
|
6363
6363
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
6364
6364
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
6365
|
-
{ pageIndex, pageSize:
|
|
6365
|
+
{ pageIndex, pageSize: chunkPWIESIO6_cjs.DEFAULT_PAGE_SIZE }
|
|
6366
6366
|
);
|
|
6367
6367
|
chain.push(...page);
|
|
6368
|
-
hasMore = meta ? page.length ===
|
|
6368
|
+
hasMore = meta ? page.length === chunkPWIESIO6_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6369
6369
|
pageIndex++;
|
|
6370
6370
|
}
|
|
6371
6371
|
return chain;
|
|
@@ -6377,12 +6377,12 @@ var IndexerExitDataSource = class {
|
|
|
6377
6377
|
while (hasMore) {
|
|
6378
6378
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
6379
6379
|
pageIndex,
|
|
6380
|
-
pageSize:
|
|
6380
|
+
pageSize: chunkPWIESIO6_cjs.DEFAULT_PAGE_SIZE
|
|
6381
6381
|
});
|
|
6382
6382
|
for (const psbt of txs) {
|
|
6383
|
-
out.set(
|
|
6383
|
+
out.set(chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6384
6384
|
}
|
|
6385
|
-
hasMore = page ? txs.length ===
|
|
6385
|
+
hasMore = page ? txs.length === chunkPWIESIO6_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6386
6386
|
pageIndex++;
|
|
6387
6387
|
}
|
|
6388
6388
|
return out;
|
|
@@ -6403,7 +6403,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
6403
6403
|
}
|
|
6404
6404
|
}
|
|
6405
6405
|
function psbtInputTxids(psbtBase64) {
|
|
6406
|
-
const tx =
|
|
6406
|
+
const tx = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
6407
6407
|
const ids = [];
|
|
6408
6408
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
6409
6409
|
const txid = tx.getInput(i).txid;
|
|
@@ -6762,10 +6762,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
6762
6762
|
try {
|
|
6763
6763
|
info = await arkProvider.getInfo();
|
|
6764
6764
|
} catch (err) {
|
|
6765
|
-
if (!
|
|
6765
|
+
if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
|
|
6766
6766
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
6767
6767
|
if (!snapshot) {
|
|
6768
|
-
throw new
|
|
6768
|
+
throw new chunkPWIESIO6_cjs.ProviderUnavailableError(
|
|
6769
6769
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
6770
6770
|
{ cause: err }
|
|
6771
6771
|
);
|
|
@@ -7172,7 +7172,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
|
|
|
7172
7172
|
return [...txids];
|
|
7173
7173
|
}
|
|
7174
7174
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
|
|
7175
|
-
const normalized = vtxos.map(
|
|
7175
|
+
const normalized = vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
7176
7176
|
const localCreatedAt = localCreatedAtByTxid(normalized);
|
|
7177
7177
|
const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
|
|
7178
7178
|
const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
|
|
@@ -7347,7 +7347,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7347
7347
|
withRecoverable: false,
|
|
7348
7348
|
genericallySpendableOnly: true
|
|
7349
7349
|
});
|
|
7350
|
-
const controlAssetRef = params.controlAssetId ?
|
|
7350
|
+
const controlAssetRef = params.controlAssetId ? chunkIAM5IEVT_cjs.AssetRef.fromId(chunkIAM5IEVT_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
7351
7351
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
7352
7352
|
let totalBtcSelected = 0n;
|
|
7353
7353
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -7360,8 +7360,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7360
7360
|
}
|
|
7361
7361
|
}
|
|
7362
7362
|
const groups = [];
|
|
7363
|
-
const issuedAssetOutput =
|
|
7364
|
-
const issuedAssetGroup =
|
|
7363
|
+
const issuedAssetOutput = chunkIAM5IEVT_cjs.AssetOutput.create(0, params.amount);
|
|
7364
|
+
const issuedAssetGroup = chunkIAM5IEVT_cjs.AssetGroup.create(
|
|
7365
7365
|
null,
|
|
7366
7366
|
controlAssetRef,
|
|
7367
7367
|
[],
|
|
@@ -7376,28 +7376,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7376
7376
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7377
7377
|
for (const asset of assets) {
|
|
7378
7378
|
if (asset.assetId !== assetId) continue;
|
|
7379
|
-
changeInputs.push(
|
|
7379
|
+
changeInputs.push(chunkIAM5IEVT_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7380
7380
|
}
|
|
7381
7381
|
}
|
|
7382
7382
|
groups.push(
|
|
7383
|
-
|
|
7384
|
-
|
|
7383
|
+
chunkIAM5IEVT_cjs.AssetGroup.create(
|
|
7384
|
+
chunkIAM5IEVT_cjs.AssetId.fromString(assetId),
|
|
7385
7385
|
null,
|
|
7386
7386
|
changeInputs,
|
|
7387
|
-
[
|
|
7387
|
+
[chunkIAM5IEVT_cjs.AssetOutput.create(0, amount)],
|
|
7388
7388
|
[]
|
|
7389
7389
|
)
|
|
7390
7390
|
);
|
|
7391
7391
|
}
|
|
7392
7392
|
}
|
|
7393
7393
|
const address = await this.wallet.getAddress();
|
|
7394
|
-
const outputAddress =
|
|
7394
|
+
const outputAddress = chunkPWIESIO6_cjs.ArkAddress.decode(address);
|
|
7395
7395
|
const outputs = [
|
|
7396
7396
|
{
|
|
7397
7397
|
script: outputAddress.pkScript,
|
|
7398
7398
|
amount: BigInt(totalBtcSelected)
|
|
7399
7399
|
},
|
|
7400
|
-
Extension.create([
|
|
7400
|
+
Extension.create([chunkIAM5IEVT_cjs.Packet.create(groups)]).txOut()
|
|
7401
7401
|
];
|
|
7402
7402
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
7403
7403
|
coinSelection.inputs,
|
|
@@ -7405,7 +7405,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7405
7405
|
);
|
|
7406
7406
|
return {
|
|
7407
7407
|
arkTxId: arkTxid,
|
|
7408
|
-
assetId:
|
|
7408
|
+
assetId: chunkIAM5IEVT_cjs.AssetId.create(arkTxid, 0).toString()
|
|
7409
7409
|
};
|
|
7410
7410
|
}
|
|
7411
7411
|
/**
|
|
@@ -7478,16 +7478,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7478
7478
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7479
7479
|
for (const asset of assets) {
|
|
7480
7480
|
if (asset.assetId !== params.assetId) continue;
|
|
7481
|
-
reissueInputs.push(
|
|
7481
|
+
reissueInputs.push(chunkIAM5IEVT_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7482
7482
|
}
|
|
7483
7483
|
}
|
|
7484
7484
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7485
|
-
const reissueAssetIdObj =
|
|
7486
|
-
const reissueAssetGroup =
|
|
7485
|
+
const reissueAssetIdObj = chunkIAM5IEVT_cjs.AssetId.fromString(params.assetId);
|
|
7486
|
+
const reissueAssetGroup = chunkIAM5IEVT_cjs.AssetGroup.create(
|
|
7487
7487
|
reissueAssetIdObj,
|
|
7488
7488
|
null,
|
|
7489
7489
|
reissueInputs,
|
|
7490
|
-
[
|
|
7490
|
+
[chunkIAM5IEVT_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7491
7491
|
[]
|
|
7492
7492
|
);
|
|
7493
7493
|
const groups = [reissueAssetGroup];
|
|
@@ -7496,27 +7496,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7496
7496
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7497
7497
|
for (const asset of assets) {
|
|
7498
7498
|
if (asset.assetId !== assetId) continue;
|
|
7499
|
-
changeInputs.push(
|
|
7499
|
+
changeInputs.push(chunkIAM5IEVT_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7500
7500
|
}
|
|
7501
7501
|
}
|
|
7502
7502
|
groups.push(
|
|
7503
|
-
|
|
7504
|
-
|
|
7503
|
+
chunkIAM5IEVT_cjs.AssetGroup.create(
|
|
7504
|
+
chunkIAM5IEVT_cjs.AssetId.fromString(assetId),
|
|
7505
7505
|
null,
|
|
7506
7506
|
changeInputs,
|
|
7507
|
-
[
|
|
7507
|
+
[chunkIAM5IEVT_cjs.AssetOutput.create(0, amount)],
|
|
7508
7508
|
[]
|
|
7509
7509
|
)
|
|
7510
7510
|
);
|
|
7511
7511
|
}
|
|
7512
7512
|
const address = await this.wallet.getAddress();
|
|
7513
|
-
const outputAddress =
|
|
7513
|
+
const outputAddress = chunkPWIESIO6_cjs.ArkAddress.decode(address);
|
|
7514
7514
|
const outputs = [
|
|
7515
7515
|
{
|
|
7516
7516
|
script: outputAddress.pkScript,
|
|
7517
7517
|
amount: BigInt(totalBtcSelected)
|
|
7518
7518
|
},
|
|
7519
|
-
Extension.create([
|
|
7519
|
+
Extension.create([chunkIAM5IEVT_cjs.Packet.create(groups)]).txOut()
|
|
7520
7520
|
];
|
|
7521
7521
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7522
7522
|
return arkTxid;
|
|
@@ -7584,27 +7584,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7584
7584
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7585
7585
|
for (const asset of assets) {
|
|
7586
7586
|
if (asset.assetId !== assetId) continue;
|
|
7587
|
-
changeInputs.push(
|
|
7587
|
+
changeInputs.push(chunkIAM5IEVT_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7588
7588
|
}
|
|
7589
7589
|
}
|
|
7590
7590
|
groups.push(
|
|
7591
|
-
|
|
7592
|
-
|
|
7591
|
+
chunkIAM5IEVT_cjs.AssetGroup.create(
|
|
7592
|
+
chunkIAM5IEVT_cjs.AssetId.fromString(assetId),
|
|
7593
7593
|
null,
|
|
7594
7594
|
changeInputs,
|
|
7595
|
-
amount > 0n ? [
|
|
7595
|
+
amount > 0n ? [chunkIAM5IEVT_cjs.AssetOutput.create(0, amount)] : [],
|
|
7596
7596
|
[]
|
|
7597
7597
|
)
|
|
7598
7598
|
);
|
|
7599
7599
|
}
|
|
7600
7600
|
const address = await this.wallet.getAddress();
|
|
7601
|
-
const outputAddress =
|
|
7601
|
+
const outputAddress = chunkPWIESIO6_cjs.ArkAddress.decode(address);
|
|
7602
7602
|
const outputs = [
|
|
7603
7603
|
{
|
|
7604
7604
|
script: outputAddress.pkScript,
|
|
7605
7605
|
amount: BigInt(totalBtcSelected)
|
|
7606
7606
|
},
|
|
7607
|
-
Extension.create([
|
|
7607
|
+
Extension.create([chunkIAM5IEVT_cjs.Packet.create(groups)]).txOut()
|
|
7608
7608
|
];
|
|
7609
7609
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7610
7610
|
return arkTxid;
|
|
@@ -7629,7 +7629,7 @@ function castMetadata(metadata) {
|
|
|
7629
7629
|
} else {
|
|
7630
7630
|
throw new Error("Invalid metadata value type");
|
|
7631
7631
|
}
|
|
7632
|
-
md.push(
|
|
7632
|
+
md.push(chunkIAM5IEVT_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7633
7633
|
}
|
|
7634
7634
|
return md;
|
|
7635
7635
|
}
|
|
@@ -7650,10 +7650,10 @@ var DelegateManagerImpl = class {
|
|
|
7650
7650
|
if (vtxos.length === 0) {
|
|
7651
7651
|
return { delegated: [], failed: [] };
|
|
7652
7652
|
}
|
|
7653
|
-
const destinationScript =
|
|
7653
|
+
const destinationScript = chunkPWIESIO6_cjs.ArkAddress.decode(destination).pkScript;
|
|
7654
7654
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
7655
7655
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
7656
|
-
const eligible = vtxos.map(
|
|
7656
|
+
const eligible = vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo).filter(
|
|
7657
7657
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7658
7658
|
);
|
|
7659
7659
|
if (eligible.length === 0) {
|
|
@@ -7682,11 +7682,11 @@ var DelegateManagerImpl = class {
|
|
|
7682
7682
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7683
7683
|
let recoverableVtxos = [];
|
|
7684
7684
|
for (const vtxo of eligible) {
|
|
7685
|
-
if (
|
|
7685
|
+
if (chunkPWIESIO6_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7686
7686
|
recoverableVtxos.push(vtxo);
|
|
7687
7687
|
continue;
|
|
7688
7688
|
}
|
|
7689
|
-
const expiry =
|
|
7689
|
+
const expiry = chunkPWIESIO6_cjs.toBatchExpiry(vtxo);
|
|
7690
7690
|
if (!expiry) continue;
|
|
7691
7691
|
const dayKey = getDayTimestamp(expiry);
|
|
7692
7692
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -7751,7 +7751,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7751
7751
|
}
|
|
7752
7752
|
if (!delegateAt) {
|
|
7753
7753
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7754
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7754
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkPWIESIO6_cjs.canRecoverOnchain(coin, now) && chunkPWIESIO6_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkPWIESIO6_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
7755
7755
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
7756
7756
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
7757
7757
|
} else {
|
|
@@ -7775,7 +7775,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7775
7775
|
let amount = 0n;
|
|
7776
7776
|
for (const coin of vtxos) {
|
|
7777
7777
|
const inputFee = estimator.evalOffchainInput({
|
|
7778
|
-
...
|
|
7778
|
+
...chunkPWIESIO6_cjs.toOffchainInputFeeParams(coin),
|
|
7779
7779
|
type: "vtxo"
|
|
7780
7780
|
});
|
|
7781
7781
|
if (inputFee.value >= coin.value) {
|
|
@@ -7789,7 +7789,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7789
7789
|
const delegateFee = BigInt(Number(fee));
|
|
7790
7790
|
if (delegateFee > 0n) {
|
|
7791
7791
|
outputs.push({
|
|
7792
|
-
script:
|
|
7792
|
+
script: chunkPWIESIO6_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
7793
7793
|
amount: delegateFee
|
|
7794
7794
|
});
|
|
7795
7795
|
}
|
|
@@ -7822,10 +7822,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7822
7822
|
destinationScript
|
|
7823
7823
|
);
|
|
7824
7824
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
7825
|
-
btcSigner.Address(
|
|
7825
|
+
btcSigner.Address(chunkPWIESIO6_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
7826
7826
|
);
|
|
7827
7827
|
const forfeits = await Promise.all(
|
|
7828
|
-
vtxos.filter((v) =>
|
|
7828
|
+
vtxos.filter((v) => chunkPWIESIO6_cjs.requiresForfeit(v)).map(async (coin) => {
|
|
7829
7829
|
const forfeit = await makeDelegateForfeitTx(
|
|
7830
7830
|
coin,
|
|
7831
7831
|
dust,
|
|
@@ -7850,7 +7850,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
7850
7850
|
index: input.vout,
|
|
7851
7851
|
witnessUtxo: {
|
|
7852
7852
|
amount: BigInt(input.value),
|
|
7853
|
-
script:
|
|
7853
|
+
script: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
7854
7854
|
},
|
|
7855
7855
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
7856
7856
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -7908,7 +7908,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
7908
7908
|
expire_at: 0,
|
|
7909
7909
|
cosigners_public_keys: cosignerPubKeys
|
|
7910
7910
|
};
|
|
7911
|
-
const proof =
|
|
7911
|
+
const proof = chunkPWIESIO6_cjs.Intent.create(message, coins, outputs);
|
|
7912
7912
|
const signedProof = await identity.sign(proof);
|
|
7913
7913
|
return {
|
|
7914
7914
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -7934,10 +7934,10 @@ function getDayTimestamp(timestamp) {
|
|
|
7934
7934
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
7935
7935
|
if (!vtxo.tapTree) return void 0;
|
|
7936
7936
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
7937
|
-
const vtxoScript =
|
|
7937
|
+
const vtxoScript = chunkPWIESIO6_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
7938
7938
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
7939
|
-
const arkTapscript =
|
|
7940
|
-
if (!
|
|
7939
|
+
const arkTapscript = chunkPWIESIO6_cjs.decodeTapscript(chunkPWIESIO6_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
7940
|
+
if (!chunkPWIESIO6_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
7941
7941
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
7942
7942
|
});
|
|
7943
7943
|
}
|
|
@@ -8218,7 +8218,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
|
|
|
8218
8218
|
};
|
|
8219
8219
|
}
|
|
8220
8220
|
function scriptFromArkAddress(address) {
|
|
8221
|
-
return base.hex.encode(
|
|
8221
|
+
return base.hex.encode(chunkPWIESIO6_cjs.ArkAddress.decode(address).pkScript);
|
|
8222
8222
|
}
|
|
8223
8223
|
|
|
8224
8224
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -8388,7 +8388,7 @@ function initDatabase(db, oldVersion, transaction) {
|
|
|
8388
8388
|
backfillVtxoIndexFields(transaction);
|
|
8389
8389
|
}
|
|
8390
8390
|
}
|
|
8391
|
-
var unspentFlag = (vtxo) =>
|
|
8391
|
+
var unspentFlag = (vtxo) => chunkPWIESIO6_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
|
|
8392
8392
|
function initDatabaseWithIntents(db, oldVersion, transaction) {
|
|
8393
8393
|
initDatabase(db, oldVersion, transaction);
|
|
8394
8394
|
if (!db.objectStoreNames.contains(STORE_INTENTS)) {
|
|
@@ -8725,9 +8725,10 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
8725
8725
|
`${context}: refusing to persist ${mismatches.length} VTXO(s) whose script does not match ${script}: ${detail}`
|
|
8726
8726
|
);
|
|
8727
8727
|
}
|
|
8728
|
-
async function getVtxosForContract(repo, contract) {
|
|
8729
|
-
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
8730
|
-
|
|
8728
|
+
async function getVtxosForContract(repo, contract, options) {
|
|
8729
|
+
const vtxos = options?.unspentOnly && repo.getVtxosForScripts ? await repo.getVtxosForScripts([contract.script], options) : repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
8730
|
+
const normalized = vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo);
|
|
8731
|
+
return options?.unspentOnly ? normalized.filter((vtxo) => !chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) : normalized;
|
|
8731
8732
|
}
|
|
8732
8733
|
function hasRecordedSpend(vtxo) {
|
|
8733
8734
|
return vtxo.isSpent === true && (!!vtxo.spentBy || !!vtxo.arkTxId || !!vtxo.settledBy);
|
|
@@ -8832,7 +8833,7 @@ var InMemoryWalletRepository = class {
|
|
|
8832
8833
|
}
|
|
8833
8834
|
}
|
|
8834
8835
|
const rows = [...byOutpoint.values()];
|
|
8835
|
-
return options?.unspentOnly ? rows.filter((vtxo) => !
|
|
8836
|
+
return options?.unspentOnly ? rows.filter((vtxo) => !chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) : rows;
|
|
8836
8837
|
}
|
|
8837
8838
|
async saveVtxosForScript(key, vtxos) {
|
|
8838
8839
|
if (!key.address) {
|
|
@@ -8934,7 +8935,7 @@ function decodeArkContract(encoded) {
|
|
|
8934
8935
|
}
|
|
8935
8936
|
function contractFromArkContract(encoded, options = {}) {
|
|
8936
8937
|
const parsed = decodeArkContract(encoded);
|
|
8937
|
-
const handler =
|
|
8938
|
+
const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(parsed.type);
|
|
8938
8939
|
if (!handler) {
|
|
8939
8940
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8940
8941
|
}
|
|
@@ -8948,9 +8949,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8948
8949
|
metadata: options.metadata
|
|
8949
8950
|
};
|
|
8950
8951
|
}
|
|
8951
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8952
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkPWIESIO6_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8952
8953
|
const parsed = decodeArkContract(encoded);
|
|
8953
|
-
const handler =
|
|
8954
|
+
const handler = chunkY7BVR6SQ_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8954
8955
|
const params = parsed.data;
|
|
8955
8956
|
const vtxoScript = handler.createScript(params);
|
|
8956
8957
|
return {
|
|
@@ -9256,9 +9257,9 @@ var ContractWatcher = class {
|
|
|
9256
9257
|
this.connectionState = "connected";
|
|
9257
9258
|
this.reconnectAttempts = 0;
|
|
9258
9259
|
this.listenLoop().catch((e) => {
|
|
9259
|
-
if (
|
|
9260
|
+
if (chunkPWIESIO6_cjs.isEventSourceError(e)) {
|
|
9260
9261
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
9261
|
-
} else if (!
|
|
9262
|
+
} else if (!chunkPWIESIO6_cjs.isEventSourceUnavailableError(e)) {
|
|
9262
9263
|
console.error(e);
|
|
9263
9264
|
}
|
|
9264
9265
|
this.connectionState = "disconnected";
|
|
@@ -9270,7 +9271,7 @@ var ContractWatcher = class {
|
|
|
9270
9271
|
this.scheduleReconnect();
|
|
9271
9272
|
});
|
|
9272
9273
|
} catch (error) {
|
|
9273
|
-
if (!
|
|
9274
|
+
if (!chunkPWIESIO6_cjs.isEventSourceUnavailableError(error)) {
|
|
9274
9275
|
console.error("ContractWatcher connection failed:", error);
|
|
9275
9276
|
}
|
|
9276
9277
|
this.connectionState = "disconnected";
|
|
@@ -9296,7 +9297,7 @@ var ContractWatcher = class {
|
|
|
9296
9297
|
* slower; what it loses is push latency.
|
|
9297
9298
|
*/
|
|
9298
9299
|
reportEventSourceUnavailable(error) {
|
|
9299
|
-
if (!
|
|
9300
|
+
if (!chunkPWIESIO6_cjs.isEventSourceUnavailableError(error)) return false;
|
|
9300
9301
|
if (!this.eventSourceReported) {
|
|
9301
9302
|
this.eventSourceReported = true;
|
|
9302
9303
|
console.warn(
|
|
@@ -9368,7 +9369,7 @@ var ContractWatcher = class {
|
|
|
9368
9369
|
const now = Date.now();
|
|
9369
9370
|
let current;
|
|
9370
9371
|
try {
|
|
9371
|
-
current = await
|
|
9372
|
+
current = await chunkPWIESIO6_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
|
|
9372
9373
|
spendableOnly: true
|
|
9373
9374
|
});
|
|
9374
9375
|
} catch (error) {
|
|
@@ -9577,14 +9578,14 @@ var ContractWatcher = class {
|
|
|
9577
9578
|
const timestamp = Date.now();
|
|
9578
9579
|
if (update.newVtxos?.length) {
|
|
9579
9580
|
this.processSubscriptionVtxos(
|
|
9580
|
-
update.newVtxos.map(
|
|
9581
|
+
update.newVtxos.map(chunkPWIESIO6_cjs.normalizeVtxo),
|
|
9581
9582
|
"vtxo_received",
|
|
9582
9583
|
timestamp
|
|
9583
9584
|
);
|
|
9584
9585
|
}
|
|
9585
9586
|
if (update.spentVtxos?.length) {
|
|
9586
9587
|
this.processSubscriptionVtxos(
|
|
9587
|
-
update.spentVtxos.map(
|
|
9588
|
+
update.spentVtxos.map(chunkPWIESIO6_cjs.normalizeVtxo),
|
|
9588
9589
|
"vtxo_spent",
|
|
9589
9590
|
timestamp
|
|
9590
9591
|
);
|
|
@@ -9612,8 +9613,8 @@ var ContractWatcher = class {
|
|
|
9612
9613
|
continue;
|
|
9613
9614
|
}
|
|
9614
9615
|
if (target === byWatchedScript && eventType === "vtxo_received") {
|
|
9615
|
-
const n =
|
|
9616
|
-
if (
|
|
9616
|
+
const n = chunkPWIESIO6_cjs.normalizeVtxo(vtxo);
|
|
9617
|
+
if (chunkPWIESIO6_cjs.isVtxoSpent(n) || n.isSwept || chunkPWIESIO6_cjs.isPastExpiry(n, now)) continue;
|
|
9617
9618
|
}
|
|
9618
9619
|
let bucket = target.get(vtxo.script);
|
|
9619
9620
|
if (!bucket) {
|
|
@@ -9712,7 +9713,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
|
|
|
9712
9713
|
(s) => !isTerminalIntentState(s)
|
|
9713
9714
|
);
|
|
9714
9715
|
function isConsumed(vtxo) {
|
|
9715
|
-
return vtxo !== void 0 &&
|
|
9716
|
+
return vtxo !== void 0 && chunkPWIESIO6_cjs.isVtxoSpent(vtxo);
|
|
9716
9717
|
}
|
|
9717
9718
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
9718
9719
|
if (isTerminalIntentState(intent.state)) return void 0;
|
|
@@ -9755,7 +9756,7 @@ async function reconcileIntents(deps) {
|
|
|
9755
9756
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
9756
9757
|
if (outpoints.length > 0) {
|
|
9757
9758
|
try {
|
|
9758
|
-
const { vtxos } = await
|
|
9759
|
+
const { vtxos } = await chunkPWIESIO6_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
9759
9760
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
9760
9761
|
} catch (e) {
|
|
9761
9762
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9812,7 +9813,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
9812
9813
|
if (!contract) continue;
|
|
9813
9814
|
try {
|
|
9814
9815
|
const key = `${contract.type}\0${script}\0${JSON.stringify(contract.params)}`;
|
|
9815
|
-
const handler =
|
|
9816
|
+
const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
|
|
9816
9817
|
const hit = memo?.get(script);
|
|
9817
9818
|
let tapscripts;
|
|
9818
9819
|
if (hit && hit.key === key && hit.handler === handler) {
|
|
@@ -9967,7 +9968,7 @@ var ContractManager = class _ContractManager {
|
|
|
9967
9968
|
try {
|
|
9968
9969
|
await this.scheduleLookAheadDrain();
|
|
9969
9970
|
} catch (err) {
|
|
9970
|
-
if (!
|
|
9971
|
+
if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
|
|
9971
9972
|
this.lookAheadRefillOwed = true;
|
|
9972
9973
|
this.markSyncDegraded(err);
|
|
9973
9974
|
}
|
|
@@ -9975,7 +9976,7 @@ var ContractManager = class _ContractManager {
|
|
|
9975
9976
|
await this.reconcileWatched();
|
|
9976
9977
|
this.markSyncOnline();
|
|
9977
9978
|
} catch (err) {
|
|
9978
|
-
if (!
|
|
9979
|
+
if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
|
|
9979
9980
|
this.markSyncDegraded(err);
|
|
9980
9981
|
}
|
|
9981
9982
|
this.initialized = true;
|
|
@@ -10107,7 +10108,7 @@ var ContractManager = class _ContractManager {
|
|
|
10107
10108
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
10108
10109
|
const to = watermark + lookAhead.size;
|
|
10109
10110
|
const deps = lookAhead.candidateDeps();
|
|
10110
|
-
const handlers =
|
|
10111
|
+
const handlers = chunkY7BVR6SQ_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkY7BVR6SQ_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
10111
10112
|
const band = /* @__PURE__ */ new Map();
|
|
10112
10113
|
for (let index = from; index <= to; index++) {
|
|
10113
10114
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -10118,7 +10119,7 @@ var ContractManager = class _ContractManager {
|
|
|
10118
10119
|
index,
|
|
10119
10120
|
params: {
|
|
10120
10121
|
...candidate,
|
|
10121
|
-
...
|
|
10122
|
+
...chunkY7BVR6SQ_cjs.speculativeReceiveMetadata(descriptor)
|
|
10122
10123
|
}
|
|
10123
10124
|
});
|
|
10124
10125
|
}
|
|
@@ -10180,7 +10181,7 @@ var ContractManager = class _ContractManager {
|
|
|
10180
10181
|
});
|
|
10181
10182
|
for (const entry of pending) entry.catchUpPending = false;
|
|
10182
10183
|
} catch (err) {
|
|
10183
|
-
if (!
|
|
10184
|
+
if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
|
|
10184
10185
|
this.markSyncDegraded(err);
|
|
10185
10186
|
}
|
|
10186
10187
|
}
|
|
@@ -10230,7 +10231,7 @@ var ContractManager = class _ContractManager {
|
|
|
10230
10231
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
10231
10232
|
this.markSyncOnline();
|
|
10232
10233
|
} catch (err) {
|
|
10233
|
-
if (!
|
|
10234
|
+
if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
|
|
10234
10235
|
this.markSyncDegraded(err);
|
|
10235
10236
|
}
|
|
10236
10237
|
await this.watcher.addContract(contract);
|
|
@@ -10264,7 +10265,7 @@ var ContractManager = class _ContractManager {
|
|
|
10264
10265
|
await this.fetchContractVxosFromIndexer(fresh);
|
|
10265
10266
|
this.markSyncOnline();
|
|
10266
10267
|
} catch (err) {
|
|
10267
|
-
if (!
|
|
10268
|
+
if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
|
|
10268
10269
|
this.markSyncDegraded(err);
|
|
10269
10270
|
}
|
|
10270
10271
|
for (const contract of fresh) await this.watcher.addContract(contract);
|
|
@@ -10302,7 +10303,7 @@ var ContractManager = class _ContractManager {
|
|
|
10302
10303
|
return result;
|
|
10303
10304
|
}
|
|
10304
10305
|
async upsertContractRow(params) {
|
|
10305
|
-
const handler =
|
|
10306
|
+
const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(params.type);
|
|
10306
10307
|
if (!handler) {
|
|
10307
10308
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
10308
10309
|
}
|
|
@@ -10402,7 +10403,7 @@ var ContractManager = class _ContractManager {
|
|
|
10402
10403
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
10403
10404
|
);
|
|
10404
10405
|
}
|
|
10405
|
-
const registered =
|
|
10406
|
+
const registered = chunkY7BVR6SQ_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkY7BVR6SQ_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
10406
10407
|
const discoverables = [
|
|
10407
10408
|
...registered.filter((h) => h.type === "boarding"),
|
|
10408
10409
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -10546,7 +10547,7 @@ var ContractManager = class _ContractManager {
|
|
|
10546
10547
|
await this.syncContracts({ contracts, pageSize });
|
|
10547
10548
|
this.markSyncOnline();
|
|
10548
10549
|
} catch (err) {
|
|
10549
|
-
if (!
|
|
10550
|
+
if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
|
|
10550
10551
|
this.markSyncDegraded(err);
|
|
10551
10552
|
if (options?.requireSynced) {
|
|
10552
10553
|
throw new Error("Spendable VTXO read requires an online contract sync", {
|
|
@@ -10579,7 +10580,7 @@ var ContractManager = class _ContractManager {
|
|
|
10579
10580
|
}
|
|
10580
10581
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
10581
10582
|
return vtxos.map(
|
|
10582
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
10583
|
+
(vtxo) => extendVirtualCoinForContract(chunkPWIESIO6_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
10583
10584
|
);
|
|
10584
10585
|
}
|
|
10585
10586
|
/** @inheritdoc */
|
|
@@ -10624,14 +10625,14 @@ var ContractManager = class _ContractManager {
|
|
|
10624
10625
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
10625
10626
|
const asking = vtxos.filter((vtxo) => {
|
|
10626
10627
|
const contract = byScript.get(vtxo.script);
|
|
10627
|
-
return contract !== void 0 &&
|
|
10628
|
+
return contract !== void 0 && chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
10628
10629
|
});
|
|
10629
10630
|
if (asking.length === 0) return refused;
|
|
10630
10631
|
const tip = await this.currentChainTip();
|
|
10631
10632
|
const walletKey = await walletPubKey?.();
|
|
10632
10633
|
for (const vtxo of asking) {
|
|
10633
10634
|
const contract = byScript.get(vtxo.script);
|
|
10634
|
-
const handler =
|
|
10635
|
+
const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
|
|
10635
10636
|
if (!handler?.assertSpendableNow) continue;
|
|
10636
10637
|
const context = {
|
|
10637
10638
|
collaborative: true,
|
|
@@ -10646,7 +10647,7 @@ var ContractManager = class _ContractManager {
|
|
|
10646
10647
|
// the next handler to answer a CSV question would meet a
|
|
10647
10648
|
// TypeError instead of a `false`. Carry the coin only when it
|
|
10648
10649
|
// really is one.
|
|
10649
|
-
vtxo:
|
|
10650
|
+
vtxo: chunkPWIESIO6_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
10650
10651
|
};
|
|
10651
10652
|
try {
|
|
10652
10653
|
await handler.assertSpendableNow(
|
|
@@ -10803,7 +10804,7 @@ var ContractManager = class _ContractManager {
|
|
|
10803
10804
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
10804
10805
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10805
10806
|
if (!contract) return [];
|
|
10806
|
-
const handler =
|
|
10807
|
+
const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
|
|
10807
10808
|
if (!handler) return [];
|
|
10808
10809
|
const script = handler.createScript(contract.params);
|
|
10809
10810
|
const tip = await this.currentChainTip();
|
|
@@ -10831,7 +10832,7 @@ var ContractManager = class _ContractManager {
|
|
|
10831
10832
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
10832
10833
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10833
10834
|
if (!contract) return [];
|
|
10834
|
-
const handler =
|
|
10835
|
+
const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
|
|
10835
10836
|
if (!handler) return [];
|
|
10836
10837
|
const script = handler.createScript(contract.params);
|
|
10837
10838
|
const context = {
|
|
@@ -10887,7 +10888,7 @@ var ContractManager = class _ContractManager {
|
|
|
10887
10888
|
}
|
|
10888
10889
|
async refreshOutpoints(outpoints) {
|
|
10889
10890
|
if (outpoints.length === 0) return;
|
|
10890
|
-
const { vtxos } = await
|
|
10891
|
+
const { vtxos } = await chunkPWIESIO6_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
10891
10892
|
outpoints
|
|
10892
10893
|
});
|
|
10893
10894
|
if (vtxos.length === 0) return;
|
|
@@ -10989,7 +10990,7 @@ var ContractManager = class _ContractManager {
|
|
|
10989
10990
|
break;
|
|
10990
10991
|
}
|
|
10991
10992
|
} catch (err) {
|
|
10992
|
-
if (!
|
|
10993
|
+
if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
|
|
10993
10994
|
this.markSyncDegraded(err);
|
|
10994
10995
|
}
|
|
10995
10996
|
this.emitEvent(event);
|
|
@@ -10999,7 +11000,7 @@ var ContractManager = class _ContractManager {
|
|
|
10999
11000
|
let rows;
|
|
11000
11001
|
if (this.config.walletRepository.getVtxosForScripts) {
|
|
11001
11002
|
const byScript = new Set(contracts.map((contract) => contract.script));
|
|
11002
|
-
rows = (await this.config.walletRepository.getVtxosForScripts([...byScript], options)).filter((vtxo) => vtxo.script !== void 0 && byScript.has(vtxo.script)).map((vtxo) => ({ ...
|
|
11003
|
+
rows = (await this.config.walletRepository.getVtxosForScripts([...byScript], options)).filter((vtxo) => vtxo.script !== void 0 && byScript.has(vtxo.script)).map((vtxo) => ({ ...chunkPWIESIO6_cjs.normalizeVtxo(vtxo), contractScript: vtxo.script }));
|
|
11003
11004
|
} else {
|
|
11004
11005
|
const res = await Promise.all(
|
|
11005
11006
|
contracts.map(
|
|
@@ -11015,7 +11016,7 @@ var ContractManager = class _ContractManager {
|
|
|
11015
11016
|
);
|
|
11016
11017
|
rows = res.flat();
|
|
11017
11018
|
}
|
|
11018
|
-
return options?.unspentOnly ? rows.filter((vtxo) => !
|
|
11019
|
+
return options?.unspentOnly ? rows.filter((vtxo) => !chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) : rows;
|
|
11019
11020
|
}
|
|
11020
11021
|
/**
|
|
11021
11022
|
* Sync virtual outputs for the given contracts against the indexer.
|
|
@@ -11088,7 +11089,7 @@ var ContractManager = class _ContractManager {
|
|
|
11088
11089
|
*/
|
|
11089
11090
|
async reconcilePendingFrontier(contracts) {
|
|
11090
11091
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
11091
|
-
const vtxos = await
|
|
11092
|
+
const vtxos = await chunkPWIESIO6_cjs.getAllNormalizedVtxos(
|
|
11092
11093
|
this.config.indexerProvider,
|
|
11093
11094
|
contracts.map((c) => c.script),
|
|
11094
11095
|
{ pendingOnly: true }
|
|
@@ -11175,7 +11176,7 @@ var ContractManager = class _ContractManager {
|
|
|
11175
11176
|
}
|
|
11176
11177
|
return result;
|
|
11177
11178
|
}
|
|
11178
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
11179
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkPWIESIO6_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
11179
11180
|
if (contracts.length === 0) {
|
|
11180
11181
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
11181
11182
|
}
|
|
@@ -11191,7 +11192,7 @@ var ContractManager = class _ContractManager {
|
|
|
11191
11192
|
before: syncWindow.before
|
|
11192
11193
|
}
|
|
11193
11194
|
} : {};
|
|
11194
|
-
const vtxos = await
|
|
11195
|
+
const vtxos = await chunkPWIESIO6_cjs.getAllNormalizedVtxos(
|
|
11195
11196
|
this.config.indexerProvider,
|
|
11196
11197
|
contracts.map((c) => c.script),
|
|
11197
11198
|
{ ...windowOpts, pageSize }
|
|
@@ -11340,7 +11341,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
11340
11341
|
const s = base.hex.decode(t.s);
|
|
11341
11342
|
return [cb, s];
|
|
11342
11343
|
};
|
|
11343
|
-
var deserializeVtxo = (o) =>
|
|
11344
|
+
var deserializeVtxo = (o) => chunkPWIESIO6_cjs.normalizeVtxo({
|
|
11344
11345
|
...o,
|
|
11345
11346
|
createdAt: new Date(o.createdAt),
|
|
11346
11347
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -11571,7 +11572,7 @@ var IndexedDBWalletRepository = class {
|
|
|
11571
11572
|
continue;
|
|
11572
11573
|
}
|
|
11573
11574
|
const vtxo = deserializeVtxoWithBackfill(row);
|
|
11574
|
-
if (!options?.unspentOnly || !
|
|
11575
|
+
if (!options?.unspentOnly || !chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) result.push(vtxo);
|
|
11575
11576
|
}
|
|
11576
11577
|
return result;
|
|
11577
11578
|
} catch (error) {
|
|
@@ -12184,7 +12185,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
12184
12185
|
*/
|
|
12185
12186
|
materializeDescriptorAt(index) {
|
|
12186
12187
|
const descriptor = this.identity.descriptor;
|
|
12187
|
-
const network =
|
|
12188
|
+
const network = chunkY7BVR6SQ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
12188
12189
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
12189
12190
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
12190
12191
|
if (!keyInfo?.keyExpression) {
|
|
@@ -12332,7 +12333,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
12332
12333
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
12333
12334
|
if (!provider) return void 0;
|
|
12334
12335
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
12335
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
12336
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
12336
12337
|
const factoryOpts = {
|
|
12337
12338
|
walletRepository: setup.walletRepository,
|
|
12338
12339
|
contractRepository: setup.contractRepository,
|
|
@@ -12533,7 +12534,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
12533
12534
|
};
|
|
12534
12535
|
function deriveLeafPubkey(descriptor) {
|
|
12535
12536
|
try {
|
|
12536
|
-
return
|
|
12537
|
+
return chunkY7BVR6SQ_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
12537
12538
|
} catch (e) {
|
|
12538
12539
|
throw new NonRangeableDescriptorError(
|
|
12539
12540
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -12545,7 +12546,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12545
12546
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
12546
12547
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
12547
12548
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
12548
|
-
const
|
|
12549
|
+
const csvTimelock2 = chunkPWIESIO6_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
12549
12550
|
const base$1 = {
|
|
12550
12551
|
script: base.hex.encode(tapscript.pkScript),
|
|
12551
12552
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -12556,18 +12557,18 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12556
12557
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
12557
12558
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
12558
12559
|
metadata: {
|
|
12559
|
-
...tagSource && { source:
|
|
12560
|
+
...tagSource && { source: chunkY7BVR6SQ_cjs.WALLET_RECEIVE_SOURCE },
|
|
12560
12561
|
signingDescriptor: descriptor
|
|
12561
12562
|
}
|
|
12562
12563
|
};
|
|
12563
|
-
const params = tapscript instanceof
|
|
12564
|
+
const params = tapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? {
|
|
12564
12565
|
...base$1,
|
|
12565
12566
|
type: "delegate",
|
|
12566
12567
|
params: {
|
|
12567
12568
|
pubKey: base.hex.encode(pubKey),
|
|
12568
12569
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12569
12570
|
delegatePubKey: base.hex.encode(tapscript.options.delegatePubKey),
|
|
12570
|
-
csvTimelock
|
|
12571
|
+
csvTimelock: csvTimelock2
|
|
12571
12572
|
}
|
|
12572
12573
|
} : {
|
|
12573
12574
|
...base$1,
|
|
@@ -12575,16 +12576,16 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12575
12576
|
params: {
|
|
12576
12577
|
pubKey: base.hex.encode(pubKey),
|
|
12577
12578
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12578
|
-
csvTimelock
|
|
12579
|
+
csvTimelock: csvTimelock2
|
|
12579
12580
|
}
|
|
12580
12581
|
};
|
|
12581
12582
|
return { tapscript, params };
|
|
12582
12583
|
}
|
|
12583
12584
|
function rebuildTapscript(current, pubKey) {
|
|
12584
|
-
if (current instanceof
|
|
12585
|
-
return new
|
|
12585
|
+
if (current instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script) {
|
|
12586
|
+
return new chunkY7BVR6SQ_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
12586
12587
|
}
|
|
12587
|
-
return new
|
|
12588
|
+
return new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
12588
12589
|
}
|
|
12589
12590
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
12590
12591
|
const candidates = await contractRepository.getContracts({
|
|
@@ -12593,7 +12594,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
12593
12594
|
});
|
|
12594
12595
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
12595
12596
|
const matching = candidates.filter(
|
|
12596
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12597
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkY7BVR6SQ_cjs.WALLET_RECEIVE_SOURCE
|
|
12597
12598
|
).sort((a, b) => {
|
|
12598
12599
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12599
12600
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12649,7 +12650,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12649
12650
|
}
|
|
12650
12651
|
};
|
|
12651
12652
|
for (const vtxo of vtxos) {
|
|
12652
|
-
if (
|
|
12653
|
+
if (chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) continue;
|
|
12653
12654
|
addAssets(owned, vtxo);
|
|
12654
12655
|
if (vtxo.isUnrolled) {
|
|
12655
12656
|
unrolled += vtxo.value;
|
|
@@ -12659,11 +12660,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12659
12660
|
pendingRecovery += vtxo.value;
|
|
12660
12661
|
continue;
|
|
12661
12662
|
}
|
|
12662
|
-
if (
|
|
12663
|
+
if (chunkPWIESIO6_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12663
12664
|
recoverable += vtxo.value;
|
|
12664
12665
|
continue;
|
|
12665
12666
|
}
|
|
12666
|
-
if (!
|
|
12667
|
+
if (!chunkPWIESIO6_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
12667
12668
|
if (vtxo.isPreconfirmed) {
|
|
12668
12669
|
preconfirmed += vtxo.value;
|
|
12669
12670
|
} else {
|
|
@@ -12840,12 +12841,12 @@ var InputSignerRouter = class {
|
|
|
12840
12841
|
};
|
|
12841
12842
|
|
|
12842
12843
|
// src/wallet/wallet.ts
|
|
12843
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
12844
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkPWIESIO6_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
12844
12845
|
function intentProofJobs(coins) {
|
|
12845
12846
|
if (coins.length === 0) return [];
|
|
12846
12847
|
const coinJobs = coins.map((coin, i) => ({
|
|
12847
12848
|
index: i + 1,
|
|
12848
|
-
lookupScript:
|
|
12849
|
+
lookupScript: chunkPWIESIO6_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12849
12850
|
}));
|
|
12850
12851
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12851
12852
|
}
|
|
@@ -12877,7 +12878,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
12877
12878
|
const seen = /* @__PURE__ */ new Set();
|
|
12878
12879
|
const deduped = [];
|
|
12879
12880
|
for (const timelock of timelocks) {
|
|
12880
|
-
const sequence =
|
|
12881
|
+
const sequence = chunkPWIESIO6_cjs.timelockToSequence(timelock).toString();
|
|
12881
12882
|
if (seen.has(sequence)) continue;
|
|
12882
12883
|
seen.add(sequence);
|
|
12883
12884
|
deduped.push(timelock);
|
|
@@ -12894,7 +12895,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12894
12895
|
state: "active"
|
|
12895
12896
|
});
|
|
12896
12897
|
const newest = candidates.filter(
|
|
12897
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12898
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkY7BVR6SQ_cjs.WALLET_RECEIVE_SOURCE
|
|
12898
12899
|
).sort((a, b) => {
|
|
12899
12900
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12900
12901
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12902,7 +12903,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12902
12903
|
if (!newest?.params.pubKey) return baseline;
|
|
12903
12904
|
try {
|
|
12904
12905
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
12905
|
-
return new
|
|
12906
|
+
return new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
12906
12907
|
} catch (e) {
|
|
12907
12908
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
12908
12909
|
return baseline;
|
|
@@ -12921,15 +12922,43 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
12921
12922
|
if (vtxo.isUnrolled) {
|
|
12922
12923
|
return !!f.withUnrolled;
|
|
12923
12924
|
}
|
|
12924
|
-
if (
|
|
12925
|
+
if (chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) {
|
|
12925
12926
|
return false;
|
|
12926
12927
|
}
|
|
12927
|
-
if (!f.withRecoverable &&
|
|
12928
|
+
if (!f.withRecoverable && chunkPWIESIO6_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12928
12929
|
return false;
|
|
12929
12930
|
}
|
|
12930
12931
|
return true;
|
|
12931
12932
|
});
|
|
12932
12933
|
}
|
|
12934
|
+
async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
12935
|
+
const candidates = inputs.filter(chunkPWIESIO6_cjs.isVirtualCoin).map(chunkPWIESIO6_cjs.normalizeVtxo).filter((v) => !v.isSwept);
|
|
12936
|
+
if (candidates.length === 0) return inputs;
|
|
12937
|
+
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkPWIESIO6_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
|
|
12938
|
+
const suspects = candidates.filter(
|
|
12939
|
+
(v) => chunkPWIESIO6_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
|
|
12940
|
+
);
|
|
12941
|
+
if (suspects.length === 0) return inputs;
|
|
12942
|
+
let sweptNow;
|
|
12943
|
+
try {
|
|
12944
|
+
const manager = await wallet.getContractManager();
|
|
12945
|
+
await manager.refreshOutpoints(suspects.map(({ txid, vout }) => ({ txid, vout })));
|
|
12946
|
+
const suspectKeys = new Set(suspects.map((v) => `${v.txid}:${v.vout}`));
|
|
12947
|
+
const fresh = await wallet.getVtxos({ withRecoverable: true });
|
|
12948
|
+
sweptNow = new Set(
|
|
12949
|
+
fresh.filter((v) => v.isSwept && suspectKeys.has(`${v.txid}:${v.vout}`)).map((v) => `${v.txid}:${v.vout}`)
|
|
12950
|
+
);
|
|
12951
|
+
} catch (e) {
|
|
12952
|
+
const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
|
|
12953
|
+
throw chunkPWIESIO6_cjs.isRetryableProviderError(e) ? new chunkPWIESIO6_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
|
|
12954
|
+
}
|
|
12955
|
+
if (sweptNow.size === 0) return inputs;
|
|
12956
|
+
return inputs.map((input) => {
|
|
12957
|
+
if (!chunkPWIESIO6_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
|
|
12958
|
+
const swept = { ...chunkPWIESIO6_cjs.normalizeVtxo(input), isSwept: true };
|
|
12959
|
+
return { ...swept, virtualStatus: chunkPWIESIO6_cjs.toVirtualStatus(swept) };
|
|
12960
|
+
});
|
|
12961
|
+
}
|
|
12933
12962
|
var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
|
|
12934
12963
|
var UNROLLED_REASON = "was unilaterally exited and lives onchain \u2014 `Unroll.completeUnroll` is the only spend that reaches it";
|
|
12935
12964
|
function omittedOutpoints(before, after) {
|
|
@@ -13264,7 +13293,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13264
13293
|
*/
|
|
13265
13294
|
static async setupWalletConfig(config, pubKey) {
|
|
13266
13295
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
13267
|
-
const arkProvider = config.arkProvider || new
|
|
13296
|
+
const arkProvider = config.arkProvider || new chunkPWIESIO6_cjs.RestArkProvider(arkadeServerUrl);
|
|
13268
13297
|
let indexerProvider = config.indexerProvider;
|
|
13269
13298
|
if (!indexerProvider) {
|
|
13270
13299
|
let indexerUrl = config.indexerUrl;
|
|
@@ -13281,7 +13310,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13281
13310
|
indexerUrl = arkadeServerUrl;
|
|
13282
13311
|
}
|
|
13283
13312
|
}
|
|
13284
|
-
indexerProvider = new
|
|
13313
|
+
indexerProvider = new chunkIAM5IEVT_cjs.RestIndexerProvider(indexerUrl);
|
|
13285
13314
|
}
|
|
13286
13315
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
13287
13316
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -13290,7 +13319,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13290
13319
|
source: serverInfoSource,
|
|
13291
13320
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
13292
13321
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
13293
|
-
const network =
|
|
13322
|
+
const network = chunkPWIESIO6_cjs.getNetwork(info.network);
|
|
13294
13323
|
if ("descriptor" in config.identity) {
|
|
13295
13324
|
const descriptor = config.identity.descriptor;
|
|
13296
13325
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -13330,18 +13359,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13330
13359
|
value: info.boardingExitDelay,
|
|
13331
13360
|
type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
|
|
13332
13361
|
};
|
|
13333
|
-
const serverPubKey =
|
|
13334
|
-
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) =>
|
|
13362
|
+
const serverPubKey = chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
13363
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
|
|
13335
13364
|
const offchainOptions = {
|
|
13336
13365
|
pubKey,
|
|
13337
13366
|
serverPubKey,
|
|
13338
13367
|
csvTimelock: exitTimelock
|
|
13339
13368
|
};
|
|
13340
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
13341
|
-
const boardingTapscript =
|
|
13369
|
+
const offchainTapscript = !delegatePubKey ? new chunkY7BVR6SQ_cjs.DefaultVtxo.Script(offchainOptions) : new chunkY7BVR6SQ_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
13370
|
+
const boardingTapscript = chunkY7BVR6SQ_cjs.BoardingContractHandler.createScript({
|
|
13342
13371
|
pubKey: base.hex.encode(pubKey),
|
|
13343
13372
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13344
|
-
csvTimelock:
|
|
13373
|
+
csvTimelock: chunkPWIESIO6_cjs.timelockToSequence(boardingTimelock).toString()
|
|
13345
13374
|
});
|
|
13346
13375
|
return {
|
|
13347
13376
|
arkProvider,
|
|
@@ -13429,7 +13458,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13429
13458
|
async getBalance() {
|
|
13430
13459
|
const [boardingUtxos, snapshot] = await Promise.all([
|
|
13431
13460
|
this.getBoardingUtxos(),
|
|
13432
|
-
|
|
13461
|
+
// The bucketer drops every spent coin and the gate reads contracts only.
|
|
13462
|
+
this.contractSnapshot(void 0, { unspentOnly: true })
|
|
13433
13463
|
]);
|
|
13434
13464
|
const vtxos = filterSnapshotVtxos(
|
|
13435
13465
|
snapshot,
|
|
@@ -13482,7 +13512,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13482
13512
|
*/
|
|
13483
13513
|
async getVtxos(filter) {
|
|
13484
13514
|
return filterSnapshotVtxos(
|
|
13485
|
-
|
|
13515
|
+
// Only an unrolled coin is returned spent, so no other read needs spent rows.
|
|
13516
|
+
await this.contractSnapshot(void 0, { unspentOnly: !filter?.withUnrolled }),
|
|
13486
13517
|
filter,
|
|
13487
13518
|
this._pendingSpendOutpoints
|
|
13488
13519
|
);
|
|
@@ -13509,7 +13540,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13509
13540
|
if (!filter?.withUnrolled) {
|
|
13510
13541
|
logExcludedVtxos(
|
|
13511
13542
|
"getSpendableVtxos",
|
|
13512
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
13543
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkPWIESIO6_cjs.isVtxoSpent(vtxo)),
|
|
13513
13544
|
[() => UNROLLED_REASON]
|
|
13514
13545
|
);
|
|
13515
13546
|
}
|
|
@@ -13670,7 +13701,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13670
13701
|
this.getBoardingTxs()
|
|
13671
13702
|
]);
|
|
13672
13703
|
const allVtxos = snapshot.flatMap((_) => _.vtxos);
|
|
13673
|
-
const resolveTxCreatedAt = (txids) =>
|
|
13704
|
+
const resolveTxCreatedAt = (txids) => chunkPWIESIO6_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
13674
13705
|
return buildTransactionHistory(
|
|
13675
13706
|
allVtxos,
|
|
13676
13707
|
boardingTxs,
|
|
@@ -13765,7 +13796,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13765
13796
|
},
|
|
13766
13797
|
isUnrolled: true,
|
|
13767
13798
|
...boardingFacts,
|
|
13768
|
-
virtualStatus:
|
|
13799
|
+
virtualStatus: chunkPWIESIO6_cjs.toVirtualStatus(boardingFacts),
|
|
13769
13800
|
spentBy: "",
|
|
13770
13801
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
13771
13802
|
script: scriptHex
|
|
@@ -13821,9 +13852,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13821
13852
|
async getBoardingTapscripts(allowedSigners) {
|
|
13822
13853
|
const byScript = /* @__PURE__ */ new Map();
|
|
13823
13854
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
13824
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
13855
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkY7BVR6SQ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13825
13856
|
add(
|
|
13826
|
-
new
|
|
13857
|
+
new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
|
|
13827
13858
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
13828
13859
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
13829
13860
|
csvTimelock: boardingCsv
|
|
@@ -13838,7 +13869,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13838
13869
|
for (const c of boardingContracts) {
|
|
13839
13870
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
13840
13871
|
try {
|
|
13841
|
-
add(
|
|
13872
|
+
add(chunkY7BVR6SQ_cjs.BoardingContractHandler.createScript(c.params));
|
|
13842
13873
|
} catch (e) {
|
|
13843
13874
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
13844
13875
|
}
|
|
@@ -13875,7 +13906,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13875
13906
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
13876
13907
|
// not the wallet's current boarding timelock, which a signer
|
|
13877
13908
|
// rotation may have changed.
|
|
13878
|
-
csvTimelock:
|
|
13909
|
+
csvTimelock: chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
13879
13910
|
coins: utxos
|
|
13880
13911
|
};
|
|
13881
13912
|
})
|
|
@@ -14012,7 +14043,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14012
14043
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
14013
14044
|
async fetchPendingTxs() {
|
|
14014
14045
|
const scripts = await this.getWalletScripts();
|
|
14015
|
-
const vtxos = await
|
|
14046
|
+
const vtxos = await chunkPWIESIO6_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
14016
14047
|
return vtxos.filter(
|
|
14017
14048
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
14018
14049
|
).map((_) => _.arkTxId);
|
|
@@ -14043,7 +14074,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14043
14074
|
});
|
|
14044
14075
|
for (const contract of contracts) {
|
|
14045
14076
|
if (map.has(contract.script)) continue;
|
|
14046
|
-
const handler =
|
|
14077
|
+
const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
|
|
14047
14078
|
if (handler) {
|
|
14048
14079
|
const script = handler.createScript(contract.params);
|
|
14049
14080
|
map.set(contract.script, script);
|
|
@@ -14155,19 +14186,19 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14155
14186
|
}
|
|
14156
14187
|
});
|
|
14157
14188
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
14158
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14189
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14159
14190
|
const baselineSigners = [
|
|
14160
14191
|
this.offchainTapscript.options.serverPubKey,
|
|
14161
14192
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
14162
14193
|
];
|
|
14163
14194
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
14164
14195
|
for (const serverPubKey of baselineSigners) {
|
|
14165
|
-
for (const
|
|
14166
|
-
const csvTimelockStr =
|
|
14167
|
-
const defaultScript = new
|
|
14196
|
+
for (const csvTimelock2 of this.walletContractTimelocks) {
|
|
14197
|
+
const csvTimelockStr = chunkPWIESIO6_cjs.timelockToSequence(csvTimelock2).toString();
|
|
14198
|
+
const defaultScript = new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
|
|
14168
14199
|
pubKey: baselinePubkey,
|
|
14169
14200
|
serverPubKey,
|
|
14170
|
-
csvTimelock
|
|
14201
|
+
csvTimelock: csvTimelock2
|
|
14171
14202
|
});
|
|
14172
14203
|
const defaultScriptHex = base.hex.encode(defaultScript.pkScript);
|
|
14173
14204
|
if (!seenBaselineScripts.has(defaultScriptHex)) {
|
|
@@ -14185,11 +14216,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14185
14216
|
});
|
|
14186
14217
|
}
|
|
14187
14218
|
if (delegatePubKey) {
|
|
14188
|
-
const delegateScript = new
|
|
14219
|
+
const delegateScript = new chunkY7BVR6SQ_cjs.DelegateVtxo.Script({
|
|
14189
14220
|
pubKey: baselinePubkey,
|
|
14190
14221
|
serverPubKey,
|
|
14191
14222
|
delegatePubKey,
|
|
14192
|
-
csvTimelock
|
|
14223
|
+
csvTimelock: csvTimelock2
|
|
14193
14224
|
});
|
|
14194
14225
|
const delegateScriptHex = base.hex.encode(delegateScript.pkScript);
|
|
14195
14226
|
if (seenBaselineScripts.has(delegateScriptHex)) continue;
|
|
@@ -14209,9 +14240,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14209
14240
|
}
|
|
14210
14241
|
}
|
|
14211
14242
|
}
|
|
14212
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
14243
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkY7BVR6SQ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14213
14244
|
for (const serverPubKey of baselineSigners) {
|
|
14214
|
-
const baselineBoarding = new
|
|
14245
|
+
const baselineBoarding = new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
|
|
14215
14246
|
pubKey: baselinePubkey,
|
|
14216
14247
|
serverPubKey,
|
|
14217
14248
|
csvTimelock: boardingCsvTimelock
|
|
@@ -14224,7 +14255,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14224
14255
|
params: {
|
|
14225
14256
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
14226
14257
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
14227
|
-
csvTimelock:
|
|
14258
|
+
csvTimelock: chunkPWIESIO6_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
14228
14259
|
},
|
|
14229
14260
|
script: boardingScriptHex,
|
|
14230
14261
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -14424,7 +14455,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14424
14455
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
14425
14456
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
14426
14457
|
csvTimelocks: this.walletContractTimelocks,
|
|
14427
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
14458
|
+
delegatePubKey: this.offchainTapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
14428
14459
|
};
|
|
14429
14460
|
}
|
|
14430
14461
|
_signerRouter;
|
|
@@ -14669,7 +14700,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14669
14700
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
14670
14701
|
const persisted = row?.metadata?.signingDescriptor;
|
|
14671
14702
|
if (typeof persisted === "string") return persisted;
|
|
14672
|
-
return
|
|
14703
|
+
return chunkY7BVR6SQ_cjs.identityDescriptor(this.identity);
|
|
14673
14704
|
}
|
|
14674
14705
|
/**
|
|
14675
14706
|
* Build, persist and shape one address of `type` owned by `descriptor` —
|
|
@@ -14685,7 +14716,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14685
14716
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
14686
14717
|
if (type === "boarding") {
|
|
14687
14718
|
const built2 = this.buildBoardingContract(
|
|
14688
|
-
|
|
14719
|
+
chunkY7BVR6SQ_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
14689
14720
|
descriptor,
|
|
14690
14721
|
tagSource
|
|
14691
14722
|
);
|
|
@@ -14730,11 +14761,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14730
14761
|
* {@link buildReceiveContract}.
|
|
14731
14762
|
*/
|
|
14732
14763
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
14733
|
-
const tapscript = new
|
|
14764
|
+
const tapscript = new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
|
|
14734
14765
|
...this._boardingTapscript.options,
|
|
14735
14766
|
pubKey
|
|
14736
14767
|
});
|
|
14737
|
-
const
|
|
14768
|
+
const csvTimelock2 = tapscript.options.csvTimelock ?? chunkY7BVR6SQ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14738
14769
|
return {
|
|
14739
14770
|
tapscript,
|
|
14740
14771
|
params: {
|
|
@@ -14742,13 +14773,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14742
14773
|
params: {
|
|
14743
14774
|
pubKey: base.hex.encode(pubKey),
|
|
14744
14775
|
serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
|
|
14745
|
-
csvTimelock:
|
|
14776
|
+
csvTimelock: chunkPWIESIO6_cjs.timelockToSequence(csvTimelock2).toString()
|
|
14746
14777
|
},
|
|
14747
14778
|
script: base.hex.encode(tapscript.pkScript),
|
|
14748
14779
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
14749
14780
|
state: "active",
|
|
14750
14781
|
metadata: {
|
|
14751
|
-
...tagSource && { source:
|
|
14782
|
+
...tagSource && { source: chunkY7BVR6SQ_cjs.WALLET_RECEIVE_SOURCE },
|
|
14752
14783
|
signingDescriptor: descriptor
|
|
14753
14784
|
}
|
|
14754
14785
|
}
|
|
@@ -14777,7 +14808,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14777
14808
|
if (this._descriptorProvider instanceof HDDescriptorProvider) {
|
|
14778
14809
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
14779
14810
|
}
|
|
14780
|
-
return
|
|
14811
|
+
return chunkY7BVR6SQ_cjs.identityDescriptor(this.identity);
|
|
14781
14812
|
}
|
|
14782
14813
|
/**
|
|
14783
14814
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -14873,7 +14904,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14873
14904
|
* the stable public API.
|
|
14874
14905
|
*/
|
|
14875
14906
|
async rotateServerSigner(newServerPubKey, checkpointTapscript) {
|
|
14876
|
-
const xonly =
|
|
14907
|
+
const xonly = chunkY7BVR6SQ_cjs.toXOnly(newServerPubKey, "ark signer key");
|
|
14877
14908
|
const newServerUnrollScript = assertValidServerUnrollScript(
|
|
14878
14909
|
checkpointTapscript,
|
|
14879
14910
|
resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
|
|
@@ -14902,21 +14933,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14902
14933
|
const [currentBoardingRow] = await manager.getContracts({
|
|
14903
14934
|
script: currentBoardingScript
|
|
14904
14935
|
});
|
|
14905
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
14936
|
+
const newOffchain = this.offchainTapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? new chunkY7BVR6SQ_cjs.DelegateVtxo.Script({
|
|
14906
14937
|
...this.offchainTapscript.options,
|
|
14907
14938
|
serverPubKey: xonly
|
|
14908
|
-
}) : new
|
|
14939
|
+
}) : new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
|
|
14909
14940
|
...this.offchainTapscript.options,
|
|
14910
14941
|
serverPubKey: xonly
|
|
14911
14942
|
});
|
|
14912
|
-
const newBoarding = new
|
|
14943
|
+
const newBoarding = new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
|
|
14913
14944
|
...this._boardingTapscript.options,
|
|
14914
14945
|
serverPubKey: xonly
|
|
14915
14946
|
});
|
|
14916
|
-
const offchainCsv =
|
|
14947
|
+
const offchainCsv = chunkPWIESIO6_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
14917
14948
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
14918
14949
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
14919
|
-
if (newOffchain instanceof
|
|
14950
|
+
if (newOffchain instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script) {
|
|
14920
14951
|
await manager.createContract({
|
|
14921
14952
|
type: "delegate",
|
|
14922
14953
|
params: {
|
|
@@ -14944,13 +14975,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14944
14975
|
metadata: currentOffchainRow?.metadata
|
|
14945
14976
|
});
|
|
14946
14977
|
}
|
|
14947
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
14978
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkY7BVR6SQ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14948
14979
|
await manager.createContract({
|
|
14949
14980
|
type: "boarding",
|
|
14950
14981
|
params: {
|
|
14951
14982
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
14952
14983
|
serverPubKey: base.hex.encode(xonly),
|
|
14953
|
-
csvTimelock:
|
|
14984
|
+
csvTimelock: chunkPWIESIO6_cjs.timelockToSequence(boardingCsv).toString()
|
|
14954
14985
|
},
|
|
14955
14986
|
script: base.hex.encode(newBoarding.pkScript),
|
|
14956
14987
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -14983,14 +15014,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14983
15014
|
_restoreInFlight;
|
|
14984
15015
|
_addPendingSpends(inputs) {
|
|
14985
15016
|
for (const input of inputs) {
|
|
14986
|
-
if (
|
|
15017
|
+
if (chunkPWIESIO6_cjs.isVirtualCoin(input)) {
|
|
14987
15018
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
14988
15019
|
}
|
|
14989
15020
|
}
|
|
14990
15021
|
}
|
|
14991
15022
|
_removePendingSpends(inputs) {
|
|
14992
15023
|
for (const input of inputs) {
|
|
14993
|
-
if (
|
|
15024
|
+
if (chunkPWIESIO6_cjs.isVirtualCoin(input)) {
|
|
14994
15025
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
14995
15026
|
}
|
|
14996
15027
|
}
|
|
@@ -15051,13 +15082,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15051
15082
|
const manager = await this.getContractManager();
|
|
15052
15083
|
const provider = this._descriptorProvider;
|
|
15053
15084
|
const hd = provider instanceof HDDescriptorProvider;
|
|
15054
|
-
const staticDescriptor = hd ? void 0 : await
|
|
15085
|
+
const staticDescriptor = hd ? void 0 : await chunkY7BVR6SQ_cjs.identityDescriptor(this.identity);
|
|
15055
15086
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
15056
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
15087
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
15057
15088
|
const arkInfo = await this.arkProvider.getInfo();
|
|
15058
|
-
const currentSignerPubKey =
|
|
15089
|
+
const currentSignerPubKey = chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
15059
15090
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
15060
|
-
(s) =>
|
|
15091
|
+
(s) => chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
15061
15092
|
);
|
|
15062
15093
|
const deps = {
|
|
15063
15094
|
indexerProvider: this.indexerProvider,
|
|
@@ -15072,7 +15103,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15072
15103
|
csvTimelocks: this.walletContractTimelocks,
|
|
15073
15104
|
// Boarding-exit CSV so the boarding handler can build its
|
|
15074
15105
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
15075
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
15106
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkY7BVR6SQ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
15076
15107
|
delegatePubKey
|
|
15077
15108
|
};
|
|
15078
15109
|
const result = await manager.scanContracts({
|
|
@@ -15186,7 +15217,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15186
15217
|
throw new Error("Invalid configured public key");
|
|
15187
15218
|
}
|
|
15188
15219
|
const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
|
|
15189
|
-
const forfeitPubkey =
|
|
15220
|
+
const forfeitPubkey = chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
|
|
15190
15221
|
const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
|
|
15191
15222
|
const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
|
|
15192
15223
|
const checkpointExitDelayOverrides = {
|
|
@@ -15335,7 +15366,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15335
15366
|
inputs: params.selectedVtxos,
|
|
15336
15367
|
changeAmount: BigInt(changeAmount)
|
|
15337
15368
|
};
|
|
15338
|
-
const outputAddress =
|
|
15369
|
+
const outputAddress = chunkPWIESIO6_cjs.ArkAddress.decode(params.address);
|
|
15339
15370
|
assertRecipientArkAddress(
|
|
15340
15371
|
params.address,
|
|
15341
15372
|
outputAddress,
|
|
@@ -15401,13 +15432,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15401
15432
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
15402
15433
|
}
|
|
15403
15434
|
const offchainAddress = await this.getAddress();
|
|
15404
|
-
const offchainPkScript =
|
|
15435
|
+
const offchainPkScript = chunkPWIESIO6_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
15405
15436
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
15406
15437
|
if (!params) {
|
|
15407
15438
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
15408
15439
|
const estimator = new Estimator(fees.intentFee);
|
|
15409
15440
|
let amount = 0;
|
|
15410
|
-
const exitScript =
|
|
15441
|
+
const exitScript = chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(
|
|
15411
15442
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
15412
15443
|
);
|
|
15413
15444
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -15439,7 +15470,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15439
15470
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
15440
15471
|
break;
|
|
15441
15472
|
}
|
|
15442
|
-
const inputFee = estimator.evalOffchainInput(
|
|
15473
|
+
const inputFee = estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(vtxo));
|
|
15443
15474
|
if (inputFee.satoshis >= vtxo.value) {
|
|
15444
15475
|
continue;
|
|
15445
15476
|
}
|
|
@@ -15478,6 +15509,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15478
15509
|
outputs: [output]
|
|
15479
15510
|
};
|
|
15480
15511
|
}
|
|
15512
|
+
params = {
|
|
15513
|
+
...params,
|
|
15514
|
+
inputs: await refreshSweptStateOfExpiredInputs(this, params.inputs)
|
|
15515
|
+
};
|
|
15481
15516
|
const onchainOutputIndexes = [];
|
|
15482
15517
|
const outputs = [];
|
|
15483
15518
|
let hasOffchainOutputs = false;
|
|
@@ -15486,7 +15521,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15486
15521
|
let script;
|
|
15487
15522
|
let arkAddress;
|
|
15488
15523
|
try {
|
|
15489
|
-
arkAddress =
|
|
15524
|
+
arkAddress = chunkPWIESIO6_cjs.ArkAddress.decode(output.address);
|
|
15490
15525
|
} catch {
|
|
15491
15526
|
arkAddress = void 0;
|
|
15492
15527
|
}
|
|
@@ -15576,7 +15611,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15576
15611
|
const abortController = new AbortController();
|
|
15577
15612
|
let stream;
|
|
15578
15613
|
let committedTxid;
|
|
15579
|
-
const settleInputVtxos = params.inputs.filter(
|
|
15614
|
+
const settleInputVtxos = params.inputs.filter(chunkPWIESIO6_cjs.isVirtualCoin);
|
|
15580
15615
|
const contractManager = await this.getContractManager();
|
|
15581
15616
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
15582
15617
|
await contractManager.assertSpendableNow?.(
|
|
@@ -15688,7 +15723,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15688
15723
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
15689
15724
|
if (!this._descriptorProvider) return;
|
|
15690
15725
|
const consumedBoarding = inputs.some(
|
|
15691
|
-
(input) => typeof input !== "string" && !
|
|
15726
|
+
(input) => typeof input !== "string" && !chunkPWIESIO6_cjs.isVirtualCoin(input)
|
|
15692
15727
|
);
|
|
15693
15728
|
if (!consumedBoarding) return;
|
|
15694
15729
|
try {
|
|
@@ -15712,7 +15747,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15712
15747
|
let connectorIndex = 0;
|
|
15713
15748
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
15714
15749
|
for (const input of inputs) {
|
|
15715
|
-
if (!
|
|
15750
|
+
if (!chunkPWIESIO6_cjs.isVirtualCoin(input)) {
|
|
15716
15751
|
let matched = false;
|
|
15717
15752
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
15718
15753
|
const settlementInput = settlementPsbt.getInput(i);
|
|
@@ -15750,7 +15785,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15750
15785
|
}
|
|
15751
15786
|
continue;
|
|
15752
15787
|
}
|
|
15753
|
-
if (
|
|
15788
|
+
if (!chunkPWIESIO6_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
15754
15789
|
continue;
|
|
15755
15790
|
}
|
|
15756
15791
|
if (connectorsLeaves.length === 0) {
|
|
@@ -15778,7 +15813,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15778
15813
|
index: input.vout,
|
|
15779
15814
|
witnessUtxo: {
|
|
15780
15815
|
amount: BigInt(input.value),
|
|
15781
|
-
script:
|
|
15816
|
+
script: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15782
15817
|
},
|
|
15783
15818
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
15784
15819
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -15797,7 +15832,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15797
15832
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
15798
15833
|
{
|
|
15799
15834
|
index: 0,
|
|
15800
|
-
lookupScript:
|
|
15835
|
+
lookupScript: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15801
15836
|
}
|
|
15802
15837
|
]);
|
|
15803
15838
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -15855,7 +15890,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15855
15890
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
15856
15891
|
);
|
|
15857
15892
|
await this.arkProvider.confirmRegistration(intentId);
|
|
15858
|
-
const sweepTapscript =
|
|
15893
|
+
const sweepTapscript = chunkPWIESIO6_cjs.CSVMultisigTapscript.encode({
|
|
15859
15894
|
timelock,
|
|
15860
15895
|
pubkeys: [this.forfeitPubkey]
|
|
15861
15896
|
}).script;
|
|
@@ -15870,10 +15905,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15870
15905
|
throw new Error("Sweep tap tree root not set");
|
|
15871
15906
|
}
|
|
15872
15907
|
const xOnlyPublicKeys = event.cosignersPublicKeys.map(
|
|
15873
|
-
(k) => base.hex.encode(
|
|
15908
|
+
(k) => base.hex.encode(chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
15874
15909
|
);
|
|
15875
15910
|
const signerPublicKey = await session.getPublicKey();
|
|
15876
|
-
const xonlySignerPublicKey =
|
|
15911
|
+
const xonlySignerPublicKey = chunkY7BVR6SQ_cjs.toXOnly(signerPublicKey, "signer key");
|
|
15877
15912
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
15878
15913
|
return { skip: true };
|
|
15879
15914
|
}
|
|
@@ -15963,9 +15998,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15963
15998
|
...existing ?? {},
|
|
15964
15999
|
intentTxId,
|
|
15965
16000
|
registerProof: intent.proof,
|
|
15966
|
-
registerProofMessage:
|
|
16001
|
+
registerProofMessage: chunkPWIESIO6_cjs.Intent.encodeMessage(intent.message),
|
|
15967
16002
|
deleteProof: deleteIntent.proof,
|
|
15968
|
-
deleteProofMessage:
|
|
16003
|
+
deleteProofMessage: chunkPWIESIO6_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
15969
16004
|
intentVtxos: inputs.map((i) => ({
|
|
15970
16005
|
txid: i.txid,
|
|
15971
16006
|
vout: i.vout
|
|
@@ -15998,7 +16033,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15998
16033
|
try {
|
|
15999
16034
|
return await this.arkProvider.registerIntent(intent);
|
|
16000
16035
|
} catch (error) {
|
|
16001
|
-
if (error instanceof
|
|
16036
|
+
if (error instanceof chunkPWIESIO6_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
16002
16037
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
16003
16038
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
16004
16039
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -16014,7 +16049,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16014
16049
|
expire_at: 0,
|
|
16015
16050
|
cosigners_public_keys: cosignerPubKeys
|
|
16016
16051
|
};
|
|
16017
|
-
const proof =
|
|
16052
|
+
const proof = chunkPWIESIO6_cjs.Intent.create(message, coins, outputs);
|
|
16018
16053
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16019
16054
|
return {
|
|
16020
16055
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16026,7 +16061,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16026
16061
|
type: "delete",
|
|
16027
16062
|
expire_at: 0
|
|
16028
16063
|
};
|
|
16029
|
-
const proof =
|
|
16064
|
+
const proof = chunkPWIESIO6_cjs.Intent.create(message, coins, []);
|
|
16030
16065
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16031
16066
|
return {
|
|
16032
16067
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16038,7 +16073,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16038
16073
|
type: "get-pending-tx",
|
|
16039
16074
|
expire_at: 0
|
|
16040
16075
|
};
|
|
16041
|
-
const proof =
|
|
16076
|
+
const proof = chunkPWIESIO6_cjs.Intent.create(message, coins, []);
|
|
16042
16077
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16043
16078
|
return {
|
|
16044
16079
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16059,7 +16094,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16059
16094
|
if (!vtxos || vtxos.length === 0) {
|
|
16060
16095
|
const scriptMap = await this.getScriptMap();
|
|
16061
16096
|
const allExtended = [];
|
|
16062
|
-
const fetchedVtxos = await
|
|
16097
|
+
const fetchedVtxos = await chunkPWIESIO6_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
16063
16098
|
...scriptMap.keys()
|
|
16064
16099
|
]);
|
|
16065
16100
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -16103,7 +16138,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16103
16138
|
try {
|
|
16104
16139
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
16105
16140
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
|
|
16106
|
-
|
|
16141
|
+
chunkPWIESIO6_cjs.assertAllowedSighashTypes(tx);
|
|
16107
16142
|
return tx;
|
|
16108
16143
|
});
|
|
16109
16144
|
assertCheckpointsMatchInputs(
|
|
@@ -16175,11 +16210,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16175
16210
|
* against the current key alone would leave it pending forever.
|
|
16176
16211
|
*/
|
|
16177
16212
|
checkpointUnrollCandidates(info) {
|
|
16178
|
-
const current =
|
|
16213
|
+
const current = chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
16179
16214
|
const candidates = [this._serverUnrollScript, current];
|
|
16180
16215
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
16181
16216
|
candidates.push(
|
|
16182
|
-
|
|
16217
|
+
chunkPWIESIO6_cjs.CSVMultisigTapscript.encode({
|
|
16183
16218
|
...current.params,
|
|
16184
16219
|
pubkeys: [base.hex.decode(deprecated)]
|
|
16185
16220
|
})
|
|
@@ -16270,7 +16305,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16270
16305
|
if (vtxos.length === 0) {
|
|
16271
16306
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
16272
16307
|
}
|
|
16273
|
-
const myPkScript =
|
|
16308
|
+
const myPkScript = chunkPWIESIO6_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
16274
16309
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
16275
16310
|
let swept = 0;
|
|
16276
16311
|
const drainable = vtxos.filter(
|
|
@@ -16346,7 +16381,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16346
16381
|
const spendable = [];
|
|
16347
16382
|
const unclaimed = [];
|
|
16348
16383
|
for (const vtxo of vtxos) {
|
|
16349
|
-
if (
|
|
16384
|
+
if (chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) {
|
|
16350
16385
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
16351
16386
|
} else if (vtxo.isUnrolled) {
|
|
16352
16387
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -16368,7 +16403,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16368
16403
|
const all = [];
|
|
16369
16404
|
const seen = /* @__PURE__ */ new Set();
|
|
16370
16405
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
16371
|
-
const { vtxos, page } = await
|
|
16406
|
+
const { vtxos, page } = await chunkPWIESIO6_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
16372
16407
|
scripts,
|
|
16373
16408
|
pageIndex,
|
|
16374
16409
|
pageSize
|
|
@@ -16415,7 +16450,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16415
16450
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
16416
16451
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
16417
16452
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
16418
|
-
const proof =
|
|
16453
|
+
const proof = chunkPWIESIO6_cjs.Intent.create(message, batch, []);
|
|
16419
16454
|
const signedProof = await identity.sign(
|
|
16420
16455
|
proof,
|
|
16421
16456
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -16437,7 +16472,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16437
16472
|
try {
|
|
16438
16473
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
16439
16474
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
16440
|
-
|
|
16475
|
+
chunkPWIESIO6_cjs.assertAllowedSighashTypes(tx);
|
|
16441
16476
|
return tx;
|
|
16442
16477
|
});
|
|
16443
16478
|
assertCheckpointsMatchInputs(
|
|
@@ -16648,7 +16683,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16648
16683
|
script: recipient.script,
|
|
16649
16684
|
amount: BigInt(recipient.amount),
|
|
16650
16685
|
// Already checked against the recipient address in `validateRecipients`.
|
|
16651
|
-
...recipient.tapTree ? { tapTree:
|
|
16686
|
+
...recipient.tapTree ? { tapTree: chunkPWIESIO6_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
|
|
16652
16687
|
}));
|
|
16653
16688
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
16654
16689
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -16832,10 +16867,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16832
16867
|
const serverPubKey = this.arkServerPublicKey;
|
|
16833
16868
|
const serverUnrollScript = this.serverUnrollScript;
|
|
16834
16869
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
16835
|
-
const normalizedInputs = inputs.map(
|
|
16836
|
-
const at = now ?? await
|
|
16870
|
+
const normalizedInputs = inputs.map(chunkPWIESIO6_cjs.normalizeVtxo);
|
|
16871
|
+
const at = now ?? await chunkPWIESIO6_cjs.resolveTimeHeight(this.onchainProvider);
|
|
16837
16872
|
for (const input of normalizedInputs) {
|
|
16838
|
-
if (!
|
|
16873
|
+
if (!chunkPWIESIO6_cjs.canSpendOffchain(input, at)) {
|
|
16839
16874
|
throw new Error(
|
|
16840
16875
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
16841
16876
|
);
|
|
@@ -16905,7 +16940,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16905
16940
|
);
|
|
16906
16941
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
16907
16942
|
index,
|
|
16908
|
-
lookupScript:
|
|
16943
|
+
lookupScript: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
16909
16944
|
}));
|
|
16910
16945
|
const identity = this.identity;
|
|
16911
16946
|
const signer = {
|
|
@@ -17006,14 +17041,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17006
17041
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
17007
17042
|
spentVtxos.push({
|
|
17008
17043
|
...spentFacts,
|
|
17009
|
-
virtualStatus:
|
|
17044
|
+
virtualStatus: chunkPWIESIO6_cjs.toVirtualStatus(spentFacts),
|
|
17010
17045
|
...spentBy ? { spentBy } : {},
|
|
17011
17046
|
arkTxId: arkTxid
|
|
17012
17047
|
});
|
|
17013
17048
|
for (const id of vtxo.commitmentTxIds) {
|
|
17014
17049
|
commitmentTxIds.add(id);
|
|
17015
17050
|
}
|
|
17016
|
-
const vtxoExpiry =
|
|
17051
|
+
const vtxoExpiry = chunkPWIESIO6_cjs.toBatchExpiry(vtxo);
|
|
17017
17052
|
if (vtxoExpiry) {
|
|
17018
17053
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
17019
17054
|
}
|
|
@@ -17026,7 +17061,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17026
17061
|
isSwept: false,
|
|
17027
17062
|
isPreconfirmed: true,
|
|
17028
17063
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
17029
|
-
...
|
|
17064
|
+
...chunkPWIESIO6_cjs.parseLegacyExpiry(batchExpiry)
|
|
17030
17065
|
};
|
|
17031
17066
|
changeVtxo = {
|
|
17032
17067
|
txid: arkTxid,
|
|
@@ -17038,7 +17073,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17038
17073
|
tapTree: offchainTapscript.encode(),
|
|
17039
17074
|
value: Number(changeAmount),
|
|
17040
17075
|
...changeFacts,
|
|
17041
|
-
virtualStatus:
|
|
17076
|
+
virtualStatus: chunkPWIESIO6_cjs.toVirtualStatus(changeFacts),
|
|
17042
17077
|
spentBy: "",
|
|
17043
17078
|
status: {
|
|
17044
17079
|
confirmed: false
|
|
@@ -17107,12 +17142,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17107
17142
|
const spentVtxos = [];
|
|
17108
17143
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
17109
17144
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
17110
|
-
const vtxoInputs = inputs.filter(
|
|
17145
|
+
const vtxoInputs = inputs.filter(chunkPWIESIO6_cjs.isVirtualCoin);
|
|
17111
17146
|
const cm = await this.getContractManager();
|
|
17112
17147
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
17113
17148
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
17114
17149
|
for (const input of inputs) {
|
|
17115
|
-
if (
|
|
17150
|
+
if (chunkPWIESIO6_cjs.isVirtualCoin(input)) {
|
|
17116
17151
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
17117
17152
|
const vtxo = annotatedByKey.get(outpoint);
|
|
17118
17153
|
if (!vtxo) {
|
|
@@ -17124,13 +17159,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17124
17159
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
17125
17160
|
spentVtxos.push({
|
|
17126
17161
|
...settledFacts,
|
|
17127
|
-
virtualStatus:
|
|
17162
|
+
virtualStatus: chunkPWIESIO6_cjs.toVirtualStatus(settledFacts),
|
|
17128
17163
|
settledBy: commitmentTxid
|
|
17129
17164
|
});
|
|
17130
17165
|
} else {
|
|
17131
17166
|
let sourceAddress;
|
|
17132
17167
|
try {
|
|
17133
|
-
sourceAddress =
|
|
17168
|
+
sourceAddress = chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
17134
17169
|
this.network
|
|
17135
17170
|
);
|
|
17136
17171
|
} catch {
|
|
@@ -17188,9 +17223,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17188
17223
|
}
|
|
17189
17224
|
};
|
|
17190
17225
|
function selectVirtualCoins(coins, targetAmount) {
|
|
17191
|
-
const sortedCoins = coins.map(
|
|
17192
|
-
const expiryA =
|
|
17193
|
-
const expiryB =
|
|
17226
|
+
const sortedCoins = coins.map(chunkPWIESIO6_cjs.normalizeVtxo).sort((a, b) => {
|
|
17227
|
+
const expiryA = chunkPWIESIO6_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
17228
|
+
const expiryB = chunkPWIESIO6_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
17194
17229
|
if (expiryA !== expiryB) {
|
|
17195
17230
|
return expiryA - expiryB;
|
|
17196
17231
|
}
|
|
@@ -17559,7 +17594,7 @@ var MessageBus = class {
|
|
|
17559
17594
|
this.initialized = true;
|
|
17560
17595
|
}
|
|
17561
17596
|
async buildServices(config) {
|
|
17562
|
-
const arkProvider = new
|
|
17597
|
+
const arkProvider = new chunkPWIESIO6_cjs.RestArkProvider(config.arkServer.url);
|
|
17563
17598
|
const storage = {
|
|
17564
17599
|
walletRepository: this.walletRepository,
|
|
17565
17600
|
contractRepository: this.contractRepository,
|
|
@@ -17913,7 +17948,7 @@ var offboardNetworkNames = [
|
|
|
17913
17948
|
function offboardDestinationScript(destinationAddress) {
|
|
17914
17949
|
for (const networkName of offboardNetworkNames) {
|
|
17915
17950
|
try {
|
|
17916
|
-
const network =
|
|
17951
|
+
const network = chunkPWIESIO6_cjs.networks[networkName];
|
|
17917
17952
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
17918
17953
|
return btcSigner.OutScript.encode(addr);
|
|
17919
17954
|
} catch {
|
|
@@ -17949,7 +17984,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
|
|
|
17949
17984
|
const inputs = [];
|
|
17950
17985
|
let subtotal = 0n;
|
|
17951
17986
|
for (const vtxo of vtxos) {
|
|
17952
|
-
const inputFee = estimator.evalOffchainInput(
|
|
17987
|
+
const inputFee = estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(vtxo));
|
|
17953
17988
|
if (inputFee.satoshis >= vtxo.value) {
|
|
17954
17989
|
if (named) {
|
|
17955
17990
|
throw new Error(
|
|
@@ -18046,7 +18081,7 @@ var Ramps = class {
|
|
|
18046
18081
|
}
|
|
18047
18082
|
amount = amount ?? totalAmount;
|
|
18048
18083
|
const offchainAddress = await this.wallet.getAddress();
|
|
18049
|
-
const offchainAddr =
|
|
18084
|
+
const offchainAddr = chunkPWIESIO6_cjs.ArkAddress.decode(offchainAddress);
|
|
18050
18085
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
18051
18086
|
const outputFee = estimator.evalOffchainOutput({
|
|
18052
18087
|
amount,
|
|
@@ -18175,7 +18210,7 @@ var Ramps = class {
|
|
|
18175
18210
|
async fundChange(left, estimator) {
|
|
18176
18211
|
if (left <= 0n) return { change: 0n };
|
|
18177
18212
|
const changeAddress = await this.wallet.getAddress();
|
|
18178
|
-
const changeScript = base.hex.encode(
|
|
18213
|
+
const changeScript = base.hex.encode(chunkPWIESIO6_cjs.ArkAddress.decode(changeAddress).pkScript);
|
|
18179
18214
|
const { change } = changeAfterOutputFee(
|
|
18180
18215
|
left,
|
|
18181
18216
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script: changeScript }).satoshis)
|
|
@@ -19008,7 +19043,7 @@ var WalletMessageHandler = class {
|
|
|
19008
19043
|
// Wallet methods
|
|
19009
19044
|
async handleInitWallet({ payload }) {
|
|
19010
19045
|
const { arkServerUrl } = payload;
|
|
19011
|
-
this.indexerProvider = new
|
|
19046
|
+
this.indexerProvider = new chunkIAM5IEVT_cjs.RestIndexerProvider(arkServerUrl);
|
|
19012
19047
|
await this.onWalletInitialized();
|
|
19013
19048
|
}
|
|
19014
19049
|
/**
|
|
@@ -19022,7 +19057,8 @@ var WalletMessageHandler = class {
|
|
|
19022
19057
|
async handleGetBalance() {
|
|
19023
19058
|
const [boardingUtxos, { snapshot, vtxos: allVtxos }] = await Promise.all([
|
|
19024
19059
|
this.getAllBoardingUtxos(),
|
|
19025
|
-
|
|
19060
|
+
// The bucketer drops every spent coin and the gate reads contracts only.
|
|
19061
|
+
this.repoSnapshot({ unspentOnly: true })
|
|
19026
19062
|
]);
|
|
19027
19063
|
const pendingOutpoints = this.readonlyWallet?.pendingRecoveryOutpointsIn(snapshot) ?? /* @__PURE__ */ new Set();
|
|
19028
19064
|
let confirmed = 0;
|
|
@@ -19289,15 +19325,15 @@ var WalletMessageHandler = class {
|
|
|
19289
19325
|
if (!this.readonlyWallet) {
|
|
19290
19326
|
throw new WalletNotInitializedError();
|
|
19291
19327
|
}
|
|
19292
|
-
const allVtxos = await this.getVtxosFromRepo();
|
|
19293
|
-
const dustAmount = this.readonlyWallet.dustAmount;
|
|
19294
19328
|
const withUnrolled = message.payload.filter?.withUnrolled ?? false;
|
|
19329
|
+
const allVtxos = await this.getVtxosFromRepo({ unspentOnly: !withUnrolled });
|
|
19330
|
+
const dustAmount = this.readonlyWallet.dustAmount;
|
|
19295
19331
|
const includeRecoverable = message.payload.filter?.withRecoverable ?? false;
|
|
19296
19332
|
return allVtxos.filter((v) => {
|
|
19297
19333
|
if (v.isUnrolled) {
|
|
19298
19334
|
return withUnrolled;
|
|
19299
19335
|
}
|
|
19300
|
-
if (
|
|
19336
|
+
if (chunkPWIESIO6_cjs.isVtxoSpent(v)) {
|
|
19301
19337
|
return false;
|
|
19302
19338
|
}
|
|
19303
19339
|
if (includeRecoverable) {
|
|
@@ -19306,10 +19342,10 @@ var WalletMessageHandler = class {
|
|
|
19306
19342
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
19307
19343
|
return false;
|
|
19308
19344
|
}
|
|
19309
|
-
if (
|
|
19345
|
+
if (chunkPWIESIO6_cjs.isRecoverable(v)) {
|
|
19310
19346
|
return false;
|
|
19311
19347
|
}
|
|
19312
|
-
if (
|
|
19348
|
+
if (chunkPWIESIO6_cjs.isExpired(v)) {
|
|
19313
19349
|
return false;
|
|
19314
19350
|
}
|
|
19315
19351
|
return true;
|
|
@@ -19341,8 +19377,8 @@ var WalletMessageHandler = class {
|
|
|
19341
19377
|
* Read all virtual outputs from the repository, aggregated across all contract
|
|
19342
19378
|
* addresses and the wallet's primary address, with deduplication.
|
|
19343
19379
|
*/
|
|
19344
|
-
async getVtxosFromRepo() {
|
|
19345
|
-
return (await this.repoSnapshot()).vtxos;
|
|
19380
|
+
async getVtxosFromRepo(options) {
|
|
19381
|
+
return (await this.repoSnapshot(options)).vtxos;
|
|
19346
19382
|
}
|
|
19347
19383
|
/**
|
|
19348
19384
|
* The worker's equivalent of `ReadonlyWallet.contractSnapshot`: contracts
|
|
@@ -19357,7 +19393,7 @@ var WalletMessageHandler = class {
|
|
|
19357
19393
|
* what it knows is closed — so the coins of a just-registered escrowed
|
|
19358
19394
|
* contract would count as available until the next poll.
|
|
19359
19395
|
*/
|
|
19360
|
-
async repoSnapshot() {
|
|
19396
|
+
async repoSnapshot(options) {
|
|
19361
19397
|
if (!this.walletRepository || !this.readonlyWallet) return { snapshot: [], vtxos: [] };
|
|
19362
19398
|
const seen = /* @__PURE__ */ new Set();
|
|
19363
19399
|
const allVtxos = [];
|
|
@@ -19379,7 +19415,9 @@ var WalletMessageHandler = class {
|
|
|
19379
19415
|
for (const contract of contracts) {
|
|
19380
19416
|
snapshot.push({
|
|
19381
19417
|
contract,
|
|
19382
|
-
vtxos: addVtxos(
|
|
19418
|
+
vtxos: addVtxos(
|
|
19419
|
+
await getVtxosForContract(this.walletRepository, contract, options)
|
|
19420
|
+
)
|
|
19383
19421
|
});
|
|
19384
19422
|
}
|
|
19385
19423
|
const walletAddress = await this.readonlyWallet.getAddress();
|
|
@@ -19392,10 +19430,11 @@ var WalletMessageHandler = class {
|
|
|
19392
19430
|
);
|
|
19393
19431
|
}
|
|
19394
19432
|
addVtxos(
|
|
19395
|
-
await getVtxosForContract(
|
|
19396
|
-
|
|
19397
|
-
address: walletAddress
|
|
19398
|
-
|
|
19433
|
+
await getVtxosForContract(
|
|
19434
|
+
this.walletRepository,
|
|
19435
|
+
{ script: walletScript, address: walletAddress },
|
|
19436
|
+
options
|
|
19437
|
+
)
|
|
19399
19438
|
);
|
|
19400
19439
|
return { snapshot, vtxos: allVtxos };
|
|
19401
19440
|
}
|
|
@@ -19417,7 +19456,7 @@ var WalletMessageHandler = class {
|
|
|
19417
19456
|
this.readonlyWallet.getBoardingTxs()
|
|
19418
19457
|
]);
|
|
19419
19458
|
const indexerProvider = this.indexerProvider;
|
|
19420
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
19459
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkPWIESIO6_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
19421
19460
|
return buildTransactionHistory(
|
|
19422
19461
|
vtxos,
|
|
19423
19462
|
boardingTxs,
|
|
@@ -20125,7 +20164,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20125
20164
|
};
|
|
20126
20165
|
try {
|
|
20127
20166
|
const response = await this.sendMessage(message);
|
|
20128
|
-
return response.payload.vtxos.map(
|
|
20167
|
+
return response.payload.vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo);
|
|
20129
20168
|
} catch (error) {
|
|
20130
20169
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
20131
20170
|
}
|
|
@@ -20156,7 +20195,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20156
20195
|
"Service worker does not support the requested contract scope or freshness check"
|
|
20157
20196
|
);
|
|
20158
20197
|
}
|
|
20159
|
-
return payload.vtxos.map(
|
|
20198
|
+
return payload.vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo);
|
|
20160
20199
|
} catch (error) {
|
|
20161
20200
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
20162
20201
|
}
|
|
@@ -20332,7 +20371,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20332
20371
|
};
|
|
20333
20372
|
try {
|
|
20334
20373
|
const response = await sendContractMessage(message);
|
|
20335
|
-
return response.payload.vtxos.map(
|
|
20374
|
+
return response.payload.vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo);
|
|
20336
20375
|
} catch (e) {
|
|
20337
20376
|
throw new Error("Failed to annotate vtxos");
|
|
20338
20377
|
}
|
|
@@ -20944,7 +20983,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
20944
20983
|
};
|
|
20945
20984
|
try {
|
|
20946
20985
|
const response = await wallet.sendMessage(message);
|
|
20947
|
-
return response.payload.vtxos.map(
|
|
20986
|
+
return response.payload.vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo);
|
|
20948
20987
|
} catch (e) {
|
|
20949
20988
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
20950
20989
|
}
|
|
@@ -21056,12 +21095,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21056
21095
|
* @returns Configured onchain wallet
|
|
21057
21096
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
21058
21097
|
*/
|
|
21059
|
-
static async create(identity, networkName =
|
|
21098
|
+
static async create(identity, networkName = chunkPWIESIO6_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
21060
21099
|
const pubkey = await identity.xOnlyPublicKey();
|
|
21061
21100
|
if (!pubkey) {
|
|
21062
21101
|
throw new Error("Invalid configured public key");
|
|
21063
21102
|
}
|
|
21064
|
-
const network =
|
|
21103
|
+
const network = chunkPWIESIO6_cjs.getNetwork(networkName);
|
|
21065
21104
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
21066
21105
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
21067
21106
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -21167,7 +21206,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21167
21206
|
if (!inputs) {
|
|
21168
21207
|
throw new Error("Fee estimation failed");
|
|
21169
21208
|
}
|
|
21170
|
-
let tx = new
|
|
21209
|
+
let tx = new chunkPWIESIO6_cjs.Transaction();
|
|
21171
21210
|
for (const input of inputs) {
|
|
21172
21211
|
tx.addInput({
|
|
21173
21212
|
txid: input.txid,
|
|
@@ -21225,7 +21264,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21225
21264
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
21226
21265
|
*/
|
|
21227
21266
|
async bumpAnchor(parentHex, feeRate) {
|
|
21228
|
-
const parent =
|
|
21267
|
+
const parent = chunkPWIESIO6_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
21229
21268
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
21230
21269
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
21231
21270
|
return [parent.hex, child.hex];
|
|
@@ -22132,7 +22171,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
22132
22171
|
try {
|
|
22133
22172
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
22134
22173
|
for (const psbt of txs) {
|
|
22135
|
-
const tx =
|
|
22174
|
+
const tx = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
22136
22175
|
resolved.set(tx.id, tx.toBytes());
|
|
22137
22176
|
}
|
|
22138
22177
|
} catch (err) {
|
|
@@ -22165,7 +22204,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
22165
22204
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
22166
22205
|
const pending = [];
|
|
22167
22206
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
22168
|
-
if (
|
|
22207
|
+
if (chunkPWIESIO6_cjs.getArkPsbtFields(tx, i, chunkPWIESIO6_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
22169
22208
|
}
|
|
22170
22209
|
if (pending.length === 0) return;
|
|
22171
22210
|
const resolved = await resolvePrevTxs(
|
|
@@ -22174,13 +22213,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
22174
22213
|
onchain
|
|
22175
22214
|
);
|
|
22176
22215
|
for (const i of pending) {
|
|
22177
|
-
|
|
22216
|
+
chunkPWIESIO6_cjs.setArkPsbtField(tx, i, chunkPWIESIO6_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
22178
22217
|
}
|
|
22179
22218
|
}
|
|
22180
22219
|
async function attachPrevoutTxs(tx, source) {
|
|
22181
22220
|
const pending = [];
|
|
22182
22221
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
22183
|
-
if (
|
|
22222
|
+
if (chunkPWIESIO6_cjs.getArkPsbtFields(tx, i, chunkPWIESIO6_cjs.PrevoutTxField).length > 0) continue;
|
|
22184
22223
|
const input = tx.getInput(i);
|
|
22185
22224
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
22186
22225
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -22191,7 +22230,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
22191
22230
|
resolved.set(txid, await source.getRawTransaction(txid));
|
|
22192
22231
|
}
|
|
22193
22232
|
for (const { index, txid } of pending) {
|
|
22194
|
-
|
|
22233
|
+
chunkPWIESIO6_cjs.setArkPsbtField(tx, index, chunkPWIESIO6_cjs.PrevoutTxField, resolved.get(txid));
|
|
22195
22234
|
}
|
|
22196
22235
|
}
|
|
22197
22236
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -22217,7 +22256,7 @@ exports.BIP322 = void 0;
|
|
|
22217
22256
|
async function sign2(message, identity, network) {
|
|
22218
22257
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
22219
22258
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
22220
|
-
const toSpend =
|
|
22259
|
+
const toSpend = chunkPWIESIO6_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
22221
22260
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
22222
22261
|
const signed = await identity.sign(toSign, [0]);
|
|
22223
22262
|
signed.finalizeIdx(0);
|
|
@@ -22275,7 +22314,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
22275
22314
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
22276
22315
|
return false;
|
|
22277
22316
|
}
|
|
22278
|
-
const toSpend =
|
|
22317
|
+
const toSpend = chunkPWIESIO6_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
22279
22318
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
22280
22319
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
22281
22320
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -22296,7 +22335,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
22296
22335
|
}
|
|
22297
22336
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
22298
22337
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
22299
|
-
const toSpend =
|
|
22338
|
+
const toSpend = chunkPWIESIO6_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
22300
22339
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
22301
22340
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
22302
22341
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -22349,7 +22388,7 @@ function encodeCompactSize(n) {
|
|
|
22349
22388
|
return buf;
|
|
22350
22389
|
}
|
|
22351
22390
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
22352
|
-
const tx = new
|
|
22391
|
+
const tx = new chunkPWIESIO6_cjs.Transaction({ version: 0 });
|
|
22353
22392
|
tx.addInput({
|
|
22354
22393
|
txid: toSpend.id,
|
|
22355
22394
|
index: 0,
|
|
@@ -22363,12 +22402,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
22363
22402
|
});
|
|
22364
22403
|
tx.addOutput({
|
|
22365
22404
|
amount: 0n,
|
|
22366
|
-
script:
|
|
22405
|
+
script: chunkPWIESIO6_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
22367
22406
|
});
|
|
22368
22407
|
return tx;
|
|
22369
22408
|
}
|
|
22370
22409
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
22371
|
-
const tx = new
|
|
22410
|
+
const tx = new chunkPWIESIO6_cjs.Transaction({ version: 0 });
|
|
22372
22411
|
tx.addInput({
|
|
22373
22412
|
txid: toSpend.id,
|
|
22374
22413
|
index: 0,
|
|
@@ -22380,7 +22419,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
22380
22419
|
});
|
|
22381
22420
|
tx.addOutput({
|
|
22382
22421
|
amount: 0n,
|
|
22383
|
-
script:
|
|
22422
|
+
script: chunkPWIESIO6_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
22384
22423
|
});
|
|
22385
22424
|
return tx;
|
|
22386
22425
|
}
|
|
@@ -22393,7 +22432,7 @@ var RestEmulatorProvider = class {
|
|
|
22393
22432
|
serverUrl;
|
|
22394
22433
|
async getInfo() {
|
|
22395
22434
|
const url = `${this.serverUrl}/v1/info`;
|
|
22396
|
-
const response = await
|
|
22435
|
+
const response = await chunkPWIESIO6_cjs.baseFetch(url);
|
|
22397
22436
|
if (!response.ok) {
|
|
22398
22437
|
const errorText2 = await response.text();
|
|
22399
22438
|
throw new Error(`Failed to get emulator info: ${errorText2}`);
|
|
@@ -22511,7 +22550,7 @@ var RestEmulatorProvider = class {
|
|
|
22511
22550
|
}
|
|
22512
22551
|
};
|
|
22513
22552
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
22514
|
-
const tx =
|
|
22553
|
+
const tx = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
22515
22554
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
22516
22555
|
const input = tx.getInput(0);
|
|
22517
22556
|
if (!input) {
|
|
@@ -22538,14 +22577,14 @@ var ExitPathError = class extends Error {
|
|
|
22538
22577
|
reason;
|
|
22539
22578
|
};
|
|
22540
22579
|
function delayWeight(sequence) {
|
|
22541
|
-
const t =
|
|
22580
|
+
const t = chunkPWIESIO6_cjs.sequenceToTimelock(sequence);
|
|
22542
22581
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
22543
22582
|
}
|
|
22544
22583
|
async function resolveUnilateralPath(params) {
|
|
22545
22584
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
22546
22585
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
22547
22586
|
if (contract) {
|
|
22548
|
-
const handler =
|
|
22587
|
+
const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
|
|
22549
22588
|
if (!handler) {
|
|
22550
22589
|
throw new ExitPathError(
|
|
22551
22590
|
"no-handler",
|
|
@@ -22568,12 +22607,12 @@ async function resolveUnilateralPath(params) {
|
|
|
22568
22607
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
22569
22608
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
22570
22609
|
}
|
|
22571
|
-
const decoded =
|
|
22610
|
+
const decoded = chunkPWIESIO6_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
22572
22611
|
let best;
|
|
22573
22612
|
for (const exit of decoded.exitPaths()) {
|
|
22574
22613
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
22575
22614
|
if (!leaf) continue;
|
|
22576
|
-
const sequence =
|
|
22615
|
+
const sequence = chunkPWIESIO6_cjs.timelockToSequence(exit.params.timelock);
|
|
22577
22616
|
const weight = delayWeight(sequence);
|
|
22578
22617
|
if (!best || weight < best.weight) {
|
|
22579
22618
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -22793,7 +22832,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22793
22832
|
let totalAmount = 0n;
|
|
22794
22833
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
22795
22834
|
for (const vtxo of vtxos) {
|
|
22796
|
-
if (!
|
|
22835
|
+
if (!chunkPWIESIO6_cjs.canSweepOnchain(vtxo)) {
|
|
22797
22836
|
throw new Error(
|
|
22798
22837
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
22799
22838
|
);
|
|
@@ -22804,14 +22843,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22804
22843
|
}
|
|
22805
22844
|
const resolved = await resolveUnilateralPath({
|
|
22806
22845
|
vtxo,
|
|
22807
|
-
scriptHex: base.hex.encode(
|
|
22846
|
+
scriptHex: base.hex.encode(chunkPWIESIO6_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
22808
22847
|
contractRepository: wallet.contractRepository,
|
|
22809
22848
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
22810
22849
|
currentTime: Date.now()
|
|
22811
22850
|
});
|
|
22812
22851
|
const spendingLeaf = resolved.selection.leaf;
|
|
22813
22852
|
const sequence = resolved.selection.sequence;
|
|
22814
|
-
const timelock =
|
|
22853
|
+
const timelock = chunkPWIESIO6_cjs.sequenceToTimelock(sequence);
|
|
22815
22854
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
22816
22855
|
if (!elapsed) {
|
|
22817
22856
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -22824,7 +22863,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22824
22863
|
sequence,
|
|
22825
22864
|
witnessUtxo: {
|
|
22826
22865
|
amount: BigInt(vtxo.value),
|
|
22827
|
-
script:
|
|
22866
|
+
script: chunkPWIESIO6_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
22828
22867
|
},
|
|
22829
22868
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
22830
22869
|
});
|
|
@@ -22834,7 +22873,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22834
22873
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
22835
22874
|
);
|
|
22836
22875
|
}
|
|
22837
|
-
const tx = new
|
|
22876
|
+
const tx = new chunkPWIESIO6_cjs.Transaction({ version: 2 });
|
|
22838
22877
|
for (const input of inputs) {
|
|
22839
22878
|
tx.addInput(input);
|
|
22840
22879
|
}
|
|
@@ -22917,7 +22956,7 @@ async function buildSignedSweep(params) {
|
|
|
22917
22956
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
22918
22957
|
);
|
|
22919
22958
|
}
|
|
22920
|
-
const tx = new
|
|
22959
|
+
const tx = new chunkPWIESIO6_cjs.Transaction({ version: 2 });
|
|
22921
22960
|
tx.addInput({
|
|
22922
22961
|
txid: vtxo.txid,
|
|
22923
22962
|
index: vtxo.vout,
|
|
@@ -22942,7 +22981,7 @@ async function buildSignedSweep(params) {
|
|
|
22942
22981
|
finalScriptWitness: [
|
|
22943
22982
|
tapScriptSig[0][1],
|
|
22944
22983
|
...path.extraWitness,
|
|
22945
|
-
|
|
22984
|
+
chunkPWIESIO6_cjs.scriptFromTapLeafScript(path.leaf),
|
|
22946
22985
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
22947
22986
|
]
|
|
22948
22987
|
});
|
|
@@ -22972,7 +23011,7 @@ async function resolveFeeRate(opts) {
|
|
|
22972
23011
|
}
|
|
22973
23012
|
async function selectExitVtxos(opts) {
|
|
22974
23013
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
22975
|
-
const res = await
|
|
23014
|
+
const res = await chunkPWIESIO6_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
22976
23015
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
22977
23016
|
const out = [];
|
|
22978
23017
|
for (const vtxo of res.vtxos) {
|
|
@@ -22987,7 +23026,7 @@ async function selectExitVtxos(opts) {
|
|
|
22987
23026
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
22988
23027
|
);
|
|
22989
23028
|
}
|
|
22990
|
-
const handler =
|
|
23029
|
+
const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
|
|
22991
23030
|
if (!handler) {
|
|
22992
23031
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
22993
23032
|
}
|
|
@@ -23017,7 +23056,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23017
23056
|
if (pendingNodes.length > 0) {
|
|
23018
23057
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
23019
23058
|
for (const psbt of txs) {
|
|
23020
|
-
psbts.set(
|
|
23059
|
+
psbts.set(chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
23021
23060
|
}
|
|
23022
23061
|
}
|
|
23023
23062
|
const childVsize = Number(
|
|
@@ -23053,7 +23092,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23053
23092
|
try {
|
|
23054
23093
|
const resolved = await resolveUnilateralPath({
|
|
23055
23094
|
vtxo,
|
|
23056
|
-
scriptHex: base.hex.encode(
|
|
23095
|
+
scriptHex: base.hex.encode(chunkPWIESIO6_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
23057
23096
|
contractRepository: wallet.contractRepository,
|
|
23058
23097
|
walletPubKeyHex,
|
|
23059
23098
|
currentTime: Date.now()
|
|
@@ -23072,7 +23111,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23072
23111
|
});
|
|
23073
23112
|
continue;
|
|
23074
23113
|
}
|
|
23075
|
-
const t =
|
|
23114
|
+
const t = chunkPWIESIO6_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
23076
23115
|
const delay = { type: t.type, value: Number(t.value) };
|
|
23077
23116
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
23078
23117
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -23473,7 +23512,7 @@ async function prepare(opts) {
|
|
|
23473
23512
|
txid: sweep.vtxo.txid,
|
|
23474
23513
|
vout: sweep.vtxo.vout,
|
|
23475
23514
|
value: sweep.vtxo.value,
|
|
23476
|
-
pkScript:
|
|
23515
|
+
pkScript: chunkPWIESIO6_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
23477
23516
|
},
|
|
23478
23517
|
path: sweep.resolved.selection,
|
|
23479
23518
|
outputAddress: opts.sweepAddress,
|
|
@@ -23562,7 +23601,7 @@ async function prepare(opts) {
|
|
|
23562
23601
|
if (newFee <= splitterFee) break;
|
|
23563
23602
|
splitterFee = newFee;
|
|
23564
23603
|
}
|
|
23565
|
-
const splitter = new
|
|
23604
|
+
const splitter = new chunkPWIESIO6_cjs.Transaction({ version: 2 });
|
|
23566
23605
|
for (const coin of selected.inputs) {
|
|
23567
23606
|
splitter.addInput({
|
|
23568
23607
|
txid: coin.txid,
|
|
@@ -23706,43 +23745,43 @@ var UnilateralExit = {
|
|
|
23706
23745
|
// src/arkade/index.ts
|
|
23707
23746
|
var arkade_exports = {};
|
|
23708
23747
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
23709
|
-
ARKADE_OP: () =>
|
|
23710
|
-
ARKADE_OPCODES: () =>
|
|
23711
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
23712
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
23713
|
-
ARKADE_OPS: () =>
|
|
23748
|
+
ARKADE_OP: () => chunkY7BVR6SQ_cjs.ARKADE_OP,
|
|
23749
|
+
ARKADE_OPCODES: () => chunkY7BVR6SQ_cjs.ARKADE_OPCODES,
|
|
23750
|
+
ARKADE_OPCODE_NAMES: () => chunkY7BVR6SQ_cjs.ARKADE_OPCODE_NAMES,
|
|
23751
|
+
ARKADE_OPCODE_VALUES: () => chunkY7BVR6SQ_cjs.ARKADE_OPCODE_VALUES,
|
|
23752
|
+
ARKADE_OPS: () => chunkY7BVR6SQ_cjs.ARKADE_OPS,
|
|
23714
23753
|
Arkade: () => Arkade,
|
|
23715
23754
|
ArkadeContract: () => ArkadeContract,
|
|
23716
|
-
ArkadeProgramScript: () =>
|
|
23717
|
-
ArkadeScript: () =>
|
|
23755
|
+
ArkadeProgramScript: () => chunkY7BVR6SQ_cjs.ArkadeProgramScript,
|
|
23756
|
+
ArkadeScript: () => chunkY7BVR6SQ_cjs.ArkadeScript,
|
|
23718
23757
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
23719
|
-
BigNum: () =>
|
|
23758
|
+
BigNum: () => chunkY7BVR6SQ_cjs.bignum_exports,
|
|
23720
23759
|
OP: () => btcSigner.OP,
|
|
23721
|
-
OPCODE_NAMES: () =>
|
|
23722
|
-
OPCODE_VALUES: () =>
|
|
23723
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
23760
|
+
OPCODE_NAMES: () => chunkY7BVR6SQ_cjs.OPCODE_NAMES,
|
|
23761
|
+
OPCODE_VALUES: () => chunkY7BVR6SQ_cjs.OPCODE_VALUES,
|
|
23762
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkY7BVR6SQ_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
23724
23763
|
Script: () => btcSigner.Script,
|
|
23725
|
-
arkadeScriptHash: () =>
|
|
23726
|
-
arkadeWitnessHash: () =>
|
|
23727
|
-
asmToBytes: () =>
|
|
23728
|
-
bytesToASM: () =>
|
|
23729
|
-
computeArkadeScriptPublicKey: () =>
|
|
23764
|
+
arkadeScriptHash: () => chunkY7BVR6SQ_cjs.arkadeScriptHash,
|
|
23765
|
+
arkadeWitnessHash: () => chunkY7BVR6SQ_cjs.arkadeWitnessHash,
|
|
23766
|
+
asmToBytes: () => chunkY7BVR6SQ_cjs.asmToBytes,
|
|
23767
|
+
bytesToASM: () => chunkY7BVR6SQ_cjs.bytesToASM,
|
|
23768
|
+
computeArkadeScriptPublicKey: () => chunkY7BVR6SQ_cjs.computeArkadeScriptPublicKey,
|
|
23730
23769
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
23731
|
-
deserializeArkadeContractParams: () =>
|
|
23732
|
-
fromASM: () =>
|
|
23733
|
-
getOpcodeName: () =>
|
|
23734
|
-
getOpcodeValue: () =>
|
|
23770
|
+
deserializeArkadeContractParams: () => chunkY7BVR6SQ_cjs.deserializeArkadeContractParams,
|
|
23771
|
+
fromASM: () => chunkY7BVR6SQ_cjs.fromASM,
|
|
23772
|
+
getOpcodeName: () => chunkY7BVR6SQ_cjs.getOpcodeName,
|
|
23773
|
+
getOpcodeValue: () => chunkY7BVR6SQ_cjs.getOpcodeValue,
|
|
23735
23774
|
isContractArtifact: () => isContractArtifact,
|
|
23736
|
-
parseArtifact: () =>
|
|
23775
|
+
parseArtifact: () => chunkY7BVR6SQ_cjs.parseArtifact,
|
|
23737
23776
|
programFromArtifact: () => programFromArtifact,
|
|
23738
|
-
resolveAsm: () =>
|
|
23739
|
-
serializeArkadeContractParams: () =>
|
|
23740
|
-
stringifyArtifact: () =>
|
|
23741
|
-
toASM: () =>
|
|
23742
|
-
validateProgram: () =>
|
|
23743
|
-
witnessRefToBytes: () =>
|
|
23777
|
+
resolveAsm: () => chunkY7BVR6SQ_cjs.resolveAsm,
|
|
23778
|
+
serializeArkadeContractParams: () => chunkY7BVR6SQ_cjs.serializeArkadeContractParams,
|
|
23779
|
+
stringifyArtifact: () => chunkY7BVR6SQ_cjs.stringifyArtifact,
|
|
23780
|
+
toASM: () => chunkY7BVR6SQ_cjs.toASM,
|
|
23781
|
+
validateProgram: () => chunkY7BVR6SQ_cjs.validateProgram,
|
|
23782
|
+
witnessRefToBytes: () => chunkY7BVR6SQ_cjs.witnessRefToBytes
|
|
23744
23783
|
});
|
|
23745
|
-
var isVtxoCoin = (input) =>
|
|
23784
|
+
var isVtxoCoin = (input) => chunkPWIESIO6_cjs.isVirtualCoin(input);
|
|
23746
23785
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
23747
23786
|
let batchId;
|
|
23748
23787
|
let sweepTapTreeRoot;
|
|
@@ -23763,23 +23802,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23763
23802
|
);
|
|
23764
23803
|
await arkProvider.confirmRegistration(intentId);
|
|
23765
23804
|
batchId = event.id;
|
|
23766
|
-
const sweepTapscript =
|
|
23805
|
+
const sweepTapscript = chunkPWIESIO6_cjs.CSVMultisigTapscript.encode({
|
|
23767
23806
|
timelock,
|
|
23768
|
-
pubkeys: [
|
|
23807
|
+
pubkeys: [chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
|
|
23769
23808
|
}).script;
|
|
23770
23809
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
23771
23810
|
return { skip: false };
|
|
23772
23811
|
},
|
|
23773
23812
|
onTreeSigningStarted: async (event, vtxoTree) => {
|
|
23774
23813
|
const signerPubKey = await session.getPublicKey();
|
|
23775
|
-
const xonlySignerPubKey =
|
|
23814
|
+
const xonlySignerPubKey = chunkY7BVR6SQ_cjs.toXOnly(signerPubKey, "signer key");
|
|
23776
23815
|
const xOnlyPubkeys = event.cosignersPublicKeys.map(
|
|
23777
|
-
(k) => base.hex.encode(
|
|
23816
|
+
(k) => base.hex.encode(chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
23778
23817
|
);
|
|
23779
23818
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
23780
23819
|
return { skip: true };
|
|
23781
23820
|
}
|
|
23782
|
-
const commitmentTx =
|
|
23821
|
+
const commitmentTx = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
23783
23822
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
23784
23823
|
if (recipients && recipients.length > 0) {
|
|
23785
23824
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -23817,7 +23856,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23817
23856
|
if (connectorTree) {
|
|
23818
23857
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
23819
23858
|
}
|
|
23820
|
-
let commitmentPsbt =
|
|
23859
|
+
let commitmentPsbt = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
23821
23860
|
assertFinalCommitmentMatchesValidated(
|
|
23822
23861
|
commitmentPsbt,
|
|
23823
23862
|
validatedCommitmentTxid,
|
|
@@ -23859,7 +23898,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23859
23898
|
boardingIndices.push(boardingIdx);
|
|
23860
23899
|
continue;
|
|
23861
23900
|
}
|
|
23862
|
-
if (
|
|
23901
|
+
if (!chunkPWIESIO6_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
|
|
23863
23902
|
continue;
|
|
23864
23903
|
}
|
|
23865
23904
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -23880,7 +23919,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23880
23919
|
index: input.vout,
|
|
23881
23920
|
witnessUtxo: {
|
|
23882
23921
|
amount: BigInt(input.value),
|
|
23883
|
-
script:
|
|
23922
|
+
script: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
23884
23923
|
},
|
|
23885
23924
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
23886
23925
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -24025,7 +24064,7 @@ function flatten(param, structs, stack = []) {
|
|
|
24025
24064
|
function opcodeToken(token) {
|
|
24026
24065
|
const base = token.slice(3);
|
|
24027
24066
|
const name = base === "0" || /^([1-9]|1[0-6])$/.test(base) ? token : base;
|
|
24028
|
-
if (!Object.hasOwn(
|
|
24067
|
+
if (!Object.hasOwn(chunkY7BVR6SQ_cjs.ARKADE_OPS, name)) {
|
|
24029
24068
|
fail(`opcode '${token}' is not in this SDK's table`);
|
|
24030
24069
|
}
|
|
24031
24070
|
return name;
|
|
@@ -24070,6 +24109,14 @@ function providedWitness(witness) {
|
|
|
24070
24109
|
return !item.injected && item.type !== "signature";
|
|
24071
24110
|
});
|
|
24072
24111
|
}
|
|
24112
|
+
function csvTimelock(leafName, operand) {
|
|
24113
|
+
if (typeof operand === "string") return { type: "blocks", value: operand };
|
|
24114
|
+
const timelock = operand >= 0n && operand < 0x80000000n ? chunkPWIESIO6_cjs.sequenceToTimelock(Number(operand)) : void 0;
|
|
24115
|
+
if (!timelock || BigInt(chunkPWIESIO6_cjs.timelockToSequence(timelock)) !== operand) {
|
|
24116
|
+
fail(`leaf '${leafName}': CSV literal ${operand} is not a canonical BIP68 sequence`);
|
|
24117
|
+
}
|
|
24118
|
+
return timelock;
|
|
24119
|
+
}
|
|
24073
24120
|
function parseLeaf(leaf, hasCovenant, instantiations, extras) {
|
|
24074
24121
|
const asm = leaf.asm;
|
|
24075
24122
|
let index = 0;
|
|
@@ -24084,7 +24131,7 @@ function parseLeaf(leaf, hasCovenant, instantiations, extras) {
|
|
|
24084
24131
|
let cltv;
|
|
24085
24132
|
if (asm.length >= index + 3 && asm[index + 2] === "OP_DROP") {
|
|
24086
24133
|
const operand = asm[index].startsWith("<") && asm[index].endsWith(">") ? `$${asm[index].slice(1, -1)}` : BigInt(asm[index]);
|
|
24087
|
-
if (asm[index + 1] === "OP_CHECKSEQUENCEVERIFY") csv =
|
|
24134
|
+
if (asm[index + 1] === "OP_CHECKSEQUENCEVERIFY") csv = csvTimelock(leaf.name, operand);
|
|
24088
24135
|
else if (asm[index + 1] === "OP_CHECKLOCKTIMEVERIFY") cltv = operand;
|
|
24089
24136
|
else fail(`leaf '${leaf.name}': unexpected timelock opcode ${asm[index + 1]}`);
|
|
24090
24137
|
index += 3;
|
|
@@ -24183,7 +24230,7 @@ function programFromArtifact(artifact) {
|
|
|
24183
24230
|
const paramNames = /* @__PURE__ */ new Set();
|
|
24184
24231
|
for (const param of params) claim(paramNames, param.name, "program parameter");
|
|
24185
24232
|
return {
|
|
24186
|
-
version:
|
|
24233
|
+
version: chunkY7BVR6SQ_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
24187
24234
|
name: artifact.contractName,
|
|
24188
24235
|
params,
|
|
24189
24236
|
functions
|
|
@@ -24228,16 +24275,16 @@ var Arkade = class _Arkade {
|
|
|
24228
24275
|
/** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
|
|
24229
24276
|
static async connect(opts) {
|
|
24230
24277
|
const info = await opts.arkade.getInfo();
|
|
24231
|
-
const serverKey =
|
|
24232
|
-
const checkpoint =
|
|
24233
|
-
const network = opts.network ?? (Object.hasOwn(
|
|
24278
|
+
const serverKey = chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
24279
|
+
const checkpoint = chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
24280
|
+
const network = opts.network ?? (Object.hasOwn(chunkPWIESIO6_cjs.networks, info.network) ? chunkPWIESIO6_cjs.getNetwork(info.network) : chunkPWIESIO6_cjs.DEFAULT_NETWORK);
|
|
24234
24281
|
let emulatorKey;
|
|
24235
24282
|
if (opts.emulator) {
|
|
24236
|
-
emulatorKey = base.hex.decode(
|
|
24283
|
+
emulatorKey = base.hex.decode(chunkPWIESIO6_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
24237
24284
|
}
|
|
24238
24285
|
let userKey;
|
|
24239
24286
|
if (opts.identity) {
|
|
24240
|
-
userKey =
|
|
24287
|
+
userKey = chunkY7BVR6SQ_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
|
|
24241
24288
|
}
|
|
24242
24289
|
return new _Arkade({
|
|
24243
24290
|
arkProvider: opts.arkade,
|
|
@@ -24263,7 +24310,7 @@ var Arkade = class _Arkade {
|
|
|
24263
24310
|
* key respectively; explicit args always win.
|
|
24264
24311
|
*/
|
|
24265
24312
|
contract(program, args = {}) {
|
|
24266
|
-
const declared = (program.params ?? []).map(
|
|
24313
|
+
const declared = (program.params ?? []).map(chunkY7BVR6SQ_cjs.inputName);
|
|
24267
24314
|
if (declared.includes("server") && args.server === void 0) {
|
|
24268
24315
|
args = { ...args, server: this.serverKey };
|
|
24269
24316
|
}
|
|
@@ -24283,7 +24330,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24283
24330
|
userKey: client.userKey,
|
|
24284
24331
|
emulatorKey: client.emulatorKey
|
|
24285
24332
|
};
|
|
24286
|
-
this.vtxoScript = new
|
|
24333
|
+
this.vtxoScript = new chunkY7BVR6SQ_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
24287
24334
|
this.tapTree = this.vtxoScript.encode();
|
|
24288
24335
|
this.compiled = this.vtxoScript.compiled;
|
|
24289
24336
|
}
|
|
@@ -24311,7 +24358,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24311
24358
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
24312
24359
|
);
|
|
24313
24360
|
}
|
|
24314
|
-
const typed =
|
|
24361
|
+
const typed = chunkY7BVR6SQ_cjs.deserializeArkadeContractParams(contract.params);
|
|
24315
24362
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
24316
24363
|
serverKey: typed.serverKey,
|
|
24317
24364
|
userKey: typed.userKey,
|
|
@@ -24352,7 +24399,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24352
24399
|
toContractParams() {
|
|
24353
24400
|
return {
|
|
24354
24401
|
type: "arkade",
|
|
24355
|
-
params:
|
|
24402
|
+
params: chunkY7BVR6SQ_cjs.serializeArkadeContractParams({
|
|
24356
24403
|
program: this.program,
|
|
24357
24404
|
args: this.args,
|
|
24358
24405
|
serverKey: this.keys.serverKey,
|
|
@@ -24401,17 +24448,17 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24401
24448
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
24402
24449
|
if (registered) {
|
|
24403
24450
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
24404
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
24451
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkPWIESIO6_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
24405
24452
|
}
|
|
24406
24453
|
}
|
|
24407
24454
|
if (!this.client.indexer) {
|
|
24408
24455
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
24409
24456
|
}
|
|
24410
|
-
const { vtxos } = await
|
|
24457
|
+
const { vtxos } = await chunkPWIESIO6_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
24411
24458
|
scripts: [scriptHex],
|
|
24412
24459
|
spendableOnly: true
|
|
24413
24460
|
});
|
|
24414
|
-
return vtxos.filter((v) => !
|
|
24461
|
+
return vtxos.filter((v) => !chunkPWIESIO6_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
24415
24462
|
}
|
|
24416
24463
|
/** Total spendable balance (requires an indexer). */
|
|
24417
24464
|
async getBalance() {
|
|
@@ -24509,7 +24556,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
24509
24556
|
this.contract.client.checkpoint
|
|
24510
24557
|
);
|
|
24511
24558
|
if (coin.sourceTx) {
|
|
24512
|
-
|
|
24559
|
+
chunkPWIESIO6_cjs.setArkPsbtField(arkTx, 0, chunkPWIESIO6_cjs.PrevArkTxField, coin.sourceTx);
|
|
24513
24560
|
}
|
|
24514
24561
|
if (this.fn.arkadeScript) {
|
|
24515
24562
|
const indexer = this.contract.client.indexer;
|
|
@@ -24526,8 +24573,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
24526
24573
|
}
|
|
24527
24574
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
24528
24575
|
if (condition.length > 0) {
|
|
24529
|
-
|
|
24530
|
-
|
|
24576
|
+
chunkPWIESIO6_cjs.setArkPsbtField(arkTx, 0, chunkPWIESIO6_cjs.ConditionWitness, condition);
|
|
24577
|
+
chunkPWIESIO6_cjs.setArkPsbtField(checkpoints[0], 0, chunkPWIESIO6_cjs.ConditionWitness, condition);
|
|
24531
24578
|
}
|
|
24532
24579
|
const packets = [];
|
|
24533
24580
|
if (this.assetSpecs.length > 0) {
|
|
@@ -24566,7 +24613,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
24566
24613
|
base.base64.encode(signedArk2.toPSBT()),
|
|
24567
24614
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
24568
24615
|
);
|
|
24569
|
-
const txid =
|
|
24616
|
+
const txid = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
24570
24617
|
return {
|
|
24571
24618
|
txid,
|
|
24572
24619
|
signedArkTx: res2.signedArkTx,
|
|
@@ -24625,23 +24672,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
24625
24672
|
}
|
|
24626
24673
|
buildAssetPacket() {
|
|
24627
24674
|
const groups = this.assetSpecs.map((s) => {
|
|
24628
|
-
const id = typeof s.assetId === "string" ?
|
|
24629
|
-
return
|
|
24675
|
+
const id = typeof s.assetId === "string" ? chunkIAM5IEVT_cjs.AssetId.fromString(s.assetId) : chunkIAM5IEVT_cjs.AssetId.fromBytes(s.assetId);
|
|
24676
|
+
return chunkIAM5IEVT_cjs.AssetGroup.create(
|
|
24630
24677
|
id,
|
|
24631
24678
|
null,
|
|
24632
|
-
s.inputs.map((i) =>
|
|
24633
|
-
s.outputs.map((o) =>
|
|
24634
|
-
(s.metadata ?? []).map((m) =>
|
|
24679
|
+
s.inputs.map((i) => chunkIAM5IEVT_cjs.AssetInput.create(i.vin, i.amount)),
|
|
24680
|
+
s.outputs.map((o) => chunkIAM5IEVT_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
24681
|
+
(s.metadata ?? []).map((m) => chunkIAM5IEVT_cjs.Metadata.create(m.key, m.value))
|
|
24635
24682
|
);
|
|
24636
24683
|
});
|
|
24637
|
-
return
|
|
24684
|
+
return chunkIAM5IEVT_cjs.Packet.create(groups);
|
|
24638
24685
|
}
|
|
24639
24686
|
witnessBytes(ref) {
|
|
24640
|
-
return
|
|
24687
|
+
return chunkY7BVR6SQ_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
24641
24688
|
}
|
|
24642
24689
|
};
|
|
24643
24690
|
function bindInputs(fn, callArgs) {
|
|
24644
|
-
const names = (fn.def.inputs ?? []).map(
|
|
24691
|
+
const names = (fn.def.inputs ?? []).map(chunkY7BVR6SQ_cjs.inputName);
|
|
24645
24692
|
if (callArgs.length !== names.length) {
|
|
24646
24693
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
24647
24694
|
}
|
|
@@ -25054,17 +25101,17 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
|
|
|
25054
25101
|
function offchainInputFees(vtxos, fees) {
|
|
25055
25102
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
25056
25103
|
return vtxos.reduce(
|
|
25057
|
-
(total, vtxo) => total + estimator.evalOffchainInput(
|
|
25104
|
+
(total, vtxo) => total + estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
|
|
25058
25105
|
0
|
|
25059
25106
|
);
|
|
25060
25107
|
}
|
|
25061
25108
|
async function changeOutputFee(wallet, inputs, needed, fees) {
|
|
25062
25109
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
25063
25110
|
const net = inputs.reduce(
|
|
25064
|
-
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(
|
|
25111
|
+
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
|
|
25065
25112
|
0n
|
|
25066
25113
|
);
|
|
25067
|
-
const script = base.hex.encode(
|
|
25114
|
+
const script = base.hex.encode(chunkPWIESIO6_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
|
|
25068
25115
|
return changeAfterOutputFee(
|
|
25069
25116
|
net - needed,
|
|
25070
25117
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script }).satoshis)
|
|
@@ -25363,5 +25410,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
|
25363
25410
|
exports.walletFeeSource = walletFeeSource;
|
|
25364
25411
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
25365
25412
|
exports.withPrevTxs = withPrevTxs;
|
|
25366
|
-
//# sourceMappingURL=chunk-
|
|
25367
|
-
//# sourceMappingURL=chunk-
|
|
25413
|
+
//# sourceMappingURL=chunk-VJ7M6WKB.cjs.map
|
|
25414
|
+
//# sourceMappingURL=chunk-VJ7M6WKB.cjs.map
|