@1sat/cli 0.0.4 → 0.0.6
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/package.json +3 -2
- package/src/commands/identity.ts +1 -4
- package/src/commands/ordinals.ts +2 -2
- package/src/commands/sweep.ts +32 -10
- package/src/commands/tokens.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1sat/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "CLI for 1Sat Ordinals SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/cli.ts",
|
|
@@ -26,8 +26,9 @@
|
|
|
26
26
|
"@clack/prompts": "^0.8.0",
|
|
27
27
|
"bitcoin-backup": "^0.0.8",
|
|
28
28
|
"dotenv": "^17.0.0",
|
|
29
|
+
"better-sqlite3": "^12.8.0",
|
|
29
30
|
"knex": "^3.1.0",
|
|
30
|
-
"
|
|
31
|
+
"sigma-protocol": "^0.1.9"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/bun": "^1.3.9",
|
package/src/commands/identity.ts
CHANGED
|
@@ -63,10 +63,7 @@ async function identityCreate(
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
async function identityInfo(
|
|
67
|
-
_args: string[],
|
|
68
|
-
opts: GlobalFlags,
|
|
69
|
-
): Promise<void> {
|
|
66
|
+
async function identityInfo(_args: string[], opts: GlobalFlags): Promise<void> {
|
|
70
67
|
const privateKey = await loadKey(resolvePassword())
|
|
71
68
|
const { ctx, destroy } = await loadContext(privateKey, {
|
|
72
69
|
chain: opts.chain,
|
package/src/commands/ordinals.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Ordinals commands - list, mint, transfer, sell, cancel, buy.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { readFileSync } from 'node:fs'
|
|
6
|
+
import { basename, extname } from 'node:path'
|
|
5
7
|
import {
|
|
6
8
|
cancelListing,
|
|
7
9
|
deriveDepositAddresses,
|
|
@@ -13,8 +15,6 @@ import {
|
|
|
13
15
|
} from '@1sat/actions'
|
|
14
16
|
import { Utils } from '@bsv/sdk'
|
|
15
17
|
import { confirm, isCancel } from '@clack/prompts'
|
|
16
|
-
import { readFileSync } from 'node:fs'
|
|
17
|
-
import { basename, extname } from 'node:path'
|
|
18
18
|
import type { GlobalFlags } from '../args'
|
|
19
19
|
import { extractFlag } from '../args'
|
|
20
20
|
import { loadContext } from '../context'
|
package/src/commands/sweep.ts
CHANGED
|
@@ -76,20 +76,28 @@ async function sweepScan(args: string[], opts: GlobalFlags): Promise<void> {
|
|
|
76
76
|
|
|
77
77
|
console.log(` ${formatLabel('Funding UTXOs:')} ${result.funding.length}`)
|
|
78
78
|
if (result.funding.length > 0) {
|
|
79
|
-
console.log(
|
|
79
|
+
console.log(
|
|
80
|
+
` ${formatLabel('Total funding:')} ${formatValue(result.totalFundingSats)} satoshis`,
|
|
81
|
+
)
|
|
80
82
|
for (const f of result.funding) {
|
|
81
|
-
console.log(
|
|
83
|
+
console.log(
|
|
84
|
+
` ${formatValue(f.outpoint)} ${formatLabel(`${f.satoshis} sats`)}`,
|
|
85
|
+
)
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
console.log(
|
|
89
|
+
console.log(
|
|
90
|
+
`\n ${formatLabel('Ordinal UTXOs:')} ${result.ordinals.length}`,
|
|
91
|
+
)
|
|
86
92
|
if (result.ordinals.length > 0) {
|
|
87
93
|
for (const o of result.ordinals) {
|
|
88
94
|
console.log(` ${formatValue(o.outpoint)}`)
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
|
|
92
|
-
console.log(
|
|
98
|
+
console.log(
|
|
99
|
+
`\n ${formatLabel('BSV-21 Tokens:')} ${result.bsv21Tokens.length}`,
|
|
100
|
+
)
|
|
93
101
|
if (result.bsv21Tokens.length > 0) {
|
|
94
102
|
for (const t of result.bsv21Tokens) {
|
|
95
103
|
console.log(
|
|
@@ -98,7 +106,10 @@ async function sweepScan(args: string[], opts: GlobalFlags): Promise<void> {
|
|
|
98
106
|
}
|
|
99
107
|
}
|
|
100
108
|
|
|
101
|
-
const total =
|
|
109
|
+
const total =
|
|
110
|
+
result.funding.length +
|
|
111
|
+
result.ordinals.length +
|
|
112
|
+
result.bsv21Tokens.reduce((n, t) => n + t.inputs.length, 0)
|
|
102
113
|
console.log(`\n ${total} total UTXO(s) found.`)
|
|
103
114
|
} finally {
|
|
104
115
|
await destroy()
|
|
@@ -141,11 +152,14 @@ async function sweepImport(args: string[], opts: GlobalFlags): Promise<void> {
|
|
|
141
152
|
|
|
142
153
|
// Summarize what will be swept
|
|
143
154
|
const parts: string[] = []
|
|
144
|
-
if (hasFunding)
|
|
155
|
+
if (hasFunding)
|
|
156
|
+
parts.push(`${scan.totalFundingSats} sats (${scan.funding.length} UTXOs)`)
|
|
145
157
|
if (hasOrdinals) parts.push(`${scan.ordinals.length} ordinal(s)`)
|
|
146
158
|
if (hasTokens) {
|
|
147
159
|
for (const t of scan.bsv21Tokens) {
|
|
148
|
-
parts.push(
|
|
160
|
+
parts.push(
|
|
161
|
+
`${t.totalAmount} ${t.symbol ?? t.tokenId.slice(0, 12)} token(s)`,
|
|
162
|
+
)
|
|
149
163
|
}
|
|
150
164
|
}
|
|
151
165
|
|
|
@@ -193,7 +207,10 @@ async function sweepImport(args: string[], opts: GlobalFlags): Promise<void> {
|
|
|
193
207
|
// Sweep BSV-21 tokens (one sweep per tokenId)
|
|
194
208
|
if (hasTokens) {
|
|
195
209
|
for (const tokenGroup of scan.bsv21Tokens) {
|
|
196
|
-
const inputs = await prepareSweepInputs(
|
|
210
|
+
const inputs = await prepareSweepInputs(
|
|
211
|
+
ctx,
|
|
212
|
+
toIndexed(tokenGroup.inputs),
|
|
213
|
+
)
|
|
197
214
|
|
|
198
215
|
const sweepInputs = inputs.map((inp, idx) => ({
|
|
199
216
|
...inp,
|
|
@@ -201,9 +218,14 @@ async function sweepImport(args: string[], opts: GlobalFlags): Promise<void> {
|
|
|
201
218
|
amount: tokenGroup.inputs[idx].amount,
|
|
202
219
|
}))
|
|
203
220
|
|
|
204
|
-
const result = await sweepBsv21.execute(ctx, {
|
|
221
|
+
const result = await sweepBsv21.execute(ctx, {
|
|
222
|
+
inputs: sweepInputs,
|
|
223
|
+
wif,
|
|
224
|
+
})
|
|
205
225
|
if (result.error) {
|
|
206
|
-
fatal(
|
|
226
|
+
fatal(
|
|
227
|
+
`Token sweep failed (${tokenGroup.symbol ?? tokenGroup.tokenId.slice(0, 12)}): ${result.error}`,
|
|
228
|
+
)
|
|
207
229
|
}
|
|
208
230
|
if (result.txid) txids.push(result.txid)
|
|
209
231
|
}
|
package/src/commands/tokens.ts
CHANGED
|
@@ -176,7 +176,9 @@ async function tokenSend(args: string[], opts: GlobalFlags): Promise<void> {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
async function tokenDeploy(_args: string[], _opts: GlobalFlags): Promise<void> {
|
|
179
|
-
fatal(
|
|
179
|
+
fatal(
|
|
180
|
+
'tokens deploy is not yet available. No deploy action exists in the actions package.',
|
|
181
|
+
)
|
|
180
182
|
}
|
|
181
183
|
|
|
182
184
|
async function tokenBuy(args: string[], opts: GlobalFlags): Promise<void> {
|