@1sat/wallet-toolbox 0.0.65 → 0.0.66

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.
@@ -5,7 +5,11 @@
5
5
  */
6
6
  import { Inscription } from "@bopen-io/templates";
7
7
  import { P2PKH, Script, Utils } from "@bsv/sdk";
8
- import { FUNDING_BASKET } from "../constants";
8
+ /**
9
+ * Magic constant that tells the wallet to send all available funds minus fees.
10
+ * When an output has this satoshis value, it's adjusted to the maximum fundable amount.
11
+ */
12
+ const maxPossibleSatoshis = 2099999999999999;
9
13
  // ============================================================================
10
14
  // Internal helpers
11
15
  // ============================================================================
@@ -153,32 +157,14 @@ export const sendAllBsv = {
153
157
  if (isPaymail(destination)) {
154
158
  return { error: "paymail-not-yet-implemented" };
155
159
  }
156
- const listResult = await ctx.wallet.listOutputs({
157
- basket: FUNDING_BASKET,
158
- include: "locking scripts",
159
- limit: 10000,
160
- });
161
- if (!listResult.outputs || listResult.outputs.length === 0) {
162
- return { error: "no-funds" };
163
- }
164
- const totalSats = listResult.outputs.reduce((sum, o) => sum + o.satoshis, 0);
165
- const estimatedFee = Math.ceil((listResult.outputs.length * 150 + 44) * 1);
166
- const sendAmount = totalSats - estimatedFee;
167
- if (sendAmount <= 0) {
168
- return { error: "insufficient-funds-for-fee" };
169
- }
170
- const inputs = listResult.outputs.map((o) => ({
171
- outpoint: o.outpoint,
172
- inputDescription: "Sweep funds",
173
- }));
174
160
  const result = await ctx.wallet.createAction({
175
161
  description: "Send all BSV",
176
- inputs,
177
162
  outputs: [
178
163
  {
179
164
  lockingScript: new P2PKH().lock(destination).toHex(),
180
- satoshis: sendAmount,
165
+ satoshis: maxPossibleSatoshis,
181
166
  outputDescription: "Sweep all funds",
167
+ tags: [],
182
168
  },
183
169
  ],
184
170
  options: { signAndProcess: true, acceptDelayedBroadcast: false },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/wallet-toolbox",
3
- "version": "0.0.65",
3
+ "version": "0.0.66",
4
4
  "description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
5
5
  "author": "1Sat Team",
6
6
  "license": "MIT",