@1sat/wallet-toolbox 0.0.26 → 0.0.27
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.
|
@@ -8,6 +8,20 @@ import { BigNumber, Hash, LockingScript, OP, P2PKH, PublicKey, Script, Transacti
|
|
|
8
8
|
import { OrdLock } from "@bopen-io/templates";
|
|
9
9
|
import { ORDINALS_BASKET, ORDLOCK_PREFIX, ORDLOCK_SUFFIX, ONESAT_PROTOCOL } from "../constants";
|
|
10
10
|
// ============================================================================
|
|
11
|
+
// Helpers
|
|
12
|
+
// ============================================================================
|
|
13
|
+
function extractName(customInstructions) {
|
|
14
|
+
if (!customInstructions)
|
|
15
|
+
return undefined;
|
|
16
|
+
try {
|
|
17
|
+
const parsed = JSON.parse(customInstructions);
|
|
18
|
+
return parsed.name;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// ============================================================================
|
|
11
25
|
// Internal helpers
|
|
12
26
|
// ============================================================================
|
|
13
27
|
async function deriveCancelAddressInternal(ctx, outpoint) {
|
|
@@ -123,6 +137,7 @@ export async function buildTransferOrdinal(ctx, request) {
|
|
|
123
137
|
tags.push(tag);
|
|
124
138
|
}
|
|
125
139
|
}
|
|
140
|
+
const sourceName = extractName(sourceOutput.customInstructions);
|
|
126
141
|
return {
|
|
127
142
|
description: "Transfer ordinal",
|
|
128
143
|
inputs: [{ outpoint, inputDescription: "Ordinal to transfer" }],
|
|
@@ -136,6 +151,7 @@ export async function buildTransferOrdinal(ctx, request) {
|
|
|
136
151
|
customInstructions: JSON.stringify({
|
|
137
152
|
protocolID: ONESAT_PROTOCOL,
|
|
138
153
|
keyID: outpoint,
|
|
154
|
+
...(sourceName && { name: sourceName }),
|
|
139
155
|
}),
|
|
140
156
|
},
|
|
141
157
|
],
|
|
@@ -154,6 +170,7 @@ export async function buildListOrdinal(ctx, request) {
|
|
|
154
170
|
const result = await ctx.wallet.listOutputs({
|
|
155
171
|
basket: ORDINALS_BASKET,
|
|
156
172
|
includeTags: true,
|
|
173
|
+
includeCustomInstructions: true,
|
|
157
174
|
include: "locking scripts",
|
|
158
175
|
limit: 10000,
|
|
159
176
|
});
|
|
@@ -165,6 +182,7 @@ export async function buildListOrdinal(ctx, request) {
|
|
|
165
182
|
const originTag = sourceOutput.tags?.find((t) => t.startsWith("origin:"));
|
|
166
183
|
const nameTag = sourceOutput.tags?.find((t) => t.startsWith("name:"));
|
|
167
184
|
const originOutpoint = originTag ? originTag.slice(7) : outpoint;
|
|
185
|
+
const sourceName = extractName(sourceOutput.customInstructions);
|
|
168
186
|
const cancelAddress = await deriveCancelAddressInternal(ctx, outpoint);
|
|
169
187
|
const lockingScript = buildOrdLockScript(cancelAddress, payAddress, price);
|
|
170
188
|
const tags = ["ordlock", `origin:${originOutpoint}`, `price:${price}`];
|
|
@@ -185,6 +203,7 @@ export async function buildListOrdinal(ctx, request) {
|
|
|
185
203
|
customInstructions: JSON.stringify({
|
|
186
204
|
protocolID: ONESAT_PROTOCOL,
|
|
187
205
|
keyID: outpoint,
|
|
206
|
+
...(sourceName && { name: sourceName }),
|
|
188
207
|
}),
|
|
189
208
|
},
|
|
190
209
|
],
|
|
@@ -347,7 +366,7 @@ export const cancelListing = {
|
|
|
347
366
|
if (!listing.customInstructions) {
|
|
348
367
|
return { error: "missing-custom-instructions" };
|
|
349
368
|
}
|
|
350
|
-
const { protocolID, keyID } = JSON.parse(listing.customInstructions);
|
|
369
|
+
const { protocolID, keyID, name: listingName } = JSON.parse(listing.customInstructions);
|
|
351
370
|
const typeTag = listing.tags?.find((t) => t.startsWith("type:"));
|
|
352
371
|
const originTag = listing.tags?.find((t) => t.startsWith("origin:"));
|
|
353
372
|
const nameTag = listing.tags?.find((t) => t.startsWith("name:"));
|
|
@@ -375,7 +394,7 @@ export const cancelListing = {
|
|
|
375
394
|
outputDescription: "Cancelled listing",
|
|
376
395
|
basket: ORDINALS_BASKET,
|
|
377
396
|
tags,
|
|
378
|
-
customInstructions: JSON.stringify({ protocolID, keyID }),
|
|
397
|
+
customInstructions: JSON.stringify({ protocolID, keyID, ...(listingName && { name: listingName }) }),
|
|
379
398
|
},
|
|
380
399
|
],
|
|
381
400
|
options: { signAndProcess: false, randomizeOutputs: false },
|
|
@@ -523,6 +542,7 @@ export const purchaseOrdinal = {
|
|
|
523
542
|
customInstructions: JSON.stringify({
|
|
524
543
|
protocolID: ONESAT_PROTOCOL,
|
|
525
544
|
keyID: outpoint,
|
|
545
|
+
...(name && { name: name.slice(0, 64) }),
|
|
526
546
|
}),
|
|
527
547
|
});
|
|
528
548
|
const payoutReader = new Utils.Reader(ordLockData.payout);
|
package/dist/api/sweep/index.js
CHANGED
|
@@ -308,8 +308,6 @@ export const sweepOrdinals = {
|
|
|
308
308
|
tags.push(`type:${input.contentType}`);
|
|
309
309
|
if (input.origin)
|
|
310
310
|
tags.push(`origin:${input.origin}`);
|
|
311
|
-
if (input.name)
|
|
312
|
-
tags.push(`name:${input.name}`);
|
|
313
311
|
outputs.push({
|
|
314
312
|
lockingScript: lockingScript.toHex(),
|
|
315
313
|
satoshis: 1,
|
|
@@ -319,6 +317,7 @@ export const sweepOrdinals = {
|
|
|
319
317
|
customInstructions: JSON.stringify({
|
|
320
318
|
protocolID: ONESAT_PROTOCOL,
|
|
321
319
|
keyID: input.outpoint,
|
|
320
|
+
...(input.name && { name: input.name.slice(0, 64) }),
|
|
322
321
|
}),
|
|
323
322
|
});
|
|
324
323
|
}
|
package/dist/sync/SyncManager.js
CHANGED
|
@@ -352,17 +352,18 @@ export class SyncProcessor {
|
|
|
352
352
|
// These outputs need custom unlock scripts when spent
|
|
353
353
|
const basket = txo.basket || "custom";
|
|
354
354
|
const tags = this.collectTags(txo);
|
|
355
|
+
const nameTag = tags.find((t) => t.startsWith("name:"));
|
|
355
356
|
return {
|
|
356
357
|
outputIndex: vout,
|
|
357
358
|
protocol: "basket insertion",
|
|
358
359
|
insertionRemittance: {
|
|
359
360
|
basket,
|
|
360
361
|
tags,
|
|
361
|
-
// Store derivation info for future signing
|
|
362
362
|
customInstructions: JSON.stringify({
|
|
363
363
|
derivationPrefix: derivation.derivationPrefix,
|
|
364
364
|
derivationSuffix: derivation.derivationSuffix,
|
|
365
365
|
senderIdentityKey: derivation.senderIdentityKey,
|
|
366
|
+
...(nameTag && { name: nameTag.slice(5).slice(0, 64) }),
|
|
366
367
|
}),
|
|
367
368
|
},
|
|
368
369
|
};
|