@arkade-os/swap 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.cjs +653 -262
- package/dist/advanced.d.cts +9 -8
- package/dist/advanced.d.ts +9 -8
- package/dist/advanced.js +4 -3
- package/dist/{chunk-7BBQ74BG.js → chunk-552GDPBU.js} +484 -128
- package/dist/chunk-5QPJWOCN.js +16 -0
- package/dist/{chunk-QFM55KP2.js → chunk-FQNG4XMF.js} +9 -3
- package/dist/{chunk-SDPNWPGY.js → chunk-I7WEXXZX.js} +27 -16
- package/dist/index.cjs +669 -278
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +4 -3
- package/dist/{lockupContract-CKPFpIt9.d.ts → lockupContract-BUOsghl1.d.ts} +1 -1
- package/dist/{lockupContract-CpJXTjX_.d.cts → lockupContract-DguuT7NK.d.cts} +1 -1
- package/dist/nostr.cjs +290 -17
- package/dist/nostr.d.cts +2 -1
- package/dist/nostr.d.ts +2 -1
- package/dist/nostr.js +2 -1
- package/dist/{offer-Drw1k_jt.d.ts → offer-BhonWuKR.d.ts} +22 -17
- package/dist/{offer-Boxive2u.d.cts → offer-D_qHpWo2.d.cts} +22 -17
- package/dist/{offerFillPlan-BxNkWLtw.d.cts → offerFillPlan-Bp6-z6dS.d.cts} +3 -3
- package/dist/{offerFillPlan-D2N4s7Xe.d.ts → offerFillPlan-_AOLo6kh.d.ts} +3 -3
- package/dist/protocol.cjs +594 -198
- package/dist/protocol.d.cts +9 -8
- package/dist/protocol.d.ts +9 -8
- package/dist/protocol.js +14 -2
- package/dist/repositories/realm/index.d.cts +3 -2
- package/dist/repositories/realm/index.d.ts +3 -2
- package/dist/repositories/sqlite/index.d.cts +3 -2
- package/dist/repositories/sqlite/index.d.ts +3 -2
- package/dist/{repository-DFDNvcZ7.d.cts → repository--pfikw2R.d.cts} +1 -1
- package/dist/{repository-Dn1V17T2.d.ts → repository-CkKK0dGO.d.ts} +1 -1
- package/dist/{rfq-CP-P0PSL.d.ts → rfq-BRpo5uWU.d.cts} +14 -2
- package/dist/{rfq-CP-P0PSL.d.cts → rfq-IzhOCG02.d.ts} +14 -2
- package/dist/rfq-contract.cjs +45 -0
- package/dist/rfq-contract.d.cts +9 -0
- package/dist/rfq-contract.d.ts +9 -0
- package/dist/rfq-contract.js +16 -0
- package/dist/{watch-D-mc_wfD.d.ts → watch-DDNycuUa.d.ts} +1 -1
- package/dist/{watch-DFNMY2K-.d.cts → watch-pvTVFp6-.d.cts} +1 -1
- package/package.json +13 -3
package/dist/advanced.cjs
CHANGED
|
@@ -35,11 +35,248 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
35
35
|
));
|
|
36
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
37
|
|
|
38
|
-
// src/swap
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
"src/swap
|
|
42
|
-
|
|
38
|
+
// src/contracts/asset-swap.json
|
|
39
|
+
var asset_swap_default;
|
|
40
|
+
var init_asset_swap = __esm({
|
|
41
|
+
"src/contracts/asset-swap.json"() {
|
|
42
|
+
asset_swap_default = {
|
|
43
|
+
formatVersion: 1,
|
|
44
|
+
contractName: "AssetSwap",
|
|
45
|
+
constructorInputs: [
|
|
46
|
+
{
|
|
47
|
+
name: "receiver",
|
|
48
|
+
type: "pubkey"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "amount",
|
|
52
|
+
type: "int"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "assetTxid",
|
|
56
|
+
type: "bytes32"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "assetGroupIndex",
|
|
60
|
+
type: "int"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "user",
|
|
64
|
+
type: "pubkey"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
functions: [
|
|
68
|
+
{
|
|
69
|
+
name: "fulfill",
|
|
70
|
+
arkade: {
|
|
71
|
+
inputs: [],
|
|
72
|
+
asm: [
|
|
73
|
+
"OP_PUSHCURRENTINPUTINDEX",
|
|
74
|
+
"OP_DUP",
|
|
75
|
+
"<assetTxid>",
|
|
76
|
+
"<assetGroupIndex>",
|
|
77
|
+
"OP_INSPECTOUTASSETLOOKUP",
|
|
78
|
+
"OP_VERIFY",
|
|
79
|
+
"<amount>",
|
|
80
|
+
"OP_GREATERTHANOREQUAL",
|
|
81
|
+
"OP_VERIFY",
|
|
82
|
+
"OP_INSPECTOUTPUTSCRIPTPUBKEY",
|
|
83
|
+
"1",
|
|
84
|
+
"OP_NUMEQUALVERIFY",
|
|
85
|
+
"<receiver>",
|
|
86
|
+
"OP_EQUAL"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
leaves: [
|
|
90
|
+
{
|
|
91
|
+
name: "fulfill",
|
|
92
|
+
witness: [
|
|
93
|
+
{
|
|
94
|
+
name: "serverSig",
|
|
95
|
+
type: "signature",
|
|
96
|
+
encoding: "schnorr-64",
|
|
97
|
+
injected: true
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "emulatorSig",
|
|
101
|
+
type: "signature",
|
|
102
|
+
encoding: "schnorr-64",
|
|
103
|
+
injected: true
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
asm: [
|
|
107
|
+
"<SERVER_KEY>",
|
|
108
|
+
"OP_CHECKSIGVERIFY",
|
|
109
|
+
"<EMULATOR_KEY:fulfill>",
|
|
110
|
+
"OP_CHECKSIG"
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "cancel",
|
|
117
|
+
leaves: [
|
|
118
|
+
{
|
|
119
|
+
name: "cancel",
|
|
120
|
+
witness: [
|
|
121
|
+
{
|
|
122
|
+
name: "userSig",
|
|
123
|
+
type: "signature",
|
|
124
|
+
encoding: "schnorr-64"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "serverSig",
|
|
128
|
+
type: "signature",
|
|
129
|
+
encoding: "schnorr-64",
|
|
130
|
+
injected: true
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
asm: [
|
|
134
|
+
"<user>",
|
|
135
|
+
"OP_CHECKSIGVERIFY",
|
|
136
|
+
"<SERVER_KEY>",
|
|
137
|
+
"OP_CHECKSIG"
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
source: {
|
|
144
|
+
entry: "asset-swap.ark",
|
|
145
|
+
files: {
|
|
146
|
+
"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"
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
compiler: {
|
|
150
|
+
name: "arkadec",
|
|
151
|
+
version: "0.1.0-rc.1",
|
|
152
|
+
options: {
|
|
153
|
+
optimize: true
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
updatedAt: "2026-11-02T17:43:42.615113722+00:00",
|
|
157
|
+
fingerprint: "sha256:e2b80add6237f6c7e2c69a96ae46d55abe6de5f71c3718106f4d5b22ac9e6d0a"
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// src/contracts/sats-swap.json
|
|
163
|
+
var sats_swap_default;
|
|
164
|
+
var init_sats_swap = __esm({
|
|
165
|
+
"src/contracts/sats-swap.json"() {
|
|
166
|
+
sats_swap_default = {
|
|
167
|
+
formatVersion: 1,
|
|
168
|
+
contractName: "SatsSwap",
|
|
169
|
+
constructorInputs: [
|
|
170
|
+
{
|
|
171
|
+
name: "receiver",
|
|
172
|
+
type: "pubkey"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "amount",
|
|
176
|
+
type: "int"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "user",
|
|
180
|
+
type: "pubkey"
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
functions: [
|
|
184
|
+
{
|
|
185
|
+
name: "fulfill",
|
|
186
|
+
arkade: {
|
|
187
|
+
inputs: [],
|
|
188
|
+
asm: [
|
|
189
|
+
"OP_PUSHCURRENTINPUTINDEX",
|
|
190
|
+
"OP_DUP",
|
|
191
|
+
"OP_INSPECTOUTPUTVALUE",
|
|
192
|
+
"<amount>",
|
|
193
|
+
"OP_GREATERTHANOREQUAL",
|
|
194
|
+
"OP_VERIFY",
|
|
195
|
+
"OP_INSPECTOUTPUTSCRIPTPUBKEY",
|
|
196
|
+
"1",
|
|
197
|
+
"OP_NUMEQUALVERIFY",
|
|
198
|
+
"<receiver>",
|
|
199
|
+
"OP_EQUAL"
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
leaves: [
|
|
203
|
+
{
|
|
204
|
+
name: "fulfill",
|
|
205
|
+
witness: [
|
|
206
|
+
{
|
|
207
|
+
name: "serverSig",
|
|
208
|
+
type: "signature",
|
|
209
|
+
encoding: "schnorr-64",
|
|
210
|
+
injected: true
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: "emulatorSig",
|
|
214
|
+
type: "signature",
|
|
215
|
+
encoding: "schnorr-64",
|
|
216
|
+
injected: true
|
|
217
|
+
}
|
|
218
|
+
],
|
|
219
|
+
asm: [
|
|
220
|
+
"<SERVER_KEY>",
|
|
221
|
+
"OP_CHECKSIGVERIFY",
|
|
222
|
+
"<EMULATOR_KEY:fulfill>",
|
|
223
|
+
"OP_CHECKSIG"
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "cancel",
|
|
230
|
+
leaves: [
|
|
231
|
+
{
|
|
232
|
+
name: "cancel",
|
|
233
|
+
witness: [
|
|
234
|
+
{
|
|
235
|
+
name: "userSig",
|
|
236
|
+
type: "signature",
|
|
237
|
+
encoding: "schnorr-64"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: "serverSig",
|
|
241
|
+
type: "signature",
|
|
242
|
+
encoding: "schnorr-64",
|
|
243
|
+
injected: true
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
asm: [
|
|
247
|
+
"<user>",
|
|
248
|
+
"OP_CHECKSIGVERIFY",
|
|
249
|
+
"<SERVER_KEY>",
|
|
250
|
+
"OP_CHECKSIG"
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
source: {
|
|
257
|
+
entry: "sats-swap.ark",
|
|
258
|
+
files: {
|
|
259
|
+
"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"
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
compiler: {
|
|
263
|
+
name: "arkadec",
|
|
264
|
+
version: "0.1.0-rc.1",
|
|
265
|
+
options: {
|
|
266
|
+
optimize: true
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
updatedAt: "2026-11-02T17:43:42.616824535+00:00",
|
|
270
|
+
fingerprint: "sha256:d7a60ab2178ede40a2e4867816689ea022641531cc662b562bebd7caa1ef96c4"
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// src/legacy/swap-want-asset.program.v1.json
|
|
276
|
+
var swap_want_asset_program_v1_default;
|
|
277
|
+
var init_swap_want_asset_program_v1 = __esm({
|
|
278
|
+
"src/legacy/swap-want-asset.program.v1.json"() {
|
|
279
|
+
swap_want_asset_program_v1_default = {
|
|
43
280
|
version: 1,
|
|
44
281
|
name: "banco-btc-to-asset",
|
|
45
282
|
params: [
|
|
@@ -80,11 +317,11 @@ var init_swap_want_asset_program = __esm({
|
|
|
80
317
|
}
|
|
81
318
|
});
|
|
82
319
|
|
|
83
|
-
// src/swap-want-btc.program.json
|
|
84
|
-
var
|
|
85
|
-
var
|
|
86
|
-
"src/swap-want-btc.program.json"() {
|
|
87
|
-
|
|
320
|
+
// src/legacy/swap-want-btc.program.v1.json
|
|
321
|
+
var swap_want_btc_program_v1_default;
|
|
322
|
+
var init_swap_want_btc_program_v1 = __esm({
|
|
323
|
+
"src/legacy/swap-want-btc.program.v1.json"() {
|
|
324
|
+
swap_want_btc_program_v1_default = {
|
|
88
325
|
version: 1,
|
|
89
326
|
name: "banco-asset-to-btc",
|
|
90
327
|
params: [
|
|
@@ -120,6 +357,80 @@ var init_swap_want_btc_program = __esm({
|
|
|
120
357
|
}
|
|
121
358
|
});
|
|
122
359
|
|
|
360
|
+
// src/rfq-contract.ts
|
|
361
|
+
var RFQ_CONTRACT_VERSIONS_KEY, RFQ_CONTRACT_VERSION_KEY, RFQ_CONTRACT_VERSION_UNSUPPORTED, ASSET_SWAP_V2, ASSET_SWAP_V3, ASSET_SWAP_BASELINE;
|
|
362
|
+
var init_rfq_contract = __esm({
|
|
363
|
+
"src/rfq-contract.ts"() {
|
|
364
|
+
"use strict";
|
|
365
|
+
RFQ_CONTRACT_VERSIONS_KEY = "contract_versions";
|
|
366
|
+
RFQ_CONTRACT_VERSION_KEY = "contract_version";
|
|
367
|
+
RFQ_CONTRACT_VERSION_UNSUPPORTED = "contract_version_unsupported";
|
|
368
|
+
ASSET_SWAP_V2 = "asset-swap-v2";
|
|
369
|
+
ASSET_SWAP_V3 = "asset-swap-v3";
|
|
370
|
+
ASSET_SWAP_BASELINE = ASSET_SWAP_V2;
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
// src/program.ts
|
|
375
|
+
var import_sdk, swapPrograms, legacySwapPrograms, sharedArgs, ASSET_SWAP_CONTRACTS, ASSET_SWAP_CONTRACT_VERSIONS, assetSwapContractVersion;
|
|
376
|
+
var init_program = __esm({
|
|
377
|
+
"src/program.ts"() {
|
|
378
|
+
"use strict";
|
|
379
|
+
import_sdk = require("@arkade-os/sdk");
|
|
380
|
+
init_asset_swap();
|
|
381
|
+
init_sats_swap();
|
|
382
|
+
init_swap_want_asset_program_v1();
|
|
383
|
+
init_swap_want_btc_program_v1();
|
|
384
|
+
init_rfq_contract();
|
|
385
|
+
init_rfq_contract();
|
|
386
|
+
swapPrograms = {
|
|
387
|
+
wantAsset: import_sdk.arkade.programFromArtifact(asset_swap_default),
|
|
388
|
+
wantBtc: import_sdk.arkade.programFromArtifact(sats_swap_default)
|
|
389
|
+
};
|
|
390
|
+
legacySwapPrograms = {
|
|
391
|
+
wantAsset: import_sdk.arkade.parseArtifact(swap_want_asset_program_v1_default),
|
|
392
|
+
wantBtc: import_sdk.arkade.parseArtifact(swap_want_btc_program_v1_default)
|
|
393
|
+
};
|
|
394
|
+
sharedArgs = ({ user, server, exitDelay }) => ({
|
|
395
|
+
user,
|
|
396
|
+
server,
|
|
397
|
+
...exitDelay && { exitDelay }
|
|
398
|
+
});
|
|
399
|
+
ASSET_SWAP_CONTRACTS = {
|
|
400
|
+
[ASSET_SWAP_V2]: {
|
|
401
|
+
programs: legacySwapPrograms,
|
|
402
|
+
args: (inputs) => ({
|
|
403
|
+
makerWP: inputs.receiver,
|
|
404
|
+
wantAmount: inputs.amount,
|
|
405
|
+
...inputs.asset && {
|
|
406
|
+
wantAssetTxid: inputs.asset.txid,
|
|
407
|
+
wantAssetGroupIndex: inputs.asset.groupIndex
|
|
408
|
+
},
|
|
409
|
+
...sharedArgs(inputs)
|
|
410
|
+
})
|
|
411
|
+
},
|
|
412
|
+
[ASSET_SWAP_V3]: {
|
|
413
|
+
programs: swapPrograms,
|
|
414
|
+
args: (inputs) => ({
|
|
415
|
+
receiver: inputs.receiver,
|
|
416
|
+
amount: inputs.amount,
|
|
417
|
+
...inputs.asset && {
|
|
418
|
+
assetTxid: inputs.asset.txid,
|
|
419
|
+
assetGroupIndex: inputs.asset.groupIndex
|
|
420
|
+
},
|
|
421
|
+
...sharedArgs(inputs)
|
|
422
|
+
})
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
ASSET_SWAP_CONTRACT_VERSIONS = [ASSET_SWAP_V3, ASSET_SWAP_V2];
|
|
426
|
+
assetSwapContractVersion = (id) => {
|
|
427
|
+
if (id === void 0) return ASSET_SWAP_BASELINE;
|
|
428
|
+
if (Object.hasOwn(ASSET_SWAP_CONTRACTS, id)) return id;
|
|
429
|
+
throw new Error(`unknown contract version ${id}`);
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
|
|
123
434
|
// src/coverage.ts
|
|
124
435
|
function markIssued(script, issued, options) {
|
|
125
436
|
const scope = options.scope ?? legacyScope;
|
|
@@ -253,27 +564,27 @@ function assertRfqSwapPageFilter(filter) {
|
|
|
253
564
|
throw new RangeError("RFQ history since must be non-negative Unix seconds");
|
|
254
565
|
}
|
|
255
566
|
}
|
|
256
|
-
var
|
|
567
|
+
var import_sdk2, collectAssetSwaps, collectRfqSwaps, collectSwapRecords;
|
|
257
568
|
var init_repository = __esm({
|
|
258
569
|
"src/repository.ts"() {
|
|
259
570
|
"use strict";
|
|
260
|
-
|
|
261
|
-
collectAssetSwaps = (repository) => (0,
|
|
262
|
-
collectRfqSwaps = (repository, filter = {}) => (0,
|
|
571
|
+
import_sdk2 = require("@arkade-os/sdk");
|
|
572
|
+
collectAssetSwaps = (repository) => (0, import_sdk2.collectPages)((page) => repository.getAssetSwapsPage(page));
|
|
573
|
+
collectRfqSwaps = (repository, filter = {}) => (0, import_sdk2.collectPages)(
|
|
263
574
|
(page) => repository.getRfqSwapsPage(filter, page)
|
|
264
575
|
);
|
|
265
|
-
collectSwapRecords = (repository) => (0,
|
|
576
|
+
collectSwapRecords = (repository) => (0, import_sdk2.collectPages)((page) => repository.getSwapRecordsPage(page));
|
|
266
577
|
}
|
|
267
578
|
});
|
|
268
579
|
|
|
269
580
|
// src/store.ts
|
|
270
|
-
var import_base, import_sha2,
|
|
581
|
+
var import_base, import_sha2, import_sdk3, BTC_ASSET_ID, byNewest, getAssetSwapsOrThrow, getAssetSwaps, saveSwapOrThrow, updateAssetSwap, updateAssetSwapBestEffort, swapSecretsToRecord, decodeHex32, PreimageNotRecoverableError, preimageForSwapRecord;
|
|
271
582
|
var init_store = __esm({
|
|
272
583
|
"src/store.ts"() {
|
|
273
584
|
"use strict";
|
|
274
585
|
import_base = require("@scure/base");
|
|
275
586
|
import_sha2 = require("@noble/hashes/sha2.js");
|
|
276
|
-
|
|
587
|
+
import_sdk3 = require("@arkade-os/sdk");
|
|
277
588
|
init_repository();
|
|
278
589
|
BTC_ASSET_ID = "btc";
|
|
279
590
|
byNewest = (a, b) => b.createdAt - a.createdAt;
|
|
@@ -359,7 +670,7 @@ var init_store = __esm({
|
|
|
359
670
|
}
|
|
360
671
|
let preimage;
|
|
361
672
|
try {
|
|
362
|
-
preimage = await (0,
|
|
673
|
+
preimage = await (0, import_sdk3.contractPreimage)(wallet, record.signingDescriptor, { stored, salt });
|
|
363
674
|
} catch (cause) {
|
|
364
675
|
throw new PreimageNotRecoverableError(
|
|
365
676
|
"not-derivable",
|
|
@@ -484,37 +795,60 @@ function withExitClosure(program, exit) {
|
|
|
484
795
|
}
|
|
485
796
|
};
|
|
486
797
|
}
|
|
487
|
-
function swapProgramBinding(offer, operatorPubkey) {
|
|
798
|
+
function swapProgramBinding(offer, operatorPubkey, contractVersion = ASSET_SWAP_BASELINE) {
|
|
488
799
|
if (offer.makerPkScript.length !== FIELDS.makerPkScript.width) {
|
|
489
800
|
throw new Error("makerPkScript is not a 34-byte taproot scriptPubKey");
|
|
490
801
|
}
|
|
802
|
+
const expected = offer.swapPkScript;
|
|
803
|
+
if (!expected?.length) return bindSwapProgram(offer, operatorPubkey, contractVersion);
|
|
804
|
+
const funded = import_base2.hex.encode(expected);
|
|
805
|
+
const order = [
|
|
806
|
+
ASSET_SWAP_BASELINE,
|
|
807
|
+
...ASSET_SWAP_CONTRACT_VERSIONS.filter((v) => v !== ASSET_SWAP_BASELINE)
|
|
808
|
+
];
|
|
809
|
+
for (const version of order) {
|
|
810
|
+
const binding = bindSwapProgram(offer, operatorPubkey, version);
|
|
811
|
+
if (pkOf(binding) === funded) return binding;
|
|
812
|
+
}
|
|
813
|
+
return bindSwapProgram(offer, operatorPubkey, contractVersion);
|
|
814
|
+
}
|
|
815
|
+
function bindSwapProgram(offer, operatorPubkey, contractVersion) {
|
|
816
|
+
const { programs, args } = ASSET_SWAP_CONTRACTS[contractVersion];
|
|
817
|
+
const user = offer.makerPublicKey;
|
|
818
|
+
const assetId = offer.wantAsset;
|
|
491
819
|
return {
|
|
492
|
-
program: withExitClosure(
|
|
493
|
-
|
|
494
|
-
offer.
|
|
495
|
-
|
|
496
|
-
args: {
|
|
497
|
-
makerWP: offer.makerPkScript.subarray(2),
|
|
498
|
-
wantAmount: offer.wantAmount,
|
|
499
|
-
server: operatorPubkey,
|
|
500
|
-
user: offer.makerPublicKey,
|
|
820
|
+
program: withExitClosure(assetId ? programs.wantAsset : programs.wantBtc, offer.exitDelay),
|
|
821
|
+
args: args({
|
|
822
|
+
receiver: offer.makerPkScript.subarray(2),
|
|
823
|
+
amount: offer.wantAmount,
|
|
501
824
|
// internal byte order
|
|
502
|
-
...
|
|
503
|
-
|
|
504
|
-
wantAssetGroupIndex: offer.wantAsset.groupIndex
|
|
825
|
+
...assetId && {
|
|
826
|
+
asset: { txid: assetId.txid.slice().reverse(), groupIndex: assetId.groupIndex }
|
|
505
827
|
},
|
|
828
|
+
user,
|
|
829
|
+
server: operatorPubkey,
|
|
506
830
|
...offer.exitDelay && { exitDelay: offer.exitDelay.value }
|
|
507
|
-
},
|
|
831
|
+
}),
|
|
508
832
|
keys: {
|
|
509
833
|
serverKey: operatorPubkey,
|
|
510
|
-
userKey:
|
|
834
|
+
userKey: user,
|
|
511
835
|
emulatorKey: offer.emulatorPubkey
|
|
512
836
|
}
|
|
513
837
|
};
|
|
514
838
|
}
|
|
515
|
-
function
|
|
516
|
-
|
|
517
|
-
|
|
839
|
+
function compileSwapBinding(binding) {
|
|
840
|
+
let script = compiledBindings.get(binding);
|
|
841
|
+
if (!script) {
|
|
842
|
+
script = new import_sdk4.arkade.ArkadeProgramScript(binding.program, binding.args, binding.keys);
|
|
843
|
+
compiledBindings.set(binding, script);
|
|
844
|
+
}
|
|
845
|
+
return script;
|
|
846
|
+
}
|
|
847
|
+
function pkOf(binding) {
|
|
848
|
+
return import_base2.hex.encode(compileSwapBinding(binding).pkScript);
|
|
849
|
+
}
|
|
850
|
+
function offerContract(offer, operatorPubkey, contractVersion) {
|
|
851
|
+
return compileSwapBinding(swapProgramBinding(offer, operatorPubkey, contractVersion));
|
|
518
852
|
}
|
|
519
853
|
function u64(name, value) {
|
|
520
854
|
if (value < BigInt(0) || value >> BigInt(64) > BigInt(0)) {
|
|
@@ -630,8 +964,8 @@ function decodeOffer(data) {
|
|
|
630
964
|
return {
|
|
631
965
|
swapPkScript: need("swapPkScript"),
|
|
632
966
|
wantAmount: readU64(amount),
|
|
633
|
-
...fields.wantAsset && { wantAsset:
|
|
634
|
-
...fields.offerAsset && { offerAsset:
|
|
967
|
+
...fields.wantAsset && { wantAsset: import_sdk4.asset.AssetId.fromBytes(fields.wantAsset) },
|
|
968
|
+
...fields.offerAsset && { offerAsset: import_sdk4.asset.AssetId.fromBytes(fields.offerAsset) },
|
|
635
969
|
makerPkScript: need("makerPkScript"),
|
|
636
970
|
makerPublicKey: need("makerPublicKey"),
|
|
637
971
|
emulatorPubkey: need("emulatorPubkey"),
|
|
@@ -657,8 +991,11 @@ async function registerOfferContract(wallet, info, binding, operatorPubkey, expe
|
|
|
657
991
|
});
|
|
658
992
|
}
|
|
659
993
|
function offerContractParams(client, binding, operatorPubkey, expectedPkScript) {
|
|
660
|
-
const { program, args, keys } = swapProgramBinding(
|
|
661
|
-
|
|
994
|
+
const { program, args, keys } = swapProgramBinding(
|
|
995
|
+
{ ...binding, swapPkScript: expectedPkScript },
|
|
996
|
+
operatorPubkey
|
|
997
|
+
);
|
|
998
|
+
const contract = new import_sdk4.arkade.ArkadeContract(client, program, args, keys);
|
|
662
999
|
if (import_base2.hex.encode(contract.pkScript) !== import_base2.hex.encode(expectedPkScript)) {
|
|
663
1000
|
throw new Error("derived covenant does not match the offer's swapPkScript");
|
|
664
1001
|
}
|
|
@@ -675,7 +1012,7 @@ async function restoreOfferCoverage(wallet, swaps) {
|
|
|
675
1012
|
wallet.getArkadeInfo({ requireLive: true }),
|
|
676
1013
|
wallet.getContractManager()
|
|
677
1014
|
]);
|
|
678
|
-
const operatorPubkey = import_base2.hex.decode((0,
|
|
1015
|
+
const operatorPubkey = import_base2.hex.decode((0, import_sdk4.toXOnlySignerHex)(info.signerPubkey));
|
|
679
1016
|
const client = await derivingClient(wallet, info, contractManager);
|
|
680
1017
|
const rows = await contractManager.getContracts({
|
|
681
1018
|
script: live.map((swap) => swap.swapPkScript)
|
|
@@ -698,7 +1035,7 @@ async function restoreOfferCoverage(wallet, swaps) {
|
|
|
698
1035
|
params: offerContractParams(
|
|
699
1036
|
client,
|
|
700
1037
|
binding,
|
|
701
|
-
stored ? import_base2.hex.decode((0,
|
|
1038
|
+
stored ? import_base2.hex.decode((0, import_sdk4.toXOnlySignerHex)(stored)) : operatorPubkey,
|
|
702
1039
|
import_base2.hex.decode(swap.swapPkScript)
|
|
703
1040
|
)
|
|
704
1041
|
});
|
|
@@ -742,7 +1079,7 @@ function resolveReceivePkScript(receiveAddress, walletPkScript, hrp, serverPubKe
|
|
|
742
1079
|
if (receiveAddress === void 0) return walletPkScript;
|
|
743
1080
|
let address;
|
|
744
1081
|
try {
|
|
745
|
-
address =
|
|
1082
|
+
address = import_sdk4.ArkAddress.decode(receiveAddress);
|
|
746
1083
|
} catch (cause) {
|
|
747
1084
|
throw new Error("receiveAddress is not a valid Arkade address", { cause });
|
|
748
1085
|
}
|
|
@@ -777,13 +1114,13 @@ async function deriveOffer(wallet, params) {
|
|
|
777
1114
|
wallet.getAddress(),
|
|
778
1115
|
wallet.identity.xOnlyPublicKey()
|
|
779
1116
|
]);
|
|
780
|
-
return { pkScript:
|
|
1117
|
+
return { pkScript: import_sdk4.ArkAddress.decode(address).pkScript, publicKey };
|
|
781
1118
|
})()
|
|
782
1119
|
]);
|
|
783
|
-
const operatorPubKey = import_base2.hex.decode((0,
|
|
784
|
-
const network = (0,
|
|
1120
|
+
const operatorPubKey = import_base2.hex.decode((0, import_sdk4.toXOnlySignerHex)(info.signerPubkey));
|
|
1121
|
+
const network = (0, import_sdk4.networkFromOperatorInfo)(info);
|
|
785
1122
|
const emuKey = import_base2.hex.decode(
|
|
786
|
-
(0,
|
|
1123
|
+
(0, import_sdk4.toXOnlySignerHex)((0, import_sdk4.resolveEmulatorPubkey)(network, params.emulatorPubkey))
|
|
787
1124
|
);
|
|
788
1125
|
const binding = Object.freeze({
|
|
789
1126
|
wantAmount: params.wantAmount,
|
|
@@ -800,7 +1137,7 @@ async function deriveOffer(wallet, params) {
|
|
|
800
1137
|
// checked before registration below. @see assertExitDelay
|
|
801
1138
|
exitDelay: params.noExit ? void 0 : params.exitDelay ? assertExitDelay(params.exitDelay) : serverExitDelay(info.unilateralExitDelay)
|
|
802
1139
|
});
|
|
803
|
-
const script = offerContract(binding, operatorPubKey);
|
|
1140
|
+
const script = offerContract(binding, operatorPubKey, params.contractVersion);
|
|
804
1141
|
const offer = { ...binding, swapPkScript: script.pkScript };
|
|
805
1142
|
const payload = encodeOffer(offer);
|
|
806
1143
|
return Object.freeze({
|
|
@@ -834,7 +1171,7 @@ async function prepareOfferCancel(wallet, offerHex, opts) {
|
|
|
834
1171
|
wallet.getArkadeReader(),
|
|
835
1172
|
wallet.getArkadeBroadcaster()
|
|
836
1173
|
]);
|
|
837
|
-
const client = await
|
|
1174
|
+
const client = await import_sdk4.arkade.Arkade.connect({
|
|
838
1175
|
arkade: { getInfo: async () => info, ...broadcaster },
|
|
839
1176
|
indexer: reader,
|
|
840
1177
|
identity: wallet.identity,
|
|
@@ -844,21 +1181,22 @@ async function prepareOfferCancel(wallet, offerHex, opts) {
|
|
|
844
1181
|
// no `network`: the row lookup is by script and the payout comes from wallet.getAddress()
|
|
845
1182
|
oneShotSubmit: wallet.oneShotSubmit
|
|
846
1183
|
});
|
|
847
|
-
const operatorPubkey = swapAddress ?
|
|
848
|
-
|
|
1184
|
+
const operatorPubkey = swapAddress ? import_sdk4.ArkAddress.decode(swapAddress).serverPubKey : client.serverKey;
|
|
1185
|
+
let binding;
|
|
849
1186
|
let rebuilt;
|
|
850
1187
|
try {
|
|
851
|
-
|
|
1188
|
+
binding = swapProgramBinding(offer, operatorPubkey);
|
|
1189
|
+
rebuilt = compileSwapBinding(binding);
|
|
852
1190
|
} catch (cause) {
|
|
853
1191
|
throw new OfferCovenantMismatchError(import_base2.hex.encode(offer.swapPkScript), { cause });
|
|
854
1192
|
}
|
|
855
1193
|
if (import_base2.hex.encode(rebuilt.pkScript) !== import_base2.hex.encode(offer.swapPkScript)) {
|
|
856
1194
|
throw new OfferCovenantMismatchError(import_base2.hex.encode(offer.swapPkScript));
|
|
857
1195
|
}
|
|
858
|
-
const contract = new
|
|
1196
|
+
const contract = new import_sdk4.arkade.ArkadeContract(client, binding.program, binding.args, binding.keys);
|
|
859
1197
|
const [vtxos, makerAddress] = await Promise.all([contract.getUtxos(), wallet.getAddress()]);
|
|
860
1198
|
const vtxo = resolveDeposit(vtxos, { fundingTxid, fundingOutpoint });
|
|
861
|
-
const makerPkScript =
|
|
1199
|
+
const makerPkScript = import_sdk4.ArkAddress.decode(makerAddress).pkScript;
|
|
862
1200
|
const cancel = contract.functions.cancel().from({ txid: vtxo.txid, vout: vtxo.vout, value: vtxo.value }).to(makerPkScript, BigInt(vtxo.value));
|
|
863
1201
|
for (const a of vtxo.assets ?? []) {
|
|
864
1202
|
cancel.withAsset({
|
|
@@ -876,25 +1214,25 @@ async function prepareOfferCancel(wallet, offerHex, opts) {
|
|
|
876
1214
|
async function connectFillContract(wallet, arkServerUrl, offer, opts = {}) {
|
|
877
1215
|
const { swapAddress, emulator, emulatorPubkey } = opts;
|
|
878
1216
|
const contractManager = await wallet.getContractManager();
|
|
879
|
-
const client = await
|
|
880
|
-
arkade: new
|
|
881
|
-
indexer: new
|
|
1217
|
+
const client = await import_sdk4.arkade.Arkade.connect({
|
|
1218
|
+
arkade: new import_sdk4.RestOperatorProvider(arkServerUrl),
|
|
1219
|
+
indexer: new import_sdk4.RestIndexerProvider(arkServerUrl),
|
|
882
1220
|
identity: wallet.identity,
|
|
883
1221
|
contractManager,
|
|
884
1222
|
...emulator !== void 0 ? {
|
|
885
|
-
emulator: typeof emulator === "string" ? new
|
|
1223
|
+
emulator: typeof emulator === "string" ? new import_sdk4.RestEmulatorProvider(emulator) : emulator
|
|
886
1224
|
} : {},
|
|
887
1225
|
...emulatorPubkey ? { emulatorPubkey } : {}
|
|
888
1226
|
});
|
|
889
|
-
const serverKey = swapAddress ?
|
|
890
|
-
const
|
|
891
|
-
const rebuilt =
|
|
1227
|
+
const serverKey = swapAddress ? import_sdk4.ArkAddress.decode(swapAddress).serverPubKey : client.serverKey;
|
|
1228
|
+
const binding = swapProgramBinding(offer, serverKey);
|
|
1229
|
+
const rebuilt = compileSwapBinding(binding);
|
|
892
1230
|
if (import_base2.hex.encode(rebuilt.pkScript) !== import_base2.hex.encode(offer.swapPkScript)) {
|
|
893
1231
|
throw new Error(
|
|
894
1232
|
"rebuilt covenant does not match the offer's swapPkScript \u2014 the server signing key has likely rotated since funding; pass swapAddress (the funded address) to pin the original key"
|
|
895
1233
|
);
|
|
896
1234
|
}
|
|
897
|
-
return new
|
|
1235
|
+
return new import_sdk4.arkade.ArkadeContract(client, binding.program, binding.args, binding.keys);
|
|
898
1236
|
}
|
|
899
1237
|
function resolveDeposit(vtxos, sel) {
|
|
900
1238
|
const { fundingTxid, fundingOutpoint } = sel;
|
|
@@ -1183,7 +1521,7 @@ function assertScript(script, what) {
|
|
|
1183
1521
|
function assertAssetId(assetId, what) {
|
|
1184
1522
|
if (typeof assetId !== "string") throw new Error(`${what} must be an asset id string`);
|
|
1185
1523
|
try {
|
|
1186
|
-
return
|
|
1524
|
+
return import_sdk4.asset.AssetId.fromString(assetId).toString();
|
|
1187
1525
|
} catch {
|
|
1188
1526
|
throw new Error(`${what} is not a valid asset id`);
|
|
1189
1527
|
}
|
|
@@ -1205,22 +1543,18 @@ function assertFillCoin(coin, what) {
|
|
|
1205
1543
|
toAmount(coin.value, `${what}.value`, "sats", BigInt(1));
|
|
1206
1544
|
assertAssetEntries(coin.assets, what);
|
|
1207
1545
|
}
|
|
1208
|
-
var import_base2, import_utils,
|
|
1546
|
+
var import_base2, import_utils, import_sdk4, compiledBindings, OFFER_PACKET_TYPE, FIELDS, EXIT_TYPES, NAMES, readU64, setRatio, OFFER_CONTRACT_LABEL, OFFER_CONTRACT_KIND, derivingClient, NoSpendableDepositError, OfferCovenantMismatchError, ASSET_CARRIER_SATS, amountOfAsset, U64_MAX, MAX_SAFE_SATS;
|
|
1209
1547
|
var init_offer = __esm({
|
|
1210
1548
|
"src/offer.ts"() {
|
|
1211
1549
|
"use strict";
|
|
1212
1550
|
import_base2 = require("@scure/base");
|
|
1213
1551
|
import_utils = require("@scure/btc-signer/utils.js");
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
init_swap_want_btc_program();
|
|
1552
|
+
import_sdk4 = require("@arkade-os/sdk");
|
|
1553
|
+
init_program();
|
|
1217
1554
|
init_coverage();
|
|
1218
1555
|
init_rfqProfileParts();
|
|
1219
1556
|
init_store();
|
|
1220
|
-
|
|
1221
|
-
wantAsset: import_sdk3.arkade.parseArtifact(swap_want_asset_program_default),
|
|
1222
|
-
wantBtc: import_sdk3.arkade.parseArtifact(swap_want_btc_program_default)
|
|
1223
|
-
};
|
|
1557
|
+
compiledBindings = /* @__PURE__ */ new WeakMap();
|
|
1224
1558
|
OFFER_PACKET_TYPE = 3;
|
|
1225
1559
|
FIELDS = {
|
|
1226
1560
|
swapPkScript: { tag: 1, width: 34 },
|
|
@@ -1244,10 +1578,10 @@ var init_offer = __esm({
|
|
|
1244
1578
|
};
|
|
1245
1579
|
OFFER_CONTRACT_LABEL = "Arkade swap offer";
|
|
1246
1580
|
OFFER_CONTRACT_KIND = "asset-swap-offer";
|
|
1247
|
-
derivingClient = (wallet, info, contractManager) =>
|
|
1581
|
+
derivingClient = (wallet, info, contractManager) => import_sdk4.arkade.Arkade.connect({
|
|
1248
1582
|
arkade: { getInfo: async () => info },
|
|
1249
1583
|
identity: wallet.identity,
|
|
1250
|
-
network: (0,
|
|
1584
|
+
network: (0, import_sdk4.networkFromOperatorInfo)(info),
|
|
1251
1585
|
contractManager
|
|
1252
1586
|
});
|
|
1253
1587
|
NoSpendableDepositError = class extends Error {
|
|
@@ -1267,7 +1601,7 @@ var init_offer = __esm({
|
|
|
1267
1601
|
swapPkScript;
|
|
1268
1602
|
name = "OfferCovenantMismatchError";
|
|
1269
1603
|
};
|
|
1270
|
-
ASSET_CARRIER_SATS = BigInt(
|
|
1604
|
+
ASSET_CARRIER_SATS = BigInt(import_sdk4.ASSET_CARRIER_SATS);
|
|
1271
1605
|
amountOfAsset = (assets, assetId) => {
|
|
1272
1606
|
let total = BigInt(0);
|
|
1273
1607
|
for (const a of assets ?? []) {
|
|
@@ -1287,7 +1621,7 @@ async function registerLockupContract(contracts, script, address, options = {})
|
|
|
1287
1621
|
import_base3.hex.encode(script.pkScript),
|
|
1288
1622
|
() => contracts.createContract({
|
|
1289
1623
|
type: SWAP_LOCKUP_CONTRACT_TYPE,
|
|
1290
|
-
params:
|
|
1624
|
+
params: import_sdk5.VHTLCV2ContractHandler.serializeParams(script.options),
|
|
1291
1625
|
script: import_base3.hex.encode(script.pkScript),
|
|
1292
1626
|
address,
|
|
1293
1627
|
label: SWAP_LOCKUP_CONTRACT_LABEL,
|
|
@@ -1300,18 +1634,18 @@ async function registerLockupContract(contracts, script, address, options = {})
|
|
|
1300
1634
|
}
|
|
1301
1635
|
}
|
|
1302
1636
|
async function lockupContractParams(contracts, lockupAddress) {
|
|
1303
|
-
const script = import_base3.hex.encode(
|
|
1637
|
+
const script = import_base3.hex.encode(import_sdk5.ArkAddress.decode(lockupAddress).pkScript);
|
|
1304
1638
|
const [row] = await contracts.getContracts({ script });
|
|
1305
1639
|
if (!row) throw new LockupContractMissing(lockupAddress, script);
|
|
1306
1640
|
return row.params;
|
|
1307
1641
|
}
|
|
1308
|
-
var import_base3,
|
|
1642
|
+
var import_base3, import_sdk5, SWAP_LOCKUP_CONTRACT_TYPE, SWAP_LOCKUP_CONTRACT_LABEL, SWAP_LOCKUP_CONTRACT_KIND, LockupContractMissing, LockupRegistrationFailed;
|
|
1309
1643
|
var init_lockupContract = __esm({
|
|
1310
1644
|
"src/lockupContract.ts"() {
|
|
1311
1645
|
"use strict";
|
|
1312
1646
|
init_coverage();
|
|
1313
1647
|
import_base3 = require("@scure/base");
|
|
1314
|
-
|
|
1648
|
+
import_sdk5 = require("@arkade-os/sdk");
|
|
1315
1649
|
SWAP_LOCKUP_CONTRACT_TYPE = "vhtlc-v2";
|
|
1316
1650
|
SWAP_LOCKUP_CONTRACT_LABEL = "Arkade RFQ swap lockup";
|
|
1317
1651
|
SWAP_LOCKUP_CONTRACT_KIND = "rfq-swap-lockup";
|
|
@@ -1351,9 +1685,9 @@ function onchainHtlcScript(params, network) {
|
|
|
1351
1685
|
if (params.claimKey.length !== 32 || params.refundKey.length !== 32) {
|
|
1352
1686
|
throw new Error("claimKey and refundKey must be 32-byte x-only keys");
|
|
1353
1687
|
}
|
|
1354
|
-
if (!Number.isInteger(params.refundLocktime) || params.refundLocktime <= 0) {
|
|
1688
|
+
if (!Number.isInteger(params.refundLocktime) || params.refundLocktime <= 0 || params.refundLocktime > 4294967295) {
|
|
1355
1689
|
throw new Error(
|
|
1356
|
-
`refundLocktime must be a positive unix timestamp, got ${params.refundLocktime}`
|
|
1690
|
+
`refundLocktime must be a positive uint32 unix timestamp, got ${params.refundLocktime}`
|
|
1357
1691
|
);
|
|
1358
1692
|
}
|
|
1359
1693
|
if (params.refundLocktime < LOCKTIME_THRESHOLD) {
|
|
@@ -1442,15 +1776,20 @@ async function claimOnchainFill(chain, input) {
|
|
|
1442
1776
|
}
|
|
1443
1777
|
async function classifyOnchainHtlc(chain, input) {
|
|
1444
1778
|
const utxos = await chain.getScriptUtxos(input.htlc.pkScript);
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1779
|
+
const deep = (u) => u.confirmations >= input.minConfirmations;
|
|
1780
|
+
const best = utxos.sort(
|
|
1781
|
+
(a, b) => deep(a) !== deep(b) ? deep(a) ? -1 : 1 : b.amount > a.amount ? 1 : -1
|
|
1782
|
+
)[0];
|
|
1783
|
+
const { funding } = input;
|
|
1784
|
+
let spend = null;
|
|
1785
|
+
if (funding && !utxos.some((u) => u.txid === funding.txid && u.vout === funding.vout)) {
|
|
1786
|
+
try {
|
|
1787
|
+
spend = await chain.getSpendingTx(funding.txid, funding.vout, input.htlc.pkScript);
|
|
1788
|
+
} catch (error) {
|
|
1789
|
+
if (!best) throw error;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
if (spend) {
|
|
1454
1793
|
const preimage = extractPreimage(spend.txHex, input.htlc.paymentHash);
|
|
1455
1794
|
const txid = btc.Transaction.fromRaw(import_base4.hex.decode(spend.txHex), {
|
|
1456
1795
|
allowUnknownInputs: true,
|
|
@@ -1458,13 +1797,14 @@ async function classifyOnchainHtlc(chain, input) {
|
|
|
1458
1797
|
}).id;
|
|
1459
1798
|
return preimage ? { phase: "claimed", txid, preimage } : { phase: "swept", txid };
|
|
1460
1799
|
}
|
|
1800
|
+
if (!best) return { phase: "unfunded" };
|
|
1461
1801
|
if (best.confirmations < input.minConfirmations)
|
|
1462
1802
|
return { phase: "awaiting_confirmations", utxo: best };
|
|
1463
1803
|
const mtp = await chain.getMtp();
|
|
1464
1804
|
if (mtp >= input.htlc.refundLocktime) return { phase: "refundable", utxo: best };
|
|
1465
1805
|
return { phase: "claimable", utxo: best };
|
|
1466
1806
|
}
|
|
1467
|
-
var import_base4, import_sha22, import_legacy, btc,
|
|
1807
|
+
var import_base4, import_sha22, import_legacy, btc, import_sdk6, ONCHAIN_ORDER_MARGIN_SECONDS, ONCHAIN_CLAIM_MARGIN_SECONDS, ONCHAIN_CLAIM_BUMP_SECONDS, MAX_MIN_CONFIRMATIONS, LOCKTIME_THRESHOLD, ONCHAIN_SECONDS_PER_BLOCK, ONCHAIN_DUST_SATS, ONCHAIN_CLAIM_VSIZE, paymentHashOf, h160FromPaymentHash, assertPreimageMatches, gateError, L1_NETWORKS, l1ScriptForAddress, buildLeafSpend, buildHtlcClaim, buildHtlcRefund;
|
|
1468
1808
|
var init_onchainHtlc = __esm({
|
|
1469
1809
|
"src/onchainHtlc.ts"() {
|
|
1470
1810
|
"use strict";
|
|
@@ -1472,7 +1812,7 @@ var init_onchainHtlc = __esm({
|
|
|
1472
1812
|
import_sha22 = require("@noble/hashes/sha2.js");
|
|
1473
1813
|
import_legacy = require("@noble/hashes/legacy.js");
|
|
1474
1814
|
btc = __toESM(require("@scure/btc-signer"), 1);
|
|
1475
|
-
|
|
1815
|
+
import_sdk6 = require("@arkade-os/sdk");
|
|
1476
1816
|
ONCHAIN_ORDER_MARGIN_SECONDS = 2 * 60 * 60;
|
|
1477
1817
|
ONCHAIN_CLAIM_MARGIN_SECONDS = 90 * 60;
|
|
1478
1818
|
ONCHAIN_CLAIM_BUMP_SECONDS = 20 * 60;
|
|
@@ -1672,7 +2012,7 @@ function deriveLightningSend(input) {
|
|
|
1672
2012
|
throw new Error("lightning-send quote is missing profile.receiver_pk_script");
|
|
1673
2013
|
}
|
|
1674
2014
|
const contractParams = {
|
|
1675
|
-
solverPubkey: (0,
|
|
2015
|
+
solverPubkey: (0, import_sdk8.toXOnly)(import_base7.hex.decode(quote.solver_pubkey), "solver key"),
|
|
1676
2016
|
refundLocktime: quote.refund_locktime,
|
|
1677
2017
|
operatorPubkey: input.operatorPubkey,
|
|
1678
2018
|
paymentHash: input.paymentHash,
|
|
@@ -1718,7 +2058,7 @@ function deriveOnchainSend(input) {
|
|
|
1718
2058
|
"onchain-send"
|
|
1719
2059
|
);
|
|
1720
2060
|
const contractParams = {
|
|
1721
|
-
solverPubkey: (0,
|
|
2061
|
+
solverPubkey: (0, import_sdk8.toXOnly)(import_base7.hex.decode(quote.solver_pubkey), "solver key"),
|
|
1722
2062
|
refundLocktime,
|
|
1723
2063
|
operatorPubkey: input.operatorPubkey,
|
|
1724
2064
|
paymentHash: input.paymentHash,
|
|
@@ -1727,7 +2067,7 @@ function deriveOnchainSend(input) {
|
|
|
1727
2067
|
emulatorPubkey: input.emulatorPubkey,
|
|
1728
2068
|
senderPubkey: input.senderPubkey,
|
|
1729
2069
|
receiverPkScript: solverHex(receiverPkScriptHex, "profile.receiver_pk_script"),
|
|
1730
|
-
refundPkScript:
|
|
2070
|
+
refundPkScript: import_sdk8.ArkAddress.decode(input.refundAddress).pkScript
|
|
1731
2071
|
};
|
|
1732
2072
|
const { script, address } = matchQuotedLockup(
|
|
1733
2073
|
quote,
|
|
@@ -1738,7 +2078,7 @@ function deriveOnchainSend(input) {
|
|
|
1738
2078
|
const htlcParams = {
|
|
1739
2079
|
paymentHash: input.paymentHash,
|
|
1740
2080
|
claimKey: input.payoutPubkey,
|
|
1741
|
-
refundKey: (0,
|
|
2081
|
+
refundKey: (0, import_sdk8.toXOnly)(import_base7.hex.decode(htlcPubkey), "solver L1 htlc key"),
|
|
1742
2082
|
refundLocktime: htlcLocktime
|
|
1743
2083
|
};
|
|
1744
2084
|
const htlc = onchainHtlcScript(htlcParams, input.l1Network);
|
|
@@ -1810,7 +2150,7 @@ function deriveOnchainReceive(input) {
|
|
|
1810
2150
|
).matched;
|
|
1811
2151
|
const htlcParams = {
|
|
1812
2152
|
paymentHash: input.paymentHash,
|
|
1813
|
-
claimKey: (0,
|
|
2153
|
+
claimKey: (0, import_sdk8.toXOnly)(import_base7.hex.decode(claimPubkey), "solver L1 claim key"),
|
|
1814
2154
|
refundKey: input.refundPubkey,
|
|
1815
2155
|
refundLocktime: htlcLocktime
|
|
1816
2156
|
};
|
|
@@ -1827,21 +2167,23 @@ function deriveOnchainReceive(input) {
|
|
|
1827
2167
|
minConfirmations
|
|
1828
2168
|
};
|
|
1829
2169
|
}
|
|
1830
|
-
var import_base7, import_solver_discovery, import_legacy2,
|
|
2170
|
+
var import_base7, import_solver_discovery, import_legacy2, import_sdk8, import_sdk9, solverHex, quoteSats, quoteAmountSats, quoteExpectedSats, ARKADE_BTC, LIGHTNING_BTC, ONCHAIN_BTC, arkadeAssetLeg, rfqPair, LIGHTNING_SEND_PAIR, LIGHTNING_RECEIVE_PAIR, ONCHAIN_SEND_PAIR, ONCHAIN_RECEIVE_PAIR, RFQ_REFUSAL_ERROR_CODES, isRfqRefusalErrorCode, REFUSAL_FIELDS, REFUSAL_UNITS, safeInteger, safeRefusalDetail, refusalMessage, SwapRefusal, AddressMismatch, newRfqId, lightningSendRequest, arkadeSwapRequest, canonicalAssetAmount, normalizeHexBytes, normalizeMakerPkScript, normalizeMakerPublicKey, MIN_HEADROOM_SECONDS, assertFinite, MAX_PAIR_LENGTH, assertPairLength, verifyLockupAddress, LOCKUP_SHAPE_VARIANTS, matchQuotedLockup, assertFundable, expectQuote, requestVersionedQuote, pairOf, SEQUENCE_GRANULARITY_SECONDS, SOLO_REFUND_HEADROOM_SECONDS, unilateralClaimDelay, unilateralRefundDelay, unilateralRefundWithoutReceiverDelay, seconds, suiteVhtlc, quotedSoloRefundDelay, offerTermsFromQuote, verifyOfferAddress, quoteCarrierSats, l1NetworkFromArk, onchainSendRequest, lightningReceiveRequest, onchainReceiveRequest, MIN_CLAIM_WINDOW_SECONDS, assertReceivable, matchReceiveLockup;
|
|
1831
2171
|
var init_rfq = __esm({
|
|
1832
2172
|
"src/rfq.ts"() {
|
|
1833
2173
|
"use strict";
|
|
1834
2174
|
import_base7 = require("@scure/base");
|
|
1835
2175
|
import_solver_discovery = require("@arkade-os/solver-discovery");
|
|
1836
2176
|
import_legacy2 = require("@noble/hashes/legacy.js");
|
|
1837
|
-
|
|
2177
|
+
import_sdk8 = require("@arkade-os/sdk");
|
|
1838
2178
|
init_onchainHtlc();
|
|
1839
2179
|
init_onchainHtlc();
|
|
1840
|
-
|
|
2180
|
+
import_sdk9 = require("@arkade-os/sdk");
|
|
1841
2181
|
init_claimAmountGate();
|
|
1842
2182
|
init_claimPacket();
|
|
1843
2183
|
init_lockupContract();
|
|
1844
2184
|
init_offer();
|
|
2185
|
+
init_program();
|
|
2186
|
+
init_rfq_contract();
|
|
1845
2187
|
solverHex = (value, field) => {
|
|
1846
2188
|
try {
|
|
1847
2189
|
return import_base7.hex.decode(value);
|
|
@@ -1878,6 +2220,7 @@ var init_rfq = __esm({
|
|
|
1878
2220
|
ONCHAIN_RECEIVE_PAIR = rfqPair(ONCHAIN_BTC, ARKADE_BTC);
|
|
1879
2221
|
RFQ_REFUSAL_ERROR_CODES = [
|
|
1880
2222
|
"amount_side_unsupported",
|
|
2223
|
+
RFQ_CONTRACT_VERSION_UNSUPPORTED,
|
|
1881
2224
|
"exact_out_unsupported",
|
|
1882
2225
|
"invalid_amount",
|
|
1883
2226
|
"invalid_payout_address",
|
|
@@ -1993,6 +2336,7 @@ var init_rfq = __esm({
|
|
|
1993
2336
|
pair,
|
|
1994
2337
|
amount_side: input.amountSide ?? "from",
|
|
1995
2338
|
amount: canonicalAssetAmount(input.amount),
|
|
2339
|
+
...input.contractVersions && input.contractVersions.length > 0 ? { [RFQ_CONTRACT_VERSIONS_KEY]: [...input.contractVersions] } : {},
|
|
1996
2340
|
// The solver's `.strict()` schema refuses any undeclared key as `unsupported_payload`.
|
|
1997
2341
|
profile: {
|
|
1998
2342
|
maker_pk_script: normalizeMakerPkScript(input.makerPkScript),
|
|
@@ -2180,6 +2524,34 @@ var init_rfq = __esm({
|
|
|
2180
2524
|
}
|
|
2181
2525
|
return payload;
|
|
2182
2526
|
};
|
|
2527
|
+
requestVersionedQuote = async (transport, request, advertised) => {
|
|
2528
|
+
if (advertised.length === 0) {
|
|
2529
|
+
throw new Error("contractVersions is empty: advertise at least one contract version");
|
|
2530
|
+
}
|
|
2531
|
+
let sent = request;
|
|
2532
|
+
let quote;
|
|
2533
|
+
try {
|
|
2534
|
+
quote = await transport.requestQuote(request);
|
|
2535
|
+
} catch (error) {
|
|
2536
|
+
if (!(error instanceof SwapRefusal) || error.reason !== "unsupported_payload" || error.errorCode !== void 0 || !advertised.includes(ASSET_SWAP_BASELINE)) {
|
|
2537
|
+
throw error;
|
|
2538
|
+
}
|
|
2539
|
+
const { [RFQ_CONTRACT_VERSIONS_KEY]: _, ...baseline } = request;
|
|
2540
|
+
sent = { ...baseline, rfq_id: newRfqId() };
|
|
2541
|
+
quote = await transport.requestQuote(sent);
|
|
2542
|
+
}
|
|
2543
|
+
const selected = quote[RFQ_CONTRACT_VERSION_KEY];
|
|
2544
|
+
if (sent !== request && selected !== void 0) {
|
|
2545
|
+
throw new Error(`solver chose contract version ${selected}, but none was advertised`);
|
|
2546
|
+
}
|
|
2547
|
+
const version = selected ?? ASSET_SWAP_BASELINE;
|
|
2548
|
+
if (!advertised.includes(version)) {
|
|
2549
|
+
throw new Error(
|
|
2550
|
+
`solver chose contract version ${version}, not one of ${advertised.join(", ")}`
|
|
2551
|
+
);
|
|
2552
|
+
}
|
|
2553
|
+
return { quote, rfqId: sent.rfq_id, contractVersion: assetSwapContractVersion(version) };
|
|
2554
|
+
};
|
|
2183
2555
|
pairOf = (payload) => typeof payload.pair === "string" ? payload.pair : void 0;
|
|
2184
2556
|
SEQUENCE_GRANULARITY_SECONDS = 512;
|
|
2185
2557
|
SOLO_REFUND_HEADROOM_SECONDS = 8 * SEQUENCE_GRANULARITY_SECONDS;
|
|
@@ -2202,7 +2574,7 @@ var init_rfq = __esm({
|
|
|
2202
2574
|
type: "seconds",
|
|
2203
2575
|
value: BigInt(value)
|
|
2204
2576
|
});
|
|
2205
|
-
suiteVhtlc = (params, roles) => new
|
|
2577
|
+
suiteVhtlc = (params, roles) => new import_sdk8.VHTLC.ScriptV2({
|
|
2206
2578
|
sender: roles.sender,
|
|
2207
2579
|
receiver: roles.receiver,
|
|
2208
2580
|
server: params.operatorPubkey,
|
|
@@ -2312,6 +2684,9 @@ var init_rfq = __esm({
|
|
|
2312
2684
|
if (input.now >= input.payDeadline) {
|
|
2313
2685
|
throw gateError("quote_expired", "quote or invoice already expired \u2014 request a fresh one");
|
|
2314
2686
|
}
|
|
2687
|
+
if (quoteAmountSats(input.quote.from_amount, "from_amount") <= 0n || quoteAmountSats(input.quote.to_amount, "to_amount") <= 0n) {
|
|
2688
|
+
throw gateError("non_positive_amount", "quote carries a non-positive amount");
|
|
2689
|
+
}
|
|
2315
2690
|
if (input.quote.refund_locktime === void 0) {
|
|
2316
2691
|
throw gateError("missing_refund_locktime", "receive quote carries no refund_locktime");
|
|
2317
2692
|
}
|
|
@@ -2331,7 +2706,7 @@ var init_rfq = __esm({
|
|
|
2331
2706
|
};
|
|
2332
2707
|
matchReceiveLockup = (input, refundLocktime, solverRefundPkScriptHex) => {
|
|
2333
2708
|
const contractParams = {
|
|
2334
|
-
solverPubkey: (0,
|
|
2709
|
+
solverPubkey: (0, import_sdk8.toXOnly)(import_base7.hex.decode(input.quote.solver_pubkey), "solver key"),
|
|
2335
2710
|
refundLocktime,
|
|
2336
2711
|
operatorPubkey: input.operatorPubkey,
|
|
2337
2712
|
paymentHash: input.paymentHash,
|
|
@@ -2339,7 +2714,7 @@ var init_rfq = __esm({
|
|
|
2339
2714
|
emulatorPubkey: input.emulatorPubkey,
|
|
2340
2715
|
solverRefundPkScript: solverHex(solverRefundPkScriptHex, "profile.solver_refund_pk_script"),
|
|
2341
2716
|
payoutPubkey: input.payoutPubkey,
|
|
2342
|
-
payoutPkScript:
|
|
2717
|
+
payoutPkScript: import_sdk8.ArkAddress.decode(input.payoutAddress).pkScript
|
|
2343
2718
|
};
|
|
2344
2719
|
const matched = matchQuotedLockup(
|
|
2345
2720
|
input.quote,
|
|
@@ -2501,14 +2876,14 @@ __export(nostr_exports, {
|
|
|
2501
2876
|
nostrRfqTransport: () => nostrRfqTransport,
|
|
2502
2877
|
sharedNostrPool: () => sharedNostrPool
|
|
2503
2878
|
});
|
|
2504
|
-
var import_solver_discovery7,
|
|
2879
|
+
var import_solver_discovery7, import_sdk20, import_nostr_tools2, RFQ_DIRECTED_KIND, DEFAULT_TIMEOUT_MS, CONNECTION_FAILURE, CARD_FETCH_TIMEOUT_MS, RelayUnavailable, TransportClosed, closeReasons, nostrRfqTransport, isNewer, nostrCardFetcher;
|
|
2505
2880
|
var init_nostr = __esm({
|
|
2506
2881
|
"src/nostr.ts"() {
|
|
2507
2882
|
"use strict";
|
|
2508
2883
|
import_solver_discovery7 = require("@arkade-os/solver-discovery");
|
|
2509
2884
|
init_rfq();
|
|
2510
2885
|
init_nostrPool();
|
|
2511
|
-
|
|
2886
|
+
import_sdk20 = require("@arkade-os/sdk");
|
|
2512
2887
|
import_nostr_tools2 = require("nostr-tools");
|
|
2513
2888
|
init_nostrPool();
|
|
2514
2889
|
RFQ_DIRECTED_KIND = 24859;
|
|
@@ -2535,7 +2910,7 @@ var init_nostr = __esm({
|
|
|
2535
2910
|
return url ? `${url}: ${reason ?? "closed"}` : reason ?? "closed";
|
|
2536
2911
|
});
|
|
2537
2912
|
nostrRfqTransport = (options) => {
|
|
2538
|
-
(0,
|
|
2913
|
+
(0, import_sdk20.assertTimerMs)("timeoutMs", options.timeoutMs);
|
|
2539
2914
|
const relays = options.relays;
|
|
2540
2915
|
const solverPubkey = options.solverPubkey;
|
|
2541
2916
|
const secretKey = options.secretKey ?? (0, import_nostr_tools2.generateSecretKey)();
|
|
@@ -2647,7 +3022,7 @@ var init_nostr = __esm({
|
|
|
2647
3022
|
};
|
|
2648
3023
|
isNewer = (event, held) => !held || event.created_at > held.created_at || event.created_at === held.created_at && event.id < held.id;
|
|
2649
3024
|
nostrCardFetcher = (options = {}) => {
|
|
2650
|
-
(0,
|
|
3025
|
+
(0, import_sdk20.assertTimerMs)("timeoutMs", options.timeoutMs);
|
|
2651
3026
|
if (options.timeoutMs === 0) throw new Error("timeoutMs must be positive");
|
|
2652
3027
|
const seen = /* @__PURE__ */ new Map();
|
|
2653
3028
|
const inflight = /* @__PURE__ */ new Map();
|
|
@@ -2925,7 +3300,7 @@ module.exports = __toCommonJS(advanced_exports);
|
|
|
2925
3300
|
// src/client/accept.ts
|
|
2926
3301
|
var import_base9 = require("@scure/base");
|
|
2927
3302
|
var import_solver_discovery6 = require("@arkade-os/solver-discovery");
|
|
2928
|
-
var
|
|
3303
|
+
var import_sdk14 = require("@arkade-os/sdk");
|
|
2929
3304
|
init_offer();
|
|
2930
3305
|
init_coverage();
|
|
2931
3306
|
init_lockupContract();
|
|
@@ -3126,7 +3501,7 @@ init_rfqProfileParts();
|
|
|
3126
3501
|
init_store();
|
|
3127
3502
|
|
|
3128
3503
|
// src/client/assetId.ts
|
|
3129
|
-
var
|
|
3504
|
+
var import_sdk7 = require("@arkade-os/sdk");
|
|
3130
3505
|
var RAILS = ["arkade", "bitcoin", "bolt11", "eip155"];
|
|
3131
3506
|
var BITCOIN_RAILS = ["arkade", "bitcoin", "bolt11"];
|
|
3132
3507
|
var BTC_ASSET_PART = "slip44:0";
|
|
@@ -3155,7 +3530,7 @@ var CHAIN_REFERENCE = /^[-_a-z0-9]{1,32}$/;
|
|
|
3155
3530
|
var CHAIN_ID = /^(0|[1-9][0-9]*)$/;
|
|
3156
3531
|
var ASSET_REFERENCE = /^[-.%a-z0-9]{1,128}$/;
|
|
3157
3532
|
var isRail = (value) => RAILS.includes(value);
|
|
3158
|
-
var isNetworkRef = (value) => Object.hasOwn(
|
|
3533
|
+
var isNetworkRef = (value) => Object.hasOwn(import_sdk7.networks, value);
|
|
3159
3534
|
var parseAssetId = (value) => {
|
|
3160
3535
|
if (/[A-Z]/.test(value)) {
|
|
3161
3536
|
throw new AssetIdError(
|
|
@@ -3220,7 +3595,7 @@ var parseAssetId = (value) => {
|
|
|
3220
3595
|
}
|
|
3221
3596
|
if (namespace === ARKADE_ASSET_NAMESPACE) {
|
|
3222
3597
|
try {
|
|
3223
|
-
|
|
3598
|
+
import_sdk7.asset.AssetId.fromString(assetReference);
|
|
3224
3599
|
} catch (cause) {
|
|
3225
3600
|
throw new AssetIdError(
|
|
3226
3601
|
"invalid_asset_reference",
|
|
@@ -3276,7 +3651,7 @@ var isBtcAssetLenient = (id) => {
|
|
|
3276
3651
|
var arkadeAsset = (network, id) => `arkade:${network}/${ARKADE_ASSET_NAMESPACE}:${id.toString()}`;
|
|
3277
3652
|
var issuanceOf = (id) => {
|
|
3278
3653
|
const { assetNamespace, assetReference } = parseAssetId(id);
|
|
3279
|
-
return assetNamespace === ARKADE_ASSET_NAMESPACE ?
|
|
3654
|
+
return assetNamespace === ARKADE_ASSET_NAMESPACE ? import_sdk7.asset.AssetId.fromString(assetReference) : void 0;
|
|
3280
3655
|
};
|
|
3281
3656
|
|
|
3282
3657
|
// src/client/aliases.ts
|
|
@@ -3516,7 +3891,7 @@ var canonicalAssetId = (input, table) => {
|
|
|
3516
3891
|
};
|
|
3517
3892
|
|
|
3518
3893
|
// src/client/assetPayment.ts
|
|
3519
|
-
var
|
|
3894
|
+
var import_sdk10 = require("@arkade-os/sdk");
|
|
3520
3895
|
var import_solver_discovery3 = require("@arkade-os/solver-discovery");
|
|
3521
3896
|
var DECIMAL = /^(0|[1-9][0-9]*)$/;
|
|
3522
3897
|
var MAX_SATS = 2100000000000000n;
|
|
@@ -3567,7 +3942,7 @@ function validateReceiverPaidQuoteShape(q) {
|
|
|
3567
3942
|
throw new Error("carrier receiver-paid quote needs an assetId");
|
|
3568
3943
|
}
|
|
3569
3944
|
try {
|
|
3570
|
-
|
|
3945
|
+
import_sdk10.asset.AssetId.fromString(q.assetId);
|
|
3571
3946
|
} catch {
|
|
3572
3947
|
throw new Error("carrier receiver-paid quote assetId is not a valid SDK asset id");
|
|
3573
3948
|
}
|
|
@@ -3806,7 +4181,7 @@ var assetPaymentOf = (stored, quoteExpiry) => {
|
|
|
3806
4181
|
};
|
|
3807
4182
|
|
|
3808
4183
|
// src/client/fundingNotSubmitted.ts
|
|
3809
|
-
var
|
|
4184
|
+
var import_sdk11 = require("@arkade-os/sdk");
|
|
3810
4185
|
var import_base8 = require("@scure/base");
|
|
3811
4186
|
init_coverage();
|
|
3812
4187
|
init_repository();
|
|
@@ -4024,7 +4399,7 @@ var retireUnsubmittedFunding = async (wallet, repository, record, contracts) =>
|
|
|
4024
4399
|
status: row.family === "offer" ? row.status : fundingWasNotSubmitted(row) ? "cancelled" : row.state === "settled" || row.state === "refunded" ? "fulfilled" : "pending"
|
|
4025
4400
|
}));
|
|
4026
4401
|
const legacy = (await collectRfqSwaps(repository)).map((row) => ({
|
|
4027
|
-
swapPkScript: import_base8.hex.encode(
|
|
4402
|
+
swapPkScript: import_base8.hex.encode(import_sdk11.ArkAddress.decode(row.lockupAddress).pkScript),
|
|
4028
4403
|
createdAt: row.createdAt * 1e3,
|
|
4029
4404
|
status: row.state === "settled" || row.state === "refunded" ? "fulfilled" : "pending"
|
|
4030
4405
|
}));
|
|
@@ -4039,7 +4414,7 @@ var retireUnsubmittedFunding = async (wallet, repository, record, contracts) =>
|
|
|
4039
4414
|
};
|
|
4040
4415
|
|
|
4041
4416
|
// src/client/corridors/lightning.ts
|
|
4042
|
-
var
|
|
4417
|
+
var import_sdk12 = require("@arkade-os/sdk");
|
|
4043
4418
|
var INVOICE_HRPS = [
|
|
4044
4419
|
["lnbcrt", ["regtest"]],
|
|
4045
4420
|
["lntbs", ["signet", "mutinynet"]],
|
|
@@ -4069,7 +4444,7 @@ var lightningCorridor = Object.assign(
|
|
|
4069
4444
|
deps,
|
|
4070
4445
|
drive: LIGHTNING_DRIVE,
|
|
4071
4446
|
matches(raw) {
|
|
4072
|
-
const invoice = (0,
|
|
4447
|
+
const invoice = (0, import_sdk12.invoiceTarget)(raw);
|
|
4073
4448
|
if (invoice === void 0) return void 0;
|
|
4074
4449
|
const networks2 = networksOfInvoiceHrp(invoice);
|
|
4075
4450
|
if (networks2 === void 0) {
|
|
@@ -4115,11 +4490,11 @@ var lightningCorridor = Object.assign(
|
|
|
4115
4490
|
};
|
|
4116
4491
|
}
|
|
4117
4492
|
}),
|
|
4118
|
-
{ target:
|
|
4493
|
+
{ target: import_sdk12.invoiceTarget }
|
|
4119
4494
|
);
|
|
4120
4495
|
|
|
4121
4496
|
// src/client/corridors/onchain.ts
|
|
4122
|
-
var
|
|
4497
|
+
var import_sdk13 = require("@arkade-os/sdk");
|
|
4123
4498
|
var btc2 = __toESM(require("@scure/btc-signer"), 1);
|
|
4124
4499
|
init_onchainHtlc();
|
|
4125
4500
|
init_rfq();
|
|
@@ -4149,14 +4524,14 @@ var onchainCorridor = Object.assign(
|
|
|
4149
4524
|
deps,
|
|
4150
4525
|
drive: ONCHAIN_DRIVE,
|
|
4151
4526
|
matches(raw) {
|
|
4152
|
-
const target = (0,
|
|
4527
|
+
const target = (0, import_sdk13.btcTarget)(raw);
|
|
4153
4528
|
if (target === void 0) return void 0;
|
|
4154
4529
|
try {
|
|
4155
4530
|
btc2.Address(L1_NETWORKS[l1]).decode(target);
|
|
4156
4531
|
} catch {
|
|
4157
4532
|
return { refused: `this is not a ${l1} address` };
|
|
4158
4533
|
}
|
|
4159
|
-
const amount =
|
|
4534
|
+
const amount = import_sdk13.BIP21.amountSats(raw);
|
|
4160
4535
|
return {
|
|
4161
4536
|
claimed: {
|
|
4162
4537
|
kind: "address",
|
|
@@ -4167,7 +4542,7 @@ var onchainCorridor = Object.assign(
|
|
|
4167
4542
|
}
|
|
4168
4543
|
};
|
|
4169
4544
|
},
|
|
4170
|
-
{ target:
|
|
4545
|
+
{ target: import_sdk13.btcTarget }
|
|
4171
4546
|
);
|
|
4172
4547
|
|
|
4173
4548
|
// src/client/outcome.ts
|
|
@@ -4521,15 +4896,15 @@ var acceptQuoteBody = async (input) => {
|
|
|
4521
4896
|
var registeredOfferRecord = async (input, preparation) => {
|
|
4522
4897
|
const { quote, wallet, corridors, now } = input;
|
|
4523
4898
|
const { plan } = preparation;
|
|
4524
|
-
const
|
|
4899
|
+
const arkade4 = corridors.get("arkade").deps;
|
|
4525
4900
|
const receiveIsBtc = plan.receive.asset.id === BTC_ASSET_ID;
|
|
4526
4901
|
const offer = await createOffer(
|
|
4527
4902
|
wallet,
|
|
4528
4903
|
{
|
|
4529
4904
|
// Keyed on the receive side: the covenant binds what the fill delivers.
|
|
4530
4905
|
wantAmount: plan.receive.atomic,
|
|
4531
|
-
...receiveIsBtc ? { offerAsset:
|
|
4532
|
-
emulatorPubkey:
|
|
4906
|
+
...receiveIsBtc ? { offerAsset: import_sdk14.asset.AssetId.fromString(plan.deposit.asset.id) } : { wantAsset: import_sdk14.asset.AssetId.fromString(plan.receive.asset.id) },
|
|
4907
|
+
emulatorPubkey: arkade4.emulatorPubkey
|
|
4533
4908
|
},
|
|
4534
4909
|
{ coverageId: quote.id }
|
|
4535
4910
|
);
|
|
@@ -4592,7 +4967,7 @@ var fundAndStamp = async (input, record, repository) => {
|
|
|
4592
4967
|
const txid = await fund({ ...input, ...bounds, validUntil }, record);
|
|
4593
4968
|
return stampFunding(repository, record, txid, input.now);
|
|
4594
4969
|
} catch (error) {
|
|
4595
|
-
if (input.firstFundingAttempt && validUntil !== void 0 && error instanceof
|
|
4970
|
+
if (input.firstFundingAttempt && validUntil !== void 0 && error instanceof import_sdk14.SendDeadlineExceededError) {
|
|
4596
4971
|
const stopped = {
|
|
4597
4972
|
...record,
|
|
4598
4973
|
...record.family === "offer" ? { status: "cancelled" } : { state: "failed" },
|
|
@@ -4661,7 +5036,7 @@ var reconcileFunding = async (input, record) => {
|
|
|
4661
5036
|
const script = record.family === "offer" ? record.swapPkScript : record.lockupPkScript;
|
|
4662
5037
|
const expected = BigInt(record.give.amount);
|
|
4663
5038
|
const reader = await input.wallet.getArkadeReader();
|
|
4664
|
-
const vtxos = await (0,
|
|
5039
|
+
const vtxos = await (0, import_sdk14.getAllNormalizedVtxos)(reader, [script]);
|
|
4665
5040
|
const deposit = vtxos.find((vtxo) => depositMatches(vtxo, record, expected));
|
|
4666
5041
|
return deposit?.txid;
|
|
4667
5042
|
};
|
|
@@ -4771,13 +5146,13 @@ var scopedToRail = (table, rail) => ({
|
|
|
4771
5146
|
|
|
4772
5147
|
// src/client/client.ts
|
|
4773
5148
|
var import_base23 = require("@scure/base");
|
|
4774
|
-
var
|
|
5149
|
+
var import_sdk38 = require("@arkade-os/sdk");
|
|
4775
5150
|
init_repository();
|
|
4776
5151
|
|
|
4777
5152
|
// src/refund.ts
|
|
4778
5153
|
var import_base10 = require("@scure/base");
|
|
4779
5154
|
var import_sha24 = require("@noble/hashes/sha2.js");
|
|
4780
|
-
var
|
|
5155
|
+
var import_sdk15 = require("@arkade-os/sdk");
|
|
4781
5156
|
init_onchainHtlc();
|
|
4782
5157
|
init_rfq();
|
|
4783
5158
|
var walletOperator = (wallet) => {
|
|
@@ -4815,7 +5190,7 @@ async function findLockupVtxos(contracts, swapPkScript) {
|
|
|
4815
5190
|
const out = [];
|
|
4816
5191
|
for (const vtxo of row?.vtxos ?? []) {
|
|
4817
5192
|
if (vtxo.isUnrolled) continue;
|
|
4818
|
-
if ((0,
|
|
5193
|
+
if ((0, import_sdk15.isVtxoSpent)(vtxo)) continue;
|
|
4819
5194
|
const key = `${vtxo.txid}:${vtxo.vout}`;
|
|
4820
5195
|
if (seen.has(key)) continue;
|
|
4821
5196
|
seen.add(key);
|
|
@@ -4831,17 +5206,17 @@ async function findLockupVtxos(contracts, swapPkScript) {
|
|
|
4831
5206
|
}
|
|
4832
5207
|
var hashesTo = (candidate, paymentHash) => import_base10.hex.encode((0, import_sha24.sha256)(candidate)) === paymentHash;
|
|
4833
5208
|
var candidateWitnessItems = (tx, inputIndex) => [
|
|
4834
|
-
...(0,
|
|
5209
|
+
...(0, import_sdk15.getArkPsbtFields)(tx, inputIndex, import_sdk15.ConditionWitness).flat(),
|
|
4835
5210
|
...tx.getInput(inputIndex).finalScriptWitness ?? []
|
|
4836
5211
|
];
|
|
4837
5212
|
var refundLeafScript = (tx, inputIndex) => {
|
|
4838
5213
|
const input = tx.getInput(inputIndex);
|
|
4839
5214
|
const witness = input.finalScriptWitness;
|
|
4840
5215
|
const leaves = input.tapLeafScript ?? [];
|
|
4841
|
-
const script = witness && witness.length >= 2 ? witness[witness.length - 2] : leaves.length === 1 ? (0,
|
|
5216
|
+
const script = witness && witness.length >= 2 ? witness[witness.length - 2] : leaves.length === 1 ? (0, import_sdk15.scriptFromTapLeafScript)(leaves[0]) : void 0;
|
|
4842
5217
|
if (!script) return void 0;
|
|
4843
5218
|
try {
|
|
4844
|
-
const { type } = (0,
|
|
5219
|
+
const { type } = (0, import_sdk15.decodeTapscript)(script);
|
|
4845
5220
|
return type === "multisig" || type === "csv-multisig" || type === "cltv-multisig" ? script : void 0;
|
|
4846
5221
|
} catch {
|
|
4847
5222
|
return void 0;
|
|
@@ -4851,7 +5226,7 @@ async function readLockupFate(indexer, input) {
|
|
|
4851
5226
|
const { vtxos } = await indexer.getVtxos({ scripts: [import_base10.hex.encode(input.swapPkScript)] });
|
|
4852
5227
|
const all = vtxos ?? [];
|
|
4853
5228
|
if (all.length === 0) return { fate: "unknown" };
|
|
4854
|
-
const exited = all.filter((vtxo) => vtxo.isUnrolled && !(0,
|
|
5229
|
+
const exited = all.filter((vtxo) => vtxo.isUnrolled && !(0, import_sdk15.isVtxoSpent)(vtxo));
|
|
4855
5230
|
if (exited.length > 0) {
|
|
4856
5231
|
return {
|
|
4857
5232
|
fate: "exited",
|
|
@@ -4863,7 +5238,7 @@ async function readLockupFate(indexer, input) {
|
|
|
4863
5238
|
let sweptLeft = false;
|
|
4864
5239
|
let live = false;
|
|
4865
5240
|
for (const vtxo of all) {
|
|
4866
|
-
if (!(0,
|
|
5241
|
+
if (!(0, import_sdk15.isVtxoSpent)(vtxo)) {
|
|
4867
5242
|
if (input.receiver && vtxo.isSwept) sweptLeft = true;
|
|
4868
5243
|
else live = true;
|
|
4869
5244
|
continue;
|
|
@@ -4890,7 +5265,7 @@ async function readLockupFate(indexer, input) {
|
|
|
4890
5265
|
for (const raw of txs) {
|
|
4891
5266
|
let tx;
|
|
4892
5267
|
try {
|
|
4893
|
-
tx =
|
|
5268
|
+
tx = import_sdk15.Transaction.fromPSBT(import_base10.base64.decode(raw));
|
|
4894
5269
|
} catch {
|
|
4895
5270
|
continue;
|
|
4896
5271
|
}
|
|
@@ -4940,10 +5315,10 @@ var assertNoneSwept = (vtxos, contract) => {
|
|
|
4940
5315
|
};
|
|
4941
5316
|
var operatorUnrollScript = async (operator, network) => {
|
|
4942
5317
|
const info = await operator.getInfo();
|
|
4943
|
-
return (0,
|
|
5318
|
+
return (0, import_sdk15.assertValidServerUnrollScript)(
|
|
4944
5319
|
info.checkpointTapscript,
|
|
4945
|
-
network ?? (0,
|
|
4946
|
-
(0,
|
|
5320
|
+
network ?? (0, import_sdk15.networkFromOperatorInfo)(info),
|
|
5321
|
+
(0, import_sdk15.toXOnly)(import_base10.hex.decode(info.forfeitPubkey), "forfeit key")
|
|
4947
5322
|
);
|
|
4948
5323
|
};
|
|
4949
5324
|
var MAX_LOCKUP_SPEND_INPUTS = 16;
|
|
@@ -4963,7 +5338,7 @@ var lockupAssetOutputs = (vtxos) => {
|
|
|
4963
5338
|
address: "",
|
|
4964
5339
|
assets: [...totals].map(([assetId, amount]) => ({ assetId, amount }))
|
|
4965
5340
|
};
|
|
4966
|
-
return [
|
|
5341
|
+
return [import_sdk15.Extension.create([(0, import_sdk15.createAssetPacket)(inputs, [receiver])]).txOut()];
|
|
4967
5342
|
};
|
|
4968
5343
|
var lockupInputs = (vtxos, contract, leaf) => {
|
|
4969
5344
|
const tapTree = contract.encode();
|
|
@@ -4988,7 +5363,7 @@ async function pushRefundWithoutReceiver(operator, input) {
|
|
|
4988
5363
|
const leaf = input.contract.refundWithoutReceiver();
|
|
4989
5364
|
const vtxos = boundedLockupSpend(input.vtxos);
|
|
4990
5365
|
const amount = vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
|
|
4991
|
-
const txid = await (0,
|
|
5366
|
+
const txid = await (0, import_sdk15.signAndSubmitOffchainTx)({
|
|
4992
5367
|
identity: input.sender,
|
|
4993
5368
|
provider: operator,
|
|
4994
5369
|
inputs: lockupInputs(vtxos, input.contract, leaf),
|
|
@@ -5006,10 +5381,10 @@ async function pushRefundWithoutReceiver(operator, input) {
|
|
|
5006
5381
|
var REFUND_MTP_LAG_SECONDS = 2 * 60 * 60;
|
|
5007
5382
|
|
|
5008
5383
|
// src/client/corridors/registry.ts
|
|
5009
|
-
var
|
|
5384
|
+
var import_sdk19 = require("@arkade-os/sdk");
|
|
5010
5385
|
|
|
5011
5386
|
// src/client/corridors/arkade.ts
|
|
5012
|
-
var
|
|
5387
|
+
var import_sdk16 = require("@arkade-os/sdk");
|
|
5013
5388
|
var ARKADE_DRIVE = {};
|
|
5014
5389
|
var messageOf = (error) => error instanceof Error ? error.message : String(error);
|
|
5015
5390
|
var arkadeCorridor = Object.assign(
|
|
@@ -5018,11 +5393,11 @@ var arkadeCorridor = Object.assign(
|
|
|
5018
5393
|
deps,
|
|
5019
5394
|
drive: ARKADE_DRIVE,
|
|
5020
5395
|
matches(raw) {
|
|
5021
|
-
const target = (0,
|
|
5396
|
+
const target = (0, import_sdk16.arkTarget)(raw);
|
|
5022
5397
|
if (target === void 0) return void 0;
|
|
5023
5398
|
try {
|
|
5024
|
-
const address =
|
|
5025
|
-
(0,
|
|
5399
|
+
const address = import_sdk16.ArkAddress.decode(target);
|
|
5400
|
+
(0, import_sdk16.assertRecipientArkadeAddress)(target, address, {
|
|
5026
5401
|
hrp: deps.network.hrp,
|
|
5027
5402
|
signerSet: deps.signerSet
|
|
5028
5403
|
});
|
|
@@ -5032,11 +5407,11 @@ var arkadeCorridor = Object.assign(
|
|
|
5032
5407
|
return { claimed: { kind: "address", address: target } };
|
|
5033
5408
|
}
|
|
5034
5409
|
}),
|
|
5035
|
-
{ target:
|
|
5410
|
+
{ target: import_sdk16.arkTarget }
|
|
5036
5411
|
);
|
|
5037
5412
|
|
|
5038
5413
|
// src/client/corridors/deps.ts
|
|
5039
|
-
var
|
|
5414
|
+
var import_sdk18 = require("@arkade-os/sdk");
|
|
5040
5415
|
|
|
5041
5416
|
// src/chainSource.ts
|
|
5042
5417
|
var btc3 = __toESM(require("@scure/btc-signer"), 1);
|
|
@@ -5120,7 +5495,7 @@ var decodeBolt11 = (invoice) => {
|
|
|
5120
5495
|
// src/client/corridors/chainSource.ts
|
|
5121
5496
|
var import_base12 = require("@scure/base");
|
|
5122
5497
|
var btc4 = __toESM(require("@scure/btc-signer"), 1);
|
|
5123
|
-
var
|
|
5498
|
+
var import_sdk17 = require("@arkade-os/sdk");
|
|
5124
5499
|
var addressOfScript = (script, network) => btc4.Address(network).encode(btc4.OutScript.decode(script));
|
|
5125
5500
|
var chainSourceOver = (backend, network) => {
|
|
5126
5501
|
const spenderFromVins = async (txid, vout, pkScript) => {
|
|
@@ -5187,7 +5562,7 @@ var esploraTip = async (esploraUrl, fetchImpl) => {
|
|
|
5187
5562
|
};
|
|
5188
5563
|
var esploraChainSource = (input) => chainSourceOver(
|
|
5189
5564
|
{
|
|
5190
|
-
provider: new
|
|
5565
|
+
provider: new import_sdk17.EsploraProvider(input.esploraUrl),
|
|
5191
5566
|
tip: () => esploraTip(input.esploraUrl, input.fetchImpl)
|
|
5192
5567
|
},
|
|
5193
5568
|
input.network
|
|
@@ -5213,10 +5588,10 @@ var refusedIfMalformed = (value, dep) => {
|
|
|
5213
5588
|
};
|
|
5214
5589
|
var emulatorPubkeyFor = (base) => {
|
|
5215
5590
|
if (base.emulatorPubkey !== void 0) {
|
|
5216
|
-
return (0,
|
|
5591
|
+
return (0, import_sdk18.resolveEmulatorPubkey)(base.network, base.emulatorPubkey);
|
|
5217
5592
|
}
|
|
5218
5593
|
try {
|
|
5219
|
-
return (0,
|
|
5594
|
+
return (0, import_sdk18.defaultEmulatorPubkey)(base.network);
|
|
5220
5595
|
} catch {
|
|
5221
5596
|
throw new MissingCorridorDep(
|
|
5222
5597
|
"arkade",
|
|
@@ -5267,7 +5642,7 @@ function resolveCorridorDeps(corridor, overrides, base) {
|
|
|
5267
5642
|
return {
|
|
5268
5643
|
networkName: base.networkName,
|
|
5269
5644
|
chain: chain && "provider" in chain ? chainSourceFrom(chain.provider, l1Network) : esploraChainSource({
|
|
5270
|
-
esploraUrl: chain?.esploraUrl ??
|
|
5645
|
+
esploraUrl: chain?.esploraUrl ?? import_sdk18.ESPLORA_URL[base.networkName],
|
|
5271
5646
|
network: L1_NETWORKS[l1Network],
|
|
5272
5647
|
fetchImpl: base.fetchImpl
|
|
5273
5648
|
}),
|
|
@@ -5298,8 +5673,8 @@ var resolveCorridorBase = async (input) => {
|
|
|
5298
5673
|
wallet: input.wallet,
|
|
5299
5674
|
operator: input.operator,
|
|
5300
5675
|
networkName,
|
|
5301
|
-
network: (0,
|
|
5302
|
-
signerSet: (0,
|
|
5676
|
+
network: (0, import_sdk18.getNetwork)(networkName),
|
|
5677
|
+
signerSet: (0, import_sdk18.signerSetFromInfo)(info),
|
|
5303
5678
|
emulatorPubkey: input.emulatorPubkey,
|
|
5304
5679
|
fetchImpl: input.fetchImpl,
|
|
5305
5680
|
repository: input.repository
|
|
@@ -5329,7 +5704,7 @@ var corridorSet = (base, overrides) => {
|
|
|
5329
5704
|
(corridor) => CORRIDOR_FACTORIES[corridor].target(raw) !== void 0
|
|
5330
5705
|
);
|
|
5331
5706
|
if (owners.length === 0) {
|
|
5332
|
-
if ((0,
|
|
5707
|
+
if ((0, import_sdk19.isLnurl)(raw)) return void 0;
|
|
5333
5708
|
throw new AmbiguousDestination(raw, "no corridor recognises this destination");
|
|
5334
5709
|
}
|
|
5335
5710
|
const claims = [];
|
|
@@ -5357,11 +5732,11 @@ var import_solver_discovery9 = require("@arkade-os/solver-discovery");
|
|
|
5357
5732
|
|
|
5358
5733
|
// src/markets.ts
|
|
5359
5734
|
var import_solver_discovery8 = require("@arkade-os/solver-discovery");
|
|
5360
|
-
var
|
|
5735
|
+
var import_sdk21 = require("@arkade-os/sdk");
|
|
5361
5736
|
init_store();
|
|
5362
5737
|
var QUOTE_OPTIONS = { safetyBps: 0 };
|
|
5363
5738
|
var makeCachedFeedFetch = (ttlMs = 3e4, fetchImpl = fetch) => {
|
|
5364
|
-
(0,
|
|
5739
|
+
(0, import_sdk21.assertNonNegativeMs)("ttlMs", ttlMs);
|
|
5365
5740
|
const cache = /* @__PURE__ */ new Map();
|
|
5366
5741
|
const inflight = /* @__PURE__ */ new Map();
|
|
5367
5742
|
return async (input, init) => {
|
|
@@ -5626,13 +6001,13 @@ var discoveryIndex = (input) => {
|
|
|
5626
6001
|
|
|
5627
6002
|
// src/client/cancel.ts
|
|
5628
6003
|
var import_base16 = require("@scure/base");
|
|
5629
|
-
var
|
|
6004
|
+
var import_sdk25 = require("@arkade-os/sdk");
|
|
5630
6005
|
init_coverage();
|
|
5631
6006
|
init_offer();
|
|
5632
6007
|
|
|
5633
6008
|
// src/restore.ts
|
|
5634
6009
|
var import_base13 = require("@scure/base");
|
|
5635
|
-
var
|
|
6010
|
+
var import_sdk22 = require("@arkade-os/sdk");
|
|
5636
6011
|
init_offer();
|
|
5637
6012
|
init_store();
|
|
5638
6013
|
var TXS_PER_REQUEST = 50;
|
|
@@ -5657,7 +6032,7 @@ async function fetchParsedTxs(indexer, txids) {
|
|
|
5657
6032
|
if (result.status !== "fulfilled") continue;
|
|
5658
6033
|
for (const psbt of result.value) {
|
|
5659
6034
|
try {
|
|
5660
|
-
const parsed =
|
|
6035
|
+
const parsed = import_sdk22.Transaction.fromPSBT(import_base13.base64.decode(psbt));
|
|
5661
6036
|
parsedByTxid.set(parsed.id, parsed);
|
|
5662
6037
|
} catch {
|
|
5663
6038
|
}
|
|
@@ -5686,7 +6061,7 @@ function classifySpend(offer, operatorPubkey, spendTx, deposit) {
|
|
|
5686
6061
|
if (!input.txid || input.index !== deposit.vout) continue;
|
|
5687
6062
|
if (import_base13.hex.encode(input.txid) !== deposit.txid) continue;
|
|
5688
6063
|
for (const leaf of input.tapLeafScript ?? []) {
|
|
5689
|
-
const spent = import_base13.hex.encode((0,
|
|
6064
|
+
const spent = import_base13.hex.encode((0, import_sdk22.scriptFromTapLeafScript)(leaf));
|
|
5690
6065
|
if (leaves.returned.some((back) => spent === import_base13.hex.encode(back))) return "cancelled";
|
|
5691
6066
|
if (leaves.fulfill && spent === import_base13.hex.encode(leaves.fulfill)) return "fulfilled";
|
|
5692
6067
|
}
|
|
@@ -5740,7 +6115,7 @@ async function restoreAssetSwaps(indexer, txs, existingIds, opts) {
|
|
|
5740
6115
|
if (!fundingTx) continue;
|
|
5741
6116
|
fetchedTxids.push(txid);
|
|
5742
6117
|
try {
|
|
5743
|
-
const packet =
|
|
6118
|
+
const packet = import_sdk22.Extension.fromTx(parsed).getPacketByType(OFFER_PACKET_TYPE);
|
|
5744
6119
|
if (!packet) continue;
|
|
5745
6120
|
const payload = packet.serialize();
|
|
5746
6121
|
found.push({
|
|
@@ -5857,7 +6232,7 @@ init_repository();
|
|
|
5857
6232
|
init_repository();
|
|
5858
6233
|
|
|
5859
6234
|
// src/rfqRecord.ts
|
|
5860
|
-
var
|
|
6235
|
+
var import_sdk23 = require("@arkade-os/sdk");
|
|
5861
6236
|
var import_base14 = require("@scure/base");
|
|
5862
6237
|
|
|
5863
6238
|
// src/rfqSwapState.ts
|
|
@@ -5915,7 +6290,7 @@ function assertSameSwap(origin, swap) {
|
|
|
5915
6290
|
`rfq swap record is a ${origin.kind} origin paired with a ${swap.kind} swap`
|
|
5916
6291
|
);
|
|
5917
6292
|
}
|
|
5918
|
-
const funded = import_base14.hex.encode(
|
|
6293
|
+
const funded = import_base14.hex.encode(import_sdk23.ArkAddress.decode(origin.lockupAddress).pkScript);
|
|
5919
6294
|
const watched = import_base14.hex.encode(swap.lockupPkScript);
|
|
5920
6295
|
if (funded !== watched) {
|
|
5921
6296
|
throw new Error(
|
|
@@ -5962,8 +6337,8 @@ function rfqSwapOriginOf(record) {
|
|
|
5962
6337
|
};
|
|
5963
6338
|
}
|
|
5964
6339
|
function lockupScript(params, lockupAddress) {
|
|
5965
|
-
const script =
|
|
5966
|
-
const funded =
|
|
6340
|
+
const script = import_sdk23.VHTLCV2ContractHandler.createScript(params);
|
|
6341
|
+
const funded = import_sdk23.ArkAddress.decode(lockupAddress).pkScript;
|
|
5967
6342
|
if (import_base14.hex.encode(funded) !== import_base14.hex.encode(script.pkScript)) {
|
|
5968
6343
|
throw new Error(
|
|
5969
6344
|
`rfq swap covenant params derive ${import_base14.hex.encode(script.pkScript)}, but the record's lockup address holds ${import_base14.hex.encode(funded)} \u2014 these params are not this swap's`
|
|
@@ -6000,7 +6375,7 @@ function shouldRetainRfqSwap(record, now) {
|
|
|
6000
6375
|
|
|
6001
6376
|
// src/client/driveRecords.ts
|
|
6002
6377
|
init_store();
|
|
6003
|
-
var
|
|
6378
|
+
var import_sdk24 = require("@arkade-os/sdk");
|
|
6004
6379
|
var import_sha25 = require("@noble/hashes/sha2.js");
|
|
6005
6380
|
var import_base15 = require("@scure/base");
|
|
6006
6381
|
var splitRecords = (records) => {
|
|
@@ -6055,7 +6430,7 @@ var pageRfqRecords = (records, filter, page) => {
|
|
|
6055
6430
|
).sort(
|
|
6056
6431
|
(a, b) => a.updatedAt - b.updatedAt || (a.rfqId < b.rfqId ? -1 : a.rfqId > b.rfqId ? 1 : 0)
|
|
6057
6432
|
).slice(0, page.limit + 1);
|
|
6058
|
-
return (0,
|
|
6433
|
+
return (0, import_sdk24.pageResult)(rows, page.limit, (record) => ({
|
|
6059
6434
|
updatedAt: record.updatedAt,
|
|
6060
6435
|
rfqId: record.rfqId
|
|
6061
6436
|
}));
|
|
@@ -6081,7 +6456,7 @@ var corridorRecordStore = (repository, onRecord = () => {
|
|
|
6081
6456
|
index,
|
|
6082
6457
|
quoteIdOf: (rfqId) => byRfqId.get(rfqId),
|
|
6083
6458
|
async getRfqSwapsPage(filter, page) {
|
|
6084
|
-
(0,
|
|
6459
|
+
(0, import_sdk24.assertPageRequest)(page);
|
|
6085
6460
|
assertRfqSwapPageFilter(filter);
|
|
6086
6461
|
const { corridor } = splitRecords(await collectSwapRecords(repository));
|
|
6087
6462
|
for (const record of corridor) index(record);
|
|
@@ -6193,7 +6568,7 @@ var restoredOfferRecord = (swap, network, now) => {
|
|
|
6193
6568
|
now
|
|
6194
6569
|
);
|
|
6195
6570
|
};
|
|
6196
|
-
var restoredAssetId = (network, id) => id === BTC_ASSET_ID ? btcOn("arkade", network) : arkadeAsset(network,
|
|
6571
|
+
var restoredAssetId = (network, id) => id === BTC_ASSET_ID ? btcOn("arkade", network) : arkadeAsset(network, import_sdk24.asset.AssetId.fromString(id));
|
|
6197
6572
|
var RESTORED_CORRIDORS = {
|
|
6198
6573
|
lightning_send: ["arkade", "lightning"],
|
|
6199
6574
|
lightning_receive: ["lightning", "arkade"],
|
|
@@ -6225,7 +6600,7 @@ var restoredCorridorRecord = (stored, network, refundLocktime) => {
|
|
|
6225
6600
|
kind: v1.kind,
|
|
6226
6601
|
rfqId: v1.rfqId,
|
|
6227
6602
|
lockupAddress: v1.lockupAddress,
|
|
6228
|
-
lockupPkScript: import_base15.hex.encode(
|
|
6603
|
+
lockupPkScript: import_base15.hex.encode(import_sdk24.ArkAddress.decode(v1.lockupAddress).pkScript),
|
|
6229
6604
|
lock: { hash },
|
|
6230
6605
|
refundLocktime,
|
|
6231
6606
|
profile: v1.profile,
|
|
@@ -6321,12 +6696,12 @@ var reconcileDepositSpend = async (record, indexer) => {
|
|
|
6321
6696
|
const { txs } = await indexer.getVirtualTxs(candidates);
|
|
6322
6697
|
const parsed = txs.map((psbt) => {
|
|
6323
6698
|
try {
|
|
6324
|
-
return
|
|
6699
|
+
return import_sdk25.Transaction.fromPSBT(import_base16.base64.decode(psbt));
|
|
6325
6700
|
} catch {
|
|
6326
6701
|
return void 0;
|
|
6327
6702
|
}
|
|
6328
6703
|
}).filter((tx) => tx !== void 0);
|
|
6329
|
-
const operatorPubkey =
|
|
6704
|
+
const operatorPubkey = import_sdk25.ArkAddress.decode(record.swapAddress).serverPubKey;
|
|
6330
6705
|
const kind = classifyDepositSpend(offer, operatorPubkey, parsed, {
|
|
6331
6706
|
txid: deposit.txid,
|
|
6332
6707
|
vout: deposit.vout
|
|
@@ -6365,12 +6740,12 @@ var retireOfferScripts = async (wallet, repository, record) => {
|
|
|
6365
6740
|
};
|
|
6366
6741
|
|
|
6367
6742
|
// src/client/drive.ts
|
|
6368
|
-
var
|
|
6743
|
+
var import_sdk32 = require("@arkade-os/sdk");
|
|
6369
6744
|
var import_base20 = require("@scure/base");
|
|
6370
6745
|
|
|
6371
6746
|
// src/claim.ts
|
|
6372
6747
|
var import_base17 = require("@scure/base");
|
|
6373
|
-
var
|
|
6748
|
+
var import_sdk26 = require("@arkade-os/sdk");
|
|
6374
6749
|
init_onchainHtlc();
|
|
6375
6750
|
var LockupAmountMismatchError = class extends Error {
|
|
6376
6751
|
name = "LockupAmountMismatchError";
|
|
@@ -6397,6 +6772,9 @@ async function pushClaim(operator, input) {
|
|
|
6397
6772
|
assertFiniteAmount(funded, "lockup_malformed", "the lockup's summed value");
|
|
6398
6773
|
if (!input.partiallyClaimed) {
|
|
6399
6774
|
assertFiniteAmount(input.expectedAmount, "invalid_gate_input", "expectedAmount");
|
|
6775
|
+
if (input.expectedAmount <= 0) {
|
|
6776
|
+
throw gateError("invalid_gate_input", "expectedAmount is not positive");
|
|
6777
|
+
}
|
|
6400
6778
|
if (funded < input.expectedAmount) {
|
|
6401
6779
|
throw new LockupAmountMismatchError(input.expectedAmount, funded);
|
|
6402
6780
|
}
|
|
@@ -6406,8 +6784,8 @@ async function pushClaim(operator, input) {
|
|
|
6406
6784
|
assertPreimageMatches(input.preimage, input.contract.options.preimageHash);
|
|
6407
6785
|
const serverUnrollScript = await operatorUnrollScript(operator, input.network);
|
|
6408
6786
|
const leaf = input.contract.claim();
|
|
6409
|
-
const txid = await (0,
|
|
6410
|
-
identity: (0,
|
|
6787
|
+
const txid = await (0, import_sdk26.signAndSubmitOffchainTx)({
|
|
6788
|
+
identity: (0, import_sdk26.claimWithPreimageIdentity)(input.receiver, input.preimage),
|
|
6411
6789
|
provider: operator,
|
|
6412
6790
|
inputs: lockupInputs(vtxos, input.contract, leaf),
|
|
6413
6791
|
// One aggregate output: this leaf inspects nothing about the output set.
|
|
@@ -6428,7 +6806,7 @@ async function findPendingClaims(operator, indexer, input) {
|
|
|
6428
6806
|
});
|
|
6429
6807
|
const byArkTx = /* @__PURE__ */ new Map();
|
|
6430
6808
|
for (const vtxo of vtxos ?? []) {
|
|
6431
|
-
if (!(0,
|
|
6809
|
+
if (!(0, import_sdk26.isVtxoSpent)(vtxo) || !vtxo.spentBy || !vtxo.arkTxId) continue;
|
|
6432
6810
|
byArkTx.set(vtxo.arkTxId, [...byArkTx.get(vtxo.arkTxId) ?? [], vtxo]);
|
|
6433
6811
|
}
|
|
6434
6812
|
if (byArkTx.size === 0) return [];
|
|
@@ -6438,9 +6816,9 @@ async function findPendingClaims(operator, indexer, input) {
|
|
|
6438
6816
|
current,
|
|
6439
6817
|
...(deprecatedSigners ?? []).flatMap(
|
|
6440
6818
|
({ pubkey }) => pubkey ? [
|
|
6441
|
-
|
|
6819
|
+
import_sdk26.CSVMultisigTapscript.encode({
|
|
6442
6820
|
...current.params,
|
|
6443
|
-
pubkeys: [(0,
|
|
6821
|
+
pubkeys: [(0, import_sdk26.toXOnly)(import_base17.hex.decode(pubkey), "deprecated signer")]
|
|
6444
6822
|
})
|
|
6445
6823
|
] : []
|
|
6446
6824
|
)
|
|
@@ -6455,7 +6833,7 @@ async function findPendingClaims(operator, indexer, input) {
|
|
|
6455
6833
|
}));
|
|
6456
6834
|
const total = live.reduce((sum, vtxo) => sum + vtxo.value, 0);
|
|
6457
6835
|
const checkpoints = unrollScripts.map(
|
|
6458
|
-
(unroll) => (0,
|
|
6836
|
+
(unroll) => (0, import_sdk26.buildOffchainTx)(
|
|
6459
6837
|
lockupInputs(live, input.contract, input.contract.claim()),
|
|
6460
6838
|
[{ script: input.contract.pkScript, amount: BigInt(total) }],
|
|
6461
6839
|
unroll
|
|
@@ -6471,14 +6849,14 @@ async function finalizePendingClaim(operator, indexer, input) {
|
|
|
6471
6849
|
const claims = await findPendingClaims(operator, indexer, input);
|
|
6472
6850
|
if (claims.length === 0) return [];
|
|
6473
6851
|
assertPreimageMatches(input.preimage, input.contract.options.preimageHash);
|
|
6474
|
-
const signer = (0,
|
|
6852
|
+
const signer = (0, import_sdk26.claimWithPreimageIdentity)(input.receiver, input.preimage);
|
|
6475
6853
|
const ours = import_base17.hex.encode(await input.receiver.xOnlyPublicKey());
|
|
6476
6854
|
const finalized = [];
|
|
6477
6855
|
for (const { arkTxid, checkpoints } of claims) {
|
|
6478
6856
|
const { txs } = await indexer.getVirtualTxs(checkpoints.map((checkpoint) => checkpoint.id));
|
|
6479
6857
|
const stored = new Map(
|
|
6480
6858
|
txs.map((raw) => {
|
|
6481
|
-
const tx =
|
|
6859
|
+
const tx = import_sdk26.Transaction.fromPSBT(import_base17.base64.decode(raw));
|
|
6482
6860
|
return [tx.id, tx];
|
|
6483
6861
|
})
|
|
6484
6862
|
);
|
|
@@ -6516,7 +6894,7 @@ init_onchainHtlc();
|
|
|
6516
6894
|
init_coverage();
|
|
6517
6895
|
|
|
6518
6896
|
// src/migrateOfferRows.ts
|
|
6519
|
-
var
|
|
6897
|
+
var import_sdk27 = require("@arkade-os/sdk");
|
|
6520
6898
|
|
|
6521
6899
|
// src/legacy/swap-want-asset.program.v0.json
|
|
6522
6900
|
var swap_want_asset_program_v0_default = {
|
|
@@ -6608,14 +6986,14 @@ function withExitV0(program, exit) {
|
|
|
6608
6986
|
}
|
|
6609
6987
|
var V0_TO_V1 = /* @__PURE__ */ new Map();
|
|
6610
6988
|
for (const [v0, v1] of [
|
|
6611
|
-
[swap_want_btc_program_v0_default,
|
|
6612
|
-
[swap_want_asset_program_v0_default,
|
|
6989
|
+
[swap_want_btc_program_v0_default, legacySwapPrograms.wantBtc],
|
|
6990
|
+
[swap_want_asset_program_v0_default, legacySwapPrograms.wantAsset]
|
|
6613
6991
|
]) {
|
|
6614
6992
|
for (const exit of [void 0, "blocks", "seconds"]) {
|
|
6615
6993
|
const timelock = exit && { type: exit, value: BigInt(0) };
|
|
6616
6994
|
V0_TO_V1.set(
|
|
6617
6995
|
JSON.stringify(withExitV0(v0, exit)),
|
|
6618
|
-
|
|
6996
|
+
import_sdk27.arkade.stringifyArtifact(withExitClosure(v1, timelock))
|
|
6619
6997
|
);
|
|
6620
6998
|
}
|
|
6621
6999
|
}
|
|
@@ -6654,7 +7032,7 @@ init_offer();
|
|
|
6654
7032
|
init_lockupContract();
|
|
6655
7033
|
|
|
6656
7034
|
// src/refundBlocked.ts
|
|
6657
|
-
var
|
|
7035
|
+
var import_sdk28 = require("@arkade-os/sdk");
|
|
6658
7036
|
var RefundNotLocallyPossibleError = class extends Error {
|
|
6659
7037
|
constructor(reason, message, options) {
|
|
6660
7038
|
super(message, options);
|
|
@@ -6671,16 +7049,16 @@ async function senderIdentityForSwapRecord(wallet, record) {
|
|
|
6671
7049
|
);
|
|
6672
7050
|
}
|
|
6673
7051
|
try {
|
|
6674
|
-
return await (0,
|
|
7052
|
+
return await (0, import_sdk28.contractSigner)(wallet, record.signingDescriptor);
|
|
6675
7053
|
} catch (cause) {
|
|
6676
|
-
if (cause instanceof
|
|
7054
|
+
if (cause instanceof import_sdk28.WalletCannotSignError) {
|
|
6677
7055
|
throw new RefundNotLocallyPossibleError(
|
|
6678
7056
|
"unsignable-wallet",
|
|
6679
7057
|
`this wallet holds ${record.signingDescriptor} but cannot sign with it; attach its signer`,
|
|
6680
7058
|
{ cause }
|
|
6681
7059
|
);
|
|
6682
7060
|
}
|
|
6683
|
-
if (cause instanceof
|
|
7061
|
+
if (cause instanceof import_sdk28.ForeignDescriptorError) {
|
|
6684
7062
|
throw new RefundNotLocallyPossibleError(
|
|
6685
7063
|
"foreign-descriptor",
|
|
6686
7064
|
`this wallet cannot derive ${record.signingDescriptor}; the swap was created on another wallet`,
|
|
@@ -6737,7 +7115,7 @@ init_repository();
|
|
|
6737
7115
|
|
|
6738
7116
|
// src/swapManager.ts
|
|
6739
7117
|
var import_base18 = require("@scure/base");
|
|
6740
|
-
var
|
|
7118
|
+
var import_sdk29 = require("@arkade-os/sdk");
|
|
6741
7119
|
init_onchainHtlc();
|
|
6742
7120
|
init_lockupContract();
|
|
6743
7121
|
init_repository();
|
|
@@ -6868,7 +7246,7 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
6868
7246
|
timer = null;
|
|
6869
7247
|
running = false;
|
|
6870
7248
|
constructor(deps, config = {}) {
|
|
6871
|
-
(0,
|
|
7249
|
+
(0, import_sdk29.assertTimerMs)("pollIntervalMs", config.pollIntervalMs);
|
|
6872
7250
|
this.deps = deps;
|
|
6873
7251
|
this.config = {
|
|
6874
7252
|
enableAutoActions: config.enableAutoActions ?? true,
|
|
@@ -7252,7 +7630,7 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
7252
7630
|
});
|
|
7253
7631
|
return;
|
|
7254
7632
|
}
|
|
7255
|
-
if (!(0,
|
|
7633
|
+
if (!(0, import_sdk29.isContractVtxoEvent)(event)) return;
|
|
7256
7634
|
const swap = this.byLockupScript.get(event.contractScript);
|
|
7257
7635
|
if (!swap) return;
|
|
7258
7636
|
void this.pollSwap(swap).catch(() => {
|
|
@@ -7489,10 +7867,10 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
7489
7867
|
return;
|
|
7490
7868
|
}
|
|
7491
7869
|
if (!partiallyClaimed) {
|
|
7492
|
-
if (!Number.
|
|
7870
|
+
if (!Number.isSafeInteger(swap.expectedAmount) || swap.expectedAmount <= 0) {
|
|
7493
7871
|
return this.block(
|
|
7494
7872
|
swap,
|
|
7495
|
-
`expectedAmount is not a
|
|
7873
|
+
`expectedAmount is not a positive number of sats (${String(swap.expectedAmount)}), so the funded value cannot be checked \u2014 refusing to publish the preimage`
|
|
7496
7874
|
);
|
|
7497
7875
|
}
|
|
7498
7876
|
const locked = vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
|
|
@@ -7522,8 +7900,8 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
7522
7900
|
this.setState(swap, "claimed");
|
|
7523
7901
|
this.emitAction(swap, "claimLockup");
|
|
7524
7902
|
} catch (error) {
|
|
7525
|
-
const ark = (0,
|
|
7526
|
-
if ((0,
|
|
7903
|
+
const ark = (0, import_sdk29.isArkError)(error) ? error : (0, import_sdk29.maybeArkError)(error);
|
|
7904
|
+
if ((0, import_sdk29.isArkError)(ark, import_sdk29.ArkErrorName.VTXO_ALREADY_SPENT)) {
|
|
7527
7905
|
if (swap.claimFailure !== void 0) {
|
|
7528
7906
|
delete swap.claimFailure;
|
|
7529
7907
|
this.touch(swap);
|
|
@@ -7753,6 +8131,9 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
7753
8131
|
utxo,
|
|
7754
8132
|
bump ? { bump } : void 0
|
|
7755
8133
|
);
|
|
8134
|
+
if (swap.funding?.txid !== utxo.txid || swap.funding.vout !== utxo.vout || swap.funding.amount === void 0) {
|
|
8135
|
+
swap.funding = { txid: utxo.txid, vout: utxo.vout, amount: Number(utxo.amount) };
|
|
8136
|
+
}
|
|
7756
8137
|
swap.claimTxid = txid;
|
|
7757
8138
|
swap.claimBroadcastAt = this.config.now();
|
|
7758
8139
|
delete swap.claimConfirmed;
|
|
@@ -7814,8 +8195,8 @@ var RfqSwapManager = class _RfqSwapManager {
|
|
|
7814
8195
|
this.refundRefused.add(swap.rfqId);
|
|
7815
8196
|
return this.block(swap, error.message);
|
|
7816
8197
|
}
|
|
7817
|
-
const ark = (0,
|
|
7818
|
-
if ((0,
|
|
8198
|
+
const ark = (0, import_sdk29.isArkError)(error) ? error : (0, import_sdk29.maybeArkError)(error);
|
|
8199
|
+
if ((0, import_sdk29.isArkError)(ark, import_sdk29.ArkErrorName.VTXO_ALREADY_SPENT)) return;
|
|
7819
8200
|
this.emitFailed(swap, error);
|
|
7820
8201
|
if (now >= swap.refundLocktime + REFUND_MTP_LAG_SECONDS) {
|
|
7821
8202
|
swap.failure = errorMessage(error);
|
|
@@ -8008,7 +8389,7 @@ var outpointKey = (vtxo) => `${vtxo.txid}:${vtxo.vout}`;
|
|
|
8008
8389
|
|
|
8009
8390
|
// src/watch.ts
|
|
8010
8391
|
var import_base19 = require("@scure/base");
|
|
8011
|
-
var
|
|
8392
|
+
var import_sdk30 = require("@arkade-os/sdk");
|
|
8012
8393
|
init_coverage();
|
|
8013
8394
|
init_offer();
|
|
8014
8395
|
init_store();
|
|
@@ -8043,7 +8424,7 @@ async function watchOfferSwaps({
|
|
|
8043
8424
|
wallet.getAddress(),
|
|
8044
8425
|
wallet.getArkadeReader()
|
|
8045
8426
|
]);
|
|
8046
|
-
const operatorPubkey =
|
|
8427
|
+
const operatorPubkey = import_sdk30.ArkAddress.decode(address).serverPubKey;
|
|
8047
8428
|
let queue = Promise.resolve();
|
|
8048
8429
|
const enqueue = (task) => {
|
|
8049
8430
|
queue = queue.then(task).catch(() => {
|
|
@@ -8058,7 +8439,7 @@ async function watchOfferSwaps({
|
|
|
8058
8439
|
return classifyDepositSpend(
|
|
8059
8440
|
decodeOffer(import_base19.hex.decode(swap.offerHex)),
|
|
8060
8441
|
operatorPubkey,
|
|
8061
|
-
txs.map((psbt) =>
|
|
8442
|
+
txs.map((psbt) => import_sdk30.Transaction.fromPSBT(import_base19.base64.decode(psbt))),
|
|
8062
8443
|
{ txid: vtxo.txid, vout: vtxo.vout }
|
|
8063
8444
|
);
|
|
8064
8445
|
} catch {
|
|
@@ -8086,7 +8467,7 @@ async function watchOfferSwaps({
|
|
|
8086
8467
|
}
|
|
8087
8468
|
};
|
|
8088
8469
|
const unsubscribe = manager.onContractEvent((event) => {
|
|
8089
|
-
if (!(0,
|
|
8470
|
+
if (!(0, import_sdk30.isContractVtxoEvent)(event) || event.type !== "vtxo_spent") return;
|
|
8090
8471
|
enqueue(() => handleSpend(event));
|
|
8091
8472
|
});
|
|
8092
8473
|
return {
|
|
@@ -8096,7 +8477,7 @@ async function watchOfferSwaps({
|
|
|
8096
8477
|
}
|
|
8097
8478
|
|
|
8098
8479
|
// src/client/legacyRecords.ts
|
|
8099
|
-
var
|
|
8480
|
+
var import_sdk31 = require("@arkade-os/sdk");
|
|
8100
8481
|
init_repository();
|
|
8101
8482
|
var readLegacyRfqSwaps = async (repository, filter = {}) => {
|
|
8102
8483
|
try {
|
|
@@ -8113,7 +8494,7 @@ var withLegacyRfqSwaps = (bridge, repository, admits) => {
|
|
|
8113
8494
|
index: bridge.index,
|
|
8114
8495
|
quoteIdOf: bridge.quoteIdOf,
|
|
8115
8496
|
async getRfqSwapsPage(filter, page) {
|
|
8116
|
-
(0,
|
|
8497
|
+
(0, import_sdk31.assertPageRequest)(page);
|
|
8117
8498
|
assertRfqSwapPageFilter(filter);
|
|
8118
8499
|
const v2 = await collectRfqSwaps(bridge, filter);
|
|
8119
8500
|
const held = new Set(
|
|
@@ -8369,7 +8750,7 @@ var createSwapDrive = (config) => {
|
|
|
8369
8750
|
const secret = rfqClaimSecretOf(record);
|
|
8370
8751
|
if (!secret) throw new Error(`rfq swap ${swap.rfqId} carries no claim secret`);
|
|
8371
8752
|
const preimage = await preimageForSwapRecord(wallet, secret);
|
|
8372
|
-
const signer = await (0,
|
|
8753
|
+
const signer = await (0, import_sdk32.contractSigner)(wallet, await (0, import_sdk32.identityDescriptor)(wallet.identity));
|
|
8373
8754
|
const claimKey = record.profile.claimKey;
|
|
8374
8755
|
if (typeof claimKey === "string") {
|
|
8375
8756
|
const held = import_base20.hex.encode(await signer.xOnlyPublicKey());
|
|
@@ -8415,7 +8796,7 @@ var createSwapDrive = (config) => {
|
|
|
8415
8796
|
`rfq swap ${swap.rfqId} carries no refund descriptor; wire the onchain corridor's refund callback to take its L1 funding back`
|
|
8416
8797
|
);
|
|
8417
8798
|
}
|
|
8418
|
-
const signer = await (0,
|
|
8799
|
+
const signer = await (0, import_sdk32.contractSigner)(wallet, descriptor);
|
|
8419
8800
|
const held = import_base20.hex.encode(await signer.xOnlyPublicKey());
|
|
8420
8801
|
if (held !== record.profile.refundKey) {
|
|
8421
8802
|
throw new Error(
|
|
@@ -8455,7 +8836,7 @@ var createSwapDrive = (config) => {
|
|
|
8455
8836
|
}
|
|
8456
8837
|
};
|
|
8457
8838
|
const drivable = async (record) => !readsChain(record.kind) || await resolveOnchain();
|
|
8458
|
-
const pinnedNetwork = async () => (0,
|
|
8839
|
+
const pinnedNetwork = async () => (0, import_sdk32.getNetwork)(await config.network());
|
|
8459
8840
|
const claimSecretOf = async (swap) => {
|
|
8460
8841
|
const record = await corridorStore().getRfqSwap(swap.rfqId);
|
|
8461
8842
|
if (!record) throw new Error(`rfq swap ${swap.rfqId} has no stored record to claim from`);
|
|
@@ -8479,7 +8860,7 @@ var createSwapDrive = (config) => {
|
|
|
8479
8860
|
await track(
|
|
8480
8861
|
finalizePendingClaim(operator, indexer, {
|
|
8481
8862
|
contract: script,
|
|
8482
|
-
receiver: await (0,
|
|
8863
|
+
receiver: await (0, import_sdk32.contractSigner)(wallet, secret.signingDescriptor),
|
|
8483
8864
|
preimage: await preimageForSwapRecord(wallet, secret),
|
|
8484
8865
|
network: await pinnedNetwork()
|
|
8485
8866
|
})
|
|
@@ -8494,10 +8875,10 @@ var createSwapDrive = (config) => {
|
|
|
8494
8875
|
return track(
|
|
8495
8876
|
pushClaim(operator, {
|
|
8496
8877
|
contract: script,
|
|
8497
|
-
receiver: await (0,
|
|
8878
|
+
receiver: await (0, import_sdk32.contractSigner)(wallet, secret.signingDescriptor),
|
|
8498
8879
|
preimage: await preimageForSwapRecord(wallet, secret),
|
|
8499
8880
|
vtxos,
|
|
8500
|
-
destinationPkScript:
|
|
8881
|
+
destinationPkScript: import_sdk32.ArkAddress.decode(payoutAddress).pkScript,
|
|
8501
8882
|
// Passed through: `pushClaim`'s own value check decides whether `P` is published.
|
|
8502
8883
|
expectedAmount: swap.expectedAmount,
|
|
8503
8884
|
partiallyClaimed,
|
|
@@ -8568,7 +8949,7 @@ var createSwapDrive = (config) => {
|
|
|
8568
8949
|
config.network()
|
|
8569
8950
|
]);
|
|
8570
8951
|
const txs = history.map(toRestoreTx);
|
|
8571
|
-
const { hrp, serverPubKey: operatorPubkey } =
|
|
8952
|
+
const { hrp, serverPubKey: operatorPubkey } = import_sdk32.ArkAddress.decode(address);
|
|
8572
8953
|
const reopened = await legacyOfferDepositsToAdopt(store);
|
|
8573
8954
|
for (const txid of reopen) reopened.add(txid);
|
|
8574
8955
|
const cursor = reopened.size === 0 ? scanned : new Set([...scanned].filter((txid) => !reopened.has(txid)));
|
|
@@ -9502,13 +9883,13 @@ var verifyPlanLegs = (plan, legs, give) => {
|
|
|
9502
9883
|
|
|
9503
9884
|
// src/client/quoteRfq.ts
|
|
9504
9885
|
var import_base22 = require("@scure/base");
|
|
9505
|
-
var
|
|
9886
|
+
var import_sdk36 = require("@arkade-os/sdk");
|
|
9506
9887
|
var import_solver_discovery12 = require("@arkade-os/solver-discovery");
|
|
9507
9888
|
|
|
9508
9889
|
// src/jointGraph.ts
|
|
9509
9890
|
var import_base21 = require("@scure/base");
|
|
9510
9891
|
var import_sha26 = require("@noble/hashes/sha2.js");
|
|
9511
|
-
var
|
|
9892
|
+
var import_sdk33 = require("@arkade-os/sdk");
|
|
9512
9893
|
function digestJointGraph(plan, template) {
|
|
9513
9894
|
const parts = [];
|
|
9514
9895
|
const pushU32 = (value) => {
|
|
@@ -9570,7 +9951,7 @@ function verifyJointGraph(plan, template) {
|
|
|
9570
9951
|
}
|
|
9571
9952
|
}
|
|
9572
9953
|
function parseGraphTx(psbt) {
|
|
9573
|
-
return
|
|
9954
|
+
return import_sdk33.Transaction.fromPSBT(import_base21.base64.decode(psbt));
|
|
9574
9955
|
}
|
|
9575
9956
|
function deepFreeze(value) {
|
|
9576
9957
|
if (value !== null && typeof value === "object") {
|
|
@@ -9591,16 +9972,17 @@ function unsignedPsbtBytes(tx) {
|
|
|
9591
9972
|
init_claimAmountGate();
|
|
9592
9973
|
init_claimPacket();
|
|
9593
9974
|
init_offer();
|
|
9975
|
+
init_program();
|
|
9594
9976
|
init_store();
|
|
9595
9977
|
init_onchainHtlc();
|
|
9596
9978
|
init_onchainHtlc();
|
|
9597
9979
|
|
|
9598
9980
|
// src/payment/onchainSwap.ts
|
|
9599
|
-
var
|
|
9981
|
+
var import_sdk35 = require("@arkade-os/sdk");
|
|
9600
9982
|
init_onchainHtlc();
|
|
9601
9983
|
|
|
9602
9984
|
// src/payment/swapRail.ts
|
|
9603
|
-
var
|
|
9985
|
+
var import_sdk34 = require("@arkade-os/sdk");
|
|
9604
9986
|
|
|
9605
9987
|
// src/client/sats.ts
|
|
9606
9988
|
var satsOf = (value, field) => {
|
|
@@ -9657,13 +10039,13 @@ var lockupOf = (derived) => ({
|
|
|
9657
10039
|
pkScript: derived.swapPkScript
|
|
9658
10040
|
});
|
|
9659
10041
|
var covenantInputs = (input) => {
|
|
9660
|
-
const network = (0,
|
|
9661
|
-
const
|
|
10042
|
+
const network = (0, import_sdk36.networkFromOperatorInfo)(input.info);
|
|
10043
|
+
const arkade4 = input.corridors.get("arkade").deps;
|
|
9662
10044
|
return {
|
|
9663
|
-
operatorPubkey: (0,
|
|
10045
|
+
operatorPubkey: (0, import_sdk36.toXOnly)(import_base22.hex.decode(input.info.signerPubkey), "ark signer key"),
|
|
9664
10046
|
// The resolved per-network pin, never operator-reported: it lands in a covenant leaf
|
|
9665
10047
|
// that decides who can move the funds.
|
|
9666
|
-
emulatorPubkey: (0,
|
|
10048
|
+
emulatorPubkey: (0, import_sdk36.toXOnly)(import_base22.hex.decode(arkade4.emulatorPubkey), "emulator signer key"),
|
|
9667
10049
|
claimDelay: unilateralClaimDelay(Number(input.info.unilateralExitDelay)),
|
|
9668
10050
|
hrp: network.hrp
|
|
9669
10051
|
};
|
|
@@ -9721,14 +10103,13 @@ var quoteArkadeAsset = async (input) => {
|
|
|
9721
10103
|
);
|
|
9722
10104
|
}
|
|
9723
10105
|
const pair = rfqPairFor(input.legs.give, input.legs.take);
|
|
9724
|
-
const rfqId = newRfqId();
|
|
9725
10106
|
const maker = await makerPosition(input.wallet);
|
|
9726
10107
|
const receiveAddress = payment?.receiveAddress;
|
|
9727
10108
|
const receivePkScript = resolveReceivePkScript(
|
|
9728
10109
|
receiveAddress,
|
|
9729
10110
|
maker.pkScript,
|
|
9730
|
-
(0,
|
|
9731
|
-
(0,
|
|
10111
|
+
(0, import_sdk36.networkFromOperatorInfo)(input.info).hrp,
|
|
10112
|
+
(0, import_sdk36.toXOnly)(import_base22.hex.decode(input.info.signerPubkey), "ark signer key")
|
|
9732
10113
|
);
|
|
9733
10114
|
const choice = payment?.carrier;
|
|
9734
10115
|
const carrierRequest = choice === void 0 ? void 0 : choice.mode === "purchase" ? { mode: "purchase" } : {
|
|
@@ -9746,20 +10127,29 @@ var quoteArkadeAsset = async (input) => {
|
|
|
9746
10127
|
throw new Error("carrier quote expired before RFQ");
|
|
9747
10128
|
}
|
|
9748
10129
|
const request = arkadeSwapRequest({
|
|
9749
|
-
rfqId,
|
|
10130
|
+
rfqId: newRfqId(),
|
|
9750
10131
|
...sides,
|
|
9751
10132
|
amount: pinned.value,
|
|
9752
10133
|
amountSide: toRfqAmountSide(pinned.on),
|
|
9753
10134
|
makerPkScript: receivePkScript,
|
|
9754
|
-
makerPublicKey: maker.publicKey
|
|
9755
|
-
|
|
9756
|
-
const wire = await input.transport.requestQuote({
|
|
9757
|
-
...request,
|
|
9758
|
-
profile: {
|
|
9759
|
-
...request.profile,
|
|
9760
|
-
...carrierRequest === void 0 ? {} : { carrier: encodeCarrierRequest(carrierRequest) }
|
|
9761
|
-
}
|
|
10135
|
+
makerPublicKey: maker.publicKey,
|
|
10136
|
+
contractVersions: ASSET_SWAP_CONTRACT_VERSIONS
|
|
9762
10137
|
});
|
|
10138
|
+
const {
|
|
10139
|
+
quote: wire,
|
|
10140
|
+
rfqId,
|
|
10141
|
+
contractVersion
|
|
10142
|
+
} = await requestVersionedQuote(
|
|
10143
|
+
input.transport,
|
|
10144
|
+
{
|
|
10145
|
+
...request,
|
|
10146
|
+
profile: {
|
|
10147
|
+
...request.profile,
|
|
10148
|
+
...carrierRequest === void 0 ? {} : { carrier: encodeCarrierRequest(carrierRequest) }
|
|
10149
|
+
}
|
|
10150
|
+
},
|
|
10151
|
+
ASSET_SWAP_CONTRACT_VERSIONS
|
|
10152
|
+
);
|
|
9763
10153
|
verifyPair(wire.pair, pair);
|
|
9764
10154
|
const parsed = parseRfqQuote(wire);
|
|
9765
10155
|
verifyCrossAssetAmount({ pair, pinned, give: parsed.give, take: parsed.take });
|
|
@@ -9792,10 +10182,10 @@ var quoteArkadeAsset = async (input) => {
|
|
|
9792
10182
|
) - 30;
|
|
9793
10183
|
if (input.now >= validUntil) throw new Error("asset payment terms lapsed before funding");
|
|
9794
10184
|
assetPayment = {
|
|
9795
|
-
receiveAddress: receiveAddress ?? new
|
|
9796
|
-
(0,
|
|
10185
|
+
receiveAddress: receiveAddress ?? new import_sdk36.ArkAddress(
|
|
10186
|
+
(0, import_sdk36.toXOnly)(import_base22.hex.decode(input.info.signerPubkey), "ark signer key"),
|
|
9797
10187
|
maker.pkScript.slice(2),
|
|
9798
|
-
(0,
|
|
10188
|
+
(0, import_sdk36.networkFromOperatorInfo)(input.info).hrp
|
|
9799
10189
|
).encode(),
|
|
9800
10190
|
validUntil,
|
|
9801
10191
|
...carrier === void 0 ? {} : { carrier },
|
|
@@ -9820,7 +10210,8 @@ var quoteArkadeAsset = async (input) => {
|
|
|
9820
10210
|
emulatorPubkey: input.corridors.get("arkade").deps.emulatorPubkey,
|
|
9821
10211
|
maker,
|
|
9822
10212
|
...receiveAddress === void 0 ? {} : { receiveAddress },
|
|
9823
|
-
info: input.info
|
|
10213
|
+
info: input.info,
|
|
10214
|
+
contractVersion
|
|
9824
10215
|
});
|
|
9825
10216
|
verifyingDerivation(() => verifyOfferAddress(wire, offer));
|
|
9826
10217
|
return {
|
|
@@ -9875,14 +10266,14 @@ var assetSidesOf = (legs) => {
|
|
|
9875
10266
|
{ give: "arkade", take: "arkade" }
|
|
9876
10267
|
);
|
|
9877
10268
|
}
|
|
9878
|
-
return giveIsBtc ? { wantAsset:
|
|
10269
|
+
return giveIsBtc ? { wantAsset: import_sdk36.asset.AssetId.fromString(legs.take.assetId) } : { offerAsset: import_sdk36.asset.AssetId.fromString(legs.give.assetId) };
|
|
9879
10270
|
};
|
|
9880
10271
|
var makerPosition = async (wallet) => {
|
|
9881
10272
|
const [address, publicKey] = await Promise.all([
|
|
9882
10273
|
wallet.getAddress(),
|
|
9883
10274
|
wallet.identity.xOnlyPublicKey()
|
|
9884
10275
|
]);
|
|
9885
|
-
return { pkScript:
|
|
10276
|
+
return { pkScript: import_sdk36.ArkAddress.decode(address).pkScript, publicKey };
|
|
9886
10277
|
};
|
|
9887
10278
|
var quoteLightningSend = async (input) => {
|
|
9888
10279
|
const invoice = input.endpoints.take.instrument;
|
|
@@ -9891,7 +10282,7 @@ var quoteLightningSend = async (input) => {
|
|
|
9891
10282
|
}
|
|
9892
10283
|
const pair = rfqPairFor(input.legs.give, input.legs.take);
|
|
9893
10284
|
const rfqId = newRfqId();
|
|
9894
|
-
const secrets = await (0,
|
|
10285
|
+
const secrets = await (0, import_sdk36.provisionRefundKey)(input.wallet);
|
|
9895
10286
|
const wire = await input.transport.requestQuote(
|
|
9896
10287
|
lightningSendRequest({
|
|
9897
10288
|
rfqId,
|
|
@@ -9967,7 +10358,7 @@ var quoteLightningReceive = async (input) => {
|
|
|
9967
10358
|
const pair = rfqPairFor(input.legs.give, input.legs.take);
|
|
9968
10359
|
const rfqId = newRfqId();
|
|
9969
10360
|
const [secrets, payoutAddress] = await Promise.all([
|
|
9970
|
-
(0,
|
|
10361
|
+
(0, import_sdk36.provisionClaimSecret)(input.wallet),
|
|
9971
10362
|
input.wallet.getAddress()
|
|
9972
10363
|
]);
|
|
9973
10364
|
const paymentHash = import_base22.hex.encode(secrets.paymentHash);
|
|
@@ -10087,8 +10478,8 @@ var quoteOnchainSend = async (input) => {
|
|
|
10087
10478
|
}) : void 0;
|
|
10088
10479
|
const quoted = claimFee === void 0 ? pinned : { on: pinned.on, value: pinned.value + claimFee, source: pinned.source };
|
|
10089
10480
|
const [secrets, payoutKey] = await Promise.all([
|
|
10090
|
-
(0,
|
|
10091
|
-
(0,
|
|
10481
|
+
(0, import_sdk36.provisionClaimSecret)(input.wallet),
|
|
10482
|
+
(0, import_sdk36.provisionRefundKey)(input.wallet)
|
|
10092
10483
|
]);
|
|
10093
10484
|
const paymentHash = import_base22.hex.encode(secrets.paymentHash);
|
|
10094
10485
|
const wire = await input.transport.requestQuote(
|
|
@@ -10196,8 +10587,8 @@ var quoteOnchainReceive = async (input) => {
|
|
|
10196
10587
|
const rfqId = newRfqId();
|
|
10197
10588
|
const l1Network = l1NetworkFromArk(input.info.network);
|
|
10198
10589
|
const [secrets, refundKey, payoutAddress, boardingAddress] = await Promise.all([
|
|
10199
|
-
(0,
|
|
10200
|
-
(0,
|
|
10590
|
+
(0, import_sdk36.provisionClaimSecret)(input.wallet),
|
|
10591
|
+
(0, import_sdk36.provisionRefundKey)(input.wallet),
|
|
10201
10592
|
input.wallet.getAddress(),
|
|
10202
10593
|
input.wallet.getBoardingAddress()
|
|
10203
10594
|
]);
|
|
@@ -10307,7 +10698,7 @@ var quoteOnchainReceive = async (input) => {
|
|
|
10307
10698
|
};
|
|
10308
10699
|
|
|
10309
10700
|
// src/client/verbs.ts
|
|
10310
|
-
var
|
|
10701
|
+
var import_sdk37 = require("@arkade-os/sdk");
|
|
10311
10702
|
var enforceFeeCeiling = (quote, call, policy) => {
|
|
10312
10703
|
let ceiling;
|
|
10313
10704
|
for (const [source, limit] of [
|
|
@@ -10332,14 +10723,14 @@ var settle = async (deps, input, maxFee) => {
|
|
|
10332
10723
|
return deps.accept(quote);
|
|
10333
10724
|
};
|
|
10334
10725
|
var pay = async (deps, destination, options = {}) => {
|
|
10335
|
-
const
|
|
10336
|
-
if (
|
|
10337
|
-
const amount = (0,
|
|
10726
|
+
const arkade4 = (0, import_sdk37.arkTarget)(destination);
|
|
10727
|
+
if (arkade4 !== void 0) {
|
|
10728
|
+
const amount = (0, import_sdk37.resolveSendAmount)(
|
|
10338
10729
|
"ark",
|
|
10339
10730
|
destination,
|
|
10340
10731
|
options.amount === void 0 ? void 0 : satsOf(options.amount, "amount")
|
|
10341
10732
|
);
|
|
10342
|
-
return { kind: "payment", txid: await deps.wallet.send({ address:
|
|
10733
|
+
return { kind: "payment", txid: await deps.wallet.send({ address: arkade4, amount }) };
|
|
10343
10734
|
}
|
|
10344
10735
|
const swap = await settle(
|
|
10345
10736
|
deps,
|
|
@@ -10545,7 +10936,7 @@ var createSwapClient = (config) => {
|
|
|
10545
10936
|
}
|
|
10546
10937
|
},
|
|
10547
10938
|
accept: async (quote, options) => {
|
|
10548
|
-
const validUntil = (0,
|
|
10939
|
+
const validUntil = (0, import_sdk38.captureSendDeadline)(options?.validUntil);
|
|
10549
10940
|
ensureLive("accept");
|
|
10550
10941
|
const { corridors } = await resolved();
|
|
10551
10942
|
const drive2 = driving();
|
|
@@ -10657,7 +11048,7 @@ var createSwapClient = (config) => {
|
|
|
10657
11048
|
|
|
10658
11049
|
// src/reveal.ts
|
|
10659
11050
|
var import_base24 = require("@scure/base");
|
|
10660
|
-
var
|
|
11051
|
+
var import_sdk39 = require("@arkade-os/sdk");
|
|
10661
11052
|
init_claimAmountGate();
|
|
10662
11053
|
init_claimPacket();
|
|
10663
11054
|
init_onchainHtlc();
|
|
@@ -10707,7 +11098,7 @@ var covclaimdClient = (baseUrl, options = {}) => {
|
|
|
10707
11098
|
const url = baseUrl.replace(/\/+$/, "");
|
|
10708
11099
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
10709
11100
|
const timeoutMs = options.timeoutMs ?? 3e4;
|
|
10710
|
-
(0,
|
|
11101
|
+
(0, import_sdk39.assertTimerMs)("timeoutMs", timeoutMs);
|
|
10711
11102
|
const send = async (what, path, init) => {
|
|
10712
11103
|
let response;
|
|
10713
11104
|
try {
|
|
@@ -10779,7 +11170,7 @@ function revealFieldsFromScript(script) {
|
|
|
10779
11170
|
}
|
|
10780
11171
|
async function revealClaimPacket(client, input) {
|
|
10781
11172
|
const fields = revealFieldsFromScript(input.script);
|
|
10782
|
-
if (import_base24.hex.encode(
|
|
11173
|
+
if (import_base24.hex.encode(import_sdk39.ArkAddress.decode(input.address).pkScript) !== import_base24.hex.encode(input.script.pkScript)) {
|
|
10783
11174
|
throw new Error("address does not belong to this covenant");
|
|
10784
11175
|
}
|
|
10785
11176
|
assertPreimageMatches(input.preimage, input.script.options.preimageHash);
|
|
@@ -10796,7 +11187,7 @@ async function revealClaimPacket(client, input) {
|
|
|
10796
11187
|
|
|
10797
11188
|
// src/offerFillPlan.ts
|
|
10798
11189
|
var import_base25 = require("@scure/base");
|
|
10799
|
-
var
|
|
11190
|
+
var import_sdk40 = require("@arkade-os/sdk");
|
|
10800
11191
|
init_offer();
|
|
10801
11192
|
var OFFER_FILL_TEMPLATE = "offer-fill/1";
|
|
10802
11193
|
var OFFER_FILL_OWNERS = [null, "solver", "sponsor"];
|
|
@@ -10814,7 +11205,7 @@ async function buildOfferFillPlan(wallet, arkServerUrl, offerHex, opts) {
|
|
|
10814
11205
|
const contract = await connectFillContract(wallet, arkServerUrl, offer, { swapAddress });
|
|
10815
11206
|
const vtxos = await contract.getUtxos();
|
|
10816
11207
|
const vtxo = resolveDeposit(vtxos, { fundingTxid, fundingOutpoint });
|
|
10817
|
-
const solverPayout = payoutScript ??
|
|
11208
|
+
const solverPayout = payoutScript ?? import_sdk40.ArkAddress.decode(await wallet.getAddress()).pkScript;
|
|
10818
11209
|
const sponsorLeg = sponsor !== void 0 ? normalizeSponsor(sponsor, assetCarrierSats) : void 0;
|
|
10819
11210
|
const fill = contract.functions.fulfill();
|
|
10820
11211
|
const layout = assembleOfferFill(fill, {
|
|
@@ -10881,14 +11272,14 @@ function toJointGraph(arkTx, checkpoints, layout, wantedAssetId) {
|
|
|
10881
11272
|
}
|
|
10882
11273
|
});
|
|
10883
11274
|
const ext = arkTx.getOutput(payments);
|
|
10884
|
-
if (!ext?.script || !
|
|
11275
|
+
if (!ext?.script || !import_sdk40.Extension.isExtension(ext.script)) {
|
|
10885
11276
|
throw new Error(`fill plan output ${payments} is not the extension packet`);
|
|
10886
11277
|
}
|
|
10887
11278
|
const anchor = arkTx.getOutput(payments + 1);
|
|
10888
|
-
if (!anchor?.script || import_base25.hex.encode(anchor.script) !== import_base25.hex.encode(
|
|
11279
|
+
if (!anchor?.script || import_base25.hex.encode(anchor.script) !== import_base25.hex.encode(import_sdk40.P2A.script) || anchor.amount !== import_sdk40.P2A.amount) {
|
|
10889
11280
|
throw new Error(`fill plan output ${payments + 1} is not the anchor`);
|
|
10890
11281
|
}
|
|
10891
|
-
const packet =
|
|
11282
|
+
const packet = import_sdk40.Extension.fromTx(arkTx).getAssetPacket();
|
|
10892
11283
|
for (const group of packet?.groups ?? []) {
|
|
10893
11284
|
if (group.assetId === null) throw new Error("fill plan carries an issuance group");
|
|
10894
11285
|
const assetId = group.assetId.toString();
|
|
@@ -10899,7 +11290,7 @@ function toJointGraph(arkTx, checkpoints, layout, wantedAssetId) {
|
|
|
10899
11290
|
}
|
|
10900
11291
|
for (const output of group.outputs) {
|
|
10901
11292
|
const hosted = arkTx.getOutput(output.vout);
|
|
10902
|
-
if (output.vout >= payments || !hosted?.script ||
|
|
11293
|
+
if (output.vout >= payments || !hosted?.script || import_sdk40.Extension.isExtension(hosted.script)) {
|
|
10903
11294
|
throw new Error(
|
|
10904
11295
|
`fill plan asset ${assetId} pays nonexistent output ${output.vout}`
|
|
10905
11296
|
);
|