@arkade-os/sdk 0.4.28 → 0.4.29
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 +14 -16
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +4 -4
- package/dist/adapters/expo.d.ts +4 -4
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{ark-TZ1gXAXU.d.cts → ark-ChhTwpLf.d.cts} +73 -61
- package/dist/{ark-TZ1gXAXU.d.ts → ark-ChhTwpLf.d.ts} +73 -61
- package/dist/{asyncStorageTaskQueue-EFqSmYTg.d.cts → asyncStorageTaskQueue-DW1-BpI7.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-Cb1F_Z9s.d.ts → asyncStorageTaskQueue-DZ0nUuEJ.d.ts} +2 -2
- package/dist/{chunk-ADV27S4N.cjs → chunk-6FLL2Q36.cjs} +8 -8
- package/dist/chunk-6FLL2Q36.cjs.map +1 -0
- package/dist/{chunk-ZBUDLTBO.js → chunk-6NWNOLL3.js} +5 -5
- package/dist/chunk-6NWNOLL3.js.map +1 -0
- package/dist/{chunk-CFZMTDWI.js → chunk-ABWRLTX5.js} +6 -5
- package/dist/chunk-ABWRLTX5.js.map +1 -0
- package/dist/{chunk-BQLHADL7.js → chunk-BVP2U66Q.js} +316 -178
- package/dist/chunk-BVP2U66Q.js.map +1 -0
- package/dist/{chunk-ZLO6NETT.cjs → chunk-GDCTOSMV.cjs} +480 -332
- package/dist/chunk-GDCTOSMV.cjs.map +1 -0
- package/dist/{chunk-FG5ACJJW.cjs → chunk-GIGILVVP.cjs} +11 -10
- package/dist/chunk-GIGILVVP.cjs.map +1 -0
- package/dist/{chunk-I3DGUUCT.cjs → chunk-IEO3XDKI.cjs} +28 -28
- package/dist/{chunk-I3DGUUCT.cjs.map → chunk-IEO3XDKI.cjs.map} +1 -1
- package/dist/{chunk-IPX2R7FR.cjs → chunk-PJUFOJ2L.cjs} +7 -7
- package/dist/{chunk-IPX2R7FR.cjs.map → chunk-PJUFOJ2L.cjs.map} +1 -1
- package/dist/{chunk-A3EMF7RN.js → chunk-TH6T23XG.js} +3 -3
- package/dist/{chunk-A3EMF7RN.js.map → chunk-TH6T23XG.js.map} +1 -1
- package/dist/{chunk-HW3JJ323.js → chunk-TU3LVAPX.js} +32 -31
- package/dist/chunk-TU3LVAPX.js.map +1 -0
- package/dist/{chunk-5PG7DV7A.cjs → chunk-WMIPYZSB.cjs} +34 -36
- package/dist/chunk-WMIPYZSB.cjs.map +1 -0
- package/dist/{chunk-T64LAI7L.js → chunk-YA4G7RFB.js} +3 -3
- package/dist/{chunk-T64LAI7L.js.map → chunk-YA4G7RFB.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +6 -6
- 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-aaVGfWsV.d.ts → delegate-4JBUkUhR.d.cts} +2 -2
- package/dist/{delegate-BFZs69hp.d.cts → delegate-DN7RELL1.d.ts} +2 -2
- package/dist/{index-NDla_UoJ.d.ts → index-Cn82bBUu.d.ts} +2 -2
- package/dist/{index-B22cA64m.d.cts → index-DfT5xzgY.d.cts} +2 -2
- package/dist/index.cjs +161 -137
- package/dist/index.d.cts +143 -17
- package/dist/index.d.ts +143 -17
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +13 -13
- package/dist/repositories/realm/index.d.cts +1 -1
- package/dist/repositories/realm/index.d.ts +1 -1
- package/dist/repositories/realm/index.js +4 -4
- package/dist/repositories/sqlite/index.cjs +13 -13
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.js +4 -4
- package/dist/{taskRunner-C6Ff4OaU.d.cts → taskRunner-B-aPfHhK.d.cts} +2 -2
- package/dist/{taskRunner-yvPN8Z0K.d.ts → taskRunner-B-vG08pX.d.ts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +19 -15
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +9 -7
- package/dist/wallet/expo/index.d.ts +9 -7
- package/dist/wallet/expo/index.js +11 -7
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-D9NBRqvC.d.ts → wallet-CCtqT2Wb.d.ts} +19 -15
- package/dist/{wallet-AF-p-OWj.d.cts → wallet-DjgFb_4T.d.cts} +19 -15
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-5PG7DV7A.cjs.map +0 -1
- package/dist/chunk-ADV27S4N.cjs.map +0 -1
- package/dist/chunk-BQLHADL7.js.map +0 -1
- package/dist/chunk-CFZMTDWI.js.map +0 -1
- package/dist/chunk-FG5ACJJW.cjs.map +0 -1
- package/dist/chunk-HW3JJ323.js.map +0 -1
- package/dist/chunk-ZBUDLTBO.js.map +0 -1
- package/dist/chunk-ZLO6NETT.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk6FLL2Q36_cjs = require('./chunk-6FLL2Q36.cjs');
|
|
4
|
+
var chunkIEO3XDKI_cjs = require('./chunk-IEO3XDKI.cjs');
|
|
5
|
+
var chunkWMIPYZSB_cjs = require('./chunk-WMIPYZSB.cjs');
|
|
6
6
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
7
7
|
var btcSigner = require('@scure/btc-signer');
|
|
8
8
|
var base = require('@scure/base');
|
|
@@ -181,7 +181,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
181
181
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
182
182
|
const tx = this.graph.find(txid);
|
|
183
183
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
184
|
-
const cosigners =
|
|
184
|
+
const cosigners = chunk6FLL2Q36_cjs.getArkPsbtFields(tx.root, 0, chunk6FLL2Q36_cjs.CosignerPublicKey).map(
|
|
185
185
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
186
186
|
// xonly pubkey
|
|
187
187
|
);
|
|
@@ -233,7 +233,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
233
233
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
234
234
|
const prevoutAmounts = [];
|
|
235
235
|
const prevoutScripts = [];
|
|
236
|
-
const cosigners =
|
|
236
|
+
const cosigners = chunk6FLL2Q36_cjs.getArkPsbtFields(g.root, 0, chunk6FLL2Q36_cjs.CosignerPublicKey).map((c) => c.key);
|
|
237
237
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
238
238
|
taprootTweak: this.scriptRoot
|
|
239
239
|
});
|
|
@@ -411,7 +411,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
411
411
|
let network;
|
|
412
412
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
413
413
|
descriptor = opts.descriptor;
|
|
414
|
-
network =
|
|
414
|
+
network = chunkIEO3XDKI_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
415
415
|
} else {
|
|
416
416
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
417
417
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -496,7 +496,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
496
496
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
497
497
|
*/
|
|
498
498
|
isOurs(descriptor) {
|
|
499
|
-
return
|
|
499
|
+
return chunkIEO3XDKI_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
500
500
|
}
|
|
501
501
|
/**
|
|
502
502
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -533,7 +533,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
533
533
|
}
|
|
534
534
|
// ── internal helpers ─────────────────────────────────────────────
|
|
535
535
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
536
|
-
const network =
|
|
536
|
+
const network = chunkIEO3XDKI_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
537
537
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
538
538
|
if (expansion.isRanged) {
|
|
539
539
|
throw new Error(
|
|
@@ -619,7 +619,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
619
619
|
*/
|
|
620
620
|
descriptor;
|
|
621
621
|
constructor(descriptor) {
|
|
622
|
-
const network =
|
|
622
|
+
const network = chunkIEO3XDKI_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
623
623
|
let expansion;
|
|
624
624
|
try {
|
|
625
625
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -669,7 +669,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
669
669
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
670
670
|
*/
|
|
671
671
|
isOurs(descriptor) {
|
|
672
|
-
return
|
|
672
|
+
return chunkIEO3XDKI_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
673
673
|
}
|
|
674
674
|
};
|
|
675
675
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -960,12 +960,12 @@ async function getActiveServiceWorker(path) {
|
|
|
960
960
|
return serviceWorker;
|
|
961
961
|
}
|
|
962
962
|
|
|
963
|
-
// src/providers/
|
|
964
|
-
var
|
|
963
|
+
// src/providers/delegate.ts
|
|
964
|
+
var RestDelegateProvider = class {
|
|
965
965
|
/**
|
|
966
|
-
* Create a REST
|
|
966
|
+
* Create a REST delegate provider targeting the given base URL.
|
|
967
967
|
*
|
|
968
|
-
* @param url - Base URL of the delegation service
|
|
968
|
+
* @param url - Base URL of the remote delegation service.
|
|
969
969
|
*/
|
|
970
970
|
constructor(url) {
|
|
971
971
|
this.url = url;
|
|
@@ -987,7 +987,7 @@ var RestDelegatorProvider = class {
|
|
|
987
987
|
},
|
|
988
988
|
body: JSON.stringify({
|
|
989
989
|
intent: {
|
|
990
|
-
message:
|
|
990
|
+
message: chunk6FLL2Q36_cjs.Intent.encodeMessage(intent.message),
|
|
991
991
|
proof: intent.proof
|
|
992
992
|
},
|
|
993
993
|
forfeit_txs: forfeitTxs,
|
|
@@ -1016,35 +1016,13 @@ var RestDelegatorProvider = class {
|
|
|
1016
1016
|
if (!isDelegateInfo(data)) {
|
|
1017
1017
|
throw new Error("Invalid delegate info");
|
|
1018
1018
|
}
|
|
1019
|
-
|
|
1019
|
+
const delegateAddress = typeof data.delegateAddress === "string" && data.delegateAddress !== "" ? data.delegateAddress : typeof data.delegatorAddress === "string" && data.delegatorAddress !== "" ? data.delegatorAddress : "";
|
|
1020
|
+
return { ...data, delegateAddress };
|
|
1020
1021
|
}
|
|
1021
1022
|
};
|
|
1023
|
+
var RestDelegatorProvider = RestDelegateProvider;
|
|
1022
1024
|
function isDelegateInfo(data) {
|
|
1023
|
-
return !!data && typeof data === "object" && "pubkey" in data && "fee" in data && "
|
|
1024
|
-
}
|
|
1025
|
-
var getNetwork = (network) => {
|
|
1026
|
-
return networks2[network];
|
|
1027
|
-
};
|
|
1028
|
-
var networks2 = {
|
|
1029
|
-
bitcoin: withArkPrefix(utils_js.NETWORK, "ark"),
|
|
1030
|
-
testnet: withArkPrefix(utils_js.TEST_NETWORK, "tark"),
|
|
1031
|
-
signet: withArkPrefix(utils_js.TEST_NETWORK, "tark"),
|
|
1032
|
-
mutinynet: withArkPrefix(utils_js.TEST_NETWORK, "tark"),
|
|
1033
|
-
regtest: withArkPrefix(
|
|
1034
|
-
{
|
|
1035
|
-
...utils_js.TEST_NETWORK,
|
|
1036
|
-
bech32: "bcrt",
|
|
1037
|
-
pubKeyHash: 111,
|
|
1038
|
-
scriptHash: 196
|
|
1039
|
-
},
|
|
1040
|
-
"tark"
|
|
1041
|
-
)
|
|
1042
|
-
};
|
|
1043
|
-
function withArkPrefix(network, prefix) {
|
|
1044
|
-
return {
|
|
1045
|
-
...network,
|
|
1046
|
-
hrp: prefix
|
|
1047
|
-
};
|
|
1025
|
+
return !!data && typeof data === "object" && "pubkey" in data && "fee" in data && typeof data.pubkey === "string" && typeof data.fee === "string" && data.pubkey !== "" && data.fee !== "" && (typeof data.delegateAddress === "string" && data.delegateAddress !== "" || typeof data.delegatorAddress === "string" && data.delegatorAddress !== "");
|
|
1048
1026
|
}
|
|
1049
1027
|
|
|
1050
1028
|
// src/providers/onchain.ts
|
|
@@ -1056,7 +1034,7 @@ var ESPLORA_URL = {
|
|
|
1056
1034
|
regtest: "http://localhost:3000"
|
|
1057
1035
|
};
|
|
1058
1036
|
var EsploraProvider = class {
|
|
1059
|
-
constructor(baseUrl, opts) {
|
|
1037
|
+
constructor(baseUrl = ESPLORA_URL[chunkWMIPYZSB_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1060
1038
|
this.baseUrl = baseUrl;
|
|
1061
1039
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1062
1040
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1299,7 +1277,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
1299
1277
|
);
|
|
1300
1278
|
}
|
|
1301
1279
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
1302
|
-
const tx = new
|
|
1280
|
+
const tx = new chunk6FLL2Q36_cjs.Transaction({
|
|
1303
1281
|
version: 3,
|
|
1304
1282
|
lockTime: txLocktime
|
|
1305
1283
|
});
|
|
@@ -1375,7 +1353,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
1375
1353
|
if (previousScriptKey.length !== 32) {
|
|
1376
1354
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
1377
1355
|
}
|
|
1378
|
-
const cosigners =
|
|
1356
|
+
const cosigners = chunk6FLL2Q36_cjs.getArkPsbtFields(child.root, 0, chunk6FLL2Q36_cjs.CosignerPublicKey);
|
|
1379
1357
|
if (cosigners.length === 0) {
|
|
1380
1358
|
throw ErrMissingCosignersPublicKeys;
|
|
1381
1359
|
}
|
|
@@ -1475,7 +1453,7 @@ var Extension = class _Extension {
|
|
|
1475
1453
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
1476
1454
|
);
|
|
1477
1455
|
}
|
|
1478
|
-
const reader = new
|
|
1456
|
+
const reader = new chunk6FLL2Q36_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
1479
1457
|
const packets = [];
|
|
1480
1458
|
while (reader.remaining() > 0) {
|
|
1481
1459
|
const packetType = reader.readByte();
|
|
@@ -1549,7 +1527,7 @@ var Extension = class _Extension {
|
|
|
1549
1527
|
*/
|
|
1550
1528
|
getAssetPacket() {
|
|
1551
1529
|
for (const p of this.packets) {
|
|
1552
|
-
if (p instanceof
|
|
1530
|
+
if (p instanceof chunk6FLL2Q36_cjs.Packet) {
|
|
1553
1531
|
return p;
|
|
1554
1532
|
}
|
|
1555
1533
|
}
|
|
@@ -1557,8 +1535,8 @@ var Extension = class _Extension {
|
|
|
1557
1535
|
}
|
|
1558
1536
|
};
|
|
1559
1537
|
function parsePacket(packetType, data) {
|
|
1560
|
-
if (packetType ===
|
|
1561
|
-
return
|
|
1538
|
+
if (packetType === chunk6FLL2Q36_cjs.Packet.PACKET_TYPE) {
|
|
1539
|
+
return chunk6FLL2Q36_cjs.Packet.fromBytes(data);
|
|
1562
1540
|
}
|
|
1563
1541
|
return new UnknownPacket(packetType, data);
|
|
1564
1542
|
}
|
|
@@ -1616,7 +1594,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
1616
1594
|
for (const recipient of recipients) {
|
|
1617
1595
|
let arkAddress;
|
|
1618
1596
|
try {
|
|
1619
|
-
arkAddress =
|
|
1597
|
+
arkAddress = chunkWMIPYZSB_cjs.ArkAddress.decode(recipient.address);
|
|
1620
1598
|
} catch {
|
|
1621
1599
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
1622
1600
|
continue;
|
|
@@ -1717,6 +1695,30 @@ function validateAssetGroupOutput(packet, outputIndex, assetId, expectedAmount)
|
|
|
1717
1695
|
}
|
|
1718
1696
|
}
|
|
1719
1697
|
|
|
1698
|
+
// src/wallet/index.ts
|
|
1699
|
+
var TxType = /* @__PURE__ */ ((TxType2) => {
|
|
1700
|
+
TxType2["TxSent"] = "SENT";
|
|
1701
|
+
TxType2["TxReceived"] = "RECEIVED";
|
|
1702
|
+
return TxType2;
|
|
1703
|
+
})(TxType || {});
|
|
1704
|
+
function isSpendable(vtxo) {
|
|
1705
|
+
return !vtxo.isSpent;
|
|
1706
|
+
}
|
|
1707
|
+
function isRecoverable(vtxo) {
|
|
1708
|
+
return vtxo.virtualStatus.state === "swept" && isSpendable(vtxo);
|
|
1709
|
+
}
|
|
1710
|
+
function isExpired(vtxo) {
|
|
1711
|
+
if (vtxo.virtualStatus.state === "swept") return true;
|
|
1712
|
+
const expiry = vtxo.virtualStatus.batchExpiry;
|
|
1713
|
+
if (!expiry) return false;
|
|
1714
|
+
const expireAt = new Date(expiry);
|
|
1715
|
+
if (expireAt.getFullYear() < 2025) return false;
|
|
1716
|
+
return expiry <= Date.now();
|
|
1717
|
+
}
|
|
1718
|
+
function isSubdust(vtxo, dust) {
|
|
1719
|
+
return vtxo.value < dust;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1720
1722
|
// src/wallet/asset.ts
|
|
1721
1723
|
function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
1722
1724
|
const inputsByAssetId = /* @__PURE__ */ new Map();
|
|
@@ -1725,7 +1727,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1725
1727
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
1726
1728
|
inputsByAssetId.set(asset.assetId, [
|
|
1727
1729
|
...existing ?? [],
|
|
1728
|
-
|
|
1730
|
+
chunk6FLL2Q36_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
1729
1731
|
]);
|
|
1730
1732
|
}
|
|
1731
1733
|
}
|
|
@@ -1737,7 +1739,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1737
1739
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
1738
1740
|
outputsByAssetId.set(asset.assetId, [
|
|
1739
1741
|
...existing ?? [],
|
|
1740
|
-
|
|
1742
|
+
chunk6FLL2Q36_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
1741
1743
|
]);
|
|
1742
1744
|
}
|
|
1743
1745
|
}
|
|
@@ -1748,7 +1750,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1748
1750
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
1749
1751
|
outputsByAssetId.set(asset.assetId, [
|
|
1750
1752
|
...existing ?? [],
|
|
1751
|
-
|
|
1753
|
+
chunk6FLL2Q36_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
1752
1754
|
]);
|
|
1753
1755
|
}
|
|
1754
1756
|
}
|
|
@@ -1757,11 +1759,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1757
1759
|
for (const assetIdStr of allAssetIds) {
|
|
1758
1760
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
1759
1761
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
1760
|
-
const assetId =
|
|
1761
|
-
const group =
|
|
1762
|
+
const assetId = chunk6FLL2Q36_cjs.AssetId.fromString(assetIdStr);
|
|
1763
|
+
const group = chunk6FLL2Q36_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
1762
1764
|
groups.push(group);
|
|
1763
1765
|
}
|
|
1764
|
-
return
|
|
1766
|
+
return chunk6FLL2Q36_cjs.Packet.create(groups);
|
|
1765
1767
|
}
|
|
1766
1768
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
1767
1769
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -1827,8 +1829,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
1827
1829
|
function buildVirtualTx(inputs, outputs) {
|
|
1828
1830
|
let lockTime = 0n;
|
|
1829
1831
|
for (const input of inputs) {
|
|
1830
|
-
const tapscript =
|
|
1831
|
-
if (
|
|
1832
|
+
const tapscript = chunkWMIPYZSB_cjs.decodeTapscript(chunkWMIPYZSB_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
1833
|
+
if (chunkWMIPYZSB_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
1832
1834
|
if (lockTime !== 0n) {
|
|
1833
1835
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
1834
1836
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -1839,7 +1841,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
1839
1841
|
}
|
|
1840
1842
|
}
|
|
1841
1843
|
}
|
|
1842
|
-
const tx = new
|
|
1844
|
+
const tx = new chunk6FLL2Q36_cjs.Transaction({
|
|
1843
1845
|
version: 3,
|
|
1844
1846
|
lockTime: Number(lockTime)
|
|
1845
1847
|
});
|
|
@@ -1849,12 +1851,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
1849
1851
|
index: input.vout,
|
|
1850
1852
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
1851
1853
|
witnessUtxo: {
|
|
1852
|
-
script:
|
|
1854
|
+
script: chunkWMIPYZSB_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
1853
1855
|
amount: BigInt(input.value)
|
|
1854
1856
|
},
|
|
1855
1857
|
tapLeafScript: [input.tapLeafScript]
|
|
1856
1858
|
});
|
|
1857
|
-
|
|
1859
|
+
chunk6FLL2Q36_cjs.setArkPsbtField(tx, i, chunk6FLL2Q36_cjs.VtxoTaprootTree, input.tapTree);
|
|
1858
1860
|
}
|
|
1859
1861
|
for (const output of outputs) {
|
|
1860
1862
|
tx.addOutput(output);
|
|
@@ -1863,8 +1865,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
1863
1865
|
return tx;
|
|
1864
1866
|
}
|
|
1865
1867
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
1866
|
-
const collaborativeClosure =
|
|
1867
|
-
const checkpointVtxoScript = new
|
|
1868
|
+
const collaborativeClosure = chunkWMIPYZSB_cjs.decodeTapscript(chunkWMIPYZSB_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
1869
|
+
const checkpointVtxoScript = new chunkWMIPYZSB_cjs.VtxoScript([
|
|
1868
1870
|
serverUnrollScript.script,
|
|
1869
1871
|
collaborativeClosure.script
|
|
1870
1872
|
]);
|
|
@@ -1998,7 +2000,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
1998
2000
|
}
|
|
1999
2001
|
function isValidArkAddress(address) {
|
|
2000
2002
|
try {
|
|
2001
|
-
|
|
2003
|
+
chunkWMIPYZSB_cjs.ArkAddress.decode(address);
|
|
2002
2004
|
return true;
|
|
2003
2005
|
} catch (e) {
|
|
2004
2006
|
return false;
|
|
@@ -2263,6 +2265,77 @@ function parseProgram(text, env) {
|
|
|
2263
2265
|
}
|
|
2264
2266
|
return { program, text };
|
|
2265
2267
|
}
|
|
2268
|
+
var DUST_AMOUNT = 546;
|
|
2269
|
+
var FALLBACK_WALLET_DUST_AMOUNT = 330n;
|
|
2270
|
+
function getDustAmount(wallet) {
|
|
2271
|
+
return "dustAmount" in wallet ? wallet.dustAmount : FALLBACK_WALLET_DUST_AMOUNT;
|
|
2272
|
+
}
|
|
2273
|
+
function extendCoin(wallet, utxo) {
|
|
2274
|
+
return {
|
|
2275
|
+
...utxo,
|
|
2276
|
+
forfeitTapLeafScript: wallet.boardingTapscript.forfeit(),
|
|
2277
|
+
intentTapLeafScript: wallet.boardingTapscript.forfeit(),
|
|
2278
|
+
tapTree: wallet.boardingTapscript.encode()
|
|
2279
|
+
};
|
|
2280
|
+
}
|
|
2281
|
+
function extendVtxoFromContract(vtxo, contract) {
|
|
2282
|
+
const handler = chunkIEO3XDKI_cjs.contractHandlers.get(contract.type);
|
|
2283
|
+
if (!handler) {
|
|
2284
|
+
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
2285
|
+
}
|
|
2286
|
+
const script = handler.createScript(contract.params);
|
|
2287
|
+
return {
|
|
2288
|
+
...vtxo,
|
|
2289
|
+
forfeitTapLeafScript: script.forfeit(),
|
|
2290
|
+
intentTapLeafScript: script.forfeit(),
|
|
2291
|
+
tapTree: script.encode()
|
|
2292
|
+
};
|
|
2293
|
+
}
|
|
2294
|
+
function extendVirtualCoinForContract(vtxo, contractOrMap) {
|
|
2295
|
+
const contract = resolveContract(vtxo, contractOrMap);
|
|
2296
|
+
if (!contract) {
|
|
2297
|
+
throw new Error(
|
|
2298
|
+
"extendVirtualCoinForContract: no contract matched vtxo.script \u2014 callers must resolve the owning contract before annotating"
|
|
2299
|
+
);
|
|
2300
|
+
}
|
|
2301
|
+
return extendVtxoFromContract(vtxo, contract);
|
|
2302
|
+
}
|
|
2303
|
+
function isContractMap(value) {
|
|
2304
|
+
return typeof value.get === "function";
|
|
2305
|
+
}
|
|
2306
|
+
function resolveContract(vtxo, contractOrMap) {
|
|
2307
|
+
if (!contractOrMap) return void 0;
|
|
2308
|
+
if (isContractMap(contractOrMap)) {
|
|
2309
|
+
return contractOrMap.get(vtxo.script);
|
|
2310
|
+
}
|
|
2311
|
+
return contractOrMap;
|
|
2312
|
+
}
|
|
2313
|
+
function getRandomId() {
|
|
2314
|
+
const randomValue = crypto.getRandomValues(new Uint8Array(16));
|
|
2315
|
+
return base.hex.encode(randomValue);
|
|
2316
|
+
}
|
|
2317
|
+
function validateRecipients(recipients, dustAmount) {
|
|
2318
|
+
const validatedRecipients = [];
|
|
2319
|
+
for (const recipient of recipients) {
|
|
2320
|
+
let address;
|
|
2321
|
+
try {
|
|
2322
|
+
address = chunkWMIPYZSB_cjs.ArkAddress.decode(recipient.address);
|
|
2323
|
+
} catch (e) {
|
|
2324
|
+
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
2325
|
+
}
|
|
2326
|
+
const amount = recipient.amount || dustAmount;
|
|
2327
|
+
if (amount <= 0) {
|
|
2328
|
+
throw new Error("Amount must be positive");
|
|
2329
|
+
}
|
|
2330
|
+
validatedRecipients.push({
|
|
2331
|
+
address: recipient.address,
|
|
2332
|
+
assets: recipient.assets ?? [],
|
|
2333
|
+
amount,
|
|
2334
|
+
script: amount < dustAmount ? address.subdustPkScript : address.pkScript
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2337
|
+
return validatedRecipients;
|
|
2338
|
+
}
|
|
2266
2339
|
|
|
2267
2340
|
// src/wallet/vtxo-manager.ts
|
|
2268
2341
|
function isSweepCapable(wallet) {
|
|
@@ -2287,7 +2360,7 @@ async function runWithCrossInstanceLock(name, fn) {
|
|
|
2287
2360
|
await fn();
|
|
2288
2361
|
});
|
|
2289
2362
|
}
|
|
2290
|
-
var DEFAULT_THRESHOLD_SECONDS =
|
|
2363
|
+
var DEFAULT_THRESHOLD_SECONDS = 259200;
|
|
2291
2364
|
var DEFAULT_THRESHOLD_MS = DEFAULT_THRESHOLD_SECONDS * 1e3;
|
|
2292
2365
|
var DEFAULT_RENEWAL_CONFIG = {
|
|
2293
2366
|
thresholdMs: DEFAULT_THRESHOLD_MS
|
|
@@ -2298,18 +2371,15 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
2298
2371
|
boardingUtxoSweep: true,
|
|
2299
2372
|
pollIntervalMs: 6e4
|
|
2300
2373
|
};
|
|
2301
|
-
function getDustAmount(wallet) {
|
|
2302
|
-
return "dustAmount" in wallet ? wallet.dustAmount : 330n;
|
|
2303
|
-
}
|
|
2304
2374
|
function getRecoverableVtxos(vtxos, dustAmount) {
|
|
2305
2375
|
return vtxos.filter((vtxo) => {
|
|
2306
|
-
if (
|
|
2376
|
+
if (isRecoverable(vtxo)) {
|
|
2307
2377
|
return true;
|
|
2308
2378
|
}
|
|
2309
|
-
if (
|
|
2379
|
+
if (isSpendable(vtxo) && isExpired(vtxo)) {
|
|
2310
2380
|
return true;
|
|
2311
2381
|
}
|
|
2312
|
-
if (vtxo.virtualStatus.state === "preconfirmed" &&
|
|
2382
|
+
if (vtxo.virtualStatus.state === "preconfirmed" && isSubdust(vtxo, dustAmount)) {
|
|
2313
2383
|
return true;
|
|
2314
2384
|
}
|
|
2315
2385
|
return false;
|
|
@@ -2320,7 +2390,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount) {
|
|
|
2320
2390
|
const subdust = [];
|
|
2321
2391
|
const regular = [];
|
|
2322
2392
|
for (const vtxo of recoverableVtxos) {
|
|
2323
|
-
if (
|
|
2393
|
+
if (isSubdust(vtxo, dustAmount)) {
|
|
2324
2394
|
subdust.push(vtxo);
|
|
2325
2395
|
} else {
|
|
2326
2396
|
regular.push(vtxo);
|
|
@@ -2350,7 +2420,7 @@ function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
|
2350
2420
|
}
|
|
2351
2421
|
function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount) {
|
|
2352
2422
|
return vtxos.filter(
|
|
2353
|
-
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
2423
|
+
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) || isRecoverable(vtxo) || isSpendable(vtxo) && isExpired(vtxo) || isSubdust(vtxo, dustAmount)
|
|
2354
2424
|
);
|
|
2355
2425
|
}
|
|
2356
2426
|
var VtxoManager = class _VtxoManager {
|
|
@@ -2516,7 +2586,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
2516
2586
|
* ```typescript
|
|
2517
2587
|
* const wallet = await Wallet.create({
|
|
2518
2588
|
* identity,
|
|
2519
|
-
*
|
|
2589
|
+
* arkProvider: new RestArkProvider(),
|
|
2520
2590
|
* settlementConfig: {
|
|
2521
2591
|
* vtxoThreshold: 86_400 // 24 hours
|
|
2522
2592
|
* },
|
|
@@ -2660,7 +2730,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
2660
2730
|
* ```typescript
|
|
2661
2731
|
* const wallet = await Wallet.create({
|
|
2662
2732
|
* identity,
|
|
2663
|
-
*
|
|
2733
|
+
* arkProvider: new RestArkProvider(),
|
|
2664
2734
|
* settlementConfig: {
|
|
2665
2735
|
* boardingUtxoSweep: true,
|
|
2666
2736
|
* },
|
|
@@ -2690,7 +2760,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
2690
2760
|
const boardingAddress = await this.wallet.getBoardingAddress();
|
|
2691
2761
|
const feeRate = await this.getOnchainProvider().getFeeRate() ?? 1;
|
|
2692
2762
|
const exitTapLeafScript = this.getBoardingExitLeaf();
|
|
2693
|
-
const sequence =
|
|
2763
|
+
const sequence = chunkWMIPYZSB_cjs.getSequence(exitTapLeafScript);
|
|
2694
2764
|
const leafScript = exitTapLeafScript[1];
|
|
2695
2765
|
const leafScriptSize = leafScript.length - 1;
|
|
2696
2766
|
const controlBlockSize = exitTapLeafScript[0].merklePath.length * 32;
|
|
@@ -2709,7 +2779,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
2709
2779
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
2710
2780
|
);
|
|
2711
2781
|
}
|
|
2712
|
-
const tx = new
|
|
2782
|
+
const tx = new chunk6FLL2Q36_cjs.Transaction();
|
|
2713
2783
|
for (const utxo of expiredUtxos) {
|
|
2714
2784
|
tx.addInput({
|
|
2715
2785
|
txid: utxo.txid,
|
|
@@ -2741,7 +2811,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
2741
2811
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
2742
2812
|
getBoardingTimelock() {
|
|
2743
2813
|
const wallet = this.getSweepWallet();
|
|
2744
|
-
const exitScript =
|
|
2814
|
+
const exitScript = chunkWMIPYZSB_cjs.CSVMultisigTapscript.decode(
|
|
2745
2815
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
2746
2816
|
);
|
|
2747
2817
|
return exitScript.params.timelock;
|
|
@@ -2779,8 +2849,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
2779
2849
|
this.startBoardingUtxoPoll();
|
|
2780
2850
|
}, 1e3);
|
|
2781
2851
|
try {
|
|
2782
|
-
const [
|
|
2783
|
-
this.wallet.
|
|
2852
|
+
const [delegateManager, contractManager, destination] = await Promise.all([
|
|
2853
|
+
this.wallet.getDelegateManager(),
|
|
2784
2854
|
this.wallet.getContractManager(),
|
|
2785
2855
|
this.wallet.getAddress()
|
|
2786
2856
|
]);
|
|
@@ -2810,8 +2880,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
2810
2880
|
console.error("Error renewing VTXOs:", e);
|
|
2811
2881
|
});
|
|
2812
2882
|
}
|
|
2813
|
-
if (
|
|
2814
|
-
|
|
2883
|
+
if (delegateManager) {
|
|
2884
|
+
delegateManager.delegate(event.vtxos, destination).catch((e) => {
|
|
2815
2885
|
console.error("Error delegating VTXOs:", e);
|
|
2816
2886
|
});
|
|
2817
2887
|
}
|
|
@@ -2870,7 +2940,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
2870
2940
|
* or doesn't carry the metadata.
|
|
2871
2941
|
*/
|
|
2872
2942
|
extractSpentOutpoint(error) {
|
|
2873
|
-
const ark =
|
|
2943
|
+
const ark = chunk6FLL2Q36_cjs.maybeArkError(error);
|
|
2874
2944
|
if (!ark || ark.name !== "VTXO_ALREADY_SPENT") return void 0;
|
|
2875
2945
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
2876
2946
|
if (typeof raw !== "string") return void 0;
|
|
@@ -3070,7 +3140,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3070
3140
|
const arkAddress = await this.wallet.getAddress();
|
|
3071
3141
|
const outputFee = estimator.evalOffchainOutput({
|
|
3072
3142
|
amount: totalAmount,
|
|
3073
|
-
script: base.hex.encode(
|
|
3143
|
+
script: base.hex.encode(chunkWMIPYZSB_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
3074
3144
|
});
|
|
3075
3145
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
3076
3146
|
if (totalAmount < dustAmount) return;
|
|
@@ -3151,7 +3221,7 @@ var ArkNote = class _ArkNote {
|
|
|
3151
3221
|
this.value = value;
|
|
3152
3222
|
this.HRP = HRP;
|
|
3153
3223
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
3154
|
-
this.vtxoScript = new
|
|
3224
|
+
this.vtxoScript = new chunkWMIPYZSB_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
3155
3225
|
const leaf = this.vtxoScript.leaves[0];
|
|
3156
3226
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
3157
3227
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -3252,73 +3322,6 @@ function readUInt32BE(array, offset) {
|
|
|
3252
3322
|
function noteTapscript(preimageHash) {
|
|
3253
3323
|
return btcSigner.Script.encode(["SHA256", preimageHash, "EQUAL"]);
|
|
3254
3324
|
}
|
|
3255
|
-
var DUST_AMOUNT = 546;
|
|
3256
|
-
function extendCoin(wallet, utxo) {
|
|
3257
|
-
return {
|
|
3258
|
-
...utxo,
|
|
3259
|
-
forfeitTapLeafScript: wallet.boardingTapscript.forfeit(),
|
|
3260
|
-
intentTapLeafScript: wallet.boardingTapscript.forfeit(),
|
|
3261
|
-
tapTree: wallet.boardingTapscript.encode()
|
|
3262
|
-
};
|
|
3263
|
-
}
|
|
3264
|
-
function extendVtxoFromContract(vtxo, contract) {
|
|
3265
|
-
const handler = chunkI3DGUUCT_cjs.contractHandlers.get(contract.type);
|
|
3266
|
-
if (!handler) {
|
|
3267
|
-
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3268
|
-
}
|
|
3269
|
-
const script = handler.createScript(contract.params);
|
|
3270
|
-
return {
|
|
3271
|
-
...vtxo,
|
|
3272
|
-
forfeitTapLeafScript: script.forfeit(),
|
|
3273
|
-
intentTapLeafScript: script.forfeit(),
|
|
3274
|
-
tapTree: script.encode()
|
|
3275
|
-
};
|
|
3276
|
-
}
|
|
3277
|
-
function extendVirtualCoinForContract(vtxo, contractOrMap) {
|
|
3278
|
-
const contract = resolveContract(vtxo, contractOrMap);
|
|
3279
|
-
if (!contract) {
|
|
3280
|
-
throw new Error(
|
|
3281
|
-
"extendVirtualCoinForContract: no contract matched vtxo.script \u2014 callers must resolve the owning contract before annotating"
|
|
3282
|
-
);
|
|
3283
|
-
}
|
|
3284
|
-
return extendVtxoFromContract(vtxo, contract);
|
|
3285
|
-
}
|
|
3286
|
-
function isContractMap(value) {
|
|
3287
|
-
return typeof value.get === "function";
|
|
3288
|
-
}
|
|
3289
|
-
function resolveContract(vtxo, contractOrMap) {
|
|
3290
|
-
if (!contractOrMap) return void 0;
|
|
3291
|
-
if (isContractMap(contractOrMap)) {
|
|
3292
|
-
return contractOrMap.get(vtxo.script);
|
|
3293
|
-
}
|
|
3294
|
-
return contractOrMap;
|
|
3295
|
-
}
|
|
3296
|
-
function getRandomId() {
|
|
3297
|
-
const randomValue = crypto.getRandomValues(new Uint8Array(16));
|
|
3298
|
-
return base.hex.encode(randomValue);
|
|
3299
|
-
}
|
|
3300
|
-
function validateRecipients(recipients, dustAmount) {
|
|
3301
|
-
const validatedRecipients = [];
|
|
3302
|
-
for (const recipient of recipients) {
|
|
3303
|
-
let address;
|
|
3304
|
-
try {
|
|
3305
|
-
address = chunk5PG7DV7A_cjs.ArkAddress.decode(recipient.address);
|
|
3306
|
-
} catch (e) {
|
|
3307
|
-
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
3308
|
-
}
|
|
3309
|
-
const amount = recipient.amount || dustAmount;
|
|
3310
|
-
if (amount <= 0) {
|
|
3311
|
-
throw new Error("Amount must be positive");
|
|
3312
|
-
}
|
|
3313
|
-
validatedRecipients.push({
|
|
3314
|
-
address: recipient.address,
|
|
3315
|
-
assets: recipient.assets ?? [],
|
|
3316
|
-
amount,
|
|
3317
|
-
script: amount < dustAmount ? address.subdustPkScript : address.pkScript
|
|
3318
|
-
});
|
|
3319
|
-
}
|
|
3320
|
-
return validatedRecipients;
|
|
3321
|
-
}
|
|
3322
3325
|
var TxTree = class {
|
|
3323
3326
|
constructor(root, children = /* @__PURE__ */ new Map()) {
|
|
3324
3327
|
this.root = root;
|
|
@@ -3808,7 +3811,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3808
3811
|
const virtualCoins = await this.wallet.getVtxos({
|
|
3809
3812
|
withRecoverable: false
|
|
3810
3813
|
});
|
|
3811
|
-
const controlAssetRef = params.controlAssetId ?
|
|
3814
|
+
const controlAssetRef = params.controlAssetId ? chunk6FLL2Q36_cjs.AssetRef.fromId(chunk6FLL2Q36_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
3812
3815
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
3813
3816
|
let totalBtcSelected = 0n;
|
|
3814
3817
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -3821,8 +3824,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3821
3824
|
}
|
|
3822
3825
|
}
|
|
3823
3826
|
const groups = [];
|
|
3824
|
-
const issuedAssetOutput =
|
|
3825
|
-
const issuedAssetGroup =
|
|
3827
|
+
const issuedAssetOutput = chunk6FLL2Q36_cjs.AssetOutput.create(0, params.amount);
|
|
3828
|
+
const issuedAssetGroup = chunk6FLL2Q36_cjs.AssetGroup.create(
|
|
3826
3829
|
null,
|
|
3827
3830
|
controlAssetRef,
|
|
3828
3831
|
[],
|
|
@@ -3837,28 +3840,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3837
3840
|
for (const [inputIndex, assets] of assetInputs) {
|
|
3838
3841
|
for (const asset of assets) {
|
|
3839
3842
|
if (asset.assetId !== assetId) continue;
|
|
3840
|
-
changeInputs.push(
|
|
3843
|
+
changeInputs.push(chunk6FLL2Q36_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
3841
3844
|
}
|
|
3842
3845
|
}
|
|
3843
3846
|
groups.push(
|
|
3844
|
-
|
|
3845
|
-
|
|
3847
|
+
chunk6FLL2Q36_cjs.AssetGroup.create(
|
|
3848
|
+
chunk6FLL2Q36_cjs.AssetId.fromString(assetId),
|
|
3846
3849
|
null,
|
|
3847
3850
|
changeInputs,
|
|
3848
|
-
[
|
|
3851
|
+
[chunk6FLL2Q36_cjs.AssetOutput.create(0, amount)],
|
|
3849
3852
|
[]
|
|
3850
3853
|
)
|
|
3851
3854
|
);
|
|
3852
3855
|
}
|
|
3853
3856
|
}
|
|
3854
3857
|
const address = await this.wallet.getAddress();
|
|
3855
|
-
const outputAddress =
|
|
3858
|
+
const outputAddress = chunkWMIPYZSB_cjs.ArkAddress.decode(address);
|
|
3856
3859
|
const outputs = [
|
|
3857
3860
|
{
|
|
3858
3861
|
script: outputAddress.pkScript,
|
|
3859
3862
|
amount: BigInt(totalBtcSelected)
|
|
3860
3863
|
},
|
|
3861
|
-
Extension.create([
|
|
3864
|
+
Extension.create([chunk6FLL2Q36_cjs.Packet.create(groups)]).txOut()
|
|
3862
3865
|
];
|
|
3863
3866
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
3864
3867
|
coinSelection.inputs,
|
|
@@ -3866,7 +3869,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3866
3869
|
);
|
|
3867
3870
|
return {
|
|
3868
3871
|
arkTxId: arkTxid,
|
|
3869
|
-
assetId:
|
|
3872
|
+
assetId: chunk6FLL2Q36_cjs.AssetId.create(arkTxid, 0).toString()
|
|
3870
3873
|
};
|
|
3871
3874
|
}
|
|
3872
3875
|
/**
|
|
@@ -3938,16 +3941,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3938
3941
|
for (const [inputIndex, assets] of assetInputs) {
|
|
3939
3942
|
for (const asset of assets) {
|
|
3940
3943
|
if (asset.assetId !== params.assetId) continue;
|
|
3941
|
-
reissueInputs.push(
|
|
3944
|
+
reissueInputs.push(chunk6FLL2Q36_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
3942
3945
|
}
|
|
3943
3946
|
}
|
|
3944
3947
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
3945
|
-
const reissueAssetIdObj =
|
|
3946
|
-
const reissueAssetGroup =
|
|
3948
|
+
const reissueAssetIdObj = chunk6FLL2Q36_cjs.AssetId.fromString(params.assetId);
|
|
3949
|
+
const reissueAssetGroup = chunk6FLL2Q36_cjs.AssetGroup.create(
|
|
3947
3950
|
reissueAssetIdObj,
|
|
3948
3951
|
null,
|
|
3949
3952
|
reissueInputs,
|
|
3950
|
-
[
|
|
3953
|
+
[chunk6FLL2Q36_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
3951
3954
|
[]
|
|
3952
3955
|
);
|
|
3953
3956
|
const groups = [reissueAssetGroup];
|
|
@@ -3956,27 +3959,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3956
3959
|
for (const [inputIndex, assets] of assetInputs) {
|
|
3957
3960
|
for (const asset of assets) {
|
|
3958
3961
|
if (asset.assetId !== assetId) continue;
|
|
3959
|
-
changeInputs.push(
|
|
3962
|
+
changeInputs.push(chunk6FLL2Q36_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
3960
3963
|
}
|
|
3961
3964
|
}
|
|
3962
3965
|
groups.push(
|
|
3963
|
-
|
|
3964
|
-
|
|
3966
|
+
chunk6FLL2Q36_cjs.AssetGroup.create(
|
|
3967
|
+
chunk6FLL2Q36_cjs.AssetId.fromString(assetId),
|
|
3965
3968
|
null,
|
|
3966
3969
|
changeInputs,
|
|
3967
|
-
[
|
|
3970
|
+
[chunk6FLL2Q36_cjs.AssetOutput.create(0, amount)],
|
|
3968
3971
|
[]
|
|
3969
3972
|
)
|
|
3970
3973
|
);
|
|
3971
3974
|
}
|
|
3972
3975
|
const address = await this.wallet.getAddress();
|
|
3973
|
-
const outputAddress =
|
|
3976
|
+
const outputAddress = chunkWMIPYZSB_cjs.ArkAddress.decode(address);
|
|
3974
3977
|
const outputs = [
|
|
3975
3978
|
{
|
|
3976
3979
|
script: outputAddress.pkScript,
|
|
3977
3980
|
amount: BigInt(totalBtcSelected)
|
|
3978
3981
|
},
|
|
3979
|
-
Extension.create([
|
|
3982
|
+
Extension.create([chunk6FLL2Q36_cjs.Packet.create(groups)]).txOut()
|
|
3980
3983
|
];
|
|
3981
3984
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
3982
3985
|
return arkTxid;
|
|
@@ -4043,27 +4046,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4043
4046
|
for (const [inputIndex, assets] of assetInputs) {
|
|
4044
4047
|
for (const asset of assets) {
|
|
4045
4048
|
if (asset.assetId !== assetId) continue;
|
|
4046
|
-
changeInputs.push(
|
|
4049
|
+
changeInputs.push(chunk6FLL2Q36_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
4047
4050
|
}
|
|
4048
4051
|
}
|
|
4049
4052
|
groups.push(
|
|
4050
|
-
|
|
4051
|
-
|
|
4053
|
+
chunk6FLL2Q36_cjs.AssetGroup.create(
|
|
4054
|
+
chunk6FLL2Q36_cjs.AssetId.fromString(assetId),
|
|
4052
4055
|
null,
|
|
4053
4056
|
changeInputs,
|
|
4054
|
-
amount > 0n ? [
|
|
4057
|
+
amount > 0n ? [chunk6FLL2Q36_cjs.AssetOutput.create(0, amount)] : [],
|
|
4055
4058
|
[]
|
|
4056
4059
|
)
|
|
4057
4060
|
);
|
|
4058
4061
|
}
|
|
4059
4062
|
const address = await this.wallet.getAddress();
|
|
4060
|
-
const outputAddress =
|
|
4063
|
+
const outputAddress = chunkWMIPYZSB_cjs.ArkAddress.decode(address);
|
|
4061
4064
|
const outputs = [
|
|
4062
4065
|
{
|
|
4063
4066
|
script: outputAddress.pkScript,
|
|
4064
4067
|
amount: BigInt(totalBtcSelected)
|
|
4065
4068
|
},
|
|
4066
|
-
Extension.create([
|
|
4069
|
+
Extension.create([chunk6FLL2Q36_cjs.Packet.create(groups)]).txOut()
|
|
4067
4070
|
];
|
|
4068
4071
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
4069
4072
|
return arkTxid;
|
|
@@ -4088,27 +4091,27 @@ function castMetadata(metadata) {
|
|
|
4088
4091
|
} else {
|
|
4089
4092
|
throw new Error("Invalid metadata value type");
|
|
4090
4093
|
}
|
|
4091
|
-
md.push(
|
|
4094
|
+
md.push(chunk6FLL2Q36_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
4092
4095
|
}
|
|
4093
4096
|
return md;
|
|
4094
4097
|
}
|
|
4095
|
-
var
|
|
4096
|
-
/** Create a
|
|
4097
|
-
constructor(
|
|
4098
|
-
this.
|
|
4098
|
+
var DelegateManagerImpl = class {
|
|
4099
|
+
/** Create a delegate manager from the configured provider, Arkade info source, and wallet identity. */
|
|
4100
|
+
constructor(delegateProvider, arkInfoProvider, identity) {
|
|
4101
|
+
this.delegateProvider = delegateProvider;
|
|
4099
4102
|
this.arkInfoProvider = arkInfoProvider;
|
|
4100
4103
|
this.identity = identity;
|
|
4101
4104
|
}
|
|
4102
4105
|
async getDelegateInfo() {
|
|
4103
|
-
return this.
|
|
4106
|
+
return this.delegateProvider.getDelegateInfo();
|
|
4104
4107
|
}
|
|
4105
4108
|
async delegate(vtxos, destination, delegateAt) {
|
|
4106
4109
|
if (vtxos.length === 0) {
|
|
4107
4110
|
return { delegated: [], failed: [] };
|
|
4108
4111
|
}
|
|
4109
|
-
const destinationScript =
|
|
4112
|
+
const destinationScript = chunkWMIPYZSB_cjs.ArkAddress.decode(destination).pkScript;
|
|
4110
4113
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
4111
|
-
const delegateInfo = await this.
|
|
4114
|
+
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
4112
4115
|
const eligible = vtxos.filter(
|
|
4113
4116
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
4114
4117
|
);
|
|
@@ -4119,7 +4122,7 @@ var DelegatorManagerImpl = class {
|
|
|
4119
4122
|
try {
|
|
4120
4123
|
await delegate(
|
|
4121
4124
|
this.identity,
|
|
4122
|
-
this.
|
|
4125
|
+
this.delegateProvider,
|
|
4123
4126
|
arkInfo,
|
|
4124
4127
|
delegateInfo,
|
|
4125
4128
|
eligible,
|
|
@@ -4137,7 +4140,7 @@ var DelegatorManagerImpl = class {
|
|
|
4137
4140
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
4138
4141
|
let recoverableVtxos = [];
|
|
4139
4142
|
for (const vtxo of eligible) {
|
|
4140
|
-
if (
|
|
4143
|
+
if (isRecoverable(vtxo)) {
|
|
4141
4144
|
recoverableVtxos.push(vtxo);
|
|
4142
4145
|
continue;
|
|
4143
4146
|
}
|
|
@@ -4150,7 +4153,7 @@ var DelegatorManagerImpl = class {
|
|
|
4150
4153
|
try {
|
|
4151
4154
|
await delegate(
|
|
4152
4155
|
this.identity,
|
|
4153
|
-
this.
|
|
4156
|
+
this.delegateProvider,
|
|
4154
4157
|
arkInfo,
|
|
4155
4158
|
delegateInfo,
|
|
4156
4159
|
recoverableVtxos,
|
|
@@ -4175,7 +4178,7 @@ var DelegatorManagerImpl = class {
|
|
|
4175
4178
|
groupsList.map(
|
|
4176
4179
|
async ([, vtxosGroup]) => delegate(
|
|
4177
4180
|
this.identity,
|
|
4178
|
-
this.
|
|
4181
|
+
this.delegateProvider,
|
|
4179
4182
|
arkInfo,
|
|
4180
4183
|
delegateInfo,
|
|
4181
4184
|
vtxosGroup,
|
|
@@ -4196,15 +4199,16 @@ var DelegatorManagerImpl = class {
|
|
|
4196
4199
|
return { delegated, failed };
|
|
4197
4200
|
}
|
|
4198
4201
|
};
|
|
4199
|
-
|
|
4202
|
+
var DelegatorManagerImpl = DelegateManagerImpl;
|
|
4203
|
+
async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos, destinationScript, delegateAt) {
|
|
4200
4204
|
if (vtxos.length === 0) {
|
|
4201
4205
|
throw new Error("unable to delegate: no vtxos provided");
|
|
4202
4206
|
}
|
|
4203
|
-
if (!
|
|
4204
|
-
throw new Error("unable to delegate:
|
|
4207
|
+
if (!delegateProvider) {
|
|
4208
|
+
throw new Error("unable to delegate: delegate provider not configured");
|
|
4205
4209
|
}
|
|
4206
4210
|
if (!delegateAt) {
|
|
4207
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
4211
|
+
const expiryTimestamp = vtxos.filter((coin) => !isRecoverable(coin) && coin.virtualStatus.batchExpiry).reduce(
|
|
4208
4212
|
(min, coin) => Math.min(min, coin.virtualStatus.batchExpiry),
|
|
4209
4213
|
Number.MAX_SAFE_INTEGER
|
|
4210
4214
|
);
|
|
@@ -4247,13 +4251,14 @@ async function delegate(identity, delegatorProvider, arkInfo, delegateInfo, vtxo
|
|
|
4247
4251
|
}
|
|
4248
4252
|
amount += BigInt(coin.value) - BigInt(inputFee.value);
|
|
4249
4253
|
}
|
|
4250
|
-
const {
|
|
4254
|
+
const { pubkey, fee } = delegateInfo;
|
|
4255
|
+
const delegateAddress = delegateInfo.delegateAddress;
|
|
4251
4256
|
const outputs = [];
|
|
4252
|
-
const
|
|
4253
|
-
if (
|
|
4257
|
+
const delegateFee = BigInt(Number(fee));
|
|
4258
|
+
if (delegateFee > 0n) {
|
|
4254
4259
|
outputs.push({
|
|
4255
|
-
script:
|
|
4256
|
-
amount:
|
|
4260
|
+
script: chunkWMIPYZSB_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
4261
|
+
amount: delegateFee
|
|
4257
4262
|
});
|
|
4258
4263
|
}
|
|
4259
4264
|
const outputFee = outputs.reduce((fee2, output) => {
|
|
@@ -4267,7 +4272,7 @@ async function delegate(identity, delegatorProvider, arkInfo, delegateInfo, vtxo
|
|
|
4267
4272
|
throw new Error("Amount is below dust limit, cannot delegate");
|
|
4268
4273
|
}
|
|
4269
4274
|
amount -= BigInt(outputFee);
|
|
4270
|
-
amount -=
|
|
4275
|
+
amount -= delegateFee;
|
|
4271
4276
|
if (amount <= dust) {
|
|
4272
4277
|
throw new Error("Amount is below dust limit, cannot delegate");
|
|
4273
4278
|
}
|
|
@@ -4285,10 +4290,10 @@ async function delegate(identity, delegatorProvider, arkInfo, delegateInfo, vtxo
|
|
|
4285
4290
|
destinationScript
|
|
4286
4291
|
);
|
|
4287
4292
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
4288
|
-
btcSigner.Address(getNetwork(network)).decode(forfeitAddress)
|
|
4293
|
+
btcSigner.Address(chunkWMIPYZSB_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
4289
4294
|
);
|
|
4290
4295
|
const forfeits = await Promise.all(
|
|
4291
|
-
vtxos.filter((v) => !
|
|
4296
|
+
vtxos.filter((v) => !isRecoverable(v)).map(async (coin) => {
|
|
4292
4297
|
const forfeit = await makeDelegateForfeitTx(
|
|
4293
4298
|
coin,
|
|
4294
4299
|
dust,
|
|
@@ -4299,7 +4304,7 @@ async function delegate(identity, delegatorProvider, arkInfo, delegateInfo, vtxo
|
|
|
4299
4304
|
return base.base64.encode(forfeit.toPSBT());
|
|
4300
4305
|
})
|
|
4301
4306
|
);
|
|
4302
|
-
await
|
|
4307
|
+
await delegateProvider.delegate(registerIntent, forfeits);
|
|
4303
4308
|
}
|
|
4304
4309
|
async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, forfeitOutputScript, identity) {
|
|
4305
4310
|
const delegateTapLeaf = findDelegateTapLeaf(input, delegatePubkey);
|
|
@@ -4313,7 +4318,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
4313
4318
|
index: input.vout,
|
|
4314
4319
|
witnessUtxo: {
|
|
4315
4320
|
amount: BigInt(input.value),
|
|
4316
|
-
script:
|
|
4321
|
+
script: chunkWMIPYZSB_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
4317
4322
|
},
|
|
4318
4323
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
4319
4324
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -4371,7 +4376,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
4371
4376
|
expire_at: 0,
|
|
4372
4377
|
cosigners_public_keys: cosignerPubKeys
|
|
4373
4378
|
};
|
|
4374
|
-
const proof =
|
|
4379
|
+
const proof = chunk6FLL2Q36_cjs.Intent.create(message, coins, outputs);
|
|
4375
4380
|
const signedProof = await identity.sign(proof);
|
|
4376
4381
|
return {
|
|
4377
4382
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -4389,10 +4394,10 @@ function getDayTimestamp(timestamp) {
|
|
|
4389
4394
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
4390
4395
|
if (!vtxo.tapTree) return void 0;
|
|
4391
4396
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
4392
|
-
const vtxoScript =
|
|
4397
|
+
const vtxoScript = chunkWMIPYZSB_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
4393
4398
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
4394
|
-
const arkTapscript =
|
|
4395
|
-
if (!
|
|
4399
|
+
const arkTapscript = chunkWMIPYZSB_cjs.decodeTapscript(chunkWMIPYZSB_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
4400
|
+
if (!chunkWMIPYZSB_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
4396
4401
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
4397
4402
|
});
|
|
4398
4403
|
}
|
|
@@ -4596,7 +4601,7 @@ var InMemoryContractRepository = class {
|
|
|
4596
4601
|
}
|
|
4597
4602
|
};
|
|
4598
4603
|
function scriptFromArkAddress(address) {
|
|
4599
|
-
return base.hex.encode(
|
|
4604
|
+
return base.hex.encode(chunkWMIPYZSB_cjs.ArkAddress.decode(address).pkScript);
|
|
4600
4605
|
}
|
|
4601
4606
|
|
|
4602
4607
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -6111,7 +6116,7 @@ var ContractWatcher = class {
|
|
|
6111
6116
|
this.connectionState = "connected";
|
|
6112
6117
|
this.reconnectAttempts = 0;
|
|
6113
6118
|
this.listenLoop().catch((e) => {
|
|
6114
|
-
if (
|
|
6119
|
+
if (chunk6FLL2Q36_cjs.isEventSourceError(e)) {
|
|
6115
6120
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
6116
6121
|
} else {
|
|
6117
6122
|
console.error(e);
|
|
@@ -6551,7 +6556,7 @@ var ContractManager = class _ContractManager {
|
|
|
6551
6556
|
* `persisted` is `true`.
|
|
6552
6557
|
*/
|
|
6553
6558
|
async upsertContract(params) {
|
|
6554
|
-
const handler =
|
|
6559
|
+
const handler = chunkIEO3XDKI_cjs.contractHandlers.get(params.type);
|
|
6555
6560
|
if (!handler) {
|
|
6556
6561
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
6557
6562
|
}
|
|
@@ -6612,7 +6617,7 @@ var ContractManager = class _ContractManager {
|
|
|
6612
6617
|
`scanContracts: gapLimit must be a positive integer (got ${String(opts.gapLimit)})`
|
|
6613
6618
|
);
|
|
6614
6619
|
}
|
|
6615
|
-
const discoverables =
|
|
6620
|
+
const discoverables = chunkIEO3XDKI_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkIEO3XDKI_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
6616
6621
|
const maxIdx = opts.hd ? SCAN_MAX_INDEX : 0;
|
|
6617
6622
|
const handlerErrors = [];
|
|
6618
6623
|
let lastIndexUsed = -1;
|
|
@@ -6767,7 +6772,7 @@ var ContractManager = class _ContractManager {
|
|
|
6767
6772
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
6768
6773
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
6769
6774
|
if (!contract) return [];
|
|
6770
|
-
const handler =
|
|
6775
|
+
const handler = chunkIEO3XDKI_cjs.contractHandlers.get(contract.type);
|
|
6771
6776
|
if (!handler) return [];
|
|
6772
6777
|
const script = handler.createScript(contract.params);
|
|
6773
6778
|
const context = {
|
|
@@ -6787,7 +6792,7 @@ var ContractManager = class _ContractManager {
|
|
|
6787
6792
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
6788
6793
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
6789
6794
|
if (!contract) return [];
|
|
6790
|
-
const handler =
|
|
6795
|
+
const handler = chunkIEO3XDKI_cjs.contractHandlers.get(contract.type);
|
|
6791
6796
|
if (!handler) return [];
|
|
6792
6797
|
const script = handler.createScript(contract.params);
|
|
6793
6798
|
const context = {
|
|
@@ -7197,7 +7202,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
7197
7202
|
*/
|
|
7198
7203
|
materializeDescriptorAt(index) {
|
|
7199
7204
|
const descriptor = this.identity.descriptor;
|
|
7200
|
-
const network =
|
|
7205
|
+
const network = chunkIEO3XDKI_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
7201
7206
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
7202
7207
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
7203
7208
|
if (!keyInfo?.keyExpression) {
|
|
@@ -7340,7 +7345,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7340
7345
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
7341
7346
|
if (!provider) return void 0;
|
|
7342
7347
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
7343
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
7348
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkIEO3XDKI_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
7344
7349
|
const factoryOpts = {
|
|
7345
7350
|
walletRepository: setup.walletRepository,
|
|
7346
7351
|
contractRepository: setup.contractRepository,
|
|
@@ -7502,8 +7507,8 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7502
7507
|
const newScript = base.hex.encode(newTapscript.pkScript);
|
|
7503
7508
|
const newAddress = newTapscript.address(wallet.network.hrp, wallet.arkServerPublicKey).encode();
|
|
7504
7509
|
const manager = await wallet.getContractManager();
|
|
7505
|
-
const csvTimelock = newTapscript.options.csvTimelock ??
|
|
7506
|
-
const csvTimelockStr =
|
|
7510
|
+
const csvTimelock = newTapscript.options.csvTimelock ?? chunkIEO3XDKI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
7511
|
+
const csvTimelockStr = chunkWMIPYZSB_cjs.timelockToSequence(csvTimelock).toString();
|
|
7507
7512
|
const serverPubKeyHex = base.hex.encode(newTapscript.options.serverPubKey);
|
|
7508
7513
|
const baseParams = {
|
|
7509
7514
|
script: newScript,
|
|
@@ -7517,11 +7522,11 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7517
7522
|
// produce unsigned PSBTs that the server rejects with
|
|
7518
7523
|
// `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
7519
7524
|
metadata: {
|
|
7520
|
-
source:
|
|
7525
|
+
source: chunkIEO3XDKI_cjs.WALLET_RECEIVE_SOURCE,
|
|
7521
7526
|
signingDescriptor: descriptor
|
|
7522
7527
|
}
|
|
7523
7528
|
};
|
|
7524
|
-
if (newTapscript instanceof
|
|
7529
|
+
if (newTapscript instanceof chunkIEO3XDKI_cjs.DelegateVtxo.Script) {
|
|
7525
7530
|
await manager.createContract({
|
|
7526
7531
|
...baseParams,
|
|
7527
7532
|
type: "delegate",
|
|
@@ -7553,7 +7558,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7553
7558
|
};
|
|
7554
7559
|
function deriveLeafPubkey(descriptor) {
|
|
7555
7560
|
try {
|
|
7556
|
-
return
|
|
7561
|
+
return chunkIEO3XDKI_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
7557
7562
|
} catch (e) {
|
|
7558
7563
|
throw new NonRangeableDescriptorError(
|
|
7559
7564
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -7562,10 +7567,10 @@ function deriveLeafPubkey(descriptor) {
|
|
|
7562
7567
|
}
|
|
7563
7568
|
}
|
|
7564
7569
|
function rebuildTapscript(current, pubKey) {
|
|
7565
|
-
if (current instanceof
|
|
7566
|
-
return new
|
|
7570
|
+
if (current instanceof chunkIEO3XDKI_cjs.DelegateVtxo.Script) {
|
|
7571
|
+
return new chunkIEO3XDKI_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
7567
7572
|
}
|
|
7568
|
-
return new
|
|
7573
|
+
return new chunkIEO3XDKI_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
7569
7574
|
}
|
|
7570
7575
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
7571
7576
|
const candidates = await contractRepository.getContracts({
|
|
@@ -7574,7 +7579,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
7574
7579
|
});
|
|
7575
7580
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
7576
7581
|
const matching = candidates.filter(
|
|
7577
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
7582
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkIEO3XDKI_cjs.WALLET_RECEIVE_SOURCE
|
|
7578
7583
|
).sort((a, b) => {
|
|
7579
7584
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
7580
7585
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -7709,12 +7714,12 @@ var InputSignerRouter = class {
|
|
|
7709
7714
|
};
|
|
7710
7715
|
|
|
7711
7716
|
// src/wallet/wallet.ts
|
|
7712
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
7717
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkWMIPYZSB_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
7713
7718
|
function intentProofJobs(coins) {
|
|
7714
7719
|
if (coins.length === 0) return [];
|
|
7715
7720
|
const coinJobs = coins.map((coin, i) => ({
|
|
7716
7721
|
index: i + 1,
|
|
7717
|
-
lookupScript:
|
|
7722
|
+
lookupScript: chunkWMIPYZSB_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
7718
7723
|
}));
|
|
7719
7724
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
7720
7725
|
}
|
|
@@ -7733,7 +7738,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
7733
7738
|
const seen = /* @__PURE__ */ new Set();
|
|
7734
7739
|
const deduped = [];
|
|
7735
7740
|
for (const timelock of timelocks) {
|
|
7736
|
-
const sequence =
|
|
7741
|
+
const sequence = chunkWMIPYZSB_cjs.timelockToSequence(timelock).toString();
|
|
7737
7742
|
if (seen.has(sequence)) continue;
|
|
7738
7743
|
seen.add(sequence);
|
|
7739
7744
|
deduped.push(timelock);
|
|
@@ -7744,7 +7749,7 @@ function hasToReadonly(identity) {
|
|
|
7744
7749
|
return typeof identity === "object" && identity !== null && "toReadonly" in identity && typeof identity.toReadonly === "function";
|
|
7745
7750
|
}
|
|
7746
7751
|
var ReadonlyWallet = class _ReadonlyWallet {
|
|
7747
|
-
constructor(identity, network, onchainProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, dustAmount, walletRepository, contractRepository,
|
|
7752
|
+
constructor(identity, network, onchainProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, dustAmount, walletRepository, contractRepository, delegateProvider, watcherConfig, walletContractTimelocks) {
|
|
7748
7753
|
this.identity = identity;
|
|
7749
7754
|
this.network = network;
|
|
7750
7755
|
this.onchainProvider = onchainProvider;
|
|
@@ -7754,7 +7759,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7754
7759
|
this.dustAmount = dustAmount;
|
|
7755
7760
|
this.walletRepository = walletRepository;
|
|
7756
7761
|
this.contractRepository = contractRepository;
|
|
7757
|
-
this.
|
|
7762
|
+
this.delegateProvider = delegateProvider;
|
|
7758
7763
|
if ("descriptor" in identity) {
|
|
7759
7764
|
const descriptor = identity.descriptor;
|
|
7760
7765
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -7769,7 +7774,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7769
7774
|
this.watcherConfig = watcherConfig;
|
|
7770
7775
|
this._assetManager = new ReadonlyAssetManager(this.indexerProvider);
|
|
7771
7776
|
this.walletContractTimelocks = walletContractTimelocks && walletContractTimelocks.length > 0 ? dedupeTimelocks(walletContractTimelocks) : [
|
|
7772
|
-
this.offchainTapscript.options.csvTimelock ??
|
|
7777
|
+
this.offchainTapscript.options.csvTimelock ?? chunkIEO3XDKI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK
|
|
7773
7778
|
];
|
|
7774
7779
|
}
|
|
7775
7780
|
_contractManager;
|
|
@@ -7808,7 +7813,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7808
7813
|
*/
|
|
7809
7814
|
static async setupWalletConfig(config, pubKey) {
|
|
7810
7815
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
7811
|
-
const arkProvider = config.arkProvider
|
|
7816
|
+
const arkProvider = config.arkProvider || new chunk6FLL2Q36_cjs.RestArkProvider(arkadeServerUrl);
|
|
7812
7817
|
let indexerProvider = config.indexerProvider;
|
|
7813
7818
|
if (!indexerProvider) {
|
|
7814
7819
|
let indexerUrl = config.indexerUrl;
|
|
@@ -7825,10 +7830,10 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7825
7830
|
indexerUrl = arkadeServerUrl;
|
|
7826
7831
|
}
|
|
7827
7832
|
}
|
|
7828
|
-
indexerProvider = new
|
|
7833
|
+
indexerProvider = new chunk6FLL2Q36_cjs.RestIndexerProvider(indexerUrl);
|
|
7829
7834
|
}
|
|
7830
7835
|
const info = await arkProvider.getInfo();
|
|
7831
|
-
const network = getNetwork(info.network);
|
|
7836
|
+
const network = chunkWMIPYZSB_cjs.getNetwork(info.network);
|
|
7832
7837
|
if ("descriptor" in config.identity) {
|
|
7833
7838
|
const descriptor = config.identity.descriptor;
|
|
7834
7839
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -7869,14 +7874,14 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7869
7874
|
type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
|
|
7870
7875
|
};
|
|
7871
7876
|
const serverPubKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
7872
|
-
const delegatePubKey = config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => base.hex.decode(info2.pubkey).slice(1)) : void 0;
|
|
7877
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => base.hex.decode(info2.pubkey).slice(1)) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => base.hex.decode(info2.pubkey).slice(1)) : void 0;
|
|
7873
7878
|
const offchainOptions = {
|
|
7874
7879
|
pubKey,
|
|
7875
7880
|
serverPubKey,
|
|
7876
7881
|
csvTimelock: exitTimelock
|
|
7877
7882
|
};
|
|
7878
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
7879
|
-
const boardingTapscript = new
|
|
7883
|
+
const offchainTapscript = !delegatePubKey ? new chunkIEO3XDKI_cjs.DefaultVtxo.Script(offchainOptions) : new chunkIEO3XDKI_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
7884
|
+
const boardingTapscript = new chunkIEO3XDKI_cjs.DefaultVtxo.Script({
|
|
7880
7885
|
...offchainOptions,
|
|
7881
7886
|
csvTimelock: boardingTimelock
|
|
7882
7887
|
});
|
|
@@ -7895,7 +7900,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7895
7900
|
walletRepository,
|
|
7896
7901
|
contractRepository,
|
|
7897
7902
|
info,
|
|
7898
|
-
|
|
7903
|
+
delegateProvider: config.delegateProvider || config.delegatorProvider,
|
|
7904
|
+
/** @deprecated alias for `delegateProvider` */
|
|
7905
|
+
delegatorProvider: config.delegateProvider || config.delegatorProvider,
|
|
7899
7906
|
walletContractTimelocks
|
|
7900
7907
|
};
|
|
7901
7908
|
}
|
|
@@ -7922,7 +7929,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7922
7929
|
setup.dustAmount,
|
|
7923
7930
|
setup.walletRepository,
|
|
7924
7931
|
setup.contractRepository,
|
|
7925
|
-
setup.delegatorProvider,
|
|
7932
|
+
setup.delegateProvider || setup.delegatorProvider,
|
|
7926
7933
|
config.watcherConfig,
|
|
7927
7934
|
setup.walletContractTimelocks
|
|
7928
7935
|
);
|
|
@@ -7967,12 +7974,12 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7967
7974
|
let recoverable = 0;
|
|
7968
7975
|
settled = vtxos.filter((coin) => coin.virtualStatus.state === "settled").reduce((sum, coin) => sum + coin.value, 0);
|
|
7969
7976
|
preconfirmed = vtxos.filter((coin) => coin.virtualStatus.state === "preconfirmed").reduce((sum, coin) => sum + coin.value, 0);
|
|
7970
|
-
recoverable = vtxos.filter((coin) =>
|
|
7977
|
+
recoverable = vtxos.filter((coin) => isSpendable(coin) && coin.virtualStatus.state === "swept").reduce((sum, coin) => sum + coin.value, 0);
|
|
7971
7978
|
const totalBoarding = confirmed + unconfirmed;
|
|
7972
7979
|
const totalOffchain = settled + preconfirmed + recoverable;
|
|
7973
7980
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
7974
7981
|
for (const vtxo of vtxos) {
|
|
7975
|
-
if (!
|
|
7982
|
+
if (!isSpendable(vtxo)) continue;
|
|
7976
7983
|
if (vtxo.assets) {
|
|
7977
7984
|
for (const a of vtxo.assets) {
|
|
7978
7985
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -8011,8 +8018,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8011
8018
|
if (this._pendingSpendOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
8012
8019
|
return false;
|
|
8013
8020
|
}
|
|
8014
|
-
if (
|
|
8015
|
-
if (!f.withRecoverable && (
|
|
8021
|
+
if (isSpendable(vtxo)) {
|
|
8022
|
+
if (!f.withRecoverable && (isRecoverable(vtxo) || isExpired(vtxo))) {
|
|
8016
8023
|
return false;
|
|
8017
8024
|
}
|
|
8018
8025
|
return true;
|
|
@@ -8216,7 +8223,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8216
8223
|
});
|
|
8217
8224
|
for (const contract of contracts) {
|
|
8218
8225
|
if (map.has(contract.script)) continue;
|
|
8219
|
-
const handler =
|
|
8226
|
+
const handler = chunkIEO3XDKI_cjs.contractHandlers.get(contract.type);
|
|
8220
8227
|
if (handler) {
|
|
8221
8228
|
const script = handler.createScript(contract.params);
|
|
8222
8229
|
map.set(contract.script, script);
|
|
@@ -8282,8 +8289,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8282
8289
|
});
|
|
8283
8290
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
8284
8291
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
8285
|
-
const csvTimelockStr =
|
|
8286
|
-
const defaultScript = new
|
|
8292
|
+
const csvTimelockStr = chunkWMIPYZSB_cjs.timelockToSequence(csvTimelock).toString();
|
|
8293
|
+
const defaultScript = new chunkIEO3XDKI_cjs.DefaultVtxo.Script({
|
|
8287
8294
|
pubKey: baselinePubkey,
|
|
8288
8295
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
8289
8296
|
csvTimelock
|
|
@@ -8300,8 +8307,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8300
8307
|
address: defaultScript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
8301
8308
|
state: "active"
|
|
8302
8309
|
});
|
|
8303
|
-
if (this.offchainTapscript instanceof
|
|
8304
|
-
const delegateScript = new
|
|
8310
|
+
if (this.offchainTapscript instanceof chunkIEO3XDKI_cjs.DelegateVtxo.Script) {
|
|
8311
|
+
const delegateScript = new chunkIEO3XDKI_cjs.DelegateVtxo.Script({
|
|
8305
8312
|
pubKey: baselinePubkey,
|
|
8306
8313
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
8307
8314
|
delegatePubKey: this.offchainTapscript.options.delegatePubKey,
|
|
@@ -8337,7 +8344,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8337
8344
|
}
|
|
8338
8345
|
};
|
|
8339
8346
|
var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
8340
|
-
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig,
|
|
8347
|
+
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider) {
|
|
8341
8348
|
super(
|
|
8342
8349
|
identity,
|
|
8343
8350
|
network,
|
|
@@ -8349,7 +8356,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8349
8356
|
dustAmount,
|
|
8350
8357
|
walletRepository,
|
|
8351
8358
|
contractRepository,
|
|
8352
|
-
|
|
8359
|
+
delegateProvider,
|
|
8353
8360
|
watcherConfig,
|
|
8354
8361
|
walletContractTimelocks
|
|
8355
8362
|
);
|
|
@@ -8374,7 +8381,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8374
8381
|
} else {
|
|
8375
8382
|
this.settlementConfig = { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
8376
8383
|
}
|
|
8377
|
-
this.
|
|
8384
|
+
this._delegateManager = delegateProvider ? new DelegateManagerImpl(delegateProvider, arkProvider, identity) : void 0;
|
|
8378
8385
|
this._receiveRotator = receiveRotator;
|
|
8379
8386
|
this._descriptorProvider = descriptorProvider;
|
|
8380
8387
|
this._signerRouter = new InputSignerRouter({
|
|
@@ -8387,7 +8394,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8387
8394
|
static MIN_FEE_RATE = 1;
|
|
8388
8395
|
// sats/vbyte
|
|
8389
8396
|
identity;
|
|
8390
|
-
|
|
8397
|
+
_delegateManager;
|
|
8391
8398
|
_vtxoManager;
|
|
8392
8399
|
_vtxoManagerInitializing;
|
|
8393
8400
|
_walletAssetManager;
|
|
@@ -8502,7 +8509,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8502
8509
|
const hd = provider instanceof HDDescriptorProvider;
|
|
8503
8510
|
const staticDescriptor = hd ? void 0 : `tr(${base.hex.encode(await this.identity.xOnlyPublicKey())})`;
|
|
8504
8511
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
8505
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
8512
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkIEO3XDKI_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
8506
8513
|
const deps = {
|
|
8507
8514
|
indexerProvider: this.indexerProvider,
|
|
8508
8515
|
onchainProvider: this.onchainProvider,
|
|
@@ -8596,7 +8603,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8596
8603
|
* ```typescript
|
|
8597
8604
|
* const wallet = await Wallet.create({
|
|
8598
8605
|
* identity,
|
|
8599
|
-
*
|
|
8606
|
+
* arkProvider: new RestArkProvider(),
|
|
8600
8607
|
* });
|
|
8601
8608
|
* ```
|
|
8602
8609
|
*/
|
|
@@ -8609,7 +8616,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8609
8616
|
let serverUnrollScript;
|
|
8610
8617
|
try {
|
|
8611
8618
|
const raw = base.hex.decode(setup.info.checkpointTapscript);
|
|
8612
|
-
serverUnrollScript =
|
|
8619
|
+
serverUnrollScript = chunkWMIPYZSB_cjs.CSVMultisigTapscript.decode(raw);
|
|
8613
8620
|
} catch (e) {
|
|
8614
8621
|
throw new Error("Invalid checkpointTapscript from server");
|
|
8615
8622
|
}
|
|
@@ -8633,7 +8640,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8633
8640
|
setup.walletRepository,
|
|
8634
8641
|
setup.contractRepository,
|
|
8635
8642
|
config.renewalConfig,
|
|
8636
|
-
config.delegatorProvider,
|
|
8643
|
+
config.delegateProvider || config.delegatorProvider,
|
|
8637
8644
|
config.watcherConfig,
|
|
8638
8645
|
config.settlementConfig,
|
|
8639
8646
|
setup.walletContractTimelocks,
|
|
@@ -8673,14 +8680,18 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8673
8680
|
this.dustAmount,
|
|
8674
8681
|
this.walletRepository,
|
|
8675
8682
|
this.contractRepository,
|
|
8676
|
-
this.
|
|
8683
|
+
this.delegateProvider,
|
|
8677
8684
|
this.watcherConfig,
|
|
8678
8685
|
this.walletContractTimelocks
|
|
8679
8686
|
);
|
|
8680
8687
|
}
|
|
8681
|
-
/** Returns the
|
|
8688
|
+
/** Returns the delegate manager when delegation support is configured. */
|
|
8689
|
+
async getDelegateManager() {
|
|
8690
|
+
return this._delegateManager;
|
|
8691
|
+
}
|
|
8692
|
+
/** @deprecated alias for @see Wallet.getDelegateManager */
|
|
8682
8693
|
async getDelegatorManager() {
|
|
8683
|
-
return this.
|
|
8694
|
+
return this.getDelegateManager();
|
|
8684
8695
|
}
|
|
8685
8696
|
/**
|
|
8686
8697
|
* Send bitcoin to an Arkade address.
|
|
@@ -8711,7 +8722,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8711
8722
|
inputs: params.selectedVtxos,
|
|
8712
8723
|
changeAmount: BigInt(changeAmount)
|
|
8713
8724
|
};
|
|
8714
|
-
const outputAddress =
|
|
8725
|
+
const outputAddress = chunkWMIPYZSB_cjs.ArkAddress.decode(params.address);
|
|
8715
8726
|
const outputScript = BigInt(params.amount) < this.dustAmount ? outputAddress.subdustPkScript : outputAddress.pkScript;
|
|
8716
8727
|
const outputs = [
|
|
8717
8728
|
{
|
|
@@ -8778,7 +8789,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8778
8789
|
const { fees } = await this.arkProvider.getInfo();
|
|
8779
8790
|
const estimator = new Estimator(fees.intentFee);
|
|
8780
8791
|
let amount = 0;
|
|
8781
|
-
const exitScript =
|
|
8792
|
+
const exitScript = chunkWMIPYZSB_cjs.CSVMultisigTapscript.decode(
|
|
8782
8793
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
8783
8794
|
);
|
|
8784
8795
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -8827,7 +8838,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8827
8838
|
};
|
|
8828
8839
|
const outputFee = estimator.evalOffchainOutput({
|
|
8829
8840
|
amount: output.amount,
|
|
8830
|
-
script: base.hex.encode(
|
|
8841
|
+
script: base.hex.encode(chunkWMIPYZSB_cjs.ArkAddress.decode(output.address).pkScript)
|
|
8831
8842
|
});
|
|
8832
8843
|
output.amount -= BigInt(outputFee.satoshis);
|
|
8833
8844
|
if (output.amount <= this.dustAmount) {
|
|
@@ -8844,7 +8855,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8844
8855
|
for (const [index, output] of params.outputs.entries()) {
|
|
8845
8856
|
let script;
|
|
8846
8857
|
try {
|
|
8847
|
-
const addr =
|
|
8858
|
+
const addr = chunkWMIPYZSB_cjs.ArkAddress.decode(output.address);
|
|
8848
8859
|
script = addr.pkScript;
|
|
8849
8860
|
hasOffchainOutputs = true;
|
|
8850
8861
|
} catch {
|
|
@@ -8867,7 +8878,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8867
8878
|
}
|
|
8868
8879
|
}
|
|
8869
8880
|
let outputAssets;
|
|
8870
|
-
const destinationScript =
|
|
8881
|
+
const destinationScript = chunkWMIPYZSB_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
8871
8882
|
const assetOutputIndex = findDestinationOutputIndex(outputs, destinationScript);
|
|
8872
8883
|
if (assetInputs.size > 0) {
|
|
8873
8884
|
if (assetOutputIndex === -1) {
|
|
@@ -8989,7 +9000,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8989
9000
|
}
|
|
8990
9001
|
continue;
|
|
8991
9002
|
}
|
|
8992
|
-
if (
|
|
9003
|
+
if (isRecoverable(input) || isSubdust(input, this.dustAmount)) {
|
|
8993
9004
|
continue;
|
|
8994
9005
|
}
|
|
8995
9006
|
if (connectorsLeaves.length === 0) {
|
|
@@ -9017,7 +9028,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9017
9028
|
index: input.vout,
|
|
9018
9029
|
witnessUtxo: {
|
|
9019
9030
|
amount: BigInt(input.value),
|
|
9020
|
-
script:
|
|
9031
|
+
script: chunkWMIPYZSB_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
9021
9032
|
},
|
|
9022
9033
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
9023
9034
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -9036,7 +9047,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9036
9047
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
9037
9048
|
{
|
|
9038
9049
|
index: 0,
|
|
9039
|
-
lookupScript:
|
|
9050
|
+
lookupScript: chunkWMIPYZSB_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
9040
9051
|
}
|
|
9041
9052
|
]);
|
|
9042
9053
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -9076,7 +9087,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9076
9087
|
if (skip) {
|
|
9077
9088
|
return { skip };
|
|
9078
9089
|
}
|
|
9079
|
-
const sweepTapscript =
|
|
9090
|
+
const sweepTapscript = chunkWMIPYZSB_cjs.CSVMultisigTapscript.encode({
|
|
9080
9091
|
timelock: {
|
|
9081
9092
|
value: event.batchExpiry,
|
|
9082
9093
|
type: event.batchExpiry >= 512n ? "seconds" : "blocks"
|
|
@@ -9167,7 +9178,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9167
9178
|
try {
|
|
9168
9179
|
return await this.arkProvider.registerIntent(intent);
|
|
9169
9180
|
} catch (error) {
|
|
9170
|
-
if (error instanceof
|
|
9181
|
+
if (error instanceof chunk6FLL2Q36_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
9171
9182
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
9172
9183
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
9173
9184
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -9183,7 +9194,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9183
9194
|
expire_at: 0,
|
|
9184
9195
|
cosigners_public_keys: cosignerPubKeys
|
|
9185
9196
|
};
|
|
9186
|
-
const proof =
|
|
9197
|
+
const proof = chunk6FLL2Q36_cjs.Intent.create(message, coins, outputs);
|
|
9187
9198
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
9188
9199
|
return {
|
|
9189
9200
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -9195,7 +9206,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9195
9206
|
type: "delete",
|
|
9196
9207
|
expire_at: 0
|
|
9197
9208
|
};
|
|
9198
|
-
const proof =
|
|
9209
|
+
const proof = chunk6FLL2Q36_cjs.Intent.create(message, coins, []);
|
|
9199
9210
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
9200
9211
|
return {
|
|
9201
9212
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -9207,7 +9218,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9207
9218
|
type: "get-pending-tx",
|
|
9208
9219
|
expire_at: 0
|
|
9209
9220
|
};
|
|
9210
|
-
const proof =
|
|
9221
|
+
const proof = chunk6FLL2Q36_cjs.Intent.create(message, coins, []);
|
|
9211
9222
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
9212
9223
|
return {
|
|
9213
9224
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -9502,7 +9513,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9502
9513
|
);
|
|
9503
9514
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
9504
9515
|
index,
|
|
9505
|
-
lookupScript:
|
|
9516
|
+
lookupScript: chunkWMIPYZSB_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
9506
9517
|
}));
|
|
9507
9518
|
const signedVirtualTx = await this._signerRouter.sign(offchainTx.arkTx, arkTxJobs);
|
|
9508
9519
|
await this.setPendingTxFlag(true);
|
|
@@ -9931,12 +9942,12 @@ var MessageBus = class {
|
|
|
9931
9942
|
this.initialized = true;
|
|
9932
9943
|
}
|
|
9933
9944
|
async buildServices(config) {
|
|
9934
|
-
const arkProvider = new
|
|
9945
|
+
const arkProvider = new chunk6FLL2Q36_cjs.RestArkProvider(config.arkServer.url);
|
|
9935
9946
|
const storage = {
|
|
9936
9947
|
walletRepository: this.walletRepository,
|
|
9937
9948
|
contractRepository: this.contractRepository
|
|
9938
9949
|
};
|
|
9939
|
-
const
|
|
9950
|
+
const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : config.delegatorUrl ? new RestDelegateProvider(config.delegatorUrl) : void 0;
|
|
9940
9951
|
const serialized = normalizeSerializedIdentity(config.wallet);
|
|
9941
9952
|
if (isSigningSerialized(serialized)) {
|
|
9942
9953
|
const identity2 = hydrateIdentity(serialized);
|
|
@@ -9947,7 +9958,7 @@ var MessageBus = class {
|
|
|
9947
9958
|
indexerUrl: config.indexerUrl,
|
|
9948
9959
|
esploraUrl: config.esploraUrl,
|
|
9949
9960
|
storage,
|
|
9950
|
-
|
|
9961
|
+
delegateProvider,
|
|
9951
9962
|
settlementConfig: config.settlementConfig,
|
|
9952
9963
|
walletMode: config.walletMode,
|
|
9953
9964
|
watcherConfig: config.watcherConfig
|
|
@@ -9962,7 +9973,7 @@ var MessageBus = class {
|
|
|
9962
9973
|
indexerUrl: config.indexerUrl,
|
|
9963
9974
|
esploraUrl: config.esploraUrl,
|
|
9964
9975
|
storage,
|
|
9965
|
-
|
|
9976
|
+
delegateProvider,
|
|
9966
9977
|
watcherConfig: config.watcherConfig
|
|
9967
9978
|
});
|
|
9968
9979
|
return { readonlyWallet, arkProvider };
|
|
@@ -10241,6 +10252,18 @@ var MessageBus = class {
|
|
|
10241
10252
|
function toError(value) {
|
|
10242
10253
|
return value instanceof Error ? value : new Error(String(value));
|
|
10243
10254
|
}
|
|
10255
|
+
var DustChangeError = class extends Error {
|
|
10256
|
+
change;
|
|
10257
|
+
dustAmount;
|
|
10258
|
+
constructor(change, dustAmount) {
|
|
10259
|
+
super(
|
|
10260
|
+
`change ${change} sats is below dust threshold ${dustAmount}; consider exiting the full balance`
|
|
10261
|
+
);
|
|
10262
|
+
this.name = "DustChangeError";
|
|
10263
|
+
this.change = change;
|
|
10264
|
+
this.dustAmount = dustAmount;
|
|
10265
|
+
}
|
|
10266
|
+
};
|
|
10244
10267
|
var Ramps = class {
|
|
10245
10268
|
/**
|
|
10246
10269
|
* Create convenience wrappers for onboarding and offboarding flows.
|
|
@@ -10295,7 +10318,7 @@ var Ramps = class {
|
|
|
10295
10318
|
}
|
|
10296
10319
|
amount = amount ?? totalAmount;
|
|
10297
10320
|
const offchainAddress = await this.wallet.getAddress();
|
|
10298
|
-
const offchainAddr =
|
|
10321
|
+
const offchainAddr = chunkWMIPYZSB_cjs.ArkAddress.decode(offchainAddress);
|
|
10299
10322
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
10300
10323
|
const outputFee = estimator.evalOffchainOutput({
|
|
10301
10324
|
amount,
|
|
@@ -10378,6 +10401,10 @@ var Ramps = class {
|
|
|
10378
10401
|
}
|
|
10379
10402
|
change = totalAmount - amount;
|
|
10380
10403
|
}
|
|
10404
|
+
const dustAmount = getDustAmount(this.wallet);
|
|
10405
|
+
if (change > 0n && change < dustAmount) {
|
|
10406
|
+
throw new DustChangeError(change, dustAmount);
|
|
10407
|
+
}
|
|
10381
10408
|
amount = amount ?? totalAmount;
|
|
10382
10409
|
const networkNames = [
|
|
10383
10410
|
"bitcoin",
|
|
@@ -10389,7 +10416,7 @@ var Ramps = class {
|
|
|
10389
10416
|
let destinationScript;
|
|
10390
10417
|
for (const networkName of networkNames) {
|
|
10391
10418
|
try {
|
|
10392
|
-
const network =
|
|
10419
|
+
const network = chunkWMIPYZSB_cjs.networks[networkName];
|
|
10393
10420
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
10394
10421
|
destinationScript = btcSigner.OutScript.encode(addr);
|
|
10395
10422
|
break;
|
|
@@ -10440,18 +10467,47 @@ var WalletNotInitializedError = class extends Error {
|
|
|
10440
10467
|
this.name = "WalletNotInitializedError";
|
|
10441
10468
|
}
|
|
10442
10469
|
};
|
|
10470
|
+
function isSerializedAggregateError(value) {
|
|
10471
|
+
if (!value || typeof value !== "object") return false;
|
|
10472
|
+
const v = value;
|
|
10473
|
+
return v.name === "AggregateError" && typeof v.message === "string" && Array.isArray(v.errors) && v.errors.every((e) => e && typeof e.name === "string" && typeof e.message === "string");
|
|
10474
|
+
}
|
|
10475
|
+
function serializeAggregateError(error) {
|
|
10476
|
+
const errors = [];
|
|
10477
|
+
for (const child of error.errors ?? []) {
|
|
10478
|
+
if (child instanceof Error) {
|
|
10479
|
+
errors.push({ name: child.name, message: child.message });
|
|
10480
|
+
} else {
|
|
10481
|
+
errors.push({ name: "Error", message: String(child) });
|
|
10482
|
+
}
|
|
10483
|
+
}
|
|
10484
|
+
return {
|
|
10485
|
+
name: "AggregateError",
|
|
10486
|
+
message: error.message,
|
|
10487
|
+
errors
|
|
10488
|
+
};
|
|
10489
|
+
}
|
|
10490
|
+
function deserializeAggregateError(payload) {
|
|
10491
|
+
const errs = payload.errors.map((e) => {
|
|
10492
|
+
const err = new Error(e.message);
|
|
10493
|
+
err.name = e.name;
|
|
10494
|
+
return err;
|
|
10495
|
+
});
|
|
10496
|
+
return new AggregateError(errs, payload.message);
|
|
10497
|
+
}
|
|
10443
10498
|
var ReadonlyWalletError = class extends Error {
|
|
10444
10499
|
constructor() {
|
|
10445
10500
|
super("Read-only wallet: operation requires signing");
|
|
10446
10501
|
this.name = "ReadonlyWalletError";
|
|
10447
10502
|
}
|
|
10448
10503
|
};
|
|
10449
|
-
var
|
|
10504
|
+
var DelegateNotConfiguredError = class extends Error {
|
|
10450
10505
|
constructor() {
|
|
10451
|
-
super("
|
|
10452
|
-
this.name = "
|
|
10506
|
+
super("Delegate not configured");
|
|
10507
|
+
this.name = "DelegateNotConfiguredError";
|
|
10453
10508
|
}
|
|
10454
10509
|
};
|
|
10510
|
+
var DelegatorNotConfiguredError = DelegateNotConfiguredError;
|
|
10455
10511
|
var DEFAULT_MESSAGE_TAG = "WALLET_UPDATER";
|
|
10456
10512
|
var WalletMessageHandler = class {
|
|
10457
10513
|
messageTag;
|
|
@@ -10534,7 +10590,10 @@ var WalletMessageHandler = class {
|
|
|
10534
10590
|
// page-side PING / MESSAGE_BUS_NOT_INITIALIZED path triggered by concurrent
|
|
10535
10591
|
// short requests (GET_STATUS, GET_BALANCE, ...).
|
|
10536
10592
|
isLongRunning(message) {
|
|
10537
|
-
return message.type === "SETTLE" || message.type === "RECOVER_VTXOS" || message.type === "RENEW_VTXOS"
|
|
10593
|
+
return message.type === "SETTLE" || message.type === "RECOVER_VTXOS" || message.type === "RENEW_VTXOS" || // HD restore walks the index range with one indexer round-trip per
|
|
10594
|
+
// step until it hits gapLimit consecutive unused indices. The bus
|
|
10595
|
+
// deadline must not race the scan; liveness stays covered by PING.
|
|
10596
|
+
message.type === "RESTORE_WALLET";
|
|
10538
10597
|
}
|
|
10539
10598
|
async handleMessage(message) {
|
|
10540
10599
|
const id = message.id;
|
|
@@ -10803,11 +10862,11 @@ var WalletMessageHandler = class {
|
|
|
10803
10862
|
}
|
|
10804
10863
|
case "GET_DELEGATE_INFO": {
|
|
10805
10864
|
const wallet = this.requireWallet();
|
|
10806
|
-
const
|
|
10807
|
-
if (!
|
|
10808
|
-
throw new
|
|
10865
|
+
const delegateManager = await wallet.getDelegateManager();
|
|
10866
|
+
if (!delegateManager) {
|
|
10867
|
+
throw new DelegateNotConfiguredError();
|
|
10809
10868
|
}
|
|
10810
|
-
const info = await
|
|
10869
|
+
const info = await delegateManager.getDelegateInfo();
|
|
10811
10870
|
return this.tagged({
|
|
10812
10871
|
id,
|
|
10813
10872
|
type: "DELEGATE_INFO",
|
|
@@ -10897,6 +10956,24 @@ var WalletMessageHandler = class {
|
|
|
10897
10956
|
payload: { txid }
|
|
10898
10957
|
});
|
|
10899
10958
|
}
|
|
10959
|
+
case "RESTORE_WALLET": {
|
|
10960
|
+
const wallet = this.requireWallet();
|
|
10961
|
+
try {
|
|
10962
|
+
await wallet.restore(message.payload);
|
|
10963
|
+
} catch (error) {
|
|
10964
|
+
if (error instanceof AggregateError) {
|
|
10965
|
+
return this.tagged({
|
|
10966
|
+
id,
|
|
10967
|
+
error: serializeAggregateError(error)
|
|
10968
|
+
});
|
|
10969
|
+
}
|
|
10970
|
+
throw error;
|
|
10971
|
+
}
|
|
10972
|
+
return this.tagged({
|
|
10973
|
+
id,
|
|
10974
|
+
type: "RESTORE_WALLET_SUCCESS"
|
|
10975
|
+
});
|
|
10976
|
+
}
|
|
10900
10977
|
default:
|
|
10901
10978
|
console.error("Unknown message type", message);
|
|
10902
10979
|
throw new Error("Unknown message");
|
|
@@ -10908,7 +10985,7 @@ var WalletMessageHandler = class {
|
|
|
10908
10985
|
// Wallet methods
|
|
10909
10986
|
async handleInitWallet({ payload }) {
|
|
10910
10987
|
const { arkServerUrl } = payload;
|
|
10911
|
-
this.indexerProvider = new
|
|
10988
|
+
this.indexerProvider = new chunk6FLL2Q36_cjs.RestIndexerProvider(arkServerUrl);
|
|
10912
10989
|
await this.onWalletInitialized();
|
|
10913
10990
|
}
|
|
10914
10991
|
async handleGetBalance() {
|
|
@@ -10925,7 +11002,7 @@ var WalletMessageHandler = class {
|
|
|
10925
11002
|
unconfirmed += utxo.value;
|
|
10926
11003
|
}
|
|
10927
11004
|
}
|
|
10928
|
-
const spendableVtxos = allVtxos.filter(
|
|
11005
|
+
const spendableVtxos = allVtxos.filter(isSpendable);
|
|
10929
11006
|
const sweptVtxos = allVtxos.filter((vtxo) => vtxo.virtualStatus.state === "swept");
|
|
10930
11007
|
let settled = 0;
|
|
10931
11008
|
let preconfirmed = 0;
|
|
@@ -10938,7 +11015,7 @@ var WalletMessageHandler = class {
|
|
|
10938
11015
|
}
|
|
10939
11016
|
}
|
|
10940
11017
|
for (const vtxo of sweptVtxos) {
|
|
10941
|
-
if (
|
|
11018
|
+
if (isSpendable(vtxo)) {
|
|
10942
11019
|
recoverable += vtxo.value;
|
|
10943
11020
|
}
|
|
10944
11021
|
}
|
|
@@ -10980,7 +11057,7 @@ var WalletMessageHandler = class {
|
|
|
10980
11057
|
*/
|
|
10981
11058
|
async getSpendableVtxos() {
|
|
10982
11059
|
const vtxos = await this.getVtxosFromRepo();
|
|
10983
|
-
return vtxos.filter(
|
|
11060
|
+
return vtxos.filter(isSpendable);
|
|
10984
11061
|
}
|
|
10985
11062
|
async onWalletInitialized() {
|
|
10986
11063
|
if (!this.readonlyWallet || !this.arkProvider || !this.indexerProvider || !this.walletRepository) {
|
|
@@ -11151,15 +11228,15 @@ var WalletMessageHandler = class {
|
|
|
11151
11228
|
}
|
|
11152
11229
|
async handleDelegate(message) {
|
|
11153
11230
|
const wallet = this.requireWallet();
|
|
11154
|
-
const
|
|
11155
|
-
if (!
|
|
11156
|
-
throw new
|
|
11231
|
+
const delegateManager = await wallet.getDelegateManager();
|
|
11232
|
+
if (!delegateManager) {
|
|
11233
|
+
throw new DelegateNotConfiguredError();
|
|
11157
11234
|
}
|
|
11158
11235
|
const { vtxoOutpoints, destination, delegateAt } = message.payload;
|
|
11159
11236
|
const allVtxos = await wallet.getVtxos();
|
|
11160
11237
|
const outpointSet = new Set(vtxoOutpoints.map((o) => `${o.txid}:${o.vout}`));
|
|
11161
11238
|
const filtered = allVtxos.filter((v) => outpointSet.has(`${v.txid}:${v.vout}`)).map((v) => ({ ...v, contractScript: v.script }));
|
|
11162
|
-
const result = await
|
|
11239
|
+
const result = await delegateManager.delegate(
|
|
11163
11240
|
filtered,
|
|
11164
11241
|
destination,
|
|
11165
11242
|
delegateAt !== void 0 ? new Date(delegateAt) : void 0
|
|
@@ -11190,13 +11267,13 @@ var WalletMessageHandler = class {
|
|
|
11190
11267
|
const dustAmount = this.readonlyWallet.dustAmount;
|
|
11191
11268
|
const includeRecoverable = message.payload.filter?.withRecoverable ?? false;
|
|
11192
11269
|
const filteredVtxos = includeRecoverable ? vtxos : vtxos.filter((v) => {
|
|
11193
|
-
if (dustAmount != null &&
|
|
11270
|
+
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
11194
11271
|
return false;
|
|
11195
11272
|
}
|
|
11196
|
-
if (
|
|
11273
|
+
if (isRecoverable(v)) {
|
|
11197
11274
|
return false;
|
|
11198
11275
|
}
|
|
11199
|
-
if (
|
|
11276
|
+
if (isExpired(v)) {
|
|
11200
11277
|
return false;
|
|
11201
11278
|
}
|
|
11202
11279
|
return true;
|
|
@@ -11366,6 +11443,10 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
11366
11443
|
RECOVER_VTXOS: 5e4,
|
|
11367
11444
|
RENEW_VTXOS: 5e4,
|
|
11368
11445
|
SWEEP_EXPIRED_BOARDING_UTXOS: 5e4,
|
|
11446
|
+
// RESTORE_WALLET is a streaming/long-running path (sendMessageWithEvents)
|
|
11447
|
+
// like SETTLE; the value here is kept for type completeness and is never
|
|
11448
|
+
// enforced as an inactivity deadline.
|
|
11449
|
+
RESTORE_WALLET: 5e4,
|
|
11369
11450
|
// Misc writes
|
|
11370
11451
|
INIT_WALLET: 3e4,
|
|
11371
11452
|
CLEAR: 1e4,
|
|
@@ -11507,6 +11588,8 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
11507
11588
|
// these immediately after construction.
|
|
11508
11589
|
arkServerUrl;
|
|
11509
11590
|
arkServerPublicKey;
|
|
11591
|
+
delegateUrl;
|
|
11592
|
+
/** @deprecated alias for @see ServiceWorkerReadonlyWallet.delegateUrl */
|
|
11510
11593
|
delegatorUrl;
|
|
11511
11594
|
indexerUrl;
|
|
11512
11595
|
esploraUrl;
|
|
@@ -11545,7 +11628,11 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
11545
11628
|
key: { publicKey },
|
|
11546
11629
|
arkServerUrl: getArkadeServerUrl(options),
|
|
11547
11630
|
arkServerPublicKey: options.arkServerPublicKey,
|
|
11548
|
-
|
|
11631
|
+
delegateUrl: options.delegateUrl || options.delegatorUrl,
|
|
11632
|
+
// Keep the deprecated field populated so pre-#519 service workers
|
|
11633
|
+
// (which only read delegatorUrl) keep delegating until they activate
|
|
11634
|
+
// a newer version.
|
|
11635
|
+
delegatorUrl: options.delegateUrl || options.delegatorUrl
|
|
11549
11636
|
};
|
|
11550
11637
|
const messageTimeouts = options.messageTimeouts ? {
|
|
11551
11638
|
...DEFAULT_MESSAGE_TIMEOUTS,
|
|
@@ -11557,7 +11644,11 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
11557
11644
|
url: getArkadeServerUrl(options),
|
|
11558
11645
|
publicKey: options.arkServerPublicKey
|
|
11559
11646
|
},
|
|
11560
|
-
|
|
11647
|
+
delegateUrl: options.delegateUrl || options.delegatorUrl,
|
|
11648
|
+
// Keep the deprecated field populated so pre-#519 service workers
|
|
11649
|
+
// (which only read delegatorUrl) keep delegating until they activate
|
|
11650
|
+
// a newer version.
|
|
11651
|
+
delegatorUrl: options.delegateUrl || options.delegatorUrl,
|
|
11561
11652
|
indexerUrl: options.indexerUrl,
|
|
11562
11653
|
esploraUrl: options.esploraUrl,
|
|
11563
11654
|
watcherConfig: options.watcherConfig,
|
|
@@ -11779,7 +11870,11 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
11779
11870
|
url: this.arkServerUrl,
|
|
11780
11871
|
publicKey: this.arkServerPublicKey
|
|
11781
11872
|
},
|
|
11782
|
-
|
|
11873
|
+
delegateUrl: this.delegateUrl || this.delegatorUrl,
|
|
11874
|
+
// Keep the deprecated field populated so pre-#519 service workers
|
|
11875
|
+
// (which only read delegatorUrl) keep delegating until they activate
|
|
11876
|
+
// a newer version.
|
|
11877
|
+
delegatorUrl: this.delegateUrl || this.delegatorUrl,
|
|
11783
11878
|
indexerUrl: this.indexerUrl,
|
|
11784
11879
|
esploraUrl: this.esploraUrl,
|
|
11785
11880
|
watcherConfig: this.watcherConfig,
|
|
@@ -12148,7 +12243,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
12148
12243
|
}
|
|
12149
12244
|
};
|
|
12150
12245
|
var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
12151
|
-
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag,
|
|
12246
|
+
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag, hasDelegate) {
|
|
12152
12247
|
super(serviceWorker, identity, walletRepository, contractRepository, messageTag);
|
|
12153
12248
|
this.serviceWorker = serviceWorker;
|
|
12154
12249
|
this.identity = identity;
|
|
@@ -12158,13 +12253,13 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
12158
12253
|
(msg) => this.sendMessage(msg),
|
|
12159
12254
|
messageTag
|
|
12160
12255
|
);
|
|
12161
|
-
this.
|
|
12256
|
+
this.hasDelegate = hasDelegate;
|
|
12162
12257
|
}
|
|
12163
12258
|
walletRepository;
|
|
12164
12259
|
contractRepository;
|
|
12165
12260
|
identity;
|
|
12166
12261
|
_assetManager;
|
|
12167
|
-
|
|
12262
|
+
hasDelegate;
|
|
12168
12263
|
get assetManager() {
|
|
12169
12264
|
return this._assetManager;
|
|
12170
12265
|
}
|
|
@@ -12188,14 +12283,18 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
12188
12283
|
walletRepository,
|
|
12189
12284
|
contractRepository,
|
|
12190
12285
|
messageTag,
|
|
12191
|
-
!!options.delegatorUrl
|
|
12286
|
+
!!(options.delegateUrl || options.delegatorUrl)
|
|
12192
12287
|
);
|
|
12193
12288
|
const legacyPrivateKey = serializedWallet.type === "single-key" ? serializedWallet.privateKey : null;
|
|
12194
12289
|
const initWalletPayload = {
|
|
12195
12290
|
key: legacyPrivateKey ? { privateKey: legacyPrivateKey } : {},
|
|
12196
12291
|
arkServerUrl: getArkadeServerUrl(options),
|
|
12197
12292
|
arkServerPublicKey: options.arkServerPublicKey,
|
|
12198
|
-
|
|
12293
|
+
delegateUrl: options.delegateUrl || options.delegatorUrl,
|
|
12294
|
+
// Keep the deprecated field populated so pre-#519 service workers
|
|
12295
|
+
// (which only read delegatorUrl) keep delegating until they activate
|
|
12296
|
+
// a newer version.
|
|
12297
|
+
delegatorUrl: options.delegateUrl || options.delegatorUrl
|
|
12199
12298
|
};
|
|
12200
12299
|
const messageTimeouts = options.messageTimeouts ? {
|
|
12201
12300
|
...DEFAULT_MESSAGE_TIMEOUTS,
|
|
@@ -12207,7 +12306,11 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
12207
12306
|
url: getArkadeServerUrl(options),
|
|
12208
12307
|
publicKey: options.arkServerPublicKey
|
|
12209
12308
|
},
|
|
12210
|
-
|
|
12309
|
+
delegateUrl: options.delegateUrl || options.delegatorUrl,
|
|
12310
|
+
// Keep the deprecated field populated so pre-#519 service workers
|
|
12311
|
+
// (which only read delegatorUrl) keep delegating until they activate
|
|
12312
|
+
// a newer version.
|
|
12313
|
+
delegatorUrl: options.delegateUrl || options.delegatorUrl,
|
|
12211
12314
|
indexerUrl: options.indexerUrl,
|
|
12212
12315
|
esploraUrl: options.esploraUrl,
|
|
12213
12316
|
settlementConfig: options.settlementConfig,
|
|
@@ -12288,6 +12391,38 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
12288
12391
|
throw new Error(`Settlement failed: ${error}`);
|
|
12289
12392
|
}
|
|
12290
12393
|
}
|
|
12394
|
+
/**
|
|
12395
|
+
* Explicitly recover this wallet's contracts and balance on a fresh repo.
|
|
12396
|
+
* Mirrors {@link Wallet.restore} but drives the scan inside the service
|
|
12397
|
+
* worker — the materialize() callback used by `scanContracts` cannot
|
|
12398
|
+
* cross the postMessage boundary, so the entire flow runs worker-side
|
|
12399
|
+
* and only the gapLimit / outcome cross the wire.
|
|
12400
|
+
*
|
|
12401
|
+
* Uses the streaming send path so the bus deadline does not race a
|
|
12402
|
+
* long indexer-bound scan. AggregateError thrown by the worker is
|
|
12403
|
+
* reconstructed here so callers can inspect `.errors`.
|
|
12404
|
+
*/
|
|
12405
|
+
async restore(opts) {
|
|
12406
|
+
const message = {
|
|
12407
|
+
id: getRandomId(),
|
|
12408
|
+
tag: this.messageTag,
|
|
12409
|
+
type: "RESTORE_WALLET",
|
|
12410
|
+
payload: opts ?? {}
|
|
12411
|
+
};
|
|
12412
|
+
try {
|
|
12413
|
+
await this.sendMessageWithEvents(
|
|
12414
|
+
message,
|
|
12415
|
+
() => {
|
|
12416
|
+
},
|
|
12417
|
+
(resp) => resp.type === "RESTORE_WALLET_SUCCESS"
|
|
12418
|
+
);
|
|
12419
|
+
} catch (error) {
|
|
12420
|
+
if (isSerializedAggregateError(error)) {
|
|
12421
|
+
throw deserializeAggregateError(error);
|
|
12422
|
+
}
|
|
12423
|
+
throw error;
|
|
12424
|
+
}
|
|
12425
|
+
}
|
|
12291
12426
|
async send(...recipients) {
|
|
12292
12427
|
const message = {
|
|
12293
12428
|
tag: this.messageTag,
|
|
@@ -12302,8 +12437,8 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
12302
12437
|
throw new Error(`Send failed: ${error}`);
|
|
12303
12438
|
}
|
|
12304
12439
|
}
|
|
12305
|
-
async
|
|
12306
|
-
if (!this.
|
|
12440
|
+
async getDelegateManager() {
|
|
12441
|
+
if (!this.hasDelegate) {
|
|
12307
12442
|
return void 0;
|
|
12308
12443
|
}
|
|
12309
12444
|
const wallet = this;
|
|
@@ -12353,6 +12488,10 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
12353
12488
|
};
|
|
12354
12489
|
return manager;
|
|
12355
12490
|
}
|
|
12491
|
+
/** @deprecated alias for @see ServiceWorkerWallet.getDelegateManager */
|
|
12492
|
+
async getDelegatorManager() {
|
|
12493
|
+
return await this.getDelegateManager();
|
|
12494
|
+
}
|
|
12356
12495
|
async getVtxoManager() {
|
|
12357
12496
|
const wallet = this;
|
|
12358
12497
|
const messageTag = this.messageTag;
|
|
@@ -12476,15 +12615,14 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
12476
12615
|
* @param networkName - Bitcoin network name, @see NetworkName
|
|
12477
12616
|
* @param provider - Optional onchain provider override, @see OnchainProvider
|
|
12478
12617
|
* @returns Configured onchain wallet
|
|
12479
|
-
* @defaultValue `provider = new EsploraProvider('https://mempool.space/api')`
|
|
12480
12618
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
12481
12619
|
*/
|
|
12482
|
-
static async create(identity, networkName =
|
|
12620
|
+
static async create(identity, networkName = chunkWMIPYZSB_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
12483
12621
|
const pubkey = await identity.xOnlyPublicKey();
|
|
12484
12622
|
if (!pubkey) {
|
|
12485
12623
|
throw new Error("Invalid configured public key");
|
|
12486
12624
|
}
|
|
12487
|
-
const network = getNetwork(networkName);
|
|
12625
|
+
const network = chunkWMIPYZSB_cjs.getNetwork(networkName);
|
|
12488
12626
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
12489
12627
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
12490
12628
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -12590,7 +12728,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
12590
12728
|
if (!inputs) {
|
|
12591
12729
|
throw new Error("Fee estimation failed");
|
|
12592
12730
|
}
|
|
12593
|
-
let tx = new
|
|
12731
|
+
let tx = new chunk6FLL2Q36_cjs.Transaction();
|
|
12594
12732
|
for (const input of inputs) {
|
|
12595
12733
|
tx.addInput({
|
|
12596
12734
|
txid: input.txid,
|
|
@@ -12621,7 +12759,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
12621
12759
|
*/
|
|
12622
12760
|
async bumpP2A(parent) {
|
|
12623
12761
|
const parentVsize = parent.vsize;
|
|
12624
|
-
let child = new
|
|
12762
|
+
let child = new chunk6FLL2Q36_cjs.Transaction({
|
|
12625
12763
|
version: 3,
|
|
12626
12764
|
allowLegacyWitnessUtxo: true
|
|
12627
12765
|
});
|
|
@@ -13378,7 +13516,7 @@ exports.BIP322 = void 0;
|
|
|
13378
13516
|
async function sign2(message, identity, network) {
|
|
13379
13517
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
13380
13518
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
13381
|
-
const toSpend =
|
|
13519
|
+
const toSpend = chunk6FLL2Q36_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
13382
13520
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
13383
13521
|
const signed = await identity.sign(toSign, [0]);
|
|
13384
13522
|
signed.finalizeIdx(0);
|
|
@@ -13436,7 +13574,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
13436
13574
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
13437
13575
|
return false;
|
|
13438
13576
|
}
|
|
13439
|
-
const toSpend =
|
|
13577
|
+
const toSpend = chunk6FLL2Q36_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
13440
13578
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
13441
13579
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
13442
13580
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -13457,7 +13595,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
13457
13595
|
}
|
|
13458
13596
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
13459
13597
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
13460
|
-
const toSpend =
|
|
13598
|
+
const toSpend = chunk6FLL2Q36_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
13461
13599
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
13462
13600
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
13463
13601
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -13510,7 +13648,7 @@ function encodeCompactSize(n) {
|
|
|
13510
13648
|
return buf;
|
|
13511
13649
|
}
|
|
13512
13650
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
13513
|
-
const tx = new
|
|
13651
|
+
const tx = new chunk6FLL2Q36_cjs.Transaction({ version: 0 });
|
|
13514
13652
|
tx.addInput({
|
|
13515
13653
|
txid: toSpend.id,
|
|
13516
13654
|
index: 0,
|
|
@@ -13524,12 +13662,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
13524
13662
|
});
|
|
13525
13663
|
tx.addOutput({
|
|
13526
13664
|
amount: 0n,
|
|
13527
|
-
script:
|
|
13665
|
+
script: chunk6FLL2Q36_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
13528
13666
|
});
|
|
13529
13667
|
return tx;
|
|
13530
13668
|
}
|
|
13531
13669
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
13532
|
-
const tx = new
|
|
13670
|
+
const tx = new chunk6FLL2Q36_cjs.Transaction({ version: 0 });
|
|
13533
13671
|
tx.addInput({
|
|
13534
13672
|
txid: toSpend.id,
|
|
13535
13673
|
index: 0,
|
|
@@ -13541,7 +13679,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
13541
13679
|
});
|
|
13542
13680
|
tx.addOutput({
|
|
13543
13681
|
amount: 0n,
|
|
13544
|
-
script:
|
|
13682
|
+
script: chunk6FLL2Q36_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
13545
13683
|
});
|
|
13546
13684
|
return tx;
|
|
13547
13685
|
}
|
|
@@ -13602,7 +13740,7 @@ exports.Unroll = void 0;
|
|
|
13602
13740
|
if (virtualTxs.txs.length === 0) {
|
|
13603
13741
|
throw new Error(`Tx ${nextTxToBroadcast.txid} not found`);
|
|
13604
13742
|
}
|
|
13605
|
-
const tx =
|
|
13743
|
+
const tx = chunk6FLL2Q36_cjs.Transaction.fromPSBT(base.base64.decode(virtualTxs.txs[0]));
|
|
13606
13744
|
if (nextTxToBroadcast.type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
13607
13745
|
const input = tx.getInput(0);
|
|
13608
13746
|
if (!input) {
|
|
@@ -13679,12 +13817,12 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
13679
13817
|
if (!exit) {
|
|
13680
13818
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
13681
13819
|
}
|
|
13682
|
-
const spendingLeaf =
|
|
13820
|
+
const spendingLeaf = chunkWMIPYZSB_cjs.VtxoScript.decode(vtxo.tapTree).findLeaf(base.hex.encode(exit.script));
|
|
13683
13821
|
if (!spendingLeaf) {
|
|
13684
13822
|
throw new Error(`spending leaf not found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
13685
13823
|
}
|
|
13686
13824
|
totalAmount += BigInt(vtxo.value);
|
|
13687
|
-
const sequence =
|
|
13825
|
+
const sequence = chunkWMIPYZSB_cjs.timelockToSequence(exit.params.timelock);
|
|
13688
13826
|
inputs.push({
|
|
13689
13827
|
txid: vtxo.txid,
|
|
13690
13828
|
index: vtxo.vout,
|
|
@@ -13692,7 +13830,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
13692
13830
|
sequence,
|
|
13693
13831
|
witnessUtxo: {
|
|
13694
13832
|
amount: BigInt(vtxo.value),
|
|
13695
|
-
script:
|
|
13833
|
+
script: chunkWMIPYZSB_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
13696
13834
|
},
|
|
13697
13835
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
13698
13836
|
});
|
|
@@ -13702,7 +13840,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
13702
13840
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
13703
13841
|
);
|
|
13704
13842
|
}
|
|
13705
|
-
const tx = new
|
|
13843
|
+
const tx = new chunk6FLL2Q36_cjs.Transaction({ version: 2 });
|
|
13706
13844
|
for (const input of inputs) {
|
|
13707
13845
|
tx.addInput(input);
|
|
13708
13846
|
}
|
|
@@ -13749,7 +13887,7 @@ function doWait(onchainProvider, txid) {
|
|
|
13749
13887
|
};
|
|
13750
13888
|
}
|
|
13751
13889
|
function availableExitPath(confirmedAt, current, vtxo) {
|
|
13752
|
-
const exits =
|
|
13890
|
+
const exits = chunkWMIPYZSB_cjs.VtxoScript.decode(vtxo.tapTree).exitPaths();
|
|
13753
13891
|
for (const exit of exits) {
|
|
13754
13892
|
if (exit.params.timelock.type === "blocks") {
|
|
13755
13893
|
if (current.height >= confirmedAt.height + Number(exit.params.timelock.value)) {
|
|
@@ -13788,7 +13926,7 @@ function decodeArkContract(encoded) {
|
|
|
13788
13926
|
}
|
|
13789
13927
|
function contractFromArkContract(encoded, options = {}) {
|
|
13790
13928
|
const parsed = decodeArkContract(encoded);
|
|
13791
|
-
const handler =
|
|
13929
|
+
const handler = chunkIEO3XDKI_cjs.contractHandlers.get(parsed.type);
|
|
13792
13930
|
if (!handler) {
|
|
13793
13931
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
13794
13932
|
}
|
|
@@ -13802,9 +13940,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
13802
13940
|
metadata: options.metadata
|
|
13803
13941
|
};
|
|
13804
13942
|
}
|
|
13805
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
13943
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkWMIPYZSB_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
13806
13944
|
const parsed = decodeArkContract(encoded);
|
|
13807
|
-
const handler =
|
|
13945
|
+
const handler = chunkIEO3XDKI_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
13808
13946
|
const params = parsed.data;
|
|
13809
13947
|
const vtxoScript = handler.createScript(params);
|
|
13810
13948
|
return {
|
|
@@ -13823,14 +13961,18 @@ function isArkContract(str) {
|
|
|
13823
13961
|
}
|
|
13824
13962
|
|
|
13825
13963
|
exports.ArkNote = ArkNote;
|
|
13964
|
+
exports.AssetManager = AssetManager;
|
|
13826
13965
|
exports.ContractManager = ContractManager;
|
|
13827
13966
|
exports.ContractRepositoryImpl = ContractRepositoryImpl;
|
|
13828
13967
|
exports.ContractWatcher = ContractWatcher;
|
|
13829
13968
|
exports.DB_VERSION = DB_VERSION;
|
|
13830
13969
|
exports.DEFAULT_MESSAGE_TIMEOUTS = DEFAULT_MESSAGE_TIMEOUTS;
|
|
13970
|
+
exports.DelegateManagerImpl = DelegateManagerImpl;
|
|
13971
|
+
exports.DelegateNotConfiguredError = DelegateNotConfiguredError;
|
|
13831
13972
|
exports.DelegatorManagerImpl = DelegatorManagerImpl;
|
|
13832
13973
|
exports.DelegatorNotConfiguredError = DelegatorNotConfiguredError;
|
|
13833
13974
|
exports.DescriptorSigningProviderMissingError = DescriptorSigningProviderMissingError;
|
|
13975
|
+
exports.DustChangeError = DustChangeError;
|
|
13834
13976
|
exports.ELECTRUM_TCP_HOST = ELECTRUM_TCP_HOST;
|
|
13835
13977
|
exports.ELECTRUM_WS_URL = ELECTRUM_WS_URL;
|
|
13836
13978
|
exports.ESPLORA_URL = ESPLORA_URL;
|
|
@@ -13851,10 +13993,12 @@ exports.MnemonicIdentity = MnemonicIdentity;
|
|
|
13851
13993
|
exports.OnchainWallet = OnchainWallet;
|
|
13852
13994
|
exports.P2A = P2A;
|
|
13853
13995
|
exports.Ramps = Ramps;
|
|
13996
|
+
exports.ReadonlyAssetManager = ReadonlyAssetManager;
|
|
13854
13997
|
exports.ReadonlyDescriptorIdentity = ReadonlyDescriptorIdentity;
|
|
13855
13998
|
exports.ReadonlySingleKey = ReadonlySingleKey;
|
|
13856
13999
|
exports.ReadonlyWallet = ReadonlyWallet;
|
|
13857
14000
|
exports.ReadonlyWalletError = ReadonlyWalletError;
|
|
14001
|
+
exports.RestDelegateProvider = RestDelegateProvider;
|
|
13858
14002
|
exports.RestDelegatorProvider = RestDelegatorProvider;
|
|
13859
14003
|
exports.SeedIdentity = SeedIdentity;
|
|
13860
14004
|
exports.ServiceWorkerReadonlyWallet = ServiceWorkerReadonlyWallet;
|
|
@@ -13862,6 +14006,7 @@ exports.ServiceWorkerTimeoutError = ServiceWorkerTimeoutError;
|
|
|
13862
14006
|
exports.ServiceWorkerWallet = ServiceWorkerWallet;
|
|
13863
14007
|
exports.SingleKey = SingleKey;
|
|
13864
14008
|
exports.TxTree = TxTree;
|
|
14009
|
+
exports.TxType = TxType;
|
|
13865
14010
|
exports.TxWeightEstimator = TxWeightEstimator;
|
|
13866
14011
|
exports.VtxoManager = VtxoManager;
|
|
13867
14012
|
exports.Wallet = Wallet2;
|
|
@@ -13887,11 +14032,14 @@ exports.hasBoardingTxExpired = hasBoardingTxExpired;
|
|
|
13887
14032
|
exports.isArkContract = isArkContract;
|
|
13888
14033
|
exports.isBatchSignable = isBatchSignable;
|
|
13889
14034
|
exports.isDiscoverable = isDiscoverable;
|
|
14035
|
+
exports.isExpired = isExpired;
|
|
14036
|
+
exports.isRecoverable = isRecoverable;
|
|
14037
|
+
exports.isSpendable = isSpendable;
|
|
14038
|
+
exports.isSubdust = isSubdust;
|
|
13890
14039
|
exports.isValidArkAddress = isValidArkAddress;
|
|
13891
14040
|
exports.isVtxoExpiringSoon = isVtxoExpiringSoon;
|
|
13892
14041
|
exports.isVtxoForScript = isVtxoForScript;
|
|
13893
14042
|
exports.migrateWalletRepository = migrateWalletRepository;
|
|
13894
|
-
exports.networks = networks2;
|
|
13895
14043
|
exports.openDatabase = openDatabase;
|
|
13896
14044
|
exports.requiresMigration = requiresMigration;
|
|
13897
14045
|
exports.rollbackMigration = rollbackMigration;
|
|
@@ -13906,5 +14054,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
13906
14054
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
13907
14055
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
13908
14056
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
13909
|
-
//# sourceMappingURL=chunk-
|
|
13910
|
-
//# sourceMappingURL=chunk-
|
|
14057
|
+
//# sourceMappingURL=chunk-GDCTOSMV.cjs.map
|
|
14058
|
+
//# sourceMappingURL=chunk-GDCTOSMV.cjs.map
|