@1sat/wallet-toolbox 0.0.46 → 0.0.48

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.
@@ -219,7 +219,7 @@ export const unlockBsv = {
219
219
  },
220
220
  ],
221
221
  lockTime: maxUntil,
222
- options: { signAndProcess: false },
222
+ options: { signAndProcess: false, noSend: true },
223
223
  });
224
224
  if ("error" in createResult && createResult.error) {
225
225
  return { error: String(createResult.error) };
@@ -270,6 +270,7 @@ export const unlockBsv = {
270
270
  const signResult = await ctx.wallet.signAction({
271
271
  reference: createResult.signableTransaction.reference,
272
272
  spends,
273
+ options: { noSend: false },
273
274
  });
274
275
  if ("error" in signResult) {
275
276
  return { error: String(signResult.error) };
@@ -340,7 +340,7 @@ export const transferOrdinals = {
340
340
  }
341
341
  const createResult = await ctx.wallet.createAction({
342
342
  ...params,
343
- options: { signAndProcess: false, randomizeOutputs: false },
343
+ options: { signAndProcess: false, randomizeOutputs: false, noSend: true },
344
344
  });
345
345
  if (!createResult.signableTransaction) {
346
346
  return { error: "no-signable-transaction" };
@@ -363,6 +363,7 @@ export const transferOrdinals = {
363
363
  const signResult = await ctx.wallet.signAction({
364
364
  reference: createResult.signableTransaction.reference,
365
365
  spends,
366
+ options: { noSend: false },
366
367
  });
367
368
  if ("error" in signResult) {
368
369
  return { error: String(signResult.error) };
@@ -404,7 +405,7 @@ export const listOrdinal = {
404
405
  }
405
406
  const createResult = await ctx.wallet.createAction({
406
407
  ...params,
407
- options: { signAndProcess: false, randomizeOutputs: false },
408
+ options: { signAndProcess: false, randomizeOutputs: false, noSend: true },
408
409
  });
409
410
  if (!createResult.signableTransaction) {
410
411
  return { error: "no-signable-transaction" };
@@ -420,6 +421,7 @@ export const listOrdinal = {
420
421
  const signResult = await ctx.wallet.signAction({
421
422
  reference: createResult.signableTransaction.reference,
422
423
  spends: { 0: { unlockingScript: unlocking } },
424
+ options: { noSend: false },
423
425
  });
424
426
  if ("error" in signResult) {
425
427
  return { error: String(signResult.error) };
@@ -490,7 +492,7 @@ export const cancelListing = {
490
492
  customInstructions: JSON.stringify({ protocolID, keyID, ...(listingName && { name: listingName }) }),
491
493
  },
492
494
  ],
493
- options: { signAndProcess: false, randomizeOutputs: false },
495
+ options: { signAndProcess: false, randomizeOutputs: false, noSend: true },
494
496
  });
495
497
  if ("error" in createResult && createResult.error) {
496
498
  return { error: String(createResult.error) };
@@ -544,6 +546,7 @@ export const cancelListing = {
544
546
  spends: {
545
547
  0: { unlockingScript: unlockingScript.toHex() },
546
548
  },
549
+ options: { noSend: false },
547
550
  });
548
551
  if ("error" in signResult) {
549
552
  return { error: String(signResult.error) };
@@ -672,7 +675,7 @@ export const purchaseOrdinal = {
672
675
  },
673
676
  ],
674
677
  outputs,
675
- options: { signAndProcess: false, randomizeOutputs: false },
678
+ options: { signAndProcess: false, randomizeOutputs: false, noSend: true },
676
679
  });
677
680
  if ("error" in createResult && createResult.error) {
678
681
  return { error: String(createResult.error) };
@@ -687,6 +690,7 @@ export const purchaseOrdinal = {
687
690
  spends: {
688
691
  0: { unlockingScript: unlockingScript.toHex() },
689
692
  },
693
+ options: { noSend: false },
690
694
  });
691
695
  if ("error" in signResult) {
692
696
  return { error: String(signResult.error) };
@@ -153,6 +153,7 @@ export const sweepBsv = {
153
153
  }
154
154
  // If no amount specified, no outputs - wallet creates change for everything
155
155
  // Step 1: Create action to get the signable transaction
156
+ // noSend: true bypasses spendable check for external inputs
156
157
  const createResult = await ctx.wallet.createAction({
157
158
  description: amount
158
159
  ? `Sweep ${amount} sats`
@@ -160,7 +161,7 @@ export const sweepBsv = {
160
161
  inputBEEF: beefData,
161
162
  inputs: inputDescriptors,
162
163
  outputs,
163
- options: { signAndProcess: false },
164
+ options: { signAndProcess: false, noSend: true },
164
165
  });
165
166
  if ("error" in createResult && createResult.error) {
166
167
  return { error: String(createResult.error) };
@@ -201,9 +202,11 @@ export const sweepBsv = {
201
202
  }
202
203
  }
203
204
  // Step 3: Complete the action with our signatures
205
+ // Override noSend to false to ensure broadcast (createAction used noSend:true to bypass spendable check)
204
206
  const signResult = await ctx.wallet.signAction({
205
207
  reference: createResult.signableTransaction.reference,
206
208
  spends,
209
+ options: { noSend: false },
207
210
  });
208
211
  if ("error" in signResult) {
209
212
  return { error: String(signResult.error) };
@@ -278,7 +281,10 @@ export const sweepOrdinals = {
278
281
  const additionalBeef = await ctx.services.getBeefForTxid(txids[i]);
279
282
  firstBeef.mergeBeef(additionalBeef);
280
283
  }
281
- console.log(`[sweepOrdinals] Merged BEEF valid=${firstBeef.isValid()}, txs=${firstBeef.txs.length}`);
284
+ console.log(`[sweepOrdinals] Merged BEEF valid=${firstBeef.isValid()}, txs=${firstBeef.txs.length}, bumps=${firstBeef.bumps.length}`);
285
+ for (const btx of firstBeef.txs) {
286
+ console.log(`[sweepOrdinals] tx ${btx.txid.slice(0, 16)}... bumpIndex=${btx.bumpIndex}`);
287
+ }
282
288
  // Build input descriptors
283
289
  const inputDescriptors = inputs.map((input) => {
284
290
  const [txid, voutStr] = input.outpoint.split("_");
@@ -328,13 +334,41 @@ export const sweepOrdinals = {
328
334
  const beefData = firstBeef.toBinary();
329
335
  // Create action to get signable transaction
330
336
  // CRITICAL: randomizeOutputs must be false to preserve ordinal satoshi positions
331
- const createResult = await ctx.wallet.createAction({
337
+ const createActionArgs = {
332
338
  description: `Sweep ${inputs.length} ordinal${inputs.length !== 1 ? "s" : ""}`,
333
339
  inputBEEF: beefData,
334
340
  inputs: inputDescriptors,
335
341
  outputs,
336
- options: { signAndProcess: false, randomizeOutputs: false },
337
- });
342
+ options: { signAndProcess: false, randomizeOutputs: false, noSend: true },
343
+ };
344
+ console.log(`[sweepOrdinals] === CREATE ACTION ARGS ===`);
345
+ console.log(`[sweepOrdinals] description: ${createActionArgs.description}`);
346
+ console.log(`[sweepOrdinals] inputBEEF length: ${beefData.length} bytes`);
347
+ console.log(`[sweepOrdinals] inputs count: ${inputDescriptors.length}`);
348
+ console.log(`[sweepOrdinals] outputs count: ${outputs.length}`);
349
+ console.log(`[sweepOrdinals] inputs:`, JSON.stringify(inputDescriptors, null, 2));
350
+ console.log(`[sweepOrdinals] outputs:`, JSON.stringify(outputs, null, 2));
351
+ console.log(`[sweepOrdinals] options:`, JSON.stringify(createActionArgs.options));
352
+ console.log(`[sweepOrdinals] Calling createAction...`);
353
+ let createResult;
354
+ try {
355
+ createResult = await ctx.wallet.createAction(createActionArgs);
356
+ console.log(`[sweepOrdinals] createAction returned:`, JSON.stringify(createResult, (key, value) => {
357
+ // Don't stringify large binary data
358
+ if (key === 'tx' && value instanceof Uint8Array)
359
+ return `<Uint8Array ${value.length} bytes>`;
360
+ if (key === 'tx' && Array.isArray(value))
361
+ return `<Array ${value.length} bytes>`;
362
+ return value;
363
+ }, 2));
364
+ }
365
+ catch (createError) {
366
+ console.error(`[sweepOrdinals] createAction threw:`, createError);
367
+ const errorMsg = createError instanceof Error ? createError.message : String(createError);
368
+ const errorStack = createError instanceof Error ? createError.stack : undefined;
369
+ console.error(`[sweepOrdinals] Stack:`, errorStack);
370
+ return { error: `createAction failed: ${errorMsg}` };
371
+ }
338
372
  if ("error" in createResult && createResult.error) {
339
373
  return { error: String(createResult.error) };
340
374
  }
@@ -399,9 +433,11 @@ export const sweepOrdinals = {
399
433
  }
400
434
  }
401
435
  // Complete the action with our signatures
436
+ // Override noSend to false to ensure broadcast (createAction used noSend:true to bypass spendable check)
402
437
  const signResult = await ctx.wallet.signAction({
403
438
  reference: createResult.signableTransaction.reference,
404
439
  spends,
440
+ options: { noSend: false },
405
441
  });
406
442
  if ("error" in signResult) {
407
443
  return { error: String(signResult.error) };
@@ -578,7 +614,7 @@ export const sweepBsv21 = {
578
614
  inputBEEF: beefData,
579
615
  inputs: inputDescriptors,
580
616
  outputs,
581
- options: { signAndProcess: false, randomizeOutputs: false },
617
+ options: { signAndProcess: false, randomizeOutputs: false, noSend: true },
582
618
  });
583
619
  if ("error" in createResult && createResult.error) {
584
620
  return { error: String(createResult.error) };
@@ -612,9 +648,11 @@ export const sweepBsv21 = {
612
648
  }
613
649
  }
614
650
  // Complete the action with our signatures
651
+ // Override noSend to false to ensure broadcast (createAction used noSend:true to bypass spendable check)
615
652
  const signResult = await ctx.wallet.signAction({
616
653
  reference: createResult.signableTransaction.reference,
617
654
  spends,
655
+ options: { noSend: false },
618
656
  });
619
657
  if ("error" in signResult) {
620
658
  return { error: String(signResult.error) };
@@ -293,7 +293,7 @@ export const sendBsv21 = {
293
293
  inputDescription: "Token input",
294
294
  })),
295
295
  outputs,
296
- options: { signAndProcess: false, randomizeOutputs: false },
296
+ options: { signAndProcess: false, randomizeOutputs: false, noSend: true },
297
297
  });
298
298
  if ("error" in createResult && createResult.error) {
299
299
  return { error: String(createResult.error) };
@@ -304,6 +304,7 @@ export const sendBsv21 = {
304
304
  const signResult = await ctx.wallet.signAction({
305
305
  reference: createResult.signableTransaction.reference,
306
306
  spends: {},
307
+ options: { noSend: false },
307
308
  });
308
309
  if ("error" in signResult) {
309
310
  return { error: String(signResult.error) };
@@ -436,7 +437,7 @@ export const purchaseBsv21 = {
436
437
  },
437
438
  ],
438
439
  outputs,
439
- options: { signAndProcess: false, randomizeOutputs: false },
440
+ options: { signAndProcess: false, randomizeOutputs: false, noSend: true },
440
441
  });
441
442
  if ("error" in createResult && createResult.error) {
442
443
  return { error: String(createResult.error) };
@@ -451,6 +452,7 @@ export const purchaseBsv21 = {
451
452
  spends: {
452
453
  0: { unlockingScript: unlockingScript.toHex() },
453
454
  },
455
+ options: { noSend: false },
454
456
  });
455
457
  if ("error" in signResult) {
456
458
  return { error: String(signResult.error) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/wallet-toolbox",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
5
5
  "author": "1Sat Team",
6
6
  "license": "MIT",