@arkade-os/swap 0.0.16 → 0.0.17
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 +1101 -1101
- package/dist/{chunk-7N7XO4PY.js → chunk-IRDBAAJZ.js} +74 -7
- package/dist/index.cjs +85 -15
- package/dist/index.d.cts +54 -4
- package/dist/index.d.ts +54 -4
- package/dist/index.js +18 -10
- package/dist/nostr.cjs +1 -0
- package/dist/nostr.js +1 -1
- package/package.json +4 -4
|
@@ -222,6 +222,7 @@ async function classifyOnchainHtlc(chain, input) {
|
|
|
222
222
|
|
|
223
223
|
// src/claimPacket.ts
|
|
224
224
|
import { base64 } from "@scure/base";
|
|
225
|
+
import { concatBytes } from "@scure/btc-signer/utils.js";
|
|
225
226
|
import { gcm } from "@noble/ciphers/aes.js";
|
|
226
227
|
import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
227
228
|
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
@@ -244,12 +245,74 @@ async function sealWithEntropy(input, ephemeralKey, nonce) {
|
|
|
244
245
|
const key = hkdf(sha2562, sharedX, ephemeralPub, HKDF_INFO, 32);
|
|
245
246
|
if (nonce.length !== 12) throw new Error("nonce must be 12 bytes");
|
|
246
247
|
const sealed = gcm(key, nonce, ephemeralPub).encrypt(input.preimage);
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return {
|
|
248
|
+
const ciphertext = new Uint8Array(33 + 12 + sealed.length);
|
|
249
|
+
ciphertext.set(ephemeralPub, 0);
|
|
250
|
+
ciphertext.set(nonce, 33);
|
|
251
|
+
ciphertext.set(sealed, 45);
|
|
252
|
+
return {
|
|
253
|
+
ciphertext: base64.encode(ciphertext),
|
|
254
|
+
packet: base64.encode(
|
|
255
|
+
concatBytes(
|
|
256
|
+
tlv(TLV_CIPHERTEXT, ciphertext),
|
|
257
|
+
tlv(TLV_COVCLAIMD_PUBKEY, input.covclaimdPubkey)
|
|
258
|
+
)
|
|
259
|
+
)
|
|
260
|
+
};
|
|
252
261
|
}
|
|
262
|
+
var TLV_CIPHERTEXT = 1;
|
|
263
|
+
var TLV_ARKADE_SCRIPT = 2;
|
|
264
|
+
var TLV_COVCLAIMD_PUBKEY = 3;
|
|
265
|
+
var COMPRESSED_PUBKEY_LENGTH = 33;
|
|
266
|
+
var SEALED_CIPHERTEXT_LENGTH = 93;
|
|
267
|
+
var CLAIM_PACKET_TYPE = 4;
|
|
268
|
+
var tlv = (type, value) => Uint8Array.from([type, value.length >> 8 & 255, value.length & 255, ...value]);
|
|
269
|
+
var appendArkadeScript = (body, arkadeScript) => Uint8Array.from([...body, ...tlv(TLV_ARKADE_SCRIPT, arkadeScript)]);
|
|
270
|
+
var parseTlv = (data) => {
|
|
271
|
+
let ciphertextLength;
|
|
272
|
+
let hasArkadeScript = false;
|
|
273
|
+
let pubkey;
|
|
274
|
+
let offset = 0;
|
|
275
|
+
while (offset < data.length) {
|
|
276
|
+
if (offset + 3 > data.length) throw new Error("truncated TLV header");
|
|
277
|
+
const type = data[offset];
|
|
278
|
+
const length = data[offset + 1] << 8 | data[offset + 2];
|
|
279
|
+
offset += 3;
|
|
280
|
+
if (offset + length > data.length) {
|
|
281
|
+
throw new Error(`TLV type 0x${type.toString(16)} overruns the buffer`);
|
|
282
|
+
}
|
|
283
|
+
const value = data.subarray(offset, offset + length);
|
|
284
|
+
offset += length;
|
|
285
|
+
if (type === TLV_CIPHERTEXT) ciphertextLength = value.length;
|
|
286
|
+
else if (type === TLV_ARKADE_SCRIPT) hasArkadeScript = true;
|
|
287
|
+
else if (type === TLV_COVCLAIMD_PUBKEY) {
|
|
288
|
+
if (value.length !== COMPRESSED_PUBKEY_LENGTH) {
|
|
289
|
+
throw new Error(
|
|
290
|
+
`covclaimd_pub_key TLV is ${value.length} bytes, want ${COMPRESSED_PUBKEY_LENGTH}`
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
pubkey = value;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return { ciphertextLength, hasArkadeScript, pubkey };
|
|
297
|
+
};
|
|
298
|
+
var claimPacketShape = (b64) => {
|
|
299
|
+
try {
|
|
300
|
+
const raw = base64.decode(b64);
|
|
301
|
+
if (raw.length === SEALED_CIPHERTEXT_LENGTH) return { kind: "ciphertext" };
|
|
302
|
+
const { ciphertextLength, hasArkadeScript, pubkey } = parseTlv(raw);
|
|
303
|
+
if (ciphertextLength !== SEALED_CIPHERTEXT_LENGTH || pubkey === void 0) {
|
|
304
|
+
return { kind: "ciphertext" };
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
kind: "packet",
|
|
308
|
+
body: raw,
|
|
309
|
+
needsArkadeScript: !hasArkadeScript,
|
|
310
|
+
...pubkey ? { covclaimdPubkey: pubkey } : {}
|
|
311
|
+
};
|
|
312
|
+
} catch {
|
|
313
|
+
return { kind: "ciphertext" };
|
|
314
|
+
}
|
|
315
|
+
};
|
|
253
316
|
|
|
254
317
|
// src/lockupContract.ts
|
|
255
318
|
import { hex as hex2 } from "@scure/base";
|
|
@@ -1166,7 +1229,7 @@ async function requestLightningReceive(wallet, arkServerUrl, transport, params)
|
|
|
1166
1229
|
paymentHash,
|
|
1167
1230
|
payoutAddress,
|
|
1168
1231
|
payoutPubkey,
|
|
1169
|
-
claimPacket: claimPacket?.
|
|
1232
|
+
claimPacket: claimPacket?.packet,
|
|
1170
1233
|
amount: params.amount,
|
|
1171
1234
|
amountSide: params.amountSide
|
|
1172
1235
|
})
|
|
@@ -1290,7 +1353,7 @@ async function requestOnchainReceive(wallet, arkServerUrl, transport, params) {
|
|
|
1290
1353
|
payoutAddress,
|
|
1291
1354
|
payoutPubkey,
|
|
1292
1355
|
refundPubkey: params.refundPubkey,
|
|
1293
|
-
claimPacket: claimPacket?.
|
|
1356
|
+
claimPacket: claimPacket?.packet,
|
|
1294
1357
|
amount: params.amount,
|
|
1295
1358
|
amountSide: params.amountSide
|
|
1296
1359
|
})
|
|
@@ -1360,6 +1423,10 @@ export {
|
|
|
1360
1423
|
claimOnchainFill,
|
|
1361
1424
|
classifyOnchainHtlc,
|
|
1362
1425
|
sealClaimPacket,
|
|
1426
|
+
SEALED_CIPHERTEXT_LENGTH,
|
|
1427
|
+
CLAIM_PACKET_TYPE,
|
|
1428
|
+
appendArkadeScript,
|
|
1429
|
+
claimPacketShape,
|
|
1363
1430
|
SWAP_LOCKUP_CONTRACT_TYPE,
|
|
1364
1431
|
SWAP_LOCKUP_CONTRACT_LABEL,
|
|
1365
1432
|
SWAP_LOCKUP_CONTRACT_KIND,
|
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
ASSET_CARRIER_SATS: () => ASSET_CARRIER_SATS,
|
|
36
36
|
AddressMismatch: () => AddressMismatch,
|
|
37
37
|
BTC_ASSET_ID: () => BTC_ASSET_ID,
|
|
38
|
+
CLAIM_PACKET_TYPE: () => CLAIM_PACKET_TYPE,
|
|
38
39
|
CROSS_ASSET_RAIL: () => CROSS_ASSET_RAIL,
|
|
39
40
|
CovclaimdRevealError: () => CovclaimdRevealError,
|
|
40
41
|
InMemoryAssetSwapRepository: () => InMemoryAssetSwapRepository,
|
|
@@ -70,6 +71,7 @@ __export(index_exports, {
|
|
|
70
71
|
RefundNotLocallyPossibleError: () => RefundNotLocallyPossibleError,
|
|
71
72
|
RfqSwapManager: () => RfqSwapManager,
|
|
72
73
|
RfqSwapOriginRequired: () => RfqSwapOriginRequired,
|
|
74
|
+
SEALED_CIPHERTEXT_LENGTH: () => SEALED_CIPHERTEXT_LENGTH,
|
|
73
75
|
SOLO_REFUND_HEADROOM_SECONDS: () => SOLO_REFUND_HEADROOM_SECONDS,
|
|
74
76
|
SOLVER_LIGHTNING_RAIL: () => SOLVER_LIGHTNING_RAIL,
|
|
75
77
|
SOLVER_ONCHAIN_RAIL: () => SOLVER_ONCHAIN_RAIL,
|
|
@@ -78,6 +80,7 @@ __export(index_exports, {
|
|
|
78
80
|
SWAP_LOCKUP_CONTRACT_TYPE: () => SWAP_LOCKUP_CONTRACT_TYPE,
|
|
79
81
|
SwapRefusal: () => SwapRefusal,
|
|
80
82
|
addAssetSwap: () => addAssetSwap,
|
|
83
|
+
appendArkadeScript: () => appendArkadeScript,
|
|
81
84
|
arkadeAssetLeg: () => arkadeAssetLeg,
|
|
82
85
|
arkadeRefunder: () => arkadeRefunder,
|
|
83
86
|
arkadeSwapRequest: () => arkadeSwapRequest,
|
|
@@ -91,6 +94,7 @@ __export(index_exports, {
|
|
|
91
94
|
cancelOffer: () => cancelOffer,
|
|
92
95
|
chainSourceFrom: () => chainSourceFrom,
|
|
93
96
|
claimOnchainFill: () => claimOnchainFill,
|
|
97
|
+
claimPacketShape: () => claimPacketShape,
|
|
94
98
|
claimReceiveLockup: () => claimReceiveLockup,
|
|
95
99
|
classifyDepositSpend: () => classifyDepositSpend,
|
|
96
100
|
classifyOnchainHtlc: () => classifyOnchainHtlc,
|
|
@@ -1090,11 +1094,11 @@ var findMarket = (markets, fromId, toId) => {
|
|
|
1090
1094
|
for (const market of markets) {
|
|
1091
1095
|
for (const side of ["base", "quote"]) {
|
|
1092
1096
|
const asset3 = side === "base" ? market.base_asset : market.quote_asset;
|
|
1093
|
-
if (asset3.id === id) return
|
|
1097
|
+
if (asset3.id === id) return (0, import_solver_discovery.marketLegKey)(market, side);
|
|
1094
1098
|
const canonical = marketAssetId(market, side) ?? "";
|
|
1095
1099
|
const matchesBtc = id === BTC_ASSET_ID && /^arkade:[^/]+\/slip44:(?:0|1)$/.test(canonical);
|
|
1096
1100
|
const matchesAsset = /^[0-9a-f]{68}$/.test(id) && canonical.endsWith(`/asset:${id}`);
|
|
1097
|
-
if (
|
|
1101
|
+
if (matchesBtc || matchesAsset) return (0, import_solver_discovery.marketLegKey)(market, side);
|
|
1098
1102
|
}
|
|
1099
1103
|
}
|
|
1100
1104
|
return id;
|
|
@@ -2260,6 +2264,7 @@ var import_sdk11 = require("@arkade-os/sdk");
|
|
|
2260
2264
|
|
|
2261
2265
|
// src/claimPacket.ts
|
|
2262
2266
|
var import_base8 = require("@scure/base");
|
|
2267
|
+
var import_utils2 = require("@scure/btc-signer/utils.js");
|
|
2263
2268
|
var import_aes = require("@noble/ciphers/aes.js");
|
|
2264
2269
|
var import_secp256k1 = require("@noble/curves/secp256k1.js");
|
|
2265
2270
|
var import_hkdf = require("@noble/hashes/hkdf.js");
|
|
@@ -2282,12 +2287,74 @@ async function sealWithEntropy(input, ephemeralKey, nonce) {
|
|
|
2282
2287
|
const key = (0, import_hkdf.hkdf)(import_sha23.sha256, sharedX, ephemeralPub, HKDF_INFO, 32);
|
|
2283
2288
|
if (nonce.length !== 12) throw new Error("nonce must be 12 bytes");
|
|
2284
2289
|
const sealed = (0, import_aes.gcm)(key, nonce, ephemeralPub).encrypt(input.preimage);
|
|
2285
|
-
const
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
return {
|
|
2290
|
+
const ciphertext = new Uint8Array(33 + 12 + sealed.length);
|
|
2291
|
+
ciphertext.set(ephemeralPub, 0);
|
|
2292
|
+
ciphertext.set(nonce, 33);
|
|
2293
|
+
ciphertext.set(sealed, 45);
|
|
2294
|
+
return {
|
|
2295
|
+
ciphertext: import_base8.base64.encode(ciphertext),
|
|
2296
|
+
packet: import_base8.base64.encode(
|
|
2297
|
+
(0, import_utils2.concatBytes)(
|
|
2298
|
+
tlv2(TLV_CIPHERTEXT, ciphertext),
|
|
2299
|
+
tlv2(TLV_COVCLAIMD_PUBKEY, input.covclaimdPubkey)
|
|
2300
|
+
)
|
|
2301
|
+
)
|
|
2302
|
+
};
|
|
2290
2303
|
}
|
|
2304
|
+
var TLV_CIPHERTEXT = 1;
|
|
2305
|
+
var TLV_ARKADE_SCRIPT = 2;
|
|
2306
|
+
var TLV_COVCLAIMD_PUBKEY = 3;
|
|
2307
|
+
var COMPRESSED_PUBKEY_LENGTH = 33;
|
|
2308
|
+
var SEALED_CIPHERTEXT_LENGTH = 93;
|
|
2309
|
+
var CLAIM_PACKET_TYPE = 4;
|
|
2310
|
+
var tlv2 = (type, value) => Uint8Array.from([type, value.length >> 8 & 255, value.length & 255, ...value]);
|
|
2311
|
+
var appendArkadeScript = (body, arkadeScript) => Uint8Array.from([...body, ...tlv2(TLV_ARKADE_SCRIPT, arkadeScript)]);
|
|
2312
|
+
var parseTlv = (data) => {
|
|
2313
|
+
let ciphertextLength;
|
|
2314
|
+
let hasArkadeScript = false;
|
|
2315
|
+
let pubkey;
|
|
2316
|
+
let offset = 0;
|
|
2317
|
+
while (offset < data.length) {
|
|
2318
|
+
if (offset + 3 > data.length) throw new Error("truncated TLV header");
|
|
2319
|
+
const type = data[offset];
|
|
2320
|
+
const length = data[offset + 1] << 8 | data[offset + 2];
|
|
2321
|
+
offset += 3;
|
|
2322
|
+
if (offset + length > data.length) {
|
|
2323
|
+
throw new Error(`TLV type 0x${type.toString(16)} overruns the buffer`);
|
|
2324
|
+
}
|
|
2325
|
+
const value = data.subarray(offset, offset + length);
|
|
2326
|
+
offset += length;
|
|
2327
|
+
if (type === TLV_CIPHERTEXT) ciphertextLength = value.length;
|
|
2328
|
+
else if (type === TLV_ARKADE_SCRIPT) hasArkadeScript = true;
|
|
2329
|
+
else if (type === TLV_COVCLAIMD_PUBKEY) {
|
|
2330
|
+
if (value.length !== COMPRESSED_PUBKEY_LENGTH) {
|
|
2331
|
+
throw new Error(
|
|
2332
|
+
`covclaimd_pub_key TLV is ${value.length} bytes, want ${COMPRESSED_PUBKEY_LENGTH}`
|
|
2333
|
+
);
|
|
2334
|
+
}
|
|
2335
|
+
pubkey = value;
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
return { ciphertextLength, hasArkadeScript, pubkey };
|
|
2339
|
+
};
|
|
2340
|
+
var claimPacketShape = (b64) => {
|
|
2341
|
+
try {
|
|
2342
|
+
const raw = import_base8.base64.decode(b64);
|
|
2343
|
+
if (raw.length === SEALED_CIPHERTEXT_LENGTH) return { kind: "ciphertext" };
|
|
2344
|
+
const { ciphertextLength, hasArkadeScript, pubkey } = parseTlv(raw);
|
|
2345
|
+
if (ciphertextLength !== SEALED_CIPHERTEXT_LENGTH || pubkey === void 0) {
|
|
2346
|
+
return { kind: "ciphertext" };
|
|
2347
|
+
}
|
|
2348
|
+
return {
|
|
2349
|
+
kind: "packet",
|
|
2350
|
+
body: raw,
|
|
2351
|
+
needsArkadeScript: !hasArkadeScript,
|
|
2352
|
+
...pubkey ? { covclaimdPubkey: pubkey } : {}
|
|
2353
|
+
};
|
|
2354
|
+
} catch {
|
|
2355
|
+
return { kind: "ciphertext" };
|
|
2356
|
+
}
|
|
2357
|
+
};
|
|
2291
2358
|
|
|
2292
2359
|
// src/lockupContract.ts
|
|
2293
2360
|
var import_base9 = require("@scure/base");
|
|
@@ -3187,7 +3254,7 @@ async function requestLightningReceive(wallet, arkServerUrl, transport, params)
|
|
|
3187
3254
|
paymentHash,
|
|
3188
3255
|
payoutAddress,
|
|
3189
3256
|
payoutPubkey,
|
|
3190
|
-
claimPacket: claimPacket?.
|
|
3257
|
+
claimPacket: claimPacket?.packet,
|
|
3191
3258
|
amount: params.amount,
|
|
3192
3259
|
amountSide: params.amountSide
|
|
3193
3260
|
})
|
|
@@ -3311,7 +3378,7 @@ async function requestOnchainReceive(wallet, arkServerUrl, transport, params) {
|
|
|
3311
3378
|
payoutAddress,
|
|
3312
3379
|
payoutPubkey,
|
|
3313
3380
|
refundPubkey: params.refundPubkey,
|
|
3314
|
-
claimPacket: claimPacket?.
|
|
3381
|
+
claimPacket: claimPacket?.packet,
|
|
3315
3382
|
amount: params.amount,
|
|
3316
3383
|
amountSide: params.amountSide
|
|
3317
3384
|
})
|
|
@@ -3429,12 +3496,11 @@ var solverRendezvous = (markets, payoutCorridor, amountSats, fallbackEmulatorPub
|
|
|
3429
3496
|
const encoded = fallbackEmulatorPubkey ? import_base12.hex.encode(fallbackEmulatorPubkey) : void 0;
|
|
3430
3497
|
if (encoded !== void 0 && !XONLY_HEX.test(encoded)) return void 0;
|
|
3431
3498
|
const pinned = encoded;
|
|
3432
|
-
const
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
});
|
|
3499
|
+
const quoteCorridor = payoutCorridor === "lightning" ? "bolt11" : "bitcoin";
|
|
3500
|
+
const isBtc = (id) => id === "btc" || /^\w+:[^/]+\/slip44:(?:0|1)$/.test(id ?? "");
|
|
3501
|
+
const candidates = markets.filter(
|
|
3502
|
+
(market) => marketCorridor(market, "base") === "arkade" && marketCorridor(market, "quote") === quoteCorridor && isBtc(marketAssetId(market, "base")) && isBtc(marketAssetId(market, "quote"))
|
|
3503
|
+
);
|
|
3438
3504
|
for (const market of candidates) {
|
|
3439
3505
|
const rendezvous = rendezvousOf(market, pinned);
|
|
3440
3506
|
if (!rendezvous) continue;
|
|
@@ -5437,6 +5503,7 @@ async function lockupTxids(indexer, record, wantFunding) {
|
|
|
5437
5503
|
ASSET_CARRIER_SATS,
|
|
5438
5504
|
AddressMismatch,
|
|
5439
5505
|
BTC_ASSET_ID,
|
|
5506
|
+
CLAIM_PACKET_TYPE,
|
|
5440
5507
|
CROSS_ASSET_RAIL,
|
|
5441
5508
|
CovclaimdRevealError,
|
|
5442
5509
|
InMemoryAssetSwapRepository,
|
|
@@ -5472,6 +5539,7 @@ async function lockupTxids(indexer, record, wantFunding) {
|
|
|
5472
5539
|
RefundNotLocallyPossibleError,
|
|
5473
5540
|
RfqSwapManager,
|
|
5474
5541
|
RfqSwapOriginRequired,
|
|
5542
|
+
SEALED_CIPHERTEXT_LENGTH,
|
|
5475
5543
|
SOLO_REFUND_HEADROOM_SECONDS,
|
|
5476
5544
|
SOLVER_LIGHTNING_RAIL,
|
|
5477
5545
|
SOLVER_ONCHAIN_RAIL,
|
|
@@ -5480,6 +5548,7 @@ async function lockupTxids(indexer, record, wantFunding) {
|
|
|
5480
5548
|
SWAP_LOCKUP_CONTRACT_TYPE,
|
|
5481
5549
|
SwapRefusal,
|
|
5482
5550
|
addAssetSwap,
|
|
5551
|
+
appendArkadeScript,
|
|
5483
5552
|
arkadeAssetLeg,
|
|
5484
5553
|
arkadeRefunder,
|
|
5485
5554
|
arkadeSwapRequest,
|
|
@@ -5493,6 +5562,7 @@ async function lockupTxids(indexer, record, wantFunding) {
|
|
|
5493
5562
|
cancelOffer,
|
|
5494
5563
|
chainSourceFrom,
|
|
5495
5564
|
claimOnchainFill,
|
|
5565
|
+
claimPacketShape,
|
|
5496
5566
|
claimReceiveLockup,
|
|
5497
5567
|
classifyDepositSpend,
|
|
5498
5568
|
classifyOnchainHtlc,
|
package/dist/index.d.cts
CHANGED
|
@@ -1014,10 +1014,28 @@ interface CrossAssetRailDeps {
|
|
|
1014
1014
|
declare function crossAssetRail(deps: CrossAssetRailDeps): PaymentRail;
|
|
1015
1015
|
|
|
1016
1016
|
interface SealedClaimPacket {
|
|
1017
|
-
/** `ephPub(33) ‖ nonce(12) ‖ ciphertext`, base64 —
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
1017
|
+
/** `ephPub(33) ‖ nonce(12) ‖ ciphertext`, base64 — the bare sealed bytes,
|
|
1018
|
+
* 93 decoded. The older of the two `claim_packet` shapes: a solver holding
|
|
1019
|
+
* it can only hand it to covclaimd over the Reveal API, which needs both
|
|
1020
|
+
* sides pointed at the SAME covclaimd — an agreement nothing on the wire
|
|
1021
|
+
* expresses. Prefer {@link SealedClaimPacket.packet}. */
|
|
1020
1022
|
ciphertext: string;
|
|
1023
|
+
/**
|
|
1024
|
+
* covclaimd's serialised `ClaimPacket` body, base64 — TLV `0x01` ciphertext
|
|
1025
|
+
* and `0x03` covclaimd_pub_key. **This is what `claim_packet` should
|
|
1026
|
+
* carry** (§ 7.1.2: senders SHOULD prefer the packet shape).
|
|
1027
|
+
*
|
|
1028
|
+
* It is what lets the solver stamp the funding transaction as Arkade
|
|
1029
|
+
* extension packet `0x04`, which covclaimd finds on the arkd stream by
|
|
1030
|
+
* itself. The `0x03` TLV is what its filter selects on, so the client alone
|
|
1031
|
+
* chooses which covclaimd — the solver needs none configured or reachable.
|
|
1032
|
+
*
|
|
1033
|
+
* `0x02` arkade_script is deliberately absent: the covenant commits to
|
|
1034
|
+
* `taggedHash("ArkScriptHash", script)`, so the funder holds the only copy
|
|
1035
|
+
* guaranteed to match and appends it. A client deriving its own would add a
|
|
1036
|
+
* way for the two to disagree and strand the claim.
|
|
1037
|
+
*/
|
|
1038
|
+
packet: string;
|
|
1021
1039
|
}
|
|
1022
1040
|
interface ClaimPacketInput {
|
|
1023
1041
|
preimage: Uint8Array;
|
|
@@ -1035,6 +1053,38 @@ interface ClaimPacketInput {
|
|
|
1035
1053
|
* helper, where no consumer reaches it by accident.
|
|
1036
1054
|
*/
|
|
1037
1055
|
declare function sealClaimPacket(input: ClaimPacketInput): Promise<SealedClaimPacket>;
|
|
1056
|
+
/** `ephPub(33) ‖ nonce(12) ‖ preimage(32) ‖ GCM tag(16)` — fixed by the sealing
|
|
1057
|
+
* scheme, and what tells the two `claim_packet` shapes apart: a TLV body needs
|
|
1058
|
+
* 96 bytes to carry this much, so the two lengths cannot collide. */
|
|
1059
|
+
declare const SEALED_CIPHERTEXT_LENGTH = 93;
|
|
1060
|
+
/** The Arkade extension packet type covclaimd scans the arkd tx stream for. */
|
|
1061
|
+
declare const CLAIM_PACKET_TYPE = 4;
|
|
1062
|
+
/**
|
|
1063
|
+
* Stamp the covenant script into a client's packet — the solver's half.
|
|
1064
|
+
*
|
|
1065
|
+
* The covenant commits to `taggedHash("ArkScriptHash", script)`, so its funder
|
|
1066
|
+
* holds the only copy guaranteed to match, which is why a client never sends
|
|
1067
|
+
* `0x02`. Appending rather than rebuilding is safe because covclaimd's
|
|
1068
|
+
* `DeserializeClaim` is an order-agnostic switch: the `0x01, 0x03, 0x02` this
|
|
1069
|
+
* produces and its own `Serialize`'s `0x01, 0x02, 0x03` read back identically.
|
|
1070
|
+
*/
|
|
1071
|
+
declare const appendArkadeScript: (body: Uint8Array, arkadeScript: Uint8Array) => Uint8Array;
|
|
1072
|
+
type ClaimPacketShape = {
|
|
1073
|
+
kind: "ciphertext";
|
|
1074
|
+
} | {
|
|
1075
|
+
kind: "packet";
|
|
1076
|
+
body: Uint8Array;
|
|
1077
|
+
covclaimdPubkey?: Uint8Array;
|
|
1078
|
+
needsArkadeScript: boolean;
|
|
1079
|
+
};
|
|
1080
|
+
/**
|
|
1081
|
+
* Which of the two `claim_packet` shapes a base64 field carries.
|
|
1082
|
+
*
|
|
1083
|
+
* Never throws: anything not unambiguously a packet reads as the legacy bare
|
|
1084
|
+
* ciphertext, which keeps the older Reveal-API path rather than failing a swap
|
|
1085
|
+
* over a field this side may simply not understand.
|
|
1086
|
+
*/
|
|
1087
|
+
declare const claimPacketShape: (b64: string) => ClaimPacketShape;
|
|
1038
1088
|
|
|
1039
1089
|
/**
|
|
1040
1090
|
* `retryable` is the point of the type: a 400 says the packet does not bind to
|
|
@@ -1441,4 +1491,4 @@ interface RfqSwapActivityDeps {
|
|
|
1441
1491
|
*/
|
|
1442
1492
|
declare function rfqSwapActivityInputs(deps: RfqSwapActivityDeps): Promise<SwapActivityInput[]>;
|
|
1443
1493
|
|
|
1444
|
-
export { ASSET_CARRIER_SATS, ArkadeRefundResult, type ArkadeRefunderDeps, AssetSwap, AssetSwapRepository, type AssetSwapRestoreChange, CROSS_ASSET_RAIL, ChainSource, type ClaimArkProvider, type ClaimPacketInput, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, type CrossAssetPhase, type CrossAssetRailDeps, type CrossAssetSwap, type DiscoverMarketsOptions, type FillFunding, IndexedDbAssetSwapRepository, InvoiceFacts, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupContractMissing, type LockupContractReader, type LockupContractWriter, LockupRegistrationFailed, LockupSpendIndexer, LockupVtxo, MARKET_CORRIDORS, type MarketCorridor, type MarketLike, MarketsCacheEntry, OFFER_PACKET_TYPE, type Offer, type OfferContractRetirer, type OfferSwapWatcher, OnchainHtlc, OnchainHtlcParams, OnchainNetwork, type OnchainSendProfile, type PlanError, QUOTE_OPTIONS, RefundArkProvider, type RefundBlockedReason, RefundIndexer, RefundNotLocallyPossibleError, type RegisterAssetSwapRestoreOptions, type RestoreAssetSwapRepositoryOptions, type RestoreAssetSwapRepositoryResult, type RestoreIndexer, type RevealParams, type RfqClaimSecretProjection, type RfqHashlockProjection, type RfqSignerProjection, RfqSwap, type RfqSwapActivityDeps, RfqSwapRecord, RfqSwapState, RfqTransport, SOLVER_LIGHTNING_RAIL, SOLVER_ONCHAIN_RAIL, SWAP_LOCKUP_CONTRACT_KIND, SWAP_LOCKUP_CONTRACT_LABEL, SWAP_LOCKUP_CONTRACT_TYPE, type SealedClaimPacket, type SolverLightningRailDeps, type SolverLightningSend, type SolverOnchainRailDeps, type SolverOnchainSend, type SolverRendezvous, type SpendKind, type SwapActivityInput, SwapSecretsProjection, type Tx, type WatchOfferSwapsParams, arkadeRefunder, awaitLockupFunding, cancelOffer, chainSourceFrom, claimReceiveLockup, classifyDepositSpend, classifySpend, covclaimdClient, createOffer, crossAssetRail, decodeOffer, discoverMarkets, encodeOffer, fillOffer, findMarket, isRfqMarket, lockupContractParams, makeCachedFeedFetch, marketAssetId, marketCorridor, marketPairLabel, offerVtxoScript, onchainSendProfile, pushClaim, registerAssetSwapRestore, registerLockupContract, requestLightningSend, requestOnchainSend, restoreAssetSwapRepository, restoreAssetSwaps, restoreOfferCoverage, retireSettledOfferContracts, revealClaimPacket, revealFieldsFromScript, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, sealClaimPacket, senderIdentityForSwapRecord, solverLightningRail, solverLightningRendezvous, solverOnchainRail, solverOnchainRendezvous, solverRendezvous, spendTxidsOf, spendUpdate, swapActivityResolver, swapPrograms, validatePlan, watchOfferSwaps };
|
|
1494
|
+
export { ASSET_CARRIER_SATS, ArkadeRefundResult, type ArkadeRefunderDeps, AssetSwap, AssetSwapRepository, type AssetSwapRestoreChange, CLAIM_PACKET_TYPE, CROSS_ASSET_RAIL, ChainSource, type ClaimArkProvider, type ClaimPacketInput, type ClaimPacketShape, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, type CrossAssetPhase, type CrossAssetRailDeps, type CrossAssetSwap, type DiscoverMarketsOptions, type FillFunding, IndexedDbAssetSwapRepository, InvoiceFacts, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupContractMissing, type LockupContractReader, type LockupContractWriter, LockupRegistrationFailed, LockupSpendIndexer, LockupVtxo, MARKET_CORRIDORS, type MarketCorridor, type MarketLike, MarketsCacheEntry, OFFER_PACKET_TYPE, type Offer, type OfferContractRetirer, type OfferSwapWatcher, OnchainHtlc, OnchainHtlcParams, OnchainNetwork, type OnchainSendProfile, type PlanError, QUOTE_OPTIONS, RefundArkProvider, type RefundBlockedReason, RefundIndexer, RefundNotLocallyPossibleError, type RegisterAssetSwapRestoreOptions, type RestoreAssetSwapRepositoryOptions, type RestoreAssetSwapRepositoryResult, type RestoreIndexer, type RevealParams, type RfqClaimSecretProjection, type RfqHashlockProjection, type RfqSignerProjection, RfqSwap, type RfqSwapActivityDeps, RfqSwapRecord, RfqSwapState, RfqTransport, SEALED_CIPHERTEXT_LENGTH, SOLVER_LIGHTNING_RAIL, SOLVER_ONCHAIN_RAIL, SWAP_LOCKUP_CONTRACT_KIND, SWAP_LOCKUP_CONTRACT_LABEL, SWAP_LOCKUP_CONTRACT_TYPE, type SealedClaimPacket, type SolverLightningRailDeps, type SolverLightningSend, type SolverOnchainRailDeps, type SolverOnchainSend, type SolverRendezvous, type SpendKind, type SwapActivityInput, SwapSecretsProjection, type Tx, type WatchOfferSwapsParams, appendArkadeScript, arkadeRefunder, awaitLockupFunding, cancelOffer, chainSourceFrom, claimPacketShape, claimReceiveLockup, classifyDepositSpend, classifySpend, covclaimdClient, createOffer, crossAssetRail, decodeOffer, discoverMarkets, encodeOffer, fillOffer, findMarket, isRfqMarket, lockupContractParams, makeCachedFeedFetch, marketAssetId, marketCorridor, marketPairLabel, offerVtxoScript, onchainSendProfile, pushClaim, registerAssetSwapRestore, registerLockupContract, requestLightningSend, requestOnchainSend, restoreAssetSwapRepository, restoreAssetSwaps, restoreOfferCoverage, retireSettledOfferContracts, revealClaimPacket, revealFieldsFromScript, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, sealClaimPacket, senderIdentityForSwapRecord, solverLightningRail, solverLightningRendezvous, solverOnchainRail, solverOnchainRendezvous, solverRendezvous, spendTxidsOf, spendUpdate, swapActivityResolver, swapPrograms, validatePlan, watchOfferSwaps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1014,10 +1014,28 @@ interface CrossAssetRailDeps {
|
|
|
1014
1014
|
declare function crossAssetRail(deps: CrossAssetRailDeps): PaymentRail;
|
|
1015
1015
|
|
|
1016
1016
|
interface SealedClaimPacket {
|
|
1017
|
-
/** `ephPub(33) ‖ nonce(12) ‖ ciphertext`, base64 —
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
1017
|
+
/** `ephPub(33) ‖ nonce(12) ‖ ciphertext`, base64 — the bare sealed bytes,
|
|
1018
|
+
* 93 decoded. The older of the two `claim_packet` shapes: a solver holding
|
|
1019
|
+
* it can only hand it to covclaimd over the Reveal API, which needs both
|
|
1020
|
+
* sides pointed at the SAME covclaimd — an agreement nothing on the wire
|
|
1021
|
+
* expresses. Prefer {@link SealedClaimPacket.packet}. */
|
|
1020
1022
|
ciphertext: string;
|
|
1023
|
+
/**
|
|
1024
|
+
* covclaimd's serialised `ClaimPacket` body, base64 — TLV `0x01` ciphertext
|
|
1025
|
+
* and `0x03` covclaimd_pub_key. **This is what `claim_packet` should
|
|
1026
|
+
* carry** (§ 7.1.2: senders SHOULD prefer the packet shape).
|
|
1027
|
+
*
|
|
1028
|
+
* It is what lets the solver stamp the funding transaction as Arkade
|
|
1029
|
+
* extension packet `0x04`, which covclaimd finds on the arkd stream by
|
|
1030
|
+
* itself. The `0x03` TLV is what its filter selects on, so the client alone
|
|
1031
|
+
* chooses which covclaimd — the solver needs none configured or reachable.
|
|
1032
|
+
*
|
|
1033
|
+
* `0x02` arkade_script is deliberately absent: the covenant commits to
|
|
1034
|
+
* `taggedHash("ArkScriptHash", script)`, so the funder holds the only copy
|
|
1035
|
+
* guaranteed to match and appends it. A client deriving its own would add a
|
|
1036
|
+
* way for the two to disagree and strand the claim.
|
|
1037
|
+
*/
|
|
1038
|
+
packet: string;
|
|
1021
1039
|
}
|
|
1022
1040
|
interface ClaimPacketInput {
|
|
1023
1041
|
preimage: Uint8Array;
|
|
@@ -1035,6 +1053,38 @@ interface ClaimPacketInput {
|
|
|
1035
1053
|
* helper, where no consumer reaches it by accident.
|
|
1036
1054
|
*/
|
|
1037
1055
|
declare function sealClaimPacket(input: ClaimPacketInput): Promise<SealedClaimPacket>;
|
|
1056
|
+
/** `ephPub(33) ‖ nonce(12) ‖ preimage(32) ‖ GCM tag(16)` — fixed by the sealing
|
|
1057
|
+
* scheme, and what tells the two `claim_packet` shapes apart: a TLV body needs
|
|
1058
|
+
* 96 bytes to carry this much, so the two lengths cannot collide. */
|
|
1059
|
+
declare const SEALED_CIPHERTEXT_LENGTH = 93;
|
|
1060
|
+
/** The Arkade extension packet type covclaimd scans the arkd tx stream for. */
|
|
1061
|
+
declare const CLAIM_PACKET_TYPE = 4;
|
|
1062
|
+
/**
|
|
1063
|
+
* Stamp the covenant script into a client's packet — the solver's half.
|
|
1064
|
+
*
|
|
1065
|
+
* The covenant commits to `taggedHash("ArkScriptHash", script)`, so its funder
|
|
1066
|
+
* holds the only copy guaranteed to match, which is why a client never sends
|
|
1067
|
+
* `0x02`. Appending rather than rebuilding is safe because covclaimd's
|
|
1068
|
+
* `DeserializeClaim` is an order-agnostic switch: the `0x01, 0x03, 0x02` this
|
|
1069
|
+
* produces and its own `Serialize`'s `0x01, 0x02, 0x03` read back identically.
|
|
1070
|
+
*/
|
|
1071
|
+
declare const appendArkadeScript: (body: Uint8Array, arkadeScript: Uint8Array) => Uint8Array;
|
|
1072
|
+
type ClaimPacketShape = {
|
|
1073
|
+
kind: "ciphertext";
|
|
1074
|
+
} | {
|
|
1075
|
+
kind: "packet";
|
|
1076
|
+
body: Uint8Array;
|
|
1077
|
+
covclaimdPubkey?: Uint8Array;
|
|
1078
|
+
needsArkadeScript: boolean;
|
|
1079
|
+
};
|
|
1080
|
+
/**
|
|
1081
|
+
* Which of the two `claim_packet` shapes a base64 field carries.
|
|
1082
|
+
*
|
|
1083
|
+
* Never throws: anything not unambiguously a packet reads as the legacy bare
|
|
1084
|
+
* ciphertext, which keeps the older Reveal-API path rather than failing a swap
|
|
1085
|
+
* over a field this side may simply not understand.
|
|
1086
|
+
*/
|
|
1087
|
+
declare const claimPacketShape: (b64: string) => ClaimPacketShape;
|
|
1038
1088
|
|
|
1039
1089
|
/**
|
|
1040
1090
|
* `retryable` is the point of the type: a 400 says the packet does not bind to
|
|
@@ -1441,4 +1491,4 @@ interface RfqSwapActivityDeps {
|
|
|
1441
1491
|
*/
|
|
1442
1492
|
declare function rfqSwapActivityInputs(deps: RfqSwapActivityDeps): Promise<SwapActivityInput[]>;
|
|
1443
1493
|
|
|
1444
|
-
export { ASSET_CARRIER_SATS, ArkadeRefundResult, type ArkadeRefunderDeps, AssetSwap, AssetSwapRepository, type AssetSwapRestoreChange, CROSS_ASSET_RAIL, ChainSource, type ClaimArkProvider, type ClaimPacketInput, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, type CrossAssetPhase, type CrossAssetRailDeps, type CrossAssetSwap, type DiscoverMarketsOptions, type FillFunding, IndexedDbAssetSwapRepository, InvoiceFacts, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupContractMissing, type LockupContractReader, type LockupContractWriter, LockupRegistrationFailed, LockupSpendIndexer, LockupVtxo, MARKET_CORRIDORS, type MarketCorridor, type MarketLike, MarketsCacheEntry, OFFER_PACKET_TYPE, type Offer, type OfferContractRetirer, type OfferSwapWatcher, OnchainHtlc, OnchainHtlcParams, OnchainNetwork, type OnchainSendProfile, type PlanError, QUOTE_OPTIONS, RefundArkProvider, type RefundBlockedReason, RefundIndexer, RefundNotLocallyPossibleError, type RegisterAssetSwapRestoreOptions, type RestoreAssetSwapRepositoryOptions, type RestoreAssetSwapRepositoryResult, type RestoreIndexer, type RevealParams, type RfqClaimSecretProjection, type RfqHashlockProjection, type RfqSignerProjection, RfqSwap, type RfqSwapActivityDeps, RfqSwapRecord, RfqSwapState, RfqTransport, SOLVER_LIGHTNING_RAIL, SOLVER_ONCHAIN_RAIL, SWAP_LOCKUP_CONTRACT_KIND, SWAP_LOCKUP_CONTRACT_LABEL, SWAP_LOCKUP_CONTRACT_TYPE, type SealedClaimPacket, type SolverLightningRailDeps, type SolverLightningSend, type SolverOnchainRailDeps, type SolverOnchainSend, type SolverRendezvous, type SpendKind, type SwapActivityInput, SwapSecretsProjection, type Tx, type WatchOfferSwapsParams, arkadeRefunder, awaitLockupFunding, cancelOffer, chainSourceFrom, claimReceiveLockup, classifyDepositSpend, classifySpend, covclaimdClient, createOffer, crossAssetRail, decodeOffer, discoverMarkets, encodeOffer, fillOffer, findMarket, isRfqMarket, lockupContractParams, makeCachedFeedFetch, marketAssetId, marketCorridor, marketPairLabel, offerVtxoScript, onchainSendProfile, pushClaim, registerAssetSwapRestore, registerLockupContract, requestLightningSend, requestOnchainSend, restoreAssetSwapRepository, restoreAssetSwaps, restoreOfferCoverage, retireSettledOfferContracts, revealClaimPacket, revealFieldsFromScript, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, sealClaimPacket, senderIdentityForSwapRecord, solverLightningRail, solverLightningRendezvous, solverOnchainRail, solverOnchainRendezvous, solverRendezvous, spendTxidsOf, spendUpdate, swapActivityResolver, swapPrograms, validatePlan, watchOfferSwaps };
|
|
1494
|
+
export { ASSET_CARRIER_SATS, ArkadeRefundResult, type ArkadeRefunderDeps, AssetSwap, AssetSwapRepository, type AssetSwapRestoreChange, CLAIM_PACKET_TYPE, CROSS_ASSET_RAIL, ChainSource, type ClaimArkProvider, type ClaimPacketInput, type ClaimPacketShape, type CovclaimdClient, type CovclaimdInfo, CovclaimdRevealError, type CrossAssetPhase, type CrossAssetRailDeps, type CrossAssetSwap, type DiscoverMarketsOptions, type FillFunding, IndexedDbAssetSwapRepository, InvoiceFacts, type LightningReceiveProfile, type LightningSendProfile, LockupAmountMismatchError, LockupContractMissing, type LockupContractReader, type LockupContractWriter, LockupRegistrationFailed, LockupSpendIndexer, LockupVtxo, MARKET_CORRIDORS, type MarketCorridor, type MarketLike, MarketsCacheEntry, OFFER_PACKET_TYPE, type Offer, type OfferContractRetirer, type OfferSwapWatcher, OnchainHtlc, OnchainHtlcParams, OnchainNetwork, type OnchainSendProfile, type PlanError, QUOTE_OPTIONS, RefundArkProvider, type RefundBlockedReason, RefundIndexer, RefundNotLocallyPossibleError, type RegisterAssetSwapRestoreOptions, type RestoreAssetSwapRepositoryOptions, type RestoreAssetSwapRepositoryResult, type RestoreIndexer, type RevealParams, type RfqClaimSecretProjection, type RfqHashlockProjection, type RfqSignerProjection, RfqSwap, type RfqSwapActivityDeps, RfqSwapRecord, RfqSwapState, RfqTransport, SEALED_CIPHERTEXT_LENGTH, SOLVER_LIGHTNING_RAIL, SOLVER_ONCHAIN_RAIL, SWAP_LOCKUP_CONTRACT_KIND, SWAP_LOCKUP_CONTRACT_LABEL, SWAP_LOCKUP_CONTRACT_TYPE, type SealedClaimPacket, type SolverLightningRailDeps, type SolverLightningSend, type SolverOnchainRailDeps, type SolverOnchainSend, type SolverRendezvous, type SpendKind, type SwapActivityInput, SwapSecretsProjection, type Tx, type WatchOfferSwapsParams, appendArkadeScript, arkadeRefunder, awaitLockupFunding, cancelOffer, chainSourceFrom, claimPacketShape, claimReceiveLockup, classifyDepositSpend, classifySpend, covclaimdClient, createOffer, crossAssetRail, decodeOffer, discoverMarkets, encodeOffer, fillOffer, findMarket, isRfqMarket, lockupContractParams, makeCachedFeedFetch, marketAssetId, marketCorridor, marketPairLabel, offerVtxoScript, onchainSendProfile, pushClaim, registerAssetSwapRestore, registerLockupContract, requestLightningSend, requestOnchainSend, restoreAssetSwapRepository, restoreAssetSwaps, restoreOfferCoverage, retireSettledOfferContracts, revealClaimPacket, revealFieldsFromScript, rfqClaimSecretOf, rfqSecretsProfile, rfqSignerOf, rfqSwapActivityInputs, sealClaimPacket, senderIdentityForSwapRecord, solverLightningRail, solverLightningRendezvous, solverOnchainRail, solverOnchainRendezvous, solverRendezvous, spendTxidsOf, spendUpdate, swapActivityResolver, swapPrograms, validatePlan, watchOfferSwaps };
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
ARKADE_ASSET,
|
|
3
3
|
ARKADE_BTC,
|
|
4
4
|
AddressMismatch,
|
|
5
|
+
CLAIM_PACKET_TYPE,
|
|
5
6
|
L1_NETWORKS,
|
|
6
7
|
LIGHTNING_BTC,
|
|
7
8
|
LIGHTNING_RECEIVE_PAIR,
|
|
@@ -21,11 +22,13 @@ import {
|
|
|
21
22
|
ONCHAIN_SEND_PAIR,
|
|
22
23
|
RFQ_REFUSAL_ERROR_CODES,
|
|
23
24
|
RFQ_TERMINAL_STATES,
|
|
25
|
+
SEALED_CIPHERTEXT_LENGTH,
|
|
24
26
|
SOLO_REFUND_HEADROOM_SECONDS,
|
|
25
27
|
SWAP_LOCKUP_CONTRACT_KIND,
|
|
26
28
|
SWAP_LOCKUP_CONTRACT_LABEL,
|
|
27
29
|
SWAP_LOCKUP_CONTRACT_TYPE,
|
|
28
30
|
SwapRefusal,
|
|
31
|
+
appendArkadeScript,
|
|
29
32
|
arkadeAssetLeg,
|
|
30
33
|
arkadeSwapRequest,
|
|
31
34
|
assertFundable,
|
|
@@ -34,6 +37,7 @@ import {
|
|
|
34
37
|
buildHtlcClaim,
|
|
35
38
|
buildHtlcRefund,
|
|
36
39
|
claimOnchainFill,
|
|
40
|
+
claimPacketShape,
|
|
37
41
|
classifyOnchainHtlc,
|
|
38
42
|
deriveLightningReceive,
|
|
39
43
|
deriveOnchainReceive,
|
|
@@ -67,7 +71,7 @@ import {
|
|
|
67
71
|
unilateralRefundWithoutReceiverDelay,
|
|
68
72
|
verifyLockupAddress,
|
|
69
73
|
verifyReceiveInvoice
|
|
70
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-IRDBAAJZ.js";
|
|
71
75
|
import {
|
|
72
76
|
InMemoryAssetSwapRepository,
|
|
73
77
|
marketsCacheKey
|
|
@@ -847,6 +851,7 @@ import {
|
|
|
847
851
|
bestMarket,
|
|
848
852
|
discover,
|
|
849
853
|
isNetwork,
|
|
854
|
+
marketLegKey,
|
|
850
855
|
sideLimits
|
|
851
856
|
} from "@arkade-os/solver-discovery";
|
|
852
857
|
import { isSubdust } from "@arkade-os/sdk";
|
|
@@ -992,11 +997,11 @@ var findMarket = (markets, fromId, toId) => {
|
|
|
992
997
|
for (const market of markets) {
|
|
993
998
|
for (const side of ["base", "quote"]) {
|
|
994
999
|
const asset2 = side === "base" ? market.base_asset : market.quote_asset;
|
|
995
|
-
if (asset2.id === id) return
|
|
1000
|
+
if (asset2.id === id) return marketLegKey(market, side);
|
|
996
1001
|
const canonical = marketAssetId(market, side) ?? "";
|
|
997
1002
|
const matchesBtc = id === BTC_ASSET_ID && /^arkade:[^/]+\/slip44:(?:0|1)$/.test(canonical);
|
|
998
1003
|
const matchesAsset = /^[0-9a-f]{68}$/.test(id) && canonical.endsWith(`/asset:${id}`);
|
|
999
|
-
if (
|
|
1004
|
+
if (matchesBtc || matchesAsset) return marketLegKey(market, side);
|
|
1000
1005
|
}
|
|
1001
1006
|
}
|
|
1002
1007
|
return id;
|
|
@@ -1941,7 +1946,7 @@ var chainSourceFrom = (provider, network) => {
|
|
|
1941
1946
|
};
|
|
1942
1947
|
|
|
1943
1948
|
// src/payment/rendezvous.ts
|
|
1944
|
-
import {
|
|
1949
|
+
import { sideLimits as sideLimits2 } from "@arkade-os/solver-discovery";
|
|
1945
1950
|
import { hex as hex8 } from "@scure/base";
|
|
1946
1951
|
var XONLY_HEX = /^[0-9a-f]{64}$/;
|
|
1947
1952
|
var rendezvousOf = (market, pinned) => {
|
|
@@ -1964,12 +1969,11 @@ var solverRendezvous = (markets, payoutCorridor, amountSats, fallbackEmulatorPub
|
|
|
1964
1969
|
const encoded = fallbackEmulatorPubkey ? hex8.encode(fallbackEmulatorPubkey) : void 0;
|
|
1965
1970
|
if (encoded !== void 0 && !XONLY_HEX.test(encoded)) return void 0;
|
|
1966
1971
|
const pinned = encoded;
|
|
1967
|
-
const
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
});
|
|
1972
|
+
const quoteCorridor = payoutCorridor === "lightning" ? "bolt11" : "bitcoin";
|
|
1973
|
+
const isBtc = (id) => id === "btc" || /^\w+:[^/]+\/slip44:(?:0|1)$/.test(id ?? "");
|
|
1974
|
+
const candidates = markets.filter(
|
|
1975
|
+
(market) => marketCorridor(market, "base") === "arkade" && marketCorridor(market, "quote") === quoteCorridor && isBtc(marketAssetId(market, "base")) && isBtc(marketAssetId(market, "quote"))
|
|
1976
|
+
);
|
|
1973
1977
|
for (const market of candidates) {
|
|
1974
1978
|
const rendezvous = rendezvousOf(market, pinned);
|
|
1975
1979
|
if (!rendezvous) continue;
|
|
@@ -4005,6 +4009,7 @@ export {
|
|
|
4005
4009
|
ASSET_CARRIER_SATS,
|
|
4006
4010
|
AddressMismatch,
|
|
4007
4011
|
BTC_ASSET_ID,
|
|
4012
|
+
CLAIM_PACKET_TYPE,
|
|
4008
4013
|
CROSS_ASSET_RAIL,
|
|
4009
4014
|
CovclaimdRevealError,
|
|
4010
4015
|
InMemoryAssetSwapRepository,
|
|
@@ -4040,6 +4045,7 @@ export {
|
|
|
4040
4045
|
RefundNotLocallyPossibleError,
|
|
4041
4046
|
RfqSwapManager,
|
|
4042
4047
|
RfqSwapOriginRequired,
|
|
4048
|
+
SEALED_CIPHERTEXT_LENGTH,
|
|
4043
4049
|
SOLO_REFUND_HEADROOM_SECONDS,
|
|
4044
4050
|
SOLVER_LIGHTNING_RAIL,
|
|
4045
4051
|
SOLVER_ONCHAIN_RAIL,
|
|
@@ -4048,6 +4054,7 @@ export {
|
|
|
4048
4054
|
SWAP_LOCKUP_CONTRACT_TYPE,
|
|
4049
4055
|
SwapRefusal,
|
|
4050
4056
|
addAssetSwap,
|
|
4057
|
+
appendArkadeScript,
|
|
4051
4058
|
arkadeAssetLeg,
|
|
4052
4059
|
arkadeRefunder,
|
|
4053
4060
|
arkadeSwapRequest,
|
|
@@ -4061,6 +4068,7 @@ export {
|
|
|
4061
4068
|
cancelOffer,
|
|
4062
4069
|
chainSourceFrom,
|
|
4063
4070
|
claimOnchainFill,
|
|
4071
|
+
claimPacketShape,
|
|
4064
4072
|
claimReceiveLockup,
|
|
4065
4073
|
classifyDepositSpend,
|
|
4066
4074
|
classifyOnchainHtlc,
|
package/dist/nostr.cjs
CHANGED
|
@@ -62,6 +62,7 @@ var import_sdk3 = require("@arkade-os/sdk");
|
|
|
62
62
|
|
|
63
63
|
// src/claimPacket.ts
|
|
64
64
|
var import_base2 = require("@scure/base");
|
|
65
|
+
var import_utils = require("@scure/btc-signer/utils.js");
|
|
65
66
|
var import_aes = require("@noble/ciphers/aes.js");
|
|
66
67
|
var import_secp256k1 = require("@noble/curves/secp256k1.js");
|
|
67
68
|
var import_hkdf = require("@noble/hashes/hkdf.js");
|
package/dist/nostr.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkade-os/swap",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Client-side Arkade Intents asset swaps: discover markets, quote, create/track/cancel offers, restore from chain.",
|
|
6
6
|
"repository": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"author": "Arkade-OS",
|
|
65
65
|
"license": "MIT",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@arkade-os/solver-discovery": "0.2.
|
|
67
|
+
"@arkade-os/solver-discovery": "0.2.4",
|
|
68
68
|
"@noble/ciphers": "2.1.1",
|
|
69
69
|
"@noble/curves": "2.0.1",
|
|
70
70
|
"@noble/hashes": "2.0.1",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"lint": "biome format src test",
|
|
96
96
|
"test": "vitest run --exclude test/e2e",
|
|
97
97
|
"test:unit": "vitest run --exclude test/e2e",
|
|
98
|
-
"test:integration": "vitest run
|
|
99
|
-
"test:integration:rfq": "vitest run test/e2e/rfq
|
|
98
|
+
"test:integration": "vitest run --exclude \"test/e2e/rfq*.test.ts\" test/e2e/",
|
|
99
|
+
"test:integration:rfq": "vitest run test/e2e/rfq",
|
|
100
100
|
"smoke:dist": "node scripts/smoke-dist.mjs"
|
|
101
101
|
}
|
|
102
102
|
}
|