@1sat/wallet-toolbox 0.0.25 → 0.0.26
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.
|
@@ -61,6 +61,11 @@ export const inscribe = {
|
|
|
61
61
|
});
|
|
62
62
|
const address = PublicKey.fromString(publicKey).toAddress();
|
|
63
63
|
const lockingScript = buildInscriptionScript(address, input.base64Content, input.contentType);
|
|
64
|
+
// Build tags - type is always included, name from MAP if provided
|
|
65
|
+
const tags = [`type:${input.contentType}`];
|
|
66
|
+
if (input.map?.name) {
|
|
67
|
+
tags.push(`name:${input.map.name}`);
|
|
68
|
+
}
|
|
64
69
|
const result = await ctx.wallet.createAction({
|
|
65
70
|
description: "Create inscription",
|
|
66
71
|
outputs: [
|
|
@@ -69,7 +74,7 @@ export const inscribe = {
|
|
|
69
74
|
satoshis: 1,
|
|
70
75
|
outputDescription: "Inscription",
|
|
71
76
|
basket: ORDINALS_BASKET,
|
|
72
|
-
tags
|
|
77
|
+
tags,
|
|
73
78
|
customInstructions: JSON.stringify({
|
|
74
79
|
protocolID: ONESAT_PROTOCOL,
|
|
75
80
|
keyID,
|
|
@@ -36,6 +36,8 @@ export interface PurchaseOrdinalRequest {
|
|
|
36
36
|
contentType?: string;
|
|
37
37
|
/** Optional origin outpoint - looked up from ordfs API if not provided */
|
|
38
38
|
origin?: string;
|
|
39
|
+
/** Optional name from MAP metadata - looked up from ordfs API if not provided */
|
|
40
|
+
name?: string;
|
|
39
41
|
}
|
|
40
42
|
export interface OrdinalOperationResponse {
|
|
41
43
|
txid?: string;
|
|
@@ -107,12 +107,22 @@ export async function buildTransferOrdinal(ctx, request) {
|
|
|
107
107
|
}
|
|
108
108
|
const result = await ctx.wallet.listOutputs({
|
|
109
109
|
basket: ORDINALS_BASKET,
|
|
110
|
+
includeTags: true,
|
|
111
|
+
includeCustomInstructions: true,
|
|
110
112
|
include: "locking scripts",
|
|
111
113
|
limit: 10000,
|
|
112
114
|
});
|
|
113
|
-
|
|
115
|
+
const sourceOutput = result.outputs.find((o) => o.outpoint === outpoint);
|
|
116
|
+
if (!sourceOutput) {
|
|
114
117
|
return { error: "ordinal-not-found" };
|
|
115
118
|
}
|
|
119
|
+
// Preserve important tags from source output
|
|
120
|
+
const tags = [];
|
|
121
|
+
for (const tag of sourceOutput.tags ?? []) {
|
|
122
|
+
if (tag.startsWith("type:") || tag.startsWith("origin:") || tag.startsWith("name:")) {
|
|
123
|
+
tags.push(tag);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
116
126
|
return {
|
|
117
127
|
description: "Transfer ordinal",
|
|
118
128
|
inputs: [{ outpoint, inputDescription: "Ordinal to transfer" }],
|
|
@@ -121,6 +131,12 @@ export async function buildTransferOrdinal(ctx, request) {
|
|
|
121
131
|
lockingScript: new P2PKH().lock(recipientAddress).toHex(),
|
|
122
132
|
satoshis: 1,
|
|
123
133
|
outputDescription: "Ordinal transfer",
|
|
134
|
+
basket: ORDINALS_BASKET,
|
|
135
|
+
tags,
|
|
136
|
+
customInstructions: JSON.stringify({
|
|
137
|
+
protocolID: ONESAT_PROTOCOL,
|
|
138
|
+
keyID: outpoint,
|
|
139
|
+
}),
|
|
124
140
|
},
|
|
125
141
|
],
|
|
126
142
|
};
|
|
@@ -147,12 +163,15 @@ export async function buildListOrdinal(ctx, request) {
|
|
|
147
163
|
}
|
|
148
164
|
const typeTag = sourceOutput.tags?.find((t) => t.startsWith("type:"));
|
|
149
165
|
const originTag = sourceOutput.tags?.find((t) => t.startsWith("origin:"));
|
|
166
|
+
const nameTag = sourceOutput.tags?.find((t) => t.startsWith("name:"));
|
|
150
167
|
const originOutpoint = originTag ? originTag.slice(7) : outpoint;
|
|
151
168
|
const cancelAddress = await deriveCancelAddressInternal(ctx, outpoint);
|
|
152
169
|
const lockingScript = buildOrdLockScript(cancelAddress, payAddress, price);
|
|
153
170
|
const tags = ["ordlock", `origin:${originOutpoint}`, `price:${price}`];
|
|
154
171
|
if (typeTag)
|
|
155
172
|
tags.push(typeTag);
|
|
173
|
+
if (nameTag)
|
|
174
|
+
tags.push(nameTag);
|
|
156
175
|
return {
|
|
157
176
|
description: `List ordinal for ${price} sats`,
|
|
158
177
|
inputs: [{ outpoint, inputDescription: "Ordinal to list" }],
|
|
@@ -331,12 +350,15 @@ export const cancelListing = {
|
|
|
331
350
|
const { protocolID, keyID } = JSON.parse(listing.customInstructions);
|
|
332
351
|
const typeTag = listing.tags?.find((t) => t.startsWith("type:"));
|
|
333
352
|
const originTag = listing.tags?.find((t) => t.startsWith("origin:"));
|
|
353
|
+
const nameTag = listing.tags?.find((t) => t.startsWith("name:"));
|
|
334
354
|
const cancelAddress = await deriveCancelAddressInternal(ctx, keyID);
|
|
335
355
|
const tags = [];
|
|
336
356
|
if (typeTag)
|
|
337
357
|
tags.push(typeTag);
|
|
338
358
|
if (originTag)
|
|
339
359
|
tags.push(originTag);
|
|
360
|
+
if (nameTag)
|
|
361
|
+
tags.push(nameTag);
|
|
340
362
|
const createResult = await ctx.wallet.createAction({
|
|
341
363
|
description: "Cancel ordinal listing",
|
|
342
364
|
inputs: [
|
|
@@ -454,11 +476,18 @@ export const purchaseOrdinal = {
|
|
|
454
476
|
}
|
|
455
477
|
const [txid, voutStr] = parts;
|
|
456
478
|
const vout = Number.parseInt(voutStr, 10);
|
|
457
|
-
let { contentType, origin } = input;
|
|
458
|
-
if (!contentType || !origin) {
|
|
479
|
+
let { contentType, origin, name } = input;
|
|
480
|
+
if (!contentType || !origin || name === undefined) {
|
|
459
481
|
const metadata = await ctx.services.ordfs.getMetadata(outpoint);
|
|
460
482
|
contentType = contentType ?? metadata.contentType;
|
|
461
483
|
origin = origin ?? metadata.origin ?? outpoint;
|
|
484
|
+
// Extract name from map.name or map.subTypeData.name
|
|
485
|
+
if (name === undefined && metadata.map) {
|
|
486
|
+
const mapName = metadata.map.name;
|
|
487
|
+
const subTypeData = metadata.map.subTypeData;
|
|
488
|
+
name = (typeof mapName === "string" ? mapName : undefined) ??
|
|
489
|
+
(typeof subTypeData?.name === "string" ? subTypeData.name : undefined);
|
|
490
|
+
}
|
|
462
491
|
}
|
|
463
492
|
const beef = await ctx.services.getBeefForTxid(txid);
|
|
464
493
|
const listingBeefTx = beef.findTxid(txid);
|
|
@@ -482,12 +511,15 @@ export const purchaseOrdinal = {
|
|
|
482
511
|
const ourOrdAddress = PublicKey.fromString(publicKey).toAddress();
|
|
483
512
|
const outputs = [];
|
|
484
513
|
const p2pkh = new P2PKH();
|
|
514
|
+
const purchaseTags = [`type:${contentType}`, `origin:${origin}`];
|
|
515
|
+
if (name)
|
|
516
|
+
purchaseTags.push(`name:${name}`);
|
|
485
517
|
outputs.push({
|
|
486
518
|
lockingScript: p2pkh.lock(ourOrdAddress).toHex(),
|
|
487
519
|
satoshis: 1,
|
|
488
520
|
outputDescription: "Purchased ordinal",
|
|
489
521
|
basket: ORDINALS_BASKET,
|
|
490
|
-
tags:
|
|
522
|
+
tags: purchaseTags,
|
|
491
523
|
customInstructions: JSON.stringify({
|
|
492
524
|
protocolID: ONESAT_PROTOCOL,
|
|
493
525
|
keyID: outpoint,
|
package/dist/api/sweep/index.js
CHANGED
|
@@ -244,6 +244,7 @@ export const sweepOrdinals = {
|
|
|
244
244
|
lockingScript: { type: "string", description: "Locking script hex" },
|
|
245
245
|
contentType: { type: "string", description: "Content type from metadata" },
|
|
246
246
|
origin: { type: "string", description: "Origin outpoint" },
|
|
247
|
+
name: { type: "string", description: "Name from MAP metadata" },
|
|
247
248
|
},
|
|
248
249
|
required: ["outpoint", "satoshis", "lockingScript"],
|
|
249
250
|
},
|
|
@@ -307,6 +308,8 @@ export const sweepOrdinals = {
|
|
|
307
308
|
tags.push(`type:${input.contentType}`);
|
|
308
309
|
if (input.origin)
|
|
309
310
|
tags.push(`origin:${input.origin}`);
|
|
311
|
+
if (input.name)
|
|
312
|
+
tags.push(`name:${input.name}`);
|
|
310
313
|
outputs.push({
|
|
311
314
|
lockingScript: lockingScript.toHex(),
|
|
312
315
|
satoshis: 1,
|
|
@@ -34,6 +34,8 @@ export interface SweepOrdinalInput extends SweepInput {
|
|
|
34
34
|
contentType?: string;
|
|
35
35
|
/** Origin outpoint for tracking */
|
|
36
36
|
origin?: string;
|
|
37
|
+
/** Name from MAP metadata */
|
|
38
|
+
name?: string;
|
|
37
39
|
}
|
|
38
40
|
/** Request to sweep ordinals */
|
|
39
41
|
export interface SweepOrdinalsRequest {
|