@1sat/wallet-toolbox 0.0.28 → 0.0.30

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.
@@ -181,18 +181,30 @@ export async function buildTransferOrdinals(ctx, request) {
181
181
  }
182
182
  const sourceName = extractName(ordinal.customInstructions);
183
183
  inputs.push({ outpoint, inputDescription: "Ordinal to transfer", unlockingScriptLength: 108 });
184
- outputs.push({
185
- lockingScript: new P2PKH().lock(recipientAddress).toHex(),
186
- satoshis: 1,
187
- outputDescription: "Ordinal transfer",
188
- basket: ORDINALS_BASKET,
189
- tags,
190
- customInstructions: JSON.stringify({
191
- protocolID: ONESAT_PROTOCOL,
192
- keyID: outpoint,
193
- ...(sourceName && { name: sourceName }),
194
- }),
195
- });
184
+ // Only track output in wallet when transferring to a counterparty (wallet can derive keys to spend it)
185
+ // External address transfers are NOT tracked since the wallet cannot spend them
186
+ if (counterparty) {
187
+ outputs.push({
188
+ lockingScript: new P2PKH().lock(recipientAddress).toHex(),
189
+ satoshis: 1,
190
+ outputDescription: "Ordinal transfer",
191
+ basket: ORDINALS_BASKET,
192
+ tags,
193
+ customInstructions: JSON.stringify({
194
+ protocolID: ONESAT_PROTOCOL,
195
+ keyID: outpoint,
196
+ ...(sourceName && { name: sourceName }),
197
+ }),
198
+ });
199
+ }
200
+ else {
201
+ // External address - output is not tracked in wallet
202
+ outputs.push({
203
+ lockingScript: new P2PKH().lock(recipientAddress).toHex(),
204
+ satoshis: 1,
205
+ outputDescription: "Ordinal transfer to external address",
206
+ });
207
+ }
196
208
  }
197
209
  return {
198
210
  description: transfers.length === 1 ? "Transfer ordinal" : `Transfer ${transfers.length} ordinals`,
@@ -337,10 +349,12 @@ export const transferOrdinals = {
337
349
  const spends = {};
338
350
  for (let i = 0; i < input.transfers.length; i++) {
339
351
  const { ordinal } = input.transfers[i];
352
+ console.log(`[transferOrdinals] Input ${i}: outpoint=${ordinal.outpoint}, customInstructions=${ordinal.customInstructions}`);
340
353
  if (!ordinal.customInstructions) {
341
354
  return { error: `missing-custom-instructions-for-${ordinal.outpoint}` };
342
355
  }
343
356
  const { protocolID, keyID } = JSON.parse(ordinal.customInstructions);
357
+ console.log(`[transferOrdinals] Input ${i}: protocolID=${JSON.stringify(protocolID)}, keyID=${keyID}`);
344
358
  const unlocking = await signP2PKHInput(ctx, tx, i, protocolID, keyID);
345
359
  if (typeof unlocking !== "string")
346
360
  return unlocking;
@@ -310,17 +310,19 @@ export const sweepOrdinals = {
310
310
  tags.push(`type:${input.contentType}`);
311
311
  if (input.origin)
312
312
  tags.push(`origin:${input.origin}`);
313
+ const customInstructions = JSON.stringify({
314
+ protocolID: ONESAT_PROTOCOL,
315
+ keyID: input.outpoint,
316
+ ...(input.name && { name: input.name.slice(0, 64) }),
317
+ });
318
+ console.log(`[sweepOrdinals] Output for ${input.outpoint}: keyID=${input.outpoint}, customInstructions=${customInstructions}`);
313
319
  outputs.push({
314
320
  lockingScript: lockingScript.toHex(),
315
321
  satoshis: 1,
316
322
  outputDescription: `Ordinal ${input.origin ?? input.outpoint}`,
317
323
  basket: "1sat",
318
324
  tags,
319
- customInstructions: JSON.stringify({
320
- protocolID: ONESAT_PROTOCOL,
321
- keyID: input.outpoint,
322
- ...(input.name && { name: input.name.slice(0, 64) }),
323
- }),
325
+ customInstructions,
324
326
  });
325
327
  }
326
328
  const beefData = firstBeef.toBinary();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/wallet-toolbox",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
5
5
  "author": "1Sat Team",
6
6
  "license": "MIT",
@@ -44,7 +44,7 @@
44
44
  "fflate": "^0.8.2"
45
45
  },
46
46
  "peerDependencies": {
47
- "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.15"
47
+ "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.16"
48
48
  },
49
49
  "peerDependenciesMeta": {
50
50
  "@bsv/wallet-toolbox-mobile": {
@@ -53,8 +53,8 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@biomejs/biome": "^1.9.4",
56
- "@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@^1.7.20-idb-fix.15",
57
- "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.15",
56
+ "@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@^1.7.20-idb-fix.16",
57
+ "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.16",
58
58
  "@types/bun": "^1.3.4",
59
59
  "@types/chrome": "^0.1.32",
60
60
  "typescript": "^5.9.3"