@arkade-os/sdk 0.5.0-rc.21 → 0.5.0-rc.22
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.js +3 -3
- package/dist/{asyncStorageTaskQueue-x8ok3tJy.d.cts → asyncStorageTaskQueue-C9Ab5DyR.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-aL7K14e4.d.ts → asyncStorageTaskQueue-CbQryNK9.d.ts} +2 -2
- package/dist/{chunk-R5OFJ23O.cjs → chunk-4X3ZGHWW.cjs} +496 -493
- package/dist/chunk-4X3ZGHWW.cjs.map +1 -0
- package/dist/{chunk-S2WWOVFC.js → chunk-EBUSHD43.js} +4 -4
- package/dist/{chunk-S2WWOVFC.js.map → chunk-EBUSHD43.js.map} +1 -1
- package/dist/{chunk-EXFU6MTA.js → chunk-MN22OMVC.js} +18 -15
- package/dist/chunk-MN22OMVC.js.map +1 -0
- package/dist/{chunk-LNJPVLIC.js → chunk-OACS4QUR.js} +4 -4
- package/dist/{chunk-LNJPVLIC.js.map → chunk-OACS4QUR.js.map} +1 -1
- package/dist/{chunk-5XBH5SAL.cjs → chunk-OJ5W7L6Q.cjs} +3 -3
- package/dist/{chunk-5XBH5SAL.cjs.map → chunk-OJ5W7L6Q.cjs.map} +1 -1
- package/dist/{chunk-GVF4OCTL.cjs → chunk-OSRXKF7B.cjs} +48 -48
- package/dist/{chunk-GVF4OCTL.cjs.map → chunk-OSRXKF7B.cjs.map} +1 -1
- package/dist/{chunk-HIZNPHB2.cjs → chunk-QFT7X26G.cjs} +15 -15
- package/dist/{chunk-HIZNPHB2.cjs.map → chunk-QFT7X26G.cjs.map} +1 -1
- package/dist/{chunk-4FDNOLBO.js → chunk-QUR5ENRP.js} +3 -3
- package/dist/{chunk-4FDNOLBO.js.map → chunk-QUR5ENRP.js.map} +1 -1
- package/dist/{chunk-JZAEFOE4.js → chunk-W27URLQ5.js} +3 -3
- package/dist/{chunk-JZAEFOE4.js.map → chunk-W27URLQ5.js.map} +1 -1
- package/dist/{chunk-VZMLADXQ.cjs → chunk-W4TZBRG3.cjs} +10 -10
- package/dist/{chunk-VZMLADXQ.cjs.map → chunk-W4TZBRG3.cjs.map} +1 -1
- package/dist/{chunk-CXHJGED6.js → chunk-WJKVNBUN.js} +3 -3
- package/dist/{chunk-CXHJGED6.js.map → chunk-WJKVNBUN.js.map} +1 -1
- package/dist/{chunk-Q7PC3NHX.cjs → chunk-XWUJBHYW.cjs} +18 -18
- package/dist/{chunk-Q7PC3NHX.cjs.map → chunk-XWUJBHYW.cjs.map} +1 -1
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/index.cjs +309 -309
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +35 -35
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +33 -33
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-BeYR6NpQ.d.ts → taskRunner-BDAZSNyd.d.ts} +1 -1
- package/dist/{taskRunner-Csey3EYJ.d.cts → taskRunner-D5ObtxWZ.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +2 -2
- package/dist/wallet/expo/background.d.ts +2 -2
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +15 -15
- package/dist/wallet/expo/index.d.cts +1 -1
- package/dist/wallet/expo/index.d.ts +1 -1
- package/dist/wallet/expo/index.js +5 -5
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +3 -3
- package/dist/worker/expo/index.d.ts +3 -3
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-EXFU6MTA.js.map +0 -1
- package/dist/chunk-R5OFJ23O.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkXWUJBHYW_cjs = require('./chunk-XWUJBHYW.cjs');
|
|
4
|
+
var chunkOSRXKF7B_cjs = require('./chunk-OSRXKF7B.cjs');
|
|
5
|
+
var chunkOJ5W7L6Q_cjs = require('./chunk-OJ5W7L6Q.cjs');
|
|
6
6
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
7
7
|
var btcSigner = require('@scure/btc-signer');
|
|
8
8
|
var base = require('@scure/base');
|
|
@@ -187,7 +187,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
187
187
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
188
188
|
const tx = this.graph.find(txid);
|
|
189
189
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
190
|
-
const cosigners =
|
|
190
|
+
const cosigners = chunkOJ5W7L6Q_cjs.getArkPsbtFields(tx.root, 0, chunkOJ5W7L6Q_cjs.CosignerPublicKey).map(
|
|
191
191
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
192
192
|
// xonly pubkey
|
|
193
193
|
);
|
|
@@ -239,7 +239,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
239
239
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
240
240
|
const prevoutAmounts = [];
|
|
241
241
|
const prevoutScripts = [];
|
|
242
|
-
const cosigners =
|
|
242
|
+
const cosigners = chunkOJ5W7L6Q_cjs.getArkPsbtFields(g.root, 0, chunkOJ5W7L6Q_cjs.CosignerPublicKey).map((c) => c.key);
|
|
243
243
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
244
244
|
taprootTweak: this.scriptRoot
|
|
245
245
|
});
|
|
@@ -322,7 +322,7 @@ var SingleKey = class _SingleKey {
|
|
|
322
322
|
async sign(tx, inputIndexes) {
|
|
323
323
|
const txCpy = tx.clone();
|
|
324
324
|
if (!inputIndexes) {
|
|
325
|
-
|
|
325
|
+
chunkOJ5W7L6Q_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
|
|
326
326
|
try {
|
|
327
327
|
if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
|
|
328
328
|
throw new Error("Failed to sign transaction");
|
|
@@ -422,7 +422,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
422
422
|
let network;
|
|
423
423
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
424
424
|
descriptor = opts.descriptor;
|
|
425
|
-
network =
|
|
425
|
+
network = chunkOSRXKF7B_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
426
426
|
} else {
|
|
427
427
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
428
428
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -499,7 +499,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
499
499
|
}
|
|
500
500
|
/** Returns true when `descriptor` is derived from this identity's seed. */
|
|
501
501
|
ownsDescriptor(descriptor) {
|
|
502
|
-
return
|
|
502
|
+
return chunkOSRXKF7B_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
503
503
|
}
|
|
504
504
|
/**
|
|
505
505
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -538,7 +538,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
538
538
|
}
|
|
539
539
|
// ── internal helpers ─────────────────────────────────────────────
|
|
540
540
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
541
|
-
const network =
|
|
541
|
+
const network = chunkOSRXKF7B_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
542
542
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
543
543
|
if (expansion.isRanged) {
|
|
544
544
|
throw new Error(
|
|
@@ -563,7 +563,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
563
563
|
signTxWithKey(tx, key, inputIndexes) {
|
|
564
564
|
const txCpy = tx.clone();
|
|
565
565
|
if (!inputIndexes) {
|
|
566
|
-
|
|
566
|
+
chunkOJ5W7L6Q_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
|
|
567
567
|
try {
|
|
568
568
|
if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
|
|
569
569
|
throw new Error("Failed to sign transaction");
|
|
@@ -615,7 +615,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
615
615
|
/** Wildcard account-descriptor template (e.g. `tr([fp/86'/0'/0']xpub/0/*)`). */
|
|
616
616
|
descriptor;
|
|
617
617
|
constructor(descriptor) {
|
|
618
|
-
const network =
|
|
618
|
+
const network = chunkOSRXKF7B_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
619
619
|
let expansion;
|
|
620
620
|
try {
|
|
621
621
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -650,7 +650,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
650
650
|
}
|
|
651
651
|
/** Returns true when `descriptor` derives from this identity's xpub. */
|
|
652
652
|
ownsDescriptor(descriptor) {
|
|
653
|
-
return
|
|
653
|
+
return chunkOSRXKF7B_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
654
654
|
}
|
|
655
655
|
};
|
|
656
656
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -793,10 +793,10 @@ var DescriptorIdentity = class {
|
|
|
793
793
|
this.base = base;
|
|
794
794
|
}
|
|
795
795
|
async xOnlyPublicKey() {
|
|
796
|
-
return
|
|
796
|
+
return chunkOSRXKF7B_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
797
797
|
}
|
|
798
798
|
async compressedPublicKey() {
|
|
799
|
-
return
|
|
799
|
+
return chunkOSRXKF7B_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
800
800
|
}
|
|
801
801
|
async sign(tx, inputIndexes) {
|
|
802
802
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -856,8 +856,8 @@ var StaticDescriptorProvider = class _StaticDescriptorProvider {
|
|
|
856
856
|
}
|
|
857
857
|
isOurs(descriptor) {
|
|
858
858
|
try {
|
|
859
|
-
const normalized =
|
|
860
|
-
const pubKey =
|
|
859
|
+
const normalized = chunkOSRXKF7B_cjs.normalizeToDescriptor(descriptor);
|
|
860
|
+
const pubKey = chunkOSRXKF7B_cjs.extractPubKey(normalized);
|
|
861
861
|
return pubKey.toLowerCase() === this.pubKeyHex.toLowerCase();
|
|
862
862
|
} catch {
|
|
863
863
|
return false;
|
|
@@ -1194,7 +1194,7 @@ function unwrapKeyring(provider) {
|
|
|
1194
1194
|
}
|
|
1195
1195
|
function keyOf(descriptor) {
|
|
1196
1196
|
try {
|
|
1197
|
-
return
|
|
1197
|
+
return chunkOSRXKF7B_cjs.extractPubKey(chunkOSRXKF7B_cjs.normalizeToDescriptor(descriptor)).toLowerCase();
|
|
1198
1198
|
} catch {
|
|
1199
1199
|
return void 0;
|
|
1200
1200
|
}
|
|
@@ -1285,12 +1285,12 @@ async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
|
1285
1285
|
signMessageWithDescriptor: (ownedDescriptor, message, signatureType) => identity.signDescriptorMessage(ownedDescriptor, message, signatureType)
|
|
1286
1286
|
} : void 0;
|
|
1287
1287
|
const owner = providerOwner ?? identityOwner;
|
|
1288
|
-
if (owner &&
|
|
1288
|
+
if (owner && chunkOSRXKF7B_cjs.parseHDDescriptor(descriptor)) {
|
|
1289
1289
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
1290
1290
|
}
|
|
1291
1291
|
let key;
|
|
1292
1292
|
try {
|
|
1293
|
-
key =
|
|
1293
|
+
key = chunkOSRXKF7B_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1294
1294
|
} catch {
|
|
1295
1295
|
throw new ForeignDescriptorError(descriptor);
|
|
1296
1296
|
}
|
|
@@ -1343,14 +1343,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1343
1343
|
}
|
|
1344
1344
|
var PREIMAGE_INDEX = 0;
|
|
1345
1345
|
function isPerArtifactDescriptor(descriptor) {
|
|
1346
|
-
return
|
|
1346
|
+
return chunkOSRXKF7B_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1347
1347
|
}
|
|
1348
1348
|
async function provisionDescriptor(wallet) {
|
|
1349
1349
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1350
|
-
return allocated ?? await
|
|
1350
|
+
return allocated ?? await chunkOSRXKF7B_cjs.identityDescriptor(wallet.identity);
|
|
1351
1351
|
}
|
|
1352
1352
|
async function provisionRefundKey(wallet) {
|
|
1353
|
-
const descriptor = await
|
|
1353
|
+
const descriptor = await chunkOSRXKF7B_cjs.identityDescriptor(wallet.identity);
|
|
1354
1354
|
const signer = await contractSigner(wallet, descriptor);
|
|
1355
1355
|
const pubkey = await signer.xOnlyPublicKey();
|
|
1356
1356
|
const identityPubkey = await wallet.identity.xOnlyPublicKey();
|
|
@@ -1360,7 +1360,7 @@ async function provisionRefundKey(wallet) {
|
|
|
1360
1360
|
);
|
|
1361
1361
|
}
|
|
1362
1362
|
const address = await wallet.getAddress();
|
|
1363
|
-
const { pkScript } =
|
|
1363
|
+
const { pkScript } = chunkOJ5W7L6Q_cjs.ArkAddress.decode(address);
|
|
1364
1364
|
return { descriptor, pubkey, pkScript, address };
|
|
1365
1365
|
}
|
|
1366
1366
|
async function provisionClaimSecret(wallet, opts = {}) {
|
|
@@ -1406,7 +1406,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1406
1406
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1407
1407
|
let expected;
|
|
1408
1408
|
try {
|
|
1409
|
-
expected =
|
|
1409
|
+
expected = chunkOSRXKF7B_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1410
1410
|
} catch (cause) {
|
|
1411
1411
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1412
1412
|
}
|
|
@@ -1488,7 +1488,7 @@ function debugLog(debug, ...args) {
|
|
|
1488
1488
|
}
|
|
1489
1489
|
function normalizeOptions(pathOrOptions) {
|
|
1490
1490
|
const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
|
|
1491
|
-
|
|
1491
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
|
|
1492
1492
|
return {
|
|
1493
1493
|
path: o.path,
|
|
1494
1494
|
updateViaCache: o.updateViaCache ?? "none",
|
|
@@ -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 chunkOJ5W7L6Q_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: chunkOJ5W7L6Q_cjs.Intent.encodeMessage(intent.message),
|
|
1622
1622
|
proof: intent.proof
|
|
1623
1623
|
},
|
|
1624
1624
|
forfeit_txs: forfeitTxs,
|
|
@@ -1637,7 +1637,7 @@ var RestDelegateProvider = class {
|
|
|
1637
1637
|
*/
|
|
1638
1638
|
async getDelegateInfo() {
|
|
1639
1639
|
const url = `${this.url}/v1/delegator/info`;
|
|
1640
|
-
const response = await
|
|
1640
|
+
const response = await chunkOJ5W7L6Q_cjs.rateGate.runHttp(url, () => chunkOJ5W7L6Q_cjs.baseFetch(url));
|
|
1641
1641
|
if (!response.ok) {
|
|
1642
1642
|
const errorText2 = await response.text();
|
|
1643
1643
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1693,7 +1693,7 @@ async function collectPages(read) {
|
|
|
1693
1693
|
return items;
|
|
1694
1694
|
}
|
|
1695
1695
|
function scriptFromArkAddress(address) {
|
|
1696
|
-
return base.hex.encode(
|
|
1696
|
+
return base.hex.encode(chunkOJ5W7L6Q_cjs.ArkAddress.decode(address).pkScript);
|
|
1697
1697
|
}
|
|
1698
1698
|
|
|
1699
1699
|
// src/repositories/walletRepository.ts
|
|
@@ -1755,9 +1755,9 @@ async function collectScriptVtxos(repository, script, options) {
|
|
|
1755
1755
|
return [...byOutpoint.values()].map((row) => row.vtxo);
|
|
1756
1756
|
}
|
|
1757
1757
|
function unspentScriptVtxos(rows, copies) {
|
|
1758
|
-
const spent = copies.filter((copy) =>
|
|
1758
|
+
const spent = copies.filter((copy) => chunkOJ5W7L6Q_cjs.isVtxoSpent(copy.vtxo));
|
|
1759
1759
|
return rows.filter(
|
|
1760
|
-
(row) => !
|
|
1760
|
+
(row) => !chunkOJ5W7L6Q_cjs.isVtxoSpent(row.vtxo) && !spent.some(
|
|
1761
1761
|
(copy) => copy.address !== row.address && copy.vtxo.txid === row.vtxo.txid && copy.vtxo.vout === row.vtxo.vout && shouldReplaceScriptVtxo(row, copy)
|
|
1762
1762
|
)
|
|
1763
1763
|
);
|
|
@@ -1840,7 +1840,7 @@ var ESPLORA_URL = {
|
|
|
1840
1840
|
regtest: "http://localhost:3000/api"
|
|
1841
1841
|
};
|
|
1842
1842
|
var EsploraProvider = class {
|
|
1843
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1843
|
+
constructor(baseUrl = ESPLORA_URL[chunkOJ5W7L6Q_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1844
1844
|
this.baseUrl = baseUrl;
|
|
1845
1845
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1846
1846
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1855,7 +1855,7 @@ var EsploraProvider = class {
|
|
|
1855
1855
|
*/
|
|
1856
1856
|
addressWatches = /* @__PURE__ */ new Map();
|
|
1857
1857
|
async getCoins(address) {
|
|
1858
|
-
const response = await
|
|
1858
|
+
const response = await chunkOJ5W7L6Q_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1859
1859
|
if (!response.ok) {
|
|
1860
1860
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1861
1861
|
}
|
|
@@ -1864,12 +1864,12 @@ var EsploraProvider = class {
|
|
|
1864
1864
|
async getFeeRate() {
|
|
1865
1865
|
let url = `${this.baseUrl}/fee-estimates`;
|
|
1866
1866
|
let key = "1";
|
|
1867
|
-
let response = await
|
|
1867
|
+
let response = await chunkOJ5W7L6Q_cjs.baseFetch(url);
|
|
1868
1868
|
if (response.status === 404) {
|
|
1869
1869
|
await response.body?.cancel();
|
|
1870
1870
|
url = `${this.baseUrl}/v1/fees/recommended`;
|
|
1871
1871
|
key = "fastestFee";
|
|
1872
|
-
response = await
|
|
1872
|
+
response = await chunkOJ5W7L6Q_cjs.baseFetch(url);
|
|
1873
1873
|
}
|
|
1874
1874
|
if (response.status === 404) {
|
|
1875
1875
|
await response.body?.cancel();
|
|
@@ -1906,7 +1906,7 @@ var EsploraProvider = class {
|
|
|
1906
1906
|
}
|
|
1907
1907
|
}
|
|
1908
1908
|
async getTxOutspends(txid) {
|
|
1909
|
-
const response = await
|
|
1909
|
+
const response = await chunkOJ5W7L6Q_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1910
1910
|
if (!response.ok) {
|
|
1911
1911
|
const error = await response.text();
|
|
1912
1912
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1914,7 +1914,7 @@ var EsploraProvider = class {
|
|
|
1914
1914
|
return response.json();
|
|
1915
1915
|
}
|
|
1916
1916
|
async getTransactions(address) {
|
|
1917
|
-
const response = await
|
|
1917
|
+
const response = await chunkOJ5W7L6Q_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1918
1918
|
if (!response.ok) {
|
|
1919
1919
|
const error = await response.text();
|
|
1920
1920
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1923,14 +1923,14 @@ var EsploraProvider = class {
|
|
|
1923
1923
|
}
|
|
1924
1924
|
/** Orders of magnitude smaller than `/address/{addr}/txs`: the polling fallback's probe. */
|
|
1925
1925
|
async getAddressStats(address) {
|
|
1926
|
-
const response = await
|
|
1926
|
+
const response = await chunkOJ5W7L6Q_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
|
|
1927
1927
|
if (!response.ok) {
|
|
1928
1928
|
throw new Error(`Failed to get address stats: ${response.statusText}`);
|
|
1929
1929
|
}
|
|
1930
1930
|
return response.json();
|
|
1931
1931
|
}
|
|
1932
1932
|
async getRawTransaction(txid) {
|
|
1933
|
-
const response = await
|
|
1933
|
+
const response = await chunkOJ5W7L6Q_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
1934
1934
|
if (!response.ok) {
|
|
1935
1935
|
const error = await response.text();
|
|
1936
1936
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -1938,7 +1938,7 @@ var EsploraProvider = class {
|
|
|
1938
1938
|
return base.hex.decode((await response.text()).trim());
|
|
1939
1939
|
}
|
|
1940
1940
|
async getTxStatus(txid) {
|
|
1941
|
-
const txresponse = await
|
|
1941
|
+
const txresponse = await chunkOJ5W7L6Q_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1942
1942
|
if (!txresponse.ok) {
|
|
1943
1943
|
throw new Error(txresponse.statusText);
|
|
1944
1944
|
}
|
|
@@ -1946,7 +1946,7 @@ var EsploraProvider = class {
|
|
|
1946
1946
|
if (!tx.status.confirmed) {
|
|
1947
1947
|
return { confirmed: false };
|
|
1948
1948
|
}
|
|
1949
|
-
const response = await
|
|
1949
|
+
const response = await chunkOJ5W7L6Q_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1950
1950
|
if (!response.ok) {
|
|
1951
1951
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1952
1952
|
}
|
|
@@ -2220,9 +2220,9 @@ var EsploraProvider = class {
|
|
|
2220
2220
|
return { subscribers, teardown, started };
|
|
2221
2221
|
}
|
|
2222
2222
|
async getChainTip() {
|
|
2223
|
-
let tipBlocks = await
|
|
2223
|
+
let tipBlocks = await chunkOJ5W7L6Q_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
2224
2224
|
if (tipBlocks.status === 404) {
|
|
2225
|
-
tipBlocks = await
|
|
2225
|
+
tipBlocks = await chunkOJ5W7L6Q_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
|
|
2226
2226
|
}
|
|
2227
2227
|
if (!tipBlocks.ok) {
|
|
2228
2228
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
@@ -2243,7 +2243,7 @@ var EsploraProvider = class {
|
|
|
2243
2243
|
};
|
|
2244
2244
|
}
|
|
2245
2245
|
async broadcastPackage(parent, child) {
|
|
2246
|
-
const response = await
|
|
2246
|
+
const response = await chunkOJ5W7L6Q_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
2247
2247
|
method: "POST",
|
|
2248
2248
|
headers: {
|
|
2249
2249
|
"Content-Type": "application/json"
|
|
@@ -2259,7 +2259,7 @@ var EsploraProvider = class {
|
|
|
2259
2259
|
return result;
|
|
2260
2260
|
}
|
|
2261
2261
|
async broadcastTx(tx) {
|
|
2262
|
-
const response = await
|
|
2262
|
+
const response = await chunkOJ5W7L6Q_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
2263
2263
|
method: "POST",
|
|
2264
2264
|
headers: {
|
|
2265
2265
|
"Content-Type": "text/plain"
|
|
@@ -2431,7 +2431,7 @@ function findP2AOutput(tx) {
|
|
|
2431
2431
|
var CHILD_DUST_AMOUNT = 546;
|
|
2432
2432
|
function buildAnchorChild(params) {
|
|
2433
2433
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2434
|
-
const child = new
|
|
2434
|
+
const child = new chunkOJ5W7L6Q_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2435
2435
|
const anchor = findP2AOutput(parent);
|
|
2436
2436
|
child.addInput(anchor);
|
|
2437
2437
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
@@ -2480,7 +2480,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2480
2480
|
);
|
|
2481
2481
|
}
|
|
2482
2482
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2483
|
-
const tx = new
|
|
2483
|
+
const tx = new chunkOJ5W7L6Q_cjs.Transaction({
|
|
2484
2484
|
version: 3,
|
|
2485
2485
|
lockTime: txLocktime
|
|
2486
2486
|
});
|
|
@@ -2507,7 +2507,7 @@ function validateConnectorsTxGraph(settlementTxB64, connectorsGraph) {
|
|
|
2507
2507
|
connectorsGraph.validate();
|
|
2508
2508
|
if (connectorsGraph.root.inputsLength !== 1) throw ErrNumberOfInputs;
|
|
2509
2509
|
const rootInput = connectorsGraph.root.getInput(0);
|
|
2510
|
-
const settlementTx =
|
|
2510
|
+
const settlementTx = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
|
|
2511
2511
|
if (settlementTx.outputsLength <= BATCH_OUTPUT_CONNECTORS_INDEX)
|
|
2512
2512
|
throw ErrInvalidSettlementTxOutputs;
|
|
2513
2513
|
const expectedRootTxid = settlementTx.id;
|
|
@@ -2556,7 +2556,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2556
2556
|
if (previousScriptKey.length !== 32) {
|
|
2557
2557
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2558
2558
|
}
|
|
2559
|
-
const cosigners =
|
|
2559
|
+
const cosigners = chunkOJ5W7L6Q_cjs.getArkPsbtFields(child.root, 0, chunkOJ5W7L6Q_cjs.CosignerPublicKey);
|
|
2560
2560
|
if (cosigners.length === 0) {
|
|
2561
2561
|
throw ErrMissingCosignersPublicKeys;
|
|
2562
2562
|
}
|
|
@@ -2614,7 +2614,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2614
2614
|
return new _EmulatorPacket(entries);
|
|
2615
2615
|
}
|
|
2616
2616
|
static fromBytes(data) {
|
|
2617
|
-
const reader = new
|
|
2617
|
+
const reader = new chunkXWUJBHYW_cjs.BufferReader(data);
|
|
2618
2618
|
const entryCount = reader.readCompactSize();
|
|
2619
2619
|
const entries = [];
|
|
2620
2620
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2632,7 +2632,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2632
2632
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2633
2633
|
}
|
|
2634
2634
|
serialize() {
|
|
2635
|
-
const writer = new
|
|
2635
|
+
const writer = new chunkXWUJBHYW_cjs.BufferWriter();
|
|
2636
2636
|
writer.writeCompactSize(this.entries.length);
|
|
2637
2637
|
for (const entry of this.entries) {
|
|
2638
2638
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2719,7 +2719,7 @@ var Extension = class _Extension {
|
|
|
2719
2719
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2720
2720
|
);
|
|
2721
2721
|
}
|
|
2722
|
-
const reader = new
|
|
2722
|
+
const reader = new chunkXWUJBHYW_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2723
2723
|
const packets = [];
|
|
2724
2724
|
while (reader.remaining() > 0) {
|
|
2725
2725
|
const packetType = reader.readByte();
|
|
@@ -2792,7 +2792,7 @@ var Extension = class _Extension {
|
|
|
2792
2792
|
* getAssetPacket returns the embedded Packet, or null if not present.
|
|
2793
2793
|
*/
|
|
2794
2794
|
getAssetPacket() {
|
|
2795
|
-
return this.packets.find((p) => p instanceof
|
|
2795
|
+
return this.packets.find((p) => p instanceof chunkXWUJBHYW_cjs.Packet) ?? null;
|
|
2796
2796
|
}
|
|
2797
2797
|
/**
|
|
2798
2798
|
* getEmulatorPacket returns the embedded EmulatorPacket, or null if not present.
|
|
@@ -2816,8 +2816,8 @@ var Extension = class _Extension {
|
|
|
2816
2816
|
};
|
|
2817
2817
|
function parsePacket(packetType, data) {
|
|
2818
2818
|
switch (packetType) {
|
|
2819
|
-
case
|
|
2820
|
-
return
|
|
2819
|
+
case chunkXWUJBHYW_cjs.Packet.PACKET_TYPE:
|
|
2820
|
+
return chunkXWUJBHYW_cjs.Packet.fromBytes(data);
|
|
2821
2821
|
case EmulatorPacket.PACKET_TYPE:
|
|
2822
2822
|
return EmulatorPacket.fromBytes(data);
|
|
2823
2823
|
default:
|
|
@@ -2864,22 +2864,22 @@ function buildOpReturnScript(data) {
|
|
|
2864
2864
|
}
|
|
2865
2865
|
return script;
|
|
2866
2866
|
}
|
|
2867
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2868
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2867
|
+
var ErrOffchainOutputNotFound = (address) => new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2868
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
2869
2869
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2870
2870
|
);
|
|
2871
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2872
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2871
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2872
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
2873
2873
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2874
2874
|
);
|
|
2875
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2876
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2875
|
+
var ErrOnchainOutputNotFound = (address) => new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2876
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
2877
2877
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2878
2878
|
);
|
|
2879
|
-
var ErrIntentOutputNotFound = (index, kind) => new
|
|
2879
|
+
var ErrIntentOutputNotFound = (index, kind) => new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
2880
2880
|
`${kind} output ${index} of the intent proof is not present in what the server built`
|
|
2881
2881
|
);
|
|
2882
|
-
var ErrUnvalidatedIntentOutput = (index) => new
|
|
2882
|
+
var ErrUnvalidatedIntentOutput = (index) => new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
2883
2883
|
`offchain output ${index} of the intent proof cannot be validated: virtual output tree signing did not run`
|
|
2884
2884
|
);
|
|
2885
2885
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2888,7 +2888,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2888
2888
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2889
2889
|
if (!validatedCommitmentTxid) return;
|
|
2890
2890
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2891
|
-
throw new
|
|
2891
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
2892
2892
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2893
2893
|
);
|
|
2894
2894
|
}
|
|
@@ -2898,7 +2898,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2898
2898
|
for (const recipient of recipients) {
|
|
2899
2899
|
let arkAddress;
|
|
2900
2900
|
try {
|
|
2901
|
-
arkAddress =
|
|
2901
|
+
arkAddress = chunkOJ5W7L6Q_cjs.ArkAddress.decode(recipient.address);
|
|
2902
2902
|
} catch {
|
|
2903
2903
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2904
2904
|
continue;
|
|
@@ -2910,7 +2910,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2910
2910
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2911
2911
|
for (const recipient of recipients) {
|
|
2912
2912
|
try {
|
|
2913
|
-
|
|
2913
|
+
chunkOJ5W7L6Q_cjs.ArkAddress.decode(recipient.address);
|
|
2914
2914
|
} catch {
|
|
2915
2915
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2916
2916
|
continue;
|
|
@@ -2919,7 +2919,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2919
2919
|
}
|
|
2920
2920
|
}
|
|
2921
2921
|
function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
|
|
2922
|
-
const proof =
|
|
2922
|
+
const proof = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
|
|
2923
2923
|
const onchain = new Set(onchainOutputIndexes);
|
|
2924
2924
|
const declared = [];
|
|
2925
2925
|
for (let i = 0; i < proof.outputsLength; i++) {
|
|
@@ -3211,7 +3211,7 @@ function assetMintResolver() {
|
|
|
3211
3211
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
3212
3212
|
const minted = tx.assets.filter((a) => {
|
|
3213
3213
|
try {
|
|
3214
|
-
return base.hex.encode(
|
|
3214
|
+
return base.hex.encode(chunkXWUJBHYW_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
3215
3215
|
} catch {
|
|
3216
3216
|
return false;
|
|
3217
3217
|
}
|
|
@@ -3288,7 +3288,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3288
3288
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
3289
3289
|
inputsByAssetId.set(asset.assetId, [
|
|
3290
3290
|
...existing ?? [],
|
|
3291
|
-
|
|
3291
|
+
chunkXWUJBHYW_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
3292
3292
|
]);
|
|
3293
3293
|
}
|
|
3294
3294
|
}
|
|
@@ -3300,7 +3300,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3300
3300
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3301
3301
|
outputsByAssetId.set(asset.assetId, [
|
|
3302
3302
|
...existing ?? [],
|
|
3303
|
-
|
|
3303
|
+
chunkXWUJBHYW_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3304
3304
|
]);
|
|
3305
3305
|
}
|
|
3306
3306
|
}
|
|
@@ -3311,7 +3311,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3311
3311
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3312
3312
|
outputsByAssetId.set(asset.assetId, [
|
|
3313
3313
|
...existing ?? [],
|
|
3314
|
-
|
|
3314
|
+
chunkXWUJBHYW_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3315
3315
|
]);
|
|
3316
3316
|
}
|
|
3317
3317
|
}
|
|
@@ -3320,11 +3320,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3320
3320
|
for (const assetIdStr of allAssetIds) {
|
|
3321
3321
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
3322
3322
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
3323
|
-
const assetId =
|
|
3324
|
-
const group =
|
|
3323
|
+
const assetId = chunkXWUJBHYW_cjs.AssetId.fromString(assetIdStr);
|
|
3324
|
+
const group = chunkXWUJBHYW_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
3325
3325
|
groups.push(group);
|
|
3326
3326
|
}
|
|
3327
|
-
return
|
|
3327
|
+
return chunkXWUJBHYW_cjs.Packet.create(groups);
|
|
3328
3328
|
}
|
|
3329
3329
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
3330
3330
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -3361,7 +3361,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
|
|
|
3361
3361
|
}
|
|
3362
3362
|
function toXOnlySignerHex(pubkeyHex) {
|
|
3363
3363
|
const bytes = base.hex.decode(pubkeyHex);
|
|
3364
|
-
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(
|
|
3364
|
+
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkOSRXKF7B_cjs.toXOnly(bytes, "signer key"));
|
|
3365
3365
|
throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
|
|
3366
3366
|
}
|
|
3367
3367
|
function signerSetFromInfo(info) {
|
|
@@ -3408,13 +3408,13 @@ var toTimelock = (value) => ({
|
|
|
3408
3408
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
3409
3409
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
3410
3410
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
3411
|
-
throw new
|
|
3411
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3412
3412
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
3413
3413
|
);
|
|
3414
3414
|
}
|
|
3415
3415
|
const seconds = toSeconds(timelock);
|
|
3416
3416
|
if (seconds < policy.minSeconds) {
|
|
3417
|
-
throw new
|
|
3417
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3418
3418
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
3419
3419
|
);
|
|
3420
3420
|
}
|
|
@@ -3435,7 +3435,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
3435
3435
|
}
|
|
3436
3436
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
3437
3437
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
3438
|
-
throw new
|
|
3438
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3439
3439
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
3440
3440
|
);
|
|
3441
3441
|
}
|
|
@@ -3465,21 +3465,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
3465
3465
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
3466
3466
|
let script;
|
|
3467
3467
|
try {
|
|
3468
|
-
script =
|
|
3468
|
+
script = chunkOJ5W7L6Q_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
3469
3469
|
} catch (e) {
|
|
3470
|
-
throw new
|
|
3470
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3471
3471
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
3472
3472
|
);
|
|
3473
3473
|
}
|
|
3474
3474
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
3475
3475
|
const { pubkeys } = script.params;
|
|
3476
3476
|
if (pubkeys.length !== 1) {
|
|
3477
|
-
throw new
|
|
3477
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3478
3478
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
3479
3479
|
);
|
|
3480
3480
|
}
|
|
3481
3481
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
3482
|
-
throw new
|
|
3482
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3483
3483
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
3484
3484
|
);
|
|
3485
3485
|
}
|
|
@@ -3523,8 +3523,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
3523
3523
|
function buildVirtualTx(inputs, outputs) {
|
|
3524
3524
|
let lockTime = 0n;
|
|
3525
3525
|
for (const input of inputs) {
|
|
3526
|
-
const tapscript =
|
|
3527
|
-
if (
|
|
3526
|
+
const tapscript = chunkOJ5W7L6Q_cjs.decodeTapscript(chunkOJ5W7L6Q_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
3527
|
+
if (chunkOJ5W7L6Q_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
3528
3528
|
if (lockTime !== 0n) {
|
|
3529
3529
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
3530
3530
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -3535,7 +3535,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3535
3535
|
}
|
|
3536
3536
|
}
|
|
3537
3537
|
}
|
|
3538
|
-
const tx = new
|
|
3538
|
+
const tx = new chunkOJ5W7L6Q_cjs.Transaction({
|
|
3539
3539
|
version: 3,
|
|
3540
3540
|
lockTime: Number(lockTime)
|
|
3541
3541
|
});
|
|
@@ -3545,12 +3545,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3545
3545
|
index: input.vout,
|
|
3546
3546
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3547
3547
|
witnessUtxo: {
|
|
3548
|
-
script:
|
|
3548
|
+
script: chunkOJ5W7L6Q_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3549
3549
|
amount: BigInt(input.value)
|
|
3550
3550
|
},
|
|
3551
3551
|
tapLeafScript: [input.tapLeafScript]
|
|
3552
3552
|
});
|
|
3553
|
-
|
|
3553
|
+
chunkOJ5W7L6Q_cjs.setArkPsbtField(tx, i, chunkOJ5W7L6Q_cjs.VtxoTaprootTree, input.tapTree);
|
|
3554
3554
|
}
|
|
3555
3555
|
for (const output of outputs) {
|
|
3556
3556
|
tx.addOutput(output);
|
|
@@ -3561,8 +3561,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3561
3561
|
return tx;
|
|
3562
3562
|
}
|
|
3563
3563
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3564
|
-
const collaborativeClosure =
|
|
3565
|
-
const checkpointVtxoScript = new
|
|
3564
|
+
const collaborativeClosure = chunkOJ5W7L6Q_cjs.decodeTapscript(chunkOJ5W7L6Q_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3565
|
+
const checkpointVtxoScript = new chunkOJ5W7L6Q_cjs.VtxoScript([
|
|
3566
3566
|
serverUnrollScript.script,
|
|
3567
3567
|
collaborativeClosure.script
|
|
3568
3568
|
]);
|
|
@@ -3638,7 +3638,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3638
3638
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3639
3639
|
const sig = signature.subarray(0, 64);
|
|
3640
3640
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3641
|
-
const sighashName =
|
|
3641
|
+
const sighashName = chunkOJ5W7L6Q_cjs.formatSighash(sighashType);
|
|
3642
3642
|
throw new Error(
|
|
3643
3643
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3644
3644
|
);
|
|
@@ -3712,7 +3712,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3712
3712
|
}
|
|
3713
3713
|
function isValidArkAddress(address) {
|
|
3714
3714
|
try {
|
|
3715
|
-
|
|
3715
|
+
chunkOJ5W7L6Q_cjs.ArkAddress.decode(address);
|
|
3716
3716
|
return true;
|
|
3717
3717
|
} catch (e) {
|
|
3718
3718
|
return false;
|
|
@@ -3720,16 +3720,16 @@ function isValidArkAddress(address) {
|
|
|
3720
3720
|
}
|
|
3721
3721
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3722
3722
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3723
|
-
throw new
|
|
3723
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3724
3724
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3725
3725
|
);
|
|
3726
3726
|
}
|
|
3727
3727
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3728
3728
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3729
|
-
const server =
|
|
3729
|
+
const server = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3730
3730
|
const local = byTxid.get(server.id);
|
|
3731
3731
|
if (!local) {
|
|
3732
|
-
throw new
|
|
3732
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3733
3733
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3734
3734
|
);
|
|
3735
3735
|
}
|
|
@@ -3739,14 +3739,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3739
3739
|
}
|
|
3740
3740
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3741
3741
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3742
|
-
throw new
|
|
3742
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3743
3743
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3744
3744
|
);
|
|
3745
3745
|
}
|
|
3746
3746
|
if (response.finalArkTx === void 0) return;
|
|
3747
|
-
const finalTxid =
|
|
3747
|
+
const finalTxid = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3748
3748
|
if (finalTxid !== signedArkTx.id) {
|
|
3749
|
-
throw new
|
|
3749
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3750
3750
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3751
3751
|
);
|
|
3752
3752
|
}
|
|
@@ -3758,20 +3758,20 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3758
3758
|
`${context}: input ${inputIndex} carries no spend leaf to verify the server signature against`
|
|
3759
3759
|
);
|
|
3760
3760
|
}
|
|
3761
|
-
const script =
|
|
3761
|
+
const script = chunkOJ5W7L6Q_cjs.scriptFromTapLeafScript(leaf);
|
|
3762
3762
|
let leafPubkeys;
|
|
3763
3763
|
try {
|
|
3764
|
-
leafPubkeys =
|
|
3765
|
-
(key) => base.hex.encode(
|
|
3764
|
+
leafPubkeys = chunkOJ5W7L6Q_cjs.decodeTapscript(script).params.pubkeys.map(
|
|
3765
|
+
(key) => base.hex.encode(chunkOSRXKF7B_cjs.toXOnly(key, "leaf key"))
|
|
3766
3766
|
);
|
|
3767
3767
|
} catch (error) {
|
|
3768
|
-
throw new
|
|
3768
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3769
3769
|
`${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
|
|
3770
3770
|
);
|
|
3771
3771
|
}
|
|
3772
3772
|
const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
|
|
3773
3773
|
if (!signer) {
|
|
3774
|
-
throw new
|
|
3774
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3775
3775
|
`${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
|
|
3776
3776
|
);
|
|
3777
3777
|
}
|
|
@@ -3785,7 +3785,7 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3785
3785
|
payment_js.tapLeafHash(script)
|
|
3786
3786
|
);
|
|
3787
3787
|
} catch (error) {
|
|
3788
|
-
throw new
|
|
3788
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3789
3789
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3790
3790
|
);
|
|
3791
3791
|
}
|
|
@@ -3794,20 +3794,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3794
3794
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3795
3795
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3796
3796
|
if (checkpoint.inputsLength !== 1) {
|
|
3797
|
-
throw new
|
|
3797
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3798
3798
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3799
3799
|
);
|
|
3800
3800
|
}
|
|
3801
3801
|
const spent = checkpoint.getInput(0);
|
|
3802
3802
|
if (!spent.txid || spent.index === void 0) {
|
|
3803
|
-
throw new
|
|
3803
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3804
3804
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3805
3805
|
);
|
|
3806
3806
|
}
|
|
3807
3807
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3808
3808
|
const input = byOutpoint.get(outpoint);
|
|
3809
3809
|
if (!input) {
|
|
3810
|
-
throw new
|
|
3810
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3811
3811
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3812
3812
|
);
|
|
3813
3813
|
}
|
|
@@ -3815,7 +3815,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3815
3815
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3816
3816
|
);
|
|
3817
3817
|
if (!rebuilt) {
|
|
3818
|
-
throw new
|
|
3818
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3819
3819
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3820
3820
|
);
|
|
3821
3821
|
}
|
|
@@ -3841,9 +3841,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3841
3841
|
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
3842
3842
|
matched.forEach(({ server }, index) => {
|
|
3843
3843
|
try {
|
|
3844
|
-
|
|
3844
|
+
chunkOJ5W7L6Q_cjs.assertAllowedSighashTypes(server);
|
|
3845
3845
|
} catch (error) {
|
|
3846
|
-
throw new
|
|
3846
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3847
3847
|
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
3848
3848
|
);
|
|
3849
3849
|
}
|
|
@@ -3851,14 +3851,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3851
3851
|
const verify = options?.verifyServerSignatures;
|
|
3852
3852
|
if (verify) {
|
|
3853
3853
|
if (response.finalArkTx === void 0) {
|
|
3854
|
-
throw new
|
|
3854
|
+
throw new chunkOJ5W7L6Q_cjs.ServerResponseMismatchError(
|
|
3855
3855
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3856
3856
|
);
|
|
3857
3857
|
}
|
|
3858
|
-
const finalArkTx =
|
|
3858
|
+
const finalArkTx = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3859
3859
|
const serverPubkeys = new Set(
|
|
3860
3860
|
[verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
|
|
3861
|
-
(key) => base.hex.encode(
|
|
3861
|
+
(key) => base.hex.encode(chunkOSRXKF7B_cjs.toXOnly(key, "server key"))
|
|
3862
3862
|
)
|
|
3863
3863
|
);
|
|
3864
3864
|
for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
|
|
@@ -3910,12 +3910,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3910
3910
|
return {
|
|
3911
3911
|
...identity,
|
|
3912
3912
|
sign: async (tx, inputIndexes) => {
|
|
3913
|
-
const signed =
|
|
3913
|
+
const signed = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(
|
|
3914
3914
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3915
3915
|
);
|
|
3916
3916
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3917
3917
|
for (const index of indexes) {
|
|
3918
|
-
|
|
3918
|
+
chunkOJ5W7L6Q_cjs.setArkPsbtField(signed, index, chunkOJ5W7L6Q_cjs.ConditionWitness, [preimage]);
|
|
3919
3919
|
}
|
|
3920
3920
|
return signed;
|
|
3921
3921
|
}
|
|
@@ -4098,7 +4098,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
4098
4098
|
};
|
|
4099
4099
|
}
|
|
4100
4100
|
function deriveContractTapscripts(contract) {
|
|
4101
|
-
const handler =
|
|
4101
|
+
const handler = chunkOSRXKF7B_cjs.contractHandlers.get(contract.type);
|
|
4102
4102
|
if (!handler) {
|
|
4103
4103
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
4104
4104
|
}
|
|
@@ -4189,7 +4189,7 @@ function assertRecipientArkadeAddress(encoded, address, context) {
|
|
|
4189
4189
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
4190
4190
|
let derived;
|
|
4191
4191
|
try {
|
|
4192
|
-
derived =
|
|
4192
|
+
derived = chunkOJ5W7L6Q_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
4193
4193
|
} catch (e) {
|
|
4194
4194
|
throw new Error(
|
|
4195
4195
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -4206,7 +4206,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4206
4206
|
for (const recipient of recipients) {
|
|
4207
4207
|
let address;
|
|
4208
4208
|
try {
|
|
4209
|
-
address =
|
|
4209
|
+
address = chunkOJ5W7L6Q_cjs.ArkAddress.decode(recipient.address);
|
|
4210
4210
|
} catch (e) {
|
|
4211
4211
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
4212
4212
|
}
|
|
@@ -4231,7 +4231,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4231
4231
|
|
|
4232
4232
|
// src/contracts/spendability.ts
|
|
4233
4233
|
function isContractGenericallySpendable(contract) {
|
|
4234
|
-
return
|
|
4234
|
+
return chunkOSRXKF7B_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
4235
4235
|
}
|
|
4236
4236
|
function gatedContracts(contracts) {
|
|
4237
4237
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -4253,7 +4253,7 @@ function gateExclusion(gated) {
|
|
|
4253
4253
|
return (vtxo) => {
|
|
4254
4254
|
const type = gatedTypeOf(vtxo, gated);
|
|
4255
4255
|
if (type === void 0) return void 0;
|
|
4256
|
-
if (!
|
|
4256
|
+
if (!chunkOSRXKF7B_cjs.contractHandlers.has(type)) {
|
|
4257
4257
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
4258
4258
|
}
|
|
4259
4259
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -4289,7 +4289,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
4289
4289
|
continue;
|
|
4290
4290
|
}
|
|
4291
4291
|
for (const v of vtxos) {
|
|
4292
|
-
if (!
|
|
4292
|
+
if (!chunkOJ5W7L6Q_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
|
|
4293
4293
|
out.add(`${v.txid}:${v.vout}`);
|
|
4294
4294
|
}
|
|
4295
4295
|
}
|
|
@@ -4325,10 +4325,10 @@ function byValueDescending(vtxos) {
|
|
|
4325
4325
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
4326
4326
|
}
|
|
4327
4327
|
async function fetchTimeHeight(wallet) {
|
|
4328
|
-
return
|
|
4328
|
+
return chunkOJ5W7L6Q_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
4329
4329
|
}
|
|
4330
4330
|
function canMigrateBySend(vtxo, now) {
|
|
4331
|
-
if (!
|
|
4331
|
+
if (!chunkOJ5W7L6Q_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
4332
4332
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
4333
4333
|
}
|
|
4334
4334
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -4336,7 +4336,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
4336
4336
|
if (vtxo.isSwept) return -Infinity;
|
|
4337
4337
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
4338
4338
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
4339
|
-
return
|
|
4339
|
+
return chunkOJ5W7L6Q_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
4340
4340
|
}
|
|
4341
4341
|
return Infinity;
|
|
4342
4342
|
};
|
|
@@ -4363,7 +4363,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
4363
4363
|
const payable = [];
|
|
4364
4364
|
const net = /* @__PURE__ */ new Map();
|
|
4365
4365
|
for (const vtxo of vtxos) {
|
|
4366
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4366
|
+
const inputFee = estimator.evalOffchainInput(chunkOJ5W7L6Q_cjs.toOffchainInputFeeParams(vtxo));
|
|
4367
4367
|
if (inputFee.satoshis >= vtxo.value) {
|
|
4368
4368
|
continue;
|
|
4369
4369
|
}
|
|
@@ -4392,7 +4392,7 @@ function offchainOutputFee(amount, estimator, arkAddress) {
|
|
|
4392
4392
|
}
|
|
4393
4393
|
const outputFee = estimator.evalOffchainOutput({
|
|
4394
4394
|
amount,
|
|
4395
|
-
script: base.hex.encode(
|
|
4395
|
+
script: base.hex.encode(chunkOJ5W7L6Q_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4396
4396
|
});
|
|
4397
4397
|
return BigInt(outputFee.satoshis);
|
|
4398
4398
|
}
|
|
@@ -4443,10 +4443,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
4443
4443
|
};
|
|
4444
4444
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
4445
4445
|
return vtxos.filter((vtxo) => {
|
|
4446
|
-
if (
|
|
4446
|
+
if (chunkOJ5W7L6Q_cjs.canRecoverOnchain(vtxo, now)) {
|
|
4447
4447
|
return true;
|
|
4448
4448
|
}
|
|
4449
|
-
if (
|
|
4449
|
+
if (chunkOJ5W7L6Q_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
4450
4450
|
return true;
|
|
4451
4451
|
}
|
|
4452
4452
|
return false;
|
|
@@ -4478,7 +4478,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
4478
4478
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
4479
4479
|
if (vtxo.isUnrolled) return false;
|
|
4480
4480
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
4481
|
-
const expiresAt =
|
|
4481
|
+
const expiresAt = chunkOJ5W7L6Q_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
4482
4482
|
if (expiresAt === void 0) return false;
|
|
4483
4483
|
const now = Date.now();
|
|
4484
4484
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -4489,7 +4489,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
4489
4489
|
return vtxos.filter(
|
|
4490
4490
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
4491
4491
|
// property and would otherwise re-admit an exited coin on its own.
|
|
4492
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
4492
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkOJ5W7L6Q_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
4493
4493
|
);
|
|
4494
4494
|
}
|
|
4495
4495
|
function isMigrationCapable(wallet) {
|
|
@@ -4549,7 +4549,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4549
4549
|
constructor(wallet, settlementConfig) {
|
|
4550
4550
|
this.wallet = wallet;
|
|
4551
4551
|
if (settlementConfig !== false) {
|
|
4552
|
-
|
|
4552
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs("pollIntervalMs", settlementConfig?.pollIntervalMs);
|
|
4553
4553
|
}
|
|
4554
4554
|
this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
4555
4555
|
this.contractEventsSubscriptionReady = this.initializeSubscription();
|
|
@@ -4856,7 +4856,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4856
4856
|
* {@link recoverImportedContracts}).
|
|
4857
4857
|
*/
|
|
4858
4858
|
async recoverOneImportedContract(wallet, contract, vtxos, info, dustAmount) {
|
|
4859
|
-
const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !
|
|
4859
|
+
const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !chunkOJ5W7L6Q_cjs.isVtxoSpent(vtxo));
|
|
4860
4860
|
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
4861
4861
|
const { payable, net } = priceSettlementInputs(recoverable, estimator);
|
|
4862
4862
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
@@ -4878,7 +4878,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4878
4878
|
if (vtxos.length === 0) return;
|
|
4879
4879
|
const spent = new Set(batch.map((vtxo) => `${vtxo.txid}:${vtxo.vout}`));
|
|
4880
4880
|
const stillSpendable = vtxos.some(
|
|
4881
|
-
(vtxo) => !
|
|
4881
|
+
(vtxo) => !chunkOJ5W7L6Q_cjs.isVtxoSpent(vtxo) && !spent.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
4882
4882
|
);
|
|
4883
4883
|
if (!stillSpendable) {
|
|
4884
4884
|
await wallet.removeRecoveryContract(contract.script);
|
|
@@ -5145,11 +5145,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
5145
5145
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
5146
5146
|
);
|
|
5147
5147
|
}
|
|
5148
|
-
const tx = new
|
|
5148
|
+
const tx = new chunkOJ5W7L6Q_cjs.Transaction();
|
|
5149
5149
|
for (const utxo of expiredUtxos) {
|
|
5150
|
-
const utxoScript =
|
|
5150
|
+
const utxoScript = chunkOJ5W7L6Q_cjs.VtxoScript.decode(utxo.tapTree);
|
|
5151
5151
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
5152
|
-
(leaf) =>
|
|
5152
|
+
(leaf) => chunkOJ5W7L6Q_cjs.CSVMultisigTapscript.isScriptValid(chunkOJ5W7L6Q_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
5153
5153
|
);
|
|
5154
5154
|
if (!utxoExitLeaf) {
|
|
5155
5155
|
throw new Error(
|
|
@@ -5164,7 +5164,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5164
5164
|
amount: BigInt(utxo.value)
|
|
5165
5165
|
},
|
|
5166
5166
|
tapLeafScript: [utxoExitLeaf],
|
|
5167
|
-
sequence:
|
|
5167
|
+
sequence: chunkOJ5W7L6Q_cjs.getSequence(utxoExitLeaf)
|
|
5168
5168
|
});
|
|
5169
5169
|
}
|
|
5170
5170
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -5390,8 +5390,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5390
5390
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
5391
5391
|
if (cls.status === "CURRENT") continue;
|
|
5392
5392
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
5393
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
5394
|
-
const spendable = live.filter((v) => !
|
|
5393
|
+
const recoverable = live.filter((v) => v.isSwept && !chunkOJ5W7L6Q_cjs.isVtxoSpent(v));
|
|
5394
|
+
const spendable = live.filter((v) => !chunkOJ5W7L6Q_cjs.isVtxoSpent(v) && !v.isSwept);
|
|
5395
5395
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
5396
5396
|
let recoverableCount = 0;
|
|
5397
5397
|
let recoverableValue = 0;
|
|
@@ -5631,7 +5631,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5631
5631
|
}
|
|
5632
5632
|
getBoardingTimelock() {
|
|
5633
5633
|
const wallet = this.getSweepWallet();
|
|
5634
|
-
const exitScript =
|
|
5634
|
+
const exitScript = chunkOJ5W7L6Q_cjs.CSVMultisigTapscript.decode(
|
|
5635
5635
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5636
5636
|
);
|
|
5637
5637
|
return exitScript.params.timelock;
|
|
@@ -5739,8 +5739,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5739
5739
|
}
|
|
5740
5740
|
/** The outpoint a `VTXO_ALREADY_SPENT` error carries in `metadata.vtxo_outpoint`, if any. */
|
|
5741
5741
|
extractSpentOutpoint(error) {
|
|
5742
|
-
const ark =
|
|
5743
|
-
if (!
|
|
5742
|
+
const ark = chunkOJ5W7L6Q_cjs.maybeArkError(error);
|
|
5743
|
+
if (!chunkOJ5W7L6Q_cjs.isArkError(ark, chunkOJ5W7L6Q_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5744
5744
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5745
5745
|
if (typeof raw !== "string") return void 0;
|
|
5746
5746
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -5914,7 +5914,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5914
5914
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
5915
5915
|
break;
|
|
5916
5916
|
}
|
|
5917
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5917
|
+
const inputFee = estimator.evalOffchainInput(chunkOJ5W7L6Q_cjs.toOffchainInputFeeParams(v));
|
|
5918
5918
|
if (inputFee.satoshis >= v.value) {
|
|
5919
5919
|
continue;
|
|
5920
5920
|
}
|
|
@@ -5934,7 +5934,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5934
5934
|
const arkAddress = await this.wallet.getAddress();
|
|
5935
5935
|
const outputFee = estimator.evalOffchainOutput({
|
|
5936
5936
|
amount: totalAmount,
|
|
5937
|
-
script: base.hex.encode(
|
|
5937
|
+
script: base.hex.encode(chunkOJ5W7L6Q_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
5938
5938
|
});
|
|
5939
5939
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
5940
5940
|
if (totalAmount < dustAmount) return;
|
|
@@ -6014,7 +6014,7 @@ var ArkNote = class _ArkNote {
|
|
|
6014
6014
|
this.value = value;
|
|
6015
6015
|
this.HRP = HRP;
|
|
6016
6016
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
6017
|
-
this.vtxoScript = new
|
|
6017
|
+
this.vtxoScript = new chunkOJ5W7L6Q_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
6018
6018
|
const leaf = this.vtxoScript.leaves[0];
|
|
6019
6019
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
6020
6020
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -6187,7 +6187,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6187
6187
|
const privateKey = data.slice(1, 33);
|
|
6188
6188
|
const serverPubKey = data.slice(33, 65);
|
|
6189
6189
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
6190
|
-
const csvTimelock2 =
|
|
6190
|
+
const csvTimelock2 = chunkOJ5W7L6Q_cjs.sequenceToTimelock(sequence);
|
|
6191
6191
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock2, decoded.prefix);
|
|
6192
6192
|
}
|
|
6193
6193
|
toString() {
|
|
@@ -6195,7 +6195,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6195
6195
|
data[0] = _ArkadeCash.Version;
|
|
6196
6196
|
data.set(this._privateKey, 1);
|
|
6197
6197
|
data.set(this._serverPubKey, 33);
|
|
6198
|
-
const sequence =
|
|
6198
|
+
const sequence = chunkOJ5W7L6Q_cjs.timelockToSequence(this.csvTimelock);
|
|
6199
6199
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
6200
6200
|
const words = base.bech32m.toWords(data);
|
|
6201
6201
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -6204,7 +6204,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6204
6204
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
6205
6205
|
}
|
|
6206
6206
|
get vtxoScript() {
|
|
6207
|
-
return new
|
|
6207
|
+
return new chunkOSRXKF7B_cjs.DefaultVtxo.Script({
|
|
6208
6208
|
pubKey: this._publicKey,
|
|
6209
6209
|
serverPubKey: this._serverPubKey,
|
|
6210
6210
|
csvTimelock: this.csvTimelock
|
|
@@ -6220,7 +6220,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
|
|
|
6220
6220
|
(s) => !isTerminalIntentState(s)
|
|
6221
6221
|
);
|
|
6222
6222
|
function isConsumed(vtxo) {
|
|
6223
|
-
return vtxo !== void 0 &&
|
|
6223
|
+
return vtxo !== void 0 && chunkOJ5W7L6Q_cjs.isVtxoSpent(vtxo);
|
|
6224
6224
|
}
|
|
6225
6225
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
6226
6226
|
if (isTerminalIntentState(intent.state)) return void 0;
|
|
@@ -6263,7 +6263,7 @@ async function reconcileIntents(deps) {
|
|
|
6263
6263
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
6264
6264
|
if (outpoints.length > 0) {
|
|
6265
6265
|
try {
|
|
6266
|
-
const { vtxos } = await
|
|
6266
|
+
const { vtxos } = await chunkOJ5W7L6Q_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
6267
6267
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
6268
6268
|
} catch (e) {
|
|
6269
6269
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -6323,7 +6323,7 @@ async function releaseFromServer(intent, deps, now) {
|
|
|
6323
6323
|
});
|
|
6324
6324
|
}
|
|
6325
6325
|
function isNoMatchingIntentsError(e) {
|
|
6326
|
-
return
|
|
6326
|
+
return chunkOJ5W7L6Q_cjs.isArkError(e, chunkOJ5W7L6Q_cjs.ArkErrorName.INVALID_INTENT_PROOF) && e.message.includes("no matching intents found");
|
|
6327
6327
|
}
|
|
6328
6328
|
function terminal(intent, state, now, patch) {
|
|
6329
6329
|
return { ...intent, ...patch, state, updatedAt: now };
|
|
@@ -6542,7 +6542,7 @@ async function captureExitBranch(params) {
|
|
|
6542
6542
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
6543
6543
|
if (nonCommitment.length > 0) {
|
|
6544
6544
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
6545
|
-
psbtByTxid.set(
|
|
6545
|
+
psbtByTxid.set(chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6546
6546
|
}
|
|
6547
6547
|
}
|
|
6548
6548
|
}
|
|
@@ -6585,10 +6585,10 @@ var IndexerExitDataSource = class {
|
|
|
6585
6585
|
while (hasMore) {
|
|
6586
6586
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
6587
6587
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
6588
|
-
{ pageIndex, pageSize:
|
|
6588
|
+
{ pageIndex, pageSize: chunkOJ5W7L6Q_cjs.DEFAULT_PAGE_SIZE }
|
|
6589
6589
|
);
|
|
6590
6590
|
chain.push(...page);
|
|
6591
|
-
hasMore = meta ? page.length ===
|
|
6591
|
+
hasMore = meta ? page.length === chunkOJ5W7L6Q_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6592
6592
|
pageIndex++;
|
|
6593
6593
|
}
|
|
6594
6594
|
return chain;
|
|
@@ -6600,12 +6600,12 @@ var IndexerExitDataSource = class {
|
|
|
6600
6600
|
while (hasMore) {
|
|
6601
6601
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
6602
6602
|
pageIndex,
|
|
6603
|
-
pageSize:
|
|
6603
|
+
pageSize: chunkOJ5W7L6Q_cjs.DEFAULT_PAGE_SIZE
|
|
6604
6604
|
});
|
|
6605
6605
|
for (const psbt of txs) {
|
|
6606
|
-
out.set(
|
|
6606
|
+
out.set(chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6607
6607
|
}
|
|
6608
|
-
hasMore = page ? txs.length ===
|
|
6608
|
+
hasMore = page ? txs.length === chunkOJ5W7L6Q_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6609
6609
|
pageIndex++;
|
|
6610
6610
|
}
|
|
6611
6611
|
return out;
|
|
@@ -6626,7 +6626,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
6626
6626
|
}
|
|
6627
6627
|
}
|
|
6628
6628
|
function psbtInputTxids(psbtBase64) {
|
|
6629
|
-
return txInputTxids(
|
|
6629
|
+
return txInputTxids(chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64)));
|
|
6630
6630
|
}
|
|
6631
6631
|
function txInputTxids(tx) {
|
|
6632
6632
|
const ids = [];
|
|
@@ -6930,10 +6930,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
|
|
|
6930
6930
|
try {
|
|
6931
6931
|
info = await arkProvider.getInfo();
|
|
6932
6932
|
} catch (err) {
|
|
6933
|
-
if (opts?.requireLive || !
|
|
6933
|
+
if (opts?.requireLive || !chunkOJ5W7L6Q_cjs.isRetryableProviderError(err)) throw err;
|
|
6934
6934
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
6935
6935
|
if (!snapshot) {
|
|
6936
|
-
throw new
|
|
6936
|
+
throw new chunkOJ5W7L6Q_cjs.ProviderUnavailableError(
|
|
6937
6937
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
6938
6938
|
{ cause: err }
|
|
6939
6939
|
);
|
|
@@ -7125,7 +7125,7 @@ function buildGraph(rootTxid, chunksByTxid) {
|
|
|
7125
7125
|
return new TxTree(rootTx, children);
|
|
7126
7126
|
}
|
|
7127
7127
|
function decodeNode(chunk) {
|
|
7128
|
-
const tx =
|
|
7128
|
+
const tx = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
|
|
7129
7129
|
return { tx, children: chunk.children };
|
|
7130
7130
|
}
|
|
7131
7131
|
exports.Batch = void 0;
|
|
@@ -7328,7 +7328,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
|
|
|
7328
7328
|
return [...txids];
|
|
7329
7329
|
}
|
|
7330
7330
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
|
|
7331
|
-
const normalized = vtxos.map(
|
|
7331
|
+
const normalized = vtxos.map(chunkOJ5W7L6Q_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
7332
7332
|
const localCreatedAt = localCreatedAtByTxid(normalized);
|
|
7333
7333
|
const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
|
|
7334
7334
|
const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
|
|
@@ -7503,7 +7503,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7503
7503
|
withRecoverable: false,
|
|
7504
7504
|
genericallySpendableOnly: true
|
|
7505
7505
|
});
|
|
7506
|
-
const controlAssetRef = params.controlAssetId ?
|
|
7506
|
+
const controlAssetRef = params.controlAssetId ? chunkXWUJBHYW_cjs.AssetRef.fromId(chunkXWUJBHYW_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
7507
7507
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
7508
7508
|
let totalBtcSelected = 0n;
|
|
7509
7509
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -7516,8 +7516,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7516
7516
|
}
|
|
7517
7517
|
}
|
|
7518
7518
|
const groups = [];
|
|
7519
|
-
const issuedAssetOutput =
|
|
7520
|
-
const issuedAssetGroup =
|
|
7519
|
+
const issuedAssetOutput = chunkXWUJBHYW_cjs.AssetOutput.create(0, params.amount);
|
|
7520
|
+
const issuedAssetGroup = chunkXWUJBHYW_cjs.AssetGroup.create(
|
|
7521
7521
|
null,
|
|
7522
7522
|
controlAssetRef,
|
|
7523
7523
|
[],
|
|
@@ -7530,11 +7530,11 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7530
7530
|
for (const [assetId, amount] of assetChanges) {
|
|
7531
7531
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
7532
7532
|
groups.push(
|
|
7533
|
-
|
|
7534
|
-
|
|
7533
|
+
chunkXWUJBHYW_cjs.AssetGroup.create(
|
|
7534
|
+
chunkXWUJBHYW_cjs.AssetId.fromString(assetId),
|
|
7535
7535
|
null,
|
|
7536
7536
|
changeInputs,
|
|
7537
|
-
[
|
|
7537
|
+
[chunkXWUJBHYW_cjs.AssetOutput.create(0, amount)],
|
|
7538
7538
|
[]
|
|
7539
7539
|
)
|
|
7540
7540
|
);
|
|
@@ -7548,7 +7548,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7548
7548
|
);
|
|
7549
7549
|
return {
|
|
7550
7550
|
arkTxId: arkTxid,
|
|
7551
|
-
assetId:
|
|
7551
|
+
assetId: chunkXWUJBHYW_cjs.AssetId.create(arkTxid, 0).toString()
|
|
7552
7552
|
};
|
|
7553
7553
|
}
|
|
7554
7554
|
/**
|
|
@@ -7619,23 +7619,23 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7619
7619
|
const assetInputs = selectedCoinsToAssetInputs(selectedCoins);
|
|
7620
7620
|
const reissueInputs = inputsForAsset(assetInputs, params.assetId);
|
|
7621
7621
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7622
|
-
const reissueAssetIdObj =
|
|
7623
|
-
const reissueAssetGroup =
|
|
7622
|
+
const reissueAssetIdObj = chunkXWUJBHYW_cjs.AssetId.fromString(params.assetId);
|
|
7623
|
+
const reissueAssetGroup = chunkXWUJBHYW_cjs.AssetGroup.create(
|
|
7624
7624
|
reissueAssetIdObj,
|
|
7625
7625
|
null,
|
|
7626
7626
|
reissueInputs,
|
|
7627
|
-
[
|
|
7627
|
+
[chunkXWUJBHYW_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7628
7628
|
[]
|
|
7629
7629
|
);
|
|
7630
7630
|
const groups = [reissueAssetGroup];
|
|
7631
7631
|
for (const [assetId, amount] of assetChanges) {
|
|
7632
7632
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
7633
7633
|
groups.push(
|
|
7634
|
-
|
|
7635
|
-
|
|
7634
|
+
chunkXWUJBHYW_cjs.AssetGroup.create(
|
|
7635
|
+
chunkXWUJBHYW_cjs.AssetId.fromString(assetId),
|
|
7636
7636
|
null,
|
|
7637
7637
|
changeInputs,
|
|
7638
|
-
[
|
|
7638
|
+
[chunkXWUJBHYW_cjs.AssetOutput.create(0, amount)],
|
|
7639
7639
|
[]
|
|
7640
7640
|
)
|
|
7641
7641
|
);
|
|
@@ -7703,11 +7703,11 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7703
7703
|
for (const [assetId, amount] of assetChanges) {
|
|
7704
7704
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
7705
7705
|
groups.push(
|
|
7706
|
-
|
|
7707
|
-
|
|
7706
|
+
chunkXWUJBHYW_cjs.AssetGroup.create(
|
|
7707
|
+
chunkXWUJBHYW_cjs.AssetId.fromString(assetId),
|
|
7708
7708
|
null,
|
|
7709
7709
|
changeInputs,
|
|
7710
|
-
amount > 0n ? [
|
|
7710
|
+
amount > 0n ? [chunkXWUJBHYW_cjs.AssetOutput.create(0, amount)] : [],
|
|
7711
7711
|
[]
|
|
7712
7712
|
)
|
|
7713
7713
|
);
|
|
@@ -7720,16 +7720,16 @@ function inputsForAsset(assetInputs, assetId) {
|
|
|
7720
7720
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7721
7721
|
for (const asset of assets) {
|
|
7722
7722
|
if (asset.assetId !== assetId) continue;
|
|
7723
|
-
inputs.push(
|
|
7723
|
+
inputs.push(chunkXWUJBHYW_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7724
7724
|
}
|
|
7725
7725
|
}
|
|
7726
7726
|
return inputs;
|
|
7727
7727
|
}
|
|
7728
7728
|
async function submitToSelf(wallet, inputs, amount, groups) {
|
|
7729
|
-
const outputAddress =
|
|
7729
|
+
const outputAddress = chunkOJ5W7L6Q_cjs.ArkAddress.decode(await wallet.getAddress());
|
|
7730
7730
|
const outputs = [
|
|
7731
7731
|
{ script: outputAddress.pkScript, amount: BigInt(amount) },
|
|
7732
|
-
Extension.create([
|
|
7732
|
+
Extension.create([chunkXWUJBHYW_cjs.Packet.create(groups)]).txOut()
|
|
7733
7733
|
];
|
|
7734
7734
|
const { arkTxid } = await wallet.buildAndSubmitOffchainTx(inputs, outputs);
|
|
7735
7735
|
return arkTxid;
|
|
@@ -7753,7 +7753,7 @@ function castMetadata(metadata) {
|
|
|
7753
7753
|
} else {
|
|
7754
7754
|
throw new Error("Invalid metadata value type");
|
|
7755
7755
|
}
|
|
7756
|
-
md.push(
|
|
7756
|
+
md.push(chunkXWUJBHYW_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7757
7757
|
}
|
|
7758
7758
|
return md;
|
|
7759
7759
|
}
|
|
@@ -7774,10 +7774,10 @@ var DelegateManagerImpl = class {
|
|
|
7774
7774
|
if (vtxos.length === 0) {
|
|
7775
7775
|
return { delegated: [], failed: [] };
|
|
7776
7776
|
}
|
|
7777
|
-
const destinationScript =
|
|
7777
|
+
const destinationScript = chunkOJ5W7L6Q_cjs.ArkAddress.decode(destination).pkScript;
|
|
7778
7778
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
7779
7779
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
7780
|
-
const eligible = vtxos.map(
|
|
7780
|
+
const eligible = vtxos.map(chunkOJ5W7L6Q_cjs.normalizeVtxo).filter(
|
|
7781
7781
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7782
7782
|
);
|
|
7783
7783
|
if (eligible.length === 0) {
|
|
@@ -7809,7 +7809,7 @@ var DelegateManagerImpl = class {
|
|
|
7809
7809
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7810
7810
|
let recoverableVtxos = [];
|
|
7811
7811
|
for (const vtxo of eligible) {
|
|
7812
|
-
if (
|
|
7812
|
+
if (chunkOJ5W7L6Q_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7813
7813
|
recoverableVtxos.push(vtxo);
|
|
7814
7814
|
continue;
|
|
7815
7815
|
}
|
|
@@ -7861,7 +7861,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7861
7861
|
}
|
|
7862
7862
|
if (!delegateAt) {
|
|
7863
7863
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7864
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7864
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkOJ5W7L6Q_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
|
|
7865
7865
|
(min, coin) => Math.min(min, coin.expiresAt.getTime()),
|
|
7866
7866
|
Number.MAX_SAFE_INTEGER
|
|
7867
7867
|
);
|
|
@@ -7888,7 +7888,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7888
7888
|
let amount = 0n;
|
|
7889
7889
|
for (const coin of vtxos) {
|
|
7890
7890
|
const inputFee = estimator.evalOffchainInput({
|
|
7891
|
-
...
|
|
7891
|
+
...chunkOJ5W7L6Q_cjs.toOffchainInputFeeParams(coin),
|
|
7892
7892
|
type: "vtxo"
|
|
7893
7893
|
});
|
|
7894
7894
|
if (inputFee.satoshis >= coin.value) {
|
|
@@ -7902,7 +7902,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7902
7902
|
const delegateFee = BigInt(Number(fee));
|
|
7903
7903
|
if (delegateFee > 0n) {
|
|
7904
7904
|
outputs.push({
|
|
7905
|
-
script:
|
|
7905
|
+
script: chunkOJ5W7L6Q_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
7906
7906
|
amount: delegateFee
|
|
7907
7907
|
});
|
|
7908
7908
|
}
|
|
@@ -7935,10 +7935,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7935
7935
|
destinationScript
|
|
7936
7936
|
);
|
|
7937
7937
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
7938
|
-
btcSigner.Address(
|
|
7938
|
+
btcSigner.Address(chunkOJ5W7L6Q_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
7939
7939
|
);
|
|
7940
7940
|
const forfeits = await Promise.all(
|
|
7941
|
-
vtxos.filter((v) =>
|
|
7941
|
+
vtxos.filter((v) => chunkOJ5W7L6Q_cjs.requiresForfeit(v)).map(async (coin) => {
|
|
7942
7942
|
const forfeit = await makeDelegateForfeitTx(
|
|
7943
7943
|
coin,
|
|
7944
7944
|
dust,
|
|
@@ -7963,7 +7963,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
7963
7963
|
index: input.vout,
|
|
7964
7964
|
witnessUtxo: {
|
|
7965
7965
|
amount: BigInt(input.value),
|
|
7966
|
-
script:
|
|
7966
|
+
script: chunkOJ5W7L6Q_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
7967
7967
|
},
|
|
7968
7968
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
7969
7969
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -8021,7 +8021,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
8021
8021
|
expire_at: 0,
|
|
8022
8022
|
cosigners_public_keys: cosignerPubKeys
|
|
8023
8023
|
};
|
|
8024
|
-
const proof =
|
|
8024
|
+
const proof = chunkOJ5W7L6Q_cjs.Intent.create(message, coins, outputs);
|
|
8025
8025
|
const signedProof = await identity.sign(proof);
|
|
8026
8026
|
return {
|
|
8027
8027
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -8047,10 +8047,10 @@ function getDayTimestamp(timestamp) {
|
|
|
8047
8047
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
8048
8048
|
if (!vtxo.tapTree) return void 0;
|
|
8049
8049
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
8050
|
-
const vtxoScript =
|
|
8050
|
+
const vtxoScript = chunkOJ5W7L6Q_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
8051
8051
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
8052
|
-
const arkTapscript =
|
|
8053
|
-
if (!
|
|
8052
|
+
const arkTapscript = chunkOJ5W7L6Q_cjs.decodeTapscript(chunkOJ5W7L6Q_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
8053
|
+
if (!chunkOJ5W7L6Q_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
8054
8054
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
8055
8055
|
});
|
|
8056
8056
|
}
|
|
@@ -8606,8 +8606,8 @@ function checkSaveVtxosForScript(backend, key, vtxos) {
|
|
|
8606
8606
|
}
|
|
8607
8607
|
async function getVtxosForContract(repo, contract, options) {
|
|
8608
8608
|
const vtxos = repo.getVtxosForScriptPage ? await collectScriptVtxos(repo, contract.script, options) : filterVtxosForScript(await collectVtxos(repo, contract.address), contract.script);
|
|
8609
|
-
const normalized = vtxos.map(
|
|
8610
|
-
return options?.unspentOnly ? normalized.filter((vtxo) => !
|
|
8609
|
+
const normalized = vtxos.map(chunkOJ5W7L6Q_cjs.normalizeVtxo);
|
|
8610
|
+
return options?.unspentOnly ? normalized.filter((vtxo) => !chunkOJ5W7L6Q_cjs.isVtxoSpent(vtxo)) : normalized;
|
|
8611
8611
|
}
|
|
8612
8612
|
async function hasVtxosForContract(repo, contract) {
|
|
8613
8613
|
if (repo.getVtxosForScriptPage) {
|
|
@@ -8838,7 +8838,7 @@ function decodeArkContract(encoded) {
|
|
|
8838
8838
|
}
|
|
8839
8839
|
function contractFromArkContract(encoded, options = {}) {
|
|
8840
8840
|
const parsed = decodeArkContract(encoded);
|
|
8841
|
-
const handler =
|
|
8841
|
+
const handler = chunkOSRXKF7B_cjs.contractHandlers.get(parsed.type);
|
|
8842
8842
|
if (!handler) {
|
|
8843
8843
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8844
8844
|
}
|
|
@@ -8852,9 +8852,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8852
8852
|
metadata: options.metadata
|
|
8853
8853
|
};
|
|
8854
8854
|
}
|
|
8855
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8855
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkOJ5W7L6Q_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8856
8856
|
const parsed = decodeArkContract(encoded);
|
|
8857
|
-
const handler =
|
|
8857
|
+
const handler = chunkOSRXKF7B_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8858
8858
|
const params = parsed.data;
|
|
8859
8859
|
const vtxoScript = handler.createScript(params);
|
|
8860
8860
|
return {
|
|
@@ -8903,9 +8903,9 @@ var ContractWatcher = class {
|
|
|
8903
8903
|
eventSourceReported = false;
|
|
8904
8904
|
/** @see ContractWatcherConfig */
|
|
8905
8905
|
constructor(config) {
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8906
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs("failsafePollIntervalMs", config.failsafePollIntervalMs);
|
|
8907
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs("reconnectDelayMs", config.reconnectDelayMs);
|
|
8908
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs("maxReconnectDelayMs", config.maxReconnectDelayMs);
|
|
8909
8909
|
this.config = {
|
|
8910
8910
|
...DEFAULT_CONTRACT_WATCHER_CONFIG,
|
|
8911
8911
|
...config
|
|
@@ -9107,9 +9107,9 @@ var ContractWatcher = class {
|
|
|
9107
9107
|
this.connectionState = "connected";
|
|
9108
9108
|
this.reconnectAttempts = 0;
|
|
9109
9109
|
this.listenLoop().catch((e) => {
|
|
9110
|
-
if (
|
|
9110
|
+
if (chunkOJ5W7L6Q_cjs.isEventSourceError(e)) {
|
|
9111
9111
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
9112
|
-
} else if (!
|
|
9112
|
+
} else if (!chunkOJ5W7L6Q_cjs.isEventSourceUnavailableError(e)) {
|
|
9113
9113
|
console.error(e);
|
|
9114
9114
|
}
|
|
9115
9115
|
this.connectionState = "disconnected";
|
|
@@ -9121,7 +9121,7 @@ var ContractWatcher = class {
|
|
|
9121
9121
|
this.scheduleReconnect();
|
|
9122
9122
|
});
|
|
9123
9123
|
} catch (error) {
|
|
9124
|
-
if (!
|
|
9124
|
+
if (!chunkOJ5W7L6Q_cjs.isEventSourceUnavailableError(error)) {
|
|
9125
9125
|
console.error("ContractWatcher connection failed:", error);
|
|
9126
9126
|
}
|
|
9127
9127
|
this.connectionState = "disconnected";
|
|
@@ -9140,7 +9140,7 @@ var ContractWatcher = class {
|
|
|
9140
9140
|
* few seconds.
|
|
9141
9141
|
*/
|
|
9142
9142
|
reportEventSourceUnavailable(error) {
|
|
9143
|
-
if (!
|
|
9143
|
+
if (!chunkOJ5W7L6Q_cjs.isEventSourceUnavailableError(error)) return false;
|
|
9144
9144
|
if (!this.eventSourceReported) {
|
|
9145
9145
|
this.eventSourceReported = true;
|
|
9146
9146
|
console.warn(
|
|
@@ -9204,7 +9204,7 @@ var ContractWatcher = class {
|
|
|
9204
9204
|
const now = Date.now();
|
|
9205
9205
|
let current;
|
|
9206
9206
|
try {
|
|
9207
|
-
current = await
|
|
9207
|
+
current = await chunkOJ5W7L6Q_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
|
|
9208
9208
|
spendableOnly: true
|
|
9209
9209
|
});
|
|
9210
9210
|
} catch (error) {
|
|
@@ -9393,14 +9393,14 @@ var ContractWatcher = class {
|
|
|
9393
9393
|
const timestamp = Date.now();
|
|
9394
9394
|
if (update.newVtxos?.length) {
|
|
9395
9395
|
this.processSubscriptionVtxos(
|
|
9396
|
-
update.newVtxos.map(
|
|
9396
|
+
update.newVtxos.map(chunkOJ5W7L6Q_cjs.normalizeVtxo),
|
|
9397
9397
|
"vtxo_received",
|
|
9398
9398
|
timestamp
|
|
9399
9399
|
);
|
|
9400
9400
|
}
|
|
9401
9401
|
if (update.spentVtxos?.length) {
|
|
9402
9402
|
this.processSubscriptionVtxos(
|
|
9403
|
-
update.spentVtxos.map(
|
|
9403
|
+
update.spentVtxos.map(chunkOJ5W7L6Q_cjs.normalizeVtxo),
|
|
9404
9404
|
"vtxo_spent",
|
|
9405
9405
|
timestamp
|
|
9406
9406
|
);
|
|
@@ -9425,8 +9425,8 @@ var ContractWatcher = class {
|
|
|
9425
9425
|
continue;
|
|
9426
9426
|
}
|
|
9427
9427
|
if (target === byWatchedScript && eventType === "vtxo_received") {
|
|
9428
|
-
const n =
|
|
9429
|
-
if (
|
|
9428
|
+
const n = chunkOJ5W7L6Q_cjs.normalizeVtxo(vtxo);
|
|
9429
|
+
if (chunkOJ5W7L6Q_cjs.isVtxoSpent(n) || n.isSwept || chunkOJ5W7L6Q_cjs.isPastExpiry(n, now)) continue;
|
|
9430
9430
|
}
|
|
9431
9431
|
let bucket = target.get(vtxo.script);
|
|
9432
9432
|
if (!bucket) {
|
|
@@ -9532,7 +9532,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
9532
9532
|
if (!contract) continue;
|
|
9533
9533
|
try {
|
|
9534
9534
|
const key = `${contract.type}\0${script}\0${JSON.stringify(contract.params)}`;
|
|
9535
|
-
const handler =
|
|
9535
|
+
const handler = chunkOSRXKF7B_cjs.contractHandlers.get(contract.type);
|
|
9536
9536
|
const hit = memo?.get(script);
|
|
9537
9537
|
let tapscripts;
|
|
9538
9538
|
if (hit && hit.key === key && hit.handler === handler) {
|
|
@@ -9594,8 +9594,8 @@ var ContractManager = class _ContractManager {
|
|
|
9594
9594
|
* `dispose()`, so it re-checks this at every await rather than run on a torn-down watcher. */
|
|
9595
9595
|
disposed = false;
|
|
9596
9596
|
constructor(config) {
|
|
9597
|
-
|
|
9598
|
-
|
|
9597
|
+
chunkOJ5W7L6Q_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", config.vtxoSyncMaxAgeMs);
|
|
9598
|
+
chunkOJ5W7L6Q_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", config.vtxoSyncOverlapMs);
|
|
9599
9599
|
this.config = { ...config };
|
|
9600
9600
|
this.watcher = new ContractWatcher({
|
|
9601
9601
|
indexerProvider: config.indexerProvider,
|
|
@@ -9625,12 +9625,12 @@ var ContractManager = class _ContractManager {
|
|
|
9625
9625
|
}
|
|
9626
9626
|
/** @see ContractManagerConfig.vtxoSyncMaxAgeMs — for factory-built managers. */
|
|
9627
9627
|
setVtxoSyncMaxAge(maxAgeMs) {
|
|
9628
|
-
|
|
9628
|
+
chunkOJ5W7L6Q_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", maxAgeMs);
|
|
9629
9629
|
this.config.vtxoSyncMaxAgeMs = maxAgeMs;
|
|
9630
9630
|
}
|
|
9631
9631
|
/** @see ContractManagerConfig.vtxoSyncOverlapMs — for factory-built managers. */
|
|
9632
9632
|
setVtxoSyncOverlap(overlapMs) {
|
|
9633
|
-
|
|
9633
|
+
chunkOJ5W7L6Q_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", overlapMs);
|
|
9634
9634
|
this.config.vtxoSyncOverlapMs = overlapMs;
|
|
9635
9635
|
}
|
|
9636
9636
|
markSyncOnline() {
|
|
@@ -9673,7 +9673,7 @@ var ContractManager = class _ContractManager {
|
|
|
9673
9673
|
this.markSyncOnline();
|
|
9674
9674
|
return void 0;
|
|
9675
9675
|
} catch (err) {
|
|
9676
|
-
if (!
|
|
9676
|
+
if (!chunkOJ5W7L6Q_cjs.isRetryableProviderError(err)) throw err;
|
|
9677
9677
|
this.markSyncDegraded(err);
|
|
9678
9678
|
return err;
|
|
9679
9679
|
}
|
|
@@ -9695,7 +9695,7 @@ var ContractManager = class _ContractManager {
|
|
|
9695
9695
|
try {
|
|
9696
9696
|
await this.scheduleLookAheadDrain();
|
|
9697
9697
|
} catch (err) {
|
|
9698
|
-
if (!
|
|
9698
|
+
if (!chunkOJ5W7L6Q_cjs.isRetryableProviderError(err)) throw err;
|
|
9699
9699
|
this.lookAheadRefillOwed = true;
|
|
9700
9700
|
this.markSyncDegraded(err);
|
|
9701
9701
|
}
|
|
@@ -9805,7 +9805,7 @@ var ContractManager = class _ContractManager {
|
|
|
9805
9805
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9806
9806
|
const to = watermark + lookAhead.size;
|
|
9807
9807
|
const deps = lookAhead.candidateDeps();
|
|
9808
|
-
const handlers =
|
|
9808
|
+
const handlers = chunkOSRXKF7B_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkOSRXKF7B_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9809
9809
|
const band = /* @__PURE__ */ new Map();
|
|
9810
9810
|
for (let index = from; index <= to; index++) {
|
|
9811
9811
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9816,7 +9816,7 @@ var ContractManager = class _ContractManager {
|
|
|
9816
9816
|
index,
|
|
9817
9817
|
params: {
|
|
9818
9818
|
...candidate,
|
|
9819
|
-
...
|
|
9819
|
+
...chunkOSRXKF7B_cjs.speculativeReceiveMetadata(descriptor)
|
|
9820
9820
|
}
|
|
9821
9821
|
});
|
|
9822
9822
|
}
|
|
@@ -9875,7 +9875,7 @@ var ContractManager = class _ContractManager {
|
|
|
9875
9875
|
});
|
|
9876
9876
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9877
9877
|
} catch (err) {
|
|
9878
|
-
if (!
|
|
9878
|
+
if (!chunkOJ5W7L6Q_cjs.isRetryableProviderError(err)) throw err;
|
|
9879
9879
|
this.markSyncDegraded(err);
|
|
9880
9880
|
}
|
|
9881
9881
|
}
|
|
@@ -9966,7 +9966,7 @@ var ContractManager = class _ContractManager {
|
|
|
9966
9966
|
return result;
|
|
9967
9967
|
}
|
|
9968
9968
|
async upsertContractRow(params) {
|
|
9969
|
-
const handler =
|
|
9969
|
+
const handler = chunkOSRXKF7B_cjs.contractHandlers.get(params.type);
|
|
9970
9970
|
if (!handler) {
|
|
9971
9971
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9972
9972
|
}
|
|
@@ -10034,7 +10034,7 @@ var ContractManager = class _ContractManager {
|
|
|
10034
10034
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
10035
10035
|
);
|
|
10036
10036
|
}
|
|
10037
|
-
const registered =
|
|
10037
|
+
const registered = chunkOSRXKF7B_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkOSRXKF7B_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
10038
10038
|
const discoverables = [
|
|
10039
10039
|
...registered.filter((h) => h.type === "boarding"),
|
|
10040
10040
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -10160,7 +10160,7 @@ var ContractManager = class _ContractManager {
|
|
|
10160
10160
|
return await collectContracts(this.config.contractRepository, dbFilter);
|
|
10161
10161
|
}
|
|
10162
10162
|
async getContractsWithVtxos(filter, pageSize, options) {
|
|
10163
|
-
|
|
10163
|
+
chunkOJ5W7L6Q_cjs.assertNonNegativeMs("maxSyncAgeMs", options?.maxSyncAgeMs);
|
|
10164
10164
|
const contracts = await this.getContracts(filter);
|
|
10165
10165
|
if (this.syncedWithin(
|
|
10166
10166
|
contracts,
|
|
@@ -10199,7 +10199,7 @@ var ContractManager = class _ContractManager {
|
|
|
10199
10199
|
}
|
|
10200
10200
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
10201
10201
|
return vtxos.map(
|
|
10202
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
10202
|
+
(vtxo) => extendVirtualCoinForContract(chunkOJ5W7L6Q_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
10203
10203
|
);
|
|
10204
10204
|
}
|
|
10205
10205
|
/** @inheritdoc */
|
|
@@ -10244,14 +10244,14 @@ var ContractManager = class _ContractManager {
|
|
|
10244
10244
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
10245
10245
|
const asking = vtxos.filter((vtxo) => {
|
|
10246
10246
|
const contract = byScript.get(vtxo.script);
|
|
10247
|
-
return contract !== void 0 &&
|
|
10247
|
+
return contract !== void 0 && chunkOSRXKF7B_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
10248
10248
|
});
|
|
10249
10249
|
if (asking.length === 0) return refused;
|
|
10250
10250
|
const tip = await this.currentChainTip();
|
|
10251
10251
|
const walletDescriptorValue = await walletDescriptor?.();
|
|
10252
10252
|
for (const vtxo of asking) {
|
|
10253
10253
|
const contract = byScript.get(vtxo.script);
|
|
10254
|
-
const handler =
|
|
10254
|
+
const handler = chunkOSRXKF7B_cjs.contractHandlers.get(contract.type);
|
|
10255
10255
|
if (!handler?.assertSpendableNow) continue;
|
|
10256
10256
|
const context = {
|
|
10257
10257
|
collaborative: true,
|
|
@@ -10261,7 +10261,7 @@ var ContractManager = class _ContractManager {
|
|
|
10261
10261
|
walletDescriptor: walletDescriptorValue,
|
|
10262
10262
|
// `isVirtualCoin` only checks `script`, which every input has; `isCsvSpendable`
|
|
10263
10263
|
// reads `vtxo.status.block_time` unguarded, so require `status` too.
|
|
10264
|
-
vtxo:
|
|
10264
|
+
vtxo: chunkOJ5W7L6Q_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
10265
10265
|
};
|
|
10266
10266
|
try {
|
|
10267
10267
|
await handler.assertSpendableNow(
|
|
@@ -10374,7 +10374,7 @@ var ContractManager = class _ContractManager {
|
|
|
10374
10374
|
const { contractScript, collaborative = true, walletDescriptor, vtxo } = options;
|
|
10375
10375
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10376
10376
|
if (!contract) return [];
|
|
10377
|
-
const handler =
|
|
10377
|
+
const handler = chunkOSRXKF7B_cjs.contractHandlers.get(contract.type);
|
|
10378
10378
|
if (!handler) return [];
|
|
10379
10379
|
const script = handler.createScript(contract.params);
|
|
10380
10380
|
const tip = await this.currentChainTip();
|
|
@@ -10396,7 +10396,7 @@ var ContractManager = class _ContractManager {
|
|
|
10396
10396
|
const { contractScript, collaborative = true, walletDescriptor } = options;
|
|
10397
10397
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10398
10398
|
if (!contract) return [];
|
|
10399
|
-
const handler =
|
|
10399
|
+
const handler = chunkOSRXKF7B_cjs.contractHandlers.get(contract.type);
|
|
10400
10400
|
if (!handler) return [];
|
|
10401
10401
|
const script = handler.createScript(contract.params);
|
|
10402
10402
|
const context = {
|
|
@@ -10442,7 +10442,7 @@ var ContractManager = class _ContractManager {
|
|
|
10442
10442
|
}
|
|
10443
10443
|
async refreshOutpoints(outpoints) {
|
|
10444
10444
|
if (outpoints.length === 0) return;
|
|
10445
|
-
const { vtxos } = await
|
|
10445
|
+
const { vtxos } = await chunkOJ5W7L6Q_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
10446
10446
|
outpoints
|
|
10447
10447
|
});
|
|
10448
10448
|
if (vtxos.length === 0) return;
|
|
@@ -10534,7 +10534,7 @@ var ContractManager = class _ContractManager {
|
|
|
10534
10534
|
break;
|
|
10535
10535
|
}
|
|
10536
10536
|
} catch (err) {
|
|
10537
|
-
if (!
|
|
10537
|
+
if (!chunkOJ5W7L6Q_cjs.isRetryableProviderError(err)) throw err;
|
|
10538
10538
|
this.markSyncDegraded(err);
|
|
10539
10539
|
}
|
|
10540
10540
|
this.emitEvent(event);
|
|
@@ -10609,7 +10609,7 @@ var ContractManager = class _ContractManager {
|
|
|
10609
10609
|
*/
|
|
10610
10610
|
async reconcilePendingFrontier(contracts) {
|
|
10611
10611
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
10612
|
-
const vtxos = await
|
|
10612
|
+
const vtxos = await chunkOJ5W7L6Q_cjs.getAllNormalizedVtxos(
|
|
10613
10613
|
this.config.indexerProvider,
|
|
10614
10614
|
contracts.map((c) => c.script),
|
|
10615
10615
|
{ pendingOnly: true }
|
|
@@ -10683,7 +10683,7 @@ var ContractManager = class _ContractManager {
|
|
|
10683
10683
|
}
|
|
10684
10684
|
return result;
|
|
10685
10685
|
}
|
|
10686
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10686
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkOJ5W7L6Q_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
10687
10687
|
if (contracts.length === 0) {
|
|
10688
10688
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
10689
10689
|
}
|
|
@@ -10699,7 +10699,7 @@ var ContractManager = class _ContractManager {
|
|
|
10699
10699
|
before: syncWindow.before
|
|
10700
10700
|
}
|
|
10701
10701
|
} : {};
|
|
10702
|
-
const vtxos = await
|
|
10702
|
+
const vtxos = await chunkOJ5W7L6Q_cjs.getAllNormalizedVtxos(
|
|
10703
10703
|
this.config.indexerProvider,
|
|
10704
10704
|
contracts.map((c) => c.script),
|
|
10705
10705
|
{ ...windowOpts, pageSize }
|
|
@@ -10786,7 +10786,7 @@ function parseLegacyExpiry(batchExpiry) {
|
|
|
10786
10786
|
if (typeof batchExpiry !== "number" || !Number.isFinite(batchExpiry) || batchExpiry <= 0) {
|
|
10787
10787
|
return {};
|
|
10788
10788
|
}
|
|
10789
|
-
if (batchExpiry >=
|
|
10789
|
+
if (batchExpiry >= chunkOJ5W7L6Q_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
|
|
10790
10790
|
return { expiresAtHeight: batchExpiry / 1e3 };
|
|
10791
10791
|
}
|
|
10792
10792
|
function legacyVtxoFacts(status) {
|
|
@@ -11024,7 +11024,7 @@ function backfillContractWatchState(store) {
|
|
|
11024
11024
|
};
|
|
11025
11025
|
readPage();
|
|
11026
11026
|
}
|
|
11027
|
-
var unspentFlag = (vtxo) =>
|
|
11027
|
+
var unspentFlag = (vtxo) => chunkOJ5W7L6Q_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
|
|
11028
11028
|
function backfillVtxoIndexFields(transaction) {
|
|
11029
11029
|
const store = transaction.objectStore(STORE_VTXOS);
|
|
11030
11030
|
const pageSize = 1e3;
|
|
@@ -11055,7 +11055,7 @@ var DEFAULT_DB_NAME = "arkade-service-worker";
|
|
|
11055
11055
|
var DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS = 1e4;
|
|
11056
11056
|
function normalizeOptions2(pathOrOptions) {
|
|
11057
11057
|
const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
|
|
11058
|
-
|
|
11058
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
|
|
11059
11059
|
return {
|
|
11060
11060
|
path: o.path,
|
|
11061
11061
|
activationTimeoutMs: o.activationTimeoutMs ?? DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS
|
|
@@ -11274,7 +11274,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
11274
11274
|
const s = base.hex.decode(t.s);
|
|
11275
11275
|
return [cb, s];
|
|
11276
11276
|
};
|
|
11277
|
-
var deserializeVtxo = (o) =>
|
|
11277
|
+
var deserializeVtxo = (o) => chunkOJ5W7L6Q_cjs.normalizeVtxo({
|
|
11278
11278
|
...o,
|
|
11279
11279
|
createdAt: new Date(o.createdAt),
|
|
11280
11280
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -11698,7 +11698,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
11698
11698
|
*/
|
|
11699
11699
|
materializeDescriptorAt(index) {
|
|
11700
11700
|
const descriptor = this.identity.descriptor;
|
|
11701
|
-
const network =
|
|
11701
|
+
const network = chunkOSRXKF7B_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
11702
11702
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
11703
11703
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
11704
11704
|
if (!keyInfo?.keyExpression) {
|
|
@@ -11766,7 +11766,7 @@ function signingDescriptorIndex(descriptor) {
|
|
|
11766
11766
|
}
|
|
11767
11767
|
function newestWalletReceiveContract(contracts, serverPubKeyHex) {
|
|
11768
11768
|
return contracts.filter(
|
|
11769
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
11769
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkOSRXKF7B_cjs.WALLET_RECEIVE_SOURCE
|
|
11770
11770
|
).sort((a, b) => {
|
|
11771
11771
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
11772
11772
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -11817,7 +11817,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11817
11817
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
11818
11818
|
if (!provider) return void 0;
|
|
11819
11819
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
11820
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
11820
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkOSRXKF7B_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
11821
11821
|
const factoryOpts = {
|
|
11822
11822
|
walletRepository: setup.walletRepository,
|
|
11823
11823
|
contractRepository: setup.contractRepository,
|
|
@@ -11974,7 +11974,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11974
11974
|
};
|
|
11975
11975
|
function deriveLeafPubkey(descriptor) {
|
|
11976
11976
|
try {
|
|
11977
|
-
return
|
|
11977
|
+
return chunkOSRXKF7B_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
11978
11978
|
} catch (e) {
|
|
11979
11979
|
throw new NonRangeableDescriptorError(
|
|
11980
11980
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -11986,7 +11986,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11986
11986
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
11987
11987
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
11988
11988
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
11989
|
-
const csvTimelock2 =
|
|
11989
|
+
const csvTimelock2 = chunkOJ5W7L6Q_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
11990
11990
|
const base$1 = {
|
|
11991
11991
|
script: base.hex.encode(tapscript.pkScript),
|
|
11992
11992
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -11994,11 +11994,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11994
11994
|
// Read at sign time to route rotated-pubkey inputs through `signWithDescriptor`; without
|
|
11995
11995
|
// it spends are rejected with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
11996
11996
|
metadata: {
|
|
11997
|
-
...tagSource && { source:
|
|
11997
|
+
...tagSource && { source: chunkOSRXKF7B_cjs.WALLET_RECEIVE_SOURCE },
|
|
11998
11998
|
signingDescriptor: descriptor
|
|
11999
11999
|
}
|
|
12000
12000
|
};
|
|
12001
|
-
const params = tapscript instanceof
|
|
12001
|
+
const params = tapscript instanceof chunkOSRXKF7B_cjs.DelegateVtxo.Script ? {
|
|
12002
12002
|
...base$1,
|
|
12003
12003
|
type: "delegate",
|
|
12004
12004
|
params: {
|
|
@@ -12019,10 +12019,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12019
12019
|
return { tapscript, params };
|
|
12020
12020
|
}
|
|
12021
12021
|
function rebuildTapscript(current, pubKey) {
|
|
12022
|
-
if (current instanceof
|
|
12023
|
-
return new
|
|
12022
|
+
if (current instanceof chunkOSRXKF7B_cjs.DelegateVtxo.Script) {
|
|
12023
|
+
return new chunkOSRXKF7B_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
12024
12024
|
}
|
|
12025
|
-
return new
|
|
12025
|
+
return new chunkOSRXKF7B_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
12026
12026
|
}
|
|
12027
12027
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
12028
12028
|
const candidates = await collectContracts(contractRepository, {
|
|
@@ -12080,7 +12080,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12080
12080
|
}
|
|
12081
12081
|
};
|
|
12082
12082
|
for (const vtxo of vtxos) {
|
|
12083
|
-
if (
|
|
12083
|
+
if (chunkOJ5W7L6Q_cjs.isVtxoSpent(vtxo)) continue;
|
|
12084
12084
|
addAssets(owned, vtxo);
|
|
12085
12085
|
if (vtxo.isUnrolled) {
|
|
12086
12086
|
unrolled += vtxo.value;
|
|
@@ -12090,11 +12090,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12090
12090
|
pendingRecovery += vtxo.value;
|
|
12091
12091
|
continue;
|
|
12092
12092
|
}
|
|
12093
|
-
if (
|
|
12093
|
+
if (chunkOJ5W7L6Q_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12094
12094
|
recoverable += vtxo.value;
|
|
12095
12095
|
continue;
|
|
12096
12096
|
}
|
|
12097
|
-
if (!
|
|
12097
|
+
if (!chunkOJ5W7L6Q_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
12098
12098
|
if (vtxo.isPreconfirmed) {
|
|
12099
12099
|
preconfirmed += vtxo.value;
|
|
12100
12100
|
} else {
|
|
@@ -12305,7 +12305,7 @@ function intentProofJobs(coins) {
|
|
|
12305
12305
|
if (coins.length === 0) return [];
|
|
12306
12306
|
const coinJobs = coins.map((coin, i) => ({
|
|
12307
12307
|
index: i + 1,
|
|
12308
|
-
lookupScript:
|
|
12308
|
+
lookupScript: chunkOJ5W7L6Q_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12309
12309
|
}));
|
|
12310
12310
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12311
12311
|
}
|
|
@@ -12331,7 +12331,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
12331
12331
|
const seen = /* @__PURE__ */ new Set();
|
|
12332
12332
|
const deduped = [];
|
|
12333
12333
|
for (const timelock of timelocks) {
|
|
12334
|
-
const sequence =
|
|
12334
|
+
const sequence = chunkOJ5W7L6Q_cjs.timelockToSequence(timelock).toString();
|
|
12335
12335
|
if (seen.has(sequence)) continue;
|
|
12336
12336
|
seen.add(sequence);
|
|
12337
12337
|
deduped.push(timelock);
|
|
@@ -12347,7 +12347,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12347
12347
|
if (!newest?.params.pubKey) return baseline;
|
|
12348
12348
|
try {
|
|
12349
12349
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
12350
|
-
return new
|
|
12350
|
+
return new chunkOSRXKF7B_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
12351
12351
|
} catch (e) {
|
|
12352
12352
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
12353
12353
|
return baseline;
|
|
@@ -12379,21 +12379,21 @@ function filterFlatVtxos(vtxos, filter, pendingSpendOutpoints) {
|
|
|
12379
12379
|
if (vtxo.isUnrolled) {
|
|
12380
12380
|
return !!f.withUnrolled;
|
|
12381
12381
|
}
|
|
12382
|
-
if (
|
|
12382
|
+
if (chunkOJ5W7L6Q_cjs.isVtxoSpent(vtxo)) {
|
|
12383
12383
|
return false;
|
|
12384
12384
|
}
|
|
12385
|
-
if (!f.withRecoverable &&
|
|
12385
|
+
if (!f.withRecoverable && chunkOJ5W7L6Q_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12386
12386
|
return false;
|
|
12387
12387
|
}
|
|
12388
12388
|
return true;
|
|
12389
12389
|
});
|
|
12390
12390
|
}
|
|
12391
12391
|
async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
12392
|
-
const candidates = inputs.filter(
|
|
12392
|
+
const candidates = inputs.filter(chunkOJ5W7L6Q_cjs.isVirtualCoin).map(chunkOJ5W7L6Q_cjs.normalizeVtxo).filter((v) => !v.isSwept);
|
|
12393
12393
|
if (candidates.length === 0) return inputs;
|
|
12394
|
-
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await
|
|
12394
|
+
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkOJ5W7L6Q_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
|
|
12395
12395
|
const suspects = candidates.filter(
|
|
12396
|
-
(v) =>
|
|
12396
|
+
(v) => chunkOJ5W7L6Q_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
|
|
12397
12397
|
);
|
|
12398
12398
|
if (suspects.length === 0) return inputs;
|
|
12399
12399
|
let sweptNow;
|
|
@@ -12407,12 +12407,12 @@ async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
|
12407
12407
|
);
|
|
12408
12408
|
} catch (e) {
|
|
12409
12409
|
const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
|
|
12410
|
-
throw
|
|
12410
|
+
throw chunkOJ5W7L6Q_cjs.isRetryableProviderError(e) ? new chunkOJ5W7L6Q_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
|
|
12411
12411
|
}
|
|
12412
12412
|
if (sweptNow.size === 0) return inputs;
|
|
12413
12413
|
return inputs.map((input) => {
|
|
12414
|
-
if (!
|
|
12415
|
-
return { ...
|
|
12414
|
+
if (!chunkOJ5W7L6Q_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
|
|
12415
|
+
return { ...chunkOJ5W7L6Q_cjs.normalizeVtxo(input), isSwept: true };
|
|
12416
12416
|
});
|
|
12417
12417
|
}
|
|
12418
12418
|
var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
|
|
@@ -12679,7 +12679,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12679
12679
|
async getArkadeReader() {
|
|
12680
12680
|
const indexer = this.indexerProvider;
|
|
12681
12681
|
return {
|
|
12682
|
-
getVtxos: (opts) =>
|
|
12682
|
+
getVtxos: (opts) => chunkOJ5W7L6Q_cjs.getNormalizedVtxos(indexer, opts),
|
|
12683
12683
|
getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
|
|
12684
12684
|
};
|
|
12685
12685
|
}
|
|
@@ -12714,7 +12714,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12714
12714
|
}
|
|
12715
12715
|
/** Shared setup for ReadonlyWallet.create() and Wallet.create(). */
|
|
12716
12716
|
static async setupWalletConfig(config, pubKey) {
|
|
12717
|
-
const arkProvider = config.arkProvider || new
|
|
12717
|
+
const arkProvider = config.arkProvider || new chunkOJ5W7L6Q_cjs.RestArkProvider();
|
|
12718
12718
|
let indexerProvider = config.indexerProvider;
|
|
12719
12719
|
if (!indexerProvider) {
|
|
12720
12720
|
const derived = extractArkProviderUrl(arkProvider);
|
|
@@ -12723,7 +12723,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12723
12723
|
"indexerProvider is required when arkProvider is provided without a discoverable serverUrl"
|
|
12724
12724
|
);
|
|
12725
12725
|
}
|
|
12726
|
-
indexerProvider = new
|
|
12726
|
+
indexerProvider = new chunkXWUJBHYW_cjs.RestIndexerProvider(derived ?? chunkOJ5W7L6Q_cjs.DEFAULT_ARKADE_SERVER_URL);
|
|
12727
12727
|
}
|
|
12728
12728
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
12729
12729
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -12732,7 +12732,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12732
12732
|
source: serverInfoSource,
|
|
12733
12733
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
12734
12734
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
12735
|
-
const network =
|
|
12735
|
+
const network = chunkOJ5W7L6Q_cjs.networkFromArkadeInfo(info);
|
|
12736
12736
|
if ("descriptor" in config.identity) {
|
|
12737
12737
|
const descriptor = config.identity.descriptor;
|
|
12738
12738
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -12768,18 +12768,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12768
12768
|
}
|
|
12769
12769
|
}
|
|
12770
12770
|
const boardingTimelock = config.boardingTimelock ?? toTimelock(info.boardingExitDelay);
|
|
12771
|
-
const serverPubKey =
|
|
12772
|
-
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) =>
|
|
12771
|
+
const serverPubKey = chunkOSRXKF7B_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
12772
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkOSRXKF7B_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
|
|
12773
12773
|
const offchainOptions = {
|
|
12774
12774
|
pubKey,
|
|
12775
12775
|
serverPubKey,
|
|
12776
12776
|
csvTimelock: exitTimelock
|
|
12777
12777
|
};
|
|
12778
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
12779
|
-
const boardingTapscript =
|
|
12778
|
+
const offchainTapscript = !delegatePubKey ? new chunkOSRXKF7B_cjs.DefaultVtxo.Script(offchainOptions) : new chunkOSRXKF7B_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
12779
|
+
const boardingTapscript = chunkOSRXKF7B_cjs.BoardingContractHandler.createScript({
|
|
12780
12780
|
pubKey: base.hex.encode(pubKey),
|
|
12781
12781
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12782
|
-
csvTimelock:
|
|
12782
|
+
csvTimelock: chunkOJ5W7L6Q_cjs.timelockToSequence(boardingTimelock).toString()
|
|
12783
12783
|
});
|
|
12784
12784
|
return {
|
|
12785
12785
|
arkProvider,
|
|
@@ -12912,7 +12912,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12912
12912
|
if (!filter?.withUnrolled) {
|
|
12913
12913
|
logExcludedVtxos(
|
|
12914
12914
|
"getSpendableVtxos",
|
|
12915
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
12915
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkOJ5W7L6Q_cjs.isVtxoSpent(vtxo)),
|
|
12916
12916
|
[() => UNROLLED_REASON]
|
|
12917
12917
|
);
|
|
12918
12918
|
}
|
|
@@ -13050,7 +13050,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13050
13050
|
this.getBoardingTxs()
|
|
13051
13051
|
]);
|
|
13052
13052
|
const allVtxos = snapshot.flatMap((_) => _.vtxos);
|
|
13053
|
-
const resolveTxCreatedAt = (txids) =>
|
|
13053
|
+
const resolveTxCreatedAt = (txids) => chunkOJ5W7L6Q_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
13054
13054
|
return buildTransactionHistory(
|
|
13055
13055
|
allVtxos,
|
|
13056
13056
|
boardingTxs,
|
|
@@ -13204,9 +13204,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13204
13204
|
async getBoardingTapscripts(allowedSigners) {
|
|
13205
13205
|
const byScript = /* @__PURE__ */ new Map();
|
|
13206
13206
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
13207
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
13207
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkOSRXKF7B_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13208
13208
|
add(
|
|
13209
|
-
new
|
|
13209
|
+
new chunkOSRXKF7B_cjs.DefaultVtxo.Script({
|
|
13210
13210
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
13211
13211
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
13212
13212
|
csvTimelock: boardingCsv
|
|
@@ -13221,7 +13221,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13221
13221
|
for (const c of boardingContracts) {
|
|
13222
13222
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
13223
13223
|
try {
|
|
13224
|
-
add(
|
|
13224
|
+
add(chunkOSRXKF7B_cjs.BoardingContractHandler.createScript(c.params));
|
|
13225
13225
|
} catch (e) {
|
|
13226
13226
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
13227
13227
|
}
|
|
@@ -13250,7 +13250,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13250
13250
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
13251
13251
|
// not the wallet's current boarding timelock, which a signer
|
|
13252
13252
|
// rotation may have changed.
|
|
13253
|
-
csvTimelock:
|
|
13253
|
+
csvTimelock: chunkOJ5W7L6Q_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
13254
13254
|
coins: utxos
|
|
13255
13255
|
};
|
|
13256
13256
|
})
|
|
@@ -13375,7 +13375,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13375
13375
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
13376
13376
|
async fetchPendingTxs() {
|
|
13377
13377
|
const scripts = await this.getWalletScripts();
|
|
13378
|
-
const vtxos = await
|
|
13378
|
+
const vtxos = await chunkOJ5W7L6Q_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
13379
13379
|
return vtxos.filter(
|
|
13380
13380
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
13381
13381
|
).map((_) => _.arkTxId);
|
|
@@ -13406,7 +13406,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13406
13406
|
});
|
|
13407
13407
|
for (const contract of contracts) {
|
|
13408
13408
|
if (map.has(contract.script)) continue;
|
|
13409
|
-
const handler =
|
|
13409
|
+
const handler = chunkOSRXKF7B_cjs.contractHandlers.get(contract.type);
|
|
13410
13410
|
if (handler) {
|
|
13411
13411
|
const script = handler.createScript(contract.params);
|
|
13412
13412
|
map.set(contract.script, script);
|
|
@@ -13517,7 +13517,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13517
13517
|
}
|
|
13518
13518
|
});
|
|
13519
13519
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
13520
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
13520
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkOSRXKF7B_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
13521
13521
|
const baselineSigners = [
|
|
13522
13522
|
this.offchainTapscript.options.serverPubKey,
|
|
13523
13523
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -13525,8 +13525,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13525
13525
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
13526
13526
|
for (const serverPubKey of baselineSigners) {
|
|
13527
13527
|
for (const csvTimelock2 of this.walletContractTimelocks) {
|
|
13528
|
-
const csvTimelockStr =
|
|
13529
|
-
const defaultScript = new
|
|
13528
|
+
const csvTimelockStr = chunkOJ5W7L6Q_cjs.timelockToSequence(csvTimelock2).toString();
|
|
13529
|
+
const defaultScript = new chunkOSRXKF7B_cjs.DefaultVtxo.Script({
|
|
13530
13530
|
pubKey: baselinePubkey,
|
|
13531
13531
|
serverPubKey,
|
|
13532
13532
|
csvTimelock: csvTimelock2
|
|
@@ -13547,7 +13547,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13547
13547
|
});
|
|
13548
13548
|
}
|
|
13549
13549
|
if (delegatePubKey) {
|
|
13550
|
-
const delegateScript = new
|
|
13550
|
+
const delegateScript = new chunkOSRXKF7B_cjs.DelegateVtxo.Script({
|
|
13551
13551
|
pubKey: baselinePubkey,
|
|
13552
13552
|
serverPubKey,
|
|
13553
13553
|
delegatePubKey,
|
|
@@ -13571,9 +13571,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13571
13571
|
}
|
|
13572
13572
|
}
|
|
13573
13573
|
}
|
|
13574
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
13574
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkOSRXKF7B_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13575
13575
|
for (const serverPubKey of baselineSigners) {
|
|
13576
|
-
const baselineBoarding = new
|
|
13576
|
+
const baselineBoarding = new chunkOSRXKF7B_cjs.DefaultVtxo.Script({
|
|
13577
13577
|
pubKey: baselinePubkey,
|
|
13578
13578
|
serverPubKey,
|
|
13579
13579
|
csvTimelock: boardingCsvTimelock
|
|
@@ -13586,7 +13586,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13586
13586
|
params: {
|
|
13587
13587
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
13588
13588
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13589
|
-
csvTimelock:
|
|
13589
|
+
csvTimelock: chunkOJ5W7L6Q_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
13590
13590
|
},
|
|
13591
13591
|
script: boardingScriptHex,
|
|
13592
13592
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -13773,7 +13773,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
13773
13773
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
13774
13774
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
13775
13775
|
csvTimelocks: this.walletContractTimelocks,
|
|
13776
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
13776
|
+
delegatePubKey: this.offchainTapscript instanceof chunkOSRXKF7B_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
13777
13777
|
};
|
|
13778
13778
|
}
|
|
13779
13779
|
_signerRouter;
|
|
@@ -13933,7 +13933,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
13933
13933
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
13934
13934
|
const persisted = row?.metadata?.signingDescriptor;
|
|
13935
13935
|
if (typeof persisted === "string") return persisted;
|
|
13936
|
-
return
|
|
13936
|
+
return chunkOSRXKF7B_cjs.identityDescriptor(this.identity);
|
|
13937
13937
|
}
|
|
13938
13938
|
/**
|
|
13939
13939
|
* Build, persist and shape one address of `type` owned by `descriptor`. The descriptor is the
|
|
@@ -13943,7 +13943,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
13943
13943
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
13944
13944
|
if (type === "boarding") {
|
|
13945
13945
|
const built2 = this.buildBoardingContract(
|
|
13946
|
-
|
|
13946
|
+
chunkOSRXKF7B_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
13947
13947
|
descriptor,
|
|
13948
13948
|
tagSource
|
|
13949
13949
|
);
|
|
@@ -13980,11 +13980,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
13980
13980
|
* (offchain analogue: {@link buildReceiveContract}).
|
|
13981
13981
|
*/
|
|
13982
13982
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
13983
|
-
const tapscript = new
|
|
13983
|
+
const tapscript = new chunkOSRXKF7B_cjs.DefaultVtxo.Script({
|
|
13984
13984
|
...this._boardingTapscript.options,
|
|
13985
13985
|
pubKey
|
|
13986
13986
|
});
|
|
13987
|
-
const csvTimelock2 = tapscript.options.csvTimelock ??
|
|
13987
|
+
const csvTimelock2 = tapscript.options.csvTimelock ?? chunkOSRXKF7B_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13988
13988
|
return {
|
|
13989
13989
|
tapscript,
|
|
13990
13990
|
params: {
|
|
@@ -13992,13 +13992,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
13992
13992
|
params: {
|
|
13993
13993
|
pubKey: base.hex.encode(pubKey),
|
|
13994
13994
|
serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
|
|
13995
|
-
csvTimelock:
|
|
13995
|
+
csvTimelock: chunkOJ5W7L6Q_cjs.timelockToSequence(csvTimelock2).toString()
|
|
13996
13996
|
},
|
|
13997
13997
|
script: base.hex.encode(tapscript.pkScript),
|
|
13998
13998
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
13999
13999
|
state: "active",
|
|
14000
14000
|
metadata: {
|
|
14001
|
-
...tagSource && { source:
|
|
14001
|
+
...tagSource && { source: chunkOSRXKF7B_cjs.WALLET_RECEIVE_SOURCE },
|
|
14002
14002
|
signingDescriptor: descriptor
|
|
14003
14003
|
}
|
|
14004
14004
|
}
|
|
@@ -14020,7 +14020,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14020
14020
|
if (this._hdProvider) {
|
|
14021
14021
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
14022
14022
|
}
|
|
14023
|
-
return
|
|
14023
|
+
return chunkOSRXKF7B_cjs.identityDescriptor(this.identity);
|
|
14024
14024
|
}
|
|
14025
14025
|
/**
|
|
14026
14026
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -14096,7 +14096,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14096
14096
|
* the stable public API.
|
|
14097
14097
|
*/
|
|
14098
14098
|
async rotateServerSigner(newServerPubKey, checkpointTapscript) {
|
|
14099
|
-
const xonly =
|
|
14099
|
+
const xonly = chunkOSRXKF7B_cjs.toXOnly(newServerPubKey, "ark signer key");
|
|
14100
14100
|
const newServerUnrollScript = assertValidServerUnrollScript(
|
|
14101
14101
|
checkpointTapscript,
|
|
14102
14102
|
resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
|
|
@@ -14125,21 +14125,21 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14125
14125
|
const [currentBoardingRow] = await manager.getContracts({
|
|
14126
14126
|
script: currentBoardingScript
|
|
14127
14127
|
});
|
|
14128
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
14128
|
+
const newOffchain = this.offchainTapscript instanceof chunkOSRXKF7B_cjs.DelegateVtxo.Script ? new chunkOSRXKF7B_cjs.DelegateVtxo.Script({
|
|
14129
14129
|
...this.offchainTapscript.options,
|
|
14130
14130
|
serverPubKey: xonly
|
|
14131
|
-
}) : new
|
|
14131
|
+
}) : new chunkOSRXKF7B_cjs.DefaultVtxo.Script({
|
|
14132
14132
|
...this.offchainTapscript.options,
|
|
14133
14133
|
serverPubKey: xonly
|
|
14134
14134
|
});
|
|
14135
|
-
const newBoarding = new
|
|
14135
|
+
const newBoarding = new chunkOSRXKF7B_cjs.DefaultVtxo.Script({
|
|
14136
14136
|
...this._boardingTapscript.options,
|
|
14137
14137
|
serverPubKey: xonly
|
|
14138
14138
|
});
|
|
14139
|
-
const offchainCsv =
|
|
14139
|
+
const offchainCsv = chunkOJ5W7L6Q_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
14140
14140
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
14141
14141
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
14142
|
-
if (newOffchain instanceof
|
|
14142
|
+
if (newOffchain instanceof chunkOSRXKF7B_cjs.DelegateVtxo.Script) {
|
|
14143
14143
|
await manager.createContract({
|
|
14144
14144
|
type: "delegate",
|
|
14145
14145
|
params: {
|
|
@@ -14167,13 +14167,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14167
14167
|
metadata: currentOffchainRow?.metadata
|
|
14168
14168
|
});
|
|
14169
14169
|
}
|
|
14170
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
14170
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkOSRXKF7B_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14171
14171
|
await manager.createContract({
|
|
14172
14172
|
type: "boarding",
|
|
14173
14173
|
params: {
|
|
14174
14174
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
14175
14175
|
serverPubKey: base.hex.encode(xonly),
|
|
14176
|
-
csvTimelock:
|
|
14176
|
+
csvTimelock: chunkOJ5W7L6Q_cjs.timelockToSequence(boardingCsv).toString()
|
|
14177
14177
|
},
|
|
14178
14178
|
script: base.hex.encode(newBoarding.pkScript),
|
|
14179
14179
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -14201,14 +14201,14 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14201
14201
|
_restoreInFlight;
|
|
14202
14202
|
_addPendingSpends(inputs) {
|
|
14203
14203
|
for (const input of inputs) {
|
|
14204
|
-
if (
|
|
14204
|
+
if (chunkOJ5W7L6Q_cjs.isVirtualCoin(input)) {
|
|
14205
14205
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
14206
14206
|
}
|
|
14207
14207
|
}
|
|
14208
14208
|
}
|
|
14209
14209
|
_removePendingSpends(inputs) {
|
|
14210
14210
|
for (const input of inputs) {
|
|
14211
|
-
if (
|
|
14211
|
+
if (chunkOJ5W7L6Q_cjs.isVirtualCoin(input)) {
|
|
14212
14212
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
14213
14213
|
}
|
|
14214
14214
|
}
|
|
@@ -14259,13 +14259,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14259
14259
|
const manager = await this.getContractManager();
|
|
14260
14260
|
const provider = this._hdProvider;
|
|
14261
14261
|
const hd = provider !== void 0;
|
|
14262
|
-
const staticDescriptor = hd ? void 0 : await
|
|
14262
|
+
const staticDescriptor = hd ? void 0 : await chunkOSRXKF7B_cjs.identityDescriptor(this.identity);
|
|
14263
14263
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
14264
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14264
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkOSRXKF7B_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14265
14265
|
const arkInfo = await this.arkProvider.getInfo();
|
|
14266
|
-
const currentSignerPubKey =
|
|
14266
|
+
const currentSignerPubKey = chunkOSRXKF7B_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
14267
14267
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
14268
|
-
(s) =>
|
|
14268
|
+
(s) => chunkOSRXKF7B_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
14269
14269
|
);
|
|
14270
14270
|
const deps = {
|
|
14271
14271
|
indexerProvider: this.indexerProvider,
|
|
@@ -14277,7 +14277,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14277
14277
|
deprecatedSignerPubKeys,
|
|
14278
14278
|
csvTimelocks: this.walletContractTimelocks,
|
|
14279
14279
|
// Boarding-exit CSV, distinct from the unilateral-exit matrix.
|
|
14280
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
14280
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkOSRXKF7B_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
14281
14281
|
delegatePubKey
|
|
14282
14282
|
};
|
|
14283
14283
|
const result = await manager.scanContracts({
|
|
@@ -14387,7 +14387,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14387
14387
|
throw new Error("Invalid configured public key");
|
|
14388
14388
|
}
|
|
14389
14389
|
const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
|
|
14390
|
-
const forfeitPubkey =
|
|
14390
|
+
const forfeitPubkey = chunkOSRXKF7B_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
|
|
14391
14391
|
const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
|
|
14392
14392
|
const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
|
|
14393
14393
|
const checkpointExitDelayOverrides = {
|
|
@@ -14546,13 +14546,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14546
14546
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
14547
14547
|
}
|
|
14548
14548
|
const offchainAddress = await this.getAddress();
|
|
14549
|
-
const offchainPkScript =
|
|
14549
|
+
const offchainPkScript = chunkOJ5W7L6Q_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
14550
14550
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
14551
14551
|
if (!params) {
|
|
14552
14552
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
14553
14553
|
const estimator = new Estimator(fees.intentFee);
|
|
14554
14554
|
let amount = 0;
|
|
14555
|
-
const exitScript =
|
|
14555
|
+
const exitScript = chunkOJ5W7L6Q_cjs.CSVMultisigTapscript.decode(
|
|
14556
14556
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
14557
14557
|
);
|
|
14558
14558
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -14584,7 +14584,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14584
14584
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
14585
14585
|
break;
|
|
14586
14586
|
}
|
|
14587
|
-
const inputFee = estimator.evalOffchainInput(
|
|
14587
|
+
const inputFee = estimator.evalOffchainInput(chunkOJ5W7L6Q_cjs.toOffchainInputFeeParams(vtxo));
|
|
14588
14588
|
if (inputFee.satoshis >= vtxo.value) {
|
|
14589
14589
|
continue;
|
|
14590
14590
|
}
|
|
@@ -14635,7 +14635,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14635
14635
|
let script;
|
|
14636
14636
|
let arkAddress;
|
|
14637
14637
|
try {
|
|
14638
|
-
arkAddress =
|
|
14638
|
+
arkAddress = chunkOJ5W7L6Q_cjs.ArkAddress.decode(output.address);
|
|
14639
14639
|
} catch {
|
|
14640
14640
|
arkAddress = void 0;
|
|
14641
14641
|
}
|
|
@@ -14707,11 +14707,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14707
14707
|
]);
|
|
14708
14708
|
let intentTxId;
|
|
14709
14709
|
try {
|
|
14710
|
-
intentTxId =
|
|
14710
|
+
intentTxId = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
|
|
14711
14711
|
} catch {
|
|
14712
14712
|
intentTxId = params.inputs.map((i) => `${i.txid}:${i.vout}`).sort().join("|");
|
|
14713
14713
|
}
|
|
14714
|
-
const settleInputVtxos = params.inputs.filter(
|
|
14714
|
+
const settleInputVtxos = params.inputs.filter(chunkOJ5W7L6Q_cjs.isVirtualCoin);
|
|
14715
14715
|
const contractManager = await this.getContractManager();
|
|
14716
14716
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
14717
14717
|
await contractManager.assertSpendableNow?.(
|
|
@@ -14820,7 +14820,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14820
14820
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
14821
14821
|
if (!this._descriptorProvider) return;
|
|
14822
14822
|
const consumedBoarding = inputs.some(
|
|
14823
|
-
(input) => typeof input !== "string" && !
|
|
14823
|
+
(input) => typeof input !== "string" && !chunkOJ5W7L6Q_cjs.isVirtualCoin(input)
|
|
14824
14824
|
);
|
|
14825
14825
|
if (!consumedBoarding) return;
|
|
14826
14826
|
try {
|
|
@@ -14831,7 +14831,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14831
14831
|
}
|
|
14832
14832
|
async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, expectedRecipients, connectorsGraph, validatedCommitmentTxid) {
|
|
14833
14833
|
const signedForfeits = [];
|
|
14834
|
-
let settlementPsbt =
|
|
14834
|
+
let settlementPsbt = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
14835
14835
|
assertFinalCommitmentMatchesValidated(
|
|
14836
14836
|
settlementPsbt,
|
|
14837
14837
|
validatedCommitmentTxid,
|
|
@@ -14844,7 +14844,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14844
14844
|
let connectorIndex = 0;
|
|
14845
14845
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
14846
14846
|
for (const input of inputs) {
|
|
14847
|
-
if (!
|
|
14847
|
+
if (!chunkOJ5W7L6Q_cjs.isVirtualCoin(input)) {
|
|
14848
14848
|
let matched = false;
|
|
14849
14849
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
14850
14850
|
const settlementInput = settlementPsbt.getInput(i);
|
|
@@ -14882,7 +14882,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14882
14882
|
}
|
|
14883
14883
|
continue;
|
|
14884
14884
|
}
|
|
14885
|
-
if (!
|
|
14885
|
+
if (!chunkOJ5W7L6Q_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
14886
14886
|
continue;
|
|
14887
14887
|
}
|
|
14888
14888
|
if (connectorsLeaves.length === 0) {
|
|
@@ -14910,7 +14910,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14910
14910
|
index: input.vout,
|
|
14911
14911
|
witnessUtxo: {
|
|
14912
14912
|
amount: BigInt(input.value),
|
|
14913
|
-
script:
|
|
14913
|
+
script: chunkOJ5W7L6Q_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14914
14914
|
},
|
|
14915
14915
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
14916
14916
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -14929,7 +14929,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14929
14929
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
14930
14930
|
{
|
|
14931
14931
|
index: 0,
|
|
14932
|
-
lookupScript:
|
|
14932
|
+
lookupScript: chunkOJ5W7L6Q_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14933
14933
|
}
|
|
14934
14934
|
]);
|
|
14935
14935
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -14987,7 +14987,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14987
14987
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
14988
14988
|
);
|
|
14989
14989
|
await this.arkProvider.confirmRegistration(intentId);
|
|
14990
|
-
const sweepTapscript =
|
|
14990
|
+
const sweepTapscript = chunkOJ5W7L6Q_cjs.CSVMultisigTapscript.encode({
|
|
14991
14991
|
timelock,
|
|
14992
14992
|
pubkeys: [this.forfeitPubkey]
|
|
14993
14993
|
}).script;
|
|
@@ -15002,14 +15002,14 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15002
15002
|
throw new Error("Sweep tap tree root not set");
|
|
15003
15003
|
}
|
|
15004
15004
|
const xOnlyPublicKeys = event.cosignersPublicKeys.map(
|
|
15005
|
-
(k) => base.hex.encode(
|
|
15005
|
+
(k) => base.hex.encode(chunkOSRXKF7B_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
15006
15006
|
);
|
|
15007
15007
|
const signerPublicKey = await session.getPublicKey();
|
|
15008
|
-
const xonlySignerPublicKey =
|
|
15008
|
+
const xonlySignerPublicKey = chunkOSRXKF7B_cjs.toXOnly(signerPublicKey, "signer key");
|
|
15009
15009
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
15010
15010
|
return { skip: true };
|
|
15011
15011
|
}
|
|
15012
|
-
const commitmentTx =
|
|
15012
|
+
const commitmentTx = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(
|
|
15013
15013
|
base.base64.decode(event.unsignedCommitmentTx)
|
|
15014
15014
|
);
|
|
15015
15015
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
@@ -15091,9 +15091,9 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15091
15091
|
...existing ?? {},
|
|
15092
15092
|
intentTxId,
|
|
15093
15093
|
registerProof: intent.proof,
|
|
15094
|
-
registerProofMessage:
|
|
15094
|
+
registerProofMessage: chunkOJ5W7L6Q_cjs.Intent.encodeMessage(intent.message),
|
|
15095
15095
|
deleteProof: deleteIntent.proof,
|
|
15096
|
-
deleteProofMessage:
|
|
15096
|
+
deleteProofMessage: chunkOJ5W7L6Q_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
15097
15097
|
intentVtxos: inputs.map((i) => ({
|
|
15098
15098
|
txid: i.txid,
|
|
15099
15099
|
vout: i.vout
|
|
@@ -15126,7 +15126,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15126
15126
|
try {
|
|
15127
15127
|
return await this.arkProvider.registerIntent(intent);
|
|
15128
15128
|
} catch (error) {
|
|
15129
|
-
if (error instanceof
|
|
15129
|
+
if (error instanceof chunkOJ5W7L6Q_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
15130
15130
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
15131
15131
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
15132
15132
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -15142,7 +15142,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15142
15142
|
expire_at: 0,
|
|
15143
15143
|
cosigners_public_keys: cosignerPubKeys
|
|
15144
15144
|
};
|
|
15145
|
-
const proof =
|
|
15145
|
+
const proof = chunkOJ5W7L6Q_cjs.Intent.create(message, coins, outputs);
|
|
15146
15146
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15147
15147
|
return {
|
|
15148
15148
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15154,7 +15154,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15154
15154
|
type: "delete",
|
|
15155
15155
|
expire_at: 0
|
|
15156
15156
|
};
|
|
15157
|
-
const proof =
|
|
15157
|
+
const proof = chunkOJ5W7L6Q_cjs.Intent.create(message, coins, []);
|
|
15158
15158
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15159
15159
|
return {
|
|
15160
15160
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15166,7 +15166,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15166
15166
|
type: "get-pending-tx",
|
|
15167
15167
|
expire_at: 0
|
|
15168
15168
|
};
|
|
15169
|
-
const proof =
|
|
15169
|
+
const proof = chunkOJ5W7L6Q_cjs.Intent.create(message, coins, []);
|
|
15170
15170
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15171
15171
|
return {
|
|
15172
15172
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15187,7 +15187,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15187
15187
|
if (!vtxos || vtxos.length === 0) {
|
|
15188
15188
|
const scriptMap = await this.getScriptMap();
|
|
15189
15189
|
const allExtended = [];
|
|
15190
|
-
const fetchedVtxos = await
|
|
15190
|
+
const fetchedVtxos = await chunkOJ5W7L6Q_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
15191
15191
|
...scriptMap.keys()
|
|
15192
15192
|
]);
|
|
15193
15193
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -15230,8 +15230,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15230
15230
|
batchPending.push(pendingTx.arkTxid);
|
|
15231
15231
|
try {
|
|
15232
15232
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
15233
|
-
const tx =
|
|
15234
|
-
|
|
15233
|
+
const tx = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(c));
|
|
15234
|
+
chunkOJ5W7L6Q_cjs.assertAllowedSighashTypes(tx);
|
|
15235
15235
|
return tx;
|
|
15236
15236
|
});
|
|
15237
15237
|
assertCheckpointsMatchInputs(
|
|
@@ -15300,11 +15300,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15300
15300
|
* and one per deprecated signer — else a pre-rotation tx would stay pending forever.
|
|
15301
15301
|
*/
|
|
15302
15302
|
checkpointUnrollCandidates(info) {
|
|
15303
|
-
const current =
|
|
15303
|
+
const current = chunkOJ5W7L6Q_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
15304
15304
|
const candidates = [this._serverUnrollScript, current];
|
|
15305
15305
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
15306
15306
|
candidates.push(
|
|
15307
|
-
|
|
15307
|
+
chunkOJ5W7L6Q_cjs.CSVMultisigTapscript.encode({
|
|
15308
15308
|
...current.params,
|
|
15309
15309
|
pubkeys: [base.hex.decode(deprecated)]
|
|
15310
15310
|
})
|
|
@@ -15393,7 +15393,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15393
15393
|
if (vtxos.length === 0) {
|
|
15394
15394
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
15395
15395
|
}
|
|
15396
|
-
const myPkScript =
|
|
15396
|
+
const myPkScript = chunkOJ5W7L6Q_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
15397
15397
|
let { spendable, recoverable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
15398
15398
|
let swept = 0;
|
|
15399
15399
|
const drainable = vtxos.filter(
|
|
@@ -15520,7 +15520,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15520
15520
|
params: {
|
|
15521
15521
|
pubKey: base.hex.encode(cash.publicKey),
|
|
15522
15522
|
serverPubKey: base.hex.encode(cash.serverPubKey),
|
|
15523
|
-
csvTimelock:
|
|
15523
|
+
csvTimelock: chunkOJ5W7L6Q_cjs.timelockToSequence(cash.csvTimelock).toString()
|
|
15524
15524
|
},
|
|
15525
15525
|
script: base.hex.encode(cashScript.pkScript),
|
|
15526
15526
|
address: cashAddress.encode(),
|
|
@@ -15601,7 +15601,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15601
15601
|
const recoverable = [];
|
|
15602
15602
|
const unclaimed = [];
|
|
15603
15603
|
for (const vtxo of vtxos) {
|
|
15604
|
-
if (
|
|
15604
|
+
if (chunkOJ5W7L6Q_cjs.isVtxoSpent(vtxo)) {
|
|
15605
15605
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
15606
15606
|
} else if (vtxo.isUnrolled) {
|
|
15607
15607
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -15623,7 +15623,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15623
15623
|
const all = [];
|
|
15624
15624
|
const seen = /* @__PURE__ */ new Set();
|
|
15625
15625
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
15626
|
-
const { vtxos, page } = await
|
|
15626
|
+
const { vtxos, page } = await chunkOJ5W7L6Q_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
15627
15627
|
scripts,
|
|
15628
15628
|
pageIndex,
|
|
15629
15629
|
pageSize
|
|
@@ -15661,7 +15661,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15661
15661
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
15662
15662
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
15663
15663
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
15664
|
-
const proof =
|
|
15664
|
+
const proof = chunkOJ5W7L6Q_cjs.Intent.create(message, batch, []);
|
|
15665
15665
|
const signedProof = await identity.sign(
|
|
15666
15666
|
proof,
|
|
15667
15667
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -15682,8 +15682,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15682
15682
|
for (const pendingTx of pendingTxs) {
|
|
15683
15683
|
try {
|
|
15684
15684
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
15685
|
-
const tx =
|
|
15686
|
-
|
|
15685
|
+
const tx = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
15686
|
+
chunkOJ5W7L6Q_cjs.assertAllowedSighashTypes(tx);
|
|
15687
15687
|
return tx;
|
|
15688
15688
|
});
|
|
15689
15689
|
assertCheckpointsMatchInputs(
|
|
@@ -15723,7 +15723,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15723
15723
|
}
|
|
15724
15724
|
/** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
|
|
15725
15725
|
arkTxAmountPaidTo(arkTxPsbt, pkScriptHex) {
|
|
15726
|
-
const arkTx =
|
|
15726
|
+
const arkTx = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
|
|
15727
15727
|
let total = 0;
|
|
15728
15728
|
for (let i = 0; i < arkTx.outputsLength; i++) {
|
|
15729
15729
|
const output = arkTx.getOutput(i);
|
|
@@ -15901,7 +15901,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15901
15901
|
script: recipient.script,
|
|
15902
15902
|
amount: BigInt(recipient.amount),
|
|
15903
15903
|
// Already checked against the recipient address in `validateRecipients`.
|
|
15904
|
-
...recipient.tapTree ? { tapTree:
|
|
15904
|
+
...recipient.tapTree ? { tapTree: chunkOJ5W7L6Q_cjs.toBIP371TapTree(recipient.tapTree) } : {}
|
|
15905
15905
|
}));
|
|
15906
15906
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
15907
15907
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -16082,10 +16082,10 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16082
16082
|
const serverPubKey = this.arkServerPublicKey;
|
|
16083
16083
|
const serverUnrollScript = this.serverUnrollScript;
|
|
16084
16084
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
16085
|
-
const normalizedInputs = inputs.map(
|
|
16086
|
-
const at = now ?? await
|
|
16085
|
+
const normalizedInputs = inputs.map(chunkOJ5W7L6Q_cjs.normalizeVtxo);
|
|
16086
|
+
const at = now ?? await chunkOJ5W7L6Q_cjs.resolveTimeHeight(this.onchainProvider);
|
|
16087
16087
|
for (const input of normalizedInputs) {
|
|
16088
|
-
if (!
|
|
16088
|
+
if (!chunkOJ5W7L6Q_cjs.canSpendOffchain(input, at)) {
|
|
16089
16089
|
throw new Error(
|
|
16090
16090
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
16091
16091
|
);
|
|
@@ -16155,7 +16155,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16155
16155
|
);
|
|
16156
16156
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
16157
16157
|
index,
|
|
16158
|
-
lookupScript:
|
|
16158
|
+
lookupScript: chunkOJ5W7L6Q_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
16159
16159
|
}));
|
|
16160
16160
|
const identity = this.identity;
|
|
16161
16161
|
const signer = {
|
|
@@ -16234,7 +16234,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16234
16234
|
}
|
|
16235
16235
|
const checkpointIdByOutpoint = /* @__PURE__ */ new Map();
|
|
16236
16236
|
for (const encoded of signedCheckpointTxs) {
|
|
16237
|
-
const checkpoint =
|
|
16237
|
+
const checkpoint = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
16238
16238
|
for (let i = 0; i < checkpoint.inputsLength; i++) {
|
|
16239
16239
|
const input = checkpoint.getInput(i);
|
|
16240
16240
|
if (!input.txid) continue;
|
|
@@ -16350,12 +16350,12 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16350
16350
|
const spentVtxos = [];
|
|
16351
16351
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
16352
16352
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
16353
|
-
const vtxoInputs = inputs.filter(
|
|
16353
|
+
const vtxoInputs = inputs.filter(chunkOJ5W7L6Q_cjs.isVirtualCoin);
|
|
16354
16354
|
const cm = await this.getContractManager();
|
|
16355
16355
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
16356
16356
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
16357
16357
|
for (const input of inputs) {
|
|
16358
|
-
if (
|
|
16358
|
+
if (chunkOJ5W7L6Q_cjs.isVirtualCoin(input)) {
|
|
16359
16359
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
16360
16360
|
const vtxo = annotatedByKey.get(outpoint);
|
|
16361
16361
|
if (!vtxo) {
|
|
@@ -16372,7 +16372,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16372
16372
|
} else {
|
|
16373
16373
|
let sourceAddress;
|
|
16374
16374
|
try {
|
|
16375
|
-
sourceAddress =
|
|
16375
|
+
sourceAddress = chunkOJ5W7L6Q_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
16376
16376
|
this.network
|
|
16377
16377
|
);
|
|
16378
16378
|
} catch {
|
|
@@ -16430,7 +16430,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16430
16430
|
}
|
|
16431
16431
|
};
|
|
16432
16432
|
function selectVirtualCoins(coins, targetAmount) {
|
|
16433
|
-
const sortedCoins = coins.map(
|
|
16433
|
+
const sortedCoins = coins.map(chunkOJ5W7L6Q_cjs.normalizeVtxo).sort((a, b) => {
|
|
16434
16434
|
const expiryA = a.expiresAt?.getTime() || Number.MAX_SAFE_INTEGER;
|
|
16435
16435
|
const expiryB = b.expiresAt?.getTime() || Number.MAX_SAFE_INTEGER;
|
|
16436
16436
|
if (expiryA !== expiryB) {
|
|
@@ -16542,7 +16542,7 @@ function assertTimeoutMap(name, timeouts) {
|
|
|
16542
16542
|
if (value === void 0) {
|
|
16543
16543
|
throw new Error(`${name}.${key} must be a non-negative safe integer`);
|
|
16544
16544
|
}
|
|
16545
|
-
|
|
16545
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs(`${name}.${key}`, value);
|
|
16546
16546
|
}
|
|
16547
16547
|
}
|
|
16548
16548
|
var MessageBus = class {
|
|
@@ -16558,8 +16558,8 @@ var MessageBus = class {
|
|
|
16558
16558
|
}) {
|
|
16559
16559
|
this.walletRepository = walletRepository;
|
|
16560
16560
|
this.contractRepository = contractRepository;
|
|
16561
|
-
|
|
16562
|
-
|
|
16561
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs("tickIntervalMs", tickIntervalMs);
|
|
16562
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs("messageTimeoutMs", messageTimeoutMs);
|
|
16563
16563
|
assertTimeoutMap("messageTimeoutOverrides", messageTimeoutOverrides);
|
|
16564
16564
|
this.intentRepository = intentRepository;
|
|
16565
16565
|
this.handlers = new Map(messageHandlers.map((u) => [u.messageTag, u]));
|
|
@@ -16813,14 +16813,14 @@ var MessageBus = class {
|
|
|
16813
16813
|
this.initialized = true;
|
|
16814
16814
|
}
|
|
16815
16815
|
async buildServices(config) {
|
|
16816
|
-
const arkProvider = new
|
|
16816
|
+
const arkProvider = new chunkOJ5W7L6Q_cjs.RestArkProvider(config.arkServer.url);
|
|
16817
16817
|
const storage = {
|
|
16818
16818
|
walletRepository: this.walletRepository,
|
|
16819
16819
|
contractRepository: this.contractRepository,
|
|
16820
16820
|
...this.intentRepository && { intentRepository: this.intentRepository }
|
|
16821
16821
|
};
|
|
16822
16822
|
const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : void 0;
|
|
16823
|
-
const indexerProvider = new
|
|
16823
|
+
const indexerProvider = new chunkXWUJBHYW_cjs.RestIndexerProvider(config.arkServer.url);
|
|
16824
16824
|
const serialized = normalizeSerializedIdentity(config.wallet);
|
|
16825
16825
|
if (isSigningSerialized(serialized)) {
|
|
16826
16826
|
const identity2 = hydrateIdentity(serialized);
|
|
@@ -17158,7 +17158,7 @@ var offboardNetworkNames = [
|
|
|
17158
17158
|
function offboardDestinationScript(destinationAddress) {
|
|
17159
17159
|
for (const networkName of offboardNetworkNames) {
|
|
17160
17160
|
try {
|
|
17161
|
-
const network =
|
|
17161
|
+
const network = chunkOJ5W7L6Q_cjs.networks[networkName];
|
|
17162
17162
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
17163
17163
|
return btcSigner.OutScript.encode(addr);
|
|
17164
17164
|
} catch {
|
|
@@ -17194,7 +17194,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
|
|
|
17194
17194
|
const inputs = [];
|
|
17195
17195
|
let subtotal = 0n;
|
|
17196
17196
|
for (const vtxo of vtxos) {
|
|
17197
|
-
const inputFee = estimator.evalOffchainInput(
|
|
17197
|
+
const inputFee = estimator.evalOffchainInput(chunkOJ5W7L6Q_cjs.toOffchainInputFeeParams(vtxo));
|
|
17198
17198
|
if (inputFee.satoshis >= vtxo.value) {
|
|
17199
17199
|
if (named) {
|
|
17200
17200
|
throw new Error(
|
|
@@ -17291,7 +17291,7 @@ var Ramps = class {
|
|
|
17291
17291
|
}
|
|
17292
17292
|
amount = amount ?? totalAmount;
|
|
17293
17293
|
const offchainAddress = await this.wallet.getAddress();
|
|
17294
|
-
const offchainAddr =
|
|
17294
|
+
const offchainAddr = chunkOJ5W7L6Q_cjs.ArkAddress.decode(offchainAddress);
|
|
17295
17295
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
17296
17296
|
const outputFee = estimator.evalOffchainOutput({
|
|
17297
17297
|
amount,
|
|
@@ -17415,7 +17415,7 @@ var Ramps = class {
|
|
|
17415
17415
|
async fundChange(left, estimator) {
|
|
17416
17416
|
if (left <= 0n) return { change: 0n };
|
|
17417
17417
|
const changeAddress = await this.wallet.getAddress();
|
|
17418
|
-
const changeScript = base.hex.encode(
|
|
17418
|
+
const changeScript = base.hex.encode(chunkOJ5W7L6Q_cjs.ArkAddress.decode(changeAddress).pkScript);
|
|
17419
17419
|
const { change } = changeAfterOutputFee(
|
|
17420
17420
|
left,
|
|
17421
17421
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script: changeScript }).satoshis)
|
|
@@ -17428,8 +17428,6 @@ var Ramps = class {
|
|
|
17428
17428
|
return { change, changeAddress };
|
|
17429
17429
|
}
|
|
17430
17430
|
};
|
|
17431
|
-
|
|
17432
|
-
// src/wallet/serviceWorker/wallet-message-handler.ts
|
|
17433
17431
|
var WalletNotInitializedError = class extends Error {
|
|
17434
17432
|
constructor() {
|
|
17435
17433
|
super("Wallet handler not initialized");
|
|
@@ -18283,7 +18281,7 @@ var WalletMessageHandler = class {
|
|
|
18283
18281
|
// Wallet methods
|
|
18284
18282
|
async handleInitWallet({ payload }) {
|
|
18285
18283
|
const { arkServerUrl } = payload;
|
|
18286
|
-
this.indexerProvider = new
|
|
18284
|
+
this.indexerProvider = new chunkXWUJBHYW_cjs.RestIndexerProvider(arkServerUrl);
|
|
18287
18285
|
await this.onWalletInitialized();
|
|
18288
18286
|
}
|
|
18289
18287
|
/**
|
|
@@ -18432,15 +18430,20 @@ var WalletMessageHandler = class {
|
|
|
18432
18430
|
if (!this.readonlyWallet || !this.walletRepository) {
|
|
18433
18431
|
return;
|
|
18434
18432
|
}
|
|
18435
|
-
const
|
|
18436
|
-
const
|
|
18437
|
-
const
|
|
18438
|
-
|
|
18439
|
-
|
|
18440
|
-
|
|
18433
|
+
const wallet = this.readonlyWallet;
|
|
18434
|
+
const repository = this.walletRepository;
|
|
18435
|
+
const currentSigner = toXOnlySignerHex(
|
|
18436
|
+
base.hex.encode(wallet.boardingTapscript.options.serverPubKey)
|
|
18437
|
+
);
|
|
18438
|
+
const groups = await wallet.getBoardingUtxosForSigners(/* @__PURE__ */ new Set([currentSigner]));
|
|
18439
|
+
for (const { tapscript, coins } of groups) {
|
|
18440
|
+
const address2 = tapscript.onchainAddress(wallet.network);
|
|
18441
|
+
const freshKeys = new Set(coins.map((coin) => `${coin.txid}:${coin.vout}`));
|
|
18442
|
+
const cached = await collectUtxos(repository, address2);
|
|
18443
|
+
const kept = cached.filter((coin) => freshKeys.has(`${coin.txid}:${coin.vout}`));
|
|
18441
18444
|
if (kept.length === cached.length) continue;
|
|
18442
|
-
await
|
|
18443
|
-
if (kept.length > 0) await
|
|
18445
|
+
await repository.deleteUtxos(address2);
|
|
18446
|
+
if (kept.length > 0) await repository.saveUtxos(address2, kept);
|
|
18444
18447
|
}
|
|
18445
18448
|
const address = await this.readonlyWallet.getAddress();
|
|
18446
18449
|
const txs = await this.buildTransactionHistoryFromCache();
|
|
@@ -18648,7 +18651,7 @@ var WalletMessageHandler = class {
|
|
|
18648
18651
|
this.readonlyWallet.getBoardingTxs()
|
|
18649
18652
|
]);
|
|
18650
18653
|
const indexerProvider = this.indexerProvider;
|
|
18651
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
18654
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkOJ5W7L6Q_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
18652
18655
|
return buildTransactionHistory(
|
|
18653
18656
|
vtxos,
|
|
18654
18657
|
boardingTxs,
|
|
@@ -18717,7 +18720,7 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
18717
18720
|
// budget so the worker's snapshot fallback stays reachable before this
|
|
18718
18721
|
// page deadline fires — lowering it below the budget would time the page
|
|
18719
18722
|
// out while the worker is still seconds from answering from cache.
|
|
18720
|
-
GET_ARKADE_INFO:
|
|
18723
|
+
GET_ARKADE_INFO: chunkOJ5W7L6Q_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
|
|
18721
18724
|
INDEXER_GET_VTXOS: 2e4,
|
|
18722
18725
|
INDEXER_GET_VIRTUAL_TXS: 2e4,
|
|
18723
18726
|
GET_VTXOS: 2e4,
|
|
@@ -18856,7 +18859,7 @@ var ServiceWorkerAssetManager = class extends ServiceWorkerReadonlyAssetManager
|
|
|
18856
18859
|
}
|
|
18857
18860
|
};
|
|
18858
18861
|
var initializeMessageBus = (serviceWorker, config, timeoutMs = 2e3) => {
|
|
18859
|
-
|
|
18862
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs("messageBusTimeoutMs", timeoutMs);
|
|
18860
18863
|
const initCmd = {
|
|
18861
18864
|
tag: "INITIALIZE_MESSAGE_BUS",
|
|
18862
18865
|
id: getRandomId(),
|
|
@@ -18943,7 +18946,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18943
18946
|
}
|
|
18944
18947
|
/** Shared tail of both `create()` factories: boot the bus, INIT_WALLET, cache for reinit. */
|
|
18945
18948
|
static async bootstrap(wallet, options, serializedWallet, busConfig) {
|
|
18946
|
-
const arkServer = options.arkServer ?? { url:
|
|
18949
|
+
const arkServer = options.arkServer ?? { url: chunkOJ5W7L6Q_cjs.DEFAULT_ARKADE_SERVER_URL };
|
|
18947
18950
|
const initWalletPayload = {
|
|
18948
18951
|
arkServerUrl: arkServer.url,
|
|
18949
18952
|
arkServerPublicKey: arkServer.publicKey
|
|
@@ -18952,7 +18955,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18952
18955
|
Object.entries(options.messageTimeouts ?? {}).filter(([, ms]) => ms !== void 0)
|
|
18953
18956
|
);
|
|
18954
18957
|
for (const [key, value] of Object.entries(overrides)) {
|
|
18955
|
-
|
|
18958
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs(`messageTimeouts.${key}`, value);
|
|
18956
18959
|
}
|
|
18957
18960
|
const messageTimeouts = {
|
|
18958
18961
|
...DEFAULT_MESSAGE_TIMEOUTS,
|
|
@@ -19282,7 +19285,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19282
19285
|
try {
|
|
19283
19286
|
const response = await this.sendMessage(message);
|
|
19284
19287
|
const { vtxos, page } = response.payload;
|
|
19285
|
-
return { vtxos: vtxos.map(
|
|
19288
|
+
return { vtxos: vtxos.map(chunkOJ5W7L6Q_cjs.normalizeVtxo), page: page && { ...page } };
|
|
19286
19289
|
} catch (cause) {
|
|
19287
19290
|
throw new Error(`Failed to get vtxos: ${cause}`, { cause });
|
|
19288
19291
|
}
|
|
@@ -19386,7 +19389,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19386
19389
|
};
|
|
19387
19390
|
try {
|
|
19388
19391
|
const response = await this.sendMessage(message);
|
|
19389
|
-
return response.payload.vtxos.map(
|
|
19392
|
+
return response.payload.vtxos.map(chunkOJ5W7L6Q_cjs.normalizeVtxo);
|
|
19390
19393
|
} catch (error) {
|
|
19391
19394
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
19392
19395
|
}
|
|
@@ -19417,7 +19420,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19417
19420
|
"Service worker does not support the requested contract scope or freshness check"
|
|
19418
19421
|
);
|
|
19419
19422
|
}
|
|
19420
|
-
return payload.vtxos.map(
|
|
19423
|
+
return payload.vtxos.map(chunkOJ5W7L6Q_cjs.normalizeVtxo);
|
|
19421
19424
|
} catch (error) {
|
|
19422
19425
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
19423
19426
|
}
|
|
@@ -19595,7 +19598,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19595
19598
|
};
|
|
19596
19599
|
try {
|
|
19597
19600
|
const response = await sendContractMessage(message);
|
|
19598
|
-
return response.payload.vtxos.map(
|
|
19601
|
+
return response.payload.vtxos.map(chunkOJ5W7L6Q_cjs.normalizeVtxo);
|
|
19599
19602
|
} catch (cause) {
|
|
19600
19603
|
throw new Error(`Failed to annotate vtxos: ${cause}`, { cause });
|
|
19601
19604
|
}
|
|
@@ -20190,7 +20193,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
20190
20193
|
};
|
|
20191
20194
|
try {
|
|
20192
20195
|
const response = await wallet.sendMessage(message);
|
|
20193
|
-
return response.payload.vtxos.map(
|
|
20196
|
+
return response.payload.vtxos.map(chunkOJ5W7L6Q_cjs.normalizeVtxo);
|
|
20194
20197
|
} catch (e) {
|
|
20195
20198
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
20196
20199
|
}
|
|
@@ -20307,12 +20310,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20307
20310
|
* @returns Configured onchain wallet
|
|
20308
20311
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
20309
20312
|
*/
|
|
20310
|
-
static async create(identity, networkName =
|
|
20313
|
+
static async create(identity, networkName = chunkOJ5W7L6Q_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
20311
20314
|
const pubkey = await identity.xOnlyPublicKey();
|
|
20312
20315
|
if (!pubkey) {
|
|
20313
20316
|
throw new Error("Invalid configured public key");
|
|
20314
20317
|
}
|
|
20315
|
-
const network =
|
|
20318
|
+
const network = chunkOJ5W7L6Q_cjs.getNetwork(networkName);
|
|
20316
20319
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
20317
20320
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
20318
20321
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -20412,7 +20415,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20412
20415
|
feeRate,
|
|
20413
20416
|
params.address
|
|
20414
20417
|
);
|
|
20415
|
-
let tx = new
|
|
20418
|
+
let tx = new chunkOJ5W7L6Q_cjs.Transaction();
|
|
20416
20419
|
for (const input of inputs) {
|
|
20417
20420
|
tx.addInput({
|
|
20418
20421
|
txid: input.txid,
|
|
@@ -20470,7 +20473,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20470
20473
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
20471
20474
|
*/
|
|
20472
20475
|
async bumpAnchor(parentHex, feeRate) {
|
|
20473
|
-
const parent =
|
|
20476
|
+
const parent = chunkOJ5W7L6Q_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
20474
20477
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
20475
20478
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
20476
20479
|
return [parent.hex, child.hex];
|
|
@@ -21286,7 +21289,7 @@ var CachingArkProvider = class {
|
|
|
21286
21289
|
constructor(inner, ttlMs = DEFAULT_TTL_MS) {
|
|
21287
21290
|
this.inner = inner;
|
|
21288
21291
|
this.ttlMs = ttlMs;
|
|
21289
|
-
|
|
21292
|
+
chunkOJ5W7L6Q_cjs.assertNonNegativeMs("ttlMs", ttlMs);
|
|
21290
21293
|
this.unsubscribe = inner.onServerInfoChanged?.((info) => {
|
|
21291
21294
|
this.cached = info;
|
|
21292
21295
|
this.expiresAt = Date.now() + this.ttlMs;
|
|
@@ -21378,7 +21381,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
21378
21381
|
try {
|
|
21379
21382
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
21380
21383
|
for (const psbt of txs) {
|
|
21381
|
-
const tx =
|
|
21384
|
+
const tx = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
21382
21385
|
resolved.set(tx.id, tx.toBytes());
|
|
21383
21386
|
}
|
|
21384
21387
|
} catch (err) {
|
|
@@ -21411,7 +21414,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
21411
21414
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
21412
21415
|
const pending = [];
|
|
21413
21416
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
21414
|
-
if (
|
|
21417
|
+
if (chunkOJ5W7L6Q_cjs.getArkPsbtFields(tx, i, chunkOJ5W7L6Q_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
21415
21418
|
}
|
|
21416
21419
|
if (pending.length === 0) return;
|
|
21417
21420
|
const resolved = await resolvePrevTxs(
|
|
@@ -21420,13 +21423,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
21420
21423
|
onchain
|
|
21421
21424
|
);
|
|
21422
21425
|
for (const i of pending) {
|
|
21423
|
-
|
|
21426
|
+
chunkOJ5W7L6Q_cjs.setArkPsbtField(tx, i, chunkOJ5W7L6Q_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
21424
21427
|
}
|
|
21425
21428
|
}
|
|
21426
21429
|
async function attachPrevoutTxs(tx, source) {
|
|
21427
21430
|
const pending = [];
|
|
21428
21431
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
21429
|
-
if (
|
|
21432
|
+
if (chunkOJ5W7L6Q_cjs.getArkPsbtFields(tx, i, chunkOJ5W7L6Q_cjs.PrevoutTxField).length > 0) continue;
|
|
21430
21433
|
const input = tx.getInput(i);
|
|
21431
21434
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
21432
21435
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -21437,7 +21440,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
21437
21440
|
resolved.set(txid, await source.getRawTransaction(txid));
|
|
21438
21441
|
}
|
|
21439
21442
|
for (const { index, txid } of pending) {
|
|
21440
|
-
|
|
21443
|
+
chunkOJ5W7L6Q_cjs.setArkPsbtField(tx, index, chunkOJ5W7L6Q_cjs.PrevoutTxField, resolved.get(txid));
|
|
21441
21444
|
}
|
|
21442
21445
|
}
|
|
21443
21446
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -21463,7 +21466,7 @@ exports.BIP322 = void 0;
|
|
|
21463
21466
|
async function sign2(message, identity, network) {
|
|
21464
21467
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
21465
21468
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
21466
|
-
const toSpend =
|
|
21469
|
+
const toSpend = chunkOJ5W7L6Q_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
21467
21470
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
21468
21471
|
const signed = await identity.sign(toSign, [0]);
|
|
21469
21472
|
signed.finalizeIdx(0);
|
|
@@ -21521,7 +21524,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
21521
21524
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
21522
21525
|
return false;
|
|
21523
21526
|
}
|
|
21524
|
-
const toSpend =
|
|
21527
|
+
const toSpend = chunkOJ5W7L6Q_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
21525
21528
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript);
|
|
21526
21529
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
21527
21530
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -21542,7 +21545,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
21542
21545
|
}
|
|
21543
21546
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
21544
21547
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
21545
|
-
const toSpend =
|
|
21548
|
+
const toSpend = chunkOJ5W7L6Q_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
21546
21549
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
21547
21550
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
21548
21551
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -21595,7 +21598,7 @@ function encodeCompactSize(n) {
|
|
|
21595
21598
|
return buf;
|
|
21596
21599
|
}
|
|
21597
21600
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
21598
|
-
const tx = new
|
|
21601
|
+
const tx = new chunkOJ5W7L6Q_cjs.Transaction({ version: 0 });
|
|
21599
21602
|
tx.addInput({
|
|
21600
21603
|
txid: toSpend.id,
|
|
21601
21604
|
index: 0,
|
|
@@ -21609,12 +21612,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
21609
21612
|
});
|
|
21610
21613
|
tx.addOutput({
|
|
21611
21614
|
amount: 0n,
|
|
21612
|
-
script:
|
|
21615
|
+
script: chunkOJ5W7L6Q_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
21613
21616
|
});
|
|
21614
21617
|
return tx;
|
|
21615
21618
|
}
|
|
21616
21619
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
21617
|
-
const tx = new
|
|
21620
|
+
const tx = new chunkOJ5W7L6Q_cjs.Transaction({ version: 0 });
|
|
21618
21621
|
tx.addInput({
|
|
21619
21622
|
txid: toSpend.id,
|
|
21620
21623
|
index: 0,
|
|
@@ -21626,7 +21629,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
21626
21629
|
});
|
|
21627
21630
|
tx.addOutput({
|
|
21628
21631
|
amount: 0n,
|
|
21629
|
-
script:
|
|
21632
|
+
script: chunkOJ5W7L6Q_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
21630
21633
|
});
|
|
21631
21634
|
return tx;
|
|
21632
21635
|
}
|
|
@@ -21639,7 +21642,7 @@ var RestEmulatorProvider = class {
|
|
|
21639
21642
|
serverUrl;
|
|
21640
21643
|
async getInfo() {
|
|
21641
21644
|
const url = `${this.serverUrl}/v1/info`;
|
|
21642
|
-
const response = await
|
|
21645
|
+
const response = await chunkOJ5W7L6Q_cjs.baseFetch(url);
|
|
21643
21646
|
if (!response.ok) {
|
|
21644
21647
|
const errorText2 = await response.text();
|
|
21645
21648
|
throw new Error(`Failed to get emulator info: ${errorText2}`);
|
|
@@ -21757,7 +21760,7 @@ var RestEmulatorProvider = class {
|
|
|
21757
21760
|
}
|
|
21758
21761
|
};
|
|
21759
21762
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
21760
|
-
const tx =
|
|
21763
|
+
const tx = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
21761
21764
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
21762
21765
|
const input = tx.getInput(0);
|
|
21763
21766
|
if (!input) {
|
|
@@ -21784,14 +21787,14 @@ var ExitPathError = class extends Error {
|
|
|
21784
21787
|
reason;
|
|
21785
21788
|
};
|
|
21786
21789
|
function delayWeight(sequence) {
|
|
21787
|
-
const t =
|
|
21790
|
+
const t = chunkOJ5W7L6Q_cjs.sequenceToTimelock(sequence);
|
|
21788
21791
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
21789
21792
|
}
|
|
21790
21793
|
async function resolveUnilateralPath(params) {
|
|
21791
21794
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
21792
21795
|
const contract = contractRepository ? (await collectContracts(contractRepository, { script: scriptHex }))[0] : void 0;
|
|
21793
21796
|
if (contract) {
|
|
21794
|
-
const handler =
|
|
21797
|
+
const handler = chunkOSRXKF7B_cjs.contractHandlers.get(contract.type);
|
|
21795
21798
|
if (!handler) {
|
|
21796
21799
|
throw new ExitPathError(
|
|
21797
21800
|
"no-handler",
|
|
@@ -21813,12 +21816,12 @@ async function resolveUnilateralPath(params) {
|
|
|
21813
21816
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
21814
21817
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
21815
21818
|
}
|
|
21816
|
-
const decoded =
|
|
21819
|
+
const decoded = chunkOJ5W7L6Q_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
21817
21820
|
let best;
|
|
21818
21821
|
for (const exit of decoded.exitPaths()) {
|
|
21819
21822
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
21820
21823
|
if (!leaf) continue;
|
|
21821
|
-
const sequence =
|
|
21824
|
+
const sequence = chunkOJ5W7L6Q_cjs.timelockToSequence(exit.params.timelock);
|
|
21822
21825
|
const weight = delayWeight(sequence);
|
|
21823
21826
|
if (!best || weight < best.weight) {
|
|
21824
21827
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -22025,7 +22028,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22025
22028
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
22026
22029
|
const walletDescriptor = base.hex.encode(await wallet.identity.xOnlyPublicKey());
|
|
22027
22030
|
for (const vtxo of vtxos) {
|
|
22028
|
-
if (!
|
|
22031
|
+
if (!chunkOJ5W7L6Q_cjs.canSweepOnchain(vtxo)) {
|
|
22029
22032
|
throw new Error(
|
|
22030
22033
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
22031
22034
|
);
|
|
@@ -22036,14 +22039,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22036
22039
|
}
|
|
22037
22040
|
const resolved = await resolveUnilateralPath({
|
|
22038
22041
|
vtxo,
|
|
22039
|
-
scriptHex: base.hex.encode(
|
|
22042
|
+
scriptHex: base.hex.encode(chunkOJ5W7L6Q_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
22040
22043
|
contractRepository: wallet.contractRepository,
|
|
22041
22044
|
walletDescriptor,
|
|
22042
22045
|
currentTime: Date.now()
|
|
22043
22046
|
});
|
|
22044
22047
|
const spendingLeaf = resolved.selection.leaf;
|
|
22045
22048
|
const sequence = resolved.selection.sequence;
|
|
22046
|
-
const timelock =
|
|
22049
|
+
const timelock = chunkOJ5W7L6Q_cjs.sequenceToTimelock(sequence);
|
|
22047
22050
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
22048
22051
|
if (!elapsed) {
|
|
22049
22052
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -22056,7 +22059,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22056
22059
|
sequence,
|
|
22057
22060
|
witnessUtxo: {
|
|
22058
22061
|
amount: BigInt(vtxo.value),
|
|
22059
|
-
script:
|
|
22062
|
+
script: chunkOJ5W7L6Q_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
22060
22063
|
},
|
|
22061
22064
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
22062
22065
|
});
|
|
@@ -22066,7 +22069,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22066
22069
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
22067
22070
|
);
|
|
22068
22071
|
}
|
|
22069
|
-
const tx = new
|
|
22072
|
+
const tx = new chunkOJ5W7L6Q_cjs.Transaction({ version: 2 });
|
|
22070
22073
|
for (const input of inputs) {
|
|
22071
22074
|
tx.addInput(input);
|
|
22072
22075
|
}
|
|
@@ -22149,7 +22152,7 @@ async function buildSignedSweep(params) {
|
|
|
22149
22152
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
22150
22153
|
);
|
|
22151
22154
|
}
|
|
22152
|
-
const tx = new
|
|
22155
|
+
const tx = new chunkOJ5W7L6Q_cjs.Transaction({ version: 2 });
|
|
22153
22156
|
tx.addInput({
|
|
22154
22157
|
txid: vtxo.txid,
|
|
22155
22158
|
index: vtxo.vout,
|
|
@@ -22174,7 +22177,7 @@ async function buildSignedSweep(params) {
|
|
|
22174
22177
|
finalScriptWitness: [
|
|
22175
22178
|
tapScriptSig[0][1],
|
|
22176
22179
|
...path.extraWitness,
|
|
22177
|
-
|
|
22180
|
+
chunkOJ5W7L6Q_cjs.scriptFromTapLeafScript(path.leaf),
|
|
22178
22181
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
22179
22182
|
]
|
|
22180
22183
|
});
|
|
@@ -22204,7 +22207,7 @@ async function resolveFeeRate(opts) {
|
|
|
22204
22207
|
}
|
|
22205
22208
|
async function selectExitVtxos(opts) {
|
|
22206
22209
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
22207
|
-
const res = await
|
|
22210
|
+
const res = await chunkOJ5W7L6Q_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
22208
22211
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
22209
22212
|
const out = [];
|
|
22210
22213
|
for (const vtxo of res.vtxos) {
|
|
@@ -22219,7 +22222,7 @@ async function selectExitVtxos(opts) {
|
|
|
22219
22222
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
22220
22223
|
);
|
|
22221
22224
|
}
|
|
22222
|
-
const handler =
|
|
22225
|
+
const handler = chunkOSRXKF7B_cjs.contractHandlers.get(contract.type);
|
|
22223
22226
|
if (!handler) {
|
|
22224
22227
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
22225
22228
|
}
|
|
@@ -22249,7 +22252,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22249
22252
|
if (pendingNodes.length > 0) {
|
|
22250
22253
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
22251
22254
|
for (const psbt of txs) {
|
|
22252
|
-
psbts.set(
|
|
22255
|
+
psbts.set(chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
22253
22256
|
}
|
|
22254
22257
|
}
|
|
22255
22258
|
const childVsize = Number(
|
|
@@ -22277,7 +22280,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22277
22280
|
try {
|
|
22278
22281
|
const resolved = await resolveUnilateralPath({
|
|
22279
22282
|
vtxo,
|
|
22280
|
-
scriptHex: base.hex.encode(
|
|
22283
|
+
scriptHex: base.hex.encode(chunkOJ5W7L6Q_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
22281
22284
|
contractRepository: wallet.contractRepository,
|
|
22282
22285
|
walletDescriptor,
|
|
22283
22286
|
currentTime: Date.now()
|
|
@@ -22296,7 +22299,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22296
22299
|
});
|
|
22297
22300
|
continue;
|
|
22298
22301
|
}
|
|
22299
|
-
const t =
|
|
22302
|
+
const t = chunkOJ5W7L6Q_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
22300
22303
|
const delay = { type: t.type, value: Number(t.value) };
|
|
22301
22304
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
22302
22305
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -22403,7 +22406,7 @@ var Executor = class {
|
|
|
22403
22406
|
constructor(pkg, provider, opts) {
|
|
22404
22407
|
this.pkg = pkg;
|
|
22405
22408
|
this.provider = provider;
|
|
22406
|
-
|
|
22409
|
+
chunkOJ5W7L6Q_cjs.assertTimerMs("pollIntervalMs", opts?.pollIntervalMs);
|
|
22407
22410
|
this.pollIntervalMs = opts?.pollIntervalMs ?? 5e3;
|
|
22408
22411
|
this.feeWallet = opts?.feeWallet;
|
|
22409
22412
|
this.signal = opts?.signal;
|
|
@@ -22698,7 +22701,7 @@ async function prepare(opts) {
|
|
|
22698
22701
|
txid: sweep.vtxo.txid,
|
|
22699
22702
|
vout: sweep.vtxo.vout,
|
|
22700
22703
|
value: sweep.vtxo.value,
|
|
22701
|
-
pkScript:
|
|
22704
|
+
pkScript: chunkOJ5W7L6Q_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
22702
22705
|
},
|
|
22703
22706
|
path: sweep.resolved.selection,
|
|
22704
22707
|
outputAddress: opts.sweepAddress,
|
|
@@ -22787,7 +22790,7 @@ async function prepare(opts) {
|
|
|
22787
22790
|
if (newFee <= splitterFee) break;
|
|
22788
22791
|
splitterFee = newFee;
|
|
22789
22792
|
}
|
|
22790
|
-
const splitter = new
|
|
22793
|
+
const splitter = new chunkOJ5W7L6Q_cjs.Transaction({ version: 2 });
|
|
22791
22794
|
for (const coin of selected.inputs) {
|
|
22792
22795
|
splitter.addInput({
|
|
22793
22796
|
txid: coin.txid,
|
|
@@ -22926,44 +22929,44 @@ var UnilateralExit = {
|
|
|
22926
22929
|
|
|
22927
22930
|
// src/arkade/index.ts
|
|
22928
22931
|
var arkade_exports = {};
|
|
22929
|
-
|
|
22930
|
-
ARKADE_OP: () =>
|
|
22931
|
-
ARKADE_OPCODES: () =>
|
|
22932
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
22933
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
22934
|
-
ARKADE_OPS: () =>
|
|
22932
|
+
chunkOJ5W7L6Q_cjs.__export(arkade_exports, {
|
|
22933
|
+
ARKADE_OP: () => chunkOSRXKF7B_cjs.ARKADE_OP,
|
|
22934
|
+
ARKADE_OPCODES: () => chunkOSRXKF7B_cjs.ARKADE_OPCODES,
|
|
22935
|
+
ARKADE_OPCODE_NAMES: () => chunkOSRXKF7B_cjs.ARKADE_OPCODE_NAMES,
|
|
22936
|
+
ARKADE_OPCODE_VALUES: () => chunkOSRXKF7B_cjs.ARKADE_OPCODE_VALUES,
|
|
22937
|
+
ARKADE_OPS: () => chunkOSRXKF7B_cjs.ARKADE_OPS,
|
|
22935
22938
|
Arkade: () => Arkade,
|
|
22936
22939
|
ArkadeContract: () => ArkadeContract,
|
|
22937
|
-
ArkadeProgramScript: () =>
|
|
22938
|
-
ArkadeScript: () =>
|
|
22940
|
+
ArkadeProgramScript: () => chunkOSRXKF7B_cjs.ArkadeProgramScript,
|
|
22941
|
+
ArkadeScript: () => chunkOSRXKF7B_cjs.ArkadeScript,
|
|
22939
22942
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
22940
|
-
BigNum: () =>
|
|
22943
|
+
BigNum: () => chunkOSRXKF7B_cjs.bignum_exports,
|
|
22941
22944
|
OP: () => btcSigner.OP,
|
|
22942
|
-
OPCODE_NAMES: () =>
|
|
22943
|
-
OPCODE_VALUES: () =>
|
|
22944
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
22945
|
+
OPCODE_NAMES: () => chunkOSRXKF7B_cjs.OPCODE_NAMES,
|
|
22946
|
+
OPCODE_VALUES: () => chunkOSRXKF7B_cjs.OPCODE_VALUES,
|
|
22947
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkOSRXKF7B_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
22945
22948
|
Script: () => btcSigner.Script,
|
|
22946
|
-
arkadeScriptHash: () =>
|
|
22947
|
-
arkadeWitnessHash: () =>
|
|
22948
|
-
asmToBytes: () =>
|
|
22949
|
-
bytesToASM: () =>
|
|
22950
|
-
computeArkadeScriptPublicKey: () =>
|
|
22949
|
+
arkadeScriptHash: () => chunkOSRXKF7B_cjs.arkadeScriptHash,
|
|
22950
|
+
arkadeWitnessHash: () => chunkOSRXKF7B_cjs.arkadeWitnessHash,
|
|
22951
|
+
asmToBytes: () => chunkOSRXKF7B_cjs.asmToBytes,
|
|
22952
|
+
bytesToASM: () => chunkOSRXKF7B_cjs.bytesToASM,
|
|
22953
|
+
computeArkadeScriptPublicKey: () => chunkOSRXKF7B_cjs.computeArkadeScriptPublicKey,
|
|
22951
22954
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
22952
|
-
deserializeArkadeContractParams: () =>
|
|
22953
|
-
fromASM: () =>
|
|
22954
|
-
getOpcodeName: () =>
|
|
22955
|
-
getOpcodeValue: () =>
|
|
22955
|
+
deserializeArkadeContractParams: () => chunkOSRXKF7B_cjs.deserializeArkadeContractParams,
|
|
22956
|
+
fromASM: () => chunkOSRXKF7B_cjs.fromASM,
|
|
22957
|
+
getOpcodeName: () => chunkOSRXKF7B_cjs.getOpcodeName,
|
|
22958
|
+
getOpcodeValue: () => chunkOSRXKF7B_cjs.getOpcodeValue,
|
|
22956
22959
|
isContractArtifact: () => isContractArtifact,
|
|
22957
|
-
parseArtifact: () =>
|
|
22960
|
+
parseArtifact: () => chunkOSRXKF7B_cjs.parseArtifact,
|
|
22958
22961
|
programFromArtifact: () => programFromArtifact,
|
|
22959
|
-
resolveAsm: () =>
|
|
22960
|
-
serializeArkadeContractParams: () =>
|
|
22961
|
-
stringifyArtifact: () =>
|
|
22962
|
-
toASM: () =>
|
|
22963
|
-
validateProgram: () =>
|
|
22964
|
-
witnessRefToBytes: () =>
|
|
22962
|
+
resolveAsm: () => chunkOSRXKF7B_cjs.resolveAsm,
|
|
22963
|
+
serializeArkadeContractParams: () => chunkOSRXKF7B_cjs.serializeArkadeContractParams,
|
|
22964
|
+
stringifyArtifact: () => chunkOSRXKF7B_cjs.stringifyArtifact,
|
|
22965
|
+
toASM: () => chunkOSRXKF7B_cjs.toASM,
|
|
22966
|
+
validateProgram: () => chunkOSRXKF7B_cjs.validateProgram,
|
|
22967
|
+
witnessRefToBytes: () => chunkOSRXKF7B_cjs.witnessRefToBytes
|
|
22965
22968
|
});
|
|
22966
|
-
var isVtxoCoin = (input) =>
|
|
22969
|
+
var isVtxoCoin = (input) => chunkOJ5W7L6Q_cjs.isVirtualCoin(input);
|
|
22967
22970
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
22968
22971
|
let batchId;
|
|
22969
22972
|
let sweepTapTreeRoot;
|
|
@@ -22984,23 +22987,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
22984
22987
|
);
|
|
22985
22988
|
await arkProvider.confirmRegistration(intentId);
|
|
22986
22989
|
batchId = event.id;
|
|
22987
|
-
const sweepTapscript =
|
|
22990
|
+
const sweepTapscript = chunkOJ5W7L6Q_cjs.CSVMultisigTapscript.encode({
|
|
22988
22991
|
timelock,
|
|
22989
|
-
pubkeys: [
|
|
22992
|
+
pubkeys: [chunkOSRXKF7B_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
|
|
22990
22993
|
}).script;
|
|
22991
22994
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
22992
22995
|
return { skip: false };
|
|
22993
22996
|
},
|
|
22994
22997
|
onTreeSigningStarted: async (event, vtxoTree) => {
|
|
22995
22998
|
const signerPubKey = await session.getPublicKey();
|
|
22996
|
-
const xonlySignerPubKey =
|
|
22999
|
+
const xonlySignerPubKey = chunkOSRXKF7B_cjs.toXOnly(signerPubKey, "signer key");
|
|
22997
23000
|
const xOnlyPubkeys = event.cosignersPublicKeys.map(
|
|
22998
|
-
(k) => base.hex.encode(
|
|
23001
|
+
(k) => base.hex.encode(chunkOSRXKF7B_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
22999
23002
|
);
|
|
23000
23003
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
23001
23004
|
return { skip: true };
|
|
23002
23005
|
}
|
|
23003
|
-
const commitmentTx =
|
|
23006
|
+
const commitmentTx = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
23004
23007
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
23005
23008
|
if (recipients && recipients.length > 0) {
|
|
23006
23009
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -23038,7 +23041,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23038
23041
|
if (connectorTree) {
|
|
23039
23042
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
23040
23043
|
}
|
|
23041
|
-
let commitmentPsbt =
|
|
23044
|
+
let commitmentPsbt = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
23042
23045
|
assertFinalCommitmentMatchesValidated(
|
|
23043
23046
|
commitmentPsbt,
|
|
23044
23047
|
validatedCommitmentTxid,
|
|
@@ -23080,7 +23083,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23080
23083
|
boardingIndices.push(boardingIdx);
|
|
23081
23084
|
continue;
|
|
23082
23085
|
}
|
|
23083
|
-
if (!
|
|
23086
|
+
if (!chunkOJ5W7L6Q_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
|
|
23084
23087
|
continue;
|
|
23085
23088
|
}
|
|
23086
23089
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -23101,7 +23104,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23101
23104
|
index: input.vout,
|
|
23102
23105
|
witnessUtxo: {
|
|
23103
23106
|
amount: BigInt(input.value),
|
|
23104
|
-
script:
|
|
23107
|
+
script: chunkOJ5W7L6Q_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
23105
23108
|
},
|
|
23106
23109
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
23107
23110
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -23246,7 +23249,7 @@ function flatten(param, structs, stack = []) {
|
|
|
23246
23249
|
function opcodeToken(token) {
|
|
23247
23250
|
const base = token.slice(3);
|
|
23248
23251
|
const name = base === "0" || /^([1-9]|1[0-6])$/.test(base) ? token : base;
|
|
23249
|
-
if (!Object.hasOwn(
|
|
23252
|
+
if (!Object.hasOwn(chunkOSRXKF7B_cjs.ARKADE_OPS, name)) {
|
|
23250
23253
|
fail(`opcode '${token}' is not in this SDK's table`);
|
|
23251
23254
|
}
|
|
23252
23255
|
return name;
|
|
@@ -23293,7 +23296,7 @@ function providedWitness(witness) {
|
|
|
23293
23296
|
}
|
|
23294
23297
|
function csvTimelock(leafName, operand) {
|
|
23295
23298
|
if (typeof operand === "string") return { type: "sequence", value: operand };
|
|
23296
|
-
const timelock =
|
|
23299
|
+
const timelock = chunkOJ5W7L6Q_cjs.sequenceToCanonicalTimelock(operand);
|
|
23297
23300
|
if (!timelock) {
|
|
23298
23301
|
fail(`leaf '${leafName}': CSV literal ${operand} is not a canonical BIP68 sequence`);
|
|
23299
23302
|
}
|
|
@@ -23412,7 +23415,7 @@ function programFromArtifact(artifact) {
|
|
|
23412
23415
|
const paramNames = /* @__PURE__ */ new Set();
|
|
23413
23416
|
for (const param of params) claim(paramNames, param.name, "program parameter");
|
|
23414
23417
|
return {
|
|
23415
|
-
version:
|
|
23418
|
+
version: chunkOSRXKF7B_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
23416
23419
|
name: artifact.contractName,
|
|
23417
23420
|
params,
|
|
23418
23421
|
functions
|
|
@@ -23453,16 +23456,16 @@ var Arkade = class _Arkade {
|
|
|
23453
23456
|
/** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
|
|
23454
23457
|
static async connect(opts) {
|
|
23455
23458
|
const info = await opts.arkade.getInfo();
|
|
23456
|
-
const serverKey =
|
|
23457
|
-
const checkpoint =
|
|
23458
|
-
const network = opts.network ?? (Object.hasOwn(
|
|
23459
|
+
const serverKey = chunkOSRXKF7B_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
23460
|
+
const checkpoint = chunkOJ5W7L6Q_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
23461
|
+
const network = opts.network ?? (Object.hasOwn(chunkOJ5W7L6Q_cjs.networks, info.network) ? chunkOJ5W7L6Q_cjs.getNetwork(info.network) : chunkOJ5W7L6Q_cjs.DEFAULT_NETWORK);
|
|
23459
23462
|
let emulatorKey;
|
|
23460
23463
|
if (opts.emulator) {
|
|
23461
|
-
emulatorKey = base.hex.decode(
|
|
23464
|
+
emulatorKey = base.hex.decode(chunkOJ5W7L6Q_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
23462
23465
|
}
|
|
23463
23466
|
let userKey;
|
|
23464
23467
|
if (opts.identity) {
|
|
23465
|
-
userKey =
|
|
23468
|
+
userKey = chunkOSRXKF7B_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
|
|
23466
23469
|
}
|
|
23467
23470
|
return new _Arkade({
|
|
23468
23471
|
arkProvider: opts.arkade,
|
|
@@ -23485,7 +23488,7 @@ var Arkade = class _Arkade {
|
|
|
23485
23488
|
* explicit args win.
|
|
23486
23489
|
*/
|
|
23487
23490
|
contract(program, args = {}) {
|
|
23488
|
-
const declared = (program.params ?? []).map(
|
|
23491
|
+
const declared = (program.params ?? []).map(chunkOSRXKF7B_cjs.inputName);
|
|
23489
23492
|
if (declared.includes("server") && args.server === void 0) {
|
|
23490
23493
|
args = { ...args, server: this.serverKey };
|
|
23491
23494
|
}
|
|
@@ -23505,7 +23508,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23505
23508
|
userKey: client.userKey,
|
|
23506
23509
|
emulatorKey: client.emulatorKey
|
|
23507
23510
|
};
|
|
23508
|
-
this.vtxoScript = new
|
|
23511
|
+
this.vtxoScript = new chunkOSRXKF7B_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
23509
23512
|
this.tapTree = this.vtxoScript.encode();
|
|
23510
23513
|
this.compiled = this.vtxoScript.compiled;
|
|
23511
23514
|
}
|
|
@@ -23530,7 +23533,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23530
23533
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
23531
23534
|
);
|
|
23532
23535
|
}
|
|
23533
|
-
const typed =
|
|
23536
|
+
const typed = chunkOSRXKF7B_cjs.deserializeArkadeContractParams(contract.params);
|
|
23534
23537
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
23535
23538
|
serverKey: typed.serverKey,
|
|
23536
23539
|
userKey: typed.userKey,
|
|
@@ -23566,7 +23569,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23566
23569
|
toContractParams() {
|
|
23567
23570
|
return {
|
|
23568
23571
|
type: "arkade",
|
|
23569
|
-
params:
|
|
23572
|
+
params: chunkOSRXKF7B_cjs.serializeArkadeContractParams({
|
|
23570
23573
|
program: this.program,
|
|
23571
23574
|
args: this.args,
|
|
23572
23575
|
serverKey: this.keys.serverKey,
|
|
@@ -23606,17 +23609,17 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23606
23609
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
23607
23610
|
if (registered) {
|
|
23608
23611
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
23609
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
23612
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkOJ5W7L6Q_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
23610
23613
|
}
|
|
23611
23614
|
}
|
|
23612
23615
|
if (!this.client.indexer) {
|
|
23613
23616
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
23614
23617
|
}
|
|
23615
|
-
const { vtxos } = await
|
|
23618
|
+
const { vtxos } = await chunkOJ5W7L6Q_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
23616
23619
|
scripts: [scriptHex],
|
|
23617
23620
|
spendableOnly: true
|
|
23618
23621
|
});
|
|
23619
|
-
return vtxos.filter((v) => !
|
|
23622
|
+
return vtxos.filter((v) => !chunkOJ5W7L6Q_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
23620
23623
|
}
|
|
23621
23624
|
/** Total spendable balance (requires an indexer). */
|
|
23622
23625
|
async getBalance() {
|
|
@@ -23714,7 +23717,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
23714
23717
|
this.contract.client.checkpoint
|
|
23715
23718
|
);
|
|
23716
23719
|
if (coin.sourceTx) {
|
|
23717
|
-
|
|
23720
|
+
chunkOJ5W7L6Q_cjs.setArkPsbtField(arkTx, 0, chunkOJ5W7L6Q_cjs.PrevArkTxField, coin.sourceTx);
|
|
23718
23721
|
}
|
|
23719
23722
|
if (this.fn.arkadeScript) {
|
|
23720
23723
|
const indexer = this.contract.client.indexer;
|
|
@@ -23731,8 +23734,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
23731
23734
|
}
|
|
23732
23735
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
23733
23736
|
if (condition.length > 0) {
|
|
23734
|
-
|
|
23735
|
-
|
|
23737
|
+
chunkOJ5W7L6Q_cjs.setArkPsbtField(arkTx, 0, chunkOJ5W7L6Q_cjs.ConditionWitness, condition);
|
|
23738
|
+
chunkOJ5W7L6Q_cjs.setArkPsbtField(checkpoints[0], 0, chunkOJ5W7L6Q_cjs.ConditionWitness, condition);
|
|
23736
23739
|
}
|
|
23737
23740
|
const packets = [];
|
|
23738
23741
|
if (this.assetSpecs.length > 0) {
|
|
@@ -23771,7 +23774,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
23771
23774
|
base.base64.encode(signedArk2.toPSBT()),
|
|
23772
23775
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
23773
23776
|
);
|
|
23774
|
-
const txid =
|
|
23777
|
+
const txid = chunkOJ5W7L6Q_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
23775
23778
|
return {
|
|
23776
23779
|
txid,
|
|
23777
23780
|
signedArkTx: res2.signedArkTx,
|
|
@@ -23836,23 +23839,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
23836
23839
|
}
|
|
23837
23840
|
buildAssetPacket() {
|
|
23838
23841
|
const groups = this.assetSpecs.map((s) => {
|
|
23839
|
-
const id = typeof s.assetId === "string" ?
|
|
23840
|
-
return
|
|
23842
|
+
const id = typeof s.assetId === "string" ? chunkXWUJBHYW_cjs.AssetId.fromString(s.assetId) : chunkXWUJBHYW_cjs.AssetId.fromBytes(s.assetId);
|
|
23843
|
+
return chunkXWUJBHYW_cjs.AssetGroup.create(
|
|
23841
23844
|
id,
|
|
23842
23845
|
null,
|
|
23843
|
-
s.inputs.map((i) =>
|
|
23844
|
-
s.outputs.map((o) =>
|
|
23845
|
-
(s.metadata ?? []).map((m) =>
|
|
23846
|
+
s.inputs.map((i) => chunkXWUJBHYW_cjs.AssetInput.create(i.vin, i.amount)),
|
|
23847
|
+
s.outputs.map((o) => chunkXWUJBHYW_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
23848
|
+
(s.metadata ?? []).map((m) => chunkXWUJBHYW_cjs.Metadata.create(m.key, m.value))
|
|
23846
23849
|
);
|
|
23847
23850
|
});
|
|
23848
|
-
return
|
|
23851
|
+
return chunkXWUJBHYW_cjs.Packet.create(groups);
|
|
23849
23852
|
}
|
|
23850
23853
|
witnessBytes(ref) {
|
|
23851
|
-
return
|
|
23854
|
+
return chunkOSRXKF7B_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
23852
23855
|
}
|
|
23853
23856
|
};
|
|
23854
23857
|
function bindInputs(fn, callArgs) {
|
|
23855
|
-
const names = (fn.def.inputs ?? []).map(
|
|
23858
|
+
const names = (fn.def.inputs ?? []).map(chunkOSRXKF7B_cjs.inputName);
|
|
23856
23859
|
if (callArgs.length !== names.length) {
|
|
23857
23860
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
23858
23861
|
}
|
|
@@ -24266,17 +24269,17 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
|
|
|
24266
24269
|
function offchainInputFees(vtxos, fees) {
|
|
24267
24270
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
24268
24271
|
return vtxos.reduce(
|
|
24269
|
-
(total, vtxo) => total + estimator.evalOffchainInput(
|
|
24272
|
+
(total, vtxo) => total + estimator.evalOffchainInput(chunkOJ5W7L6Q_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
|
|
24270
24273
|
0
|
|
24271
24274
|
);
|
|
24272
24275
|
}
|
|
24273
24276
|
async function changeOutputFee(wallet, inputs, needed, fees) {
|
|
24274
24277
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
24275
24278
|
const net = inputs.reduce(
|
|
24276
|
-
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(
|
|
24279
|
+
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkOJ5W7L6Q_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
|
|
24277
24280
|
0n
|
|
24278
24281
|
);
|
|
24279
|
-
const script = base.hex.encode(
|
|
24282
|
+
const script = base.hex.encode(chunkOJ5W7L6Q_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
|
|
24280
24283
|
return changeAfterOutputFee(
|
|
24281
24284
|
net - needed,
|
|
24282
24285
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script }).satoshis)
|
|
@@ -24578,5 +24581,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
|
24578
24581
|
exports.walletFeeSource = walletFeeSource;
|
|
24579
24582
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
24580
24583
|
exports.withPrevTxs = withPrevTxs;
|
|
24581
|
-
//# sourceMappingURL=chunk-
|
|
24582
|
-
//# sourceMappingURL=chunk-
|
|
24584
|
+
//# sourceMappingURL=chunk-4X3ZGHWW.cjs.map
|
|
24585
|
+
//# sourceMappingURL=chunk-4X3ZGHWW.cjs.map
|