@arkade-os/sdk 0.5.0-rc.2 → 0.5.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{asyncStorageTaskQueue-C5rBYlru.d.ts → asyncStorageTaskQueue-DAs_n1xr.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-BuDvgWh6.d.cts → asyncStorageTaskQueue-DqGRG66E.d.cts} +2 -2
- package/dist/{chunk-HLCGYOIH.cjs → chunk-43XGA362.cjs} +17 -17
- package/dist/{chunk-HLCGYOIH.cjs.map → chunk-43XGA362.cjs.map} +1 -1
- package/dist/{chunk-3R476TDV.js → chunk-7W6FHWYN.js} +3 -3
- package/dist/{chunk-3R476TDV.js.map → chunk-7W6FHWYN.js.map} +1 -1
- package/dist/{chunk-D25O4EGY.cjs → chunk-BCT7DT2J.cjs} +10 -10
- package/dist/{chunk-D25O4EGY.cjs.map → chunk-BCT7DT2J.cjs.map} +1 -1
- package/dist/{chunk-4PKLULWT.js → chunk-ERUAQGYF.js} +3 -3
- package/dist/{chunk-4PKLULWT.js.map → chunk-ERUAQGYF.js.map} +1 -1
- package/dist/{chunk-GMZZQXV5.cjs → chunk-FSF2PGTR.cjs} +439 -439
- package/dist/{chunk-GMZZQXV5.cjs.map → chunk-FSF2PGTR.cjs.map} +1 -1
- package/dist/{chunk-ZOTXDOS5.js → chunk-G4UPMCKW.js} +4 -4
- package/dist/{chunk-ZOTXDOS5.js.map → chunk-G4UPMCKW.js.map} +1 -1
- package/dist/{chunk-ISO4TI5J.js → chunk-HSG2GQTM.js} +4 -4
- package/dist/{chunk-ISO4TI5J.js.map → chunk-HSG2GQTM.js.map} +1 -1
- package/dist/{chunk-NVZJSKZS.cjs → chunk-L4HZK4KK.cjs} +17 -17
- package/dist/{chunk-NVZJSKZS.cjs.map → chunk-L4HZK4KK.cjs.map} +1 -1
- package/dist/{chunk-6DNR46C7.js → chunk-ROD5H7RX.js} +4 -4
- package/dist/{chunk-6DNR46C7.js.map → chunk-ROD5H7RX.js.map} +1 -1
- package/dist/{chunk-43FKNLX4.cjs → chunk-UCSTNXB4.cjs} +49 -49
- package/dist/{chunk-43FKNLX4.cjs.map → chunk-UCSTNXB4.cjs.map} +1 -1
- package/dist/{chunk-JZWLXNHV.cjs → chunk-UJTYUYY4.cjs} +3 -3
- package/dist/{chunk-JZWLXNHV.cjs.map → chunk-UJTYUYY4.cjs.map} +1 -1
- package/dist/{chunk-ZRNQV6HV.js → chunk-VQCDDGRW.js} +5 -5
- package/dist/{chunk-ZRNQV6HV.js.map → chunk-VQCDDGRW.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-BAX5QftB.d.ts → delegate-B9Bmrns7.d.ts} +1 -1
- package/dist/{delegate-1yp1HyP7.d.cts → delegate-CZzIduW4.d.cts} +1 -1
- package/dist/{hdWalletCapable-eJgaT-ec.d.cts → hdWalletCapable-BIl3yLVM.d.cts} +3 -3
- package/dist/{hdWalletCapable-CmEU0NP1.d.ts → hdWalletCapable-Cr5nGpK5.d.ts} +3 -3
- package/dist/{index-W_oMcOmG.d.cts → index-Ci5MmNnK.d.cts} +3 -3
- package/dist/{index-Bem5vKzX.d.ts → index-DQ1Hb2w_.d.ts} +3 -3
- package/dist/{index-DUxufw76.d.cts → index-DnNIOqHS.d.cts} +1 -1
- package/dist/{index-DUxufw76.d.ts → index-DnNIOqHS.d.ts} +1 -1
- package/dist/index.cjs +300 -300
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +18 -18
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-Dr3NStc0.d.cts → taskRunner-BDb5Ee2J.d.cts} +2 -2
- package/dist/{taskRunner-D_iPiZIi.d.ts → taskRunner-F7wNJcF3.d.ts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +5 -5
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkL4HZK4KK_cjs = require('./chunk-L4HZK4KK.cjs');
|
|
4
|
+
var chunkUCSTNXB4_cjs = require('./chunk-UCSTNXB4.cjs');
|
|
5
|
+
var chunkUJTYUYY4_cjs = require('./chunk-UJTYUYY4.cjs');
|
|
6
6
|
var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
|
|
7
7
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
8
8
|
var btcSigner = require('@scure/btc-signer');
|
|
@@ -188,7 +188,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
188
188
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
189
189
|
const tx = this.graph.find(txid);
|
|
190
190
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
191
|
-
const cosigners =
|
|
191
|
+
const cosigners = chunkUJTYUYY4_cjs.getArkPsbtFields(tx.root, 0, chunkUJTYUYY4_cjs.CosignerPublicKey).map(
|
|
192
192
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
193
193
|
// xonly pubkey
|
|
194
194
|
);
|
|
@@ -240,7 +240,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
240
240
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
241
241
|
const prevoutAmounts = [];
|
|
242
242
|
const prevoutScripts = [];
|
|
243
|
-
const cosigners =
|
|
243
|
+
const cosigners = chunkUJTYUYY4_cjs.getArkPsbtFields(g.root, 0, chunkUJTYUYY4_cjs.CosignerPublicKey).map((c) => c.key);
|
|
244
244
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
245
245
|
taprootTweak: this.scriptRoot
|
|
246
246
|
});
|
|
@@ -323,7 +323,7 @@ var SingleKey = class _SingleKey {
|
|
|
323
323
|
async sign(tx, inputIndexes) {
|
|
324
324
|
const txCpy = tx.clone();
|
|
325
325
|
if (!inputIndexes) {
|
|
326
|
-
|
|
326
|
+
chunkUJTYUYY4_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
|
|
327
327
|
try {
|
|
328
328
|
if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
|
|
329
329
|
throw new Error("Failed to sign transaction");
|
|
@@ -432,7 +432,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
432
432
|
let network;
|
|
433
433
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
434
434
|
descriptor = opts.descriptor;
|
|
435
|
-
network =
|
|
435
|
+
network = chunkUCSTNXB4_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
436
436
|
} else {
|
|
437
437
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
438
438
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -530,7 +530,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
530
530
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
531
531
|
*/
|
|
532
532
|
isOurs(descriptor) {
|
|
533
|
-
return
|
|
533
|
+
return chunkUCSTNXB4_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
534
534
|
}
|
|
535
535
|
/**
|
|
536
536
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -579,7 +579,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
579
579
|
}
|
|
580
580
|
// ── internal helpers ─────────────────────────────────────────────
|
|
581
581
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
582
|
-
const network =
|
|
582
|
+
const network = chunkUCSTNXB4_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
583
583
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
584
584
|
if (expansion.isRanged) {
|
|
585
585
|
throw new Error(
|
|
@@ -604,7 +604,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
604
604
|
signTxWithKey(tx, key, inputIndexes) {
|
|
605
605
|
const txCpy = tx.clone();
|
|
606
606
|
if (!inputIndexes) {
|
|
607
|
-
|
|
607
|
+
chunkUJTYUYY4_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
|
|
608
608
|
try {
|
|
609
609
|
if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
|
|
610
610
|
throw new Error("Failed to sign transaction");
|
|
@@ -666,7 +666,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
666
666
|
*/
|
|
667
667
|
descriptor;
|
|
668
668
|
constructor(descriptor) {
|
|
669
|
-
const network =
|
|
669
|
+
const network = chunkUCSTNXB4_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
670
670
|
let expansion;
|
|
671
671
|
try {
|
|
672
672
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -716,7 +716,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
716
716
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
717
717
|
*/
|
|
718
718
|
isOurs(descriptor) {
|
|
719
|
-
return
|
|
719
|
+
return chunkUCSTNXB4_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
720
720
|
}
|
|
721
721
|
};
|
|
722
722
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -878,10 +878,10 @@ var DescriptorIdentity = class {
|
|
|
878
878
|
this.base = base;
|
|
879
879
|
}
|
|
880
880
|
async xOnlyPublicKey() {
|
|
881
|
-
return
|
|
881
|
+
return chunkUCSTNXB4_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
882
882
|
}
|
|
883
883
|
async compressedPublicKey() {
|
|
884
|
-
return
|
|
884
|
+
return chunkUCSTNXB4_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
885
885
|
}
|
|
886
886
|
async sign(tx, inputIndexes) {
|
|
887
887
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -949,12 +949,12 @@ var WalletCannotAllocateAddressError = class extends Error {
|
|
|
949
949
|
};
|
|
950
950
|
async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
951
951
|
const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
|
|
952
|
-
if (owner &&
|
|
952
|
+
if (owner && chunkUCSTNXB4_cjs.parseHDDescriptor(descriptor)) {
|
|
953
953
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
954
954
|
}
|
|
955
955
|
let key;
|
|
956
956
|
try {
|
|
957
|
-
key =
|
|
957
|
+
key = chunkUCSTNXB4_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
958
958
|
} catch {
|
|
959
959
|
throw new ForeignDescriptorError(descriptor);
|
|
960
960
|
}
|
|
@@ -1329,14 +1329,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1329
1329
|
}
|
|
1330
1330
|
var PREIMAGE_INDEX = 0;
|
|
1331
1331
|
function isPerArtifactDescriptor(descriptor) {
|
|
1332
|
-
return
|
|
1332
|
+
return chunkUCSTNXB4_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1333
1333
|
}
|
|
1334
1334
|
async function provisionDescriptor(wallet) {
|
|
1335
1335
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1336
|
-
return allocated ?? await
|
|
1336
|
+
return allocated ?? await chunkUCSTNXB4_cjs.identityDescriptor(wallet.identity);
|
|
1337
1337
|
}
|
|
1338
1338
|
async function provisionRefundKey(wallet) {
|
|
1339
|
-
const descriptor = await
|
|
1339
|
+
const descriptor = await chunkUCSTNXB4_cjs.identityDescriptor(wallet.identity);
|
|
1340
1340
|
const signer = await contractSigner(wallet, descriptor);
|
|
1341
1341
|
const pubkey = await signer.xOnlyPublicKey();
|
|
1342
1342
|
const identityPubkey = await wallet.identity.xOnlyPublicKey();
|
|
@@ -1346,7 +1346,7 @@ async function provisionRefundKey(wallet) {
|
|
|
1346
1346
|
);
|
|
1347
1347
|
}
|
|
1348
1348
|
const address = await wallet.getAddress();
|
|
1349
|
-
const { pkScript } =
|
|
1349
|
+
const { pkScript } = chunkUJTYUYY4_cjs.ArkAddress.decode(address);
|
|
1350
1350
|
return { descriptor, pubkey, pkScript, address };
|
|
1351
1351
|
}
|
|
1352
1352
|
async function provisionClaimSecret(wallet, opts = {}) {
|
|
@@ -1392,7 +1392,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1392
1392
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1393
1393
|
let expected;
|
|
1394
1394
|
try {
|
|
1395
|
-
expected =
|
|
1395
|
+
expected = chunkUCSTNXB4_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1396
1396
|
} catch (cause) {
|
|
1397
1397
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1398
1398
|
}
|
|
@@ -1611,14 +1611,14 @@ var RestDelegateProvider = class {
|
|
|
1611
1611
|
*/
|
|
1612
1612
|
async delegate(intent, forfeitTxs, options) {
|
|
1613
1613
|
const url = `${this.url}/v1/delegate`;
|
|
1614
|
-
const response = await
|
|
1614
|
+
const response = await chunkUJTYUYY4_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: chunkUJTYUYY4_cjs.Intent.encodeMessage(intent.message),
|
|
1622
1622
|
proof: intent.proof
|
|
1623
1623
|
},
|
|
1624
1624
|
forfeit_txs: forfeitTxs,
|
|
@@ -1638,7 +1638,7 @@ var RestDelegateProvider = class {
|
|
|
1638
1638
|
*/
|
|
1639
1639
|
async getDelegateInfo() {
|
|
1640
1640
|
const url = `${this.url}/v1/delegator/info`;
|
|
1641
|
-
const response = await
|
|
1641
|
+
const response = await chunkUJTYUYY4_cjs.rateGate.runHttp(url, () => chunkUJTYUYY4_cjs.baseFetch(url));
|
|
1642
1642
|
if (!response.ok) {
|
|
1643
1643
|
const errorText2 = await response.text();
|
|
1644
1644
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1663,7 +1663,7 @@ var ESPLORA_URL = {
|
|
|
1663
1663
|
regtest: "http://localhost:3000/api"
|
|
1664
1664
|
};
|
|
1665
1665
|
var EsploraProvider = class {
|
|
1666
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1666
|
+
constructor(baseUrl = ESPLORA_URL[chunkUJTYUYY4_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1667
1667
|
this.baseUrl = baseUrl;
|
|
1668
1668
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1669
1669
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1682,14 +1682,14 @@ var EsploraProvider = class {
|
|
|
1682
1682
|
*/
|
|
1683
1683
|
addressWatches = /* @__PURE__ */ new Map();
|
|
1684
1684
|
async getCoins(address) {
|
|
1685
|
-
const response = await
|
|
1685
|
+
const response = await chunkUJTYUYY4_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1686
1686
|
if (!response.ok) {
|
|
1687
1687
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1688
1688
|
}
|
|
1689
1689
|
return response.json();
|
|
1690
1690
|
}
|
|
1691
1691
|
async getFeeRate() {
|
|
1692
|
-
const response = await
|
|
1692
|
+
const response = await chunkUJTYUYY4_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1693
1693
|
if (response.status === 404) {
|
|
1694
1694
|
return void 0;
|
|
1695
1695
|
}
|
|
@@ -1710,7 +1710,7 @@ var EsploraProvider = class {
|
|
|
1710
1710
|
}
|
|
1711
1711
|
}
|
|
1712
1712
|
async getTxOutspends(txid) {
|
|
1713
|
-
const response = await
|
|
1713
|
+
const response = await chunkUJTYUYY4_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1714
1714
|
if (!response.ok) {
|
|
1715
1715
|
const error = await response.text();
|
|
1716
1716
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1718,7 +1718,7 @@ var EsploraProvider = class {
|
|
|
1718
1718
|
return response.json();
|
|
1719
1719
|
}
|
|
1720
1720
|
async getTransactions(address) {
|
|
1721
|
-
const response = await
|
|
1721
|
+
const response = await chunkUJTYUYY4_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1722
1722
|
if (!response.ok) {
|
|
1723
1723
|
const error = await response.text();
|
|
1724
1724
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1731,14 +1731,14 @@ var EsploraProvider = class {
|
|
|
1731
1731
|
* usable as a change probe for the polling fallback.
|
|
1732
1732
|
*/
|
|
1733
1733
|
async getAddressStats(address) {
|
|
1734
|
-
const response = await
|
|
1734
|
+
const response = await chunkUJTYUYY4_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
|
|
1735
1735
|
if (!response.ok) {
|
|
1736
1736
|
throw new Error(`Failed to get address stats: ${response.statusText}`);
|
|
1737
1737
|
}
|
|
1738
1738
|
return response.json();
|
|
1739
1739
|
}
|
|
1740
1740
|
async getRawTransaction(txid) {
|
|
1741
|
-
const response = await
|
|
1741
|
+
const response = await chunkUJTYUYY4_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
1742
1742
|
if (!response.ok) {
|
|
1743
1743
|
const error = await response.text();
|
|
1744
1744
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -1746,7 +1746,7 @@ var EsploraProvider = class {
|
|
|
1746
1746
|
return base.hex.decode((await response.text()).trim());
|
|
1747
1747
|
}
|
|
1748
1748
|
async getTxStatus(txid) {
|
|
1749
|
-
const txresponse = await
|
|
1749
|
+
const txresponse = await chunkUJTYUYY4_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1750
1750
|
if (!txresponse.ok) {
|
|
1751
1751
|
throw new Error(txresponse.statusText);
|
|
1752
1752
|
}
|
|
@@ -1754,7 +1754,7 @@ var EsploraProvider = class {
|
|
|
1754
1754
|
if (!tx.status.confirmed) {
|
|
1755
1755
|
return { confirmed: false };
|
|
1756
1756
|
}
|
|
1757
|
-
const response = await
|
|
1757
|
+
const response = await chunkUJTYUYY4_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1758
1758
|
if (!response.ok) {
|
|
1759
1759
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1760
1760
|
}
|
|
@@ -2038,7 +2038,7 @@ var EsploraProvider = class {
|
|
|
2038
2038
|
return { subscribers, teardown, started };
|
|
2039
2039
|
}
|
|
2040
2040
|
async getChainTip() {
|
|
2041
|
-
const tipBlocks = await
|
|
2041
|
+
const tipBlocks = await chunkUJTYUYY4_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
2042
2042
|
if (!tipBlocks.ok) {
|
|
2043
2043
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
2044
2044
|
}
|
|
@@ -2059,7 +2059,7 @@ var EsploraProvider = class {
|
|
|
2059
2059
|
};
|
|
2060
2060
|
}
|
|
2061
2061
|
async broadcastPackage(parent, child) {
|
|
2062
|
-
const response = await
|
|
2062
|
+
const response = await chunkUJTYUYY4_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
2063
2063
|
method: "POST",
|
|
2064
2064
|
headers: {
|
|
2065
2065
|
"Content-Type": "application/json"
|
|
@@ -2075,7 +2075,7 @@ var EsploraProvider = class {
|
|
|
2075
2075
|
return result;
|
|
2076
2076
|
}
|
|
2077
2077
|
async broadcastTx(tx) {
|
|
2078
|
-
const response = await
|
|
2078
|
+
const response = await chunkUJTYUYY4_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
2079
2079
|
method: "POST",
|
|
2080
2080
|
headers: {
|
|
2081
2081
|
"Content-Type": "text/plain"
|
|
@@ -2258,7 +2258,7 @@ function findP2AOutput(tx) {
|
|
|
2258
2258
|
var CHILD_DUST_AMOUNT = 546;
|
|
2259
2259
|
function buildAnchorChild(params) {
|
|
2260
2260
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2261
|
-
const child = new
|
|
2261
|
+
const child = new chunkUJTYUYY4_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2262
2262
|
child.addInput(findP2AOutput(parent));
|
|
2263
2263
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
2264
2264
|
for (const _ of fundingCoins) {
|
|
@@ -2306,7 +2306,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2306
2306
|
);
|
|
2307
2307
|
}
|
|
2308
2308
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2309
|
-
const tx = new
|
|
2309
|
+
const tx = new chunkUJTYUYY4_cjs.Transaction({
|
|
2310
2310
|
version: 3,
|
|
2311
2311
|
lockTime: txLocktime
|
|
2312
2312
|
});
|
|
@@ -2382,7 +2382,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2382
2382
|
if (previousScriptKey.length !== 32) {
|
|
2383
2383
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2384
2384
|
}
|
|
2385
|
-
const cosigners =
|
|
2385
|
+
const cosigners = chunkUJTYUYY4_cjs.getArkPsbtFields(child.root, 0, chunkUJTYUYY4_cjs.CosignerPublicKey);
|
|
2386
2386
|
if (cosigners.length === 0) {
|
|
2387
2387
|
throw ErrMissingCosignersPublicKeys;
|
|
2388
2388
|
}
|
|
@@ -2440,7 +2440,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2440
2440
|
return new _EmulatorPacket(entries);
|
|
2441
2441
|
}
|
|
2442
2442
|
static fromBytes(data) {
|
|
2443
|
-
const reader = new
|
|
2443
|
+
const reader = new chunkL4HZK4KK_cjs.BufferReader(data);
|
|
2444
2444
|
const entryCount = reader.readCompactSize();
|
|
2445
2445
|
const entries = [];
|
|
2446
2446
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2458,7 +2458,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2458
2458
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2459
2459
|
}
|
|
2460
2460
|
serialize() {
|
|
2461
|
-
const writer = new
|
|
2461
|
+
const writer = new chunkL4HZK4KK_cjs.BufferWriter();
|
|
2462
2462
|
writer.writeCompactSize(this.entries.length);
|
|
2463
2463
|
for (const entry of this.entries) {
|
|
2464
2464
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2545,7 +2545,7 @@ var Extension = class _Extension {
|
|
|
2545
2545
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2546
2546
|
);
|
|
2547
2547
|
}
|
|
2548
|
-
const reader = new
|
|
2548
|
+
const reader = new chunkL4HZK4KK_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2549
2549
|
const packets = [];
|
|
2550
2550
|
while (reader.remaining() > 0) {
|
|
2551
2551
|
const packetType = reader.readByte();
|
|
@@ -2619,7 +2619,7 @@ var Extension = class _Extension {
|
|
|
2619
2619
|
*/
|
|
2620
2620
|
getAssetPacket() {
|
|
2621
2621
|
for (const p of this.packets) {
|
|
2622
|
-
if (p instanceof
|
|
2622
|
+
if (p instanceof chunkL4HZK4KK_cjs.Packet) {
|
|
2623
2623
|
return p;
|
|
2624
2624
|
}
|
|
2625
2625
|
}
|
|
@@ -2657,8 +2657,8 @@ var Extension = class _Extension {
|
|
|
2657
2657
|
};
|
|
2658
2658
|
function parsePacket(packetType, data) {
|
|
2659
2659
|
switch (packetType) {
|
|
2660
|
-
case
|
|
2661
|
-
return
|
|
2660
|
+
case chunkL4HZK4KK_cjs.Packet.PACKET_TYPE:
|
|
2661
|
+
return chunkL4HZK4KK_cjs.Packet.fromBytes(data);
|
|
2662
2662
|
case EmulatorPacket.PACKET_TYPE:
|
|
2663
2663
|
return EmulatorPacket.fromBytes(data);
|
|
2664
2664
|
default:
|
|
@@ -2705,16 +2705,16 @@ function buildOpReturnScript(data) {
|
|
|
2705
2705
|
}
|
|
2706
2706
|
return script;
|
|
2707
2707
|
}
|
|
2708
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2709
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2708
|
+
var ErrOffchainOutputNotFound = (address) => new chunkUJTYUYY4_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2709
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
2710
2710
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2711
2711
|
);
|
|
2712
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2713
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2712
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkUJTYUYY4_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2713
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
2714
2714
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2715
2715
|
);
|
|
2716
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2717
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2716
|
+
var ErrOnchainOutputNotFound = (address) => new chunkUJTYUYY4_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2717
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
2718
2718
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2719
2719
|
);
|
|
2720
2720
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2723,7 +2723,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2723
2723
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2724
2724
|
if (!validatedCommitmentTxid) return;
|
|
2725
2725
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2726
|
-
throw new
|
|
2726
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
2727
2727
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2728
2728
|
);
|
|
2729
2729
|
}
|
|
@@ -2733,7 +2733,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2733
2733
|
for (const recipient of recipients) {
|
|
2734
2734
|
let arkAddress;
|
|
2735
2735
|
try {
|
|
2736
|
-
arkAddress =
|
|
2736
|
+
arkAddress = chunkUJTYUYY4_cjs.ArkAddress.decode(recipient.address);
|
|
2737
2737
|
} catch {
|
|
2738
2738
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2739
2739
|
continue;
|
|
@@ -2745,7 +2745,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2745
2745
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2746
2746
|
for (const recipient of recipients) {
|
|
2747
2747
|
try {
|
|
2748
|
-
|
|
2748
|
+
chunkUJTYUYY4_cjs.ArkAddress.decode(recipient.address);
|
|
2749
2749
|
} catch {
|
|
2750
2750
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2751
2751
|
continue;
|
|
@@ -2978,7 +2978,7 @@ function assetMintResolver() {
|
|
|
2978
2978
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
2979
2979
|
const minted = tx.assets.filter((a) => {
|
|
2980
2980
|
try {
|
|
2981
|
-
return base.hex.encode(
|
|
2981
|
+
return base.hex.encode(chunkL4HZK4KK_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
2982
2982
|
} catch {
|
|
2983
2983
|
return false;
|
|
2984
2984
|
}
|
|
@@ -3021,7 +3021,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3021
3021
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
3022
3022
|
inputsByAssetId.set(asset.assetId, [
|
|
3023
3023
|
...existing ?? [],
|
|
3024
|
-
|
|
3024
|
+
chunkL4HZK4KK_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
3025
3025
|
]);
|
|
3026
3026
|
}
|
|
3027
3027
|
}
|
|
@@ -3033,7 +3033,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3033
3033
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3034
3034
|
outputsByAssetId.set(asset.assetId, [
|
|
3035
3035
|
...existing ?? [],
|
|
3036
|
-
|
|
3036
|
+
chunkL4HZK4KK_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3037
3037
|
]);
|
|
3038
3038
|
}
|
|
3039
3039
|
}
|
|
@@ -3044,7 +3044,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3044
3044
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3045
3045
|
outputsByAssetId.set(asset.assetId, [
|
|
3046
3046
|
...existing ?? [],
|
|
3047
|
-
|
|
3047
|
+
chunkL4HZK4KK_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3048
3048
|
]);
|
|
3049
3049
|
}
|
|
3050
3050
|
}
|
|
@@ -3053,11 +3053,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3053
3053
|
for (const assetIdStr of allAssetIds) {
|
|
3054
3054
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
3055
3055
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
3056
|
-
const assetId =
|
|
3057
|
-
const group =
|
|
3056
|
+
const assetId = chunkL4HZK4KK_cjs.AssetId.fromString(assetIdStr);
|
|
3057
|
+
const group = chunkL4HZK4KK_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
3058
3058
|
groups.push(group);
|
|
3059
3059
|
}
|
|
3060
|
-
return
|
|
3060
|
+
return chunkL4HZK4KK_cjs.Packet.create(groups);
|
|
3061
3061
|
}
|
|
3062
3062
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
3063
3063
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -3094,7 +3094,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
|
|
|
3094
3094
|
}
|
|
3095
3095
|
function toXOnlySignerHex(pubkeyHex) {
|
|
3096
3096
|
const bytes = base.hex.decode(pubkeyHex);
|
|
3097
|
-
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(
|
|
3097
|
+
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkUCSTNXB4_cjs.toXOnly(bytes, "signer key"));
|
|
3098
3098
|
throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
|
|
3099
3099
|
}
|
|
3100
3100
|
function signerSetFromInfo(info) {
|
|
@@ -3141,13 +3141,13 @@ var toTimelock = (value) => ({
|
|
|
3141
3141
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
3142
3142
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
3143
3143
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
3144
|
-
throw new
|
|
3144
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3145
3145
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
3146
3146
|
);
|
|
3147
3147
|
}
|
|
3148
3148
|
const seconds = toSeconds(timelock);
|
|
3149
3149
|
if (seconds < policy.minSeconds) {
|
|
3150
|
-
throw new
|
|
3150
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3151
3151
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
3152
3152
|
);
|
|
3153
3153
|
}
|
|
@@ -3168,7 +3168,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
3168
3168
|
}
|
|
3169
3169
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
3170
3170
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
3171
|
-
throw new
|
|
3171
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3172
3172
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
3173
3173
|
);
|
|
3174
3174
|
}
|
|
@@ -3198,21 +3198,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
3198
3198
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
3199
3199
|
let script;
|
|
3200
3200
|
try {
|
|
3201
|
-
script =
|
|
3201
|
+
script = chunkUJTYUYY4_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
3202
3202
|
} catch (e) {
|
|
3203
|
-
throw new
|
|
3203
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3204
3204
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
3205
3205
|
);
|
|
3206
3206
|
}
|
|
3207
3207
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
3208
3208
|
const { pubkeys } = script.params;
|
|
3209
3209
|
if (pubkeys.length !== 1) {
|
|
3210
|
-
throw new
|
|
3210
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3211
3211
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
3212
3212
|
);
|
|
3213
3213
|
}
|
|
3214
3214
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
3215
|
-
throw new
|
|
3215
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3216
3216
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
3217
3217
|
);
|
|
3218
3218
|
}
|
|
@@ -3256,8 +3256,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
3256
3256
|
function buildVirtualTx(inputs, outputs) {
|
|
3257
3257
|
let lockTime = 0n;
|
|
3258
3258
|
for (const input of inputs) {
|
|
3259
|
-
const tapscript =
|
|
3260
|
-
if (
|
|
3259
|
+
const tapscript = chunkUJTYUYY4_cjs.decodeTapscript(chunkUJTYUYY4_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
3260
|
+
if (chunkUJTYUYY4_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
3261
3261
|
if (lockTime !== 0n) {
|
|
3262
3262
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
3263
3263
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -3268,7 +3268,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3268
3268
|
}
|
|
3269
3269
|
}
|
|
3270
3270
|
}
|
|
3271
|
-
const tx = new
|
|
3271
|
+
const tx = new chunkUJTYUYY4_cjs.Transaction({
|
|
3272
3272
|
version: 3,
|
|
3273
3273
|
lockTime: Number(lockTime)
|
|
3274
3274
|
});
|
|
@@ -3278,12 +3278,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3278
3278
|
index: input.vout,
|
|
3279
3279
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3280
3280
|
witnessUtxo: {
|
|
3281
|
-
script:
|
|
3281
|
+
script: chunkUJTYUYY4_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3282
3282
|
amount: BigInt(input.value)
|
|
3283
3283
|
},
|
|
3284
3284
|
tapLeafScript: [input.tapLeafScript]
|
|
3285
3285
|
});
|
|
3286
|
-
|
|
3286
|
+
chunkUJTYUYY4_cjs.setArkPsbtField(tx, i, chunkUJTYUYY4_cjs.VtxoTaprootTree, input.tapTree);
|
|
3287
3287
|
}
|
|
3288
3288
|
for (const output of outputs) {
|
|
3289
3289
|
tx.addOutput(output);
|
|
@@ -3292,8 +3292,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3292
3292
|
return tx;
|
|
3293
3293
|
}
|
|
3294
3294
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3295
|
-
const collaborativeClosure =
|
|
3296
|
-
const checkpointVtxoScript = new
|
|
3295
|
+
const collaborativeClosure = chunkUJTYUYY4_cjs.decodeTapscript(chunkUJTYUYY4_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3296
|
+
const checkpointVtxoScript = new chunkUJTYUYY4_cjs.VtxoScript([
|
|
3297
3297
|
serverUnrollScript.script,
|
|
3298
3298
|
collaborativeClosure.script
|
|
3299
3299
|
]);
|
|
@@ -3369,7 +3369,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3369
3369
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3370
3370
|
const sig = signature.subarray(0, 64);
|
|
3371
3371
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3372
|
-
const sighashName =
|
|
3372
|
+
const sighashName = chunkUJTYUYY4_cjs.formatSighash(sighashType);
|
|
3373
3373
|
throw new Error(
|
|
3374
3374
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3375
3375
|
);
|
|
@@ -3443,7 +3443,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3443
3443
|
}
|
|
3444
3444
|
function isValidArkAddress(address) {
|
|
3445
3445
|
try {
|
|
3446
|
-
|
|
3446
|
+
chunkUJTYUYY4_cjs.ArkAddress.decode(address);
|
|
3447
3447
|
return true;
|
|
3448
3448
|
} catch (e) {
|
|
3449
3449
|
return false;
|
|
@@ -3451,16 +3451,16 @@ function isValidArkAddress(address) {
|
|
|
3451
3451
|
}
|
|
3452
3452
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3453
3453
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3454
|
-
throw new
|
|
3454
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3455
3455
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3456
3456
|
);
|
|
3457
3457
|
}
|
|
3458
3458
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3459
3459
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3460
|
-
const server =
|
|
3460
|
+
const server = chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3461
3461
|
const local = byTxid.get(server.id);
|
|
3462
3462
|
if (!local) {
|
|
3463
|
-
throw new
|
|
3463
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3464
3464
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3465
3465
|
);
|
|
3466
3466
|
}
|
|
@@ -3470,14 +3470,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3470
3470
|
}
|
|
3471
3471
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3472
3472
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3473
|
-
throw new
|
|
3473
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3474
3474
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3475
3475
|
);
|
|
3476
3476
|
}
|
|
3477
3477
|
if (response.finalArkTx === void 0) return;
|
|
3478
|
-
const finalTxid =
|
|
3478
|
+
const finalTxid = chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3479
3479
|
if (finalTxid !== signedArkTx.id) {
|
|
3480
|
-
throw new
|
|
3480
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3481
3481
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3482
3482
|
);
|
|
3483
3483
|
}
|
|
@@ -3496,10 +3496,10 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex,
|
|
|
3496
3496
|
[serverPubkeyHex],
|
|
3497
3497
|
void 0,
|
|
3498
3498
|
void 0,
|
|
3499
|
-
payment_js.tapLeafHash(
|
|
3499
|
+
payment_js.tapLeafHash(chunkUJTYUYY4_cjs.scriptFromTapLeafScript(leaf))
|
|
3500
3500
|
);
|
|
3501
3501
|
} catch (error) {
|
|
3502
|
-
throw new
|
|
3502
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3503
3503
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3504
3504
|
);
|
|
3505
3505
|
}
|
|
@@ -3508,20 +3508,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3508
3508
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3509
3509
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3510
3510
|
if (checkpoint.inputsLength !== 1) {
|
|
3511
|
-
throw new
|
|
3511
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3512
3512
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3513
3513
|
);
|
|
3514
3514
|
}
|
|
3515
3515
|
const spent = checkpoint.getInput(0);
|
|
3516
3516
|
if (!spent.txid || spent.index === void 0) {
|
|
3517
|
-
throw new
|
|
3517
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3518
3518
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3519
3519
|
);
|
|
3520
3520
|
}
|
|
3521
3521
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3522
3522
|
const input = byOutpoint.get(outpoint);
|
|
3523
3523
|
if (!input) {
|
|
3524
|
-
throw new
|
|
3524
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3525
3525
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3526
3526
|
);
|
|
3527
3527
|
}
|
|
@@ -3529,7 +3529,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3529
3529
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3530
3530
|
);
|
|
3531
3531
|
if (!rebuilt) {
|
|
3532
|
-
throw new
|
|
3532
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3533
3533
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3534
3534
|
);
|
|
3535
3535
|
}
|
|
@@ -3555,9 +3555,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3555
3555
|
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
3556
3556
|
matched.forEach(({ server }, index) => {
|
|
3557
3557
|
try {
|
|
3558
|
-
|
|
3558
|
+
chunkUJTYUYY4_cjs.assertAllowedSighashTypes(server);
|
|
3559
3559
|
} catch (error) {
|
|
3560
|
-
throw new
|
|
3560
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3561
3561
|
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
3562
3562
|
);
|
|
3563
3563
|
}
|
|
@@ -3565,12 +3565,12 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3565
3565
|
const verify = options?.verifyServerSignatures;
|
|
3566
3566
|
if (verify) {
|
|
3567
3567
|
if (response.finalArkTx === void 0) {
|
|
3568
|
-
throw new
|
|
3568
|
+
throw new chunkUJTYUYY4_cjs.ServerResponseMismatchError(
|
|
3569
3569
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3570
3570
|
);
|
|
3571
3571
|
}
|
|
3572
|
-
const finalArkTx =
|
|
3573
|
-
const serverPubkeyHex = base.hex.encode(
|
|
3572
|
+
const finalArkTx = chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3573
|
+
const serverPubkeyHex = base.hex.encode(chunkUCSTNXB4_cjs.toXOnly(verify.serverPubkey, "server key"));
|
|
3574
3574
|
for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
|
|
3575
3575
|
assertServerSignedLeaf(
|
|
3576
3576
|
finalArkTx,
|
|
@@ -3626,12 +3626,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3626
3626
|
return {
|
|
3627
3627
|
...identity,
|
|
3628
3628
|
sign: async (tx, inputIndexes) => {
|
|
3629
|
-
const signed =
|
|
3629
|
+
const signed = chunkUJTYUYY4_cjs.Transaction.fromPSBT(
|
|
3630
3630
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3631
3631
|
);
|
|
3632
3632
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3633
3633
|
for (const index of indexes) {
|
|
3634
|
-
|
|
3634
|
+
chunkUJTYUYY4_cjs.setArkPsbtField(signed, index, chunkUJTYUYY4_cjs.ConditionWitness, [preimage]);
|
|
3635
3635
|
}
|
|
3636
3636
|
return signed;
|
|
3637
3637
|
}
|
|
@@ -3823,7 +3823,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
3823
3823
|
};
|
|
3824
3824
|
}
|
|
3825
3825
|
function deriveContractTapscripts(contract) {
|
|
3826
|
-
const handler =
|
|
3826
|
+
const handler = chunkUCSTNXB4_cjs.contractHandlers.get(contract.type);
|
|
3827
3827
|
if (!handler) {
|
|
3828
3828
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3829
3829
|
}
|
|
@@ -3894,7 +3894,7 @@ function getRandomId() {
|
|
|
3894
3894
|
}
|
|
3895
3895
|
function isValidArkAddress2(address) {
|
|
3896
3896
|
try {
|
|
3897
|
-
|
|
3897
|
+
chunkUJTYUYY4_cjs.ArkAddress.decode(address);
|
|
3898
3898
|
return true;
|
|
3899
3899
|
} catch (e) {
|
|
3900
3900
|
return false;
|
|
@@ -3922,7 +3922,7 @@ function assertRecipientArkadeAddress(encoded, address, context) {
|
|
|
3922
3922
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
3923
3923
|
let derived;
|
|
3924
3924
|
try {
|
|
3925
|
-
derived =
|
|
3925
|
+
derived = chunkUJTYUYY4_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
3926
3926
|
} catch (e) {
|
|
3927
3927
|
throw new Error(
|
|
3928
3928
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -3939,7 +3939,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3939
3939
|
for (const recipient of recipients) {
|
|
3940
3940
|
let address;
|
|
3941
3941
|
try {
|
|
3942
|
-
address =
|
|
3942
|
+
address = chunkUJTYUYY4_cjs.ArkAddress.decode(recipient.address);
|
|
3943
3943
|
} catch (e) {
|
|
3944
3944
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
3945
3945
|
}
|
|
@@ -3964,7 +3964,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3964
3964
|
|
|
3965
3965
|
// src/contracts/spendability.ts
|
|
3966
3966
|
function isContractGenericallySpendable(contract) {
|
|
3967
|
-
return
|
|
3967
|
+
return chunkUCSTNXB4_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
3968
3968
|
}
|
|
3969
3969
|
function gatedContracts(contracts) {
|
|
3970
3970
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -3977,7 +3977,7 @@ function gateExclusion(gated) {
|
|
|
3977
3977
|
return (vtxo) => {
|
|
3978
3978
|
const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
|
|
3979
3979
|
if (type === void 0) return void 0;
|
|
3980
|
-
if (!
|
|
3980
|
+
if (!chunkUCSTNXB4_cjs.contractHandlers.has(type)) {
|
|
3981
3981
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
3982
3982
|
}
|
|
3983
3983
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -4013,7 +4013,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
4013
4013
|
continue;
|
|
4014
4014
|
}
|
|
4015
4015
|
for (const v of vtxos) {
|
|
4016
|
-
if (!
|
|
4016
|
+
if (!chunkUJTYUYY4_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
|
|
4017
4017
|
out.add(`${v.txid}:${v.vout}`);
|
|
4018
4018
|
}
|
|
4019
4019
|
}
|
|
@@ -4048,10 +4048,10 @@ function byValueDescending(vtxos) {
|
|
|
4048
4048
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
4049
4049
|
}
|
|
4050
4050
|
async function fetchTimeHeight(wallet) {
|
|
4051
|
-
return
|
|
4051
|
+
return chunkUJTYUYY4_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
4052
4052
|
}
|
|
4053
4053
|
function canMigrateBySend(vtxo, now) {
|
|
4054
|
-
if (!
|
|
4054
|
+
if (!chunkUJTYUYY4_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
4055
4055
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
4056
4056
|
}
|
|
4057
4057
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -4059,7 +4059,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
4059
4059
|
if (vtxo.isSwept) return -Infinity;
|
|
4060
4060
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
4061
4061
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
4062
|
-
return
|
|
4062
|
+
return chunkUJTYUYY4_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
4063
4063
|
}
|
|
4064
4064
|
return Infinity;
|
|
4065
4065
|
};
|
|
@@ -4086,7 +4086,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
4086
4086
|
const payable = [];
|
|
4087
4087
|
const net = /* @__PURE__ */ new Map();
|
|
4088
4088
|
for (const vtxo of vtxos) {
|
|
4089
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4089
|
+
const inputFee = estimator.evalOffchainInput(chunkUJTYUYY4_cjs.toOffchainInputFeeParams(vtxo));
|
|
4090
4090
|
if (inputFee.satoshis >= vtxo.value) {
|
|
4091
4091
|
continue;
|
|
4092
4092
|
}
|
|
@@ -4112,7 +4112,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
4112
4112
|
}
|
|
4113
4113
|
const outputFee = estimator.evalOffchainOutput({
|
|
4114
4114
|
amount: subtotal,
|
|
4115
|
-
script: base.hex.encode(
|
|
4115
|
+
script: base.hex.encode(chunkUJTYUYY4_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4116
4116
|
});
|
|
4117
4117
|
return subtotal - BigInt(outputFee.satoshis);
|
|
4118
4118
|
}
|
|
@@ -4130,10 +4130,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
4130
4130
|
};
|
|
4131
4131
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
4132
4132
|
return vtxos.filter((vtxo) => {
|
|
4133
|
-
if (
|
|
4133
|
+
if (chunkUJTYUYY4_cjs.canRecoverOnchain(vtxo, now)) {
|
|
4134
4134
|
return true;
|
|
4135
4135
|
}
|
|
4136
|
-
if (
|
|
4136
|
+
if (chunkUJTYUYY4_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
4137
4137
|
return true;
|
|
4138
4138
|
}
|
|
4139
4139
|
return false;
|
|
@@ -4165,7 +4165,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
4165
4165
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
4166
4166
|
if (vtxo.isUnrolled) return false;
|
|
4167
4167
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
4168
|
-
const expiresAt =
|
|
4168
|
+
const expiresAt = chunkUJTYUYY4_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
4169
4169
|
if (expiresAt === void 0) return false;
|
|
4170
4170
|
const now = Date.now();
|
|
4171
4171
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -4176,7 +4176,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
4176
4176
|
return vtxos.filter(
|
|
4177
4177
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
4178
4178
|
// property and would otherwise re-admit an exited coin on its own.
|
|
4179
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
4179
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkUJTYUYY4_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
4180
4180
|
);
|
|
4181
4181
|
}
|
|
4182
4182
|
function isMigrationCapable(wallet) {
|
|
@@ -4775,11 +4775,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
4775
4775
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
4776
4776
|
);
|
|
4777
4777
|
}
|
|
4778
|
-
const tx = new
|
|
4778
|
+
const tx = new chunkUJTYUYY4_cjs.Transaction();
|
|
4779
4779
|
for (const utxo of expiredUtxos) {
|
|
4780
|
-
const utxoScript =
|
|
4780
|
+
const utxoScript = chunkUJTYUYY4_cjs.VtxoScript.decode(utxo.tapTree);
|
|
4781
4781
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
4782
|
-
(leaf) =>
|
|
4782
|
+
(leaf) => chunkUJTYUYY4_cjs.CSVMultisigTapscript.isScriptValid(chunkUJTYUYY4_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
4783
4783
|
);
|
|
4784
4784
|
if (!utxoExitLeaf) {
|
|
4785
4785
|
throw new Error(
|
|
@@ -4794,7 +4794,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4794
4794
|
amount: BigInt(utxo.value)
|
|
4795
4795
|
},
|
|
4796
4796
|
tapLeafScript: [utxoExitLeaf],
|
|
4797
|
-
sequence:
|
|
4797
|
+
sequence: chunkUJTYUYY4_cjs.getSequence(utxoExitLeaf)
|
|
4798
4798
|
});
|
|
4799
4799
|
}
|
|
4800
4800
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -5037,8 +5037,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5037
5037
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
5038
5038
|
if (cls.status === "CURRENT") continue;
|
|
5039
5039
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
5040
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
5041
|
-
const spendable = live.filter((v) => !
|
|
5040
|
+
const recoverable = live.filter((v) => v.isSwept && !chunkUJTYUYY4_cjs.hasTerminalSpend(v));
|
|
5041
|
+
const spendable = live.filter((v) => !chunkUJTYUYY4_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
5042
5042
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
5043
5043
|
let recoverableCount = 0;
|
|
5044
5044
|
let recoverableValue = 0;
|
|
@@ -5051,7 +5051,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5051
5051
|
awaitingSweepCount = spendable.length;
|
|
5052
5052
|
awaitingSweepValue = value;
|
|
5053
5053
|
for (const v of spendable) {
|
|
5054
|
-
const exp =
|
|
5054
|
+
const exp = chunkUJTYUYY4_cjs.toBatchExpiry(v);
|
|
5055
5055
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
5056
5056
|
nextSweepEta = exp;
|
|
5057
5057
|
}
|
|
@@ -5312,7 +5312,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5312
5312
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
5313
5313
|
getBoardingTimelock() {
|
|
5314
5314
|
const wallet = this.getSweepWallet();
|
|
5315
|
-
const exitScript =
|
|
5315
|
+
const exitScript = chunkUJTYUYY4_cjs.CSVMultisigTapscript.decode(
|
|
5316
5316
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5317
5317
|
);
|
|
5318
5318
|
return exitScript.params.timelock;
|
|
@@ -5443,8 +5443,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5443
5443
|
* or doesn't carry the metadata.
|
|
5444
5444
|
*/
|
|
5445
5445
|
extractSpentOutpoint(error) {
|
|
5446
|
-
const ark =
|
|
5447
|
-
if (!
|
|
5446
|
+
const ark = chunkUJTYUYY4_cjs.maybeArkError(error);
|
|
5447
|
+
if (!chunkUJTYUYY4_cjs.isArkError(ark, chunkUJTYUYY4_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5448
5448
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5449
5449
|
if (typeof raw !== "string") return void 0;
|
|
5450
5450
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -5634,7 +5634,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5634
5634
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
5635
5635
|
break;
|
|
5636
5636
|
}
|
|
5637
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5637
|
+
const inputFee = estimator.evalOffchainInput(chunkUJTYUYY4_cjs.toOffchainInputFeeParams(v));
|
|
5638
5638
|
if (inputFee.satoshis >= v.value) {
|
|
5639
5639
|
continue;
|
|
5640
5640
|
}
|
|
@@ -5654,7 +5654,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5654
5654
|
const arkAddress = await this.wallet.getAddress();
|
|
5655
5655
|
const outputFee = estimator.evalOffchainOutput({
|
|
5656
5656
|
amount: totalAmount,
|
|
5657
|
-
script: base.hex.encode(
|
|
5657
|
+
script: base.hex.encode(chunkUJTYUYY4_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
5658
5658
|
});
|
|
5659
5659
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
5660
5660
|
if (totalAmount < dustAmount) return;
|
|
@@ -5734,7 +5734,7 @@ var ArkNote = class _ArkNote {
|
|
|
5734
5734
|
this.value = value;
|
|
5735
5735
|
this.HRP = HRP;
|
|
5736
5736
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
5737
|
-
this.vtxoScript = new
|
|
5737
|
+
this.vtxoScript = new chunkUJTYUYY4_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
5738
5738
|
const leaf = this.vtxoScript.leaves[0];
|
|
5739
5739
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
5740
5740
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -5901,7 +5901,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5901
5901
|
const privateKey = data.slice(1, 33);
|
|
5902
5902
|
const serverPubKey = data.slice(33, 65);
|
|
5903
5903
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
5904
|
-
const csvTimelock =
|
|
5904
|
+
const csvTimelock = chunkUJTYUYY4_cjs.sequenceToTimelock(sequence);
|
|
5905
5905
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
5906
5906
|
}
|
|
5907
5907
|
toString() {
|
|
@@ -5909,7 +5909,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5909
5909
|
data[0] = _ArkadeCash.Version;
|
|
5910
5910
|
data.set(this._privateKey, 1);
|
|
5911
5911
|
data.set(this._serverPubKey, 33);
|
|
5912
|
-
const sequence =
|
|
5912
|
+
const sequence = chunkUJTYUYY4_cjs.timelockToSequence(this.csvTimelock);
|
|
5913
5913
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
5914
5914
|
const words = base.bech32m.toWords(data);
|
|
5915
5915
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -5918,7 +5918,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5918
5918
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
5919
5919
|
}
|
|
5920
5920
|
get vtxoScript() {
|
|
5921
|
-
return new
|
|
5921
|
+
return new chunkUCSTNXB4_cjs.DefaultVtxo.Script({
|
|
5922
5922
|
pubKey: this._publicKey,
|
|
5923
5923
|
serverPubKey: this._serverPubKey,
|
|
5924
5924
|
csvTimelock: this.csvTimelock
|
|
@@ -6179,7 +6179,7 @@ async function captureExitBranch(params) {
|
|
|
6179
6179
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
6180
6180
|
if (nonCommitment.length > 0) {
|
|
6181
6181
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
6182
|
-
psbtByTxid.set(
|
|
6182
|
+
psbtByTxid.set(chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6183
6183
|
}
|
|
6184
6184
|
}
|
|
6185
6185
|
}
|
|
@@ -6222,10 +6222,10 @@ var IndexerExitDataSource = class {
|
|
|
6222
6222
|
while (hasMore) {
|
|
6223
6223
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
6224
6224
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
6225
|
-
{ pageIndex, pageSize:
|
|
6225
|
+
{ pageIndex, pageSize: chunkUJTYUYY4_cjs.DEFAULT_PAGE_SIZE }
|
|
6226
6226
|
);
|
|
6227
6227
|
chain.push(...page);
|
|
6228
|
-
hasMore = meta ? page.length ===
|
|
6228
|
+
hasMore = meta ? page.length === chunkUJTYUYY4_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6229
6229
|
pageIndex++;
|
|
6230
6230
|
}
|
|
6231
6231
|
return chain;
|
|
@@ -6237,12 +6237,12 @@ var IndexerExitDataSource = class {
|
|
|
6237
6237
|
while (hasMore) {
|
|
6238
6238
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
6239
6239
|
pageIndex,
|
|
6240
|
-
pageSize:
|
|
6240
|
+
pageSize: chunkUJTYUYY4_cjs.DEFAULT_PAGE_SIZE
|
|
6241
6241
|
});
|
|
6242
6242
|
for (const psbt of txs) {
|
|
6243
|
-
out.set(
|
|
6243
|
+
out.set(chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6244
6244
|
}
|
|
6245
|
-
hasMore = page ? txs.length ===
|
|
6245
|
+
hasMore = page ? txs.length === chunkUJTYUYY4_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6246
6246
|
pageIndex++;
|
|
6247
6247
|
}
|
|
6248
6248
|
return out;
|
|
@@ -6263,7 +6263,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
6263
6263
|
}
|
|
6264
6264
|
}
|
|
6265
6265
|
function psbtInputTxids(psbtBase64) {
|
|
6266
|
-
const tx =
|
|
6266
|
+
const tx = chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
6267
6267
|
const ids = [];
|
|
6268
6268
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
6269
6269
|
const txid = tx.getInput(i).txid;
|
|
@@ -6622,10 +6622,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
|
|
|
6622
6622
|
try {
|
|
6623
6623
|
info = await arkProvider.getInfo();
|
|
6624
6624
|
} catch (err) {
|
|
6625
|
-
if (opts?.requireLive || !
|
|
6625
|
+
if (opts?.requireLive || !chunkUJTYUYY4_cjs.isRetryableProviderError(err)) throw err;
|
|
6626
6626
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
6627
6627
|
if (!snapshot) {
|
|
6628
|
-
throw new
|
|
6628
|
+
throw new chunkUJTYUYY4_cjs.ProviderUnavailableError(
|
|
6629
6629
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
6630
6630
|
{ cause: err }
|
|
6631
6631
|
);
|
|
@@ -7015,7 +7015,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
7015
7015
|
return [...txids];
|
|
7016
7016
|
}
|
|
7017
7017
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
7018
|
-
const fromOldestVtxo = vtxos.map(
|
|
7018
|
+
const fromOldestVtxo = vtxos.map(chunkUJTYUYY4_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
7019
7019
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
7020
7020
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
7021
7021
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -7179,7 +7179,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7179
7179
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
7180
7180
|
withRecoverable: false
|
|
7181
7181
|
});
|
|
7182
|
-
const controlAssetRef = params.controlAssetId ?
|
|
7182
|
+
const controlAssetRef = params.controlAssetId ? chunkL4HZK4KK_cjs.AssetRef.fromId(chunkL4HZK4KK_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
7183
7183
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
7184
7184
|
let totalBtcSelected = 0n;
|
|
7185
7185
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -7192,8 +7192,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7192
7192
|
}
|
|
7193
7193
|
}
|
|
7194
7194
|
const groups = [];
|
|
7195
|
-
const issuedAssetOutput =
|
|
7196
|
-
const issuedAssetGroup =
|
|
7195
|
+
const issuedAssetOutput = chunkL4HZK4KK_cjs.AssetOutput.create(0, params.amount);
|
|
7196
|
+
const issuedAssetGroup = chunkL4HZK4KK_cjs.AssetGroup.create(
|
|
7197
7197
|
null,
|
|
7198
7198
|
controlAssetRef,
|
|
7199
7199
|
[],
|
|
@@ -7208,28 +7208,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7208
7208
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7209
7209
|
for (const asset of assets) {
|
|
7210
7210
|
if (asset.assetId !== assetId) continue;
|
|
7211
|
-
changeInputs.push(
|
|
7211
|
+
changeInputs.push(chunkL4HZK4KK_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7212
7212
|
}
|
|
7213
7213
|
}
|
|
7214
7214
|
groups.push(
|
|
7215
|
-
|
|
7216
|
-
|
|
7215
|
+
chunkL4HZK4KK_cjs.AssetGroup.create(
|
|
7216
|
+
chunkL4HZK4KK_cjs.AssetId.fromString(assetId),
|
|
7217
7217
|
null,
|
|
7218
7218
|
changeInputs,
|
|
7219
|
-
[
|
|
7219
|
+
[chunkL4HZK4KK_cjs.AssetOutput.create(0, amount)],
|
|
7220
7220
|
[]
|
|
7221
7221
|
)
|
|
7222
7222
|
);
|
|
7223
7223
|
}
|
|
7224
7224
|
}
|
|
7225
7225
|
const address = await this.wallet.getAddress();
|
|
7226
|
-
const outputAddress =
|
|
7226
|
+
const outputAddress = chunkUJTYUYY4_cjs.ArkAddress.decode(address);
|
|
7227
7227
|
const outputs = [
|
|
7228
7228
|
{
|
|
7229
7229
|
script: outputAddress.pkScript,
|
|
7230
7230
|
amount: BigInt(totalBtcSelected)
|
|
7231
7231
|
},
|
|
7232
|
-
Extension.create([
|
|
7232
|
+
Extension.create([chunkL4HZK4KK_cjs.Packet.create(groups)]).txOut()
|
|
7233
7233
|
];
|
|
7234
7234
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
7235
7235
|
coinSelection.inputs,
|
|
@@ -7237,7 +7237,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7237
7237
|
);
|
|
7238
7238
|
return {
|
|
7239
7239
|
arkTxId: arkTxid,
|
|
7240
|
-
assetId:
|
|
7240
|
+
assetId: chunkL4HZK4KK_cjs.AssetId.create(arkTxid, 0).toString()
|
|
7241
7241
|
};
|
|
7242
7242
|
}
|
|
7243
7243
|
/**
|
|
@@ -7309,16 +7309,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7309
7309
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7310
7310
|
for (const asset of assets) {
|
|
7311
7311
|
if (asset.assetId !== params.assetId) continue;
|
|
7312
|
-
reissueInputs.push(
|
|
7312
|
+
reissueInputs.push(chunkL4HZK4KK_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7313
7313
|
}
|
|
7314
7314
|
}
|
|
7315
7315
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7316
|
-
const reissueAssetIdObj =
|
|
7317
|
-
const reissueAssetGroup =
|
|
7316
|
+
const reissueAssetIdObj = chunkL4HZK4KK_cjs.AssetId.fromString(params.assetId);
|
|
7317
|
+
const reissueAssetGroup = chunkL4HZK4KK_cjs.AssetGroup.create(
|
|
7318
7318
|
reissueAssetIdObj,
|
|
7319
7319
|
null,
|
|
7320
7320
|
reissueInputs,
|
|
7321
|
-
[
|
|
7321
|
+
[chunkL4HZK4KK_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7322
7322
|
[]
|
|
7323
7323
|
);
|
|
7324
7324
|
const groups = [reissueAssetGroup];
|
|
@@ -7327,27 +7327,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7327
7327
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7328
7328
|
for (const asset of assets) {
|
|
7329
7329
|
if (asset.assetId !== assetId) continue;
|
|
7330
|
-
changeInputs.push(
|
|
7330
|
+
changeInputs.push(chunkL4HZK4KK_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7331
7331
|
}
|
|
7332
7332
|
}
|
|
7333
7333
|
groups.push(
|
|
7334
|
-
|
|
7335
|
-
|
|
7334
|
+
chunkL4HZK4KK_cjs.AssetGroup.create(
|
|
7335
|
+
chunkL4HZK4KK_cjs.AssetId.fromString(assetId),
|
|
7336
7336
|
null,
|
|
7337
7337
|
changeInputs,
|
|
7338
|
-
[
|
|
7338
|
+
[chunkL4HZK4KK_cjs.AssetOutput.create(0, amount)],
|
|
7339
7339
|
[]
|
|
7340
7340
|
)
|
|
7341
7341
|
);
|
|
7342
7342
|
}
|
|
7343
7343
|
const address = await this.wallet.getAddress();
|
|
7344
|
-
const outputAddress =
|
|
7344
|
+
const outputAddress = chunkUJTYUYY4_cjs.ArkAddress.decode(address);
|
|
7345
7345
|
const outputs = [
|
|
7346
7346
|
{
|
|
7347
7347
|
script: outputAddress.pkScript,
|
|
7348
7348
|
amount: BigInt(totalBtcSelected)
|
|
7349
7349
|
},
|
|
7350
|
-
Extension.create([
|
|
7350
|
+
Extension.create([chunkL4HZK4KK_cjs.Packet.create(groups)]).txOut()
|
|
7351
7351
|
];
|
|
7352
7352
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7353
7353
|
return arkTxid;
|
|
@@ -7414,27 +7414,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7414
7414
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7415
7415
|
for (const asset of assets) {
|
|
7416
7416
|
if (asset.assetId !== assetId) continue;
|
|
7417
|
-
changeInputs.push(
|
|
7417
|
+
changeInputs.push(chunkL4HZK4KK_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7418
7418
|
}
|
|
7419
7419
|
}
|
|
7420
7420
|
groups.push(
|
|
7421
|
-
|
|
7422
|
-
|
|
7421
|
+
chunkL4HZK4KK_cjs.AssetGroup.create(
|
|
7422
|
+
chunkL4HZK4KK_cjs.AssetId.fromString(assetId),
|
|
7423
7423
|
null,
|
|
7424
7424
|
changeInputs,
|
|
7425
|
-
amount > 0n ? [
|
|
7425
|
+
amount > 0n ? [chunkL4HZK4KK_cjs.AssetOutput.create(0, amount)] : [],
|
|
7426
7426
|
[]
|
|
7427
7427
|
)
|
|
7428
7428
|
);
|
|
7429
7429
|
}
|
|
7430
7430
|
const address = await this.wallet.getAddress();
|
|
7431
|
-
const outputAddress =
|
|
7431
|
+
const outputAddress = chunkUJTYUYY4_cjs.ArkAddress.decode(address);
|
|
7432
7432
|
const outputs = [
|
|
7433
7433
|
{
|
|
7434
7434
|
script: outputAddress.pkScript,
|
|
7435
7435
|
amount: BigInt(totalBtcSelected)
|
|
7436
7436
|
},
|
|
7437
|
-
Extension.create([
|
|
7437
|
+
Extension.create([chunkL4HZK4KK_cjs.Packet.create(groups)]).txOut()
|
|
7438
7438
|
];
|
|
7439
7439
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7440
7440
|
return arkTxid;
|
|
@@ -7459,7 +7459,7 @@ function castMetadata(metadata) {
|
|
|
7459
7459
|
} else {
|
|
7460
7460
|
throw new Error("Invalid metadata value type");
|
|
7461
7461
|
}
|
|
7462
|
-
md.push(
|
|
7462
|
+
md.push(chunkL4HZK4KK_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7463
7463
|
}
|
|
7464
7464
|
return md;
|
|
7465
7465
|
}
|
|
@@ -7480,10 +7480,10 @@ var DelegateManagerImpl = class {
|
|
|
7480
7480
|
if (vtxos.length === 0) {
|
|
7481
7481
|
return { delegated: [], failed: [] };
|
|
7482
7482
|
}
|
|
7483
|
-
const destinationScript =
|
|
7483
|
+
const destinationScript = chunkUJTYUYY4_cjs.ArkAddress.decode(destination).pkScript;
|
|
7484
7484
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
7485
7485
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
7486
|
-
const eligible = vtxos.map(
|
|
7486
|
+
const eligible = vtxos.map(chunkUJTYUYY4_cjs.normalizeVtxo).filter(
|
|
7487
7487
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7488
7488
|
);
|
|
7489
7489
|
if (eligible.length === 0) {
|
|
@@ -7512,11 +7512,11 @@ var DelegateManagerImpl = class {
|
|
|
7512
7512
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7513
7513
|
let recoverableVtxos = [];
|
|
7514
7514
|
for (const vtxo of eligible) {
|
|
7515
|
-
if (
|
|
7515
|
+
if (chunkUJTYUYY4_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7516
7516
|
recoverableVtxos.push(vtxo);
|
|
7517
7517
|
continue;
|
|
7518
7518
|
}
|
|
7519
|
-
const expiry =
|
|
7519
|
+
const expiry = chunkUJTYUYY4_cjs.toBatchExpiry(vtxo);
|
|
7520
7520
|
if (!expiry) continue;
|
|
7521
7521
|
const dayKey = getDayTimestamp(expiry);
|
|
7522
7522
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -7581,7 +7581,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7581
7581
|
}
|
|
7582
7582
|
if (!delegateAt) {
|
|
7583
7583
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7584
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7584
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkUJTYUYY4_cjs.canRecoverOnchain(coin, now) && chunkUJTYUYY4_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkUJTYUYY4_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
7585
7585
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
7586
7586
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
7587
7587
|
} else {
|
|
@@ -7610,7 +7610,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7610
7610
|
let amount = 0n;
|
|
7611
7611
|
for (const coin of vtxos) {
|
|
7612
7612
|
const inputFee = estimator.evalOffchainInput({
|
|
7613
|
-
...
|
|
7613
|
+
...chunkUJTYUYY4_cjs.toOffchainInputFeeParams(coin),
|
|
7614
7614
|
type: "vtxo"
|
|
7615
7615
|
});
|
|
7616
7616
|
if (inputFee.value >= coin.value) {
|
|
@@ -7624,7 +7624,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7624
7624
|
const delegateFee = BigInt(Number(fee));
|
|
7625
7625
|
if (delegateFee > 0n) {
|
|
7626
7626
|
outputs.push({
|
|
7627
|
-
script:
|
|
7627
|
+
script: chunkUJTYUYY4_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
7628
7628
|
amount: delegateFee
|
|
7629
7629
|
});
|
|
7630
7630
|
}
|
|
@@ -7657,10 +7657,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7657
7657
|
destinationScript
|
|
7658
7658
|
);
|
|
7659
7659
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
7660
|
-
btcSigner.Address(
|
|
7660
|
+
btcSigner.Address(chunkUJTYUYY4_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
7661
7661
|
);
|
|
7662
7662
|
const forfeits = await Promise.all(
|
|
7663
|
-
vtxos.filter((v) => !
|
|
7663
|
+
vtxos.filter((v) => !chunkUJTYUYY4_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
7664
7664
|
const forfeit = await makeDelegateForfeitTx(
|
|
7665
7665
|
coin,
|
|
7666
7666
|
dust,
|
|
@@ -7685,7 +7685,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
7685
7685
|
index: input.vout,
|
|
7686
7686
|
witnessUtxo: {
|
|
7687
7687
|
amount: BigInt(input.value),
|
|
7688
|
-
script:
|
|
7688
|
+
script: chunkUJTYUYY4_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
7689
7689
|
},
|
|
7690
7690
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
7691
7691
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -7743,7 +7743,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
7743
7743
|
expire_at: 0,
|
|
7744
7744
|
cosigners_public_keys: cosignerPubKeys
|
|
7745
7745
|
};
|
|
7746
|
-
const proof =
|
|
7746
|
+
const proof = chunkUJTYUYY4_cjs.Intent.create(message, coins, outputs);
|
|
7747
7747
|
const signedProof = await identity.sign(proof);
|
|
7748
7748
|
return {
|
|
7749
7749
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -7761,10 +7761,10 @@ function getDayTimestamp(timestamp) {
|
|
|
7761
7761
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
7762
7762
|
if (!vtxo.tapTree) return void 0;
|
|
7763
7763
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
7764
|
-
const vtxoScript =
|
|
7764
|
+
const vtxoScript = chunkUJTYUYY4_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
7765
7765
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
7766
|
-
const arkTapscript =
|
|
7767
|
-
if (!
|
|
7766
|
+
const arkTapscript = chunkUJTYUYY4_cjs.decodeTapscript(chunkUJTYUYY4_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
7767
|
+
if (!chunkUJTYUYY4_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
7768
7768
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
7769
7769
|
});
|
|
7770
7770
|
}
|
|
@@ -8045,7 +8045,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
|
|
|
8045
8045
|
};
|
|
8046
8046
|
}
|
|
8047
8047
|
function scriptFromArkAddress(address) {
|
|
8048
|
-
return base.hex.encode(
|
|
8048
|
+
return base.hex.encode(chunkUJTYUYY4_cjs.ArkAddress.decode(address).pkScript);
|
|
8049
8049
|
}
|
|
8050
8050
|
|
|
8051
8051
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -8540,7 +8540,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
8540
8540
|
}
|
|
8541
8541
|
async function getVtxosForContract(repo, contract) {
|
|
8542
8542
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
8543
|
-
return vtxos.map(
|
|
8543
|
+
return vtxos.map(chunkUJTYUYY4_cjs.normalizeVtxo);
|
|
8544
8544
|
}
|
|
8545
8545
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
8546
8546
|
if (repo.saveVtxosForScript) {
|
|
@@ -8682,7 +8682,7 @@ function decodeArkContract(encoded) {
|
|
|
8682
8682
|
}
|
|
8683
8683
|
function contractFromArkContract(encoded, options = {}) {
|
|
8684
8684
|
const parsed = decodeArkContract(encoded);
|
|
8685
|
-
const handler =
|
|
8685
|
+
const handler = chunkUCSTNXB4_cjs.contractHandlers.get(parsed.type);
|
|
8686
8686
|
if (!handler) {
|
|
8687
8687
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8688
8688
|
}
|
|
@@ -8696,9 +8696,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8696
8696
|
metadata: options.metadata
|
|
8697
8697
|
};
|
|
8698
8698
|
}
|
|
8699
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8699
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkUJTYUYY4_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8700
8700
|
const parsed = decodeArkContract(encoded);
|
|
8701
|
-
const handler =
|
|
8701
|
+
const handler = chunkUCSTNXB4_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8702
8702
|
const params = parsed.data;
|
|
8703
8703
|
const vtxoScript = handler.createScript(params);
|
|
8704
8704
|
return {
|
|
@@ -8952,9 +8952,9 @@ var ContractWatcher = class {
|
|
|
8952
8952
|
this.connectionState = "connected";
|
|
8953
8953
|
this.reconnectAttempts = 0;
|
|
8954
8954
|
this.listenLoop().catch((e) => {
|
|
8955
|
-
if (
|
|
8955
|
+
if (chunkUJTYUYY4_cjs.isEventSourceError(e)) {
|
|
8956
8956
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8957
|
-
} else if (!
|
|
8957
|
+
} else if (!chunkUJTYUYY4_cjs.isEventSourceUnavailableError(e)) {
|
|
8958
8958
|
console.error(e);
|
|
8959
8959
|
}
|
|
8960
8960
|
this.connectionState = "disconnected";
|
|
@@ -8966,7 +8966,7 @@ var ContractWatcher = class {
|
|
|
8966
8966
|
this.scheduleReconnect();
|
|
8967
8967
|
});
|
|
8968
8968
|
} catch (error) {
|
|
8969
|
-
if (!
|
|
8969
|
+
if (!chunkUJTYUYY4_cjs.isEventSourceUnavailableError(error)) {
|
|
8970
8970
|
console.error("ContractWatcher connection failed:", error);
|
|
8971
8971
|
}
|
|
8972
8972
|
this.connectionState = "disconnected";
|
|
@@ -8992,7 +8992,7 @@ var ContractWatcher = class {
|
|
|
8992
8992
|
* slower; what it loses is push latency.
|
|
8993
8993
|
*/
|
|
8994
8994
|
reportEventSourceUnavailable(error) {
|
|
8995
|
-
if (!
|
|
8995
|
+
if (!chunkUJTYUYY4_cjs.isEventSourceUnavailableError(error)) return false;
|
|
8996
8996
|
if (!this.eventSourceReported) {
|
|
8997
8997
|
this.eventSourceReported = true;
|
|
8998
8998
|
console.warn(
|
|
@@ -9208,14 +9208,14 @@ var ContractWatcher = class {
|
|
|
9208
9208
|
const timestamp = Date.now();
|
|
9209
9209
|
if (update.newVtxos?.length) {
|
|
9210
9210
|
this.processSubscriptionVtxos(
|
|
9211
|
-
update.newVtxos.map(
|
|
9211
|
+
update.newVtxos.map(chunkUJTYUYY4_cjs.normalizeVtxo),
|
|
9212
9212
|
"vtxo_received",
|
|
9213
9213
|
timestamp
|
|
9214
9214
|
);
|
|
9215
9215
|
}
|
|
9216
9216
|
if (update.spentVtxos?.length) {
|
|
9217
9217
|
this.processSubscriptionVtxos(
|
|
9218
|
-
update.spentVtxos.map(
|
|
9218
|
+
update.spentVtxos.map(chunkUJTYUYY4_cjs.normalizeVtxo),
|
|
9219
9219
|
"vtxo_spent",
|
|
9220
9220
|
timestamp
|
|
9221
9221
|
);
|
|
@@ -9310,7 +9310,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
|
|
|
9310
9310
|
(s) => !isTerminalIntentState(s)
|
|
9311
9311
|
);
|
|
9312
9312
|
function isConsumed(vtxo) {
|
|
9313
|
-
return vtxo !== void 0 &&
|
|
9313
|
+
return vtxo !== void 0 && chunkUJTYUYY4_cjs.hasTerminalSpend(vtxo);
|
|
9314
9314
|
}
|
|
9315
9315
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
9316
9316
|
if (isTerminalIntentState(intent.state)) return void 0;
|
|
@@ -9353,7 +9353,7 @@ async function reconcileIntents(deps) {
|
|
|
9353
9353
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
9354
9354
|
if (outpoints.length > 0) {
|
|
9355
9355
|
try {
|
|
9356
|
-
const { vtxos } = await
|
|
9356
|
+
const { vtxos } = await chunkUJTYUYY4_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
9357
9357
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
9358
9358
|
} catch (e) {
|
|
9359
9359
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9527,7 +9527,7 @@ var ContractManager = class _ContractManager {
|
|
|
9527
9527
|
await this.reconcileWatched();
|
|
9528
9528
|
this.markSyncOnline();
|
|
9529
9529
|
} catch (err) {
|
|
9530
|
-
if (!
|
|
9530
|
+
if (!chunkUJTYUYY4_cjs.isRetryableProviderError(err)) throw err;
|
|
9531
9531
|
this.markSyncDegraded(err);
|
|
9532
9532
|
}
|
|
9533
9533
|
this.initialized = true;
|
|
@@ -9659,7 +9659,7 @@ var ContractManager = class _ContractManager {
|
|
|
9659
9659
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9660
9660
|
const to = watermark + lookAhead.size;
|
|
9661
9661
|
const deps = lookAhead.candidateDeps();
|
|
9662
|
-
const handlers =
|
|
9662
|
+
const handlers = chunkUCSTNXB4_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkUCSTNXB4_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9663
9663
|
const band = /* @__PURE__ */ new Map();
|
|
9664
9664
|
for (let index = from; index <= to; index++) {
|
|
9665
9665
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9670,7 +9670,7 @@ var ContractManager = class _ContractManager {
|
|
|
9670
9670
|
index,
|
|
9671
9671
|
params: {
|
|
9672
9672
|
...candidate,
|
|
9673
|
-
...
|
|
9673
|
+
...chunkUCSTNXB4_cjs.speculativeReceiveMetadata(descriptor)
|
|
9674
9674
|
}
|
|
9675
9675
|
});
|
|
9676
9676
|
}
|
|
@@ -9732,7 +9732,7 @@ var ContractManager = class _ContractManager {
|
|
|
9732
9732
|
});
|
|
9733
9733
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9734
9734
|
} catch (err) {
|
|
9735
|
-
if (!
|
|
9735
|
+
if (!chunkUJTYUYY4_cjs.isRetryableProviderError(err)) throw err;
|
|
9736
9736
|
this.markSyncDegraded(err);
|
|
9737
9737
|
}
|
|
9738
9738
|
}
|
|
@@ -9782,7 +9782,7 @@ var ContractManager = class _ContractManager {
|
|
|
9782
9782
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9783
9783
|
this.markSyncOnline();
|
|
9784
9784
|
} catch (err) {
|
|
9785
|
-
if (!
|
|
9785
|
+
if (!chunkUJTYUYY4_cjs.isRetryableProviderError(err)) throw err;
|
|
9786
9786
|
this.markSyncDegraded(err);
|
|
9787
9787
|
}
|
|
9788
9788
|
await this.watcher.addContract(contract);
|
|
@@ -9819,7 +9819,7 @@ var ContractManager = class _ContractManager {
|
|
|
9819
9819
|
return result;
|
|
9820
9820
|
}
|
|
9821
9821
|
async upsertContractRow(params) {
|
|
9822
|
-
const handler =
|
|
9822
|
+
const handler = chunkUCSTNXB4_cjs.contractHandlers.get(params.type);
|
|
9823
9823
|
if (!handler) {
|
|
9824
9824
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9825
9825
|
}
|
|
@@ -9919,7 +9919,7 @@ var ContractManager = class _ContractManager {
|
|
|
9919
9919
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
9920
9920
|
);
|
|
9921
9921
|
}
|
|
9922
|
-
const registered =
|
|
9922
|
+
const registered = chunkUCSTNXB4_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkUCSTNXB4_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
9923
9923
|
const discoverables = [
|
|
9924
9924
|
...registered.filter((h) => h.type === "boarding"),
|
|
9925
9925
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -10054,7 +10054,7 @@ var ContractManager = class _ContractManager {
|
|
|
10054
10054
|
await this.syncContracts({ contracts, pageSize });
|
|
10055
10055
|
this.markSyncOnline();
|
|
10056
10056
|
} catch (err) {
|
|
10057
|
-
if (!
|
|
10057
|
+
if (!chunkUJTYUYY4_cjs.isRetryableProviderError(err)) throw err;
|
|
10058
10058
|
this.markSyncDegraded(err);
|
|
10059
10059
|
}
|
|
10060
10060
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -10075,7 +10075,7 @@ var ContractManager = class _ContractManager {
|
|
|
10075
10075
|
}
|
|
10076
10076
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
10077
10077
|
return vtxos.map(
|
|
10078
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
10078
|
+
(vtxo) => extendVirtualCoinForContract(chunkUJTYUYY4_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
10079
10079
|
);
|
|
10080
10080
|
}
|
|
10081
10081
|
/** @inheritdoc */
|
|
@@ -10119,14 +10119,14 @@ var ContractManager = class _ContractManager {
|
|
|
10119
10119
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
10120
10120
|
const asking = vtxos.filter((vtxo) => {
|
|
10121
10121
|
const contract = byScript.get(vtxo.script);
|
|
10122
|
-
return contract !== void 0 &&
|
|
10122
|
+
return contract !== void 0 && chunkUCSTNXB4_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
10123
10123
|
});
|
|
10124
10124
|
if (asking.length === 0) return refused;
|
|
10125
10125
|
const tip = await this.currentChainTip();
|
|
10126
10126
|
const walletKey = await walletPubKey?.();
|
|
10127
10127
|
for (const vtxo of asking) {
|
|
10128
10128
|
const contract = byScript.get(vtxo.script);
|
|
10129
|
-
const handler =
|
|
10129
|
+
const handler = chunkUCSTNXB4_cjs.contractHandlers.get(contract.type);
|
|
10130
10130
|
if (!handler?.assertSpendableNow) continue;
|
|
10131
10131
|
const context = {
|
|
10132
10132
|
collaborative: true,
|
|
@@ -10141,7 +10141,7 @@ var ContractManager = class _ContractManager {
|
|
|
10141
10141
|
// the next handler to answer a CSV question would meet a
|
|
10142
10142
|
// TypeError instead of a `false`. Carry the coin only when it
|
|
10143
10143
|
// really is one.
|
|
10144
|
-
vtxo:
|
|
10144
|
+
vtxo: chunkUJTYUYY4_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
10145
10145
|
};
|
|
10146
10146
|
try {
|
|
10147
10147
|
await handler.assertSpendableNow(
|
|
@@ -10297,7 +10297,7 @@ var ContractManager = class _ContractManager {
|
|
|
10297
10297
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
10298
10298
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10299
10299
|
if (!contract) return [];
|
|
10300
|
-
const handler =
|
|
10300
|
+
const handler = chunkUCSTNXB4_cjs.contractHandlers.get(contract.type);
|
|
10301
10301
|
if (!handler) return [];
|
|
10302
10302
|
const script = handler.createScript(contract.params);
|
|
10303
10303
|
const tip = await this.currentChainTip();
|
|
@@ -10325,7 +10325,7 @@ var ContractManager = class _ContractManager {
|
|
|
10325
10325
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
10326
10326
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10327
10327
|
if (!contract) return [];
|
|
10328
|
-
const handler =
|
|
10328
|
+
const handler = chunkUCSTNXB4_cjs.contractHandlers.get(contract.type);
|
|
10329
10329
|
if (!handler) return [];
|
|
10330
10330
|
const script = handler.createScript(contract.params);
|
|
10331
10331
|
const context = {
|
|
@@ -10381,7 +10381,7 @@ var ContractManager = class _ContractManager {
|
|
|
10381
10381
|
}
|
|
10382
10382
|
async refreshOutpoints(outpoints) {
|
|
10383
10383
|
if (outpoints.length === 0) return;
|
|
10384
|
-
const { vtxos } = await
|
|
10384
|
+
const { vtxos } = await chunkUJTYUYY4_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
10385
10385
|
outpoints
|
|
10386
10386
|
});
|
|
10387
10387
|
if (vtxos.length === 0) return;
|
|
@@ -10460,7 +10460,7 @@ var ContractManager = class _ContractManager {
|
|
|
10460
10460
|
break;
|
|
10461
10461
|
}
|
|
10462
10462
|
} catch (err) {
|
|
10463
|
-
if (!
|
|
10463
|
+
if (!chunkUJTYUYY4_cjs.isRetryableProviderError(err)) throw err;
|
|
10464
10464
|
this.markSyncDegraded(err);
|
|
10465
10465
|
}
|
|
10466
10466
|
this.emitEvent(event);
|
|
@@ -10539,7 +10539,7 @@ var ContractManager = class _ContractManager {
|
|
|
10539
10539
|
*/
|
|
10540
10540
|
async reconcilePendingFrontier(contracts) {
|
|
10541
10541
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
10542
|
-
const vtxos = await
|
|
10542
|
+
const vtxos = await chunkUJTYUYY4_cjs.getAllNormalizedVtxos(
|
|
10543
10543
|
this.config.indexerProvider,
|
|
10544
10544
|
contracts.map((c) => c.script),
|
|
10545
10545
|
{ pendingOnly: true }
|
|
@@ -10622,7 +10622,7 @@ var ContractManager = class _ContractManager {
|
|
|
10622
10622
|
}
|
|
10623
10623
|
return result;
|
|
10624
10624
|
}
|
|
10625
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10625
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkUJTYUYY4_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
10626
10626
|
if (contracts.length === 0) {
|
|
10627
10627
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
10628
10628
|
}
|
|
@@ -10638,7 +10638,7 @@ var ContractManager = class _ContractManager {
|
|
|
10638
10638
|
before: syncWindow.before
|
|
10639
10639
|
}
|
|
10640
10640
|
} : {};
|
|
10641
|
-
const vtxos = await
|
|
10641
|
+
const vtxos = await chunkUJTYUYY4_cjs.getAllNormalizedVtxos(
|
|
10642
10642
|
this.config.indexerProvider,
|
|
10643
10643
|
contracts.map((c) => c.script),
|
|
10644
10644
|
{ ...windowOpts, pageSize }
|
|
@@ -10783,7 +10783,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
10783
10783
|
const s = base.hex.decode(t.s);
|
|
10784
10784
|
return [cb, s];
|
|
10785
10785
|
};
|
|
10786
|
-
var deserializeVtxo = (o) =>
|
|
10786
|
+
var deserializeVtxo = (o) => chunkUJTYUYY4_cjs.normalizeVtxo({
|
|
10787
10787
|
...o,
|
|
10788
10788
|
createdAt: new Date(o.createdAt),
|
|
10789
10789
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -11606,7 +11606,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
11606
11606
|
*/
|
|
11607
11607
|
materializeDescriptorAt(index) {
|
|
11608
11608
|
const descriptor = this.identity.descriptor;
|
|
11609
|
-
const network =
|
|
11609
|
+
const network = chunkUCSTNXB4_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
11610
11610
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
11611
11611
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
11612
11612
|
if (!keyInfo?.keyExpression) {
|
|
@@ -11754,7 +11754,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11754
11754
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
11755
11755
|
if (!provider) return void 0;
|
|
11756
11756
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
11757
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
11757
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkUCSTNXB4_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
11758
11758
|
const factoryOpts = {
|
|
11759
11759
|
walletRepository: setup.walletRepository,
|
|
11760
11760
|
contractRepository: setup.contractRepository,
|
|
@@ -11955,7 +11955,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11955
11955
|
};
|
|
11956
11956
|
function deriveLeafPubkey(descriptor) {
|
|
11957
11957
|
try {
|
|
11958
|
-
return
|
|
11958
|
+
return chunkUCSTNXB4_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
11959
11959
|
} catch (e) {
|
|
11960
11960
|
throw new NonRangeableDescriptorError(
|
|
11961
11961
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -11967,7 +11967,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11967
11967
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
11968
11968
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
11969
11969
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
11970
|
-
const csvTimelock =
|
|
11970
|
+
const csvTimelock = chunkUJTYUYY4_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
11971
11971
|
const base$1 = {
|
|
11972
11972
|
script: base.hex.encode(tapscript.pkScript),
|
|
11973
11973
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -11978,11 +11978,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11978
11978
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
11979
11979
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
11980
11980
|
metadata: {
|
|
11981
|
-
...tagSource && { source:
|
|
11981
|
+
...tagSource && { source: chunkUCSTNXB4_cjs.WALLET_RECEIVE_SOURCE },
|
|
11982
11982
|
signingDescriptor: descriptor
|
|
11983
11983
|
}
|
|
11984
11984
|
};
|
|
11985
|
-
const params = tapscript instanceof
|
|
11985
|
+
const params = tapscript instanceof chunkUCSTNXB4_cjs.DelegateVtxo.Script ? {
|
|
11986
11986
|
...base$1,
|
|
11987
11987
|
type: "delegate",
|
|
11988
11988
|
params: {
|
|
@@ -12003,10 +12003,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12003
12003
|
return { tapscript, params };
|
|
12004
12004
|
}
|
|
12005
12005
|
function rebuildTapscript(current, pubKey) {
|
|
12006
|
-
if (current instanceof
|
|
12007
|
-
return new
|
|
12006
|
+
if (current instanceof chunkUCSTNXB4_cjs.DelegateVtxo.Script) {
|
|
12007
|
+
return new chunkUCSTNXB4_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
12008
12008
|
}
|
|
12009
|
-
return new
|
|
12009
|
+
return new chunkUCSTNXB4_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
12010
12010
|
}
|
|
12011
12011
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
12012
12012
|
const candidates = await contractRepository.getContracts({
|
|
@@ -12015,7 +12015,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
12015
12015
|
});
|
|
12016
12016
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
12017
12017
|
const matching = candidates.filter(
|
|
12018
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12018
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkUCSTNXB4_cjs.WALLET_RECEIVE_SOURCE
|
|
12019
12019
|
).sort((a, b) => {
|
|
12020
12020
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12021
12021
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12071,7 +12071,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12071
12071
|
}
|
|
12072
12072
|
};
|
|
12073
12073
|
for (const vtxo of vtxos) {
|
|
12074
|
-
if (
|
|
12074
|
+
if (chunkUJTYUYY4_cjs.hasTerminalSpend(vtxo)) continue;
|
|
12075
12075
|
addAssets(owned, vtxo);
|
|
12076
12076
|
if (vtxo.isUnrolled) {
|
|
12077
12077
|
unrolled += vtxo.value;
|
|
@@ -12081,11 +12081,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12081
12081
|
pendingRecovery += vtxo.value;
|
|
12082
12082
|
continue;
|
|
12083
12083
|
}
|
|
12084
|
-
if (
|
|
12084
|
+
if (chunkUJTYUYY4_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12085
12085
|
recoverable += vtxo.value;
|
|
12086
12086
|
continue;
|
|
12087
12087
|
}
|
|
12088
|
-
if (!
|
|
12088
|
+
if (!chunkUJTYUYY4_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
12089
12089
|
if (vtxo.isPreconfirmed) {
|
|
12090
12090
|
preconfirmed += vtxo.value;
|
|
12091
12091
|
} else {
|
|
@@ -12255,12 +12255,12 @@ var InputSignerRouter = class {
|
|
|
12255
12255
|
};
|
|
12256
12256
|
|
|
12257
12257
|
// src/wallet/wallet.ts
|
|
12258
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
12258
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkUJTYUYY4_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
12259
12259
|
function intentProofJobs(coins) {
|
|
12260
12260
|
if (coins.length === 0) return [];
|
|
12261
12261
|
const coinJobs = coins.map((coin, i) => ({
|
|
12262
12262
|
index: i + 1,
|
|
12263
|
-
lookupScript:
|
|
12263
|
+
lookupScript: chunkUJTYUYY4_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12264
12264
|
}));
|
|
12265
12265
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12266
12266
|
}
|
|
@@ -12292,7 +12292,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
12292
12292
|
const seen = /* @__PURE__ */ new Set();
|
|
12293
12293
|
const deduped = [];
|
|
12294
12294
|
for (const timelock of timelocks) {
|
|
12295
|
-
const sequence =
|
|
12295
|
+
const sequence = chunkUJTYUYY4_cjs.timelockToSequence(timelock).toString();
|
|
12296
12296
|
if (seen.has(sequence)) continue;
|
|
12297
12297
|
seen.add(sequence);
|
|
12298
12298
|
deduped.push(timelock);
|
|
@@ -12309,7 +12309,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12309
12309
|
state: "active"
|
|
12310
12310
|
});
|
|
12311
12311
|
const newest = candidates.filter(
|
|
12312
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12312
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkUCSTNXB4_cjs.WALLET_RECEIVE_SOURCE
|
|
12313
12313
|
).sort((a, b) => {
|
|
12314
12314
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12315
12315
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12317,7 +12317,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12317
12317
|
if (!newest?.params.pubKey) return baseline;
|
|
12318
12318
|
try {
|
|
12319
12319
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
12320
|
-
return new
|
|
12320
|
+
return new chunkUCSTNXB4_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
12321
12321
|
} catch (e) {
|
|
12322
12322
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
12323
12323
|
return baseline;
|
|
@@ -12336,10 +12336,10 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
12336
12336
|
if (vtxo.isUnrolled) {
|
|
12337
12337
|
return !!f.withUnrolled;
|
|
12338
12338
|
}
|
|
12339
|
-
if (
|
|
12339
|
+
if (chunkUJTYUYY4_cjs.hasTerminalSpend(vtxo)) {
|
|
12340
12340
|
return false;
|
|
12341
12341
|
}
|
|
12342
|
-
if (!f.withRecoverable &&
|
|
12342
|
+
if (!f.withRecoverable && chunkUJTYUYY4_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12343
12343
|
return false;
|
|
12344
12344
|
}
|
|
12345
12345
|
return true;
|
|
@@ -12690,7 +12690,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12690
12690
|
async getArkadeReader() {
|
|
12691
12691
|
const indexer = this.indexerProvider;
|
|
12692
12692
|
return {
|
|
12693
|
-
getVtxos: (opts) =>
|
|
12693
|
+
getVtxos: (opts) => chunkUJTYUYY4_cjs.getNormalizedVtxos(indexer, opts),
|
|
12694
12694
|
getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
|
|
12695
12695
|
};
|
|
12696
12696
|
}
|
|
@@ -12746,7 +12746,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12746
12746
|
*/
|
|
12747
12747
|
static async setupWalletConfig(config, pubKey) {
|
|
12748
12748
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
12749
|
-
const arkProvider = config.arkProvider || new
|
|
12749
|
+
const arkProvider = config.arkProvider || new chunkUJTYUYY4_cjs.RestArkProvider(arkadeServerUrl);
|
|
12750
12750
|
let indexerProvider = config.indexerProvider;
|
|
12751
12751
|
if (!indexerProvider) {
|
|
12752
12752
|
let indexerUrl = config.indexerUrl;
|
|
@@ -12763,7 +12763,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12763
12763
|
indexerUrl = arkadeServerUrl;
|
|
12764
12764
|
}
|
|
12765
12765
|
}
|
|
12766
|
-
indexerProvider = new
|
|
12766
|
+
indexerProvider = new chunkL4HZK4KK_cjs.RestIndexerProvider(indexerUrl);
|
|
12767
12767
|
}
|
|
12768
12768
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
12769
12769
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -12772,7 +12772,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12772
12772
|
source: serverInfoSource,
|
|
12773
12773
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
12774
12774
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
12775
|
-
const network =
|
|
12775
|
+
const network = chunkUJTYUYY4_cjs.networkFromArkadeInfo(info);
|
|
12776
12776
|
if ("descriptor" in config.identity) {
|
|
12777
12777
|
const descriptor = config.identity.descriptor;
|
|
12778
12778
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -12812,18 +12812,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12812
12812
|
value: info.boardingExitDelay,
|
|
12813
12813
|
type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
|
|
12814
12814
|
};
|
|
12815
|
-
const serverPubKey =
|
|
12816
|
-
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) =>
|
|
12815
|
+
const serverPubKey = chunkUCSTNXB4_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
12816
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkUCSTNXB4_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunkUCSTNXB4_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
|
|
12817
12817
|
const offchainOptions = {
|
|
12818
12818
|
pubKey,
|
|
12819
12819
|
serverPubKey,
|
|
12820
12820
|
csvTimelock: exitTimelock
|
|
12821
12821
|
};
|
|
12822
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
12823
|
-
const boardingTapscript =
|
|
12822
|
+
const offchainTapscript = !delegatePubKey ? new chunkUCSTNXB4_cjs.DefaultVtxo.Script(offchainOptions) : new chunkUCSTNXB4_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
12823
|
+
const boardingTapscript = chunkUCSTNXB4_cjs.BoardingContractHandler.createScript({
|
|
12824
12824
|
pubKey: base.hex.encode(pubKey),
|
|
12825
12825
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12826
|
-
csvTimelock:
|
|
12826
|
+
csvTimelock: chunkUJTYUYY4_cjs.timelockToSequence(boardingTimelock).toString()
|
|
12827
12827
|
});
|
|
12828
12828
|
return {
|
|
12829
12829
|
arkProvider,
|
|
@@ -12990,7 +12990,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12990
12990
|
if (!filter?.withUnrolled) {
|
|
12991
12991
|
logExcludedVtxos(
|
|
12992
12992
|
"getSpendableVtxos",
|
|
12993
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
12993
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkUJTYUYY4_cjs.hasTerminalSpend(vtxo)),
|
|
12994
12994
|
[() => UNROLLED_REASON]
|
|
12995
12995
|
);
|
|
12996
12996
|
}
|
|
@@ -13133,7 +13133,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13133
13133
|
const response = await contractManager.getContractsWithVtxos();
|
|
13134
13134
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
13135
13135
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
13136
|
-
const resolveTxCreatedAt = (txids) =>
|
|
13136
|
+
const resolveTxCreatedAt = (txids) => chunkUJTYUYY4_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
13137
13137
|
return buildTransactionHistory(
|
|
13138
13138
|
allVtxos,
|
|
13139
13139
|
boardingTxs,
|
|
@@ -13227,7 +13227,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13227
13227
|
},
|
|
13228
13228
|
isUnrolled: true,
|
|
13229
13229
|
...boardingFacts,
|
|
13230
|
-
virtualStatus:
|
|
13230
|
+
virtualStatus: chunkUJTYUYY4_cjs.toVirtualStatus(boardingFacts),
|
|
13231
13231
|
spentBy: "",
|
|
13232
13232
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
13233
13233
|
script: scriptHex
|
|
@@ -13283,9 +13283,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13283
13283
|
async getBoardingTapscripts(allowedSigners) {
|
|
13284
13284
|
const byScript = /* @__PURE__ */ new Map();
|
|
13285
13285
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
13286
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
13286
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkUCSTNXB4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13287
13287
|
add(
|
|
13288
|
-
new
|
|
13288
|
+
new chunkUCSTNXB4_cjs.DefaultVtxo.Script({
|
|
13289
13289
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
13290
13290
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
13291
13291
|
csvTimelock: boardingCsv
|
|
@@ -13300,7 +13300,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13300
13300
|
for (const c of boardingContracts) {
|
|
13301
13301
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
13302
13302
|
try {
|
|
13303
|
-
add(
|
|
13303
|
+
add(chunkUCSTNXB4_cjs.BoardingContractHandler.createScript(c.params));
|
|
13304
13304
|
} catch (e) {
|
|
13305
13305
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
13306
13306
|
}
|
|
@@ -13338,7 +13338,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13338
13338
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
13339
13339
|
// not the wallet's current boarding timelock, which a signer
|
|
13340
13340
|
// rotation may have changed.
|
|
13341
|
-
csvTimelock:
|
|
13341
|
+
csvTimelock: chunkUJTYUYY4_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
13342
13342
|
coins: utxos
|
|
13343
13343
|
});
|
|
13344
13344
|
}
|
|
@@ -13471,7 +13471,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13471
13471
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
13472
13472
|
async fetchPendingTxs() {
|
|
13473
13473
|
const scripts = await this.getWalletScripts();
|
|
13474
|
-
const vtxos = await
|
|
13474
|
+
const vtxos = await chunkUJTYUYY4_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
13475
13475
|
return vtxos.filter(
|
|
13476
13476
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
13477
13477
|
).map((_) => _.arkTxId);
|
|
@@ -13502,7 +13502,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13502
13502
|
});
|
|
13503
13503
|
for (const contract of contracts) {
|
|
13504
13504
|
if (map.has(contract.script)) continue;
|
|
13505
|
-
const handler =
|
|
13505
|
+
const handler = chunkUCSTNXB4_cjs.contractHandlers.get(contract.type);
|
|
13506
13506
|
if (handler) {
|
|
13507
13507
|
const script = handler.createScript(contract.params);
|
|
13508
13508
|
map.set(contract.script, script);
|
|
@@ -13614,7 +13614,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13614
13614
|
}
|
|
13615
13615
|
});
|
|
13616
13616
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
13617
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
13617
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkUCSTNXB4_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
13618
13618
|
const baselineSigners = [
|
|
13619
13619
|
this.offchainTapscript.options.serverPubKey,
|
|
13620
13620
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -13622,8 +13622,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13622
13622
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
13623
13623
|
for (const serverPubKey of baselineSigners) {
|
|
13624
13624
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
13625
|
-
const csvTimelockStr =
|
|
13626
|
-
const defaultScript = new
|
|
13625
|
+
const csvTimelockStr = chunkUJTYUYY4_cjs.timelockToSequence(csvTimelock).toString();
|
|
13626
|
+
const defaultScript = new chunkUCSTNXB4_cjs.DefaultVtxo.Script({
|
|
13627
13627
|
pubKey: baselinePubkey,
|
|
13628
13628
|
serverPubKey,
|
|
13629
13629
|
csvTimelock
|
|
@@ -13644,7 +13644,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13644
13644
|
});
|
|
13645
13645
|
}
|
|
13646
13646
|
if (delegatePubKey) {
|
|
13647
|
-
const delegateScript = new
|
|
13647
|
+
const delegateScript = new chunkUCSTNXB4_cjs.DelegateVtxo.Script({
|
|
13648
13648
|
pubKey: baselinePubkey,
|
|
13649
13649
|
serverPubKey,
|
|
13650
13650
|
delegatePubKey,
|
|
@@ -13668,9 +13668,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13668
13668
|
}
|
|
13669
13669
|
}
|
|
13670
13670
|
}
|
|
13671
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
13671
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkUCSTNXB4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13672
13672
|
for (const serverPubKey of baselineSigners) {
|
|
13673
|
-
const baselineBoarding = new
|
|
13673
|
+
const baselineBoarding = new chunkUCSTNXB4_cjs.DefaultVtxo.Script({
|
|
13674
13674
|
pubKey: baselinePubkey,
|
|
13675
13675
|
serverPubKey,
|
|
13676
13676
|
csvTimelock: boardingCsvTimelock
|
|
@@ -13683,7 +13683,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13683
13683
|
params: {
|
|
13684
13684
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
13685
13685
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13686
|
-
csvTimelock:
|
|
13686
|
+
csvTimelock: chunkUJTYUYY4_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
13687
13687
|
},
|
|
13688
13688
|
script: boardingScriptHex,
|
|
13689
13689
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -13882,7 +13882,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13882
13882
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
13883
13883
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
13884
13884
|
csvTimelocks: this.walletContractTimelocks,
|
|
13885
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
13885
|
+
delegatePubKey: this.offchainTapscript instanceof chunkUCSTNXB4_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
13886
13886
|
};
|
|
13887
13887
|
}
|
|
13888
13888
|
_signerRouter;
|
|
@@ -14127,7 +14127,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14127
14127
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
14128
14128
|
const persisted = row?.metadata?.signingDescriptor;
|
|
14129
14129
|
if (typeof persisted === "string") return persisted;
|
|
14130
|
-
return
|
|
14130
|
+
return chunkUCSTNXB4_cjs.identityDescriptor(this.identity);
|
|
14131
14131
|
}
|
|
14132
14132
|
/**
|
|
14133
14133
|
* Build, persist and shape one address of `type` owned by `descriptor` —
|
|
@@ -14143,7 +14143,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14143
14143
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
14144
14144
|
if (type === "boarding") {
|
|
14145
14145
|
const built2 = this.buildBoardingContract(
|
|
14146
|
-
|
|
14146
|
+
chunkUCSTNXB4_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
14147
14147
|
descriptor,
|
|
14148
14148
|
tagSource
|
|
14149
14149
|
);
|
|
@@ -14188,11 +14188,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14188
14188
|
* {@link buildReceiveContract}.
|
|
14189
14189
|
*/
|
|
14190
14190
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
14191
|
-
const tapscript = new
|
|
14191
|
+
const tapscript = new chunkUCSTNXB4_cjs.DefaultVtxo.Script({
|
|
14192
14192
|
...this._boardingTapscript.options,
|
|
14193
14193
|
pubKey
|
|
14194
14194
|
});
|
|
14195
|
-
const csvTimelock = tapscript.options.csvTimelock ??
|
|
14195
|
+
const csvTimelock = tapscript.options.csvTimelock ?? chunkUCSTNXB4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14196
14196
|
return {
|
|
14197
14197
|
tapscript,
|
|
14198
14198
|
params: {
|
|
@@ -14200,13 +14200,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14200
14200
|
params: {
|
|
14201
14201
|
pubKey: base.hex.encode(pubKey),
|
|
14202
14202
|
serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
|
|
14203
|
-
csvTimelock:
|
|
14203
|
+
csvTimelock: chunkUJTYUYY4_cjs.timelockToSequence(csvTimelock).toString()
|
|
14204
14204
|
},
|
|
14205
14205
|
script: base.hex.encode(tapscript.pkScript),
|
|
14206
14206
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
14207
14207
|
state: "active",
|
|
14208
14208
|
metadata: {
|
|
14209
|
-
...tagSource && { source:
|
|
14209
|
+
...tagSource && { source: chunkUCSTNXB4_cjs.WALLET_RECEIVE_SOURCE },
|
|
14210
14210
|
signingDescriptor: descriptor
|
|
14211
14211
|
}
|
|
14212
14212
|
}
|
|
@@ -14235,7 +14235,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14235
14235
|
if (this._descriptorProvider instanceof HDDescriptorProvider) {
|
|
14236
14236
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
14237
14237
|
}
|
|
14238
|
-
return
|
|
14238
|
+
return chunkUCSTNXB4_cjs.identityDescriptor(this.identity);
|
|
14239
14239
|
}
|
|
14240
14240
|
/**
|
|
14241
14241
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -14331,7 +14331,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14331
14331
|
* the stable public API.
|
|
14332
14332
|
*/
|
|
14333
14333
|
async rotateServerSigner(newServerPubKey, checkpointTapscript) {
|
|
14334
|
-
const xonly =
|
|
14334
|
+
const xonly = chunkUCSTNXB4_cjs.toXOnly(newServerPubKey, "ark signer key");
|
|
14335
14335
|
const newServerUnrollScript = assertValidServerUnrollScript(
|
|
14336
14336
|
checkpointTapscript,
|
|
14337
14337
|
resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
|
|
@@ -14360,21 +14360,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14360
14360
|
const [currentBoardingRow] = await manager.getContracts({
|
|
14361
14361
|
script: currentBoardingScript
|
|
14362
14362
|
});
|
|
14363
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
14363
|
+
const newOffchain = this.offchainTapscript instanceof chunkUCSTNXB4_cjs.DelegateVtxo.Script ? new chunkUCSTNXB4_cjs.DelegateVtxo.Script({
|
|
14364
14364
|
...this.offchainTapscript.options,
|
|
14365
14365
|
serverPubKey: xonly
|
|
14366
|
-
}) : new
|
|
14366
|
+
}) : new chunkUCSTNXB4_cjs.DefaultVtxo.Script({
|
|
14367
14367
|
...this.offchainTapscript.options,
|
|
14368
14368
|
serverPubKey: xonly
|
|
14369
14369
|
});
|
|
14370
|
-
const newBoarding = new
|
|
14370
|
+
const newBoarding = new chunkUCSTNXB4_cjs.DefaultVtxo.Script({
|
|
14371
14371
|
...this._boardingTapscript.options,
|
|
14372
14372
|
serverPubKey: xonly
|
|
14373
14373
|
});
|
|
14374
|
-
const offchainCsv =
|
|
14374
|
+
const offchainCsv = chunkUJTYUYY4_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
14375
14375
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
14376
14376
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
14377
|
-
if (newOffchain instanceof
|
|
14377
|
+
if (newOffchain instanceof chunkUCSTNXB4_cjs.DelegateVtxo.Script) {
|
|
14378
14378
|
await manager.createContract({
|
|
14379
14379
|
type: "delegate",
|
|
14380
14380
|
params: {
|
|
@@ -14402,13 +14402,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14402
14402
|
metadata: currentOffchainRow?.metadata
|
|
14403
14403
|
});
|
|
14404
14404
|
}
|
|
14405
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
14405
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkUCSTNXB4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14406
14406
|
await manager.createContract({
|
|
14407
14407
|
type: "boarding",
|
|
14408
14408
|
params: {
|
|
14409
14409
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
14410
14410
|
serverPubKey: base.hex.encode(xonly),
|
|
14411
|
-
csvTimelock:
|
|
14411
|
+
csvTimelock: chunkUJTYUYY4_cjs.timelockToSequence(boardingCsv).toString()
|
|
14412
14412
|
},
|
|
14413
14413
|
script: base.hex.encode(newBoarding.pkScript),
|
|
14414
14414
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -14441,14 +14441,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14441
14441
|
_restoreInFlight;
|
|
14442
14442
|
_addPendingSpends(inputs) {
|
|
14443
14443
|
for (const input of inputs) {
|
|
14444
|
-
if (
|
|
14444
|
+
if (chunkUJTYUYY4_cjs.isVirtualCoin(input)) {
|
|
14445
14445
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
14446
14446
|
}
|
|
14447
14447
|
}
|
|
14448
14448
|
}
|
|
14449
14449
|
_removePendingSpends(inputs) {
|
|
14450
14450
|
for (const input of inputs) {
|
|
14451
|
-
if (
|
|
14451
|
+
if (chunkUJTYUYY4_cjs.isVirtualCoin(input)) {
|
|
14452
14452
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
14453
14453
|
}
|
|
14454
14454
|
}
|
|
@@ -14506,13 +14506,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14506
14506
|
const manager = await this.getContractManager();
|
|
14507
14507
|
const provider = this._descriptorProvider;
|
|
14508
14508
|
const hd = provider instanceof HDDescriptorProvider;
|
|
14509
|
-
const staticDescriptor = hd ? void 0 : await
|
|
14509
|
+
const staticDescriptor = hd ? void 0 : await chunkUCSTNXB4_cjs.identityDescriptor(this.identity);
|
|
14510
14510
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
14511
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14511
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkUCSTNXB4_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14512
14512
|
const arkInfo = await this.arkProvider.getInfo();
|
|
14513
|
-
const currentSignerPubKey =
|
|
14513
|
+
const currentSignerPubKey = chunkUCSTNXB4_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
14514
14514
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
14515
|
-
(s) =>
|
|
14515
|
+
(s) => chunkUCSTNXB4_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
14516
14516
|
);
|
|
14517
14517
|
const deps = {
|
|
14518
14518
|
indexerProvider: this.indexerProvider,
|
|
@@ -14527,7 +14527,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14527
14527
|
csvTimelocks: this.walletContractTimelocks,
|
|
14528
14528
|
// Boarding-exit CSV so the boarding handler can build its
|
|
14529
14529
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
14530
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
14530
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkUCSTNXB4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
14531
14531
|
delegatePubKey
|
|
14532
14532
|
};
|
|
14533
14533
|
const result = await manager.scanContracts({
|
|
@@ -14656,7 +14656,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14656
14656
|
throw new Error("Invalid configured public key");
|
|
14657
14657
|
}
|
|
14658
14658
|
const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
|
|
14659
|
-
const forfeitPubkey =
|
|
14659
|
+
const forfeitPubkey = chunkUCSTNXB4_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
|
|
14660
14660
|
const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
|
|
14661
14661
|
const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
|
|
14662
14662
|
const checkpointExitDelayOverrides = {
|
|
@@ -14806,7 +14806,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14806
14806
|
inputs: params.selectedVtxos,
|
|
14807
14807
|
changeAmount: BigInt(changeAmount)
|
|
14808
14808
|
};
|
|
14809
|
-
const outputAddress =
|
|
14809
|
+
const outputAddress = chunkUJTYUYY4_cjs.ArkAddress.decode(params.address);
|
|
14810
14810
|
assertRecipientArkadeAddress(
|
|
14811
14811
|
params.address,
|
|
14812
14812
|
outputAddress,
|
|
@@ -14872,13 +14872,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14872
14872
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
14873
14873
|
}
|
|
14874
14874
|
const offchainAddress = await this.getAddress();
|
|
14875
|
-
const offchainPkScript =
|
|
14875
|
+
const offchainPkScript = chunkUJTYUYY4_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
14876
14876
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
14877
14877
|
if (!params) {
|
|
14878
14878
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
14879
14879
|
const estimator = new Estimator(fees.intentFee);
|
|
14880
14880
|
let amount = 0;
|
|
14881
|
-
const exitScript =
|
|
14881
|
+
const exitScript = chunkUJTYUYY4_cjs.CSVMultisigTapscript.decode(
|
|
14882
14882
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
14883
14883
|
);
|
|
14884
14884
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -14907,7 +14907,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14907
14907
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
14908
14908
|
break;
|
|
14909
14909
|
}
|
|
14910
|
-
const inputFee = estimator.evalOffchainInput(
|
|
14910
|
+
const inputFee = estimator.evalOffchainInput(chunkUJTYUYY4_cjs.toOffchainInputFeeParams(vtxo));
|
|
14911
14911
|
if (inputFee.satoshis >= vtxo.value) {
|
|
14912
14912
|
continue;
|
|
14913
14913
|
}
|
|
@@ -14954,7 +14954,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14954
14954
|
let script;
|
|
14955
14955
|
let arkAddress;
|
|
14956
14956
|
try {
|
|
14957
|
-
arkAddress =
|
|
14957
|
+
arkAddress = chunkUJTYUYY4_cjs.ArkAddress.decode(output.address);
|
|
14958
14958
|
} catch {
|
|
14959
14959
|
arkAddress = void 0;
|
|
14960
14960
|
}
|
|
@@ -15044,7 +15044,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15044
15044
|
const abortController = new AbortController();
|
|
15045
15045
|
let stream;
|
|
15046
15046
|
let committedTxid;
|
|
15047
|
-
const settleInputVtxos = params.inputs.filter(
|
|
15047
|
+
const settleInputVtxos = params.inputs.filter(chunkUJTYUYY4_cjs.isVirtualCoin);
|
|
15048
15048
|
const contractManager = await this.getContractManager();
|
|
15049
15049
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
15050
15050
|
await contractManager.assertSpendableNow?.(
|
|
@@ -15156,7 +15156,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15156
15156
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
15157
15157
|
if (!this._descriptorProvider) return;
|
|
15158
15158
|
const consumedBoarding = inputs.some(
|
|
15159
|
-
(input) => typeof input !== "string" && !
|
|
15159
|
+
(input) => typeof input !== "string" && !chunkUJTYUYY4_cjs.isVirtualCoin(input)
|
|
15160
15160
|
);
|
|
15161
15161
|
if (!consumedBoarding) return;
|
|
15162
15162
|
try {
|
|
@@ -15180,7 +15180,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15180
15180
|
let connectorIndex = 0;
|
|
15181
15181
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
15182
15182
|
for (const input of inputs) {
|
|
15183
|
-
if (!
|
|
15183
|
+
if (!chunkUJTYUYY4_cjs.isVirtualCoin(input)) {
|
|
15184
15184
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
15185
15185
|
const settlementInput = settlementPsbt.getInput(i);
|
|
15186
15186
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -15211,7 +15211,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15211
15211
|
}
|
|
15212
15212
|
continue;
|
|
15213
15213
|
}
|
|
15214
|
-
if (
|
|
15214
|
+
if (chunkUJTYUYY4_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
15215
15215
|
continue;
|
|
15216
15216
|
}
|
|
15217
15217
|
if (connectorsLeaves.length === 0) {
|
|
@@ -15239,7 +15239,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15239
15239
|
index: input.vout,
|
|
15240
15240
|
witnessUtxo: {
|
|
15241
15241
|
amount: BigInt(input.value),
|
|
15242
|
-
script:
|
|
15242
|
+
script: chunkUJTYUYY4_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15243
15243
|
},
|
|
15244
15244
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
15245
15245
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -15258,7 +15258,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15258
15258
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
15259
15259
|
{
|
|
15260
15260
|
index: 0,
|
|
15261
|
-
lookupScript:
|
|
15261
|
+
lookupScript: chunkUJTYUYY4_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15262
15262
|
}
|
|
15263
15263
|
]);
|
|
15264
15264
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -15316,7 +15316,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15316
15316
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
15317
15317
|
);
|
|
15318
15318
|
await this.arkProvider.confirmRegistration(intentId);
|
|
15319
|
-
const sweepTapscript =
|
|
15319
|
+
const sweepTapscript = chunkUJTYUYY4_cjs.CSVMultisigTapscript.encode({
|
|
15320
15320
|
timelock,
|
|
15321
15321
|
pubkeys: [this.forfeitPubkey]
|
|
15322
15322
|
}).script;
|
|
@@ -15331,10 +15331,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15331
15331
|
throw new Error("Sweep tap tree root not set");
|
|
15332
15332
|
}
|
|
15333
15333
|
const xOnlyPublicKeys = event.cosignersPublicKeys.map(
|
|
15334
|
-
(k) => base.hex.encode(
|
|
15334
|
+
(k) => base.hex.encode(chunkUCSTNXB4_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
15335
15335
|
);
|
|
15336
15336
|
const signerPublicKey = await session.getPublicKey();
|
|
15337
|
-
const xonlySignerPublicKey =
|
|
15337
|
+
const xonlySignerPublicKey = chunkUCSTNXB4_cjs.toXOnly(signerPublicKey, "signer key");
|
|
15338
15338
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
15339
15339
|
return { skip: true };
|
|
15340
15340
|
}
|
|
@@ -15424,9 +15424,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15424
15424
|
...existing ?? {},
|
|
15425
15425
|
intentTxId,
|
|
15426
15426
|
registerProof: intent.proof,
|
|
15427
|
-
registerProofMessage:
|
|
15427
|
+
registerProofMessage: chunkUJTYUYY4_cjs.Intent.encodeMessage(intent.message),
|
|
15428
15428
|
deleteProof: deleteIntent.proof,
|
|
15429
|
-
deleteProofMessage:
|
|
15429
|
+
deleteProofMessage: chunkUJTYUYY4_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
15430
15430
|
intentVtxos: inputs.map((i) => ({
|
|
15431
15431
|
txid: i.txid,
|
|
15432
15432
|
vout: i.vout
|
|
@@ -15458,7 +15458,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15458
15458
|
try {
|
|
15459
15459
|
return await this.arkProvider.registerIntent(intent);
|
|
15460
15460
|
} catch (error) {
|
|
15461
|
-
if (error instanceof
|
|
15461
|
+
if (error instanceof chunkUJTYUYY4_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
15462
15462
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
15463
15463
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
15464
15464
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -15474,7 +15474,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15474
15474
|
expire_at: 0,
|
|
15475
15475
|
cosigners_public_keys: cosignerPubKeys
|
|
15476
15476
|
};
|
|
15477
|
-
const proof =
|
|
15477
|
+
const proof = chunkUJTYUYY4_cjs.Intent.create(message, coins, outputs);
|
|
15478
15478
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15479
15479
|
return {
|
|
15480
15480
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15486,7 +15486,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15486
15486
|
type: "delete",
|
|
15487
15487
|
expire_at: 0
|
|
15488
15488
|
};
|
|
15489
|
-
const proof =
|
|
15489
|
+
const proof = chunkUJTYUYY4_cjs.Intent.create(message, coins, []);
|
|
15490
15490
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15491
15491
|
return {
|
|
15492
15492
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15498,7 +15498,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15498
15498
|
type: "get-pending-tx",
|
|
15499
15499
|
expire_at: 0
|
|
15500
15500
|
};
|
|
15501
|
-
const proof =
|
|
15501
|
+
const proof = chunkUJTYUYY4_cjs.Intent.create(message, coins, []);
|
|
15502
15502
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15503
15503
|
return {
|
|
15504
15504
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15519,7 +15519,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15519
15519
|
if (!vtxos || vtxos.length === 0) {
|
|
15520
15520
|
const scriptMap = await this.getScriptMap();
|
|
15521
15521
|
const allExtended = [];
|
|
15522
|
-
const fetchedVtxos = await
|
|
15522
|
+
const fetchedVtxos = await chunkUJTYUYY4_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
15523
15523
|
...scriptMap.keys()
|
|
15524
15524
|
]);
|
|
15525
15525
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -15563,7 +15563,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15563
15563
|
try {
|
|
15564
15564
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
15565
15565
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
|
|
15566
|
-
|
|
15566
|
+
chunkUJTYUYY4_cjs.assertAllowedSighashTypes(tx);
|
|
15567
15567
|
return tx;
|
|
15568
15568
|
});
|
|
15569
15569
|
assertCheckpointsMatchInputs(
|
|
@@ -15635,11 +15635,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15635
15635
|
* against the current key alone would leave it pending forever.
|
|
15636
15636
|
*/
|
|
15637
15637
|
checkpointUnrollCandidates(info) {
|
|
15638
|
-
const current =
|
|
15638
|
+
const current = chunkUJTYUYY4_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
15639
15639
|
const candidates = [this._serverUnrollScript, current];
|
|
15640
15640
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
15641
15641
|
candidates.push(
|
|
15642
|
-
|
|
15642
|
+
chunkUJTYUYY4_cjs.CSVMultisigTapscript.encode({
|
|
15643
15643
|
...current.params,
|
|
15644
15644
|
pubkeys: [base.hex.decode(deprecated)]
|
|
15645
15645
|
})
|
|
@@ -15730,7 +15730,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15730
15730
|
if (vtxos.length === 0) {
|
|
15731
15731
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
15732
15732
|
}
|
|
15733
|
-
const myPkScript =
|
|
15733
|
+
const myPkScript = chunkUJTYUYY4_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
15734
15734
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
15735
15735
|
let swept = 0;
|
|
15736
15736
|
const drainable = vtxos.filter(
|
|
@@ -15806,7 +15806,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15806
15806
|
const spendable = [];
|
|
15807
15807
|
const unclaimed = [];
|
|
15808
15808
|
for (const vtxo of vtxos) {
|
|
15809
|
-
if (
|
|
15809
|
+
if (chunkUJTYUYY4_cjs.hasTerminalSpend(vtxo)) {
|
|
15810
15810
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
15811
15811
|
} else if (vtxo.isUnrolled) {
|
|
15812
15812
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -15828,7 +15828,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15828
15828
|
const all = [];
|
|
15829
15829
|
const seen = /* @__PURE__ */ new Set();
|
|
15830
15830
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
15831
|
-
const { vtxos, page } = await
|
|
15831
|
+
const { vtxos, page } = await chunkUJTYUYY4_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
15832
15832
|
scripts,
|
|
15833
15833
|
pageIndex,
|
|
15834
15834
|
pageSize
|
|
@@ -15875,7 +15875,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15875
15875
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
15876
15876
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
15877
15877
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
15878
|
-
const proof =
|
|
15878
|
+
const proof = chunkUJTYUYY4_cjs.Intent.create(message, batch, []);
|
|
15879
15879
|
const signedProof = await identity.sign(
|
|
15880
15880
|
proof,
|
|
15881
15881
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -15897,7 +15897,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15897
15897
|
try {
|
|
15898
15898
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
15899
15899
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
15900
|
-
|
|
15900
|
+
chunkUJTYUYY4_cjs.assertAllowedSighashTypes(tx);
|
|
15901
15901
|
return tx;
|
|
15902
15902
|
});
|
|
15903
15903
|
assertCheckpointsMatchInputs(
|
|
@@ -16096,7 +16096,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16096
16096
|
script: recipient.script,
|
|
16097
16097
|
amount: BigInt(recipient.amount),
|
|
16098
16098
|
// Already checked against the recipient address in `validateRecipients`.
|
|
16099
|
-
...recipient.tapTree ? { tapTree:
|
|
16099
|
+
...recipient.tapTree ? { tapTree: chunkUJTYUYY4_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
|
|
16100
16100
|
}));
|
|
16101
16101
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
16102
16102
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -16240,10 +16240,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16240
16240
|
const serverPubKey = this.arkServerPublicKey;
|
|
16241
16241
|
const serverUnrollScript = this.serverUnrollScript;
|
|
16242
16242
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
16243
|
-
const normalizedInputs = inputs.map(
|
|
16244
|
-
const at = now ?? await
|
|
16243
|
+
const normalizedInputs = inputs.map(chunkUJTYUYY4_cjs.normalizeVtxo);
|
|
16244
|
+
const at = now ?? await chunkUJTYUYY4_cjs.resolveTimeHeight(this.onchainProvider);
|
|
16245
16245
|
for (const input of normalizedInputs) {
|
|
16246
|
-
if (!
|
|
16246
|
+
if (!chunkUJTYUYY4_cjs.canSpendOffchain(input, at)) {
|
|
16247
16247
|
throw new Error(
|
|
16248
16248
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
16249
16249
|
);
|
|
@@ -16313,7 +16313,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16313
16313
|
);
|
|
16314
16314
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
16315
16315
|
index,
|
|
16316
|
-
lookupScript:
|
|
16316
|
+
lookupScript: chunkUJTYUYY4_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
16317
16317
|
}));
|
|
16318
16318
|
const identity = this.identity;
|
|
16319
16319
|
const signer = {
|
|
@@ -16399,14 +16399,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16399
16399
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
16400
16400
|
spentVtxos.push({
|
|
16401
16401
|
...spentFacts,
|
|
16402
|
-
virtualStatus:
|
|
16402
|
+
virtualStatus: chunkUJTYUYY4_cjs.toVirtualStatus(spentFacts),
|
|
16403
16403
|
...spentBy ? { spentBy } : {},
|
|
16404
16404
|
arkTxId: arkTxid
|
|
16405
16405
|
});
|
|
16406
16406
|
for (const id of vtxo.commitmentTxIds) {
|
|
16407
16407
|
commitmentTxIds.add(id);
|
|
16408
16408
|
}
|
|
16409
|
-
const vtxoExpiry =
|
|
16409
|
+
const vtxoExpiry = chunkUJTYUYY4_cjs.toBatchExpiry(vtxo);
|
|
16410
16410
|
if (vtxoExpiry) {
|
|
16411
16411
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
16412
16412
|
}
|
|
@@ -16419,7 +16419,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16419
16419
|
isSwept: false,
|
|
16420
16420
|
isPreconfirmed: true,
|
|
16421
16421
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
16422
|
-
...
|
|
16422
|
+
...chunkUJTYUYY4_cjs.parseLegacyExpiry(batchExpiry)
|
|
16423
16423
|
};
|
|
16424
16424
|
changeVtxo = {
|
|
16425
16425
|
txid: arkTxid,
|
|
@@ -16431,7 +16431,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16431
16431
|
tapTree: offchainTapscript.encode(),
|
|
16432
16432
|
value: Number(changeAmount),
|
|
16433
16433
|
...changeFacts,
|
|
16434
|
-
virtualStatus:
|
|
16434
|
+
virtualStatus: chunkUJTYUYY4_cjs.toVirtualStatus(changeFacts),
|
|
16435
16435
|
spentBy: "",
|
|
16436
16436
|
status: {
|
|
16437
16437
|
confirmed: false
|
|
@@ -16500,12 +16500,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16500
16500
|
const spentVtxos = [];
|
|
16501
16501
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
16502
16502
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
16503
|
-
const vtxoInputs = inputs.filter(
|
|
16503
|
+
const vtxoInputs = inputs.filter(chunkUJTYUYY4_cjs.isVirtualCoin);
|
|
16504
16504
|
const cm = await this.getContractManager();
|
|
16505
16505
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
16506
16506
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
16507
16507
|
for (const input of inputs) {
|
|
16508
|
-
if (
|
|
16508
|
+
if (chunkUJTYUYY4_cjs.isVirtualCoin(input)) {
|
|
16509
16509
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
16510
16510
|
const vtxo = annotatedByKey.get(outpoint);
|
|
16511
16511
|
if (!vtxo) {
|
|
@@ -16517,13 +16517,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16517
16517
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
16518
16518
|
spentVtxos.push({
|
|
16519
16519
|
...settledFacts,
|
|
16520
|
-
virtualStatus:
|
|
16520
|
+
virtualStatus: chunkUJTYUYY4_cjs.toVirtualStatus(settledFacts),
|
|
16521
16521
|
settledBy: commitmentTxid
|
|
16522
16522
|
});
|
|
16523
16523
|
} else {
|
|
16524
16524
|
let sourceAddress;
|
|
16525
16525
|
try {
|
|
16526
|
-
sourceAddress =
|
|
16526
|
+
sourceAddress = chunkUJTYUYY4_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
16527
16527
|
this.network
|
|
16528
16528
|
);
|
|
16529
16529
|
} catch {
|
|
@@ -16581,9 +16581,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16581
16581
|
}
|
|
16582
16582
|
};
|
|
16583
16583
|
function selectVirtualCoins(coins, targetAmount) {
|
|
16584
|
-
const sortedCoins = coins.map(
|
|
16585
|
-
const expiryA =
|
|
16586
|
-
const expiryB =
|
|
16584
|
+
const sortedCoins = coins.map(chunkUJTYUYY4_cjs.normalizeVtxo).sort((a, b) => {
|
|
16585
|
+
const expiryA = chunkUJTYUYY4_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
16586
|
+
const expiryB = chunkUJTYUYY4_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
16587
16587
|
if (expiryA !== expiryB) {
|
|
16588
16588
|
return expiryA - expiryB;
|
|
16589
16589
|
}
|
|
@@ -16952,7 +16952,7 @@ var MessageBus = class {
|
|
|
16952
16952
|
this.initialized = true;
|
|
16953
16953
|
}
|
|
16954
16954
|
async buildServices(config) {
|
|
16955
|
-
const arkProvider = new
|
|
16955
|
+
const arkProvider = new chunkUJTYUYY4_cjs.RestArkProvider(config.arkServer.url);
|
|
16956
16956
|
const storage = {
|
|
16957
16957
|
walletRepository: this.walletRepository,
|
|
16958
16958
|
contractRepository: this.contractRepository,
|
|
@@ -17297,7 +17297,7 @@ var offboardNetworkNames = [
|
|
|
17297
17297
|
function offboardDestinationScript(destinationAddress) {
|
|
17298
17298
|
for (const networkName of offboardNetworkNames) {
|
|
17299
17299
|
try {
|
|
17300
|
-
const network =
|
|
17300
|
+
const network = chunkUJTYUYY4_cjs.networks[networkName];
|
|
17301
17301
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
17302
17302
|
return btcSigner.OutScript.encode(addr);
|
|
17303
17303
|
} catch {
|
|
@@ -17361,7 +17361,7 @@ var Ramps = class {
|
|
|
17361
17361
|
}
|
|
17362
17362
|
amount = amount ?? totalAmount;
|
|
17363
17363
|
const offchainAddress = await this.wallet.getAddress();
|
|
17364
|
-
const offchainAddr =
|
|
17364
|
+
const offchainAddr = chunkUJTYUYY4_cjs.ArkAddress.decode(offchainAddress);
|
|
17365
17365
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
17366
17366
|
const outputFee = estimator.evalOffchainOutput({
|
|
17367
17367
|
amount,
|
|
@@ -17421,7 +17421,7 @@ var Ramps = class {
|
|
|
17421
17421
|
const filteredVtxos = [];
|
|
17422
17422
|
let totalAmount = 0n;
|
|
17423
17423
|
for (const vtxo of vtxos) {
|
|
17424
|
-
const inputFee = estimator.evalOffchainInput(
|
|
17424
|
+
const inputFee = estimator.evalOffchainInput(chunkUJTYUYY4_cjs.toOffchainInputFeeParams(vtxo));
|
|
17425
17425
|
if (inputFee.satoshis >= vtxo.value) {
|
|
17426
17426
|
continue;
|
|
17427
17427
|
}
|
|
@@ -18300,7 +18300,7 @@ var WalletMessageHandler = class {
|
|
|
18300
18300
|
// Wallet methods
|
|
18301
18301
|
async handleInitWallet({ payload }) {
|
|
18302
18302
|
const { arkServerUrl } = payload;
|
|
18303
|
-
this.indexerProvider = new
|
|
18303
|
+
this.indexerProvider = new chunkL4HZK4KK_cjs.RestIndexerProvider(arkServerUrl);
|
|
18304
18304
|
await this.onWalletInitialized();
|
|
18305
18305
|
}
|
|
18306
18306
|
/**
|
|
@@ -18589,7 +18589,7 @@ var WalletMessageHandler = class {
|
|
|
18589
18589
|
if (v.isUnrolled) {
|
|
18590
18590
|
return withUnrolled;
|
|
18591
18591
|
}
|
|
18592
|
-
if (
|
|
18592
|
+
if (chunkUJTYUYY4_cjs.hasTerminalSpend(v)) {
|
|
18593
18593
|
return false;
|
|
18594
18594
|
}
|
|
18595
18595
|
if (includeRecoverable) {
|
|
@@ -18598,10 +18598,10 @@ var WalletMessageHandler = class {
|
|
|
18598
18598
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
18599
18599
|
return false;
|
|
18600
18600
|
}
|
|
18601
|
-
if (
|
|
18601
|
+
if (chunkUJTYUYY4_cjs.isRecoverable(v)) {
|
|
18602
18602
|
return false;
|
|
18603
18603
|
}
|
|
18604
|
-
if (
|
|
18604
|
+
if (chunkUJTYUYY4_cjs.isExpired(v)) {
|
|
18605
18605
|
return false;
|
|
18606
18606
|
}
|
|
18607
18607
|
return true;
|
|
@@ -18699,7 +18699,7 @@ var WalletMessageHandler = class {
|
|
|
18699
18699
|
if (!this.readonlyWallet) return null;
|
|
18700
18700
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
18701
18701
|
const indexerProvider = this.indexerProvider;
|
|
18702
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
18702
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkUJTYUYY4_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
18703
18703
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
18704
18704
|
}
|
|
18705
18705
|
async ensureContractEventBroadcasting() {
|
|
@@ -18762,7 +18762,7 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
18762
18762
|
// budget so the worker's snapshot fallback stays reachable before this
|
|
18763
18763
|
// page deadline fires — lowering it below the budget would time the page
|
|
18764
18764
|
// out while the worker is still seconds from answering from cache.
|
|
18765
|
-
GET_ARKADE_INFO:
|
|
18765
|
+
GET_ARKADE_INFO: chunkUJTYUYY4_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
|
|
18766
18766
|
INDEXER_GET_VTXOS: 2e4,
|
|
18767
18767
|
INDEXER_GET_VIRTUAL_TXS: 2e4,
|
|
18768
18768
|
GET_VTXOS: 2e4,
|
|
@@ -19375,7 +19375,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19375
19375
|
try {
|
|
19376
19376
|
const response = await this.sendMessage(message);
|
|
19377
19377
|
const { vtxos, page } = response.payload;
|
|
19378
|
-
return { vtxos: vtxos.map(
|
|
19378
|
+
return { vtxos: vtxos.map(chunkUJTYUYY4_cjs.normalizeVtxo), page: page && { ...page } };
|
|
19379
19379
|
} catch (error) {
|
|
19380
19380
|
throw new Error(`Failed to get vtxos: ${error}`, { cause: error });
|
|
19381
19381
|
}
|
|
@@ -19479,7 +19479,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19479
19479
|
};
|
|
19480
19480
|
try {
|
|
19481
19481
|
const response = await this.sendMessage(message);
|
|
19482
|
-
return response.payload.vtxos.map(
|
|
19482
|
+
return response.payload.vtxos.map(chunkUJTYUYY4_cjs.normalizeVtxo);
|
|
19483
19483
|
} catch (error) {
|
|
19484
19484
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
19485
19485
|
}
|
|
@@ -19504,7 +19504,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19504
19504
|
};
|
|
19505
19505
|
try {
|
|
19506
19506
|
const response = await this.sendMessage(message);
|
|
19507
|
-
return response.payload.vtxos.map(
|
|
19507
|
+
return response.payload.vtxos.map(chunkUJTYUYY4_cjs.normalizeVtxo);
|
|
19508
19508
|
} catch (error) {
|
|
19509
19509
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
19510
19510
|
}
|
|
@@ -19635,7 +19635,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19635
19635
|
};
|
|
19636
19636
|
try {
|
|
19637
19637
|
const response = await sendContractMessage(message);
|
|
19638
|
-
return response.payload.vtxos.map(
|
|
19638
|
+
return response.payload.vtxos.map(chunkUJTYUYY4_cjs.normalizeVtxo);
|
|
19639
19639
|
} catch (e) {
|
|
19640
19640
|
throw new Error("Failed to annotate vtxos");
|
|
19641
19641
|
}
|
|
@@ -20273,7 +20273,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
20273
20273
|
};
|
|
20274
20274
|
try {
|
|
20275
20275
|
const response = await wallet.sendMessage(message);
|
|
20276
|
-
return response.payload.vtxos.map(
|
|
20276
|
+
return response.payload.vtxos.map(chunkUJTYUYY4_cjs.normalizeVtxo);
|
|
20277
20277
|
} catch (e) {
|
|
20278
20278
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
20279
20279
|
}
|
|
@@ -20385,12 +20385,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20385
20385
|
* @returns Configured onchain wallet
|
|
20386
20386
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
20387
20387
|
*/
|
|
20388
|
-
static async create(identity, networkName =
|
|
20388
|
+
static async create(identity, networkName = chunkUJTYUYY4_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
20389
20389
|
const pubkey = await identity.xOnlyPublicKey();
|
|
20390
20390
|
if (!pubkey) {
|
|
20391
20391
|
throw new Error("Invalid configured public key");
|
|
20392
20392
|
}
|
|
20393
|
-
const network =
|
|
20393
|
+
const network = chunkUJTYUYY4_cjs.getNetwork(networkName);
|
|
20394
20394
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
20395
20395
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
20396
20396
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -20496,7 +20496,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20496
20496
|
if (!inputs) {
|
|
20497
20497
|
throw new Error("Fee estimation failed");
|
|
20498
20498
|
}
|
|
20499
|
-
let tx = new
|
|
20499
|
+
let tx = new chunkUJTYUYY4_cjs.Transaction();
|
|
20500
20500
|
for (const input of inputs) {
|
|
20501
20501
|
tx.addInput({
|
|
20502
20502
|
txid: input.txid,
|
|
@@ -20554,7 +20554,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20554
20554
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
20555
20555
|
*/
|
|
20556
20556
|
async bumpAnchor(parentHex, feeRate) {
|
|
20557
|
-
const parent =
|
|
20557
|
+
const parent = chunkUJTYUYY4_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
20558
20558
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
20559
20559
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
20560
20560
|
return [parent.hex, child.hex];
|
|
@@ -21461,7 +21461,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
21461
21461
|
try {
|
|
21462
21462
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
21463
21463
|
for (const psbt of txs) {
|
|
21464
|
-
const tx =
|
|
21464
|
+
const tx = chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
21465
21465
|
resolved.set(tx.id, tx.toBytes());
|
|
21466
21466
|
}
|
|
21467
21467
|
} catch (err) {
|
|
@@ -21494,7 +21494,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
21494
21494
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
21495
21495
|
const pending = [];
|
|
21496
21496
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
21497
|
-
if (
|
|
21497
|
+
if (chunkUJTYUYY4_cjs.getArkPsbtFields(tx, i, chunkUJTYUYY4_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
21498
21498
|
}
|
|
21499
21499
|
if (pending.length === 0) return;
|
|
21500
21500
|
const resolved = await resolvePrevTxs(
|
|
@@ -21503,13 +21503,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
21503
21503
|
onchain
|
|
21504
21504
|
);
|
|
21505
21505
|
for (const i of pending) {
|
|
21506
|
-
|
|
21506
|
+
chunkUJTYUYY4_cjs.setArkPsbtField(tx, i, chunkUJTYUYY4_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
21507
21507
|
}
|
|
21508
21508
|
}
|
|
21509
21509
|
async function attachPrevoutTxs(tx, source) {
|
|
21510
21510
|
const pending = [];
|
|
21511
21511
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
21512
|
-
if (
|
|
21512
|
+
if (chunkUJTYUYY4_cjs.getArkPsbtFields(tx, i, chunkUJTYUYY4_cjs.PrevoutTxField).length > 0) continue;
|
|
21513
21513
|
const input = tx.getInput(i);
|
|
21514
21514
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
21515
21515
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -21520,7 +21520,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
21520
21520
|
resolved.set(txid, await source.getRawTransaction(txid));
|
|
21521
21521
|
}
|
|
21522
21522
|
for (const { index, txid } of pending) {
|
|
21523
|
-
|
|
21523
|
+
chunkUJTYUYY4_cjs.setArkPsbtField(tx, index, chunkUJTYUYY4_cjs.PrevoutTxField, resolved.get(txid));
|
|
21524
21524
|
}
|
|
21525
21525
|
}
|
|
21526
21526
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -21546,7 +21546,7 @@ exports.BIP322 = void 0;
|
|
|
21546
21546
|
async function sign2(message, identity, network) {
|
|
21547
21547
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
21548
21548
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
21549
|
-
const toSpend =
|
|
21549
|
+
const toSpend = chunkUJTYUYY4_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
21550
21550
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
21551
21551
|
const signed = await identity.sign(toSign, [0]);
|
|
21552
21552
|
signed.finalizeIdx(0);
|
|
@@ -21604,7 +21604,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
21604
21604
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
21605
21605
|
return false;
|
|
21606
21606
|
}
|
|
21607
|
-
const toSpend =
|
|
21607
|
+
const toSpend = chunkUJTYUYY4_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
21608
21608
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
21609
21609
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
21610
21610
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -21625,7 +21625,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
21625
21625
|
}
|
|
21626
21626
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
21627
21627
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
21628
|
-
const toSpend =
|
|
21628
|
+
const toSpend = chunkUJTYUYY4_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
21629
21629
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
21630
21630
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
21631
21631
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -21678,7 +21678,7 @@ function encodeCompactSize(n) {
|
|
|
21678
21678
|
return buf;
|
|
21679
21679
|
}
|
|
21680
21680
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
21681
|
-
const tx = new
|
|
21681
|
+
const tx = new chunkUJTYUYY4_cjs.Transaction({ version: 0 });
|
|
21682
21682
|
tx.addInput({
|
|
21683
21683
|
txid: toSpend.id,
|
|
21684
21684
|
index: 0,
|
|
@@ -21692,12 +21692,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
21692
21692
|
});
|
|
21693
21693
|
tx.addOutput({
|
|
21694
21694
|
amount: 0n,
|
|
21695
|
-
script:
|
|
21695
|
+
script: chunkUJTYUYY4_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
21696
21696
|
});
|
|
21697
21697
|
return tx;
|
|
21698
21698
|
}
|
|
21699
21699
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
21700
|
-
const tx = new
|
|
21700
|
+
const tx = new chunkUJTYUYY4_cjs.Transaction({ version: 0 });
|
|
21701
21701
|
tx.addInput({
|
|
21702
21702
|
txid: toSpend.id,
|
|
21703
21703
|
index: 0,
|
|
@@ -21709,7 +21709,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
21709
21709
|
});
|
|
21710
21710
|
tx.addOutput({
|
|
21711
21711
|
amount: 0n,
|
|
21712
|
-
script:
|
|
21712
|
+
script: chunkUJTYUYY4_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
21713
21713
|
});
|
|
21714
21714
|
return tx;
|
|
21715
21715
|
}
|
|
@@ -21840,7 +21840,7 @@ var RestEmulatorProvider = class {
|
|
|
21840
21840
|
}
|
|
21841
21841
|
};
|
|
21842
21842
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
21843
|
-
const tx =
|
|
21843
|
+
const tx = chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
21844
21844
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
21845
21845
|
const input = tx.getInput(0);
|
|
21846
21846
|
if (!input) {
|
|
@@ -21867,14 +21867,14 @@ var ExitPathError = class extends Error {
|
|
|
21867
21867
|
reason;
|
|
21868
21868
|
};
|
|
21869
21869
|
function delayWeight(sequence) {
|
|
21870
|
-
const t =
|
|
21870
|
+
const t = chunkUJTYUYY4_cjs.sequenceToTimelock(sequence);
|
|
21871
21871
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
21872
21872
|
}
|
|
21873
21873
|
async function resolveUnilateralPath(params) {
|
|
21874
21874
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
21875
21875
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
21876
21876
|
if (contract) {
|
|
21877
|
-
const handler =
|
|
21877
|
+
const handler = chunkUCSTNXB4_cjs.contractHandlers.get(contract.type);
|
|
21878
21878
|
if (!handler) {
|
|
21879
21879
|
throw new ExitPathError(
|
|
21880
21880
|
"no-handler",
|
|
@@ -21897,12 +21897,12 @@ async function resolveUnilateralPath(params) {
|
|
|
21897
21897
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
21898
21898
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
21899
21899
|
}
|
|
21900
|
-
const decoded =
|
|
21900
|
+
const decoded = chunkUJTYUYY4_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
21901
21901
|
let best;
|
|
21902
21902
|
for (const exit of decoded.exitPaths()) {
|
|
21903
21903
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
21904
21904
|
if (!leaf) continue;
|
|
21905
|
-
const sequence =
|
|
21905
|
+
const sequence = chunkUJTYUYY4_cjs.timelockToSequence(exit.params.timelock);
|
|
21906
21906
|
const weight = delayWeight(sequence);
|
|
21907
21907
|
if (!best || weight < best.weight) {
|
|
21908
21908
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -22122,7 +22122,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22122
22122
|
let totalAmount = 0n;
|
|
22123
22123
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
22124
22124
|
for (const vtxo of vtxos) {
|
|
22125
|
-
if (!
|
|
22125
|
+
if (!chunkUJTYUYY4_cjs.canSweepOnchain(vtxo)) {
|
|
22126
22126
|
throw new Error(
|
|
22127
22127
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
22128
22128
|
);
|
|
@@ -22133,14 +22133,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22133
22133
|
}
|
|
22134
22134
|
const resolved = await resolveUnilateralPath({
|
|
22135
22135
|
vtxo,
|
|
22136
|
-
scriptHex: base.hex.encode(
|
|
22136
|
+
scriptHex: base.hex.encode(chunkUJTYUYY4_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
22137
22137
|
contractRepository: wallet.contractRepository,
|
|
22138
22138
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
22139
22139
|
currentTime: Date.now()
|
|
22140
22140
|
});
|
|
22141
22141
|
const spendingLeaf = resolved.selection.leaf;
|
|
22142
22142
|
const sequence = resolved.selection.sequence;
|
|
22143
|
-
const timelock =
|
|
22143
|
+
const timelock = chunkUJTYUYY4_cjs.sequenceToTimelock(sequence);
|
|
22144
22144
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
22145
22145
|
if (!elapsed) {
|
|
22146
22146
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -22153,7 +22153,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22153
22153
|
sequence,
|
|
22154
22154
|
witnessUtxo: {
|
|
22155
22155
|
amount: BigInt(vtxo.value),
|
|
22156
|
-
script:
|
|
22156
|
+
script: chunkUJTYUYY4_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
22157
22157
|
},
|
|
22158
22158
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
22159
22159
|
});
|
|
@@ -22163,7 +22163,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22163
22163
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
22164
22164
|
);
|
|
22165
22165
|
}
|
|
22166
|
-
const tx = new
|
|
22166
|
+
const tx = new chunkUJTYUYY4_cjs.Transaction({ version: 2 });
|
|
22167
22167
|
for (const input of inputs) {
|
|
22168
22168
|
tx.addInput(input);
|
|
22169
22169
|
}
|
|
@@ -22246,7 +22246,7 @@ async function buildSignedSweep(params) {
|
|
|
22246
22246
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
22247
22247
|
);
|
|
22248
22248
|
}
|
|
22249
|
-
const tx = new
|
|
22249
|
+
const tx = new chunkUJTYUYY4_cjs.Transaction({ version: 2 });
|
|
22250
22250
|
tx.addInput({
|
|
22251
22251
|
txid: vtxo.txid,
|
|
22252
22252
|
index: vtxo.vout,
|
|
@@ -22271,7 +22271,7 @@ async function buildSignedSweep(params) {
|
|
|
22271
22271
|
finalScriptWitness: [
|
|
22272
22272
|
tapScriptSig[0][1],
|
|
22273
22273
|
...path.extraWitness,
|
|
22274
|
-
|
|
22274
|
+
chunkUJTYUYY4_cjs.scriptFromTapLeafScript(path.leaf),
|
|
22275
22275
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
22276
22276
|
]
|
|
22277
22277
|
});
|
|
@@ -22301,7 +22301,7 @@ async function resolveFeeRate(opts) {
|
|
|
22301
22301
|
}
|
|
22302
22302
|
async function selectExitVtxos(opts) {
|
|
22303
22303
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
22304
|
-
const res = await
|
|
22304
|
+
const res = await chunkUJTYUYY4_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
22305
22305
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
22306
22306
|
const out = [];
|
|
22307
22307
|
for (const vtxo of res.vtxos) {
|
|
@@ -22316,7 +22316,7 @@ async function selectExitVtxos(opts) {
|
|
|
22316
22316
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
22317
22317
|
);
|
|
22318
22318
|
}
|
|
22319
|
-
const handler =
|
|
22319
|
+
const handler = chunkUCSTNXB4_cjs.contractHandlers.get(contract.type);
|
|
22320
22320
|
if (!handler) {
|
|
22321
22321
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
22322
22322
|
}
|
|
@@ -22346,7 +22346,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22346
22346
|
if (pendingNodes.length > 0) {
|
|
22347
22347
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
22348
22348
|
for (const psbt of txs) {
|
|
22349
|
-
psbts.set(
|
|
22349
|
+
psbts.set(chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
22350
22350
|
}
|
|
22351
22351
|
}
|
|
22352
22352
|
const childVsize = Number(
|
|
@@ -22382,7 +22382,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22382
22382
|
try {
|
|
22383
22383
|
const resolved = await resolveUnilateralPath({
|
|
22384
22384
|
vtxo,
|
|
22385
|
-
scriptHex: base.hex.encode(
|
|
22385
|
+
scriptHex: base.hex.encode(chunkUJTYUYY4_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
22386
22386
|
contractRepository: wallet.contractRepository,
|
|
22387
22387
|
walletPubKeyHex,
|
|
22388
22388
|
currentTime: Date.now()
|
|
@@ -22401,7 +22401,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22401
22401
|
});
|
|
22402
22402
|
continue;
|
|
22403
22403
|
}
|
|
22404
|
-
const t =
|
|
22404
|
+
const t = chunkUJTYUYY4_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
22405
22405
|
const delay = { type: t.type, value: Number(t.value) };
|
|
22406
22406
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
22407
22407
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -22802,7 +22802,7 @@ async function prepare(opts) {
|
|
|
22802
22802
|
txid: sweep.vtxo.txid,
|
|
22803
22803
|
vout: sweep.vtxo.vout,
|
|
22804
22804
|
value: sweep.vtxo.value,
|
|
22805
|
-
pkScript:
|
|
22805
|
+
pkScript: chunkUJTYUYY4_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
22806
22806
|
},
|
|
22807
22807
|
path: sweep.resolved.selection,
|
|
22808
22808
|
outputAddress: opts.sweepAddress,
|
|
@@ -22890,7 +22890,7 @@ async function prepare(opts) {
|
|
|
22890
22890
|
if (newFee <= splitterFee) break;
|
|
22891
22891
|
splitterFee = newFee;
|
|
22892
22892
|
}
|
|
22893
|
-
const splitter = new
|
|
22893
|
+
const splitter = new chunkUJTYUYY4_cjs.Transaction({ version: 2 });
|
|
22894
22894
|
for (const coin of selected.inputs) {
|
|
22895
22895
|
splitter.addInput({
|
|
22896
22896
|
txid: coin.txid,
|
|
@@ -23034,41 +23034,41 @@ var UnilateralExit = {
|
|
|
23034
23034
|
// src/arkade/index.ts
|
|
23035
23035
|
var arkade_exports = {};
|
|
23036
23036
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
23037
|
-
ARKADE_OP: () =>
|
|
23038
|
-
ARKADE_OPCODES: () =>
|
|
23039
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
23040
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
23041
|
-
ARKADE_OPS: () =>
|
|
23037
|
+
ARKADE_OP: () => chunkUCSTNXB4_cjs.ARKADE_OP,
|
|
23038
|
+
ARKADE_OPCODES: () => chunkUCSTNXB4_cjs.ARKADE_OPCODES,
|
|
23039
|
+
ARKADE_OPCODE_NAMES: () => chunkUCSTNXB4_cjs.ARKADE_OPCODE_NAMES,
|
|
23040
|
+
ARKADE_OPCODE_VALUES: () => chunkUCSTNXB4_cjs.ARKADE_OPCODE_VALUES,
|
|
23041
|
+
ARKADE_OPS: () => chunkUCSTNXB4_cjs.ARKADE_OPS,
|
|
23042
23042
|
Arkade: () => Arkade,
|
|
23043
23043
|
ArkadeContract: () => ArkadeContract,
|
|
23044
|
-
ArkadeProgramScript: () =>
|
|
23045
|
-
ArkadeScript: () =>
|
|
23044
|
+
ArkadeProgramScript: () => chunkUCSTNXB4_cjs.ArkadeProgramScript,
|
|
23045
|
+
ArkadeScript: () => chunkUCSTNXB4_cjs.ArkadeScript,
|
|
23046
23046
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
23047
|
-
BigNum: () =>
|
|
23047
|
+
BigNum: () => chunkUCSTNXB4_cjs.bignum_exports,
|
|
23048
23048
|
OP: () => btcSigner.OP,
|
|
23049
|
-
OPCODE_NAMES: () =>
|
|
23050
|
-
OPCODE_VALUES: () =>
|
|
23051
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
23049
|
+
OPCODE_NAMES: () => chunkUCSTNXB4_cjs.OPCODE_NAMES,
|
|
23050
|
+
OPCODE_VALUES: () => chunkUCSTNXB4_cjs.OPCODE_VALUES,
|
|
23051
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkUCSTNXB4_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
23052
23052
|
Script: () => btcSigner.Script,
|
|
23053
|
-
arkadeScriptHash: () =>
|
|
23054
|
-
arkadeWitnessHash: () =>
|
|
23055
|
-
asmToBytes: () =>
|
|
23056
|
-
bytesToASM: () =>
|
|
23057
|
-
computeArkadeScriptPublicKey: () =>
|
|
23053
|
+
arkadeScriptHash: () => chunkUCSTNXB4_cjs.arkadeScriptHash,
|
|
23054
|
+
arkadeWitnessHash: () => chunkUCSTNXB4_cjs.arkadeWitnessHash,
|
|
23055
|
+
asmToBytes: () => chunkUCSTNXB4_cjs.asmToBytes,
|
|
23056
|
+
bytesToASM: () => chunkUCSTNXB4_cjs.bytesToASM,
|
|
23057
|
+
computeArkadeScriptPublicKey: () => chunkUCSTNXB4_cjs.computeArkadeScriptPublicKey,
|
|
23058
23058
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
23059
|
-
deserializeArkadeContractParams: () =>
|
|
23060
|
-
fromASM: () =>
|
|
23061
|
-
getOpcodeName: () =>
|
|
23062
|
-
getOpcodeValue: () =>
|
|
23063
|
-
parseArtifact: () =>
|
|
23064
|
-
resolveAsm: () =>
|
|
23065
|
-
serializeArkadeContractParams: () =>
|
|
23066
|
-
stringifyArtifact: () =>
|
|
23067
|
-
toASM: () =>
|
|
23068
|
-
validateProgram: () =>
|
|
23069
|
-
witnessRefToBytes: () =>
|
|
23059
|
+
deserializeArkadeContractParams: () => chunkUCSTNXB4_cjs.deserializeArkadeContractParams,
|
|
23060
|
+
fromASM: () => chunkUCSTNXB4_cjs.fromASM,
|
|
23061
|
+
getOpcodeName: () => chunkUCSTNXB4_cjs.getOpcodeName,
|
|
23062
|
+
getOpcodeValue: () => chunkUCSTNXB4_cjs.getOpcodeValue,
|
|
23063
|
+
parseArtifact: () => chunkUCSTNXB4_cjs.parseArtifact,
|
|
23064
|
+
resolveAsm: () => chunkUCSTNXB4_cjs.resolveAsm,
|
|
23065
|
+
serializeArkadeContractParams: () => chunkUCSTNXB4_cjs.serializeArkadeContractParams,
|
|
23066
|
+
stringifyArtifact: () => chunkUCSTNXB4_cjs.stringifyArtifact,
|
|
23067
|
+
toASM: () => chunkUCSTNXB4_cjs.toASM,
|
|
23068
|
+
validateProgram: () => chunkUCSTNXB4_cjs.validateProgram,
|
|
23069
|
+
witnessRefToBytes: () => chunkUCSTNXB4_cjs.witnessRefToBytes
|
|
23070
23070
|
});
|
|
23071
|
-
var isVtxoCoin = (input) =>
|
|
23071
|
+
var isVtxoCoin = (input) => chunkUJTYUYY4_cjs.isVirtualCoin(input);
|
|
23072
23072
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
23073
23073
|
let batchId;
|
|
23074
23074
|
let sweepTapTreeRoot;
|
|
@@ -23089,23 +23089,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23089
23089
|
);
|
|
23090
23090
|
await arkProvider.confirmRegistration(intentId);
|
|
23091
23091
|
batchId = event.id;
|
|
23092
|
-
const sweepTapscript =
|
|
23092
|
+
const sweepTapscript = chunkUJTYUYY4_cjs.CSVMultisigTapscript.encode({
|
|
23093
23093
|
timelock,
|
|
23094
|
-
pubkeys: [
|
|
23094
|
+
pubkeys: [chunkUCSTNXB4_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
|
|
23095
23095
|
}).script;
|
|
23096
23096
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
23097
23097
|
return { skip: false };
|
|
23098
23098
|
},
|
|
23099
23099
|
onTreeSigningStarted: async (event, vtxoTree) => {
|
|
23100
23100
|
const signerPubKey = await session.getPublicKey();
|
|
23101
|
-
const xonlySignerPubKey =
|
|
23101
|
+
const xonlySignerPubKey = chunkUCSTNXB4_cjs.toXOnly(signerPubKey, "signer key");
|
|
23102
23102
|
const xOnlyPubkeys = event.cosignersPublicKeys.map(
|
|
23103
|
-
(k) => base.hex.encode(
|
|
23103
|
+
(k) => base.hex.encode(chunkUCSTNXB4_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
23104
23104
|
);
|
|
23105
23105
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
23106
23106
|
return { skip: true };
|
|
23107
23107
|
}
|
|
23108
|
-
const commitmentTx =
|
|
23108
|
+
const commitmentTx = chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
23109
23109
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
23110
23110
|
if (recipients && recipients.length > 0) {
|
|
23111
23111
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -23137,7 +23137,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23137
23137
|
if (connectorTree) {
|
|
23138
23138
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
23139
23139
|
}
|
|
23140
|
-
let commitmentPsbt =
|
|
23140
|
+
let commitmentPsbt = chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
23141
23141
|
assertFinalCommitmentMatchesValidated(
|
|
23142
23142
|
commitmentPsbt,
|
|
23143
23143
|
validatedCommitmentTxid,
|
|
@@ -23172,7 +23172,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23172
23172
|
boardingIndices.push(boardingIdx);
|
|
23173
23173
|
continue;
|
|
23174
23174
|
}
|
|
23175
|
-
if (
|
|
23175
|
+
if (chunkUJTYUYY4_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
23176
23176
|
continue;
|
|
23177
23177
|
}
|
|
23178
23178
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -23193,7 +23193,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23193
23193
|
index: input.vout,
|
|
23194
23194
|
witnessUtxo: {
|
|
23195
23195
|
amount: BigInt(input.value),
|
|
23196
|
-
script:
|
|
23196
|
+
script: chunkUJTYUYY4_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
23197
23197
|
},
|
|
23198
23198
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
23199
23199
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -23284,16 +23284,16 @@ var Arkade = class _Arkade {
|
|
|
23284
23284
|
/** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
|
|
23285
23285
|
static async connect(opts) {
|
|
23286
23286
|
const info = await opts.arkade.getInfo();
|
|
23287
|
-
const serverKey =
|
|
23288
|
-
const checkpoint =
|
|
23289
|
-
const network = opts.network ??
|
|
23287
|
+
const serverKey = chunkUCSTNXB4_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
23288
|
+
const checkpoint = chunkUJTYUYY4_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
23289
|
+
const network = opts.network ?? chunkUJTYUYY4_cjs.DEFAULT_NETWORK;
|
|
23290
23290
|
let emulatorKey;
|
|
23291
23291
|
if (opts.emulator) {
|
|
23292
|
-
emulatorKey = base.hex.decode(
|
|
23292
|
+
emulatorKey = base.hex.decode(chunkUJTYUYY4_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
23293
23293
|
}
|
|
23294
23294
|
let userKey;
|
|
23295
23295
|
if (opts.identity) {
|
|
23296
|
-
userKey =
|
|
23296
|
+
userKey = chunkUCSTNXB4_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
|
|
23297
23297
|
}
|
|
23298
23298
|
return new _Arkade({
|
|
23299
23299
|
arkProvider: opts.arkade,
|
|
@@ -23319,7 +23319,7 @@ var Arkade = class _Arkade {
|
|
|
23319
23319
|
* key respectively; explicit args always win.
|
|
23320
23320
|
*/
|
|
23321
23321
|
contract(program, args = {}) {
|
|
23322
|
-
const declared = (program.params ?? []).map(
|
|
23322
|
+
const declared = (program.params ?? []).map(chunkUCSTNXB4_cjs.inputName);
|
|
23323
23323
|
if (declared.includes("server") && args.server === void 0) {
|
|
23324
23324
|
args = { ...args, server: this.serverKey };
|
|
23325
23325
|
}
|
|
@@ -23339,7 +23339,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23339
23339
|
userKey: client.userKey,
|
|
23340
23340
|
emulatorKey: client.emulatorKey
|
|
23341
23341
|
};
|
|
23342
|
-
this.vtxoScript = new
|
|
23342
|
+
this.vtxoScript = new chunkUCSTNXB4_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
23343
23343
|
this.tapTree = this.vtxoScript.encode();
|
|
23344
23344
|
this.compiled = this.vtxoScript.compiled;
|
|
23345
23345
|
}
|
|
@@ -23367,7 +23367,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23367
23367
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
23368
23368
|
);
|
|
23369
23369
|
}
|
|
23370
|
-
const typed =
|
|
23370
|
+
const typed = chunkUCSTNXB4_cjs.deserializeArkadeContractParams(contract.params);
|
|
23371
23371
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
23372
23372
|
serverKey: typed.serverKey,
|
|
23373
23373
|
userKey: typed.userKey,
|
|
@@ -23408,7 +23408,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23408
23408
|
toContractParams() {
|
|
23409
23409
|
return {
|
|
23410
23410
|
type: "arkade",
|
|
23411
|
-
params:
|
|
23411
|
+
params: chunkUCSTNXB4_cjs.serializeArkadeContractParams({
|
|
23412
23412
|
program: this.program,
|
|
23413
23413
|
args: this.args,
|
|
23414
23414
|
serverKey: this.keys.serverKey,
|
|
@@ -23458,18 +23458,18 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23458
23458
|
if (registered) {
|
|
23459
23459
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
23460
23460
|
return (withVtxos?.vtxos ?? []).filter(
|
|
23461
|
-
(v) => !
|
|
23461
|
+
(v) => !chunkUJTYUYY4_cjs.hasTerminalSpend(v) && !v.isUnrolled
|
|
23462
23462
|
);
|
|
23463
23463
|
}
|
|
23464
23464
|
}
|
|
23465
23465
|
if (!this.client.indexer) {
|
|
23466
23466
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
23467
23467
|
}
|
|
23468
|
-
const { vtxos } = await
|
|
23468
|
+
const { vtxos } = await chunkUJTYUYY4_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
23469
23469
|
scripts: [scriptHex],
|
|
23470
23470
|
spendableOnly: true
|
|
23471
23471
|
});
|
|
23472
|
-
return vtxos.filter((v) => !
|
|
23472
|
+
return vtxos.filter((v) => !chunkUJTYUYY4_cjs.hasTerminalSpend(v) && !v.isUnrolled);
|
|
23473
23473
|
}
|
|
23474
23474
|
/** Total spendable balance (requires an indexer). */
|
|
23475
23475
|
async getBalance() {
|
|
@@ -23567,7 +23567,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
23567
23567
|
this.contract.client.checkpoint
|
|
23568
23568
|
);
|
|
23569
23569
|
if (coin.sourceTx) {
|
|
23570
|
-
|
|
23570
|
+
chunkUJTYUYY4_cjs.setArkPsbtField(arkTx, 0, chunkUJTYUYY4_cjs.PrevArkTxField, coin.sourceTx);
|
|
23571
23571
|
}
|
|
23572
23572
|
if (this.fn.arkadeScript) {
|
|
23573
23573
|
const indexer = this.contract.client.indexer;
|
|
@@ -23584,8 +23584,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
23584
23584
|
}
|
|
23585
23585
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
23586
23586
|
if (condition.length > 0) {
|
|
23587
|
-
|
|
23588
|
-
|
|
23587
|
+
chunkUJTYUYY4_cjs.setArkPsbtField(arkTx, 0, chunkUJTYUYY4_cjs.ConditionWitness, condition);
|
|
23588
|
+
chunkUJTYUYY4_cjs.setArkPsbtField(checkpoints[0], 0, chunkUJTYUYY4_cjs.ConditionWitness, condition);
|
|
23589
23589
|
}
|
|
23590
23590
|
const packets = [];
|
|
23591
23591
|
if (this.assetSpecs.length > 0) {
|
|
@@ -23624,7 +23624,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
23624
23624
|
base.base64.encode(signedArk2.toPSBT()),
|
|
23625
23625
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
23626
23626
|
);
|
|
23627
|
-
const txid =
|
|
23627
|
+
const txid = chunkUJTYUYY4_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
23628
23628
|
return {
|
|
23629
23629
|
txid,
|
|
23630
23630
|
signedArkTx: res2.signedArkTx,
|
|
@@ -23689,23 +23689,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
23689
23689
|
}
|
|
23690
23690
|
buildAssetPacket() {
|
|
23691
23691
|
const groups = this.assetSpecs.map((s) => {
|
|
23692
|
-
const id = typeof s.assetId === "string" ?
|
|
23693
|
-
return
|
|
23692
|
+
const id = typeof s.assetId === "string" ? chunkL4HZK4KK_cjs.AssetId.fromString(s.assetId) : chunkL4HZK4KK_cjs.AssetId.fromBytes(s.assetId);
|
|
23693
|
+
return chunkL4HZK4KK_cjs.AssetGroup.create(
|
|
23694
23694
|
id,
|
|
23695
23695
|
null,
|
|
23696
|
-
s.inputs.map((i) =>
|
|
23697
|
-
s.outputs.map((o) =>
|
|
23698
|
-
(s.metadata ?? []).map((m) =>
|
|
23696
|
+
s.inputs.map((i) => chunkL4HZK4KK_cjs.AssetInput.create(i.vin, i.amount)),
|
|
23697
|
+
s.outputs.map((o) => chunkL4HZK4KK_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
23698
|
+
(s.metadata ?? []).map((m) => chunkL4HZK4KK_cjs.Metadata.create(m.key, m.value))
|
|
23699
23699
|
);
|
|
23700
23700
|
});
|
|
23701
|
-
return
|
|
23701
|
+
return chunkL4HZK4KK_cjs.Packet.create(groups);
|
|
23702
23702
|
}
|
|
23703
23703
|
witnessBytes(ref) {
|
|
23704
|
-
return
|
|
23704
|
+
return chunkUCSTNXB4_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
23705
23705
|
}
|
|
23706
23706
|
};
|
|
23707
23707
|
function bindInputs(fn, callArgs) {
|
|
23708
|
-
const names = (fn.def.inputs ?? []).map(
|
|
23708
|
+
const names = (fn.def.inputs ?? []).map(chunkUCSTNXB4_cjs.inputName);
|
|
23709
23709
|
if (callArgs.length !== names.length) {
|
|
23710
23710
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
23711
23711
|
}
|
|
@@ -24384,5 +24384,5 @@ exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
|
24384
24384
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
24385
24385
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
24386
24386
|
exports.withPrevTxs = withPrevTxs;
|
|
24387
|
-
//# sourceMappingURL=chunk-
|
|
24388
|
-
//# sourceMappingURL=chunk-
|
|
24387
|
+
//# sourceMappingURL=chunk-FSF2PGTR.cjs.map
|
|
24388
|
+
//# sourceMappingURL=chunk-FSF2PGTR.cjs.map
|