@1sat/cli 0.0.105 → 0.0.106
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.
- package/dist/cli.js +13 -8
- package/package.json +1 -1
- package/src/commands/sweep.ts +13 -8
package/dist/cli.js
CHANGED
|
@@ -3940,9 +3940,10 @@ async function sweepImport(args, opts) {
|
|
|
3940
3940
|
if (!wif)
|
|
3941
3941
|
fatal("Missing --wif <private-key>");
|
|
3942
3942
|
let address;
|
|
3943
|
+
let sweepKey;
|
|
3943
3944
|
try {
|
|
3944
|
-
|
|
3945
|
-
address =
|
|
3945
|
+
sweepKey = PrivateKey4.fromWif(wif);
|
|
3946
|
+
address = sweepKey.toPublicKey().toAddress();
|
|
3946
3947
|
} catch {
|
|
3947
3948
|
fatal("Invalid WIF private key");
|
|
3948
3949
|
}
|
|
@@ -3990,7 +3991,8 @@ async function sweepImport(args, opts) {
|
|
|
3990
3991
|
const txids = [];
|
|
3991
3992
|
if (hasFunding) {
|
|
3992
3993
|
const inputs = await prepareSweepInputs(ctx, scan.funding);
|
|
3993
|
-
const
|
|
3994
|
+
const keys = inputs.map(() => sweepKey);
|
|
3995
|
+
const result = await sweepBsv.execute(ctx, { inputs, keys });
|
|
3994
3996
|
if (result.error) {
|
|
3995
3997
|
fatal(`BSV sweep failed: ${result.error}`);
|
|
3996
3998
|
}
|
|
@@ -3999,7 +4001,8 @@ async function sweepImport(args, opts) {
|
|
|
3999
4001
|
}
|
|
4000
4002
|
if (hasOrdinals) {
|
|
4001
4003
|
const inputs = await prepareSweepInputs(ctx, scan.ordinals);
|
|
4002
|
-
const
|
|
4004
|
+
const keys = inputs.map(() => sweepKey);
|
|
4005
|
+
const result = await sweepOrdinals.execute(ctx, { inputs, keys });
|
|
4003
4006
|
if (result.error) {
|
|
4004
4007
|
fatal(`Ordinals sweep failed: ${result.error}`);
|
|
4005
4008
|
}
|
|
@@ -4010,12 +4013,14 @@ async function sweepImport(args, opts) {
|
|
|
4010
4013
|
for (const token of scan.bsv21Tokens) {
|
|
4011
4014
|
if (!token.isActive || token.outputs.length === 0)
|
|
4012
4015
|
continue;
|
|
4013
|
-
const
|
|
4014
|
-
|
|
4016
|
+
const base = await prepareSweepInputs(ctx, token.outputs);
|
|
4017
|
+
const inputs = base.map((b) => ({
|
|
4018
|
+
...b,
|
|
4015
4019
|
tokenId: token.tokenId,
|
|
4016
|
-
amount: token.amounts.get(
|
|
4020
|
+
amount: token.amounts.get(b.outpoint) ?? "0"
|
|
4017
4021
|
}));
|
|
4018
|
-
const
|
|
4022
|
+
const keys = inputs.map(() => sweepKey);
|
|
4023
|
+
const result = await sweepBsv21.execute(ctx, { inputs, keys });
|
|
4019
4024
|
if (result.error) {
|
|
4020
4025
|
fatal(`Token sweep failed (${token.symbol ?? token.tokenId.slice(0, 12)}): ${result.error}`);
|
|
4021
4026
|
}
|
package/package.json
CHANGED
package/src/commands/sweep.ts
CHANGED
|
@@ -135,9 +135,10 @@ async function sweepImport(args: string[], opts: GlobalFlags): Promise<void> {
|
|
|
135
135
|
if (!wif) fatal('Missing --wif <private-key>')
|
|
136
136
|
|
|
137
137
|
let address: string
|
|
138
|
+
let sweepKey: PrivateKey
|
|
138
139
|
try {
|
|
139
|
-
|
|
140
|
-
address =
|
|
140
|
+
sweepKey = PrivateKey.fromWif(wif)
|
|
141
|
+
address = sweepKey.toPublicKey().toAddress()
|
|
141
142
|
} catch {
|
|
142
143
|
fatal('Invalid WIF private key')
|
|
143
144
|
}
|
|
@@ -200,7 +201,8 @@ async function sweepImport(args: string[], opts: GlobalFlags): Promise<void> {
|
|
|
200
201
|
// Sweep BSV funding UTXOs
|
|
201
202
|
if (hasFunding) {
|
|
202
203
|
const inputs = await prepareSweepInputs(ctx, scan.funding)
|
|
203
|
-
const
|
|
204
|
+
const keys = inputs.map(() => sweepKey)
|
|
205
|
+
const result = await sweepBsv.execute(ctx, { inputs, keys })
|
|
204
206
|
if (result.error) {
|
|
205
207
|
fatal(`BSV sweep failed: ${result.error}`)
|
|
206
208
|
}
|
|
@@ -210,7 +212,8 @@ async function sweepImport(args: string[], opts: GlobalFlags): Promise<void> {
|
|
|
210
212
|
// Sweep ordinals
|
|
211
213
|
if (hasOrdinals) {
|
|
212
214
|
const inputs = await prepareSweepInputs(ctx, scan.ordinals)
|
|
213
|
-
const
|
|
215
|
+
const keys = inputs.map(() => sweepKey)
|
|
216
|
+
const result = await sweepOrdinals.execute(ctx, { inputs, keys })
|
|
214
217
|
if (result.error) {
|
|
215
218
|
fatal(`Ordinals sweep failed: ${result.error}`)
|
|
216
219
|
}
|
|
@@ -222,13 +225,15 @@ async function sweepImport(args: string[], opts: GlobalFlags): Promise<void> {
|
|
|
222
225
|
for (const token of scan.bsv21Tokens) {
|
|
223
226
|
if (!token.isActive || token.outputs.length === 0) continue
|
|
224
227
|
|
|
225
|
-
const
|
|
226
|
-
|
|
228
|
+
const base = await prepareSweepInputs(ctx, token.outputs)
|
|
229
|
+
const inputs = base.map((b) => ({
|
|
230
|
+
...b,
|
|
227
231
|
tokenId: token.tokenId,
|
|
228
|
-
amount: token.amounts.get(
|
|
232
|
+
amount: token.amounts.get(b.outpoint) ?? '0',
|
|
229
233
|
}))
|
|
234
|
+
const keys = inputs.map(() => sweepKey)
|
|
230
235
|
|
|
231
|
-
const result = await sweepBsv21.execute(ctx, { inputs,
|
|
236
|
+
const result = await sweepBsv21.execute(ctx, { inputs, keys })
|
|
232
237
|
if (result.error) {
|
|
233
238
|
fatal(
|
|
234
239
|
`Token sweep failed (${token.symbol ?? token.tokenId.slice(0, 12)}): ${result.error}`,
|