@arkade-os/sdk 0.4.68 → 0.5.0-rc.0
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/README.md +35 -5
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{asyncStorageTaskQueue-DaZlVTbM.d.ts → asyncStorageTaskQueue-BCzN3Y45.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-B2CcXIHU.d.cts → asyncStorageTaskQueue-CdF_ELX8.d.cts} +1 -1
- package/dist/{chunk-WCJVKFAP.cjs → chunk-5MJHZHG7.cjs} +726 -468
- package/dist/chunk-5MJHZHG7.cjs.map +1 -0
- package/dist/{chunk-EJOFL5WH.cjs → chunk-6AFUNKK7.cjs} +19 -7
- package/dist/chunk-6AFUNKK7.cjs.map +1 -0
- package/dist/{chunk-VBHXBI7F.js → chunk-6F2Q32KA.js} +298 -41
- package/dist/chunk-6F2Q32KA.js.map +1 -0
- package/dist/{chunk-GQ4NMQGR.js → chunk-ABJPM4JF.js} +4 -4
- package/dist/{chunk-GQ4NMQGR.js.map → chunk-ABJPM4JF.js.map} +1 -1
- package/dist/{chunk-PJR63FTK.cjs → chunk-CZ32XADN.cjs} +17 -17
- package/dist/{chunk-PJR63FTK.cjs.map → chunk-CZ32XADN.cjs.map} +1 -1
- package/dist/{chunk-33Q2RFET.js → chunk-FVTJJQNM.js} +3 -3
- package/dist/{chunk-33Q2RFET.js.map → chunk-FVTJJQNM.js.map} +1 -1
- package/dist/{chunk-6YUACVX4.cjs → chunk-HL7EC2Z5.cjs} +52 -53
- package/dist/chunk-HL7EC2Z5.cjs.map +1 -0
- package/dist/{chunk-G4I6PU5H.js → chunk-JYP7YXT2.js} +4 -4
- package/dist/{chunk-G4I6PU5H.js.map → chunk-JYP7YXT2.js.map} +1 -1
- package/dist/{chunk-45FKMOJH.js → chunk-KTU44AEH.js} +6 -7
- package/dist/chunk-KTU44AEH.js.map +1 -0
- package/dist/{chunk-4KCVS4ZN.cjs → chunk-PB5KJI4U.cjs} +10 -10
- package/dist/{chunk-4KCVS4ZN.cjs.map → chunk-PB5KJI4U.cjs.map} +1 -1
- package/dist/{chunk-4CMXV5SF.js → chunk-PPG6W34P.js} +18 -8
- package/dist/chunk-PPG6W34P.js.map +1 -0
- package/dist/{chunk-JGMSZIE4.cjs → chunk-RXWKCEZP.cjs} +17 -17
- package/dist/{chunk-JGMSZIE4.cjs.map → chunk-RXWKCEZP.cjs.map} +1 -1
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-Bffc5f54.d.cts → delegate-DLIOBQ5x.d.cts} +1 -1
- package/dist/{delegate-AomVWxO_.d.ts → delegate-Dyn5L80J.d.ts} +1 -1
- package/dist/{hdWalletCapable-B5nRs3RH.d.cts → hdWalletCapable-D9tooZ6F.d.ts} +102 -27
- package/dist/{hdWalletCapable-DZdIVa23.d.ts → hdWalletCapable-Dt3MUiGE.d.cts} +102 -27
- package/dist/{index-jouvy8FD.d.ts → index-D3hmsuKs.d.cts} +6 -6
- package/dist/{index-nfyQM33h.d.cts → index-D9tXd-tN.d.ts} +6 -6
- package/dist/{index-C7RZCfoY.d.cts → index-Udm5V2xW.d.cts} +168 -19
- package/dist/{index-C7RZCfoY.d.ts → index-Udm5V2xW.d.ts} +168 -19
- package/dist/index.cjs +306 -290
- package/dist/index.d.cts +121 -29
- package/dist/index.d.ts +121 -29
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +18 -18
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-D2vnpPBT.d.cts → taskRunner-DxZciNaa.d.cts} +1 -1
- package/dist/{taskRunner-DuwK9t8O.d.ts → taskRunner-ZdS16Ypm.d.ts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +23 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +7 -4
- package/dist/wallet/expo/index.d.ts +7 -4
- package/dist/wallet/expo/index.js +14 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +3 -2
- package/dist/chunk-45FKMOJH.js.map +0 -1
- package/dist/chunk-4CMXV5SF.js.map +0 -1
- package/dist/chunk-6YUACVX4.cjs.map +0 -1
- package/dist/chunk-EJOFL5WH.cjs.map +0 -1
- package/dist/chunk-VBHXBI7F.js.map +0 -1
- package/dist/chunk-WCJVKFAP.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkCZ32XADN_cjs = require('./chunk-CZ32XADN.cjs');
|
|
4
|
+
var chunkHL7EC2Z5_cjs = require('./chunk-HL7EC2Z5.cjs');
|
|
5
|
+
var chunk6AFUNKK7_cjs = require('./chunk-6AFUNKK7.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 = chunk6AFUNKK7_cjs.getArkPsbtFields(tx.root, 0, chunk6AFUNKK7_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 = chunk6AFUNKK7_cjs.getArkPsbtFields(g.root, 0, chunk6AFUNKK7_cjs.CosignerPublicKey).map((c) => c.key);
|
|
244
244
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
245
245
|
taprootTweak: this.scriptRoot
|
|
246
246
|
});
|
|
@@ -323,7 +323,7 @@ var SingleKey = class _SingleKey {
|
|
|
323
323
|
async sign(tx, inputIndexes) {
|
|
324
324
|
const txCpy = tx.clone();
|
|
325
325
|
if (!inputIndexes) {
|
|
326
|
-
|
|
326
|
+
chunk6AFUNKK7_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
|
|
327
327
|
try {
|
|
328
328
|
if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
|
|
329
329
|
throw new Error("Failed to sign transaction");
|
|
@@ -432,7 +432,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
432
432
|
let network;
|
|
433
433
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
434
434
|
descriptor = opts.descriptor;
|
|
435
|
-
network =
|
|
435
|
+
network = chunkHL7EC2Z5_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
436
436
|
} else {
|
|
437
437
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
438
438
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -530,7 +530,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
530
530
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
531
531
|
*/
|
|
532
532
|
isOurs(descriptor) {
|
|
533
|
-
return
|
|
533
|
+
return chunkHL7EC2Z5_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
534
534
|
}
|
|
535
535
|
/**
|
|
536
536
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -579,7 +579,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
579
579
|
}
|
|
580
580
|
// ── internal helpers ─────────────────────────────────────────────
|
|
581
581
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
582
|
-
const network =
|
|
582
|
+
const network = chunkHL7EC2Z5_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
583
583
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
584
584
|
if (expansion.isRanged) {
|
|
585
585
|
throw new Error(
|
|
@@ -604,7 +604,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
604
604
|
signTxWithKey(tx, key, inputIndexes) {
|
|
605
605
|
const txCpy = tx.clone();
|
|
606
606
|
if (!inputIndexes) {
|
|
607
|
-
|
|
607
|
+
chunk6AFUNKK7_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
|
|
608
608
|
try {
|
|
609
609
|
if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
|
|
610
610
|
throw new Error("Failed to sign transaction");
|
|
@@ -666,7 +666,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
666
666
|
*/
|
|
667
667
|
descriptor;
|
|
668
668
|
constructor(descriptor) {
|
|
669
|
-
const network =
|
|
669
|
+
const network = chunkHL7EC2Z5_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
670
670
|
let expansion;
|
|
671
671
|
try {
|
|
672
672
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -716,7 +716,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
716
716
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
717
717
|
*/
|
|
718
718
|
isOurs(descriptor) {
|
|
719
|
-
return
|
|
719
|
+
return chunkHL7EC2Z5_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
720
720
|
}
|
|
721
721
|
};
|
|
722
722
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -878,10 +878,10 @@ var DescriptorIdentity = class {
|
|
|
878
878
|
this.base = base;
|
|
879
879
|
}
|
|
880
880
|
async xOnlyPublicKey() {
|
|
881
|
-
return
|
|
881
|
+
return chunkHL7EC2Z5_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
882
882
|
}
|
|
883
883
|
async compressedPublicKey() {
|
|
884
|
-
return
|
|
884
|
+
return chunkHL7EC2Z5_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
885
885
|
}
|
|
886
886
|
async sign(tx, inputIndexes) {
|
|
887
887
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -949,12 +949,12 @@ var WalletCannotAllocateAddressError = class extends Error {
|
|
|
949
949
|
};
|
|
950
950
|
async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
951
951
|
const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
|
|
952
|
-
if (owner &&
|
|
952
|
+
if (owner && chunkHL7EC2Z5_cjs.parseHDDescriptor(descriptor)) {
|
|
953
953
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
954
954
|
}
|
|
955
955
|
let key;
|
|
956
956
|
try {
|
|
957
|
-
key =
|
|
957
|
+
key = chunkHL7EC2Z5_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
958
958
|
} catch {
|
|
959
959
|
throw new ForeignDescriptorError(descriptor);
|
|
960
960
|
}
|
|
@@ -1329,14 +1329,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1329
1329
|
}
|
|
1330
1330
|
var PREIMAGE_INDEX = 0;
|
|
1331
1331
|
function isPerArtifactDescriptor(descriptor) {
|
|
1332
|
-
return
|
|
1332
|
+
return chunkHL7EC2Z5_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1333
1333
|
}
|
|
1334
1334
|
async function provisionDescriptor(wallet) {
|
|
1335
1335
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1336
|
-
return allocated ?? await
|
|
1336
|
+
return allocated ?? await chunkHL7EC2Z5_cjs.identityDescriptor(wallet.identity);
|
|
1337
1337
|
}
|
|
1338
1338
|
async function provisionRefundKey(wallet) {
|
|
1339
|
-
const descriptor = await
|
|
1339
|
+
const descriptor = await chunkHL7EC2Z5_cjs.identityDescriptor(wallet.identity);
|
|
1340
1340
|
const signer = await contractSigner(wallet, descriptor);
|
|
1341
1341
|
const pubkey = await signer.xOnlyPublicKey();
|
|
1342
1342
|
const identityPubkey = await wallet.identity.xOnlyPublicKey();
|
|
@@ -1346,7 +1346,7 @@ async function provisionRefundKey(wallet) {
|
|
|
1346
1346
|
);
|
|
1347
1347
|
}
|
|
1348
1348
|
const address = await wallet.getAddress();
|
|
1349
|
-
const { pkScript } =
|
|
1349
|
+
const { pkScript } = chunk6AFUNKK7_cjs.ArkAddress.decode(address);
|
|
1350
1350
|
return { descriptor, pubkey, pkScript, address };
|
|
1351
1351
|
}
|
|
1352
1352
|
async function provisionClaimSecret(wallet, opts = {}) {
|
|
@@ -1392,7 +1392,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1392
1392
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1393
1393
|
let expected;
|
|
1394
1394
|
try {
|
|
1395
|
-
expected =
|
|
1395
|
+
expected = chunkHL7EC2Z5_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1396
1396
|
} catch (cause) {
|
|
1397
1397
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1398
1398
|
}
|
|
@@ -1611,14 +1611,14 @@ var RestDelegateProvider = class {
|
|
|
1611
1611
|
*/
|
|
1612
1612
|
async delegate(intent, forfeitTxs, options) {
|
|
1613
1613
|
const url = `${this.url}/v1/delegate`;
|
|
1614
|
-
const response = await
|
|
1614
|
+
const response = await chunk6AFUNKK7_cjs.baseFetch(url, {
|
|
1615
1615
|
method: "POST",
|
|
1616
1616
|
headers: {
|
|
1617
1617
|
"Content-Type": "application/json"
|
|
1618
1618
|
},
|
|
1619
1619
|
body: JSON.stringify({
|
|
1620
1620
|
intent: {
|
|
1621
|
-
message:
|
|
1621
|
+
message: chunk6AFUNKK7_cjs.Intent.encodeMessage(intent.message),
|
|
1622
1622
|
proof: intent.proof
|
|
1623
1623
|
},
|
|
1624
1624
|
forfeit_txs: forfeitTxs,
|
|
@@ -1638,7 +1638,7 @@ var RestDelegateProvider = class {
|
|
|
1638
1638
|
*/
|
|
1639
1639
|
async getDelegateInfo() {
|
|
1640
1640
|
const url = `${this.url}/v1/delegator/info`;
|
|
1641
|
-
const response = await
|
|
1641
|
+
const response = await chunk6AFUNKK7_cjs.rateGate.runHttp(url, () => chunk6AFUNKK7_cjs.baseFetch(url));
|
|
1642
1642
|
if (!response.ok) {
|
|
1643
1643
|
const errorText2 = await response.text();
|
|
1644
1644
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1663,7 +1663,7 @@ var ESPLORA_URL = {
|
|
|
1663
1663
|
regtest: "http://localhost:3000/api"
|
|
1664
1664
|
};
|
|
1665
1665
|
var EsploraProvider = class {
|
|
1666
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1666
|
+
constructor(baseUrl = ESPLORA_URL[chunk6AFUNKK7_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1667
1667
|
this.baseUrl = baseUrl;
|
|
1668
1668
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1669
1669
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1672,14 +1672,14 @@ var EsploraProvider = class {
|
|
|
1672
1672
|
pollingInterval;
|
|
1673
1673
|
forcePolling;
|
|
1674
1674
|
async getCoins(address) {
|
|
1675
|
-
const response = await
|
|
1675
|
+
const response = await chunk6AFUNKK7_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1676
1676
|
if (!response.ok) {
|
|
1677
1677
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1678
1678
|
}
|
|
1679
1679
|
return response.json();
|
|
1680
1680
|
}
|
|
1681
1681
|
async getFeeRate() {
|
|
1682
|
-
const response = await
|
|
1682
|
+
const response = await chunk6AFUNKK7_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1683
1683
|
if (response.status === 404) {
|
|
1684
1684
|
return void 0;
|
|
1685
1685
|
}
|
|
@@ -1700,7 +1700,7 @@ var EsploraProvider = class {
|
|
|
1700
1700
|
}
|
|
1701
1701
|
}
|
|
1702
1702
|
async getTxOutspends(txid) {
|
|
1703
|
-
const response = await
|
|
1703
|
+
const response = await chunk6AFUNKK7_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1704
1704
|
if (!response.ok) {
|
|
1705
1705
|
const error = await response.text();
|
|
1706
1706
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1708,7 +1708,7 @@ var EsploraProvider = class {
|
|
|
1708
1708
|
return response.json();
|
|
1709
1709
|
}
|
|
1710
1710
|
async getTransactions(address) {
|
|
1711
|
-
const response = await
|
|
1711
|
+
const response = await chunk6AFUNKK7_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1712
1712
|
if (!response.ok) {
|
|
1713
1713
|
const error = await response.text();
|
|
1714
1714
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1716,7 +1716,7 @@ var EsploraProvider = class {
|
|
|
1716
1716
|
return response.json();
|
|
1717
1717
|
}
|
|
1718
1718
|
async getRawTransaction(txid) {
|
|
1719
|
-
const response = await
|
|
1719
|
+
const response = await chunk6AFUNKK7_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
1720
1720
|
if (!response.ok) {
|
|
1721
1721
|
const error = await response.text();
|
|
1722
1722
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -1724,7 +1724,7 @@ var EsploraProvider = class {
|
|
|
1724
1724
|
return base.hex.decode((await response.text()).trim());
|
|
1725
1725
|
}
|
|
1726
1726
|
async getTxStatus(txid) {
|
|
1727
|
-
const txresponse = await
|
|
1727
|
+
const txresponse = await chunk6AFUNKK7_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1728
1728
|
if (!txresponse.ok) {
|
|
1729
1729
|
throw new Error(txresponse.statusText);
|
|
1730
1730
|
}
|
|
@@ -1732,7 +1732,7 @@ var EsploraProvider = class {
|
|
|
1732
1732
|
if (!tx.status.confirmed) {
|
|
1733
1733
|
return { confirmed: false };
|
|
1734
1734
|
}
|
|
1735
|
-
const response = await
|
|
1735
|
+
const response = await chunk6AFUNKK7_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1736
1736
|
if (!response.ok) {
|
|
1737
1737
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1738
1738
|
}
|
|
@@ -1816,7 +1816,7 @@ var EsploraProvider = class {
|
|
|
1816
1816
|
return stopFunc;
|
|
1817
1817
|
}
|
|
1818
1818
|
async getChainTip() {
|
|
1819
|
-
const tipBlocks = await
|
|
1819
|
+
const tipBlocks = await chunk6AFUNKK7_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
1820
1820
|
if (!tipBlocks.ok) {
|
|
1821
1821
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
1822
1822
|
}
|
|
@@ -1835,7 +1835,7 @@ var EsploraProvider = class {
|
|
|
1835
1835
|
};
|
|
1836
1836
|
}
|
|
1837
1837
|
async broadcastPackage(parent, child) {
|
|
1838
|
-
const response = await
|
|
1838
|
+
const response = await chunk6AFUNKK7_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
1839
1839
|
method: "POST",
|
|
1840
1840
|
headers: {
|
|
1841
1841
|
"Content-Type": "application/json"
|
|
@@ -1851,7 +1851,7 @@ var EsploraProvider = class {
|
|
|
1851
1851
|
return result;
|
|
1852
1852
|
}
|
|
1853
1853
|
async broadcastTx(tx) {
|
|
1854
|
-
const response = await
|
|
1854
|
+
const response = await chunk6AFUNKK7_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
1855
1855
|
method: "POST",
|
|
1856
1856
|
headers: {
|
|
1857
1857
|
"Content-Type": "text/plain"
|
|
@@ -2031,7 +2031,7 @@ function findP2AOutput(tx) {
|
|
|
2031
2031
|
var CHILD_DUST_AMOUNT = 546;
|
|
2032
2032
|
function buildAnchorChild(params) {
|
|
2033
2033
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2034
|
-
const child = new
|
|
2034
|
+
const child = new chunk6AFUNKK7_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2035
2035
|
child.addInput(findP2AOutput(parent));
|
|
2036
2036
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
2037
2037
|
for (const _ of fundingCoins) {
|
|
@@ -2079,7 +2079,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2079
2079
|
);
|
|
2080
2080
|
}
|
|
2081
2081
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2082
|
-
const tx = new
|
|
2082
|
+
const tx = new chunk6AFUNKK7_cjs.Transaction({
|
|
2083
2083
|
version: 3,
|
|
2084
2084
|
lockTime: txLocktime
|
|
2085
2085
|
});
|
|
@@ -2155,7 +2155,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2155
2155
|
if (previousScriptKey.length !== 32) {
|
|
2156
2156
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2157
2157
|
}
|
|
2158
|
-
const cosigners =
|
|
2158
|
+
const cosigners = chunk6AFUNKK7_cjs.getArkPsbtFields(child.root, 0, chunk6AFUNKK7_cjs.CosignerPublicKey);
|
|
2159
2159
|
if (cosigners.length === 0) {
|
|
2160
2160
|
throw ErrMissingCosignersPublicKeys;
|
|
2161
2161
|
}
|
|
@@ -2213,7 +2213,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2213
2213
|
return new _EmulatorPacket(entries);
|
|
2214
2214
|
}
|
|
2215
2215
|
static fromBytes(data) {
|
|
2216
|
-
const reader = new
|
|
2216
|
+
const reader = new chunkCZ32XADN_cjs.BufferReader(data);
|
|
2217
2217
|
const entryCount = reader.readCompactSize();
|
|
2218
2218
|
const entries = [];
|
|
2219
2219
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2231,7 +2231,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2231
2231
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2232
2232
|
}
|
|
2233
2233
|
serialize() {
|
|
2234
|
-
const writer = new
|
|
2234
|
+
const writer = new chunkCZ32XADN_cjs.BufferWriter();
|
|
2235
2235
|
writer.writeCompactSize(this.entries.length);
|
|
2236
2236
|
for (const entry of this.entries) {
|
|
2237
2237
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2318,7 +2318,7 @@ var Extension = class _Extension {
|
|
|
2318
2318
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2319
2319
|
);
|
|
2320
2320
|
}
|
|
2321
|
-
const reader = new
|
|
2321
|
+
const reader = new chunkCZ32XADN_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2322
2322
|
const packets = [];
|
|
2323
2323
|
while (reader.remaining() > 0) {
|
|
2324
2324
|
const packetType = reader.readByte();
|
|
@@ -2392,7 +2392,7 @@ var Extension = class _Extension {
|
|
|
2392
2392
|
*/
|
|
2393
2393
|
getAssetPacket() {
|
|
2394
2394
|
for (const p of this.packets) {
|
|
2395
|
-
if (p instanceof
|
|
2395
|
+
if (p instanceof chunkCZ32XADN_cjs.Packet) {
|
|
2396
2396
|
return p;
|
|
2397
2397
|
}
|
|
2398
2398
|
}
|
|
@@ -2430,8 +2430,8 @@ var Extension = class _Extension {
|
|
|
2430
2430
|
};
|
|
2431
2431
|
function parsePacket(packetType, data) {
|
|
2432
2432
|
switch (packetType) {
|
|
2433
|
-
case
|
|
2434
|
-
return
|
|
2433
|
+
case chunkCZ32XADN_cjs.Packet.PACKET_TYPE:
|
|
2434
|
+
return chunkCZ32XADN_cjs.Packet.fromBytes(data);
|
|
2435
2435
|
case EmulatorPacket.PACKET_TYPE:
|
|
2436
2436
|
return EmulatorPacket.fromBytes(data);
|
|
2437
2437
|
default:
|
|
@@ -2478,16 +2478,16 @@ function buildOpReturnScript(data) {
|
|
|
2478
2478
|
}
|
|
2479
2479
|
return script;
|
|
2480
2480
|
}
|
|
2481
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2482
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2481
|
+
var ErrOffchainOutputNotFound = (address) => new chunk6AFUNKK7_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2482
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
2483
2483
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2484
2484
|
);
|
|
2485
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2486
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2485
|
+
var ErrAssetGroupNotFound = (assetId) => new chunk6AFUNKK7_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2486
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
2487
2487
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2488
2488
|
);
|
|
2489
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2490
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2489
|
+
var ErrOnchainOutputNotFound = (address) => new chunk6AFUNKK7_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2490
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
2491
2491
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2492
2492
|
);
|
|
2493
2493
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2496,7 +2496,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2496
2496
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2497
2497
|
if (!validatedCommitmentTxid) return;
|
|
2498
2498
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2499
|
-
throw new
|
|
2499
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
2500
2500
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2501
2501
|
);
|
|
2502
2502
|
}
|
|
@@ -2506,7 +2506,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2506
2506
|
for (const recipient of recipients) {
|
|
2507
2507
|
let arkAddress;
|
|
2508
2508
|
try {
|
|
2509
|
-
arkAddress =
|
|
2509
|
+
arkAddress = chunk6AFUNKK7_cjs.ArkAddress.decode(recipient.address);
|
|
2510
2510
|
} catch {
|
|
2511
2511
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2512
2512
|
continue;
|
|
@@ -2518,7 +2518,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2518
2518
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2519
2519
|
for (const recipient of recipients) {
|
|
2520
2520
|
try {
|
|
2521
|
-
|
|
2521
|
+
chunk6AFUNKK7_cjs.ArkAddress.decode(recipient.address);
|
|
2522
2522
|
} catch {
|
|
2523
2523
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2524
2524
|
continue;
|
|
@@ -2751,7 +2751,7 @@ function assetMintResolver() {
|
|
|
2751
2751
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
2752
2752
|
const minted = tx.assets.filter((a) => {
|
|
2753
2753
|
try {
|
|
2754
|
-
return base.hex.encode(
|
|
2754
|
+
return base.hex.encode(chunkCZ32XADN_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
2755
2755
|
} catch {
|
|
2756
2756
|
return false;
|
|
2757
2757
|
}
|
|
@@ -2794,7 +2794,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2794
2794
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
2795
2795
|
inputsByAssetId.set(asset.assetId, [
|
|
2796
2796
|
...existing ?? [],
|
|
2797
|
-
|
|
2797
|
+
chunkCZ32XADN_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
2798
2798
|
]);
|
|
2799
2799
|
}
|
|
2800
2800
|
}
|
|
@@ -2806,7 +2806,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2806
2806
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2807
2807
|
outputsByAssetId.set(asset.assetId, [
|
|
2808
2808
|
...existing ?? [],
|
|
2809
|
-
|
|
2809
|
+
chunkCZ32XADN_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2810
2810
|
]);
|
|
2811
2811
|
}
|
|
2812
2812
|
}
|
|
@@ -2817,7 +2817,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2817
2817
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2818
2818
|
outputsByAssetId.set(asset.assetId, [
|
|
2819
2819
|
...existing ?? [],
|
|
2820
|
-
|
|
2820
|
+
chunkCZ32XADN_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2821
2821
|
]);
|
|
2822
2822
|
}
|
|
2823
2823
|
}
|
|
@@ -2826,11 +2826,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2826
2826
|
for (const assetIdStr of allAssetIds) {
|
|
2827
2827
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
2828
2828
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
2829
|
-
const assetId =
|
|
2830
|
-
const group =
|
|
2829
|
+
const assetId = chunkCZ32XADN_cjs.AssetId.fromString(assetIdStr);
|
|
2830
|
+
const group = chunkCZ32XADN_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
2831
2831
|
groups.push(group);
|
|
2832
2832
|
}
|
|
2833
|
-
return
|
|
2833
|
+
return chunkCZ32XADN_cjs.Packet.create(groups);
|
|
2834
2834
|
}
|
|
2835
2835
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
2836
2836
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -2867,7 +2867,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
|
|
|
2867
2867
|
}
|
|
2868
2868
|
function toXOnlySignerHex(pubkeyHex) {
|
|
2869
2869
|
const bytes = base.hex.decode(pubkeyHex);
|
|
2870
|
-
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(
|
|
2870
|
+
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkHL7EC2Z5_cjs.toXOnly(bytes, "signer key"));
|
|
2871
2871
|
throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
|
|
2872
2872
|
}
|
|
2873
2873
|
function signerSetFromInfo(info) {
|
|
@@ -2914,13 +2914,13 @@ var toTimelock = (value) => ({
|
|
|
2914
2914
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
2915
2915
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
2916
2916
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
2917
|
-
throw new
|
|
2917
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
2918
2918
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
2919
2919
|
);
|
|
2920
2920
|
}
|
|
2921
2921
|
const seconds = toSeconds(timelock);
|
|
2922
2922
|
if (seconds < policy.minSeconds) {
|
|
2923
|
-
throw new
|
|
2923
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
2924
2924
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
2925
2925
|
);
|
|
2926
2926
|
}
|
|
@@ -2941,7 +2941,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
2941
2941
|
}
|
|
2942
2942
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
2943
2943
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
2944
|
-
throw new
|
|
2944
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
2945
2945
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
2946
2946
|
);
|
|
2947
2947
|
}
|
|
@@ -2971,21 +2971,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
2971
2971
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
2972
2972
|
let script;
|
|
2973
2973
|
try {
|
|
2974
|
-
script =
|
|
2974
|
+
script = chunk6AFUNKK7_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
2975
2975
|
} catch (e) {
|
|
2976
|
-
throw new
|
|
2976
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
2977
2977
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
2978
2978
|
);
|
|
2979
2979
|
}
|
|
2980
2980
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
2981
2981
|
const { pubkeys } = script.params;
|
|
2982
2982
|
if (pubkeys.length !== 1) {
|
|
2983
|
-
throw new
|
|
2983
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
2984
2984
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
2985
2985
|
);
|
|
2986
2986
|
}
|
|
2987
2987
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
2988
|
-
throw new
|
|
2988
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
2989
2989
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
2990
2990
|
);
|
|
2991
2991
|
}
|
|
@@ -3029,8 +3029,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
3029
3029
|
function buildVirtualTx(inputs, outputs) {
|
|
3030
3030
|
let lockTime = 0n;
|
|
3031
3031
|
for (const input of inputs) {
|
|
3032
|
-
const tapscript =
|
|
3033
|
-
if (
|
|
3032
|
+
const tapscript = chunk6AFUNKK7_cjs.decodeTapscript(chunk6AFUNKK7_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
3033
|
+
if (chunk6AFUNKK7_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
3034
3034
|
if (lockTime !== 0n) {
|
|
3035
3035
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
3036
3036
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -3041,7 +3041,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3041
3041
|
}
|
|
3042
3042
|
}
|
|
3043
3043
|
}
|
|
3044
|
-
const tx = new
|
|
3044
|
+
const tx = new chunk6AFUNKK7_cjs.Transaction({
|
|
3045
3045
|
version: 3,
|
|
3046
3046
|
lockTime: Number(lockTime)
|
|
3047
3047
|
});
|
|
@@ -3051,12 +3051,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3051
3051
|
index: input.vout,
|
|
3052
3052
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3053
3053
|
witnessUtxo: {
|
|
3054
|
-
script:
|
|
3054
|
+
script: chunk6AFUNKK7_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3055
3055
|
amount: BigInt(input.value)
|
|
3056
3056
|
},
|
|
3057
3057
|
tapLeafScript: [input.tapLeafScript]
|
|
3058
3058
|
});
|
|
3059
|
-
|
|
3059
|
+
chunk6AFUNKK7_cjs.setArkPsbtField(tx, i, chunk6AFUNKK7_cjs.VtxoTaprootTree, input.tapTree);
|
|
3060
3060
|
}
|
|
3061
3061
|
for (const output of outputs) {
|
|
3062
3062
|
tx.addOutput(output);
|
|
@@ -3065,8 +3065,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3065
3065
|
return tx;
|
|
3066
3066
|
}
|
|
3067
3067
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3068
|
-
const collaborativeClosure =
|
|
3069
|
-
const checkpointVtxoScript = new
|
|
3068
|
+
const collaborativeClosure = chunk6AFUNKK7_cjs.decodeTapscript(chunk6AFUNKK7_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3069
|
+
const checkpointVtxoScript = new chunk6AFUNKK7_cjs.VtxoScript([
|
|
3070
3070
|
serverUnrollScript.script,
|
|
3071
3071
|
collaborativeClosure.script
|
|
3072
3072
|
]);
|
|
@@ -3142,7 +3142,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3142
3142
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3143
3143
|
const sig = signature.subarray(0, 64);
|
|
3144
3144
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3145
|
-
const sighashName =
|
|
3145
|
+
const sighashName = chunk6AFUNKK7_cjs.formatSighash(sighashType);
|
|
3146
3146
|
throw new Error(
|
|
3147
3147
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3148
3148
|
);
|
|
@@ -3216,7 +3216,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3216
3216
|
}
|
|
3217
3217
|
function isValidArkAddress(address) {
|
|
3218
3218
|
try {
|
|
3219
|
-
|
|
3219
|
+
chunk6AFUNKK7_cjs.ArkAddress.decode(address);
|
|
3220
3220
|
return true;
|
|
3221
3221
|
} catch (e) {
|
|
3222
3222
|
return false;
|
|
@@ -3224,16 +3224,16 @@ function isValidArkAddress(address) {
|
|
|
3224
3224
|
}
|
|
3225
3225
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3226
3226
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3227
|
-
throw new
|
|
3227
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
3228
3228
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3229
3229
|
);
|
|
3230
3230
|
}
|
|
3231
3231
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3232
3232
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3233
|
-
const server =
|
|
3233
|
+
const server = chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3234
3234
|
const local = byTxid.get(server.id);
|
|
3235
3235
|
if (!local) {
|
|
3236
|
-
throw new
|
|
3236
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
3237
3237
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3238
3238
|
);
|
|
3239
3239
|
}
|
|
@@ -3243,14 +3243,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3243
3243
|
}
|
|
3244
3244
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3245
3245
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3246
|
-
throw new
|
|
3246
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
3247
3247
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3248
3248
|
);
|
|
3249
3249
|
}
|
|
3250
3250
|
if (response.finalArkTx === void 0) return;
|
|
3251
|
-
const finalTxid =
|
|
3251
|
+
const finalTxid = chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3252
3252
|
if (finalTxid !== signedArkTx.id) {
|
|
3253
|
-
throw new
|
|
3253
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
3254
3254
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3255
3255
|
);
|
|
3256
3256
|
}
|
|
@@ -3269,10 +3269,10 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex,
|
|
|
3269
3269
|
[serverPubkeyHex],
|
|
3270
3270
|
void 0,
|
|
3271
3271
|
void 0,
|
|
3272
|
-
payment_js.tapLeafHash(
|
|
3272
|
+
payment_js.tapLeafHash(chunk6AFUNKK7_cjs.scriptFromTapLeafScript(leaf))
|
|
3273
3273
|
);
|
|
3274
3274
|
} catch (error) {
|
|
3275
|
-
throw new
|
|
3275
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
3276
3276
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3277
3277
|
);
|
|
3278
3278
|
}
|
|
@@ -3281,20 +3281,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3281
3281
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3282
3282
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3283
3283
|
if (checkpoint.inputsLength !== 1) {
|
|
3284
|
-
throw new
|
|
3284
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
3285
3285
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3286
3286
|
);
|
|
3287
3287
|
}
|
|
3288
3288
|
const spent = checkpoint.getInput(0);
|
|
3289
3289
|
if (!spent.txid || spent.index === void 0) {
|
|
3290
|
-
throw new
|
|
3290
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
3291
3291
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3292
3292
|
);
|
|
3293
3293
|
}
|
|
3294
3294
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3295
3295
|
const input = byOutpoint.get(outpoint);
|
|
3296
3296
|
if (!input) {
|
|
3297
|
-
throw new
|
|
3297
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
3298
3298
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3299
3299
|
);
|
|
3300
3300
|
}
|
|
@@ -3302,7 +3302,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3302
3302
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3303
3303
|
);
|
|
3304
3304
|
if (!rebuilt) {
|
|
3305
|
-
throw new
|
|
3305
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
3306
3306
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3307
3307
|
);
|
|
3308
3308
|
}
|
|
@@ -3328,9 +3328,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3328
3328
|
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
3329
3329
|
matched.forEach(({ server }, index) => {
|
|
3330
3330
|
try {
|
|
3331
|
-
|
|
3331
|
+
chunk6AFUNKK7_cjs.assertAllowedSighashTypes(server);
|
|
3332
3332
|
} catch (error) {
|
|
3333
|
-
throw new
|
|
3333
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
3334
3334
|
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
3335
3335
|
);
|
|
3336
3336
|
}
|
|
@@ -3338,12 +3338,12 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3338
3338
|
const verify = options?.verifyServerSignatures;
|
|
3339
3339
|
if (verify) {
|
|
3340
3340
|
if (response.finalArkTx === void 0) {
|
|
3341
|
-
throw new
|
|
3341
|
+
throw new chunk6AFUNKK7_cjs.ServerResponseMismatchError(
|
|
3342
3342
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3343
3343
|
);
|
|
3344
3344
|
}
|
|
3345
|
-
const finalArkTx =
|
|
3346
|
-
const serverPubkeyHex = base.hex.encode(
|
|
3345
|
+
const finalArkTx = chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3346
|
+
const serverPubkeyHex = base.hex.encode(chunkHL7EC2Z5_cjs.toXOnly(verify.serverPubkey, "server key"));
|
|
3347
3347
|
for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
|
|
3348
3348
|
assertServerSignedLeaf(
|
|
3349
3349
|
finalArkTx,
|
|
@@ -3399,12 +3399,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3399
3399
|
return {
|
|
3400
3400
|
...identity,
|
|
3401
3401
|
sign: async (tx, inputIndexes) => {
|
|
3402
|
-
const signed =
|
|
3402
|
+
const signed = chunk6AFUNKK7_cjs.Transaction.fromPSBT(
|
|
3403
3403
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3404
3404
|
);
|
|
3405
3405
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3406
3406
|
for (const index of indexes) {
|
|
3407
|
-
|
|
3407
|
+
chunk6AFUNKK7_cjs.setArkPsbtField(signed, index, chunk6AFUNKK7_cjs.ConditionWitness, [preimage]);
|
|
3408
3408
|
}
|
|
3409
3409
|
return signed;
|
|
3410
3410
|
}
|
|
@@ -3596,7 +3596,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
3596
3596
|
};
|
|
3597
3597
|
}
|
|
3598
3598
|
function deriveContractTapscripts(contract) {
|
|
3599
|
-
const handler =
|
|
3599
|
+
const handler = chunkHL7EC2Z5_cjs.contractHandlers.get(contract.type);
|
|
3600
3600
|
if (!handler) {
|
|
3601
3601
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3602
3602
|
}
|
|
@@ -3667,13 +3667,13 @@ function getRandomId() {
|
|
|
3667
3667
|
}
|
|
3668
3668
|
function isValidArkAddress2(address) {
|
|
3669
3669
|
try {
|
|
3670
|
-
|
|
3670
|
+
chunk6AFUNKK7_cjs.ArkAddress.decode(address);
|
|
3671
3671
|
return true;
|
|
3672
3672
|
} catch (e) {
|
|
3673
3673
|
return false;
|
|
3674
3674
|
}
|
|
3675
3675
|
}
|
|
3676
|
-
function
|
|
3676
|
+
function assertRecipientArkadeAddress(encoded, address, context) {
|
|
3677
3677
|
if (address.hrp !== context.hrp) {
|
|
3678
3678
|
throw new Error(
|
|
3679
3679
|
`Invalid Arkade address ${encoded}: expected prefix "${context.hrp}", got "${address.hrp}"`
|
|
@@ -3695,7 +3695,7 @@ function assertRecipientArkAddress(encoded, address, context) {
|
|
|
3695
3695
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
3696
3696
|
let derived;
|
|
3697
3697
|
try {
|
|
3698
|
-
derived =
|
|
3698
|
+
derived = chunk6AFUNKK7_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
3699
3699
|
} catch (e) {
|
|
3700
3700
|
throw new Error(
|
|
3701
3701
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -3712,11 +3712,11 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3712
3712
|
for (const recipient of recipients) {
|
|
3713
3713
|
let address;
|
|
3714
3714
|
try {
|
|
3715
|
-
address =
|
|
3715
|
+
address = chunk6AFUNKK7_cjs.ArkAddress.decode(recipient.address);
|
|
3716
3716
|
} catch (e) {
|
|
3717
3717
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
3718
3718
|
}
|
|
3719
|
-
|
|
3719
|
+
assertRecipientArkadeAddress(recipient.address, address, context);
|
|
3720
3720
|
const amount = recipient.amount || dustAmount;
|
|
3721
3721
|
if (amount <= 0) {
|
|
3722
3722
|
throw new Error("Amount must be positive");
|
|
@@ -3737,7 +3737,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3737
3737
|
|
|
3738
3738
|
// src/contracts/spendability.ts
|
|
3739
3739
|
function isContractGenericallySpendable(contract) {
|
|
3740
|
-
return
|
|
3740
|
+
return chunkHL7EC2Z5_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
3741
3741
|
}
|
|
3742
3742
|
function gatedContracts(contracts) {
|
|
3743
3743
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -3750,7 +3750,7 @@ function gateExclusion(gated) {
|
|
|
3750
3750
|
return (vtxo) => {
|
|
3751
3751
|
const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
|
|
3752
3752
|
if (type === void 0) return void 0;
|
|
3753
|
-
if (!
|
|
3753
|
+
if (!chunkHL7EC2Z5_cjs.contractHandlers.has(type)) {
|
|
3754
3754
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
3755
3755
|
}
|
|
3756
3756
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -3786,7 +3786,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
3786
3786
|
continue;
|
|
3787
3787
|
}
|
|
3788
3788
|
for (const v of vtxos) {
|
|
3789
|
-
if (!
|
|
3789
|
+
if (!chunk6AFUNKK7_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
|
|
3790
3790
|
out.add(`${v.txid}:${v.vout}`);
|
|
3791
3791
|
}
|
|
3792
3792
|
}
|
|
@@ -3821,10 +3821,10 @@ function byValueDescending(vtxos) {
|
|
|
3821
3821
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
3822
3822
|
}
|
|
3823
3823
|
async function fetchTimeHeight(wallet) {
|
|
3824
|
-
return
|
|
3824
|
+
return chunk6AFUNKK7_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
3825
3825
|
}
|
|
3826
3826
|
function canMigrateBySend(vtxo, now) {
|
|
3827
|
-
if (!
|
|
3827
|
+
if (!chunk6AFUNKK7_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
3828
3828
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
3829
3829
|
}
|
|
3830
3830
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -3832,7 +3832,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
3832
3832
|
if (vtxo.isSwept) return -Infinity;
|
|
3833
3833
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
3834
3834
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
3835
|
-
return
|
|
3835
|
+
return chunk6AFUNKK7_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
3836
3836
|
}
|
|
3837
3837
|
return Infinity;
|
|
3838
3838
|
};
|
|
@@ -3859,7 +3859,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
3859
3859
|
const payable = [];
|
|
3860
3860
|
const net = /* @__PURE__ */ new Map();
|
|
3861
3861
|
for (const vtxo of vtxos) {
|
|
3862
|
-
const inputFee = estimator.evalOffchainInput(
|
|
3862
|
+
const inputFee = estimator.evalOffchainInput(chunk6AFUNKK7_cjs.toOffchainInputFeeParams(vtxo));
|
|
3863
3863
|
if (inputFee.satoshis >= vtxo.value) {
|
|
3864
3864
|
continue;
|
|
3865
3865
|
}
|
|
@@ -3885,7 +3885,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
3885
3885
|
}
|
|
3886
3886
|
const outputFee = estimator.evalOffchainOutput({
|
|
3887
3887
|
amount: subtotal,
|
|
3888
|
-
script: base.hex.encode(
|
|
3888
|
+
script: base.hex.encode(chunk6AFUNKK7_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
3889
3889
|
});
|
|
3890
3890
|
return subtotal - BigInt(outputFee.satoshis);
|
|
3891
3891
|
}
|
|
@@ -3903,10 +3903,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
3903
3903
|
};
|
|
3904
3904
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
3905
3905
|
return vtxos.filter((vtxo) => {
|
|
3906
|
-
if (
|
|
3906
|
+
if (chunk6AFUNKK7_cjs.canRecoverOnchain(vtxo, now)) {
|
|
3907
3907
|
return true;
|
|
3908
3908
|
}
|
|
3909
|
-
if (
|
|
3909
|
+
if (chunk6AFUNKK7_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
3910
3910
|
return true;
|
|
3911
3911
|
}
|
|
3912
3912
|
return false;
|
|
@@ -3938,7 +3938,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
3938
3938
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
3939
3939
|
if (vtxo.isUnrolled) return false;
|
|
3940
3940
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
3941
|
-
const expiresAt =
|
|
3941
|
+
const expiresAt = chunk6AFUNKK7_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
3942
3942
|
if (expiresAt === void 0) return false;
|
|
3943
3943
|
const now = Date.now();
|
|
3944
3944
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -3949,7 +3949,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
3949
3949
|
return vtxos.filter(
|
|
3950
3950
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
3951
3951
|
// property and would otherwise re-admit an exited coin on its own.
|
|
3952
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
3952
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunk6AFUNKK7_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
3953
3953
|
);
|
|
3954
3954
|
}
|
|
3955
3955
|
function isMigrationCapable(wallet) {
|
|
@@ -4548,11 +4548,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
4548
4548
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
4549
4549
|
);
|
|
4550
4550
|
}
|
|
4551
|
-
const tx = new
|
|
4551
|
+
const tx = new chunk6AFUNKK7_cjs.Transaction();
|
|
4552
4552
|
for (const utxo of expiredUtxos) {
|
|
4553
|
-
const utxoScript =
|
|
4553
|
+
const utxoScript = chunk6AFUNKK7_cjs.VtxoScript.decode(utxo.tapTree);
|
|
4554
4554
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
4555
|
-
(leaf) =>
|
|
4555
|
+
(leaf) => chunk6AFUNKK7_cjs.CSVMultisigTapscript.isScriptValid(chunk6AFUNKK7_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
4556
4556
|
);
|
|
4557
4557
|
if (!utxoExitLeaf) {
|
|
4558
4558
|
throw new Error(
|
|
@@ -4567,7 +4567,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4567
4567
|
amount: BigInt(utxo.value)
|
|
4568
4568
|
},
|
|
4569
4569
|
tapLeafScript: [utxoExitLeaf],
|
|
4570
|
-
sequence:
|
|
4570
|
+
sequence: chunk6AFUNKK7_cjs.getSequence(utxoExitLeaf)
|
|
4571
4571
|
});
|
|
4572
4572
|
}
|
|
4573
4573
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -4607,7 +4607,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4607
4607
|
}
|
|
4608
4608
|
/**
|
|
4609
4609
|
* Core migration routine shared by the manual API and the automatic poll
|
|
4610
|
-
* pass. Fetches a fresh {@link
|
|
4610
|
+
* pass. Fetches a fresh {@link ArkadeInfo}, applies a mid-session signer
|
|
4611
4611
|
* rotation when the wallet's own snapshot signer has been deprecated,
|
|
4612
4612
|
* selects spendable VTXOs under deprecated-signer contracts (cutoff-first),
|
|
4613
4613
|
* and settles them to the active-signer Ark address.
|
|
@@ -4810,8 +4810,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4810
4810
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
4811
4811
|
if (cls.status === "CURRENT") continue;
|
|
4812
4812
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
4813
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
4814
|
-
const spendable = live.filter((v) => !
|
|
4813
|
+
const recoverable = live.filter((v) => v.isSwept && !chunk6AFUNKK7_cjs.hasTerminalSpend(v));
|
|
4814
|
+
const spendable = live.filter((v) => !chunk6AFUNKK7_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
4815
4815
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
4816
4816
|
let recoverableCount = 0;
|
|
4817
4817
|
let recoverableValue = 0;
|
|
@@ -4824,7 +4824,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4824
4824
|
awaitingSweepCount = spendable.length;
|
|
4825
4825
|
awaitingSweepValue = value;
|
|
4826
4826
|
for (const v of spendable) {
|
|
4827
|
-
const exp =
|
|
4827
|
+
const exp = chunk6AFUNKK7_cjs.toBatchExpiry(v);
|
|
4828
4828
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
4829
4829
|
nextSweepEta = exp;
|
|
4830
4830
|
}
|
|
@@ -5085,7 +5085,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5085
5085
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
5086
5086
|
getBoardingTimelock() {
|
|
5087
5087
|
const wallet = this.getSweepWallet();
|
|
5088
|
-
const exitScript =
|
|
5088
|
+
const exitScript = chunk6AFUNKK7_cjs.CSVMultisigTapscript.decode(
|
|
5089
5089
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5090
5090
|
);
|
|
5091
5091
|
return exitScript.params.timelock;
|
|
@@ -5216,8 +5216,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5216
5216
|
* or doesn't carry the metadata.
|
|
5217
5217
|
*/
|
|
5218
5218
|
extractSpentOutpoint(error) {
|
|
5219
|
-
const ark =
|
|
5220
|
-
if (!
|
|
5219
|
+
const ark = chunk6AFUNKK7_cjs.maybeArkError(error);
|
|
5220
|
+
if (!chunk6AFUNKK7_cjs.isArkError(ark, chunk6AFUNKK7_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5221
5221
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5222
5222
|
if (typeof raw !== "string") return void 0;
|
|
5223
5223
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -5407,7 +5407,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5407
5407
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
5408
5408
|
break;
|
|
5409
5409
|
}
|
|
5410
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5410
|
+
const inputFee = estimator.evalOffchainInput(chunk6AFUNKK7_cjs.toOffchainInputFeeParams(v));
|
|
5411
5411
|
if (inputFee.satoshis >= v.value) {
|
|
5412
5412
|
continue;
|
|
5413
5413
|
}
|
|
@@ -5427,7 +5427,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5427
5427
|
const arkAddress = await this.wallet.getAddress();
|
|
5428
5428
|
const outputFee = estimator.evalOffchainOutput({
|
|
5429
5429
|
amount: totalAmount,
|
|
5430
|
-
script: base.hex.encode(
|
|
5430
|
+
script: base.hex.encode(chunk6AFUNKK7_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
5431
5431
|
});
|
|
5432
5432
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
5433
5433
|
if (totalAmount < dustAmount) return;
|
|
@@ -5507,7 +5507,7 @@ var ArkNote = class _ArkNote {
|
|
|
5507
5507
|
this.value = value;
|
|
5508
5508
|
this.HRP = HRP;
|
|
5509
5509
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
5510
|
-
this.vtxoScript = new
|
|
5510
|
+
this.vtxoScript = new chunk6AFUNKK7_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
5511
5511
|
const leaf = this.vtxoScript.leaves[0];
|
|
5512
5512
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
5513
5513
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -5674,7 +5674,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5674
5674
|
const privateKey = data.slice(1, 33);
|
|
5675
5675
|
const serverPubKey = data.slice(33, 65);
|
|
5676
5676
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
5677
|
-
const csvTimelock =
|
|
5677
|
+
const csvTimelock = chunk6AFUNKK7_cjs.sequenceToTimelock(sequence);
|
|
5678
5678
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
5679
5679
|
}
|
|
5680
5680
|
toString() {
|
|
@@ -5682,7 +5682,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5682
5682
|
data[0] = _ArkadeCash.Version;
|
|
5683
5683
|
data.set(this._privateKey, 1);
|
|
5684
5684
|
data.set(this._serverPubKey, 33);
|
|
5685
|
-
const sequence =
|
|
5685
|
+
const sequence = chunk6AFUNKK7_cjs.timelockToSequence(this.csvTimelock);
|
|
5686
5686
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
5687
5687
|
const words = base.bech32m.toWords(data);
|
|
5688
5688
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -5691,7 +5691,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5691
5691
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
5692
5692
|
}
|
|
5693
5693
|
get vtxoScript() {
|
|
5694
|
-
return new
|
|
5694
|
+
return new chunkHL7EC2Z5_cjs.DefaultVtxo.Script({
|
|
5695
5695
|
pubKey: this._publicKey,
|
|
5696
5696
|
serverPubKey: this._serverPubKey,
|
|
5697
5697
|
csvTimelock: this.csvTimelock
|
|
@@ -5952,7 +5952,7 @@ async function captureExitBranch(params) {
|
|
|
5952
5952
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
5953
5953
|
if (nonCommitment.length > 0) {
|
|
5954
5954
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
5955
|
-
psbtByTxid.set(
|
|
5955
|
+
psbtByTxid.set(chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5956
5956
|
}
|
|
5957
5957
|
}
|
|
5958
5958
|
}
|
|
@@ -5995,10 +5995,10 @@ var IndexerExitDataSource = class {
|
|
|
5995
5995
|
while (hasMore) {
|
|
5996
5996
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
5997
5997
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
5998
|
-
{ pageIndex, pageSize:
|
|
5998
|
+
{ pageIndex, pageSize: chunk6AFUNKK7_cjs.DEFAULT_PAGE_SIZE }
|
|
5999
5999
|
);
|
|
6000
6000
|
chain.push(...page);
|
|
6001
|
-
hasMore = meta ? page.length ===
|
|
6001
|
+
hasMore = meta ? page.length === chunk6AFUNKK7_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6002
6002
|
pageIndex++;
|
|
6003
6003
|
}
|
|
6004
6004
|
return chain;
|
|
@@ -6010,12 +6010,12 @@ var IndexerExitDataSource = class {
|
|
|
6010
6010
|
while (hasMore) {
|
|
6011
6011
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
6012
6012
|
pageIndex,
|
|
6013
|
-
pageSize:
|
|
6013
|
+
pageSize: chunk6AFUNKK7_cjs.DEFAULT_PAGE_SIZE
|
|
6014
6014
|
});
|
|
6015
6015
|
for (const psbt of txs) {
|
|
6016
|
-
out.set(
|
|
6016
|
+
out.set(chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6017
6017
|
}
|
|
6018
|
-
hasMore = page ? txs.length ===
|
|
6018
|
+
hasMore = page ? txs.length === chunk6AFUNKK7_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6019
6019
|
pageIndex++;
|
|
6020
6020
|
}
|
|
6021
6021
|
return out;
|
|
@@ -6036,7 +6036,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
6036
6036
|
}
|
|
6037
6037
|
}
|
|
6038
6038
|
function psbtInputTxids(psbtBase64) {
|
|
6039
|
-
const tx =
|
|
6039
|
+
const tx = chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
6040
6040
|
const ids = [];
|
|
6041
6041
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
6042
6042
|
const txid = tx.getInput(i).txid;
|
|
@@ -6390,15 +6390,15 @@ async function saveArkInfoSnapshot(repo, info, savedAt) {
|
|
|
6390
6390
|
}
|
|
6391
6391
|
}));
|
|
6392
6392
|
}
|
|
6393
|
-
async function resolveArkInfo(arkProvider, walletRepository) {
|
|
6393
|
+
async function resolveArkInfo(arkProvider, walletRepository, opts) {
|
|
6394
6394
|
let info;
|
|
6395
6395
|
try {
|
|
6396
6396
|
info = await arkProvider.getInfo();
|
|
6397
6397
|
} catch (err) {
|
|
6398
|
-
if (!
|
|
6398
|
+
if (opts?.requireLive || !chunk6AFUNKK7_cjs.isRetryableProviderError(err)) throw err;
|
|
6399
6399
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
6400
6400
|
if (!snapshot) {
|
|
6401
|
-
throw new
|
|
6401
|
+
throw new chunk6AFUNKK7_cjs.ProviderUnavailableError(
|
|
6402
6402
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
6403
6403
|
{ cause: err }
|
|
6404
6404
|
);
|
|
@@ -6788,7 +6788,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
6788
6788
|
return [...txids];
|
|
6789
6789
|
}
|
|
6790
6790
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
6791
|
-
const fromOldestVtxo = vtxos.map(
|
|
6791
|
+
const fromOldestVtxo = vtxos.map(chunk6AFUNKK7_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
6792
6792
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
6793
6793
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
6794
6794
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -6952,7 +6952,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6952
6952
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
6953
6953
|
withRecoverable: false
|
|
6954
6954
|
});
|
|
6955
|
-
const controlAssetRef = params.controlAssetId ?
|
|
6955
|
+
const controlAssetRef = params.controlAssetId ? chunkCZ32XADN_cjs.AssetRef.fromId(chunkCZ32XADN_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
6956
6956
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
6957
6957
|
let totalBtcSelected = 0n;
|
|
6958
6958
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -6965,8 +6965,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6965
6965
|
}
|
|
6966
6966
|
}
|
|
6967
6967
|
const groups = [];
|
|
6968
|
-
const issuedAssetOutput =
|
|
6969
|
-
const issuedAssetGroup =
|
|
6968
|
+
const issuedAssetOutput = chunkCZ32XADN_cjs.AssetOutput.create(0, params.amount);
|
|
6969
|
+
const issuedAssetGroup = chunkCZ32XADN_cjs.AssetGroup.create(
|
|
6970
6970
|
null,
|
|
6971
6971
|
controlAssetRef,
|
|
6972
6972
|
[],
|
|
@@ -6981,28 +6981,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6981
6981
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6982
6982
|
for (const asset of assets) {
|
|
6983
6983
|
if (asset.assetId !== assetId) continue;
|
|
6984
|
-
changeInputs.push(
|
|
6984
|
+
changeInputs.push(chunkCZ32XADN_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6985
6985
|
}
|
|
6986
6986
|
}
|
|
6987
6987
|
groups.push(
|
|
6988
|
-
|
|
6989
|
-
|
|
6988
|
+
chunkCZ32XADN_cjs.AssetGroup.create(
|
|
6989
|
+
chunkCZ32XADN_cjs.AssetId.fromString(assetId),
|
|
6990
6990
|
null,
|
|
6991
6991
|
changeInputs,
|
|
6992
|
-
[
|
|
6992
|
+
[chunkCZ32XADN_cjs.AssetOutput.create(0, amount)],
|
|
6993
6993
|
[]
|
|
6994
6994
|
)
|
|
6995
6995
|
);
|
|
6996
6996
|
}
|
|
6997
6997
|
}
|
|
6998
6998
|
const address = await this.wallet.getAddress();
|
|
6999
|
-
const outputAddress =
|
|
6999
|
+
const outputAddress = chunk6AFUNKK7_cjs.ArkAddress.decode(address);
|
|
7000
7000
|
const outputs = [
|
|
7001
7001
|
{
|
|
7002
7002
|
script: outputAddress.pkScript,
|
|
7003
7003
|
amount: BigInt(totalBtcSelected)
|
|
7004
7004
|
},
|
|
7005
|
-
Extension.create([
|
|
7005
|
+
Extension.create([chunkCZ32XADN_cjs.Packet.create(groups)]).txOut()
|
|
7006
7006
|
];
|
|
7007
7007
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
7008
7008
|
coinSelection.inputs,
|
|
@@ -7010,7 +7010,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7010
7010
|
);
|
|
7011
7011
|
return {
|
|
7012
7012
|
arkTxId: arkTxid,
|
|
7013
|
-
assetId:
|
|
7013
|
+
assetId: chunkCZ32XADN_cjs.AssetId.create(arkTxid, 0).toString()
|
|
7014
7014
|
};
|
|
7015
7015
|
}
|
|
7016
7016
|
/**
|
|
@@ -7082,16 +7082,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7082
7082
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7083
7083
|
for (const asset of assets) {
|
|
7084
7084
|
if (asset.assetId !== params.assetId) continue;
|
|
7085
|
-
reissueInputs.push(
|
|
7085
|
+
reissueInputs.push(chunkCZ32XADN_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7086
7086
|
}
|
|
7087
7087
|
}
|
|
7088
7088
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7089
|
-
const reissueAssetIdObj =
|
|
7090
|
-
const reissueAssetGroup =
|
|
7089
|
+
const reissueAssetIdObj = chunkCZ32XADN_cjs.AssetId.fromString(params.assetId);
|
|
7090
|
+
const reissueAssetGroup = chunkCZ32XADN_cjs.AssetGroup.create(
|
|
7091
7091
|
reissueAssetIdObj,
|
|
7092
7092
|
null,
|
|
7093
7093
|
reissueInputs,
|
|
7094
|
-
[
|
|
7094
|
+
[chunkCZ32XADN_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7095
7095
|
[]
|
|
7096
7096
|
);
|
|
7097
7097
|
const groups = [reissueAssetGroup];
|
|
@@ -7100,27 +7100,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7100
7100
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7101
7101
|
for (const asset of assets) {
|
|
7102
7102
|
if (asset.assetId !== assetId) continue;
|
|
7103
|
-
changeInputs.push(
|
|
7103
|
+
changeInputs.push(chunkCZ32XADN_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7104
7104
|
}
|
|
7105
7105
|
}
|
|
7106
7106
|
groups.push(
|
|
7107
|
-
|
|
7108
|
-
|
|
7107
|
+
chunkCZ32XADN_cjs.AssetGroup.create(
|
|
7108
|
+
chunkCZ32XADN_cjs.AssetId.fromString(assetId),
|
|
7109
7109
|
null,
|
|
7110
7110
|
changeInputs,
|
|
7111
|
-
[
|
|
7111
|
+
[chunkCZ32XADN_cjs.AssetOutput.create(0, amount)],
|
|
7112
7112
|
[]
|
|
7113
7113
|
)
|
|
7114
7114
|
);
|
|
7115
7115
|
}
|
|
7116
7116
|
const address = await this.wallet.getAddress();
|
|
7117
|
-
const outputAddress =
|
|
7117
|
+
const outputAddress = chunk6AFUNKK7_cjs.ArkAddress.decode(address);
|
|
7118
7118
|
const outputs = [
|
|
7119
7119
|
{
|
|
7120
7120
|
script: outputAddress.pkScript,
|
|
7121
7121
|
amount: BigInt(totalBtcSelected)
|
|
7122
7122
|
},
|
|
7123
|
-
Extension.create([
|
|
7123
|
+
Extension.create([chunkCZ32XADN_cjs.Packet.create(groups)]).txOut()
|
|
7124
7124
|
];
|
|
7125
7125
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7126
7126
|
return arkTxid;
|
|
@@ -7187,27 +7187,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7187
7187
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7188
7188
|
for (const asset of assets) {
|
|
7189
7189
|
if (asset.assetId !== assetId) continue;
|
|
7190
|
-
changeInputs.push(
|
|
7190
|
+
changeInputs.push(chunkCZ32XADN_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7191
7191
|
}
|
|
7192
7192
|
}
|
|
7193
7193
|
groups.push(
|
|
7194
|
-
|
|
7195
|
-
|
|
7194
|
+
chunkCZ32XADN_cjs.AssetGroup.create(
|
|
7195
|
+
chunkCZ32XADN_cjs.AssetId.fromString(assetId),
|
|
7196
7196
|
null,
|
|
7197
7197
|
changeInputs,
|
|
7198
|
-
amount > 0n ? [
|
|
7198
|
+
amount > 0n ? [chunkCZ32XADN_cjs.AssetOutput.create(0, amount)] : [],
|
|
7199
7199
|
[]
|
|
7200
7200
|
)
|
|
7201
7201
|
);
|
|
7202
7202
|
}
|
|
7203
7203
|
const address = await this.wallet.getAddress();
|
|
7204
|
-
const outputAddress =
|
|
7204
|
+
const outputAddress = chunk6AFUNKK7_cjs.ArkAddress.decode(address);
|
|
7205
7205
|
const outputs = [
|
|
7206
7206
|
{
|
|
7207
7207
|
script: outputAddress.pkScript,
|
|
7208
7208
|
amount: BigInt(totalBtcSelected)
|
|
7209
7209
|
},
|
|
7210
|
-
Extension.create([
|
|
7210
|
+
Extension.create([chunkCZ32XADN_cjs.Packet.create(groups)]).txOut()
|
|
7211
7211
|
];
|
|
7212
7212
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7213
7213
|
return arkTxid;
|
|
@@ -7232,7 +7232,7 @@ function castMetadata(metadata) {
|
|
|
7232
7232
|
} else {
|
|
7233
7233
|
throw new Error("Invalid metadata value type");
|
|
7234
7234
|
}
|
|
7235
|
-
md.push(
|
|
7235
|
+
md.push(chunkCZ32XADN_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7236
7236
|
}
|
|
7237
7237
|
return md;
|
|
7238
7238
|
}
|
|
@@ -7253,10 +7253,10 @@ var DelegateManagerImpl = class {
|
|
|
7253
7253
|
if (vtxos.length === 0) {
|
|
7254
7254
|
return { delegated: [], failed: [] };
|
|
7255
7255
|
}
|
|
7256
|
-
const destinationScript =
|
|
7256
|
+
const destinationScript = chunk6AFUNKK7_cjs.ArkAddress.decode(destination).pkScript;
|
|
7257
7257
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
7258
7258
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
7259
|
-
const eligible = vtxos.map(
|
|
7259
|
+
const eligible = vtxos.map(chunk6AFUNKK7_cjs.normalizeVtxo).filter(
|
|
7260
7260
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7261
7261
|
);
|
|
7262
7262
|
if (eligible.length === 0) {
|
|
@@ -7285,11 +7285,11 @@ var DelegateManagerImpl = class {
|
|
|
7285
7285
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7286
7286
|
let recoverableVtxos = [];
|
|
7287
7287
|
for (const vtxo of eligible) {
|
|
7288
|
-
if (
|
|
7288
|
+
if (chunk6AFUNKK7_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7289
7289
|
recoverableVtxos.push(vtxo);
|
|
7290
7290
|
continue;
|
|
7291
7291
|
}
|
|
7292
|
-
const expiry =
|
|
7292
|
+
const expiry = chunk6AFUNKK7_cjs.toBatchExpiry(vtxo);
|
|
7293
7293
|
if (!expiry) continue;
|
|
7294
7294
|
const dayKey = getDayTimestamp(expiry);
|
|
7295
7295
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -7354,7 +7354,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7354
7354
|
}
|
|
7355
7355
|
if (!delegateAt) {
|
|
7356
7356
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7357
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7357
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunk6AFUNKK7_cjs.canRecoverOnchain(coin, now) && chunk6AFUNKK7_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunk6AFUNKK7_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
7358
7358
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
7359
7359
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
7360
7360
|
} else {
|
|
@@ -7383,7 +7383,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7383
7383
|
let amount = 0n;
|
|
7384
7384
|
for (const coin of vtxos) {
|
|
7385
7385
|
const inputFee = estimator.evalOffchainInput({
|
|
7386
|
-
...
|
|
7386
|
+
...chunk6AFUNKK7_cjs.toOffchainInputFeeParams(coin),
|
|
7387
7387
|
type: "vtxo"
|
|
7388
7388
|
});
|
|
7389
7389
|
if (inputFee.value >= coin.value) {
|
|
@@ -7397,7 +7397,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7397
7397
|
const delegateFee = BigInt(Number(fee));
|
|
7398
7398
|
if (delegateFee > 0n) {
|
|
7399
7399
|
outputs.push({
|
|
7400
|
-
script:
|
|
7400
|
+
script: chunk6AFUNKK7_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
7401
7401
|
amount: delegateFee
|
|
7402
7402
|
});
|
|
7403
7403
|
}
|
|
@@ -7430,10 +7430,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7430
7430
|
destinationScript
|
|
7431
7431
|
);
|
|
7432
7432
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
7433
|
-
btcSigner.Address(
|
|
7433
|
+
btcSigner.Address(chunk6AFUNKK7_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
7434
7434
|
);
|
|
7435
7435
|
const forfeits = await Promise.all(
|
|
7436
|
-
vtxos.filter((v) => !
|
|
7436
|
+
vtxos.filter((v) => !chunk6AFUNKK7_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
7437
7437
|
const forfeit = await makeDelegateForfeitTx(
|
|
7438
7438
|
coin,
|
|
7439
7439
|
dust,
|
|
@@ -7458,7 +7458,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
7458
7458
|
index: input.vout,
|
|
7459
7459
|
witnessUtxo: {
|
|
7460
7460
|
amount: BigInt(input.value),
|
|
7461
|
-
script:
|
|
7461
|
+
script: chunk6AFUNKK7_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
7462
7462
|
},
|
|
7463
7463
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
7464
7464
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -7516,7 +7516,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
7516
7516
|
expire_at: 0,
|
|
7517
7517
|
cosigners_public_keys: cosignerPubKeys
|
|
7518
7518
|
};
|
|
7519
|
-
const proof =
|
|
7519
|
+
const proof = chunk6AFUNKK7_cjs.Intent.create(message, coins, outputs);
|
|
7520
7520
|
const signedProof = await identity.sign(proof);
|
|
7521
7521
|
return {
|
|
7522
7522
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -7534,10 +7534,10 @@ function getDayTimestamp(timestamp) {
|
|
|
7534
7534
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
7535
7535
|
if (!vtxo.tapTree) return void 0;
|
|
7536
7536
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
7537
|
-
const vtxoScript =
|
|
7537
|
+
const vtxoScript = chunk6AFUNKK7_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
7538
7538
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
7539
|
-
const arkTapscript =
|
|
7540
|
-
if (!
|
|
7539
|
+
const arkTapscript = chunk6AFUNKK7_cjs.decodeTapscript(chunk6AFUNKK7_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
7540
|
+
if (!chunk6AFUNKK7_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
7541
7541
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
7542
7542
|
});
|
|
7543
7543
|
}
|
|
@@ -7818,7 +7818,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
|
|
|
7818
7818
|
};
|
|
7819
7819
|
}
|
|
7820
7820
|
function scriptFromArkAddress(address) {
|
|
7821
|
-
return base.hex.encode(
|
|
7821
|
+
return base.hex.encode(chunk6AFUNKK7_cjs.ArkAddress.decode(address).pkScript);
|
|
7822
7822
|
}
|
|
7823
7823
|
|
|
7824
7824
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -8313,7 +8313,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
8313
8313
|
}
|
|
8314
8314
|
async function getVtxosForContract(repo, contract) {
|
|
8315
8315
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
8316
|
-
return vtxos.map(
|
|
8316
|
+
return vtxos.map(chunk6AFUNKK7_cjs.normalizeVtxo);
|
|
8317
8317
|
}
|
|
8318
8318
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
8319
8319
|
if (repo.saveVtxosForScript) {
|
|
@@ -8455,7 +8455,7 @@ function decodeArkContract(encoded) {
|
|
|
8455
8455
|
}
|
|
8456
8456
|
function contractFromArkContract(encoded, options = {}) {
|
|
8457
8457
|
const parsed = decodeArkContract(encoded);
|
|
8458
|
-
const handler =
|
|
8458
|
+
const handler = chunkHL7EC2Z5_cjs.contractHandlers.get(parsed.type);
|
|
8459
8459
|
if (!handler) {
|
|
8460
8460
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8461
8461
|
}
|
|
@@ -8469,9 +8469,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8469
8469
|
metadata: options.metadata
|
|
8470
8470
|
};
|
|
8471
8471
|
}
|
|
8472
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8472
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunk6AFUNKK7_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8473
8473
|
const parsed = decodeArkContract(encoded);
|
|
8474
|
-
const handler =
|
|
8474
|
+
const handler = chunkHL7EC2Z5_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8475
8475
|
const params = parsed.data;
|
|
8476
8476
|
const vtxoScript = handler.createScript(params);
|
|
8477
8477
|
return {
|
|
@@ -8725,9 +8725,9 @@ var ContractWatcher = class {
|
|
|
8725
8725
|
this.connectionState = "connected";
|
|
8726
8726
|
this.reconnectAttempts = 0;
|
|
8727
8727
|
this.listenLoop().catch((e) => {
|
|
8728
|
-
if (
|
|
8728
|
+
if (chunk6AFUNKK7_cjs.isEventSourceError(e)) {
|
|
8729
8729
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8730
|
-
} else if (!
|
|
8730
|
+
} else if (!chunk6AFUNKK7_cjs.isEventSourceUnavailableError(e)) {
|
|
8731
8731
|
console.error(e);
|
|
8732
8732
|
}
|
|
8733
8733
|
this.connectionState = "disconnected";
|
|
@@ -8739,7 +8739,7 @@ var ContractWatcher = class {
|
|
|
8739
8739
|
this.scheduleReconnect();
|
|
8740
8740
|
});
|
|
8741
8741
|
} catch (error) {
|
|
8742
|
-
if (!
|
|
8742
|
+
if (!chunk6AFUNKK7_cjs.isEventSourceUnavailableError(error)) {
|
|
8743
8743
|
console.error("ContractWatcher connection failed:", error);
|
|
8744
8744
|
}
|
|
8745
8745
|
this.connectionState = "disconnected";
|
|
@@ -8765,7 +8765,7 @@ var ContractWatcher = class {
|
|
|
8765
8765
|
* slower; what it loses is push latency.
|
|
8766
8766
|
*/
|
|
8767
8767
|
reportEventSourceUnavailable(error) {
|
|
8768
|
-
if (!
|
|
8768
|
+
if (!chunk6AFUNKK7_cjs.isEventSourceUnavailableError(error)) return false;
|
|
8769
8769
|
if (!this.eventSourceReported) {
|
|
8770
8770
|
this.eventSourceReported = true;
|
|
8771
8771
|
console.warn(
|
|
@@ -8981,14 +8981,14 @@ var ContractWatcher = class {
|
|
|
8981
8981
|
const timestamp = Date.now();
|
|
8982
8982
|
if (update.newVtxos?.length) {
|
|
8983
8983
|
this.processSubscriptionVtxos(
|
|
8984
|
-
update.newVtxos.map(
|
|
8984
|
+
update.newVtxos.map(chunk6AFUNKK7_cjs.normalizeVtxo),
|
|
8985
8985
|
"vtxo_received",
|
|
8986
8986
|
timestamp
|
|
8987
8987
|
);
|
|
8988
8988
|
}
|
|
8989
8989
|
if (update.spentVtxos?.length) {
|
|
8990
8990
|
this.processSubscriptionVtxos(
|
|
8991
|
-
update.spentVtxos.map(
|
|
8991
|
+
update.spentVtxos.map(chunk6AFUNKK7_cjs.normalizeVtxo),
|
|
8992
8992
|
"vtxo_spent",
|
|
8993
8993
|
timestamp
|
|
8994
8994
|
);
|
|
@@ -9083,7 +9083,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
|
|
|
9083
9083
|
(s) => !isTerminalIntentState(s)
|
|
9084
9084
|
);
|
|
9085
9085
|
function isConsumed(vtxo) {
|
|
9086
|
-
return vtxo !== void 0 &&
|
|
9086
|
+
return vtxo !== void 0 && chunk6AFUNKK7_cjs.hasTerminalSpend(vtxo);
|
|
9087
9087
|
}
|
|
9088
9088
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
9089
9089
|
if (isTerminalIntentState(intent.state)) return void 0;
|
|
@@ -9126,7 +9126,7 @@ async function reconcileIntents(deps) {
|
|
|
9126
9126
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
9127
9127
|
if (outpoints.length > 0) {
|
|
9128
9128
|
try {
|
|
9129
|
-
const { vtxos } = await
|
|
9129
|
+
const { vtxos } = await chunk6AFUNKK7_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
9130
9130
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
9131
9131
|
} catch (e) {
|
|
9132
9132
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9300,7 +9300,7 @@ var ContractManager = class _ContractManager {
|
|
|
9300
9300
|
await this.reconcileWatched();
|
|
9301
9301
|
this.markSyncOnline();
|
|
9302
9302
|
} catch (err) {
|
|
9303
|
-
if (!
|
|
9303
|
+
if (!chunk6AFUNKK7_cjs.isRetryableProviderError(err)) throw err;
|
|
9304
9304
|
this.markSyncDegraded(err);
|
|
9305
9305
|
}
|
|
9306
9306
|
this.initialized = true;
|
|
@@ -9432,7 +9432,7 @@ var ContractManager = class _ContractManager {
|
|
|
9432
9432
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9433
9433
|
const to = watermark + lookAhead.size;
|
|
9434
9434
|
const deps = lookAhead.candidateDeps();
|
|
9435
|
-
const handlers =
|
|
9435
|
+
const handlers = chunkHL7EC2Z5_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkHL7EC2Z5_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9436
9436
|
const band = /* @__PURE__ */ new Map();
|
|
9437
9437
|
for (let index = from; index <= to; index++) {
|
|
9438
9438
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9443,7 +9443,7 @@ var ContractManager = class _ContractManager {
|
|
|
9443
9443
|
index,
|
|
9444
9444
|
params: {
|
|
9445
9445
|
...candidate,
|
|
9446
|
-
...
|
|
9446
|
+
...chunkHL7EC2Z5_cjs.speculativeReceiveMetadata(descriptor)
|
|
9447
9447
|
}
|
|
9448
9448
|
});
|
|
9449
9449
|
}
|
|
@@ -9505,7 +9505,7 @@ var ContractManager = class _ContractManager {
|
|
|
9505
9505
|
});
|
|
9506
9506
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9507
9507
|
} catch (err) {
|
|
9508
|
-
if (!
|
|
9508
|
+
if (!chunk6AFUNKK7_cjs.isRetryableProviderError(err)) throw err;
|
|
9509
9509
|
this.markSyncDegraded(err);
|
|
9510
9510
|
}
|
|
9511
9511
|
}
|
|
@@ -9555,7 +9555,7 @@ var ContractManager = class _ContractManager {
|
|
|
9555
9555
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9556
9556
|
this.markSyncOnline();
|
|
9557
9557
|
} catch (err) {
|
|
9558
|
-
if (!
|
|
9558
|
+
if (!chunk6AFUNKK7_cjs.isRetryableProviderError(err)) throw err;
|
|
9559
9559
|
this.markSyncDegraded(err);
|
|
9560
9560
|
}
|
|
9561
9561
|
await this.watcher.addContract(contract);
|
|
@@ -9592,7 +9592,7 @@ var ContractManager = class _ContractManager {
|
|
|
9592
9592
|
return result;
|
|
9593
9593
|
}
|
|
9594
9594
|
async upsertContractRow(params) {
|
|
9595
|
-
const handler =
|
|
9595
|
+
const handler = chunkHL7EC2Z5_cjs.contractHandlers.get(params.type);
|
|
9596
9596
|
if (!handler) {
|
|
9597
9597
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9598
9598
|
}
|
|
@@ -9692,7 +9692,7 @@ var ContractManager = class _ContractManager {
|
|
|
9692
9692
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
9693
9693
|
);
|
|
9694
9694
|
}
|
|
9695
|
-
const registered =
|
|
9695
|
+
const registered = chunkHL7EC2Z5_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkHL7EC2Z5_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
9696
9696
|
const discoverables = [
|
|
9697
9697
|
...registered.filter((h) => h.type === "boarding"),
|
|
9698
9698
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9827,7 +9827,7 @@ var ContractManager = class _ContractManager {
|
|
|
9827
9827
|
await this.syncContracts({ contracts, pageSize });
|
|
9828
9828
|
this.markSyncOnline();
|
|
9829
9829
|
} catch (err) {
|
|
9830
|
-
if (!
|
|
9830
|
+
if (!chunk6AFUNKK7_cjs.isRetryableProviderError(err)) throw err;
|
|
9831
9831
|
this.markSyncDegraded(err);
|
|
9832
9832
|
}
|
|
9833
9833
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -9848,7 +9848,7 @@ var ContractManager = class _ContractManager {
|
|
|
9848
9848
|
}
|
|
9849
9849
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
9850
9850
|
return vtxos.map(
|
|
9851
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9851
|
+
(vtxo) => extendVirtualCoinForContract(chunk6AFUNKK7_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
9852
9852
|
);
|
|
9853
9853
|
}
|
|
9854
9854
|
/** @inheritdoc */
|
|
@@ -9892,14 +9892,14 @@ var ContractManager = class _ContractManager {
|
|
|
9892
9892
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
9893
9893
|
const asking = vtxos.filter((vtxo) => {
|
|
9894
9894
|
const contract = byScript.get(vtxo.script);
|
|
9895
|
-
return contract !== void 0 &&
|
|
9895
|
+
return contract !== void 0 && chunkHL7EC2Z5_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
9896
9896
|
});
|
|
9897
9897
|
if (asking.length === 0) return refused;
|
|
9898
9898
|
const tip = await this.currentChainTip();
|
|
9899
9899
|
const walletKey = await walletPubKey?.();
|
|
9900
9900
|
for (const vtxo of asking) {
|
|
9901
9901
|
const contract = byScript.get(vtxo.script);
|
|
9902
|
-
const handler =
|
|
9902
|
+
const handler = chunkHL7EC2Z5_cjs.contractHandlers.get(contract.type);
|
|
9903
9903
|
if (!handler?.assertSpendableNow) continue;
|
|
9904
9904
|
const context = {
|
|
9905
9905
|
collaborative: true,
|
|
@@ -9914,7 +9914,7 @@ var ContractManager = class _ContractManager {
|
|
|
9914
9914
|
// the next handler to answer a CSV question would meet a
|
|
9915
9915
|
// TypeError instead of a `false`. Carry the coin only when it
|
|
9916
9916
|
// really is one.
|
|
9917
|
-
vtxo:
|
|
9917
|
+
vtxo: chunk6AFUNKK7_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
9918
9918
|
};
|
|
9919
9919
|
try {
|
|
9920
9920
|
await handler.assertSpendableNow(
|
|
@@ -10070,7 +10070,7 @@ var ContractManager = class _ContractManager {
|
|
|
10070
10070
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
10071
10071
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10072
10072
|
if (!contract) return [];
|
|
10073
|
-
const handler =
|
|
10073
|
+
const handler = chunkHL7EC2Z5_cjs.contractHandlers.get(contract.type);
|
|
10074
10074
|
if (!handler) return [];
|
|
10075
10075
|
const script = handler.createScript(contract.params);
|
|
10076
10076
|
const tip = await this.currentChainTip();
|
|
@@ -10098,7 +10098,7 @@ var ContractManager = class _ContractManager {
|
|
|
10098
10098
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
10099
10099
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10100
10100
|
if (!contract) return [];
|
|
10101
|
-
const handler =
|
|
10101
|
+
const handler = chunkHL7EC2Z5_cjs.contractHandlers.get(contract.type);
|
|
10102
10102
|
if (!handler) return [];
|
|
10103
10103
|
const script = handler.createScript(contract.params);
|
|
10104
10104
|
const context = {
|
|
@@ -10154,7 +10154,7 @@ var ContractManager = class _ContractManager {
|
|
|
10154
10154
|
}
|
|
10155
10155
|
async refreshOutpoints(outpoints) {
|
|
10156
10156
|
if (outpoints.length === 0) return;
|
|
10157
|
-
const { vtxos } = await
|
|
10157
|
+
const { vtxos } = await chunk6AFUNKK7_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
10158
10158
|
outpoints
|
|
10159
10159
|
});
|
|
10160
10160
|
if (vtxos.length === 0) return;
|
|
@@ -10233,7 +10233,7 @@ var ContractManager = class _ContractManager {
|
|
|
10233
10233
|
break;
|
|
10234
10234
|
}
|
|
10235
10235
|
} catch (err) {
|
|
10236
|
-
if (!
|
|
10236
|
+
if (!chunk6AFUNKK7_cjs.isRetryableProviderError(err)) throw err;
|
|
10237
10237
|
this.markSyncDegraded(err);
|
|
10238
10238
|
}
|
|
10239
10239
|
this.emitEvent(event);
|
|
@@ -10312,7 +10312,7 @@ var ContractManager = class _ContractManager {
|
|
|
10312
10312
|
*/
|
|
10313
10313
|
async reconcilePendingFrontier(contracts) {
|
|
10314
10314
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
10315
|
-
const vtxos = await
|
|
10315
|
+
const vtxos = await chunk6AFUNKK7_cjs.getAllNormalizedVtxos(
|
|
10316
10316
|
this.config.indexerProvider,
|
|
10317
10317
|
contracts.map((c) => c.script),
|
|
10318
10318
|
{ pendingOnly: true }
|
|
@@ -10395,7 +10395,7 @@ var ContractManager = class _ContractManager {
|
|
|
10395
10395
|
}
|
|
10396
10396
|
return result;
|
|
10397
10397
|
}
|
|
10398
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10398
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunk6AFUNKK7_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
10399
10399
|
if (contracts.length === 0) {
|
|
10400
10400
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
10401
10401
|
}
|
|
@@ -10411,7 +10411,7 @@ var ContractManager = class _ContractManager {
|
|
|
10411
10411
|
before: syncWindow.before
|
|
10412
10412
|
}
|
|
10413
10413
|
} : {};
|
|
10414
|
-
const vtxos = await
|
|
10414
|
+
const vtxos = await chunk6AFUNKK7_cjs.getAllNormalizedVtxos(
|
|
10415
10415
|
this.config.indexerProvider,
|
|
10416
10416
|
contracts.map((c) => c.script),
|
|
10417
10417
|
{ ...windowOpts, pageSize }
|
|
@@ -10556,7 +10556,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
10556
10556
|
const s = base.hex.decode(t.s);
|
|
10557
10557
|
return [cb, s];
|
|
10558
10558
|
};
|
|
10559
|
-
var deserializeVtxo = (o) =>
|
|
10559
|
+
var deserializeVtxo = (o) => chunk6AFUNKK7_cjs.normalizeVtxo({
|
|
10560
10560
|
...o,
|
|
10561
10561
|
createdAt: new Date(o.createdAt),
|
|
10562
10562
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -11379,7 +11379,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
11379
11379
|
*/
|
|
11380
11380
|
materializeDescriptorAt(index) {
|
|
11381
11381
|
const descriptor = this.identity.descriptor;
|
|
11382
|
-
const network =
|
|
11382
|
+
const network = chunkHL7EC2Z5_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
11383
11383
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
11384
11384
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
11385
11385
|
if (!keyInfo?.keyExpression) {
|
|
@@ -11527,7 +11527,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11527
11527
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
11528
11528
|
if (!provider) return void 0;
|
|
11529
11529
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
11530
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
11530
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkHL7EC2Z5_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
11531
11531
|
const factoryOpts = {
|
|
11532
11532
|
walletRepository: setup.walletRepository,
|
|
11533
11533
|
contractRepository: setup.contractRepository,
|
|
@@ -11728,7 +11728,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11728
11728
|
};
|
|
11729
11729
|
function deriveLeafPubkey(descriptor) {
|
|
11730
11730
|
try {
|
|
11731
|
-
return
|
|
11731
|
+
return chunkHL7EC2Z5_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
11732
11732
|
} catch (e) {
|
|
11733
11733
|
throw new NonRangeableDescriptorError(
|
|
11734
11734
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -11740,7 +11740,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11740
11740
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
11741
11741
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
11742
11742
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
11743
|
-
const csvTimelock =
|
|
11743
|
+
const csvTimelock = chunk6AFUNKK7_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
11744
11744
|
const base$1 = {
|
|
11745
11745
|
script: base.hex.encode(tapscript.pkScript),
|
|
11746
11746
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -11751,11 +11751,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11751
11751
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
11752
11752
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
11753
11753
|
metadata: {
|
|
11754
|
-
...tagSource && { source:
|
|
11754
|
+
...tagSource && { source: chunkHL7EC2Z5_cjs.WALLET_RECEIVE_SOURCE },
|
|
11755
11755
|
signingDescriptor: descriptor
|
|
11756
11756
|
}
|
|
11757
11757
|
};
|
|
11758
|
-
const params = tapscript instanceof
|
|
11758
|
+
const params = tapscript instanceof chunkHL7EC2Z5_cjs.DelegateVtxo.Script ? {
|
|
11759
11759
|
...base$1,
|
|
11760
11760
|
type: "delegate",
|
|
11761
11761
|
params: {
|
|
@@ -11776,10 +11776,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11776
11776
|
return { tapscript, params };
|
|
11777
11777
|
}
|
|
11778
11778
|
function rebuildTapscript(current, pubKey) {
|
|
11779
|
-
if (current instanceof
|
|
11780
|
-
return new
|
|
11779
|
+
if (current instanceof chunkHL7EC2Z5_cjs.DelegateVtxo.Script) {
|
|
11780
|
+
return new chunkHL7EC2Z5_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
11781
11781
|
}
|
|
11782
|
-
return new
|
|
11782
|
+
return new chunkHL7EC2Z5_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
11783
11783
|
}
|
|
11784
11784
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
11785
11785
|
const candidates = await contractRepository.getContracts({
|
|
@@ -11788,7 +11788,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
11788
11788
|
});
|
|
11789
11789
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
11790
11790
|
const matching = candidates.filter(
|
|
11791
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
11791
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkHL7EC2Z5_cjs.WALLET_RECEIVE_SOURCE
|
|
11792
11792
|
).sort((a, b) => {
|
|
11793
11793
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
11794
11794
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -11844,7 +11844,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
11844
11844
|
}
|
|
11845
11845
|
};
|
|
11846
11846
|
for (const vtxo of vtxos) {
|
|
11847
|
-
if (
|
|
11847
|
+
if (chunk6AFUNKK7_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11848
11848
|
addAssets(owned, vtxo);
|
|
11849
11849
|
if (vtxo.isUnrolled) {
|
|
11850
11850
|
unrolled += vtxo.value;
|
|
@@ -11854,11 +11854,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
11854
11854
|
pendingRecovery += vtxo.value;
|
|
11855
11855
|
continue;
|
|
11856
11856
|
}
|
|
11857
|
-
if (
|
|
11857
|
+
if (chunk6AFUNKK7_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11858
11858
|
recoverable += vtxo.value;
|
|
11859
11859
|
continue;
|
|
11860
11860
|
}
|
|
11861
|
-
if (!
|
|
11861
|
+
if (!chunk6AFUNKK7_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
11862
11862
|
if (vtxo.isPreconfirmed) {
|
|
11863
11863
|
preconfirmed += vtxo.value;
|
|
11864
11864
|
} else {
|
|
@@ -12028,12 +12028,12 @@ var InputSignerRouter = class {
|
|
|
12028
12028
|
};
|
|
12029
12029
|
|
|
12030
12030
|
// src/wallet/wallet.ts
|
|
12031
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
12031
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunk6AFUNKK7_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
12032
12032
|
function intentProofJobs(coins) {
|
|
12033
12033
|
if (coins.length === 0) return [];
|
|
12034
12034
|
const coinJobs = coins.map((coin, i) => ({
|
|
12035
12035
|
index: i + 1,
|
|
12036
|
-
lookupScript:
|
|
12036
|
+
lookupScript: chunk6AFUNKK7_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12037
12037
|
}));
|
|
12038
12038
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12039
12039
|
}
|
|
@@ -12065,7 +12065,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
12065
12065
|
const seen = /* @__PURE__ */ new Set();
|
|
12066
12066
|
const deduped = [];
|
|
12067
12067
|
for (const timelock of timelocks) {
|
|
12068
|
-
const sequence =
|
|
12068
|
+
const sequence = chunk6AFUNKK7_cjs.timelockToSequence(timelock).toString();
|
|
12069
12069
|
if (seen.has(sequence)) continue;
|
|
12070
12070
|
seen.add(sequence);
|
|
12071
12071
|
deduped.push(timelock);
|
|
@@ -12082,7 +12082,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12082
12082
|
state: "active"
|
|
12083
12083
|
});
|
|
12084
12084
|
const newest = candidates.filter(
|
|
12085
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12085
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkHL7EC2Z5_cjs.WALLET_RECEIVE_SOURCE
|
|
12086
12086
|
).sort((a, b) => {
|
|
12087
12087
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12088
12088
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12090,7 +12090,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12090
12090
|
if (!newest?.params.pubKey) return baseline;
|
|
12091
12091
|
try {
|
|
12092
12092
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
12093
|
-
return new
|
|
12093
|
+
return new chunkHL7EC2Z5_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
12094
12094
|
} catch (e) {
|
|
12095
12095
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
12096
12096
|
return baseline;
|
|
@@ -12109,10 +12109,10 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
12109
12109
|
if (vtxo.isUnrolled) {
|
|
12110
12110
|
return !!f.withUnrolled;
|
|
12111
12111
|
}
|
|
12112
|
-
if (
|
|
12112
|
+
if (chunk6AFUNKK7_cjs.hasTerminalSpend(vtxo)) {
|
|
12113
12113
|
return false;
|
|
12114
12114
|
}
|
|
12115
|
-
if (!f.withRecoverable &&
|
|
12115
|
+
if (!f.withRecoverable && chunk6AFUNKK7_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12116
12116
|
return false;
|
|
12117
12117
|
}
|
|
12118
12118
|
return true;
|
|
@@ -12162,10 +12162,11 @@ var ArkadeCashCreateError = class extends Error {
|
|
|
12162
12162
|
cause;
|
|
12163
12163
|
};
|
|
12164
12164
|
var ReadonlyWallet = class _ReadonlyWallet {
|
|
12165
|
-
constructor(identity, network, onchainProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, dustAmount, walletRepository, contractRepository, delegateProvider, watcherConfig, walletContractTimelocks) {
|
|
12165
|
+
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, dustAmount, walletRepository, contractRepository, delegateProvider, watcherConfig, walletContractTimelocks) {
|
|
12166
12166
|
this.identity = identity;
|
|
12167
12167
|
this.network = network;
|
|
12168
12168
|
this.onchainProvider = onchainProvider;
|
|
12169
|
+
this.arkProvider = arkProvider;
|
|
12169
12170
|
this.indexerProvider = indexerProvider;
|
|
12170
12171
|
this.dustAmount = dustAmount;
|
|
12171
12172
|
this.walletRepository = walletRepository;
|
|
@@ -12191,6 +12192,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12191
12192
|
identity;
|
|
12192
12193
|
network;
|
|
12193
12194
|
onchainProvider;
|
|
12195
|
+
arkProvider;
|
|
12194
12196
|
indexerProvider;
|
|
12195
12197
|
dustAmount;
|
|
12196
12198
|
walletRepository;
|
|
@@ -12258,14 +12260,19 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12258
12260
|
*/
|
|
12259
12261
|
_arkServerPublicKey;
|
|
12260
12262
|
/**
|
|
12261
|
-
* Whether
|
|
12262
|
-
*
|
|
12263
|
-
* (`"cache"`).
|
|
12263
|
+
* Whether the LATEST server-info resolution answered live (`"live"`) or
|
|
12264
|
+
* from the cached snapshot because the operator was unreachable
|
|
12265
|
+
* (`"cache"`). Seeded at construction and updated by every
|
|
12266
|
+
* {@link getArkadeInfo} read, so a wallet that booted offline and
|
|
12267
|
+
* recovered stops reporting degraded — and one that just fell back stops
|
|
12268
|
+
* claiming online. Freshness signal for
|
|
12269
|
+
* {@link getProviderConnectionState}.
|
|
12264
12270
|
*/
|
|
12265
12271
|
_serverInfoSource = "live";
|
|
12266
12272
|
/**
|
|
12267
|
-
* Epoch-ms of the last known live operator contact:
|
|
12268
|
-
*
|
|
12273
|
+
* Epoch-ms of the last known live operator contact: the most recent live
|
|
12274
|
+
* resolution (construction or a later {@link getArkadeInfo}), or the
|
|
12275
|
+
* cached snapshot's `savedAt` when the latest resolution fell back.
|
|
12269
12276
|
*/
|
|
12270
12277
|
_serverInfoLastOnlineAt;
|
|
12271
12278
|
/** @see {@link _serverInfoSource} */
|
|
@@ -12273,13 +12280,15 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12273
12280
|
return this._serverInfoSource;
|
|
12274
12281
|
}
|
|
12275
12282
|
/**
|
|
12276
|
-
* Composed provider-connection freshness: the
|
|
12277
|
-
* (
|
|
12278
|
-
* manager
|
|
12279
|
-
*
|
|
12280
|
-
*
|
|
12283
|
+
* Composed provider-connection freshness: the LATEST server-info
|
|
12284
|
+
* resolution (boot, or any later {@link getArkadeInfo} read) combined with
|
|
12285
|
+
* the contract-manager's indexer-sync health, if the manager has been
|
|
12286
|
+
* initialized. Reads no live provider state — it never forces a
|
|
12287
|
+
* `ContractManager` to construct — so it is safe for readonly callers
|
|
12288
|
+
* that only use address/balance APIs.
|
|
12281
12289
|
*
|
|
12282
|
-
* -
|
|
12290
|
+
* - Latest resolution fell back to the cached snapshot → degraded on
|
|
12291
|
+
* `arkade` (`cache`).
|
|
12283
12292
|
* - Otherwise, if the contract manager has degraded to repository data →
|
|
12284
12293
|
* degraded on `indexer` (`repository`).
|
|
12285
12294
|
* - Otherwise online.
|
|
@@ -12325,7 +12334,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12325
12334
|
}
|
|
12326
12335
|
/**
|
|
12327
12336
|
* x-only hex of the operator's deprecated signer keys (from
|
|
12328
|
-
* `
|
|
12337
|
+
* `ArkadeInfo.deprecatedSigners`), cached for the OFFLINE read/watch paths.
|
|
12329
12338
|
* The boarding watch/history surfaces ({@link getBoardingAddresses},
|
|
12330
12339
|
* {@link getBoardingTxs}) fan out over {current} ∪ this set so a deposit at
|
|
12331
12340
|
* a boarding address minted under a now-rotated operator signer keeps being
|
|
@@ -12400,6 +12409,64 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12400
12409
|
get arkServerPublicKey() {
|
|
12401
12410
|
return this._arkServerPublicKey;
|
|
12402
12411
|
}
|
|
12412
|
+
/**
|
|
12413
|
+
* Server info for the Arkade server this wallet is connected to, resolved
|
|
12414
|
+
* exactly as construction resolves it: live wins, a retryable failure
|
|
12415
|
+
* falls back to the snapshot persisted at boot, a terminal one propagates.
|
|
12416
|
+
*
|
|
12417
|
+
* Live rather than the pinned boot snapshot because the fields callers
|
|
12418
|
+
* come here for — `signerPubkey`, `checkpointTapscript`, `fees` — are the
|
|
12419
|
+
* ones a mid-session rotation moves, and a covenant built against a
|
|
12420
|
+
* superseded signer is unspendable.
|
|
12421
|
+
*
|
|
12422
|
+
* One rotation caveat: reading does NOT re-pin the wallet —
|
|
12423
|
+
* {@link arkServerPublicKey}, {@link dustAmount} and the tapscripts move
|
|
12424
|
+
* only through `handleServerInfoChanged`/`rotateServerSigner` — so inside
|
|
12425
|
+
* a rotation window this can report epoch N+1 while the wallet still
|
|
12426
|
+
* spends on N. The window closes on its own: a read that observes a moved
|
|
12427
|
+
* digest makes the provider emit `onServerInfoChanged`, which is what
|
|
12428
|
+
* drives that rotation. A caller about to bind the answer into a covenant
|
|
12429
|
+
* passes `{ requireLive: true }` and fails closed instead of receiving
|
|
12430
|
+
* the boot snapshot.
|
|
12431
|
+
*
|
|
12432
|
+
* @returns The Arkade server's info
|
|
12433
|
+
* @see ArkadeInfo
|
|
12434
|
+
*/
|
|
12435
|
+
async getArkadeInfo(opts) {
|
|
12436
|
+
const { info, source, lastOnlineAt } = await resolveArkInfo(
|
|
12437
|
+
this.arkProvider,
|
|
12438
|
+
this.walletRepository,
|
|
12439
|
+
opts
|
|
12440
|
+
);
|
|
12441
|
+
this._serverInfoSource = source;
|
|
12442
|
+
if (source === "live") {
|
|
12443
|
+
this._serverInfoLastOnlineAt = Date.now();
|
|
12444
|
+
} else if (lastOnlineAt !== void 0) {
|
|
12445
|
+
this._serverInfoLastOnlineAt = lastOnlineAt;
|
|
12446
|
+
}
|
|
12447
|
+
return info;
|
|
12448
|
+
}
|
|
12449
|
+
/**
|
|
12450
|
+
* Chain reads against this wallet's server for scripts it does not own.
|
|
12451
|
+
*
|
|
12452
|
+
* Binds the wallet's own `indexerProvider` — which may be an Expo or
|
|
12453
|
+
* injected one that a caller's hand-built `RestIndexerProvider` would
|
|
12454
|
+
* silently bypass. `getVtxos` goes through
|
|
12455
|
+
* {@link getNormalizedVtxos}, which is what makes every VTXO leaving the
|
|
12456
|
+
* seam carry its canonical facts.
|
|
12457
|
+
*
|
|
12458
|
+
* A bound object rather than the provider itself, so an `IReadonlyWallet`
|
|
12459
|
+
* holder gets `getVtxos`/`getVirtualTxs` and nothing else at runtime.
|
|
12460
|
+
* (`indexerProvider` is still public on the concrete classes, unlike
|
|
12461
|
+
* `arkProvider`, so this narrows the interface rather than the field.)
|
|
12462
|
+
*/
|
|
12463
|
+
async getArkadeReader() {
|
|
12464
|
+
const indexer = this.indexerProvider;
|
|
12465
|
+
return {
|
|
12466
|
+
getVtxos: (opts) => chunk6AFUNKK7_cjs.getNormalizedVtxos(indexer, opts),
|
|
12467
|
+
getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
|
|
12468
|
+
};
|
|
12469
|
+
}
|
|
12403
12470
|
/**
|
|
12404
12471
|
* The wallet's current boarding tapscript (the on-chain onboarding
|
|
12405
12472
|
* target). Read-only from the outside; mutated only via
|
|
@@ -12452,7 +12519,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12452
12519
|
*/
|
|
12453
12520
|
static async setupWalletConfig(config, pubKey) {
|
|
12454
12521
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
12455
|
-
const arkProvider = config.arkProvider || new
|
|
12522
|
+
const arkProvider = config.arkProvider || new chunk6AFUNKK7_cjs.RestArkProvider(arkadeServerUrl);
|
|
12456
12523
|
let indexerProvider = config.indexerProvider;
|
|
12457
12524
|
if (!indexerProvider) {
|
|
12458
12525
|
let indexerUrl = config.indexerUrl;
|
|
@@ -12469,7 +12536,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12469
12536
|
indexerUrl = arkadeServerUrl;
|
|
12470
12537
|
}
|
|
12471
12538
|
}
|
|
12472
|
-
indexerProvider = new
|
|
12539
|
+
indexerProvider = new chunkCZ32XADN_cjs.RestIndexerProvider(indexerUrl);
|
|
12473
12540
|
}
|
|
12474
12541
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
12475
12542
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -12478,7 +12545,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12478
12545
|
source: serverInfoSource,
|
|
12479
12546
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
12480
12547
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
12481
|
-
const network =
|
|
12548
|
+
const network = chunk6AFUNKK7_cjs.networkFromArkadeInfo(info);
|
|
12482
12549
|
if ("descriptor" in config.identity) {
|
|
12483
12550
|
const descriptor = config.identity.descriptor;
|
|
12484
12551
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -12518,18 +12585,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12518
12585
|
value: info.boardingExitDelay,
|
|
12519
12586
|
type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
|
|
12520
12587
|
};
|
|
12521
|
-
const serverPubKey =
|
|
12522
|
-
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) =>
|
|
12588
|
+
const serverPubKey = chunkHL7EC2Z5_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
12589
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkHL7EC2Z5_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunkHL7EC2Z5_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
|
|
12523
12590
|
const offchainOptions = {
|
|
12524
12591
|
pubKey,
|
|
12525
12592
|
serverPubKey,
|
|
12526
12593
|
csvTimelock: exitTimelock
|
|
12527
12594
|
};
|
|
12528
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
12529
|
-
const boardingTapscript =
|
|
12595
|
+
const offchainTapscript = !delegatePubKey ? new chunkHL7EC2Z5_cjs.DefaultVtxo.Script(offchainOptions) : new chunkHL7EC2Z5_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
12596
|
+
const boardingTapscript = chunkHL7EC2Z5_cjs.BoardingContractHandler.createScript({
|
|
12530
12597
|
pubKey: base.hex.encode(pubKey),
|
|
12531
12598
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12532
|
-
csvTimelock:
|
|
12599
|
+
csvTimelock: chunk6AFUNKK7_cjs.timelockToSequence(boardingTimelock).toString()
|
|
12533
12600
|
});
|
|
12534
12601
|
return {
|
|
12535
12602
|
arkProvider,
|
|
@@ -12568,6 +12635,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12568
12635
|
config.identity,
|
|
12569
12636
|
setup.network,
|
|
12570
12637
|
setup.onchainProvider,
|
|
12638
|
+
setup.arkProvider,
|
|
12571
12639
|
setup.indexerProvider,
|
|
12572
12640
|
setup.serverPubKey,
|
|
12573
12641
|
setup.offchainTapscript,
|
|
@@ -12695,7 +12763,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12695
12763
|
if (!filter?.withUnrolled) {
|
|
12696
12764
|
logExcludedVtxos(
|
|
12697
12765
|
"getSpendableVtxos",
|
|
12698
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
12766
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunk6AFUNKK7_cjs.hasTerminalSpend(vtxo)),
|
|
12699
12767
|
[() => UNROLLED_REASON]
|
|
12700
12768
|
);
|
|
12701
12769
|
}
|
|
@@ -12838,7 +12906,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12838
12906
|
const response = await contractManager.getContractsWithVtxos();
|
|
12839
12907
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
12840
12908
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
12841
|
-
const resolveTxCreatedAt = (txids) =>
|
|
12909
|
+
const resolveTxCreatedAt = (txids) => chunk6AFUNKK7_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
12842
12910
|
return buildTransactionHistory(
|
|
12843
12911
|
allVtxos,
|
|
12844
12912
|
boardingTxs,
|
|
@@ -12932,7 +13000,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12932
13000
|
},
|
|
12933
13001
|
isUnrolled: true,
|
|
12934
13002
|
...boardingFacts,
|
|
12935
|
-
virtualStatus:
|
|
13003
|
+
virtualStatus: chunk6AFUNKK7_cjs.toVirtualStatus(boardingFacts),
|
|
12936
13004
|
spentBy: "",
|
|
12937
13005
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
12938
13006
|
script: scriptHex
|
|
@@ -12988,9 +13056,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12988
13056
|
async getBoardingTapscripts(allowedSigners) {
|
|
12989
13057
|
const byScript = /* @__PURE__ */ new Map();
|
|
12990
13058
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
12991
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
13059
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkHL7EC2Z5_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12992
13060
|
add(
|
|
12993
|
-
new
|
|
13061
|
+
new chunkHL7EC2Z5_cjs.DefaultVtxo.Script({
|
|
12994
13062
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
12995
13063
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
12996
13064
|
csvTimelock: boardingCsv
|
|
@@ -13005,7 +13073,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13005
13073
|
for (const c of boardingContracts) {
|
|
13006
13074
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
13007
13075
|
try {
|
|
13008
|
-
add(
|
|
13076
|
+
add(chunkHL7EC2Z5_cjs.BoardingContractHandler.createScript(c.params));
|
|
13009
13077
|
} catch (e) {
|
|
13010
13078
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
13011
13079
|
}
|
|
@@ -13043,7 +13111,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13043
13111
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
13044
13112
|
// not the wallet's current boarding timelock, which a signer
|
|
13045
13113
|
// rotation may have changed.
|
|
13046
|
-
csvTimelock:
|
|
13114
|
+
csvTimelock: chunk6AFUNKK7_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
13047
13115
|
coins: utxos
|
|
13048
13116
|
});
|
|
13049
13117
|
}
|
|
@@ -13176,7 +13244,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13176
13244
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
13177
13245
|
async fetchPendingTxs() {
|
|
13178
13246
|
const scripts = await this.getWalletScripts();
|
|
13179
|
-
const vtxos = await
|
|
13247
|
+
const vtxos = await chunk6AFUNKK7_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
13180
13248
|
return vtxos.filter(
|
|
13181
13249
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
13182
13250
|
).map((_) => _.arkTxId);
|
|
@@ -13207,7 +13275,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13207
13275
|
});
|
|
13208
13276
|
for (const contract of contracts) {
|
|
13209
13277
|
if (map.has(contract.script)) continue;
|
|
13210
|
-
const handler =
|
|
13278
|
+
const handler = chunkHL7EC2Z5_cjs.contractHandlers.get(contract.type);
|
|
13211
13279
|
if (handler) {
|
|
13212
13280
|
const script = handler.createScript(contract.params);
|
|
13213
13281
|
map.set(contract.script, script);
|
|
@@ -13319,7 +13387,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13319
13387
|
}
|
|
13320
13388
|
});
|
|
13321
13389
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
13322
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
13390
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkHL7EC2Z5_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
13323
13391
|
const baselineSigners = [
|
|
13324
13392
|
this.offchainTapscript.options.serverPubKey,
|
|
13325
13393
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -13327,8 +13395,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13327
13395
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
13328
13396
|
for (const serverPubKey of baselineSigners) {
|
|
13329
13397
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
13330
|
-
const csvTimelockStr =
|
|
13331
|
-
const defaultScript = new
|
|
13398
|
+
const csvTimelockStr = chunk6AFUNKK7_cjs.timelockToSequence(csvTimelock).toString();
|
|
13399
|
+
const defaultScript = new chunkHL7EC2Z5_cjs.DefaultVtxo.Script({
|
|
13332
13400
|
pubKey: baselinePubkey,
|
|
13333
13401
|
serverPubKey,
|
|
13334
13402
|
csvTimelock
|
|
@@ -13349,7 +13417,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13349
13417
|
});
|
|
13350
13418
|
}
|
|
13351
13419
|
if (delegatePubKey) {
|
|
13352
|
-
const delegateScript = new
|
|
13420
|
+
const delegateScript = new chunkHL7EC2Z5_cjs.DelegateVtxo.Script({
|
|
13353
13421
|
pubKey: baselinePubkey,
|
|
13354
13422
|
serverPubKey,
|
|
13355
13423
|
delegatePubKey,
|
|
@@ -13373,9 +13441,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13373
13441
|
}
|
|
13374
13442
|
}
|
|
13375
13443
|
}
|
|
13376
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
13444
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkHL7EC2Z5_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13377
13445
|
for (const serverPubKey of baselineSigners) {
|
|
13378
|
-
const baselineBoarding = new
|
|
13446
|
+
const baselineBoarding = new chunkHL7EC2Z5_cjs.DefaultVtxo.Script({
|
|
13379
13447
|
pubKey: baselinePubkey,
|
|
13380
13448
|
serverPubKey,
|
|
13381
13449
|
csvTimelock: boardingCsvTimelock
|
|
@@ -13388,7 +13456,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13388
13456
|
params: {
|
|
13389
13457
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
13390
13458
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13391
|
-
csvTimelock:
|
|
13459
|
+
csvTimelock: chunk6AFUNKK7_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
13392
13460
|
},
|
|
13393
13461
|
script: boardingScriptHex,
|
|
13394
13462
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -13415,6 +13483,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13415
13483
|
identity,
|
|
13416
13484
|
network,
|
|
13417
13485
|
onchainProvider,
|
|
13486
|
+
arkProvider,
|
|
13418
13487
|
indexerProvider,
|
|
13419
13488
|
arkServerPublicKey,
|
|
13420
13489
|
offchainTapscript,
|
|
@@ -13426,7 +13495,6 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13426
13495
|
watcherConfig,
|
|
13427
13496
|
walletContractTimelocks
|
|
13428
13497
|
);
|
|
13429
|
-
this.arkProvider = arkProvider;
|
|
13430
13498
|
this.forfeitOutputScript = forfeitOutputScript;
|
|
13431
13499
|
this.forfeitPubkey = forfeitPubkey;
|
|
13432
13500
|
this.batchExpiryPolicy = batchExpiryPolicy;
|
|
@@ -13460,7 +13528,6 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13460
13528
|
boardingPkScript: boardingTapscript.pkScript
|
|
13461
13529
|
});
|
|
13462
13530
|
}
|
|
13463
|
-
arkProvider;
|
|
13464
13531
|
forfeitOutputScript;
|
|
13465
13532
|
forfeitPubkey;
|
|
13466
13533
|
batchExpiryPolicy;
|
|
@@ -13588,7 +13655,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13588
13655
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
13589
13656
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
13590
13657
|
csvTimelocks: this.walletContractTimelocks,
|
|
13591
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
13658
|
+
delegatePubKey: this.offchainTapscript instanceof chunkHL7EC2Z5_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
13592
13659
|
};
|
|
13593
13660
|
}
|
|
13594
13661
|
_signerRouter;
|
|
@@ -13623,7 +13690,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13623
13690
|
/**
|
|
13624
13691
|
* Output script for checkpoint transactions, decoded from the server's
|
|
13625
13692
|
* `checkpointTapscript`. Server-controlled state: pinned at construction
|
|
13626
|
-
* and re-sourced from a fresh `
|
|
13693
|
+
* and re-sourced from a fresh `ArkadeInfo` on server-signer rotation. Read it
|
|
13627
13694
|
* through {@link serverUnrollScript}; write it only through
|
|
13628
13695
|
* {@link setServerUnrollScriptForRotation}.
|
|
13629
13696
|
*/
|
|
@@ -13634,7 +13701,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13634
13701
|
/**
|
|
13635
13702
|
* @internal Sole write path for `serverUnrollScript` after construction.
|
|
13636
13703
|
* Called by {@link Wallet._doRotateServerSigner} with the checkpoint script
|
|
13637
|
-
* sourced from the fresh `
|
|
13704
|
+
* sourced from the fresh `ArkadeInfo` that triggered the rotation, so the send
|
|
13638
13705
|
* path builds checkpoints against the new server epoch. External code must
|
|
13639
13706
|
* treat `serverUnrollScript` as read-only.
|
|
13640
13707
|
*/
|
|
@@ -13833,7 +13900,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13833
13900
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
13834
13901
|
const persisted = row?.metadata?.signingDescriptor;
|
|
13835
13902
|
if (typeof persisted === "string") return persisted;
|
|
13836
|
-
return
|
|
13903
|
+
return chunkHL7EC2Z5_cjs.identityDescriptor(this.identity);
|
|
13837
13904
|
}
|
|
13838
13905
|
/**
|
|
13839
13906
|
* Build, persist and shape one address of `type` owned by `descriptor` —
|
|
@@ -13849,7 +13916,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13849
13916
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
13850
13917
|
if (type === "boarding") {
|
|
13851
13918
|
const built2 = this.buildBoardingContract(
|
|
13852
|
-
|
|
13919
|
+
chunkHL7EC2Z5_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
13853
13920
|
descriptor,
|
|
13854
13921
|
tagSource
|
|
13855
13922
|
);
|
|
@@ -13894,11 +13961,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13894
13961
|
* {@link buildReceiveContract}.
|
|
13895
13962
|
*/
|
|
13896
13963
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
13897
|
-
const tapscript = new
|
|
13964
|
+
const tapscript = new chunkHL7EC2Z5_cjs.DefaultVtxo.Script({
|
|
13898
13965
|
...this._boardingTapscript.options,
|
|
13899
13966
|
pubKey
|
|
13900
13967
|
});
|
|
13901
|
-
const csvTimelock = tapscript.options.csvTimelock ??
|
|
13968
|
+
const csvTimelock = tapscript.options.csvTimelock ?? chunkHL7EC2Z5_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13902
13969
|
return {
|
|
13903
13970
|
tapscript,
|
|
13904
13971
|
params: {
|
|
@@ -13906,13 +13973,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13906
13973
|
params: {
|
|
13907
13974
|
pubKey: base.hex.encode(pubKey),
|
|
13908
13975
|
serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
|
|
13909
|
-
csvTimelock:
|
|
13976
|
+
csvTimelock: chunk6AFUNKK7_cjs.timelockToSequence(csvTimelock).toString()
|
|
13910
13977
|
},
|
|
13911
13978
|
script: base.hex.encode(tapscript.pkScript),
|
|
13912
13979
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
13913
13980
|
state: "active",
|
|
13914
13981
|
metadata: {
|
|
13915
|
-
...tagSource && { source:
|
|
13982
|
+
...tagSource && { source: chunkHL7EC2Z5_cjs.WALLET_RECEIVE_SOURCE },
|
|
13916
13983
|
signingDescriptor: descriptor
|
|
13917
13984
|
}
|
|
13918
13985
|
}
|
|
@@ -13941,7 +14008,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13941
14008
|
if (this._descriptorProvider instanceof HDDescriptorProvider) {
|
|
13942
14009
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
13943
14010
|
}
|
|
13944
|
-
return
|
|
14011
|
+
return chunkHL7EC2Z5_cjs.identityDescriptor(this.identity);
|
|
13945
14012
|
}
|
|
13946
14013
|
/**
|
|
13947
14014
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -14037,7 +14104,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14037
14104
|
* the stable public API.
|
|
14038
14105
|
*/
|
|
14039
14106
|
async rotateServerSigner(newServerPubKey, checkpointTapscript) {
|
|
14040
|
-
const xonly =
|
|
14107
|
+
const xonly = chunkHL7EC2Z5_cjs.toXOnly(newServerPubKey, "ark signer key");
|
|
14041
14108
|
const newServerUnrollScript = assertValidServerUnrollScript(
|
|
14042
14109
|
checkpointTapscript,
|
|
14043
14110
|
resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
|
|
@@ -14066,21 +14133,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14066
14133
|
const [currentBoardingRow] = await manager.getContracts({
|
|
14067
14134
|
script: currentBoardingScript
|
|
14068
14135
|
});
|
|
14069
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
14136
|
+
const newOffchain = this.offchainTapscript instanceof chunkHL7EC2Z5_cjs.DelegateVtxo.Script ? new chunkHL7EC2Z5_cjs.DelegateVtxo.Script({
|
|
14070
14137
|
...this.offchainTapscript.options,
|
|
14071
14138
|
serverPubKey: xonly
|
|
14072
|
-
}) : new
|
|
14139
|
+
}) : new chunkHL7EC2Z5_cjs.DefaultVtxo.Script({
|
|
14073
14140
|
...this.offchainTapscript.options,
|
|
14074
14141
|
serverPubKey: xonly
|
|
14075
14142
|
});
|
|
14076
|
-
const newBoarding = new
|
|
14143
|
+
const newBoarding = new chunkHL7EC2Z5_cjs.DefaultVtxo.Script({
|
|
14077
14144
|
...this._boardingTapscript.options,
|
|
14078
14145
|
serverPubKey: xonly
|
|
14079
14146
|
});
|
|
14080
|
-
const offchainCsv =
|
|
14147
|
+
const offchainCsv = chunk6AFUNKK7_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
14081
14148
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
14082
14149
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
14083
|
-
if (newOffchain instanceof
|
|
14150
|
+
if (newOffchain instanceof chunkHL7EC2Z5_cjs.DelegateVtxo.Script) {
|
|
14084
14151
|
await manager.createContract({
|
|
14085
14152
|
type: "delegate",
|
|
14086
14153
|
params: {
|
|
@@ -14108,13 +14175,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14108
14175
|
metadata: currentOffchainRow?.metadata
|
|
14109
14176
|
});
|
|
14110
14177
|
}
|
|
14111
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
14178
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkHL7EC2Z5_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14112
14179
|
await manager.createContract({
|
|
14113
14180
|
type: "boarding",
|
|
14114
14181
|
params: {
|
|
14115
14182
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
14116
14183
|
serverPubKey: base.hex.encode(xonly),
|
|
14117
|
-
csvTimelock:
|
|
14184
|
+
csvTimelock: chunk6AFUNKK7_cjs.timelockToSequence(boardingCsv).toString()
|
|
14118
14185
|
},
|
|
14119
14186
|
script: base.hex.encode(newBoarding.pkScript),
|
|
14120
14187
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -14147,14 +14214,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14147
14214
|
_restoreInFlight;
|
|
14148
14215
|
_addPendingSpends(inputs) {
|
|
14149
14216
|
for (const input of inputs) {
|
|
14150
|
-
if (
|
|
14217
|
+
if (chunk6AFUNKK7_cjs.isVirtualCoin(input)) {
|
|
14151
14218
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
14152
14219
|
}
|
|
14153
14220
|
}
|
|
14154
14221
|
}
|
|
14155
14222
|
_removePendingSpends(inputs) {
|
|
14156
14223
|
for (const input of inputs) {
|
|
14157
|
-
if (
|
|
14224
|
+
if (chunk6AFUNKK7_cjs.isVirtualCoin(input)) {
|
|
14158
14225
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
14159
14226
|
}
|
|
14160
14227
|
}
|
|
@@ -14212,13 +14279,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14212
14279
|
const manager = await this.getContractManager();
|
|
14213
14280
|
const provider = this._descriptorProvider;
|
|
14214
14281
|
const hd = provider instanceof HDDescriptorProvider;
|
|
14215
|
-
const staticDescriptor = hd ? void 0 : await
|
|
14282
|
+
const staticDescriptor = hd ? void 0 : await chunkHL7EC2Z5_cjs.identityDescriptor(this.identity);
|
|
14216
14283
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
14217
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14284
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkHL7EC2Z5_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14218
14285
|
const arkInfo = await this.arkProvider.getInfo();
|
|
14219
|
-
const currentSignerPubKey =
|
|
14286
|
+
const currentSignerPubKey = chunkHL7EC2Z5_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
14220
14287
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
14221
|
-
(s) =>
|
|
14288
|
+
(s) => chunkHL7EC2Z5_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
14222
14289
|
);
|
|
14223
14290
|
const deps = {
|
|
14224
14291
|
indexerProvider: this.indexerProvider,
|
|
@@ -14233,7 +14300,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14233
14300
|
csvTimelocks: this.walletContractTimelocks,
|
|
14234
14301
|
// Boarding-exit CSV so the boarding handler can build its
|
|
14235
14302
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
14236
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
14303
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkHL7EC2Z5_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
14237
14304
|
delegatePubKey
|
|
14238
14305
|
};
|
|
14239
14306
|
const result = await manager.scanContracts({
|
|
@@ -14266,6 +14333,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14266
14333
|
/** @deprecated Use settlementConfig instead */
|
|
14267
14334
|
renewalConfig;
|
|
14268
14335
|
settlementConfig;
|
|
14336
|
+
/**
|
|
14337
|
+
* Broadcast access bound to this wallet's server, so a plugin needs only
|
|
14338
|
+
* the wallet.
|
|
14339
|
+
*
|
|
14340
|
+
* Defined here and not on {@link ReadonlyWallet} for the same reason
|
|
14341
|
+
* `arkProvider` is protected there: a readonly wallet, and every
|
|
14342
|
+
* `toReadonly()` view, must not be able to submit.
|
|
14343
|
+
*/
|
|
14344
|
+
async getArkadeBroadcaster() {
|
|
14345
|
+
const ark = this.arkProvider;
|
|
14346
|
+
return {
|
|
14347
|
+
submitTx: (signedArkTx, checkpointTxs) => ark.submitTx(signedArkTx, checkpointTxs),
|
|
14348
|
+
finalizeTx: (arkTxid, finalCheckpointTxs) => ark.finalizeTx(arkTxid, finalCheckpointTxs)
|
|
14349
|
+
};
|
|
14350
|
+
}
|
|
14269
14351
|
get assetManager() {
|
|
14270
14352
|
this._walletAssetManager ??= new AssetManager(this);
|
|
14271
14353
|
return this._walletAssetManager;
|
|
@@ -14347,7 +14429,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14347
14429
|
throw new Error("Invalid configured public key");
|
|
14348
14430
|
}
|
|
14349
14431
|
const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
|
|
14350
|
-
const forfeitPubkey =
|
|
14432
|
+
const forfeitPubkey = chunkHL7EC2Z5_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
|
|
14351
14433
|
const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
|
|
14352
14434
|
const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
|
|
14353
14435
|
const checkpointExitDelayOverrides = {
|
|
@@ -14445,6 +14527,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14445
14527
|
readonlyIdentity,
|
|
14446
14528
|
this.network,
|
|
14447
14529
|
this.onchainProvider,
|
|
14530
|
+
this.arkProvider,
|
|
14448
14531
|
this.indexerProvider,
|
|
14449
14532
|
this.arkServerPublicKey,
|
|
14450
14533
|
this.offchainTapscript,
|
|
@@ -14496,8 +14579,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14496
14579
|
inputs: params.selectedVtxos,
|
|
14497
14580
|
changeAmount: BigInt(changeAmount)
|
|
14498
14581
|
};
|
|
14499
|
-
const outputAddress =
|
|
14500
|
-
|
|
14582
|
+
const outputAddress = chunk6AFUNKK7_cjs.ArkAddress.decode(params.address);
|
|
14583
|
+
assertRecipientArkadeAddress(
|
|
14501
14584
|
params.address,
|
|
14502
14585
|
outputAddress,
|
|
14503
14586
|
this.recipientAddressContext(serverPubKey)
|
|
@@ -14562,13 +14645,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14562
14645
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
14563
14646
|
}
|
|
14564
14647
|
const offchainAddress = await this.getAddress();
|
|
14565
|
-
const offchainPkScript =
|
|
14648
|
+
const offchainPkScript = chunk6AFUNKK7_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
14566
14649
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
14567
14650
|
if (!params) {
|
|
14568
14651
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
14569
14652
|
const estimator = new Estimator(fees.intentFee);
|
|
14570
14653
|
let amount = 0;
|
|
14571
|
-
const exitScript =
|
|
14654
|
+
const exitScript = chunk6AFUNKK7_cjs.CSVMultisigTapscript.decode(
|
|
14572
14655
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
14573
14656
|
);
|
|
14574
14657
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -14597,7 +14680,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14597
14680
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
14598
14681
|
break;
|
|
14599
14682
|
}
|
|
14600
|
-
const inputFee = estimator.evalOffchainInput(
|
|
14683
|
+
const inputFee = estimator.evalOffchainInput(chunk6AFUNKK7_cjs.toOffchainInputFeeParams(vtxo));
|
|
14601
14684
|
if (inputFee.satoshis >= vtxo.value) {
|
|
14602
14685
|
continue;
|
|
14603
14686
|
}
|
|
@@ -14644,13 +14727,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14644
14727
|
let script;
|
|
14645
14728
|
let arkAddress;
|
|
14646
14729
|
try {
|
|
14647
|
-
arkAddress =
|
|
14730
|
+
arkAddress = chunk6AFUNKK7_cjs.ArkAddress.decode(output.address);
|
|
14648
14731
|
} catch {
|
|
14649
14732
|
arkAddress = void 0;
|
|
14650
14733
|
}
|
|
14651
14734
|
if (arkAddress) {
|
|
14652
14735
|
recipientContext ??= this.recipientAddressContext();
|
|
14653
|
-
|
|
14736
|
+
assertRecipientArkadeAddress(output.address, arkAddress, recipientContext);
|
|
14654
14737
|
script = arkAddress.pkScript;
|
|
14655
14738
|
hasOffchainOutputs = true;
|
|
14656
14739
|
} else {
|
|
@@ -14734,7 +14817,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14734
14817
|
const abortController = new AbortController();
|
|
14735
14818
|
let stream;
|
|
14736
14819
|
let committedTxid;
|
|
14737
|
-
const settleInputVtxos = params.inputs.filter(
|
|
14820
|
+
const settleInputVtxos = params.inputs.filter(chunk6AFUNKK7_cjs.isVirtualCoin);
|
|
14738
14821
|
const contractManager = await this.getContractManager();
|
|
14739
14822
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
14740
14823
|
await contractManager.assertSpendableNow?.(
|
|
@@ -14846,7 +14929,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14846
14929
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
14847
14930
|
if (!this._descriptorProvider) return;
|
|
14848
14931
|
const consumedBoarding = inputs.some(
|
|
14849
|
-
(input) => typeof input !== "string" && !
|
|
14932
|
+
(input) => typeof input !== "string" && !chunk6AFUNKK7_cjs.isVirtualCoin(input)
|
|
14850
14933
|
);
|
|
14851
14934
|
if (!consumedBoarding) return;
|
|
14852
14935
|
try {
|
|
@@ -14870,7 +14953,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14870
14953
|
let connectorIndex = 0;
|
|
14871
14954
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
14872
14955
|
for (const input of inputs) {
|
|
14873
|
-
if (!
|
|
14956
|
+
if (!chunk6AFUNKK7_cjs.isVirtualCoin(input)) {
|
|
14874
14957
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
14875
14958
|
const settlementInput = settlementPsbt.getInput(i);
|
|
14876
14959
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -14901,7 +14984,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14901
14984
|
}
|
|
14902
14985
|
continue;
|
|
14903
14986
|
}
|
|
14904
|
-
if (
|
|
14987
|
+
if (chunk6AFUNKK7_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
14905
14988
|
continue;
|
|
14906
14989
|
}
|
|
14907
14990
|
if (connectorsLeaves.length === 0) {
|
|
@@ -14929,7 +15012,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14929
15012
|
index: input.vout,
|
|
14930
15013
|
witnessUtxo: {
|
|
14931
15014
|
amount: BigInt(input.value),
|
|
14932
|
-
script:
|
|
15015
|
+
script: chunk6AFUNKK7_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14933
15016
|
},
|
|
14934
15017
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
14935
15018
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -14948,7 +15031,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14948
15031
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
14949
15032
|
{
|
|
14950
15033
|
index: 0,
|
|
14951
|
-
lookupScript:
|
|
15034
|
+
lookupScript: chunk6AFUNKK7_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14952
15035
|
}
|
|
14953
15036
|
]);
|
|
14954
15037
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -15006,7 +15089,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15006
15089
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
15007
15090
|
);
|
|
15008
15091
|
await this.arkProvider.confirmRegistration(intentId);
|
|
15009
|
-
const sweepTapscript =
|
|
15092
|
+
const sweepTapscript = chunk6AFUNKK7_cjs.CSVMultisigTapscript.encode({
|
|
15010
15093
|
timelock,
|
|
15011
15094
|
pubkeys: [this.forfeitPubkey]
|
|
15012
15095
|
}).script;
|
|
@@ -15021,10 +15104,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15021
15104
|
throw new Error("Sweep tap tree root not set");
|
|
15022
15105
|
}
|
|
15023
15106
|
const xOnlyPublicKeys = event.cosignersPublicKeys.map(
|
|
15024
|
-
(k) => base.hex.encode(
|
|
15107
|
+
(k) => base.hex.encode(chunkHL7EC2Z5_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
15025
15108
|
);
|
|
15026
15109
|
const signerPublicKey = await session.getPublicKey();
|
|
15027
|
-
const xonlySignerPublicKey =
|
|
15110
|
+
const xonlySignerPublicKey = chunkHL7EC2Z5_cjs.toXOnly(signerPublicKey, "signer key");
|
|
15028
15111
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
15029
15112
|
return { skip: true };
|
|
15030
15113
|
}
|
|
@@ -15114,9 +15197,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15114
15197
|
...existing ?? {},
|
|
15115
15198
|
intentTxId,
|
|
15116
15199
|
registerProof: intent.proof,
|
|
15117
|
-
registerProofMessage:
|
|
15200
|
+
registerProofMessage: chunk6AFUNKK7_cjs.Intent.encodeMessage(intent.message),
|
|
15118
15201
|
deleteProof: deleteIntent.proof,
|
|
15119
|
-
deleteProofMessage:
|
|
15202
|
+
deleteProofMessage: chunk6AFUNKK7_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
15120
15203
|
intentVtxos: inputs.map((i) => ({
|
|
15121
15204
|
txid: i.txid,
|
|
15122
15205
|
vout: i.vout
|
|
@@ -15148,7 +15231,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15148
15231
|
try {
|
|
15149
15232
|
return await this.arkProvider.registerIntent(intent);
|
|
15150
15233
|
} catch (error) {
|
|
15151
|
-
if (error instanceof
|
|
15234
|
+
if (error instanceof chunk6AFUNKK7_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
15152
15235
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
15153
15236
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
15154
15237
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -15164,7 +15247,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15164
15247
|
expire_at: 0,
|
|
15165
15248
|
cosigners_public_keys: cosignerPubKeys
|
|
15166
15249
|
};
|
|
15167
|
-
const proof =
|
|
15250
|
+
const proof = chunk6AFUNKK7_cjs.Intent.create(message, coins, outputs);
|
|
15168
15251
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15169
15252
|
return {
|
|
15170
15253
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15176,7 +15259,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15176
15259
|
type: "delete",
|
|
15177
15260
|
expire_at: 0
|
|
15178
15261
|
};
|
|
15179
|
-
const proof =
|
|
15262
|
+
const proof = chunk6AFUNKK7_cjs.Intent.create(message, coins, []);
|
|
15180
15263
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15181
15264
|
return {
|
|
15182
15265
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15188,7 +15271,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15188
15271
|
type: "get-pending-tx",
|
|
15189
15272
|
expire_at: 0
|
|
15190
15273
|
};
|
|
15191
|
-
const proof =
|
|
15274
|
+
const proof = chunk6AFUNKK7_cjs.Intent.create(message, coins, []);
|
|
15192
15275
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15193
15276
|
return {
|
|
15194
15277
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15209,7 +15292,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15209
15292
|
if (!vtxos || vtxos.length === 0) {
|
|
15210
15293
|
const scriptMap = await this.getScriptMap();
|
|
15211
15294
|
const allExtended = [];
|
|
15212
|
-
const fetchedVtxos = await
|
|
15295
|
+
const fetchedVtxos = await chunk6AFUNKK7_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
15213
15296
|
...scriptMap.keys()
|
|
15214
15297
|
]);
|
|
15215
15298
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -15253,7 +15336,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15253
15336
|
try {
|
|
15254
15337
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
15255
15338
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
|
|
15256
|
-
|
|
15339
|
+
chunk6AFUNKK7_cjs.assertAllowedSighashTypes(tx);
|
|
15257
15340
|
return tx;
|
|
15258
15341
|
});
|
|
15259
15342
|
assertCheckpointsMatchInputs(
|
|
@@ -15325,11 +15408,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15325
15408
|
* against the current key alone would leave it pending forever.
|
|
15326
15409
|
*/
|
|
15327
15410
|
checkpointUnrollCandidates(info) {
|
|
15328
|
-
const current =
|
|
15411
|
+
const current = chunk6AFUNKK7_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
15329
15412
|
const candidates = [this._serverUnrollScript, current];
|
|
15330
15413
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
15331
15414
|
candidates.push(
|
|
15332
|
-
|
|
15415
|
+
chunk6AFUNKK7_cjs.CSVMultisigTapscript.encode({
|
|
15333
15416
|
...current.params,
|
|
15334
15417
|
pubkeys: [base.hex.decode(deprecated)]
|
|
15335
15418
|
})
|
|
@@ -15420,7 +15503,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15420
15503
|
if (vtxos.length === 0) {
|
|
15421
15504
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
15422
15505
|
}
|
|
15423
|
-
const myPkScript =
|
|
15506
|
+
const myPkScript = chunk6AFUNKK7_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
15424
15507
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
15425
15508
|
let swept = 0;
|
|
15426
15509
|
const drainable = vtxos.filter(
|
|
@@ -15496,7 +15579,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15496
15579
|
const spendable = [];
|
|
15497
15580
|
const unclaimed = [];
|
|
15498
15581
|
for (const vtxo of vtxos) {
|
|
15499
|
-
if (
|
|
15582
|
+
if (chunk6AFUNKK7_cjs.hasTerminalSpend(vtxo)) {
|
|
15500
15583
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
15501
15584
|
} else if (vtxo.isUnrolled) {
|
|
15502
15585
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -15518,7 +15601,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15518
15601
|
const all = [];
|
|
15519
15602
|
const seen = /* @__PURE__ */ new Set();
|
|
15520
15603
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
15521
|
-
const { vtxos, page } = await
|
|
15604
|
+
const { vtxos, page } = await chunk6AFUNKK7_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
15522
15605
|
scripts,
|
|
15523
15606
|
pageIndex,
|
|
15524
15607
|
pageSize
|
|
@@ -15565,7 +15648,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15565
15648
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
15566
15649
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
15567
15650
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
15568
|
-
const proof =
|
|
15651
|
+
const proof = chunk6AFUNKK7_cjs.Intent.create(message, batch, []);
|
|
15569
15652
|
const signedProof = await identity.sign(
|
|
15570
15653
|
proof,
|
|
15571
15654
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -15587,7 +15670,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15587
15670
|
try {
|
|
15588
15671
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
15589
15672
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
15590
|
-
|
|
15673
|
+
chunk6AFUNKK7_cjs.assertAllowedSighashTypes(tx);
|
|
15591
15674
|
return tx;
|
|
15592
15675
|
});
|
|
15593
15676
|
assertCheckpointsMatchInputs(
|
|
@@ -15786,7 +15869,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15786
15869
|
script: recipient.script,
|
|
15787
15870
|
amount: BigInt(recipient.amount),
|
|
15788
15871
|
// Already checked against the recipient address in `validateRecipients`.
|
|
15789
|
-
...recipient.tapTree ? { tapTree:
|
|
15872
|
+
...recipient.tapTree ? { tapTree: chunk6AFUNKK7_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
|
|
15790
15873
|
}));
|
|
15791
15874
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
15792
15875
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -15930,10 +16013,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15930
16013
|
const serverPubKey = this.arkServerPublicKey;
|
|
15931
16014
|
const serverUnrollScript = this.serverUnrollScript;
|
|
15932
16015
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
15933
|
-
const normalizedInputs = inputs.map(
|
|
15934
|
-
const at = now ?? await
|
|
16016
|
+
const normalizedInputs = inputs.map(chunk6AFUNKK7_cjs.normalizeVtxo);
|
|
16017
|
+
const at = now ?? await chunk6AFUNKK7_cjs.resolveTimeHeight(this.onchainProvider);
|
|
15935
16018
|
for (const input of normalizedInputs) {
|
|
15936
|
-
if (!
|
|
16019
|
+
if (!chunk6AFUNKK7_cjs.canSpendOffchain(input, at)) {
|
|
15937
16020
|
throw new Error(
|
|
15938
16021
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
15939
16022
|
);
|
|
@@ -16003,7 +16086,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16003
16086
|
);
|
|
16004
16087
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
16005
16088
|
index,
|
|
16006
|
-
lookupScript:
|
|
16089
|
+
lookupScript: chunk6AFUNKK7_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
16007
16090
|
}));
|
|
16008
16091
|
const identity = this.identity;
|
|
16009
16092
|
const signer = {
|
|
@@ -16089,14 +16172,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16089
16172
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
16090
16173
|
spentVtxos.push({
|
|
16091
16174
|
...spentFacts,
|
|
16092
|
-
virtualStatus:
|
|
16175
|
+
virtualStatus: chunk6AFUNKK7_cjs.toVirtualStatus(spentFacts),
|
|
16093
16176
|
...spentBy ? { spentBy } : {},
|
|
16094
16177
|
arkTxId: arkTxid
|
|
16095
16178
|
});
|
|
16096
16179
|
for (const id of vtxo.commitmentTxIds) {
|
|
16097
16180
|
commitmentTxIds.add(id);
|
|
16098
16181
|
}
|
|
16099
|
-
const vtxoExpiry =
|
|
16182
|
+
const vtxoExpiry = chunk6AFUNKK7_cjs.toBatchExpiry(vtxo);
|
|
16100
16183
|
if (vtxoExpiry) {
|
|
16101
16184
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
16102
16185
|
}
|
|
@@ -16109,7 +16192,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16109
16192
|
isSwept: false,
|
|
16110
16193
|
isPreconfirmed: true,
|
|
16111
16194
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
16112
|
-
...
|
|
16195
|
+
...chunk6AFUNKK7_cjs.parseLegacyExpiry(batchExpiry)
|
|
16113
16196
|
};
|
|
16114
16197
|
changeVtxo = {
|
|
16115
16198
|
txid: arkTxid,
|
|
@@ -16121,7 +16204,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16121
16204
|
tapTree: offchainTapscript.encode(),
|
|
16122
16205
|
value: Number(changeAmount),
|
|
16123
16206
|
...changeFacts,
|
|
16124
|
-
virtualStatus:
|
|
16207
|
+
virtualStatus: chunk6AFUNKK7_cjs.toVirtualStatus(changeFacts),
|
|
16125
16208
|
spentBy: "",
|
|
16126
16209
|
status: {
|
|
16127
16210
|
confirmed: false
|
|
@@ -16190,12 +16273,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16190
16273
|
const spentVtxos = [];
|
|
16191
16274
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
16192
16275
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
16193
|
-
const vtxoInputs = inputs.filter(
|
|
16276
|
+
const vtxoInputs = inputs.filter(chunk6AFUNKK7_cjs.isVirtualCoin);
|
|
16194
16277
|
const cm = await this.getContractManager();
|
|
16195
16278
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
16196
16279
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
16197
16280
|
for (const input of inputs) {
|
|
16198
|
-
if (
|
|
16281
|
+
if (chunk6AFUNKK7_cjs.isVirtualCoin(input)) {
|
|
16199
16282
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
16200
16283
|
const vtxo = annotatedByKey.get(outpoint);
|
|
16201
16284
|
if (!vtxo) {
|
|
@@ -16207,13 +16290,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16207
16290
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
16208
16291
|
spentVtxos.push({
|
|
16209
16292
|
...settledFacts,
|
|
16210
|
-
virtualStatus:
|
|
16293
|
+
virtualStatus: chunk6AFUNKK7_cjs.toVirtualStatus(settledFacts),
|
|
16211
16294
|
settledBy: commitmentTxid
|
|
16212
16295
|
});
|
|
16213
16296
|
} else {
|
|
16214
16297
|
let sourceAddress;
|
|
16215
16298
|
try {
|
|
16216
|
-
sourceAddress =
|
|
16299
|
+
sourceAddress = chunk6AFUNKK7_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
16217
16300
|
this.network
|
|
16218
16301
|
);
|
|
16219
16302
|
} catch {
|
|
@@ -16271,9 +16354,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16271
16354
|
}
|
|
16272
16355
|
};
|
|
16273
16356
|
function selectVirtualCoins(coins, targetAmount) {
|
|
16274
|
-
const sortedCoins = coins.map(
|
|
16275
|
-
const expiryA =
|
|
16276
|
-
const expiryB =
|
|
16357
|
+
const sortedCoins = coins.map(chunk6AFUNKK7_cjs.normalizeVtxo).sort((a, b) => {
|
|
16358
|
+
const expiryA = chunk6AFUNKK7_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
16359
|
+
const expiryB = chunk6AFUNKK7_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
16277
16360
|
if (expiryA !== expiryB) {
|
|
16278
16361
|
return expiryA - expiryB;
|
|
16279
16362
|
}
|
|
@@ -16608,7 +16691,7 @@ var MessageBus = class {
|
|
|
16608
16691
|
this.initialized = true;
|
|
16609
16692
|
}
|
|
16610
16693
|
async buildServices(config) {
|
|
16611
|
-
const arkProvider = new
|
|
16694
|
+
const arkProvider = new chunk6AFUNKK7_cjs.RestArkProvider(config.arkServer.url);
|
|
16612
16695
|
const storage = {
|
|
16613
16696
|
walletRepository: this.walletRepository,
|
|
16614
16697
|
contractRepository: this.contractRepository,
|
|
@@ -16854,6 +16937,9 @@ var MessageBus = class {
|
|
|
16854
16937
|
});
|
|
16855
16938
|
return;
|
|
16856
16939
|
}
|
|
16940
|
+
if (response.error instanceof Error && !response.errorName) {
|
|
16941
|
+
response.errorName = response.error.name;
|
|
16942
|
+
}
|
|
16857
16943
|
source.postMessage(response);
|
|
16858
16944
|
}
|
|
16859
16945
|
/**
|
|
@@ -16950,7 +17036,7 @@ var offboardNetworkNames = [
|
|
|
16950
17036
|
function offboardDestinationScript(destinationAddress) {
|
|
16951
17037
|
for (const networkName of offboardNetworkNames) {
|
|
16952
17038
|
try {
|
|
16953
|
-
const network =
|
|
17039
|
+
const network = chunk6AFUNKK7_cjs.networks[networkName];
|
|
16954
17040
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
16955
17041
|
return btcSigner.OutScript.encode(addr);
|
|
16956
17042
|
} catch {
|
|
@@ -17014,7 +17100,7 @@ var Ramps = class {
|
|
|
17014
17100
|
}
|
|
17015
17101
|
amount = amount ?? totalAmount;
|
|
17016
17102
|
const offchainAddress = await this.wallet.getAddress();
|
|
17017
|
-
const offchainAddr =
|
|
17103
|
+
const offchainAddr = chunk6AFUNKK7_cjs.ArkAddress.decode(offchainAddress);
|
|
17018
17104
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
17019
17105
|
const outputFee = estimator.evalOffchainOutput({
|
|
17020
17106
|
amount,
|
|
@@ -17074,7 +17160,7 @@ var Ramps = class {
|
|
|
17074
17160
|
const filteredVtxos = [];
|
|
17075
17161
|
let totalAmount = 0n;
|
|
17076
17162
|
for (const vtxo of vtxos) {
|
|
17077
|
-
const inputFee = estimator.evalOffchainInput(
|
|
17163
|
+
const inputFee = estimator.evalOffchainInput(chunk6AFUNKK7_cjs.toOffchainInputFeeParams(vtxo));
|
|
17078
17164
|
if (inputFee.satoshis >= vtxo.value) {
|
|
17079
17165
|
continue;
|
|
17080
17166
|
}
|
|
@@ -17447,6 +17533,49 @@ var WalletMessageHandler = class {
|
|
|
17447
17533
|
payload: { address }
|
|
17448
17534
|
});
|
|
17449
17535
|
}
|
|
17536
|
+
case "GET_ARKADE_INFO": {
|
|
17537
|
+
const { payload } = message;
|
|
17538
|
+
const info = await this.readonlyWallet.getArkadeInfo(payload);
|
|
17539
|
+
return this.tagged({
|
|
17540
|
+
id,
|
|
17541
|
+
type: "ARKADE_INFO",
|
|
17542
|
+
payload: { info }
|
|
17543
|
+
});
|
|
17544
|
+
}
|
|
17545
|
+
case "INDEXER_GET_VTXOS": {
|
|
17546
|
+
const { opts } = message.payload;
|
|
17547
|
+
const reader = await this.readonlyWallet.getArkadeReader();
|
|
17548
|
+
return this.tagged({
|
|
17549
|
+
id,
|
|
17550
|
+
type: "INDEXER_VTXOS",
|
|
17551
|
+
payload: await reader.getVtxos(opts)
|
|
17552
|
+
});
|
|
17553
|
+
}
|
|
17554
|
+
case "INDEXER_GET_VIRTUAL_TXS": {
|
|
17555
|
+
const { txids, opts } = message.payload;
|
|
17556
|
+
const reader = await this.readonlyWallet.getArkadeReader();
|
|
17557
|
+
return this.tagged({
|
|
17558
|
+
id,
|
|
17559
|
+
type: "INDEXER_VIRTUAL_TXS",
|
|
17560
|
+
payload: await reader.getVirtualTxs(txids, opts)
|
|
17561
|
+
});
|
|
17562
|
+
}
|
|
17563
|
+
case "SUBMIT_TX": {
|
|
17564
|
+
const { signedArkTx, checkpointTxs } = message.payload;
|
|
17565
|
+
const broadcaster = await this.requireWallet().getArkadeBroadcaster();
|
|
17566
|
+
const result = await broadcaster.submitTx(signedArkTx, checkpointTxs);
|
|
17567
|
+
return this.tagged({
|
|
17568
|
+
id,
|
|
17569
|
+
type: "SUBMIT_TX_SUCCESS",
|
|
17570
|
+
payload: result
|
|
17571
|
+
});
|
|
17572
|
+
}
|
|
17573
|
+
case "FINALIZE_TX": {
|
|
17574
|
+
const { arkTxid, finalCheckpointTxs } = message.payload;
|
|
17575
|
+
const broadcaster = await this.requireWallet().getArkadeBroadcaster();
|
|
17576
|
+
await broadcaster.finalizeTx(arkTxid, finalCheckpointTxs);
|
|
17577
|
+
return this.tagged({ id, type: "FINALIZE_TX_SUCCESS" });
|
|
17578
|
+
}
|
|
17450
17579
|
case "GET_BALANCE": {
|
|
17451
17580
|
const balance = await this.handleGetBalance();
|
|
17452
17581
|
return this.tagged({
|
|
@@ -17910,7 +18039,7 @@ var WalletMessageHandler = class {
|
|
|
17910
18039
|
// Wallet methods
|
|
17911
18040
|
async handleInitWallet({ payload }) {
|
|
17912
18041
|
const { arkServerUrl } = payload;
|
|
17913
|
-
this.indexerProvider = new
|
|
18042
|
+
this.indexerProvider = new chunkCZ32XADN_cjs.RestIndexerProvider(arkServerUrl);
|
|
17914
18043
|
await this.onWalletInitialized();
|
|
17915
18044
|
}
|
|
17916
18045
|
/**
|
|
@@ -18199,7 +18328,7 @@ var WalletMessageHandler = class {
|
|
|
18199
18328
|
if (v.isUnrolled) {
|
|
18200
18329
|
return withUnrolled;
|
|
18201
18330
|
}
|
|
18202
|
-
if (
|
|
18331
|
+
if (chunk6AFUNKK7_cjs.hasTerminalSpend(v)) {
|
|
18203
18332
|
return false;
|
|
18204
18333
|
}
|
|
18205
18334
|
if (includeRecoverable) {
|
|
@@ -18208,10 +18337,10 @@ var WalletMessageHandler = class {
|
|
|
18208
18337
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
18209
18338
|
return false;
|
|
18210
18339
|
}
|
|
18211
|
-
if (
|
|
18340
|
+
if (chunk6AFUNKK7_cjs.isRecoverable(v)) {
|
|
18212
18341
|
return false;
|
|
18213
18342
|
}
|
|
18214
|
-
if (
|
|
18343
|
+
if (chunk6AFUNKK7_cjs.isExpired(v)) {
|
|
18215
18344
|
return false;
|
|
18216
18345
|
}
|
|
18217
18346
|
return true;
|
|
@@ -18309,7 +18438,7 @@ var WalletMessageHandler = class {
|
|
|
18309
18438
|
if (!this.readonlyWallet) return null;
|
|
18310
18439
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
18311
18440
|
const indexerProvider = this.indexerProvider;
|
|
18312
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
18441
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunk6AFUNKK7_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
18313
18442
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
18314
18443
|
}
|
|
18315
18444
|
async ensureContractEventBroadcasting() {
|
|
@@ -18338,6 +18467,13 @@ var WalletMessageHandler = class {
|
|
|
18338
18467
|
|
|
18339
18468
|
// src/wallet/serviceWorker/wallet.ts
|
|
18340
18469
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
18470
|
+
var restoreErrorName = (response) => {
|
|
18471
|
+
const error = response.error;
|
|
18472
|
+
if (response.errorName && error instanceof Error && error.name !== response.errorName) {
|
|
18473
|
+
error.name = response.errorName;
|
|
18474
|
+
}
|
|
18475
|
+
return error;
|
|
18476
|
+
};
|
|
18341
18477
|
var INIT_WAIT_BACKOFF_CAP_MS = 2e3;
|
|
18342
18478
|
var MAX_INIT_WAITS = 8;
|
|
18343
18479
|
var initWaitBackoffMs = (attempt) => Math.min(100 * 2 ** attempt, INIT_WAIT_BACKOFF_CAP_MS);
|
|
@@ -18360,6 +18496,14 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
18360
18496
|
GET_USED_SIGNING_DESCRIPTORS: 2e4,
|
|
18361
18497
|
ADVANCE_SIGNING_DESCRIPTOR_WATERMARK: 1e4,
|
|
18362
18498
|
// Medium reads — may involve indexer queries
|
|
18499
|
+
// A live `/v1/info` fetch queued behind the same per-origin rate gate as
|
|
18500
|
+
// the indexer, not a repository read. Derived from the fetch's own abort
|
|
18501
|
+
// budget so the worker's snapshot fallback stays reachable before this
|
|
18502
|
+
// page deadline fires — lowering it below the budget would time the page
|
|
18503
|
+
// out while the worker is still seconds from answering from cache.
|
|
18504
|
+
GET_ARKADE_INFO: chunk6AFUNKK7_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
|
|
18505
|
+
INDEXER_GET_VTXOS: 2e4,
|
|
18506
|
+
INDEXER_GET_VIRTUAL_TXS: 2e4,
|
|
18363
18507
|
GET_VTXOS: 2e4,
|
|
18364
18508
|
GET_SPENDABLE_VTXOS: 2e4,
|
|
18365
18509
|
GET_BOARDING_UTXOS: 2e4,
|
|
@@ -18382,6 +18526,10 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
18382
18526
|
SEND_BITCOIN: 5e4,
|
|
18383
18527
|
SEND: 5e4,
|
|
18384
18528
|
SETTLE: 5e4,
|
|
18529
|
+
// Broadcast: the server round-trip a spend ends in, so it belongs
|
|
18530
|
+
// with the writes rather than the reads above.
|
|
18531
|
+
SUBMIT_TX: 5e4,
|
|
18532
|
+
FINALIZE_TX: 5e4,
|
|
18385
18533
|
ISSUE: 5e4,
|
|
18386
18534
|
REISSUE: 5e4,
|
|
18387
18535
|
BURN: 5e4,
|
|
@@ -18408,6 +18556,9 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
18408
18556
|
};
|
|
18409
18557
|
var DEDUPABLE_REQUEST_TYPES = /* @__PURE__ */ new Set([
|
|
18410
18558
|
"GET_ADDRESS",
|
|
18559
|
+
"GET_ARKADE_INFO",
|
|
18560
|
+
"INDEXER_GET_VTXOS",
|
|
18561
|
+
"INDEXER_GET_VIRTUAL_TXS",
|
|
18411
18562
|
"GET_BALANCE",
|
|
18412
18563
|
"GET_BOARDING_ADDRESS",
|
|
18413
18564
|
"GET_BOARDING_UTXOS",
|
|
@@ -18499,7 +18650,7 @@ var initializeMessageBus = (serviceWorker, config, timeoutMs = 2e3) => {
|
|
|
18499
18650
|
if (response?.id !== initCmd.id) return;
|
|
18500
18651
|
cleanup();
|
|
18501
18652
|
if (response.error) {
|
|
18502
|
-
reject(response
|
|
18653
|
+
reject(restoreErrorName(response));
|
|
18503
18654
|
} else {
|
|
18504
18655
|
resolve();
|
|
18505
18656
|
}
|
|
@@ -18671,7 +18822,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18671
18822
|
}
|
|
18672
18823
|
cleanup();
|
|
18673
18824
|
if (response.error) {
|
|
18674
|
-
reject(response
|
|
18825
|
+
reject(restoreErrorName(response));
|
|
18675
18826
|
} else {
|
|
18676
18827
|
resolve(response);
|
|
18677
18828
|
}
|
|
@@ -18697,7 +18848,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18697
18848
|
if (request.id !== response.id) return;
|
|
18698
18849
|
if (response.error) {
|
|
18699
18850
|
cleanup();
|
|
18700
|
-
reject(response
|
|
18851
|
+
reject(restoreErrorName(response));
|
|
18701
18852
|
return;
|
|
18702
18853
|
}
|
|
18703
18854
|
if (isComplete(response)) {
|
|
@@ -18923,6 +19074,68 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18923
19074
|
throw new Error(`Failed to get boarding address: ${error}`);
|
|
18924
19075
|
}
|
|
18925
19076
|
}
|
|
19077
|
+
/**
|
|
19078
|
+
* Delegated to the worker, which holds the wallet that owns the connection.
|
|
19079
|
+
* The payload crosses raw — see {@link ResponseGetArkadeInfo} for why.
|
|
19080
|
+
*/
|
|
19081
|
+
async getArkadeInfo(opts) {
|
|
19082
|
+
const message = {
|
|
19083
|
+
id: getRandomId(),
|
|
19084
|
+
tag: this.messageTag,
|
|
19085
|
+
type: "GET_ARKADE_INFO",
|
|
19086
|
+
// omitted entirely for the default read: wire-shape hygiene
|
|
19087
|
+
// toward workers built before the option existed. (Dedup is
|
|
19088
|
+
// unaffected either way — the key is JSON.stringify, which drops
|
|
19089
|
+
// undefined-valued properties.)
|
|
19090
|
+
...opts?.requireLive ? { payload: { requireLive: true } } : {}
|
|
19091
|
+
};
|
|
19092
|
+
try {
|
|
19093
|
+
const response = await this.sendMessage(message);
|
|
19094
|
+
return response.payload.info;
|
|
19095
|
+
} catch (error) {
|
|
19096
|
+
throw new Error(`Failed to get arkade info: ${error}`, { cause: error });
|
|
19097
|
+
}
|
|
19098
|
+
}
|
|
19099
|
+
/**
|
|
19100
|
+
* An {@link ArkadeReader} that speaks to the worker rather than to the
|
|
19101
|
+
* server. The page holds no provider, so a caller that built its own from a
|
|
19102
|
+
* URL would open a second connection outside the worker's rate gate and
|
|
19103
|
+
* caches — this proxy is what keeps chain reads in one place.
|
|
19104
|
+
*/
|
|
19105
|
+
async getArkadeReader() {
|
|
19106
|
+
return {
|
|
19107
|
+
getVtxos: async (opts) => {
|
|
19108
|
+
const message = {
|
|
19109
|
+
id: getRandomId(),
|
|
19110
|
+
tag: this.messageTag,
|
|
19111
|
+
type: "INDEXER_GET_VTXOS",
|
|
19112
|
+
payload: { opts }
|
|
19113
|
+
};
|
|
19114
|
+
try {
|
|
19115
|
+
const response = await this.sendMessage(message);
|
|
19116
|
+
const { vtxos, page } = response.payload;
|
|
19117
|
+
return { vtxos: vtxos.map(chunk6AFUNKK7_cjs.normalizeVtxo), page: page && { ...page } };
|
|
19118
|
+
} catch (error) {
|
|
19119
|
+
throw new Error(`Failed to get vtxos: ${error}`, { cause: error });
|
|
19120
|
+
}
|
|
19121
|
+
},
|
|
19122
|
+
getVirtualTxs: async (txids, opts) => {
|
|
19123
|
+
const message = {
|
|
19124
|
+
id: getRandomId(),
|
|
19125
|
+
tag: this.messageTag,
|
|
19126
|
+
type: "INDEXER_GET_VIRTUAL_TXS",
|
|
19127
|
+
payload: { txids, opts }
|
|
19128
|
+
};
|
|
19129
|
+
try {
|
|
19130
|
+
const response = await this.sendMessage(message);
|
|
19131
|
+
const { txs, page } = response.payload;
|
|
19132
|
+
return { txs: [...txs], page: page && { ...page } };
|
|
19133
|
+
} catch (error) {
|
|
19134
|
+
throw new Error(`Failed to get virtual txs: ${error}`, { cause: error });
|
|
19135
|
+
}
|
|
19136
|
+
}
|
|
19137
|
+
};
|
|
19138
|
+
}
|
|
18926
19139
|
async getBalance() {
|
|
18927
19140
|
const message = {
|
|
18928
19141
|
id: getRandomId(),
|
|
@@ -19005,7 +19218,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19005
19218
|
};
|
|
19006
19219
|
try {
|
|
19007
19220
|
const response = await this.sendMessage(message);
|
|
19008
|
-
return response.payload.vtxos.map(
|
|
19221
|
+
return response.payload.vtxos.map(chunk6AFUNKK7_cjs.normalizeVtxo);
|
|
19009
19222
|
} catch (error) {
|
|
19010
19223
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
19011
19224
|
}
|
|
@@ -19030,7 +19243,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19030
19243
|
};
|
|
19031
19244
|
try {
|
|
19032
19245
|
const response = await this.sendMessage(message);
|
|
19033
|
-
return response.payload.vtxos.map(
|
|
19246
|
+
return response.payload.vtxos.map(chunk6AFUNKK7_cjs.normalizeVtxo);
|
|
19034
19247
|
} catch (error) {
|
|
19035
19248
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
19036
19249
|
}
|
|
@@ -19161,7 +19374,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19161
19374
|
};
|
|
19162
19375
|
try {
|
|
19163
19376
|
const response = await sendContractMessage(message);
|
|
19164
|
-
return response.payload.vtxos.map(
|
|
19377
|
+
return response.payload.vtxos.map(chunk6AFUNKK7_cjs.normalizeVtxo);
|
|
19165
19378
|
} catch (e) {
|
|
19166
19379
|
throw new Error("Failed to annotate vtxos");
|
|
19167
19380
|
}
|
|
@@ -19579,6 +19792,43 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
19579
19792
|
async signerForDescriptor(descriptor) {
|
|
19580
19793
|
return resolveDescriptorSigner(descriptor, this.identity);
|
|
19581
19794
|
}
|
|
19795
|
+
/**
|
|
19796
|
+
* An {@link ArkadeBroadcaster} proxied to the worker, which holds the
|
|
19797
|
+
* provider. Only `ServiceWorkerWallet` offers one: a readonly worker
|
|
19798
|
+
* refuses `SUBMIT_TX`/`FINALIZE_TX` outright, so exposing it on the
|
|
19799
|
+
* readonly class would promise something the boundary rejects.
|
|
19800
|
+
*/
|
|
19801
|
+
async getArkadeBroadcaster() {
|
|
19802
|
+
return {
|
|
19803
|
+
submitTx: async (signedArkTx, checkpointTxs) => {
|
|
19804
|
+
const message = {
|
|
19805
|
+
id: getRandomId(),
|
|
19806
|
+
tag: this.messageTag,
|
|
19807
|
+
type: "SUBMIT_TX",
|
|
19808
|
+
payload: { signedArkTx, checkpointTxs }
|
|
19809
|
+
};
|
|
19810
|
+
try {
|
|
19811
|
+
const response = await this.sendMessage(message);
|
|
19812
|
+
return response.payload;
|
|
19813
|
+
} catch (error) {
|
|
19814
|
+
throw new Error(`Failed to submit tx: ${error}`, { cause: error });
|
|
19815
|
+
}
|
|
19816
|
+
},
|
|
19817
|
+
finalizeTx: async (arkTxid, finalCheckpointTxs) => {
|
|
19818
|
+
const message = {
|
|
19819
|
+
id: getRandomId(),
|
|
19820
|
+
tag: this.messageTag,
|
|
19821
|
+
type: "FINALIZE_TX",
|
|
19822
|
+
payload: { arkTxid, finalCheckpointTxs }
|
|
19823
|
+
};
|
|
19824
|
+
try {
|
|
19825
|
+
await this.sendMessage(message);
|
|
19826
|
+
} catch (error) {
|
|
19827
|
+
throw new Error(`Failed to finalize tx: ${error}`, { cause: error });
|
|
19828
|
+
}
|
|
19829
|
+
}
|
|
19830
|
+
};
|
|
19831
|
+
}
|
|
19582
19832
|
async sendBitcoin(params) {
|
|
19583
19833
|
const message = {
|
|
19584
19834
|
id: getRandomId(),
|
|
@@ -19762,7 +20012,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
19762
20012
|
};
|
|
19763
20013
|
try {
|
|
19764
20014
|
const response = await wallet.sendMessage(message);
|
|
19765
|
-
return response.payload.vtxos.map(
|
|
20015
|
+
return response.payload.vtxos.map(chunk6AFUNKK7_cjs.normalizeVtxo);
|
|
19766
20016
|
} catch (e) {
|
|
19767
20017
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
19768
20018
|
}
|
|
@@ -19874,12 +20124,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
19874
20124
|
* @returns Configured onchain wallet
|
|
19875
20125
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
19876
20126
|
*/
|
|
19877
|
-
static async create(identity, networkName =
|
|
20127
|
+
static async create(identity, networkName = chunk6AFUNKK7_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
19878
20128
|
const pubkey = await identity.xOnlyPublicKey();
|
|
19879
20129
|
if (!pubkey) {
|
|
19880
20130
|
throw new Error("Invalid configured public key");
|
|
19881
20131
|
}
|
|
19882
|
-
const network =
|
|
20132
|
+
const network = chunk6AFUNKK7_cjs.getNetwork(networkName);
|
|
19883
20133
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
19884
20134
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
19885
20135
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -19985,7 +20235,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
19985
20235
|
if (!inputs) {
|
|
19986
20236
|
throw new Error("Fee estimation failed");
|
|
19987
20237
|
}
|
|
19988
|
-
let tx = new
|
|
20238
|
+
let tx = new chunk6AFUNKK7_cjs.Transaction();
|
|
19989
20239
|
for (const input of inputs) {
|
|
19990
20240
|
tx.addInput({
|
|
19991
20241
|
txid: input.txid,
|
|
@@ -20043,7 +20293,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20043
20293
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
20044
20294
|
*/
|
|
20045
20295
|
async bumpAnchor(parentHex, feeRate) {
|
|
20046
|
-
const parent =
|
|
20296
|
+
const parent = chunk6AFUNKK7_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
20047
20297
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
20048
20298
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
20049
20299
|
return [parent.hex, child.hex];
|
|
@@ -20904,7 +21154,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
20904
21154
|
try {
|
|
20905
21155
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
20906
21156
|
for (const psbt of txs) {
|
|
20907
|
-
const tx =
|
|
21157
|
+
const tx = chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
20908
21158
|
resolved.set(tx.id, tx.toBytes());
|
|
20909
21159
|
}
|
|
20910
21160
|
} catch (err) {
|
|
@@ -20937,7 +21187,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
20937
21187
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
20938
21188
|
const pending = [];
|
|
20939
21189
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
20940
|
-
if (
|
|
21190
|
+
if (chunk6AFUNKK7_cjs.getArkPsbtFields(tx, i, chunk6AFUNKK7_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
20941
21191
|
}
|
|
20942
21192
|
if (pending.length === 0) return;
|
|
20943
21193
|
const resolved = await resolvePrevTxs(
|
|
@@ -20946,13 +21196,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
20946
21196
|
onchain
|
|
20947
21197
|
);
|
|
20948
21198
|
for (const i of pending) {
|
|
20949
|
-
|
|
21199
|
+
chunk6AFUNKK7_cjs.setArkPsbtField(tx, i, chunk6AFUNKK7_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
20950
21200
|
}
|
|
20951
21201
|
}
|
|
20952
21202
|
async function attachPrevoutTxs(tx, source) {
|
|
20953
21203
|
const pending = [];
|
|
20954
21204
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
20955
|
-
if (
|
|
21205
|
+
if (chunk6AFUNKK7_cjs.getArkPsbtFields(tx, i, chunk6AFUNKK7_cjs.PrevoutTxField).length > 0) continue;
|
|
20956
21206
|
const input = tx.getInput(i);
|
|
20957
21207
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
20958
21208
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -20963,7 +21213,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
20963
21213
|
resolved.set(txid, await source.getRawTransaction(txid));
|
|
20964
21214
|
}
|
|
20965
21215
|
for (const { index, txid } of pending) {
|
|
20966
|
-
|
|
21216
|
+
chunk6AFUNKK7_cjs.setArkPsbtField(tx, index, chunk6AFUNKK7_cjs.PrevoutTxField, resolved.get(txid));
|
|
20967
21217
|
}
|
|
20968
21218
|
}
|
|
20969
21219
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -20989,7 +21239,7 @@ exports.BIP322 = void 0;
|
|
|
20989
21239
|
async function sign2(message, identity, network) {
|
|
20990
21240
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
20991
21241
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
20992
|
-
const toSpend =
|
|
21242
|
+
const toSpend = chunk6AFUNKK7_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
20993
21243
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
20994
21244
|
const signed = await identity.sign(toSign, [0]);
|
|
20995
21245
|
signed.finalizeIdx(0);
|
|
@@ -21047,7 +21297,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
21047
21297
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
21048
21298
|
return false;
|
|
21049
21299
|
}
|
|
21050
|
-
const toSpend =
|
|
21300
|
+
const toSpend = chunk6AFUNKK7_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
21051
21301
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
21052
21302
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
21053
21303
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -21068,7 +21318,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
21068
21318
|
}
|
|
21069
21319
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
21070
21320
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
21071
|
-
const toSpend =
|
|
21321
|
+
const toSpend = chunk6AFUNKK7_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
21072
21322
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
21073
21323
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
21074
21324
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -21121,7 +21371,7 @@ function encodeCompactSize(n) {
|
|
|
21121
21371
|
return buf;
|
|
21122
21372
|
}
|
|
21123
21373
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
21124
|
-
const tx = new
|
|
21374
|
+
const tx = new chunk6AFUNKK7_cjs.Transaction({ version: 0 });
|
|
21125
21375
|
tx.addInput({
|
|
21126
21376
|
txid: toSpend.id,
|
|
21127
21377
|
index: 0,
|
|
@@ -21135,12 +21385,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
21135
21385
|
});
|
|
21136
21386
|
tx.addOutput({
|
|
21137
21387
|
amount: 0n,
|
|
21138
|
-
script:
|
|
21388
|
+
script: chunk6AFUNKK7_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
21139
21389
|
});
|
|
21140
21390
|
return tx;
|
|
21141
21391
|
}
|
|
21142
21392
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
21143
|
-
const tx = new
|
|
21393
|
+
const tx = new chunk6AFUNKK7_cjs.Transaction({ version: 0 });
|
|
21144
21394
|
tx.addInput({
|
|
21145
21395
|
txid: toSpend.id,
|
|
21146
21396
|
index: 0,
|
|
@@ -21152,7 +21402,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
21152
21402
|
});
|
|
21153
21403
|
tx.addOutput({
|
|
21154
21404
|
amount: 0n,
|
|
21155
|
-
script:
|
|
21405
|
+
script: chunk6AFUNKK7_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
21156
21406
|
});
|
|
21157
21407
|
return tx;
|
|
21158
21408
|
}
|
|
@@ -21283,7 +21533,7 @@ var RestEmulatorProvider = class {
|
|
|
21283
21533
|
}
|
|
21284
21534
|
};
|
|
21285
21535
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
21286
|
-
const tx =
|
|
21536
|
+
const tx = chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
21287
21537
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
21288
21538
|
const input = tx.getInput(0);
|
|
21289
21539
|
if (!input) {
|
|
@@ -21310,14 +21560,14 @@ var ExitPathError = class extends Error {
|
|
|
21310
21560
|
reason;
|
|
21311
21561
|
};
|
|
21312
21562
|
function delayWeight(sequence) {
|
|
21313
|
-
const t =
|
|
21563
|
+
const t = chunk6AFUNKK7_cjs.sequenceToTimelock(sequence);
|
|
21314
21564
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
21315
21565
|
}
|
|
21316
21566
|
async function resolveUnilateralPath(params) {
|
|
21317
21567
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
21318
21568
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
21319
21569
|
if (contract) {
|
|
21320
|
-
const handler =
|
|
21570
|
+
const handler = chunkHL7EC2Z5_cjs.contractHandlers.get(contract.type);
|
|
21321
21571
|
if (!handler) {
|
|
21322
21572
|
throw new ExitPathError(
|
|
21323
21573
|
"no-handler",
|
|
@@ -21340,12 +21590,12 @@ async function resolveUnilateralPath(params) {
|
|
|
21340
21590
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
21341
21591
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
21342
21592
|
}
|
|
21343
|
-
const decoded =
|
|
21593
|
+
const decoded = chunk6AFUNKK7_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
21344
21594
|
let best;
|
|
21345
21595
|
for (const exit of decoded.exitPaths()) {
|
|
21346
21596
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
21347
21597
|
if (!leaf) continue;
|
|
21348
|
-
const sequence =
|
|
21598
|
+
const sequence = chunk6AFUNKK7_cjs.timelockToSequence(exit.params.timelock);
|
|
21349
21599
|
const weight = delayWeight(sequence);
|
|
21350
21600
|
if (!best || weight < best.weight) {
|
|
21351
21601
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -21565,7 +21815,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
21565
21815
|
let totalAmount = 0n;
|
|
21566
21816
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
21567
21817
|
for (const vtxo of vtxos) {
|
|
21568
|
-
if (!
|
|
21818
|
+
if (!chunk6AFUNKK7_cjs.canSweepOnchain(vtxo)) {
|
|
21569
21819
|
throw new Error(
|
|
21570
21820
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
21571
21821
|
);
|
|
@@ -21576,14 +21826,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
21576
21826
|
}
|
|
21577
21827
|
const resolved = await resolveUnilateralPath({
|
|
21578
21828
|
vtxo,
|
|
21579
|
-
scriptHex: base.hex.encode(
|
|
21829
|
+
scriptHex: base.hex.encode(chunk6AFUNKK7_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
21580
21830
|
contractRepository: wallet.contractRepository,
|
|
21581
21831
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
21582
21832
|
currentTime: Date.now()
|
|
21583
21833
|
});
|
|
21584
21834
|
const spendingLeaf = resolved.selection.leaf;
|
|
21585
21835
|
const sequence = resolved.selection.sequence;
|
|
21586
|
-
const timelock =
|
|
21836
|
+
const timelock = chunk6AFUNKK7_cjs.sequenceToTimelock(sequence);
|
|
21587
21837
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
21588
21838
|
if (!elapsed) {
|
|
21589
21839
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -21596,7 +21846,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
21596
21846
|
sequence,
|
|
21597
21847
|
witnessUtxo: {
|
|
21598
21848
|
amount: BigInt(vtxo.value),
|
|
21599
|
-
script:
|
|
21849
|
+
script: chunk6AFUNKK7_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
21600
21850
|
},
|
|
21601
21851
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
21602
21852
|
});
|
|
@@ -21606,7 +21856,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
21606
21856
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
21607
21857
|
);
|
|
21608
21858
|
}
|
|
21609
|
-
const tx = new
|
|
21859
|
+
const tx = new chunk6AFUNKK7_cjs.Transaction({ version: 2 });
|
|
21610
21860
|
for (const input of inputs) {
|
|
21611
21861
|
tx.addInput(input);
|
|
21612
21862
|
}
|
|
@@ -21689,7 +21939,7 @@ async function buildSignedSweep(params) {
|
|
|
21689
21939
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
21690
21940
|
);
|
|
21691
21941
|
}
|
|
21692
|
-
const tx = new
|
|
21942
|
+
const tx = new chunk6AFUNKK7_cjs.Transaction({ version: 2 });
|
|
21693
21943
|
tx.addInput({
|
|
21694
21944
|
txid: vtxo.txid,
|
|
21695
21945
|
index: vtxo.vout,
|
|
@@ -21714,7 +21964,7 @@ async function buildSignedSweep(params) {
|
|
|
21714
21964
|
finalScriptWitness: [
|
|
21715
21965
|
tapScriptSig[0][1],
|
|
21716
21966
|
...path.extraWitness,
|
|
21717
|
-
|
|
21967
|
+
chunk6AFUNKK7_cjs.scriptFromTapLeafScript(path.leaf),
|
|
21718
21968
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
21719
21969
|
]
|
|
21720
21970
|
});
|
|
@@ -21744,7 +21994,7 @@ async function resolveFeeRate(opts) {
|
|
|
21744
21994
|
}
|
|
21745
21995
|
async function selectExitVtxos(opts) {
|
|
21746
21996
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
21747
|
-
const res = await
|
|
21997
|
+
const res = await chunk6AFUNKK7_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
21748
21998
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
21749
21999
|
const out = [];
|
|
21750
22000
|
for (const vtxo of res.vtxos) {
|
|
@@ -21759,7 +22009,7 @@ async function selectExitVtxos(opts) {
|
|
|
21759
22009
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
21760
22010
|
);
|
|
21761
22011
|
}
|
|
21762
|
-
const handler =
|
|
22012
|
+
const handler = chunkHL7EC2Z5_cjs.contractHandlers.get(contract.type);
|
|
21763
22013
|
if (!handler) {
|
|
21764
22014
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
21765
22015
|
}
|
|
@@ -21789,7 +22039,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
21789
22039
|
if (pendingNodes.length > 0) {
|
|
21790
22040
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
21791
22041
|
for (const psbt of txs) {
|
|
21792
|
-
psbts.set(
|
|
22042
|
+
psbts.set(chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
21793
22043
|
}
|
|
21794
22044
|
}
|
|
21795
22045
|
const childVsize = Number(
|
|
@@ -21825,7 +22075,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
21825
22075
|
try {
|
|
21826
22076
|
const resolved = await resolveUnilateralPath({
|
|
21827
22077
|
vtxo,
|
|
21828
|
-
scriptHex: base.hex.encode(
|
|
22078
|
+
scriptHex: base.hex.encode(chunk6AFUNKK7_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
21829
22079
|
contractRepository: wallet.contractRepository,
|
|
21830
22080
|
walletPubKeyHex,
|
|
21831
22081
|
currentTime: Date.now()
|
|
@@ -21844,7 +22094,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
21844
22094
|
});
|
|
21845
22095
|
continue;
|
|
21846
22096
|
}
|
|
21847
|
-
const t =
|
|
22097
|
+
const t = chunk6AFUNKK7_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
21848
22098
|
const delay = { type: t.type, value: Number(t.value) };
|
|
21849
22099
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
21850
22100
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -22245,7 +22495,7 @@ async function prepare(opts) {
|
|
|
22245
22495
|
txid: sweep.vtxo.txid,
|
|
22246
22496
|
vout: sweep.vtxo.vout,
|
|
22247
22497
|
value: sweep.vtxo.value,
|
|
22248
|
-
pkScript:
|
|
22498
|
+
pkScript: chunk6AFUNKK7_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
22249
22499
|
},
|
|
22250
22500
|
path: sweep.resolved.selection,
|
|
22251
22501
|
outputAddress: opts.sweepAddress,
|
|
@@ -22333,7 +22583,7 @@ async function prepare(opts) {
|
|
|
22333
22583
|
if (newFee <= splitterFee) break;
|
|
22334
22584
|
splitterFee = newFee;
|
|
22335
22585
|
}
|
|
22336
|
-
const splitter = new
|
|
22586
|
+
const splitter = new chunk6AFUNKK7_cjs.Transaction({ version: 2 });
|
|
22337
22587
|
for (const coin of selected.inputs) {
|
|
22338
22588
|
splitter.addInput({
|
|
22339
22589
|
txid: coin.txid,
|
|
@@ -22477,41 +22727,41 @@ var UnilateralExit = {
|
|
|
22477
22727
|
// src/arkade/index.ts
|
|
22478
22728
|
var arkade_exports = {};
|
|
22479
22729
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
22480
|
-
ARKADE_OP: () =>
|
|
22481
|
-
ARKADE_OPCODES: () =>
|
|
22482
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
22483
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
22484
|
-
ARKADE_OPS: () =>
|
|
22730
|
+
ARKADE_OP: () => chunkHL7EC2Z5_cjs.ARKADE_OP,
|
|
22731
|
+
ARKADE_OPCODES: () => chunkHL7EC2Z5_cjs.ARKADE_OPCODES,
|
|
22732
|
+
ARKADE_OPCODE_NAMES: () => chunkHL7EC2Z5_cjs.ARKADE_OPCODE_NAMES,
|
|
22733
|
+
ARKADE_OPCODE_VALUES: () => chunkHL7EC2Z5_cjs.ARKADE_OPCODE_VALUES,
|
|
22734
|
+
ARKADE_OPS: () => chunkHL7EC2Z5_cjs.ARKADE_OPS,
|
|
22485
22735
|
Arkade: () => Arkade,
|
|
22486
22736
|
ArkadeContract: () => ArkadeContract,
|
|
22487
|
-
ArkadeProgramScript: () =>
|
|
22488
|
-
ArkadeScript: () =>
|
|
22737
|
+
ArkadeProgramScript: () => chunkHL7EC2Z5_cjs.ArkadeProgramScript,
|
|
22738
|
+
ArkadeScript: () => chunkHL7EC2Z5_cjs.ArkadeScript,
|
|
22489
22739
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
22490
|
-
BigNum: () =>
|
|
22740
|
+
BigNum: () => chunkHL7EC2Z5_cjs.bignum_exports,
|
|
22491
22741
|
OP: () => btcSigner.OP,
|
|
22492
|
-
OPCODE_NAMES: () =>
|
|
22493
|
-
OPCODE_VALUES: () =>
|
|
22494
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
22742
|
+
OPCODE_NAMES: () => chunkHL7EC2Z5_cjs.OPCODE_NAMES,
|
|
22743
|
+
OPCODE_VALUES: () => chunkHL7EC2Z5_cjs.OPCODE_VALUES,
|
|
22744
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkHL7EC2Z5_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
22495
22745
|
Script: () => btcSigner.Script,
|
|
22496
|
-
arkadeScriptHash: () =>
|
|
22497
|
-
arkadeWitnessHash: () =>
|
|
22498
|
-
asmToBytes: () =>
|
|
22499
|
-
bytesToASM: () =>
|
|
22500
|
-
computeArkadeScriptPublicKey: () =>
|
|
22746
|
+
arkadeScriptHash: () => chunkHL7EC2Z5_cjs.arkadeScriptHash,
|
|
22747
|
+
arkadeWitnessHash: () => chunkHL7EC2Z5_cjs.arkadeWitnessHash,
|
|
22748
|
+
asmToBytes: () => chunkHL7EC2Z5_cjs.asmToBytes,
|
|
22749
|
+
bytesToASM: () => chunkHL7EC2Z5_cjs.bytesToASM,
|
|
22750
|
+
computeArkadeScriptPublicKey: () => chunkHL7EC2Z5_cjs.computeArkadeScriptPublicKey,
|
|
22501
22751
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
22502
|
-
deserializeArkadeContractParams: () =>
|
|
22503
|
-
fromASM: () =>
|
|
22504
|
-
getOpcodeName: () =>
|
|
22505
|
-
getOpcodeValue: () =>
|
|
22506
|
-
parseArtifact: () =>
|
|
22507
|
-
resolveAsm: () =>
|
|
22508
|
-
serializeArkadeContractParams: () =>
|
|
22509
|
-
stringifyArtifact: () =>
|
|
22510
|
-
toASM: () =>
|
|
22511
|
-
validateProgram: () =>
|
|
22512
|
-
witnessRefToBytes: () =>
|
|
22752
|
+
deserializeArkadeContractParams: () => chunkHL7EC2Z5_cjs.deserializeArkadeContractParams,
|
|
22753
|
+
fromASM: () => chunkHL7EC2Z5_cjs.fromASM,
|
|
22754
|
+
getOpcodeName: () => chunkHL7EC2Z5_cjs.getOpcodeName,
|
|
22755
|
+
getOpcodeValue: () => chunkHL7EC2Z5_cjs.getOpcodeValue,
|
|
22756
|
+
parseArtifact: () => chunkHL7EC2Z5_cjs.parseArtifact,
|
|
22757
|
+
resolveAsm: () => chunkHL7EC2Z5_cjs.resolveAsm,
|
|
22758
|
+
serializeArkadeContractParams: () => chunkHL7EC2Z5_cjs.serializeArkadeContractParams,
|
|
22759
|
+
stringifyArtifact: () => chunkHL7EC2Z5_cjs.stringifyArtifact,
|
|
22760
|
+
toASM: () => chunkHL7EC2Z5_cjs.toASM,
|
|
22761
|
+
validateProgram: () => chunkHL7EC2Z5_cjs.validateProgram,
|
|
22762
|
+
witnessRefToBytes: () => chunkHL7EC2Z5_cjs.witnessRefToBytes
|
|
22513
22763
|
});
|
|
22514
|
-
var isVtxoCoin = (input) =>
|
|
22764
|
+
var isVtxoCoin = (input) => chunk6AFUNKK7_cjs.isVirtualCoin(input);
|
|
22515
22765
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
22516
22766
|
let batchId;
|
|
22517
22767
|
let sweepTapTreeRoot;
|
|
@@ -22532,23 +22782,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
22532
22782
|
);
|
|
22533
22783
|
await arkProvider.confirmRegistration(intentId);
|
|
22534
22784
|
batchId = event.id;
|
|
22535
|
-
const sweepTapscript =
|
|
22785
|
+
const sweepTapscript = chunk6AFUNKK7_cjs.CSVMultisigTapscript.encode({
|
|
22536
22786
|
timelock,
|
|
22537
|
-
pubkeys: [
|
|
22787
|
+
pubkeys: [chunkHL7EC2Z5_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
|
|
22538
22788
|
}).script;
|
|
22539
22789
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
22540
22790
|
return { skip: false };
|
|
22541
22791
|
},
|
|
22542
22792
|
onTreeSigningStarted: async (event, vtxoTree) => {
|
|
22543
22793
|
const signerPubKey = await session.getPublicKey();
|
|
22544
|
-
const xonlySignerPubKey =
|
|
22794
|
+
const xonlySignerPubKey = chunkHL7EC2Z5_cjs.toXOnly(signerPubKey, "signer key");
|
|
22545
22795
|
const xOnlyPubkeys = event.cosignersPublicKeys.map(
|
|
22546
|
-
(k) => base.hex.encode(
|
|
22796
|
+
(k) => base.hex.encode(chunkHL7EC2Z5_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
22547
22797
|
);
|
|
22548
22798
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
22549
22799
|
return { skip: true };
|
|
22550
22800
|
}
|
|
22551
|
-
const commitmentTx =
|
|
22801
|
+
const commitmentTx = chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
22552
22802
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
22553
22803
|
if (recipients && recipients.length > 0) {
|
|
22554
22804
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -22580,7 +22830,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
22580
22830
|
if (connectorTree) {
|
|
22581
22831
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
22582
22832
|
}
|
|
22583
|
-
let commitmentPsbt =
|
|
22833
|
+
let commitmentPsbt = chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
22584
22834
|
assertFinalCommitmentMatchesValidated(
|
|
22585
22835
|
commitmentPsbt,
|
|
22586
22836
|
validatedCommitmentTxid,
|
|
@@ -22615,7 +22865,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
22615
22865
|
boardingIndices.push(boardingIdx);
|
|
22616
22866
|
continue;
|
|
22617
22867
|
}
|
|
22618
|
-
if (
|
|
22868
|
+
if (chunk6AFUNKK7_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
22619
22869
|
continue;
|
|
22620
22870
|
}
|
|
22621
22871
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -22636,7 +22886,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
22636
22886
|
index: input.vout,
|
|
22637
22887
|
witnessUtxo: {
|
|
22638
22888
|
amount: BigInt(input.value),
|
|
22639
|
-
script:
|
|
22889
|
+
script: chunk6AFUNKK7_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
22640
22890
|
},
|
|
22641
22891
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
22642
22892
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -22727,16 +22977,16 @@ var Arkade = class _Arkade {
|
|
|
22727
22977
|
/** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
|
|
22728
22978
|
static async connect(opts) {
|
|
22729
22979
|
const info = await opts.arkade.getInfo();
|
|
22730
|
-
const serverKey =
|
|
22731
|
-
const checkpoint =
|
|
22732
|
-
const network = opts.network ??
|
|
22980
|
+
const serverKey = chunkHL7EC2Z5_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
22981
|
+
const checkpoint = chunk6AFUNKK7_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
22982
|
+
const network = opts.network ?? chunk6AFUNKK7_cjs.DEFAULT_NETWORK;
|
|
22733
22983
|
let emulatorKey;
|
|
22734
22984
|
if (opts.emulator) {
|
|
22735
|
-
emulatorKey = base.hex.decode(
|
|
22985
|
+
emulatorKey = base.hex.decode(chunk6AFUNKK7_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
22736
22986
|
}
|
|
22737
22987
|
let userKey;
|
|
22738
22988
|
if (opts.identity) {
|
|
22739
|
-
userKey =
|
|
22989
|
+
userKey = chunkHL7EC2Z5_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
|
|
22740
22990
|
}
|
|
22741
22991
|
return new _Arkade({
|
|
22742
22992
|
arkProvider: opts.arkade,
|
|
@@ -22762,7 +23012,7 @@ var Arkade = class _Arkade {
|
|
|
22762
23012
|
* key respectively; explicit args always win.
|
|
22763
23013
|
*/
|
|
22764
23014
|
contract(program, args = {}) {
|
|
22765
|
-
const declared = (program.params ?? []).map(
|
|
23015
|
+
const declared = (program.params ?? []).map(chunkHL7EC2Z5_cjs.inputName);
|
|
22766
23016
|
if (declared.includes("server") && args.server === void 0) {
|
|
22767
23017
|
args = { ...args, server: this.serverKey };
|
|
22768
23018
|
}
|
|
@@ -22782,7 +23032,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22782
23032
|
userKey: client.userKey,
|
|
22783
23033
|
emulatorKey: client.emulatorKey
|
|
22784
23034
|
};
|
|
22785
|
-
this.vtxoScript = new
|
|
23035
|
+
this.vtxoScript = new chunkHL7EC2Z5_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
22786
23036
|
this.tapTree = this.vtxoScript.encode();
|
|
22787
23037
|
this.compiled = this.vtxoScript.compiled;
|
|
22788
23038
|
}
|
|
@@ -22810,7 +23060,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22810
23060
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
22811
23061
|
);
|
|
22812
23062
|
}
|
|
22813
|
-
const typed =
|
|
23063
|
+
const typed = chunkHL7EC2Z5_cjs.deserializeArkadeContractParams(contract.params);
|
|
22814
23064
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
22815
23065
|
serverKey: typed.serverKey,
|
|
22816
23066
|
userKey: typed.userKey,
|
|
@@ -22851,7 +23101,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22851
23101
|
toContractParams() {
|
|
22852
23102
|
return {
|
|
22853
23103
|
type: "arkade",
|
|
22854
|
-
params:
|
|
23104
|
+
params: chunkHL7EC2Z5_cjs.serializeArkadeContractParams({
|
|
22855
23105
|
program: this.program,
|
|
22856
23106
|
args: this.args,
|
|
22857
23107
|
serverKey: this.keys.serverKey,
|
|
@@ -22901,18 +23151,18 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22901
23151
|
if (registered) {
|
|
22902
23152
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
22903
23153
|
return (withVtxos?.vtxos ?? []).filter(
|
|
22904
|
-
(v) => !
|
|
23154
|
+
(v) => !chunk6AFUNKK7_cjs.hasTerminalSpend(v) && !v.isUnrolled
|
|
22905
23155
|
);
|
|
22906
23156
|
}
|
|
22907
23157
|
}
|
|
22908
23158
|
if (!this.client.indexer) {
|
|
22909
23159
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
22910
23160
|
}
|
|
22911
|
-
const { vtxos } = await
|
|
23161
|
+
const { vtxos } = await chunk6AFUNKK7_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
22912
23162
|
scripts: [scriptHex],
|
|
22913
23163
|
spendableOnly: true
|
|
22914
23164
|
});
|
|
22915
|
-
return vtxos.filter((v) => !
|
|
23165
|
+
return vtxos.filter((v) => !chunk6AFUNKK7_cjs.hasTerminalSpend(v) && !v.isUnrolled);
|
|
22916
23166
|
}
|
|
22917
23167
|
/** Total spendable balance (requires an indexer). */
|
|
22918
23168
|
async getBalance() {
|
|
@@ -23010,7 +23260,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
23010
23260
|
this.contract.client.checkpoint
|
|
23011
23261
|
);
|
|
23012
23262
|
if (coin.sourceTx) {
|
|
23013
|
-
|
|
23263
|
+
chunk6AFUNKK7_cjs.setArkPsbtField(arkTx, 0, chunk6AFUNKK7_cjs.PrevArkTxField, coin.sourceTx);
|
|
23014
23264
|
}
|
|
23015
23265
|
if (this.fn.arkadeScript) {
|
|
23016
23266
|
const indexer = this.contract.client.indexer;
|
|
@@ -23027,8 +23277,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
23027
23277
|
}
|
|
23028
23278
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
23029
23279
|
if (condition.length > 0) {
|
|
23030
|
-
|
|
23031
|
-
|
|
23280
|
+
chunk6AFUNKK7_cjs.setArkPsbtField(arkTx, 0, chunk6AFUNKK7_cjs.ConditionWitness, condition);
|
|
23281
|
+
chunk6AFUNKK7_cjs.setArkPsbtField(checkpoints[0], 0, chunk6AFUNKK7_cjs.ConditionWitness, condition);
|
|
23032
23282
|
}
|
|
23033
23283
|
const packets = [];
|
|
23034
23284
|
if (this.assetSpecs.length > 0) {
|
|
@@ -23067,7 +23317,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
23067
23317
|
base.base64.encode(signedArk2.toPSBT()),
|
|
23068
23318
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
23069
23319
|
);
|
|
23070
|
-
const txid =
|
|
23320
|
+
const txid = chunk6AFUNKK7_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
23071
23321
|
return {
|
|
23072
23322
|
txid,
|
|
23073
23323
|
signedArkTx: res2.signedArkTx,
|
|
@@ -23077,8 +23327,14 @@ var ArkadeTransactionBuilder = class {
|
|
|
23077
23327
|
if (!client.identity) {
|
|
23078
23328
|
throw new Error("a signing identity is required for non-covenant spends");
|
|
23079
23329
|
}
|
|
23330
|
+
const ark = client.arkProvider;
|
|
23331
|
+
if (!ark.submitTx || !ark.finalizeTx) {
|
|
23332
|
+
throw new Error(
|
|
23333
|
+
"broadcasting requires an `arkade` provider with `submitTx`/`finalizeTx` on the Arkade client"
|
|
23334
|
+
);
|
|
23335
|
+
}
|
|
23080
23336
|
const signedArk = await this.signArk(arkTx, userInputs);
|
|
23081
|
-
const res = await
|
|
23337
|
+
const res = await ark.submitTx(
|
|
23082
23338
|
base.base64.encode(signedArk.toPSBT()),
|
|
23083
23339
|
checkpoints.map((c) => base.base64.encode(c.toPSBT()))
|
|
23084
23340
|
);
|
|
@@ -23089,7 +23345,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
23089
23345
|
async ({ server }) => base.base64.encode((await client.identity.sign(server, [0])).toPSBT())
|
|
23090
23346
|
)
|
|
23091
23347
|
);
|
|
23092
|
-
await
|
|
23348
|
+
await ark.finalizeTx(res.arkTxid, finalCps);
|
|
23093
23349
|
return {
|
|
23094
23350
|
txid: res.arkTxid,
|
|
23095
23351
|
signedArkTx: res.finalArkTx,
|
|
@@ -23126,23 +23382,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
23126
23382
|
}
|
|
23127
23383
|
buildAssetPacket() {
|
|
23128
23384
|
const groups = this.assetSpecs.map((s) => {
|
|
23129
|
-
const id = typeof s.assetId === "string" ?
|
|
23130
|
-
return
|
|
23385
|
+
const id = typeof s.assetId === "string" ? chunkCZ32XADN_cjs.AssetId.fromString(s.assetId) : chunkCZ32XADN_cjs.AssetId.fromBytes(s.assetId);
|
|
23386
|
+
return chunkCZ32XADN_cjs.AssetGroup.create(
|
|
23131
23387
|
id,
|
|
23132
23388
|
null,
|
|
23133
|
-
s.inputs.map((i) =>
|
|
23134
|
-
s.outputs.map((o) =>
|
|
23135
|
-
(s.metadata ?? []).map((m) =>
|
|
23389
|
+
s.inputs.map((i) => chunkCZ32XADN_cjs.AssetInput.create(i.vin, i.amount)),
|
|
23390
|
+
s.outputs.map((o) => chunkCZ32XADN_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
23391
|
+
(s.metadata ?? []).map((m) => chunkCZ32XADN_cjs.Metadata.create(m.key, m.value))
|
|
23136
23392
|
);
|
|
23137
23393
|
});
|
|
23138
|
-
return
|
|
23394
|
+
return chunkCZ32XADN_cjs.Packet.create(groups);
|
|
23139
23395
|
}
|
|
23140
23396
|
witnessBytes(ref) {
|
|
23141
|
-
return
|
|
23397
|
+
return chunkHL7EC2Z5_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
23142
23398
|
}
|
|
23143
23399
|
};
|
|
23144
23400
|
function bindInputs(fn, callArgs) {
|
|
23145
|
-
const names = (fn.def.inputs ?? []).map(
|
|
23401
|
+
const names = (fn.def.inputs ?? []).map(chunkHL7EC2Z5_cjs.inputName);
|
|
23146
23402
|
if (callArgs.length !== names.length) {
|
|
23147
23403
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
23148
23404
|
}
|
|
@@ -23177,6 +23433,7 @@ var BIP21Error = /* @__PURE__ */ ((BIP21Error2) => {
|
|
|
23177
23433
|
BIP21Error2["INVALID_ADDRESS"] = "Invalid address";
|
|
23178
23434
|
return BIP21Error2;
|
|
23179
23435
|
})(BIP21Error || {});
|
|
23436
|
+
var ARK_HRP = /^(?:t?ark|T?ARK)/;
|
|
23180
23437
|
var BIP21 = class _BIP21 {
|
|
23181
23438
|
/**
|
|
23182
23439
|
* Create a BIP21 URI from the provided parameters.
|
|
@@ -23200,7 +23457,7 @@ var BIP21 = class _BIP21 {
|
|
|
23200
23457
|
}
|
|
23201
23458
|
queryParams[key] = value;
|
|
23202
23459
|
} else if (key === "ark") {
|
|
23203
|
-
if (typeof value === "string" &&
|
|
23460
|
+
if (typeof value === "string" && ARK_HRP.test(value)) {
|
|
23204
23461
|
queryParams[key] = value;
|
|
23205
23462
|
} else {
|
|
23206
23463
|
console.warn("Invalid ARK address format");
|
|
@@ -23220,7 +23477,7 @@ var BIP21 = class _BIP21 {
|
|
|
23220
23477
|
Object.entries(queryParams).map(([k, v]) => [k, String(v)])
|
|
23221
23478
|
)
|
|
23222
23479
|
).toString() : "";
|
|
23223
|
-
return `bitcoin:${address
|
|
23480
|
+
return `bitcoin:${address ?? ""}${query}`;
|
|
23224
23481
|
}
|
|
23225
23482
|
/**
|
|
23226
23483
|
* Integer-sats amount encoded in a BIP21 URI (`amount=` is BTC), or
|
|
@@ -23253,7 +23510,7 @@ var BIP21 = class _BIP21 {
|
|
|
23253
23510
|
const [address, query] = withoutPrefix.split("?");
|
|
23254
23511
|
const params = {};
|
|
23255
23512
|
if (address) {
|
|
23256
|
-
params.address = address
|
|
23513
|
+
params.address = address;
|
|
23257
23514
|
}
|
|
23258
23515
|
if (query) {
|
|
23259
23516
|
const queryParams = new URLSearchParams(query);
|
|
@@ -23269,7 +23526,7 @@ var BIP21 = class _BIP21 {
|
|
|
23269
23526
|
}
|
|
23270
23527
|
params[key] = amount;
|
|
23271
23528
|
} else if (key === "ark") {
|
|
23272
|
-
if (
|
|
23529
|
+
if (ARK_HRP.test(value)) {
|
|
23273
23530
|
params[key] = value;
|
|
23274
23531
|
} else {
|
|
23275
23532
|
console.warn("Invalid ARK address format");
|
|
@@ -23521,7 +23778,7 @@ function onchainRail() {
|
|
|
23521
23778
|
function createDefaultPaymentRouter(wallet) {
|
|
23522
23779
|
return new PaymentRouter({
|
|
23523
23780
|
wallet,
|
|
23524
|
-
prefs: { priority: ["ark", "
|
|
23781
|
+
prefs: { priority: ["ark", "onchain"] }
|
|
23525
23782
|
}).use(arkRail()).use(onchainRail());
|
|
23526
23783
|
}
|
|
23527
23784
|
/*! Bundled license information:
|
|
@@ -23631,6 +23888,7 @@ exports.arkTarget = arkTarget;
|
|
|
23631
23888
|
exports.arkade_exports = arkade_exports;
|
|
23632
23889
|
exports.assertFinalCommitmentMatchesValidated = assertFinalCommitmentMatchesValidated;
|
|
23633
23890
|
exports.assertIntentIdUnique = assertIntentIdUnique;
|
|
23891
|
+
exports.assertRecipientArkadeAddress = assertRecipientArkadeAddress;
|
|
23634
23892
|
exports.assertSendableAmount = assertSendableAmount;
|
|
23635
23893
|
exports.assertSubmittedArkTxid = assertSubmittedArkTxid;
|
|
23636
23894
|
exports.assertValidBatchExpiry = assertValidBatchExpiry;
|
|
@@ -23747,5 +24005,5 @@ exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
|
23747
24005
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
23748
24006
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
23749
24007
|
exports.withPrevTxs = withPrevTxs;
|
|
23750
|
-
//# sourceMappingURL=chunk-
|
|
23751
|
-
//# sourceMappingURL=chunk-
|
|
24008
|
+
//# sourceMappingURL=chunk-5MJHZHG7.cjs.map
|
|
24009
|
+
//# sourceMappingURL=chunk-5MJHZHG7.cjs.map
|