@arkade-os/sdk 0.4.47 → 0.4.48-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/expo.cjs +4 -4
- package/dist/adapters/expo.js +2 -2
- package/dist/adapters/indexedDB.cjs +3 -3
- package/dist/adapters/indexedDB.js +2 -2
- package/dist/{asyncStorageTaskQueue-Dowyo59a.d.cts → asyncStorageTaskQueue-CwknfM_j.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-Z3aFoXCl.d.ts → asyncStorageTaskQueue-D2Zl7yAB.d.ts} +2 -2
- package/dist/{chunk-JAYOXOLT.cjs → chunk-3HUZAIKI.cjs} +11 -11
- package/dist/{chunk-JAYOXOLT.cjs.map → chunk-3HUZAIKI.cjs.map} +1 -1
- package/dist/{chunk-3N5I6GT6.js → chunk-4AIHKC65.js} +3 -3
- package/dist/{chunk-3N5I6GT6.js.map → chunk-4AIHKC65.js.map} +1 -1
- package/dist/{chunk-HHV5FPC6.cjs → chunk-CFQO5MCM.cjs} +3 -3
- package/dist/chunk-CFQO5MCM.cjs.map +1 -0
- package/dist/{chunk-VE67GMGM.cjs → chunk-EA3IWZ4W.cjs} +7 -7
- package/dist/{chunk-VE67GMGM.cjs.map → chunk-EA3IWZ4W.cjs.map} +1 -1
- package/dist/{chunk-CDDWXBEM.js → chunk-GM6JRQP5.js} +3 -3
- package/dist/chunk-GM6JRQP5.js.map +1 -0
- package/dist/{chunk-WTTLIFS7.cjs → chunk-RJMFTTRJ.cjs} +486 -108
- package/dist/chunk-RJMFTTRJ.cjs.map +1 -0
- package/dist/{chunk-OCS5S3L3.js → chunk-SV4PCGKM.js} +383 -7
- package/dist/chunk-SV4PCGKM.js.map +1 -0
- package/dist/{chunk-AJQ4AOT3.js → chunk-ZRY2KSK5.js} +3 -3
- package/dist/{chunk-AJQ4AOT3.js.map → chunk-ZRY2KSK5.js.map} +1 -1
- package/dist/index.cjs +154 -146
- package/dist/index.d.cts +39 -6
- package/dist/index.d.ts +39 -6
- package/dist/index.js +2 -2
- package/dist/repositories/realm/index.cjs +17 -17
- package/dist/repositories/realm/index.js +3 -3
- package/dist/repositories/sqlite/index.cjs +16 -16
- package/dist/repositories/sqlite/index.js +3 -3
- package/dist/{taskRunner-Dz-TI4Rb.d.ts → taskRunner-Df8YQpn1.d.ts} +1 -1
- package/dist/{taskRunner-Dz47k0lp.d.cts → taskRunner-RYihSj9E.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +12 -12
- package/dist/wallet/expo/background.d.cts +2 -2
- package/dist/wallet/expo/background.d.ts +2 -2
- package/dist/wallet/expo/background.js +4 -4
- package/dist/wallet/expo/index.cjs +12 -12
- package/dist/wallet/expo/index.d.cts +2 -2
- package/dist/wallet/expo/index.d.ts +2 -2
- package/dist/wallet/expo/index.js +3 -3
- package/dist/{wallet-Oxz_wLxo.d.cts → wallet-B6s7_5bJ.d.cts} +124 -1
- package/dist/{wallet-x7egmXq6.d.ts → wallet-C61huH8i.d.ts} +124 -1
- package/dist/worker/expo/index.cjs +7 -7
- package/dist/worker/expo/index.d.cts +3 -3
- package/dist/worker/expo/index.d.ts +3 -3
- package/dist/worker/expo/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-CDDWXBEM.js.map +0 -1
- package/dist/chunk-HHV5FPC6.cjs.map +0 -1
- package/dist/chunk-OCS5S3L3.js.map +0 -1
- package/dist/chunk-WTTLIFS7.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkCFQO5MCM_cjs = require('./chunk-CFQO5MCM.cjs');
|
|
4
4
|
var chunkRQSA7ADZ_cjs = require('./chunk-RQSA7ADZ.cjs');
|
|
5
5
|
var chunkL5ND2FJJ_cjs = require('./chunk-L5ND2FJJ.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 = chunkCFQO5MCM_cjs.getArkPsbtFields(tx.root, 0, chunkCFQO5MCM_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 = chunkCFQO5MCM_cjs.getArkPsbtFields(g.root, 0, chunkCFQO5MCM_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 chunkCFQO5MCM_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: chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 = chunkCFQO5MCM_cjs.getArkPsbtFields(child.root, 0, chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_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 chunkCFQO5MCM_cjs.Packet.PACKET_TYPE:
|
|
1783
|
+
return chunkCFQO5MCM_cjs.Packet.fromBytes(data);
|
|
1784
1784
|
case EmulatorPacket.PACKET_TYPE:
|
|
1785
1785
|
return EmulatorPacket.fromBytes(data);
|
|
1786
1786
|
default:
|
|
@@ -2091,7 +2091,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2091
2091
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
2092
2092
|
inputsByAssetId.set(asset.assetId, [
|
|
2093
2093
|
...existing ?? [],
|
|
2094
|
-
|
|
2094
|
+
chunkCFQO5MCM_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
2095
2095
|
]);
|
|
2096
2096
|
}
|
|
2097
2097
|
}
|
|
@@ -2103,7 +2103,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2103
2103
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2104
2104
|
outputsByAssetId.set(asset.assetId, [
|
|
2105
2105
|
...existing ?? [],
|
|
2106
|
-
|
|
2106
|
+
chunkCFQO5MCM_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2107
2107
|
]);
|
|
2108
2108
|
}
|
|
2109
2109
|
}
|
|
@@ -2114,7 +2114,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2114
2114
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2115
2115
|
outputsByAssetId.set(asset.assetId, [
|
|
2116
2116
|
...existing ?? [],
|
|
2117
|
-
|
|
2117
|
+
chunkCFQO5MCM_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2118
2118
|
]);
|
|
2119
2119
|
}
|
|
2120
2120
|
}
|
|
@@ -2123,11 +2123,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2123
2123
|
for (const assetIdStr of allAssetIds) {
|
|
2124
2124
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
2125
2125
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
2126
|
-
const assetId =
|
|
2127
|
-
const group =
|
|
2126
|
+
const assetId = chunkCFQO5MCM_cjs.AssetId.fromString(assetIdStr);
|
|
2127
|
+
const group = chunkCFQO5MCM_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
2128
2128
|
groups.push(group);
|
|
2129
2129
|
}
|
|
2130
|
-
return
|
|
2130
|
+
return chunkCFQO5MCM_cjs.Packet.create(groups);
|
|
2131
2131
|
}
|
|
2132
2132
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
2133
2133
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -2244,7 +2244,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2244
2244
|
}
|
|
2245
2245
|
}
|
|
2246
2246
|
}
|
|
2247
|
-
const tx = new
|
|
2247
|
+
const tx = new chunkCFQO5MCM_cjs.Transaction({
|
|
2248
2248
|
version: 3,
|
|
2249
2249
|
lockTime: Number(lockTime)
|
|
2250
2250
|
});
|
|
@@ -2259,7 +2259,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2259
2259
|
},
|
|
2260
2260
|
tapLeafScript: [input.tapLeafScript]
|
|
2261
2261
|
});
|
|
2262
|
-
|
|
2262
|
+
chunkCFQO5MCM_cjs.setArkPsbtField(tx, i, chunkCFQO5MCM_cjs.VtxoTaprootTree, input.tapTree);
|
|
2263
2263
|
}
|
|
2264
2264
|
for (const output of outputs) {
|
|
2265
2265
|
tx.addOutput(output);
|
|
@@ -2442,14 +2442,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks) {
|
|
|
2442
2442
|
let finalCheckpoints;
|
|
2443
2443
|
if (userSignedCheckpoints) {
|
|
2444
2444
|
finalCheckpoints = signedCheckpointTxs.map((c, i) => {
|
|
2445
|
-
const serverSigned =
|
|
2445
|
+
const serverSigned = chunkCFQO5MCM_cjs.Transaction.fromPSBT(base.base64.decode(c));
|
|
2446
2446
|
combineTapscriptSigs(userSignedCheckpoints[i], serverSigned);
|
|
2447
2447
|
return base.base64.encode(serverSigned.toPSBT());
|
|
2448
2448
|
});
|
|
2449
2449
|
} else {
|
|
2450
2450
|
finalCheckpoints = await Promise.all(
|
|
2451
2451
|
signedCheckpointTxs.map(async (c) => {
|
|
2452
|
-
const tx =
|
|
2452
|
+
const tx = chunkCFQO5MCM_cjs.Transaction.fromPSBT(base.base64.decode(c));
|
|
2453
2453
|
const signed = await signer.signCheckpoint(tx);
|
|
2454
2454
|
return base.base64.encode(signed.toPSBT());
|
|
2455
2455
|
})
|
|
@@ -2459,6 +2459,15 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks) {
|
|
|
2459
2459
|
await hooks?.afterFinalize?.();
|
|
2460
2460
|
return { arkTxid, signedCheckpointTxs };
|
|
2461
2461
|
}
|
|
2462
|
+
async function signAndSubmitOffchainTx(params) {
|
|
2463
|
+
const offchainTx = buildOffchainTx(params.inputs, params.outputs, params.serverUnrollScript);
|
|
2464
|
+
const signer = {
|
|
2465
|
+
signArkTx: async (arkTx) => ({ arkTx: await params.identity.sign(arkTx) }),
|
|
2466
|
+
signCheckpoint: (checkpoint) => params.identity.sign(checkpoint)
|
|
2467
|
+
};
|
|
2468
|
+
const { arkTxid } = await submitOffchainTx(params.provider, offchainTx, signer);
|
|
2469
|
+
return arkTxid;
|
|
2470
|
+
}
|
|
2462
2471
|
var AmountVariableName = "amount";
|
|
2463
2472
|
var ExpiryVariableName = "expiry";
|
|
2464
2473
|
var BirthVariableName = "birth";
|
|
@@ -2766,6 +2775,7 @@ async function runWithCrossInstanceLock(name, fn) {
|
|
|
2766
2775
|
});
|
|
2767
2776
|
}
|
|
2768
2777
|
var MAX_VTXOS_PER_SETTLEMENT = 50;
|
|
2778
|
+
var MAX_INPUTS_PER_INTENT = 20;
|
|
2769
2779
|
function byValueDescending(vtxos) {
|
|
2770
2780
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
2771
2781
|
}
|
|
@@ -3317,7 +3327,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3317
3327
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
3318
3328
|
);
|
|
3319
3329
|
}
|
|
3320
|
-
const tx = new
|
|
3330
|
+
const tx = new chunkCFQO5MCM_cjs.Transaction();
|
|
3321
3331
|
for (const utxo of expiredUtxos) {
|
|
3322
3332
|
const utxoScript = chunkL5ND2FJJ_cjs.VtxoScript.decode(utxo.tapTree);
|
|
3323
3333
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
@@ -3956,8 +3966,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
3956
3966
|
* or doesn't carry the metadata.
|
|
3957
3967
|
*/
|
|
3958
3968
|
extractSpentOutpoint(error) {
|
|
3959
|
-
const ark =
|
|
3960
|
-
if (!
|
|
3969
|
+
const ark = chunkCFQO5MCM_cjs.maybeArkError(error);
|
|
3970
|
+
if (!chunkCFQO5MCM_cjs.isArkError(ark, chunkCFQO5MCM_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
3961
3971
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
3962
3972
|
if (typeof raw !== "string") return void 0;
|
|
3963
3973
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -4355,6 +4365,96 @@ function readUInt32BE(array, offset) {
|
|
|
4355
4365
|
function noteTapscript(preimageHash) {
|
|
4356
4366
|
return btcSigner.Script.encode(["SHA256", preimageHash, "EQUAL"]);
|
|
4357
4367
|
}
|
|
4368
|
+
var ArkCash = class _ArkCash {
|
|
4369
|
+
constructor(privateKey, serverPubKey, csvTimelock, hrp = _ArkCash.DefaultHRP) {
|
|
4370
|
+
this.csvTimelock = csvTimelock;
|
|
4371
|
+
this.hrp = hrp;
|
|
4372
|
+
if (privateKey.length !== 32) {
|
|
4373
|
+
throw new Error(
|
|
4374
|
+
`Invalid private key length: expected 32 bytes, got ${privateKey.length}`
|
|
4375
|
+
);
|
|
4376
|
+
}
|
|
4377
|
+
if (serverPubKey.length !== 32) {
|
|
4378
|
+
throw new Error(
|
|
4379
|
+
`Invalid server public key length: expected 32 bytes, got ${serverPubKey.length}`
|
|
4380
|
+
);
|
|
4381
|
+
}
|
|
4382
|
+
this._privateKey = privateKey.slice();
|
|
4383
|
+
this._serverPubKey = serverPubKey.slice();
|
|
4384
|
+
this._publicKey = utils_js.pubSchnorr(this._privateKey);
|
|
4385
|
+
}
|
|
4386
|
+
csvTimelock;
|
|
4387
|
+
hrp;
|
|
4388
|
+
static DefaultHRP = "arkcash";
|
|
4389
|
+
static Version = 0;
|
|
4390
|
+
static PayloadLength = 1 + 32 + 32 + 4;
|
|
4391
|
+
// 69 bytes
|
|
4392
|
+
// Keys are held as private copies so a caller mutating the array it passed
|
|
4393
|
+
// in — or one it reads back from a getter — cannot alter this note's
|
|
4394
|
+
// identity or the outputs derived from it.
|
|
4395
|
+
_privateKey;
|
|
4396
|
+
_serverPubKey;
|
|
4397
|
+
_publicKey;
|
|
4398
|
+
/** The note's private key. Returns a fresh copy; mutating it is a no-op. */
|
|
4399
|
+
get privateKey() {
|
|
4400
|
+
return this._privateKey.slice();
|
|
4401
|
+
}
|
|
4402
|
+
/** The server's public key. Returns a fresh copy; mutating it is a no-op. */
|
|
4403
|
+
get serverPubKey() {
|
|
4404
|
+
return this._serverPubKey.slice();
|
|
4405
|
+
}
|
|
4406
|
+
/** The note's public key. Returns a fresh copy; mutating it is a no-op. */
|
|
4407
|
+
get publicKey() {
|
|
4408
|
+
return this._publicKey.slice();
|
|
4409
|
+
}
|
|
4410
|
+
static generate(serverPubKey, csvTimelock, hrp) {
|
|
4411
|
+
return new _ArkCash(utils_js.randomPrivateKeyBytes(), serverPubKey, csvTimelock, hrp);
|
|
4412
|
+
}
|
|
4413
|
+
static fromString(encoded) {
|
|
4414
|
+
const decoded = base.bech32m.decodeUnsafe(encoded.trim().toLowerCase(), 1023);
|
|
4415
|
+
if (!decoded) {
|
|
4416
|
+
throw new Error("Invalid arkcash string: failed to decode bech32m");
|
|
4417
|
+
}
|
|
4418
|
+
const data = new Uint8Array(base.bech32m.fromWords(decoded.words));
|
|
4419
|
+
if (data.length !== _ArkCash.PayloadLength) {
|
|
4420
|
+
throw new Error(
|
|
4421
|
+
`Invalid arkcash data length: expected ${_ArkCash.PayloadLength} bytes, got ${data.length}`
|
|
4422
|
+
);
|
|
4423
|
+
}
|
|
4424
|
+
const version = data[0];
|
|
4425
|
+
if (version !== _ArkCash.Version) {
|
|
4426
|
+
throw new Error(`Unsupported arkcash version: ${version}`);
|
|
4427
|
+
}
|
|
4428
|
+
const privateKey = data.slice(1, 33);
|
|
4429
|
+
const serverPubKey = data.slice(33, 65);
|
|
4430
|
+
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
4431
|
+
const csvTimelock = chunkL5ND2FJJ_cjs.sequenceToTimelock(sequence);
|
|
4432
|
+
return new _ArkCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
4433
|
+
}
|
|
4434
|
+
toString() {
|
|
4435
|
+
const data = new Uint8Array(_ArkCash.PayloadLength);
|
|
4436
|
+
data[0] = _ArkCash.Version;
|
|
4437
|
+
data.set(this._privateKey, 1);
|
|
4438
|
+
data.set(this._serverPubKey, 33);
|
|
4439
|
+
const sequence = chunkL5ND2FJJ_cjs.timelockToSequence(this.csvTimelock);
|
|
4440
|
+
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
4441
|
+
const words = base.bech32m.toWords(data);
|
|
4442
|
+
return base.bech32m.encode(this.hrp, words, 1023);
|
|
4443
|
+
}
|
|
4444
|
+
get identity() {
|
|
4445
|
+
return SingleKey.fromPrivateKey(this._privateKey);
|
|
4446
|
+
}
|
|
4447
|
+
get vtxoScript() {
|
|
4448
|
+
return new chunkRQSA7ADZ_cjs.DefaultVtxo.Script({
|
|
4449
|
+
pubKey: this._publicKey,
|
|
4450
|
+
serverPubKey: this._serverPubKey,
|
|
4451
|
+
csvTimelock: this.csvTimelock
|
|
4452
|
+
});
|
|
4453
|
+
}
|
|
4454
|
+
address(addressHrp) {
|
|
4455
|
+
return this.vtxoScript.address(addressHrp, this._serverPubKey);
|
|
4456
|
+
}
|
|
4457
|
+
};
|
|
4358
4458
|
|
|
4359
4459
|
// src/repositories/intentRepository.ts
|
|
4360
4460
|
var ALL_INTENT_STATES = [
|
|
@@ -4606,7 +4706,7 @@ async function captureExitBranch(params) {
|
|
|
4606
4706
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
4607
4707
|
if (nonCommitment.length > 0) {
|
|
4608
4708
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
4609
|
-
psbtByTxid.set(
|
|
4709
|
+
psbtByTxid.set(chunkCFQO5MCM_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
4610
4710
|
}
|
|
4611
4711
|
}
|
|
4612
4712
|
}
|
|
@@ -4667,7 +4767,7 @@ var IndexerExitDataSource = class {
|
|
|
4667
4767
|
pageSize: chunkRQSA7ADZ_cjs.DEFAULT_PAGE_SIZE
|
|
4668
4768
|
});
|
|
4669
4769
|
for (const psbt of txs) {
|
|
4670
|
-
out.set(
|
|
4770
|
+
out.set(chunkCFQO5MCM_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
4671
4771
|
}
|
|
4672
4772
|
hasMore = page ? txs.length === chunkRQSA7ADZ_cjs.DEFAULT_PAGE_SIZE : false;
|
|
4673
4773
|
pageIndex++;
|
|
@@ -4690,7 +4790,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
4690
4790
|
}
|
|
4691
4791
|
}
|
|
4692
4792
|
function psbtInputTxids(psbtBase64) {
|
|
4693
|
-
const tx =
|
|
4793
|
+
const tx = chunkCFQO5MCM_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
4694
4794
|
const ids = [];
|
|
4695
4795
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
4696
4796
|
const txid = tx.getInput(i).txid;
|
|
@@ -4793,7 +4893,7 @@ function createExitChainResolver(params) {
|
|
|
4793
4893
|
|
|
4794
4894
|
// src/providers/availability.ts
|
|
4795
4895
|
function isRetryableProviderError(error) {
|
|
4796
|
-
return error instanceof
|
|
4896
|
+
return error instanceof chunkCFQO5MCM_cjs.ProviderUnavailableError || error instanceof chunkCFQO5MCM_cjs.FetchError || chunkCFQO5MCM_cjs.isFetchTimeoutError(error);
|
|
4797
4897
|
}
|
|
4798
4898
|
|
|
4799
4899
|
// src/utils/syncCursors.ts
|
|
@@ -5046,7 +5146,7 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
5046
5146
|
if (!isRetryableProviderError(err)) throw err;
|
|
5047
5147
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
5048
5148
|
if (!snapshot) {
|
|
5049
|
-
throw new
|
|
5149
|
+
throw new chunkCFQO5MCM_cjs.ProviderUnavailableError(
|
|
5050
5150
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
5051
5151
|
{ cause: err }
|
|
5052
5152
|
);
|
|
@@ -5581,7 +5681,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5581
5681
|
const virtualCoins = await this.wallet.getVtxos({
|
|
5582
5682
|
withRecoverable: false
|
|
5583
5683
|
});
|
|
5584
|
-
const controlAssetRef = params.controlAssetId ?
|
|
5684
|
+
const controlAssetRef = params.controlAssetId ? chunkCFQO5MCM_cjs.AssetRef.fromId(chunkCFQO5MCM_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
5585
5685
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
5586
5686
|
let totalBtcSelected = 0n;
|
|
5587
5687
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -5594,8 +5694,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5594
5694
|
}
|
|
5595
5695
|
}
|
|
5596
5696
|
const groups = [];
|
|
5597
|
-
const issuedAssetOutput =
|
|
5598
|
-
const issuedAssetGroup =
|
|
5697
|
+
const issuedAssetOutput = chunkCFQO5MCM_cjs.AssetOutput.create(0, params.amount);
|
|
5698
|
+
const issuedAssetGroup = chunkCFQO5MCM_cjs.AssetGroup.create(
|
|
5599
5699
|
null,
|
|
5600
5700
|
controlAssetRef,
|
|
5601
5701
|
[],
|
|
@@ -5610,15 +5710,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5610
5710
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5611
5711
|
for (const asset of assets) {
|
|
5612
5712
|
if (asset.assetId !== assetId) continue;
|
|
5613
|
-
changeInputs.push(
|
|
5713
|
+
changeInputs.push(chunkCFQO5MCM_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5614
5714
|
}
|
|
5615
5715
|
}
|
|
5616
5716
|
groups.push(
|
|
5617
|
-
|
|
5618
|
-
|
|
5717
|
+
chunkCFQO5MCM_cjs.AssetGroup.create(
|
|
5718
|
+
chunkCFQO5MCM_cjs.AssetId.fromString(assetId),
|
|
5619
5719
|
null,
|
|
5620
5720
|
changeInputs,
|
|
5621
|
-
[
|
|
5721
|
+
[chunkCFQO5MCM_cjs.AssetOutput.create(0, amount)],
|
|
5622
5722
|
[]
|
|
5623
5723
|
)
|
|
5624
5724
|
);
|
|
@@ -5631,7 +5731,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5631
5731
|
script: outputAddress.pkScript,
|
|
5632
5732
|
amount: BigInt(totalBtcSelected)
|
|
5633
5733
|
},
|
|
5634
|
-
Extension.create([
|
|
5734
|
+
Extension.create([chunkCFQO5MCM_cjs.Packet.create(groups)]).txOut()
|
|
5635
5735
|
];
|
|
5636
5736
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
5637
5737
|
coinSelection.inputs,
|
|
@@ -5639,7 +5739,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5639
5739
|
);
|
|
5640
5740
|
return {
|
|
5641
5741
|
arkTxId: arkTxid,
|
|
5642
|
-
assetId:
|
|
5742
|
+
assetId: chunkCFQO5MCM_cjs.AssetId.create(arkTxid, 0).toString()
|
|
5643
5743
|
};
|
|
5644
5744
|
}
|
|
5645
5745
|
/**
|
|
@@ -5711,16 +5811,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5711
5811
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5712
5812
|
for (const asset of assets) {
|
|
5713
5813
|
if (asset.assetId !== params.assetId) continue;
|
|
5714
|
-
reissueInputs.push(
|
|
5814
|
+
reissueInputs.push(chunkCFQO5MCM_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5715
5815
|
}
|
|
5716
5816
|
}
|
|
5717
5817
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
5718
|
-
const reissueAssetIdObj =
|
|
5719
|
-
const reissueAssetGroup =
|
|
5818
|
+
const reissueAssetIdObj = chunkCFQO5MCM_cjs.AssetId.fromString(params.assetId);
|
|
5819
|
+
const reissueAssetGroup = chunkCFQO5MCM_cjs.AssetGroup.create(
|
|
5720
5820
|
reissueAssetIdObj,
|
|
5721
5821
|
null,
|
|
5722
5822
|
reissueInputs,
|
|
5723
|
-
[
|
|
5823
|
+
[chunkCFQO5MCM_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
5724
5824
|
[]
|
|
5725
5825
|
);
|
|
5726
5826
|
const groups = [reissueAssetGroup];
|
|
@@ -5729,15 +5829,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5729
5829
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5730
5830
|
for (const asset of assets) {
|
|
5731
5831
|
if (asset.assetId !== assetId) continue;
|
|
5732
|
-
changeInputs.push(
|
|
5832
|
+
changeInputs.push(chunkCFQO5MCM_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5733
5833
|
}
|
|
5734
5834
|
}
|
|
5735
5835
|
groups.push(
|
|
5736
|
-
|
|
5737
|
-
|
|
5836
|
+
chunkCFQO5MCM_cjs.AssetGroup.create(
|
|
5837
|
+
chunkCFQO5MCM_cjs.AssetId.fromString(assetId),
|
|
5738
5838
|
null,
|
|
5739
5839
|
changeInputs,
|
|
5740
|
-
[
|
|
5840
|
+
[chunkCFQO5MCM_cjs.AssetOutput.create(0, amount)],
|
|
5741
5841
|
[]
|
|
5742
5842
|
)
|
|
5743
5843
|
);
|
|
@@ -5749,7 +5849,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5749
5849
|
script: outputAddress.pkScript,
|
|
5750
5850
|
amount: BigInt(totalBtcSelected)
|
|
5751
5851
|
},
|
|
5752
|
-
Extension.create([
|
|
5852
|
+
Extension.create([chunkCFQO5MCM_cjs.Packet.create(groups)]).txOut()
|
|
5753
5853
|
];
|
|
5754
5854
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
5755
5855
|
return arkTxid;
|
|
@@ -5816,15 +5916,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5816
5916
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5817
5917
|
for (const asset of assets) {
|
|
5818
5918
|
if (asset.assetId !== assetId) continue;
|
|
5819
|
-
changeInputs.push(
|
|
5919
|
+
changeInputs.push(chunkCFQO5MCM_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5820
5920
|
}
|
|
5821
5921
|
}
|
|
5822
5922
|
groups.push(
|
|
5823
|
-
|
|
5824
|
-
|
|
5923
|
+
chunkCFQO5MCM_cjs.AssetGroup.create(
|
|
5924
|
+
chunkCFQO5MCM_cjs.AssetId.fromString(assetId),
|
|
5825
5925
|
null,
|
|
5826
5926
|
changeInputs,
|
|
5827
|
-
amount > 0n ? [
|
|
5927
|
+
amount > 0n ? [chunkCFQO5MCM_cjs.AssetOutput.create(0, amount)] : [],
|
|
5828
5928
|
[]
|
|
5829
5929
|
)
|
|
5830
5930
|
);
|
|
@@ -5836,7 +5936,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5836
5936
|
script: outputAddress.pkScript,
|
|
5837
5937
|
amount: BigInt(totalBtcSelected)
|
|
5838
5938
|
},
|
|
5839
|
-
Extension.create([
|
|
5939
|
+
Extension.create([chunkCFQO5MCM_cjs.Packet.create(groups)]).txOut()
|
|
5840
5940
|
];
|
|
5841
5941
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
5842
5942
|
return arkTxid;
|
|
@@ -5861,7 +5961,7 @@ function castMetadata(metadata) {
|
|
|
5861
5961
|
} else {
|
|
5862
5962
|
throw new Error("Invalid metadata value type");
|
|
5863
5963
|
}
|
|
5864
|
-
md.push(
|
|
5964
|
+
md.push(chunkCFQO5MCM_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
5865
5965
|
}
|
|
5866
5966
|
return md;
|
|
5867
5967
|
}
|
|
@@ -6149,7 +6249,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
6149
6249
|
expire_at: 0,
|
|
6150
6250
|
cosigners_public_keys: cosignerPubKeys
|
|
6151
6251
|
};
|
|
6152
|
-
const proof =
|
|
6252
|
+
const proof = chunkCFQO5MCM_cjs.Intent.create(message, coins, outputs);
|
|
6153
6253
|
const signedProof = await identity.sign(proof);
|
|
6154
6254
|
return {
|
|
6155
6255
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -8232,7 +8332,7 @@ var ContractWatcher = class {
|
|
|
8232
8332
|
this.connectionState = "connected";
|
|
8233
8333
|
this.reconnectAttempts = 0;
|
|
8234
8334
|
this.listenLoop().catch((e) => {
|
|
8235
|
-
if (
|
|
8335
|
+
if (chunkCFQO5MCM_cjs.isEventSourceError(e)) {
|
|
8236
8336
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8237
8337
|
} else {
|
|
8238
8338
|
console.error(e);
|
|
@@ -10149,6 +10249,24 @@ async function spendableVtxosExcludingLocked(vtxos, intentRepository) {
|
|
|
10149
10249
|
}
|
|
10150
10250
|
return excludeLockedOutpoints(vtxos, locked);
|
|
10151
10251
|
}
|
|
10252
|
+
var cashReport = (vtxo, reason) => ({
|
|
10253
|
+
txid: vtxo.txid,
|
|
10254
|
+
vout: vtxo.vout,
|
|
10255
|
+
value: vtxo.value,
|
|
10256
|
+
reason
|
|
10257
|
+
});
|
|
10258
|
+
var ArkCashCreateError = class extends Error {
|
|
10259
|
+
constructor(cash, cause) {
|
|
10260
|
+
super(
|
|
10261
|
+
`Failed to create ArkCash: send failed after the note may have been submitted. Recover with claimCash using the token on this error's \`cash\` field.`
|
|
10262
|
+
);
|
|
10263
|
+
this.cash = cash;
|
|
10264
|
+
this.cause = cause;
|
|
10265
|
+
this.name = "ArkCashCreateError";
|
|
10266
|
+
}
|
|
10267
|
+
cash;
|
|
10268
|
+
cause;
|
|
10269
|
+
};
|
|
10152
10270
|
var ReadonlyWallet = class _ReadonlyWallet {
|
|
10153
10271
|
constructor(identity, network, onchainProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, dustAmount, walletRepository, contractRepository, delegateProvider, watcherConfig, walletContractTimelocks) {
|
|
10154
10272
|
this.identity = identity;
|
|
@@ -10426,7 +10544,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
10426
10544
|
*/
|
|
10427
10545
|
static async setupWalletConfig(config, pubKey) {
|
|
10428
10546
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
10429
|
-
const arkProvider = config.arkProvider || new
|
|
10547
|
+
const arkProvider = config.arkProvider || new chunkCFQO5MCM_cjs.RestArkProvider(arkadeServerUrl);
|
|
10430
10548
|
let indexerProvider = config.indexerProvider;
|
|
10431
10549
|
if (!indexerProvider) {
|
|
10432
10550
|
let indexerUrl = config.indexerUrl;
|
|
@@ -10443,7 +10561,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
10443
10561
|
indexerUrl = arkadeServerUrl;
|
|
10444
10562
|
}
|
|
10445
10563
|
}
|
|
10446
|
-
indexerProvider = new
|
|
10564
|
+
indexerProvider = new chunkCFQO5MCM_cjs.RestIndexerProvider(indexerUrl);
|
|
10447
10565
|
}
|
|
10448
10566
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
10449
10567
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -12516,9 +12634,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12516
12634
|
...existing ?? {},
|
|
12517
12635
|
intentTxId,
|
|
12518
12636
|
registerProof: intent.proof,
|
|
12519
|
-
registerProofMessage:
|
|
12637
|
+
registerProofMessage: chunkCFQO5MCM_cjs.Intent.encodeMessage(intent.message),
|
|
12520
12638
|
deleteProof: deleteIntent.proof,
|
|
12521
|
-
deleteProofMessage:
|
|
12639
|
+
deleteProofMessage: chunkCFQO5MCM_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
12522
12640
|
intentVtxos: inputs.map((i) => ({
|
|
12523
12641
|
txid: i.txid,
|
|
12524
12642
|
vout: i.vout
|
|
@@ -12550,7 +12668,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12550
12668
|
try {
|
|
12551
12669
|
return await this.arkProvider.registerIntent(intent);
|
|
12552
12670
|
} catch (error) {
|
|
12553
|
-
if (error instanceof
|
|
12671
|
+
if (error instanceof chunkCFQO5MCM_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
12554
12672
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
12555
12673
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
12556
12674
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -12566,7 +12684,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12566
12684
|
expire_at: 0,
|
|
12567
12685
|
cosigners_public_keys: cosignerPubKeys
|
|
12568
12686
|
};
|
|
12569
|
-
const proof =
|
|
12687
|
+
const proof = chunkCFQO5MCM_cjs.Intent.create(message, coins, outputs);
|
|
12570
12688
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
12571
12689
|
return {
|
|
12572
12690
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -12578,7 +12696,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12578
12696
|
type: "delete",
|
|
12579
12697
|
expire_at: 0
|
|
12580
12698
|
};
|
|
12581
|
-
const proof =
|
|
12699
|
+
const proof = chunkCFQO5MCM_cjs.Intent.create(message, coins, []);
|
|
12582
12700
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
12583
12701
|
return {
|
|
12584
12702
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -12590,7 +12708,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12590
12708
|
type: "get-pending-tx",
|
|
12591
12709
|
expire_at: 0
|
|
12592
12710
|
};
|
|
12593
|
-
const proof =
|
|
12711
|
+
const proof = chunkCFQO5MCM_cjs.Intent.create(message, coins, []);
|
|
12594
12712
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
12595
12713
|
return {
|
|
12596
12714
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -12608,7 +12726,6 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12608
12726
|
if (!hasPending) {
|
|
12609
12727
|
return { finalized: [], pending: [] };
|
|
12610
12728
|
}
|
|
12611
|
-
const MAX_INPUTS_PER_INTENT = 20;
|
|
12612
12729
|
if (!vtxos || vtxos.length === 0) {
|
|
12613
12730
|
const scriptMap = await this.getScriptMap();
|
|
12614
12731
|
const allExtended = [];
|
|
@@ -12718,6 +12835,265 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12718
12835
|
settings: { ...state.settings, hasPendingTx: value }
|
|
12719
12836
|
}));
|
|
12720
12837
|
}
|
|
12838
|
+
/**
|
|
12839
|
+
* Create an ArkCash bearer instrument.
|
|
12840
|
+
*
|
|
12841
|
+
* Generates a fresh keypair, sends the specified amount to a DefaultVtxo
|
|
12842
|
+
* controlled by the new key, and returns the encoded arkcash string.
|
|
12843
|
+
* The receiver can claim the funds using `claimCash()` without ever
|
|
12844
|
+
* sharing their address.
|
|
12845
|
+
*
|
|
12846
|
+
* ArkCash is a short-lived instrument: it carries a private key, so it is
|
|
12847
|
+
* meant to be handed over and claimed promptly, not held. A note left
|
|
12848
|
+
* unclaimed past its batch expiry is swept by the server and `claimCash`
|
|
12849
|
+
* can only report it, not move it.
|
|
12850
|
+
*
|
|
12851
|
+
* @param amount - Amount in satoshis to send. Must be a whole number of
|
|
12852
|
+
* sats at or above the dust threshold — a below-dust amount would mint an
|
|
12853
|
+
* OP_RETURN output that is unspendable as cash.
|
|
12854
|
+
* @returns The encoded arkcash string (e.g., "arkcash1...")
|
|
12855
|
+
*/
|
|
12856
|
+
async createCash(amount) {
|
|
12857
|
+
if (!Number.isSafeInteger(amount) || amount < Number(this.dustAmount)) {
|
|
12858
|
+
throw new Error(
|
|
12859
|
+
`Invalid ArkCash amount ${amount}: must be a whole number of sats >= dust (${this.dustAmount})`
|
|
12860
|
+
);
|
|
12861
|
+
}
|
|
12862
|
+
const cashHrp = this.network.hrp.replace(/ark$/, "arkcash");
|
|
12863
|
+
const cash = ArkCash.generate(
|
|
12864
|
+
this.arkServerPublicKey,
|
|
12865
|
+
this.offchainTapscript.options.csvTimelock,
|
|
12866
|
+
cashHrp
|
|
12867
|
+
);
|
|
12868
|
+
const address = cash.address(this.network.hrp).encode();
|
|
12869
|
+
const cashStr = cash.toString();
|
|
12870
|
+
try {
|
|
12871
|
+
await this.send({ address, amount });
|
|
12872
|
+
} catch (error) {
|
|
12873
|
+
throw new ArkCashCreateError(cashStr, error);
|
|
12874
|
+
}
|
|
12875
|
+
return cashStr;
|
|
12876
|
+
}
|
|
12877
|
+
/**
|
|
12878
|
+
* Claim an ArkCash bearer instrument: sweep what can be swept, report the
|
|
12879
|
+
* rest.
|
|
12880
|
+
*
|
|
12881
|
+
* Every spendable VTXO at the arkcash address is swept to this wallet in
|
|
12882
|
+
* its own offchain transaction, signed with the key carried by the arkcash
|
|
12883
|
+
* string. Nothing is ever persisted: no contract is imported, and the
|
|
12884
|
+
* arkcash key is not stored. Anything that cannot be swept — server-swept,
|
|
12885
|
+
* subdust, already claimed, or asset-bearing — is returned in `unclaimed`
|
|
12886
|
+
* with a per-VTXO reason and otherwise ignored.
|
|
12887
|
+
*
|
|
12888
|
+
* The arkcash string is the recovery token: a claim interrupted between
|
|
12889
|
+
* submit and finalize is completed by simply re-running `claimCash`, which
|
|
12890
|
+
* drains any pending arkcash transaction on the server before sweeping.
|
|
12891
|
+
*
|
|
12892
|
+
* @param cashStr - The encoded arkcash string (e.g., "arkcash1...")
|
|
12893
|
+
* @returns The swept total and the report of what was left behind. The
|
|
12894
|
+
* shape is open: further buckets may be added alongside `unclaimed`.
|
|
12895
|
+
*/
|
|
12896
|
+
async claimCash(cashStr) {
|
|
12897
|
+
const cash = ArkCash.fromString(cashStr);
|
|
12898
|
+
const cashScript = cash.vtxoScript;
|
|
12899
|
+
const cashPkScript = base.hex.encode(cashScript.pkScript);
|
|
12900
|
+
const scripts = [cashPkScript];
|
|
12901
|
+
let vtxos = await this.fetchAllVtxos(scripts);
|
|
12902
|
+
if (vtxos.length === 0) {
|
|
12903
|
+
throw new Error("No VTXOs found for this arkcash");
|
|
12904
|
+
}
|
|
12905
|
+
const myPkScript = chunkL5ND2FJJ_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
12906
|
+
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
12907
|
+
let swept = 0;
|
|
12908
|
+
const drainable = vtxos.filter((vtxo) => !isSubdust(vtxo, this.dustAmount));
|
|
12909
|
+
if (drainable.length > 0) {
|
|
12910
|
+
let drained = { count: 0, swept: 0, claimed: /* @__PURE__ */ new Set() };
|
|
12911
|
+
try {
|
|
12912
|
+
drained = await this.finalizePendingCashTxs(
|
|
12913
|
+
cash,
|
|
12914
|
+
drainable,
|
|
12915
|
+
cashScript,
|
|
12916
|
+
myPkScript
|
|
12917
|
+
);
|
|
12918
|
+
} catch (error) {
|
|
12919
|
+
console.error("Failed to drain pending arkcash txs:", error);
|
|
12920
|
+
}
|
|
12921
|
+
if (drained.count > 0) {
|
|
12922
|
+
vtxos = await this.fetchAllVtxos(scripts);
|
|
12923
|
+
({ spendable, unclaimed } = this.classifyCashVtxos(vtxos));
|
|
12924
|
+
swept += drained.swept;
|
|
12925
|
+
unclaimed = unclaimed.filter(
|
|
12926
|
+
(vtxo) => !drained.claimed.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
12927
|
+
);
|
|
12928
|
+
}
|
|
12929
|
+
}
|
|
12930
|
+
if (spendable.length > 0) {
|
|
12931
|
+
const info = await this.arkProvider.getInfo();
|
|
12932
|
+
const serverUnrollScript = chunkL5ND2FJJ_cjs.CSVMultisigTapscript.decode(
|
|
12933
|
+
base.hex.decode(info.checkpointTapscript)
|
|
12934
|
+
);
|
|
12935
|
+
for (const vtxo of spendable) {
|
|
12936
|
+
try {
|
|
12937
|
+
await signAndSubmitOffchainTx({
|
|
12938
|
+
identity: cash.identity,
|
|
12939
|
+
provider: this.arkProvider,
|
|
12940
|
+
inputs: [
|
|
12941
|
+
{
|
|
12942
|
+
txid: vtxo.txid,
|
|
12943
|
+
vout: vtxo.vout,
|
|
12944
|
+
value: vtxo.value,
|
|
12945
|
+
tapLeafScript: cashScript.forfeit(),
|
|
12946
|
+
tapTree: cashScript.encode()
|
|
12947
|
+
}
|
|
12948
|
+
],
|
|
12949
|
+
outputs: [{ script: myPkScript, amount: BigInt(vtxo.value) }],
|
|
12950
|
+
serverUnrollScript
|
|
12951
|
+
});
|
|
12952
|
+
swept += vtxo.value;
|
|
12953
|
+
} catch (error) {
|
|
12954
|
+
console.error(`Failed to sweep arkcash VTXO ${vtxo.txid}:${vtxo.vout}:`, error);
|
|
12955
|
+
unclaimed.push(cashReport(vtxo, "sweep-failed"));
|
|
12956
|
+
}
|
|
12957
|
+
}
|
|
12958
|
+
}
|
|
12959
|
+
return {
|
|
12960
|
+
swept,
|
|
12961
|
+
unclaimed: {
|
|
12962
|
+
amount: unclaimed.reduce((total, vtxo) => total + vtxo.value, 0),
|
|
12963
|
+
vtxos: unclaimed
|
|
12964
|
+
}
|
|
12965
|
+
};
|
|
12966
|
+
}
|
|
12967
|
+
/**
|
|
12968
|
+
* Split the VTXOs at an arkcash address into the ones the thin sweep can
|
|
12969
|
+
* move and the ones it can only report.
|
|
12970
|
+
*/
|
|
12971
|
+
classifyCashVtxos(vtxos) {
|
|
12972
|
+
const spendable = [];
|
|
12973
|
+
const unclaimed = [];
|
|
12974
|
+
for (const vtxo of vtxos) {
|
|
12975
|
+
if (!isSpendable(vtxo)) {
|
|
12976
|
+
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
12977
|
+
} else if (isSubdust(vtxo, this.dustAmount)) {
|
|
12978
|
+
unclaimed.push(cashReport(vtxo, "subdust"));
|
|
12979
|
+
} else if (isRecoverable(vtxo)) {
|
|
12980
|
+
unclaimed.push(cashReport(vtxo, "swept"));
|
|
12981
|
+
} else if (vtxo.assets && vtxo.assets.length > 0) {
|
|
12982
|
+
unclaimed.push(cashReport(vtxo, "has-assets"));
|
|
12983
|
+
} else {
|
|
12984
|
+
spendable.push(vtxo);
|
|
12985
|
+
}
|
|
12986
|
+
}
|
|
12987
|
+
return { spendable, unclaimed };
|
|
12988
|
+
}
|
|
12989
|
+
/** Read every page of an unfiltered VTXO query for the given scripts. */
|
|
12990
|
+
async fetchAllVtxos(scripts) {
|
|
12991
|
+
const pageSize = 100;
|
|
12992
|
+
const all = [];
|
|
12993
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12994
|
+
for (let pageIndex = 0; ; pageIndex++) {
|
|
12995
|
+
const { vtxos, page } = await this.indexerProvider.getVtxos({
|
|
12996
|
+
scripts,
|
|
12997
|
+
pageIndex,
|
|
12998
|
+
pageSize
|
|
12999
|
+
});
|
|
13000
|
+
for (const vtxo of vtxos) {
|
|
13001
|
+
const outpoint = `${vtxo.txid}:${vtxo.vout}`;
|
|
13002
|
+
if (seen.has(outpoint)) continue;
|
|
13003
|
+
seen.add(outpoint);
|
|
13004
|
+
all.push(vtxo);
|
|
13005
|
+
}
|
|
13006
|
+
if (!page || vtxos.length < pageSize) return all;
|
|
13007
|
+
}
|
|
13008
|
+
}
|
|
13009
|
+
/**
|
|
13010
|
+
* Complete any sweep a previous `claimCash` registered but never finalized.
|
|
13011
|
+
* A thin variant of {@link finalizePendingTxs}, scoped to the arkcash key:
|
|
13012
|
+
* the intent is signed with it, and so are the returned checkpoints.
|
|
13013
|
+
*
|
|
13014
|
+
* A drained sweep is not automatically *ours*. Whoever registered it chose
|
|
13015
|
+
* the destination, so a tx a different claimer left half-finished pays that
|
|
13016
|
+
* claimer — finalizing it is still right (the input is spent either way, and
|
|
13017
|
+
* completing it unsticks the funds), but only the value it actually pays to
|
|
13018
|
+
* `myPkScript` may be counted as claimed here.
|
|
13019
|
+
*
|
|
13020
|
+
* @param vtxos - VTXOs at the arkcash contract's own pkScript, spent ones
|
|
13021
|
+
* included (a registered sweep marks its input spent). Any other outpoint —
|
|
13022
|
+
* subdust above all — would make the proof invalid, since it describes every
|
|
13023
|
+
* input by that pkScript.
|
|
13024
|
+
* @returns The number of pending txs finalized, the sats among them paid to
|
|
13025
|
+
* this wallet, and the outpoints those txs consumed to pay it.
|
|
13026
|
+
*/
|
|
13027
|
+
async finalizePendingCashTxs(cash, vtxos, cashScript, myPkScript) {
|
|
13028
|
+
const result = { count: 0, swept: 0, claimed: /* @__PURE__ */ new Set() };
|
|
13029
|
+
const inputs = vtxos.map((vtxo) => ({
|
|
13030
|
+
...vtxo,
|
|
13031
|
+
forfeitTapLeafScript: cashScript.forfeit(),
|
|
13032
|
+
intentTapLeafScript: cashScript.forfeit(),
|
|
13033
|
+
tapTree: cashScript.encode()
|
|
13034
|
+
}));
|
|
13035
|
+
if (inputs.length === 0) return result;
|
|
13036
|
+
const identity = cash.identity;
|
|
13037
|
+
const seenTxids = /* @__PURE__ */ new Set();
|
|
13038
|
+
const pendingTxs = [];
|
|
13039
|
+
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
13040
|
+
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
13041
|
+
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
13042
|
+
const proof = chunkCFQO5MCM_cjs.Intent.create(message, batch, []);
|
|
13043
|
+
const signedProof = await identity.sign(
|
|
13044
|
+
proof,
|
|
13045
|
+
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
13046
|
+
);
|
|
13047
|
+
const batchPending = await this.arkProvider.getPendingTxs({
|
|
13048
|
+
proof: base.base64.encode(signedProof.toPSBT()),
|
|
13049
|
+
message
|
|
13050
|
+
});
|
|
13051
|
+
for (const pendingTx of batchPending) {
|
|
13052
|
+
if (seenTxids.has(pendingTx.arkTxid)) continue;
|
|
13053
|
+
seenTxids.add(pendingTx.arkTxid);
|
|
13054
|
+
pendingTxs.push(pendingTx);
|
|
13055
|
+
}
|
|
13056
|
+
}
|
|
13057
|
+
const myPkScriptHex = base.hex.encode(myPkScript);
|
|
13058
|
+
for (const pendingTx of pendingTxs) {
|
|
13059
|
+
try {
|
|
13060
|
+
const checkpointTxs = pendingTx.signedCheckpointTxs.map(
|
|
13061
|
+
(checkpoint) => btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint))
|
|
13062
|
+
);
|
|
13063
|
+
const finalCheckpoints = await Promise.all(
|
|
13064
|
+
checkpointTxs.map(
|
|
13065
|
+
async (checkpoint) => base.base64.encode((await identity.sign(checkpoint)).toPSBT())
|
|
13066
|
+
)
|
|
13067
|
+
);
|
|
13068
|
+
await this.arkProvider.finalizeTx(pendingTx.arkTxid, finalCheckpoints);
|
|
13069
|
+
result.count++;
|
|
13070
|
+
const paidToMe = this.arkTxAmountPaidTo(pendingTx.finalArkTx, myPkScriptHex);
|
|
13071
|
+
if (paidToMe === 0) continue;
|
|
13072
|
+
result.swept += paidToMe;
|
|
13073
|
+
for (const checkpoint of checkpointTxs) {
|
|
13074
|
+
for (let i = 0; i < checkpoint.inputsLength; i++) {
|
|
13075
|
+
const input = checkpoint.getInput(i);
|
|
13076
|
+
if (!input.txid) continue;
|
|
13077
|
+
result.claimed.add(`${base.hex.encode(input.txid)}:${input.index}`);
|
|
13078
|
+
}
|
|
13079
|
+
}
|
|
13080
|
+
} catch (error) {
|
|
13081
|
+
console.error(`Failed to finalize pending arkcash tx ${pendingTx.arkTxid}:`, error);
|
|
13082
|
+
}
|
|
13083
|
+
}
|
|
13084
|
+
return result;
|
|
13085
|
+
}
|
|
13086
|
+
/** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
|
|
13087
|
+
arkTxAmountPaidTo(arkTxPsbt, pkScriptHex) {
|
|
13088
|
+
const arkTx = btcSigner.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
|
|
13089
|
+
let total = 0;
|
|
13090
|
+
for (let i = 0; i < arkTx.outputsLength; i++) {
|
|
13091
|
+
const output = arkTx.getOutput(i);
|
|
13092
|
+
if (!output.script || output.amount === void 0) continue;
|
|
13093
|
+
if (base.hex.encode(output.script) === pkScriptHex) total += Number(output.amount);
|
|
13094
|
+
}
|
|
13095
|
+
return total;
|
|
13096
|
+
}
|
|
12721
13097
|
/**
|
|
12722
13098
|
* Send BTC and/or assets to one or more recipients.
|
|
12723
13099
|
*
|
|
@@ -13545,7 +13921,7 @@ var MessageBus = class {
|
|
|
13545
13921
|
this.initialized = true;
|
|
13546
13922
|
}
|
|
13547
13923
|
async buildServices(config) {
|
|
13548
|
-
const arkProvider = new
|
|
13924
|
+
const arkProvider = new chunkCFQO5MCM_cjs.RestArkProvider(config.arkServer.url);
|
|
13549
13925
|
const storage = {
|
|
13550
13926
|
walletRepository: this.walletRepository,
|
|
13551
13927
|
contractRepository: this.contractRepository
|
|
@@ -14711,7 +15087,7 @@ var WalletMessageHandler = class {
|
|
|
14711
15087
|
// Wallet methods
|
|
14712
15088
|
async handleInitWallet({ payload }) {
|
|
14713
15089
|
const { arkServerUrl } = payload;
|
|
14714
|
-
this.indexerProvider = new
|
|
15090
|
+
this.indexerProvider = new chunkCFQO5MCM_cjs.RestIndexerProvider(arkServerUrl);
|
|
14715
15091
|
await this.onWalletInitialized();
|
|
14716
15092
|
}
|
|
14717
15093
|
async handleGetBalance() {
|
|
@@ -16577,7 +16953,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
16577
16953
|
if (!inputs) {
|
|
16578
16954
|
throw new Error("Fee estimation failed");
|
|
16579
16955
|
}
|
|
16580
|
-
let tx = new
|
|
16956
|
+
let tx = new chunkCFQO5MCM_cjs.Transaction();
|
|
16581
16957
|
for (const input of inputs) {
|
|
16582
16958
|
tx.addInput({
|
|
16583
16959
|
txid: input.txid,
|
|
@@ -16635,7 +17011,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
16635
17011
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
16636
17012
|
*/
|
|
16637
17013
|
async bumpAnchor(parentHex, feeRate) {
|
|
16638
|
-
const parent =
|
|
17014
|
+
const parent = chunkCFQO5MCM_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
16639
17015
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
16640
17016
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
16641
17017
|
return [parent.hex, child.hex];
|
|
@@ -17400,7 +17776,7 @@ exports.BIP322 = void 0;
|
|
|
17400
17776
|
async function sign2(message, identity, network) {
|
|
17401
17777
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
17402
17778
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
17403
|
-
const toSpend =
|
|
17779
|
+
const toSpend = chunkCFQO5MCM_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
17404
17780
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
17405
17781
|
const signed = await identity.sign(toSign, [0]);
|
|
17406
17782
|
signed.finalizeIdx(0);
|
|
@@ -17458,7 +17834,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
17458
17834
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
17459
17835
|
return false;
|
|
17460
17836
|
}
|
|
17461
|
-
const toSpend =
|
|
17837
|
+
const toSpend = chunkCFQO5MCM_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
17462
17838
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
17463
17839
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
17464
17840
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -17479,7 +17855,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
17479
17855
|
}
|
|
17480
17856
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
17481
17857
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
17482
|
-
const toSpend =
|
|
17858
|
+
const toSpend = chunkCFQO5MCM_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
17483
17859
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
17484
17860
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
17485
17861
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -17532,7 +17908,7 @@ function encodeCompactSize(n) {
|
|
|
17532
17908
|
return buf;
|
|
17533
17909
|
}
|
|
17534
17910
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
17535
|
-
const tx = new
|
|
17911
|
+
const tx = new chunkCFQO5MCM_cjs.Transaction({ version: 0 });
|
|
17536
17912
|
tx.addInput({
|
|
17537
17913
|
txid: toSpend.id,
|
|
17538
17914
|
index: 0,
|
|
@@ -17546,12 +17922,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
17546
17922
|
});
|
|
17547
17923
|
tx.addOutput({
|
|
17548
17924
|
amount: 0n,
|
|
17549
|
-
script:
|
|
17925
|
+
script: chunkCFQO5MCM_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
17550
17926
|
});
|
|
17551
17927
|
return tx;
|
|
17552
17928
|
}
|
|
17553
17929
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
17554
|
-
const tx = new
|
|
17930
|
+
const tx = new chunkCFQO5MCM_cjs.Transaction({ version: 0 });
|
|
17555
17931
|
tx.addInput({
|
|
17556
17932
|
txid: toSpend.id,
|
|
17557
17933
|
index: 0,
|
|
@@ -17563,7 +17939,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
17563
17939
|
});
|
|
17564
17940
|
tx.addOutput({
|
|
17565
17941
|
amount: 0n,
|
|
17566
|
-
script:
|
|
17942
|
+
script: chunkCFQO5MCM_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
17567
17943
|
});
|
|
17568
17944
|
return tx;
|
|
17569
17945
|
}
|
|
@@ -17694,7 +18070,7 @@ var RestEmulatorProvider = class {
|
|
|
17694
18070
|
}
|
|
17695
18071
|
};
|
|
17696
18072
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
17697
|
-
const tx =
|
|
18073
|
+
const tx = chunkCFQO5MCM_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
17698
18074
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
17699
18075
|
const input = tx.getInput(0);
|
|
17700
18076
|
if (!input) {
|
|
@@ -17972,7 +18348,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
17972
18348
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
17973
18349
|
);
|
|
17974
18350
|
}
|
|
17975
|
-
const tx = new
|
|
18351
|
+
const tx = new chunkCFQO5MCM_cjs.Transaction({ version: 2 });
|
|
17976
18352
|
for (const input of inputs) {
|
|
17977
18353
|
tx.addInput(input);
|
|
17978
18354
|
}
|
|
@@ -18039,7 +18415,7 @@ async function buildSignedSweep(params) {
|
|
|
18039
18415
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
18040
18416
|
);
|
|
18041
18417
|
}
|
|
18042
|
-
const tx = new
|
|
18418
|
+
const tx = new chunkCFQO5MCM_cjs.Transaction({ version: 2 });
|
|
18043
18419
|
tx.addInput({
|
|
18044
18420
|
txid: vtxo.txid,
|
|
18045
18421
|
index: vtxo.vout,
|
|
@@ -18139,7 +18515,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
18139
18515
|
if (pendingNodes.length > 0) {
|
|
18140
18516
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
18141
18517
|
for (const psbt of txs) {
|
|
18142
|
-
psbts.set(
|
|
18518
|
+
psbts.set(chunkCFQO5MCM_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
18143
18519
|
}
|
|
18144
18520
|
}
|
|
18145
18521
|
const childVsize = Number(
|
|
@@ -18586,7 +18962,7 @@ async function prepare(opts) {
|
|
|
18586
18962
|
if (newFee <= splitterFee) break;
|
|
18587
18963
|
splitterFee = newFee;
|
|
18588
18964
|
}
|
|
18589
|
-
const splitter = new
|
|
18965
|
+
const splitter = new chunkCFQO5MCM_cjs.Transaction({ version: 2 });
|
|
18590
18966
|
for (const coin of selected.inputs) {
|
|
18591
18967
|
splitter.addInput({
|
|
18592
18968
|
txid: coin.txid,
|
|
@@ -18793,7 +19169,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
18793
19169
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
18794
19170
|
return { skip: true };
|
|
18795
19171
|
}
|
|
18796
|
-
const commitmentTx =
|
|
19172
|
+
const commitmentTx = chunkCFQO5MCM_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
18797
19173
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
18798
19174
|
if (recipients && recipients.length > 0) {
|
|
18799
19175
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -18824,7 +19200,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
18824
19200
|
if (connectorTree) {
|
|
18825
19201
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
18826
19202
|
}
|
|
18827
|
-
let commitmentPsbt =
|
|
19203
|
+
let commitmentPsbt = chunkCFQO5MCM_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
18828
19204
|
const signedForfeits = [];
|
|
18829
19205
|
let connectorIndex = 0;
|
|
18830
19206
|
const connectorLeaves = connectorTree?.leaves() || [];
|
|
@@ -19228,12 +19604,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
19228
19604
|
this.contract.client.checkpoint
|
|
19229
19605
|
);
|
|
19230
19606
|
if (coin.sourceTx) {
|
|
19231
|
-
|
|
19607
|
+
chunkCFQO5MCM_cjs.setArkPsbtField(arkTx, 0, chunkCFQO5MCM_cjs.PrevArkTxField, coin.sourceTx);
|
|
19232
19608
|
}
|
|
19233
19609
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
19234
19610
|
if (condition.length > 0) {
|
|
19235
|
-
|
|
19236
|
-
|
|
19611
|
+
chunkCFQO5MCM_cjs.setArkPsbtField(arkTx, 0, chunkCFQO5MCM_cjs.ConditionWitness, condition);
|
|
19612
|
+
chunkCFQO5MCM_cjs.setArkPsbtField(checkpoints[0], 0, chunkCFQO5MCM_cjs.ConditionWitness, condition);
|
|
19237
19613
|
}
|
|
19238
19614
|
const packets = [];
|
|
19239
19615
|
if (this.assetSpecs.length > 0) {
|
|
@@ -19272,7 +19648,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
19272
19648
|
base.base64.encode(signedArk2.toPSBT()),
|
|
19273
19649
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
19274
19650
|
);
|
|
19275
|
-
const txid =
|
|
19651
|
+
const txid = chunkCFQO5MCM_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
19276
19652
|
return {
|
|
19277
19653
|
txid,
|
|
19278
19654
|
signedArkTx: res2.signedArkTx,
|
|
@@ -19290,7 +19666,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
19290
19666
|
const finalCps = await Promise.all(
|
|
19291
19667
|
res.signedCheckpointTxs.map(
|
|
19292
19668
|
async (b) => base.base64.encode(
|
|
19293
|
-
(await client.identity.sign(
|
|
19669
|
+
(await client.identity.sign(chunkCFQO5MCM_cjs.Transaction.fromPSBT(base.base64.decode(b)), [0])).toPSBT()
|
|
19294
19670
|
)
|
|
19295
19671
|
)
|
|
19296
19672
|
);
|
|
@@ -19331,16 +19707,16 @@ var ArkadeTransactionBuilder = class {
|
|
|
19331
19707
|
}
|
|
19332
19708
|
buildAssetPacket() {
|
|
19333
19709
|
const groups = this.assetSpecs.map((s) => {
|
|
19334
|
-
const id = typeof s.assetId === "string" ?
|
|
19335
|
-
return
|
|
19710
|
+
const id = typeof s.assetId === "string" ? chunkCFQO5MCM_cjs.AssetId.fromString(s.assetId) : chunkCFQO5MCM_cjs.AssetId.fromBytes(s.assetId);
|
|
19711
|
+
return chunkCFQO5MCM_cjs.AssetGroup.create(
|
|
19336
19712
|
id,
|
|
19337
19713
|
null,
|
|
19338
|
-
s.inputs.map((i) =>
|
|
19339
|
-
s.outputs.map((o) =>
|
|
19340
|
-
(s.metadata ?? []).map((m) =>
|
|
19714
|
+
s.inputs.map((i) => chunkCFQO5MCM_cjs.AssetInput.create(i.vin, i.amount)),
|
|
19715
|
+
s.outputs.map((o) => chunkCFQO5MCM_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
19716
|
+
(s.metadata ?? []).map((m) => chunkCFQO5MCM_cjs.Metadata.create(m.key, m.value))
|
|
19341
19717
|
);
|
|
19342
19718
|
});
|
|
19343
|
-
return
|
|
19719
|
+
return chunkCFQO5MCM_cjs.Packet.create(groups);
|
|
19344
19720
|
}
|
|
19345
19721
|
witnessBytes(ref) {
|
|
19346
19722
|
return chunkRQSA7ADZ_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
@@ -19436,6 +19812,8 @@ function isArkContract(str) {
|
|
|
19436
19812
|
|
|
19437
19813
|
exports.ARKADE_MAGIC = ARKADE_MAGIC;
|
|
19438
19814
|
exports.ActivityRegistry = ActivityRegistry;
|
|
19815
|
+
exports.ArkCash = ArkCash;
|
|
19816
|
+
exports.ArkCashCreateError = ArkCashCreateError;
|
|
19439
19817
|
exports.ArkNote = ArkNote;
|
|
19440
19818
|
exports.AssetManager = AssetManager;
|
|
19441
19819
|
exports.ChainedTxType = ChainedTxType;
|
|
@@ -19564,5 +19942,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
19564
19942
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
19565
19943
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
19566
19944
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
19567
|
-
//# sourceMappingURL=chunk-
|
|
19568
|
-
//# sourceMappingURL=chunk-
|
|
19945
|
+
//# sourceMappingURL=chunk-RJMFTTRJ.cjs.map
|
|
19946
|
+
//# sourceMappingURL=chunk-RJMFTTRJ.cjs.map
|