@arkade-os/sdk 0.4.50 → 0.4.51
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 +33 -8
- package/dist/adapters/expo.cjs +4 -4
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +2 -2
- package/dist/adapters/indexedDB.cjs +3 -3
- package/dist/adapters/indexedDB.js +2 -2
- package/dist/{ark-ApoclKQZ.d.cts → ark-9V45Anrs.d.cts} +105 -1
- package/dist/{ark-ApoclKQZ.d.ts → ark-9V45Anrs.d.ts} +105 -1
- package/dist/{asyncStorageTaskQueue-CIjgv1co.d.cts → asyncStorageTaskQueue-B6nXJv7m.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-BCWmdVg8.d.ts → asyncStorageTaskQueue-BZjR843B.d.ts} +1 -1
- package/dist/{chunk-AA4Q2J57.js → chunk-3AOTJZQ4.js} +3 -3
- package/dist/{chunk-AA4Q2J57.js.map → chunk-3AOTJZQ4.js.map} +1 -1
- package/dist/{chunk-Q4K2RSMY.cjs → chunk-3E4GDBYU.cjs} +7 -7
- package/dist/{chunk-Q4K2RSMY.cjs.map → chunk-3E4GDBYU.cjs.map} +1 -1
- package/dist/{chunk-7WSVP7DK.js → chunk-4KGT3IP2.js} +3 -3
- package/dist/{chunk-7WSVP7DK.js.map → chunk-4KGT3IP2.js.map} +1 -1
- package/dist/{chunk-TO3SR7TY.cjs → chunk-5AT2NV5G.cjs} +11 -11
- package/dist/{chunk-TO3SR7TY.cjs.map → chunk-5AT2NV5G.cjs.map} +1 -1
- package/dist/{chunk-ZXRSSBCF.js → chunk-6T5BBPKO.js} +3 -3
- package/dist/{chunk-ZXRSSBCF.js.map → chunk-6T5BBPKO.js.map} +1 -1
- package/dist/{chunk-6BQTROB4.cjs → chunk-6XF6ZATZ.cjs} +427 -163
- package/dist/chunk-6XF6ZATZ.cjs.map +1 -0
- package/dist/{chunk-SIAVTHMZ.cjs → chunk-FHDUEBBC.cjs} +3 -3
- package/dist/{chunk-SIAVTHMZ.cjs.map → chunk-FHDUEBBC.cjs.map} +1 -1
- package/dist/{chunk-SNTSB6M2.js → chunk-TS2MTRP4.js} +323 -59
- package/dist/chunk-TS2MTRP4.js.map +1 -0
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/{delegate-hJYMZN1D.d.ts → delegate-CJkolr2s.d.ts} +1 -1
- package/dist/{delegate-CCHPwQft.d.cts → delegate-tVTPM4fm.d.cts} +1 -1
- package/dist/{index-5Y9h9OnO.d.ts → index-B5Fdwzs_.d.ts} +2 -2
- package/dist/{index-8jE1XJpT.d.cts → index-BBAffp_8.d.cts} +2 -2
- package/dist/index.cjs +145 -145
- package/dist/index.d.cts +24 -8
- package/dist/index.d.ts +24 -8
- package/dist/index.js +2 -2
- package/dist/repositories/realm/index.cjs +17 -17
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +3 -3
- package/dist/repositories/sqlite/index.cjs +16 -16
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +3 -3
- package/dist/{taskRunner-C3YLaM2x.d.cts → taskRunner-4CrJaWHv.d.cts} +1 -1
- package/dist/{taskRunner-ChvV6Xrh.d.ts → taskRunner-TgdjRf_b.d.ts} +1 -1
- package/dist/wallet/expo/background.cjs +12 -12
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +4 -4
- package/dist/wallet/expo/index.cjs +12 -12
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +3 -3
- package/dist/{wallet-DIH0gVfW.d.ts → wallet-BBfhZx_Z.d.cts} +22 -3
- package/dist/{wallet-B260BTJs.d.cts → wallet-CSSTN8Yc.d.ts} +22 -3
- package/dist/worker/expo/index.cjs +7 -7
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-6BQTROB4.cjs.map +0 -1
- package/dist/chunk-SNTSB6M2.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkFHDUEBBC_cjs = require('./chunk-FHDUEBBC.cjs');
|
|
4
4
|
var chunkLJQ2VQBE_cjs = require('./chunk-LJQ2VQBE.cjs');
|
|
5
5
|
var chunkE7HB3GKK_cjs = require('./chunk-E7HB3GKK.cjs');
|
|
6
6
|
var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
|
|
@@ -185,7 +185,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
185
185
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
186
186
|
const tx = this.graph.find(txid);
|
|
187
187
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
188
|
-
const cosigners =
|
|
188
|
+
const cosigners = chunkFHDUEBBC_cjs.getArkPsbtFields(tx.root, 0, chunkFHDUEBBC_cjs.CosignerPublicKey).map(
|
|
189
189
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
190
190
|
// xonly pubkey
|
|
191
191
|
);
|
|
@@ -237,7 +237,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
237
237
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
238
238
|
const prevoutAmounts = [];
|
|
239
239
|
const prevoutScripts = [];
|
|
240
|
-
const cosigners =
|
|
240
|
+
const cosigners = chunkFHDUEBBC_cjs.getArkPsbtFields(g.root, 0, chunkFHDUEBBC_cjs.CosignerPublicKey).map((c) => c.key);
|
|
241
241
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
242
242
|
taprootTweak: this.scriptRoot
|
|
243
243
|
});
|
|
@@ -986,14 +986,14 @@ var RestDelegateProvider = class {
|
|
|
986
986
|
*/
|
|
987
987
|
async delegate(intent, forfeitTxs, options) {
|
|
988
988
|
const url = `${this.url}/v1/delegate`;
|
|
989
|
-
const response = await
|
|
989
|
+
const response = await chunkFHDUEBBC_cjs.baseFetch(url, {
|
|
990
990
|
method: "POST",
|
|
991
991
|
headers: {
|
|
992
992
|
"Content-Type": "application/json"
|
|
993
993
|
},
|
|
994
994
|
body: JSON.stringify({
|
|
995
995
|
intent: {
|
|
996
|
-
message:
|
|
996
|
+
message: chunkFHDUEBBC_cjs.Intent.encodeMessage(intent.message),
|
|
997
997
|
proof: intent.proof
|
|
998
998
|
},
|
|
999
999
|
forfeit_txs: forfeitTxs,
|
|
@@ -1013,7 +1013,7 @@ var RestDelegateProvider = class {
|
|
|
1013
1013
|
*/
|
|
1014
1014
|
async getDelegateInfo() {
|
|
1015
1015
|
const url = `${this.url}/v1/delegator/info`;
|
|
1016
|
-
const response = await
|
|
1016
|
+
const response = await chunkFHDUEBBC_cjs.rateGate.runHttp(url, () => chunkFHDUEBBC_cjs.baseFetch(url));
|
|
1017
1017
|
if (!response.ok) {
|
|
1018
1018
|
const errorText2 = await response.text();
|
|
1019
1019
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1049,14 +1049,14 @@ var EsploraProvider = class {
|
|
|
1049
1049
|
pollingInterval;
|
|
1050
1050
|
forcePolling;
|
|
1051
1051
|
async getCoins(address) {
|
|
1052
|
-
const response = await
|
|
1052
|
+
const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1053
1053
|
if (!response.ok) {
|
|
1054
1054
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1055
1055
|
}
|
|
1056
1056
|
return response.json();
|
|
1057
1057
|
}
|
|
1058
1058
|
async getFeeRate() {
|
|
1059
|
-
const response = await
|
|
1059
|
+
const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1060
1060
|
if (response.status === 404) {
|
|
1061
1061
|
return void 0;
|
|
1062
1062
|
}
|
|
@@ -1077,7 +1077,7 @@ var EsploraProvider = class {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
}
|
|
1079
1079
|
async getTxOutspends(txid) {
|
|
1080
|
-
const response = await
|
|
1080
|
+
const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1081
1081
|
if (!response.ok) {
|
|
1082
1082
|
const error = await response.text();
|
|
1083
1083
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1085,7 +1085,7 @@ var EsploraProvider = class {
|
|
|
1085
1085
|
return response.json();
|
|
1086
1086
|
}
|
|
1087
1087
|
async getTransactions(address) {
|
|
1088
|
-
const response = await
|
|
1088
|
+
const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1089
1089
|
if (!response.ok) {
|
|
1090
1090
|
const error = await response.text();
|
|
1091
1091
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1093,7 +1093,7 @@ var EsploraProvider = class {
|
|
|
1093
1093
|
return response.json();
|
|
1094
1094
|
}
|
|
1095
1095
|
async getTxStatus(txid) {
|
|
1096
|
-
const txresponse = await
|
|
1096
|
+
const txresponse = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1097
1097
|
if (!txresponse.ok) {
|
|
1098
1098
|
throw new Error(txresponse.statusText);
|
|
1099
1099
|
}
|
|
@@ -1101,7 +1101,7 @@ var EsploraProvider = class {
|
|
|
1101
1101
|
if (!tx.status.confirmed) {
|
|
1102
1102
|
return { confirmed: false };
|
|
1103
1103
|
}
|
|
1104
|
-
const response = await
|
|
1104
|
+
const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1105
1105
|
if (!response.ok) {
|
|
1106
1106
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1107
1107
|
}
|
|
@@ -1185,7 +1185,7 @@ var EsploraProvider = class {
|
|
|
1185
1185
|
return stopFunc;
|
|
1186
1186
|
}
|
|
1187
1187
|
async getChainTip() {
|
|
1188
|
-
const tipBlocks = await
|
|
1188
|
+
const tipBlocks = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
1189
1189
|
if (!tipBlocks.ok) {
|
|
1190
1190
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
1191
1191
|
}
|
|
@@ -1204,7 +1204,7 @@ var EsploraProvider = class {
|
|
|
1204
1204
|
};
|
|
1205
1205
|
}
|
|
1206
1206
|
async broadcastPackage(parent, child) {
|
|
1207
|
-
const response = await
|
|
1207
|
+
const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
1208
1208
|
method: "POST",
|
|
1209
1209
|
headers: {
|
|
1210
1210
|
"Content-Type": "application/json"
|
|
@@ -1218,7 +1218,7 @@ var EsploraProvider = class {
|
|
|
1218
1218
|
return response.json();
|
|
1219
1219
|
}
|
|
1220
1220
|
async broadcastTx(tx) {
|
|
1221
|
-
const response = await
|
|
1221
|
+
const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
1222
1222
|
method: "POST",
|
|
1223
1223
|
headers: {
|
|
1224
1224
|
"Content-Type": "text/plain"
|
|
@@ -1380,7 +1380,7 @@ function findP2AOutput(tx) {
|
|
|
1380
1380
|
var CHILD_DUST_AMOUNT = 546;
|
|
1381
1381
|
function buildAnchorChild(params) {
|
|
1382
1382
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
1383
|
-
const child = new
|
|
1383
|
+
const child = new chunkFHDUEBBC_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
1384
1384
|
child.addInput(findP2AOutput(parent));
|
|
1385
1385
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
1386
1386
|
for (const _ of fundingCoins) {
|
|
@@ -1428,7 +1428,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
1428
1428
|
);
|
|
1429
1429
|
}
|
|
1430
1430
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
1431
|
-
const tx = new
|
|
1431
|
+
const tx = new chunkFHDUEBBC_cjs.Transaction({
|
|
1432
1432
|
version: 3,
|
|
1433
1433
|
lockTime: txLocktime
|
|
1434
1434
|
});
|
|
@@ -1504,7 +1504,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
1504
1504
|
if (previousScriptKey.length !== 32) {
|
|
1505
1505
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
1506
1506
|
}
|
|
1507
|
-
const cosigners =
|
|
1507
|
+
const cosigners = chunkFHDUEBBC_cjs.getArkPsbtFields(child.root, 0, chunkFHDUEBBC_cjs.CosignerPublicKey);
|
|
1508
1508
|
if (cosigners.length === 0) {
|
|
1509
1509
|
throw ErrMissingCosignersPublicKeys;
|
|
1510
1510
|
}
|
|
@@ -1562,7 +1562,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
1562
1562
|
return new _EmulatorPacket(entries);
|
|
1563
1563
|
}
|
|
1564
1564
|
static fromBytes(data) {
|
|
1565
|
-
const reader = new
|
|
1565
|
+
const reader = new chunkFHDUEBBC_cjs.BufferReader(data);
|
|
1566
1566
|
const entryCount = reader.readCompactSize();
|
|
1567
1567
|
const entries = [];
|
|
1568
1568
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -1580,7 +1580,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
1580
1580
|
return _EmulatorPacket.PACKET_TYPE;
|
|
1581
1581
|
}
|
|
1582
1582
|
serialize() {
|
|
1583
|
-
const writer = new
|
|
1583
|
+
const writer = new chunkFHDUEBBC_cjs.BufferWriter();
|
|
1584
1584
|
writer.writeCompactSize(this.entries.length);
|
|
1585
1585
|
for (const entry of this.entries) {
|
|
1586
1586
|
writer.writeUint16LE(entry.vin);
|
|
@@ -1667,7 +1667,7 @@ var Extension = class _Extension {
|
|
|
1667
1667
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
1668
1668
|
);
|
|
1669
1669
|
}
|
|
1670
|
-
const reader = new
|
|
1670
|
+
const reader = new chunkFHDUEBBC_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
1671
1671
|
const packets = [];
|
|
1672
1672
|
while (reader.remaining() > 0) {
|
|
1673
1673
|
const packetType = reader.readByte();
|
|
@@ -1741,7 +1741,7 @@ var Extension = class _Extension {
|
|
|
1741
1741
|
*/
|
|
1742
1742
|
getAssetPacket() {
|
|
1743
1743
|
for (const p of this.packets) {
|
|
1744
|
-
if (p instanceof
|
|
1744
|
+
if (p instanceof chunkFHDUEBBC_cjs.Packet) {
|
|
1745
1745
|
return p;
|
|
1746
1746
|
}
|
|
1747
1747
|
}
|
|
@@ -1779,8 +1779,8 @@ var Extension = class _Extension {
|
|
|
1779
1779
|
};
|
|
1780
1780
|
function parsePacket(packetType, data) {
|
|
1781
1781
|
switch (packetType) {
|
|
1782
|
-
case
|
|
1783
|
-
return
|
|
1782
|
+
case chunkFHDUEBBC_cjs.Packet.PACKET_TYPE:
|
|
1783
|
+
return chunkFHDUEBBC_cjs.Packet.fromBytes(data);
|
|
1784
1784
|
case EmulatorPacket.PACKET_TYPE:
|
|
1785
1785
|
return EmulatorPacket.fromBytes(data);
|
|
1786
1786
|
default:
|
|
@@ -2077,7 +2077,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2077
2077
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
2078
2078
|
inputsByAssetId.set(asset.assetId, [
|
|
2079
2079
|
...existing ?? [],
|
|
2080
|
-
|
|
2080
|
+
chunkFHDUEBBC_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
2081
2081
|
]);
|
|
2082
2082
|
}
|
|
2083
2083
|
}
|
|
@@ -2089,7 +2089,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2089
2089
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2090
2090
|
outputsByAssetId.set(asset.assetId, [
|
|
2091
2091
|
...existing ?? [],
|
|
2092
|
-
|
|
2092
|
+
chunkFHDUEBBC_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2093
2093
|
]);
|
|
2094
2094
|
}
|
|
2095
2095
|
}
|
|
@@ -2100,7 +2100,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2100
2100
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2101
2101
|
outputsByAssetId.set(asset.assetId, [
|
|
2102
2102
|
...existing ?? [],
|
|
2103
|
-
|
|
2103
|
+
chunkFHDUEBBC_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2104
2104
|
]);
|
|
2105
2105
|
}
|
|
2106
2106
|
}
|
|
@@ -2109,11 +2109,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2109
2109
|
for (const assetIdStr of allAssetIds) {
|
|
2110
2110
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
2111
2111
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
2112
|
-
const assetId =
|
|
2113
|
-
const group =
|
|
2112
|
+
const assetId = chunkFHDUEBBC_cjs.AssetId.fromString(assetIdStr);
|
|
2113
|
+
const group = chunkFHDUEBBC_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
2114
2114
|
groups.push(group);
|
|
2115
2115
|
}
|
|
2116
|
-
return
|
|
2116
|
+
return chunkFHDUEBBC_cjs.Packet.create(groups);
|
|
2117
2117
|
}
|
|
2118
2118
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
2119
2119
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -2230,7 +2230,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2230
2230
|
}
|
|
2231
2231
|
}
|
|
2232
2232
|
}
|
|
2233
|
-
const tx = new
|
|
2233
|
+
const tx = new chunkFHDUEBBC_cjs.Transaction({
|
|
2234
2234
|
version: 3,
|
|
2235
2235
|
lockTime: Number(lockTime)
|
|
2236
2236
|
});
|
|
@@ -2245,7 +2245,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2245
2245
|
},
|
|
2246
2246
|
tapLeafScript: [input.tapLeafScript]
|
|
2247
2247
|
});
|
|
2248
|
-
|
|
2248
|
+
chunkFHDUEBBC_cjs.setArkPsbtField(tx, i, chunkFHDUEBBC_cjs.VtxoTaprootTree, input.tapTree);
|
|
2249
2249
|
}
|
|
2250
2250
|
for (const output of outputs) {
|
|
2251
2251
|
tx.addOutput(output);
|
|
@@ -2428,14 +2428,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks) {
|
|
|
2428
2428
|
let finalCheckpoints;
|
|
2429
2429
|
if (userSignedCheckpoints) {
|
|
2430
2430
|
finalCheckpoints = signedCheckpointTxs.map((c, i) => {
|
|
2431
|
-
const serverSigned =
|
|
2431
|
+
const serverSigned = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(c));
|
|
2432
2432
|
combineTapscriptSigs(userSignedCheckpoints[i], serverSigned);
|
|
2433
2433
|
return base.base64.encode(serverSigned.toPSBT());
|
|
2434
2434
|
});
|
|
2435
2435
|
} else {
|
|
2436
2436
|
finalCheckpoints = await Promise.all(
|
|
2437
2437
|
signedCheckpointTxs.map(async (c) => {
|
|
2438
|
-
const tx =
|
|
2438
|
+
const tx = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(c));
|
|
2439
2439
|
const signed = await signer.signCheckpoint(tx);
|
|
2440
2440
|
return base.base64.encode(signed.toPSBT());
|
|
2441
2441
|
})
|
|
@@ -3339,7 +3339,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3339
3339
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
3340
3340
|
);
|
|
3341
3341
|
}
|
|
3342
|
-
const tx = new
|
|
3342
|
+
const tx = new chunkFHDUEBBC_cjs.Transaction();
|
|
3343
3343
|
for (const utxo of expiredUtxos) {
|
|
3344
3344
|
const utxoScript = chunkE7HB3GKK_cjs.VtxoScript.decode(utxo.tapTree);
|
|
3345
3345
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
@@ -3998,8 +3998,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
3998
3998
|
* or doesn't carry the metadata.
|
|
3999
3999
|
*/
|
|
4000
4000
|
extractSpentOutpoint(error) {
|
|
4001
|
-
const ark =
|
|
4002
|
-
if (!
|
|
4001
|
+
const ark = chunkFHDUEBBC_cjs.maybeArkError(error);
|
|
4002
|
+
if (!chunkFHDUEBBC_cjs.isArkError(ark, chunkFHDUEBBC_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
4003
4003
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
4004
4004
|
if (typeof raw !== "string") return void 0;
|
|
4005
4005
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -4734,7 +4734,7 @@ async function captureExitBranch(params) {
|
|
|
4734
4734
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
4735
4735
|
if (nonCommitment.length > 0) {
|
|
4736
4736
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
4737
|
-
psbtByTxid.set(
|
|
4737
|
+
psbtByTxid.set(chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
4738
4738
|
}
|
|
4739
4739
|
}
|
|
4740
4740
|
}
|
|
@@ -4795,7 +4795,7 @@ var IndexerExitDataSource = class {
|
|
|
4795
4795
|
pageSize: chunkE7HB3GKK_cjs.DEFAULT_PAGE_SIZE
|
|
4796
4796
|
});
|
|
4797
4797
|
for (const psbt of txs) {
|
|
4798
|
-
out.set(
|
|
4798
|
+
out.set(chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
4799
4799
|
}
|
|
4800
4800
|
hasMore = page ? txs.length === chunkE7HB3GKK_cjs.DEFAULT_PAGE_SIZE : false;
|
|
4801
4801
|
pageIndex++;
|
|
@@ -4818,7 +4818,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
4818
4818
|
}
|
|
4819
4819
|
}
|
|
4820
4820
|
function psbtInputTxids(psbtBase64) {
|
|
4821
|
-
const tx =
|
|
4821
|
+
const tx = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
4822
4822
|
const ids = [];
|
|
4823
4823
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
4824
4824
|
const txid = tx.getInput(i).txid;
|
|
@@ -4921,7 +4921,7 @@ function createExitChainResolver(params) {
|
|
|
4921
4921
|
|
|
4922
4922
|
// src/providers/availability.ts
|
|
4923
4923
|
function isRetryableProviderError(error) {
|
|
4924
|
-
return error instanceof
|
|
4924
|
+
return error instanceof chunkFHDUEBBC_cjs.ProviderUnavailableError || error instanceof chunkFHDUEBBC_cjs.FetchError || chunkFHDUEBBC_cjs.isFetchTimeoutError(error);
|
|
4925
4925
|
}
|
|
4926
4926
|
|
|
4927
4927
|
// src/utils/syncCursors.ts
|
|
@@ -5174,7 +5174,7 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
5174
5174
|
if (!isRetryableProviderError(err)) throw err;
|
|
5175
5175
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
5176
5176
|
if (!snapshot) {
|
|
5177
|
-
throw new
|
|
5177
|
+
throw new chunkFHDUEBBC_cjs.ProviderUnavailableError(
|
|
5178
5178
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
5179
5179
|
{ cause: err }
|
|
5180
5180
|
);
|
|
@@ -5709,7 +5709,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5709
5709
|
const virtualCoins = await this.wallet.getVtxos({
|
|
5710
5710
|
withRecoverable: false
|
|
5711
5711
|
});
|
|
5712
|
-
const controlAssetRef = params.controlAssetId ?
|
|
5712
|
+
const controlAssetRef = params.controlAssetId ? chunkFHDUEBBC_cjs.AssetRef.fromId(chunkFHDUEBBC_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
5713
5713
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
5714
5714
|
let totalBtcSelected = 0n;
|
|
5715
5715
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -5722,8 +5722,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5722
5722
|
}
|
|
5723
5723
|
}
|
|
5724
5724
|
const groups = [];
|
|
5725
|
-
const issuedAssetOutput =
|
|
5726
|
-
const issuedAssetGroup =
|
|
5725
|
+
const issuedAssetOutput = chunkFHDUEBBC_cjs.AssetOutput.create(0, params.amount);
|
|
5726
|
+
const issuedAssetGroup = chunkFHDUEBBC_cjs.AssetGroup.create(
|
|
5727
5727
|
null,
|
|
5728
5728
|
controlAssetRef,
|
|
5729
5729
|
[],
|
|
@@ -5738,15 +5738,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5738
5738
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5739
5739
|
for (const asset of assets) {
|
|
5740
5740
|
if (asset.assetId !== assetId) continue;
|
|
5741
|
-
changeInputs.push(
|
|
5741
|
+
changeInputs.push(chunkFHDUEBBC_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5742
5742
|
}
|
|
5743
5743
|
}
|
|
5744
5744
|
groups.push(
|
|
5745
|
-
|
|
5746
|
-
|
|
5745
|
+
chunkFHDUEBBC_cjs.AssetGroup.create(
|
|
5746
|
+
chunkFHDUEBBC_cjs.AssetId.fromString(assetId),
|
|
5747
5747
|
null,
|
|
5748
5748
|
changeInputs,
|
|
5749
|
-
[
|
|
5749
|
+
[chunkFHDUEBBC_cjs.AssetOutput.create(0, amount)],
|
|
5750
5750
|
[]
|
|
5751
5751
|
)
|
|
5752
5752
|
);
|
|
@@ -5759,7 +5759,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5759
5759
|
script: outputAddress.pkScript,
|
|
5760
5760
|
amount: BigInt(totalBtcSelected)
|
|
5761
5761
|
},
|
|
5762
|
-
Extension.create([
|
|
5762
|
+
Extension.create([chunkFHDUEBBC_cjs.Packet.create(groups)]).txOut()
|
|
5763
5763
|
];
|
|
5764
5764
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
5765
5765
|
coinSelection.inputs,
|
|
@@ -5767,7 +5767,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5767
5767
|
);
|
|
5768
5768
|
return {
|
|
5769
5769
|
arkTxId: arkTxid,
|
|
5770
|
-
assetId:
|
|
5770
|
+
assetId: chunkFHDUEBBC_cjs.AssetId.create(arkTxid, 0).toString()
|
|
5771
5771
|
};
|
|
5772
5772
|
}
|
|
5773
5773
|
/**
|
|
@@ -5839,16 +5839,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5839
5839
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5840
5840
|
for (const asset of assets) {
|
|
5841
5841
|
if (asset.assetId !== params.assetId) continue;
|
|
5842
|
-
reissueInputs.push(
|
|
5842
|
+
reissueInputs.push(chunkFHDUEBBC_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5843
5843
|
}
|
|
5844
5844
|
}
|
|
5845
5845
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
5846
|
-
const reissueAssetIdObj =
|
|
5847
|
-
const reissueAssetGroup =
|
|
5846
|
+
const reissueAssetIdObj = chunkFHDUEBBC_cjs.AssetId.fromString(params.assetId);
|
|
5847
|
+
const reissueAssetGroup = chunkFHDUEBBC_cjs.AssetGroup.create(
|
|
5848
5848
|
reissueAssetIdObj,
|
|
5849
5849
|
null,
|
|
5850
5850
|
reissueInputs,
|
|
5851
|
-
[
|
|
5851
|
+
[chunkFHDUEBBC_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
5852
5852
|
[]
|
|
5853
5853
|
);
|
|
5854
5854
|
const groups = [reissueAssetGroup];
|
|
@@ -5857,15 +5857,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5857
5857
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5858
5858
|
for (const asset of assets) {
|
|
5859
5859
|
if (asset.assetId !== assetId) continue;
|
|
5860
|
-
changeInputs.push(
|
|
5860
|
+
changeInputs.push(chunkFHDUEBBC_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5861
5861
|
}
|
|
5862
5862
|
}
|
|
5863
5863
|
groups.push(
|
|
5864
|
-
|
|
5865
|
-
|
|
5864
|
+
chunkFHDUEBBC_cjs.AssetGroup.create(
|
|
5865
|
+
chunkFHDUEBBC_cjs.AssetId.fromString(assetId),
|
|
5866
5866
|
null,
|
|
5867
5867
|
changeInputs,
|
|
5868
|
-
[
|
|
5868
|
+
[chunkFHDUEBBC_cjs.AssetOutput.create(0, amount)],
|
|
5869
5869
|
[]
|
|
5870
5870
|
)
|
|
5871
5871
|
);
|
|
@@ -5877,7 +5877,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5877
5877
|
script: outputAddress.pkScript,
|
|
5878
5878
|
amount: BigInt(totalBtcSelected)
|
|
5879
5879
|
},
|
|
5880
|
-
Extension.create([
|
|
5880
|
+
Extension.create([chunkFHDUEBBC_cjs.Packet.create(groups)]).txOut()
|
|
5881
5881
|
];
|
|
5882
5882
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
5883
5883
|
return arkTxid;
|
|
@@ -5944,15 +5944,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5944
5944
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5945
5945
|
for (const asset of assets) {
|
|
5946
5946
|
if (asset.assetId !== assetId) continue;
|
|
5947
|
-
changeInputs.push(
|
|
5947
|
+
changeInputs.push(chunkFHDUEBBC_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5948
5948
|
}
|
|
5949
5949
|
}
|
|
5950
5950
|
groups.push(
|
|
5951
|
-
|
|
5952
|
-
|
|
5951
|
+
chunkFHDUEBBC_cjs.AssetGroup.create(
|
|
5952
|
+
chunkFHDUEBBC_cjs.AssetId.fromString(assetId),
|
|
5953
5953
|
null,
|
|
5954
5954
|
changeInputs,
|
|
5955
|
-
amount > 0n ? [
|
|
5955
|
+
amount > 0n ? [chunkFHDUEBBC_cjs.AssetOutput.create(0, amount)] : [],
|
|
5956
5956
|
[]
|
|
5957
5957
|
)
|
|
5958
5958
|
);
|
|
@@ -5964,7 +5964,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5964
5964
|
script: outputAddress.pkScript,
|
|
5965
5965
|
amount: BigInt(totalBtcSelected)
|
|
5966
5966
|
},
|
|
5967
|
-
Extension.create([
|
|
5967
|
+
Extension.create([chunkFHDUEBBC_cjs.Packet.create(groups)]).txOut()
|
|
5968
5968
|
];
|
|
5969
5969
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
5970
5970
|
return arkTxid;
|
|
@@ -5989,7 +5989,7 @@ function castMetadata(metadata) {
|
|
|
5989
5989
|
} else {
|
|
5990
5990
|
throw new Error("Invalid metadata value type");
|
|
5991
5991
|
}
|
|
5992
|
-
md.push(
|
|
5992
|
+
md.push(chunkFHDUEBBC_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
5993
5993
|
}
|
|
5994
5994
|
return md;
|
|
5995
5995
|
}
|
|
@@ -6273,7 +6273,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
6273
6273
|
expire_at: 0,
|
|
6274
6274
|
cosigners_public_keys: cosignerPubKeys
|
|
6275
6275
|
};
|
|
6276
|
-
const proof =
|
|
6276
|
+
const proof = chunkFHDUEBBC_cjs.Intent.create(message, coins, outputs);
|
|
6277
6277
|
const signedProof = await identity.sign(proof);
|
|
6278
6278
|
return {
|
|
6279
6279
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -8322,7 +8322,7 @@ var ContractWatcher = class {
|
|
|
8322
8322
|
this.connectionState = "connected";
|
|
8323
8323
|
this.reconnectAttempts = 0;
|
|
8324
8324
|
this.listenLoop().catch((e) => {
|
|
8325
|
-
if (
|
|
8325
|
+
if (chunkFHDUEBBC_cjs.isEventSourceError(e)) {
|
|
8326
8326
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8327
8327
|
} else {
|
|
8328
8328
|
console.error(e);
|
|
@@ -8735,6 +8735,9 @@ function dedupeOutpoints(outpoints) {
|
|
|
8735
8735
|
function areCoalescibleContractTypes(a, b) {
|
|
8736
8736
|
return a === "default" && b === "boarding" || a === "boarding" && b === "default";
|
|
8737
8737
|
}
|
|
8738
|
+
function toWatchOnlyContract(params) {
|
|
8739
|
+
return { ...params, state: params.state ?? "active", createdAt: Date.now() };
|
|
8740
|
+
}
|
|
8738
8741
|
var SCAN_MAX_INDEX = 1e4;
|
|
8739
8742
|
var DEFAULT_SCAN_BATCH = 10;
|
|
8740
8743
|
var ContractManager = class _ContractManager {
|
|
@@ -8747,6 +8750,12 @@ var ContractManager = class _ContractManager {
|
|
|
8747
8750
|
syncDegradedReason;
|
|
8748
8751
|
/** Epoch-ms of the last successful provider sync, if any. */
|
|
8749
8752
|
lastSyncedAt;
|
|
8753
|
+
/** Speculative look-ahead scripts, keyed by script. @see LookAheadEntry */
|
|
8754
|
+
lookAheadEntries = /* @__PURE__ */ new Map();
|
|
8755
|
+
/** In-flight look-ahead drain, if any. @see scheduleLookAheadDrain */
|
|
8756
|
+
lookAheadDrain;
|
|
8757
|
+
/** A refill was requested while a drain was running. */
|
|
8758
|
+
lookAheadDirty = false;
|
|
8750
8759
|
constructor(config) {
|
|
8751
8760
|
this.config = config;
|
|
8752
8761
|
this.watcher = new ContractWatcher({
|
|
@@ -8797,6 +8806,7 @@ var ContractManager = class _ContractManager {
|
|
|
8797
8806
|
for (const contract of contracts) {
|
|
8798
8807
|
await this.watcher.addContract(contract);
|
|
8799
8808
|
}
|
|
8809
|
+
await this.scheduleLookAheadDrain();
|
|
8800
8810
|
try {
|
|
8801
8811
|
await this.reconcileWatched();
|
|
8802
8812
|
this.markSyncOnline();
|
|
@@ -8848,6 +8858,156 @@ var ContractManager = class _ContractManager {
|
|
|
8848
8858
|
console.error("ContractManager: intent reconciliation failed", e);
|
|
8849
8859
|
}
|
|
8850
8860
|
}
|
|
8861
|
+
/** @see IContractManager.refillLookAhead */
|
|
8862
|
+
refillLookAhead() {
|
|
8863
|
+
return this.scheduleLookAheadDrain();
|
|
8864
|
+
}
|
|
8865
|
+
/**
|
|
8866
|
+
* Serialized drain of the look-ahead band: concurrent callers join the
|
|
8867
|
+
* active drain and mark it dirty, an idle call starts a new one. Promotion
|
|
8868
|
+
* can uncover more funded indices, and boot / SSE / rotate / reconnect can
|
|
8869
|
+
* all request a refill at once, so the loop coalesces them instead of
|
|
8870
|
+
* recursing.
|
|
8871
|
+
*/
|
|
8872
|
+
scheduleLookAheadDrain() {
|
|
8873
|
+
if (!this.config.lookAhead) return Promise.resolve();
|
|
8874
|
+
if (this.lookAheadDrain) {
|
|
8875
|
+
this.lookAheadDirty = true;
|
|
8876
|
+
return this.lookAheadDrain;
|
|
8877
|
+
}
|
|
8878
|
+
const drain = (async () => {
|
|
8879
|
+
do {
|
|
8880
|
+
this.lookAheadDirty = false;
|
|
8881
|
+
await this.ensureLookAhead();
|
|
8882
|
+
} while (this.lookAheadDirty);
|
|
8883
|
+
})().finally(() => {
|
|
8884
|
+
this.lookAheadDrain = void 0;
|
|
8885
|
+
});
|
|
8886
|
+
this.lookAheadDrain = drain;
|
|
8887
|
+
return drain;
|
|
8888
|
+
}
|
|
8889
|
+
/**
|
|
8890
|
+
* Request a drain without awaiting it. Used from inside a sync (promotion),
|
|
8891
|
+
* where awaiting the drain that the sync itself is part of would deadlock.
|
|
8892
|
+
*/
|
|
8893
|
+
requestLookAheadDrain() {
|
|
8894
|
+
if (!this.config.lookAhead) return;
|
|
8895
|
+
if (this.lookAheadDrain) {
|
|
8896
|
+
this.lookAheadDirty = true;
|
|
8897
|
+
return;
|
|
8898
|
+
}
|
|
8899
|
+
void this.scheduleLookAheadDrain().catch((err) => {
|
|
8900
|
+
console.error("ContractManager: look-ahead refill failed", err);
|
|
8901
|
+
});
|
|
8902
|
+
}
|
|
8903
|
+
/**
|
|
8904
|
+
* Rebuild the speculative watch band around the allocation watermark.
|
|
8905
|
+
*
|
|
8906
|
+
* NArk needs no analogue because it *is* the address issuer: it persists a
|
|
8907
|
+
* contract row at derivation time, so its watched set is a superset of
|
|
8908
|
+
* every address it ever advertised. This SDK, when a third party issues
|
|
8909
|
+
* addresses from the shared seed, cannot observe those allocations at all —
|
|
8910
|
+
* the window is how a non-issuer compensates.
|
|
8911
|
+
*
|
|
8912
|
+
* Entries are registered with the watcher but NOT persisted: they become
|
|
8913
|
+
* repository rows only once funded (see {@link promoteLookAheadHits}).
|
|
8914
|
+
*/
|
|
8915
|
+
async ensureLookAhead() {
|
|
8916
|
+
const lookAhead = this.config.lookAhead;
|
|
8917
|
+
if (!lookAhead) return;
|
|
8918
|
+
const watermark = await lookAhead.currentWatermark();
|
|
8919
|
+
const from = Math.max(0, watermark - lookAhead.size);
|
|
8920
|
+
const to = watermark + lookAhead.size;
|
|
8921
|
+
const band = /* @__PURE__ */ new Map();
|
|
8922
|
+
for (let index = from; index <= to; index++) {
|
|
8923
|
+
const params = lookAhead.materialize(index);
|
|
8924
|
+
band.set(params.script, { index, params });
|
|
8925
|
+
}
|
|
8926
|
+
await this.watcher.withCoalescedSubscription(async () => {
|
|
8927
|
+
const persisted = await this.config.contractRepository.getContracts({
|
|
8928
|
+
script: [...band.keys()]
|
|
8929
|
+
});
|
|
8930
|
+
const persistedScripts = new Set(persisted.map((c) => c.script));
|
|
8931
|
+
for (const [script, { index, params }] of band) {
|
|
8932
|
+
if (persistedScripts.has(script)) {
|
|
8933
|
+
this.lookAheadEntries.delete(script);
|
|
8934
|
+
continue;
|
|
8935
|
+
}
|
|
8936
|
+
if (this.lookAheadEntries.has(script)) continue;
|
|
8937
|
+
const contract = toWatchOnlyContract(params);
|
|
8938
|
+
this.lookAheadEntries.set(script, {
|
|
8939
|
+
index,
|
|
8940
|
+
params,
|
|
8941
|
+
contract,
|
|
8942
|
+
catchUpPending: true
|
|
8943
|
+
});
|
|
8944
|
+
await this.watcher.addContract(contract);
|
|
8945
|
+
}
|
|
8946
|
+
const stale = [...this.lookAheadEntries.keys()].filter((s) => !band.has(s));
|
|
8947
|
+
if (stale.length > 0) {
|
|
8948
|
+
const rows = await this.config.contractRepository.getContracts({ script: stale });
|
|
8949
|
+
const nowPersisted = new Set(rows.map((c) => c.script));
|
|
8950
|
+
for (const script of stale) {
|
|
8951
|
+
this.lookAheadEntries.delete(script);
|
|
8952
|
+
if (!nowPersisted.has(script)) await this.watcher.removeContract(script);
|
|
8953
|
+
}
|
|
8954
|
+
}
|
|
8955
|
+
});
|
|
8956
|
+
await this.runLookAheadCatchUp();
|
|
8957
|
+
}
|
|
8958
|
+
/**
|
|
8959
|
+
* One-time full-history sync for speculative entries the manager has not
|
|
8960
|
+
* successfully caught up on yet.
|
|
8961
|
+
*
|
|
8962
|
+
* Every normal sync uses the cursor-derived delta window and SSE only
|
|
8963
|
+
* delivers events after a script is subscribed, so a script first
|
|
8964
|
+
* registered after its funding time would otherwise be skipped forever
|
|
8965
|
+
* (upgrade migration, or a band that slid over an already-funded index).
|
|
8966
|
+
* The entries are passed as in-memory contracts because `refreshVtxos`
|
|
8967
|
+
* resolves scripts through the repository, where they deliberately do not
|
|
8968
|
+
* exist. Targeted + explicitly windowed, so the global cursor stays put.
|
|
8969
|
+
*/
|
|
8970
|
+
async runLookAheadCatchUp() {
|
|
8971
|
+
const pending = [...this.lookAheadEntries.values()].filter((e) => e.catchUpPending);
|
|
8972
|
+
if (pending.length === 0) return;
|
|
8973
|
+
try {
|
|
8974
|
+
await this.syncContracts({
|
|
8975
|
+
contracts: pending.map((e) => e.contract),
|
|
8976
|
+
window: { after: 0 }
|
|
8977
|
+
});
|
|
8978
|
+
for (const entry of pending) entry.catchUpPending = false;
|
|
8979
|
+
} catch (err) {
|
|
8980
|
+
if (!isRetryableProviderError(err)) throw err;
|
|
8981
|
+
this.markSyncDegraded(err);
|
|
8982
|
+
}
|
|
8983
|
+
}
|
|
8984
|
+
/**
|
|
8985
|
+
* Promote every look-ahead entry funded by `vtxos` into a real repository
|
|
8986
|
+
* row, returning the persisted rows keyed by script.
|
|
8987
|
+
*
|
|
8988
|
+
* MUST run on each raw indexer fetch before `annotateVtxos`:
|
|
8989
|
+
* `extendVirtualCoinForContract` throws when a VTXO's script has no
|
|
8990
|
+
* contract row, so a funded window entry has to be persisted before its
|
|
8991
|
+
* VTXOs are annotated and saved. Callers also swap the returned rows into
|
|
8992
|
+
* the local contract maps they built pre-promotion, so `saveVtxosForContract`
|
|
8993
|
+
* and `onVtxosPersisted` never see the synthetic watcher object.
|
|
8994
|
+
*/
|
|
8995
|
+
async promoteLookAheadHits(vtxos) {
|
|
8996
|
+
const promoted = /* @__PURE__ */ new Map();
|
|
8997
|
+
if (this.lookAheadEntries.size === 0) return promoted;
|
|
8998
|
+
const hits = /* @__PURE__ */ new Map();
|
|
8999
|
+
for (const vtxo of vtxos) {
|
|
9000
|
+
const entry = this.lookAheadEntries.get(vtxo.script);
|
|
9001
|
+
if (entry) hits.set(vtxo.script, entry);
|
|
9002
|
+
}
|
|
9003
|
+
if (hits.size === 0) return promoted;
|
|
9004
|
+
for (const [script, entry] of hits) {
|
|
9005
|
+
promoted.set(script, await this.persistAndWatchContract(entry.params));
|
|
9006
|
+
await this.config.lookAhead?.onPromoted?.(entry.index);
|
|
9007
|
+
}
|
|
9008
|
+
this.requestLookAheadDrain();
|
|
9009
|
+
return promoted;
|
|
9010
|
+
}
|
|
8851
9011
|
/**
|
|
8852
9012
|
* Create and register a new contract.
|
|
8853
9013
|
*
|
|
@@ -8893,6 +9053,11 @@ var ContractManager = class _ContractManager {
|
|
|
8893
9053
|
* `persisted` is `true`.
|
|
8894
9054
|
*/
|
|
8895
9055
|
async upsertContract(params) {
|
|
9056
|
+
const result = await this.upsertContractRow(params);
|
|
9057
|
+
this.lookAheadEntries.delete(params.script);
|
|
9058
|
+
return result;
|
|
9059
|
+
}
|
|
9060
|
+
async upsertContractRow(params) {
|
|
8896
9061
|
const handler = chunkLJQ2VQBE_cjs.contractHandlers.get(params.type);
|
|
8897
9062
|
if (!handler) {
|
|
8898
9063
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
@@ -9382,6 +9547,7 @@ var ContractManager = class _ContractManager {
|
|
|
9382
9547
|
}
|
|
9383
9548
|
break;
|
|
9384
9549
|
case "connection_reset":
|
|
9550
|
+
await this.scheduleLookAheadDrain();
|
|
9385
9551
|
await this.reconcileWatched();
|
|
9386
9552
|
this.markSyncOnline();
|
|
9387
9553
|
break;
|
|
@@ -9441,11 +9607,16 @@ var ContractManager = class _ContractManager {
|
|
|
9441
9607
|
contracts.map((c) => c.script),
|
|
9442
9608
|
{ pendingOnly: true }
|
|
9443
9609
|
);
|
|
9610
|
+
for (const [script, contract] of await this.promoteLookAheadHits(vtxos)) {
|
|
9611
|
+
scriptToContract.set(script, contract);
|
|
9612
|
+
}
|
|
9444
9613
|
const owned = vtxos.filter((v) => scriptToContract.has(v.script));
|
|
9445
9614
|
const annotated = await this.annotateVtxos(owned);
|
|
9446
9615
|
const byContract = /* @__PURE__ */ new Map();
|
|
9616
|
+
const contractByAddress = /* @__PURE__ */ new Map();
|
|
9447
9617
|
for (const vtxo of annotated) {
|
|
9448
9618
|
const contract = scriptToContract.get(vtxo.script);
|
|
9619
|
+
contractByAddress.set(contract.address, contract);
|
|
9449
9620
|
let arr = byContract.get(contract.address);
|
|
9450
9621
|
if (!arr) {
|
|
9451
9622
|
arr = [];
|
|
@@ -9457,7 +9628,7 @@ var ContractManager = class _ContractManager {
|
|
|
9457
9628
|
});
|
|
9458
9629
|
}
|
|
9459
9630
|
for (const [addr, contractVtxos] of byContract) {
|
|
9460
|
-
const contract =
|
|
9631
|
+
const contract = contractByAddress.get(addr);
|
|
9461
9632
|
const filtered = warnAndFilterVtxosForScript(
|
|
9462
9633
|
contractVtxos,
|
|
9463
9634
|
contract.script,
|
|
@@ -9478,11 +9649,15 @@ var ContractManager = class _ContractManager {
|
|
|
9478
9649
|
}
|
|
9479
9650
|
}
|
|
9480
9651
|
async fetchContractVxosFromIndexer(contracts, pageSize, syncWindow) {
|
|
9481
|
-
const
|
|
9652
|
+
const { vtxosByScript, promoted } = await this.fetchContractVtxosBulk(
|
|
9653
|
+
contracts,
|
|
9654
|
+
pageSize,
|
|
9655
|
+
syncWindow
|
|
9656
|
+
);
|
|
9482
9657
|
const result = /* @__PURE__ */ new Map();
|
|
9483
|
-
for (const [contractScript, vtxos] of
|
|
9658
|
+
for (const [contractScript, vtxos] of vtxosByScript) {
|
|
9484
9659
|
result.set(contractScript, vtxos);
|
|
9485
|
-
const contract = contracts.find((c) => c.script === contractScript);
|
|
9660
|
+
const contract = promoted.get(contractScript) ?? contracts.find((c) => c.script === contractScript);
|
|
9486
9661
|
if (contract) {
|
|
9487
9662
|
const filtered = warnAndFilterVtxosForScript(
|
|
9488
9663
|
vtxos,
|
|
@@ -9510,7 +9685,7 @@ var ContractManager = class _ContractManager {
|
|
|
9510
9685
|
}
|
|
9511
9686
|
async fetchContractVtxosBulk(contracts, pageSize = chunkE7HB3GKK_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
9512
9687
|
if (contracts.length === 0) {
|
|
9513
|
-
return /* @__PURE__ */ new Map();
|
|
9688
|
+
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
9514
9689
|
}
|
|
9515
9690
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
9516
9691
|
const result = new Map(
|
|
@@ -9529,6 +9704,10 @@ var ContractManager = class _ContractManager {
|
|
|
9529
9704
|
contracts.map((c) => c.script),
|
|
9530
9705
|
{ ...windowOpts, pageSize }
|
|
9531
9706
|
);
|
|
9707
|
+
const promoted = await this.promoteLookAheadHits(vtxos);
|
|
9708
|
+
for (const [script, contract] of promoted) {
|
|
9709
|
+
scriptToContract.set(script, contract);
|
|
9710
|
+
}
|
|
9532
9711
|
const owned = vtxos.filter((v) => scriptToContract.has(v.script));
|
|
9533
9712
|
const annotated = await this.annotateVtxos(owned);
|
|
9534
9713
|
for (const vtxo of annotated) {
|
|
@@ -9537,7 +9716,7 @@ var ContractManager = class _ContractManager {
|
|
|
9537
9716
|
contractScript: vtxo.script
|
|
9538
9717
|
});
|
|
9539
9718
|
}
|
|
9540
|
-
return result;
|
|
9719
|
+
return { vtxosByScript: result, promoted };
|
|
9541
9720
|
}
|
|
9542
9721
|
/**
|
|
9543
9722
|
* Dispose of the ContractManager and release all resources.
|
|
@@ -9551,6 +9730,7 @@ var ContractManager = class _ContractManager {
|
|
|
9551
9730
|
this.stopWatcherFn?.();
|
|
9552
9731
|
this.stopWatcherFn = void 0;
|
|
9553
9732
|
this.eventCallbacks.clear();
|
|
9733
|
+
this.lookAheadEntries.clear();
|
|
9554
9734
|
this.initialized = false;
|
|
9555
9735
|
}
|
|
9556
9736
|
/**
|
|
@@ -9616,6 +9796,15 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
9616
9796
|
if (settings.lastIndexUsed === void 0) return void 0;
|
|
9617
9797
|
return this.materializeDescriptorAt(settings.lastIndexUsed);
|
|
9618
9798
|
}
|
|
9799
|
+
/**
|
|
9800
|
+
* The most recently allocated index, or `undefined` when nothing has ever
|
|
9801
|
+
* been allocated on this repo. Read-only peek at the watermark that
|
|
9802
|
+
* {@link getNextSigningDescriptor} advances.
|
|
9803
|
+
*/
|
|
9804
|
+
async getLastIndexUsed() {
|
|
9805
|
+
const state = await this.walletRepository.getWalletState();
|
|
9806
|
+
return this.parseSettings(state ?? {}).lastIndexUsed;
|
|
9807
|
+
}
|
|
9619
9808
|
/**
|
|
9620
9809
|
* Monotonically advance the allocation watermark so the next
|
|
9621
9810
|
* `getNextSigningDescriptor()` skips indices discovered by a restore
|
|
@@ -9998,58 +10187,26 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
9998
10187
|
*/
|
|
9999
10188
|
async rotate(wallet) {
|
|
10000
10189
|
const descriptor = await this.provider.getNextSigningDescriptor();
|
|
10001
|
-
const
|
|
10002
|
-
|
|
10003
|
-
|
|
10004
|
-
|
|
10190
|
+
const { tapscript: newTapscript, params } = buildReceiveContract(
|
|
10191
|
+
wallet.offchainTapscript,
|
|
10192
|
+
descriptor,
|
|
10193
|
+
wallet.network.hrp,
|
|
10194
|
+
true
|
|
10195
|
+
);
|
|
10196
|
+
const newScript = params.script;
|
|
10005
10197
|
const manager = await wallet.getContractManager();
|
|
10006
|
-
|
|
10007
|
-
const csvTimelockStr = chunkE7HB3GKK_cjs.timelockToSequence(csvTimelock).toString();
|
|
10008
|
-
const serverPubKeyHex = base.hex.encode(newTapscript.options.serverPubKey);
|
|
10009
|
-
const baseParams = {
|
|
10010
|
-
script: newScript,
|
|
10011
|
-
address: newAddress,
|
|
10012
|
-
state: "active",
|
|
10013
|
-
// Persist the materialized signing descriptor alongside the
|
|
10014
|
-
// source tag. The wallet's spending paths read this at sign
|
|
10015
|
-
// time to route inputs locked by a rotated pubkey through
|
|
10016
|
-
// `DescriptorProvider.signWithDescriptor` instead of the
|
|
10017
|
-
// identity's index-0 key. Without it, post-rotation sends
|
|
10018
|
-
// produce unsigned PSBTs that the server rejects with
|
|
10019
|
-
// `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
10020
|
-
metadata: {
|
|
10021
|
-
source: chunkLJQ2VQBE_cjs.WALLET_RECEIVE_SOURCE,
|
|
10022
|
-
signingDescriptor: descriptor
|
|
10023
|
-
}
|
|
10024
|
-
};
|
|
10025
|
-
if (newTapscript instanceof chunkLJQ2VQBE_cjs.DelegateVtxo.Script) {
|
|
10026
|
-
await manager.createContract({
|
|
10027
|
-
...baseParams,
|
|
10028
|
-
type: "delegate",
|
|
10029
|
-
params: {
|
|
10030
|
-
pubKey: base.hex.encode(pubKey),
|
|
10031
|
-
serverPubKey: serverPubKeyHex,
|
|
10032
|
-
delegatePubKey: base.hex.encode(newTapscript.options.delegatePubKey),
|
|
10033
|
-
csvTimelock: csvTimelockStr
|
|
10034
|
-
}
|
|
10035
|
-
});
|
|
10036
|
-
} else {
|
|
10037
|
-
await manager.createContract({
|
|
10038
|
-
...baseParams,
|
|
10039
|
-
type: "default",
|
|
10040
|
-
params: {
|
|
10041
|
-
pubKey: base.hex.encode(pubKey),
|
|
10042
|
-
serverPubKey: serverPubKeyHex,
|
|
10043
|
-
csvTimelock: csvTimelockStr
|
|
10044
|
-
}
|
|
10045
|
-
});
|
|
10046
|
-
}
|
|
10198
|
+
await manager.createContract(params);
|
|
10047
10199
|
wallet.setOffchainTapscriptForRotation(newTapscript);
|
|
10048
10200
|
const previousTagged = this.currentTaggedScript;
|
|
10049
10201
|
if (previousTagged !== void 0 && previousTagged !== newScript) {
|
|
10050
10202
|
await manager.setContractState(previousTagged, "inactive");
|
|
10051
10203
|
}
|
|
10052
10204
|
this.currentTaggedScript = newScript;
|
|
10205
|
+
try {
|
|
10206
|
+
await manager.refillLookAhead();
|
|
10207
|
+
} catch (err) {
|
|
10208
|
+
this.logger.error("WalletReceiveRotator: look-ahead refill failed", err);
|
|
10209
|
+
}
|
|
10053
10210
|
}
|
|
10054
10211
|
};
|
|
10055
10212
|
function deriveLeafPubkey(descriptor) {
|
|
@@ -10062,6 +10219,45 @@ function deriveLeafPubkey(descriptor) {
|
|
|
10062
10219
|
);
|
|
10063
10220
|
}
|
|
10064
10221
|
}
|
|
10222
|
+
function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
10223
|
+
const pubKey = deriveLeafPubkey(descriptor);
|
|
10224
|
+
const tapscript = rebuildTapscript(current, pubKey);
|
|
10225
|
+
const serverPubKey = tapscript.options.serverPubKey;
|
|
10226
|
+
const csvTimelock = chunkE7HB3GKK_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
10227
|
+
const base$1 = {
|
|
10228
|
+
script: base.hex.encode(tapscript.pkScript),
|
|
10229
|
+
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
10230
|
+
state: "active",
|
|
10231
|
+
// The materialized signing descriptor is read at sign time to route
|
|
10232
|
+
// inputs locked by a rotated pubkey through
|
|
10233
|
+
// `DescriptorProvider.signWithDescriptor` instead of the identity's
|
|
10234
|
+
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
10235
|
+
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
10236
|
+
metadata: {
|
|
10237
|
+
...tagSource && { source: chunkLJQ2VQBE_cjs.WALLET_RECEIVE_SOURCE },
|
|
10238
|
+
signingDescriptor: descriptor
|
|
10239
|
+
}
|
|
10240
|
+
};
|
|
10241
|
+
const params = tapscript instanceof chunkLJQ2VQBE_cjs.DelegateVtxo.Script ? {
|
|
10242
|
+
...base$1,
|
|
10243
|
+
type: "delegate",
|
|
10244
|
+
params: {
|
|
10245
|
+
pubKey: base.hex.encode(pubKey),
|
|
10246
|
+
serverPubKey: base.hex.encode(serverPubKey),
|
|
10247
|
+
delegatePubKey: base.hex.encode(tapscript.options.delegatePubKey),
|
|
10248
|
+
csvTimelock
|
|
10249
|
+
}
|
|
10250
|
+
} : {
|
|
10251
|
+
...base$1,
|
|
10252
|
+
type: "default",
|
|
10253
|
+
params: {
|
|
10254
|
+
pubKey: base.hex.encode(pubKey),
|
|
10255
|
+
serverPubKey: base.hex.encode(serverPubKey),
|
|
10256
|
+
csvTimelock
|
|
10257
|
+
}
|
|
10258
|
+
};
|
|
10259
|
+
return { tapscript, params };
|
|
10260
|
+
}
|
|
10065
10261
|
function rebuildTapscript(current, pubKey) {
|
|
10066
10262
|
if (current instanceof chunkLJQ2VQBE_cjs.DelegateVtxo.Script) {
|
|
10067
10263
|
return new chunkLJQ2VQBE_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
@@ -10264,6 +10460,7 @@ function extractArkProviderUrl(provider) {
|
|
|
10264
10460
|
const serverUrl = provider.serverUrl;
|
|
10265
10461
|
return typeof serverUrl === "string" && serverUrl.length > 0 ? serverUrl : void 0;
|
|
10266
10462
|
}
|
|
10463
|
+
var DEFAULT_LOOK_AHEAD_WINDOW = 20;
|
|
10267
10464
|
var MAINNET_UNILATERAL_EXIT_DELAY = 605184n;
|
|
10268
10465
|
function toXOnlyPubKey(pubkey) {
|
|
10269
10466
|
if (pubkey.length === 33) return pubkey.slice(1);
|
|
@@ -10625,7 +10822,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
10625
10822
|
*/
|
|
10626
10823
|
static async setupWalletConfig(config, pubKey) {
|
|
10627
10824
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
10628
|
-
const arkProvider = config.arkProvider || new
|
|
10825
|
+
const arkProvider = config.arkProvider || new chunkFHDUEBBC_cjs.RestArkProvider(arkadeServerUrl);
|
|
10629
10826
|
let indexerProvider = config.indexerProvider;
|
|
10630
10827
|
if (!indexerProvider) {
|
|
10631
10828
|
let indexerUrl = config.indexerUrl;
|
|
@@ -10642,7 +10839,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
10642
10839
|
indexerUrl = arkadeServerUrl;
|
|
10643
10840
|
}
|
|
10644
10841
|
}
|
|
10645
|
-
indexerProvider = new
|
|
10842
|
+
indexerProvider = new chunkFHDUEBBC_cjs.RestIndexerProvider(indexerUrl);
|
|
10646
10843
|
}
|
|
10647
10844
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
10648
10845
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -11319,6 +11516,14 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11319
11516
|
this._contractManagerInitializing = void 0;
|
|
11320
11517
|
}
|
|
11321
11518
|
}
|
|
11519
|
+
/**
|
|
11520
|
+
* HD look-ahead configuration for the contract manager. Readonly wallets
|
|
11521
|
+
* have no descriptor provider, hence no watermark to look ahead of.
|
|
11522
|
+
* @see Wallet.lookAheadConfig
|
|
11523
|
+
*/
|
|
11524
|
+
lookAheadConfig() {
|
|
11525
|
+
return void 0;
|
|
11526
|
+
}
|
|
11322
11527
|
async initializeContractManager() {
|
|
11323
11528
|
const virtualTxRepository = this.virtualTxRepository;
|
|
11324
11529
|
let onVtxosPersisted;
|
|
@@ -11353,7 +11558,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11353
11558
|
intentRepository: this.intentRepository,
|
|
11354
11559
|
onVtxosPersisted,
|
|
11355
11560
|
onVtxosSpent,
|
|
11356
|
-
watcherConfig: this.watcherConfig
|
|
11561
|
+
watcherConfig: this.watcherConfig,
|
|
11562
|
+
lookAhead: this.lookAheadConfig()
|
|
11357
11563
|
});
|
|
11358
11564
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
11359
11565
|
const delegatePubKey = this.offchainTapscript instanceof chunkLJQ2VQBE_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
@@ -11447,7 +11653,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11447
11653
|
}
|
|
11448
11654
|
};
|
|
11449
11655
|
var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
11450
|
-
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider) {
|
|
11656
|
+
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, lookAheadWindow) {
|
|
11451
11657
|
super(
|
|
11452
11658
|
identity,
|
|
11453
11659
|
network,
|
|
@@ -11487,6 +11693,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11487
11693
|
this._serverUnrollScript = serverUnrollScript;
|
|
11488
11694
|
this._receiveRotator = receiveRotator;
|
|
11489
11695
|
this._descriptorProvider = descriptorProvider;
|
|
11696
|
+
this._lookAheadWindow = lookAheadWindow ?? DEFAULT_LOOK_AHEAD_WINDOW;
|
|
11490
11697
|
this._signerRouter = new InputSignerRouter({
|
|
11491
11698
|
identity,
|
|
11492
11699
|
contractRepository,
|
|
@@ -11559,6 +11766,36 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11559
11766
|
* paths only ever take the identity-sign branch.
|
|
11560
11767
|
*/
|
|
11561
11768
|
_descriptorProvider;
|
|
11769
|
+
/** Per-side width of the HD look-ahead band. @see WalletConfig.lookAheadWindow */
|
|
11770
|
+
_lookAheadWindow;
|
|
11771
|
+
/**
|
|
11772
|
+
* Watch a band of missing offchain receive scripts around the HD watermark
|
|
11773
|
+
* so payments to an externally-issued address land without a `restore()`.
|
|
11774
|
+
* Only HD wallets have a watermark to look ahead of; static / `auto`
|
|
11775
|
+
* wallets keep a single index-0 receive address, so the feature stays off.
|
|
11776
|
+
*
|
|
11777
|
+
* `materialize` reads `this.offchainTapscript` at call time, so a refill
|
|
11778
|
+
* after {@link rotateServerSigner} rebuilds the band under the active
|
|
11779
|
+
* signer (persisted old-signer rows stay watched through the repository).
|
|
11780
|
+
*/
|
|
11781
|
+
lookAheadConfig() {
|
|
11782
|
+
const provider = this._descriptorProvider;
|
|
11783
|
+
if (!(provider instanceof HDDescriptorProvider)) return void 0;
|
|
11784
|
+
return {
|
|
11785
|
+
size: this._lookAheadWindow,
|
|
11786
|
+
currentWatermark: async () => await provider.getLastIndexUsed() ?? -1,
|
|
11787
|
+
materialize: (index) => buildReceiveContract(
|
|
11788
|
+
this.offchainTapscript,
|
|
11789
|
+
provider.materializeDescriptorAt(index),
|
|
11790
|
+
this.network.hrp,
|
|
11791
|
+
// Never tagged: a promoted entry was generated by someone
|
|
11792
|
+
// else, and the tag would make the next boot advertise a
|
|
11793
|
+
// third party's invoice address as our own.
|
|
11794
|
+
false
|
|
11795
|
+
).params,
|
|
11796
|
+
onPromoted: (index) => provider.advanceLastIndexUsed(index)
|
|
11797
|
+
};
|
|
11798
|
+
}
|
|
11562
11799
|
_signerRouter;
|
|
11563
11800
|
/**
|
|
11564
11801
|
* @internal Sole write path for `offchainTapscript` after construction.
|
|
@@ -11671,6 +11908,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11671
11908
|
}
|
|
11672
11909
|
});
|
|
11673
11910
|
this.setBoardingTapscriptForRotation(newBoarding);
|
|
11911
|
+
try {
|
|
11912
|
+
await manager.refillLookAhead();
|
|
11913
|
+
} catch (e) {
|
|
11914
|
+
console.warn("look-ahead refill after boarding allocation failed", e);
|
|
11915
|
+
}
|
|
11674
11916
|
return newBoarding.onchainAddress(this.network);
|
|
11675
11917
|
}
|
|
11676
11918
|
/**
|
|
@@ -11792,6 +12034,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11792
12034
|
this.setBoardingTapscriptForRotation(newBoarding);
|
|
11793
12035
|
this.setArkServerPublicKeyForRotation(xonly);
|
|
11794
12036
|
this.setServerUnrollScriptForRotation(newServerUnrollScript);
|
|
12037
|
+
try {
|
|
12038
|
+
await manager.refillLookAhead();
|
|
12039
|
+
} catch (e) {
|
|
12040
|
+
console.warn("look-ahead refill after server-signer rotation failed", e);
|
|
12041
|
+
}
|
|
11795
12042
|
}
|
|
11796
12043
|
/**
|
|
11797
12044
|
* Async mutex that serializes all operations submitting VTXOs to the Arkade
|
|
@@ -11907,6 +12154,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11907
12154
|
if (hd && result.highestConfirmedUsedIndex >= 0) {
|
|
11908
12155
|
await provider.advanceLastIndexUsed(result.highestConfirmedUsedIndex);
|
|
11909
12156
|
}
|
|
12157
|
+
await manager.refillLookAhead();
|
|
11910
12158
|
await manager.refreshVtxos({ includeInactive: true, after: 0 });
|
|
11911
12159
|
const causes = result.handlerErrors.map(
|
|
11912
12160
|
(e) => e.error instanceof Error ? e.error : new Error(String(e.error))
|
|
@@ -11998,6 +12246,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11998
12246
|
* ```
|
|
11999
12247
|
*/
|
|
12000
12248
|
static async create(config) {
|
|
12249
|
+
if (config.lookAheadWindow !== void 0 && (!Number.isInteger(config.lookAheadWindow) || config.lookAheadWindow <= 0)) {
|
|
12250
|
+
throw new Error(
|
|
12251
|
+
`lookAheadWindow must be a positive integer (got ${String(config.lookAheadWindow)})`
|
|
12252
|
+
);
|
|
12253
|
+
}
|
|
12001
12254
|
const pubkey = await config.identity.xOnlyPublicKey();
|
|
12002
12255
|
if (!pubkey) {
|
|
12003
12256
|
throw new Error("Invalid configured public key");
|
|
@@ -12035,7 +12288,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12035
12288
|
config.settlementConfig,
|
|
12036
12289
|
setup.walletContractTimelocks,
|
|
12037
12290
|
boot?.rotator,
|
|
12038
|
-
boot?.provider
|
|
12291
|
+
boot?.provider,
|
|
12292
|
+
config.lookAheadWindow
|
|
12039
12293
|
);
|
|
12040
12294
|
wallet._serverInfoSource = setup.serverInfoSource;
|
|
12041
12295
|
if (setup.serverInfoSource === "live") {
|
|
@@ -12720,9 +12974,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12720
12974
|
...existing ?? {},
|
|
12721
12975
|
intentTxId,
|
|
12722
12976
|
registerProof: intent.proof,
|
|
12723
|
-
registerProofMessage:
|
|
12977
|
+
registerProofMessage: chunkFHDUEBBC_cjs.Intent.encodeMessage(intent.message),
|
|
12724
12978
|
deleteProof: deleteIntent.proof,
|
|
12725
|
-
deleteProofMessage:
|
|
12979
|
+
deleteProofMessage: chunkFHDUEBBC_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
12726
12980
|
intentVtxos: inputs.map((i) => ({
|
|
12727
12981
|
txid: i.txid,
|
|
12728
12982
|
vout: i.vout
|
|
@@ -12754,7 +13008,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12754
13008
|
try {
|
|
12755
13009
|
return await this.arkProvider.registerIntent(intent);
|
|
12756
13010
|
} catch (error) {
|
|
12757
|
-
if (error instanceof
|
|
13011
|
+
if (error instanceof chunkFHDUEBBC_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
12758
13012
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
12759
13013
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
12760
13014
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -12770,7 +13024,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12770
13024
|
expire_at: 0,
|
|
12771
13025
|
cosigners_public_keys: cosignerPubKeys
|
|
12772
13026
|
};
|
|
12773
|
-
const proof =
|
|
13027
|
+
const proof = chunkFHDUEBBC_cjs.Intent.create(message, coins, outputs);
|
|
12774
13028
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
12775
13029
|
return {
|
|
12776
13030
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -12782,7 +13036,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12782
13036
|
type: "delete",
|
|
12783
13037
|
expire_at: 0
|
|
12784
13038
|
};
|
|
12785
|
-
const proof =
|
|
13039
|
+
const proof = chunkFHDUEBBC_cjs.Intent.create(message, coins, []);
|
|
12786
13040
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
12787
13041
|
return {
|
|
12788
13042
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -12794,7 +13048,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12794
13048
|
type: "get-pending-tx",
|
|
12795
13049
|
expire_at: 0
|
|
12796
13050
|
};
|
|
12797
|
-
const proof =
|
|
13051
|
+
const proof = chunkFHDUEBBC_cjs.Intent.create(message, coins, []);
|
|
12798
13052
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
12799
13053
|
return {
|
|
12800
13054
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13127,7 +13381,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13127
13381
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
13128
13382
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
13129
13383
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
13130
|
-
const proof =
|
|
13384
|
+
const proof = chunkFHDUEBBC_cjs.Intent.create(message, batch, []);
|
|
13131
13385
|
const signedProof = await identity.sign(
|
|
13132
13386
|
proof,
|
|
13133
13387
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -14010,7 +14264,7 @@ var MessageBus = class {
|
|
|
14010
14264
|
this.initialized = true;
|
|
14011
14265
|
}
|
|
14012
14266
|
async buildServices(config) {
|
|
14013
|
-
const arkProvider = new
|
|
14267
|
+
const arkProvider = new chunkFHDUEBBC_cjs.RestArkProvider(config.arkServer.url);
|
|
14014
14268
|
const storage = {
|
|
14015
14269
|
walletRepository: this.walletRepository,
|
|
14016
14270
|
contractRepository: this.contractRepository
|
|
@@ -14029,7 +14283,8 @@ var MessageBus = class {
|
|
|
14029
14283
|
delegateProvider,
|
|
14030
14284
|
settlementConfig: config.settlementConfig,
|
|
14031
14285
|
walletMode: config.walletMode,
|
|
14032
|
-
watcherConfig: config.watcherConfig
|
|
14286
|
+
watcherConfig: config.watcherConfig,
|
|
14287
|
+
lookAheadWindow: config.lookAheadWindow
|
|
14033
14288
|
});
|
|
14034
14289
|
return { wallet, arkProvider, readonlyWallet: wallet };
|
|
14035
14290
|
}
|
|
@@ -15170,7 +15425,7 @@ var WalletMessageHandler = class {
|
|
|
15170
15425
|
// Wallet methods
|
|
15171
15426
|
async handleInitWallet({ payload }) {
|
|
15172
15427
|
const { arkServerUrl } = payload;
|
|
15173
|
-
this.indexerProvider = new
|
|
15428
|
+
this.indexerProvider = new chunkFHDUEBBC_cjs.RestIndexerProvider(arkServerUrl);
|
|
15174
15429
|
await this.onWalletInitialized();
|
|
15175
15430
|
}
|
|
15176
15431
|
async handleGetBalance() {
|
|
@@ -16494,6 +16749,9 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
16494
16749
|
)
|
|
16495
16750
|
);
|
|
16496
16751
|
},
|
|
16752
|
+
refillLookAhead() {
|
|
16753
|
+
return Promise.resolve();
|
|
16754
|
+
},
|
|
16497
16755
|
async isWatching() {
|
|
16498
16756
|
const message = {
|
|
16499
16757
|
type: "IS_CONTRACT_MANAGER_WATCHING",
|
|
@@ -16543,6 +16801,11 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
16543
16801
|
return serializeSigningIdentity(this.identity);
|
|
16544
16802
|
}
|
|
16545
16803
|
static async create(options) {
|
|
16804
|
+
if (options.lookAheadWindow !== void 0 && (!Number.isInteger(options.lookAheadWindow) || options.lookAheadWindow <= 0)) {
|
|
16805
|
+
throw new Error(
|
|
16806
|
+
`lookAheadWindow must be a positive integer (got ${String(options.lookAheadWindow)})`
|
|
16807
|
+
);
|
|
16808
|
+
}
|
|
16546
16809
|
const walletRepository = options.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
16547
16810
|
const contractRepository = options.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
16548
16811
|
if (!isSigningCapable(options.identity)) {
|
|
@@ -16592,6 +16855,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
16592
16855
|
settlementConfig: options.settlementConfig,
|
|
16593
16856
|
walletMode: options.walletMode,
|
|
16594
16857
|
watcherConfig: options.watcherConfig,
|
|
16858
|
+
lookAheadWindow: options.lookAheadWindow,
|
|
16595
16859
|
messageTimeouts
|
|
16596
16860
|
};
|
|
16597
16861
|
await initializeMessageBus(
|
|
@@ -17038,7 +17302,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17038
17302
|
if (!inputs) {
|
|
17039
17303
|
throw new Error("Fee estimation failed");
|
|
17040
17304
|
}
|
|
17041
|
-
let tx = new
|
|
17305
|
+
let tx = new chunkFHDUEBBC_cjs.Transaction();
|
|
17042
17306
|
for (const input of inputs) {
|
|
17043
17307
|
tx.addInput({
|
|
17044
17308
|
txid: input.txid,
|
|
@@ -17096,7 +17360,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17096
17360
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
17097
17361
|
*/
|
|
17098
17362
|
async bumpAnchor(parentHex, feeRate) {
|
|
17099
|
-
const parent =
|
|
17363
|
+
const parent = chunkFHDUEBBC_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
17100
17364
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
17101
17365
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
17102
17366
|
return [parent.hex, child.hex];
|
|
@@ -17861,7 +18125,7 @@ exports.BIP322 = void 0;
|
|
|
17861
18125
|
async function sign2(message, identity, network) {
|
|
17862
18126
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
17863
18127
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
17864
|
-
const toSpend =
|
|
18128
|
+
const toSpend = chunkFHDUEBBC_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
17865
18129
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
17866
18130
|
const signed = await identity.sign(toSign, [0]);
|
|
17867
18131
|
signed.finalizeIdx(0);
|
|
@@ -17919,7 +18183,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
17919
18183
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
17920
18184
|
return false;
|
|
17921
18185
|
}
|
|
17922
|
-
const toSpend =
|
|
18186
|
+
const toSpend = chunkFHDUEBBC_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
17923
18187
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
17924
18188
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
17925
18189
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -17940,7 +18204,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
17940
18204
|
}
|
|
17941
18205
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
17942
18206
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
17943
|
-
const toSpend =
|
|
18207
|
+
const toSpend = chunkFHDUEBBC_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
17944
18208
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
17945
18209
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
17946
18210
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -17993,7 +18257,7 @@ function encodeCompactSize(n) {
|
|
|
17993
18257
|
return buf;
|
|
17994
18258
|
}
|
|
17995
18259
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
17996
|
-
const tx = new
|
|
18260
|
+
const tx = new chunkFHDUEBBC_cjs.Transaction({ version: 0 });
|
|
17997
18261
|
tx.addInput({
|
|
17998
18262
|
txid: toSpend.id,
|
|
17999
18263
|
index: 0,
|
|
@@ -18007,12 +18271,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
18007
18271
|
});
|
|
18008
18272
|
tx.addOutput({
|
|
18009
18273
|
amount: 0n,
|
|
18010
|
-
script:
|
|
18274
|
+
script: chunkFHDUEBBC_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18011
18275
|
});
|
|
18012
18276
|
return tx;
|
|
18013
18277
|
}
|
|
18014
18278
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
18015
|
-
const tx = new
|
|
18279
|
+
const tx = new chunkFHDUEBBC_cjs.Transaction({ version: 0 });
|
|
18016
18280
|
tx.addInput({
|
|
18017
18281
|
txid: toSpend.id,
|
|
18018
18282
|
index: 0,
|
|
@@ -18024,7 +18288,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
18024
18288
|
});
|
|
18025
18289
|
tx.addOutput({
|
|
18026
18290
|
amount: 0n,
|
|
18027
|
-
script:
|
|
18291
|
+
script: chunkFHDUEBBC_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18028
18292
|
});
|
|
18029
18293
|
return tx;
|
|
18030
18294
|
}
|
|
@@ -18155,7 +18419,7 @@ var RestEmulatorProvider = class {
|
|
|
18155
18419
|
}
|
|
18156
18420
|
};
|
|
18157
18421
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
18158
|
-
const tx =
|
|
18422
|
+
const tx = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
18159
18423
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
18160
18424
|
const input = tx.getInput(0);
|
|
18161
18425
|
if (!input) {
|
|
@@ -18433,7 +18697,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
18433
18697
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
18434
18698
|
);
|
|
18435
18699
|
}
|
|
18436
|
-
const tx = new
|
|
18700
|
+
const tx = new chunkFHDUEBBC_cjs.Transaction({ version: 2 });
|
|
18437
18701
|
for (const input of inputs) {
|
|
18438
18702
|
tx.addInput(input);
|
|
18439
18703
|
}
|
|
@@ -18500,7 +18764,7 @@ async function buildSignedSweep(params) {
|
|
|
18500
18764
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
18501
18765
|
);
|
|
18502
18766
|
}
|
|
18503
|
-
const tx = new
|
|
18767
|
+
const tx = new chunkFHDUEBBC_cjs.Transaction({ version: 2 });
|
|
18504
18768
|
tx.addInput({
|
|
18505
18769
|
txid: vtxo.txid,
|
|
18506
18770
|
index: vtxo.vout,
|
|
@@ -18600,7 +18864,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
18600
18864
|
if (pendingNodes.length > 0) {
|
|
18601
18865
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
18602
18866
|
for (const psbt of txs) {
|
|
18603
|
-
psbts.set(
|
|
18867
|
+
psbts.set(chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
18604
18868
|
}
|
|
18605
18869
|
}
|
|
18606
18870
|
const childVsize = Number(
|
|
@@ -19047,7 +19311,7 @@ async function prepare(opts) {
|
|
|
19047
19311
|
if (newFee <= splitterFee) break;
|
|
19048
19312
|
splitterFee = newFee;
|
|
19049
19313
|
}
|
|
19050
|
-
const splitter = new
|
|
19314
|
+
const splitter = new chunkFHDUEBBC_cjs.Transaction({ version: 2 });
|
|
19051
19315
|
for (const coin of selected.inputs) {
|
|
19052
19316
|
splitter.addInput({
|
|
19053
19317
|
txid: coin.txid,
|
|
@@ -19254,7 +19518,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19254
19518
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
19255
19519
|
return { skip: true };
|
|
19256
19520
|
}
|
|
19257
|
-
const commitmentTx =
|
|
19521
|
+
const commitmentTx = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
19258
19522
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
19259
19523
|
if (recipients && recipients.length > 0) {
|
|
19260
19524
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -19285,7 +19549,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19285
19549
|
if (connectorTree) {
|
|
19286
19550
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
19287
19551
|
}
|
|
19288
|
-
let commitmentPsbt =
|
|
19552
|
+
let commitmentPsbt = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
19289
19553
|
const signedForfeits = [];
|
|
19290
19554
|
let connectorIndex = 0;
|
|
19291
19555
|
const connectorLeaves = connectorTree?.leaves() || [];
|
|
@@ -19693,12 +19957,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
19693
19957
|
this.contract.client.checkpoint
|
|
19694
19958
|
);
|
|
19695
19959
|
if (coin.sourceTx) {
|
|
19696
|
-
|
|
19960
|
+
chunkFHDUEBBC_cjs.setArkPsbtField(arkTx, 0, chunkFHDUEBBC_cjs.PrevArkTxField, coin.sourceTx);
|
|
19697
19961
|
}
|
|
19698
19962
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
19699
19963
|
if (condition.length > 0) {
|
|
19700
|
-
|
|
19701
|
-
|
|
19964
|
+
chunkFHDUEBBC_cjs.setArkPsbtField(arkTx, 0, chunkFHDUEBBC_cjs.ConditionWitness, condition);
|
|
19965
|
+
chunkFHDUEBBC_cjs.setArkPsbtField(checkpoints[0], 0, chunkFHDUEBBC_cjs.ConditionWitness, condition);
|
|
19702
19966
|
}
|
|
19703
19967
|
const packets = [];
|
|
19704
19968
|
if (this.assetSpecs.length > 0) {
|
|
@@ -19737,7 +20001,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
19737
20001
|
base.base64.encode(signedArk2.toPSBT()),
|
|
19738
20002
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
19739
20003
|
);
|
|
19740
|
-
const txid =
|
|
20004
|
+
const txid = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
19741
20005
|
return {
|
|
19742
20006
|
txid,
|
|
19743
20007
|
signedArkTx: res2.signedArkTx,
|
|
@@ -19755,7 +20019,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
19755
20019
|
const finalCps = await Promise.all(
|
|
19756
20020
|
res.signedCheckpointTxs.map(
|
|
19757
20021
|
async (b) => base.base64.encode(
|
|
19758
|
-
(await client.identity.sign(
|
|
20022
|
+
(await client.identity.sign(chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(b)), [0])).toPSBT()
|
|
19759
20023
|
)
|
|
19760
20024
|
)
|
|
19761
20025
|
);
|
|
@@ -19796,16 +20060,16 @@ var ArkadeTransactionBuilder = class {
|
|
|
19796
20060
|
}
|
|
19797
20061
|
buildAssetPacket() {
|
|
19798
20062
|
const groups = this.assetSpecs.map((s) => {
|
|
19799
|
-
const id = typeof s.assetId === "string" ?
|
|
19800
|
-
return
|
|
20063
|
+
const id = typeof s.assetId === "string" ? chunkFHDUEBBC_cjs.AssetId.fromString(s.assetId) : chunkFHDUEBBC_cjs.AssetId.fromBytes(s.assetId);
|
|
20064
|
+
return chunkFHDUEBBC_cjs.AssetGroup.create(
|
|
19801
20065
|
id,
|
|
19802
20066
|
null,
|
|
19803
|
-
s.inputs.map((i) =>
|
|
19804
|
-
s.outputs.map((o) =>
|
|
19805
|
-
(s.metadata ?? []).map((m) =>
|
|
20067
|
+
s.inputs.map((i) => chunkFHDUEBBC_cjs.AssetInput.create(i.vin, i.amount)),
|
|
20068
|
+
s.outputs.map((o) => chunkFHDUEBBC_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
20069
|
+
(s.metadata ?? []).map((m) => chunkFHDUEBBC_cjs.Metadata.create(m.key, m.value))
|
|
19806
20070
|
);
|
|
19807
20071
|
});
|
|
19808
|
-
return
|
|
20072
|
+
return chunkFHDUEBBC_cjs.Packet.create(groups);
|
|
19809
20073
|
}
|
|
19810
20074
|
witnessBytes(ref) {
|
|
19811
20075
|
return chunkLJQ2VQBE_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
@@ -20028,5 +20292,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
20028
20292
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
20029
20293
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
20030
20294
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
20031
|
-
//# sourceMappingURL=chunk-
|
|
20032
|
-
//# sourceMappingURL=chunk-
|
|
20295
|
+
//# sourceMappingURL=chunk-6XF6ZATZ.cjs.map
|
|
20296
|
+
//# sourceMappingURL=chunk-6XF6ZATZ.cjs.map
|