@arkade-os/swap 0.1.0-rc.17 → 0.1.0-rc.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -21
- package/dist/advanced.cjs +84 -82
- package/dist/advanced.d.cts +3 -3
- package/dist/advanced.d.ts +3 -3
- package/dist/advanced.js +3 -3
- package/dist/{chunk-CIIJT5O4.js → chunk-7FCXWHBU.js} +9 -1
- package/dist/{chunk-BBP25BWH.js → chunk-AYKAMAP5.js} +0 -1
- package/dist/{chunk-QJ2MUUDO.js → chunk-RVRXQU2E.js} +39 -147
- package/dist/{errors-DQ-J_lgV.d.cts → errors-B7boQfoR.d.cts} +1 -1
- package/dist/{errors-CUKl1fFo.d.ts → errors-DtvJU2MN.d.ts} +1 -1
- package/dist/index.cjs +107 -212
- package/dist/index.d.cts +5 -61
- package/dist/index.d.ts +5 -61
- package/dist/index.js +3 -7
- package/dist/{lockupContract-iI7QGIEr.d.ts → lockupContract-5r5RlgOJ.d.cts} +2 -82
- package/dist/{lockupContract-CWR83JvL.d.cts → lockupContract-5r5RlgOJ.d.ts} +2 -82
- package/dist/nostr.js +1 -1
- package/dist/{offer-CJzNPS5H.d.ts → offer-Byp0FNO6.d.ts} +1 -1
- package/dist/{offer-DCaE0YNp.d.cts → offer-D9xdNCZS.d.cts} +1 -1
- package/dist/protocol.d.cts +84 -5
- package/dist/protocol.d.ts +84 -5
- package/dist/protocol.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -192,32 +192,17 @@ newer.
|
|
|
192
192
|
|
|
193
193
|
### Restore an imported wallet
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
Run the core wallet's `restore()` first (addresses, contracts, history), **then** create the client:
|
|
196
196
|
|
|
197
197
|
```ts
|
|
198
|
-
import { IndexedDbAssetSwapRepository, registerAssetSwapRestore } from "@arkade-os/swap";
|
|
199
|
-
|
|
200
|
-
const repository = new IndexedDbAssetSwapRepository();
|
|
201
|
-
const unregisterSwapRestore = registerAssetSwapRestore(wallet, {
|
|
202
|
-
arkServerUrl,
|
|
203
|
-
repository,
|
|
204
|
-
onResult: ({ changes, coverageError }) => {
|
|
205
|
-
if (coverageError) console.warn("Swap coverage was incomplete", coverageError);
|
|
206
|
-
console.info(`Restored or updated ${changes.length} swaps`);
|
|
207
|
-
},
|
|
208
|
-
});
|
|
209
|
-
|
|
210
198
|
await wallet.restore();
|
|
199
|
+
const client = createSwapClient({ wallet, repository: new IndexedDbAssetSwapRepository() });
|
|
200
|
+
await client.ready;
|
|
211
201
|
```
|
|
212
202
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
`serverPubkey` when it does not expose them. Keep calling `restoreAssetSwapRepository` directly
|
|
217
|
-
during ordinary startup: hooks run only for an explicit `wallet.restore()`.
|
|
218
|
-
|
|
219
|
-
The client's own records need none of this: `client.ready` rebuilds a record for every offer
|
|
220
|
-
deposit the store has no record for. Such a record carries `market: { kind: "restored" }`.
|
|
203
|
+
`client.ready` rebuilds a record for every offer deposit in that history, with
|
|
204
|
+
`market: { kind: "restored" }`. A client created before `restore()` finishes rebuilds only what
|
|
205
|
+
history held at that moment, until its next construction.
|
|
221
206
|
|
|
222
207
|
## Runtime requirements
|
|
223
208
|
|
package/dist/advanced.cjs
CHANGED
|
@@ -3429,7 +3429,7 @@ var scopedToRail = (table, rail) => ({
|
|
|
3429
3429
|
});
|
|
3430
3430
|
|
|
3431
3431
|
// src/client/client.ts
|
|
3432
|
-
var
|
|
3432
|
+
var import_base18 = require("@scure/base");
|
|
3433
3433
|
init_repository();
|
|
3434
3434
|
|
|
3435
3435
|
// src/refund.ts
|
|
@@ -4083,6 +4083,13 @@ var import_sdk17 = require("@arkade-os/sdk");
|
|
|
4083
4083
|
init_offer();
|
|
4084
4084
|
init_store();
|
|
4085
4085
|
var TXS_PER_REQUEST = 50;
|
|
4086
|
+
var toRestoreTx = (tx) => ({
|
|
4087
|
+
type: tx.type.toLowerCase(),
|
|
4088
|
+
redeemTxid: tx.key.arkTxid,
|
|
4089
|
+
boardingTxid: tx.key.boardingTxid,
|
|
4090
|
+
roundTxid: tx.key.commitmentTxid,
|
|
4091
|
+
createdAt: Math.floor(tx.createdAt / 1e3)
|
|
4092
|
+
});
|
|
4086
4093
|
async function fetchParsedTxs(indexer, txids) {
|
|
4087
4094
|
const parsedByTxid = /* @__PURE__ */ new Map();
|
|
4088
4095
|
if (txids.length === 0) return parsedByTxid;
|
|
@@ -4614,8 +4621,8 @@ var retireOfferScripts = async (wallet, repository, record) => {
|
|
|
4614
4621
|
};
|
|
4615
4622
|
|
|
4616
4623
|
// src/client/drive.ts
|
|
4617
|
-
var
|
|
4618
|
-
var
|
|
4624
|
+
var import_sdk26 = require("@arkade-os/sdk");
|
|
4625
|
+
var import_base16 = require("@scure/base");
|
|
4619
4626
|
|
|
4620
4627
|
// src/claim.ts
|
|
4621
4628
|
var import_sdk20 = require("@arkade-os/sdk");
|
|
@@ -4874,31 +4881,13 @@ function shouldRetainRfqSwap(record, now) {
|
|
|
4874
4881
|
return now - record.updatedAt < RFQ_SWAP_RETENTION_SECONDS;
|
|
4875
4882
|
}
|
|
4876
4883
|
|
|
4877
|
-
// src/registerRestore.ts
|
|
4878
|
-
var import_base14 = require("@scure/base");
|
|
4879
|
-
var import_sdk24 = require("@arkade-os/sdk");
|
|
4880
|
-
|
|
4881
|
-
// src/restoreRepository.ts
|
|
4882
|
-
var import_sdk23 = require("@arkade-os/sdk");
|
|
4883
|
-
init_offer();
|
|
4884
|
-
init_store();
|
|
4885
|
-
|
|
4886
|
-
// src/registerRestore.ts
|
|
4887
|
-
var toRestoreTx = (tx) => ({
|
|
4888
|
-
type: tx.type.toLowerCase(),
|
|
4889
|
-
redeemTxid: tx.key.arkTxid,
|
|
4890
|
-
boardingTxid: tx.key.boardingTxid,
|
|
4891
|
-
roundTxid: tx.key.commitmentTxid,
|
|
4892
|
-
createdAt: Math.floor(tx.createdAt / 1e3)
|
|
4893
|
-
});
|
|
4894
|
-
|
|
4895
4884
|
// src/client/drive.ts
|
|
4896
4885
|
init_store();
|
|
4897
4886
|
init_repository();
|
|
4898
4887
|
|
|
4899
4888
|
// src/swapManager.ts
|
|
4900
|
-
var
|
|
4901
|
-
var
|
|
4889
|
+
var import_base14 = require("@scure/base");
|
|
4890
|
+
var import_sdk23 = require("@arkade-os/sdk");
|
|
4902
4891
|
init_onchainHtlc();
|
|
4903
4892
|
init_lockupContract();
|
|
4904
4893
|
init_repository();
|
|
@@ -5310,13 +5299,13 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
5310
5299
|
// ── internals ────────────────────────────────────────────────────────────
|
|
5311
5300
|
track(swap) {
|
|
5312
5301
|
this.monitored.set(swap.rfqId, swap);
|
|
5313
|
-
this.byLockupScript.set(
|
|
5302
|
+
this.byLockupScript.set(import_base14.hex.encode(swap.lockupPkScript), swap);
|
|
5314
5303
|
}
|
|
5315
5304
|
/** Drops the swap from BOTH indexes. `pollSwap`'s `monitored` check also stops a late
|
|
5316
5305
|
* event, deliberately redundant so neither change alone re-drives a removed swap. */
|
|
5317
5306
|
untrack(rfqId) {
|
|
5318
5307
|
const swap = this.monitored.get(rfqId);
|
|
5319
|
-
if (swap) this.byLockupScript.delete(
|
|
5308
|
+
if (swap) this.byLockupScript.delete(import_base14.hex.encode(swap.lockupPkScript));
|
|
5320
5309
|
this.monitored.delete(rfqId);
|
|
5321
5310
|
this.refundRefused.delete(rfqId);
|
|
5322
5311
|
this.claimedOutpoints.delete(rfqId);
|
|
@@ -5339,7 +5328,7 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
5339
5328
|
});
|
|
5340
5329
|
return;
|
|
5341
5330
|
}
|
|
5342
|
-
if (!(0,
|
|
5331
|
+
if (!(0, import_sdk23.isContractVtxoEvent)(event)) return;
|
|
5343
5332
|
const swap = this.byLockupScript.get(event.contractScript);
|
|
5344
5333
|
if (!swap) return;
|
|
5345
5334
|
void this.pollSwap(swap).catch(() => {
|
|
@@ -5362,7 +5351,7 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
5362
5351
|
if (!lockup) {
|
|
5363
5352
|
try {
|
|
5364
5353
|
const [existing] = await contracts.getContracts({
|
|
5365
|
-
script:
|
|
5354
|
+
script: import_base14.hex.encode(swap.lockupPkScript)
|
|
5366
5355
|
});
|
|
5367
5356
|
if (existing) {
|
|
5368
5357
|
this.registered.set(swap.rfqId, true);
|
|
@@ -5381,13 +5370,13 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
5381
5370
|
);
|
|
5382
5371
|
return;
|
|
5383
5372
|
}
|
|
5384
|
-
const script =
|
|
5385
|
-
if (script !==
|
|
5373
|
+
const script = import_base14.hex.encode(lockup.script.pkScript);
|
|
5374
|
+
if (script !== import_base14.hex.encode(swap.lockupPkScript)) {
|
|
5386
5375
|
this.registered.set(swap.rfqId, false);
|
|
5387
5376
|
this.emitFailed(
|
|
5388
5377
|
swap,
|
|
5389
5378
|
new Error(
|
|
5390
|
-
`swap ${swap.rfqId} lockup script ${script} does not match its lockupPkScript ${
|
|
5379
|
+
`swap ${swap.rfqId} lockup script ${script} does not match its lockupPkScript ${import_base14.hex.encode(swap.lockupPkScript)}`
|
|
5391
5380
|
)
|
|
5392
5381
|
);
|
|
5393
5382
|
return;
|
|
@@ -5404,7 +5393,7 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
5404
5393
|
retireContract(swap) {
|
|
5405
5394
|
if (!this.deps.contracts || !this.registered.get(swap.rfqId)) return;
|
|
5406
5395
|
if (!LOCKUP_RETIRABLE.includes(swap.state)) return;
|
|
5407
|
-
void this.deps.contracts.setContractWatchState(
|
|
5396
|
+
void this.deps.contracts.setContractWatchState(import_base14.hex.encode(swap.lockupPkScript), "retained").catch((error) => this.emitFailed(swap, error));
|
|
5408
5397
|
}
|
|
5409
5398
|
arm() {
|
|
5410
5399
|
if (!this.running) return;
|
|
@@ -5566,8 +5555,8 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
5566
5555
|
this.setState(swap, "claimed");
|
|
5567
5556
|
this.emitAction(swap, "claimLockup");
|
|
5568
5557
|
} catch (error) {
|
|
5569
|
-
const ark = (0,
|
|
5570
|
-
if ((0,
|
|
5558
|
+
const ark = (0, import_sdk23.isArkError)(error) ? error : (0, import_sdk23.maybeArkError)(error);
|
|
5559
|
+
if ((0, import_sdk23.isArkError)(ark, import_sdk23.ArkErrorName.VTXO_ALREADY_SPENT)) {
|
|
5571
5560
|
if (swap.claimFailure !== void 0) {
|
|
5572
5561
|
delete swap.claimFailure;
|
|
5573
5562
|
this.touch(swap);
|
|
@@ -5756,7 +5745,7 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
5756
5745
|
*/
|
|
5757
5746
|
stampSettlementPreimage(swap, preimage) {
|
|
5758
5747
|
if (swap.kind !== "lightning_send") return;
|
|
5759
|
-
swap.settlementPreimageHex =
|
|
5748
|
+
swap.settlementPreimageHex = import_base14.hex.encode(preimage);
|
|
5760
5749
|
this.touch(swap);
|
|
5761
5750
|
}
|
|
5762
5751
|
touch(swap) {
|
|
@@ -5879,8 +5868,8 @@ var errorMessage = (error) => error instanceof Error ? error.message : String(er
|
|
|
5879
5868
|
var outpointKey = (vtxo) => `${vtxo.txid}:${vtxo.vout}`;
|
|
5880
5869
|
|
|
5881
5870
|
// src/watch.ts
|
|
5882
|
-
var
|
|
5883
|
-
var
|
|
5871
|
+
var import_base15 = require("@scure/base");
|
|
5872
|
+
var import_sdk24 = require("@arkade-os/sdk");
|
|
5884
5873
|
init_coverage();
|
|
5885
5874
|
init_offer();
|
|
5886
5875
|
init_store();
|
|
@@ -5915,7 +5904,7 @@ async function watchOfferSwaps({
|
|
|
5915
5904
|
wallet.getAddress(),
|
|
5916
5905
|
wallet.getArkadeReader()
|
|
5917
5906
|
]);
|
|
5918
|
-
const operatorPubkey =
|
|
5907
|
+
const operatorPubkey = import_sdk24.ArkAddress.decode(address).serverPubKey;
|
|
5919
5908
|
let queue = Promise.resolve();
|
|
5920
5909
|
const enqueue = (task) => {
|
|
5921
5910
|
queue = queue.then(task).catch(() => {
|
|
@@ -5928,9 +5917,9 @@ async function watchOfferSwaps({
|
|
|
5928
5917
|
if (candidates.length === 0) return "indeterminate";
|
|
5929
5918
|
const { txs } = await indexer.getVirtualTxs(candidates);
|
|
5930
5919
|
return classifyDepositSpend(
|
|
5931
|
-
decodeOffer(
|
|
5920
|
+
decodeOffer(import_base15.hex.decode(swap.offerHex)),
|
|
5932
5921
|
operatorPubkey,
|
|
5933
|
-
txs.map((psbt) =>
|
|
5922
|
+
txs.map((psbt) => import_sdk24.Transaction.fromPSBT(import_base15.base64.decode(psbt))),
|
|
5934
5923
|
{ txid: vtxo.txid, vout: vtxo.vout }
|
|
5935
5924
|
);
|
|
5936
5925
|
} catch {
|
|
@@ -5958,7 +5947,7 @@ async function watchOfferSwaps({
|
|
|
5958
5947
|
}
|
|
5959
5948
|
};
|
|
5960
5949
|
const unsubscribe = manager.onContractEvent((event) => {
|
|
5961
|
-
if (!(0,
|
|
5950
|
+
if (!(0, import_sdk24.isContractVtxoEvent)(event) || event.type !== "vtxo_spent") return;
|
|
5962
5951
|
enqueue(() => handleSpend(event));
|
|
5963
5952
|
});
|
|
5964
5953
|
return {
|
|
@@ -5968,7 +5957,7 @@ async function watchOfferSwaps({
|
|
|
5968
5957
|
}
|
|
5969
5958
|
|
|
5970
5959
|
// src/client/legacyRecords.ts
|
|
5971
|
-
var
|
|
5960
|
+
var import_sdk25 = require("@arkade-os/sdk");
|
|
5972
5961
|
init_repository();
|
|
5973
5962
|
var readLegacyRfqSwaps = async (repository, filter = {}) => {
|
|
5974
5963
|
try {
|
|
@@ -5985,7 +5974,7 @@ var withLegacyRfqSwaps = (bridge, repository, admits) => {
|
|
|
5985
5974
|
index: bridge.index,
|
|
5986
5975
|
quoteIdOf: bridge.quoteIdOf,
|
|
5987
5976
|
async getRfqSwapsPage(filter, page) {
|
|
5988
|
-
(0,
|
|
5977
|
+
(0, import_sdk25.assertPageRequest)(page);
|
|
5989
5978
|
assertRfqSwapPageFilter(filter);
|
|
5990
5979
|
const v2 = await collectRfqSwaps(bridge, filter);
|
|
5991
5980
|
const held = new Set(
|
|
@@ -6021,14 +6010,14 @@ var readLegacyAssetSwaps = async (repository) => {
|
|
|
6021
6010
|
return [];
|
|
6022
6011
|
}
|
|
6023
6012
|
};
|
|
6024
|
-
var
|
|
6025
|
-
const
|
|
6026
|
-
(swap) => !!swap.offerHex && !!swap.fundingTxid
|
|
6013
|
+
var legacyOfferDepositsToAdopt = async (repository) => {
|
|
6014
|
+
const unadopted = (await readLegacyAssetSwaps(repository)).filter(
|
|
6015
|
+
(swap) => !!swap.offerHex && !!swap.fundingTxid
|
|
6027
6016
|
);
|
|
6028
|
-
if (
|
|
6017
|
+
if (unadopted.length === 0) return /* @__PURE__ */ new Set();
|
|
6029
6018
|
const { offer } = splitRecords(await collectSwapRecords(repository));
|
|
6030
6019
|
const adopted = new Set(offer.map((record) => record.fundingTxid));
|
|
6031
|
-
return new Set(
|
|
6020
|
+
return new Set(unadopted.map((swap) => swap.fundingTxid).filter((txid) => !adopted.has(txid)));
|
|
6032
6021
|
};
|
|
6033
6022
|
|
|
6034
6023
|
// src/client/drive.ts
|
|
@@ -6209,10 +6198,10 @@ var createSwapDrive = (config) => {
|
|
|
6209
6198
|
const secret = rfqClaimSecretOf(record);
|
|
6210
6199
|
if (!secret) throw new Error(`rfq swap ${swap.rfqId} carries no claim secret`);
|
|
6211
6200
|
const preimage = await preimageForSwapRecord(wallet, secret);
|
|
6212
|
-
const signer = await (0,
|
|
6201
|
+
const signer = await (0, import_sdk26.contractSigner)(wallet, await (0, import_sdk26.identityDescriptor)(wallet.identity));
|
|
6213
6202
|
const claimKey = record.profile.claimKey;
|
|
6214
6203
|
if (typeof claimKey === "string") {
|
|
6215
|
-
const held =
|
|
6204
|
+
const held = import_base16.hex.encode(await signer.xOnlyPublicKey());
|
|
6216
6205
|
if (held !== claimKey) {
|
|
6217
6206
|
throw new Error(
|
|
6218
6207
|
`this wallet's identity key ${held} is not the payout key ${claimKey} rfq swap ${swap.rfqId} was quoted against \u2014 a wrong seed, or key provisioning has drifted from the identity key`
|
|
@@ -6253,7 +6242,7 @@ var createSwapDrive = (config) => {
|
|
|
6253
6242
|
}
|
|
6254
6243
|
};
|
|
6255
6244
|
const drivable = async (record) => !readsChain(record.kind) || await resolveOnchain();
|
|
6256
|
-
const pinnedNetwork = async () => (0,
|
|
6245
|
+
const pinnedNetwork = async () => (0, import_sdk26.getNetwork)(await config.network());
|
|
6257
6246
|
const claimLockup = async (swap, vtxos, { partiallyClaimed }) => {
|
|
6258
6247
|
const record = await corridorStore().getRfqSwap(swap.rfqId);
|
|
6259
6248
|
if (!record) throw new Error(`rfq swap ${swap.rfqId} has no stored record to claim from`);
|
|
@@ -6268,10 +6257,10 @@ var createSwapDrive = (config) => {
|
|
|
6268
6257
|
return track(
|
|
6269
6258
|
pushClaim(operator, {
|
|
6270
6259
|
contract: script,
|
|
6271
|
-
receiver: await (0,
|
|
6260
|
+
receiver: await (0, import_sdk26.contractSigner)(wallet, secret.signingDescriptor),
|
|
6272
6261
|
preimage: await preimageForSwapRecord(wallet, secret),
|
|
6273
6262
|
vtxos,
|
|
6274
|
-
destinationPkScript:
|
|
6263
|
+
destinationPkScript: import_sdk26.ArkAddress.decode(payoutAddress).pkScript,
|
|
6275
6264
|
// Passed through: `pushClaim`'s own value check decides whether `P` is published.
|
|
6276
6265
|
expectedAmount: swap.expectedAmount,
|
|
6277
6266
|
partiallyClaimed,
|
|
@@ -6338,8 +6327,8 @@ var createSwapDrive = (config) => {
|
|
|
6338
6327
|
config.network()
|
|
6339
6328
|
]);
|
|
6340
6329
|
const txs = history.map(toRestoreTx);
|
|
6341
|
-
const { hrp, serverPubKey: operatorPubkey } =
|
|
6342
|
-
const reopened = await
|
|
6330
|
+
const { hrp, serverPubKey: operatorPubkey } = import_sdk26.ArkAddress.decode(address);
|
|
6331
|
+
const reopened = await legacyOfferDepositsToAdopt(store);
|
|
6343
6332
|
for (const txid of reopen) reopened.add(txid);
|
|
6344
6333
|
const cursor = reopened.size === 0 ? scanned : new Set([...scanned].filter((txid) => !reopened.has(txid)));
|
|
6345
6334
|
const { restored, scannedTxids } = await restoreAssetSwaps(indexer, txs, /* @__PURE__ */ new Set(), {
|
|
@@ -6436,6 +6425,18 @@ var createSwapDrive = (config) => {
|
|
|
6436
6425
|
});
|
|
6437
6426
|
}
|
|
6438
6427
|
};
|
|
6428
|
+
const registerRestoredOffers = async (offers2) => {
|
|
6429
|
+
if (mode === "readonly") return;
|
|
6430
|
+
const live2 = offers2.filter(
|
|
6431
|
+
(record) => record.fundingTxid !== void 0 && !RETIRABLE.includes(record.status)
|
|
6432
|
+
);
|
|
6433
|
+
if (live2.length === 0) return;
|
|
6434
|
+
try {
|
|
6435
|
+
await restoreOfferCoverage(wallet, live2.map(offerFactsOf));
|
|
6436
|
+
} catch (error) {
|
|
6437
|
+
console.warn("[swap] could not register restored offer covenants", error);
|
|
6438
|
+
}
|
|
6439
|
+
};
|
|
6439
6440
|
const restore = async () => {
|
|
6440
6441
|
if (!repository) return;
|
|
6441
6442
|
const all = await collectSwapRecords(repository);
|
|
@@ -6480,6 +6481,7 @@ var createSwapDrive = (config) => {
|
|
|
6480
6481
|
} catch (error) {
|
|
6481
6482
|
console.warn("[swap] the offer deposit restore did not complete", error);
|
|
6482
6483
|
}
|
|
6484
|
+
await registerRestoredOffers(offers2);
|
|
6483
6485
|
emitAll();
|
|
6484
6486
|
if (mode === "auto" && await hasLiveWork(offers2)) {
|
|
6485
6487
|
try {
|
|
@@ -6533,7 +6535,7 @@ var createSwapDrive = (config) => {
|
|
|
6533
6535
|
id
|
|
6534
6536
|
);
|
|
6535
6537
|
}
|
|
6536
|
-
const script =
|
|
6538
|
+
const script = import_base16.hex.decode(record.lockupPkScript);
|
|
6537
6539
|
const before = await recoverableAt(script);
|
|
6538
6540
|
if (before.length === 0) {
|
|
6539
6541
|
throw new SwapDriveRefusedError(
|
|
@@ -7151,8 +7153,8 @@ var verifyPlanLegs = (plan, legs, give) => {
|
|
|
7151
7153
|
};
|
|
7152
7154
|
|
|
7153
7155
|
// src/client/quoteRfq.ts
|
|
7154
|
-
var
|
|
7155
|
-
var
|
|
7156
|
+
var import_base17 = require("@scure/base");
|
|
7157
|
+
var import_sdk29 = require("@arkade-os/sdk");
|
|
7156
7158
|
var import_solver_discovery9 = require("@arkade-os/solver-discovery");
|
|
7157
7159
|
init_claimPacket();
|
|
7158
7160
|
init_offer();
|
|
@@ -7161,11 +7163,11 @@ init_onchainHtlc();
|
|
|
7161
7163
|
init_onchainHtlc();
|
|
7162
7164
|
|
|
7163
7165
|
// src/payment/onchainSwap.ts
|
|
7164
|
-
var
|
|
7166
|
+
var import_sdk28 = require("@arkade-os/sdk");
|
|
7165
7167
|
init_onchainHtlc();
|
|
7166
7168
|
|
|
7167
7169
|
// src/payment/swapRail.ts
|
|
7168
|
-
var
|
|
7170
|
+
var import_sdk27 = require("@arkade-os/sdk");
|
|
7169
7171
|
|
|
7170
7172
|
// src/client/sats.ts
|
|
7171
7173
|
var satsOf = (value, field) => {
|
|
@@ -7222,13 +7224,13 @@ var lockupOf = (derived) => ({
|
|
|
7222
7224
|
pkScript: derived.swapPkScript
|
|
7223
7225
|
});
|
|
7224
7226
|
var covenantInputs = (input) => {
|
|
7225
|
-
const network = (0,
|
|
7227
|
+
const network = (0, import_sdk29.networkFromArkadeInfo)(input.info);
|
|
7226
7228
|
const arkade2 = input.corridors.get("arkade").deps;
|
|
7227
7229
|
return {
|
|
7228
|
-
operatorPubkey: (0,
|
|
7230
|
+
operatorPubkey: (0, import_sdk29.toXOnly)(import_base17.hex.decode(input.info.signerPubkey), "ark signer key"),
|
|
7229
7231
|
// The resolved per-network pin, never operator-reported: it lands in a covenant leaf
|
|
7230
7232
|
// that decides who can move the funds.
|
|
7231
|
-
emulatorPubkey: (0,
|
|
7233
|
+
emulatorPubkey: (0, import_sdk29.toXOnly)(import_base17.hex.decode(arkade2.emulatorPubkey), "emulator signer key"),
|
|
7232
7234
|
claimDelay: unilateralClaimDelay(Number(input.info.unilateralExitDelay)),
|
|
7233
7235
|
hrp: network.hrp
|
|
7234
7236
|
};
|
|
@@ -7236,7 +7238,7 @@ var covenantInputs = (input) => {
|
|
|
7236
7238
|
var sealingKey = (deps) => {
|
|
7237
7239
|
const configured = deps.covclaimd?.pubkey;
|
|
7238
7240
|
if (configured === void 0) return void 0;
|
|
7239
|
-
const key =
|
|
7241
|
+
const key = import_base17.hex.decode(configured);
|
|
7240
7242
|
if (key.length !== 33) {
|
|
7241
7243
|
throw new Error(
|
|
7242
7244
|
`the covclaimd deployment key must be 33-byte compressed hex, got ${key.length} bytes`
|
|
@@ -7365,14 +7367,14 @@ var assetSidesOf = (legs) => {
|
|
|
7365
7367
|
{ give: "arkade", take: "arkade" }
|
|
7366
7368
|
);
|
|
7367
7369
|
}
|
|
7368
|
-
return giveIsBtc ? { wantAsset:
|
|
7370
|
+
return giveIsBtc ? { wantAsset: import_sdk29.asset.AssetId.fromString(legs.take.assetId) } : { offerAsset: import_sdk29.asset.AssetId.fromString(legs.give.assetId) };
|
|
7369
7371
|
};
|
|
7370
7372
|
var makerPosition = async (wallet) => {
|
|
7371
7373
|
const [address, publicKey] = await Promise.all([
|
|
7372
7374
|
wallet.getAddress(),
|
|
7373
7375
|
wallet.identity.xOnlyPublicKey()
|
|
7374
7376
|
]);
|
|
7375
|
-
return { pkScript:
|
|
7377
|
+
return { pkScript: import_sdk29.ArkAddress.decode(address).pkScript, publicKey };
|
|
7376
7378
|
};
|
|
7377
7379
|
var quoteLightningSend = async (input) => {
|
|
7378
7380
|
const invoice = input.endpoints.take.instrument;
|
|
@@ -7381,7 +7383,7 @@ var quoteLightningSend = async (input) => {
|
|
|
7381
7383
|
}
|
|
7382
7384
|
const pair = rfqPairFor(input.legs.give, input.legs.take);
|
|
7383
7385
|
const rfqId = newRfqId();
|
|
7384
|
-
const secrets = await (0,
|
|
7386
|
+
const secrets = await (0, import_sdk29.provisionRefundKey)(input.wallet);
|
|
7385
7387
|
const wire = await input.transport.requestQuote(
|
|
7386
7388
|
lightningSendRequest({
|
|
7387
7389
|
rfqId,
|
|
@@ -7450,8 +7452,8 @@ var quoteLightningReceive = async (input) => {
|
|
|
7450
7452
|
const pinned = pinnedFor(input);
|
|
7451
7453
|
const pair = rfqPairFor(input.legs.give, input.legs.take);
|
|
7452
7454
|
const rfqId = newRfqId();
|
|
7453
|
-
const secrets = await (0,
|
|
7454
|
-
const paymentHash =
|
|
7455
|
+
const secrets = await (0, import_sdk29.provisionClaimSecret)(input.wallet);
|
|
7456
|
+
const paymentHash = import_base17.hex.encode(secrets.paymentHash);
|
|
7455
7457
|
const payoutAddress = await input.wallet.getAddress();
|
|
7456
7458
|
const lightning = input.corridors.get("lightning").deps;
|
|
7457
7459
|
const sealTo = sealingKey(lightning);
|
|
@@ -7562,9 +7564,9 @@ var quoteOnchainSend = async (input) => {
|
|
|
7562
7564
|
claimVsize: onchain.claimVsize
|
|
7563
7565
|
}) : void 0;
|
|
7564
7566
|
const quoted = claimFee === void 0 ? pinned : { on: pinned.on, value: pinned.value + claimFee, source: pinned.source };
|
|
7565
|
-
const secrets = await (0,
|
|
7566
|
-
const payoutKey = await (0,
|
|
7567
|
-
const paymentHash =
|
|
7567
|
+
const secrets = await (0, import_sdk29.provisionClaimSecret)(input.wallet);
|
|
7568
|
+
const payoutKey = await (0, import_sdk29.provisionRefundKey)(input.wallet);
|
|
7569
|
+
const paymentHash = import_base17.hex.encode(secrets.paymentHash);
|
|
7568
7570
|
const wire = await input.transport.requestQuote(
|
|
7569
7571
|
withCanonicalAmount(
|
|
7570
7572
|
onchainSendRequest({
|
|
@@ -7660,7 +7662,7 @@ var quoteOnchainSend = async (input) => {
|
|
|
7660
7662
|
};
|
|
7661
7663
|
|
|
7662
7664
|
// src/client/verbs.ts
|
|
7663
|
-
var
|
|
7665
|
+
var import_sdk30 = require("@arkade-os/sdk");
|
|
7664
7666
|
var enforceFeeCeiling = (quote, call, policy) => {
|
|
7665
7667
|
let ceiling;
|
|
7666
7668
|
for (const [source, limit] of [
|
|
@@ -7685,9 +7687,9 @@ var settle = async (deps, input, maxFee) => {
|
|
|
7685
7687
|
return deps.accept(quote);
|
|
7686
7688
|
};
|
|
7687
7689
|
var pay = async (deps, destination, options = {}) => {
|
|
7688
|
-
const arkade2 = (0,
|
|
7690
|
+
const arkade2 = (0, import_sdk30.arkTarget)(destination);
|
|
7689
7691
|
if (arkade2 !== void 0) {
|
|
7690
|
-
const amount = (0,
|
|
7692
|
+
const amount = (0, import_sdk30.resolveSendAmount)(
|
|
7691
7693
|
"ark",
|
|
7692
7694
|
destination,
|
|
7693
7695
|
options.amount === void 0 ? void 0 : satsOf(options.amount, "amount")
|
|
@@ -7750,7 +7752,7 @@ var nostrTransportFactory = async (rendezvous) => {
|
|
|
7750
7752
|
|
|
7751
7753
|
// src/client/client.ts
|
|
7752
7754
|
var PREPARATIONS_HELD = 64;
|
|
7753
|
-
var mintQuoteId = () =>
|
|
7755
|
+
var mintQuoteId = () => import_base18.hex.encode(crypto.getRandomValues(new Uint8Array(16)));
|
|
7754
7756
|
var createSwapClient = (config) => {
|
|
7755
7757
|
const { wallet } = config;
|
|
7756
7758
|
const operator = config.operator ?? walletOperator(wallet);
|
|
@@ -7999,8 +8001,8 @@ var createSwapClient = (config) => {
|
|
|
7999
8001
|
};
|
|
8000
8002
|
|
|
8001
8003
|
// src/reveal.ts
|
|
8002
|
-
var
|
|
8003
|
-
var
|
|
8004
|
+
var import_base19 = require("@scure/base");
|
|
8005
|
+
var import_sdk31 = require("@arkade-os/sdk");
|
|
8004
8006
|
init_claimPacket();
|
|
8005
8007
|
init_onchainHtlc();
|
|
8006
8008
|
var CovclaimdRevealError = class extends Error {
|
|
@@ -8019,7 +8021,7 @@ var decodeKey = (value, field) => {
|
|
|
8019
8021
|
if (typeof value !== "string") throw new Error(`covclaimd info: ${field} is not a string`);
|
|
8020
8022
|
let bytes;
|
|
8021
8023
|
try {
|
|
8022
|
-
bytes =
|
|
8024
|
+
bytes = import_base19.hex.decode(value);
|
|
8023
8025
|
} catch {
|
|
8024
8026
|
throw new Error(`covclaimd info: ${field} is not hex`);
|
|
8025
8027
|
}
|
|
@@ -8079,7 +8081,7 @@ var covclaimdClient = (baseUrl, options = {}) => {
|
|
|
8079
8081
|
const body = await readJson("info", response);
|
|
8080
8082
|
return {
|
|
8081
8083
|
covclaimdPubkey: decodeKey(body?.covclaimd_pub_key, "covclaimd_pub_key"),
|
|
8082
|
-
emulatorPubkey:
|
|
8084
|
+
emulatorPubkey: import_base19.hex.encode(decodeKey(body?.emulator_pub_key, "emulator_pub_key"))
|
|
8083
8085
|
};
|
|
8084
8086
|
},
|
|
8085
8087
|
async reveal(params) {
|
|
@@ -8100,13 +8102,13 @@ function revealFieldsFromScript(script) {
|
|
|
8100
8102
|
throw new Error("this covenant has no non-interactive claim leaf to reveal against");
|
|
8101
8103
|
}
|
|
8102
8104
|
return {
|
|
8103
|
-
arkadeScript:
|
|
8104
|
-
taptree:
|
|
8105
|
+
arkadeScript: import_base19.base64.encode(script.nonInteractiveClaimArkadeScript),
|
|
8106
|
+
taptree: import_base19.hex.encode(script.encode())
|
|
8105
8107
|
};
|
|
8106
8108
|
}
|
|
8107
8109
|
async function revealClaimPacket(client, input) {
|
|
8108
8110
|
const fields = revealFieldsFromScript(input.script);
|
|
8109
|
-
if (
|
|
8111
|
+
if (import_base19.hex.encode(import_sdk31.ArkAddress.decode(input.address).pkScript) !== import_base19.hex.encode(input.script.pkScript)) {
|
|
8110
8112
|
throw new Error("address does not belong to this covenant");
|
|
8111
8113
|
}
|
|
8112
8114
|
assertPreimageMatches(input.preimage, input.script.options.preimageHash);
|
package/dist/advanced.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AssetAliasTable, C as CorridorFactory, a as ArkadeCorridorDeps, L as LightningCorridorDeps, O as OnchainCorridorDeps, b as CorridorSet, D as DiscoveryIndex, S as SwapPolicy, c as DiscoveryLeg, M as MarketCandidate, d as DiscoverySnapshot } from './errors-
|
|
2
|
-
export { e as AcceptConflict, f as AcceptInput, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, j as AssetRfqPreparation, k as AttestingRfqTransport, l as CORRIDOR_FACTORIES, m as CancelInput, n as CancelOutcome, o as ClaimedDestination, p as ClientDisposed, q as CorridorBase, r as CorridorClaim, s as CorridorCovenant, t as CorridorDeadline, u as CorridorDeps, v as CorridorDepsByCorridor, w as CorridorDrive, x as CorridorLockup, y as CorridorModule, z as CorridorOverrides, B as CorridorPass, E as CorridorRfqPreparation, F as DiscoveryConfig, G as DiscoveryIndexInput, H as DiscoverySnapshotUnavailable, I as DriveMode, J as DriveRefusal, K as ExchangeOptions, N as FEED_TTL_MS, P as FeeCeiling, Q as FeedFetch, R as FeedQuoteInput, T as INDEXED_NETWORKS, U as InconsistentRoute, V as InsufficientFunds, W as LockupOwner, X as Market, Y as MaxFeeExceeded, Z as MissingCorridorDep, _ as NotCancellable, $ as ONCHAIN_CLAIM_FEE_RATE_SATVB, a0 as ObservationSeam, a1 as OfferPreparation, a2 as OnchainClaim, a3 as OperatorUnreachable, a4 as ParsedRfqQuote, a5 as PayOptions, a6 as PayResult, a7 as QuoteCheck, a8 as QuoteExpired, a9 as QuotePreparation, aa as QuoteVerificationFailed, ab as REGISTRY_URL, ac as ReceiveArtifact, ad as ReceiveOptions, ae as ReceiveRequest, af as RecoveryResult, ag as RegisteredAsset, ah as RfqAuctionPolicy, ai as RfqPreparation, aj as RfqQuoteInput, ak as RfqRendezvous, al as RfqTransportFactory, am as RouteSide, an as SWAP_ERROR_NAMES, ao as SwapClient, ap as SwapClientConfig, aq as SwapDrive, ar as SwapDriveConfig, as as SwapDriveRefusedError, at as SwapError, au as SwapErrorName, av as SwapFilter, aw as UnsupportedRoute, ax as VerbDeps, ay as acceptQuote, az as attesting, aA as cancelSwap, aB as canonicalAssetId, aC as cardMarketOf, aD as chooseMarket, aE as conflictingFields, aF as corridorSet, aG as createSwapClient, aH as createSwapDrive, aI as discoveryIndex, aJ as eligibleMarkets, aK as enforceFeeCeiling, aL as exchange, aM as feedFetch, aN as feedSpread, aO as isAddressable, aP as isCardMarket, aQ as isIndexedNetwork, aR as isSwapError, aS as isUsableCard, aT as liveArkadeInfo, aU as marketBackendOf, aV as marketKeyOf, aW as marketRefOf, aX as nostrTransportFactory, aY as parseRfqQuote, aZ as pay, a_ as quoteFromFeed, a$ as quoteViaRfq, b0 as readableRecord, b1 as receive, b2 as resolveCorridorBase, b3 as resolveCorridorDeps, b4 as rfqLeg, b5 as rfqPairFor, b6 as swapRecordOf, b7 as toDiscoveryLeg, b8 as usableMarkets, b9 as verifyPlanLegs, ba as withCanonicalAmount } from './errors-
|
|
1
|
+
import { A as AssetAliasTable, C as CorridorFactory, a as ArkadeCorridorDeps, L as LightningCorridorDeps, O as OnchainCorridorDeps, b as CorridorSet, D as DiscoveryIndex, S as SwapPolicy, c as DiscoveryLeg, M as MarketCandidate, d as DiscoverySnapshot } from './errors-B7boQfoR.cjs';
|
|
2
|
+
export { e as AcceptConflict, f as AcceptInput, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, j as AssetRfqPreparation, k as AttestingRfqTransport, l as CORRIDOR_FACTORIES, m as CancelInput, n as CancelOutcome, o as ClaimedDestination, p as ClientDisposed, q as CorridorBase, r as CorridorClaim, s as CorridorCovenant, t as CorridorDeadline, u as CorridorDeps, v as CorridorDepsByCorridor, w as CorridorDrive, x as CorridorLockup, y as CorridorModule, z as CorridorOverrides, B as CorridorPass, E as CorridorRfqPreparation, F as DiscoveryConfig, G as DiscoveryIndexInput, H as DiscoverySnapshotUnavailable, I as DriveMode, J as DriveRefusal, K as ExchangeOptions, N as FEED_TTL_MS, P as FeeCeiling, Q as FeedFetch, R as FeedQuoteInput, T as INDEXED_NETWORKS, U as InconsistentRoute, V as InsufficientFunds, W as LockupOwner, X as Market, Y as MaxFeeExceeded, Z as MissingCorridorDep, _ as NotCancellable, $ as ONCHAIN_CLAIM_FEE_RATE_SATVB, a0 as ObservationSeam, a1 as OfferPreparation, a2 as OnchainClaim, a3 as OperatorUnreachable, a4 as ParsedRfqQuote, a5 as PayOptions, a6 as PayResult, a7 as QuoteCheck, a8 as QuoteExpired, a9 as QuotePreparation, aa as QuoteVerificationFailed, ab as REGISTRY_URL, ac as ReceiveArtifact, ad as ReceiveOptions, ae as ReceiveRequest, af as RecoveryResult, ag as RegisteredAsset, ah as RfqAuctionPolicy, ai as RfqPreparation, aj as RfqQuoteInput, ak as RfqRendezvous, al as RfqTransportFactory, am as RouteSide, an as SWAP_ERROR_NAMES, ao as SwapClient, ap as SwapClientConfig, aq as SwapDrive, ar as SwapDriveConfig, as as SwapDriveRefusedError, at as SwapError, au as SwapErrorName, av as SwapFilter, aw as UnsupportedRoute, ax as VerbDeps, ay as acceptQuote, az as attesting, aA as cancelSwap, aB as canonicalAssetId, aC as cardMarketOf, aD as chooseMarket, aE as conflictingFields, aF as corridorSet, aG as createSwapClient, aH as createSwapDrive, aI as discoveryIndex, aJ as eligibleMarkets, aK as enforceFeeCeiling, aL as exchange, aM as feedFetch, aN as feedSpread, aO as isAddressable, aP as isCardMarket, aQ as isIndexedNetwork, aR as isSwapError, aS as isUsableCard, aT as liveArkadeInfo, aU as marketBackendOf, aV as marketKeyOf, aW as marketRefOf, aX as nostrTransportFactory, aY as parseRfqQuote, aZ as pay, a_ as quoteFromFeed, a$ as quoteViaRfq, b0 as readableRecord, b1 as receive, b2 as resolveCorridorBase, b3 as resolveCorridorDeps, b4 as rfqLeg, b5 as rfqPairFor, b6 as swapRecordOf, b7 as toDiscoveryLeg, b8 as usableMarkets, b9 as verifyPlanLegs, ba as withCanonicalAmount } from './errors-B7boQfoR.cjs';
|
|
3
3
|
import { DiscoveredMarket } from '@arkade-os/solver-discovery';
|
|
4
4
|
import { N as NetworkRef, C as Corridor, A as AssetId, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-S2OS6Yl-.cjs';
|
|
5
5
|
export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as Artifact, u as AssetIdError, v as AssetIdRefusal, w as AssetNamespace, x as AssetOn, y as AssetPart, z as AssetRef, B as AssetScale, D as AssetSwapId, E as AtomicDecimal, F as AuctionMarketRef, G as AuctionProvenance, H as BITCOIN_RAILS, J as BTC_ASSET_PART, K as BitcoinRail, M as CORRIDORS, T as CORRIDOR_PASS, U as CardMarketRef, V as CorridorId, W as CorridorKind, X as DepositArtifact, Y as DisplayDecimal, Z as Endpoint, _ as Ep, $ as Hex, a0 as LOCKUP_OWNER, a1 as MarketBackend, a2 as MarketRef, a3 as OFFER_SWAP_ID_PREFIX, a4 as Outcome, a5 as ParsedAssetId, a6 as Quote, a7 as QuoteLeg, a8 as RAILS, a9 as RFQ_SWAP_ID_PREFIX, aa as RailOf, ab as RankedBid, ac as RawState, ad as RecordedArtifact, ae as RecordedEndpoint, af as RecordedInstrument, ag as RecordedLeg, ah as RestoredMarketRef, ai as RfqAmountSide, aj as SnapshotRef, ak as Swap, al as SwapFamily, am as SwapRecordCommon, an as SwapUpdate, ao as Unsubscribe, ap as arkadeAsset, aq as artifactOf, ar as assetPartOf, as as assetSwapIdOf, at as bitcoinNetworkOf, au as btcAssetPart, av as btcOn, aw as corridorOfRail, ax as corridorOutcome, ay as decodeRfqAmount, az as encodeRfqAmount, aA as familyOfSwapId, aB as formatAssetId, aC as fromAtomicDecimal, aD as fromRfqAmountSide, aE as fundsFromWallet, aF as instrumentOf, aG as isAssetId, aH as isAtomicDecimal, aI as isBtcAsset, aJ as isBtcAssetLenient, aK as isNetworkRef, aL as issuanceOf, aM as legOf, aN as offerOutcome, aO as parseAssetId, aP as quoteIdOfSwapId, aQ as railOf, aR as railOfCorridor, aS as readsChain, aT as recordArtifact, aU as recordEndpoint, aV as recordInstrument, aW as recordLeg, aX as recordOutcome, aY as sameAsset, aZ as swapOf, a_ as toAtomicDecimal, a$ as toRfqAmountSide, b0 as toSafeNumber } from './repository-S2OS6Yl-.cjs';
|
|
@@ -8,7 +8,7 @@ export { S as SwapRefusal } from './rfq-60PGpQ_x.cjs';
|
|
|
8
8
|
import * as btc from '@scure/btc-signer';
|
|
9
9
|
import { OnchainProvider, NetworkName, PageRequest, PageResult, IWallet, VHTLC } from '@arkade-os/sdk';
|
|
10
10
|
import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-BFMXLQV-.cjs';
|
|
11
|
-
import './offer-
|
|
11
|
+
import './offer-D9xdNCZS.cjs';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* The alias table, filled from discovery: the inverse of `toDiscoveryLeg`, mapping a card's
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AssetAliasTable, C as CorridorFactory, a as ArkadeCorridorDeps, L as LightningCorridorDeps, O as OnchainCorridorDeps, b as CorridorSet, D as DiscoveryIndex, S as SwapPolicy, c as DiscoveryLeg, M as MarketCandidate, d as DiscoverySnapshot } from './errors-
|
|
2
|
-
export { e as AcceptConflict, f as AcceptInput, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, j as AssetRfqPreparation, k as AttestingRfqTransport, l as CORRIDOR_FACTORIES, m as CancelInput, n as CancelOutcome, o as ClaimedDestination, p as ClientDisposed, q as CorridorBase, r as CorridorClaim, s as CorridorCovenant, t as CorridorDeadline, u as CorridorDeps, v as CorridorDepsByCorridor, w as CorridorDrive, x as CorridorLockup, y as CorridorModule, z as CorridorOverrides, B as CorridorPass, E as CorridorRfqPreparation, F as DiscoveryConfig, G as DiscoveryIndexInput, H as DiscoverySnapshotUnavailable, I as DriveMode, J as DriveRefusal, K as ExchangeOptions, N as FEED_TTL_MS, P as FeeCeiling, Q as FeedFetch, R as FeedQuoteInput, T as INDEXED_NETWORKS, U as InconsistentRoute, V as InsufficientFunds, W as LockupOwner, X as Market, Y as MaxFeeExceeded, Z as MissingCorridorDep, _ as NotCancellable, $ as ONCHAIN_CLAIM_FEE_RATE_SATVB, a0 as ObservationSeam, a1 as OfferPreparation, a2 as OnchainClaim, a3 as OperatorUnreachable, a4 as ParsedRfqQuote, a5 as PayOptions, a6 as PayResult, a7 as QuoteCheck, a8 as QuoteExpired, a9 as QuotePreparation, aa as QuoteVerificationFailed, ab as REGISTRY_URL, ac as ReceiveArtifact, ad as ReceiveOptions, ae as ReceiveRequest, af as RecoveryResult, ag as RegisteredAsset, ah as RfqAuctionPolicy, ai as RfqPreparation, aj as RfqQuoteInput, ak as RfqRendezvous, al as RfqTransportFactory, am as RouteSide, an as SWAP_ERROR_NAMES, ao as SwapClient, ap as SwapClientConfig, aq as SwapDrive, ar as SwapDriveConfig, as as SwapDriveRefusedError, at as SwapError, au as SwapErrorName, av as SwapFilter, aw as UnsupportedRoute, ax as VerbDeps, ay as acceptQuote, az as attesting, aA as cancelSwap, aB as canonicalAssetId, aC as cardMarketOf, aD as chooseMarket, aE as conflictingFields, aF as corridorSet, aG as createSwapClient, aH as createSwapDrive, aI as discoveryIndex, aJ as eligibleMarkets, aK as enforceFeeCeiling, aL as exchange, aM as feedFetch, aN as feedSpread, aO as isAddressable, aP as isCardMarket, aQ as isIndexedNetwork, aR as isSwapError, aS as isUsableCard, aT as liveArkadeInfo, aU as marketBackendOf, aV as marketKeyOf, aW as marketRefOf, aX as nostrTransportFactory, aY as parseRfqQuote, aZ as pay, a_ as quoteFromFeed, a$ as quoteViaRfq, b0 as readableRecord, b1 as receive, b2 as resolveCorridorBase, b3 as resolveCorridorDeps, b4 as rfqLeg, b5 as rfqPairFor, b6 as swapRecordOf, b7 as toDiscoveryLeg, b8 as usableMarkets, b9 as verifyPlanLegs, ba as withCanonicalAmount } from './errors-
|
|
1
|
+
import { A as AssetAliasTable, C as CorridorFactory, a as ArkadeCorridorDeps, L as LightningCorridorDeps, O as OnchainCorridorDeps, b as CorridorSet, D as DiscoveryIndex, S as SwapPolicy, c as DiscoveryLeg, M as MarketCandidate, d as DiscoverySnapshot } from './errors-DtvJU2MN.js';
|
|
2
|
+
export { e as AcceptConflict, f as AcceptInput, g as AmbiguousDestination, h as AmountEncodingUnsupported, i as AmountMismatch, j as AssetRfqPreparation, k as AttestingRfqTransport, l as CORRIDOR_FACTORIES, m as CancelInput, n as CancelOutcome, o as ClaimedDestination, p as ClientDisposed, q as CorridorBase, r as CorridorClaim, s as CorridorCovenant, t as CorridorDeadline, u as CorridorDeps, v as CorridorDepsByCorridor, w as CorridorDrive, x as CorridorLockup, y as CorridorModule, z as CorridorOverrides, B as CorridorPass, E as CorridorRfqPreparation, F as DiscoveryConfig, G as DiscoveryIndexInput, H as DiscoverySnapshotUnavailable, I as DriveMode, J as DriveRefusal, K as ExchangeOptions, N as FEED_TTL_MS, P as FeeCeiling, Q as FeedFetch, R as FeedQuoteInput, T as INDEXED_NETWORKS, U as InconsistentRoute, V as InsufficientFunds, W as LockupOwner, X as Market, Y as MaxFeeExceeded, Z as MissingCorridorDep, _ as NotCancellable, $ as ONCHAIN_CLAIM_FEE_RATE_SATVB, a0 as ObservationSeam, a1 as OfferPreparation, a2 as OnchainClaim, a3 as OperatorUnreachable, a4 as ParsedRfqQuote, a5 as PayOptions, a6 as PayResult, a7 as QuoteCheck, a8 as QuoteExpired, a9 as QuotePreparation, aa as QuoteVerificationFailed, ab as REGISTRY_URL, ac as ReceiveArtifact, ad as ReceiveOptions, ae as ReceiveRequest, af as RecoveryResult, ag as RegisteredAsset, ah as RfqAuctionPolicy, ai as RfqPreparation, aj as RfqQuoteInput, ak as RfqRendezvous, al as RfqTransportFactory, am as RouteSide, an as SWAP_ERROR_NAMES, ao as SwapClient, ap as SwapClientConfig, aq as SwapDrive, ar as SwapDriveConfig, as as SwapDriveRefusedError, at as SwapError, au as SwapErrorName, av as SwapFilter, aw as UnsupportedRoute, ax as VerbDeps, ay as acceptQuote, az as attesting, aA as cancelSwap, aB as canonicalAssetId, aC as cardMarketOf, aD as chooseMarket, aE as conflictingFields, aF as corridorSet, aG as createSwapClient, aH as createSwapDrive, aI as discoveryIndex, aJ as eligibleMarkets, aK as enforceFeeCeiling, aL as exchange, aM as feedFetch, aN as feedSpread, aO as isAddressable, aP as isCardMarket, aQ as isIndexedNetwork, aR as isSwapError, aS as isUsableCard, aT as liveArkadeInfo, aU as marketBackendOf, aV as marketKeyOf, aW as marketRefOf, aX as nostrTransportFactory, aY as parseRfqQuote, aZ as pay, a_ as quoteFromFeed, a$ as quoteViaRfq, b0 as readableRecord, b1 as receive, b2 as resolveCorridorBase, b3 as resolveCorridorDeps, b4 as rfqLeg, b5 as rfqPairFor, b6 as swapRecordOf, b7 as toDiscoveryLeg, b8 as usableMarkets, b9 as verifyPlanLegs, ba as withCanonicalAmount } from './errors-DtvJU2MN.js';
|
|
3
3
|
import { DiscoveredMarket } from '@arkade-os/solver-discovery';
|
|
4
4
|
import { N as NetworkRef, C as Corridor, A as AssetId, R as Rail, a as RfqSwapRecordStore, b as CorridorSwapRecord, Q as QuoteId, c as AssetSwapStatus, S as SwapRecord, O as OfferSwapRecord, d as AssetSwapRepository, e as RfqSwapRecord, f as RfqSwapPageFilter, g as RfqSwapPageCursor, h as AssetSwap, L as LockupSpendIndexer, i as RouteResolution, j as ResolvedEndpoint, P as PinnedAmount, I as Instrument, k as Route, l as QuoteInput, m as Pubkey } from './repository-V98jQmTD.js';
|
|
5
5
|
export { n as ACTIVITY_TOKEN, o as ARKADE_ASSET_NAMESPACE, p as Amount, q as AmountFormatError, r as AmountOn, s as AmountRefusal, t as Artifact, u as AssetIdError, v as AssetIdRefusal, w as AssetNamespace, x as AssetOn, y as AssetPart, z as AssetRef, B as AssetScale, D as AssetSwapId, E as AtomicDecimal, F as AuctionMarketRef, G as AuctionProvenance, H as BITCOIN_RAILS, J as BTC_ASSET_PART, K as BitcoinRail, M as CORRIDORS, T as CORRIDOR_PASS, U as CardMarketRef, V as CorridorId, W as CorridorKind, X as DepositArtifact, Y as DisplayDecimal, Z as Endpoint, _ as Ep, $ as Hex, a0 as LOCKUP_OWNER, a1 as MarketBackend, a2 as MarketRef, a3 as OFFER_SWAP_ID_PREFIX, a4 as Outcome, a5 as ParsedAssetId, a6 as Quote, a7 as QuoteLeg, a8 as RAILS, a9 as RFQ_SWAP_ID_PREFIX, aa as RailOf, ab as RankedBid, ac as RawState, ad as RecordedArtifact, ae as RecordedEndpoint, af as RecordedInstrument, ag as RecordedLeg, ah as RestoredMarketRef, ai as RfqAmountSide, aj as SnapshotRef, ak as Swap, al as SwapFamily, am as SwapRecordCommon, an as SwapUpdate, ao as Unsubscribe, ap as arkadeAsset, aq as artifactOf, ar as assetPartOf, as as assetSwapIdOf, at as bitcoinNetworkOf, au as btcAssetPart, av as btcOn, aw as corridorOfRail, ax as corridorOutcome, ay as decodeRfqAmount, az as encodeRfqAmount, aA as familyOfSwapId, aB as formatAssetId, aC as fromAtomicDecimal, aD as fromRfqAmountSide, aE as fundsFromWallet, aF as instrumentOf, aG as isAssetId, aH as isAtomicDecimal, aI as isBtcAsset, aJ as isBtcAssetLenient, aK as isNetworkRef, aL as issuanceOf, aM as legOf, aN as offerOutcome, aO as parseAssetId, aP as quoteIdOfSwapId, aQ as railOf, aR as railOfCorridor, aS as readsChain, aT as recordArtifact, aU as recordEndpoint, aV as recordInstrument, aW as recordLeg, aX as recordOutcome, aY as sameAsset, aZ as swapOf, a_ as toAtomicDecimal, a$ as toRfqAmountSide, b0 as toSafeNumber } from './repository-V98jQmTD.js';
|
|
@@ -8,7 +8,7 @@ export { S as SwapRefusal } from './rfq-60PGpQ_x.js';
|
|
|
8
8
|
import * as btc from '@scure/btc-signer';
|
|
9
9
|
import { OnchainProvider, NetworkName, PageRequest, PageResult, IWallet, VHTLC } from '@arkade-os/sdk';
|
|
10
10
|
import { O as OfferSpendChanges, a as OfferSwapFacts, b as OfferSwapSource } from './watch-3pNJbc4T.js';
|
|
11
|
-
import './offer-
|
|
11
|
+
import './offer-Byp0FNO6.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* The alias table, filled from discovery: the inverse of `toDiscoveryLeg`, mapping a card's
|
package/dist/advanced.js
CHANGED
|
@@ -143,7 +143,7 @@ import {
|
|
|
143
143
|
withCanonicalAmount,
|
|
144
144
|
withDepositFate,
|
|
145
145
|
withRfqState
|
|
146
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-RVRXQU2E.js";
|
|
147
147
|
import {
|
|
148
148
|
ACTIVITY_TOKEN,
|
|
149
149
|
CORRIDOR_PASS,
|
|
@@ -158,12 +158,12 @@ import {
|
|
|
158
158
|
onchainCorridor,
|
|
159
159
|
readsChain,
|
|
160
160
|
recordOutcome
|
|
161
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-7FCXWHBU.js";
|
|
162
162
|
import {
|
|
163
163
|
SwapRefusal,
|
|
164
164
|
assertPreimageMatches,
|
|
165
165
|
sealClaimPacket
|
|
166
|
-
} from "./chunk-
|
|
166
|
+
} from "./chunk-AYKAMAP5.js";
|
|
167
167
|
import "./chunk-A3SHHRX4.js";
|
|
168
168
|
|
|
169
169
|
// src/reveal.ts
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
sleep,
|
|
24
24
|
swapSecretsToRecord,
|
|
25
25
|
updateAssetSwapBestEffort
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-AYKAMAP5.js";
|
|
27
27
|
import {
|
|
28
28
|
collectRfqSwaps
|
|
29
29
|
} from "./chunk-A3SHHRX4.js";
|
|
@@ -904,6 +904,13 @@ import {
|
|
|
904
904
|
scriptFromTapLeafScript
|
|
905
905
|
} from "@arkade-os/sdk";
|
|
906
906
|
var TXS_PER_REQUEST = 50;
|
|
907
|
+
var toRestoreTx = (tx) => ({
|
|
908
|
+
type: tx.type.toLowerCase(),
|
|
909
|
+
redeemTxid: tx.key.arkTxid,
|
|
910
|
+
boardingTxid: tx.key.boardingTxid,
|
|
911
|
+
roundTxid: tx.key.commitmentTxid,
|
|
912
|
+
createdAt: Math.floor(tx.createdAt / 1e3)
|
|
913
|
+
});
|
|
907
914
|
async function fetchParsedTxs(indexer, txids) {
|
|
908
915
|
const parsedByTxid = /* @__PURE__ */ new Map();
|
|
909
916
|
if (txids.length === 0) return parsedByTxid;
|
|
@@ -2493,6 +2500,7 @@ export {
|
|
|
2493
2500
|
discoverMarkets,
|
|
2494
2501
|
findMarket,
|
|
2495
2502
|
validatePlan,
|
|
2503
|
+
toRestoreTx,
|
|
2496
2504
|
classifySpend,
|
|
2497
2505
|
spendTxidsOf,
|
|
2498
2506
|
classifyDepositSpend,
|