@arkade-os/sdk 0.4.31 → 0.4.33
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.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +2 -2
- package/dist/adapters/indexedDB.cjs +4 -4
- package/dist/adapters/indexedDB.js +3 -3
- package/dist/{ark-ibLW4Hte.d.cts → ark-DEsDMYGv.d.cts} +17 -4
- package/dist/{ark-ibLW4Hte.d.ts → ark-DEsDMYGv.d.ts} +17 -4
- package/dist/{asyncStorageTaskQueue-BEOFPNc0.d.ts → asyncStorageTaskQueue-CMrTYlKG.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-VGHXWR9F.d.cts → asyncStorageTaskQueue-D8T1VXEx.d.cts} +1 -1
- package/dist/{chunk-GIGILVVP.cjs → chunk-5CCRRL5S.cjs} +8 -8
- package/dist/{chunk-GIGILVVP.cjs.map → chunk-5CCRRL5S.cjs.map} +1 -1
- package/dist/{chunk-GPZH5QNA.cjs → chunk-7K3ROJF6.cjs} +315 -146
- package/dist/chunk-7K3ROJF6.cjs.map +1 -0
- package/dist/{chunk-YA4G7RFB.js → chunk-AOJUURHM.js} +30 -6
- package/dist/chunk-AOJUURHM.js.map +1 -0
- package/dist/{chunk-AXGVYRAL.js → chunk-BU3BU6XK.js} +3 -3
- package/dist/{chunk-AXGVYRAL.js.map → chunk-BU3BU6XK.js.map} +1 -1
- package/dist/{chunk-HJM6JPG4.js → chunk-DSS2GQUG.js} +224 -55
- package/dist/chunk-DSS2GQUG.js.map +1 -0
- package/dist/{chunk-6NWNOLL3.js → chunk-E22HEKLN.js} +3 -3
- package/dist/chunk-E22HEKLN.js.map +1 -0
- package/dist/{chunk-IEO3XDKI.cjs → chunk-GYSK5R57.cjs} +32 -5
- package/dist/chunk-GYSK5R57.cjs.map +1 -0
- package/dist/{chunk-RN2OFLC3.cjs → chunk-HAVA4XB7.cjs} +7 -7
- package/dist/{chunk-RN2OFLC3.cjs.map → chunk-HAVA4XB7.cjs.map} +1 -1
- package/dist/{chunk-ABWRLTX5.js → chunk-L6ZETTX3.js} +3 -3
- package/dist/{chunk-ABWRLTX5.js.map → chunk-L6ZETTX3.js.map} +1 -1
- package/dist/{chunk-6FLL2Q36.cjs → chunk-SPDNHPM4.cjs} +3 -3
- package/dist/chunk-SPDNHPM4.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -5
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +1 -1
- package/dist/{delegate-BvNTw44a.d.cts → delegate-BJeBNP5a.d.cts} +10 -2
- package/dist/{delegate-BXaR1RNG.d.ts → delegate-EXN2mfkb.d.ts} +10 -2
- package/dist/{index-BusKawmy.d.ts → index-BG2ooYKO.d.ts} +57 -3
- package/dist/{index-C-5Tw7VA.d.cts → index-DHjEeHEp.d.cts} +57 -3
- package/dist/index.cjs +125 -113
- package/dist/index.d.cts +33 -9
- package/dist/index.d.ts +33 -9
- package/dist/index.js +3 -3
- package/dist/repositories/realm/index.cjs +12 -12
- package/dist/repositories/realm/index.d.cts +1 -1
- package/dist/repositories/realm/index.d.ts +1 -1
- package/dist/repositories/realm/index.js +3 -3
- package/dist/repositories/sqlite/index.cjs +12 -12
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.js +3 -3
- package/dist/{taskRunner-B1igKGAo.d.ts → taskRunner-B7lBU45X.d.ts} +1 -1
- package/dist/{taskRunner-By92TQ1m.d.cts → taskRunner-pIGyarFG.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +13 -13
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +5 -5
- package/dist/wallet/expo/index.cjs +13 -13
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +5 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-CyM4F7Bs.d.ts → wallet-C4L_X0i6.d.ts} +2 -2
- package/dist/{wallet-B_rxgQTu.d.cts → wallet-D4Dll5Gu.d.cts} +2 -2
- package/dist/worker/expo/index.cjs +8 -8
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-6FLL2Q36.cjs.map +0 -1
- package/dist/chunk-6NWNOLL3.js.map +0 -1
- package/dist/chunk-GPZH5QNA.cjs.map +0 -1
- package/dist/chunk-HJM6JPG4.js.map +0 -1
- package/dist/chunk-IEO3XDKI.cjs.map +0 -1
- package/dist/chunk-YA4G7RFB.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkSPDNHPM4_cjs = require('./chunk-SPDNHPM4.cjs');
|
|
4
|
+
var chunkGYSK5R57_cjs = require('./chunk-GYSK5R57.cjs');
|
|
5
5
|
var chunkWMIPYZSB_cjs = require('./chunk-WMIPYZSB.cjs');
|
|
6
6
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
7
7
|
var btcSigner = require('@scure/btc-signer');
|
|
@@ -181,7 +181,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
181
181
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
182
182
|
const tx = this.graph.find(txid);
|
|
183
183
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
184
|
-
const cosigners =
|
|
184
|
+
const cosigners = chunkSPDNHPM4_cjs.getArkPsbtFields(tx.root, 0, chunkSPDNHPM4_cjs.CosignerPublicKey).map(
|
|
185
185
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
186
186
|
// xonly pubkey
|
|
187
187
|
);
|
|
@@ -233,7 +233,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
233
233
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
234
234
|
const prevoutAmounts = [];
|
|
235
235
|
const prevoutScripts = [];
|
|
236
|
-
const cosigners =
|
|
236
|
+
const cosigners = chunkSPDNHPM4_cjs.getArkPsbtFields(g.root, 0, chunkSPDNHPM4_cjs.CosignerPublicKey).map((c) => c.key);
|
|
237
237
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
238
238
|
taprootTweak: this.scriptRoot
|
|
239
239
|
});
|
|
@@ -411,7 +411,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
411
411
|
let network;
|
|
412
412
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
413
413
|
descriptor = opts.descriptor;
|
|
414
|
-
network =
|
|
414
|
+
network = chunkGYSK5R57_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
415
415
|
} else {
|
|
416
416
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
417
417
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -496,7 +496,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
496
496
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
497
497
|
*/
|
|
498
498
|
isOurs(descriptor) {
|
|
499
|
-
return
|
|
499
|
+
return chunkGYSK5R57_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
500
500
|
}
|
|
501
501
|
/**
|
|
502
502
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -533,7 +533,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
533
533
|
}
|
|
534
534
|
// ── internal helpers ─────────────────────────────────────────────
|
|
535
535
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
536
|
-
const network =
|
|
536
|
+
const network = chunkGYSK5R57_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
537
537
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
538
538
|
if (expansion.isRanged) {
|
|
539
539
|
throw new Error(
|
|
@@ -619,7 +619,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
619
619
|
*/
|
|
620
620
|
descriptor;
|
|
621
621
|
constructor(descriptor) {
|
|
622
|
-
const network =
|
|
622
|
+
const network = chunkGYSK5R57_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
623
623
|
let expansion;
|
|
624
624
|
try {
|
|
625
625
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -669,7 +669,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
669
669
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
670
670
|
*/
|
|
671
671
|
isOurs(descriptor) {
|
|
672
|
-
return
|
|
672
|
+
return chunkGYSK5R57_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
673
673
|
}
|
|
674
674
|
};
|
|
675
675
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -987,7 +987,7 @@ var RestDelegateProvider = class {
|
|
|
987
987
|
},
|
|
988
988
|
body: JSON.stringify({
|
|
989
989
|
intent: {
|
|
990
|
-
message:
|
|
990
|
+
message: chunkSPDNHPM4_cjs.Intent.encodeMessage(intent.message),
|
|
991
991
|
proof: intent.proof
|
|
992
992
|
},
|
|
993
993
|
forfeit_txs: forfeitTxs,
|
|
@@ -1277,7 +1277,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
1277
1277
|
);
|
|
1278
1278
|
}
|
|
1279
1279
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
1280
|
-
const tx = new
|
|
1280
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction({
|
|
1281
1281
|
version: 3,
|
|
1282
1282
|
lockTime: txLocktime
|
|
1283
1283
|
});
|
|
@@ -1353,7 +1353,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
1353
1353
|
if (previousScriptKey.length !== 32) {
|
|
1354
1354
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
1355
1355
|
}
|
|
1356
|
-
const cosigners =
|
|
1356
|
+
const cosigners = chunkSPDNHPM4_cjs.getArkPsbtFields(child.root, 0, chunkSPDNHPM4_cjs.CosignerPublicKey);
|
|
1357
1357
|
if (cosigners.length === 0) {
|
|
1358
1358
|
throw ErrMissingCosignersPublicKeys;
|
|
1359
1359
|
}
|
|
@@ -1453,7 +1453,7 @@ var Extension = class _Extension {
|
|
|
1453
1453
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
1454
1454
|
);
|
|
1455
1455
|
}
|
|
1456
|
-
const reader = new
|
|
1456
|
+
const reader = new chunkSPDNHPM4_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
1457
1457
|
const packets = [];
|
|
1458
1458
|
while (reader.remaining() > 0) {
|
|
1459
1459
|
const packetType = reader.readByte();
|
|
@@ -1527,7 +1527,7 @@ var Extension = class _Extension {
|
|
|
1527
1527
|
*/
|
|
1528
1528
|
getAssetPacket() {
|
|
1529
1529
|
for (const p of this.packets) {
|
|
1530
|
-
if (p instanceof
|
|
1530
|
+
if (p instanceof chunkSPDNHPM4_cjs.Packet) {
|
|
1531
1531
|
return p;
|
|
1532
1532
|
}
|
|
1533
1533
|
}
|
|
@@ -1535,8 +1535,8 @@ var Extension = class _Extension {
|
|
|
1535
1535
|
}
|
|
1536
1536
|
};
|
|
1537
1537
|
function parsePacket(packetType, data) {
|
|
1538
|
-
if (packetType ===
|
|
1539
|
-
return
|
|
1538
|
+
if (packetType === chunkSPDNHPM4_cjs.Packet.PACKET_TYPE) {
|
|
1539
|
+
return chunkSPDNHPM4_cjs.Packet.fromBytes(data);
|
|
1540
1540
|
}
|
|
1541
1541
|
return new UnknownPacket(packetType, data);
|
|
1542
1542
|
}
|
|
@@ -1727,7 +1727,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1727
1727
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
1728
1728
|
inputsByAssetId.set(asset.assetId, [
|
|
1729
1729
|
...existing ?? [],
|
|
1730
|
-
|
|
1730
|
+
chunkSPDNHPM4_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
1731
1731
|
]);
|
|
1732
1732
|
}
|
|
1733
1733
|
}
|
|
@@ -1739,7 +1739,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1739
1739
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
1740
1740
|
outputsByAssetId.set(asset.assetId, [
|
|
1741
1741
|
...existing ?? [],
|
|
1742
|
-
|
|
1742
|
+
chunkSPDNHPM4_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
1743
1743
|
]);
|
|
1744
1744
|
}
|
|
1745
1745
|
}
|
|
@@ -1750,7 +1750,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1750
1750
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
1751
1751
|
outputsByAssetId.set(asset.assetId, [
|
|
1752
1752
|
...existing ?? [],
|
|
1753
|
-
|
|
1753
|
+
chunkSPDNHPM4_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
1754
1754
|
]);
|
|
1755
1755
|
}
|
|
1756
1756
|
}
|
|
@@ -1759,11 +1759,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1759
1759
|
for (const assetIdStr of allAssetIds) {
|
|
1760
1760
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
1761
1761
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
1762
|
-
const assetId =
|
|
1763
|
-
const group =
|
|
1762
|
+
const assetId = chunkSPDNHPM4_cjs.AssetId.fromString(assetIdStr);
|
|
1763
|
+
const group = chunkSPDNHPM4_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
1764
1764
|
groups.push(group);
|
|
1765
1765
|
}
|
|
1766
|
-
return
|
|
1766
|
+
return chunkSPDNHPM4_cjs.Packet.create(groups);
|
|
1767
1767
|
}
|
|
1768
1768
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
1769
1769
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -1841,7 +1841,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
1841
1841
|
}
|
|
1842
1842
|
}
|
|
1843
1843
|
}
|
|
1844
|
-
const tx = new
|
|
1844
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction({
|
|
1845
1845
|
version: 3,
|
|
1846
1846
|
lockTime: Number(lockTime)
|
|
1847
1847
|
});
|
|
@@ -1856,7 +1856,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
1856
1856
|
},
|
|
1857
1857
|
tapLeafScript: [input.tapLeafScript]
|
|
1858
1858
|
});
|
|
1859
|
-
|
|
1859
|
+
chunkSPDNHPM4_cjs.setArkPsbtField(tx, i, chunkSPDNHPM4_cjs.VtxoTaprootTree, input.tapTree);
|
|
1860
1860
|
}
|
|
1861
1861
|
for (const output of outputs) {
|
|
1862
1862
|
tx.addOutput(output);
|
|
@@ -1988,12 +1988,22 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
1988
1988
|
}
|
|
1989
1989
|
}
|
|
1990
1990
|
function combineTapscriptSigs(signedTx, originalTx) {
|
|
1991
|
+
if (signedTx.inputsLength !== originalTx.inputsLength) {
|
|
1992
|
+
throw new Error(
|
|
1993
|
+
`combineTapscriptSigs: input count mismatch (signedTx ${signedTx.inputsLength}, originalTx ${originalTx.inputsLength})`
|
|
1994
|
+
);
|
|
1995
|
+
}
|
|
1991
1996
|
for (let i = 0; i < signedTx.inputsLength; i++) {
|
|
1992
1997
|
const input = originalTx.getInput(i);
|
|
1993
1998
|
const signedInput = signedTx.getInput(i);
|
|
1994
|
-
if (!input.tapScriptSig)
|
|
1999
|
+
if (!input.tapScriptSig) {
|
|
2000
|
+
throw new Error(`combineTapscriptSigs: originalTx input ${i} has no tapScriptSig`);
|
|
2001
|
+
}
|
|
2002
|
+
if (!signedInput.tapScriptSig) {
|
|
2003
|
+
throw new Error(`combineTapscriptSigs: signedTx input ${i} has no tapScriptSig`);
|
|
2004
|
+
}
|
|
1995
2005
|
originalTx.updateInput(i, {
|
|
1996
|
-
tapScriptSig: input.tapScriptSig
|
|
2006
|
+
tapScriptSig: input.tapScriptSig.concat(signedInput.tapScriptSig)
|
|
1997
2007
|
});
|
|
1998
2008
|
}
|
|
1999
2009
|
return originalTx;
|
|
@@ -2279,7 +2289,7 @@ function extendCoin(wallet, utxo) {
|
|
|
2279
2289
|
};
|
|
2280
2290
|
}
|
|
2281
2291
|
function deriveContractTapscripts(contract) {
|
|
2282
|
-
const handler =
|
|
2292
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(contract.type);
|
|
2283
2293
|
if (!handler) {
|
|
2284
2294
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
2285
2295
|
}
|
|
@@ -2828,7 +2838,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
2828
2838
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
2829
2839
|
);
|
|
2830
2840
|
}
|
|
2831
|
-
const tx = new
|
|
2841
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction();
|
|
2832
2842
|
for (const utxo of expiredUtxos) {
|
|
2833
2843
|
tx.addInput({
|
|
2834
2844
|
txid: utxo.txid,
|
|
@@ -2989,7 +2999,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
2989
2999
|
* or doesn't carry the metadata.
|
|
2990
3000
|
*/
|
|
2991
3001
|
extractSpentOutpoint(error) {
|
|
2992
|
-
const ark =
|
|
3002
|
+
const ark = chunkSPDNHPM4_cjs.maybeArkError(error);
|
|
2993
3003
|
if (!ark || ark.name !== "VTXO_ALREADY_SPENT") return void 0;
|
|
2994
3004
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
2995
3005
|
if (typeof raw !== "string") return void 0;
|
|
@@ -3679,6 +3689,15 @@ var txKey = {
|
|
|
3679
3689
|
boardingTxid: "",
|
|
3680
3690
|
arkTxid: ""
|
|
3681
3691
|
};
|
|
3692
|
+
function consumeBoardingReceive(boardingTxs, predicate) {
|
|
3693
|
+
const index = boardingTxs.findIndex(predicate);
|
|
3694
|
+
if (index === -1) return false;
|
|
3695
|
+
boardingTxs.splice(index, 1);
|
|
3696
|
+
return true;
|
|
3697
|
+
}
|
|
3698
|
+
function isSettledBoardingReceive(tx) {
|
|
3699
|
+
return tx.type === "RECEIVED" /* TxReceived */ && tx.settled && tx.key.boardingTxid !== "";
|
|
3700
|
+
}
|
|
3682
3701
|
function collectAssets(vtxos) {
|
|
3683
3702
|
const map = /* @__PURE__ */ new Map();
|
|
3684
3703
|
for (const vtxo of vtxos) {
|
|
@@ -3718,24 +3737,39 @@ function subtractAssets(spent, change) {
|
|
|
3718
3737
|
}
|
|
3719
3738
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, getTxCreatedAt) {
|
|
3720
3739
|
const fromOldestVtxo = [...vtxos].sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
3740
|
+
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
3721
3741
|
const sent = [];
|
|
3722
3742
|
let received = [];
|
|
3723
3743
|
for (const vtxo of fromOldestVtxo) {
|
|
3724
3744
|
if (vtxo.status.isLeaf) {
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3745
|
+
const commitmentTxid = vtxo.virtualStatus.commitmentTxIds[0];
|
|
3746
|
+
const vtxoCreatedAt = vtxo.createdAt.getTime();
|
|
3747
|
+
const ignoredCommitment = commitmentsToIgnore.has(commitmentTxid) || !!vtxo.settledBy && commitmentsToIgnore.has(vtxo.settledBy);
|
|
3748
|
+
if (ignoredCommitment) {
|
|
3749
|
+
consumeBoardingReceive(
|
|
3750
|
+
unmatchedSettledBoardingTxs,
|
|
3751
|
+
(tx) => tx.createdAt <= vtxoCreatedAt && (tx.key.commitmentTxid === commitmentTxid || tx.key.commitmentTxid === vtxo.settledBy)
|
|
3752
|
+
);
|
|
3753
|
+
} else if (fromOldestVtxo.filter((v) => v.settledBy === vtxo.virtualStatus.commitmentTxIds[0]).length === 0) {
|
|
3754
|
+
const duplicateBoardingReceive = consumeBoardingReceive(
|
|
3755
|
+
unmatchedSettledBoardingTxs,
|
|
3756
|
+
(tx) => tx.amount === vtxo.value && tx.createdAt <= vtxoCreatedAt
|
|
3757
|
+
);
|
|
3758
|
+
if (!duplicateBoardingReceive) {
|
|
3759
|
+
const assets = collectAssets([vtxo]);
|
|
3760
|
+
received.push({
|
|
3761
|
+
key: {
|
|
3762
|
+
...txKey,
|
|
3763
|
+
commitmentTxid
|
|
3764
|
+
},
|
|
3765
|
+
tag: "batch",
|
|
3766
|
+
type: "RECEIVED" /* TxReceived */,
|
|
3767
|
+
amount: vtxo.value,
|
|
3768
|
+
settled: vtxo.status.isLeaf || vtxo.isSpent,
|
|
3769
|
+
createdAt: vtxoCreatedAt,
|
|
3770
|
+
...assets && { assets }
|
|
3771
|
+
});
|
|
3772
|
+
}
|
|
3739
3773
|
}
|
|
3740
3774
|
} else if (fromOldestVtxo.filter((v) => v.arkTxId === vtxo.txid).length === 0) {
|
|
3741
3775
|
const assets = collectAssets([vtxo]);
|
|
@@ -3860,7 +3894,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3860
3894
|
const virtualCoins = await this.wallet.getVtxos({
|
|
3861
3895
|
withRecoverable: false
|
|
3862
3896
|
});
|
|
3863
|
-
const controlAssetRef = params.controlAssetId ?
|
|
3897
|
+
const controlAssetRef = params.controlAssetId ? chunkSPDNHPM4_cjs.AssetRef.fromId(chunkSPDNHPM4_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
3864
3898
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
3865
3899
|
let totalBtcSelected = 0n;
|
|
3866
3900
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -3873,8 +3907,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3873
3907
|
}
|
|
3874
3908
|
}
|
|
3875
3909
|
const groups = [];
|
|
3876
|
-
const issuedAssetOutput =
|
|
3877
|
-
const issuedAssetGroup =
|
|
3910
|
+
const issuedAssetOutput = chunkSPDNHPM4_cjs.AssetOutput.create(0, params.amount);
|
|
3911
|
+
const issuedAssetGroup = chunkSPDNHPM4_cjs.AssetGroup.create(
|
|
3878
3912
|
null,
|
|
3879
3913
|
controlAssetRef,
|
|
3880
3914
|
[],
|
|
@@ -3889,15 +3923,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3889
3923
|
for (const [inputIndex, assets] of assetInputs) {
|
|
3890
3924
|
for (const asset of assets) {
|
|
3891
3925
|
if (asset.assetId !== assetId) continue;
|
|
3892
|
-
changeInputs.push(
|
|
3926
|
+
changeInputs.push(chunkSPDNHPM4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
3893
3927
|
}
|
|
3894
3928
|
}
|
|
3895
3929
|
groups.push(
|
|
3896
|
-
|
|
3897
|
-
|
|
3930
|
+
chunkSPDNHPM4_cjs.AssetGroup.create(
|
|
3931
|
+
chunkSPDNHPM4_cjs.AssetId.fromString(assetId),
|
|
3898
3932
|
null,
|
|
3899
3933
|
changeInputs,
|
|
3900
|
-
[
|
|
3934
|
+
[chunkSPDNHPM4_cjs.AssetOutput.create(0, amount)],
|
|
3901
3935
|
[]
|
|
3902
3936
|
)
|
|
3903
3937
|
);
|
|
@@ -3910,7 +3944,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3910
3944
|
script: outputAddress.pkScript,
|
|
3911
3945
|
amount: BigInt(totalBtcSelected)
|
|
3912
3946
|
},
|
|
3913
|
-
Extension.create([
|
|
3947
|
+
Extension.create([chunkSPDNHPM4_cjs.Packet.create(groups)]).txOut()
|
|
3914
3948
|
];
|
|
3915
3949
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
3916
3950
|
coinSelection.inputs,
|
|
@@ -3918,7 +3952,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3918
3952
|
);
|
|
3919
3953
|
return {
|
|
3920
3954
|
arkTxId: arkTxid,
|
|
3921
|
-
assetId:
|
|
3955
|
+
assetId: chunkSPDNHPM4_cjs.AssetId.create(arkTxid, 0).toString()
|
|
3922
3956
|
};
|
|
3923
3957
|
}
|
|
3924
3958
|
/**
|
|
@@ -3990,16 +4024,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3990
4024
|
for (const [inputIndex, assets] of assetInputs) {
|
|
3991
4025
|
for (const asset of assets) {
|
|
3992
4026
|
if (asset.assetId !== params.assetId) continue;
|
|
3993
|
-
reissueInputs.push(
|
|
4027
|
+
reissueInputs.push(chunkSPDNHPM4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
3994
4028
|
}
|
|
3995
4029
|
}
|
|
3996
4030
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
3997
|
-
const reissueAssetIdObj =
|
|
3998
|
-
const reissueAssetGroup =
|
|
4031
|
+
const reissueAssetIdObj = chunkSPDNHPM4_cjs.AssetId.fromString(params.assetId);
|
|
4032
|
+
const reissueAssetGroup = chunkSPDNHPM4_cjs.AssetGroup.create(
|
|
3999
4033
|
reissueAssetIdObj,
|
|
4000
4034
|
null,
|
|
4001
4035
|
reissueInputs,
|
|
4002
|
-
[
|
|
4036
|
+
[chunkSPDNHPM4_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
4003
4037
|
[]
|
|
4004
4038
|
);
|
|
4005
4039
|
const groups = [reissueAssetGroup];
|
|
@@ -4008,15 +4042,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4008
4042
|
for (const [inputIndex, assets] of assetInputs) {
|
|
4009
4043
|
for (const asset of assets) {
|
|
4010
4044
|
if (asset.assetId !== assetId) continue;
|
|
4011
|
-
changeInputs.push(
|
|
4045
|
+
changeInputs.push(chunkSPDNHPM4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
4012
4046
|
}
|
|
4013
4047
|
}
|
|
4014
4048
|
groups.push(
|
|
4015
|
-
|
|
4016
|
-
|
|
4049
|
+
chunkSPDNHPM4_cjs.AssetGroup.create(
|
|
4050
|
+
chunkSPDNHPM4_cjs.AssetId.fromString(assetId),
|
|
4017
4051
|
null,
|
|
4018
4052
|
changeInputs,
|
|
4019
|
-
[
|
|
4053
|
+
[chunkSPDNHPM4_cjs.AssetOutput.create(0, amount)],
|
|
4020
4054
|
[]
|
|
4021
4055
|
)
|
|
4022
4056
|
);
|
|
@@ -4028,7 +4062,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4028
4062
|
script: outputAddress.pkScript,
|
|
4029
4063
|
amount: BigInt(totalBtcSelected)
|
|
4030
4064
|
},
|
|
4031
|
-
Extension.create([
|
|
4065
|
+
Extension.create([chunkSPDNHPM4_cjs.Packet.create(groups)]).txOut()
|
|
4032
4066
|
];
|
|
4033
4067
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
4034
4068
|
return arkTxid;
|
|
@@ -4095,15 +4129,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4095
4129
|
for (const [inputIndex, assets] of assetInputs) {
|
|
4096
4130
|
for (const asset of assets) {
|
|
4097
4131
|
if (asset.assetId !== assetId) continue;
|
|
4098
|
-
changeInputs.push(
|
|
4132
|
+
changeInputs.push(chunkSPDNHPM4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
4099
4133
|
}
|
|
4100
4134
|
}
|
|
4101
4135
|
groups.push(
|
|
4102
|
-
|
|
4103
|
-
|
|
4136
|
+
chunkSPDNHPM4_cjs.AssetGroup.create(
|
|
4137
|
+
chunkSPDNHPM4_cjs.AssetId.fromString(assetId),
|
|
4104
4138
|
null,
|
|
4105
4139
|
changeInputs,
|
|
4106
|
-
amount > 0n ? [
|
|
4140
|
+
amount > 0n ? [chunkSPDNHPM4_cjs.AssetOutput.create(0, amount)] : [],
|
|
4107
4141
|
[]
|
|
4108
4142
|
)
|
|
4109
4143
|
);
|
|
@@ -4115,7 +4149,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4115
4149
|
script: outputAddress.pkScript,
|
|
4116
4150
|
amount: BigInt(totalBtcSelected)
|
|
4117
4151
|
},
|
|
4118
|
-
Extension.create([
|
|
4152
|
+
Extension.create([chunkSPDNHPM4_cjs.Packet.create(groups)]).txOut()
|
|
4119
4153
|
];
|
|
4120
4154
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
4121
4155
|
return arkTxid;
|
|
@@ -4140,7 +4174,7 @@ function castMetadata(metadata) {
|
|
|
4140
4174
|
} else {
|
|
4141
4175
|
throw new Error("Invalid metadata value type");
|
|
4142
4176
|
}
|
|
4143
|
-
md.push(
|
|
4177
|
+
md.push(chunkSPDNHPM4_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
4144
4178
|
}
|
|
4145
4179
|
return md;
|
|
4146
4180
|
}
|
|
@@ -4425,7 +4459,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
4425
4459
|
expire_at: 0,
|
|
4426
4460
|
cosigners_public_keys: cosignerPubKeys
|
|
4427
4461
|
};
|
|
4428
|
-
const proof =
|
|
4462
|
+
const proof = chunkSPDNHPM4_cjs.Intent.create(message, coins, outputs);
|
|
4429
4463
|
const signedProof = await identity.sign(proof);
|
|
4430
4464
|
return {
|
|
4431
4465
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -6165,7 +6199,7 @@ var ContractWatcher = class {
|
|
|
6165
6199
|
this.connectionState = "connected";
|
|
6166
6200
|
this.reconnectAttempts = 0;
|
|
6167
6201
|
this.listenLoop().catch((e) => {
|
|
6168
|
-
if (
|
|
6202
|
+
if (chunkSPDNHPM4_cjs.isEventSourceError(e)) {
|
|
6169
6203
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
6170
6204
|
} else {
|
|
6171
6205
|
console.error(e);
|
|
@@ -6605,7 +6639,7 @@ var ContractManager = class _ContractManager {
|
|
|
6605
6639
|
* `persisted` is `true`.
|
|
6606
6640
|
*/
|
|
6607
6641
|
async upsertContract(params) {
|
|
6608
|
-
const handler =
|
|
6642
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(params.type);
|
|
6609
6643
|
if (!handler) {
|
|
6610
6644
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
6611
6645
|
}
|
|
@@ -6666,7 +6700,7 @@ var ContractManager = class _ContractManager {
|
|
|
6666
6700
|
`scanContracts: gapLimit must be a positive integer (got ${String(opts.gapLimit)})`
|
|
6667
6701
|
);
|
|
6668
6702
|
}
|
|
6669
|
-
const discoverables =
|
|
6703
|
+
const discoverables = chunkGYSK5R57_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkGYSK5R57_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
6670
6704
|
const maxIdx = opts.hd ? SCAN_MAX_INDEX : 0;
|
|
6671
6705
|
const handlerErrors = [];
|
|
6672
6706
|
let lastIndexUsed = -1;
|
|
@@ -6822,7 +6856,7 @@ var ContractManager = class _ContractManager {
|
|
|
6822
6856
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
6823
6857
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
6824
6858
|
if (!contract) return [];
|
|
6825
|
-
const handler =
|
|
6859
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(contract.type);
|
|
6826
6860
|
if (!handler) return [];
|
|
6827
6861
|
const script = handler.createScript(contract.params);
|
|
6828
6862
|
const context = {
|
|
@@ -6842,7 +6876,7 @@ var ContractManager = class _ContractManager {
|
|
|
6842
6876
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
6843
6877
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
6844
6878
|
if (!contract) return [];
|
|
6845
|
-
const handler =
|
|
6879
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(contract.type);
|
|
6846
6880
|
if (!handler) return [];
|
|
6847
6881
|
const script = handler.createScript(contract.params);
|
|
6848
6882
|
const context = {
|
|
@@ -7252,7 +7286,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
7252
7286
|
*/
|
|
7253
7287
|
materializeDescriptorAt(index) {
|
|
7254
7288
|
const descriptor = this.identity.descriptor;
|
|
7255
|
-
const network =
|
|
7289
|
+
const network = chunkGYSK5R57_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
7256
7290
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
7257
7291
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
7258
7292
|
if (!keyInfo?.keyExpression) {
|
|
@@ -7395,7 +7429,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7395
7429
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
7396
7430
|
if (!provider) return void 0;
|
|
7397
7431
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
7398
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
7432
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkGYSK5R57_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
7399
7433
|
const factoryOpts = {
|
|
7400
7434
|
walletRepository: setup.walletRepository,
|
|
7401
7435
|
contractRepository: setup.contractRepository,
|
|
@@ -7557,7 +7591,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7557
7591
|
const newScript = base.hex.encode(newTapscript.pkScript);
|
|
7558
7592
|
const newAddress = newTapscript.address(wallet.network.hrp, wallet.arkServerPublicKey).encode();
|
|
7559
7593
|
const manager = await wallet.getContractManager();
|
|
7560
|
-
const csvTimelock = newTapscript.options.csvTimelock
|
|
7594
|
+
const csvTimelock = newTapscript.options.csvTimelock;
|
|
7561
7595
|
const csvTimelockStr = chunkWMIPYZSB_cjs.timelockToSequence(csvTimelock).toString();
|
|
7562
7596
|
const serverPubKeyHex = base.hex.encode(newTapscript.options.serverPubKey);
|
|
7563
7597
|
const baseParams = {
|
|
@@ -7572,11 +7606,11 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7572
7606
|
// produce unsigned PSBTs that the server rejects with
|
|
7573
7607
|
// `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
7574
7608
|
metadata: {
|
|
7575
|
-
source:
|
|
7609
|
+
source: chunkGYSK5R57_cjs.WALLET_RECEIVE_SOURCE,
|
|
7576
7610
|
signingDescriptor: descriptor
|
|
7577
7611
|
}
|
|
7578
7612
|
};
|
|
7579
|
-
if (newTapscript instanceof
|
|
7613
|
+
if (newTapscript instanceof chunkGYSK5R57_cjs.DelegateVtxo.Script) {
|
|
7580
7614
|
await manager.createContract({
|
|
7581
7615
|
...baseParams,
|
|
7582
7616
|
type: "delegate",
|
|
@@ -7608,7 +7642,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7608
7642
|
};
|
|
7609
7643
|
function deriveLeafPubkey(descriptor) {
|
|
7610
7644
|
try {
|
|
7611
|
-
return
|
|
7645
|
+
return chunkGYSK5R57_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
7612
7646
|
} catch (e) {
|
|
7613
7647
|
throw new NonRangeableDescriptorError(
|
|
7614
7648
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -7617,10 +7651,10 @@ function deriveLeafPubkey(descriptor) {
|
|
|
7617
7651
|
}
|
|
7618
7652
|
}
|
|
7619
7653
|
function rebuildTapscript(current, pubKey) {
|
|
7620
|
-
if (current instanceof
|
|
7621
|
-
return new
|
|
7654
|
+
if (current instanceof chunkGYSK5R57_cjs.DelegateVtxo.Script) {
|
|
7655
|
+
return new chunkGYSK5R57_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
7622
7656
|
}
|
|
7623
|
-
return new
|
|
7657
|
+
return new chunkGYSK5R57_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
7624
7658
|
}
|
|
7625
7659
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
7626
7660
|
const candidates = await contractRepository.getContracts({
|
|
@@ -7629,7 +7663,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
7629
7663
|
});
|
|
7630
7664
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
7631
7665
|
const matching = candidates.filter(
|
|
7632
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
7666
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkGYSK5R57_cjs.WALLET_RECEIVE_SOURCE
|
|
7633
7667
|
).sort((a, b) => {
|
|
7634
7668
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
7635
7669
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -7690,8 +7724,24 @@ var InputSignerRouter = class {
|
|
|
7690
7724
|
constructor(deps) {
|
|
7691
7725
|
this.deps = deps;
|
|
7692
7726
|
}
|
|
7693
|
-
|
|
7694
|
-
|
|
7727
|
+
/**
|
|
7728
|
+
* Resolve each job to its target signer without invoking signing. The
|
|
7729
|
+
* returned plan is the single source of truth for both {@link sign} and
|
|
7730
|
+
* the batch-eligibility predicate {@link canBatch} — callers that want
|
|
7731
|
+
* to pre-flight a batch path call {@link canBatch} (which delegates
|
|
7732
|
+
* here) so the routing rules never live in two places.
|
|
7733
|
+
*
|
|
7734
|
+
* Throws {@link MissingSigningDescriptorError} for a non-baseline
|
|
7735
|
+
* default/delegate contract whose `metadata.signingDescriptor` is
|
|
7736
|
+
* missing — the same condition that would later abort signing. Failing
|
|
7737
|
+
* here moves the failure earlier, before any PSBT is mutated.
|
|
7738
|
+
*/
|
|
7739
|
+
async classify(jobs) {
|
|
7740
|
+
const identityIndexes = [];
|
|
7741
|
+
const descriptorGroups = /* @__PURE__ */ new Map();
|
|
7742
|
+
if (jobs.length === 0) {
|
|
7743
|
+
return { identityIndexes, descriptorGroups };
|
|
7744
|
+
}
|
|
7695
7745
|
const distinctScripts = Array.from(new Set(jobs.map((j) => base.hex.encode(j.lookupScript))));
|
|
7696
7746
|
const contracts = await this.deps.contractRepository.getContracts({
|
|
7697
7747
|
script: distinctScripts
|
|
@@ -7704,8 +7754,6 @@ var InputSignerRouter = class {
|
|
|
7704
7754
|
}
|
|
7705
7755
|
const baselinePubKeyHex = base.hex.encode(await this.deps.identity.xOnlyPublicKey());
|
|
7706
7756
|
const boardingScriptHex = base.hex.encode(this.deps.boardingPkScript);
|
|
7707
|
-
const identityIndexes = [];
|
|
7708
|
-
const descriptorGroups = /* @__PURE__ */ new Map();
|
|
7709
7757
|
for (const job of jobs) {
|
|
7710
7758
|
const scriptHex = base.hex.encode(job.lookupScript);
|
|
7711
7759
|
const contract = scriptToContract.get(scriptHex);
|
|
@@ -7738,6 +7786,31 @@ var InputSignerRouter = class {
|
|
|
7738
7786
|
descriptorGroups.set(descriptor, [job.index]);
|
|
7739
7787
|
}
|
|
7740
7788
|
}
|
|
7789
|
+
return { identityIndexes, descriptorGroups };
|
|
7790
|
+
}
|
|
7791
|
+
/**
|
|
7792
|
+
* Returns `true` when every signable input across all `jobSets` resolves
|
|
7793
|
+
* to the baseline {@link Identity} key — i.e. the descriptor provider
|
|
7794
|
+
* would not be invoked. Used by the wallet's send/recovery paths to
|
|
7795
|
+
* pre-flight the {@link BatchSignableIdentity.signMultiple} fast path,
|
|
7796
|
+
* which can only fold work a single identity key can sign.
|
|
7797
|
+
*
|
|
7798
|
+
* Accepts several job sets (e.g. an arkTx's jobs plus one set per
|
|
7799
|
+
* checkpoint) and classifies their union in a single pass. Eligibility
|
|
7800
|
+
* is monotonic — the union routes entirely to the baseline key iff every
|
|
7801
|
+
* set does — so this returns the same answer as ANDing the per-set
|
|
7802
|
+
* results, but with one {@link classify} (one repo round-trip + one
|
|
7803
|
+
* `xOnlyPublicKey` call) instead of one per set. Only the routing buckets
|
|
7804
|
+
* matter here, so the input-index collisions produced by flattening jobs
|
|
7805
|
+
* from different transactions are irrelevant.
|
|
7806
|
+
*/
|
|
7807
|
+
async canBatch(...jobSets) {
|
|
7808
|
+
const plan = await this.classify(jobSets.flat());
|
|
7809
|
+
return plan.descriptorGroups.size === 0;
|
|
7810
|
+
}
|
|
7811
|
+
async sign(tx, jobs) {
|
|
7812
|
+
if (jobs.length === 0) return tx;
|
|
7813
|
+
const { identityIndexes, descriptorGroups } = await this.classify(jobs);
|
|
7741
7814
|
let signed = tx;
|
|
7742
7815
|
if (identityIndexes.length > 0) {
|
|
7743
7816
|
signed = await this.deps.identity.sign(signed, identityIndexes);
|
|
@@ -7795,6 +7868,20 @@ function dedupeTimelocks(timelocks) {
|
|
|
7795
7868
|
}
|
|
7796
7869
|
return deduped;
|
|
7797
7870
|
}
|
|
7871
|
+
function areSameScriptBaselineTypesCompatible(existingType, requestedType) {
|
|
7872
|
+
if (existingType === requestedType) return true;
|
|
7873
|
+
return existingType === "default" && requestedType === "boarding" || existingType === "boarding" && requestedType === "default";
|
|
7874
|
+
}
|
|
7875
|
+
async function ensureWalletContract(manager, params) {
|
|
7876
|
+
const [existing] = await manager.getContracts({ script: params.script });
|
|
7877
|
+
if (existing && existing.type !== params.type && areSameScriptBaselineTypesCompatible(existing.type, params.type)) {
|
|
7878
|
+
if (params.type === "default" && existing.type === "boarding") {
|
|
7879
|
+
await manager.updateContract(params.script, { type: "default" });
|
|
7880
|
+
}
|
|
7881
|
+
return;
|
|
7882
|
+
}
|
|
7883
|
+
await manager.createContract(params);
|
|
7884
|
+
}
|
|
7798
7885
|
function hasToReadonly(identity) {
|
|
7799
7886
|
return typeof identity === "object" && identity !== null && "toReadonly" in identity && typeof identity.toReadonly === "function";
|
|
7800
7887
|
}
|
|
@@ -7823,9 +7910,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7823
7910
|
this._offchainTapscript = offchainTapscript;
|
|
7824
7911
|
this.watcherConfig = watcherConfig;
|
|
7825
7912
|
this._assetManager = new ReadonlyAssetManager(this.indexerProvider);
|
|
7826
|
-
this.walletContractTimelocks = walletContractTimelocks && walletContractTimelocks.length > 0 ? dedupeTimelocks(walletContractTimelocks) : [
|
|
7827
|
-
this.offchainTapscript.options.csvTimelock ?? chunkIEO3XDKI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK
|
|
7828
|
-
];
|
|
7913
|
+
this.walletContractTimelocks = walletContractTimelocks && walletContractTimelocks.length > 0 ? dedupeTimelocks(walletContractTimelocks) : [this.offchainTapscript.options.csvTimelock];
|
|
7829
7914
|
}
|
|
7830
7915
|
_contractManager;
|
|
7831
7916
|
_contractManagerInitializing;
|
|
@@ -7863,7 +7948,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7863
7948
|
*/
|
|
7864
7949
|
static async setupWalletConfig(config, pubKey) {
|
|
7865
7950
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
7866
|
-
const arkProvider = config.arkProvider || new
|
|
7951
|
+
const arkProvider = config.arkProvider || new chunkSPDNHPM4_cjs.RestArkProvider(arkadeServerUrl);
|
|
7867
7952
|
let indexerProvider = config.indexerProvider;
|
|
7868
7953
|
if (!indexerProvider) {
|
|
7869
7954
|
let indexerUrl = config.indexerUrl;
|
|
@@ -7880,7 +7965,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7880
7965
|
indexerUrl = arkadeServerUrl;
|
|
7881
7966
|
}
|
|
7882
7967
|
}
|
|
7883
|
-
indexerProvider = new
|
|
7968
|
+
indexerProvider = new chunkSPDNHPM4_cjs.RestIndexerProvider(indexerUrl);
|
|
7884
7969
|
}
|
|
7885
7970
|
const info = await arkProvider.getInfo();
|
|
7886
7971
|
const network = chunkWMIPYZSB_cjs.getNetwork(info.network);
|
|
@@ -7930,10 +8015,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7930
8015
|
serverPubKey,
|
|
7931
8016
|
csvTimelock: exitTimelock
|
|
7932
8017
|
};
|
|
7933
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
7934
|
-
const boardingTapscript =
|
|
7935
|
-
|
|
7936
|
-
|
|
8018
|
+
const offchainTapscript = !delegatePubKey ? new chunkGYSK5R57_cjs.DefaultVtxo.Script(offchainOptions) : new chunkGYSK5R57_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
8019
|
+
const boardingTapscript = chunkGYSK5R57_cjs.BoardingContractHandler.createScript({
|
|
8020
|
+
pubKey: base.hex.encode(pubKey),
|
|
8021
|
+
serverPubKey: base.hex.encode(serverPubKey),
|
|
8022
|
+
csvTimelock: chunkWMIPYZSB_cjs.timelockToSequence(boardingTimelock).toString()
|
|
7937
8023
|
});
|
|
7938
8024
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
7939
8025
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -8142,7 +8228,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8142
8228
|
const tx = {
|
|
8143
8229
|
key: {
|
|
8144
8230
|
boardingTxid: utxo.txid,
|
|
8145
|
-
commitmentTxid: "",
|
|
8231
|
+
commitmentTxid: utxo.virtualStatus.commitmentTxIds?.[0] ?? "",
|
|
8146
8232
|
arkTxid: ""
|
|
8147
8233
|
},
|
|
8148
8234
|
amount: utxo.value,
|
|
@@ -8273,7 +8359,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8273
8359
|
});
|
|
8274
8360
|
for (const contract of contracts) {
|
|
8275
8361
|
if (map.has(contract.script)) continue;
|
|
8276
|
-
const handler =
|
|
8362
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(contract.type);
|
|
8277
8363
|
if (handler) {
|
|
8278
8364
|
const script = handler.createScript(contract.params);
|
|
8279
8365
|
map.set(contract.script, script);
|
|
@@ -8340,13 +8426,13 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8340
8426
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
8341
8427
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
8342
8428
|
const csvTimelockStr = chunkWMIPYZSB_cjs.timelockToSequence(csvTimelock).toString();
|
|
8343
|
-
const defaultScript = new
|
|
8429
|
+
const defaultScript = new chunkGYSK5R57_cjs.DefaultVtxo.Script({
|
|
8344
8430
|
pubKey: baselinePubkey,
|
|
8345
8431
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
8346
8432
|
csvTimelock
|
|
8347
8433
|
});
|
|
8348
8434
|
const defaultScriptHex = base.hex.encode(defaultScript.pkScript);
|
|
8349
|
-
await manager
|
|
8435
|
+
await ensureWalletContract(manager, {
|
|
8350
8436
|
type: "default",
|
|
8351
8437
|
params: {
|
|
8352
8438
|
pubKey: base.hex.encode(defaultScript.options.pubKey),
|
|
@@ -8357,8 +8443,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8357
8443
|
address: defaultScript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
8358
8444
|
state: "active"
|
|
8359
8445
|
});
|
|
8360
|
-
if (this.offchainTapscript instanceof
|
|
8361
|
-
const delegateScript = new
|
|
8446
|
+
if (this.offchainTapscript instanceof chunkGYSK5R57_cjs.DelegateVtxo.Script) {
|
|
8447
|
+
const delegateScript = new chunkGYSK5R57_cjs.DelegateVtxo.Script({
|
|
8362
8448
|
pubKey: baselinePubkey,
|
|
8363
8449
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
8364
8450
|
delegatePubKey: this.offchainTapscript.options.delegatePubKey,
|
|
@@ -8379,6 +8465,19 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8379
8465
|
});
|
|
8380
8466
|
}
|
|
8381
8467
|
}
|
|
8468
|
+
const boardingScriptHex = base.hex.encode(this.boardingTapscript.pkScript);
|
|
8469
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkGYSK5R57_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
8470
|
+
await ensureWalletContract(manager, {
|
|
8471
|
+
type: "boarding",
|
|
8472
|
+
params: {
|
|
8473
|
+
pubKey: base.hex.encode(this.boardingTapscript.options.pubKey),
|
|
8474
|
+
serverPubKey: base.hex.encode(this.boardingTapscript.options.serverPubKey),
|
|
8475
|
+
csvTimelock: chunkWMIPYZSB_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
8476
|
+
},
|
|
8477
|
+
script: boardingScriptHex,
|
|
8478
|
+
address: this.boardingTapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
8479
|
+
state: "active"
|
|
8480
|
+
});
|
|
8382
8481
|
return manager;
|
|
8383
8482
|
}
|
|
8384
8483
|
/** Dispose wallet-owned managers and release background resources. */
|
|
@@ -8559,7 +8658,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8559
8658
|
const hd = provider instanceof HDDescriptorProvider;
|
|
8560
8659
|
const staticDescriptor = hd ? void 0 : `tr(${base.hex.encode(await this.identity.xOnlyPublicKey())})`;
|
|
8561
8660
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
8562
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
8661
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkGYSK5R57_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
8563
8662
|
const deps = {
|
|
8564
8663
|
indexerProvider: this.indexerProvider,
|
|
8565
8664
|
onchainProvider: this.onchainProvider,
|
|
@@ -9228,7 +9327,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9228
9327
|
try {
|
|
9229
9328
|
return await this.arkProvider.registerIntent(intent);
|
|
9230
9329
|
} catch (error) {
|
|
9231
|
-
if (error instanceof
|
|
9330
|
+
if (error instanceof chunkSPDNHPM4_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
9232
9331
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
9233
9332
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
9234
9333
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -9244,7 +9343,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9244
9343
|
expire_at: 0,
|
|
9245
9344
|
cosigners_public_keys: cosignerPubKeys
|
|
9246
9345
|
};
|
|
9247
|
-
const proof =
|
|
9346
|
+
const proof = chunkSPDNHPM4_cjs.Intent.create(message, coins, outputs);
|
|
9248
9347
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
9249
9348
|
return {
|
|
9250
9349
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -9256,7 +9355,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9256
9355
|
type: "delete",
|
|
9257
9356
|
expire_at: 0
|
|
9258
9357
|
};
|
|
9259
|
-
const proof =
|
|
9358
|
+
const proof = chunkSPDNHPM4_cjs.Intent.create(message, coins, []);
|
|
9260
9359
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
9261
9360
|
return {
|
|
9262
9361
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -9268,7 +9367,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9268
9367
|
type: "get-pending-tx",
|
|
9269
9368
|
expire_at: 0
|
|
9270
9369
|
};
|
|
9271
|
-
const proof =
|
|
9370
|
+
const proof = chunkSPDNHPM4_cjs.Intent.create(message, coins, []);
|
|
9272
9371
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
9273
9372
|
return {
|
|
9274
9373
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -9328,16 +9427,38 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9328
9427
|
seen.add(pendingTx.arkTxid);
|
|
9329
9428
|
batchPending.push(pendingTx.arkTxid);
|
|
9330
9429
|
try {
|
|
9331
|
-
const
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
this.inputSigningJobsFromWitnessUtxos(tx)
|
|
9337
|
-
);
|
|
9338
|
-
return base.base64.encode(signedCheckpoint.toPSBT());
|
|
9339
|
-
})
|
|
9430
|
+
const checkpointTxs = pendingTx.signedCheckpointTxs.map(
|
|
9431
|
+
(c) => btcSigner.Transaction.fromPSBT(base.base64.decode(c))
|
|
9432
|
+
);
|
|
9433
|
+
const checkpointJobs = checkpointTxs.map(
|
|
9434
|
+
(tx) => this.inputSigningJobsFromWitnessUtxos(tx)
|
|
9340
9435
|
);
|
|
9436
|
+
const identity = this.identity;
|
|
9437
|
+
const batchEligible = isBatchSignable(identity) && await this._signerRouter.canBatch(...checkpointJobs);
|
|
9438
|
+
let finalCheckpoints;
|
|
9439
|
+
if (batchEligible) {
|
|
9440
|
+
const requests = checkpointTxs.map((tx, i) => ({
|
|
9441
|
+
tx,
|
|
9442
|
+
inputIndexes: checkpointJobs[i].map((j) => j.index)
|
|
9443
|
+
}));
|
|
9444
|
+
const signed = await identity.signMultiple(requests);
|
|
9445
|
+
if (signed.length !== requests.length) {
|
|
9446
|
+
throw new Error(
|
|
9447
|
+
`signMultiple returned ${signed.length} transactions, expected ${requests.length}`
|
|
9448
|
+
);
|
|
9449
|
+
}
|
|
9450
|
+
finalCheckpoints = signed.map((tx) => base.base64.encode(tx.toPSBT()));
|
|
9451
|
+
} else {
|
|
9452
|
+
finalCheckpoints = await Promise.all(
|
|
9453
|
+
checkpointTxs.map(async (tx, i) => {
|
|
9454
|
+
const signedCheckpoint = await this._signerRouter.sign(
|
|
9455
|
+
tx,
|
|
9456
|
+
checkpointJobs[i]
|
|
9457
|
+
);
|
|
9458
|
+
return base.base64.encode(signedCheckpoint.toPSBT());
|
|
9459
|
+
})
|
|
9460
|
+
);
|
|
9461
|
+
}
|
|
9341
9462
|
await this.arkProvider.finalizeTx(pendingTx.arkTxid, finalCheckpoints);
|
|
9342
9463
|
batchFinalized.push(pendingTx.arkTxid);
|
|
9343
9464
|
} catch (error) {
|
|
@@ -9565,22 +9686,65 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9565
9686
|
index,
|
|
9566
9687
|
lookupScript: chunkWMIPYZSB_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
9567
9688
|
}));
|
|
9568
|
-
const
|
|
9689
|
+
const checkpointJobs = offchainTx.checkpoints.map(
|
|
9690
|
+
(c) => this.inputSigningJobsFromWitnessUtxos(c)
|
|
9691
|
+
);
|
|
9692
|
+
let signedVirtualTx;
|
|
9693
|
+
let userSignedCheckpoints;
|
|
9694
|
+
const identity = this.identity;
|
|
9695
|
+
const batchEligible = isBatchSignable(identity) && await this._signerRouter.canBatch(arkTxJobs, ...checkpointJobs);
|
|
9696
|
+
if (batchEligible) {
|
|
9697
|
+
const requests = [
|
|
9698
|
+
{
|
|
9699
|
+
tx: offchainTx.arkTx.clone(),
|
|
9700
|
+
inputIndexes: arkTxJobs.map((j) => j.index)
|
|
9701
|
+
},
|
|
9702
|
+
...offchainTx.checkpoints.map((c, i) => ({
|
|
9703
|
+
tx: c.clone(),
|
|
9704
|
+
inputIndexes: checkpointJobs[i].map((j) => j.index)
|
|
9705
|
+
}))
|
|
9706
|
+
];
|
|
9707
|
+
const signed = await identity.signMultiple(requests);
|
|
9708
|
+
if (signed.length !== requests.length) {
|
|
9709
|
+
throw new Error(
|
|
9710
|
+
`signMultiple returned ${signed.length} transactions, expected ${requests.length}`
|
|
9711
|
+
);
|
|
9712
|
+
}
|
|
9713
|
+
const [firstSignedTx, ...signedCheckpoints] = signed;
|
|
9714
|
+
signedVirtualTx = firstSignedTx;
|
|
9715
|
+
userSignedCheckpoints = signedCheckpoints;
|
|
9716
|
+
} else {
|
|
9717
|
+
signedVirtualTx = await this._signerRouter.sign(offchainTx.arkTx, arkTxJobs);
|
|
9718
|
+
}
|
|
9569
9719
|
await this.setPendingTxFlag(true);
|
|
9570
9720
|
const { arkTxid, signedCheckpointTxs } = await this.arkProvider.submitTx(
|
|
9571
9721
|
base.base64.encode(signedVirtualTx.toPSBT()),
|
|
9572
9722
|
offchainTx.checkpoints.map((c) => base.base64.encode(c.toPSBT()))
|
|
9573
9723
|
);
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
this.inputSigningJobsFromWitnessUtxos(tx)
|
|
9724
|
+
let finalCheckpoints;
|
|
9725
|
+
if (userSignedCheckpoints) {
|
|
9726
|
+
if (signedCheckpointTxs.length !== userSignedCheckpoints.length) {
|
|
9727
|
+
throw new Error(
|
|
9728
|
+
`submitTx returned ${signedCheckpointTxs.length} checkpoints, expected ${userSignedCheckpoints.length}`
|
|
9580
9729
|
);
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9730
|
+
}
|
|
9731
|
+
finalCheckpoints = signedCheckpointTxs.map((c, i) => {
|
|
9732
|
+
const serverSigned = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
|
|
9733
|
+
combineTapscriptSigs(userSignedCheckpoints[i], serverSigned);
|
|
9734
|
+
return base.base64.encode(serverSigned.toPSBT());
|
|
9735
|
+
});
|
|
9736
|
+
} else {
|
|
9737
|
+
finalCheckpoints = await Promise.all(
|
|
9738
|
+
signedCheckpointTxs.map(async (c) => {
|
|
9739
|
+
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
|
|
9740
|
+
const signedCheckpoint = await this._signerRouter.sign(
|
|
9741
|
+
tx,
|
|
9742
|
+
this.inputSigningJobsFromWitnessUtxos(tx)
|
|
9743
|
+
);
|
|
9744
|
+
return base.base64.encode(signedCheckpoint.toPSBT());
|
|
9745
|
+
})
|
|
9746
|
+
);
|
|
9747
|
+
}
|
|
9584
9748
|
await this.arkProvider.finalizeTx(arkTxid, finalCheckpoints);
|
|
9585
9749
|
try {
|
|
9586
9750
|
await this.setPendingTxFlag(false);
|
|
@@ -9830,12 +9994,17 @@ function selectVirtualCoins(coins, targetAmount) {
|
|
|
9830
9994
|
}
|
|
9831
9995
|
async function waitForIncomingFunds(wallet) {
|
|
9832
9996
|
let stopFunc;
|
|
9997
|
+
let settled = false;
|
|
9833
9998
|
return new Promise((resolve) => {
|
|
9834
|
-
wallet.notifyIncomingFunds((
|
|
9835
|
-
|
|
9836
|
-
if (
|
|
9999
|
+
wallet.notifyIncomingFunds((funds) => {
|
|
10000
|
+
const hasFunds = funds.type === "utxo" ? funds.coins.length > 0 : funds.newVtxos.length > 0;
|
|
10001
|
+
if (settled || !hasFunds) return;
|
|
10002
|
+
settled = true;
|
|
10003
|
+
resolve(funds);
|
|
10004
|
+
stopFunc?.();
|
|
9837
10005
|
}).then((stop) => {
|
|
9838
10006
|
stopFunc = stop;
|
|
10007
|
+
if (settled) stop();
|
|
9839
10008
|
});
|
|
9840
10009
|
});
|
|
9841
10010
|
}
|
|
@@ -9992,7 +10161,7 @@ var MessageBus = class {
|
|
|
9992
10161
|
this.initialized = true;
|
|
9993
10162
|
}
|
|
9994
10163
|
async buildServices(config) {
|
|
9995
|
-
const arkProvider = new
|
|
10164
|
+
const arkProvider = new chunkSPDNHPM4_cjs.RestArkProvider(config.arkServer.url);
|
|
9996
10165
|
const storage = {
|
|
9997
10166
|
walletRepository: this.walletRepository,
|
|
9998
10167
|
contractRepository: this.contractRepository
|
|
@@ -11035,7 +11204,7 @@ var WalletMessageHandler = class {
|
|
|
11035
11204
|
// Wallet methods
|
|
11036
11205
|
async handleInitWallet({ payload }) {
|
|
11037
11206
|
const { arkServerUrl } = payload;
|
|
11038
|
-
this.indexerProvider = new
|
|
11207
|
+
this.indexerProvider = new chunkSPDNHPM4_cjs.RestIndexerProvider(arkServerUrl);
|
|
11039
11208
|
await this.onWalletInitialized();
|
|
11040
11209
|
}
|
|
11041
11210
|
async handleGetBalance() {
|
|
@@ -12779,7 +12948,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
12779
12948
|
if (!inputs) {
|
|
12780
12949
|
throw new Error("Fee estimation failed");
|
|
12781
12950
|
}
|
|
12782
|
-
let tx = new
|
|
12951
|
+
let tx = new chunkSPDNHPM4_cjs.Transaction();
|
|
12783
12952
|
for (const input of inputs) {
|
|
12784
12953
|
tx.addInput({
|
|
12785
12954
|
txid: input.txid,
|
|
@@ -12810,7 +12979,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
12810
12979
|
*/
|
|
12811
12980
|
async bumpP2A(parent) {
|
|
12812
12981
|
const parentVsize = parent.vsize;
|
|
12813
|
-
let child = new
|
|
12982
|
+
let child = new chunkSPDNHPM4_cjs.Transaction({
|
|
12814
12983
|
version: 3,
|
|
12815
12984
|
allowLegacyWitnessUtxo: true
|
|
12816
12985
|
});
|
|
@@ -13567,7 +13736,7 @@ exports.BIP322 = void 0;
|
|
|
13567
13736
|
async function sign2(message, identity, network) {
|
|
13568
13737
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
13569
13738
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
13570
|
-
const toSpend =
|
|
13739
|
+
const toSpend = chunkSPDNHPM4_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
13571
13740
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
13572
13741
|
const signed = await identity.sign(toSign, [0]);
|
|
13573
13742
|
signed.finalizeIdx(0);
|
|
@@ -13625,7 +13794,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
13625
13794
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
13626
13795
|
return false;
|
|
13627
13796
|
}
|
|
13628
|
-
const toSpend =
|
|
13797
|
+
const toSpend = chunkSPDNHPM4_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
13629
13798
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
13630
13799
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
13631
13800
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -13646,7 +13815,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
13646
13815
|
}
|
|
13647
13816
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
13648
13817
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
13649
|
-
const toSpend =
|
|
13818
|
+
const toSpend = chunkSPDNHPM4_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
13650
13819
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
13651
13820
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
13652
13821
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -13699,7 +13868,7 @@ function encodeCompactSize(n) {
|
|
|
13699
13868
|
return buf;
|
|
13700
13869
|
}
|
|
13701
13870
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
13702
|
-
const tx = new
|
|
13871
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction({ version: 0 });
|
|
13703
13872
|
tx.addInput({
|
|
13704
13873
|
txid: toSpend.id,
|
|
13705
13874
|
index: 0,
|
|
@@ -13713,12 +13882,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
13713
13882
|
});
|
|
13714
13883
|
tx.addOutput({
|
|
13715
13884
|
amount: 0n,
|
|
13716
|
-
script:
|
|
13885
|
+
script: chunkSPDNHPM4_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
13717
13886
|
});
|
|
13718
13887
|
return tx;
|
|
13719
13888
|
}
|
|
13720
13889
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
13721
|
-
const tx = new
|
|
13890
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction({ version: 0 });
|
|
13722
13891
|
tx.addInput({
|
|
13723
13892
|
txid: toSpend.id,
|
|
13724
13893
|
index: 0,
|
|
@@ -13730,7 +13899,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
13730
13899
|
});
|
|
13731
13900
|
tx.addOutput({
|
|
13732
13901
|
amount: 0n,
|
|
13733
|
-
script:
|
|
13902
|
+
script: chunkSPDNHPM4_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
13734
13903
|
});
|
|
13735
13904
|
return tx;
|
|
13736
13905
|
}
|
|
@@ -13791,7 +13960,7 @@ exports.Unroll = void 0;
|
|
|
13791
13960
|
if (virtualTxs.txs.length === 0) {
|
|
13792
13961
|
throw new Error(`Tx ${nextTxToBroadcast.txid} not found`);
|
|
13793
13962
|
}
|
|
13794
|
-
const tx =
|
|
13963
|
+
const tx = chunkSPDNHPM4_cjs.Transaction.fromPSBT(base.base64.decode(virtualTxs.txs[0]));
|
|
13795
13964
|
if (nextTxToBroadcast.type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
13796
13965
|
const input = tx.getInput(0);
|
|
13797
13966
|
if (!input) {
|
|
@@ -13891,7 +14060,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
13891
14060
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
13892
14061
|
);
|
|
13893
14062
|
}
|
|
13894
|
-
const tx = new
|
|
14063
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction({ version: 2 });
|
|
13895
14064
|
for (const input of inputs) {
|
|
13896
14065
|
tx.addInput(input);
|
|
13897
14066
|
}
|
|
@@ -13977,7 +14146,7 @@ function decodeArkContract(encoded) {
|
|
|
13977
14146
|
}
|
|
13978
14147
|
function contractFromArkContract(encoded, options = {}) {
|
|
13979
14148
|
const parsed = decodeArkContract(encoded);
|
|
13980
|
-
const handler =
|
|
14149
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(parsed.type);
|
|
13981
14150
|
if (!handler) {
|
|
13982
14151
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
13983
14152
|
}
|
|
@@ -13993,7 +14162,7 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
13993
14162
|
}
|
|
13994
14163
|
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkWMIPYZSB_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
13995
14164
|
const parsed = decodeArkContract(encoded);
|
|
13996
|
-
const handler =
|
|
14165
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
13997
14166
|
const params = parsed.data;
|
|
13998
14167
|
const vtxoScript = handler.createScript(params);
|
|
13999
14168
|
return {
|
|
@@ -14105,5 +14274,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
14105
14274
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
14106
14275
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
14107
14276
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
14108
|
-
//# sourceMappingURL=chunk-
|
|
14109
|
-
//# sourceMappingURL=chunk-
|
|
14277
|
+
//# sourceMappingURL=chunk-7K3ROJF6.cjs.map
|
|
14278
|
+
//# sourceMappingURL=chunk-7K3ROJF6.cjs.map
|