@arkade-os/swap 0.1.10 → 0.1.12
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 +58 -0
- package/dist/advanced.cjs +1058 -414
- package/dist/advanced.d.cts +7 -64
- package/dist/advanced.d.ts +7 -64
- package/dist/advanced.js +29 -5
- package/dist/{chunk-AUJDREZN.js → chunk-CIDVLDDM.js} +1 -1
- package/dist/{chunk-FWRDAL73.js → chunk-F3BGKWIB.js} +758 -104
- package/dist/{chunk-LCO6AJOS.js → chunk-ISKJIONJ.js} +58 -285
- package/dist/{chunk-2HQZLIVX.js → chunk-JBTU7Y6M.js} +1 -1
- package/dist/chunk-UXK7YDA4.js +568 -0
- package/dist/{chunk-6RJVT65W.js → chunk-VPVSSBY2.js} +2 -4
- package/dist/index.cjs +1045 -414
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +15 -5
- package/dist/{lockupContract-BTTRVwOt.d.cts → lockupContract-B1mr672c.d.cts} +1 -1
- package/dist/{lockupContract-aFarhlxj.d.ts → lockupContract-BRpk0NxT.d.ts} +1 -1
- package/dist/node/index.d.cts +18 -18
- package/dist/node/index.d.ts +18 -18
- package/dist/nostr.cjs +276 -302
- package/dist/nostr.d.cts +20 -2
- package/dist/nostr.d.ts +20 -2
- package/dist/nostr.js +21 -357
- package/dist/{offerFillPlan-CJC5tnEd.d.ts → offerFillPlan-BMZXiVMB.d.ts} +213 -28
- package/dist/{offerFillPlan-FmyaQoYT.d.cts → offerFillPlan-CqJerwXd.d.cts} +213 -28
- package/dist/openRfq-Dx-vxOzl.d.cts +32 -0
- package/dist/openRfq-Dx-vxOzl.d.ts +32 -0
- package/dist/openRfqTransport-MQZ7JWYN.js +9 -0
- package/dist/protocol.cjs +301 -322
- package/dist/protocol.d.cts +5 -5
- package/dist/protocol.d.ts +5 -5
- package/dist/protocol.js +6 -8
- package/dist/repositories/realm/index.d.cts +1 -1
- package/dist/repositories/realm/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/{repository-CwwhIAEd.d.cts → repository-CFC0fHAy.d.cts} +26 -26
- package/dist/{repository-DO6QKxBx.d.ts → repository-suGldzOK.d.ts} +26 -26
- package/dist/rfq-contract.cjs +3 -6
- package/dist/rfq-contract.d.cts +3 -4
- package/dist/rfq-contract.d.ts +3 -4
- package/dist/rfq-contract.js +3 -5
- package/dist/transportErrors-DZuZqnF4.d.cts +8 -0
- package/dist/transportErrors-DZuZqnF4.d.ts +8 -0
- package/dist/{verify-ENO36VPK.js → verify-HU5COTNO.js} +3 -3
- package/dist/{watch-_fZSgx_l.d.ts → watch-C2z6Onak.d.ts} +1 -1
- package/dist/{watch-DpDSP2tu.d.cts → watch-CpYjItYX.d.cts} +1 -1
- package/package.json +3 -3
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ASSET_SWAP_BASELINE,
|
|
3
|
+
ASSET_SWAP_DIRECTED,
|
|
3
4
|
ASSET_SWAP_V2,
|
|
4
|
-
ASSET_SWAP_V3,
|
|
5
|
-
ASSET_SWAP_V4,
|
|
6
5
|
RFQ_CONTRACT_VERSIONS_KEY,
|
|
7
6
|
RFQ_CONTRACT_VERSION_KEY,
|
|
8
7
|
RFQ_CONTRACT_VERSION_UNSUPPORTED
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VPVSSBY2.js";
|
|
10
9
|
import {
|
|
11
10
|
collectAssetSwaps
|
|
12
11
|
} from "./chunk-A3SHHRX4.js";
|
|
@@ -14,127 +13,8 @@ import {
|
|
|
14
13
|
// src/program.ts
|
|
15
14
|
import { arkade } from "@arkade-os/sdk";
|
|
16
15
|
|
|
17
|
-
// src/contracts/asset-swap.json
|
|
18
|
-
var
|
|
19
|
-
formatVersion: 1,
|
|
20
|
-
contractName: "AssetSwap",
|
|
21
|
-
constructorInputs: [
|
|
22
|
-
{
|
|
23
|
-
name: "receiver",
|
|
24
|
-
type: "pubkey"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: "amount",
|
|
28
|
-
type: "int"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: "assetTxid",
|
|
32
|
-
type: "bytes32"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: "assetGroupIndex",
|
|
36
|
-
type: "int"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "user",
|
|
40
|
-
type: "pubkey"
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
functions: [
|
|
44
|
-
{
|
|
45
|
-
name: "fulfill",
|
|
46
|
-
arkade: {
|
|
47
|
-
inputs: [],
|
|
48
|
-
asm: [
|
|
49
|
-
"OP_PUSHCURRENTINPUTINDEX",
|
|
50
|
-
"OP_DUP",
|
|
51
|
-
"<assetTxid>",
|
|
52
|
-
"<assetGroupIndex>",
|
|
53
|
-
"OP_INSPECTOUTASSETLOOKUP",
|
|
54
|
-
"OP_VERIFY",
|
|
55
|
-
"<amount>",
|
|
56
|
-
"OP_GREATERTHANOREQUAL",
|
|
57
|
-
"OP_VERIFY",
|
|
58
|
-
"OP_INSPECTOUTPUTSCRIPTPUBKEY",
|
|
59
|
-
"1",
|
|
60
|
-
"OP_NUMEQUALVERIFY",
|
|
61
|
-
"<receiver>",
|
|
62
|
-
"OP_EQUAL"
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
leaves: [
|
|
66
|
-
{
|
|
67
|
-
name: "fulfill",
|
|
68
|
-
witness: [
|
|
69
|
-
{
|
|
70
|
-
name: "serverSig",
|
|
71
|
-
type: "signature",
|
|
72
|
-
encoding: "schnorr-64",
|
|
73
|
-
injected: true
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: "emulatorSig",
|
|
77
|
-
type: "signature",
|
|
78
|
-
encoding: "schnorr-64",
|
|
79
|
-
injected: true
|
|
80
|
-
}
|
|
81
|
-
],
|
|
82
|
-
asm: [
|
|
83
|
-
"<SERVER_KEY>",
|
|
84
|
-
"OP_CHECKSIGVERIFY",
|
|
85
|
-
"<EMULATOR_KEY:fulfill>",
|
|
86
|
-
"OP_CHECKSIG"
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
name: "cancel",
|
|
93
|
-
leaves: [
|
|
94
|
-
{
|
|
95
|
-
name: "cancel",
|
|
96
|
-
witness: [
|
|
97
|
-
{
|
|
98
|
-
name: "userSig",
|
|
99
|
-
type: "signature",
|
|
100
|
-
encoding: "schnorr-64"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: "serverSig",
|
|
104
|
-
type: "signature",
|
|
105
|
-
encoding: "schnorr-64",
|
|
106
|
-
injected: true
|
|
107
|
-
}
|
|
108
|
-
],
|
|
109
|
-
asm: [
|
|
110
|
-
"<user>",
|
|
111
|
-
"OP_CHECKSIGVERIFY",
|
|
112
|
-
"<SERVER_KEY>",
|
|
113
|
-
"OP_CHECKSIG"
|
|
114
|
-
]
|
|
115
|
-
}
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
],
|
|
119
|
-
source: {
|
|
120
|
-
entry: "asset-swap.ark",
|
|
121
|
-
files: {
|
|
122
|
-
"asset-swap.ark": "pragma arkade ^0.1.0;\n\n// The output at this input's index pays `receiver` at least `amount` of the asset.\n// Coordination of who funds it lives outside the contract.\ncontract AssetSwap(\n pubkey receiver,\n int amount,\n bytes32 assetTxid,\n int assetGroupIndex,\n pubkey user\n) {\n function fulfill() {\n int i = this.activeInputIndex;\n require(tx.outputs[i].assets.lookup(assetTxid, assetGroupIndex) >= amount);\n let paid = tx.outputs[i].script;\n require(paid.version == 1);\n require(paid.program == receiver);\n }\n\n function cancel(signature userSig, signature serverSig) tapscript {\n require(checkMultisig([user, server], [userSig, serverSig], 2));\n }\n}\n"
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
compiler: {
|
|
126
|
-
name: "arkadec",
|
|
127
|
-
version: "0.1.0-rc.1",
|
|
128
|
-
options: {
|
|
129
|
-
optimize: true
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
updatedAt: "2026-11-02T17:43:42.615113722+00:00",
|
|
133
|
-
fingerprint: "sha256:e2b80add6237f6c7e2c69a96ae46d55abe6de5f71c3718106f4d5b22ac9e6d0a"
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// src/contracts/asset-swap-v4.json
|
|
137
|
-
var asset_swap_v4_default = {
|
|
16
|
+
// src/contracts/asset-swap-directed.json
|
|
17
|
+
var asset_swap_directed_default = {
|
|
138
18
|
formatVersion: 1,
|
|
139
19
|
contractName: "AssetSwap",
|
|
140
20
|
constructorInputs: [
|
|
@@ -247,9 +127,9 @@ var asset_swap_v4_default = {
|
|
|
247
127
|
}
|
|
248
128
|
],
|
|
249
129
|
source: {
|
|
250
|
-
entry: "asset-swap-
|
|
130
|
+
entry: "asset-swap-directed.ark",
|
|
251
131
|
files: {
|
|
252
|
-
"asset-swap-
|
|
132
|
+
"asset-swap-directed.ark": "pragma arkade ^0.1.0;\n\n// The output at this input's index pays `receiver` at least `amount` of the asset,\n// and only `taker` can make that spend.\ncontract AssetSwap(\n pubkey receiver,\n int amount,\n bytes32 assetTxid,\n int assetGroupIndex,\n pubkey user,\n pubkey taker\n) {\n function fulfill() {\n int i = this.activeInputIndex;\n require(tx.outputs[i].assets.lookup(assetTxid, assetGroupIndex) >= amount);\n let paid = tx.outputs[i].script;\n require(paid.version == 1);\n require(paid.program == receiver);\n }\n\n // Replaces the synthesized collaborative leaf: the quoting solver is a third\n // conjunct, so an observer who reads the deposit cannot complete it.\n function fulfill(signature takerSig, signature serverSig, signature emulatorSig) tapscript {\n require(checkMultisig([taker, server, emulator], [takerSig, serverSig, emulatorSig], 3));\n }\n\n function cancel(signature userSig, signature serverSig) tapscript {\n require(checkMultisig([user, server], [userSig, serverSig], 2));\n }\n}\n"
|
|
253
133
|
}
|
|
254
134
|
},
|
|
255
135
|
compiler: {
|
|
@@ -263,116 +143,8 @@ var asset_swap_v4_default = {
|
|
|
263
143
|
fingerprint: "sha256:d830de32cd1d286a0a1fac698ff114a6c8ef5338a69f9f813717d1038ab2fb4a"
|
|
264
144
|
};
|
|
265
145
|
|
|
266
|
-
// src/contracts/sats-swap.json
|
|
267
|
-
var
|
|
268
|
-
formatVersion: 1,
|
|
269
|
-
contractName: "SatsSwap",
|
|
270
|
-
constructorInputs: [
|
|
271
|
-
{
|
|
272
|
-
name: "receiver",
|
|
273
|
-
type: "pubkey"
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
name: "amount",
|
|
277
|
-
type: "int"
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
name: "user",
|
|
281
|
-
type: "pubkey"
|
|
282
|
-
}
|
|
283
|
-
],
|
|
284
|
-
functions: [
|
|
285
|
-
{
|
|
286
|
-
name: "fulfill",
|
|
287
|
-
arkade: {
|
|
288
|
-
inputs: [],
|
|
289
|
-
asm: [
|
|
290
|
-
"OP_PUSHCURRENTINPUTINDEX",
|
|
291
|
-
"OP_DUP",
|
|
292
|
-
"OP_INSPECTOUTPUTVALUE",
|
|
293
|
-
"<amount>",
|
|
294
|
-
"OP_GREATERTHANOREQUAL",
|
|
295
|
-
"OP_VERIFY",
|
|
296
|
-
"OP_INSPECTOUTPUTSCRIPTPUBKEY",
|
|
297
|
-
"1",
|
|
298
|
-
"OP_NUMEQUALVERIFY",
|
|
299
|
-
"<receiver>",
|
|
300
|
-
"OP_EQUAL"
|
|
301
|
-
]
|
|
302
|
-
},
|
|
303
|
-
leaves: [
|
|
304
|
-
{
|
|
305
|
-
name: "fulfill",
|
|
306
|
-
witness: [
|
|
307
|
-
{
|
|
308
|
-
name: "serverSig",
|
|
309
|
-
type: "signature",
|
|
310
|
-
encoding: "schnorr-64",
|
|
311
|
-
injected: true
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
name: "emulatorSig",
|
|
315
|
-
type: "signature",
|
|
316
|
-
encoding: "schnorr-64",
|
|
317
|
-
injected: true
|
|
318
|
-
}
|
|
319
|
-
],
|
|
320
|
-
asm: [
|
|
321
|
-
"<SERVER_KEY>",
|
|
322
|
-
"OP_CHECKSIGVERIFY",
|
|
323
|
-
"<EMULATOR_KEY:fulfill>",
|
|
324
|
-
"OP_CHECKSIG"
|
|
325
|
-
]
|
|
326
|
-
}
|
|
327
|
-
]
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
name: "cancel",
|
|
331
|
-
leaves: [
|
|
332
|
-
{
|
|
333
|
-
name: "cancel",
|
|
334
|
-
witness: [
|
|
335
|
-
{
|
|
336
|
-
name: "userSig",
|
|
337
|
-
type: "signature",
|
|
338
|
-
encoding: "schnorr-64"
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
name: "serverSig",
|
|
342
|
-
type: "signature",
|
|
343
|
-
encoding: "schnorr-64",
|
|
344
|
-
injected: true
|
|
345
|
-
}
|
|
346
|
-
],
|
|
347
|
-
asm: [
|
|
348
|
-
"<user>",
|
|
349
|
-
"OP_CHECKSIGVERIFY",
|
|
350
|
-
"<SERVER_KEY>",
|
|
351
|
-
"OP_CHECKSIG"
|
|
352
|
-
]
|
|
353
|
-
}
|
|
354
|
-
]
|
|
355
|
-
}
|
|
356
|
-
],
|
|
357
|
-
source: {
|
|
358
|
-
entry: "sats-swap.ark",
|
|
359
|
-
files: {
|
|
360
|
-
"sats-swap.ark": "pragma arkade ^0.1.0;\n\n// The output at this input's index pays `receiver` at least `amount` sats.\n// Coordination of who funds it lives outside the contract.\ncontract SatsSwap(\n pubkey receiver,\n int amount,\n pubkey user\n) {\n function fulfill() {\n int i = this.activeInputIndex;\n require(tx.outputs[i].value >= amount);\n let paid = tx.outputs[i].script;\n require(paid.version == 1);\n require(paid.program == receiver);\n }\n\n function cancel(signature userSig, signature serverSig) tapscript {\n require(checkMultisig([user, server], [userSig, serverSig], 2));\n }\n}\n"
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
compiler: {
|
|
364
|
-
name: "arkadec",
|
|
365
|
-
version: "0.1.0-rc.1",
|
|
366
|
-
options: {
|
|
367
|
-
optimize: true
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
updatedAt: "2026-11-02T17:43:42.616824535+00:00",
|
|
371
|
-
fingerprint: "sha256:d7a60ab2178ede40a2e4867816689ea022641531cc662b562bebd7caa1ef96c4"
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
// src/contracts/sats-swap-v4.json
|
|
375
|
-
var sats_swap_v4_default = {
|
|
146
|
+
// src/contracts/sats-swap-directed.json
|
|
147
|
+
var sats_swap_directed_default = {
|
|
376
148
|
formatVersion: 1,
|
|
377
149
|
contractName: "SatsSwap",
|
|
378
150
|
constructorInputs: [
|
|
@@ -474,9 +246,9 @@ var sats_swap_v4_default = {
|
|
|
474
246
|
}
|
|
475
247
|
],
|
|
476
248
|
source: {
|
|
477
|
-
entry: "sats-swap-
|
|
249
|
+
entry: "sats-swap-directed.ark",
|
|
478
250
|
files: {
|
|
479
|
-
"sats-swap-
|
|
251
|
+
"sats-swap-directed.ark": "pragma arkade ^0.1.0;\n\n// The output at this input's index pays `receiver` at least `amount` sats,\n// and only `taker` can make that spend.\ncontract SatsSwap(\n pubkey receiver,\n int amount,\n pubkey user,\n pubkey taker\n) {\n function fulfill() {\n int i = this.activeInputIndex;\n require(tx.outputs[i].value >= amount);\n let paid = tx.outputs[i].script;\n require(paid.version == 1);\n require(paid.program == receiver);\n }\n\n function fulfill(signature takerSig, signature serverSig, signature emulatorSig) tapscript {\n require(checkMultisig([taker, server, emulator], [takerSig, serverSig, emulatorSig], 3));\n }\n\n function cancel(signature userSig, signature serverSig) tapscript {\n require(checkMultisig([user, server], [userSig, serverSig], 2));\n }\n}\n"
|
|
480
252
|
}
|
|
481
253
|
},
|
|
482
254
|
compiler: {
|
|
@@ -567,39 +339,23 @@ var swap_want_btc_program_v1_default = {
|
|
|
567
339
|
|
|
568
340
|
// src/program.ts
|
|
569
341
|
var swapPrograms = {
|
|
570
|
-
wantAsset: arkade.programFromArtifact(asset_swap_default),
|
|
571
|
-
wantBtc: arkade.programFromArtifact(sats_swap_default)
|
|
572
|
-
};
|
|
573
|
-
var legacySwapPrograms = {
|
|
574
342
|
wantAsset: arkade.parseArtifact(swap_want_asset_program_v1_default),
|
|
575
343
|
wantBtc: arkade.parseArtifact(swap_want_btc_program_v1_default)
|
|
576
344
|
};
|
|
577
345
|
var directedSwapPrograms = {
|
|
578
|
-
wantAsset: arkade.programFromArtifact(
|
|
579
|
-
wantBtc: arkade.programFromArtifact(
|
|
346
|
+
wantAsset: arkade.programFromArtifact(asset_swap_directed_default),
|
|
347
|
+
wantBtc: arkade.programFromArtifact(sats_swap_directed_default)
|
|
580
348
|
};
|
|
581
349
|
var sharedArgs = ({ user, server, exitDelay }) => ({
|
|
582
350
|
user,
|
|
583
351
|
server,
|
|
584
352
|
...exitDelay && { exitDelay }
|
|
585
353
|
});
|
|
586
|
-
var refuseTaker = (version, { taker }) => {
|
|
587
|
-
if (taker !== void 0) throw new Error(`${version} binds no taker key`);
|
|
588
|
-
};
|
|
589
|
-
var v3Args = (inputs) => ({
|
|
590
|
-
receiver: inputs.receiver,
|
|
591
|
-
amount: inputs.amount,
|
|
592
|
-
...inputs.asset && {
|
|
593
|
-
assetTxid: inputs.asset.txid,
|
|
594
|
-
assetGroupIndex: inputs.asset.groupIndex
|
|
595
|
-
},
|
|
596
|
-
...sharedArgs(inputs)
|
|
597
|
-
});
|
|
598
354
|
var ASSET_SWAP_CONTRACTS = {
|
|
599
355
|
[ASSET_SWAP_V2]: {
|
|
600
|
-
programs:
|
|
356
|
+
programs: swapPrograms,
|
|
601
357
|
args: (inputs) => {
|
|
602
|
-
|
|
358
|
+
if (inputs.taker !== void 0) throw new Error(`${ASSET_SWAP_V2} binds no taker key`);
|
|
603
359
|
return {
|
|
604
360
|
makerWP: inputs.receiver,
|
|
605
361
|
wantAmount: inputs.amount,
|
|
@@ -611,23 +367,26 @@ var ASSET_SWAP_CONTRACTS = {
|
|
|
611
367
|
};
|
|
612
368
|
}
|
|
613
369
|
},
|
|
614
|
-
[
|
|
615
|
-
programs: swapPrograms,
|
|
616
|
-
args: (inputs) => {
|
|
617
|
-
refuseTaker(ASSET_SWAP_V3, inputs);
|
|
618
|
-
return v3Args(inputs);
|
|
619
|
-
}
|
|
620
|
-
},
|
|
621
|
-
[ASSET_SWAP_V4]: {
|
|
370
|
+
[ASSET_SWAP_DIRECTED]: {
|
|
622
371
|
programs: directedSwapPrograms,
|
|
623
372
|
args: (inputs) => {
|
|
624
|
-
if (inputs.taker === void 0)
|
|
625
|
-
|
|
373
|
+
if (inputs.taker === void 0)
|
|
374
|
+
throw new Error(`${ASSET_SWAP_DIRECTED} needs a taker key`);
|
|
375
|
+
return {
|
|
376
|
+
receiver: inputs.receiver,
|
|
377
|
+
amount: inputs.amount,
|
|
378
|
+
...inputs.asset && {
|
|
379
|
+
assetTxid: inputs.asset.txid,
|
|
380
|
+
assetGroupIndex: inputs.asset.groupIndex
|
|
381
|
+
},
|
|
382
|
+
...sharedArgs(inputs),
|
|
383
|
+
taker: inputs.taker
|
|
384
|
+
};
|
|
626
385
|
}
|
|
627
386
|
}
|
|
628
387
|
};
|
|
629
|
-
var ASSET_SWAP_CONTRACT_VERSIONS = [
|
|
630
|
-
var ASSET_SWAP_DERIVABLE_VERSIONS = [
|
|
388
|
+
var ASSET_SWAP_CONTRACT_VERSIONS = [ASSET_SWAP_DIRECTED];
|
|
389
|
+
var ASSET_SWAP_DERIVABLE_VERSIONS = [ASSET_SWAP_DIRECTED, ASSET_SWAP_V2];
|
|
631
390
|
var assetSwapContractVersion = (id) => {
|
|
632
391
|
if (id === void 0) return ASSET_SWAP_BASELINE;
|
|
633
392
|
if (Object.hasOwn(ASSET_SWAP_CONTRACTS, id)) return id;
|
|
@@ -982,19 +741,16 @@ function swapProgramBinding(offer, operatorPubkey, contractVersion) {
|
|
|
982
741
|
throw new Error("makerPkScript is not a 34-byte taproot scriptPubKey");
|
|
983
742
|
}
|
|
984
743
|
const directed = offer.taker !== void 0;
|
|
985
|
-
const version = contractVersion ?? (directed ?
|
|
744
|
+
const version = contractVersion ?? (directed ? ASSET_SWAP_DIRECTED : ASSET_SWAP_BASELINE);
|
|
986
745
|
const expected = offer.swapPkScript;
|
|
987
746
|
if (!expected?.length) return bindSwapProgram(offer, operatorPubkey, version);
|
|
988
|
-
const
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
if (pkOf(binding) === funded) return binding;
|
|
993
|
-
}
|
|
994
|
-
return bindSwapProgram(offer, operatorPubkey, directed ? ASSET_SWAP_V4 : version);
|
|
747
|
+
const candidate = directed ? ASSET_SWAP_DIRECTED : ASSET_SWAP_BASELINE;
|
|
748
|
+
const binding = bindSwapProgram(offer, operatorPubkey, candidate);
|
|
749
|
+
if (pkOf(binding) === hex2.encode(expected)) return binding;
|
|
750
|
+
return bindSwapProgram(offer, operatorPubkey, directed ? ASSET_SWAP_DIRECTED : version);
|
|
995
751
|
}
|
|
996
752
|
function bindSwapProgram(offer, operatorPubkey, contractVersion) {
|
|
997
|
-
const { programs, args } = ASSET_SWAP_CONTRACTS[contractVersion];
|
|
753
|
+
const { programs, args } = ASSET_SWAP_CONTRACTS[assetSwapContractVersion(contractVersion)];
|
|
998
754
|
const user = offer.makerPublicKey;
|
|
999
755
|
const assetId = offer.wantAsset;
|
|
1000
756
|
return {
|
|
@@ -2251,6 +2007,20 @@ async function classifyOnchainHtlc(chain, input) {
|
|
|
2251
2007
|
return { phase: "claimable", utxo: best };
|
|
2252
2008
|
}
|
|
2253
2009
|
|
|
2010
|
+
// src/transportErrors.ts
|
|
2011
|
+
var SolverUnavailable = class extends Error {
|
|
2012
|
+
constructor(message, options) {
|
|
2013
|
+
super(message, options);
|
|
2014
|
+
this.name = "SolverUnavailable";
|
|
2015
|
+
}
|
|
2016
|
+
};
|
|
2017
|
+
var SolverResponseInvalid = class extends SolverUnavailable {
|
|
2018
|
+
constructor(message, options) {
|
|
2019
|
+
super(message, options);
|
|
2020
|
+
this.name = "SolverResponseInvalid";
|
|
2021
|
+
}
|
|
2022
|
+
};
|
|
2023
|
+
|
|
2254
2024
|
// src/claimPacket.ts
|
|
2255
2025
|
import { base64 } from "@scure/base";
|
|
2256
2026
|
import { concatBytes as concatBytes2 } from "@scure/btc-signer/utils.js";
|
|
@@ -2704,10 +2474,10 @@ var expectQuote = (payload, rfqId, requestedPair) => {
|
|
|
2704
2474
|
});
|
|
2705
2475
|
}
|
|
2706
2476
|
if (p?.type !== "rfq_quote" || p.rfq_id !== rfqId) {
|
|
2707
|
-
throw new
|
|
2477
|
+
throw new SolverResponseInvalid(`unexpected reply: ${p?.type ?? "no payload"}`);
|
|
2708
2478
|
}
|
|
2709
2479
|
if (requestedPair !== void 0 && p.pair !== requestedPair) {
|
|
2710
|
-
throw new
|
|
2480
|
+
throw new SolverResponseInvalid(
|
|
2711
2481
|
`solver quoted ${JSON.stringify(p.pair)}, not the requested ${requestedPair}`
|
|
2712
2482
|
);
|
|
2713
2483
|
}
|
|
@@ -2731,11 +2501,13 @@ var requestVersionedQuote = async (transport, request, advertised) => {
|
|
|
2731
2501
|
}
|
|
2732
2502
|
const selected = quote[RFQ_CONTRACT_VERSION_KEY];
|
|
2733
2503
|
if (sent !== request && selected !== void 0) {
|
|
2734
|
-
throw new
|
|
2504
|
+
throw new SolverResponseInvalid(
|
|
2505
|
+
`solver chose contract version ${selected}, but none was advertised`
|
|
2506
|
+
);
|
|
2735
2507
|
}
|
|
2736
2508
|
const version = selected ?? ASSET_SWAP_BASELINE;
|
|
2737
2509
|
if (!advertised.includes(version)) {
|
|
2738
|
-
throw new
|
|
2510
|
+
throw new SolverResponseInvalid(
|
|
2739
2511
|
selected === void 0 ? `solver negotiated no contract version; advertised ${advertised.join(", ")}` : `solver chose contract version ${version}, not one of ${advertised.join(", ")}`
|
|
2740
2512
|
);
|
|
2741
2513
|
}
|
|
@@ -3109,7 +2881,7 @@ async function requestArkadeSwap(wallet, transport, params) {
|
|
|
3109
2881
|
if (quote.pair !== pair) {
|
|
3110
2882
|
throw new Error(`solver quoted ${JSON.stringify(quote.pair)}, not the requested ${pair}`);
|
|
3111
2883
|
}
|
|
3112
|
-
const taker = contractVersion ===
|
|
2884
|
+
const taker = contractVersion === ASSET_SWAP_DIRECTED ? (await import("./verify-HU5COTNO.js")).verifyTaker({
|
|
3113
2885
|
attested: transport.attestedResponder,
|
|
3114
2886
|
solverPubkey: quote.solver_pubkey
|
|
3115
2887
|
}) : void 0;
|
|
@@ -3656,7 +3428,6 @@ async function requestOnchainReceive(wallet, transport, params) {
|
|
|
3656
3428
|
|
|
3657
3429
|
export {
|
|
3658
3430
|
swapPrograms,
|
|
3659
|
-
legacySwapPrograms,
|
|
3660
3431
|
ASSET_SWAP_CONTRACT_VERSIONS,
|
|
3661
3432
|
ASSET_SWAP_DERIVABLE_VERSIONS,
|
|
3662
3433
|
assetSwapContractVersion,
|
|
@@ -3736,6 +3507,8 @@ export {
|
|
|
3736
3507
|
awaitOnchainFill,
|
|
3737
3508
|
claimOnchainFill,
|
|
3738
3509
|
classifyOnchainHtlc,
|
|
3510
|
+
SolverUnavailable,
|
|
3511
|
+
SolverResponseInvalid,
|
|
3739
3512
|
bindsClaimAmount,
|
|
3740
3513
|
sealClaimPacket,
|
|
3741
3514
|
SEALED_CIPHERTEXT_LENGTH,
|