@arkade-os/sdk 0.5.0-rc.6 → 0.5.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.js +3 -3
- package/dist/{chunk-IRXEWL2A.js → chunk-2JU54RGB.js} +3 -3
- package/dist/{chunk-IRXEWL2A.js.map → chunk-2JU54RGB.js.map} +1 -1
- package/dist/{chunk-BWHKCHJN.js → chunk-4MB3Z33G.js} +4 -4
- package/dist/{chunk-BWHKCHJN.js.map → chunk-4MB3Z33G.js.map} +1 -1
- package/dist/{chunk-ISA3HWFN.js → chunk-7B2QAHQU.js} +7 -5
- package/dist/chunk-7B2QAHQU.js.map +1 -0
- package/dist/{chunk-ZF52B7BV.cjs → chunk-A2T3GGAK.cjs} +50 -50
- package/dist/{chunk-ZF52B7BV.cjs.map → chunk-A2T3GGAK.cjs.map} +1 -1
- package/dist/{chunk-4I6KPFCB.cjs → chunk-EIMOVGBV.cjs} +436 -434
- package/dist/chunk-EIMOVGBV.cjs.map +1 -0
- package/dist/{chunk-XR23C6TF.cjs → chunk-GLLBSULU.cjs} +3 -3
- package/dist/{chunk-XR23C6TF.cjs.map → chunk-GLLBSULU.cjs.map} +1 -1
- package/dist/{chunk-2P75JIT5.js → chunk-H7KLBU6G.js} +3 -3
- package/dist/{chunk-2P75JIT5.js.map → chunk-H7KLBU6G.js.map} +1 -1
- package/dist/{chunk-QKHXUTXM.js → chunk-L6MGV7ZA.js} +3 -3
- package/dist/{chunk-QKHXUTXM.js.map → chunk-L6MGV7ZA.js.map} +1 -1
- package/dist/{chunk-7PW4GV2Q.js → chunk-LFIORZO3.js} +4 -4
- package/dist/{chunk-7PW4GV2Q.js.map → chunk-LFIORZO3.js.map} +1 -1
- package/dist/{chunk-3LGOKP52.cjs → chunk-VUR6RP73.cjs} +10 -10
- package/dist/{chunk-3LGOKP52.cjs.map → chunk-VUR6RP73.cjs.map} +1 -1
- package/dist/{chunk-BMYEJA3W.cjs → chunk-XIPWLWPU.cjs} +17 -17
- package/dist/{chunk-BMYEJA3W.cjs.map → chunk-XIPWLWPU.cjs.map} +1 -1
- package/dist/{chunk-TVG3GDEO.cjs → chunk-XOT73T36.cjs} +18 -18
- package/dist/{chunk-TVG3GDEO.cjs.map → chunk-XOT73T36.cjs.map} +1 -1
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/index.cjs +290 -290
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +20 -20
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +19 -19
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.js +5 -5
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-4I6KPFCB.cjs.map +0 -1
- package/dist/chunk-ISA3HWFN.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkXOT73T36_cjs = require('./chunk-XOT73T36.cjs');
|
|
4
|
+
var chunkA2T3GGAK_cjs = require('./chunk-A2T3GGAK.cjs');
|
|
5
|
+
var chunkGLLBSULU_cjs = require('./chunk-GLLBSULU.cjs');
|
|
6
6
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
7
7
|
var btcSigner = require('@scure/btc-signer');
|
|
8
8
|
var base = require('@scure/base');
|
|
@@ -187,7 +187,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
187
187
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
188
188
|
const tx = this.graph.find(txid);
|
|
189
189
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
190
|
-
const cosigners =
|
|
190
|
+
const cosigners = chunkGLLBSULU_cjs.getArkPsbtFields(tx.root, 0, chunkGLLBSULU_cjs.CosignerPublicKey).map(
|
|
191
191
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
192
192
|
// xonly pubkey
|
|
193
193
|
);
|
|
@@ -239,7 +239,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
239
239
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
240
240
|
const prevoutAmounts = [];
|
|
241
241
|
const prevoutScripts = [];
|
|
242
|
-
const cosigners =
|
|
242
|
+
const cosigners = chunkGLLBSULU_cjs.getArkPsbtFields(g.root, 0, chunkGLLBSULU_cjs.CosignerPublicKey).map((c) => c.key);
|
|
243
243
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
244
244
|
taprootTweak: this.scriptRoot
|
|
245
245
|
});
|
|
@@ -322,7 +322,7 @@ var SingleKey = class _SingleKey {
|
|
|
322
322
|
async sign(tx, inputIndexes) {
|
|
323
323
|
const txCpy = tx.clone();
|
|
324
324
|
if (!inputIndexes) {
|
|
325
|
-
|
|
325
|
+
chunkGLLBSULU_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
|
|
326
326
|
try {
|
|
327
327
|
if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
|
|
328
328
|
throw new Error("Failed to sign transaction");
|
|
@@ -431,7 +431,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
431
431
|
let network;
|
|
432
432
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
433
433
|
descriptor = opts.descriptor;
|
|
434
|
-
network =
|
|
434
|
+
network = chunkA2T3GGAK_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
435
435
|
} else {
|
|
436
436
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
437
437
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -521,7 +521,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
521
521
|
}
|
|
522
522
|
/** Returns true when `descriptor` is derived from this identity's seed. */
|
|
523
523
|
ownsDescriptor(descriptor) {
|
|
524
|
-
return
|
|
524
|
+
return chunkA2T3GGAK_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
525
525
|
}
|
|
526
526
|
/**
|
|
527
527
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -560,7 +560,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
560
560
|
}
|
|
561
561
|
// ── internal helpers ─────────────────────────────────────────────
|
|
562
562
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
563
|
-
const network =
|
|
563
|
+
const network = chunkA2T3GGAK_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
564
564
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
565
565
|
if (expansion.isRanged) {
|
|
566
566
|
throw new Error(
|
|
@@ -585,7 +585,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
585
585
|
signTxWithKey(tx, key, inputIndexes) {
|
|
586
586
|
const txCpy = tx.clone();
|
|
587
587
|
if (!inputIndexes) {
|
|
588
|
-
|
|
588
|
+
chunkGLLBSULU_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
|
|
589
589
|
try {
|
|
590
590
|
if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
|
|
591
591
|
throw new Error("Failed to sign transaction");
|
|
@@ -647,7 +647,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
647
647
|
*/
|
|
648
648
|
descriptor;
|
|
649
649
|
constructor(descriptor) {
|
|
650
|
-
const network =
|
|
650
|
+
const network = chunkA2T3GGAK_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
651
651
|
let expansion;
|
|
652
652
|
try {
|
|
653
653
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -688,7 +688,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
688
688
|
}
|
|
689
689
|
/** Returns true when `descriptor` derives from this identity's xpub. */
|
|
690
690
|
ownsDescriptor(descriptor) {
|
|
691
|
-
return
|
|
691
|
+
return chunkA2T3GGAK_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
692
692
|
}
|
|
693
693
|
};
|
|
694
694
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -834,10 +834,10 @@ var DescriptorIdentity = class {
|
|
|
834
834
|
this.base = base;
|
|
835
835
|
}
|
|
836
836
|
async xOnlyPublicKey() {
|
|
837
|
-
return
|
|
837
|
+
return chunkA2T3GGAK_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
838
838
|
}
|
|
839
839
|
async compressedPublicKey() {
|
|
840
|
-
return
|
|
840
|
+
return chunkA2T3GGAK_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
841
841
|
}
|
|
842
842
|
async sign(tx, inputIndexes) {
|
|
843
843
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -910,12 +910,12 @@ async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
|
910
910
|
signMessageWithDescriptor: (ownedDescriptor, message, signatureType) => identity.signDescriptorMessage(ownedDescriptor, message, signatureType)
|
|
911
911
|
} : void 0;
|
|
912
912
|
const owner = providerOwner ?? identityOwner;
|
|
913
|
-
if (owner &&
|
|
913
|
+
if (owner && chunkA2T3GGAK_cjs.parseHDDescriptor(descriptor)) {
|
|
914
914
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
915
915
|
}
|
|
916
916
|
let key;
|
|
917
917
|
try {
|
|
918
|
-
key =
|
|
918
|
+
key = chunkA2T3GGAK_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
919
919
|
} catch {
|
|
920
920
|
throw new ForeignDescriptorError(descriptor);
|
|
921
921
|
}
|
|
@@ -1290,14 +1290,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1290
1290
|
}
|
|
1291
1291
|
var PREIMAGE_INDEX = 0;
|
|
1292
1292
|
function isPerArtifactDescriptor(descriptor) {
|
|
1293
|
-
return
|
|
1293
|
+
return chunkA2T3GGAK_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1294
1294
|
}
|
|
1295
1295
|
async function provisionDescriptor(wallet) {
|
|
1296
1296
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1297
|
-
return allocated ?? await
|
|
1297
|
+
return allocated ?? await chunkA2T3GGAK_cjs.identityDescriptor(wallet.identity);
|
|
1298
1298
|
}
|
|
1299
1299
|
async function provisionRefundKey(wallet) {
|
|
1300
|
-
const descriptor = await
|
|
1300
|
+
const descriptor = await chunkA2T3GGAK_cjs.identityDescriptor(wallet.identity);
|
|
1301
1301
|
const signer = await contractSigner(wallet, descriptor);
|
|
1302
1302
|
const pubkey = await signer.xOnlyPublicKey();
|
|
1303
1303
|
const identityPubkey = await wallet.identity.xOnlyPublicKey();
|
|
@@ -1307,7 +1307,7 @@ async function provisionRefundKey(wallet) {
|
|
|
1307
1307
|
);
|
|
1308
1308
|
}
|
|
1309
1309
|
const address = await wallet.getAddress();
|
|
1310
|
-
const { pkScript } =
|
|
1310
|
+
const { pkScript } = chunkGLLBSULU_cjs.ArkAddress.decode(address);
|
|
1311
1311
|
return { descriptor, pubkey, pkScript, address };
|
|
1312
1312
|
}
|
|
1313
1313
|
async function provisionClaimSecret(wallet, opts = {}) {
|
|
@@ -1353,7 +1353,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1353
1353
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1354
1354
|
let expected;
|
|
1355
1355
|
try {
|
|
1356
|
-
expected =
|
|
1356
|
+
expected = chunkA2T3GGAK_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1357
1357
|
} catch (cause) {
|
|
1358
1358
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1359
1359
|
}
|
|
@@ -1572,14 +1572,14 @@ var RestDelegateProvider = class {
|
|
|
1572
1572
|
*/
|
|
1573
1573
|
async delegate(intent, forfeitTxs, options) {
|
|
1574
1574
|
const url = `${this.url}/v1/delegate`;
|
|
1575
|
-
const response = await
|
|
1575
|
+
const response = await chunkGLLBSULU_cjs.baseFetch(url, {
|
|
1576
1576
|
method: "POST",
|
|
1577
1577
|
headers: {
|
|
1578
1578
|
"Content-Type": "application/json"
|
|
1579
1579
|
},
|
|
1580
1580
|
body: JSON.stringify({
|
|
1581
1581
|
intent: {
|
|
1582
|
-
message:
|
|
1582
|
+
message: chunkGLLBSULU_cjs.Intent.encodeMessage(intent.message),
|
|
1583
1583
|
proof: intent.proof
|
|
1584
1584
|
},
|
|
1585
1585
|
forfeit_txs: forfeitTxs,
|
|
@@ -1599,7 +1599,7 @@ var RestDelegateProvider = class {
|
|
|
1599
1599
|
*/
|
|
1600
1600
|
async getDelegateInfo() {
|
|
1601
1601
|
const url = `${this.url}/v1/delegator/info`;
|
|
1602
|
-
const response = await
|
|
1602
|
+
const response = await chunkGLLBSULU_cjs.rateGate.runHttp(url, () => chunkGLLBSULU_cjs.baseFetch(url));
|
|
1603
1603
|
if (!response.ok) {
|
|
1604
1604
|
const errorText2 = await response.text();
|
|
1605
1605
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1622,7 +1622,7 @@ var ESPLORA_URL = {
|
|
|
1622
1622
|
regtest: "http://localhost:3000/api"
|
|
1623
1623
|
};
|
|
1624
1624
|
var EsploraProvider = class {
|
|
1625
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1625
|
+
constructor(baseUrl = ESPLORA_URL[chunkGLLBSULU_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1626
1626
|
this.baseUrl = baseUrl;
|
|
1627
1627
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1628
1628
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1641,14 +1641,14 @@ var EsploraProvider = class {
|
|
|
1641
1641
|
*/
|
|
1642
1642
|
addressWatches = /* @__PURE__ */ new Map();
|
|
1643
1643
|
async getCoins(address) {
|
|
1644
|
-
const response = await
|
|
1644
|
+
const response = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1645
1645
|
if (!response.ok) {
|
|
1646
1646
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1647
1647
|
}
|
|
1648
1648
|
return response.json();
|
|
1649
1649
|
}
|
|
1650
1650
|
async getFeeRate() {
|
|
1651
|
-
const response = await
|
|
1651
|
+
const response = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1652
1652
|
if (response.status === 404) {
|
|
1653
1653
|
return void 0;
|
|
1654
1654
|
}
|
|
@@ -1669,7 +1669,7 @@ var EsploraProvider = class {
|
|
|
1669
1669
|
}
|
|
1670
1670
|
}
|
|
1671
1671
|
async getTxOutspends(txid) {
|
|
1672
|
-
const response = await
|
|
1672
|
+
const response = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1673
1673
|
if (!response.ok) {
|
|
1674
1674
|
const error = await response.text();
|
|
1675
1675
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1677,7 +1677,7 @@ var EsploraProvider = class {
|
|
|
1677
1677
|
return response.json();
|
|
1678
1678
|
}
|
|
1679
1679
|
async getTransactions(address) {
|
|
1680
|
-
const response = await
|
|
1680
|
+
const response = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1681
1681
|
if (!response.ok) {
|
|
1682
1682
|
const error = await response.text();
|
|
1683
1683
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1690,14 +1690,14 @@ var EsploraProvider = class {
|
|
|
1690
1690
|
* usable as a change probe for the polling fallback.
|
|
1691
1691
|
*/
|
|
1692
1692
|
async getAddressStats(address) {
|
|
1693
|
-
const response = await
|
|
1693
|
+
const response = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
|
|
1694
1694
|
if (!response.ok) {
|
|
1695
1695
|
throw new Error(`Failed to get address stats: ${response.statusText}`);
|
|
1696
1696
|
}
|
|
1697
1697
|
return response.json();
|
|
1698
1698
|
}
|
|
1699
1699
|
async getRawTransaction(txid) {
|
|
1700
|
-
const response = await
|
|
1700
|
+
const response = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
1701
1701
|
if (!response.ok) {
|
|
1702
1702
|
const error = await response.text();
|
|
1703
1703
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -1705,7 +1705,7 @@ var EsploraProvider = class {
|
|
|
1705
1705
|
return base.hex.decode((await response.text()).trim());
|
|
1706
1706
|
}
|
|
1707
1707
|
async getTxStatus(txid) {
|
|
1708
|
-
const txresponse = await
|
|
1708
|
+
const txresponse = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1709
1709
|
if (!txresponse.ok) {
|
|
1710
1710
|
throw new Error(txresponse.statusText);
|
|
1711
1711
|
}
|
|
@@ -1713,7 +1713,7 @@ var EsploraProvider = class {
|
|
|
1713
1713
|
if (!tx.status.confirmed) {
|
|
1714
1714
|
return { confirmed: false };
|
|
1715
1715
|
}
|
|
1716
|
-
const response = await
|
|
1716
|
+
const response = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1717
1717
|
if (!response.ok) {
|
|
1718
1718
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1719
1719
|
}
|
|
@@ -1997,9 +1997,9 @@ var EsploraProvider = class {
|
|
|
1997
1997
|
return { subscribers, teardown, started };
|
|
1998
1998
|
}
|
|
1999
1999
|
async getChainTip() {
|
|
2000
|
-
let tipBlocks = await
|
|
2000
|
+
let tipBlocks = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
2001
2001
|
if (tipBlocks.status === 404) {
|
|
2002
|
-
tipBlocks = await
|
|
2002
|
+
tipBlocks = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
|
|
2003
2003
|
}
|
|
2004
2004
|
if (!tipBlocks.ok) {
|
|
2005
2005
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
@@ -2021,7 +2021,7 @@ var EsploraProvider = class {
|
|
|
2021
2021
|
};
|
|
2022
2022
|
}
|
|
2023
2023
|
async broadcastPackage(parent, child) {
|
|
2024
|
-
const response = await
|
|
2024
|
+
const response = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
2025
2025
|
method: "POST",
|
|
2026
2026
|
headers: {
|
|
2027
2027
|
"Content-Type": "application/json"
|
|
@@ -2037,7 +2037,7 @@ var EsploraProvider = class {
|
|
|
2037
2037
|
return result;
|
|
2038
2038
|
}
|
|
2039
2039
|
async broadcastTx(tx) {
|
|
2040
|
-
const response = await
|
|
2040
|
+
const response = await chunkGLLBSULU_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
2041
2041
|
method: "POST",
|
|
2042
2042
|
headers: {
|
|
2043
2043
|
"Content-Type": "text/plain"
|
|
@@ -2220,7 +2220,7 @@ function findP2AOutput(tx) {
|
|
|
2220
2220
|
var CHILD_DUST_AMOUNT = 546;
|
|
2221
2221
|
function buildAnchorChild(params) {
|
|
2222
2222
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2223
|
-
const child = new
|
|
2223
|
+
const child = new chunkGLLBSULU_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2224
2224
|
child.addInput(findP2AOutput(parent));
|
|
2225
2225
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
2226
2226
|
for (const _ of fundingCoins) {
|
|
@@ -2268,7 +2268,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2268
2268
|
);
|
|
2269
2269
|
}
|
|
2270
2270
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2271
|
-
const tx = new
|
|
2271
|
+
const tx = new chunkGLLBSULU_cjs.Transaction({
|
|
2272
2272
|
version: 3,
|
|
2273
2273
|
lockTime: txLocktime
|
|
2274
2274
|
});
|
|
@@ -2344,7 +2344,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2344
2344
|
if (previousScriptKey.length !== 32) {
|
|
2345
2345
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2346
2346
|
}
|
|
2347
|
-
const cosigners =
|
|
2347
|
+
const cosigners = chunkGLLBSULU_cjs.getArkPsbtFields(child.root, 0, chunkGLLBSULU_cjs.CosignerPublicKey);
|
|
2348
2348
|
if (cosigners.length === 0) {
|
|
2349
2349
|
throw ErrMissingCosignersPublicKeys;
|
|
2350
2350
|
}
|
|
@@ -2402,7 +2402,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2402
2402
|
return new _EmulatorPacket(entries);
|
|
2403
2403
|
}
|
|
2404
2404
|
static fromBytes(data) {
|
|
2405
|
-
const reader = new
|
|
2405
|
+
const reader = new chunkXOT73T36_cjs.BufferReader(data);
|
|
2406
2406
|
const entryCount = reader.readCompactSize();
|
|
2407
2407
|
const entries = [];
|
|
2408
2408
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2420,7 +2420,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2420
2420
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2421
2421
|
}
|
|
2422
2422
|
serialize() {
|
|
2423
|
-
const writer = new
|
|
2423
|
+
const writer = new chunkXOT73T36_cjs.BufferWriter();
|
|
2424
2424
|
writer.writeCompactSize(this.entries.length);
|
|
2425
2425
|
for (const entry of this.entries) {
|
|
2426
2426
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2507,7 +2507,7 @@ var Extension = class _Extension {
|
|
|
2507
2507
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2508
2508
|
);
|
|
2509
2509
|
}
|
|
2510
|
-
const reader = new
|
|
2510
|
+
const reader = new chunkXOT73T36_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2511
2511
|
const packets = [];
|
|
2512
2512
|
while (reader.remaining() > 0) {
|
|
2513
2513
|
const packetType = reader.readByte();
|
|
@@ -2581,7 +2581,7 @@ var Extension = class _Extension {
|
|
|
2581
2581
|
*/
|
|
2582
2582
|
getAssetPacket() {
|
|
2583
2583
|
for (const p of this.packets) {
|
|
2584
|
-
if (p instanceof
|
|
2584
|
+
if (p instanceof chunkXOT73T36_cjs.Packet) {
|
|
2585
2585
|
return p;
|
|
2586
2586
|
}
|
|
2587
2587
|
}
|
|
@@ -2619,8 +2619,8 @@ var Extension = class _Extension {
|
|
|
2619
2619
|
};
|
|
2620
2620
|
function parsePacket(packetType, data) {
|
|
2621
2621
|
switch (packetType) {
|
|
2622
|
-
case
|
|
2623
|
-
return
|
|
2622
|
+
case chunkXOT73T36_cjs.Packet.PACKET_TYPE:
|
|
2623
|
+
return chunkXOT73T36_cjs.Packet.fromBytes(data);
|
|
2624
2624
|
case EmulatorPacket.PACKET_TYPE:
|
|
2625
2625
|
return EmulatorPacket.fromBytes(data);
|
|
2626
2626
|
default:
|
|
@@ -2667,16 +2667,16 @@ function buildOpReturnScript(data) {
|
|
|
2667
2667
|
}
|
|
2668
2668
|
return script;
|
|
2669
2669
|
}
|
|
2670
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2671
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2670
|
+
var ErrOffchainOutputNotFound = (address) => new chunkGLLBSULU_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2671
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
2672
2672
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2673
2673
|
);
|
|
2674
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2675
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2674
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkGLLBSULU_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2675
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
2676
2676
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2677
2677
|
);
|
|
2678
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2679
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2678
|
+
var ErrOnchainOutputNotFound = (address) => new chunkGLLBSULU_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2679
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
2680
2680
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2681
2681
|
);
|
|
2682
2682
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2685,7 +2685,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2685
2685
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2686
2686
|
if (!validatedCommitmentTxid) return;
|
|
2687
2687
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2688
|
-
throw new
|
|
2688
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
2689
2689
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2690
2690
|
);
|
|
2691
2691
|
}
|
|
@@ -2695,7 +2695,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2695
2695
|
for (const recipient of recipients) {
|
|
2696
2696
|
let arkAddress;
|
|
2697
2697
|
try {
|
|
2698
|
-
arkAddress =
|
|
2698
|
+
arkAddress = chunkGLLBSULU_cjs.ArkAddress.decode(recipient.address);
|
|
2699
2699
|
} catch {
|
|
2700
2700
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2701
2701
|
continue;
|
|
@@ -2707,7 +2707,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2707
2707
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2708
2708
|
for (const recipient of recipients) {
|
|
2709
2709
|
try {
|
|
2710
|
-
|
|
2710
|
+
chunkGLLBSULU_cjs.ArkAddress.decode(recipient.address);
|
|
2711
2711
|
} catch {
|
|
2712
2712
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2713
2713
|
continue;
|
|
@@ -2940,7 +2940,7 @@ function assetMintResolver() {
|
|
|
2940
2940
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
2941
2941
|
const minted = tx.assets.filter((a) => {
|
|
2942
2942
|
try {
|
|
2943
|
-
return base.hex.encode(
|
|
2943
|
+
return base.hex.encode(chunkXOT73T36_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
2944
2944
|
} catch {
|
|
2945
2945
|
return false;
|
|
2946
2946
|
}
|
|
@@ -2983,7 +2983,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2983
2983
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
2984
2984
|
inputsByAssetId.set(asset.assetId, [
|
|
2985
2985
|
...existing ?? [],
|
|
2986
|
-
|
|
2986
|
+
chunkXOT73T36_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
2987
2987
|
]);
|
|
2988
2988
|
}
|
|
2989
2989
|
}
|
|
@@ -2995,7 +2995,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2995
2995
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2996
2996
|
outputsByAssetId.set(asset.assetId, [
|
|
2997
2997
|
...existing ?? [],
|
|
2998
|
-
|
|
2998
|
+
chunkXOT73T36_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2999
2999
|
]);
|
|
3000
3000
|
}
|
|
3001
3001
|
}
|
|
@@ -3006,7 +3006,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3006
3006
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3007
3007
|
outputsByAssetId.set(asset.assetId, [
|
|
3008
3008
|
...existing ?? [],
|
|
3009
|
-
|
|
3009
|
+
chunkXOT73T36_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3010
3010
|
]);
|
|
3011
3011
|
}
|
|
3012
3012
|
}
|
|
@@ -3015,11 +3015,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3015
3015
|
for (const assetIdStr of allAssetIds) {
|
|
3016
3016
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
3017
3017
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
3018
|
-
const assetId =
|
|
3019
|
-
const group =
|
|
3018
|
+
const assetId = chunkXOT73T36_cjs.AssetId.fromString(assetIdStr);
|
|
3019
|
+
const group = chunkXOT73T36_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
3020
3020
|
groups.push(group);
|
|
3021
3021
|
}
|
|
3022
|
-
return
|
|
3022
|
+
return chunkXOT73T36_cjs.Packet.create(groups);
|
|
3023
3023
|
}
|
|
3024
3024
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
3025
3025
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -3056,7 +3056,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
|
|
|
3056
3056
|
}
|
|
3057
3057
|
function toXOnlySignerHex(pubkeyHex) {
|
|
3058
3058
|
const bytes = base.hex.decode(pubkeyHex);
|
|
3059
|
-
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(
|
|
3059
|
+
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkA2T3GGAK_cjs.toXOnly(bytes, "signer key"));
|
|
3060
3060
|
throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
|
|
3061
3061
|
}
|
|
3062
3062
|
function signerSetFromInfo(info) {
|
|
@@ -3103,13 +3103,13 @@ var toTimelock = (value) => ({
|
|
|
3103
3103
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
3104
3104
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
3105
3105
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
3106
|
-
throw new
|
|
3106
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3107
3107
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
3108
3108
|
);
|
|
3109
3109
|
}
|
|
3110
3110
|
const seconds = toSeconds(timelock);
|
|
3111
3111
|
if (seconds < policy.minSeconds) {
|
|
3112
|
-
throw new
|
|
3112
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3113
3113
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
3114
3114
|
);
|
|
3115
3115
|
}
|
|
@@ -3130,7 +3130,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
3130
3130
|
}
|
|
3131
3131
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
3132
3132
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
3133
|
-
throw new
|
|
3133
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3134
3134
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
3135
3135
|
);
|
|
3136
3136
|
}
|
|
@@ -3160,21 +3160,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
3160
3160
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
3161
3161
|
let script;
|
|
3162
3162
|
try {
|
|
3163
|
-
script =
|
|
3163
|
+
script = chunkGLLBSULU_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
3164
3164
|
} catch (e) {
|
|
3165
|
-
throw new
|
|
3165
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3166
3166
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
3167
3167
|
);
|
|
3168
3168
|
}
|
|
3169
3169
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
3170
3170
|
const { pubkeys } = script.params;
|
|
3171
3171
|
if (pubkeys.length !== 1) {
|
|
3172
|
-
throw new
|
|
3172
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3173
3173
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
3174
3174
|
);
|
|
3175
3175
|
}
|
|
3176
3176
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
3177
|
-
throw new
|
|
3177
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3178
3178
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
3179
3179
|
);
|
|
3180
3180
|
}
|
|
@@ -3218,8 +3218,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
3218
3218
|
function buildVirtualTx(inputs, outputs) {
|
|
3219
3219
|
let lockTime = 0n;
|
|
3220
3220
|
for (const input of inputs) {
|
|
3221
|
-
const tapscript =
|
|
3222
|
-
if (
|
|
3221
|
+
const tapscript = chunkGLLBSULU_cjs.decodeTapscript(chunkGLLBSULU_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
3222
|
+
if (chunkGLLBSULU_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
3223
3223
|
if (lockTime !== 0n) {
|
|
3224
3224
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
3225
3225
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -3230,7 +3230,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3230
3230
|
}
|
|
3231
3231
|
}
|
|
3232
3232
|
}
|
|
3233
|
-
const tx = new
|
|
3233
|
+
const tx = new chunkGLLBSULU_cjs.Transaction({
|
|
3234
3234
|
version: 3,
|
|
3235
3235
|
lockTime: Number(lockTime)
|
|
3236
3236
|
});
|
|
@@ -3240,12 +3240,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3240
3240
|
index: input.vout,
|
|
3241
3241
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3242
3242
|
witnessUtxo: {
|
|
3243
|
-
script:
|
|
3243
|
+
script: chunkGLLBSULU_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3244
3244
|
amount: BigInt(input.value)
|
|
3245
3245
|
},
|
|
3246
3246
|
tapLeafScript: [input.tapLeafScript]
|
|
3247
3247
|
});
|
|
3248
|
-
|
|
3248
|
+
chunkGLLBSULU_cjs.setArkPsbtField(tx, i, chunkGLLBSULU_cjs.VtxoTaprootTree, input.tapTree);
|
|
3249
3249
|
}
|
|
3250
3250
|
for (const output of outputs) {
|
|
3251
3251
|
tx.addOutput(output);
|
|
@@ -3254,8 +3254,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3254
3254
|
return tx;
|
|
3255
3255
|
}
|
|
3256
3256
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3257
|
-
const collaborativeClosure =
|
|
3258
|
-
const checkpointVtxoScript = new
|
|
3257
|
+
const collaborativeClosure = chunkGLLBSULU_cjs.decodeTapscript(chunkGLLBSULU_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3258
|
+
const checkpointVtxoScript = new chunkGLLBSULU_cjs.VtxoScript([
|
|
3259
3259
|
serverUnrollScript.script,
|
|
3260
3260
|
collaborativeClosure.script
|
|
3261
3261
|
]);
|
|
@@ -3331,7 +3331,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3331
3331
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3332
3332
|
const sig = signature.subarray(0, 64);
|
|
3333
3333
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3334
|
-
const sighashName =
|
|
3334
|
+
const sighashName = chunkGLLBSULU_cjs.formatSighash(sighashType);
|
|
3335
3335
|
throw new Error(
|
|
3336
3336
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3337
3337
|
);
|
|
@@ -3405,7 +3405,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3405
3405
|
}
|
|
3406
3406
|
function isValidArkAddress(address) {
|
|
3407
3407
|
try {
|
|
3408
|
-
|
|
3408
|
+
chunkGLLBSULU_cjs.ArkAddress.decode(address);
|
|
3409
3409
|
return true;
|
|
3410
3410
|
} catch (e) {
|
|
3411
3411
|
return false;
|
|
@@ -3413,16 +3413,16 @@ function isValidArkAddress(address) {
|
|
|
3413
3413
|
}
|
|
3414
3414
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3415
3415
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3416
|
-
throw new
|
|
3416
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3417
3417
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3418
3418
|
);
|
|
3419
3419
|
}
|
|
3420
3420
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3421
3421
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3422
|
-
const server =
|
|
3422
|
+
const server = chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3423
3423
|
const local = byTxid.get(server.id);
|
|
3424
3424
|
if (!local) {
|
|
3425
|
-
throw new
|
|
3425
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3426
3426
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3427
3427
|
);
|
|
3428
3428
|
}
|
|
@@ -3432,14 +3432,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3432
3432
|
}
|
|
3433
3433
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3434
3434
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3435
|
-
throw new
|
|
3435
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3436
3436
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3437
3437
|
);
|
|
3438
3438
|
}
|
|
3439
3439
|
if (response.finalArkTx === void 0) return;
|
|
3440
|
-
const finalTxid =
|
|
3440
|
+
const finalTxid = chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3441
3441
|
if (finalTxid !== signedArkTx.id) {
|
|
3442
|
-
throw new
|
|
3442
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3443
3443
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3444
3444
|
);
|
|
3445
3445
|
}
|
|
@@ -3458,10 +3458,10 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex,
|
|
|
3458
3458
|
[serverPubkeyHex],
|
|
3459
3459
|
void 0,
|
|
3460
3460
|
void 0,
|
|
3461
|
-
payment_js.tapLeafHash(
|
|
3461
|
+
payment_js.tapLeafHash(chunkGLLBSULU_cjs.scriptFromTapLeafScript(leaf))
|
|
3462
3462
|
);
|
|
3463
3463
|
} catch (error) {
|
|
3464
|
-
throw new
|
|
3464
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3465
3465
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3466
3466
|
);
|
|
3467
3467
|
}
|
|
@@ -3470,20 +3470,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3470
3470
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3471
3471
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3472
3472
|
if (checkpoint.inputsLength !== 1) {
|
|
3473
|
-
throw new
|
|
3473
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3474
3474
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3475
3475
|
);
|
|
3476
3476
|
}
|
|
3477
3477
|
const spent = checkpoint.getInput(0);
|
|
3478
3478
|
if (!spent.txid || spent.index === void 0) {
|
|
3479
|
-
throw new
|
|
3479
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3480
3480
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3481
3481
|
);
|
|
3482
3482
|
}
|
|
3483
3483
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3484
3484
|
const input = byOutpoint.get(outpoint);
|
|
3485
3485
|
if (!input) {
|
|
3486
|
-
throw new
|
|
3486
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3487
3487
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3488
3488
|
);
|
|
3489
3489
|
}
|
|
@@ -3491,7 +3491,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3491
3491
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3492
3492
|
);
|
|
3493
3493
|
if (!rebuilt) {
|
|
3494
|
-
throw new
|
|
3494
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3495
3495
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3496
3496
|
);
|
|
3497
3497
|
}
|
|
@@ -3517,9 +3517,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3517
3517
|
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
3518
3518
|
matched.forEach(({ server }, index) => {
|
|
3519
3519
|
try {
|
|
3520
|
-
|
|
3520
|
+
chunkGLLBSULU_cjs.assertAllowedSighashTypes(server);
|
|
3521
3521
|
} catch (error) {
|
|
3522
|
-
throw new
|
|
3522
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3523
3523
|
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
3524
3524
|
);
|
|
3525
3525
|
}
|
|
@@ -3527,12 +3527,12 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3527
3527
|
const verify = options?.verifyServerSignatures;
|
|
3528
3528
|
if (verify) {
|
|
3529
3529
|
if (response.finalArkTx === void 0) {
|
|
3530
|
-
throw new
|
|
3530
|
+
throw new chunkGLLBSULU_cjs.ServerResponseMismatchError(
|
|
3531
3531
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3532
3532
|
);
|
|
3533
3533
|
}
|
|
3534
|
-
const finalArkTx =
|
|
3535
|
-
const serverPubkeyHex = base.hex.encode(
|
|
3534
|
+
const finalArkTx = chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3535
|
+
const serverPubkeyHex = base.hex.encode(chunkA2T3GGAK_cjs.toXOnly(verify.serverPubkey, "server key"));
|
|
3536
3536
|
for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
|
|
3537
3537
|
assertServerSignedLeaf(
|
|
3538
3538
|
finalArkTx,
|
|
@@ -3588,12 +3588,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3588
3588
|
return {
|
|
3589
3589
|
...identity,
|
|
3590
3590
|
sign: async (tx, inputIndexes) => {
|
|
3591
|
-
const signed =
|
|
3591
|
+
const signed = chunkGLLBSULU_cjs.Transaction.fromPSBT(
|
|
3592
3592
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3593
3593
|
);
|
|
3594
3594
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3595
3595
|
for (const index of indexes) {
|
|
3596
|
-
|
|
3596
|
+
chunkGLLBSULU_cjs.setArkPsbtField(signed, index, chunkGLLBSULU_cjs.ConditionWitness, [preimage]);
|
|
3597
3597
|
}
|
|
3598
3598
|
return signed;
|
|
3599
3599
|
}
|
|
@@ -3788,7 +3788,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
3788
3788
|
};
|
|
3789
3789
|
}
|
|
3790
3790
|
function deriveContractTapscripts(contract) {
|
|
3791
|
-
const handler =
|
|
3791
|
+
const handler = chunkA2T3GGAK_cjs.contractHandlers.get(contract.type);
|
|
3792
3792
|
if (!handler) {
|
|
3793
3793
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3794
3794
|
}
|
|
@@ -3859,7 +3859,7 @@ function getRandomId() {
|
|
|
3859
3859
|
}
|
|
3860
3860
|
function isValidArkAddress2(address) {
|
|
3861
3861
|
try {
|
|
3862
|
-
|
|
3862
|
+
chunkGLLBSULU_cjs.ArkAddress.decode(address);
|
|
3863
3863
|
return true;
|
|
3864
3864
|
} catch (e) {
|
|
3865
3865
|
return false;
|
|
@@ -3887,7 +3887,7 @@ function assertRecipientArkadeAddress(encoded, address, context) {
|
|
|
3887
3887
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
3888
3888
|
let derived;
|
|
3889
3889
|
try {
|
|
3890
|
-
derived =
|
|
3890
|
+
derived = chunkGLLBSULU_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
3891
3891
|
} catch (e) {
|
|
3892
3892
|
throw new Error(
|
|
3893
3893
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -3904,7 +3904,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3904
3904
|
for (const recipient of recipients) {
|
|
3905
3905
|
let address;
|
|
3906
3906
|
try {
|
|
3907
|
-
address =
|
|
3907
|
+
address = chunkGLLBSULU_cjs.ArkAddress.decode(recipient.address);
|
|
3908
3908
|
} catch (e) {
|
|
3909
3909
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
3910
3910
|
}
|
|
@@ -3929,7 +3929,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3929
3929
|
|
|
3930
3930
|
// src/contracts/spendability.ts
|
|
3931
3931
|
function isContractGenericallySpendable(contract) {
|
|
3932
|
-
return
|
|
3932
|
+
return chunkA2T3GGAK_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
3933
3933
|
}
|
|
3934
3934
|
function gatedContracts(contracts) {
|
|
3935
3935
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -3951,7 +3951,7 @@ function gateExclusion(gated) {
|
|
|
3951
3951
|
return (vtxo) => {
|
|
3952
3952
|
const type = gatedTypeOf(vtxo, gated);
|
|
3953
3953
|
if (type === void 0) return void 0;
|
|
3954
|
-
if (!
|
|
3954
|
+
if (!chunkA2T3GGAK_cjs.contractHandlers.has(type)) {
|
|
3955
3955
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
3956
3956
|
}
|
|
3957
3957
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -3987,7 +3987,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
3987
3987
|
continue;
|
|
3988
3988
|
}
|
|
3989
3989
|
for (const v of vtxos) {
|
|
3990
|
-
if (!
|
|
3990
|
+
if (!chunkGLLBSULU_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
|
|
3991
3991
|
out.add(`${v.txid}:${v.vout}`);
|
|
3992
3992
|
}
|
|
3993
3993
|
}
|
|
@@ -4022,10 +4022,10 @@ function byValueDescending(vtxos) {
|
|
|
4022
4022
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
4023
4023
|
}
|
|
4024
4024
|
async function fetchTimeHeight(wallet) {
|
|
4025
|
-
return
|
|
4025
|
+
return chunkGLLBSULU_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
4026
4026
|
}
|
|
4027
4027
|
function canMigrateBySend(vtxo, now) {
|
|
4028
|
-
if (!
|
|
4028
|
+
if (!chunkGLLBSULU_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
4029
4029
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
4030
4030
|
}
|
|
4031
4031
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -4033,7 +4033,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
4033
4033
|
if (vtxo.isSwept) return -Infinity;
|
|
4034
4034
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
4035
4035
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
4036
|
-
return
|
|
4036
|
+
return chunkGLLBSULU_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
4037
4037
|
}
|
|
4038
4038
|
return Infinity;
|
|
4039
4039
|
};
|
|
@@ -4060,7 +4060,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
4060
4060
|
const payable = [];
|
|
4061
4061
|
const net = /* @__PURE__ */ new Map();
|
|
4062
4062
|
for (const vtxo of vtxos) {
|
|
4063
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4063
|
+
const inputFee = estimator.evalOffchainInput(chunkGLLBSULU_cjs.toOffchainInputFeeParams(vtxo));
|
|
4064
4064
|
if (inputFee.satoshis >= vtxo.value) {
|
|
4065
4065
|
continue;
|
|
4066
4066
|
}
|
|
@@ -4086,7 +4086,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
4086
4086
|
}
|
|
4087
4087
|
const outputFee = estimator.evalOffchainOutput({
|
|
4088
4088
|
amount: subtotal,
|
|
4089
|
-
script: base.hex.encode(
|
|
4089
|
+
script: base.hex.encode(chunkGLLBSULU_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4090
4090
|
});
|
|
4091
4091
|
return subtotal - BigInt(outputFee.satoshis);
|
|
4092
4092
|
}
|
|
@@ -4100,10 +4100,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
4100
4100
|
};
|
|
4101
4101
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
4102
4102
|
return vtxos.filter((vtxo) => {
|
|
4103
|
-
if (
|
|
4103
|
+
if (chunkGLLBSULU_cjs.canRecoverOnchain(vtxo, now)) {
|
|
4104
4104
|
return true;
|
|
4105
4105
|
}
|
|
4106
|
-
if (
|
|
4106
|
+
if (chunkGLLBSULU_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
4107
4107
|
return true;
|
|
4108
4108
|
}
|
|
4109
4109
|
return false;
|
|
@@ -4135,7 +4135,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
4135
4135
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
4136
4136
|
if (vtxo.isUnrolled) return false;
|
|
4137
4137
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
4138
|
-
const expiresAt =
|
|
4138
|
+
const expiresAt = chunkGLLBSULU_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
4139
4139
|
if (expiresAt === void 0) return false;
|
|
4140
4140
|
const now = Date.now();
|
|
4141
4141
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -4146,7 +4146,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
4146
4146
|
return vtxos.filter(
|
|
4147
4147
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
4148
4148
|
// property and would otherwise re-admit an exited coin on its own.
|
|
4149
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
4149
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkGLLBSULU_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
4150
4150
|
);
|
|
4151
4151
|
}
|
|
4152
4152
|
function isMigrationCapable(wallet) {
|
|
@@ -4733,11 +4733,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
4733
4733
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
4734
4734
|
);
|
|
4735
4735
|
}
|
|
4736
|
-
const tx = new
|
|
4736
|
+
const tx = new chunkGLLBSULU_cjs.Transaction();
|
|
4737
4737
|
for (const utxo of expiredUtxos) {
|
|
4738
|
-
const utxoScript =
|
|
4738
|
+
const utxoScript = chunkGLLBSULU_cjs.VtxoScript.decode(utxo.tapTree);
|
|
4739
4739
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
4740
|
-
(leaf) =>
|
|
4740
|
+
(leaf) => chunkGLLBSULU_cjs.CSVMultisigTapscript.isScriptValid(chunkGLLBSULU_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
4741
4741
|
);
|
|
4742
4742
|
if (!utxoExitLeaf) {
|
|
4743
4743
|
throw new Error(
|
|
@@ -4752,7 +4752,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4752
4752
|
amount: BigInt(utxo.value)
|
|
4753
4753
|
},
|
|
4754
4754
|
tapLeafScript: [utxoExitLeaf],
|
|
4755
|
-
sequence:
|
|
4755
|
+
sequence: chunkGLLBSULU_cjs.getSequence(utxoExitLeaf)
|
|
4756
4756
|
});
|
|
4757
4757
|
}
|
|
4758
4758
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -4995,8 +4995,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4995
4995
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
4996
4996
|
if (cls.status === "CURRENT") continue;
|
|
4997
4997
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
4998
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
4999
|
-
const spendable = live.filter((v) => !
|
|
4998
|
+
const recoverable = live.filter((v) => v.isSwept && !chunkGLLBSULU_cjs.hasTerminalSpend(v));
|
|
4999
|
+
const spendable = live.filter((v) => !chunkGLLBSULU_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
5000
5000
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
5001
5001
|
let recoverableCount = 0;
|
|
5002
5002
|
let recoverableValue = 0;
|
|
@@ -5270,7 +5270,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5270
5270
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
5271
5271
|
getBoardingTimelock() {
|
|
5272
5272
|
const wallet = this.getSweepWallet();
|
|
5273
|
-
const exitScript =
|
|
5273
|
+
const exitScript = chunkGLLBSULU_cjs.CSVMultisigTapscript.decode(
|
|
5274
5274
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5275
5275
|
);
|
|
5276
5276
|
return exitScript.params.timelock;
|
|
@@ -5401,8 +5401,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5401
5401
|
* or doesn't carry the metadata.
|
|
5402
5402
|
*/
|
|
5403
5403
|
extractSpentOutpoint(error) {
|
|
5404
|
-
const ark =
|
|
5405
|
-
if (!
|
|
5404
|
+
const ark = chunkGLLBSULU_cjs.maybeArkError(error);
|
|
5405
|
+
if (!chunkGLLBSULU_cjs.isArkError(ark, chunkGLLBSULU_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5406
5406
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5407
5407
|
if (typeof raw !== "string") return void 0;
|
|
5408
5408
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -5592,7 +5592,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5592
5592
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
5593
5593
|
break;
|
|
5594
5594
|
}
|
|
5595
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5595
|
+
const inputFee = estimator.evalOffchainInput(chunkGLLBSULU_cjs.toOffchainInputFeeParams(v));
|
|
5596
5596
|
if (inputFee.satoshis >= v.value) {
|
|
5597
5597
|
continue;
|
|
5598
5598
|
}
|
|
@@ -5612,7 +5612,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5612
5612
|
const arkAddress = await this.wallet.getAddress();
|
|
5613
5613
|
const outputFee = estimator.evalOffchainOutput({
|
|
5614
5614
|
amount: totalAmount,
|
|
5615
|
-
script: base.hex.encode(
|
|
5615
|
+
script: base.hex.encode(chunkGLLBSULU_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
5616
5616
|
});
|
|
5617
5617
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
5618
5618
|
if (totalAmount < dustAmount) return;
|
|
@@ -5692,7 +5692,7 @@ var ArkNote = class _ArkNote {
|
|
|
5692
5692
|
this.value = value;
|
|
5693
5693
|
this.HRP = HRP;
|
|
5694
5694
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
5695
|
-
this.vtxoScript = new
|
|
5695
|
+
this.vtxoScript = new chunkGLLBSULU_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
5696
5696
|
const leaf = this.vtxoScript.leaves[0];
|
|
5697
5697
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
5698
5698
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -5859,7 +5859,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5859
5859
|
const privateKey = data.slice(1, 33);
|
|
5860
5860
|
const serverPubKey = data.slice(33, 65);
|
|
5861
5861
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
5862
|
-
const csvTimelock =
|
|
5862
|
+
const csvTimelock = chunkGLLBSULU_cjs.sequenceToTimelock(sequence);
|
|
5863
5863
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
5864
5864
|
}
|
|
5865
5865
|
toString() {
|
|
@@ -5867,7 +5867,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5867
5867
|
data[0] = _ArkadeCash.Version;
|
|
5868
5868
|
data.set(this._privateKey, 1);
|
|
5869
5869
|
data.set(this._serverPubKey, 33);
|
|
5870
|
-
const sequence =
|
|
5870
|
+
const sequence = chunkGLLBSULU_cjs.timelockToSequence(this.csvTimelock);
|
|
5871
5871
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
5872
5872
|
const words = base.bech32m.toWords(data);
|
|
5873
5873
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -5876,7 +5876,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5876
5876
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
5877
5877
|
}
|
|
5878
5878
|
get vtxoScript() {
|
|
5879
|
-
return new
|
|
5879
|
+
return new chunkA2T3GGAK_cjs.DefaultVtxo.Script({
|
|
5880
5880
|
pubKey: this._publicKey,
|
|
5881
5881
|
serverPubKey: this._serverPubKey,
|
|
5882
5882
|
csvTimelock: this.csvTimelock
|
|
@@ -6137,7 +6137,7 @@ async function captureExitBranch(params) {
|
|
|
6137
6137
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
6138
6138
|
if (nonCommitment.length > 0) {
|
|
6139
6139
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
6140
|
-
psbtByTxid.set(
|
|
6140
|
+
psbtByTxid.set(chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6141
6141
|
}
|
|
6142
6142
|
}
|
|
6143
6143
|
}
|
|
@@ -6180,10 +6180,10 @@ var IndexerExitDataSource = class {
|
|
|
6180
6180
|
while (hasMore) {
|
|
6181
6181
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
6182
6182
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
6183
|
-
{ pageIndex, pageSize:
|
|
6183
|
+
{ pageIndex, pageSize: chunkGLLBSULU_cjs.DEFAULT_PAGE_SIZE }
|
|
6184
6184
|
);
|
|
6185
6185
|
chain.push(...page);
|
|
6186
|
-
hasMore = meta ? page.length ===
|
|
6186
|
+
hasMore = meta ? page.length === chunkGLLBSULU_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6187
6187
|
pageIndex++;
|
|
6188
6188
|
}
|
|
6189
6189
|
return chain;
|
|
@@ -6195,12 +6195,12 @@ var IndexerExitDataSource = class {
|
|
|
6195
6195
|
while (hasMore) {
|
|
6196
6196
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
6197
6197
|
pageIndex,
|
|
6198
|
-
pageSize:
|
|
6198
|
+
pageSize: chunkGLLBSULU_cjs.DEFAULT_PAGE_SIZE
|
|
6199
6199
|
});
|
|
6200
6200
|
for (const psbt of txs) {
|
|
6201
|
-
out.set(
|
|
6201
|
+
out.set(chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6202
6202
|
}
|
|
6203
|
-
hasMore = page ? txs.length ===
|
|
6203
|
+
hasMore = page ? txs.length === chunkGLLBSULU_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6204
6204
|
pageIndex++;
|
|
6205
6205
|
}
|
|
6206
6206
|
return out;
|
|
@@ -6221,7 +6221,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
6221
6221
|
}
|
|
6222
6222
|
}
|
|
6223
6223
|
function psbtInputTxids(psbtBase64) {
|
|
6224
|
-
const tx =
|
|
6224
|
+
const tx = chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
6225
6225
|
const ids = [];
|
|
6226
6226
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
6227
6227
|
const txid = tx.getInput(i).txid;
|
|
@@ -6580,10 +6580,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
|
|
|
6580
6580
|
try {
|
|
6581
6581
|
info = await arkProvider.getInfo();
|
|
6582
6582
|
} catch (err) {
|
|
6583
|
-
if (opts?.requireLive || !
|
|
6583
|
+
if (opts?.requireLive || !chunkGLLBSULU_cjs.isRetryableProviderError(err)) throw err;
|
|
6584
6584
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
6585
6585
|
if (!snapshot) {
|
|
6586
|
-
throw new
|
|
6586
|
+
throw new chunkGLLBSULU_cjs.ProviderUnavailableError(
|
|
6587
6587
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
6588
6588
|
{ cause: err }
|
|
6589
6589
|
);
|
|
@@ -6990,7 +6990,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
|
|
|
6990
6990
|
return [...txids];
|
|
6991
6991
|
}
|
|
6992
6992
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
|
|
6993
|
-
const normalized = vtxos.map(
|
|
6993
|
+
const normalized = vtxos.map(chunkGLLBSULU_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
6994
6994
|
const localCreatedAt = localCreatedAtByTxid(normalized);
|
|
6995
6995
|
const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
|
|
6996
6996
|
const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
|
|
@@ -7164,7 +7164,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7164
7164
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
7165
7165
|
withRecoverable: false
|
|
7166
7166
|
});
|
|
7167
|
-
const controlAssetRef = params.controlAssetId ?
|
|
7167
|
+
const controlAssetRef = params.controlAssetId ? chunkXOT73T36_cjs.AssetRef.fromId(chunkXOT73T36_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
7168
7168
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
7169
7169
|
let totalBtcSelected = 0n;
|
|
7170
7170
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -7177,8 +7177,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7177
7177
|
}
|
|
7178
7178
|
}
|
|
7179
7179
|
const groups = [];
|
|
7180
|
-
const issuedAssetOutput =
|
|
7181
|
-
const issuedAssetGroup =
|
|
7180
|
+
const issuedAssetOutput = chunkXOT73T36_cjs.AssetOutput.create(0, params.amount);
|
|
7181
|
+
const issuedAssetGroup = chunkXOT73T36_cjs.AssetGroup.create(
|
|
7182
7182
|
null,
|
|
7183
7183
|
controlAssetRef,
|
|
7184
7184
|
[],
|
|
@@ -7193,28 +7193,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7193
7193
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7194
7194
|
for (const asset of assets) {
|
|
7195
7195
|
if (asset.assetId !== assetId) continue;
|
|
7196
|
-
changeInputs.push(
|
|
7196
|
+
changeInputs.push(chunkXOT73T36_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7197
7197
|
}
|
|
7198
7198
|
}
|
|
7199
7199
|
groups.push(
|
|
7200
|
-
|
|
7201
|
-
|
|
7200
|
+
chunkXOT73T36_cjs.AssetGroup.create(
|
|
7201
|
+
chunkXOT73T36_cjs.AssetId.fromString(assetId),
|
|
7202
7202
|
null,
|
|
7203
7203
|
changeInputs,
|
|
7204
|
-
[
|
|
7204
|
+
[chunkXOT73T36_cjs.AssetOutput.create(0, amount)],
|
|
7205
7205
|
[]
|
|
7206
7206
|
)
|
|
7207
7207
|
);
|
|
7208
7208
|
}
|
|
7209
7209
|
}
|
|
7210
7210
|
const address = await this.wallet.getAddress();
|
|
7211
|
-
const outputAddress =
|
|
7211
|
+
const outputAddress = chunkGLLBSULU_cjs.ArkAddress.decode(address);
|
|
7212
7212
|
const outputs = [
|
|
7213
7213
|
{
|
|
7214
7214
|
script: outputAddress.pkScript,
|
|
7215
7215
|
amount: BigInt(totalBtcSelected)
|
|
7216
7216
|
},
|
|
7217
|
-
Extension.create([
|
|
7217
|
+
Extension.create([chunkXOT73T36_cjs.Packet.create(groups)]).txOut()
|
|
7218
7218
|
];
|
|
7219
7219
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
7220
7220
|
coinSelection.inputs,
|
|
@@ -7222,7 +7222,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7222
7222
|
);
|
|
7223
7223
|
return {
|
|
7224
7224
|
arkTxId: arkTxid,
|
|
7225
|
-
assetId:
|
|
7225
|
+
assetId: chunkXOT73T36_cjs.AssetId.create(arkTxid, 0).toString()
|
|
7226
7226
|
};
|
|
7227
7227
|
}
|
|
7228
7228
|
/**
|
|
@@ -7294,16 +7294,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7294
7294
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7295
7295
|
for (const asset of assets) {
|
|
7296
7296
|
if (asset.assetId !== params.assetId) continue;
|
|
7297
|
-
reissueInputs.push(
|
|
7297
|
+
reissueInputs.push(chunkXOT73T36_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7298
7298
|
}
|
|
7299
7299
|
}
|
|
7300
7300
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7301
|
-
const reissueAssetIdObj =
|
|
7302
|
-
const reissueAssetGroup =
|
|
7301
|
+
const reissueAssetIdObj = chunkXOT73T36_cjs.AssetId.fromString(params.assetId);
|
|
7302
|
+
const reissueAssetGroup = chunkXOT73T36_cjs.AssetGroup.create(
|
|
7303
7303
|
reissueAssetIdObj,
|
|
7304
7304
|
null,
|
|
7305
7305
|
reissueInputs,
|
|
7306
|
-
[
|
|
7306
|
+
[chunkXOT73T36_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7307
7307
|
[]
|
|
7308
7308
|
);
|
|
7309
7309
|
const groups = [reissueAssetGroup];
|
|
@@ -7312,27 +7312,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7312
7312
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7313
7313
|
for (const asset of assets) {
|
|
7314
7314
|
if (asset.assetId !== assetId) continue;
|
|
7315
|
-
changeInputs.push(
|
|
7315
|
+
changeInputs.push(chunkXOT73T36_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7316
7316
|
}
|
|
7317
7317
|
}
|
|
7318
7318
|
groups.push(
|
|
7319
|
-
|
|
7320
|
-
|
|
7319
|
+
chunkXOT73T36_cjs.AssetGroup.create(
|
|
7320
|
+
chunkXOT73T36_cjs.AssetId.fromString(assetId),
|
|
7321
7321
|
null,
|
|
7322
7322
|
changeInputs,
|
|
7323
|
-
[
|
|
7323
|
+
[chunkXOT73T36_cjs.AssetOutput.create(0, amount)],
|
|
7324
7324
|
[]
|
|
7325
7325
|
)
|
|
7326
7326
|
);
|
|
7327
7327
|
}
|
|
7328
7328
|
const address = await this.wallet.getAddress();
|
|
7329
|
-
const outputAddress =
|
|
7329
|
+
const outputAddress = chunkGLLBSULU_cjs.ArkAddress.decode(address);
|
|
7330
7330
|
const outputs = [
|
|
7331
7331
|
{
|
|
7332
7332
|
script: outputAddress.pkScript,
|
|
7333
7333
|
amount: BigInt(totalBtcSelected)
|
|
7334
7334
|
},
|
|
7335
|
-
Extension.create([
|
|
7335
|
+
Extension.create([chunkXOT73T36_cjs.Packet.create(groups)]).txOut()
|
|
7336
7336
|
];
|
|
7337
7337
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7338
7338
|
return arkTxid;
|
|
@@ -7399,27 +7399,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7399
7399
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7400
7400
|
for (const asset of assets) {
|
|
7401
7401
|
if (asset.assetId !== assetId) continue;
|
|
7402
|
-
changeInputs.push(
|
|
7402
|
+
changeInputs.push(chunkXOT73T36_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7403
7403
|
}
|
|
7404
7404
|
}
|
|
7405
7405
|
groups.push(
|
|
7406
|
-
|
|
7407
|
-
|
|
7406
|
+
chunkXOT73T36_cjs.AssetGroup.create(
|
|
7407
|
+
chunkXOT73T36_cjs.AssetId.fromString(assetId),
|
|
7408
7408
|
null,
|
|
7409
7409
|
changeInputs,
|
|
7410
|
-
amount > 0n ? [
|
|
7410
|
+
amount > 0n ? [chunkXOT73T36_cjs.AssetOutput.create(0, amount)] : [],
|
|
7411
7411
|
[]
|
|
7412
7412
|
)
|
|
7413
7413
|
);
|
|
7414
7414
|
}
|
|
7415
7415
|
const address = await this.wallet.getAddress();
|
|
7416
|
-
const outputAddress =
|
|
7416
|
+
const outputAddress = chunkGLLBSULU_cjs.ArkAddress.decode(address);
|
|
7417
7417
|
const outputs = [
|
|
7418
7418
|
{
|
|
7419
7419
|
script: outputAddress.pkScript,
|
|
7420
7420
|
amount: BigInt(totalBtcSelected)
|
|
7421
7421
|
},
|
|
7422
|
-
Extension.create([
|
|
7422
|
+
Extension.create([chunkXOT73T36_cjs.Packet.create(groups)]).txOut()
|
|
7423
7423
|
];
|
|
7424
7424
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7425
7425
|
return arkTxid;
|
|
@@ -7444,7 +7444,7 @@ function castMetadata(metadata) {
|
|
|
7444
7444
|
} else {
|
|
7445
7445
|
throw new Error("Invalid metadata value type");
|
|
7446
7446
|
}
|
|
7447
|
-
md.push(
|
|
7447
|
+
md.push(chunkXOT73T36_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7448
7448
|
}
|
|
7449
7449
|
return md;
|
|
7450
7450
|
}
|
|
@@ -7465,10 +7465,10 @@ var DelegateManagerImpl = class {
|
|
|
7465
7465
|
if (vtxos.length === 0) {
|
|
7466
7466
|
return { delegated: [], failed: [] };
|
|
7467
7467
|
}
|
|
7468
|
-
const destinationScript =
|
|
7468
|
+
const destinationScript = chunkGLLBSULU_cjs.ArkAddress.decode(destination).pkScript;
|
|
7469
7469
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
7470
7470
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
7471
|
-
const eligible = vtxos.map(
|
|
7471
|
+
const eligible = vtxos.map(chunkGLLBSULU_cjs.normalizeVtxo).filter(
|
|
7472
7472
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7473
7473
|
);
|
|
7474
7474
|
if (eligible.length === 0) {
|
|
@@ -7497,7 +7497,7 @@ var DelegateManagerImpl = class {
|
|
|
7497
7497
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7498
7498
|
let recoverableVtxos = [];
|
|
7499
7499
|
for (const vtxo of eligible) {
|
|
7500
|
-
if (
|
|
7500
|
+
if (chunkGLLBSULU_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7501
7501
|
recoverableVtxos.push(vtxo);
|
|
7502
7502
|
continue;
|
|
7503
7503
|
}
|
|
@@ -7565,7 +7565,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7565
7565
|
}
|
|
7566
7566
|
if (!delegateAt) {
|
|
7567
7567
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7568
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7568
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkGLLBSULU_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
|
|
7569
7569
|
(min, coin) => Math.min(min, coin.expiresAt.getTime()),
|
|
7570
7570
|
Number.MAX_SAFE_INTEGER
|
|
7571
7571
|
);
|
|
@@ -7597,7 +7597,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7597
7597
|
let amount = 0n;
|
|
7598
7598
|
for (const coin of vtxos) {
|
|
7599
7599
|
const inputFee = estimator.evalOffchainInput({
|
|
7600
|
-
...
|
|
7600
|
+
...chunkGLLBSULU_cjs.toOffchainInputFeeParams(coin),
|
|
7601
7601
|
type: "vtxo"
|
|
7602
7602
|
});
|
|
7603
7603
|
if (inputFee.value >= coin.value) {
|
|
@@ -7611,7 +7611,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7611
7611
|
const delegateFee = BigInt(Number(fee));
|
|
7612
7612
|
if (delegateFee > 0n) {
|
|
7613
7613
|
outputs.push({
|
|
7614
|
-
script:
|
|
7614
|
+
script: chunkGLLBSULU_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
7615
7615
|
amount: delegateFee
|
|
7616
7616
|
});
|
|
7617
7617
|
}
|
|
@@ -7644,10 +7644,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7644
7644
|
destinationScript
|
|
7645
7645
|
);
|
|
7646
7646
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
7647
|
-
btcSigner.Address(
|
|
7647
|
+
btcSigner.Address(chunkGLLBSULU_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
7648
7648
|
);
|
|
7649
7649
|
const forfeits = await Promise.all(
|
|
7650
|
-
vtxos.filter((v) => !
|
|
7650
|
+
vtxos.filter((v) => !chunkGLLBSULU_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
7651
7651
|
const forfeit = await makeDelegateForfeitTx(
|
|
7652
7652
|
coin,
|
|
7653
7653
|
dust,
|
|
@@ -7672,7 +7672,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
7672
7672
|
index: input.vout,
|
|
7673
7673
|
witnessUtxo: {
|
|
7674
7674
|
amount: BigInt(input.value),
|
|
7675
|
-
script:
|
|
7675
|
+
script: chunkGLLBSULU_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
7676
7676
|
},
|
|
7677
7677
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
7678
7678
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -7730,7 +7730,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
7730
7730
|
expire_at: 0,
|
|
7731
7731
|
cosigners_public_keys: cosignerPubKeys
|
|
7732
7732
|
};
|
|
7733
|
-
const proof =
|
|
7733
|
+
const proof = chunkGLLBSULU_cjs.Intent.create(message, coins, outputs);
|
|
7734
7734
|
const signedProof = await identity.sign(proof);
|
|
7735
7735
|
return {
|
|
7736
7736
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -7748,10 +7748,10 @@ function getDayTimestamp(timestamp) {
|
|
|
7748
7748
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
7749
7749
|
if (!vtxo.tapTree) return void 0;
|
|
7750
7750
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
7751
|
-
const vtxoScript =
|
|
7751
|
+
const vtxoScript = chunkGLLBSULU_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
7752
7752
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
7753
|
-
const arkTapscript =
|
|
7754
|
-
if (!
|
|
7753
|
+
const arkTapscript = chunkGLLBSULU_cjs.decodeTapscript(chunkGLLBSULU_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
7754
|
+
if (!chunkGLLBSULU_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
7755
7755
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
7756
7756
|
});
|
|
7757
7757
|
}
|
|
@@ -8032,7 +8032,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
|
|
|
8032
8032
|
};
|
|
8033
8033
|
}
|
|
8034
8034
|
function scriptFromArkAddress(address) {
|
|
8035
|
-
return base.hex.encode(
|
|
8035
|
+
return base.hex.encode(chunkGLLBSULU_cjs.ArkAddress.decode(address).pkScript);
|
|
8036
8036
|
}
|
|
8037
8037
|
|
|
8038
8038
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -8516,7 +8516,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
8516
8516
|
}
|
|
8517
8517
|
async function getVtxosForContract(repo, contract) {
|
|
8518
8518
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
8519
|
-
return vtxos.map(
|
|
8519
|
+
return vtxos.map(chunkGLLBSULU_cjs.normalizeVtxo);
|
|
8520
8520
|
}
|
|
8521
8521
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
8522
8522
|
if (repo.saveVtxosForScript) {
|
|
@@ -8658,7 +8658,7 @@ function decodeArkContract(encoded) {
|
|
|
8658
8658
|
}
|
|
8659
8659
|
function contractFromArkContract(encoded, options = {}) {
|
|
8660
8660
|
const parsed = decodeArkContract(encoded);
|
|
8661
|
-
const handler =
|
|
8661
|
+
const handler = chunkA2T3GGAK_cjs.contractHandlers.get(parsed.type);
|
|
8662
8662
|
if (!handler) {
|
|
8663
8663
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8664
8664
|
}
|
|
@@ -8672,9 +8672,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8672
8672
|
metadata: options.metadata
|
|
8673
8673
|
};
|
|
8674
8674
|
}
|
|
8675
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8675
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkGLLBSULU_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8676
8676
|
const parsed = decodeArkContract(encoded);
|
|
8677
|
-
const handler =
|
|
8677
|
+
const handler = chunkA2T3GGAK_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8678
8678
|
const params = parsed.data;
|
|
8679
8679
|
const vtxoScript = handler.createScript(params);
|
|
8680
8680
|
return {
|
|
@@ -8971,9 +8971,9 @@ var ContractWatcher = class {
|
|
|
8971
8971
|
this.connectionState = "connected";
|
|
8972
8972
|
this.reconnectAttempts = 0;
|
|
8973
8973
|
this.listenLoop().catch((e) => {
|
|
8974
|
-
if (
|
|
8974
|
+
if (chunkGLLBSULU_cjs.isEventSourceError(e)) {
|
|
8975
8975
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8976
|
-
} else if (!
|
|
8976
|
+
} else if (!chunkGLLBSULU_cjs.isEventSourceUnavailableError(e)) {
|
|
8977
8977
|
console.error(e);
|
|
8978
8978
|
}
|
|
8979
8979
|
this.connectionState = "disconnected";
|
|
@@ -8985,7 +8985,7 @@ var ContractWatcher = class {
|
|
|
8985
8985
|
this.scheduleReconnect();
|
|
8986
8986
|
});
|
|
8987
8987
|
} catch (error) {
|
|
8988
|
-
if (!
|
|
8988
|
+
if (!chunkGLLBSULU_cjs.isEventSourceUnavailableError(error)) {
|
|
8989
8989
|
console.error("ContractWatcher connection failed:", error);
|
|
8990
8990
|
}
|
|
8991
8991
|
this.connectionState = "disconnected";
|
|
@@ -9011,7 +9011,7 @@ var ContractWatcher = class {
|
|
|
9011
9011
|
* slower; what it loses is push latency.
|
|
9012
9012
|
*/
|
|
9013
9013
|
reportEventSourceUnavailable(error) {
|
|
9014
|
-
if (!
|
|
9014
|
+
if (!chunkGLLBSULU_cjs.isEventSourceUnavailableError(error)) return false;
|
|
9015
9015
|
if (!this.eventSourceReported) {
|
|
9016
9016
|
this.eventSourceReported = true;
|
|
9017
9017
|
console.warn(
|
|
@@ -9083,7 +9083,7 @@ var ContractWatcher = class {
|
|
|
9083
9083
|
const now = Date.now();
|
|
9084
9084
|
let current;
|
|
9085
9085
|
try {
|
|
9086
|
-
current = await
|
|
9086
|
+
current = await chunkGLLBSULU_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
|
|
9087
9087
|
spendableOnly: true
|
|
9088
9088
|
});
|
|
9089
9089
|
} catch (error) {
|
|
@@ -9291,14 +9291,14 @@ var ContractWatcher = class {
|
|
|
9291
9291
|
const timestamp = Date.now();
|
|
9292
9292
|
if (update.newVtxos?.length) {
|
|
9293
9293
|
this.processSubscriptionVtxos(
|
|
9294
|
-
update.newVtxos.map(
|
|
9294
|
+
update.newVtxos.map(chunkGLLBSULU_cjs.normalizeVtxo),
|
|
9295
9295
|
"vtxo_received",
|
|
9296
9296
|
timestamp
|
|
9297
9297
|
);
|
|
9298
9298
|
}
|
|
9299
9299
|
if (update.spentVtxos?.length) {
|
|
9300
9300
|
this.processSubscriptionVtxos(
|
|
9301
|
-
update.spentVtxos.map(
|
|
9301
|
+
update.spentVtxos.map(chunkGLLBSULU_cjs.normalizeVtxo),
|
|
9302
9302
|
"vtxo_spent",
|
|
9303
9303
|
timestamp
|
|
9304
9304
|
);
|
|
@@ -9326,8 +9326,8 @@ var ContractWatcher = class {
|
|
|
9326
9326
|
continue;
|
|
9327
9327
|
}
|
|
9328
9328
|
if (target === byWatchedScript && eventType === "vtxo_received") {
|
|
9329
|
-
const n =
|
|
9330
|
-
if (
|
|
9329
|
+
const n = chunkGLLBSULU_cjs.normalizeVtxo(vtxo);
|
|
9330
|
+
if (chunkGLLBSULU_cjs.hasTerminalSpend(n) || n.isSwept || chunkGLLBSULU_cjs.isPastExpiry(n, now)) continue;
|
|
9331
9331
|
}
|
|
9332
9332
|
let bucket = target.get(vtxo.script);
|
|
9333
9333
|
if (!bucket) {
|
|
@@ -9426,7 +9426,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
|
|
|
9426
9426
|
(s) => !isTerminalIntentState(s)
|
|
9427
9427
|
);
|
|
9428
9428
|
function isConsumed(vtxo) {
|
|
9429
|
-
return vtxo !== void 0 &&
|
|
9429
|
+
return vtxo !== void 0 && chunkGLLBSULU_cjs.hasTerminalSpend(vtxo);
|
|
9430
9430
|
}
|
|
9431
9431
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
9432
9432
|
if (isTerminalIntentState(intent.state)) return void 0;
|
|
@@ -9469,7 +9469,7 @@ async function reconcileIntents(deps) {
|
|
|
9469
9469
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
9470
9470
|
if (outpoints.length > 0) {
|
|
9471
9471
|
try {
|
|
9472
|
-
const { vtxos } = await
|
|
9472
|
+
const { vtxos } = await chunkGLLBSULU_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
9473
9473
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
9474
9474
|
} catch (e) {
|
|
9475
9475
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9648,7 +9648,7 @@ var ContractManager = class _ContractManager {
|
|
|
9648
9648
|
await this.reconcileWatched();
|
|
9649
9649
|
this.markSyncOnline();
|
|
9650
9650
|
} catch (err) {
|
|
9651
|
-
if (!
|
|
9651
|
+
if (!chunkGLLBSULU_cjs.isRetryableProviderError(err)) throw err;
|
|
9652
9652
|
this.markSyncDegraded(err);
|
|
9653
9653
|
}
|
|
9654
9654
|
this.initialized = true;
|
|
@@ -9780,7 +9780,7 @@ var ContractManager = class _ContractManager {
|
|
|
9780
9780
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9781
9781
|
const to = watermark + lookAhead.size;
|
|
9782
9782
|
const deps = lookAhead.candidateDeps();
|
|
9783
|
-
const handlers =
|
|
9783
|
+
const handlers = chunkA2T3GGAK_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkA2T3GGAK_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9784
9784
|
const band = /* @__PURE__ */ new Map();
|
|
9785
9785
|
for (let index = from; index <= to; index++) {
|
|
9786
9786
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9791,7 +9791,7 @@ var ContractManager = class _ContractManager {
|
|
|
9791
9791
|
index,
|
|
9792
9792
|
params: {
|
|
9793
9793
|
...candidate,
|
|
9794
|
-
...
|
|
9794
|
+
...chunkA2T3GGAK_cjs.speculativeReceiveMetadata(descriptor)
|
|
9795
9795
|
}
|
|
9796
9796
|
});
|
|
9797
9797
|
}
|
|
@@ -9853,7 +9853,7 @@ var ContractManager = class _ContractManager {
|
|
|
9853
9853
|
});
|
|
9854
9854
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9855
9855
|
} catch (err) {
|
|
9856
|
-
if (!
|
|
9856
|
+
if (!chunkGLLBSULU_cjs.isRetryableProviderError(err)) throw err;
|
|
9857
9857
|
this.markSyncDegraded(err);
|
|
9858
9858
|
}
|
|
9859
9859
|
}
|
|
@@ -9902,7 +9902,7 @@ var ContractManager = class _ContractManager {
|
|
|
9902
9902
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9903
9903
|
this.markSyncOnline();
|
|
9904
9904
|
} catch (err) {
|
|
9905
|
-
if (!
|
|
9905
|
+
if (!chunkGLLBSULU_cjs.isRetryableProviderError(err)) throw err;
|
|
9906
9906
|
this.markSyncDegraded(err);
|
|
9907
9907
|
}
|
|
9908
9908
|
await this.watcher.addContract(contract);
|
|
@@ -9939,7 +9939,7 @@ var ContractManager = class _ContractManager {
|
|
|
9939
9939
|
return result;
|
|
9940
9940
|
}
|
|
9941
9941
|
async upsertContractRow(params) {
|
|
9942
|
-
const handler =
|
|
9942
|
+
const handler = chunkA2T3GGAK_cjs.contractHandlers.get(params.type);
|
|
9943
9943
|
if (!handler) {
|
|
9944
9944
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9945
9945
|
}
|
|
@@ -10039,7 +10039,7 @@ var ContractManager = class _ContractManager {
|
|
|
10039
10039
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
10040
10040
|
);
|
|
10041
10041
|
}
|
|
10042
|
-
const registered =
|
|
10042
|
+
const registered = chunkA2T3GGAK_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkA2T3GGAK_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
10043
10043
|
const discoverables = [
|
|
10044
10044
|
...registered.filter((h) => h.type === "boarding"),
|
|
10045
10045
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -10176,7 +10176,7 @@ var ContractManager = class _ContractManager {
|
|
|
10176
10176
|
await this.syncContracts({ contracts, pageSize });
|
|
10177
10177
|
this.markSyncOnline();
|
|
10178
10178
|
} catch (err) {
|
|
10179
|
-
if (!
|
|
10179
|
+
if (!chunkGLLBSULU_cjs.isRetryableProviderError(err)) throw err;
|
|
10180
10180
|
this.markSyncDegraded(err);
|
|
10181
10181
|
}
|
|
10182
10182
|
}
|
|
@@ -10198,7 +10198,7 @@ var ContractManager = class _ContractManager {
|
|
|
10198
10198
|
}
|
|
10199
10199
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
10200
10200
|
return vtxos.map(
|
|
10201
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
10201
|
+
(vtxo) => extendVirtualCoinForContract(chunkGLLBSULU_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
10202
10202
|
);
|
|
10203
10203
|
}
|
|
10204
10204
|
/** @inheritdoc */
|
|
@@ -10242,14 +10242,14 @@ var ContractManager = class _ContractManager {
|
|
|
10242
10242
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
10243
10243
|
const asking = vtxos.filter((vtxo) => {
|
|
10244
10244
|
const contract = byScript.get(vtxo.script);
|
|
10245
|
-
return contract !== void 0 &&
|
|
10245
|
+
return contract !== void 0 && chunkA2T3GGAK_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
10246
10246
|
});
|
|
10247
10247
|
if (asking.length === 0) return refused;
|
|
10248
10248
|
const tip = await this.currentChainTip();
|
|
10249
10249
|
const walletDescriptorValue = await walletDescriptor?.();
|
|
10250
10250
|
for (const vtxo of asking) {
|
|
10251
10251
|
const contract = byScript.get(vtxo.script);
|
|
10252
|
-
const handler =
|
|
10252
|
+
const handler = chunkA2T3GGAK_cjs.contractHandlers.get(contract.type);
|
|
10253
10253
|
if (!handler?.assertSpendableNow) continue;
|
|
10254
10254
|
const context = {
|
|
10255
10255
|
collaborative: true,
|
|
@@ -10264,7 +10264,7 @@ var ContractManager = class _ContractManager {
|
|
|
10264
10264
|
// the next handler to answer a CSV question would meet a
|
|
10265
10265
|
// TypeError instead of a `false`. Carry the coin only when it
|
|
10266
10266
|
// really is one.
|
|
10267
|
-
vtxo:
|
|
10267
|
+
vtxo: chunkGLLBSULU_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
10268
10268
|
};
|
|
10269
10269
|
try {
|
|
10270
10270
|
await handler.assertSpendableNow(
|
|
@@ -10420,7 +10420,7 @@ var ContractManager = class _ContractManager {
|
|
|
10420
10420
|
const { contractScript, collaborative = true, walletDescriptor, vtxo } = options;
|
|
10421
10421
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10422
10422
|
if (!contract) return [];
|
|
10423
|
-
const handler =
|
|
10423
|
+
const handler = chunkA2T3GGAK_cjs.contractHandlers.get(contract.type);
|
|
10424
10424
|
if (!handler) return [];
|
|
10425
10425
|
const script = handler.createScript(contract.params);
|
|
10426
10426
|
const tip = await this.currentChainTip();
|
|
@@ -10448,7 +10448,7 @@ var ContractManager = class _ContractManager {
|
|
|
10448
10448
|
const { contractScript, collaborative = true, walletDescriptor } = options;
|
|
10449
10449
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10450
10450
|
if (!contract) return [];
|
|
10451
|
-
const handler =
|
|
10451
|
+
const handler = chunkA2T3GGAK_cjs.contractHandlers.get(contract.type);
|
|
10452
10452
|
if (!handler) return [];
|
|
10453
10453
|
const script = handler.createScript(contract.params);
|
|
10454
10454
|
const context = {
|
|
@@ -10504,7 +10504,7 @@ var ContractManager = class _ContractManager {
|
|
|
10504
10504
|
}
|
|
10505
10505
|
async refreshOutpoints(outpoints) {
|
|
10506
10506
|
if (outpoints.length === 0) return;
|
|
10507
|
-
const { vtxos } = await
|
|
10507
|
+
const { vtxos } = await chunkGLLBSULU_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
10508
10508
|
outpoints
|
|
10509
10509
|
});
|
|
10510
10510
|
if (vtxos.length === 0) return;
|
|
@@ -10600,7 +10600,7 @@ var ContractManager = class _ContractManager {
|
|
|
10600
10600
|
break;
|
|
10601
10601
|
}
|
|
10602
10602
|
} catch (err) {
|
|
10603
|
-
if (!
|
|
10603
|
+
if (!chunkGLLBSULU_cjs.isRetryableProviderError(err)) throw err;
|
|
10604
10604
|
this.markSyncDegraded(err);
|
|
10605
10605
|
}
|
|
10606
10606
|
this.emitEvent(event);
|
|
@@ -10691,7 +10691,7 @@ var ContractManager = class _ContractManager {
|
|
|
10691
10691
|
*/
|
|
10692
10692
|
async reconcilePendingFrontier(contracts) {
|
|
10693
10693
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
10694
|
-
const vtxos = await
|
|
10694
|
+
const vtxos = await chunkGLLBSULU_cjs.getAllNormalizedVtxos(
|
|
10695
10695
|
this.config.indexerProvider,
|
|
10696
10696
|
contracts.map((c) => c.script),
|
|
10697
10697
|
{ pendingOnly: true }
|
|
@@ -10774,7 +10774,7 @@ var ContractManager = class _ContractManager {
|
|
|
10774
10774
|
}
|
|
10775
10775
|
return result;
|
|
10776
10776
|
}
|
|
10777
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10777
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkGLLBSULU_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
10778
10778
|
if (contracts.length === 0) {
|
|
10779
10779
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
10780
10780
|
}
|
|
@@ -10790,7 +10790,7 @@ var ContractManager = class _ContractManager {
|
|
|
10790
10790
|
before: syncWindow.before
|
|
10791
10791
|
}
|
|
10792
10792
|
} : {};
|
|
10793
|
-
const vtxos = await
|
|
10793
|
+
const vtxos = await chunkGLLBSULU_cjs.getAllNormalizedVtxos(
|
|
10794
10794
|
this.config.indexerProvider,
|
|
10795
10795
|
contracts.map((c) => c.script),
|
|
10796
10796
|
{ ...windowOpts, pageSize }
|
|
@@ -10931,7 +10931,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
10931
10931
|
const s = base.hex.decode(t.s);
|
|
10932
10932
|
return [cb, s];
|
|
10933
10933
|
};
|
|
10934
|
-
var deserializeVtxo = (o) =>
|
|
10934
|
+
var deserializeVtxo = (o) => chunkGLLBSULU_cjs.normalizeVtxo({
|
|
10935
10935
|
...o,
|
|
10936
10936
|
createdAt: new Date(o.createdAt),
|
|
10937
10937
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -11066,7 +11066,7 @@ function parseLegacyExpiry(batchExpiry) {
|
|
|
11066
11066
|
if (typeof batchExpiry !== "number" || !Number.isFinite(batchExpiry) || batchExpiry <= 0) {
|
|
11067
11067
|
return {};
|
|
11068
11068
|
}
|
|
11069
|
-
if (batchExpiry >=
|
|
11069
|
+
if (batchExpiry >= chunkGLLBSULU_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
|
|
11070
11070
|
return { expiresAtHeight: batchExpiry / 1e3 };
|
|
11071
11071
|
}
|
|
11072
11072
|
function legacyVtxoFacts(status) {
|
|
@@ -11478,7 +11478,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
11478
11478
|
*/
|
|
11479
11479
|
materializeDescriptorAt(index) {
|
|
11480
11480
|
const descriptor = this.identity.descriptor;
|
|
11481
|
-
const network =
|
|
11481
|
+
const network = chunkA2T3GGAK_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
11482
11482
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
11483
11483
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
11484
11484
|
if (!keyInfo?.keyExpression) {
|
|
@@ -11626,7 +11626,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11626
11626
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
11627
11627
|
if (!provider) return void 0;
|
|
11628
11628
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
11629
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
11629
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkA2T3GGAK_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
11630
11630
|
const factoryOpts = {
|
|
11631
11631
|
walletRepository: setup.walletRepository,
|
|
11632
11632
|
contractRepository: setup.contractRepository,
|
|
@@ -11827,7 +11827,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11827
11827
|
};
|
|
11828
11828
|
function deriveLeafPubkey(descriptor) {
|
|
11829
11829
|
try {
|
|
11830
|
-
return
|
|
11830
|
+
return chunkA2T3GGAK_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
11831
11831
|
} catch (e) {
|
|
11832
11832
|
throw new NonRangeableDescriptorError(
|
|
11833
11833
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -11839,7 +11839,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11839
11839
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
11840
11840
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
11841
11841
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
11842
|
-
const csvTimelock =
|
|
11842
|
+
const csvTimelock = chunkGLLBSULU_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
11843
11843
|
const base$1 = {
|
|
11844
11844
|
script: base.hex.encode(tapscript.pkScript),
|
|
11845
11845
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -11850,11 +11850,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11850
11850
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
11851
11851
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
11852
11852
|
metadata: {
|
|
11853
|
-
...tagSource && { source:
|
|
11853
|
+
...tagSource && { source: chunkA2T3GGAK_cjs.WALLET_RECEIVE_SOURCE },
|
|
11854
11854
|
signingDescriptor: descriptor
|
|
11855
11855
|
}
|
|
11856
11856
|
};
|
|
11857
|
-
const params = tapscript instanceof
|
|
11857
|
+
const params = tapscript instanceof chunkA2T3GGAK_cjs.DelegateVtxo.Script ? {
|
|
11858
11858
|
...base$1,
|
|
11859
11859
|
type: "delegate",
|
|
11860
11860
|
params: {
|
|
@@ -11875,10 +11875,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11875
11875
|
return { tapscript, params };
|
|
11876
11876
|
}
|
|
11877
11877
|
function rebuildTapscript(current, pubKey) {
|
|
11878
|
-
if (current instanceof
|
|
11879
|
-
return new
|
|
11878
|
+
if (current instanceof chunkA2T3GGAK_cjs.DelegateVtxo.Script) {
|
|
11879
|
+
return new chunkA2T3GGAK_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
11880
11880
|
}
|
|
11881
|
-
return new
|
|
11881
|
+
return new chunkA2T3GGAK_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
11882
11882
|
}
|
|
11883
11883
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
11884
11884
|
const candidates = await contractRepository.getContracts({
|
|
@@ -11887,7 +11887,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
11887
11887
|
});
|
|
11888
11888
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
11889
11889
|
const matching = candidates.filter(
|
|
11890
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
11890
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkA2T3GGAK_cjs.WALLET_RECEIVE_SOURCE
|
|
11891
11891
|
).sort((a, b) => {
|
|
11892
11892
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
11893
11893
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -11943,7 +11943,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
11943
11943
|
}
|
|
11944
11944
|
};
|
|
11945
11945
|
for (const vtxo of vtxos) {
|
|
11946
|
-
if (
|
|
11946
|
+
if (chunkGLLBSULU_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11947
11947
|
addAssets(owned, vtxo);
|
|
11948
11948
|
if (vtxo.isUnrolled) {
|
|
11949
11949
|
unrolled += vtxo.value;
|
|
@@ -11953,11 +11953,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
11953
11953
|
pendingRecovery += vtxo.value;
|
|
11954
11954
|
continue;
|
|
11955
11955
|
}
|
|
11956
|
-
if (
|
|
11956
|
+
if (chunkGLLBSULU_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11957
11957
|
recoverable += vtxo.value;
|
|
11958
11958
|
continue;
|
|
11959
11959
|
}
|
|
11960
|
-
if (!
|
|
11960
|
+
if (!chunkGLLBSULU_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
11961
11961
|
if (vtxo.isPreconfirmed) {
|
|
11962
11962
|
preconfirmed += vtxo.value;
|
|
11963
11963
|
} else {
|
|
@@ -12131,7 +12131,7 @@ function intentProofJobs(coins) {
|
|
|
12131
12131
|
if (coins.length === 0) return [];
|
|
12132
12132
|
const coinJobs = coins.map((coin, i) => ({
|
|
12133
12133
|
index: i + 1,
|
|
12134
|
-
lookupScript:
|
|
12134
|
+
lookupScript: chunkGLLBSULU_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12135
12135
|
}));
|
|
12136
12136
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12137
12137
|
}
|
|
@@ -12163,7 +12163,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
12163
12163
|
const seen = /* @__PURE__ */ new Set();
|
|
12164
12164
|
const deduped = [];
|
|
12165
12165
|
for (const timelock of timelocks) {
|
|
12166
|
-
const sequence =
|
|
12166
|
+
const sequence = chunkGLLBSULU_cjs.timelockToSequence(timelock).toString();
|
|
12167
12167
|
if (seen.has(sequence)) continue;
|
|
12168
12168
|
seen.add(sequence);
|
|
12169
12169
|
deduped.push(timelock);
|
|
@@ -12180,7 +12180,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12180
12180
|
state: "active"
|
|
12181
12181
|
});
|
|
12182
12182
|
const newest = candidates.filter(
|
|
12183
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12183
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkA2T3GGAK_cjs.WALLET_RECEIVE_SOURCE
|
|
12184
12184
|
).sort((a, b) => {
|
|
12185
12185
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12186
12186
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12188,7 +12188,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12188
12188
|
if (!newest?.params.pubKey) return baseline;
|
|
12189
12189
|
try {
|
|
12190
12190
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
12191
|
-
return new
|
|
12191
|
+
return new chunkA2T3GGAK_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
12192
12192
|
} catch (e) {
|
|
12193
12193
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
12194
12194
|
return baseline;
|
|
@@ -12207,10 +12207,10 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
12207
12207
|
if (vtxo.isUnrolled) {
|
|
12208
12208
|
return !!f.withUnrolled;
|
|
12209
12209
|
}
|
|
12210
|
-
if (
|
|
12210
|
+
if (chunkGLLBSULU_cjs.hasTerminalSpend(vtxo)) {
|
|
12211
12211
|
return false;
|
|
12212
12212
|
}
|
|
12213
|
-
if (!f.withRecoverable &&
|
|
12213
|
+
if (!f.withRecoverable && chunkGLLBSULU_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12214
12214
|
return false;
|
|
12215
12215
|
}
|
|
12216
12216
|
return true;
|
|
@@ -12561,7 +12561,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12561
12561
|
async getArkadeReader() {
|
|
12562
12562
|
const indexer = this.indexerProvider;
|
|
12563
12563
|
return {
|
|
12564
|
-
getVtxos: (opts) =>
|
|
12564
|
+
getVtxos: (opts) => chunkGLLBSULU_cjs.getNormalizedVtxos(indexer, opts),
|
|
12565
12565
|
getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
|
|
12566
12566
|
};
|
|
12567
12567
|
}
|
|
@@ -12616,7 +12616,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12616
12616
|
* Extracts common logic used by both ReadonlyWallet.create() and Wallet.create().
|
|
12617
12617
|
*/
|
|
12618
12618
|
static async setupWalletConfig(config, pubKey) {
|
|
12619
|
-
const arkProvider = config.arkProvider || new
|
|
12619
|
+
const arkProvider = config.arkProvider || new chunkGLLBSULU_cjs.RestArkProvider();
|
|
12620
12620
|
let indexerProvider = config.indexerProvider;
|
|
12621
12621
|
if (!indexerProvider) {
|
|
12622
12622
|
const derived = extractArkProviderUrl(arkProvider);
|
|
@@ -12625,7 +12625,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12625
12625
|
"indexerProvider is required when arkProvider is provided without a discoverable serverUrl"
|
|
12626
12626
|
);
|
|
12627
12627
|
}
|
|
12628
|
-
indexerProvider = new
|
|
12628
|
+
indexerProvider = new chunkXOT73T36_cjs.RestIndexerProvider(derived ?? chunkGLLBSULU_cjs.DEFAULT_ARKADE_SERVER_URL);
|
|
12629
12629
|
}
|
|
12630
12630
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
12631
12631
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -12634,7 +12634,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12634
12634
|
source: serverInfoSource,
|
|
12635
12635
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
12636
12636
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
12637
|
-
const network =
|
|
12637
|
+
const network = chunkGLLBSULU_cjs.networkFromArkadeInfo(info);
|
|
12638
12638
|
if ("descriptor" in config.identity) {
|
|
12639
12639
|
const descriptor = config.identity.descriptor;
|
|
12640
12640
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -12673,18 +12673,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12673
12673
|
value: info.boardingExitDelay,
|
|
12674
12674
|
type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
|
|
12675
12675
|
};
|
|
12676
|
-
const serverPubKey =
|
|
12677
|
-
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) =>
|
|
12676
|
+
const serverPubKey = chunkA2T3GGAK_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
12677
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkA2T3GGAK_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
|
|
12678
12678
|
const offchainOptions = {
|
|
12679
12679
|
pubKey,
|
|
12680
12680
|
serverPubKey,
|
|
12681
12681
|
csvTimelock: exitTimelock
|
|
12682
12682
|
};
|
|
12683
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
12684
|
-
const boardingTapscript =
|
|
12683
|
+
const offchainTapscript = !delegatePubKey ? new chunkA2T3GGAK_cjs.DefaultVtxo.Script(offchainOptions) : new chunkA2T3GGAK_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
12684
|
+
const boardingTapscript = chunkA2T3GGAK_cjs.BoardingContractHandler.createScript({
|
|
12685
12685
|
pubKey: base.hex.encode(pubKey),
|
|
12686
12686
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12687
|
-
csvTimelock:
|
|
12687
|
+
csvTimelock: chunkGLLBSULU_cjs.timelockToSequence(boardingTimelock).toString()
|
|
12688
12688
|
});
|
|
12689
12689
|
return {
|
|
12690
12690
|
arkProvider,
|
|
@@ -12849,7 +12849,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12849
12849
|
if (!filter?.withUnrolled) {
|
|
12850
12850
|
logExcludedVtxos(
|
|
12851
12851
|
"getSpendableVtxos",
|
|
12852
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
12852
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkGLLBSULU_cjs.hasTerminalSpend(vtxo)),
|
|
12853
12853
|
[() => UNROLLED_REASON]
|
|
12854
12854
|
);
|
|
12855
12855
|
}
|
|
@@ -12993,7 +12993,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12993
12993
|
this.getBoardingTxs()
|
|
12994
12994
|
]);
|
|
12995
12995
|
const allVtxos = snapshot.flatMap((_) => _.vtxos);
|
|
12996
|
-
const resolveTxCreatedAt = (txids) =>
|
|
12996
|
+
const resolveTxCreatedAt = (txids) => chunkGLLBSULU_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
12997
12997
|
return buildTransactionHistory(
|
|
12998
12998
|
allVtxos,
|
|
12999
12999
|
boardingTxs,
|
|
@@ -13143,9 +13143,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13143
13143
|
async getBoardingTapscripts(allowedSigners) {
|
|
13144
13144
|
const byScript = /* @__PURE__ */ new Map();
|
|
13145
13145
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
13146
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
13146
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkA2T3GGAK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13147
13147
|
add(
|
|
13148
|
-
new
|
|
13148
|
+
new chunkA2T3GGAK_cjs.DefaultVtxo.Script({
|
|
13149
13149
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
13150
13150
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
13151
13151
|
csvTimelock: boardingCsv
|
|
@@ -13160,7 +13160,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13160
13160
|
for (const c of boardingContracts) {
|
|
13161
13161
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
13162
13162
|
try {
|
|
13163
|
-
add(
|
|
13163
|
+
add(chunkA2T3GGAK_cjs.BoardingContractHandler.createScript(c.params));
|
|
13164
13164
|
} catch (e) {
|
|
13165
13165
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
13166
13166
|
}
|
|
@@ -13198,7 +13198,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13198
13198
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
13199
13199
|
// not the wallet's current boarding timelock, which a signer
|
|
13200
13200
|
// rotation may have changed.
|
|
13201
|
-
csvTimelock:
|
|
13201
|
+
csvTimelock: chunkGLLBSULU_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
13202
13202
|
coins: utxos
|
|
13203
13203
|
});
|
|
13204
13204
|
}
|
|
@@ -13331,7 +13331,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13331
13331
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
13332
13332
|
async fetchPendingTxs() {
|
|
13333
13333
|
const scripts = await this.getWalletScripts();
|
|
13334
|
-
const vtxos = await
|
|
13334
|
+
const vtxos = await chunkGLLBSULU_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
13335
13335
|
return vtxos.filter(
|
|
13336
13336
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
13337
13337
|
).map((_) => _.arkTxId);
|
|
@@ -13362,7 +13362,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13362
13362
|
});
|
|
13363
13363
|
for (const contract of contracts) {
|
|
13364
13364
|
if (map.has(contract.script)) continue;
|
|
13365
|
-
const handler =
|
|
13365
|
+
const handler = chunkA2T3GGAK_cjs.contractHandlers.get(contract.type);
|
|
13366
13366
|
if (handler) {
|
|
13367
13367
|
const script = handler.createScript(contract.params);
|
|
13368
13368
|
map.set(contract.script, script);
|
|
@@ -13474,7 +13474,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13474
13474
|
}
|
|
13475
13475
|
});
|
|
13476
13476
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
13477
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
13477
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkA2T3GGAK_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
13478
13478
|
const baselineSigners = [
|
|
13479
13479
|
this.offchainTapscript.options.serverPubKey,
|
|
13480
13480
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -13482,8 +13482,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13482
13482
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
13483
13483
|
for (const serverPubKey of baselineSigners) {
|
|
13484
13484
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
13485
|
-
const csvTimelockStr =
|
|
13486
|
-
const defaultScript = new
|
|
13485
|
+
const csvTimelockStr = chunkGLLBSULU_cjs.timelockToSequence(csvTimelock).toString();
|
|
13486
|
+
const defaultScript = new chunkA2T3GGAK_cjs.DefaultVtxo.Script({
|
|
13487
13487
|
pubKey: baselinePubkey,
|
|
13488
13488
|
serverPubKey,
|
|
13489
13489
|
csvTimelock
|
|
@@ -13504,7 +13504,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13504
13504
|
});
|
|
13505
13505
|
}
|
|
13506
13506
|
if (delegatePubKey) {
|
|
13507
|
-
const delegateScript = new
|
|
13507
|
+
const delegateScript = new chunkA2T3GGAK_cjs.DelegateVtxo.Script({
|
|
13508
13508
|
pubKey: baselinePubkey,
|
|
13509
13509
|
serverPubKey,
|
|
13510
13510
|
delegatePubKey,
|
|
@@ -13528,9 +13528,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13528
13528
|
}
|
|
13529
13529
|
}
|
|
13530
13530
|
}
|
|
13531
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
13531
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkA2T3GGAK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13532
13532
|
for (const serverPubKey of baselineSigners) {
|
|
13533
|
-
const baselineBoarding = new
|
|
13533
|
+
const baselineBoarding = new chunkA2T3GGAK_cjs.DefaultVtxo.Script({
|
|
13534
13534
|
pubKey: baselinePubkey,
|
|
13535
13535
|
serverPubKey,
|
|
13536
13536
|
csvTimelock: boardingCsvTimelock
|
|
@@ -13543,7 +13543,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13543
13543
|
params: {
|
|
13544
13544
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
13545
13545
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13546
|
-
csvTimelock:
|
|
13546
|
+
csvTimelock: chunkGLLBSULU_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
13547
13547
|
},
|
|
13548
13548
|
script: boardingScriptHex,
|
|
13549
13549
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -13727,7 +13727,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13727
13727
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
13728
13728
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
13729
13729
|
csvTimelocks: this.walletContractTimelocks,
|
|
13730
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
13730
|
+
delegatePubKey: this.offchainTapscript instanceof chunkA2T3GGAK_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
13731
13731
|
};
|
|
13732
13732
|
}
|
|
13733
13733
|
_signerRouter;
|
|
@@ -13972,7 +13972,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13972
13972
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
13973
13973
|
const persisted = row?.metadata?.signingDescriptor;
|
|
13974
13974
|
if (typeof persisted === "string") return persisted;
|
|
13975
|
-
return
|
|
13975
|
+
return chunkA2T3GGAK_cjs.identityDescriptor(this.identity);
|
|
13976
13976
|
}
|
|
13977
13977
|
/**
|
|
13978
13978
|
* Build, persist and shape one address of `type` owned by `descriptor` —
|
|
@@ -13988,7 +13988,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13988
13988
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
13989
13989
|
if (type === "boarding") {
|
|
13990
13990
|
const built2 = this.buildBoardingContract(
|
|
13991
|
-
|
|
13991
|
+
chunkA2T3GGAK_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
13992
13992
|
descriptor,
|
|
13993
13993
|
tagSource
|
|
13994
13994
|
);
|
|
@@ -14033,11 +14033,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14033
14033
|
* {@link buildReceiveContract}.
|
|
14034
14034
|
*/
|
|
14035
14035
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
14036
|
-
const tapscript = new
|
|
14036
|
+
const tapscript = new chunkA2T3GGAK_cjs.DefaultVtxo.Script({
|
|
14037
14037
|
...this._boardingTapscript.options,
|
|
14038
14038
|
pubKey
|
|
14039
14039
|
});
|
|
14040
|
-
const csvTimelock = tapscript.options.csvTimelock ??
|
|
14040
|
+
const csvTimelock = tapscript.options.csvTimelock ?? chunkA2T3GGAK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14041
14041
|
return {
|
|
14042
14042
|
tapscript,
|
|
14043
14043
|
params: {
|
|
@@ -14045,13 +14045,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14045
14045
|
params: {
|
|
14046
14046
|
pubKey: base.hex.encode(pubKey),
|
|
14047
14047
|
serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
|
|
14048
|
-
csvTimelock:
|
|
14048
|
+
csvTimelock: chunkGLLBSULU_cjs.timelockToSequence(csvTimelock).toString()
|
|
14049
14049
|
},
|
|
14050
14050
|
script: base.hex.encode(tapscript.pkScript),
|
|
14051
14051
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
14052
14052
|
state: "active",
|
|
14053
14053
|
metadata: {
|
|
14054
|
-
...tagSource && { source:
|
|
14054
|
+
...tagSource && { source: chunkA2T3GGAK_cjs.WALLET_RECEIVE_SOURCE },
|
|
14055
14055
|
signingDescriptor: descriptor
|
|
14056
14056
|
}
|
|
14057
14057
|
}
|
|
@@ -14080,7 +14080,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14080
14080
|
if (this._descriptorProvider instanceof HDDescriptorProvider) {
|
|
14081
14081
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
14082
14082
|
}
|
|
14083
|
-
return
|
|
14083
|
+
return chunkA2T3GGAK_cjs.identityDescriptor(this.identity);
|
|
14084
14084
|
}
|
|
14085
14085
|
/**
|
|
14086
14086
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -14176,7 +14176,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14176
14176
|
* the stable public API.
|
|
14177
14177
|
*/
|
|
14178
14178
|
async rotateServerSigner(newServerPubKey, checkpointTapscript) {
|
|
14179
|
-
const xonly =
|
|
14179
|
+
const xonly = chunkA2T3GGAK_cjs.toXOnly(newServerPubKey, "ark signer key");
|
|
14180
14180
|
const newServerUnrollScript = assertValidServerUnrollScript(
|
|
14181
14181
|
checkpointTapscript,
|
|
14182
14182
|
resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
|
|
@@ -14205,21 +14205,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14205
14205
|
const [currentBoardingRow] = await manager.getContracts({
|
|
14206
14206
|
script: currentBoardingScript
|
|
14207
14207
|
});
|
|
14208
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
14208
|
+
const newOffchain = this.offchainTapscript instanceof chunkA2T3GGAK_cjs.DelegateVtxo.Script ? new chunkA2T3GGAK_cjs.DelegateVtxo.Script({
|
|
14209
14209
|
...this.offchainTapscript.options,
|
|
14210
14210
|
serverPubKey: xonly
|
|
14211
|
-
}) : new
|
|
14211
|
+
}) : new chunkA2T3GGAK_cjs.DefaultVtxo.Script({
|
|
14212
14212
|
...this.offchainTapscript.options,
|
|
14213
14213
|
serverPubKey: xonly
|
|
14214
14214
|
});
|
|
14215
|
-
const newBoarding = new
|
|
14215
|
+
const newBoarding = new chunkA2T3GGAK_cjs.DefaultVtxo.Script({
|
|
14216
14216
|
...this._boardingTapscript.options,
|
|
14217
14217
|
serverPubKey: xonly
|
|
14218
14218
|
});
|
|
14219
|
-
const offchainCsv =
|
|
14219
|
+
const offchainCsv = chunkGLLBSULU_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
14220
14220
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
14221
14221
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
14222
|
-
if (newOffchain instanceof
|
|
14222
|
+
if (newOffchain instanceof chunkA2T3GGAK_cjs.DelegateVtxo.Script) {
|
|
14223
14223
|
await manager.createContract({
|
|
14224
14224
|
type: "delegate",
|
|
14225
14225
|
params: {
|
|
@@ -14247,13 +14247,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14247
14247
|
metadata: currentOffchainRow?.metadata
|
|
14248
14248
|
});
|
|
14249
14249
|
}
|
|
14250
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
14250
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkA2T3GGAK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14251
14251
|
await manager.createContract({
|
|
14252
14252
|
type: "boarding",
|
|
14253
14253
|
params: {
|
|
14254
14254
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
14255
14255
|
serverPubKey: base.hex.encode(xonly),
|
|
14256
|
-
csvTimelock:
|
|
14256
|
+
csvTimelock: chunkGLLBSULU_cjs.timelockToSequence(boardingCsv).toString()
|
|
14257
14257
|
},
|
|
14258
14258
|
script: base.hex.encode(newBoarding.pkScript),
|
|
14259
14259
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -14286,14 +14286,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14286
14286
|
_restoreInFlight;
|
|
14287
14287
|
_addPendingSpends(inputs) {
|
|
14288
14288
|
for (const input of inputs) {
|
|
14289
|
-
if (
|
|
14289
|
+
if (chunkGLLBSULU_cjs.isVirtualCoin(input)) {
|
|
14290
14290
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
14291
14291
|
}
|
|
14292
14292
|
}
|
|
14293
14293
|
}
|
|
14294
14294
|
_removePendingSpends(inputs) {
|
|
14295
14295
|
for (const input of inputs) {
|
|
14296
|
-
if (
|
|
14296
|
+
if (chunkGLLBSULU_cjs.isVirtualCoin(input)) {
|
|
14297
14297
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
14298
14298
|
}
|
|
14299
14299
|
}
|
|
@@ -14351,13 +14351,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14351
14351
|
const manager = await this.getContractManager();
|
|
14352
14352
|
const provider = this._descriptorProvider;
|
|
14353
14353
|
const hd = provider instanceof HDDescriptorProvider;
|
|
14354
|
-
const staticDescriptor = hd ? void 0 : await
|
|
14354
|
+
const staticDescriptor = hd ? void 0 : await chunkA2T3GGAK_cjs.identityDescriptor(this.identity);
|
|
14355
14355
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
14356
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14356
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkA2T3GGAK_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14357
14357
|
const arkInfo = await this.arkProvider.getInfo();
|
|
14358
|
-
const currentSignerPubKey =
|
|
14358
|
+
const currentSignerPubKey = chunkA2T3GGAK_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
14359
14359
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
14360
|
-
(s) =>
|
|
14360
|
+
(s) => chunkA2T3GGAK_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
14361
14361
|
);
|
|
14362
14362
|
const deps = {
|
|
14363
14363
|
indexerProvider: this.indexerProvider,
|
|
@@ -14372,7 +14372,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14372
14372
|
csvTimelocks: this.walletContractTimelocks,
|
|
14373
14373
|
// Boarding-exit CSV so the boarding handler can build its
|
|
14374
14374
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
14375
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
14375
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkA2T3GGAK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
14376
14376
|
delegatePubKey
|
|
14377
14377
|
};
|
|
14378
14378
|
const result = await manager.scanContracts({
|
|
@@ -14499,7 +14499,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14499
14499
|
throw new Error("Invalid configured public key");
|
|
14500
14500
|
}
|
|
14501
14501
|
const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
|
|
14502
|
-
const forfeitPubkey =
|
|
14502
|
+
const forfeitPubkey = chunkA2T3GGAK_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
|
|
14503
14503
|
const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
|
|
14504
14504
|
const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
|
|
14505
14505
|
const checkpointExitDelayOverrides = {
|
|
@@ -14646,13 +14646,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14646
14646
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
14647
14647
|
}
|
|
14648
14648
|
const offchainAddress = await this.getAddress();
|
|
14649
|
-
const offchainPkScript =
|
|
14649
|
+
const offchainPkScript = chunkGLLBSULU_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
14650
14650
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
14651
14651
|
if (!params) {
|
|
14652
14652
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
14653
14653
|
const estimator = new Estimator(fees.intentFee);
|
|
14654
14654
|
let amount = 0;
|
|
14655
|
-
const exitScript =
|
|
14655
|
+
const exitScript = chunkGLLBSULU_cjs.CSVMultisigTapscript.decode(
|
|
14656
14656
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
14657
14657
|
);
|
|
14658
14658
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -14681,7 +14681,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14681
14681
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
14682
14682
|
break;
|
|
14683
14683
|
}
|
|
14684
|
-
const inputFee = estimator.evalOffchainInput(
|
|
14684
|
+
const inputFee = estimator.evalOffchainInput(chunkGLLBSULU_cjs.toOffchainInputFeeParams(vtxo));
|
|
14685
14685
|
if (inputFee.satoshis >= vtxo.value) {
|
|
14686
14686
|
continue;
|
|
14687
14687
|
}
|
|
@@ -14728,7 +14728,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14728
14728
|
let script;
|
|
14729
14729
|
let arkAddress;
|
|
14730
14730
|
try {
|
|
14731
|
-
arkAddress =
|
|
14731
|
+
arkAddress = chunkGLLBSULU_cjs.ArkAddress.decode(output.address);
|
|
14732
14732
|
} catch {
|
|
14733
14733
|
arkAddress = void 0;
|
|
14734
14734
|
}
|
|
@@ -14818,7 +14818,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14818
14818
|
const abortController = new AbortController();
|
|
14819
14819
|
let stream;
|
|
14820
14820
|
let committedTxid;
|
|
14821
|
-
const settleInputVtxos = params.inputs.filter(
|
|
14821
|
+
const settleInputVtxos = params.inputs.filter(chunkGLLBSULU_cjs.isVirtualCoin);
|
|
14822
14822
|
const contractManager = await this.getContractManager();
|
|
14823
14823
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
14824
14824
|
await contractManager.assertSpendableNow?.(
|
|
@@ -14930,7 +14930,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14930
14930
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
14931
14931
|
if (!this._descriptorProvider) return;
|
|
14932
14932
|
const consumedBoarding = inputs.some(
|
|
14933
|
-
(input) => typeof input !== "string" && !
|
|
14933
|
+
(input) => typeof input !== "string" && !chunkGLLBSULU_cjs.isVirtualCoin(input)
|
|
14934
14934
|
);
|
|
14935
14935
|
if (!consumedBoarding) return;
|
|
14936
14936
|
try {
|
|
@@ -14954,7 +14954,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14954
14954
|
let connectorIndex = 0;
|
|
14955
14955
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
14956
14956
|
for (const input of inputs) {
|
|
14957
|
-
if (!
|
|
14957
|
+
if (!chunkGLLBSULU_cjs.isVirtualCoin(input)) {
|
|
14958
14958
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
14959
14959
|
const settlementInput = settlementPsbt.getInput(i);
|
|
14960
14960
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -14985,7 +14985,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14985
14985
|
}
|
|
14986
14986
|
continue;
|
|
14987
14987
|
}
|
|
14988
|
-
if (
|
|
14988
|
+
if (chunkGLLBSULU_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
14989
14989
|
continue;
|
|
14990
14990
|
}
|
|
14991
14991
|
if (connectorsLeaves.length === 0) {
|
|
@@ -15013,7 +15013,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15013
15013
|
index: input.vout,
|
|
15014
15014
|
witnessUtxo: {
|
|
15015
15015
|
amount: BigInt(input.value),
|
|
15016
|
-
script:
|
|
15016
|
+
script: chunkGLLBSULU_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15017
15017
|
},
|
|
15018
15018
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
15019
15019
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -15032,7 +15032,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15032
15032
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
15033
15033
|
{
|
|
15034
15034
|
index: 0,
|
|
15035
|
-
lookupScript:
|
|
15035
|
+
lookupScript: chunkGLLBSULU_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15036
15036
|
}
|
|
15037
15037
|
]);
|
|
15038
15038
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -15090,7 +15090,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15090
15090
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
15091
15091
|
);
|
|
15092
15092
|
await this.arkProvider.confirmRegistration(intentId);
|
|
15093
|
-
const sweepTapscript =
|
|
15093
|
+
const sweepTapscript = chunkGLLBSULU_cjs.CSVMultisigTapscript.encode({
|
|
15094
15094
|
timelock,
|
|
15095
15095
|
pubkeys: [this.forfeitPubkey]
|
|
15096
15096
|
}).script;
|
|
@@ -15105,10 +15105,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15105
15105
|
throw new Error("Sweep tap tree root not set");
|
|
15106
15106
|
}
|
|
15107
15107
|
const xOnlyPublicKeys = event.cosignersPublicKeys.map(
|
|
15108
|
-
(k) => base.hex.encode(
|
|
15108
|
+
(k) => base.hex.encode(chunkA2T3GGAK_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
15109
15109
|
);
|
|
15110
15110
|
const signerPublicKey = await session.getPublicKey();
|
|
15111
|
-
const xonlySignerPublicKey =
|
|
15111
|
+
const xonlySignerPublicKey = chunkA2T3GGAK_cjs.toXOnly(signerPublicKey, "signer key");
|
|
15112
15112
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
15113
15113
|
return { skip: true };
|
|
15114
15114
|
}
|
|
@@ -15198,9 +15198,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15198
15198
|
...existing ?? {},
|
|
15199
15199
|
intentTxId,
|
|
15200
15200
|
registerProof: intent.proof,
|
|
15201
|
-
registerProofMessage:
|
|
15201
|
+
registerProofMessage: chunkGLLBSULU_cjs.Intent.encodeMessage(intent.message),
|
|
15202
15202
|
deleteProof: deleteIntent.proof,
|
|
15203
|
-
deleteProofMessage:
|
|
15203
|
+
deleteProofMessage: chunkGLLBSULU_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
15204
15204
|
intentVtxos: inputs.map((i) => ({
|
|
15205
15205
|
txid: i.txid,
|
|
15206
15206
|
vout: i.vout
|
|
@@ -15232,7 +15232,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15232
15232
|
try {
|
|
15233
15233
|
return await this.arkProvider.registerIntent(intent);
|
|
15234
15234
|
} catch (error) {
|
|
15235
|
-
if (error instanceof
|
|
15235
|
+
if (error instanceof chunkGLLBSULU_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
15236
15236
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
15237
15237
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
15238
15238
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -15248,7 +15248,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15248
15248
|
expire_at: 0,
|
|
15249
15249
|
cosigners_public_keys: cosignerPubKeys
|
|
15250
15250
|
};
|
|
15251
|
-
const proof =
|
|
15251
|
+
const proof = chunkGLLBSULU_cjs.Intent.create(message, coins, outputs);
|
|
15252
15252
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15253
15253
|
return {
|
|
15254
15254
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15260,7 +15260,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15260
15260
|
type: "delete",
|
|
15261
15261
|
expire_at: 0
|
|
15262
15262
|
};
|
|
15263
|
-
const proof =
|
|
15263
|
+
const proof = chunkGLLBSULU_cjs.Intent.create(message, coins, []);
|
|
15264
15264
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15265
15265
|
return {
|
|
15266
15266
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15272,7 +15272,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15272
15272
|
type: "get-pending-tx",
|
|
15273
15273
|
expire_at: 0
|
|
15274
15274
|
};
|
|
15275
|
-
const proof =
|
|
15275
|
+
const proof = chunkGLLBSULU_cjs.Intent.create(message, coins, []);
|
|
15276
15276
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15277
15277
|
return {
|
|
15278
15278
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15293,7 +15293,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15293
15293
|
if (!vtxos || vtxos.length === 0) {
|
|
15294
15294
|
const scriptMap = await this.getScriptMap();
|
|
15295
15295
|
const allExtended = [];
|
|
15296
|
-
const fetchedVtxos = await
|
|
15296
|
+
const fetchedVtxos = await chunkGLLBSULU_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
15297
15297
|
...scriptMap.keys()
|
|
15298
15298
|
]);
|
|
15299
15299
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -15337,7 +15337,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15337
15337
|
try {
|
|
15338
15338
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
15339
15339
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
|
|
15340
|
-
|
|
15340
|
+
chunkGLLBSULU_cjs.assertAllowedSighashTypes(tx);
|
|
15341
15341
|
return tx;
|
|
15342
15342
|
});
|
|
15343
15343
|
assertCheckpointsMatchInputs(
|
|
@@ -15409,11 +15409,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15409
15409
|
* against the current key alone would leave it pending forever.
|
|
15410
15410
|
*/
|
|
15411
15411
|
checkpointUnrollCandidates(info) {
|
|
15412
|
-
const current =
|
|
15412
|
+
const current = chunkGLLBSULU_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
15413
15413
|
const candidates = [this._serverUnrollScript, current];
|
|
15414
15414
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
15415
15415
|
candidates.push(
|
|
15416
|
-
|
|
15416
|
+
chunkGLLBSULU_cjs.CSVMultisigTapscript.encode({
|
|
15417
15417
|
...current.params,
|
|
15418
15418
|
pubkeys: [base.hex.decode(deprecated)]
|
|
15419
15419
|
})
|
|
@@ -15504,7 +15504,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15504
15504
|
if (vtxos.length === 0) {
|
|
15505
15505
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
15506
15506
|
}
|
|
15507
|
-
const myPkScript =
|
|
15507
|
+
const myPkScript = chunkGLLBSULU_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
15508
15508
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
15509
15509
|
let swept = 0;
|
|
15510
15510
|
const drainable = vtxos.filter(
|
|
@@ -15580,7 +15580,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15580
15580
|
const spendable = [];
|
|
15581
15581
|
const unclaimed = [];
|
|
15582
15582
|
for (const vtxo of vtxos) {
|
|
15583
|
-
if (
|
|
15583
|
+
if (chunkGLLBSULU_cjs.hasTerminalSpend(vtxo)) {
|
|
15584
15584
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
15585
15585
|
} else if (vtxo.isUnrolled) {
|
|
15586
15586
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -15602,7 +15602,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15602
15602
|
const all = [];
|
|
15603
15603
|
const seen = /* @__PURE__ */ new Set();
|
|
15604
15604
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
15605
|
-
const { vtxos, page } = await
|
|
15605
|
+
const { vtxos, page } = await chunkGLLBSULU_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
15606
15606
|
scripts,
|
|
15607
15607
|
pageIndex,
|
|
15608
15608
|
pageSize
|
|
@@ -15649,7 +15649,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15649
15649
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
15650
15650
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
15651
15651
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
15652
|
-
const proof =
|
|
15652
|
+
const proof = chunkGLLBSULU_cjs.Intent.create(message, batch, []);
|
|
15653
15653
|
const signedProof = await identity.sign(
|
|
15654
15654
|
proof,
|
|
15655
15655
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -15671,7 +15671,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15671
15671
|
try {
|
|
15672
15672
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
15673
15673
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
15674
|
-
|
|
15674
|
+
chunkGLLBSULU_cjs.assertAllowedSighashTypes(tx);
|
|
15675
15675
|
return tx;
|
|
15676
15676
|
});
|
|
15677
15677
|
assertCheckpointsMatchInputs(
|
|
@@ -15870,7 +15870,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15870
15870
|
script: recipient.script,
|
|
15871
15871
|
amount: BigInt(recipient.amount),
|
|
15872
15872
|
// Already checked against the recipient address in `validateRecipients`.
|
|
15873
|
-
...recipient.tapTree ? { tapTree:
|
|
15873
|
+
...recipient.tapTree ? { tapTree: chunkGLLBSULU_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
|
|
15874
15874
|
}));
|
|
15875
15875
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
15876
15876
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -16014,10 +16014,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16014
16014
|
const serverPubKey = this.arkServerPublicKey;
|
|
16015
16015
|
const serverUnrollScript = this.serverUnrollScript;
|
|
16016
16016
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
16017
|
-
const normalizedInputs = inputs.map(
|
|
16018
|
-
const at = now ?? await
|
|
16017
|
+
const normalizedInputs = inputs.map(chunkGLLBSULU_cjs.normalizeVtxo);
|
|
16018
|
+
const at = now ?? await chunkGLLBSULU_cjs.resolveTimeHeight(this.onchainProvider);
|
|
16019
16019
|
for (const input of normalizedInputs) {
|
|
16020
|
-
if (!
|
|
16020
|
+
if (!chunkGLLBSULU_cjs.canSpendOffchain(input, at)) {
|
|
16021
16021
|
throw new Error(
|
|
16022
16022
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
16023
16023
|
);
|
|
@@ -16087,7 +16087,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16087
16087
|
);
|
|
16088
16088
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
16089
16089
|
index,
|
|
16090
|
-
lookupScript:
|
|
16090
|
+
lookupScript: chunkGLLBSULU_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
16091
16091
|
}));
|
|
16092
16092
|
const identity = this.identity;
|
|
16093
16093
|
const signer = {
|
|
@@ -16272,12 +16272,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16272
16272
|
const spentVtxos = [];
|
|
16273
16273
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
16274
16274
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
16275
|
-
const vtxoInputs = inputs.filter(
|
|
16275
|
+
const vtxoInputs = inputs.filter(chunkGLLBSULU_cjs.isVirtualCoin);
|
|
16276
16276
|
const cm = await this.getContractManager();
|
|
16277
16277
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
16278
16278
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
16279
16279
|
for (const input of inputs) {
|
|
16280
|
-
if (
|
|
16280
|
+
if (chunkGLLBSULU_cjs.isVirtualCoin(input)) {
|
|
16281
16281
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
16282
16282
|
const vtxo = annotatedByKey.get(outpoint);
|
|
16283
16283
|
if (!vtxo) {
|
|
@@ -16294,7 +16294,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16294
16294
|
} else {
|
|
16295
16295
|
let sourceAddress;
|
|
16296
16296
|
try {
|
|
16297
|
-
sourceAddress =
|
|
16297
|
+
sourceAddress = chunkGLLBSULU_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
16298
16298
|
this.network
|
|
16299
16299
|
);
|
|
16300
16300
|
} catch {
|
|
@@ -16352,7 +16352,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16352
16352
|
}
|
|
16353
16353
|
};
|
|
16354
16354
|
function selectVirtualCoins(coins, targetAmount) {
|
|
16355
|
-
const sortedCoins = coins.map(
|
|
16355
|
+
const sortedCoins = coins.map(chunkGLLBSULU_cjs.normalizeVtxo).sort((a, b) => {
|
|
16356
16356
|
const expiryA = a.expiresAt?.getTime() || Number.MAX_SAFE_INTEGER;
|
|
16357
16357
|
const expiryB = b.expiresAt?.getTime() || Number.MAX_SAFE_INTEGER;
|
|
16358
16358
|
if (expiryA !== expiryB) {
|
|
@@ -16723,14 +16723,14 @@ var MessageBus = class {
|
|
|
16723
16723
|
this.initialized = true;
|
|
16724
16724
|
}
|
|
16725
16725
|
async buildServices(config) {
|
|
16726
|
-
const arkProvider = new
|
|
16726
|
+
const arkProvider = new chunkGLLBSULU_cjs.RestArkProvider(config.arkServer.url);
|
|
16727
16727
|
const storage = {
|
|
16728
16728
|
walletRepository: this.walletRepository,
|
|
16729
16729
|
contractRepository: this.contractRepository,
|
|
16730
16730
|
...this.intentRepository && { intentRepository: this.intentRepository }
|
|
16731
16731
|
};
|
|
16732
16732
|
const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : void 0;
|
|
16733
|
-
const indexerProvider = new
|
|
16733
|
+
const indexerProvider = new chunkXOT73T36_cjs.RestIndexerProvider(config.arkServer.url);
|
|
16734
16734
|
const serialized = normalizeSerializedIdentity(config.wallet);
|
|
16735
16735
|
if (isSigningSerialized(serialized)) {
|
|
16736
16736
|
const identity2 = hydrateIdentity(serialized);
|
|
@@ -17067,7 +17067,7 @@ var offboardNetworkNames = [
|
|
|
17067
17067
|
function offboardDestinationScript(destinationAddress) {
|
|
17068
17068
|
for (const networkName of offboardNetworkNames) {
|
|
17069
17069
|
try {
|
|
17070
|
-
const network =
|
|
17070
|
+
const network = chunkGLLBSULU_cjs.networks[networkName];
|
|
17071
17071
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
17072
17072
|
return btcSigner.OutScript.encode(addr);
|
|
17073
17073
|
} catch {
|
|
@@ -17131,7 +17131,7 @@ var Ramps = class {
|
|
|
17131
17131
|
}
|
|
17132
17132
|
amount = amount ?? totalAmount;
|
|
17133
17133
|
const offchainAddress = await this.wallet.getAddress();
|
|
17134
|
-
const offchainAddr =
|
|
17134
|
+
const offchainAddr = chunkGLLBSULU_cjs.ArkAddress.decode(offchainAddress);
|
|
17135
17135
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
17136
17136
|
const outputFee = estimator.evalOffchainOutput({
|
|
17137
17137
|
amount,
|
|
@@ -17191,7 +17191,7 @@ var Ramps = class {
|
|
|
17191
17191
|
const filteredVtxos = [];
|
|
17192
17192
|
let totalAmount = 0n;
|
|
17193
17193
|
for (const vtxo of vtxos) {
|
|
17194
|
-
const inputFee = estimator.evalOffchainInput(
|
|
17194
|
+
const inputFee = estimator.evalOffchainInput(chunkGLLBSULU_cjs.toOffchainInputFeeParams(vtxo));
|
|
17195
17195
|
if (inputFee.satoshis >= vtxo.value) {
|
|
17196
17196
|
continue;
|
|
17197
17197
|
}
|
|
@@ -18098,7 +18098,7 @@ var WalletMessageHandler = class {
|
|
|
18098
18098
|
// Wallet methods
|
|
18099
18099
|
async handleInitWallet({ payload }) {
|
|
18100
18100
|
const { arkServerUrl } = payload;
|
|
18101
|
-
this.indexerProvider = new
|
|
18101
|
+
this.indexerProvider = new chunkXOT73T36_cjs.RestIndexerProvider(arkServerUrl);
|
|
18102
18102
|
await this.onWalletInitialized();
|
|
18103
18103
|
}
|
|
18104
18104
|
/**
|
|
@@ -18375,7 +18375,7 @@ var WalletMessageHandler = class {
|
|
|
18375
18375
|
if (v.isUnrolled) {
|
|
18376
18376
|
return withUnrolled;
|
|
18377
18377
|
}
|
|
18378
|
-
if (
|
|
18378
|
+
if (chunkGLLBSULU_cjs.hasTerminalSpend(v)) {
|
|
18379
18379
|
return false;
|
|
18380
18380
|
}
|
|
18381
18381
|
if (includeRecoverable) {
|
|
@@ -18384,7 +18384,7 @@ var WalletMessageHandler = class {
|
|
|
18384
18384
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
18385
18385
|
return false;
|
|
18386
18386
|
}
|
|
18387
|
-
return
|
|
18387
|
+
return chunkGLLBSULU_cjs.canSpendOffchain(v, { timestamp: /* @__PURE__ */ new Date() });
|
|
18388
18388
|
});
|
|
18389
18389
|
}
|
|
18390
18390
|
/** Tear down handler subscriptions, then delegate the full wipe to the wallet. */
|
|
@@ -18489,7 +18489,7 @@ var WalletMessageHandler = class {
|
|
|
18489
18489
|
this.readonlyWallet.getBoardingTxs()
|
|
18490
18490
|
]);
|
|
18491
18491
|
const indexerProvider = this.indexerProvider;
|
|
18492
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
18492
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkGLLBSULU_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
18493
18493
|
return buildTransactionHistory(
|
|
18494
18494
|
vtxos,
|
|
18495
18495
|
boardingTxs,
|
|
@@ -18558,7 +18558,7 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
18558
18558
|
// budget so the worker's snapshot fallback stays reachable before this
|
|
18559
18559
|
// page deadline fires — lowering it below the budget would time the page
|
|
18560
18560
|
// out while the worker is still seconds from answering from cache.
|
|
18561
|
-
GET_ARKADE_INFO:
|
|
18561
|
+
GET_ARKADE_INFO: chunkGLLBSULU_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
|
|
18562
18562
|
INDEXER_GET_VTXOS: 2e4,
|
|
18563
18563
|
INDEXER_GET_VIRTUAL_TXS: 2e4,
|
|
18564
18564
|
GET_VTXOS: 2e4,
|
|
@@ -19145,7 +19145,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19145
19145
|
try {
|
|
19146
19146
|
const response = await this.sendMessage(message);
|
|
19147
19147
|
const { vtxos, page } = response.payload;
|
|
19148
|
-
return { vtxos: vtxos.map(
|
|
19148
|
+
return { vtxos: vtxos.map(chunkGLLBSULU_cjs.normalizeVtxo), page: page && { ...page } };
|
|
19149
19149
|
} catch (error) {
|
|
19150
19150
|
throw new Error(`Failed to get vtxos: ${error}`, { cause: error });
|
|
19151
19151
|
}
|
|
@@ -19249,7 +19249,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19249
19249
|
};
|
|
19250
19250
|
try {
|
|
19251
19251
|
const response = await this.sendMessage(message);
|
|
19252
|
-
return response.payload.vtxos.map(
|
|
19252
|
+
return response.payload.vtxos.map(chunkGLLBSULU_cjs.normalizeVtxo);
|
|
19253
19253
|
} catch (error) {
|
|
19254
19254
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
19255
19255
|
}
|
|
@@ -19274,7 +19274,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19274
19274
|
};
|
|
19275
19275
|
try {
|
|
19276
19276
|
const response = await this.sendMessage(message);
|
|
19277
|
-
return response.payload.vtxos.map(
|
|
19277
|
+
return response.payload.vtxos.map(chunkGLLBSULU_cjs.normalizeVtxo);
|
|
19278
19278
|
} catch (error) {
|
|
19279
19279
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
19280
19280
|
}
|
|
@@ -19445,7 +19445,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19445
19445
|
};
|
|
19446
19446
|
try {
|
|
19447
19447
|
const response = await sendContractMessage(message);
|
|
19448
|
-
return response.payload.vtxos.map(
|
|
19448
|
+
return response.payload.vtxos.map(chunkGLLBSULU_cjs.normalizeVtxo);
|
|
19449
19449
|
} catch (e) {
|
|
19450
19450
|
throw new Error("Failed to annotate vtxos");
|
|
19451
19451
|
}
|
|
@@ -20050,7 +20050,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
20050
20050
|
};
|
|
20051
20051
|
try {
|
|
20052
20052
|
const response = await wallet.sendMessage(message);
|
|
20053
|
-
return response.payload.vtxos.map(
|
|
20053
|
+
return response.payload.vtxos.map(chunkGLLBSULU_cjs.normalizeVtxo);
|
|
20054
20054
|
} catch (e) {
|
|
20055
20055
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
20056
20056
|
}
|
|
@@ -20162,12 +20162,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20162
20162
|
* @returns Configured onchain wallet
|
|
20163
20163
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
20164
20164
|
*/
|
|
20165
|
-
static async create(identity, networkName =
|
|
20165
|
+
static async create(identity, networkName = chunkGLLBSULU_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
20166
20166
|
const pubkey = await identity.xOnlyPublicKey();
|
|
20167
20167
|
if (!pubkey) {
|
|
20168
20168
|
throw new Error("Invalid configured public key");
|
|
20169
20169
|
}
|
|
20170
|
-
const network =
|
|
20170
|
+
const network = chunkGLLBSULU_cjs.getNetwork(networkName);
|
|
20171
20171
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
20172
20172
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
20173
20173
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -20273,7 +20273,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20273
20273
|
if (!inputs) {
|
|
20274
20274
|
throw new Error("Fee estimation failed");
|
|
20275
20275
|
}
|
|
20276
|
-
let tx = new
|
|
20276
|
+
let tx = new chunkGLLBSULU_cjs.Transaction();
|
|
20277
20277
|
for (const input of inputs) {
|
|
20278
20278
|
tx.addInput({
|
|
20279
20279
|
txid: input.txid,
|
|
@@ -20331,7 +20331,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20331
20331
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
20332
20332
|
*/
|
|
20333
20333
|
async bumpAnchor(parentHex, feeRate) {
|
|
20334
|
-
const parent =
|
|
20334
|
+
const parent = chunkGLLBSULU_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
20335
20335
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
20336
20336
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
20337
20337
|
return [parent.hex, child.hex];
|
|
@@ -21238,7 +21238,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
21238
21238
|
try {
|
|
21239
21239
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
21240
21240
|
for (const psbt of txs) {
|
|
21241
|
-
const tx =
|
|
21241
|
+
const tx = chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
21242
21242
|
resolved.set(tx.id, tx.toBytes());
|
|
21243
21243
|
}
|
|
21244
21244
|
} catch (err) {
|
|
@@ -21271,7 +21271,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
21271
21271
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
21272
21272
|
const pending = [];
|
|
21273
21273
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
21274
|
-
if (
|
|
21274
|
+
if (chunkGLLBSULU_cjs.getArkPsbtFields(tx, i, chunkGLLBSULU_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
21275
21275
|
}
|
|
21276
21276
|
if (pending.length === 0) return;
|
|
21277
21277
|
const resolved = await resolvePrevTxs(
|
|
@@ -21280,13 +21280,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
21280
21280
|
onchain
|
|
21281
21281
|
);
|
|
21282
21282
|
for (const i of pending) {
|
|
21283
|
-
|
|
21283
|
+
chunkGLLBSULU_cjs.setArkPsbtField(tx, i, chunkGLLBSULU_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
21284
21284
|
}
|
|
21285
21285
|
}
|
|
21286
21286
|
async function attachPrevoutTxs(tx, source) {
|
|
21287
21287
|
const pending = [];
|
|
21288
21288
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
21289
|
-
if (
|
|
21289
|
+
if (chunkGLLBSULU_cjs.getArkPsbtFields(tx, i, chunkGLLBSULU_cjs.PrevoutTxField).length > 0) continue;
|
|
21290
21290
|
const input = tx.getInput(i);
|
|
21291
21291
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
21292
21292
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -21297,7 +21297,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
21297
21297
|
resolved.set(txid, await source.getRawTransaction(txid));
|
|
21298
21298
|
}
|
|
21299
21299
|
for (const { index, txid } of pending) {
|
|
21300
|
-
|
|
21300
|
+
chunkGLLBSULU_cjs.setArkPsbtField(tx, index, chunkGLLBSULU_cjs.PrevoutTxField, resolved.get(txid));
|
|
21301
21301
|
}
|
|
21302
21302
|
}
|
|
21303
21303
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -21323,7 +21323,7 @@ exports.BIP322 = void 0;
|
|
|
21323
21323
|
async function sign2(message, identity, network) {
|
|
21324
21324
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
21325
21325
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
21326
|
-
const toSpend =
|
|
21326
|
+
const toSpend = chunkGLLBSULU_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
21327
21327
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
21328
21328
|
const signed = await identity.sign(toSign, [0]);
|
|
21329
21329
|
signed.finalizeIdx(0);
|
|
@@ -21381,7 +21381,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
21381
21381
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
21382
21382
|
return false;
|
|
21383
21383
|
}
|
|
21384
|
-
const toSpend =
|
|
21384
|
+
const toSpend = chunkGLLBSULU_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
21385
21385
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
21386
21386
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
21387
21387
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -21402,7 +21402,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
21402
21402
|
}
|
|
21403
21403
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
21404
21404
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
21405
|
-
const toSpend =
|
|
21405
|
+
const toSpend = chunkGLLBSULU_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
21406
21406
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
21407
21407
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
21408
21408
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -21455,7 +21455,7 @@ function encodeCompactSize(n) {
|
|
|
21455
21455
|
return buf;
|
|
21456
21456
|
}
|
|
21457
21457
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
21458
|
-
const tx = new
|
|
21458
|
+
const tx = new chunkGLLBSULU_cjs.Transaction({ version: 0 });
|
|
21459
21459
|
tx.addInput({
|
|
21460
21460
|
txid: toSpend.id,
|
|
21461
21461
|
index: 0,
|
|
@@ -21469,12 +21469,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
21469
21469
|
});
|
|
21470
21470
|
tx.addOutput({
|
|
21471
21471
|
amount: 0n,
|
|
21472
|
-
script:
|
|
21472
|
+
script: chunkGLLBSULU_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
21473
21473
|
});
|
|
21474
21474
|
return tx;
|
|
21475
21475
|
}
|
|
21476
21476
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
21477
|
-
const tx = new
|
|
21477
|
+
const tx = new chunkGLLBSULU_cjs.Transaction({ version: 0 });
|
|
21478
21478
|
tx.addInput({
|
|
21479
21479
|
txid: toSpend.id,
|
|
21480
21480
|
index: 0,
|
|
@@ -21486,7 +21486,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
21486
21486
|
});
|
|
21487
21487
|
tx.addOutput({
|
|
21488
21488
|
amount: 0n,
|
|
21489
|
-
script:
|
|
21489
|
+
script: chunkGLLBSULU_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
21490
21490
|
});
|
|
21491
21491
|
return tx;
|
|
21492
21492
|
}
|
|
@@ -21499,7 +21499,7 @@ var RestEmulatorProvider = class {
|
|
|
21499
21499
|
serverUrl;
|
|
21500
21500
|
async getInfo() {
|
|
21501
21501
|
const url = `${this.serverUrl}/v1/info`;
|
|
21502
|
-
const response = await
|
|
21502
|
+
const response = await chunkGLLBSULU_cjs.baseFetch(url);
|
|
21503
21503
|
if (!response.ok) {
|
|
21504
21504
|
const errorText2 = await response.text();
|
|
21505
21505
|
throw new Error(`Failed to get emulator info: ${errorText2}`);
|
|
@@ -21617,7 +21617,7 @@ var RestEmulatorProvider = class {
|
|
|
21617
21617
|
}
|
|
21618
21618
|
};
|
|
21619
21619
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
21620
|
-
const tx =
|
|
21620
|
+
const tx = chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
21621
21621
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
21622
21622
|
const input = tx.getInput(0);
|
|
21623
21623
|
if (!input) {
|
|
@@ -21644,14 +21644,14 @@ var ExitPathError = class extends Error {
|
|
|
21644
21644
|
reason;
|
|
21645
21645
|
};
|
|
21646
21646
|
function delayWeight(sequence) {
|
|
21647
|
-
const t =
|
|
21647
|
+
const t = chunkGLLBSULU_cjs.sequenceToTimelock(sequence);
|
|
21648
21648
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
21649
21649
|
}
|
|
21650
21650
|
async function resolveUnilateralPath(params) {
|
|
21651
21651
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
21652
21652
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
21653
21653
|
if (contract) {
|
|
21654
|
-
const handler =
|
|
21654
|
+
const handler = chunkA2T3GGAK_cjs.contractHandlers.get(contract.type);
|
|
21655
21655
|
if (!handler) {
|
|
21656
21656
|
throw new ExitPathError(
|
|
21657
21657
|
"no-handler",
|
|
@@ -21673,12 +21673,12 @@ async function resolveUnilateralPath(params) {
|
|
|
21673
21673
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
21674
21674
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
21675
21675
|
}
|
|
21676
|
-
const decoded =
|
|
21676
|
+
const decoded = chunkGLLBSULU_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
21677
21677
|
let best;
|
|
21678
21678
|
for (const exit of decoded.exitPaths()) {
|
|
21679
21679
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
21680
21680
|
if (!leaf) continue;
|
|
21681
|
-
const sequence =
|
|
21681
|
+
const sequence = chunkGLLBSULU_cjs.timelockToSequence(exit.params.timelock);
|
|
21682
21682
|
const weight = delayWeight(sequence);
|
|
21683
21683
|
if (!best || weight < best.weight) {
|
|
21684
21684
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -21897,8 +21897,9 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
21897
21897
|
const inputs = [];
|
|
21898
21898
|
let totalAmount = 0n;
|
|
21899
21899
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
21900
|
+
const walletDescriptor = base.hex.encode(await wallet.identity.xOnlyPublicKey());
|
|
21900
21901
|
for (const vtxo of vtxos) {
|
|
21901
|
-
if (!
|
|
21902
|
+
if (!chunkGLLBSULU_cjs.canSweepOnchain(vtxo)) {
|
|
21902
21903
|
throw new Error(
|
|
21903
21904
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
21904
21905
|
);
|
|
@@ -21909,13 +21910,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
21909
21910
|
}
|
|
21910
21911
|
const resolved = await resolveUnilateralPath({
|
|
21911
21912
|
vtxo,
|
|
21912
|
-
scriptHex: base.hex.encode(
|
|
21913
|
+
scriptHex: base.hex.encode(chunkGLLBSULU_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
21913
21914
|
contractRepository: wallet.contractRepository,
|
|
21915
|
+
walletDescriptor,
|
|
21914
21916
|
currentTime: Date.now()
|
|
21915
21917
|
});
|
|
21916
21918
|
const spendingLeaf = resolved.selection.leaf;
|
|
21917
21919
|
const sequence = resolved.selection.sequence;
|
|
21918
|
-
const timelock =
|
|
21920
|
+
const timelock = chunkGLLBSULU_cjs.sequenceToTimelock(sequence);
|
|
21919
21921
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
21920
21922
|
if (!elapsed) {
|
|
21921
21923
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -21928,7 +21930,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
21928
21930
|
sequence,
|
|
21929
21931
|
witnessUtxo: {
|
|
21930
21932
|
amount: BigInt(vtxo.value),
|
|
21931
|
-
script:
|
|
21933
|
+
script: chunkGLLBSULU_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
21932
21934
|
},
|
|
21933
21935
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
21934
21936
|
});
|
|
@@ -21938,7 +21940,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
21938
21940
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
21939
21941
|
);
|
|
21940
21942
|
}
|
|
21941
|
-
const tx = new
|
|
21943
|
+
const tx = new chunkGLLBSULU_cjs.Transaction({ version: 2 });
|
|
21942
21944
|
for (const input of inputs) {
|
|
21943
21945
|
tx.addInput(input);
|
|
21944
21946
|
}
|
|
@@ -22021,7 +22023,7 @@ async function buildSignedSweep(params) {
|
|
|
22021
22023
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
22022
22024
|
);
|
|
22023
22025
|
}
|
|
22024
|
-
const tx = new
|
|
22026
|
+
const tx = new chunkGLLBSULU_cjs.Transaction({ version: 2 });
|
|
22025
22027
|
tx.addInput({
|
|
22026
22028
|
txid: vtxo.txid,
|
|
22027
22029
|
index: vtxo.vout,
|
|
@@ -22046,7 +22048,7 @@ async function buildSignedSweep(params) {
|
|
|
22046
22048
|
finalScriptWitness: [
|
|
22047
22049
|
tapScriptSig[0][1],
|
|
22048
22050
|
...path.extraWitness,
|
|
22049
|
-
|
|
22051
|
+
chunkGLLBSULU_cjs.scriptFromTapLeafScript(path.leaf),
|
|
22050
22052
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
22051
22053
|
]
|
|
22052
22054
|
});
|
|
@@ -22076,7 +22078,7 @@ async function resolveFeeRate(opts) {
|
|
|
22076
22078
|
}
|
|
22077
22079
|
async function selectExitVtxos(opts) {
|
|
22078
22080
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
22079
|
-
const res = await
|
|
22081
|
+
const res = await chunkGLLBSULU_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
22080
22082
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
22081
22083
|
const out = [];
|
|
22082
22084
|
for (const vtxo of res.vtxos) {
|
|
@@ -22091,7 +22093,7 @@ async function selectExitVtxos(opts) {
|
|
|
22091
22093
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
22092
22094
|
);
|
|
22093
22095
|
}
|
|
22094
|
-
const handler =
|
|
22096
|
+
const handler = chunkA2T3GGAK_cjs.contractHandlers.get(contract.type);
|
|
22095
22097
|
if (!handler) {
|
|
22096
22098
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
22097
22099
|
}
|
|
@@ -22121,7 +22123,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22121
22123
|
if (pendingNodes.length > 0) {
|
|
22122
22124
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
22123
22125
|
for (const psbt of txs) {
|
|
22124
|
-
psbts.set(
|
|
22126
|
+
psbts.set(chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
22125
22127
|
}
|
|
22126
22128
|
}
|
|
22127
22129
|
const childVsize = Number(
|
|
@@ -22157,7 +22159,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22157
22159
|
try {
|
|
22158
22160
|
const resolved = await resolveUnilateralPath({
|
|
22159
22161
|
vtxo,
|
|
22160
|
-
scriptHex: base.hex.encode(
|
|
22162
|
+
scriptHex: base.hex.encode(chunkGLLBSULU_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
22161
22163
|
contractRepository: wallet.contractRepository,
|
|
22162
22164
|
walletDescriptor,
|
|
22163
22165
|
currentTime: Date.now()
|
|
@@ -22176,7 +22178,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22176
22178
|
});
|
|
22177
22179
|
continue;
|
|
22178
22180
|
}
|
|
22179
|
-
const t =
|
|
22181
|
+
const t = chunkGLLBSULU_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
22180
22182
|
const delay = { type: t.type, value: Number(t.value) };
|
|
22181
22183
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
22182
22184
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -22577,7 +22579,7 @@ async function prepare(opts) {
|
|
|
22577
22579
|
txid: sweep.vtxo.txid,
|
|
22578
22580
|
vout: sweep.vtxo.vout,
|
|
22579
22581
|
value: sweep.vtxo.value,
|
|
22580
|
-
pkScript:
|
|
22582
|
+
pkScript: chunkGLLBSULU_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
22581
22583
|
},
|
|
22582
22584
|
path: sweep.resolved.selection,
|
|
22583
22585
|
outputAddress: opts.sweepAddress,
|
|
@@ -22665,7 +22667,7 @@ async function prepare(opts) {
|
|
|
22665
22667
|
if (newFee <= splitterFee) break;
|
|
22666
22668
|
splitterFee = newFee;
|
|
22667
22669
|
}
|
|
22668
|
-
const splitter = new
|
|
22670
|
+
const splitter = new chunkGLLBSULU_cjs.Transaction({ version: 2 });
|
|
22669
22671
|
for (const coin of selected.inputs) {
|
|
22670
22672
|
splitter.addInput({
|
|
22671
22673
|
txid: coin.txid,
|
|
@@ -22808,42 +22810,42 @@ var UnilateralExit = {
|
|
|
22808
22810
|
|
|
22809
22811
|
// src/arkade/index.ts
|
|
22810
22812
|
var arkade_exports = {};
|
|
22811
|
-
|
|
22812
|
-
ARKADE_OP: () =>
|
|
22813
|
-
ARKADE_OPCODES: () =>
|
|
22814
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
22815
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
22816
|
-
ARKADE_OPS: () =>
|
|
22813
|
+
chunkGLLBSULU_cjs.__export(arkade_exports, {
|
|
22814
|
+
ARKADE_OP: () => chunkA2T3GGAK_cjs.ARKADE_OP,
|
|
22815
|
+
ARKADE_OPCODES: () => chunkA2T3GGAK_cjs.ARKADE_OPCODES,
|
|
22816
|
+
ARKADE_OPCODE_NAMES: () => chunkA2T3GGAK_cjs.ARKADE_OPCODE_NAMES,
|
|
22817
|
+
ARKADE_OPCODE_VALUES: () => chunkA2T3GGAK_cjs.ARKADE_OPCODE_VALUES,
|
|
22818
|
+
ARKADE_OPS: () => chunkA2T3GGAK_cjs.ARKADE_OPS,
|
|
22817
22819
|
Arkade: () => Arkade,
|
|
22818
22820
|
ArkadeContract: () => ArkadeContract,
|
|
22819
|
-
ArkadeProgramScript: () =>
|
|
22820
|
-
ArkadeScript: () =>
|
|
22821
|
+
ArkadeProgramScript: () => chunkA2T3GGAK_cjs.ArkadeProgramScript,
|
|
22822
|
+
ArkadeScript: () => chunkA2T3GGAK_cjs.ArkadeScript,
|
|
22821
22823
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
22822
|
-
BigNum: () =>
|
|
22824
|
+
BigNum: () => chunkA2T3GGAK_cjs.bignum_exports,
|
|
22823
22825
|
OP: () => btcSigner.OP,
|
|
22824
|
-
OPCODE_NAMES: () =>
|
|
22825
|
-
OPCODE_VALUES: () =>
|
|
22826
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
22826
|
+
OPCODE_NAMES: () => chunkA2T3GGAK_cjs.OPCODE_NAMES,
|
|
22827
|
+
OPCODE_VALUES: () => chunkA2T3GGAK_cjs.OPCODE_VALUES,
|
|
22828
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkA2T3GGAK_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
22827
22829
|
Script: () => btcSigner.Script,
|
|
22828
|
-
arkadeScriptHash: () =>
|
|
22829
|
-
arkadeWitnessHash: () =>
|
|
22830
|
-
asmToBytes: () =>
|
|
22831
|
-
bytesToASM: () =>
|
|
22832
|
-
computeArkadeScriptPublicKey: () =>
|
|
22830
|
+
arkadeScriptHash: () => chunkA2T3GGAK_cjs.arkadeScriptHash,
|
|
22831
|
+
arkadeWitnessHash: () => chunkA2T3GGAK_cjs.arkadeWitnessHash,
|
|
22832
|
+
asmToBytes: () => chunkA2T3GGAK_cjs.asmToBytes,
|
|
22833
|
+
bytesToASM: () => chunkA2T3GGAK_cjs.bytesToASM,
|
|
22834
|
+
computeArkadeScriptPublicKey: () => chunkA2T3GGAK_cjs.computeArkadeScriptPublicKey,
|
|
22833
22835
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
22834
|
-
deserializeArkadeContractParams: () =>
|
|
22835
|
-
fromASM: () =>
|
|
22836
|
-
getOpcodeName: () =>
|
|
22837
|
-
getOpcodeValue: () =>
|
|
22838
|
-
parseArtifact: () =>
|
|
22839
|
-
resolveAsm: () =>
|
|
22840
|
-
serializeArkadeContractParams: () =>
|
|
22841
|
-
stringifyArtifact: () =>
|
|
22842
|
-
toASM: () =>
|
|
22843
|
-
validateProgram: () =>
|
|
22844
|
-
witnessRefToBytes: () =>
|
|
22836
|
+
deserializeArkadeContractParams: () => chunkA2T3GGAK_cjs.deserializeArkadeContractParams,
|
|
22837
|
+
fromASM: () => chunkA2T3GGAK_cjs.fromASM,
|
|
22838
|
+
getOpcodeName: () => chunkA2T3GGAK_cjs.getOpcodeName,
|
|
22839
|
+
getOpcodeValue: () => chunkA2T3GGAK_cjs.getOpcodeValue,
|
|
22840
|
+
parseArtifact: () => chunkA2T3GGAK_cjs.parseArtifact,
|
|
22841
|
+
resolveAsm: () => chunkA2T3GGAK_cjs.resolveAsm,
|
|
22842
|
+
serializeArkadeContractParams: () => chunkA2T3GGAK_cjs.serializeArkadeContractParams,
|
|
22843
|
+
stringifyArtifact: () => chunkA2T3GGAK_cjs.stringifyArtifact,
|
|
22844
|
+
toASM: () => chunkA2T3GGAK_cjs.toASM,
|
|
22845
|
+
validateProgram: () => chunkA2T3GGAK_cjs.validateProgram,
|
|
22846
|
+
witnessRefToBytes: () => chunkA2T3GGAK_cjs.witnessRefToBytes
|
|
22845
22847
|
});
|
|
22846
|
-
var isVtxoCoin = (input) =>
|
|
22848
|
+
var isVtxoCoin = (input) => chunkGLLBSULU_cjs.isVirtualCoin(input);
|
|
22847
22849
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
22848
22850
|
let batchId;
|
|
22849
22851
|
let sweepTapTreeRoot;
|
|
@@ -22864,23 +22866,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
22864
22866
|
);
|
|
22865
22867
|
await arkProvider.confirmRegistration(intentId);
|
|
22866
22868
|
batchId = event.id;
|
|
22867
|
-
const sweepTapscript =
|
|
22869
|
+
const sweepTapscript = chunkGLLBSULU_cjs.CSVMultisigTapscript.encode({
|
|
22868
22870
|
timelock,
|
|
22869
|
-
pubkeys: [
|
|
22871
|
+
pubkeys: [chunkA2T3GGAK_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
|
|
22870
22872
|
}).script;
|
|
22871
22873
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
22872
22874
|
return { skip: false };
|
|
22873
22875
|
},
|
|
22874
22876
|
onTreeSigningStarted: async (event, vtxoTree) => {
|
|
22875
22877
|
const signerPubKey = await session.getPublicKey();
|
|
22876
|
-
const xonlySignerPubKey =
|
|
22878
|
+
const xonlySignerPubKey = chunkA2T3GGAK_cjs.toXOnly(signerPubKey, "signer key");
|
|
22877
22879
|
const xOnlyPubkeys = event.cosignersPublicKeys.map(
|
|
22878
|
-
(k) => base.hex.encode(
|
|
22880
|
+
(k) => base.hex.encode(chunkA2T3GGAK_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
22879
22881
|
);
|
|
22880
22882
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
22881
22883
|
return { skip: true };
|
|
22882
22884
|
}
|
|
22883
|
-
const commitmentTx =
|
|
22885
|
+
const commitmentTx = chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
22884
22886
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
22885
22887
|
if (recipients && recipients.length > 0) {
|
|
22886
22888
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -22912,7 +22914,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
22912
22914
|
if (connectorTree) {
|
|
22913
22915
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
22914
22916
|
}
|
|
22915
|
-
let commitmentPsbt =
|
|
22917
|
+
let commitmentPsbt = chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
22916
22918
|
assertFinalCommitmentMatchesValidated(
|
|
22917
22919
|
commitmentPsbt,
|
|
22918
22920
|
validatedCommitmentTxid,
|
|
@@ -22947,7 +22949,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
22947
22949
|
boardingIndices.push(boardingIdx);
|
|
22948
22950
|
continue;
|
|
22949
22951
|
}
|
|
22950
|
-
if (
|
|
22952
|
+
if (chunkGLLBSULU_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust(input, info.dust)) {
|
|
22951
22953
|
continue;
|
|
22952
22954
|
}
|
|
22953
22955
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -22968,7 +22970,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
22968
22970
|
index: input.vout,
|
|
22969
22971
|
witnessUtxo: {
|
|
22970
22972
|
amount: BigInt(input.value),
|
|
22971
|
-
script:
|
|
22973
|
+
script: chunkGLLBSULU_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
22972
22974
|
},
|
|
22973
22975
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
22974
22976
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -23059,16 +23061,16 @@ var Arkade = class _Arkade {
|
|
|
23059
23061
|
/** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
|
|
23060
23062
|
static async connect(opts) {
|
|
23061
23063
|
const info = await opts.arkade.getInfo();
|
|
23062
|
-
const serverKey =
|
|
23063
|
-
const checkpoint =
|
|
23064
|
-
const network = opts.network ??
|
|
23064
|
+
const serverKey = chunkA2T3GGAK_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
23065
|
+
const checkpoint = chunkGLLBSULU_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
23066
|
+
const network = opts.network ?? chunkGLLBSULU_cjs.DEFAULT_NETWORK;
|
|
23065
23067
|
let emulatorKey;
|
|
23066
23068
|
if (opts.emulator) {
|
|
23067
|
-
emulatorKey = base.hex.decode(
|
|
23069
|
+
emulatorKey = base.hex.decode(chunkGLLBSULU_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
23068
23070
|
}
|
|
23069
23071
|
let userKey;
|
|
23070
23072
|
if (opts.identity) {
|
|
23071
|
-
userKey =
|
|
23073
|
+
userKey = chunkA2T3GGAK_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
|
|
23072
23074
|
}
|
|
23073
23075
|
return new _Arkade({
|
|
23074
23076
|
arkProvider: opts.arkade,
|
|
@@ -23094,7 +23096,7 @@ var Arkade = class _Arkade {
|
|
|
23094
23096
|
* key respectively; explicit args always win.
|
|
23095
23097
|
*/
|
|
23096
23098
|
contract(program, args = {}) {
|
|
23097
|
-
const declared = (program.params ?? []).map(
|
|
23099
|
+
const declared = (program.params ?? []).map(chunkA2T3GGAK_cjs.inputName);
|
|
23098
23100
|
if (declared.includes("server") && args.server === void 0) {
|
|
23099
23101
|
args = { ...args, server: this.serverKey };
|
|
23100
23102
|
}
|
|
@@ -23114,7 +23116,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23114
23116
|
userKey: client.userKey,
|
|
23115
23117
|
emulatorKey: client.emulatorKey
|
|
23116
23118
|
};
|
|
23117
|
-
this.vtxoScript = new
|
|
23119
|
+
this.vtxoScript = new chunkA2T3GGAK_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
23118
23120
|
this.tapTree = this.vtxoScript.encode();
|
|
23119
23121
|
this.compiled = this.vtxoScript.compiled;
|
|
23120
23122
|
}
|
|
@@ -23142,7 +23144,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23142
23144
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
23143
23145
|
);
|
|
23144
23146
|
}
|
|
23145
|
-
const typed =
|
|
23147
|
+
const typed = chunkA2T3GGAK_cjs.deserializeArkadeContractParams(contract.params);
|
|
23146
23148
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
23147
23149
|
serverKey: typed.serverKey,
|
|
23148
23150
|
userKey: typed.userKey,
|
|
@@ -23183,7 +23185,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23183
23185
|
toContractParams() {
|
|
23184
23186
|
return {
|
|
23185
23187
|
type: "arkade",
|
|
23186
|
-
params:
|
|
23188
|
+
params: chunkA2T3GGAK_cjs.serializeArkadeContractParams({
|
|
23187
23189
|
program: this.program,
|
|
23188
23190
|
args: this.args,
|
|
23189
23191
|
serverKey: this.keys.serverKey,
|
|
@@ -23233,18 +23235,18 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23233
23235
|
if (registered) {
|
|
23234
23236
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
23235
23237
|
return (withVtxos?.vtxos ?? []).filter(
|
|
23236
|
-
(v) => !
|
|
23238
|
+
(v) => !chunkGLLBSULU_cjs.hasTerminalSpend(v) && !v.isUnrolled
|
|
23237
23239
|
);
|
|
23238
23240
|
}
|
|
23239
23241
|
}
|
|
23240
23242
|
if (!this.client.indexer) {
|
|
23241
23243
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
23242
23244
|
}
|
|
23243
|
-
const { vtxos } = await
|
|
23245
|
+
const { vtxos } = await chunkGLLBSULU_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
23244
23246
|
scripts: [scriptHex],
|
|
23245
23247
|
spendableOnly: true
|
|
23246
23248
|
});
|
|
23247
|
-
return vtxos.filter((v) => !
|
|
23249
|
+
return vtxos.filter((v) => !chunkGLLBSULU_cjs.hasTerminalSpend(v) && !v.isUnrolled);
|
|
23248
23250
|
}
|
|
23249
23251
|
/** Total spendable balance (requires an indexer). */
|
|
23250
23252
|
async getBalance() {
|
|
@@ -23342,7 +23344,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
23342
23344
|
this.contract.client.checkpoint
|
|
23343
23345
|
);
|
|
23344
23346
|
if (coin.sourceTx) {
|
|
23345
|
-
|
|
23347
|
+
chunkGLLBSULU_cjs.setArkPsbtField(arkTx, 0, chunkGLLBSULU_cjs.PrevArkTxField, coin.sourceTx);
|
|
23346
23348
|
}
|
|
23347
23349
|
if (this.fn.arkadeScript) {
|
|
23348
23350
|
const indexer = this.contract.client.indexer;
|
|
@@ -23359,8 +23361,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
23359
23361
|
}
|
|
23360
23362
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
23361
23363
|
if (condition.length > 0) {
|
|
23362
|
-
|
|
23363
|
-
|
|
23364
|
+
chunkGLLBSULU_cjs.setArkPsbtField(arkTx, 0, chunkGLLBSULU_cjs.ConditionWitness, condition);
|
|
23365
|
+
chunkGLLBSULU_cjs.setArkPsbtField(checkpoints[0], 0, chunkGLLBSULU_cjs.ConditionWitness, condition);
|
|
23364
23366
|
}
|
|
23365
23367
|
const packets = [];
|
|
23366
23368
|
if (this.assetSpecs.length > 0) {
|
|
@@ -23399,7 +23401,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
23399
23401
|
base.base64.encode(signedArk2.toPSBT()),
|
|
23400
23402
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
23401
23403
|
);
|
|
23402
|
-
const txid =
|
|
23404
|
+
const txid = chunkGLLBSULU_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
23403
23405
|
return {
|
|
23404
23406
|
txid,
|
|
23405
23407
|
signedArkTx: res2.signedArkTx,
|
|
@@ -23464,23 +23466,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
23464
23466
|
}
|
|
23465
23467
|
buildAssetPacket() {
|
|
23466
23468
|
const groups = this.assetSpecs.map((s) => {
|
|
23467
|
-
const id = typeof s.assetId === "string" ?
|
|
23468
|
-
return
|
|
23469
|
+
const id = typeof s.assetId === "string" ? chunkXOT73T36_cjs.AssetId.fromString(s.assetId) : chunkXOT73T36_cjs.AssetId.fromBytes(s.assetId);
|
|
23470
|
+
return chunkXOT73T36_cjs.AssetGroup.create(
|
|
23469
23471
|
id,
|
|
23470
23472
|
null,
|
|
23471
|
-
s.inputs.map((i) =>
|
|
23472
|
-
s.outputs.map((o) =>
|
|
23473
|
-
(s.metadata ?? []).map((m) =>
|
|
23473
|
+
s.inputs.map((i) => chunkXOT73T36_cjs.AssetInput.create(i.vin, i.amount)),
|
|
23474
|
+
s.outputs.map((o) => chunkXOT73T36_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
23475
|
+
(s.metadata ?? []).map((m) => chunkXOT73T36_cjs.Metadata.create(m.key, m.value))
|
|
23474
23476
|
);
|
|
23475
23477
|
});
|
|
23476
|
-
return
|
|
23478
|
+
return chunkXOT73T36_cjs.Packet.create(groups);
|
|
23477
23479
|
}
|
|
23478
23480
|
witnessBytes(ref) {
|
|
23479
|
-
return
|
|
23481
|
+
return chunkA2T3GGAK_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
23480
23482
|
}
|
|
23481
23483
|
};
|
|
23482
23484
|
function bindInputs(fn, callArgs) {
|
|
23483
|
-
const names = (fn.def.inputs ?? []).map(
|
|
23485
|
+
const names = (fn.def.inputs ?? []).map(chunkA2T3GGAK_cjs.inputName);
|
|
23484
23486
|
if (callArgs.length !== names.length) {
|
|
23485
23487
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
23486
23488
|
}
|
|
@@ -24155,5 +24157,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
|
24155
24157
|
exports.walletFeeSource = walletFeeSource;
|
|
24156
24158
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
24157
24159
|
exports.withPrevTxs = withPrevTxs;
|
|
24158
|
-
//# sourceMappingURL=chunk-
|
|
24159
|
-
//# sourceMappingURL=chunk-
|
|
24160
|
+
//# sourceMappingURL=chunk-EIMOVGBV.cjs.map
|
|
24161
|
+
//# sourceMappingURL=chunk-EIMOVGBV.cjs.map
|