@arkade-os/sdk 0.4.39 → 0.4.41
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 +24 -0
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{ark-BzUNnkoc.d.cts → ark-CSqMJczW.d.cts} +111 -4
- package/dist/{ark-BzUNnkoc.d.ts → ark-CSqMJczW.d.ts} +111 -4
- package/dist/{asyncStorageTaskQueue-C0kQoY1x.d.cts → asyncStorageTaskQueue-79XdGsdW.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-CIYeI6GM.d.ts → asyncStorageTaskQueue-SZPrhw23.d.ts} +1 -1
- package/dist/{chunk-GUTKJMSF.cjs → chunk-32YKLQPS.cjs} +29 -29
- package/dist/{chunk-GUTKJMSF.cjs.map → chunk-32YKLQPS.cjs.map} +1 -1
- package/dist/{chunk-P5FKMIGY.cjs → chunk-3MPXMLP4.cjs} +538 -282
- package/dist/chunk-3MPXMLP4.cjs.map +1 -0
- package/dist/{chunk-D744IES4.js → chunk-5XAYUPK4.js} +15 -6
- package/dist/chunk-5XAYUPK4.js.map +1 -0
- package/dist/{chunk-LJLEFPWD.cjs → chunk-ALISWEQ5.cjs} +20 -11
- package/dist/chunk-ALISWEQ5.cjs.map +1 -0
- package/dist/{chunk-OUVTG72A.js → chunk-BE5MUB7T.js} +5 -3
- package/dist/chunk-BE5MUB7T.js.map +1 -0
- package/dist/{chunk-SYEGCMNV.js → chunk-D5MQYYYF.js} +355 -104
- package/dist/chunk-D5MQYYYF.js.map +1 -0
- package/dist/{chunk-VGXTJ7HR.js → chunk-DDG4RE5F.js} +4 -4
- package/dist/{chunk-VGXTJ7HR.js.map → chunk-DDG4RE5F.js.map} +1 -1
- package/dist/{chunk-CMPJR3HS.cjs → chunk-HXDZ2QTW.cjs} +5 -3
- package/dist/chunk-HXDZ2QTW.cjs.map +1 -0
- package/dist/{chunk-A5RLZCPO.cjs → chunk-KNASU3QI.cjs} +7 -7
- package/dist/{chunk-A5RLZCPO.cjs.map → chunk-KNASU3QI.cjs.map} +1 -1
- package/dist/{chunk-UIFBMKI7.js → chunk-MYI333YH.js} +3 -3
- package/dist/{chunk-UIFBMKI7.js.map → chunk-MYI333YH.js.map} +1 -1
- package/dist/{chunk-N56IDZON.cjs → chunk-WBF3FNS3.cjs} +14 -14
- package/dist/{chunk-N56IDZON.cjs.map → chunk-WBF3FNS3.cjs.map} +1 -1
- package/dist/{chunk-CUSABEUQ.js → chunk-YNEDJTX2.js} +3 -3
- package/dist/{chunk-CUSABEUQ.js.map → chunk-YNEDJTX2.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +7 -7
- 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-BjPbX-MR.d.ts → delegate-BTn9BK8E.d.ts} +1 -1
- package/dist/{delegate-DHAgMIS9.d.cts → delegate-Bqwe-kbj.d.cts} +1 -1
- package/dist/{index-YkMAtSfw.d.cts → index-aYiHTMkX.d.cts} +2 -2
- package/dist/{index-BOQKDCmS.d.ts → index-kITujXlS.d.ts} +2 -2
- package/dist/index.cjs +163 -139
- package/dist/index.d.cts +53 -11
- package/dist/index.d.ts +53 -11
- 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-Dfmt7ZPN.d.ts → taskRunner-BuBAZQwB.d.ts} +1 -1
- package/dist/{taskRunner-CVEgBO6d.d.cts → taskRunner-DRHElPMG.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +44 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +14 -4
- package/dist/wallet/expo/index.d.ts +14 -4
- package/dist/wallet/expo/index.js +36 -6
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-C4Pide44.d.ts → wallet-BZgRfnAE.d.cts} +15 -2
- package/dist/{wallet-_PTv-lMe.d.cts → wallet-CTEQpKG9.d.ts} +15 -2
- 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-CMPJR3HS.cjs.map +0 -1
- package/dist/chunk-D744IES4.js.map +0 -1
- package/dist/chunk-LJLEFPWD.cjs.map +0 -1
- package/dist/chunk-OUVTG72A.js.map +0 -1
- package/dist/chunk-P5FKMIGY.cjs.map +0 -1
- package/dist/chunk-SYEGCMNV.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkALISWEQ5_cjs = require('./chunk-ALISWEQ5.cjs');
|
|
4
|
+
var chunk32YKLQPS_cjs = require('./chunk-32YKLQPS.cjs');
|
|
5
|
+
var chunkHXDZ2QTW_cjs = require('./chunk-HXDZ2QTW.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 = chunkALISWEQ5_cjs.getArkPsbtFields(tx.root, 0, chunkALISWEQ5_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 = chunkALISWEQ5_cjs.getArkPsbtFields(g.root, 0, chunkALISWEQ5_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 = chunk32YKLQPS_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 chunk32YKLQPS_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 = chunk32YKLQPS_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 = chunk32YKLQPS_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 chunk32YKLQPS_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
673
673
|
}
|
|
674
674
|
};
|
|
675
675
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -980,14 +980,14 @@ var RestDelegateProvider = class {
|
|
|
980
980
|
*/
|
|
981
981
|
async delegate(intent, forfeitTxs, options) {
|
|
982
982
|
const url = `${this.url}/v1/delegate`;
|
|
983
|
-
const response = await
|
|
983
|
+
const response = await chunkALISWEQ5_cjs.baseFetch(url, {
|
|
984
984
|
method: "POST",
|
|
985
985
|
headers: {
|
|
986
986
|
"Content-Type": "application/json"
|
|
987
987
|
},
|
|
988
988
|
body: JSON.stringify({
|
|
989
989
|
intent: {
|
|
990
|
-
message:
|
|
990
|
+
message: chunkALISWEQ5_cjs.Intent.encodeMessage(intent.message),
|
|
991
991
|
proof: intent.proof
|
|
992
992
|
},
|
|
993
993
|
forfeit_txs: forfeitTxs,
|
|
@@ -1007,7 +1007,7 @@ var RestDelegateProvider = class {
|
|
|
1007
1007
|
*/
|
|
1008
1008
|
async getDelegateInfo() {
|
|
1009
1009
|
const url = `${this.url}/v1/delegator/info`;
|
|
1010
|
-
const response = await
|
|
1010
|
+
const response = await chunkALISWEQ5_cjs.baseFetch(url);
|
|
1011
1011
|
if (!response.ok) {
|
|
1012
1012
|
const errorText2 = await response.text();
|
|
1013
1013
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1034,7 +1034,7 @@ var ESPLORA_URL = {
|
|
|
1034
1034
|
regtest: "http://localhost:3000/api"
|
|
1035
1035
|
};
|
|
1036
1036
|
var EsploraProvider = class {
|
|
1037
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1037
|
+
constructor(baseUrl = ESPLORA_URL[chunkHXDZ2QTW_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1038
1038
|
this.baseUrl = baseUrl;
|
|
1039
1039
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1040
1040
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1042,14 +1042,14 @@ var EsploraProvider = class {
|
|
|
1042
1042
|
pollingInterval;
|
|
1043
1043
|
forcePolling;
|
|
1044
1044
|
async getCoins(address) {
|
|
1045
|
-
const response = await
|
|
1045
|
+
const response = await chunkALISWEQ5_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1046
1046
|
if (!response.ok) {
|
|
1047
1047
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1048
1048
|
}
|
|
1049
1049
|
return response.json();
|
|
1050
1050
|
}
|
|
1051
1051
|
async getFeeRate() {
|
|
1052
|
-
const response = await
|
|
1052
|
+
const response = await chunkALISWEQ5_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1053
1053
|
if (response.status === 404) {
|
|
1054
1054
|
return void 0;
|
|
1055
1055
|
}
|
|
@@ -1070,7 +1070,7 @@ var EsploraProvider = class {
|
|
|
1070
1070
|
}
|
|
1071
1071
|
}
|
|
1072
1072
|
async getTxOutspends(txid) {
|
|
1073
|
-
const response = await
|
|
1073
|
+
const response = await chunkALISWEQ5_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1074
1074
|
if (!response.ok) {
|
|
1075
1075
|
const error = await response.text();
|
|
1076
1076
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1078,7 +1078,7 @@ var EsploraProvider = class {
|
|
|
1078
1078
|
return response.json();
|
|
1079
1079
|
}
|
|
1080
1080
|
async getTransactions(address) {
|
|
1081
|
-
const response = await
|
|
1081
|
+
const response = await chunkALISWEQ5_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1082
1082
|
if (!response.ok) {
|
|
1083
1083
|
const error = await response.text();
|
|
1084
1084
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1086,7 +1086,7 @@ var EsploraProvider = class {
|
|
|
1086
1086
|
return response.json();
|
|
1087
1087
|
}
|
|
1088
1088
|
async getTxStatus(txid) {
|
|
1089
|
-
const txresponse = await
|
|
1089
|
+
const txresponse = await chunkALISWEQ5_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1090
1090
|
if (!txresponse.ok) {
|
|
1091
1091
|
throw new Error(txresponse.statusText);
|
|
1092
1092
|
}
|
|
@@ -1094,7 +1094,7 @@ var EsploraProvider = class {
|
|
|
1094
1094
|
if (!tx.status.confirmed) {
|
|
1095
1095
|
return { confirmed: false };
|
|
1096
1096
|
}
|
|
1097
|
-
const response = await
|
|
1097
|
+
const response = await chunkALISWEQ5_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1098
1098
|
if (!response.ok) {
|
|
1099
1099
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1100
1100
|
}
|
|
@@ -1178,7 +1178,7 @@ var EsploraProvider = class {
|
|
|
1178
1178
|
return stopFunc;
|
|
1179
1179
|
}
|
|
1180
1180
|
async getChainTip() {
|
|
1181
|
-
const tipBlocks = await
|
|
1181
|
+
const tipBlocks = await chunkALISWEQ5_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
1182
1182
|
if (!tipBlocks.ok) {
|
|
1183
1183
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
1184
1184
|
}
|
|
@@ -1197,7 +1197,7 @@ var EsploraProvider = class {
|
|
|
1197
1197
|
};
|
|
1198
1198
|
}
|
|
1199
1199
|
async broadcastPackage(parent, child) {
|
|
1200
|
-
const response = await
|
|
1200
|
+
const response = await chunkALISWEQ5_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
1201
1201
|
method: "POST",
|
|
1202
1202
|
headers: {
|
|
1203
1203
|
"Content-Type": "application/json"
|
|
@@ -1211,7 +1211,7 @@ var EsploraProvider = class {
|
|
|
1211
1211
|
return response.json();
|
|
1212
1212
|
}
|
|
1213
1213
|
async broadcastTx(tx) {
|
|
1214
|
-
const response = await
|
|
1214
|
+
const response = await chunkALISWEQ5_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
1215
1215
|
method: "POST",
|
|
1216
1216
|
headers: {
|
|
1217
1217
|
"Content-Type": "text/plain"
|
|
@@ -1231,7 +1231,9 @@ function isValidBlocksTip(tip) {
|
|
|
1231
1231
|
});
|
|
1232
1232
|
}
|
|
1233
1233
|
var isExplorerTransaction = (tx) => {
|
|
1234
|
-
return typeof tx.txid === "string" && Array.isArray(tx.
|
|
1234
|
+
return typeof tx.txid === "string" && (tx.vin === void 0 || Array.isArray(tx.vin) && tx.vin.every(
|
|
1235
|
+
(vin) => typeof vin.txid === "string" && typeof vin.vout === "number"
|
|
1236
|
+
)) && Array.isArray(tx.vout) && tx.vout.every(
|
|
1235
1237
|
(vout) => typeof vout.scriptpubkey_address === "string" && typeof vout.value === "number"
|
|
1236
1238
|
) && typeof tx.status === "object" && typeof tx.status.confirmed === "boolean";
|
|
1237
1239
|
};
|
|
@@ -1280,7 +1282,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
1280
1282
|
);
|
|
1281
1283
|
}
|
|
1282
1284
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
1283
|
-
const tx = new
|
|
1285
|
+
const tx = new chunkALISWEQ5_cjs.Transaction({
|
|
1284
1286
|
version: 3,
|
|
1285
1287
|
lockTime: txLocktime
|
|
1286
1288
|
});
|
|
@@ -1356,7 +1358,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
1356
1358
|
if (previousScriptKey.length !== 32) {
|
|
1357
1359
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
1358
1360
|
}
|
|
1359
|
-
const cosigners =
|
|
1361
|
+
const cosigners = chunkALISWEQ5_cjs.getArkPsbtFields(child.root, 0, chunkALISWEQ5_cjs.CosignerPublicKey);
|
|
1360
1362
|
if (cosigners.length === 0) {
|
|
1361
1363
|
throw ErrMissingCosignersPublicKeys;
|
|
1362
1364
|
}
|
|
@@ -1456,7 +1458,7 @@ var Extension = class _Extension {
|
|
|
1456
1458
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
1457
1459
|
);
|
|
1458
1460
|
}
|
|
1459
|
-
const reader = new
|
|
1461
|
+
const reader = new chunkALISWEQ5_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
1460
1462
|
const packets = [];
|
|
1461
1463
|
while (reader.remaining() > 0) {
|
|
1462
1464
|
const packetType = reader.readByte();
|
|
@@ -1530,7 +1532,7 @@ var Extension = class _Extension {
|
|
|
1530
1532
|
*/
|
|
1531
1533
|
getAssetPacket() {
|
|
1532
1534
|
for (const p of this.packets) {
|
|
1533
|
-
if (p instanceof
|
|
1535
|
+
if (p instanceof chunkALISWEQ5_cjs.Packet) {
|
|
1534
1536
|
return p;
|
|
1535
1537
|
}
|
|
1536
1538
|
}
|
|
@@ -1538,8 +1540,8 @@ var Extension = class _Extension {
|
|
|
1538
1540
|
}
|
|
1539
1541
|
};
|
|
1540
1542
|
function parsePacket(packetType, data) {
|
|
1541
|
-
if (packetType ===
|
|
1542
|
-
return
|
|
1543
|
+
if (packetType === chunkALISWEQ5_cjs.Packet.PACKET_TYPE) {
|
|
1544
|
+
return chunkALISWEQ5_cjs.Packet.fromBytes(data);
|
|
1543
1545
|
}
|
|
1544
1546
|
return new UnknownPacket(packetType, data);
|
|
1545
1547
|
}
|
|
@@ -1597,7 +1599,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
1597
1599
|
for (const recipient of recipients) {
|
|
1598
1600
|
let arkAddress;
|
|
1599
1601
|
try {
|
|
1600
|
-
arkAddress =
|
|
1602
|
+
arkAddress = chunkHXDZ2QTW_cjs.ArkAddress.decode(recipient.address);
|
|
1601
1603
|
} catch {
|
|
1602
1604
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
1603
1605
|
continue;
|
|
@@ -1698,6 +1700,122 @@ function validateAssetGroupOutput(packet, outputIndex, assetId, expectedAmount)
|
|
|
1698
1700
|
}
|
|
1699
1701
|
}
|
|
1700
1702
|
|
|
1703
|
+
// src/wallet/activity.ts
|
|
1704
|
+
async function buildActivities(txs, resolvers) {
|
|
1705
|
+
const preparedResolvers = (await Promise.all(
|
|
1706
|
+
resolvers.map(async (r) => {
|
|
1707
|
+
try {
|
|
1708
|
+
await r.prepare?.();
|
|
1709
|
+
return r;
|
|
1710
|
+
} catch {
|
|
1711
|
+
return void 0;
|
|
1712
|
+
}
|
|
1713
|
+
})
|
|
1714
|
+
)).filter((r) => r !== void 0);
|
|
1715
|
+
const keyOf = (tx) => tx.key.arkTxid || tx.key.commitmentTxid || tx.key.boardingTxid;
|
|
1716
|
+
const merge = (a, b) => ({
|
|
1717
|
+
groupId: a.groupId,
|
|
1718
|
+
label: a.label ?? b.label,
|
|
1719
|
+
kind: a.kind ?? b.kind,
|
|
1720
|
+
metadata: { ...b.metadata, ...a.metadata },
|
|
1721
|
+
amount: a.amount ?? b.amount
|
|
1722
|
+
});
|
|
1723
|
+
const isSent = (tx) => tx.type === "SENT" /* TxSent */;
|
|
1724
|
+
const signedAmount = (tx, amount = tx.amount) => {
|
|
1725
|
+
const magnitude = Math.abs(amount);
|
|
1726
|
+
return isSent(tx) ? -magnitude : magnitude;
|
|
1727
|
+
};
|
|
1728
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
1729
|
+
for (const tx of txs) {
|
|
1730
|
+
const perGroup = /* @__PURE__ */ new Map();
|
|
1731
|
+
for (const r of preparedResolvers) {
|
|
1732
|
+
let ms;
|
|
1733
|
+
try {
|
|
1734
|
+
ms = r.resolve(tx);
|
|
1735
|
+
} catch {
|
|
1736
|
+
ms = void 0;
|
|
1737
|
+
}
|
|
1738
|
+
for (const m of ms ?? []) {
|
|
1739
|
+
if (!m.groupId) continue;
|
|
1740
|
+
if (m.amount !== void 0 && !Number.isFinite(m.amount)) continue;
|
|
1741
|
+
const existing = perGroup.get(m.groupId);
|
|
1742
|
+
perGroup.set(m.groupId, existing ? merge(existing, m) : { ...m });
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
if (perGroup.size === 0) {
|
|
1746
|
+
const id = keyOf(tx);
|
|
1747
|
+
const b = buckets.get(id) ?? { members: [] };
|
|
1748
|
+
b.members.push({ tx, amount: signedAmount(tx) });
|
|
1749
|
+
buckets.set(id, b);
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
for (const m of perGroup.values()) {
|
|
1753
|
+
const b = buckets.get(m.groupId) ?? { members: [] };
|
|
1754
|
+
b.intent = {
|
|
1755
|
+
label: b.intent?.label ?? m.label,
|
|
1756
|
+
kind: b.intent?.kind ?? m.kind,
|
|
1757
|
+
metadata: { ...m.metadata, ...b.intent?.metadata }
|
|
1758
|
+
};
|
|
1759
|
+
b.members.push({ tx, amount: signedAmount(tx, m.amount ?? tx.amount) });
|
|
1760
|
+
buckets.set(m.groupId, b);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
const netAmount = (members) => {
|
|
1764
|
+
const sentKeys = new Set(members.filter((x) => isSent(x.tx)).map((x) => keyOf(x.tx)));
|
|
1765
|
+
return members.reduce((s, x) => {
|
|
1766
|
+
if (!isSent(x.tx) && sentKeys.has(keyOf(x.tx))) return s;
|
|
1767
|
+
return s + x.amount;
|
|
1768
|
+
}, 0);
|
|
1769
|
+
};
|
|
1770
|
+
const latest = (a) => a.txs[a.txs.length - 1].createdAt;
|
|
1771
|
+
return [...buckets.entries()].map(([id, b]) => {
|
|
1772
|
+
const members = [...b.members].sort((x, y) => x.tx.createdAt - y.tx.createdAt);
|
|
1773
|
+
return {
|
|
1774
|
+
id,
|
|
1775
|
+
intent: b.intent,
|
|
1776
|
+
txs: members.map((x) => x.tx),
|
|
1777
|
+
amount: netAmount(members),
|
|
1778
|
+
createdAt: members[0].tx.createdAt,
|
|
1779
|
+
settled: members.every((x) => x.tx.settled)
|
|
1780
|
+
};
|
|
1781
|
+
}).sort((a, c) => latest(c) - latest(a));
|
|
1782
|
+
}
|
|
1783
|
+
var ActivityRegistry = class {
|
|
1784
|
+
resolvers = /* @__PURE__ */ new Map();
|
|
1785
|
+
/** Add a resolver, or override an existing one with the same id (kept in place). */
|
|
1786
|
+
use(resolver) {
|
|
1787
|
+
this.resolvers.set(resolver.id, resolver);
|
|
1788
|
+
}
|
|
1789
|
+
/** Remove a resolver (built-in or custom) by id. */
|
|
1790
|
+
remove(id) {
|
|
1791
|
+
this.resolvers.delete(id);
|
|
1792
|
+
}
|
|
1793
|
+
/** The registered resolver ids, in registration order. */
|
|
1794
|
+
list() {
|
|
1795
|
+
return [...this.resolvers.keys()];
|
|
1796
|
+
}
|
|
1797
|
+
/** All registered resolvers, in registration (priority) order. */
|
|
1798
|
+
all() {
|
|
1799
|
+
return [...this.resolvers.values()];
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
function boardingResolver() {
|
|
1803
|
+
return {
|
|
1804
|
+
id: "boarding",
|
|
1805
|
+
resolve(tx) {
|
|
1806
|
+
if (!tx.key.boardingTxid) return void 0;
|
|
1807
|
+
return [
|
|
1808
|
+
{ groupId: `boarding:${tx.key.boardingTxid}`, label: "Deposit", kind: "boarding" }
|
|
1809
|
+
];
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
1813
|
+
function createDefaultActivityRegistry() {
|
|
1814
|
+
const registry = new ActivityRegistry();
|
|
1815
|
+
registry.use(boardingResolver());
|
|
1816
|
+
return registry;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1701
1819
|
// src/wallet/index.ts
|
|
1702
1820
|
var TxType = /* @__PURE__ */ ((TxType2) => {
|
|
1703
1821
|
TxType2["TxSent"] = "SENT";
|
|
@@ -1730,7 +1848,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1730
1848
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
1731
1849
|
inputsByAssetId.set(asset.assetId, [
|
|
1732
1850
|
...existing ?? [],
|
|
1733
|
-
|
|
1851
|
+
chunkALISWEQ5_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
1734
1852
|
]);
|
|
1735
1853
|
}
|
|
1736
1854
|
}
|
|
@@ -1742,7 +1860,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1742
1860
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
1743
1861
|
outputsByAssetId.set(asset.assetId, [
|
|
1744
1862
|
...existing ?? [],
|
|
1745
|
-
|
|
1863
|
+
chunkALISWEQ5_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
1746
1864
|
]);
|
|
1747
1865
|
}
|
|
1748
1866
|
}
|
|
@@ -1753,7 +1871,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1753
1871
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
1754
1872
|
outputsByAssetId.set(asset.assetId, [
|
|
1755
1873
|
...existing ?? [],
|
|
1756
|
-
|
|
1874
|
+
chunkALISWEQ5_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
1757
1875
|
]);
|
|
1758
1876
|
}
|
|
1759
1877
|
}
|
|
@@ -1762,11 +1880,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1762
1880
|
for (const assetIdStr of allAssetIds) {
|
|
1763
1881
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
1764
1882
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
1765
|
-
const assetId =
|
|
1766
|
-
const group =
|
|
1883
|
+
const assetId = chunkALISWEQ5_cjs.AssetId.fromString(assetIdStr);
|
|
1884
|
+
const group = chunkALISWEQ5_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
1767
1885
|
groups.push(group);
|
|
1768
1886
|
}
|
|
1769
|
-
return
|
|
1887
|
+
return chunkALISWEQ5_cjs.Packet.create(groups);
|
|
1770
1888
|
}
|
|
1771
1889
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
1772
1890
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -1871,8 +1989,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
1871
1989
|
function buildVirtualTx(inputs, outputs) {
|
|
1872
1990
|
let lockTime = 0n;
|
|
1873
1991
|
for (const input of inputs) {
|
|
1874
|
-
const tapscript =
|
|
1875
|
-
if (
|
|
1992
|
+
const tapscript = chunkHXDZ2QTW_cjs.decodeTapscript(chunkHXDZ2QTW_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
1993
|
+
if (chunkHXDZ2QTW_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
1876
1994
|
if (lockTime !== 0n) {
|
|
1877
1995
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
1878
1996
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -1883,7 +2001,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
1883
2001
|
}
|
|
1884
2002
|
}
|
|
1885
2003
|
}
|
|
1886
|
-
const tx = new
|
|
2004
|
+
const tx = new chunkALISWEQ5_cjs.Transaction({
|
|
1887
2005
|
version: 3,
|
|
1888
2006
|
lockTime: Number(lockTime)
|
|
1889
2007
|
});
|
|
@@ -1893,12 +2011,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
1893
2011
|
index: input.vout,
|
|
1894
2012
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
1895
2013
|
witnessUtxo: {
|
|
1896
|
-
script:
|
|
2014
|
+
script: chunkHXDZ2QTW_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
1897
2015
|
amount: BigInt(input.value)
|
|
1898
2016
|
},
|
|
1899
2017
|
tapLeafScript: [input.tapLeafScript]
|
|
1900
2018
|
});
|
|
1901
|
-
|
|
2019
|
+
chunkALISWEQ5_cjs.setArkPsbtField(tx, i, chunkALISWEQ5_cjs.VtxoTaprootTree, input.tapTree);
|
|
1902
2020
|
}
|
|
1903
2021
|
for (const output of outputs) {
|
|
1904
2022
|
tx.addOutput(output);
|
|
@@ -1907,8 +2025,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
1907
2025
|
return tx;
|
|
1908
2026
|
}
|
|
1909
2027
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
1910
|
-
const collaborativeClosure =
|
|
1911
|
-
const checkpointVtxoScript = new
|
|
2028
|
+
const collaborativeClosure = chunkHXDZ2QTW_cjs.decodeTapscript(chunkHXDZ2QTW_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
2029
|
+
const checkpointVtxoScript = new chunkHXDZ2QTW_cjs.VtxoScript([
|
|
1912
2030
|
serverUnrollScript.script,
|
|
1913
2031
|
collaborativeClosure.script
|
|
1914
2032
|
]);
|
|
@@ -2052,7 +2170,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
2052
2170
|
}
|
|
2053
2171
|
function isValidArkAddress(address) {
|
|
2054
2172
|
try {
|
|
2055
|
-
|
|
2173
|
+
chunkHXDZ2QTW_cjs.ArkAddress.decode(address);
|
|
2056
2174
|
return true;
|
|
2057
2175
|
} catch (e) {
|
|
2058
2176
|
return false;
|
|
@@ -2269,7 +2387,7 @@ var Estimator = class {
|
|
|
2269
2387
|
* @param onchainOutputs - Array of onchain outputs to evaluate
|
|
2270
2388
|
* @returns The total fee amount
|
|
2271
2389
|
*/
|
|
2272
|
-
|
|
2390
|
+
evaluate(offchainInputs, onchainInputs, offchainOutputs, onchainOutputs) {
|
|
2273
2391
|
let fee = FeeAmount.ZERO;
|
|
2274
2392
|
for (const input of offchainInputs) {
|
|
2275
2393
|
fee = fee.add(this.evalOffchainInput(input));
|
|
@@ -2331,7 +2449,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
2331
2449
|
};
|
|
2332
2450
|
}
|
|
2333
2451
|
function deriveContractTapscripts(contract) {
|
|
2334
|
-
const handler =
|
|
2452
|
+
const handler = chunk32YKLQPS_cjs.contractHandlers.get(contract.type);
|
|
2335
2453
|
if (!handler) {
|
|
2336
2454
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
2337
2455
|
}
|
|
@@ -2401,7 +2519,7 @@ function validateRecipients(recipients, dustAmount) {
|
|
|
2401
2519
|
for (const recipient of recipients) {
|
|
2402
2520
|
let address;
|
|
2403
2521
|
try {
|
|
2404
|
-
address =
|
|
2522
|
+
address = chunkHXDZ2QTW_cjs.ArkAddress.decode(recipient.address);
|
|
2405
2523
|
} catch (e) {
|
|
2406
2524
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
2407
2525
|
}
|
|
@@ -3006,11 +3124,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3006
3124
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
3007
3125
|
);
|
|
3008
3126
|
}
|
|
3009
|
-
const tx = new
|
|
3127
|
+
const tx = new chunkALISWEQ5_cjs.Transaction();
|
|
3010
3128
|
for (const utxo of expiredUtxos) {
|
|
3011
|
-
const utxoScript =
|
|
3129
|
+
const utxoScript = chunkHXDZ2QTW_cjs.VtxoScript.decode(utxo.tapTree);
|
|
3012
3130
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
3013
|
-
(leaf) =>
|
|
3131
|
+
(leaf) => chunkHXDZ2QTW_cjs.CSVMultisigTapscript.isScriptValid(chunkHXDZ2QTW_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
3014
3132
|
);
|
|
3015
3133
|
if (!utxoExitLeaf) {
|
|
3016
3134
|
throw new Error(
|
|
@@ -3025,7 +3143,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3025
3143
|
amount: BigInt(utxo.value)
|
|
3026
3144
|
},
|
|
3027
3145
|
tapLeafScript: [utxoExitLeaf],
|
|
3028
|
-
sequence:
|
|
3146
|
+
sequence: chunkHXDZ2QTW_cjs.getSequence(utxoExitLeaf)
|
|
3029
3147
|
});
|
|
3030
3148
|
}
|
|
3031
3149
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -3513,7 +3631,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3513
3631
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
3514
3632
|
getBoardingTimelock() {
|
|
3515
3633
|
const wallet = this.getSweepWallet();
|
|
3516
|
-
const exitScript =
|
|
3634
|
+
const exitScript = chunkHXDZ2QTW_cjs.CSVMultisigTapscript.decode(
|
|
3517
3635
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
3518
3636
|
);
|
|
3519
3637
|
return exitScript.params.timelock;
|
|
@@ -3644,7 +3762,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3644
3762
|
* or doesn't carry the metadata.
|
|
3645
3763
|
*/
|
|
3646
3764
|
extractSpentOutpoint(error) {
|
|
3647
|
-
const ark =
|
|
3765
|
+
const ark = chunkALISWEQ5_cjs.maybeArkError(error);
|
|
3648
3766
|
if (!ark || ark.name !== "VTXO_ALREADY_SPENT") return void 0;
|
|
3649
3767
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
3650
3768
|
if (typeof raw !== "string") return void 0;
|
|
@@ -3859,7 +3977,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3859
3977
|
const arkAddress = await this.wallet.getAddress();
|
|
3860
3978
|
const outputFee = estimator.evalOffchainOutput({
|
|
3861
3979
|
amount: totalAmount,
|
|
3862
|
-
script: base.hex.encode(
|
|
3980
|
+
script: base.hex.encode(chunkHXDZ2QTW_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
3863
3981
|
});
|
|
3864
3982
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
3865
3983
|
if (totalAmount < dustAmount) return;
|
|
@@ -3939,7 +4057,7 @@ var ArkNote = class _ArkNote {
|
|
|
3939
4057
|
this.value = value;
|
|
3940
4058
|
this.HRP = HRP;
|
|
3941
4059
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
3942
|
-
this.vtxoScript = new
|
|
4060
|
+
this.vtxoScript = new chunkHXDZ2QTW_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
3943
4061
|
const leaf = this.vtxoScript.leaves[0];
|
|
3944
4062
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
3945
4063
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -4555,7 +4673,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4555
4673
|
const virtualCoins = await this.wallet.getVtxos({
|
|
4556
4674
|
withRecoverable: false
|
|
4557
4675
|
});
|
|
4558
|
-
const controlAssetRef = params.controlAssetId ?
|
|
4676
|
+
const controlAssetRef = params.controlAssetId ? chunkALISWEQ5_cjs.AssetRef.fromId(chunkALISWEQ5_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
4559
4677
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
4560
4678
|
let totalBtcSelected = 0n;
|
|
4561
4679
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -4568,8 +4686,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4568
4686
|
}
|
|
4569
4687
|
}
|
|
4570
4688
|
const groups = [];
|
|
4571
|
-
const issuedAssetOutput =
|
|
4572
|
-
const issuedAssetGroup =
|
|
4689
|
+
const issuedAssetOutput = chunkALISWEQ5_cjs.AssetOutput.create(0, params.amount);
|
|
4690
|
+
const issuedAssetGroup = chunkALISWEQ5_cjs.AssetGroup.create(
|
|
4573
4691
|
null,
|
|
4574
4692
|
controlAssetRef,
|
|
4575
4693
|
[],
|
|
@@ -4584,28 +4702,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4584
4702
|
for (const [inputIndex, assets] of assetInputs) {
|
|
4585
4703
|
for (const asset of assets) {
|
|
4586
4704
|
if (asset.assetId !== assetId) continue;
|
|
4587
|
-
changeInputs.push(
|
|
4705
|
+
changeInputs.push(chunkALISWEQ5_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
4588
4706
|
}
|
|
4589
4707
|
}
|
|
4590
4708
|
groups.push(
|
|
4591
|
-
|
|
4592
|
-
|
|
4709
|
+
chunkALISWEQ5_cjs.AssetGroup.create(
|
|
4710
|
+
chunkALISWEQ5_cjs.AssetId.fromString(assetId),
|
|
4593
4711
|
null,
|
|
4594
4712
|
changeInputs,
|
|
4595
|
-
[
|
|
4713
|
+
[chunkALISWEQ5_cjs.AssetOutput.create(0, amount)],
|
|
4596
4714
|
[]
|
|
4597
4715
|
)
|
|
4598
4716
|
);
|
|
4599
4717
|
}
|
|
4600
4718
|
}
|
|
4601
4719
|
const address = await this.wallet.getAddress();
|
|
4602
|
-
const outputAddress =
|
|
4720
|
+
const outputAddress = chunkHXDZ2QTW_cjs.ArkAddress.decode(address);
|
|
4603
4721
|
const outputs = [
|
|
4604
4722
|
{
|
|
4605
4723
|
script: outputAddress.pkScript,
|
|
4606
4724
|
amount: BigInt(totalBtcSelected)
|
|
4607
4725
|
},
|
|
4608
|
-
Extension.create([
|
|
4726
|
+
Extension.create([chunkALISWEQ5_cjs.Packet.create(groups)]).txOut()
|
|
4609
4727
|
];
|
|
4610
4728
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
4611
4729
|
coinSelection.inputs,
|
|
@@ -4613,7 +4731,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4613
4731
|
);
|
|
4614
4732
|
return {
|
|
4615
4733
|
arkTxId: arkTxid,
|
|
4616
|
-
assetId:
|
|
4734
|
+
assetId: chunkALISWEQ5_cjs.AssetId.create(arkTxid, 0).toString()
|
|
4617
4735
|
};
|
|
4618
4736
|
}
|
|
4619
4737
|
/**
|
|
@@ -4685,16 +4803,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4685
4803
|
for (const [inputIndex, assets] of assetInputs) {
|
|
4686
4804
|
for (const asset of assets) {
|
|
4687
4805
|
if (asset.assetId !== params.assetId) continue;
|
|
4688
|
-
reissueInputs.push(
|
|
4806
|
+
reissueInputs.push(chunkALISWEQ5_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
4689
4807
|
}
|
|
4690
4808
|
}
|
|
4691
4809
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
4692
|
-
const reissueAssetIdObj =
|
|
4693
|
-
const reissueAssetGroup =
|
|
4810
|
+
const reissueAssetIdObj = chunkALISWEQ5_cjs.AssetId.fromString(params.assetId);
|
|
4811
|
+
const reissueAssetGroup = chunkALISWEQ5_cjs.AssetGroup.create(
|
|
4694
4812
|
reissueAssetIdObj,
|
|
4695
4813
|
null,
|
|
4696
4814
|
reissueInputs,
|
|
4697
|
-
[
|
|
4815
|
+
[chunkALISWEQ5_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
4698
4816
|
[]
|
|
4699
4817
|
);
|
|
4700
4818
|
const groups = [reissueAssetGroup];
|
|
@@ -4703,27 +4821,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4703
4821
|
for (const [inputIndex, assets] of assetInputs) {
|
|
4704
4822
|
for (const asset of assets) {
|
|
4705
4823
|
if (asset.assetId !== assetId) continue;
|
|
4706
|
-
changeInputs.push(
|
|
4824
|
+
changeInputs.push(chunkALISWEQ5_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
4707
4825
|
}
|
|
4708
4826
|
}
|
|
4709
4827
|
groups.push(
|
|
4710
|
-
|
|
4711
|
-
|
|
4828
|
+
chunkALISWEQ5_cjs.AssetGroup.create(
|
|
4829
|
+
chunkALISWEQ5_cjs.AssetId.fromString(assetId),
|
|
4712
4830
|
null,
|
|
4713
4831
|
changeInputs,
|
|
4714
|
-
[
|
|
4832
|
+
[chunkALISWEQ5_cjs.AssetOutput.create(0, amount)],
|
|
4715
4833
|
[]
|
|
4716
4834
|
)
|
|
4717
4835
|
);
|
|
4718
4836
|
}
|
|
4719
4837
|
const address = await this.wallet.getAddress();
|
|
4720
|
-
const outputAddress =
|
|
4838
|
+
const outputAddress = chunkHXDZ2QTW_cjs.ArkAddress.decode(address);
|
|
4721
4839
|
const outputs = [
|
|
4722
4840
|
{
|
|
4723
4841
|
script: outputAddress.pkScript,
|
|
4724
4842
|
amount: BigInt(totalBtcSelected)
|
|
4725
4843
|
},
|
|
4726
|
-
Extension.create([
|
|
4844
|
+
Extension.create([chunkALISWEQ5_cjs.Packet.create(groups)]).txOut()
|
|
4727
4845
|
];
|
|
4728
4846
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
4729
4847
|
return arkTxid;
|
|
@@ -4790,27 +4908,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4790
4908
|
for (const [inputIndex, assets] of assetInputs) {
|
|
4791
4909
|
for (const asset of assets) {
|
|
4792
4910
|
if (asset.assetId !== assetId) continue;
|
|
4793
|
-
changeInputs.push(
|
|
4911
|
+
changeInputs.push(chunkALISWEQ5_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
4794
4912
|
}
|
|
4795
4913
|
}
|
|
4796
4914
|
groups.push(
|
|
4797
|
-
|
|
4798
|
-
|
|
4915
|
+
chunkALISWEQ5_cjs.AssetGroup.create(
|
|
4916
|
+
chunkALISWEQ5_cjs.AssetId.fromString(assetId),
|
|
4799
4917
|
null,
|
|
4800
4918
|
changeInputs,
|
|
4801
|
-
amount > 0n ? [
|
|
4919
|
+
amount > 0n ? [chunkALISWEQ5_cjs.AssetOutput.create(0, amount)] : [],
|
|
4802
4920
|
[]
|
|
4803
4921
|
)
|
|
4804
4922
|
);
|
|
4805
4923
|
}
|
|
4806
4924
|
const address = await this.wallet.getAddress();
|
|
4807
|
-
const outputAddress =
|
|
4925
|
+
const outputAddress = chunkHXDZ2QTW_cjs.ArkAddress.decode(address);
|
|
4808
4926
|
const outputs = [
|
|
4809
4927
|
{
|
|
4810
4928
|
script: outputAddress.pkScript,
|
|
4811
4929
|
amount: BigInt(totalBtcSelected)
|
|
4812
4930
|
},
|
|
4813
|
-
Extension.create([
|
|
4931
|
+
Extension.create([chunkALISWEQ5_cjs.Packet.create(groups)]).txOut()
|
|
4814
4932
|
];
|
|
4815
4933
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
4816
4934
|
return arkTxid;
|
|
@@ -4835,7 +4953,7 @@ function castMetadata(metadata) {
|
|
|
4835
4953
|
} else {
|
|
4836
4954
|
throw new Error("Invalid metadata value type");
|
|
4837
4955
|
}
|
|
4838
|
-
md.push(
|
|
4956
|
+
md.push(chunkALISWEQ5_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
4839
4957
|
}
|
|
4840
4958
|
return md;
|
|
4841
4959
|
}
|
|
@@ -4853,7 +4971,7 @@ var DelegateManagerImpl = class {
|
|
|
4853
4971
|
if (vtxos.length === 0) {
|
|
4854
4972
|
return { delegated: [], failed: [] };
|
|
4855
4973
|
}
|
|
4856
|
-
const destinationScript =
|
|
4974
|
+
const destinationScript = chunkHXDZ2QTW_cjs.ArkAddress.decode(destination).pkScript;
|
|
4857
4975
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
4858
4976
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
4859
4977
|
const eligible = vtxos.filter(
|
|
@@ -5001,7 +5119,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
5001
5119
|
const delegateFee = BigInt(Number(fee));
|
|
5002
5120
|
if (delegateFee > 0n) {
|
|
5003
5121
|
outputs.push({
|
|
5004
|
-
script:
|
|
5122
|
+
script: chunkHXDZ2QTW_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
5005
5123
|
amount: delegateFee
|
|
5006
5124
|
});
|
|
5007
5125
|
}
|
|
@@ -5034,7 +5152,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
5034
5152
|
destinationScript
|
|
5035
5153
|
);
|
|
5036
5154
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
5037
|
-
btcSigner.Address(
|
|
5155
|
+
btcSigner.Address(chunkHXDZ2QTW_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
5038
5156
|
);
|
|
5039
5157
|
const forfeits = await Promise.all(
|
|
5040
5158
|
vtxos.filter((v) => !isRecoverable(v)).map(async (coin) => {
|
|
@@ -5062,7 +5180,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
5062
5180
|
index: input.vout,
|
|
5063
5181
|
witnessUtxo: {
|
|
5064
5182
|
amount: BigInt(input.value),
|
|
5065
|
-
script:
|
|
5183
|
+
script: chunkHXDZ2QTW_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
5066
5184
|
},
|
|
5067
5185
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
5068
5186
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -5120,7 +5238,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
5120
5238
|
expire_at: 0,
|
|
5121
5239
|
cosigners_public_keys: cosignerPubKeys
|
|
5122
5240
|
};
|
|
5123
|
-
const proof =
|
|
5241
|
+
const proof = chunkALISWEQ5_cjs.Intent.create(message, coins, outputs);
|
|
5124
5242
|
const signedProof = await identity.sign(proof);
|
|
5125
5243
|
return {
|
|
5126
5244
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -5138,10 +5256,10 @@ function getDayTimestamp(timestamp) {
|
|
|
5138
5256
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
5139
5257
|
if (!vtxo.tapTree) return void 0;
|
|
5140
5258
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
5141
|
-
const vtxoScript =
|
|
5259
|
+
const vtxoScript = chunkHXDZ2QTW_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
5142
5260
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
5143
|
-
const arkTapscript =
|
|
5144
|
-
if (!
|
|
5261
|
+
const arkTapscript = chunkHXDZ2QTW_cjs.decodeTapscript(chunkHXDZ2QTW_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
5262
|
+
if (!chunkHXDZ2QTW_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
5145
5263
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
5146
5264
|
});
|
|
5147
5265
|
}
|
|
@@ -5345,7 +5463,7 @@ var InMemoryContractRepository = class {
|
|
|
5345
5463
|
}
|
|
5346
5464
|
};
|
|
5347
5465
|
function scriptFromArkAddress(address) {
|
|
5348
|
-
return base.hex.encode(
|
|
5466
|
+
return base.hex.encode(chunkHXDZ2QTW_cjs.ArkAddress.decode(address).pkScript);
|
|
5349
5467
|
}
|
|
5350
5468
|
|
|
5351
5469
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -5625,7 +5743,13 @@ async function openDatabase(dbName, dbVersion, initDatabase2) {
|
|
|
5625
5743
|
reject(request.error);
|
|
5626
5744
|
};
|
|
5627
5745
|
request.onsuccess = () => {
|
|
5628
|
-
|
|
5746
|
+
const db = request.result;
|
|
5747
|
+
db.onversionchange = () => {
|
|
5748
|
+
db.close();
|
|
5749
|
+
dbCache.delete(dbName);
|
|
5750
|
+
refCounts.delete(dbName);
|
|
5751
|
+
};
|
|
5752
|
+
resolve(db);
|
|
5629
5753
|
};
|
|
5630
5754
|
request.onupgradeneeded = (event) => {
|
|
5631
5755
|
const db = request.result;
|
|
@@ -6863,7 +6987,7 @@ var ContractWatcher = class {
|
|
|
6863
6987
|
this.connectionState = "connected";
|
|
6864
6988
|
this.reconnectAttempts = 0;
|
|
6865
6989
|
this.listenLoop().catch((e) => {
|
|
6866
|
-
if (
|
|
6990
|
+
if (chunkALISWEQ5_cjs.isEventSourceError(e)) {
|
|
6867
6991
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
6868
6992
|
} else {
|
|
6869
6993
|
console.error(e);
|
|
@@ -7307,7 +7431,7 @@ var ContractManager = class _ContractManager {
|
|
|
7307
7431
|
* `persisted` is `true`.
|
|
7308
7432
|
*/
|
|
7309
7433
|
async upsertContract(params) {
|
|
7310
|
-
const handler =
|
|
7434
|
+
const handler = chunk32YKLQPS_cjs.contractHandlers.get(params.type);
|
|
7311
7435
|
if (!handler) {
|
|
7312
7436
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
7313
7437
|
}
|
|
@@ -7390,7 +7514,7 @@ var ContractManager = class _ContractManager {
|
|
|
7390
7514
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
7391
7515
|
);
|
|
7392
7516
|
}
|
|
7393
|
-
const registered =
|
|
7517
|
+
const registered = chunk32YKLQPS_cjs.contractHandlers.getRegisteredTypes().map((t) => chunk32YKLQPS_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
7394
7518
|
const discoverables = [
|
|
7395
7519
|
...registered.filter((h) => h.type === "boarding"),
|
|
7396
7520
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -7574,7 +7698,7 @@ var ContractManager = class _ContractManager {
|
|
|
7574
7698
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
7575
7699
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
7576
7700
|
if (!contract) return [];
|
|
7577
|
-
const handler =
|
|
7701
|
+
const handler = chunk32YKLQPS_cjs.contractHandlers.get(contract.type);
|
|
7578
7702
|
if (!handler) return [];
|
|
7579
7703
|
const script = handler.createScript(contract.params);
|
|
7580
7704
|
const context = {
|
|
@@ -7594,7 +7718,7 @@ var ContractManager = class _ContractManager {
|
|
|
7594
7718
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
7595
7719
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
7596
7720
|
if (!contract) return [];
|
|
7597
|
-
const handler =
|
|
7721
|
+
const handler = chunk32YKLQPS_cjs.contractHandlers.get(contract.type);
|
|
7598
7722
|
if (!handler) return [];
|
|
7599
7723
|
const script = handler.createScript(contract.params);
|
|
7600
7724
|
const context = {
|
|
@@ -7828,7 +7952,7 @@ var ContractManager = class _ContractManager {
|
|
|
7828
7952
|
}
|
|
7829
7953
|
return result;
|
|
7830
7954
|
}
|
|
7831
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
7955
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunk32YKLQPS_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
7832
7956
|
if (contracts.length === 0) {
|
|
7833
7957
|
return /* @__PURE__ */ new Map();
|
|
7834
7958
|
}
|
|
@@ -8004,7 +8128,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
8004
8128
|
*/
|
|
8005
8129
|
materializeDescriptorAt(index) {
|
|
8006
8130
|
const descriptor = this.identity.descriptor;
|
|
8007
|
-
const network =
|
|
8131
|
+
const network = chunk32YKLQPS_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
8008
8132
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
8009
8133
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
8010
8134
|
if (!keyInfo?.keyExpression) {
|
|
@@ -8147,7 +8271,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
8147
8271
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
8148
8272
|
if (!provider) return void 0;
|
|
8149
8273
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
8150
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
8274
|
+
const expectedContractType = setup.offchainTapscript instanceof chunk32YKLQPS_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
8151
8275
|
const factoryOpts = {
|
|
8152
8276
|
walletRepository: setup.walletRepository,
|
|
8153
8277
|
contractRepository: setup.contractRepository,
|
|
@@ -8330,7 +8454,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
8330
8454
|
const newAddress = newTapscript.address(wallet.network.hrp, wallet.arkServerPublicKey).encode();
|
|
8331
8455
|
const manager = await wallet.getContractManager();
|
|
8332
8456
|
const csvTimelock = newTapscript.options.csvTimelock;
|
|
8333
|
-
const csvTimelockStr =
|
|
8457
|
+
const csvTimelockStr = chunkHXDZ2QTW_cjs.timelockToSequence(csvTimelock).toString();
|
|
8334
8458
|
const serverPubKeyHex = base.hex.encode(newTapscript.options.serverPubKey);
|
|
8335
8459
|
const baseParams = {
|
|
8336
8460
|
script: newScript,
|
|
@@ -8344,11 +8468,11 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
8344
8468
|
// produce unsigned PSBTs that the server rejects with
|
|
8345
8469
|
// `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
8346
8470
|
metadata: {
|
|
8347
|
-
source:
|
|
8471
|
+
source: chunk32YKLQPS_cjs.WALLET_RECEIVE_SOURCE,
|
|
8348
8472
|
signingDescriptor: descriptor
|
|
8349
8473
|
}
|
|
8350
8474
|
};
|
|
8351
|
-
if (newTapscript instanceof
|
|
8475
|
+
if (newTapscript instanceof chunk32YKLQPS_cjs.DelegateVtxo.Script) {
|
|
8352
8476
|
await manager.createContract({
|
|
8353
8477
|
...baseParams,
|
|
8354
8478
|
type: "delegate",
|
|
@@ -8380,7 +8504,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
8380
8504
|
};
|
|
8381
8505
|
function deriveLeafPubkey(descriptor) {
|
|
8382
8506
|
try {
|
|
8383
|
-
return
|
|
8507
|
+
return chunk32YKLQPS_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
8384
8508
|
} catch (e) {
|
|
8385
8509
|
throw new NonRangeableDescriptorError(
|
|
8386
8510
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -8389,10 +8513,10 @@ function deriveLeafPubkey(descriptor) {
|
|
|
8389
8513
|
}
|
|
8390
8514
|
}
|
|
8391
8515
|
function rebuildTapscript(current, pubKey) {
|
|
8392
|
-
if (current instanceof
|
|
8393
|
-
return new
|
|
8516
|
+
if (current instanceof chunk32YKLQPS_cjs.DelegateVtxo.Script) {
|
|
8517
|
+
return new chunk32YKLQPS_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
8394
8518
|
}
|
|
8395
|
-
return new
|
|
8519
|
+
return new chunk32YKLQPS_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
8396
8520
|
}
|
|
8397
8521
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
8398
8522
|
const candidates = await contractRepository.getContracts({
|
|
@@ -8401,7 +8525,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
8401
8525
|
});
|
|
8402
8526
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
8403
8527
|
const matching = candidates.filter(
|
|
8404
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
8528
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunk32YKLQPS_cjs.WALLET_RECEIVE_SOURCE
|
|
8405
8529
|
).sort((a, b) => {
|
|
8406
8530
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
8407
8531
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -8574,12 +8698,12 @@ var InputSignerRouter = class {
|
|
|
8574
8698
|
};
|
|
8575
8699
|
|
|
8576
8700
|
// src/wallet/wallet.ts
|
|
8577
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
8701
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkHXDZ2QTW_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
8578
8702
|
function intentProofJobs(coins) {
|
|
8579
8703
|
if (coins.length === 0) return [];
|
|
8580
8704
|
const coinJobs = coins.map((coin, i) => ({
|
|
8581
8705
|
index: i + 1,
|
|
8582
|
-
lookupScript:
|
|
8706
|
+
lookupScript: chunkHXDZ2QTW_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
8583
8707
|
}));
|
|
8584
8708
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
8585
8709
|
}
|
|
@@ -8603,7 +8727,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
8603
8727
|
const seen = /* @__PURE__ */ new Set();
|
|
8604
8728
|
const deduped = [];
|
|
8605
8729
|
for (const timelock of timelocks) {
|
|
8606
|
-
const sequence =
|
|
8730
|
+
const sequence = chunkHXDZ2QTW_cjs.timelockToSequence(timelock).toString();
|
|
8607
8731
|
if (seen.has(sequence)) continue;
|
|
8608
8732
|
seen.add(sequence);
|
|
8609
8733
|
deduped.push(timelock);
|
|
@@ -8620,7 +8744,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
8620
8744
|
state: "active"
|
|
8621
8745
|
});
|
|
8622
8746
|
const newest = candidates.filter(
|
|
8623
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
8747
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunk32YKLQPS_cjs.WALLET_RECEIVE_SOURCE
|
|
8624
8748
|
).sort((a, b) => {
|
|
8625
8749
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
8626
8750
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -8628,7 +8752,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
8628
8752
|
if (!newest?.params.pubKey) return baseline;
|
|
8629
8753
|
try {
|
|
8630
8754
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
8631
|
-
return new
|
|
8755
|
+
return new chunk32YKLQPS_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
8632
8756
|
} catch (e) {
|
|
8633
8757
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
8634
8758
|
return baseline;
|
|
@@ -8675,6 +8799,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8675
8799
|
// already on their way out. The set is in-memory only: a process crash
|
|
8676
8800
|
// clears it, and a stale entry only hides a VTXO (never spends one).
|
|
8677
8801
|
_pendingSpendOutpoints = /* @__PURE__ */ new Set();
|
|
8802
|
+
/** Activity resolvers consumed by {@link getActivityHistory}. */
|
|
8803
|
+
activity = createDefaultActivityRegistry();
|
|
8678
8804
|
get assetManager() {
|
|
8679
8805
|
return this._assetManager;
|
|
8680
8806
|
}
|
|
@@ -8819,7 +8945,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8819
8945
|
*/
|
|
8820
8946
|
static async setupWalletConfig(config, pubKey) {
|
|
8821
8947
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
8822
|
-
const arkProvider = config.arkProvider || new
|
|
8948
|
+
const arkProvider = config.arkProvider || new chunkALISWEQ5_cjs.RestArkProvider(arkadeServerUrl);
|
|
8823
8949
|
let indexerProvider = config.indexerProvider;
|
|
8824
8950
|
if (!indexerProvider) {
|
|
8825
8951
|
let indexerUrl = config.indexerUrl;
|
|
@@ -8836,10 +8962,10 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8836
8962
|
indexerUrl = arkadeServerUrl;
|
|
8837
8963
|
}
|
|
8838
8964
|
}
|
|
8839
|
-
indexerProvider = new
|
|
8965
|
+
indexerProvider = new chunkALISWEQ5_cjs.RestIndexerProvider(indexerUrl);
|
|
8840
8966
|
}
|
|
8841
8967
|
const info = await arkProvider.getInfo();
|
|
8842
|
-
const network =
|
|
8968
|
+
const network = chunkHXDZ2QTW_cjs.getNetwork(info.network);
|
|
8843
8969
|
if ("descriptor" in config.identity) {
|
|
8844
8970
|
const descriptor = config.identity.descriptor;
|
|
8845
8971
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -8880,17 +9006,17 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8880
9006
|
type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
|
|
8881
9007
|
};
|
|
8882
9008
|
const serverPubKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
8883
|
-
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;
|
|
9009
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => base.hex.decode(info2.pubkey).slice(1)).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => base.hex.decode(info2.pubkey).slice(1)).catch(() => void 0) : void 0;
|
|
8884
9010
|
const offchainOptions = {
|
|
8885
9011
|
pubKey,
|
|
8886
9012
|
serverPubKey,
|
|
8887
9013
|
csvTimelock: exitTimelock
|
|
8888
9014
|
};
|
|
8889
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
8890
|
-
const boardingTapscript =
|
|
9015
|
+
const offchainTapscript = !delegatePubKey ? new chunk32YKLQPS_cjs.DefaultVtxo.Script(offchainOptions) : new chunk32YKLQPS_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
9016
|
+
const boardingTapscript = chunk32YKLQPS_cjs.BoardingContractHandler.createScript({
|
|
8891
9017
|
pubKey: base.hex.encode(pubKey),
|
|
8892
9018
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
8893
|
-
csvTimelock:
|
|
9019
|
+
csvTimelock: chunkHXDZ2QTW_cjs.timelockToSequence(boardingTimelock).toString()
|
|
8894
9020
|
});
|
|
8895
9021
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
8896
9022
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -9071,6 +9197,13 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9071
9197
|
const getTxCreatedAt = (txid) => this.indexerProvider.getVtxos({ outpoints: [{ txid, vout: 0 }] }).then((res) => res.vtxos[0]?.createdAt.getTime());
|
|
9072
9198
|
return buildTransactionHistory(allVtxos, boardingTxs, commitmentsToIgnore, getTxCreatedAt);
|
|
9073
9199
|
}
|
|
9200
|
+
/**
|
|
9201
|
+
* Wallet history grouped by registered activity resolvers. With no resolver match,
|
|
9202
|
+
* rows bucket by transaction key so send/change pairs stay together.
|
|
9203
|
+
*/
|
|
9204
|
+
async getActivityHistory() {
|
|
9205
|
+
return buildActivities(await this.getTransactionHistory(), this.activity.all());
|
|
9206
|
+
}
|
|
9074
9207
|
/**
|
|
9075
9208
|
* Clear the global VTXO sync cursor, forcing a full re-bootstrap on next sync.
|
|
9076
9209
|
* Useful for recovery after indexer reprocessing or debugging.
|
|
@@ -9078,6 +9211,17 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9078
9211
|
async clearSyncCursor() {
|
|
9079
9212
|
await clearSyncCursor(this.walletRepository);
|
|
9080
9213
|
}
|
|
9214
|
+
/**
|
|
9215
|
+
* Wipe all locally persisted wallet data (VTXOs, UTXOs, history, sync
|
|
9216
|
+
* cursor, contracts). Create a fresh wallet instance afterward.
|
|
9217
|
+
*/
|
|
9218
|
+
async clear() {
|
|
9219
|
+
try {
|
|
9220
|
+
await this.dispose();
|
|
9221
|
+
} finally {
|
|
9222
|
+
await Promise.all([this.walletRepository.clear(), this.contractRepository.clear()]);
|
|
9223
|
+
}
|
|
9224
|
+
}
|
|
9081
9225
|
/**
|
|
9082
9226
|
* The on-chain (P2TR) addresses of every boarding tapscript this wallet
|
|
9083
9227
|
* uses — the current address plus any historical rotated boarding
|
|
@@ -9102,6 +9246,12 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9102
9246
|
const boardingAddress = tapscript.onchainAddress(this.network);
|
|
9103
9247
|
const scriptHex = base.hex.encode(tapscript.pkScript);
|
|
9104
9248
|
const txs = await this.onchainProvider.getTransactions(boardingAddress);
|
|
9249
|
+
const commitmentByOutpoint = /* @__PURE__ */ new Map();
|
|
9250
|
+
for (const tx of txs) {
|
|
9251
|
+
for (const input of tx.vin ?? []) {
|
|
9252
|
+
commitmentByOutpoint.set(`${input.txid}:${input.vout}`, tx.txid);
|
|
9253
|
+
}
|
|
9254
|
+
}
|
|
9105
9255
|
for (const tx of txs) {
|
|
9106
9256
|
for (let i = 0; i < tx.vout.length; i++) {
|
|
9107
9257
|
const vout = tx.vout[i];
|
|
@@ -9112,8 +9262,10 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9112
9262
|
outspendCache.set(tx.txid, spentStatuses);
|
|
9113
9263
|
}
|
|
9114
9264
|
const spentStatus = spentStatuses[i];
|
|
9115
|
-
|
|
9116
|
-
|
|
9265
|
+
const commitmentTxid = spentStatus?.txid || commitmentByOutpoint.get(`${tx.txid}:${i}`);
|
|
9266
|
+
const spent = Boolean(spentStatus?.spent) || commitmentTxid !== void 0;
|
|
9267
|
+
if (spent && commitmentTxid) {
|
|
9268
|
+
commitmentsToIgnore.add(commitmentTxid);
|
|
9117
9269
|
}
|
|
9118
9270
|
utxos.push({
|
|
9119
9271
|
txid: tx.txid,
|
|
@@ -9125,8 +9277,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9125
9277
|
},
|
|
9126
9278
|
isUnrolled: true,
|
|
9127
9279
|
virtualStatus: {
|
|
9128
|
-
state:
|
|
9129
|
-
commitmentTxIds:
|
|
9280
|
+
state: spent ? "spent" : "settled",
|
|
9281
|
+
commitmentTxIds: spent && commitmentTxid ? [commitmentTxid] : void 0
|
|
9130
9282
|
},
|
|
9131
9283
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
9132
9284
|
script: scriptHex
|
|
@@ -9182,9 +9334,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9182
9334
|
async getBoardingTapscripts(allowedSigners) {
|
|
9183
9335
|
const byScript = /* @__PURE__ */ new Map();
|
|
9184
9336
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
9185
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
9337
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunk32YKLQPS_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
9186
9338
|
add(
|
|
9187
|
-
new
|
|
9339
|
+
new chunk32YKLQPS_cjs.DefaultVtxo.Script({
|
|
9188
9340
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
9189
9341
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
9190
9342
|
csvTimelock: boardingCsv
|
|
@@ -9199,7 +9351,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9199
9351
|
for (const c of boardingContracts) {
|
|
9200
9352
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
9201
9353
|
try {
|
|
9202
|
-
add(
|
|
9354
|
+
add(chunk32YKLQPS_cjs.BoardingContractHandler.createScript(c.params));
|
|
9203
9355
|
} catch (e) {
|
|
9204
9356
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
9205
9357
|
}
|
|
@@ -9237,7 +9389,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9237
9389
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
9238
9390
|
// not the wallet's current boarding timelock, which a signer
|
|
9239
9391
|
// rotation may have changed.
|
|
9240
|
-
csvTimelock:
|
|
9392
|
+
csvTimelock: chunkHXDZ2QTW_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
9241
9393
|
coins: utxos
|
|
9242
9394
|
});
|
|
9243
9395
|
}
|
|
@@ -9403,7 +9555,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9403
9555
|
});
|
|
9404
9556
|
for (const contract of contracts) {
|
|
9405
9557
|
if (map.has(contract.script)) continue;
|
|
9406
|
-
const handler =
|
|
9558
|
+
const handler = chunk32YKLQPS_cjs.contractHandlers.get(contract.type);
|
|
9407
9559
|
if (handler) {
|
|
9408
9560
|
const script = handler.createScript(contract.params);
|
|
9409
9561
|
map.set(contract.script, script);
|
|
@@ -9468,7 +9620,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9468
9620
|
watcherConfig: this.watcherConfig
|
|
9469
9621
|
});
|
|
9470
9622
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
9471
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
9623
|
+
const delegatePubKey = this.offchainTapscript instanceof chunk32YKLQPS_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
9472
9624
|
const baselineSigners = [
|
|
9473
9625
|
this.offchainTapscript.options.serverPubKey,
|
|
9474
9626
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -9476,8 +9628,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9476
9628
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
9477
9629
|
for (const serverPubKey of baselineSigners) {
|
|
9478
9630
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
9479
|
-
const csvTimelockStr =
|
|
9480
|
-
const defaultScript = new
|
|
9631
|
+
const csvTimelockStr = chunkHXDZ2QTW_cjs.timelockToSequence(csvTimelock).toString();
|
|
9632
|
+
const defaultScript = new chunk32YKLQPS_cjs.DefaultVtxo.Script({
|
|
9481
9633
|
pubKey: baselinePubkey,
|
|
9482
9634
|
serverPubKey,
|
|
9483
9635
|
csvTimelock
|
|
@@ -9498,7 +9650,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9498
9650
|
});
|
|
9499
9651
|
}
|
|
9500
9652
|
if (delegatePubKey) {
|
|
9501
|
-
const delegateScript = new
|
|
9653
|
+
const delegateScript = new chunk32YKLQPS_cjs.DelegateVtxo.Script({
|
|
9502
9654
|
pubKey: baselinePubkey,
|
|
9503
9655
|
serverPubKey,
|
|
9504
9656
|
delegatePubKey,
|
|
@@ -9522,9 +9674,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9522
9674
|
}
|
|
9523
9675
|
}
|
|
9524
9676
|
}
|
|
9525
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
9677
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunk32YKLQPS_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
9526
9678
|
for (const serverPubKey of baselineSigners) {
|
|
9527
|
-
const baselineBoarding = new
|
|
9679
|
+
const baselineBoarding = new chunk32YKLQPS_cjs.DefaultVtxo.Script({
|
|
9528
9680
|
pubKey: baselinePubkey,
|
|
9529
9681
|
serverPubKey,
|
|
9530
9682
|
csvTimelock: boardingCsvTimelock
|
|
@@ -9537,7 +9689,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
9537
9689
|
params: {
|
|
9538
9690
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
9539
9691
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
9540
|
-
csvTimelock:
|
|
9692
|
+
csvTimelock: chunkHXDZ2QTW_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
9541
9693
|
},
|
|
9542
9694
|
script: boardingScriptHex,
|
|
9543
9695
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -9757,25 +9909,25 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9757
9909
|
return this.getBoardingAddress();
|
|
9758
9910
|
}
|
|
9759
9911
|
const descriptor = await provider.getNextSigningDescriptor();
|
|
9760
|
-
const pubKey =
|
|
9761
|
-
const newBoarding = new
|
|
9912
|
+
const pubKey = chunk32YKLQPS_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
9913
|
+
const newBoarding = new chunk32YKLQPS_cjs.DefaultVtxo.Script({
|
|
9762
9914
|
...this._boardingTapscript.options,
|
|
9763
9915
|
pubKey
|
|
9764
9916
|
});
|
|
9765
|
-
const csvTimelock = newBoarding.options.csvTimelock ??
|
|
9917
|
+
const csvTimelock = newBoarding.options.csvTimelock ?? chunk32YKLQPS_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
9766
9918
|
const manager = await this.getContractManager();
|
|
9767
9919
|
await manager.createContract({
|
|
9768
9920
|
type: "boarding",
|
|
9769
9921
|
params: {
|
|
9770
9922
|
pubKey: base.hex.encode(pubKey),
|
|
9771
9923
|
serverPubKey: base.hex.encode(newBoarding.options.serverPubKey),
|
|
9772
|
-
csvTimelock:
|
|
9924
|
+
csvTimelock: chunkHXDZ2QTW_cjs.timelockToSequence(csvTimelock).toString()
|
|
9773
9925
|
},
|
|
9774
9926
|
script: base.hex.encode(newBoarding.pkScript),
|
|
9775
9927
|
address: newBoarding.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
9776
9928
|
state: "active",
|
|
9777
9929
|
metadata: {
|
|
9778
|
-
source:
|
|
9930
|
+
source: chunk32YKLQPS_cjs.WALLET_RECEIVE_SOURCE,
|
|
9779
9931
|
signingDescriptor: descriptor
|
|
9780
9932
|
}
|
|
9781
9933
|
});
|
|
@@ -9814,7 +9966,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9814
9966
|
const xonly = toXOnlyPubKey(newServerPubKey);
|
|
9815
9967
|
let newServerUnrollScript;
|
|
9816
9968
|
try {
|
|
9817
|
-
newServerUnrollScript =
|
|
9969
|
+
newServerUnrollScript = chunkHXDZ2QTW_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
9818
9970
|
} catch (e) {
|
|
9819
9971
|
throw new Error("Invalid checkpointTapscript from server");
|
|
9820
9972
|
}
|
|
@@ -9842,21 +9994,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9842
9994
|
const [currentBoardingRow] = await manager.getContracts({
|
|
9843
9995
|
script: currentBoardingScript
|
|
9844
9996
|
});
|
|
9845
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
9997
|
+
const newOffchain = this.offchainTapscript instanceof chunk32YKLQPS_cjs.DelegateVtxo.Script ? new chunk32YKLQPS_cjs.DelegateVtxo.Script({
|
|
9846
9998
|
...this.offchainTapscript.options,
|
|
9847
9999
|
serverPubKey: xonly
|
|
9848
|
-
}) : new
|
|
10000
|
+
}) : new chunk32YKLQPS_cjs.DefaultVtxo.Script({
|
|
9849
10001
|
...this.offchainTapscript.options,
|
|
9850
10002
|
serverPubKey: xonly
|
|
9851
10003
|
});
|
|
9852
|
-
const newBoarding = new
|
|
10004
|
+
const newBoarding = new chunk32YKLQPS_cjs.DefaultVtxo.Script({
|
|
9853
10005
|
...this._boardingTapscript.options,
|
|
9854
10006
|
serverPubKey: xonly
|
|
9855
10007
|
});
|
|
9856
|
-
const offchainCsv =
|
|
10008
|
+
const offchainCsv = chunkHXDZ2QTW_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
9857
10009
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
9858
10010
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
9859
|
-
if (newOffchain instanceof
|
|
10011
|
+
if (newOffchain instanceof chunk32YKLQPS_cjs.DelegateVtxo.Script) {
|
|
9860
10012
|
await manager.createContract({
|
|
9861
10013
|
type: "delegate",
|
|
9862
10014
|
params: {
|
|
@@ -9884,13 +10036,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9884
10036
|
metadata: currentOffchainRow?.metadata
|
|
9885
10037
|
});
|
|
9886
10038
|
}
|
|
9887
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
10039
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunk32YKLQPS_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
9888
10040
|
await manager.createContract({
|
|
9889
10041
|
type: "boarding",
|
|
9890
10042
|
params: {
|
|
9891
10043
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
9892
10044
|
serverPubKey: base.hex.encode(xonly),
|
|
9893
|
-
csvTimelock:
|
|
10045
|
+
csvTimelock: chunkHXDZ2QTW_cjs.timelockToSequence(boardingCsv).toString()
|
|
9894
10046
|
},
|
|
9895
10047
|
script: base.hex.encode(newBoarding.pkScript),
|
|
9896
10048
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -9985,7 +10137,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9985
10137
|
const hd = provider instanceof HDDescriptorProvider;
|
|
9986
10138
|
const staticDescriptor = hd ? void 0 : `tr(${base.hex.encode(await this.identity.xOnlyPublicKey())})`;
|
|
9987
10139
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
9988
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
10140
|
+
const delegatePubKey = this.offchainTapscript instanceof chunk32YKLQPS_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
9989
10141
|
const arkInfo = await this.arkProvider.getInfo();
|
|
9990
10142
|
const currentSignerPubKey = toXOnlyPubKey(base.hex.decode(arkInfo.signerPubkey));
|
|
9991
10143
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
@@ -10004,7 +10156,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10004
10156
|
csvTimelocks: this.walletContractTimelocks,
|
|
10005
10157
|
// Boarding-exit CSV so the boarding handler can build its
|
|
10006
10158
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
10007
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
10159
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunk32YKLQPS_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
10008
10160
|
delegatePubKey
|
|
10009
10161
|
};
|
|
10010
10162
|
const result = await manager.scanContracts({
|
|
@@ -10108,7 +10260,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10108
10260
|
let serverUnrollScript;
|
|
10109
10261
|
try {
|
|
10110
10262
|
const raw = base.hex.decode(setup.info.checkpointTapscript);
|
|
10111
|
-
serverUnrollScript =
|
|
10263
|
+
serverUnrollScript = chunkHXDZ2QTW_cjs.CSVMultisigTapscript.decode(raw);
|
|
10112
10264
|
} catch (e) {
|
|
10113
10265
|
throw new Error("Invalid checkpointTapscript from server");
|
|
10114
10266
|
}
|
|
@@ -10234,7 +10386,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10234
10386
|
inputs: params.selectedVtxos,
|
|
10235
10387
|
changeAmount: BigInt(changeAmount)
|
|
10236
10388
|
};
|
|
10237
|
-
const outputAddress =
|
|
10389
|
+
const outputAddress = chunkHXDZ2QTW_cjs.ArkAddress.decode(params.address);
|
|
10238
10390
|
const outputScript = BigInt(params.amount) < this.dustAmount ? outputAddress.subdustPkScript : outputAddress.pkScript;
|
|
10239
10391
|
const outputs = [
|
|
10240
10392
|
{
|
|
@@ -10287,13 +10439,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10287
10439
|
}
|
|
10288
10440
|
}
|
|
10289
10441
|
const offchainAddress = await this.getAddress();
|
|
10290
|
-
const offchainPkScript =
|
|
10442
|
+
const offchainPkScript = chunkHXDZ2QTW_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
10291
10443
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
10292
10444
|
if (!params) {
|
|
10293
10445
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
10294
10446
|
const estimator = new Estimator(fees.intentFee);
|
|
10295
10447
|
let amount = 0;
|
|
10296
|
-
const exitScript =
|
|
10448
|
+
const exitScript = chunkHXDZ2QTW_cjs.CSVMultisigTapscript.decode(
|
|
10297
10449
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
10298
10450
|
);
|
|
10299
10451
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -10373,7 +10525,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10373
10525
|
for (const [index, output] of params.outputs.entries()) {
|
|
10374
10526
|
let script;
|
|
10375
10527
|
try {
|
|
10376
|
-
const addr =
|
|
10528
|
+
const addr = chunkHXDZ2QTW_cjs.ArkAddress.decode(output.address);
|
|
10377
10529
|
script = addr.pkScript;
|
|
10378
10530
|
hasOffchainOutputs = true;
|
|
10379
10531
|
} catch {
|
|
@@ -10548,6 +10700,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10548
10700
|
settlementPsbt = await this._signerRouter.sign(settlementPsbt, [
|
|
10549
10701
|
{ index: i, lookupScript: script }
|
|
10550
10702
|
]);
|
|
10703
|
+
if (!settlementPsbt.getInput(i).tapScriptSig?.length) {
|
|
10704
|
+
throw new Error(await this.unsignableBoardingInputError(input, script));
|
|
10705
|
+
}
|
|
10551
10706
|
hasBoardingUtxos = true;
|
|
10552
10707
|
break;
|
|
10553
10708
|
}
|
|
@@ -10581,7 +10736,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10581
10736
|
index: input.vout,
|
|
10582
10737
|
witnessUtxo: {
|
|
10583
10738
|
amount: BigInt(input.value),
|
|
10584
|
-
script:
|
|
10739
|
+
script: chunkHXDZ2QTW_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
10585
10740
|
},
|
|
10586
10741
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
10587
10742
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -10600,7 +10755,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10600
10755
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
10601
10756
|
{
|
|
10602
10757
|
index: 0,
|
|
10603
|
-
lookupScript:
|
|
10758
|
+
lookupScript: chunkHXDZ2QTW_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
10604
10759
|
}
|
|
10605
10760
|
]);
|
|
10606
10761
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -10612,6 +10767,24 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10612
10767
|
);
|
|
10613
10768
|
}
|
|
10614
10769
|
}
|
|
10770
|
+
// Best-effort: every enrichment is guarded so a secondary failure can't
|
|
10771
|
+
// mask the original signing error.
|
|
10772
|
+
async unsignableBoardingInputError(input, script) {
|
|
10773
|
+
const scriptHex = base.hex.encode(script);
|
|
10774
|
+
let unresolvedAddress = "<undecodable>";
|
|
10775
|
+
try {
|
|
10776
|
+
unresolvedAddress = btcSigner.Address(this.network).encode(btcSigner.OutScript.decode(script));
|
|
10777
|
+
} catch {
|
|
10778
|
+
}
|
|
10779
|
+
let recognized = "<unavailable>";
|
|
10780
|
+
try {
|
|
10781
|
+
const current = await this.getBoardingAddress();
|
|
10782
|
+
const all = await this.getBoardingAddresses();
|
|
10783
|
+
recognized = `current=${current}; all=[${all.join(", ")}]`;
|
|
10784
|
+
} catch {
|
|
10785
|
+
}
|
|
10786
|
+
return `failed to sign boarding input ${input.txid}:${input.vout}: signer did not recognize script ${scriptHex} (${unresolvedAddress}); would have reached arkd unsigned and been rejected as "not a wallet script". Recognized boarding addresses: ${recognized}. Likely a rotated boarding address with a missing contract row.`;
|
|
10787
|
+
}
|
|
10615
10788
|
/**
|
|
10616
10789
|
* Create a batch event handler for settlement flows.
|
|
10617
10790
|
*
|
|
@@ -10640,7 +10813,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10640
10813
|
if (skip) {
|
|
10641
10814
|
return { skip };
|
|
10642
10815
|
}
|
|
10643
|
-
const sweepTapscript =
|
|
10816
|
+
const sweepTapscript = chunkHXDZ2QTW_cjs.CSVMultisigTapscript.encode({
|
|
10644
10817
|
timelock: {
|
|
10645
10818
|
value: event.batchExpiry,
|
|
10646
10819
|
type: event.batchExpiry >= 512n ? "seconds" : "blocks"
|
|
@@ -10744,7 +10917,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10744
10917
|
try {
|
|
10745
10918
|
return await this.arkProvider.registerIntent(intent);
|
|
10746
10919
|
} catch (error) {
|
|
10747
|
-
if (error instanceof
|
|
10920
|
+
if (error instanceof chunkALISWEQ5_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
10748
10921
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
10749
10922
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
10750
10923
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -10760,7 +10933,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10760
10933
|
expire_at: 0,
|
|
10761
10934
|
cosigners_public_keys: cosignerPubKeys
|
|
10762
10935
|
};
|
|
10763
|
-
const proof =
|
|
10936
|
+
const proof = chunkALISWEQ5_cjs.Intent.create(message, coins, outputs);
|
|
10764
10937
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
10765
10938
|
return {
|
|
10766
10939
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -10772,7 +10945,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10772
10945
|
type: "delete",
|
|
10773
10946
|
expire_at: 0
|
|
10774
10947
|
};
|
|
10775
|
-
const proof =
|
|
10948
|
+
const proof = chunkALISWEQ5_cjs.Intent.create(message, coins, []);
|
|
10776
10949
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
10777
10950
|
return {
|
|
10778
10951
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -10784,7 +10957,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
10784
10957
|
type: "get-pending-tx",
|
|
10785
10958
|
expire_at: 0
|
|
10786
10959
|
};
|
|
10787
|
-
const proof =
|
|
10960
|
+
const proof = chunkALISWEQ5_cjs.Intent.create(message, coins, []);
|
|
10788
10961
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
10789
10962
|
return {
|
|
10790
10963
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -11200,7 +11373,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11200
11373
|
);
|
|
11201
11374
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
11202
11375
|
index,
|
|
11203
|
-
lookupScript:
|
|
11376
|
+
lookupScript: chunkHXDZ2QTW_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
11204
11377
|
}));
|
|
11205
11378
|
const checkpointJobs = offchainTx.checkpoints.map(
|
|
11206
11379
|
(c) => this.inputSigningJobsFromWitnessUtxos(c)
|
|
@@ -11433,7 +11606,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11433
11606
|
} else {
|
|
11434
11607
|
let sourceAddress;
|
|
11435
11608
|
try {
|
|
11436
|
-
sourceAddress =
|
|
11609
|
+
sourceAddress = chunkHXDZ2QTW_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
11437
11610
|
this.network
|
|
11438
11611
|
);
|
|
11439
11612
|
} catch {
|
|
@@ -11539,9 +11712,15 @@ async function waitForIncomingFunds(wallet) {
|
|
|
11539
11712
|
|
|
11540
11713
|
// src/worker/errors.ts
|
|
11541
11714
|
var MESSAGE_BUS_NOT_INITIALIZED = "MessageBus not initialized";
|
|
11715
|
+
var MESSAGE_BUS_INITIALIZING = `${MESSAGE_BUS_NOT_INITIALIZED}: initializing`;
|
|
11542
11716
|
var MessageBusNotInitializedError = class extends Error {
|
|
11717
|
+
constructor(message = MESSAGE_BUS_NOT_INITIALIZED) {
|
|
11718
|
+
super(message);
|
|
11719
|
+
}
|
|
11720
|
+
};
|
|
11721
|
+
var MessageBusInitializingError = class extends MessageBusNotInitializedError {
|
|
11543
11722
|
constructor() {
|
|
11544
|
-
super(
|
|
11723
|
+
super(MESSAGE_BUS_INITIALIZING);
|
|
11545
11724
|
}
|
|
11546
11725
|
};
|
|
11547
11726
|
var ServiceWorkerTimeoutError = class extends Error {
|
|
@@ -11583,6 +11762,16 @@ var MessageBus = class {
|
|
|
11583
11762
|
tickInProgress = false;
|
|
11584
11763
|
debug = false;
|
|
11585
11764
|
initialized = false;
|
|
11765
|
+
/**
|
|
11766
|
+
* FIFO chain that serializes `INITIALIZE_MESSAGE_BUS` handling. Each init
|
|
11767
|
+
* runs to completion in enqueue order.
|
|
11768
|
+
*/
|
|
11769
|
+
initChain = Promise.resolve();
|
|
11770
|
+
/**
|
|
11771
|
+
* Number of inits accepted but not yet settled (queued or running). The
|
|
11772
|
+
* bus refuses ordinary wallet messages while this is > 0.
|
|
11773
|
+
*/
|
|
11774
|
+
pendingInitCount = 0;
|
|
11586
11775
|
buildServicesFn;
|
|
11587
11776
|
boundOnMessage = this.onMessage.bind(this);
|
|
11588
11777
|
/** Start the message bus and attach service-worker event listeners. */
|
|
@@ -11628,11 +11817,12 @@ var MessageBus = class {
|
|
|
11628
11817
|
async runTick() {
|
|
11629
11818
|
if (!this.running) return;
|
|
11630
11819
|
if (this.tickInProgress) return;
|
|
11631
|
-
this.tickInProgress = true;
|
|
11632
11820
|
if (this.tickTimeout !== null) {
|
|
11633
11821
|
self.clearTimeout(this.tickTimeout);
|
|
11634
11822
|
this.tickTimeout = null;
|
|
11635
11823
|
}
|
|
11824
|
+
if (this.pendingInitCount > 0) return;
|
|
11825
|
+
this.tickInProgress = true;
|
|
11636
11826
|
try {
|
|
11637
11827
|
const now = Date.now();
|
|
11638
11828
|
for (const updater of this.handlers.values()) {
|
|
@@ -11666,7 +11856,34 @@ var MessageBus = class {
|
|
|
11666
11856
|
this.scheduleNextTick();
|
|
11667
11857
|
}
|
|
11668
11858
|
}
|
|
11669
|
-
|
|
11859
|
+
/**
|
|
11860
|
+
* Serialize init requests on {@link initChain}.
|
|
11861
|
+
* Returns this init's own result.
|
|
11862
|
+
*/
|
|
11863
|
+
waitForInit(config) {
|
|
11864
|
+
this.pendingInitCount += 1;
|
|
11865
|
+
const run = this.initChain.then(
|
|
11866
|
+
() => this.doInit(config),
|
|
11867
|
+
// A rejected init never blocks the next request.
|
|
11868
|
+
() => this.doInit(config)
|
|
11869
|
+
).finally(() => {
|
|
11870
|
+
this.pendingInitCount -= 1;
|
|
11871
|
+
});
|
|
11872
|
+
this.initChain = run.catch(() => void 0);
|
|
11873
|
+
return run;
|
|
11874
|
+
}
|
|
11875
|
+
/**
|
|
11876
|
+
* The bus serves ordinary wallet messages only when it is initialized AND
|
|
11877
|
+
* no init is in flight.
|
|
11878
|
+
*/
|
|
11879
|
+
acceptsWalletMessages() {
|
|
11880
|
+
return this.initialized && this.pendingInitCount === 0;
|
|
11881
|
+
}
|
|
11882
|
+
async doInit(config) {
|
|
11883
|
+
if (this.tickTimeout !== null) {
|
|
11884
|
+
self.clearTimeout(this.tickTimeout);
|
|
11885
|
+
this.tickTimeout = null;
|
|
11886
|
+
}
|
|
11670
11887
|
if (this.initialized) {
|
|
11671
11888
|
this.initialized = false;
|
|
11672
11889
|
await Promise.all(
|
|
@@ -11679,17 +11896,26 @@ var MessageBus = class {
|
|
|
11679
11896
|
...config.messageTimeouts ?? {}
|
|
11680
11897
|
};
|
|
11681
11898
|
const services = await this.buildServicesFn(config);
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11899
|
+
const started = [];
|
|
11900
|
+
try {
|
|
11901
|
+
for (const updater of this.handlers.values()) {
|
|
11902
|
+
if (this.debug) console.log(`Starting updater: ${updater.messageTag}`);
|
|
11903
|
+
await updater.start(services, {
|
|
11904
|
+
walletRepository: this.walletRepository
|
|
11905
|
+
});
|
|
11906
|
+
started.push(updater);
|
|
11907
|
+
}
|
|
11908
|
+
} catch (err) {
|
|
11909
|
+
await Promise.all(started.map((h) => h.stop().catch(() => {
|
|
11910
|
+
})));
|
|
11911
|
+
this.initialized = false;
|
|
11912
|
+
throw err;
|
|
11687
11913
|
}
|
|
11688
11914
|
this.scheduleNextTick();
|
|
11689
11915
|
this.initialized = true;
|
|
11690
11916
|
}
|
|
11691
11917
|
async buildServices(config) {
|
|
11692
|
-
const arkProvider = new
|
|
11918
|
+
const arkProvider = new chunkALISWEQ5_cjs.RestArkProvider(config.arkServer.url);
|
|
11693
11919
|
const storage = {
|
|
11694
11920
|
walletRepository: this.walletRepository,
|
|
11695
11921
|
contractRepository: this.contractRepository
|
|
@@ -11742,23 +11968,29 @@ var MessageBus = class {
|
|
|
11742
11968
|
if (this.debug) {
|
|
11743
11969
|
console.log("Init Command received");
|
|
11744
11970
|
}
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
11971
|
+
try {
|
|
11972
|
+
await this.waitForInit(event.data.config);
|
|
11973
|
+
this.deliverResponse(event.source, { id, tag }, { id, tag });
|
|
11974
|
+
if (this.debug) {
|
|
11975
|
+
console.log("MessageBus initialized");
|
|
11976
|
+
}
|
|
11977
|
+
} catch (error) {
|
|
11978
|
+
if (this.debug) console.error("MessageBus init failed", error);
|
|
11979
|
+
this.deliverResponse(event.source, { id, tag, error: toError(error) }, { id, tag });
|
|
11749
11980
|
}
|
|
11750
11981
|
return;
|
|
11751
11982
|
}
|
|
11752
|
-
if (!this.
|
|
11983
|
+
if (!this.acceptsWalletMessages()) {
|
|
11753
11984
|
if (this.debug)
|
|
11754
|
-
console.warn("Event received
|
|
11985
|
+
console.warn("Event received while bus unavailable, dropping", event.data);
|
|
11755
11986
|
const fallbackTag = tag ?? "unknown";
|
|
11987
|
+
const error = this.pendingInitCount > 0 ? new MessageBusInitializingError() : new MessageBusNotInitializedError();
|
|
11756
11988
|
this.deliverResponse(
|
|
11757
11989
|
event.source,
|
|
11758
11990
|
{
|
|
11759
11991
|
id,
|
|
11760
11992
|
tag: fallbackTag,
|
|
11761
|
-
error
|
|
11993
|
+
error
|
|
11762
11994
|
},
|
|
11763
11995
|
{ id, tag: fallbackTag }
|
|
11764
11996
|
);
|
|
@@ -12065,7 +12297,7 @@ var Ramps = class {
|
|
|
12065
12297
|
}
|
|
12066
12298
|
amount = amount ?? totalAmount;
|
|
12067
12299
|
const offchainAddress = await this.wallet.getAddress();
|
|
12068
|
-
const offchainAddr =
|
|
12300
|
+
const offchainAddr = chunkHXDZ2QTW_cjs.ArkAddress.decode(offchainAddress);
|
|
12069
12301
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
12070
12302
|
const outputFee = estimator.evalOffchainOutput({
|
|
12071
12303
|
amount,
|
|
@@ -12163,7 +12395,7 @@ var Ramps = class {
|
|
|
12163
12395
|
let destinationScript;
|
|
12164
12396
|
for (const networkName of networkNames) {
|
|
12165
12397
|
try {
|
|
12166
|
-
const network =
|
|
12398
|
+
const network = chunkHXDZ2QTW_cjs.networks[networkName];
|
|
12167
12399
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
12168
12400
|
destinationScript = btcSigner.OutScript.encode(addr);
|
|
12169
12401
|
break;
|
|
@@ -12840,7 +13072,7 @@ var WalletMessageHandler = class {
|
|
|
12840
13072
|
// Wallet methods
|
|
12841
13073
|
async handleInitWallet({ payload }) {
|
|
12842
13074
|
const { arkServerUrl } = payload;
|
|
12843
|
-
this.indexerProvider = new
|
|
13075
|
+
this.indexerProvider = new chunkALISWEQ5_cjs.RestIndexerProvider(arkServerUrl);
|
|
12844
13076
|
await this.onWalletInitialized();
|
|
12845
13077
|
}
|
|
12846
13078
|
async handleGetBalance() {
|
|
@@ -13141,26 +13373,19 @@ var WalletMessageHandler = class {
|
|
|
13141
13373
|
});
|
|
13142
13374
|
return filteredVtxos;
|
|
13143
13375
|
}
|
|
13376
|
+
/** Tear down handler subscriptions, then delegate the full wipe to the wallet. */
|
|
13144
13377
|
async clear() {
|
|
13145
|
-
|
|
13146
|
-
if (
|
|
13378
|
+
const wallet = this.wallet ?? this.readonlyWallet;
|
|
13379
|
+
if (!wallet) return;
|
|
13380
|
+
if (this.incomingFundsSubscription) {
|
|
13381
|
+
this.incomingFundsSubscription();
|
|
13382
|
+
this.incomingFundsSubscription = void 0;
|
|
13383
|
+
}
|
|
13147
13384
|
if (this.contractEventsSubscription) {
|
|
13148
13385
|
this.contractEventsSubscription();
|
|
13149
13386
|
this.contractEventsSubscription = void 0;
|
|
13150
13387
|
}
|
|
13151
|
-
|
|
13152
|
-
if (this.wallet) {
|
|
13153
|
-
await this.wallet.dispose();
|
|
13154
|
-
} else {
|
|
13155
|
-
await this.readonlyWallet.dispose();
|
|
13156
|
-
}
|
|
13157
|
-
} catch (_) {
|
|
13158
|
-
}
|
|
13159
|
-
try {
|
|
13160
|
-
await this.walletRepository?.clear();
|
|
13161
|
-
} catch (_) {
|
|
13162
|
-
console.warn("Failed to clear vtxos from wallet repository");
|
|
13163
|
-
}
|
|
13388
|
+
await wallet.clear();
|
|
13164
13389
|
this.wallet = void 0;
|
|
13165
13390
|
this.readonlyWallet = void 0;
|
|
13166
13391
|
this.arkProvider = void 0;
|
|
@@ -13268,6 +13493,13 @@ var WalletMessageHandler = class {
|
|
|
13268
13493
|
function isMessageBusNotInitializedError(error) {
|
|
13269
13494
|
return error instanceof Error && error.message.includes(MESSAGE_BUS_NOT_INITIALIZED);
|
|
13270
13495
|
}
|
|
13496
|
+
function isMessageBusInitializingError(error) {
|
|
13497
|
+
return error instanceof Error && error.message.includes(MESSAGE_BUS_INITIALIZING);
|
|
13498
|
+
}
|
|
13499
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
13500
|
+
var INIT_WAIT_BACKOFF_CAP_MS = 2e3;
|
|
13501
|
+
var MAX_INIT_WAITS = 8;
|
|
13502
|
+
var initWaitBackoffMs = (attempt) => Math.min(100 * 2 ** attempt, INIT_WAIT_BACKOFF_CAP_MS);
|
|
13271
13503
|
var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
13272
13504
|
// Fast reads — fail quickly
|
|
13273
13505
|
GET_ADDRESS: 1e4,
|
|
@@ -13444,6 +13676,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13444
13676
|
walletRepository;
|
|
13445
13677
|
contractRepository;
|
|
13446
13678
|
identity;
|
|
13679
|
+
activity = createDefaultActivityRegistry();
|
|
13447
13680
|
_readonlyAssetManager;
|
|
13448
13681
|
initConfig = null;
|
|
13449
13682
|
initWalletPayload = null;
|
|
@@ -13536,6 +13769,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13536
13769
|
wallet.initWalletPayload = initWalletPayload;
|
|
13537
13770
|
wallet.messageBusTimeoutMs = options.messageBusTimeoutMs;
|
|
13538
13771
|
wallet.messageTimeouts = messageTimeouts;
|
|
13772
|
+
await wallet.assertWorkerIdentityMatches();
|
|
13539
13773
|
return wallet;
|
|
13540
13774
|
}
|
|
13541
13775
|
/**
|
|
@@ -13667,7 +13901,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13667
13901
|
}
|
|
13668
13902
|
// send a message, retrying up to 2 times if the service worker was
|
|
13669
13903
|
// killed and restarted by the OS (mobile browsers do this aggressively)
|
|
13670
|
-
async sendMessageWithRetry(request) {
|
|
13904
|
+
async sendMessageWithRetry(request, withEvents) {
|
|
13671
13905
|
if (this.initConfig) {
|
|
13672
13906
|
try {
|
|
13673
13907
|
await this.pingServiceWorker();
|
|
@@ -13677,32 +13911,23 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13677
13911
|
}
|
|
13678
13912
|
const timeoutMs = this.getTimeoutForRequest(request);
|
|
13679
13913
|
const maxRetries = 2;
|
|
13680
|
-
for (let attempt = 0; ; attempt++) {
|
|
13914
|
+
for (let attempt = 0, initWaits = 0; ; attempt++) {
|
|
13681
13915
|
try {
|
|
13916
|
+
if (withEvents) {
|
|
13917
|
+
return await this.sendMessageStreaming(
|
|
13918
|
+
request,
|
|
13919
|
+
withEvents.onEvent,
|
|
13920
|
+
withEvents.isComplete
|
|
13921
|
+
);
|
|
13922
|
+
}
|
|
13682
13923
|
return await this.sendMessageDirect(request, timeoutMs);
|
|
13683
13924
|
} catch (error) {
|
|
13684
|
-
if (
|
|
13685
|
-
throw error;
|
|
13925
|
+
if (isMessageBusInitializingError(error)) {
|
|
13926
|
+
if (initWaits >= MAX_INIT_WAITS) throw error;
|
|
13927
|
+
await sleep(initWaitBackoffMs(initWaits++));
|
|
13928
|
+
attempt--;
|
|
13929
|
+
continue;
|
|
13686
13930
|
}
|
|
13687
|
-
await this.reinitialize();
|
|
13688
|
-
}
|
|
13689
|
-
}
|
|
13690
|
-
}
|
|
13691
|
-
// Like sendMessage but for streaming responses — retries with
|
|
13692
|
-
// reinitialize when the service worker has been killed/restarted.
|
|
13693
|
-
async sendMessageWithEvents(request, onEvent, isComplete) {
|
|
13694
|
-
if (this.initConfig) {
|
|
13695
|
-
try {
|
|
13696
|
-
await this.pingServiceWorker();
|
|
13697
|
-
} catch {
|
|
13698
|
-
await this.reinitialize();
|
|
13699
|
-
}
|
|
13700
|
-
}
|
|
13701
|
-
const maxRetries = 2;
|
|
13702
|
-
for (let attempt = 0; ; attempt++) {
|
|
13703
|
-
try {
|
|
13704
|
-
return await this.sendMessageStreaming(request, onEvent, isComplete);
|
|
13705
|
-
} catch (error) {
|
|
13706
13931
|
if (!isMessageBusNotInitializedError(error) || attempt >= maxRetries) {
|
|
13707
13932
|
throw error;
|
|
13708
13933
|
}
|
|
@@ -13775,24 +14000,48 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13775
14000
|
payload
|
|
13776
14001
|
};
|
|
13777
14002
|
await this.sendMessageDirect(initMessage, this.getTimeoutForRequest(initMessage));
|
|
14003
|
+
await this.assertWorkerIdentityMatches();
|
|
13778
14004
|
})().finally(() => {
|
|
13779
14005
|
this.reinitPromise = null;
|
|
13780
14006
|
});
|
|
13781
14007
|
return this.reinitPromise;
|
|
13782
14008
|
}
|
|
13783
|
-
/**
|
|
14009
|
+
/**
|
|
14010
|
+
* Verify the worker is bound to this wallet's identity before the SDK hands
|
|
14011
|
+
* back (or recovers) a usable wallet object.
|
|
14012
|
+
*
|
|
14013
|
+
* Compares the stable baseline identity key (`identity.xOnlyPublicKey()`) to the one reported
|
|
14014
|
+
* by the worker via GET_STATUS.
|
|
14015
|
+
*/
|
|
14016
|
+
async assertWorkerIdentityMatches() {
|
|
14017
|
+
const expected = base.hex.encode(await this.identity.xOnlyPublicKey());
|
|
14018
|
+
const message = {
|
|
14019
|
+
id: getRandomId(),
|
|
14020
|
+
tag: this.messageTag,
|
|
14021
|
+
type: "GET_STATUS"
|
|
14022
|
+
};
|
|
14023
|
+
const response = await this.sendMessageDirect(
|
|
14024
|
+
message,
|
|
14025
|
+
this.getTimeoutForRequest(message)
|
|
14026
|
+
);
|
|
14027
|
+
const workerKey = response.payload.xOnlyPublicKey;
|
|
14028
|
+
if (!workerKey) {
|
|
14029
|
+
throw new Error("Service worker identity mismatch: worker did not report an identity");
|
|
14030
|
+
}
|
|
14031
|
+
const actual = base.hex.encode(workerKey);
|
|
14032
|
+
if (actual !== expected) {
|
|
14033
|
+
throw new Error(
|
|
14034
|
+
`Service worker identity mismatch: expected ${expected}, got ${actual}`
|
|
14035
|
+
);
|
|
14036
|
+
}
|
|
14037
|
+
}
|
|
14038
|
+
/** This tells the service worker to wipe all locally persisted wallet data. */
|
|
13784
14039
|
async clear() {
|
|
13785
14040
|
const message = {
|
|
13786
14041
|
id: getRandomId(),
|
|
13787
14042
|
tag: this.messageTag,
|
|
13788
14043
|
type: "CLEAR"
|
|
13789
14044
|
};
|
|
13790
|
-
try {
|
|
13791
|
-
const address = await this.getAddress();
|
|
13792
|
-
await this.walletRepository.deleteVtxos(address);
|
|
13793
|
-
} catch (_) {
|
|
13794
|
-
console.warn("Failed to clear vtxos from wallet repository");
|
|
13795
|
-
}
|
|
13796
14045
|
await this.sendMessage(message);
|
|
13797
14046
|
}
|
|
13798
14047
|
async getAddress() {
|
|
@@ -13865,6 +14114,9 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
13865
14114
|
throw new Error(`Failed to get status: ${error}`);
|
|
13866
14115
|
}
|
|
13867
14116
|
}
|
|
14117
|
+
async getActivityHistory() {
|
|
14118
|
+
return buildActivities(await this.getTransactionHistory(), this.activity.all());
|
|
14119
|
+
}
|
|
13868
14120
|
async getTransactionHistory() {
|
|
13869
14121
|
const message = {
|
|
13870
14122
|
id: getRandomId(),
|
|
@@ -14200,6 +14452,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14200
14452
|
wallet.initWalletPayload = initWalletPayload;
|
|
14201
14453
|
wallet.messageBusTimeoutMs = options.messageBusTimeoutMs;
|
|
14202
14454
|
wallet.messageTimeouts = messageTimeouts;
|
|
14455
|
+
await wallet.assertWorkerIdentityMatches();
|
|
14203
14456
|
return wallet;
|
|
14204
14457
|
}
|
|
14205
14458
|
/**
|
|
@@ -14247,11 +14500,10 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14247
14500
|
payload: { params }
|
|
14248
14501
|
};
|
|
14249
14502
|
try {
|
|
14250
|
-
const response = await this.
|
|
14251
|
-
|
|
14252
|
-
(resp) =>
|
|
14253
|
-
|
|
14254
|
-
);
|
|
14503
|
+
const response = await this.sendMessageWithRetry(message, {
|
|
14504
|
+
onEvent: (resp) => callback?.(resp.payload),
|
|
14505
|
+
isComplete: (resp) => resp.type === "SETTLE_SUCCESS"
|
|
14506
|
+
});
|
|
14255
14507
|
return response.payload.txid;
|
|
14256
14508
|
} catch (error) {
|
|
14257
14509
|
throw new Error(`Settlement failed: ${error}`);
|
|
@@ -14276,12 +14528,11 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14276
14528
|
payload: opts ?? {}
|
|
14277
14529
|
};
|
|
14278
14530
|
try {
|
|
14279
|
-
await this.
|
|
14280
|
-
|
|
14281
|
-
() => {
|
|
14531
|
+
await this.sendMessageWithRetry(message, {
|
|
14532
|
+
onEvent: () => {
|
|
14282
14533
|
},
|
|
14283
|
-
(resp) => resp.type === "RESTORE_WALLET_SUCCESS"
|
|
14284
|
-
);
|
|
14534
|
+
isComplete: (resp) => resp.type === "RESTORE_WALLET_SUCCESS"
|
|
14535
|
+
});
|
|
14285
14536
|
} catch (error) {
|
|
14286
14537
|
if (isSerializedAggregateError(error)) {
|
|
14287
14538
|
throw deserializeAggregateError(error);
|
|
@@ -14369,11 +14620,10 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14369
14620
|
id: getRandomId()
|
|
14370
14621
|
};
|
|
14371
14622
|
try {
|
|
14372
|
-
const response = await wallet.
|
|
14373
|
-
|
|
14374
|
-
(resp) =>
|
|
14375
|
-
|
|
14376
|
-
);
|
|
14623
|
+
const response = await wallet.sendMessageWithRetry(message, {
|
|
14624
|
+
onEvent: (resp) => eventCallback?.(resp.payload),
|
|
14625
|
+
isComplete: (resp) => resp.type === "RECOVER_VTXOS_SUCCESS"
|
|
14626
|
+
});
|
|
14377
14627
|
return response.payload.txid;
|
|
14378
14628
|
} catch (e) {
|
|
14379
14629
|
throw new Error(`Failed to recover vtxos: ${e}`);
|
|
@@ -14420,11 +14670,10 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14420
14670
|
payload: options
|
|
14421
14671
|
};
|
|
14422
14672
|
try {
|
|
14423
|
-
const response = await wallet.
|
|
14424
|
-
|
|
14425
|
-
(resp) =>
|
|
14426
|
-
|
|
14427
|
-
);
|
|
14673
|
+
const response = await wallet.sendMessageWithRetry(message, {
|
|
14674
|
+
onEvent: (resp) => eventCallback?.(resp.payload),
|
|
14675
|
+
isComplete: (resp) => resp.type === "RENEW_VTXOS_SUCCESS"
|
|
14676
|
+
});
|
|
14428
14677
|
return response.payload.txid;
|
|
14429
14678
|
} catch (e) {
|
|
14430
14679
|
throw new Error(`Failed to renew vtxos: ${e}`);
|
|
@@ -14463,13 +14712,12 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
14463
14712
|
id: getRandomId()
|
|
14464
14713
|
};
|
|
14465
14714
|
try {
|
|
14466
|
-
const response = await wallet.
|
|
14467
|
-
|
|
14468
|
-
(resp) => options?.eventCallback?.(
|
|
14715
|
+
const response = await wallet.sendMessageWithRetry(message, {
|
|
14716
|
+
onEvent: (resp) => options?.eventCallback?.(
|
|
14469
14717
|
resp.payload
|
|
14470
14718
|
),
|
|
14471
|
-
(resp) => resp.type === "MIGRATE_DEPRECATED_SIGNER_VTXOS_SUCCESS"
|
|
14472
|
-
);
|
|
14719
|
+
isComplete: (resp) => resp.type === "MIGRATE_DEPRECATED_SIGNER_VTXOS_SUCCESS"
|
|
14720
|
+
});
|
|
14473
14721
|
return deserializeMigrationReport(
|
|
14474
14722
|
response.payload.report
|
|
14475
14723
|
);
|
|
@@ -14520,12 +14768,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
14520
14768
|
* @returns Configured onchain wallet
|
|
14521
14769
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
14522
14770
|
*/
|
|
14523
|
-
static async create(identity, networkName =
|
|
14771
|
+
static async create(identity, networkName = chunkHXDZ2QTW_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
14524
14772
|
const pubkey = await identity.xOnlyPublicKey();
|
|
14525
14773
|
if (!pubkey) {
|
|
14526
14774
|
throw new Error("Invalid configured public key");
|
|
14527
14775
|
}
|
|
14528
|
-
const network =
|
|
14776
|
+
const network = chunkHXDZ2QTW_cjs.getNetwork(networkName);
|
|
14529
14777
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
14530
14778
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
14531
14779
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -14631,7 +14879,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
14631
14879
|
if (!inputs) {
|
|
14632
14880
|
throw new Error("Fee estimation failed");
|
|
14633
14881
|
}
|
|
14634
|
-
let tx = new
|
|
14882
|
+
let tx = new chunkALISWEQ5_cjs.Transaction();
|
|
14635
14883
|
for (const input of inputs) {
|
|
14636
14884
|
tx.addInput({
|
|
14637
14885
|
txid: input.txid,
|
|
@@ -14662,7 +14910,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
14662
14910
|
*/
|
|
14663
14911
|
async bumpP2A(parent) {
|
|
14664
14912
|
const parentVsize = parent.vsize;
|
|
14665
|
-
let child = new
|
|
14913
|
+
let child = new chunkALISWEQ5_cjs.Transaction({
|
|
14666
14914
|
version: 3,
|
|
14667
14915
|
allowLegacyWitnessUtxo: true
|
|
14668
14916
|
});
|
|
@@ -15405,12 +15653,15 @@ function errorText(err) {
|
|
|
15405
15653
|
}
|
|
15406
15654
|
return "";
|
|
15407
15655
|
}
|
|
15656
|
+
function normalizedErrorText(err) {
|
|
15657
|
+
return errorText(err).toLowerCase().replace(/\s+/g, "");
|
|
15658
|
+
}
|
|
15408
15659
|
function isMissingHeightError(err) {
|
|
15409
|
-
return
|
|
15660
|
+
return normalizedErrorText(err).includes("missingheight");
|
|
15410
15661
|
}
|
|
15411
15662
|
function isTxNotInBlockError(err) {
|
|
15412
|
-
const normalized =
|
|
15413
|
-
return normalized.includes("
|
|
15663
|
+
const normalized = normalizedErrorText(err);
|
|
15664
|
+
return normalized.includes("notyetinablock") || normalized.includes("notinablock") || normalized.includes("notinblock") || normalized.includes("noconfirmedtransaction");
|
|
15414
15665
|
}
|
|
15415
15666
|
function childTxidFromHex(txHex) {
|
|
15416
15667
|
const tx = btcSigner.Transaction.fromRaw(base.hex.decode(txHex), {
|
|
@@ -15425,7 +15676,7 @@ exports.BIP322 = void 0;
|
|
|
15425
15676
|
async function sign2(message, identity, network) {
|
|
15426
15677
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
15427
15678
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
15428
|
-
const toSpend =
|
|
15679
|
+
const toSpend = chunkALISWEQ5_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
15429
15680
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
15430
15681
|
const signed = await identity.sign(toSign, [0]);
|
|
15431
15682
|
signed.finalizeIdx(0);
|
|
@@ -15483,7 +15734,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
15483
15734
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
15484
15735
|
return false;
|
|
15485
15736
|
}
|
|
15486
|
-
const toSpend =
|
|
15737
|
+
const toSpend = chunkALISWEQ5_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
15487
15738
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
15488
15739
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
15489
15740
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -15504,7 +15755,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
15504
15755
|
}
|
|
15505
15756
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
15506
15757
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
15507
|
-
const toSpend =
|
|
15758
|
+
const toSpend = chunkALISWEQ5_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
15508
15759
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
15509
15760
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
15510
15761
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -15557,7 +15808,7 @@ function encodeCompactSize(n) {
|
|
|
15557
15808
|
return buf;
|
|
15558
15809
|
}
|
|
15559
15810
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
15560
|
-
const tx = new
|
|
15811
|
+
const tx = new chunkALISWEQ5_cjs.Transaction({ version: 0 });
|
|
15561
15812
|
tx.addInput({
|
|
15562
15813
|
txid: toSpend.id,
|
|
15563
15814
|
index: 0,
|
|
@@ -15571,12 +15822,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
15571
15822
|
});
|
|
15572
15823
|
tx.addOutput({
|
|
15573
15824
|
amount: 0n,
|
|
15574
|
-
script:
|
|
15825
|
+
script: chunkALISWEQ5_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
15575
15826
|
});
|
|
15576
15827
|
return tx;
|
|
15577
15828
|
}
|
|
15578
15829
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
15579
|
-
const tx = new
|
|
15830
|
+
const tx = new chunkALISWEQ5_cjs.Transaction({ version: 0 });
|
|
15580
15831
|
tx.addInput({
|
|
15581
15832
|
txid: toSpend.id,
|
|
15582
15833
|
index: 0,
|
|
@@ -15588,7 +15839,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
15588
15839
|
});
|
|
15589
15840
|
tx.addOutput({
|
|
15590
15841
|
amount: 0n,
|
|
15591
|
-
script:
|
|
15842
|
+
script: chunkALISWEQ5_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
15592
15843
|
});
|
|
15593
15844
|
return tx;
|
|
15594
15845
|
}
|
|
@@ -15649,7 +15900,7 @@ exports.Unroll = void 0;
|
|
|
15649
15900
|
if (virtualTxs.txs.length === 0) {
|
|
15650
15901
|
throw new Error(`Tx ${nextTxToBroadcast.txid} not found`);
|
|
15651
15902
|
}
|
|
15652
|
-
const tx =
|
|
15903
|
+
const tx = chunkALISWEQ5_cjs.Transaction.fromPSBT(base.base64.decode(virtualTxs.txs[0]));
|
|
15653
15904
|
if (nextTxToBroadcast.type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
15654
15905
|
const input = tx.getInput(0);
|
|
15655
15906
|
if (!input) {
|
|
@@ -15681,7 +15932,7 @@ exports.Unroll = void 0;
|
|
|
15681
15932
|
let lastStep;
|
|
15682
15933
|
do {
|
|
15683
15934
|
if (lastStep !== void 0) {
|
|
15684
|
-
await
|
|
15935
|
+
await sleep2(1e3);
|
|
15685
15936
|
}
|
|
15686
15937
|
const step = await this.next();
|
|
15687
15938
|
await step.do();
|
|
@@ -15726,12 +15977,12 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
15726
15977
|
if (!exit) {
|
|
15727
15978
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
15728
15979
|
}
|
|
15729
|
-
const spendingLeaf =
|
|
15980
|
+
const spendingLeaf = chunkHXDZ2QTW_cjs.VtxoScript.decode(vtxo.tapTree).findLeaf(base.hex.encode(exit.script));
|
|
15730
15981
|
if (!spendingLeaf) {
|
|
15731
15982
|
throw new Error(`spending leaf not found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
15732
15983
|
}
|
|
15733
15984
|
totalAmount += BigInt(vtxo.value);
|
|
15734
|
-
const sequence =
|
|
15985
|
+
const sequence = chunkHXDZ2QTW_cjs.timelockToSequence(exit.params.timelock);
|
|
15735
15986
|
inputs.push({
|
|
15736
15987
|
txid: vtxo.txid,
|
|
15737
15988
|
index: vtxo.vout,
|
|
@@ -15739,7 +15990,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
15739
15990
|
sequence,
|
|
15740
15991
|
witnessUtxo: {
|
|
15741
15992
|
amount: BigInt(vtxo.value),
|
|
15742
|
-
script:
|
|
15993
|
+
script: chunkHXDZ2QTW_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
15743
15994
|
},
|
|
15744
15995
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
15745
15996
|
});
|
|
@@ -15749,7 +16000,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
15749
16000
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
15750
16001
|
);
|
|
15751
16002
|
}
|
|
15752
|
-
const tx = new
|
|
16003
|
+
const tx = new chunkALISWEQ5_cjs.Transaction({ version: 2 });
|
|
15753
16004
|
for (const input of inputs) {
|
|
15754
16005
|
tx.addInput(input);
|
|
15755
16006
|
}
|
|
@@ -15771,7 +16022,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
15771
16022
|
signedTx.finalize();
|
|
15772
16023
|
return signedTx;
|
|
15773
16024
|
}
|
|
15774
|
-
function
|
|
16025
|
+
function sleep2(ms) {
|
|
15775
16026
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15776
16027
|
}
|
|
15777
16028
|
function doUnroll(onchainProvider, pkg) {
|
|
@@ -15796,7 +16047,7 @@ function doWait(onchainProvider, txid) {
|
|
|
15796
16047
|
};
|
|
15797
16048
|
}
|
|
15798
16049
|
function availableExitPath(confirmedAt, current, vtxo) {
|
|
15799
|
-
const exits =
|
|
16050
|
+
const exits = chunkHXDZ2QTW_cjs.VtxoScript.decode(vtxo.tapTree).exitPaths();
|
|
15800
16051
|
for (const exit of exits) {
|
|
15801
16052
|
if (exit.params.timelock.type === "blocks") {
|
|
15802
16053
|
if (current.height >= confirmedAt.height + Number(exit.params.timelock.value)) {
|
|
@@ -15835,7 +16086,7 @@ function decodeArkContract(encoded) {
|
|
|
15835
16086
|
}
|
|
15836
16087
|
function contractFromArkContract(encoded, options = {}) {
|
|
15837
16088
|
const parsed = decodeArkContract(encoded);
|
|
15838
|
-
const handler =
|
|
16089
|
+
const handler = chunk32YKLQPS_cjs.contractHandlers.get(parsed.type);
|
|
15839
16090
|
if (!handler) {
|
|
15840
16091
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
15841
16092
|
}
|
|
@@ -15849,9 +16100,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
15849
16100
|
metadata: options.metadata
|
|
15850
16101
|
};
|
|
15851
16102
|
}
|
|
15852
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
16103
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkHXDZ2QTW_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
15853
16104
|
const parsed = decodeArkContract(encoded);
|
|
15854
|
-
const handler =
|
|
16105
|
+
const handler = chunk32YKLQPS_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
15855
16106
|
const params = parsed.data;
|
|
15856
16107
|
const vtxoScript = handler.createScript(params);
|
|
15857
16108
|
return {
|
|
@@ -15869,6 +16120,7 @@ function isArkContract(str) {
|
|
|
15869
16120
|
return str.startsWith(ARKCONTRACT_PREFIX + "=");
|
|
15870
16121
|
}
|
|
15871
16122
|
|
|
16123
|
+
exports.ActivityRegistry = ActivityRegistry;
|
|
15872
16124
|
exports.ArkNote = ArkNote;
|
|
15873
16125
|
exports.AssetManager = AssetManager;
|
|
15874
16126
|
exports.ContractManager = ContractManager;
|
|
@@ -15893,9 +16145,11 @@ exports.InMemoryContractRepository = InMemoryContractRepository;
|
|
|
15893
16145
|
exports.InMemoryWalletRepository = InMemoryWalletRepository;
|
|
15894
16146
|
exports.IndexedDBContractRepository = IndexedDBContractRepository;
|
|
15895
16147
|
exports.IndexedDBWalletRepository = IndexedDBWalletRepository;
|
|
16148
|
+
exports.MESSAGE_BUS_INITIALIZING = MESSAGE_BUS_INITIALIZING;
|
|
15896
16149
|
exports.MESSAGE_BUS_NOT_INITIALIZED = MESSAGE_BUS_NOT_INITIALIZED;
|
|
15897
16150
|
exports.MIGRATION_KEY = MIGRATION_KEY;
|
|
15898
16151
|
exports.MessageBus = MessageBus;
|
|
16152
|
+
exports.MessageBusInitializingError = MessageBusInitializingError;
|
|
15899
16153
|
exports.MessageBusNotInitializedError = MessageBusNotInitializedError;
|
|
15900
16154
|
exports.MissingSigningDescriptorError = MissingSigningDescriptorError;
|
|
15901
16155
|
exports.MnemonicIdentity = MnemonicIdentity;
|
|
@@ -15923,6 +16177,7 @@ exports.WalletMessageHandler = WalletMessageHandler;
|
|
|
15923
16177
|
exports.WalletNotInitializedError = WalletNotInitializedError;
|
|
15924
16178
|
exports.WalletRepositoryImpl = WalletRepositoryImpl;
|
|
15925
16179
|
exports.WsElectrumChainSource = WsElectrumChainSource;
|
|
16180
|
+
exports.boardingResolver = boardingResolver;
|
|
15926
16181
|
exports.buildForfeitTx = buildForfeitTx;
|
|
15927
16182
|
exports.buildOffchainTx = buildOffchainTx;
|
|
15928
16183
|
exports.classifyAgainstSignerSet = classifyAgainstSignerSet;
|
|
@@ -15931,6 +16186,7 @@ exports.closeDatabase = closeDatabase;
|
|
|
15931
16186
|
exports.combineTapscriptSigs = combineTapscriptSigs;
|
|
15932
16187
|
exports.contractFromArkContract = contractFromArkContract;
|
|
15933
16188
|
exports.contractFromArkContractWithAddress = contractFromArkContractWithAddress;
|
|
16189
|
+
exports.createDefaultActivityRegistry = createDefaultActivityRegistry;
|
|
15934
16190
|
exports.decodeArkContract = decodeArkContract;
|
|
15935
16191
|
exports.deserializeAssets = deserializeAssets;
|
|
15936
16192
|
exports.deserializeUtxo = deserializeUtxo;
|
|
@@ -15968,5 +16224,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
15968
16224
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
15969
16225
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
15970
16226
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
15971
|
-
//# sourceMappingURL=chunk-
|
|
15972
|
-
//# sourceMappingURL=chunk-
|
|
16227
|
+
//# sourceMappingURL=chunk-3MPXMLP4.cjs.map
|
|
16228
|
+
//# sourceMappingURL=chunk-3MPXMLP4.cjs.map
|