@arkade-os/sdk 0.4.63 → 0.4.64
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/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{asyncStorageTaskQueue-CIUEhv2t.d.cts → asyncStorageTaskQueue-Chwe60Ce.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-LT-xvvDN.d.ts → asyncStorageTaskQueue-Dq_UcvDx.d.ts} +2 -2
- package/dist/{chunk-K56BNZV3.cjs → chunk-35YIP6OA.cjs} +10 -10
- package/dist/{chunk-K56BNZV3.cjs.map → chunk-35YIP6OA.cjs.map} +1 -1
- package/dist/{chunk-P6XYE27K.cjs → chunk-4N45WCSJ.cjs} +17 -17
- package/dist/{chunk-P6XYE27K.cjs.map → chunk-4N45WCSJ.cjs.map} +1 -1
- package/dist/{chunk-AB67CMHS.cjs → chunk-FZFSGOTZ.cjs} +3 -3
- package/dist/{chunk-AB67CMHS.cjs.map → chunk-FZFSGOTZ.cjs.map} +1 -1
- package/dist/{chunk-CZFAMS57.js → chunk-HQ2DDMQN.js} +3 -3
- package/dist/{chunk-CZFAMS57.js.map → chunk-HQ2DDMQN.js.map} +1 -1
- package/dist/{chunk-OAESYVZQ.js → chunk-LN2VZP63.js} +3 -3
- package/dist/{chunk-OAESYVZQ.js.map → chunk-LN2VZP63.js.map} +1 -1
- package/dist/{chunk-COOBS7ET.cjs → chunk-LPEE2H2M.cjs} +401 -401
- package/dist/{chunk-COOBS7ET.cjs.map → chunk-LPEE2H2M.cjs.map} +1 -1
- package/dist/{chunk-LG5GY73A.cjs → chunk-RXITDAV4.cjs} +17 -17
- package/dist/{chunk-LG5GY73A.cjs.map → chunk-RXITDAV4.cjs.map} +1 -1
- package/dist/{chunk-KWW74O2F.js → chunk-USXWE2EJ.js} +4 -4
- package/dist/{chunk-KWW74O2F.js.map → chunk-USXWE2EJ.js.map} +1 -1
- package/dist/{chunk-X7MMBB7S.js → chunk-WJN2BLEI.js} +5 -5
- package/dist/{chunk-X7MMBB7S.js.map → chunk-WJN2BLEI.js.map} +1 -1
- package/dist/{chunk-OL7V43WS.cjs → chunk-WXCVS6PD.cjs} +48 -48
- package/dist/{chunk-OL7V43WS.cjs.map → chunk-WXCVS6PD.cjs.map} +1 -1
- package/dist/{chunk-MA32NXUV.js → chunk-XJCBV4AA.js} +3 -3
- package/dist/{chunk-MA32NXUV.js.map → chunk-XJCBV4AA.js.map} +1 -1
- package/dist/{chunk-FKKERGKA.js → chunk-ZUEGFM3T.js} +4 -4
- package/dist/{chunk-FKKERGKA.js.map → chunk-ZUEGFM3T.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/index.cjs +268 -268
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +18 -18
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-BQb0W1XG.d.ts → taskRunner-BDzWbpct.d.ts} +1 -1
- package/dist/{taskRunner-BJ6_AnLq.d.cts → taskRunner-CIKOS2OO.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +2 -2
- package/dist/wallet/expo/background.d.ts +2 -2
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.d.cts +1 -1
- package/dist/wallet/expo/index.d.ts +1 -1
- package/dist/wallet/expo/index.js +5 -5
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +3 -3
- package/dist/worker/expo/index.d.ts +3 -3
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkRXITDAV4_cjs = require('./chunk-RXITDAV4.cjs');
|
|
4
|
+
var chunkWXCVS6PD_cjs = require('./chunk-WXCVS6PD.cjs');
|
|
5
|
+
var chunkFZFSGOTZ_cjs = require('./chunk-FZFSGOTZ.cjs');
|
|
6
6
|
var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
|
|
7
7
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
8
8
|
var btcSigner = require('@scure/btc-signer');
|
|
@@ -188,7 +188,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
188
188
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
189
189
|
const tx = this.graph.find(txid);
|
|
190
190
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
191
|
-
const cosigners =
|
|
191
|
+
const cosigners = chunkFZFSGOTZ_cjs.getArkPsbtFields(tx.root, 0, chunkFZFSGOTZ_cjs.CosignerPublicKey).map(
|
|
192
192
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
193
193
|
// xonly pubkey
|
|
194
194
|
);
|
|
@@ -240,7 +240,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
240
240
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
241
241
|
const prevoutAmounts = [];
|
|
242
242
|
const prevoutScripts = [];
|
|
243
|
-
const cosigners =
|
|
243
|
+
const cosigners = chunkFZFSGOTZ_cjs.getArkPsbtFields(g.root, 0, chunkFZFSGOTZ_cjs.CosignerPublicKey).map((c) => c.key);
|
|
244
244
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
245
245
|
taprootTweak: this.scriptRoot
|
|
246
246
|
});
|
|
@@ -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 = chunkWXCVS6PD_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({
|
|
@@ -529,7 +529,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
529
529
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
530
530
|
*/
|
|
531
531
|
isOurs(descriptor) {
|
|
532
|
-
return
|
|
532
|
+
return chunkWXCVS6PD_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
533
533
|
}
|
|
534
534
|
/**
|
|
535
535
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -578,7 +578,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
578
578
|
}
|
|
579
579
|
// ── internal helpers ─────────────────────────────────────────────
|
|
580
580
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
581
|
-
const network =
|
|
581
|
+
const network = chunkWXCVS6PD_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
582
582
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
583
583
|
if (expansion.isRanged) {
|
|
584
584
|
throw new Error(
|
|
@@ -664,7 +664,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
664
664
|
*/
|
|
665
665
|
descriptor;
|
|
666
666
|
constructor(descriptor) {
|
|
667
|
-
const network =
|
|
667
|
+
const network = chunkWXCVS6PD_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
668
668
|
let expansion;
|
|
669
669
|
try {
|
|
670
670
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -714,7 +714,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
714
714
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
715
715
|
*/
|
|
716
716
|
isOurs(descriptor) {
|
|
717
|
-
return
|
|
717
|
+
return chunkWXCVS6PD_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
718
718
|
}
|
|
719
719
|
};
|
|
720
720
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -876,10 +876,10 @@ var DescriptorIdentity = class {
|
|
|
876
876
|
this.base = base;
|
|
877
877
|
}
|
|
878
878
|
async xOnlyPublicKey() {
|
|
879
|
-
return
|
|
879
|
+
return chunkWXCVS6PD_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
880
880
|
}
|
|
881
881
|
async compressedPublicKey() {
|
|
882
|
-
return
|
|
882
|
+
return chunkWXCVS6PD_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
883
883
|
}
|
|
884
884
|
async sign(tx, inputIndexes) {
|
|
885
885
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -941,12 +941,12 @@ var ForeignDescriptorError = class extends Error {
|
|
|
941
941
|
};
|
|
942
942
|
async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
943
943
|
const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
|
|
944
|
-
if (owner &&
|
|
944
|
+
if (owner && chunkWXCVS6PD_cjs.parseHDDescriptor(descriptor)) {
|
|
945
945
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
946
946
|
}
|
|
947
947
|
let key;
|
|
948
948
|
try {
|
|
949
|
-
key =
|
|
949
|
+
key = chunkWXCVS6PD_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
950
950
|
} catch {
|
|
951
951
|
throw new ForeignDescriptorError(descriptor);
|
|
952
952
|
}
|
|
@@ -1317,11 +1317,11 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1317
1317
|
}
|
|
1318
1318
|
var PREIMAGE_INDEX = 0;
|
|
1319
1319
|
function isPerArtifactDescriptor(descriptor) {
|
|
1320
|
-
return
|
|
1320
|
+
return chunkWXCVS6PD_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1321
1321
|
}
|
|
1322
1322
|
async function provisionDescriptor(wallet) {
|
|
1323
1323
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1324
|
-
return allocated ?? await
|
|
1324
|
+
return allocated ?? await chunkWXCVS6PD_cjs.identityDescriptor(wallet.identity);
|
|
1325
1325
|
}
|
|
1326
1326
|
async function provisionRefundKey(wallet) {
|
|
1327
1327
|
const descriptor = await provisionDescriptor(wallet);
|
|
@@ -1369,7 +1369,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1369
1369
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1370
1370
|
let expected;
|
|
1371
1371
|
try {
|
|
1372
|
-
expected =
|
|
1372
|
+
expected = chunkWXCVS6PD_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1373
1373
|
} catch (cause) {
|
|
1374
1374
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1375
1375
|
}
|
|
@@ -1588,14 +1588,14 @@ var RestDelegateProvider = class {
|
|
|
1588
1588
|
*/
|
|
1589
1589
|
async delegate(intent, forfeitTxs, options) {
|
|
1590
1590
|
const url = `${this.url}/v1/delegate`;
|
|
1591
|
-
const response = await
|
|
1591
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(url, {
|
|
1592
1592
|
method: "POST",
|
|
1593
1593
|
headers: {
|
|
1594
1594
|
"Content-Type": "application/json"
|
|
1595
1595
|
},
|
|
1596
1596
|
body: JSON.stringify({
|
|
1597
1597
|
intent: {
|
|
1598
|
-
message:
|
|
1598
|
+
message: chunkFZFSGOTZ_cjs.Intent.encodeMessage(intent.message),
|
|
1599
1599
|
proof: intent.proof
|
|
1600
1600
|
},
|
|
1601
1601
|
forfeit_txs: forfeitTxs,
|
|
@@ -1615,7 +1615,7 @@ var RestDelegateProvider = class {
|
|
|
1615
1615
|
*/
|
|
1616
1616
|
async getDelegateInfo() {
|
|
1617
1617
|
const url = `${this.url}/v1/delegator/info`;
|
|
1618
|
-
const response = await
|
|
1618
|
+
const response = await chunkFZFSGOTZ_cjs.rateGate.runHttp(url, () => chunkFZFSGOTZ_cjs.baseFetch(url));
|
|
1619
1619
|
if (!response.ok) {
|
|
1620
1620
|
const errorText2 = await response.text();
|
|
1621
1621
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1642,7 +1642,7 @@ var ESPLORA_URL = {
|
|
|
1642
1642
|
regtest: "http://localhost:3000/api"
|
|
1643
1643
|
};
|
|
1644
1644
|
var EsploraProvider = class {
|
|
1645
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1645
|
+
constructor(baseUrl = ESPLORA_URL[chunkFZFSGOTZ_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1646
1646
|
this.baseUrl = baseUrl;
|
|
1647
1647
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1648
1648
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1651,14 +1651,14 @@ var EsploraProvider = class {
|
|
|
1651
1651
|
pollingInterval;
|
|
1652
1652
|
forcePolling;
|
|
1653
1653
|
async getCoins(address) {
|
|
1654
|
-
const response = await
|
|
1654
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1655
1655
|
if (!response.ok) {
|
|
1656
1656
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1657
1657
|
}
|
|
1658
1658
|
return response.json();
|
|
1659
1659
|
}
|
|
1660
1660
|
async getFeeRate() {
|
|
1661
|
-
const response = await
|
|
1661
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1662
1662
|
if (response.status === 404) {
|
|
1663
1663
|
return void 0;
|
|
1664
1664
|
}
|
|
@@ -1679,7 +1679,7 @@ var EsploraProvider = class {
|
|
|
1679
1679
|
}
|
|
1680
1680
|
}
|
|
1681
1681
|
async getTxOutspends(txid) {
|
|
1682
|
-
const response = await
|
|
1682
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1683
1683
|
if (!response.ok) {
|
|
1684
1684
|
const error = await response.text();
|
|
1685
1685
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1687,7 +1687,7 @@ var EsploraProvider = class {
|
|
|
1687
1687
|
return response.json();
|
|
1688
1688
|
}
|
|
1689
1689
|
async getTransactions(address) {
|
|
1690
|
-
const response = await
|
|
1690
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1691
1691
|
if (!response.ok) {
|
|
1692
1692
|
const error = await response.text();
|
|
1693
1693
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1695,7 +1695,7 @@ var EsploraProvider = class {
|
|
|
1695
1695
|
return response.json();
|
|
1696
1696
|
}
|
|
1697
1697
|
async getTxStatus(txid) {
|
|
1698
|
-
const txresponse = await
|
|
1698
|
+
const txresponse = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1699
1699
|
if (!txresponse.ok) {
|
|
1700
1700
|
throw new Error(txresponse.statusText);
|
|
1701
1701
|
}
|
|
@@ -1703,7 +1703,7 @@ var EsploraProvider = class {
|
|
|
1703
1703
|
if (!tx.status.confirmed) {
|
|
1704
1704
|
return { confirmed: false };
|
|
1705
1705
|
}
|
|
1706
|
-
const response = await
|
|
1706
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1707
1707
|
if (!response.ok) {
|
|
1708
1708
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1709
1709
|
}
|
|
@@ -1787,7 +1787,7 @@ var EsploraProvider = class {
|
|
|
1787
1787
|
return stopFunc;
|
|
1788
1788
|
}
|
|
1789
1789
|
async getChainTip() {
|
|
1790
|
-
const tipBlocks = await
|
|
1790
|
+
const tipBlocks = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
1791
1791
|
if (!tipBlocks.ok) {
|
|
1792
1792
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
1793
1793
|
}
|
|
@@ -1806,7 +1806,7 @@ var EsploraProvider = class {
|
|
|
1806
1806
|
};
|
|
1807
1807
|
}
|
|
1808
1808
|
async broadcastPackage(parent, child) {
|
|
1809
|
-
const response = await
|
|
1809
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
1810
1810
|
method: "POST",
|
|
1811
1811
|
headers: {
|
|
1812
1812
|
"Content-Type": "application/json"
|
|
@@ -1820,7 +1820,7 @@ var EsploraProvider = class {
|
|
|
1820
1820
|
return response.json();
|
|
1821
1821
|
}
|
|
1822
1822
|
async broadcastTx(tx) {
|
|
1823
|
-
const response = await
|
|
1823
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
1824
1824
|
method: "POST",
|
|
1825
1825
|
headers: {
|
|
1826
1826
|
"Content-Type": "text/plain"
|
|
@@ -1982,7 +1982,7 @@ function findP2AOutput(tx) {
|
|
|
1982
1982
|
var CHILD_DUST_AMOUNT = 546;
|
|
1983
1983
|
function buildAnchorChild(params) {
|
|
1984
1984
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
1985
|
-
const child = new
|
|
1985
|
+
const child = new chunkFZFSGOTZ_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
1986
1986
|
child.addInput(findP2AOutput(parent));
|
|
1987
1987
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
1988
1988
|
for (const _ of fundingCoins) {
|
|
@@ -2030,7 +2030,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2030
2030
|
);
|
|
2031
2031
|
}
|
|
2032
2032
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2033
|
-
const tx = new
|
|
2033
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({
|
|
2034
2034
|
version: 3,
|
|
2035
2035
|
lockTime: txLocktime
|
|
2036
2036
|
});
|
|
@@ -2106,7 +2106,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2106
2106
|
if (previousScriptKey.length !== 32) {
|
|
2107
2107
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2108
2108
|
}
|
|
2109
|
-
const cosigners =
|
|
2109
|
+
const cosigners = chunkFZFSGOTZ_cjs.getArkPsbtFields(child.root, 0, chunkFZFSGOTZ_cjs.CosignerPublicKey);
|
|
2110
2110
|
if (cosigners.length === 0) {
|
|
2111
2111
|
throw ErrMissingCosignersPublicKeys;
|
|
2112
2112
|
}
|
|
@@ -2164,7 +2164,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2164
2164
|
return new _EmulatorPacket(entries);
|
|
2165
2165
|
}
|
|
2166
2166
|
static fromBytes(data) {
|
|
2167
|
-
const reader = new
|
|
2167
|
+
const reader = new chunkRXITDAV4_cjs.BufferReader(data);
|
|
2168
2168
|
const entryCount = reader.readCompactSize();
|
|
2169
2169
|
const entries = [];
|
|
2170
2170
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2182,7 +2182,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2182
2182
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2183
2183
|
}
|
|
2184
2184
|
serialize() {
|
|
2185
|
-
const writer = new
|
|
2185
|
+
const writer = new chunkRXITDAV4_cjs.BufferWriter();
|
|
2186
2186
|
writer.writeCompactSize(this.entries.length);
|
|
2187
2187
|
for (const entry of this.entries) {
|
|
2188
2188
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2269,7 +2269,7 @@ var Extension = class _Extension {
|
|
|
2269
2269
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2270
2270
|
);
|
|
2271
2271
|
}
|
|
2272
|
-
const reader = new
|
|
2272
|
+
const reader = new chunkRXITDAV4_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2273
2273
|
const packets = [];
|
|
2274
2274
|
while (reader.remaining() > 0) {
|
|
2275
2275
|
const packetType = reader.readByte();
|
|
@@ -2343,7 +2343,7 @@ var Extension = class _Extension {
|
|
|
2343
2343
|
*/
|
|
2344
2344
|
getAssetPacket() {
|
|
2345
2345
|
for (const p of this.packets) {
|
|
2346
|
-
if (p instanceof
|
|
2346
|
+
if (p instanceof chunkRXITDAV4_cjs.Packet) {
|
|
2347
2347
|
return p;
|
|
2348
2348
|
}
|
|
2349
2349
|
}
|
|
@@ -2381,8 +2381,8 @@ var Extension = class _Extension {
|
|
|
2381
2381
|
};
|
|
2382
2382
|
function parsePacket(packetType, data) {
|
|
2383
2383
|
switch (packetType) {
|
|
2384
|
-
case
|
|
2385
|
-
return
|
|
2384
|
+
case chunkRXITDAV4_cjs.Packet.PACKET_TYPE:
|
|
2385
|
+
return chunkRXITDAV4_cjs.Packet.fromBytes(data);
|
|
2386
2386
|
case EmulatorPacket.PACKET_TYPE:
|
|
2387
2387
|
return EmulatorPacket.fromBytes(data);
|
|
2388
2388
|
default:
|
|
@@ -2429,16 +2429,16 @@ function buildOpReturnScript(data) {
|
|
|
2429
2429
|
}
|
|
2430
2430
|
return script;
|
|
2431
2431
|
}
|
|
2432
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2433
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2432
|
+
var ErrOffchainOutputNotFound = (address) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2433
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2434
2434
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2435
2435
|
);
|
|
2436
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2437
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2436
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2437
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2438
2438
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2439
2439
|
);
|
|
2440
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2441
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2440
|
+
var ErrOnchainOutputNotFound = (address) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2441
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2442
2442
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2443
2443
|
);
|
|
2444
2444
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2447,7 +2447,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2447
2447
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2448
2448
|
if (!validatedCommitmentTxid) return;
|
|
2449
2449
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2450
|
-
throw new
|
|
2450
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2451
2451
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2452
2452
|
);
|
|
2453
2453
|
}
|
|
@@ -2457,7 +2457,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2457
2457
|
for (const recipient of recipients) {
|
|
2458
2458
|
let arkAddress;
|
|
2459
2459
|
try {
|
|
2460
|
-
arkAddress =
|
|
2460
|
+
arkAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(recipient.address);
|
|
2461
2461
|
} catch {
|
|
2462
2462
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2463
2463
|
continue;
|
|
@@ -2469,7 +2469,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2469
2469
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2470
2470
|
for (const recipient of recipients) {
|
|
2471
2471
|
try {
|
|
2472
|
-
|
|
2472
|
+
chunkFZFSGOTZ_cjs.ArkAddress.decode(recipient.address);
|
|
2473
2473
|
} catch {
|
|
2474
2474
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2475
2475
|
continue;
|
|
@@ -2702,7 +2702,7 @@ function assetMintResolver() {
|
|
|
2702
2702
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
2703
2703
|
const minted = tx.assets.filter((a) => {
|
|
2704
2704
|
try {
|
|
2705
|
-
return base.hex.encode(
|
|
2705
|
+
return base.hex.encode(chunkRXITDAV4_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
2706
2706
|
} catch {
|
|
2707
2707
|
return false;
|
|
2708
2708
|
}
|
|
@@ -2745,7 +2745,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2745
2745
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
2746
2746
|
inputsByAssetId.set(asset.assetId, [
|
|
2747
2747
|
...existing ?? [],
|
|
2748
|
-
|
|
2748
|
+
chunkRXITDAV4_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
2749
2749
|
]);
|
|
2750
2750
|
}
|
|
2751
2751
|
}
|
|
@@ -2757,7 +2757,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2757
2757
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2758
2758
|
outputsByAssetId.set(asset.assetId, [
|
|
2759
2759
|
...existing ?? [],
|
|
2760
|
-
|
|
2760
|
+
chunkRXITDAV4_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2761
2761
|
]);
|
|
2762
2762
|
}
|
|
2763
2763
|
}
|
|
@@ -2768,7 +2768,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2768
2768
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2769
2769
|
outputsByAssetId.set(asset.assetId, [
|
|
2770
2770
|
...existing ?? [],
|
|
2771
|
-
|
|
2771
|
+
chunkRXITDAV4_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2772
2772
|
]);
|
|
2773
2773
|
}
|
|
2774
2774
|
}
|
|
@@ -2777,11 +2777,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2777
2777
|
for (const assetIdStr of allAssetIds) {
|
|
2778
2778
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
2779
2779
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
2780
|
-
const assetId =
|
|
2781
|
-
const group =
|
|
2780
|
+
const assetId = chunkRXITDAV4_cjs.AssetId.fromString(assetIdStr);
|
|
2781
|
+
const group = chunkRXITDAV4_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
2782
2782
|
groups.push(group);
|
|
2783
2783
|
}
|
|
2784
|
-
return
|
|
2784
|
+
return chunkRXITDAV4_cjs.Packet.create(groups);
|
|
2785
2785
|
}
|
|
2786
2786
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
2787
2787
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -2866,13 +2866,13 @@ var toTimelock = (value) => ({
|
|
|
2866
2866
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
2867
2867
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
2868
2868
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
2869
|
-
throw new
|
|
2869
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2870
2870
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
2871
2871
|
);
|
|
2872
2872
|
}
|
|
2873
2873
|
const seconds = toSeconds(timelock);
|
|
2874
2874
|
if (seconds < policy.minSeconds) {
|
|
2875
|
-
throw new
|
|
2875
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2876
2876
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
2877
2877
|
);
|
|
2878
2878
|
}
|
|
@@ -2893,7 +2893,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
2893
2893
|
}
|
|
2894
2894
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
2895
2895
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
2896
|
-
throw new
|
|
2896
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2897
2897
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
2898
2898
|
);
|
|
2899
2899
|
}
|
|
@@ -2923,21 +2923,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
2923
2923
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
2924
2924
|
let script;
|
|
2925
2925
|
try {
|
|
2926
|
-
script =
|
|
2926
|
+
script = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
2927
2927
|
} catch (e) {
|
|
2928
|
-
throw new
|
|
2928
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2929
2929
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
2930
2930
|
);
|
|
2931
2931
|
}
|
|
2932
2932
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
2933
2933
|
const { pubkeys } = script.params;
|
|
2934
2934
|
if (pubkeys.length !== 1) {
|
|
2935
|
-
throw new
|
|
2935
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2936
2936
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
2937
2937
|
);
|
|
2938
2938
|
}
|
|
2939
2939
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
2940
|
-
throw new
|
|
2940
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2941
2941
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
2942
2942
|
);
|
|
2943
2943
|
}
|
|
@@ -2981,8 +2981,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
2981
2981
|
function buildVirtualTx(inputs, outputs) {
|
|
2982
2982
|
let lockTime = 0n;
|
|
2983
2983
|
for (const input of inputs) {
|
|
2984
|
-
const tapscript =
|
|
2985
|
-
if (
|
|
2984
|
+
const tapscript = chunkFZFSGOTZ_cjs.decodeTapscript(chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
2985
|
+
if (chunkFZFSGOTZ_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
2986
2986
|
if (lockTime !== 0n) {
|
|
2987
2987
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
2988
2988
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -2993,7 +2993,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2993
2993
|
}
|
|
2994
2994
|
}
|
|
2995
2995
|
}
|
|
2996
|
-
const tx = new
|
|
2996
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({
|
|
2997
2997
|
version: 3,
|
|
2998
2998
|
lockTime: Number(lockTime)
|
|
2999
2999
|
});
|
|
@@ -3003,12 +3003,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3003
3003
|
index: input.vout,
|
|
3004
3004
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3005
3005
|
witnessUtxo: {
|
|
3006
|
-
script:
|
|
3006
|
+
script: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3007
3007
|
amount: BigInt(input.value)
|
|
3008
3008
|
},
|
|
3009
3009
|
tapLeafScript: [input.tapLeafScript]
|
|
3010
3010
|
});
|
|
3011
|
-
|
|
3011
|
+
chunkFZFSGOTZ_cjs.setArkPsbtField(tx, i, chunkFZFSGOTZ_cjs.VtxoTaprootTree, input.tapTree);
|
|
3012
3012
|
}
|
|
3013
3013
|
for (const output of outputs) {
|
|
3014
3014
|
tx.addOutput(output);
|
|
@@ -3017,8 +3017,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3017
3017
|
return tx;
|
|
3018
3018
|
}
|
|
3019
3019
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3020
|
-
const collaborativeClosure =
|
|
3021
|
-
const checkpointVtxoScript = new
|
|
3020
|
+
const collaborativeClosure = chunkFZFSGOTZ_cjs.decodeTapscript(chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3021
|
+
const checkpointVtxoScript = new chunkFZFSGOTZ_cjs.VtxoScript([
|
|
3022
3022
|
serverUnrollScript.script,
|
|
3023
3023
|
collaborativeClosure.script
|
|
3024
3024
|
]);
|
|
@@ -3171,7 +3171,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3171
3171
|
}
|
|
3172
3172
|
function isValidArkAddress(address) {
|
|
3173
3173
|
try {
|
|
3174
|
-
|
|
3174
|
+
chunkFZFSGOTZ_cjs.ArkAddress.decode(address);
|
|
3175
3175
|
return true;
|
|
3176
3176
|
} catch (e) {
|
|
3177
3177
|
return false;
|
|
@@ -3179,16 +3179,16 @@ function isValidArkAddress(address) {
|
|
|
3179
3179
|
}
|
|
3180
3180
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3181
3181
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3182
|
-
throw new
|
|
3182
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3183
3183
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3184
3184
|
);
|
|
3185
3185
|
}
|
|
3186
3186
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3187
3187
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3188
|
-
const server =
|
|
3188
|
+
const server = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3189
3189
|
const local = byTxid.get(server.id);
|
|
3190
3190
|
if (!local) {
|
|
3191
|
-
throw new
|
|
3191
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3192
3192
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3193
3193
|
);
|
|
3194
3194
|
}
|
|
@@ -3198,14 +3198,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3198
3198
|
}
|
|
3199
3199
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3200
3200
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3201
|
-
throw new
|
|
3201
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3202
3202
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3203
3203
|
);
|
|
3204
3204
|
}
|
|
3205
3205
|
if (response.finalArkTx === void 0) return;
|
|
3206
|
-
const finalTxid =
|
|
3206
|
+
const finalTxid = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3207
3207
|
if (finalTxid !== signedArkTx.id) {
|
|
3208
|
-
throw new
|
|
3208
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3209
3209
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3210
3210
|
);
|
|
3211
3211
|
}
|
|
@@ -3224,10 +3224,10 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex,
|
|
|
3224
3224
|
[serverPubkeyHex],
|
|
3225
3225
|
void 0,
|
|
3226
3226
|
void 0,
|
|
3227
|
-
payment_js.tapLeafHash(
|
|
3227
|
+
payment_js.tapLeafHash(chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(leaf))
|
|
3228
3228
|
);
|
|
3229
3229
|
} catch (error) {
|
|
3230
|
-
throw new
|
|
3230
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3231
3231
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3232
3232
|
);
|
|
3233
3233
|
}
|
|
@@ -3236,20 +3236,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3236
3236
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3237
3237
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3238
3238
|
if (checkpoint.inputsLength !== 1) {
|
|
3239
|
-
throw new
|
|
3239
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3240
3240
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3241
3241
|
);
|
|
3242
3242
|
}
|
|
3243
3243
|
const spent = checkpoint.getInput(0);
|
|
3244
3244
|
if (!spent.txid || spent.index === void 0) {
|
|
3245
|
-
throw new
|
|
3245
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3246
3246
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3247
3247
|
);
|
|
3248
3248
|
}
|
|
3249
3249
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3250
3250
|
const input = byOutpoint.get(outpoint);
|
|
3251
3251
|
if (!input) {
|
|
3252
|
-
throw new
|
|
3252
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3253
3253
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3254
3254
|
);
|
|
3255
3255
|
}
|
|
@@ -3257,7 +3257,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3257
3257
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3258
3258
|
);
|
|
3259
3259
|
if (!rebuilt) {
|
|
3260
|
-
throw new
|
|
3260
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3261
3261
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3262
3262
|
);
|
|
3263
3263
|
}
|
|
@@ -3284,11 +3284,11 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3284
3284
|
const verify = options?.verifyServerSignatures;
|
|
3285
3285
|
if (verify) {
|
|
3286
3286
|
if (response.finalArkTx === void 0) {
|
|
3287
|
-
throw new
|
|
3287
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3288
3288
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3289
3289
|
);
|
|
3290
3290
|
}
|
|
3291
|
-
const finalArkTx =
|
|
3291
|
+
const finalArkTx = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3292
3292
|
const serverPubkeyHex = base.hex.encode(
|
|
3293
3293
|
verify.serverPubkey.length === 33 ? verify.serverPubkey.subarray(1) : verify.serverPubkey
|
|
3294
3294
|
);
|
|
@@ -3347,12 +3347,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3347
3347
|
return {
|
|
3348
3348
|
...identity,
|
|
3349
3349
|
sign: async (tx, inputIndexes) => {
|
|
3350
|
-
const signed =
|
|
3350
|
+
const signed = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(
|
|
3351
3351
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3352
3352
|
);
|
|
3353
3353
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3354
3354
|
for (const index of indexes) {
|
|
3355
|
-
|
|
3355
|
+
chunkFZFSGOTZ_cjs.setArkPsbtField(signed, index, chunkFZFSGOTZ_cjs.ConditionWitness, [preimage]);
|
|
3356
3356
|
}
|
|
3357
3357
|
return signed;
|
|
3358
3358
|
}
|
|
@@ -3544,7 +3544,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
3544
3544
|
};
|
|
3545
3545
|
}
|
|
3546
3546
|
function deriveContractTapscripts(contract) {
|
|
3547
|
-
const handler =
|
|
3547
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
3548
3548
|
if (!handler) {
|
|
3549
3549
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3550
3550
|
}
|
|
@@ -3615,7 +3615,7 @@ function getRandomId() {
|
|
|
3615
3615
|
}
|
|
3616
3616
|
function isValidArkAddress2(address) {
|
|
3617
3617
|
try {
|
|
3618
|
-
|
|
3618
|
+
chunkFZFSGOTZ_cjs.ArkAddress.decode(address);
|
|
3619
3619
|
return true;
|
|
3620
3620
|
} catch (e) {
|
|
3621
3621
|
return false;
|
|
@@ -3643,7 +3643,7 @@ function assertRecipientArkAddress(encoded, address, context) {
|
|
|
3643
3643
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
3644
3644
|
let derived;
|
|
3645
3645
|
try {
|
|
3646
|
-
derived =
|
|
3646
|
+
derived = chunkFZFSGOTZ_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
3647
3647
|
} catch (e) {
|
|
3648
3648
|
throw new Error(
|
|
3649
3649
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -3660,7 +3660,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3660
3660
|
for (const recipient of recipients) {
|
|
3661
3661
|
let address;
|
|
3662
3662
|
try {
|
|
3663
|
-
address =
|
|
3663
|
+
address = chunkFZFSGOTZ_cjs.ArkAddress.decode(recipient.address);
|
|
3664
3664
|
} catch (e) {
|
|
3665
3665
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
3666
3666
|
}
|
|
@@ -3685,7 +3685,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3685
3685
|
|
|
3686
3686
|
// src/contracts/spendability.ts
|
|
3687
3687
|
function isContractGenericallySpendable(contract) {
|
|
3688
|
-
return
|
|
3688
|
+
return chunkWXCVS6PD_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
3689
3689
|
}
|
|
3690
3690
|
function gatedContracts(contracts) {
|
|
3691
3691
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -3698,7 +3698,7 @@ function gateExclusion(gated) {
|
|
|
3698
3698
|
return (vtxo) => {
|
|
3699
3699
|
const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
|
|
3700
3700
|
if (type === void 0) return void 0;
|
|
3701
|
-
if (!
|
|
3701
|
+
if (!chunkWXCVS6PD_cjs.contractHandlers.has(type)) {
|
|
3702
3702
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
3703
3703
|
}
|
|
3704
3704
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -3734,7 +3734,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
3734
3734
|
continue;
|
|
3735
3735
|
}
|
|
3736
3736
|
for (const v of vtxos) {
|
|
3737
|
-
if (!
|
|
3737
|
+
if (!chunkFZFSGOTZ_cjs.hasTerminalSpend(v) && !v.isSwept) out.add(`${v.txid}:${v.vout}`);
|
|
3738
3738
|
}
|
|
3739
3739
|
}
|
|
3740
3740
|
return out;
|
|
@@ -3767,10 +3767,10 @@ function byValueDescending(vtxos) {
|
|
|
3767
3767
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
3768
3768
|
}
|
|
3769
3769
|
async function fetchTimeHeight(wallet) {
|
|
3770
|
-
return
|
|
3770
|
+
return chunkFZFSGOTZ_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
3771
3771
|
}
|
|
3772
3772
|
function canMigrateBySend(vtxo, now) {
|
|
3773
|
-
if (!
|
|
3773
|
+
if (!chunkFZFSGOTZ_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
3774
3774
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
3775
3775
|
}
|
|
3776
3776
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -3778,7 +3778,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
3778
3778
|
if (vtxo.isSwept) return -Infinity;
|
|
3779
3779
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
3780
3780
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
3781
|
-
return
|
|
3781
|
+
return chunkFZFSGOTZ_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
3782
3782
|
}
|
|
3783
3783
|
return Infinity;
|
|
3784
3784
|
};
|
|
@@ -3805,7 +3805,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
3805
3805
|
const payable = [];
|
|
3806
3806
|
const net = /* @__PURE__ */ new Map();
|
|
3807
3807
|
for (const vtxo of vtxos) {
|
|
3808
|
-
const inputFee = estimator.evalOffchainInput(
|
|
3808
|
+
const inputFee = estimator.evalOffchainInput(chunkFZFSGOTZ_cjs.toOffchainInputFeeParams(vtxo));
|
|
3809
3809
|
if (inputFee.satoshis >= vtxo.value) {
|
|
3810
3810
|
continue;
|
|
3811
3811
|
}
|
|
@@ -3831,7 +3831,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
3831
3831
|
}
|
|
3832
3832
|
const outputFee = estimator.evalOffchainOutput({
|
|
3833
3833
|
amount: subtotal,
|
|
3834
|
-
script: base.hex.encode(
|
|
3834
|
+
script: base.hex.encode(chunkFZFSGOTZ_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
3835
3835
|
});
|
|
3836
3836
|
return subtotal - BigInt(outputFee.satoshis);
|
|
3837
3837
|
}
|
|
@@ -3849,10 +3849,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
3849
3849
|
};
|
|
3850
3850
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
3851
3851
|
return vtxos.filter((vtxo) => {
|
|
3852
|
-
if (
|
|
3852
|
+
if (chunkFZFSGOTZ_cjs.canRecoverOnchain(vtxo, now)) {
|
|
3853
3853
|
return true;
|
|
3854
3854
|
}
|
|
3855
|
-
if (
|
|
3855
|
+
if (chunkFZFSGOTZ_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
3856
3856
|
return true;
|
|
3857
3857
|
}
|
|
3858
3858
|
return false;
|
|
@@ -3883,7 +3883,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
3883
3883
|
}
|
|
3884
3884
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
3885
3885
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
3886
|
-
const expiresAt =
|
|
3886
|
+
const expiresAt = chunkFZFSGOTZ_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
3887
3887
|
if (expiresAt === void 0) return false;
|
|
3888
3888
|
const now = Date.now();
|
|
3889
3889
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -3892,7 +3892,7 @@ function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
|
3892
3892
|
}
|
|
3893
3893
|
function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
3894
3894
|
return vtxos.filter(
|
|
3895
|
-
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
3895
|
+
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) || chunkFZFSGOTZ_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount)
|
|
3896
3896
|
);
|
|
3897
3897
|
}
|
|
3898
3898
|
function isMigrationCapable(wallet) {
|
|
@@ -4491,11 +4491,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
4491
4491
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
4492
4492
|
);
|
|
4493
4493
|
}
|
|
4494
|
-
const tx = new
|
|
4494
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction();
|
|
4495
4495
|
for (const utxo of expiredUtxos) {
|
|
4496
|
-
const utxoScript =
|
|
4496
|
+
const utxoScript = chunkFZFSGOTZ_cjs.VtxoScript.decode(utxo.tapTree);
|
|
4497
4497
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
4498
|
-
(leaf) =>
|
|
4498
|
+
(leaf) => chunkFZFSGOTZ_cjs.CSVMultisigTapscript.isScriptValid(chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
4499
4499
|
);
|
|
4500
4500
|
if (!utxoExitLeaf) {
|
|
4501
4501
|
throw new Error(
|
|
@@ -4510,7 +4510,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4510
4510
|
amount: BigInt(utxo.value)
|
|
4511
4511
|
},
|
|
4512
4512
|
tapLeafScript: [utxoExitLeaf],
|
|
4513
|
-
sequence:
|
|
4513
|
+
sequence: chunkFZFSGOTZ_cjs.getSequence(utxoExitLeaf)
|
|
4514
4514
|
});
|
|
4515
4515
|
}
|
|
4516
4516
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -4744,8 +4744,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4744
4744
|
if (!serverPubKey) continue;
|
|
4745
4745
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
4746
4746
|
if (cls.status === "CURRENT") continue;
|
|
4747
|
-
const recoverable = vtxos.filter((v) => v.isSwept && !
|
|
4748
|
-
const spendable = vtxos.filter((v) => !
|
|
4747
|
+
const recoverable = vtxos.filter((v) => v.isSwept && !chunkFZFSGOTZ_cjs.hasTerminalSpend(v));
|
|
4748
|
+
const spendable = vtxos.filter((v) => !chunkFZFSGOTZ_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
4749
4749
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
4750
4750
|
let recoverableCount = 0;
|
|
4751
4751
|
let recoverableValue = 0;
|
|
@@ -4758,7 +4758,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4758
4758
|
awaitingSweepCount = spendable.length;
|
|
4759
4759
|
awaitingSweepValue = value;
|
|
4760
4760
|
for (const v of spendable) {
|
|
4761
|
-
const exp =
|
|
4761
|
+
const exp = chunkFZFSGOTZ_cjs.toBatchExpiry(v);
|
|
4762
4762
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
4763
4763
|
nextSweepEta = exp;
|
|
4764
4764
|
}
|
|
@@ -5019,7 +5019,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5019
5019
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
5020
5020
|
getBoardingTimelock() {
|
|
5021
5021
|
const wallet = this.getSweepWallet();
|
|
5022
|
-
const exitScript =
|
|
5022
|
+
const exitScript = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(
|
|
5023
5023
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5024
5024
|
);
|
|
5025
5025
|
return exitScript.params.timelock;
|
|
@@ -5150,8 +5150,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5150
5150
|
* or doesn't carry the metadata.
|
|
5151
5151
|
*/
|
|
5152
5152
|
extractSpentOutpoint(error) {
|
|
5153
|
-
const ark =
|
|
5154
|
-
if (!
|
|
5153
|
+
const ark = chunkFZFSGOTZ_cjs.maybeArkError(error);
|
|
5154
|
+
if (!chunkFZFSGOTZ_cjs.isArkError(ark, chunkFZFSGOTZ_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5155
5155
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5156
5156
|
if (typeof raw !== "string") return void 0;
|
|
5157
5157
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -5341,7 +5341,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5341
5341
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
5342
5342
|
break;
|
|
5343
5343
|
}
|
|
5344
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5344
|
+
const inputFee = estimator.evalOffchainInput(chunkFZFSGOTZ_cjs.toOffchainInputFeeParams(v));
|
|
5345
5345
|
if (inputFee.satoshis >= v.value) {
|
|
5346
5346
|
continue;
|
|
5347
5347
|
}
|
|
@@ -5361,7 +5361,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5361
5361
|
const arkAddress = await this.wallet.getAddress();
|
|
5362
5362
|
const outputFee = estimator.evalOffchainOutput({
|
|
5363
5363
|
amount: totalAmount,
|
|
5364
|
-
script: base.hex.encode(
|
|
5364
|
+
script: base.hex.encode(chunkFZFSGOTZ_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
5365
5365
|
});
|
|
5366
5366
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
5367
5367
|
if (totalAmount < dustAmount) return;
|
|
@@ -5441,7 +5441,7 @@ var ArkNote = class _ArkNote {
|
|
|
5441
5441
|
this.value = value;
|
|
5442
5442
|
this.HRP = HRP;
|
|
5443
5443
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
5444
|
-
this.vtxoScript = new
|
|
5444
|
+
this.vtxoScript = new chunkFZFSGOTZ_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
5445
5445
|
const leaf = this.vtxoScript.leaves[0];
|
|
5446
5446
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
5447
5447
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -5608,7 +5608,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5608
5608
|
const privateKey = data.slice(1, 33);
|
|
5609
5609
|
const serverPubKey = data.slice(33, 65);
|
|
5610
5610
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
5611
|
-
const csvTimelock =
|
|
5611
|
+
const csvTimelock = chunkFZFSGOTZ_cjs.sequenceToTimelock(sequence);
|
|
5612
5612
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
5613
5613
|
}
|
|
5614
5614
|
toString() {
|
|
@@ -5616,7 +5616,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5616
5616
|
data[0] = _ArkadeCash.Version;
|
|
5617
5617
|
data.set(this._privateKey, 1);
|
|
5618
5618
|
data.set(this._serverPubKey, 33);
|
|
5619
|
-
const sequence =
|
|
5619
|
+
const sequence = chunkFZFSGOTZ_cjs.timelockToSequence(this.csvTimelock);
|
|
5620
5620
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
5621
5621
|
const words = base.bech32m.toWords(data);
|
|
5622
5622
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -5625,7 +5625,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5625
5625
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
5626
5626
|
}
|
|
5627
5627
|
get vtxoScript() {
|
|
5628
|
-
return new
|
|
5628
|
+
return new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
5629
5629
|
pubKey: this._publicKey,
|
|
5630
5630
|
serverPubKey: this._serverPubKey,
|
|
5631
5631
|
csvTimelock: this.csvTimelock
|
|
@@ -5886,7 +5886,7 @@ async function captureExitBranch(params) {
|
|
|
5886
5886
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
5887
5887
|
if (nonCommitment.length > 0) {
|
|
5888
5888
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
5889
|
-
psbtByTxid.set(
|
|
5889
|
+
psbtByTxid.set(chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5890
5890
|
}
|
|
5891
5891
|
}
|
|
5892
5892
|
}
|
|
@@ -5929,10 +5929,10 @@ var IndexerExitDataSource = class {
|
|
|
5929
5929
|
while (hasMore) {
|
|
5930
5930
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
5931
5931
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
5932
|
-
{ pageIndex, pageSize:
|
|
5932
|
+
{ pageIndex, pageSize: chunkFZFSGOTZ_cjs.DEFAULT_PAGE_SIZE }
|
|
5933
5933
|
);
|
|
5934
5934
|
chain.push(...page);
|
|
5935
|
-
hasMore = meta ? page.length ===
|
|
5935
|
+
hasMore = meta ? page.length === chunkFZFSGOTZ_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5936
5936
|
pageIndex++;
|
|
5937
5937
|
}
|
|
5938
5938
|
return chain;
|
|
@@ -5944,12 +5944,12 @@ var IndexerExitDataSource = class {
|
|
|
5944
5944
|
while (hasMore) {
|
|
5945
5945
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
5946
5946
|
pageIndex,
|
|
5947
|
-
pageSize:
|
|
5947
|
+
pageSize: chunkFZFSGOTZ_cjs.DEFAULT_PAGE_SIZE
|
|
5948
5948
|
});
|
|
5949
5949
|
for (const psbt of txs) {
|
|
5950
|
-
out.set(
|
|
5950
|
+
out.set(chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5951
5951
|
}
|
|
5952
|
-
hasMore = page ? txs.length ===
|
|
5952
|
+
hasMore = page ? txs.length === chunkFZFSGOTZ_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5953
5953
|
pageIndex++;
|
|
5954
5954
|
}
|
|
5955
5955
|
return out;
|
|
@@ -5970,7 +5970,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
5970
5970
|
}
|
|
5971
5971
|
}
|
|
5972
5972
|
function psbtInputTxids(psbtBase64) {
|
|
5973
|
-
const tx =
|
|
5973
|
+
const tx = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
5974
5974
|
const ids = [];
|
|
5975
5975
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
5976
5976
|
const txid = tx.getInput(i).txid;
|
|
@@ -6323,10 +6323,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
6323
6323
|
try {
|
|
6324
6324
|
info = await arkProvider.getInfo();
|
|
6325
6325
|
} catch (err) {
|
|
6326
|
-
if (!
|
|
6326
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
6327
6327
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
6328
6328
|
if (!snapshot) {
|
|
6329
|
-
throw new
|
|
6329
|
+
throw new chunkFZFSGOTZ_cjs.ProviderUnavailableError(
|
|
6330
6330
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
6331
6331
|
{ cause: err }
|
|
6332
6332
|
);
|
|
@@ -6709,7 +6709,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
6709
6709
|
return [...txids];
|
|
6710
6710
|
}
|
|
6711
6711
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
6712
|
-
const fromOldestVtxo = vtxos.map(
|
|
6712
|
+
const fromOldestVtxo = vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
6713
6713
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
6714
6714
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
6715
6715
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -6873,7 +6873,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6873
6873
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
6874
6874
|
withRecoverable: false
|
|
6875
6875
|
});
|
|
6876
|
-
const controlAssetRef = params.controlAssetId ?
|
|
6876
|
+
const controlAssetRef = params.controlAssetId ? chunkRXITDAV4_cjs.AssetRef.fromId(chunkRXITDAV4_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
6877
6877
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
6878
6878
|
let totalBtcSelected = 0n;
|
|
6879
6879
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -6886,8 +6886,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6886
6886
|
}
|
|
6887
6887
|
}
|
|
6888
6888
|
const groups = [];
|
|
6889
|
-
const issuedAssetOutput =
|
|
6890
|
-
const issuedAssetGroup =
|
|
6889
|
+
const issuedAssetOutput = chunkRXITDAV4_cjs.AssetOutput.create(0, params.amount);
|
|
6890
|
+
const issuedAssetGroup = chunkRXITDAV4_cjs.AssetGroup.create(
|
|
6891
6891
|
null,
|
|
6892
6892
|
controlAssetRef,
|
|
6893
6893
|
[],
|
|
@@ -6902,28 +6902,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6902
6902
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6903
6903
|
for (const asset of assets) {
|
|
6904
6904
|
if (asset.assetId !== assetId) continue;
|
|
6905
|
-
changeInputs.push(
|
|
6905
|
+
changeInputs.push(chunkRXITDAV4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6906
6906
|
}
|
|
6907
6907
|
}
|
|
6908
6908
|
groups.push(
|
|
6909
|
-
|
|
6910
|
-
|
|
6909
|
+
chunkRXITDAV4_cjs.AssetGroup.create(
|
|
6910
|
+
chunkRXITDAV4_cjs.AssetId.fromString(assetId),
|
|
6911
6911
|
null,
|
|
6912
6912
|
changeInputs,
|
|
6913
|
-
[
|
|
6913
|
+
[chunkRXITDAV4_cjs.AssetOutput.create(0, amount)],
|
|
6914
6914
|
[]
|
|
6915
6915
|
)
|
|
6916
6916
|
);
|
|
6917
6917
|
}
|
|
6918
6918
|
}
|
|
6919
6919
|
const address = await this.wallet.getAddress();
|
|
6920
|
-
const outputAddress =
|
|
6920
|
+
const outputAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(address);
|
|
6921
6921
|
const outputs = [
|
|
6922
6922
|
{
|
|
6923
6923
|
script: outputAddress.pkScript,
|
|
6924
6924
|
amount: BigInt(totalBtcSelected)
|
|
6925
6925
|
},
|
|
6926
|
-
Extension.create([
|
|
6926
|
+
Extension.create([chunkRXITDAV4_cjs.Packet.create(groups)]).txOut()
|
|
6927
6927
|
];
|
|
6928
6928
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
6929
6929
|
coinSelection.inputs,
|
|
@@ -6931,7 +6931,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6931
6931
|
);
|
|
6932
6932
|
return {
|
|
6933
6933
|
arkTxId: arkTxid,
|
|
6934
|
-
assetId:
|
|
6934
|
+
assetId: chunkRXITDAV4_cjs.AssetId.create(arkTxid, 0).toString()
|
|
6935
6935
|
};
|
|
6936
6936
|
}
|
|
6937
6937
|
/**
|
|
@@ -7003,16 +7003,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7003
7003
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7004
7004
|
for (const asset of assets) {
|
|
7005
7005
|
if (asset.assetId !== params.assetId) continue;
|
|
7006
|
-
reissueInputs.push(
|
|
7006
|
+
reissueInputs.push(chunkRXITDAV4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7007
7007
|
}
|
|
7008
7008
|
}
|
|
7009
7009
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7010
|
-
const reissueAssetIdObj =
|
|
7011
|
-
const reissueAssetGroup =
|
|
7010
|
+
const reissueAssetIdObj = chunkRXITDAV4_cjs.AssetId.fromString(params.assetId);
|
|
7011
|
+
const reissueAssetGroup = chunkRXITDAV4_cjs.AssetGroup.create(
|
|
7012
7012
|
reissueAssetIdObj,
|
|
7013
7013
|
null,
|
|
7014
7014
|
reissueInputs,
|
|
7015
|
-
[
|
|
7015
|
+
[chunkRXITDAV4_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7016
7016
|
[]
|
|
7017
7017
|
);
|
|
7018
7018
|
const groups = [reissueAssetGroup];
|
|
@@ -7021,27 +7021,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7021
7021
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7022
7022
|
for (const asset of assets) {
|
|
7023
7023
|
if (asset.assetId !== assetId) continue;
|
|
7024
|
-
changeInputs.push(
|
|
7024
|
+
changeInputs.push(chunkRXITDAV4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7025
7025
|
}
|
|
7026
7026
|
}
|
|
7027
7027
|
groups.push(
|
|
7028
|
-
|
|
7029
|
-
|
|
7028
|
+
chunkRXITDAV4_cjs.AssetGroup.create(
|
|
7029
|
+
chunkRXITDAV4_cjs.AssetId.fromString(assetId),
|
|
7030
7030
|
null,
|
|
7031
7031
|
changeInputs,
|
|
7032
|
-
[
|
|
7032
|
+
[chunkRXITDAV4_cjs.AssetOutput.create(0, amount)],
|
|
7033
7033
|
[]
|
|
7034
7034
|
)
|
|
7035
7035
|
);
|
|
7036
7036
|
}
|
|
7037
7037
|
const address = await this.wallet.getAddress();
|
|
7038
|
-
const outputAddress =
|
|
7038
|
+
const outputAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(address);
|
|
7039
7039
|
const outputs = [
|
|
7040
7040
|
{
|
|
7041
7041
|
script: outputAddress.pkScript,
|
|
7042
7042
|
amount: BigInt(totalBtcSelected)
|
|
7043
7043
|
},
|
|
7044
|
-
Extension.create([
|
|
7044
|
+
Extension.create([chunkRXITDAV4_cjs.Packet.create(groups)]).txOut()
|
|
7045
7045
|
];
|
|
7046
7046
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7047
7047
|
return arkTxid;
|
|
@@ -7108,27 +7108,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7108
7108
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7109
7109
|
for (const asset of assets) {
|
|
7110
7110
|
if (asset.assetId !== assetId) continue;
|
|
7111
|
-
changeInputs.push(
|
|
7111
|
+
changeInputs.push(chunkRXITDAV4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7112
7112
|
}
|
|
7113
7113
|
}
|
|
7114
7114
|
groups.push(
|
|
7115
|
-
|
|
7116
|
-
|
|
7115
|
+
chunkRXITDAV4_cjs.AssetGroup.create(
|
|
7116
|
+
chunkRXITDAV4_cjs.AssetId.fromString(assetId),
|
|
7117
7117
|
null,
|
|
7118
7118
|
changeInputs,
|
|
7119
|
-
amount > 0n ? [
|
|
7119
|
+
amount > 0n ? [chunkRXITDAV4_cjs.AssetOutput.create(0, amount)] : [],
|
|
7120
7120
|
[]
|
|
7121
7121
|
)
|
|
7122
7122
|
);
|
|
7123
7123
|
}
|
|
7124
7124
|
const address = await this.wallet.getAddress();
|
|
7125
|
-
const outputAddress =
|
|
7125
|
+
const outputAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(address);
|
|
7126
7126
|
const outputs = [
|
|
7127
7127
|
{
|
|
7128
7128
|
script: outputAddress.pkScript,
|
|
7129
7129
|
amount: BigInt(totalBtcSelected)
|
|
7130
7130
|
},
|
|
7131
|
-
Extension.create([
|
|
7131
|
+
Extension.create([chunkRXITDAV4_cjs.Packet.create(groups)]).txOut()
|
|
7132
7132
|
];
|
|
7133
7133
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7134
7134
|
return arkTxid;
|
|
@@ -7153,7 +7153,7 @@ function castMetadata(metadata) {
|
|
|
7153
7153
|
} else {
|
|
7154
7154
|
throw new Error("Invalid metadata value type");
|
|
7155
7155
|
}
|
|
7156
|
-
md.push(
|
|
7156
|
+
md.push(chunkRXITDAV4_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7157
7157
|
}
|
|
7158
7158
|
return md;
|
|
7159
7159
|
}
|
|
@@ -7174,10 +7174,10 @@ var DelegateManagerImpl = class {
|
|
|
7174
7174
|
if (vtxos.length === 0) {
|
|
7175
7175
|
return { delegated: [], failed: [] };
|
|
7176
7176
|
}
|
|
7177
|
-
const destinationScript =
|
|
7177
|
+
const destinationScript = chunkFZFSGOTZ_cjs.ArkAddress.decode(destination).pkScript;
|
|
7178
7178
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
7179
7179
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
7180
|
-
const eligible = vtxos.map(
|
|
7180
|
+
const eligible = vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo).filter(
|
|
7181
7181
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7182
7182
|
);
|
|
7183
7183
|
if (eligible.length === 0) {
|
|
@@ -7206,11 +7206,11 @@ var DelegateManagerImpl = class {
|
|
|
7206
7206
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7207
7207
|
let recoverableVtxos = [];
|
|
7208
7208
|
for (const vtxo of eligible) {
|
|
7209
|
-
if (
|
|
7209
|
+
if (chunkFZFSGOTZ_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7210
7210
|
recoverableVtxos.push(vtxo);
|
|
7211
7211
|
continue;
|
|
7212
7212
|
}
|
|
7213
|
-
const expiry =
|
|
7213
|
+
const expiry = chunkFZFSGOTZ_cjs.toBatchExpiry(vtxo);
|
|
7214
7214
|
if (!expiry) continue;
|
|
7215
7215
|
const dayKey = getDayTimestamp(expiry);
|
|
7216
7216
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -7275,7 +7275,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7275
7275
|
}
|
|
7276
7276
|
if (!delegateAt) {
|
|
7277
7277
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7278
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7278
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkFZFSGOTZ_cjs.canRecoverOnchain(coin, now) && chunkFZFSGOTZ_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkFZFSGOTZ_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
7279
7279
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
7280
7280
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
7281
7281
|
} else {
|
|
@@ -7304,7 +7304,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7304
7304
|
let amount = 0n;
|
|
7305
7305
|
for (const coin of vtxos) {
|
|
7306
7306
|
const inputFee = estimator.evalOffchainInput({
|
|
7307
|
-
...
|
|
7307
|
+
...chunkFZFSGOTZ_cjs.toOffchainInputFeeParams(coin),
|
|
7308
7308
|
type: "vtxo"
|
|
7309
7309
|
});
|
|
7310
7310
|
if (inputFee.value >= coin.value) {
|
|
@@ -7318,7 +7318,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7318
7318
|
const delegateFee = BigInt(Number(fee));
|
|
7319
7319
|
if (delegateFee > 0n) {
|
|
7320
7320
|
outputs.push({
|
|
7321
|
-
script:
|
|
7321
|
+
script: chunkFZFSGOTZ_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
7322
7322
|
amount: delegateFee
|
|
7323
7323
|
});
|
|
7324
7324
|
}
|
|
@@ -7351,10 +7351,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7351
7351
|
destinationScript
|
|
7352
7352
|
);
|
|
7353
7353
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
7354
|
-
btcSigner.Address(
|
|
7354
|
+
btcSigner.Address(chunkFZFSGOTZ_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
7355
7355
|
);
|
|
7356
7356
|
const forfeits = await Promise.all(
|
|
7357
|
-
vtxos.filter((v) => !
|
|
7357
|
+
vtxos.filter((v) => !chunkFZFSGOTZ_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
7358
7358
|
const forfeit = await makeDelegateForfeitTx(
|
|
7359
7359
|
coin,
|
|
7360
7360
|
dust,
|
|
@@ -7379,7 +7379,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
7379
7379
|
index: input.vout,
|
|
7380
7380
|
witnessUtxo: {
|
|
7381
7381
|
amount: BigInt(input.value),
|
|
7382
|
-
script:
|
|
7382
|
+
script: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
7383
7383
|
},
|
|
7384
7384
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
7385
7385
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -7437,7 +7437,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
7437
7437
|
expire_at: 0,
|
|
7438
7438
|
cosigners_public_keys: cosignerPubKeys
|
|
7439
7439
|
};
|
|
7440
|
-
const proof =
|
|
7440
|
+
const proof = chunkFZFSGOTZ_cjs.Intent.create(message, coins, outputs);
|
|
7441
7441
|
const signedProof = await identity.sign(proof);
|
|
7442
7442
|
return {
|
|
7443
7443
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -7455,10 +7455,10 @@ function getDayTimestamp(timestamp) {
|
|
|
7455
7455
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
7456
7456
|
if (!vtxo.tapTree) return void 0;
|
|
7457
7457
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
7458
|
-
const vtxoScript =
|
|
7458
|
+
const vtxoScript = chunkFZFSGOTZ_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
7459
7459
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
7460
|
-
const arkTapscript =
|
|
7461
|
-
if (!
|
|
7460
|
+
const arkTapscript = chunkFZFSGOTZ_cjs.decodeTapscript(chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
7461
|
+
if (!chunkFZFSGOTZ_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
7462
7462
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
7463
7463
|
});
|
|
7464
7464
|
}
|
|
@@ -7646,7 +7646,7 @@ async function closeDatabase(dbName) {
|
|
|
7646
7646
|
return true;
|
|
7647
7647
|
}
|
|
7648
7648
|
function scriptFromArkAddress(address) {
|
|
7649
|
-
return base.hex.encode(
|
|
7649
|
+
return base.hex.encode(chunkFZFSGOTZ_cjs.ArkAddress.decode(address).pkScript);
|
|
7650
7650
|
}
|
|
7651
7651
|
|
|
7652
7652
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -8143,7 +8143,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
8143
8143
|
}
|
|
8144
8144
|
async function getVtxosForContract(repo, contract) {
|
|
8145
8145
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
8146
|
-
return vtxos.map(
|
|
8146
|
+
return vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
8147
8147
|
}
|
|
8148
8148
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
8149
8149
|
if (repo.saveVtxosForScript) {
|
|
@@ -8285,7 +8285,7 @@ function decodeArkContract(encoded) {
|
|
|
8285
8285
|
}
|
|
8286
8286
|
function contractFromArkContract(encoded, options = {}) {
|
|
8287
8287
|
const parsed = decodeArkContract(encoded);
|
|
8288
|
-
const handler =
|
|
8288
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(parsed.type);
|
|
8289
8289
|
if (!handler) {
|
|
8290
8290
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8291
8291
|
}
|
|
@@ -8299,9 +8299,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8299
8299
|
metadata: options.metadata
|
|
8300
8300
|
};
|
|
8301
8301
|
}
|
|
8302
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8302
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkFZFSGOTZ_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8303
8303
|
const parsed = decodeArkContract(encoded);
|
|
8304
|
-
const handler =
|
|
8304
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8305
8305
|
const params = parsed.data;
|
|
8306
8306
|
const vtxoScript = handler.createScript(params);
|
|
8307
8307
|
return {
|
|
@@ -8555,9 +8555,9 @@ var ContractWatcher = class {
|
|
|
8555
8555
|
this.connectionState = "connected";
|
|
8556
8556
|
this.reconnectAttempts = 0;
|
|
8557
8557
|
this.listenLoop().catch((e) => {
|
|
8558
|
-
if (
|
|
8558
|
+
if (chunkFZFSGOTZ_cjs.isEventSourceError(e)) {
|
|
8559
8559
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8560
|
-
} else if (!
|
|
8560
|
+
} else if (!chunkFZFSGOTZ_cjs.isEventSourceUnavailableError(e)) {
|
|
8561
8561
|
console.error(e);
|
|
8562
8562
|
}
|
|
8563
8563
|
this.connectionState = "disconnected";
|
|
@@ -8569,7 +8569,7 @@ var ContractWatcher = class {
|
|
|
8569
8569
|
this.scheduleReconnect();
|
|
8570
8570
|
});
|
|
8571
8571
|
} catch (error) {
|
|
8572
|
-
if (!
|
|
8572
|
+
if (!chunkFZFSGOTZ_cjs.isEventSourceUnavailableError(error)) {
|
|
8573
8573
|
console.error("ContractWatcher connection failed:", error);
|
|
8574
8574
|
}
|
|
8575
8575
|
this.connectionState = "disconnected";
|
|
@@ -8595,7 +8595,7 @@ var ContractWatcher = class {
|
|
|
8595
8595
|
* slower; what it loses is push latency.
|
|
8596
8596
|
*/
|
|
8597
8597
|
reportEventSourceUnavailable(error) {
|
|
8598
|
-
if (!
|
|
8598
|
+
if (!chunkFZFSGOTZ_cjs.isEventSourceUnavailableError(error)) return false;
|
|
8599
8599
|
if (!this.eventSourceReported) {
|
|
8600
8600
|
this.eventSourceReported = true;
|
|
8601
8601
|
console.warn(
|
|
@@ -8811,14 +8811,14 @@ var ContractWatcher = class {
|
|
|
8811
8811
|
const timestamp = Date.now();
|
|
8812
8812
|
if (update.newVtxos?.length) {
|
|
8813
8813
|
this.processSubscriptionVtxos(
|
|
8814
|
-
update.newVtxos.map(
|
|
8814
|
+
update.newVtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo),
|
|
8815
8815
|
"vtxo_received",
|
|
8816
8816
|
timestamp
|
|
8817
8817
|
);
|
|
8818
8818
|
}
|
|
8819
8819
|
if (update.spentVtxos?.length) {
|
|
8820
8820
|
this.processSubscriptionVtxos(
|
|
8821
|
-
update.spentVtxos.map(
|
|
8821
|
+
update.spentVtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo),
|
|
8822
8822
|
"vtxo_spent",
|
|
8823
8823
|
timestamp
|
|
8824
8824
|
);
|
|
@@ -8951,7 +8951,7 @@ async function reconcileIntents(deps) {
|
|
|
8951
8951
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
8952
8952
|
if (outpoints.length > 0) {
|
|
8953
8953
|
try {
|
|
8954
|
-
const { vtxos } = await
|
|
8954
|
+
const { vtxos } = await chunkFZFSGOTZ_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
8955
8955
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
8956
8956
|
} catch (e) {
|
|
8957
8957
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9125,7 +9125,7 @@ var ContractManager = class _ContractManager {
|
|
|
9125
9125
|
await this.reconcileWatched();
|
|
9126
9126
|
this.markSyncOnline();
|
|
9127
9127
|
} catch (err) {
|
|
9128
|
-
if (!
|
|
9128
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
9129
9129
|
this.markSyncDegraded(err);
|
|
9130
9130
|
}
|
|
9131
9131
|
this.initialized = true;
|
|
@@ -9257,7 +9257,7 @@ var ContractManager = class _ContractManager {
|
|
|
9257
9257
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9258
9258
|
const to = watermark + lookAhead.size;
|
|
9259
9259
|
const deps = lookAhead.candidateDeps();
|
|
9260
|
-
const handlers =
|
|
9260
|
+
const handlers = chunkWXCVS6PD_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkWXCVS6PD_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9261
9261
|
const band = /* @__PURE__ */ new Map();
|
|
9262
9262
|
for (let index = from; index <= to; index++) {
|
|
9263
9263
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9268,7 +9268,7 @@ var ContractManager = class _ContractManager {
|
|
|
9268
9268
|
index,
|
|
9269
9269
|
params: {
|
|
9270
9270
|
...candidate,
|
|
9271
|
-
...
|
|
9271
|
+
...chunkWXCVS6PD_cjs.speculativeReceiveMetadata(descriptor)
|
|
9272
9272
|
}
|
|
9273
9273
|
});
|
|
9274
9274
|
}
|
|
@@ -9330,7 +9330,7 @@ var ContractManager = class _ContractManager {
|
|
|
9330
9330
|
});
|
|
9331
9331
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9332
9332
|
} catch (err) {
|
|
9333
|
-
if (!
|
|
9333
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
9334
9334
|
this.markSyncDegraded(err);
|
|
9335
9335
|
}
|
|
9336
9336
|
}
|
|
@@ -9380,7 +9380,7 @@ var ContractManager = class _ContractManager {
|
|
|
9380
9380
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9381
9381
|
this.markSyncOnline();
|
|
9382
9382
|
} catch (err) {
|
|
9383
|
-
if (!
|
|
9383
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
9384
9384
|
this.markSyncDegraded(err);
|
|
9385
9385
|
}
|
|
9386
9386
|
await this.watcher.addContract(contract);
|
|
@@ -9417,7 +9417,7 @@ var ContractManager = class _ContractManager {
|
|
|
9417
9417
|
return result;
|
|
9418
9418
|
}
|
|
9419
9419
|
async upsertContractRow(params) {
|
|
9420
|
-
const handler =
|
|
9420
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(params.type);
|
|
9421
9421
|
if (!handler) {
|
|
9422
9422
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9423
9423
|
}
|
|
@@ -9517,7 +9517,7 @@ var ContractManager = class _ContractManager {
|
|
|
9517
9517
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
9518
9518
|
);
|
|
9519
9519
|
}
|
|
9520
|
-
const registered =
|
|
9520
|
+
const registered = chunkWXCVS6PD_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkWXCVS6PD_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
9521
9521
|
const discoverables = [
|
|
9522
9522
|
...registered.filter((h) => h.type === "boarding"),
|
|
9523
9523
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9652,7 +9652,7 @@ var ContractManager = class _ContractManager {
|
|
|
9652
9652
|
await this.syncContracts({ contracts, pageSize });
|
|
9653
9653
|
this.markSyncOnline();
|
|
9654
9654
|
} catch (err) {
|
|
9655
|
-
if (!
|
|
9655
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
9656
9656
|
this.markSyncDegraded(err);
|
|
9657
9657
|
}
|
|
9658
9658
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -9673,7 +9673,7 @@ var ContractManager = class _ContractManager {
|
|
|
9673
9673
|
}
|
|
9674
9674
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
9675
9675
|
return vtxos.map(
|
|
9676
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9676
|
+
(vtxo) => extendVirtualCoinForContract(chunkFZFSGOTZ_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
9677
9677
|
);
|
|
9678
9678
|
}
|
|
9679
9679
|
/** @inheritdoc */
|
|
@@ -9717,14 +9717,14 @@ var ContractManager = class _ContractManager {
|
|
|
9717
9717
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
9718
9718
|
const asking = vtxos.filter((vtxo) => {
|
|
9719
9719
|
const contract = byScript.get(vtxo.script);
|
|
9720
|
-
return contract !== void 0 &&
|
|
9720
|
+
return contract !== void 0 && chunkWXCVS6PD_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
9721
9721
|
});
|
|
9722
9722
|
if (asking.length === 0) return refused;
|
|
9723
9723
|
const tip = await this.currentChainTip();
|
|
9724
9724
|
const walletKey = await walletPubKey?.();
|
|
9725
9725
|
for (const vtxo of asking) {
|
|
9726
9726
|
const contract = byScript.get(vtxo.script);
|
|
9727
|
-
const handler =
|
|
9727
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
9728
9728
|
if (!handler?.assertSpendableNow) continue;
|
|
9729
9729
|
const context = {
|
|
9730
9730
|
collaborative: true,
|
|
@@ -9739,7 +9739,7 @@ var ContractManager = class _ContractManager {
|
|
|
9739
9739
|
// the next handler to answer a CSV question would meet a
|
|
9740
9740
|
// TypeError instead of a `false`. Carry the coin only when it
|
|
9741
9741
|
// really is one.
|
|
9742
|
-
vtxo:
|
|
9742
|
+
vtxo: chunkFZFSGOTZ_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
9743
9743
|
};
|
|
9744
9744
|
try {
|
|
9745
9745
|
await handler.assertSpendableNow(
|
|
@@ -9895,7 +9895,7 @@ var ContractManager = class _ContractManager {
|
|
|
9895
9895
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
9896
9896
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9897
9897
|
if (!contract) return [];
|
|
9898
|
-
const handler =
|
|
9898
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
9899
9899
|
if (!handler) return [];
|
|
9900
9900
|
const script = handler.createScript(contract.params);
|
|
9901
9901
|
const tip = await this.currentChainTip();
|
|
@@ -9923,7 +9923,7 @@ var ContractManager = class _ContractManager {
|
|
|
9923
9923
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
9924
9924
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9925
9925
|
if (!contract) return [];
|
|
9926
|
-
const handler =
|
|
9926
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
9927
9927
|
if (!handler) return [];
|
|
9928
9928
|
const script = handler.createScript(contract.params);
|
|
9929
9929
|
const context = {
|
|
@@ -9979,7 +9979,7 @@ var ContractManager = class _ContractManager {
|
|
|
9979
9979
|
}
|
|
9980
9980
|
async refreshOutpoints(outpoints) {
|
|
9981
9981
|
if (outpoints.length === 0) return;
|
|
9982
|
-
const { vtxos } = await
|
|
9982
|
+
const { vtxos } = await chunkFZFSGOTZ_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
9983
9983
|
outpoints
|
|
9984
9984
|
});
|
|
9985
9985
|
if (vtxos.length === 0) return;
|
|
@@ -10058,7 +10058,7 @@ var ContractManager = class _ContractManager {
|
|
|
10058
10058
|
break;
|
|
10059
10059
|
}
|
|
10060
10060
|
} catch (err) {
|
|
10061
|
-
if (!
|
|
10061
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
10062
10062
|
this.markSyncDegraded(err);
|
|
10063
10063
|
}
|
|
10064
10064
|
this.emitEvent(event);
|
|
@@ -10137,7 +10137,7 @@ var ContractManager = class _ContractManager {
|
|
|
10137
10137
|
*/
|
|
10138
10138
|
async reconcilePendingFrontier(contracts) {
|
|
10139
10139
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
10140
|
-
const vtxos = await
|
|
10140
|
+
const vtxos = await chunkFZFSGOTZ_cjs.getAllNormalizedVtxos(
|
|
10141
10141
|
this.config.indexerProvider,
|
|
10142
10142
|
contracts.map((c) => c.script),
|
|
10143
10143
|
{ pendingOnly: true }
|
|
@@ -10220,7 +10220,7 @@ var ContractManager = class _ContractManager {
|
|
|
10220
10220
|
}
|
|
10221
10221
|
return result;
|
|
10222
10222
|
}
|
|
10223
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10223
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkFZFSGOTZ_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
10224
10224
|
if (contracts.length === 0) {
|
|
10225
10225
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
10226
10226
|
}
|
|
@@ -10236,7 +10236,7 @@ var ContractManager = class _ContractManager {
|
|
|
10236
10236
|
before: syncWindow.before
|
|
10237
10237
|
}
|
|
10238
10238
|
} : {};
|
|
10239
|
-
const vtxos = await
|
|
10239
|
+
const vtxos = await chunkFZFSGOTZ_cjs.getAllNormalizedVtxos(
|
|
10240
10240
|
this.config.indexerProvider,
|
|
10241
10241
|
contracts.map((c) => c.script),
|
|
10242
10242
|
{ ...windowOpts, pageSize }
|
|
@@ -10381,7 +10381,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
10381
10381
|
const s = base.hex.decode(t.s);
|
|
10382
10382
|
return [cb, s];
|
|
10383
10383
|
};
|
|
10384
|
-
var deserializeVtxo = (o) =>
|
|
10384
|
+
var deserializeVtxo = (o) => chunkFZFSGOTZ_cjs.normalizeVtxo({
|
|
10385
10385
|
...o,
|
|
10386
10386
|
createdAt: new Date(o.createdAt),
|
|
10387
10387
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -11422,7 +11422,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
11422
11422
|
*/
|
|
11423
11423
|
materializeDescriptorAt(index) {
|
|
11424
11424
|
const descriptor = this.identity.descriptor;
|
|
11425
|
-
const network =
|
|
11425
|
+
const network = chunkWXCVS6PD_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
11426
11426
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
11427
11427
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
11428
11428
|
if (!keyInfo?.keyExpression) {
|
|
@@ -11570,7 +11570,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11570
11570
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
11571
11571
|
if (!provider) return void 0;
|
|
11572
11572
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
11573
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
11573
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
11574
11574
|
const factoryOpts = {
|
|
11575
11575
|
walletRepository: setup.walletRepository,
|
|
11576
11576
|
contractRepository: setup.contractRepository,
|
|
@@ -11769,7 +11769,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11769
11769
|
};
|
|
11770
11770
|
function deriveLeafPubkey(descriptor) {
|
|
11771
11771
|
try {
|
|
11772
|
-
return
|
|
11772
|
+
return chunkWXCVS6PD_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
11773
11773
|
} catch (e) {
|
|
11774
11774
|
throw new NonRangeableDescriptorError(
|
|
11775
11775
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -11781,7 +11781,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11781
11781
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
11782
11782
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
11783
11783
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
11784
|
-
const csvTimelock =
|
|
11784
|
+
const csvTimelock = chunkFZFSGOTZ_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
11785
11785
|
const base$1 = {
|
|
11786
11786
|
script: base.hex.encode(tapscript.pkScript),
|
|
11787
11787
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -11792,11 +11792,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11792
11792
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
11793
11793
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
11794
11794
|
metadata: {
|
|
11795
|
-
...{ source:
|
|
11795
|
+
...{ source: chunkWXCVS6PD_cjs.WALLET_RECEIVE_SOURCE },
|
|
11796
11796
|
signingDescriptor: descriptor
|
|
11797
11797
|
}
|
|
11798
11798
|
};
|
|
11799
|
-
const params = tapscript instanceof
|
|
11799
|
+
const params = tapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? {
|
|
11800
11800
|
...base$1,
|
|
11801
11801
|
type: "delegate",
|
|
11802
11802
|
params: {
|
|
@@ -11817,10 +11817,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11817
11817
|
return { tapscript, params };
|
|
11818
11818
|
}
|
|
11819
11819
|
function rebuildTapscript(current, pubKey) {
|
|
11820
|
-
if (current instanceof
|
|
11821
|
-
return new
|
|
11820
|
+
if (current instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script) {
|
|
11821
|
+
return new chunkWXCVS6PD_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
11822
11822
|
}
|
|
11823
|
-
return new
|
|
11823
|
+
return new chunkWXCVS6PD_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
11824
11824
|
}
|
|
11825
11825
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
11826
11826
|
const candidates = await contractRepository.getContracts({
|
|
@@ -11829,7 +11829,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
11829
11829
|
});
|
|
11830
11830
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
11831
11831
|
const matching = candidates.filter(
|
|
11832
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
11832
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkWXCVS6PD_cjs.WALLET_RECEIVE_SOURCE
|
|
11833
11833
|
).sort((a, b) => {
|
|
11834
11834
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
11835
11835
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -11884,17 +11884,17 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
11884
11884
|
}
|
|
11885
11885
|
};
|
|
11886
11886
|
for (const vtxo of vtxos) {
|
|
11887
|
-
if (
|
|
11887
|
+
if (chunkFZFSGOTZ_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11888
11888
|
addAssets(owned, vtxo);
|
|
11889
11889
|
if (isPendingRecovery(vtxo)) {
|
|
11890
11890
|
pendingRecovery += vtxo.value;
|
|
11891
11891
|
continue;
|
|
11892
11892
|
}
|
|
11893
|
-
if (
|
|
11893
|
+
if (chunkFZFSGOTZ_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11894
11894
|
recoverable += vtxo.value;
|
|
11895
11895
|
continue;
|
|
11896
11896
|
}
|
|
11897
|
-
if (!
|
|
11897
|
+
if (!chunkFZFSGOTZ_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
11898
11898
|
if (vtxo.isPreconfirmed) {
|
|
11899
11899
|
preconfirmed += vtxo.value;
|
|
11900
11900
|
} else {
|
|
@@ -12063,12 +12063,12 @@ var InputSignerRouter = class {
|
|
|
12063
12063
|
};
|
|
12064
12064
|
|
|
12065
12065
|
// src/wallet/wallet.ts
|
|
12066
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
12066
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkFZFSGOTZ_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
12067
12067
|
function intentProofJobs(coins) {
|
|
12068
12068
|
if (coins.length === 0) return [];
|
|
12069
12069
|
const coinJobs = coins.map((coin, i) => ({
|
|
12070
12070
|
index: i + 1,
|
|
12071
|
-
lookupScript:
|
|
12071
|
+
lookupScript: chunkFZFSGOTZ_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12072
12072
|
}));
|
|
12073
12073
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12074
12074
|
}
|
|
@@ -12105,7 +12105,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
12105
12105
|
const seen = /* @__PURE__ */ new Set();
|
|
12106
12106
|
const deduped = [];
|
|
12107
12107
|
for (const timelock of timelocks) {
|
|
12108
|
-
const sequence =
|
|
12108
|
+
const sequence = chunkFZFSGOTZ_cjs.timelockToSequence(timelock).toString();
|
|
12109
12109
|
if (seen.has(sequence)) continue;
|
|
12110
12110
|
seen.add(sequence);
|
|
12111
12111
|
deduped.push(timelock);
|
|
@@ -12122,7 +12122,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12122
12122
|
state: "active"
|
|
12123
12123
|
});
|
|
12124
12124
|
const newest = candidates.filter(
|
|
12125
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12125
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkWXCVS6PD_cjs.WALLET_RECEIVE_SOURCE
|
|
12126
12126
|
).sort((a, b) => {
|
|
12127
12127
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12128
12128
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12130,7 +12130,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12130
12130
|
if (!newest?.params.pubKey) return baseline;
|
|
12131
12131
|
try {
|
|
12132
12132
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
12133
|
-
return new
|
|
12133
|
+
return new chunkWXCVS6PD_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
12134
12134
|
} catch (e) {
|
|
12135
12135
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
12136
12136
|
return baseline;
|
|
@@ -12146,8 +12146,8 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
12146
12146
|
if (pendingSpendOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
12147
12147
|
return false;
|
|
12148
12148
|
}
|
|
12149
|
-
if (!
|
|
12150
|
-
if (!f.withRecoverable &&
|
|
12149
|
+
if (!chunkFZFSGOTZ_cjs.hasTerminalSpend(vtxo)) {
|
|
12150
|
+
if (!f.withRecoverable && chunkFZFSGOTZ_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12151
12151
|
return false;
|
|
12152
12152
|
}
|
|
12153
12153
|
return true;
|
|
@@ -12488,7 +12488,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12488
12488
|
*/
|
|
12489
12489
|
static async setupWalletConfig(config, pubKey) {
|
|
12490
12490
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
12491
|
-
const arkProvider = config.arkProvider || new
|
|
12491
|
+
const arkProvider = config.arkProvider || new chunkFZFSGOTZ_cjs.RestArkProvider(arkadeServerUrl);
|
|
12492
12492
|
let indexerProvider = config.indexerProvider;
|
|
12493
12493
|
if (!indexerProvider) {
|
|
12494
12494
|
let indexerUrl = config.indexerUrl;
|
|
@@ -12505,7 +12505,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12505
12505
|
indexerUrl = arkadeServerUrl;
|
|
12506
12506
|
}
|
|
12507
12507
|
}
|
|
12508
|
-
indexerProvider = new
|
|
12508
|
+
indexerProvider = new chunkRXITDAV4_cjs.RestIndexerProvider(indexerUrl);
|
|
12509
12509
|
}
|
|
12510
12510
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
12511
12511
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -12514,7 +12514,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12514
12514
|
source: serverInfoSource,
|
|
12515
12515
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
12516
12516
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
12517
|
-
const network =
|
|
12517
|
+
const network = chunkFZFSGOTZ_cjs.getNetwork(info.network);
|
|
12518
12518
|
if ("descriptor" in config.identity) {
|
|
12519
12519
|
const descriptor = config.identity.descriptor;
|
|
12520
12520
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -12561,11 +12561,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12561
12561
|
serverPubKey,
|
|
12562
12562
|
csvTimelock: exitTimelock
|
|
12563
12563
|
};
|
|
12564
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
12565
|
-
const boardingTapscript =
|
|
12564
|
+
const offchainTapscript = !delegatePubKey ? new chunkWXCVS6PD_cjs.DefaultVtxo.Script(offchainOptions) : new chunkWXCVS6PD_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
12565
|
+
const boardingTapscript = chunkWXCVS6PD_cjs.BoardingContractHandler.createScript({
|
|
12566
12566
|
pubKey: base.hex.encode(pubKey),
|
|
12567
12567
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12568
|
-
csvTimelock:
|
|
12568
|
+
csvTimelock: chunkFZFSGOTZ_cjs.timelockToSequence(boardingTimelock).toString()
|
|
12569
12569
|
});
|
|
12570
12570
|
return {
|
|
12571
12571
|
arkProvider,
|
|
@@ -12862,7 +12862,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12862
12862
|
const response = await contractManager.getContractsWithVtxos();
|
|
12863
12863
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
12864
12864
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
12865
|
-
const resolveTxCreatedAt = (txids) =>
|
|
12865
|
+
const resolveTxCreatedAt = (txids) => chunkFZFSGOTZ_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
12866
12866
|
return buildTransactionHistory(
|
|
12867
12867
|
allVtxos,
|
|
12868
12868
|
boardingTxs,
|
|
@@ -12956,7 +12956,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12956
12956
|
},
|
|
12957
12957
|
isUnrolled: true,
|
|
12958
12958
|
...boardingFacts,
|
|
12959
|
-
virtualStatus:
|
|
12959
|
+
virtualStatus: chunkFZFSGOTZ_cjs.toVirtualStatus(boardingFacts),
|
|
12960
12960
|
spentBy: "",
|
|
12961
12961
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
12962
12962
|
script: scriptHex
|
|
@@ -13012,9 +13012,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13012
13012
|
async getBoardingTapscripts(allowedSigners) {
|
|
13013
13013
|
const byScript = /* @__PURE__ */ new Map();
|
|
13014
13014
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
13015
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
13015
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkWXCVS6PD_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13016
13016
|
add(
|
|
13017
|
-
new
|
|
13017
|
+
new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13018
13018
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
13019
13019
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
13020
13020
|
csvTimelock: boardingCsv
|
|
@@ -13029,7 +13029,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13029
13029
|
for (const c of boardingContracts) {
|
|
13030
13030
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
13031
13031
|
try {
|
|
13032
|
-
add(
|
|
13032
|
+
add(chunkWXCVS6PD_cjs.BoardingContractHandler.createScript(c.params));
|
|
13033
13033
|
} catch (e) {
|
|
13034
13034
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
13035
13035
|
}
|
|
@@ -13067,7 +13067,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13067
13067
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
13068
13068
|
// not the wallet's current boarding timelock, which a signer
|
|
13069
13069
|
// rotation may have changed.
|
|
13070
|
-
csvTimelock:
|
|
13070
|
+
csvTimelock: chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
13071
13071
|
coins: utxos
|
|
13072
13072
|
});
|
|
13073
13073
|
}
|
|
@@ -13200,7 +13200,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13200
13200
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
13201
13201
|
async fetchPendingTxs() {
|
|
13202
13202
|
const scripts = await this.getWalletScripts();
|
|
13203
|
-
const vtxos = await
|
|
13203
|
+
const vtxos = await chunkFZFSGOTZ_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
13204
13204
|
return vtxos.filter(
|
|
13205
13205
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
13206
13206
|
).map((_) => _.arkTxId);
|
|
@@ -13231,7 +13231,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13231
13231
|
});
|
|
13232
13232
|
for (const contract of contracts) {
|
|
13233
13233
|
if (map.has(contract.script)) continue;
|
|
13234
|
-
const handler =
|
|
13234
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
13235
13235
|
if (handler) {
|
|
13236
13236
|
const script = handler.createScript(contract.params);
|
|
13237
13237
|
map.set(contract.script, script);
|
|
@@ -13343,7 +13343,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13343
13343
|
}
|
|
13344
13344
|
});
|
|
13345
13345
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
13346
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
13346
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
13347
13347
|
const baselineSigners = [
|
|
13348
13348
|
this.offchainTapscript.options.serverPubKey,
|
|
13349
13349
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -13351,8 +13351,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13351
13351
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
13352
13352
|
for (const serverPubKey of baselineSigners) {
|
|
13353
13353
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
13354
|
-
const csvTimelockStr =
|
|
13355
|
-
const defaultScript = new
|
|
13354
|
+
const csvTimelockStr = chunkFZFSGOTZ_cjs.timelockToSequence(csvTimelock).toString();
|
|
13355
|
+
const defaultScript = new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13356
13356
|
pubKey: baselinePubkey,
|
|
13357
13357
|
serverPubKey,
|
|
13358
13358
|
csvTimelock
|
|
@@ -13373,7 +13373,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13373
13373
|
});
|
|
13374
13374
|
}
|
|
13375
13375
|
if (delegatePubKey) {
|
|
13376
|
-
const delegateScript = new
|
|
13376
|
+
const delegateScript = new chunkWXCVS6PD_cjs.DelegateVtxo.Script({
|
|
13377
13377
|
pubKey: baselinePubkey,
|
|
13378
13378
|
serverPubKey,
|
|
13379
13379
|
delegatePubKey,
|
|
@@ -13397,9 +13397,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13397
13397
|
}
|
|
13398
13398
|
}
|
|
13399
13399
|
}
|
|
13400
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
13400
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkWXCVS6PD_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13401
13401
|
for (const serverPubKey of baselineSigners) {
|
|
13402
|
-
const baselineBoarding = new
|
|
13402
|
+
const baselineBoarding = new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13403
13403
|
pubKey: baselinePubkey,
|
|
13404
13404
|
serverPubKey,
|
|
13405
13405
|
csvTimelock: boardingCsvTimelock
|
|
@@ -13412,7 +13412,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13412
13412
|
params: {
|
|
13413
13413
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
13414
13414
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13415
|
-
csvTimelock:
|
|
13415
|
+
csvTimelock: chunkFZFSGOTZ_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
13416
13416
|
},
|
|
13417
13417
|
script: boardingScriptHex,
|
|
13418
13418
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -13591,7 +13591,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13591
13591
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
13592
13592
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
13593
13593
|
csvTimelocks: this.walletContractTimelocks,
|
|
13594
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
13594
|
+
delegatePubKey: this.offchainTapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
13595
13595
|
};
|
|
13596
13596
|
}
|
|
13597
13597
|
_signerRouter;
|
|
@@ -13685,24 +13685,24 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13685
13685
|
const manager = await this.getContractManager();
|
|
13686
13686
|
const descriptor = await manager.getNextSigningDescriptor();
|
|
13687
13687
|
if (!descriptor) return this.getBoardingAddress();
|
|
13688
|
-
const pubKey =
|
|
13689
|
-
const newBoarding = new
|
|
13688
|
+
const pubKey = chunkWXCVS6PD_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
13689
|
+
const newBoarding = new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13690
13690
|
...this._boardingTapscript.options,
|
|
13691
13691
|
pubKey
|
|
13692
13692
|
});
|
|
13693
|
-
const csvTimelock = newBoarding.options.csvTimelock ??
|
|
13693
|
+
const csvTimelock = newBoarding.options.csvTimelock ?? chunkWXCVS6PD_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13694
13694
|
await manager.createContract({
|
|
13695
13695
|
type: "boarding",
|
|
13696
13696
|
params: {
|
|
13697
13697
|
pubKey: base.hex.encode(pubKey),
|
|
13698
13698
|
serverPubKey: base.hex.encode(newBoarding.options.serverPubKey),
|
|
13699
|
-
csvTimelock:
|
|
13699
|
+
csvTimelock: chunkFZFSGOTZ_cjs.timelockToSequence(csvTimelock).toString()
|
|
13700
13700
|
},
|
|
13701
13701
|
script: base.hex.encode(newBoarding.pkScript),
|
|
13702
13702
|
address: newBoarding.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
13703
13703
|
state: "active",
|
|
13704
13704
|
metadata: {
|
|
13705
|
-
source:
|
|
13705
|
+
source: chunkWXCVS6PD_cjs.WALLET_RECEIVE_SOURCE,
|
|
13706
13706
|
signingDescriptor: descriptor
|
|
13707
13707
|
}
|
|
13708
13708
|
});
|
|
@@ -13737,7 +13737,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13737
13737
|
if (this._descriptorProvider instanceof HDDescriptorProvider) {
|
|
13738
13738
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
13739
13739
|
}
|
|
13740
|
-
return
|
|
13740
|
+
return chunkWXCVS6PD_cjs.identityDescriptor(this.identity);
|
|
13741
13741
|
}
|
|
13742
13742
|
/**
|
|
13743
13743
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -13862,21 +13862,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13862
13862
|
const [currentBoardingRow] = await manager.getContracts({
|
|
13863
13863
|
script: currentBoardingScript
|
|
13864
13864
|
});
|
|
13865
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
13865
|
+
const newOffchain = this.offchainTapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? new chunkWXCVS6PD_cjs.DelegateVtxo.Script({
|
|
13866
13866
|
...this.offchainTapscript.options,
|
|
13867
13867
|
serverPubKey: xonly
|
|
13868
|
-
}) : new
|
|
13868
|
+
}) : new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13869
13869
|
...this.offchainTapscript.options,
|
|
13870
13870
|
serverPubKey: xonly
|
|
13871
13871
|
});
|
|
13872
|
-
const newBoarding = new
|
|
13872
|
+
const newBoarding = new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13873
13873
|
...this._boardingTapscript.options,
|
|
13874
13874
|
serverPubKey: xonly
|
|
13875
13875
|
});
|
|
13876
|
-
const offchainCsv =
|
|
13876
|
+
const offchainCsv = chunkFZFSGOTZ_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
13877
13877
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
13878
13878
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
13879
|
-
if (newOffchain instanceof
|
|
13879
|
+
if (newOffchain instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script) {
|
|
13880
13880
|
await manager.createContract({
|
|
13881
13881
|
type: "delegate",
|
|
13882
13882
|
params: {
|
|
@@ -13904,13 +13904,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13904
13904
|
metadata: currentOffchainRow?.metadata
|
|
13905
13905
|
});
|
|
13906
13906
|
}
|
|
13907
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
13907
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkWXCVS6PD_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13908
13908
|
await manager.createContract({
|
|
13909
13909
|
type: "boarding",
|
|
13910
13910
|
params: {
|
|
13911
13911
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
13912
13912
|
serverPubKey: base.hex.encode(xonly),
|
|
13913
|
-
csvTimelock:
|
|
13913
|
+
csvTimelock: chunkFZFSGOTZ_cjs.timelockToSequence(boardingCsv).toString()
|
|
13914
13914
|
},
|
|
13915
13915
|
script: base.hex.encode(newBoarding.pkScript),
|
|
13916
13916
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -13943,14 +13943,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13943
13943
|
_restoreInFlight;
|
|
13944
13944
|
_addPendingSpends(inputs) {
|
|
13945
13945
|
for (const input of inputs) {
|
|
13946
|
-
if (
|
|
13946
|
+
if (chunkFZFSGOTZ_cjs.isVirtualCoin(input)) {
|
|
13947
13947
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
13948
13948
|
}
|
|
13949
13949
|
}
|
|
13950
13950
|
}
|
|
13951
13951
|
_removePendingSpends(inputs) {
|
|
13952
13952
|
for (const input of inputs) {
|
|
13953
|
-
if (
|
|
13953
|
+
if (chunkFZFSGOTZ_cjs.isVirtualCoin(input)) {
|
|
13954
13954
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
13955
13955
|
}
|
|
13956
13956
|
}
|
|
@@ -14008,9 +14008,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14008
14008
|
const manager = await this.getContractManager();
|
|
14009
14009
|
const provider = this._descriptorProvider;
|
|
14010
14010
|
const hd = provider instanceof HDDescriptorProvider;
|
|
14011
|
-
const staticDescriptor = hd ? void 0 : await
|
|
14011
|
+
const staticDescriptor = hd ? void 0 : await chunkWXCVS6PD_cjs.identityDescriptor(this.identity);
|
|
14012
14012
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
14013
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14013
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14014
14014
|
const arkInfo = await this.arkProvider.getInfo();
|
|
14015
14015
|
const currentSignerPubKey = toXOnlyPubKey(base.hex.decode(arkInfo.signerPubkey));
|
|
14016
14016
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
@@ -14029,7 +14029,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14029
14029
|
csvTimelocks: this.walletContractTimelocks,
|
|
14030
14030
|
// Boarding-exit CSV so the boarding handler can build its
|
|
14031
14031
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
14032
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
14032
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkWXCVS6PD_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
14033
14033
|
delegatePubKey
|
|
14034
14034
|
};
|
|
14035
14035
|
const result = await manager.scanContracts({
|
|
@@ -14292,7 +14292,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14292
14292
|
inputs: params.selectedVtxos,
|
|
14293
14293
|
changeAmount: BigInt(changeAmount)
|
|
14294
14294
|
};
|
|
14295
|
-
const outputAddress =
|
|
14295
|
+
const outputAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(params.address);
|
|
14296
14296
|
assertRecipientArkAddress(
|
|
14297
14297
|
params.address,
|
|
14298
14298
|
outputAddress,
|
|
@@ -14358,13 +14358,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14358
14358
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
14359
14359
|
}
|
|
14360
14360
|
const offchainAddress = await this.getAddress();
|
|
14361
|
-
const offchainPkScript =
|
|
14361
|
+
const offchainPkScript = chunkFZFSGOTZ_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
14362
14362
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
14363
14363
|
if (!params) {
|
|
14364
14364
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
14365
14365
|
const estimator = new Estimator(fees.intentFee);
|
|
14366
14366
|
let amount = 0;
|
|
14367
|
-
const exitScript =
|
|
14367
|
+
const exitScript = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(
|
|
14368
14368
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
14369
14369
|
);
|
|
14370
14370
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -14393,7 +14393,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14393
14393
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
14394
14394
|
break;
|
|
14395
14395
|
}
|
|
14396
|
-
const inputFee = estimator.evalOffchainInput(
|
|
14396
|
+
const inputFee = estimator.evalOffchainInput(chunkFZFSGOTZ_cjs.toOffchainInputFeeParams(vtxo));
|
|
14397
14397
|
if (inputFee.satoshis >= vtxo.value) {
|
|
14398
14398
|
continue;
|
|
14399
14399
|
}
|
|
@@ -14440,7 +14440,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14440
14440
|
let script;
|
|
14441
14441
|
let arkAddress;
|
|
14442
14442
|
try {
|
|
14443
|
-
arkAddress =
|
|
14443
|
+
arkAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(output.address);
|
|
14444
14444
|
} catch {
|
|
14445
14445
|
arkAddress = void 0;
|
|
14446
14446
|
}
|
|
@@ -14530,7 +14530,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14530
14530
|
const abortController = new AbortController();
|
|
14531
14531
|
let stream;
|
|
14532
14532
|
let committedTxid;
|
|
14533
|
-
const settleInputVtxos = params.inputs.filter(
|
|
14533
|
+
const settleInputVtxos = params.inputs.filter(chunkFZFSGOTZ_cjs.isVirtualCoin);
|
|
14534
14534
|
const contractManager = await this.getContractManager();
|
|
14535
14535
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
14536
14536
|
await contractManager.assertSpendableNow?.(
|
|
@@ -14639,7 +14639,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14639
14639
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
14640
14640
|
if (!this._descriptorProvider) return;
|
|
14641
14641
|
const consumedBoarding = inputs.some(
|
|
14642
|
-
(input) => typeof input !== "string" && !
|
|
14642
|
+
(input) => typeof input !== "string" && !chunkFZFSGOTZ_cjs.isVirtualCoin(input)
|
|
14643
14643
|
);
|
|
14644
14644
|
if (!consumedBoarding) return;
|
|
14645
14645
|
try {
|
|
@@ -14663,7 +14663,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14663
14663
|
let connectorIndex = 0;
|
|
14664
14664
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
14665
14665
|
for (const input of inputs) {
|
|
14666
|
-
if (!
|
|
14666
|
+
if (!chunkFZFSGOTZ_cjs.isVirtualCoin(input)) {
|
|
14667
14667
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
14668
14668
|
const settlementInput = settlementPsbt.getInput(i);
|
|
14669
14669
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -14694,7 +14694,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14694
14694
|
}
|
|
14695
14695
|
continue;
|
|
14696
14696
|
}
|
|
14697
|
-
if (
|
|
14697
|
+
if (chunkFZFSGOTZ_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
14698
14698
|
continue;
|
|
14699
14699
|
}
|
|
14700
14700
|
if (connectorsLeaves.length === 0) {
|
|
@@ -14722,7 +14722,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14722
14722
|
index: input.vout,
|
|
14723
14723
|
witnessUtxo: {
|
|
14724
14724
|
amount: BigInt(input.value),
|
|
14725
|
-
script:
|
|
14725
|
+
script: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14726
14726
|
},
|
|
14727
14727
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
14728
14728
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -14741,7 +14741,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14741
14741
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
14742
14742
|
{
|
|
14743
14743
|
index: 0,
|
|
14744
|
-
lookupScript:
|
|
14744
|
+
lookupScript: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14745
14745
|
}
|
|
14746
14746
|
]);
|
|
14747
14747
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -14799,7 +14799,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14799
14799
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
14800
14800
|
);
|
|
14801
14801
|
await this.arkProvider.confirmRegistration(intentId);
|
|
14802
|
-
const sweepTapscript =
|
|
14802
|
+
const sweepTapscript = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.encode({
|
|
14803
14803
|
timelock,
|
|
14804
14804
|
pubkeys: [this.forfeitPubkey]
|
|
14805
14805
|
}).script;
|
|
@@ -14905,9 +14905,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14905
14905
|
...existing ?? {},
|
|
14906
14906
|
intentTxId,
|
|
14907
14907
|
registerProof: intent.proof,
|
|
14908
|
-
registerProofMessage:
|
|
14908
|
+
registerProofMessage: chunkFZFSGOTZ_cjs.Intent.encodeMessage(intent.message),
|
|
14909
14909
|
deleteProof: deleteIntent.proof,
|
|
14910
|
-
deleteProofMessage:
|
|
14910
|
+
deleteProofMessage: chunkFZFSGOTZ_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
14911
14911
|
intentVtxos: inputs.map((i) => ({
|
|
14912
14912
|
txid: i.txid,
|
|
14913
14913
|
vout: i.vout
|
|
@@ -14939,7 +14939,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14939
14939
|
try {
|
|
14940
14940
|
return await this.arkProvider.registerIntent(intent);
|
|
14941
14941
|
} catch (error) {
|
|
14942
|
-
if (error instanceof
|
|
14942
|
+
if (error instanceof chunkFZFSGOTZ_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
14943
14943
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
14944
14944
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
14945
14945
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -14955,7 +14955,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14955
14955
|
expire_at: 0,
|
|
14956
14956
|
cosigners_public_keys: cosignerPubKeys
|
|
14957
14957
|
};
|
|
14958
|
-
const proof =
|
|
14958
|
+
const proof = chunkFZFSGOTZ_cjs.Intent.create(message, coins, outputs);
|
|
14959
14959
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14960
14960
|
return {
|
|
14961
14961
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -14967,7 +14967,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14967
14967
|
type: "delete",
|
|
14968
14968
|
expire_at: 0
|
|
14969
14969
|
};
|
|
14970
|
-
const proof =
|
|
14970
|
+
const proof = chunkFZFSGOTZ_cjs.Intent.create(message, coins, []);
|
|
14971
14971
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14972
14972
|
return {
|
|
14973
14973
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -14979,7 +14979,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14979
14979
|
type: "get-pending-tx",
|
|
14980
14980
|
expire_at: 0
|
|
14981
14981
|
};
|
|
14982
|
-
const proof =
|
|
14982
|
+
const proof = chunkFZFSGOTZ_cjs.Intent.create(message, coins, []);
|
|
14983
14983
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14984
14984
|
return {
|
|
14985
14985
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15000,7 +15000,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15000
15000
|
if (!vtxos || vtxos.length === 0) {
|
|
15001
15001
|
const scriptMap = await this.getScriptMap();
|
|
15002
15002
|
const allExtended = [];
|
|
15003
|
-
const fetchedVtxos = await
|
|
15003
|
+
const fetchedVtxos = await chunkFZFSGOTZ_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
15004
15004
|
...scriptMap.keys()
|
|
15005
15005
|
]);
|
|
15006
15006
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -15114,11 +15114,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15114
15114
|
* against the current key alone would leave it pending forever.
|
|
15115
15115
|
*/
|
|
15116
15116
|
checkpointUnrollCandidates(info) {
|
|
15117
|
-
const current =
|
|
15117
|
+
const current = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
15118
15118
|
const candidates = [this._serverUnrollScript, current];
|
|
15119
15119
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
15120
15120
|
candidates.push(
|
|
15121
|
-
|
|
15121
|
+
chunkFZFSGOTZ_cjs.CSVMultisigTapscript.encode({
|
|
15122
15122
|
...current.params,
|
|
15123
15123
|
pubkeys: [base.hex.decode(deprecated)]
|
|
15124
15124
|
})
|
|
@@ -15209,7 +15209,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15209
15209
|
if (vtxos.length === 0) {
|
|
15210
15210
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
15211
15211
|
}
|
|
15212
|
-
const myPkScript =
|
|
15212
|
+
const myPkScript = chunkFZFSGOTZ_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
15213
15213
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
15214
15214
|
let swept = 0;
|
|
15215
15215
|
const drainable = vtxos.filter((vtxo) => !isSubdust(vtxo, this.dustAmount));
|
|
@@ -15283,7 +15283,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15283
15283
|
const spendable = [];
|
|
15284
15284
|
const unclaimed = [];
|
|
15285
15285
|
for (const vtxo of vtxos) {
|
|
15286
|
-
if (
|
|
15286
|
+
if (chunkFZFSGOTZ_cjs.hasTerminalSpend(vtxo)) {
|
|
15287
15287
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
15288
15288
|
} else if (isSubdust(vtxo, this.dustAmount)) {
|
|
15289
15289
|
unclaimed.push(cashReport(vtxo, "subdust"));
|
|
@@ -15303,7 +15303,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15303
15303
|
const all = [];
|
|
15304
15304
|
const seen = /* @__PURE__ */ new Set();
|
|
15305
15305
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
15306
|
-
const { vtxos, page } = await
|
|
15306
|
+
const { vtxos, page } = await chunkFZFSGOTZ_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
15307
15307
|
scripts,
|
|
15308
15308
|
pageIndex,
|
|
15309
15309
|
pageSize
|
|
@@ -15350,7 +15350,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15350
15350
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
15351
15351
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
15352
15352
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
15353
|
-
const proof =
|
|
15353
|
+
const proof = chunkFZFSGOTZ_cjs.Intent.create(message, batch, []);
|
|
15354
15354
|
const signedProof = await identity.sign(
|
|
15355
15355
|
proof,
|
|
15356
15356
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -15569,7 +15569,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15569
15569
|
script: recipient.script,
|
|
15570
15570
|
amount: BigInt(recipient.amount),
|
|
15571
15571
|
// Already checked against the recipient address in `validateRecipients`.
|
|
15572
|
-
...recipient.tapTree ? { tapTree:
|
|
15572
|
+
...recipient.tapTree ? { tapTree: chunkFZFSGOTZ_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
|
|
15573
15573
|
}));
|
|
15574
15574
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
15575
15575
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -15713,10 +15713,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15713
15713
|
const serverPubKey = this.arkServerPublicKey;
|
|
15714
15714
|
const serverUnrollScript = this.serverUnrollScript;
|
|
15715
15715
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
15716
|
-
const normalizedInputs = inputs.map(
|
|
15717
|
-
const at = now ?? await
|
|
15716
|
+
const normalizedInputs = inputs.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
15717
|
+
const at = now ?? await chunkFZFSGOTZ_cjs.resolveTimeHeight(this.onchainProvider);
|
|
15718
15718
|
for (const input of normalizedInputs) {
|
|
15719
|
-
if (!
|
|
15719
|
+
if (!chunkFZFSGOTZ_cjs.canSpendOffchain(input, at)) {
|
|
15720
15720
|
throw new Error(
|
|
15721
15721
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
15722
15722
|
);
|
|
@@ -15786,7 +15786,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15786
15786
|
);
|
|
15787
15787
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
15788
15788
|
index,
|
|
15789
|
-
lookupScript:
|
|
15789
|
+
lookupScript: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15790
15790
|
}));
|
|
15791
15791
|
const identity = this.identity;
|
|
15792
15792
|
const signer = {
|
|
@@ -15872,14 +15872,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15872
15872
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
15873
15873
|
spentVtxos.push({
|
|
15874
15874
|
...spentFacts,
|
|
15875
|
-
virtualStatus:
|
|
15875
|
+
virtualStatus: chunkFZFSGOTZ_cjs.toVirtualStatus(spentFacts),
|
|
15876
15876
|
...spentBy ? { spentBy } : {},
|
|
15877
15877
|
arkTxId: arkTxid
|
|
15878
15878
|
});
|
|
15879
15879
|
for (const id of vtxo.commitmentTxIds) {
|
|
15880
15880
|
commitmentTxIds.add(id);
|
|
15881
15881
|
}
|
|
15882
|
-
const vtxoExpiry =
|
|
15882
|
+
const vtxoExpiry = chunkFZFSGOTZ_cjs.toBatchExpiry(vtxo);
|
|
15883
15883
|
if (vtxoExpiry) {
|
|
15884
15884
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
15885
15885
|
}
|
|
@@ -15892,7 +15892,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15892
15892
|
isSwept: false,
|
|
15893
15893
|
isPreconfirmed: true,
|
|
15894
15894
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
15895
|
-
...
|
|
15895
|
+
...chunkFZFSGOTZ_cjs.parseLegacyExpiry(batchExpiry)
|
|
15896
15896
|
};
|
|
15897
15897
|
changeVtxo = {
|
|
15898
15898
|
txid: arkTxid,
|
|
@@ -15904,7 +15904,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15904
15904
|
tapTree: offchainTapscript.encode(),
|
|
15905
15905
|
value: Number(changeAmount),
|
|
15906
15906
|
...changeFacts,
|
|
15907
|
-
virtualStatus:
|
|
15907
|
+
virtualStatus: chunkFZFSGOTZ_cjs.toVirtualStatus(changeFacts),
|
|
15908
15908
|
spentBy: "",
|
|
15909
15909
|
status: {
|
|
15910
15910
|
confirmed: false
|
|
@@ -15973,12 +15973,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15973
15973
|
const spentVtxos = [];
|
|
15974
15974
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
15975
15975
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
15976
|
-
const vtxoInputs = inputs.filter(
|
|
15976
|
+
const vtxoInputs = inputs.filter(chunkFZFSGOTZ_cjs.isVirtualCoin);
|
|
15977
15977
|
const cm = await this.getContractManager();
|
|
15978
15978
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
15979
15979
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
15980
15980
|
for (const input of inputs) {
|
|
15981
|
-
if (
|
|
15981
|
+
if (chunkFZFSGOTZ_cjs.isVirtualCoin(input)) {
|
|
15982
15982
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
15983
15983
|
const vtxo = annotatedByKey.get(outpoint);
|
|
15984
15984
|
if (!vtxo) {
|
|
@@ -15990,13 +15990,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15990
15990
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
15991
15991
|
spentVtxos.push({
|
|
15992
15992
|
...settledFacts,
|
|
15993
|
-
virtualStatus:
|
|
15993
|
+
virtualStatus: chunkFZFSGOTZ_cjs.toVirtualStatus(settledFacts),
|
|
15994
15994
|
settledBy: commitmentTxid
|
|
15995
15995
|
});
|
|
15996
15996
|
} else {
|
|
15997
15997
|
let sourceAddress;
|
|
15998
15998
|
try {
|
|
15999
|
-
sourceAddress =
|
|
15999
|
+
sourceAddress = chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
16000
16000
|
this.network
|
|
16001
16001
|
);
|
|
16002
16002
|
} catch {
|
|
@@ -16054,9 +16054,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16054
16054
|
}
|
|
16055
16055
|
};
|
|
16056
16056
|
function selectVirtualCoins(coins, targetAmount) {
|
|
16057
|
-
const sortedCoins = coins.map(
|
|
16058
|
-
const expiryA =
|
|
16059
|
-
const expiryB =
|
|
16057
|
+
const sortedCoins = coins.map(chunkFZFSGOTZ_cjs.normalizeVtxo).sort((a, b) => {
|
|
16058
|
+
const expiryA = chunkFZFSGOTZ_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
16059
|
+
const expiryB = chunkFZFSGOTZ_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
16060
16060
|
if (expiryA !== expiryB) {
|
|
16061
16061
|
return expiryA - expiryB;
|
|
16062
16062
|
}
|
|
@@ -16316,7 +16316,7 @@ var MessageBus = class {
|
|
|
16316
16316
|
this.initialized = true;
|
|
16317
16317
|
}
|
|
16318
16318
|
async buildServices(config) {
|
|
16319
|
-
const arkProvider = new
|
|
16319
|
+
const arkProvider = new chunkFZFSGOTZ_cjs.RestArkProvider(config.arkServer.url);
|
|
16320
16320
|
const storage = {
|
|
16321
16321
|
walletRepository: this.walletRepository,
|
|
16322
16322
|
contractRepository: this.contractRepository,
|
|
@@ -16658,7 +16658,7 @@ var offboardNetworkNames = [
|
|
|
16658
16658
|
function offboardDestinationScript(destinationAddress) {
|
|
16659
16659
|
for (const networkName of offboardNetworkNames) {
|
|
16660
16660
|
try {
|
|
16661
|
-
const network =
|
|
16661
|
+
const network = chunkFZFSGOTZ_cjs.networks[networkName];
|
|
16662
16662
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
16663
16663
|
return btcSigner.OutScript.encode(addr);
|
|
16664
16664
|
} catch {
|
|
@@ -16722,7 +16722,7 @@ var Ramps = class {
|
|
|
16722
16722
|
}
|
|
16723
16723
|
amount = amount ?? totalAmount;
|
|
16724
16724
|
const offchainAddress = await this.wallet.getAddress();
|
|
16725
|
-
const offchainAddr =
|
|
16725
|
+
const offchainAddr = chunkFZFSGOTZ_cjs.ArkAddress.decode(offchainAddress);
|
|
16726
16726
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
16727
16727
|
const outputFee = estimator.evalOffchainOutput({
|
|
16728
16728
|
amount,
|
|
@@ -16782,7 +16782,7 @@ var Ramps = class {
|
|
|
16782
16782
|
const filteredVtxos = [];
|
|
16783
16783
|
let totalAmount = 0n;
|
|
16784
16784
|
for (const vtxo of vtxos) {
|
|
16785
|
-
const inputFee = estimator.evalOffchainInput(
|
|
16785
|
+
const inputFee = estimator.evalOffchainInput(chunkFZFSGOTZ_cjs.toOffchainInputFeeParams(vtxo));
|
|
16786
16786
|
if (inputFee.satoshis >= vtxo.value) {
|
|
16787
16787
|
continue;
|
|
16788
16788
|
}
|
|
@@ -17549,7 +17549,7 @@ var WalletMessageHandler = class {
|
|
|
17549
17549
|
// Wallet methods
|
|
17550
17550
|
async handleInitWallet({ payload }) {
|
|
17551
17551
|
const { arkServerUrl } = payload;
|
|
17552
|
-
this.indexerProvider = new
|
|
17552
|
+
this.indexerProvider = new chunkRXITDAV4_cjs.RestIndexerProvider(arkServerUrl);
|
|
17553
17553
|
await this.onWalletInitialized();
|
|
17554
17554
|
}
|
|
17555
17555
|
/**
|
|
@@ -17816,17 +17816,17 @@ var WalletMessageHandler = class {
|
|
|
17816
17816
|
throw new WalletNotInitializedError();
|
|
17817
17817
|
}
|
|
17818
17818
|
const allVtxos = await this.getVtxosFromRepo();
|
|
17819
|
-
const vtxos = allVtxos.filter((v) => !
|
|
17819
|
+
const vtxos = allVtxos.filter((v) => !chunkFZFSGOTZ_cjs.hasTerminalSpend(v));
|
|
17820
17820
|
const dustAmount = this.readonlyWallet.dustAmount;
|
|
17821
17821
|
const includeRecoverable = message.payload.filter?.withRecoverable ?? false;
|
|
17822
17822
|
const filteredVtxos = includeRecoverable ? vtxos : vtxos.filter((v) => {
|
|
17823
17823
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
17824
17824
|
return false;
|
|
17825
17825
|
}
|
|
17826
|
-
if (
|
|
17826
|
+
if (chunkFZFSGOTZ_cjs.isRecoverable(v)) {
|
|
17827
17827
|
return false;
|
|
17828
17828
|
}
|
|
17829
|
-
if (
|
|
17829
|
+
if (chunkFZFSGOTZ_cjs.isExpired(v)) {
|
|
17830
17830
|
return false;
|
|
17831
17831
|
}
|
|
17832
17832
|
return true;
|
|
@@ -17834,7 +17834,7 @@ var WalletMessageHandler = class {
|
|
|
17834
17834
|
if (!message.payload.filter?.withUnrolled) {
|
|
17835
17835
|
return filteredVtxos;
|
|
17836
17836
|
}
|
|
17837
|
-
return filteredVtxos.concat(allVtxos.filter((v) =>
|
|
17837
|
+
return filteredVtxos.concat(allVtxos.filter((v) => chunkFZFSGOTZ_cjs.hasTerminalSpend(v) && v.isUnrolled));
|
|
17838
17838
|
}
|
|
17839
17839
|
/** Tear down handler subscriptions, then delegate the full wipe to the wallet. */
|
|
17840
17840
|
async clear() {
|
|
@@ -17924,7 +17924,7 @@ var WalletMessageHandler = class {
|
|
|
17924
17924
|
if (!this.readonlyWallet) return null;
|
|
17925
17925
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
17926
17926
|
const indexerProvider = this.indexerProvider;
|
|
17927
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
17927
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkFZFSGOTZ_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
17928
17928
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
17929
17929
|
}
|
|
17930
17930
|
async ensureContractEventBroadcasting() {
|
|
@@ -18613,7 +18613,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18613
18613
|
};
|
|
18614
18614
|
try {
|
|
18615
18615
|
const response = await this.sendMessage(message);
|
|
18616
|
-
return response.payload.vtxos.map(
|
|
18616
|
+
return response.payload.vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
18617
18617
|
} catch (error) {
|
|
18618
18618
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
18619
18619
|
}
|
|
@@ -18638,7 +18638,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18638
18638
|
};
|
|
18639
18639
|
try {
|
|
18640
18640
|
const response = await this.sendMessage(message);
|
|
18641
|
-
return response.payload.vtxos.map(
|
|
18641
|
+
return response.payload.vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
18642
18642
|
} catch (error) {
|
|
18643
18643
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
18644
18644
|
}
|
|
@@ -18769,7 +18769,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18769
18769
|
};
|
|
18770
18770
|
try {
|
|
18771
18771
|
const response = await sendContractMessage(message);
|
|
18772
|
-
return response.payload.vtxos.map(
|
|
18772
|
+
return response.payload.vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
18773
18773
|
} catch (e) {
|
|
18774
18774
|
throw new Error("Failed to annotate vtxos");
|
|
18775
18775
|
}
|
|
@@ -19341,7 +19341,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
19341
19341
|
};
|
|
19342
19342
|
try {
|
|
19343
19343
|
const response = await wallet.sendMessage(message);
|
|
19344
|
-
return response.payload.vtxos.map(
|
|
19344
|
+
return response.payload.vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
19345
19345
|
} catch (e) {
|
|
19346
19346
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
19347
19347
|
}
|
|
@@ -19453,12 +19453,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
19453
19453
|
* @returns Configured onchain wallet
|
|
19454
19454
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
19455
19455
|
*/
|
|
19456
|
-
static async create(identity, networkName =
|
|
19456
|
+
static async create(identity, networkName = chunkFZFSGOTZ_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
19457
19457
|
const pubkey = await identity.xOnlyPublicKey();
|
|
19458
19458
|
if (!pubkey) {
|
|
19459
19459
|
throw new Error("Invalid configured public key");
|
|
19460
19460
|
}
|
|
19461
|
-
const network =
|
|
19461
|
+
const network = chunkFZFSGOTZ_cjs.getNetwork(networkName);
|
|
19462
19462
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
19463
19463
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
19464
19464
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -19564,7 +19564,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
19564
19564
|
if (!inputs) {
|
|
19565
19565
|
throw new Error("Fee estimation failed");
|
|
19566
19566
|
}
|
|
19567
|
-
let tx = new
|
|
19567
|
+
let tx = new chunkFZFSGOTZ_cjs.Transaction();
|
|
19568
19568
|
for (const input of inputs) {
|
|
19569
19569
|
tx.addInput({
|
|
19570
19570
|
txid: input.txid,
|
|
@@ -19622,7 +19622,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
19622
19622
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
19623
19623
|
*/
|
|
19624
19624
|
async bumpAnchor(parentHex, feeRate) {
|
|
19625
|
-
const parent =
|
|
19625
|
+
const parent = chunkFZFSGOTZ_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
19626
19626
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
19627
19627
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
19628
19628
|
return [parent.hex, child.hex];
|
|
@@ -20387,7 +20387,7 @@ exports.BIP322 = void 0;
|
|
|
20387
20387
|
async function sign2(message, identity, network) {
|
|
20388
20388
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
20389
20389
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
20390
|
-
const toSpend =
|
|
20390
|
+
const toSpend = chunkFZFSGOTZ_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
20391
20391
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
20392
20392
|
const signed = await identity.sign(toSign, [0]);
|
|
20393
20393
|
signed.finalizeIdx(0);
|
|
@@ -20445,7 +20445,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
20445
20445
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
20446
20446
|
return false;
|
|
20447
20447
|
}
|
|
20448
|
-
const toSpend =
|
|
20448
|
+
const toSpend = chunkFZFSGOTZ_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
20449
20449
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
20450
20450
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
20451
20451
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -20466,7 +20466,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
20466
20466
|
}
|
|
20467
20467
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
20468
20468
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
20469
|
-
const toSpend =
|
|
20469
|
+
const toSpend = chunkFZFSGOTZ_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
20470
20470
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
20471
20471
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
20472
20472
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -20519,7 +20519,7 @@ function encodeCompactSize(n) {
|
|
|
20519
20519
|
return buf;
|
|
20520
20520
|
}
|
|
20521
20521
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
20522
|
-
const tx = new
|
|
20522
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({ version: 0 });
|
|
20523
20523
|
tx.addInput({
|
|
20524
20524
|
txid: toSpend.id,
|
|
20525
20525
|
index: 0,
|
|
@@ -20533,12 +20533,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
20533
20533
|
});
|
|
20534
20534
|
tx.addOutput({
|
|
20535
20535
|
amount: 0n,
|
|
20536
|
-
script:
|
|
20536
|
+
script: chunkFZFSGOTZ_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
20537
20537
|
});
|
|
20538
20538
|
return tx;
|
|
20539
20539
|
}
|
|
20540
20540
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
20541
|
-
const tx = new
|
|
20541
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({ version: 0 });
|
|
20542
20542
|
tx.addInput({
|
|
20543
20543
|
txid: toSpend.id,
|
|
20544
20544
|
index: 0,
|
|
@@ -20550,7 +20550,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
20550
20550
|
});
|
|
20551
20551
|
tx.addOutput({
|
|
20552
20552
|
amount: 0n,
|
|
20553
|
-
script:
|
|
20553
|
+
script: chunkFZFSGOTZ_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
20554
20554
|
});
|
|
20555
20555
|
return tx;
|
|
20556
20556
|
}
|
|
@@ -20681,7 +20681,7 @@ var RestEmulatorProvider = class {
|
|
|
20681
20681
|
}
|
|
20682
20682
|
};
|
|
20683
20683
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
20684
|
-
const tx =
|
|
20684
|
+
const tx = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
20685
20685
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
20686
20686
|
const input = tx.getInput(0);
|
|
20687
20687
|
if (!input) {
|
|
@@ -20708,14 +20708,14 @@ var ExitPathError = class extends Error {
|
|
|
20708
20708
|
reason;
|
|
20709
20709
|
};
|
|
20710
20710
|
function delayWeight(sequence) {
|
|
20711
|
-
const t =
|
|
20711
|
+
const t = chunkFZFSGOTZ_cjs.sequenceToTimelock(sequence);
|
|
20712
20712
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
20713
20713
|
}
|
|
20714
20714
|
async function resolveUnilateralPath(params) {
|
|
20715
20715
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
20716
20716
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
20717
20717
|
if (contract) {
|
|
20718
|
-
const handler =
|
|
20718
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
20719
20719
|
if (!handler) {
|
|
20720
20720
|
throw new ExitPathError(
|
|
20721
20721
|
"no-handler",
|
|
@@ -20738,12 +20738,12 @@ async function resolveUnilateralPath(params) {
|
|
|
20738
20738
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
20739
20739
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
20740
20740
|
}
|
|
20741
|
-
const decoded =
|
|
20741
|
+
const decoded = chunkFZFSGOTZ_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
20742
20742
|
let best;
|
|
20743
20743
|
for (const exit of decoded.exitPaths()) {
|
|
20744
20744
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
20745
20745
|
if (!leaf) continue;
|
|
20746
|
-
const sequence =
|
|
20746
|
+
const sequence = chunkFZFSGOTZ_cjs.timelockToSequence(exit.params.timelock);
|
|
20747
20747
|
const weight = delayWeight(sequence);
|
|
20748
20748
|
if (!best || weight < best.weight) {
|
|
20749
20749
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -20929,14 +20929,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20929
20929
|
}
|
|
20930
20930
|
const resolved = await resolveUnilateralPath({
|
|
20931
20931
|
vtxo,
|
|
20932
|
-
scriptHex: base.hex.encode(
|
|
20932
|
+
scriptHex: base.hex.encode(chunkFZFSGOTZ_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
20933
20933
|
contractRepository: wallet.contractRepository,
|
|
20934
20934
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
20935
20935
|
currentTime: Date.now()
|
|
20936
20936
|
});
|
|
20937
20937
|
const spendingLeaf = resolved.selection.leaf;
|
|
20938
20938
|
const sequence = resolved.selection.sequence;
|
|
20939
|
-
const timelock =
|
|
20939
|
+
const timelock = chunkFZFSGOTZ_cjs.sequenceToTimelock(sequence);
|
|
20940
20940
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
20941
20941
|
if (!elapsed) {
|
|
20942
20942
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -20949,7 +20949,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20949
20949
|
sequence,
|
|
20950
20950
|
witnessUtxo: {
|
|
20951
20951
|
amount: BigInt(vtxo.value),
|
|
20952
|
-
script:
|
|
20952
|
+
script: chunkFZFSGOTZ_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
20953
20953
|
},
|
|
20954
20954
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
20955
20955
|
});
|
|
@@ -20959,7 +20959,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20959
20959
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
20960
20960
|
);
|
|
20961
20961
|
}
|
|
20962
|
-
const tx = new
|
|
20962
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({ version: 2 });
|
|
20963
20963
|
for (const input of inputs) {
|
|
20964
20964
|
tx.addInput(input);
|
|
20965
20965
|
}
|
|
@@ -21026,7 +21026,7 @@ async function buildSignedSweep(params) {
|
|
|
21026
21026
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
21027
21027
|
);
|
|
21028
21028
|
}
|
|
21029
|
-
const tx = new
|
|
21029
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({ version: 2 });
|
|
21030
21030
|
tx.addInput({
|
|
21031
21031
|
txid: vtxo.txid,
|
|
21032
21032
|
index: vtxo.vout,
|
|
@@ -21051,7 +21051,7 @@ async function buildSignedSweep(params) {
|
|
|
21051
21051
|
finalScriptWitness: [
|
|
21052
21052
|
tapScriptSig[0][1],
|
|
21053
21053
|
...path.extraWitness,
|
|
21054
|
-
|
|
21054
|
+
chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(path.leaf),
|
|
21055
21055
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
21056
21056
|
]
|
|
21057
21057
|
});
|
|
@@ -21081,7 +21081,7 @@ async function resolveFeeRate(opts) {
|
|
|
21081
21081
|
}
|
|
21082
21082
|
async function selectExitVtxos(opts) {
|
|
21083
21083
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
21084
|
-
const res = await
|
|
21084
|
+
const res = await chunkFZFSGOTZ_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
21085
21085
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
21086
21086
|
const out = [];
|
|
21087
21087
|
for (const vtxo of res.vtxos) {
|
|
@@ -21096,7 +21096,7 @@ async function selectExitVtxos(opts) {
|
|
|
21096
21096
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
21097
21097
|
);
|
|
21098
21098
|
}
|
|
21099
|
-
const handler =
|
|
21099
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
21100
21100
|
if (!handler) {
|
|
21101
21101
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
21102
21102
|
}
|
|
@@ -21126,7 +21126,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
21126
21126
|
if (pendingNodes.length > 0) {
|
|
21127
21127
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
21128
21128
|
for (const psbt of txs) {
|
|
21129
|
-
psbts.set(
|
|
21129
|
+
psbts.set(chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
21130
21130
|
}
|
|
21131
21131
|
}
|
|
21132
21132
|
const childVsize = Number(
|
|
@@ -21162,7 +21162,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
21162
21162
|
try {
|
|
21163
21163
|
const resolved = await resolveUnilateralPath({
|
|
21164
21164
|
vtxo,
|
|
21165
|
-
scriptHex: base.hex.encode(
|
|
21165
|
+
scriptHex: base.hex.encode(chunkFZFSGOTZ_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
21166
21166
|
contractRepository: wallet.contractRepository,
|
|
21167
21167
|
walletPubKeyHex,
|
|
21168
21168
|
currentTime: Date.now()
|
|
@@ -21181,7 +21181,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
21181
21181
|
});
|
|
21182
21182
|
continue;
|
|
21183
21183
|
}
|
|
21184
|
-
const t =
|
|
21184
|
+
const t = chunkFZFSGOTZ_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
21185
21185
|
const delay = { type: t.type, value: Number(t.value) };
|
|
21186
21186
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
21187
21187
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -21520,7 +21520,7 @@ async function prepare(opts) {
|
|
|
21520
21520
|
txid: sweep.vtxo.txid,
|
|
21521
21521
|
vout: sweep.vtxo.vout,
|
|
21522
21522
|
value: sweep.vtxo.value,
|
|
21523
|
-
pkScript:
|
|
21523
|
+
pkScript: chunkFZFSGOTZ_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
21524
21524
|
},
|
|
21525
21525
|
path: sweep.resolved.selection,
|
|
21526
21526
|
outputAddress: opts.sweepAddress,
|
|
@@ -21605,7 +21605,7 @@ async function prepare(opts) {
|
|
|
21605
21605
|
if (newFee <= splitterFee) break;
|
|
21606
21606
|
splitterFee = newFee;
|
|
21607
21607
|
}
|
|
21608
|
-
const splitter = new
|
|
21608
|
+
const splitter = new chunkFZFSGOTZ_cjs.Transaction({ version: 2 });
|
|
21609
21609
|
for (const coin of selected.inputs) {
|
|
21610
21610
|
splitter.addInput({
|
|
21611
21611
|
txid: coin.txid,
|
|
@@ -21748,41 +21748,41 @@ var UnilateralExit = {
|
|
|
21748
21748
|
// src/arkade/index.ts
|
|
21749
21749
|
var arkade_exports = {};
|
|
21750
21750
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
21751
|
-
ARKADE_OP: () =>
|
|
21752
|
-
ARKADE_OPCODES: () =>
|
|
21753
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
21754
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
21755
|
-
ARKADE_OPS: () =>
|
|
21751
|
+
ARKADE_OP: () => chunkWXCVS6PD_cjs.ARKADE_OP,
|
|
21752
|
+
ARKADE_OPCODES: () => chunkWXCVS6PD_cjs.ARKADE_OPCODES,
|
|
21753
|
+
ARKADE_OPCODE_NAMES: () => chunkWXCVS6PD_cjs.ARKADE_OPCODE_NAMES,
|
|
21754
|
+
ARKADE_OPCODE_VALUES: () => chunkWXCVS6PD_cjs.ARKADE_OPCODE_VALUES,
|
|
21755
|
+
ARKADE_OPS: () => chunkWXCVS6PD_cjs.ARKADE_OPS,
|
|
21756
21756
|
Arkade: () => Arkade,
|
|
21757
21757
|
ArkadeContract: () => ArkadeContract,
|
|
21758
|
-
ArkadeProgramScript: () =>
|
|
21759
|
-
ArkadeScript: () =>
|
|
21758
|
+
ArkadeProgramScript: () => chunkWXCVS6PD_cjs.ArkadeProgramScript,
|
|
21759
|
+
ArkadeScript: () => chunkWXCVS6PD_cjs.ArkadeScript,
|
|
21760
21760
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
21761
|
-
BigNum: () =>
|
|
21761
|
+
BigNum: () => chunkWXCVS6PD_cjs.bignum_exports,
|
|
21762
21762
|
OP: () => btcSigner.OP,
|
|
21763
|
-
OPCODE_NAMES: () =>
|
|
21764
|
-
OPCODE_VALUES: () =>
|
|
21765
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
21763
|
+
OPCODE_NAMES: () => chunkWXCVS6PD_cjs.OPCODE_NAMES,
|
|
21764
|
+
OPCODE_VALUES: () => chunkWXCVS6PD_cjs.OPCODE_VALUES,
|
|
21765
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkWXCVS6PD_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
21766
21766
|
Script: () => btcSigner.Script,
|
|
21767
|
-
arkadeScriptHash: () =>
|
|
21768
|
-
arkadeWitnessHash: () =>
|
|
21769
|
-
asmToBytes: () =>
|
|
21770
|
-
bytesToASM: () =>
|
|
21771
|
-
computeArkadeScriptPublicKey: () =>
|
|
21767
|
+
arkadeScriptHash: () => chunkWXCVS6PD_cjs.arkadeScriptHash,
|
|
21768
|
+
arkadeWitnessHash: () => chunkWXCVS6PD_cjs.arkadeWitnessHash,
|
|
21769
|
+
asmToBytes: () => chunkWXCVS6PD_cjs.asmToBytes,
|
|
21770
|
+
bytesToASM: () => chunkWXCVS6PD_cjs.bytesToASM,
|
|
21771
|
+
computeArkadeScriptPublicKey: () => chunkWXCVS6PD_cjs.computeArkadeScriptPublicKey,
|
|
21772
21772
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
21773
|
-
deserializeArkadeContractParams: () =>
|
|
21774
|
-
fromASM: () =>
|
|
21775
|
-
getOpcodeName: () =>
|
|
21776
|
-
getOpcodeValue: () =>
|
|
21777
|
-
parseArtifact: () =>
|
|
21778
|
-
resolveAsm: () =>
|
|
21779
|
-
serializeArkadeContractParams: () =>
|
|
21780
|
-
stringifyArtifact: () =>
|
|
21781
|
-
toASM: () =>
|
|
21782
|
-
validateProgram: () =>
|
|
21783
|
-
witnessRefToBytes: () =>
|
|
21773
|
+
deserializeArkadeContractParams: () => chunkWXCVS6PD_cjs.deserializeArkadeContractParams,
|
|
21774
|
+
fromASM: () => chunkWXCVS6PD_cjs.fromASM,
|
|
21775
|
+
getOpcodeName: () => chunkWXCVS6PD_cjs.getOpcodeName,
|
|
21776
|
+
getOpcodeValue: () => chunkWXCVS6PD_cjs.getOpcodeValue,
|
|
21777
|
+
parseArtifact: () => chunkWXCVS6PD_cjs.parseArtifact,
|
|
21778
|
+
resolveAsm: () => chunkWXCVS6PD_cjs.resolveAsm,
|
|
21779
|
+
serializeArkadeContractParams: () => chunkWXCVS6PD_cjs.serializeArkadeContractParams,
|
|
21780
|
+
stringifyArtifact: () => chunkWXCVS6PD_cjs.stringifyArtifact,
|
|
21781
|
+
toASM: () => chunkWXCVS6PD_cjs.toASM,
|
|
21782
|
+
validateProgram: () => chunkWXCVS6PD_cjs.validateProgram,
|
|
21783
|
+
witnessRefToBytes: () => chunkWXCVS6PD_cjs.witnessRefToBytes
|
|
21784
21784
|
});
|
|
21785
|
-
var isVtxoCoin = (input) =>
|
|
21785
|
+
var isVtxoCoin = (input) => chunkFZFSGOTZ_cjs.isVirtualCoin(input);
|
|
21786
21786
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
21787
21787
|
let batchId;
|
|
21788
21788
|
let sweepTapTreeRoot;
|
|
@@ -21803,7 +21803,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21803
21803
|
);
|
|
21804
21804
|
await arkProvider.confirmRegistration(intentId);
|
|
21805
21805
|
batchId = event.id;
|
|
21806
|
-
const sweepTapscript =
|
|
21806
|
+
const sweepTapscript = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.encode({
|
|
21807
21807
|
timelock,
|
|
21808
21808
|
pubkeys: [base.hex.decode(info.forfeitPubkey).subarray(1)]
|
|
21809
21809
|
}).script;
|
|
@@ -21817,7 +21817,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21817
21817
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
21818
21818
|
return { skip: true };
|
|
21819
21819
|
}
|
|
21820
|
-
const commitmentTx =
|
|
21820
|
+
const commitmentTx = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
21821
21821
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
21822
21822
|
if (recipients && recipients.length > 0) {
|
|
21823
21823
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -21849,7 +21849,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21849
21849
|
if (connectorTree) {
|
|
21850
21850
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
21851
21851
|
}
|
|
21852
|
-
let commitmentPsbt =
|
|
21852
|
+
let commitmentPsbt = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
21853
21853
|
assertFinalCommitmentMatchesValidated(
|
|
21854
21854
|
commitmentPsbt,
|
|
21855
21855
|
validatedCommitmentTxid,
|
|
@@ -21884,7 +21884,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21884
21884
|
boardingIndices.push(boardingIdx);
|
|
21885
21885
|
continue;
|
|
21886
21886
|
}
|
|
21887
|
-
if (
|
|
21887
|
+
if (chunkFZFSGOTZ_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
21888
21888
|
continue;
|
|
21889
21889
|
}
|
|
21890
21890
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -21905,7 +21905,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21905
21905
|
index: input.vout,
|
|
21906
21906
|
witnessUtxo: {
|
|
21907
21907
|
amount: BigInt(input.value),
|
|
21908
|
-
script:
|
|
21908
|
+
script: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
21909
21909
|
},
|
|
21910
21910
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
21911
21911
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -21997,11 +21997,11 @@ var Arkade = class _Arkade {
|
|
|
21997
21997
|
static async connect(opts) {
|
|
21998
21998
|
const info = await opts.arkade.getInfo();
|
|
21999
21999
|
const serverKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
22000
|
-
const checkpoint =
|
|
22001
|
-
const network = opts.network ??
|
|
22000
|
+
const checkpoint = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
22001
|
+
const network = opts.network ?? chunkFZFSGOTZ_cjs.DEFAULT_NETWORK;
|
|
22002
22002
|
let emulatorKey;
|
|
22003
22003
|
if (opts.emulator) {
|
|
22004
|
-
emulatorKey = base.hex.decode(
|
|
22004
|
+
emulatorKey = base.hex.decode(chunkFZFSGOTZ_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
22005
22005
|
}
|
|
22006
22006
|
let userKey;
|
|
22007
22007
|
if (opts.identity) {
|
|
@@ -22032,7 +22032,7 @@ var Arkade = class _Arkade {
|
|
|
22032
22032
|
* key respectively; explicit args always win.
|
|
22033
22033
|
*/
|
|
22034
22034
|
contract(program, args = {}) {
|
|
22035
|
-
const declared = (program.params ?? []).map(
|
|
22035
|
+
const declared = (program.params ?? []).map(chunkWXCVS6PD_cjs.inputName);
|
|
22036
22036
|
if (declared.includes("server") && args.server === void 0) {
|
|
22037
22037
|
args = { ...args, server: this.serverKey };
|
|
22038
22038
|
}
|
|
@@ -22052,7 +22052,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22052
22052
|
userKey: client.userKey,
|
|
22053
22053
|
emulatorKey: client.emulatorKey
|
|
22054
22054
|
};
|
|
22055
|
-
this.vtxoScript = new
|
|
22055
|
+
this.vtxoScript = new chunkWXCVS6PD_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
22056
22056
|
this.tapTree = this.vtxoScript.encode();
|
|
22057
22057
|
this.compiled = this.vtxoScript.compiled;
|
|
22058
22058
|
}
|
|
@@ -22080,7 +22080,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22080
22080
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
22081
22081
|
);
|
|
22082
22082
|
}
|
|
22083
|
-
const typed =
|
|
22083
|
+
const typed = chunkWXCVS6PD_cjs.deserializeArkadeContractParams(contract.params);
|
|
22084
22084
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
22085
22085
|
serverKey: typed.serverKey,
|
|
22086
22086
|
userKey: typed.userKey,
|
|
@@ -22121,7 +22121,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22121
22121
|
toContractParams() {
|
|
22122
22122
|
return {
|
|
22123
22123
|
type: "arkade",
|
|
22124
|
-
params:
|
|
22124
|
+
params: chunkWXCVS6PD_cjs.serializeArkadeContractParams({
|
|
22125
22125
|
program: this.program,
|
|
22126
22126
|
args: this.args,
|
|
22127
22127
|
serverKey: this.keys.serverKey,
|
|
@@ -22166,13 +22166,13 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22166
22166
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
22167
22167
|
if (registered) {
|
|
22168
22168
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
22169
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
22169
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkFZFSGOTZ_cjs.hasTerminalSpend(v));
|
|
22170
22170
|
}
|
|
22171
22171
|
}
|
|
22172
22172
|
if (!this.client.indexer) {
|
|
22173
22173
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
22174
22174
|
}
|
|
22175
|
-
const { vtxos } = await
|
|
22175
|
+
const { vtxos } = await chunkFZFSGOTZ_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
22176
22176
|
scripts: [scriptHex],
|
|
22177
22177
|
spendableOnly: true
|
|
22178
22178
|
});
|
|
@@ -22274,12 +22274,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
22274
22274
|
this.contract.client.checkpoint
|
|
22275
22275
|
);
|
|
22276
22276
|
if (coin.sourceTx) {
|
|
22277
|
-
|
|
22277
|
+
chunkFZFSGOTZ_cjs.setArkPsbtField(arkTx, 0, chunkFZFSGOTZ_cjs.PrevArkTxField, coin.sourceTx);
|
|
22278
22278
|
}
|
|
22279
22279
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
22280
22280
|
if (condition.length > 0) {
|
|
22281
|
-
|
|
22282
|
-
|
|
22281
|
+
chunkFZFSGOTZ_cjs.setArkPsbtField(arkTx, 0, chunkFZFSGOTZ_cjs.ConditionWitness, condition);
|
|
22282
|
+
chunkFZFSGOTZ_cjs.setArkPsbtField(checkpoints[0], 0, chunkFZFSGOTZ_cjs.ConditionWitness, condition);
|
|
22283
22283
|
}
|
|
22284
22284
|
const packets = [];
|
|
22285
22285
|
if (this.assetSpecs.length > 0) {
|
|
@@ -22318,7 +22318,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
22318
22318
|
base.base64.encode(signedArk2.toPSBT()),
|
|
22319
22319
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
22320
22320
|
);
|
|
22321
|
-
const txid =
|
|
22321
|
+
const txid = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
22322
22322
|
return {
|
|
22323
22323
|
txid,
|
|
22324
22324
|
signedArkTx: res2.signedArkTx,
|
|
@@ -22377,23 +22377,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
22377
22377
|
}
|
|
22378
22378
|
buildAssetPacket() {
|
|
22379
22379
|
const groups = this.assetSpecs.map((s) => {
|
|
22380
|
-
const id = typeof s.assetId === "string" ?
|
|
22381
|
-
return
|
|
22380
|
+
const id = typeof s.assetId === "string" ? chunkRXITDAV4_cjs.AssetId.fromString(s.assetId) : chunkRXITDAV4_cjs.AssetId.fromBytes(s.assetId);
|
|
22381
|
+
return chunkRXITDAV4_cjs.AssetGroup.create(
|
|
22382
22382
|
id,
|
|
22383
22383
|
null,
|
|
22384
|
-
s.inputs.map((i) =>
|
|
22385
|
-
s.outputs.map((o) =>
|
|
22386
|
-
(s.metadata ?? []).map((m) =>
|
|
22384
|
+
s.inputs.map((i) => chunkRXITDAV4_cjs.AssetInput.create(i.vin, i.amount)),
|
|
22385
|
+
s.outputs.map((o) => chunkRXITDAV4_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
22386
|
+
(s.metadata ?? []).map((m) => chunkRXITDAV4_cjs.Metadata.create(m.key, m.value))
|
|
22387
22387
|
);
|
|
22388
22388
|
});
|
|
22389
|
-
return
|
|
22389
|
+
return chunkRXITDAV4_cjs.Packet.create(groups);
|
|
22390
22390
|
}
|
|
22391
22391
|
witnessBytes(ref) {
|
|
22392
|
-
return
|
|
22392
|
+
return chunkWXCVS6PD_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
22393
22393
|
}
|
|
22394
22394
|
};
|
|
22395
22395
|
function bindInputs(fn, callArgs) {
|
|
22396
|
-
const names = (fn.def.inputs ?? []).map(
|
|
22396
|
+
const names = (fn.def.inputs ?? []).map(chunkWXCVS6PD_cjs.inputName);
|
|
22397
22397
|
if (callArgs.length !== names.length) {
|
|
22398
22398
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
22399
22399
|
}
|
|
@@ -22979,5 +22979,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
22979
22979
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
22980
22980
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
22981
22981
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
22982
|
-
//# sourceMappingURL=chunk-
|
|
22983
|
-
//# sourceMappingURL=chunk-
|
|
22982
|
+
//# sourceMappingURL=chunk-LPEE2H2M.cjs.map
|
|
22983
|
+
//# sourceMappingURL=chunk-LPEE2H2M.cjs.map
|