@1sat/cli 0.0.102 → 0.0.103
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/README.md +8 -2
- package/dist/cli.js +5157 -0
- package/package.json +18 -13
- package/src/beef.ts +1 -1
- package/src/cli.ts +0 -2
- package/src/commands/action.ts +4 -4
- package/src/commands/authfetch.ts +5 -5
- package/src/commands/config.ts +4 -4
- package/src/commands/identity.ts +6 -6
- package/src/commands/init.ts +4 -4
- package/src/commands/locks.ts +7 -7
- package/src/commands/mcp-proxy.ts +2 -6
- package/src/commands/messagebox.ts +6 -6
- package/src/commands/opns.ts +7 -7
- package/src/commands/ordinals.ts +7 -7
- package/src/commands/remote.ts +6 -6
- package/src/commands/serve.ts +21 -48
- package/src/commands/social.ts +6 -6
- package/src/commands/storage.ts +11 -12
- package/src/commands/sweep.ts +6 -6
- package/src/commands/tokens.ts +6 -6
- package/src/commands/tx.ts +3 -3
- package/src/commands/wallet.ts +9 -7
- package/src/config.ts +9 -29
- package/src/context.ts +2 -2
- package/src/help.ts +2 -2
- package/src/keys.ts +1 -1
- package/src/main.ts +27 -22
- package/src/monitor-lock.ts +1 -4
- package/src/monitor-once.ts +3 -3
- package/src/repricer/buildPriceUpdateTask.ts +2 -2
- package/src/repricer/computeReprice.ts +1 -1
- package/src/repricer/index.ts +8 -8
- package/src/repricer/providers.ts +2 -2
- package/src/repricer/whatsOnChain.ts +1 -1
- package/scripts/check-bun.cjs +0 -17
- package/scripts/resubmit-bsv21-discovery.ts +0 -33
package/src/config.ts
CHANGED
|
@@ -29,8 +29,7 @@ export type ServerStorageConfig =
|
|
|
29
29
|
* Shared repricer engine (`server.repricer`). When enabled, a monitor task
|
|
30
30
|
* fetches the BSV/USD rate on the interval and rewrites each service's sats
|
|
31
31
|
* price toward its own `targetUsd` (`server.accounts.targetUsd` →
|
|
32
|
-
* `satsPerUnit
|
|
33
|
-
* `targetUsd` set are left alone.
|
|
32
|
+
* `satsPerUnit`). Services with no `targetUsd` set are left alone.
|
|
34
33
|
*/
|
|
35
34
|
export interface RepricerConfig {
|
|
36
35
|
/** Master toggle. Defaults to false. */
|
|
@@ -112,30 +111,13 @@ export interface ServerPaymailConfig {
|
|
|
112
111
|
*/
|
|
113
112
|
messageboxUrl?: string
|
|
114
113
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
114
|
+
* Domain served from the host accounts table (e.g. "1sat.app").
|
|
115
|
+
* Aliases on this domain resolve username→identity key via registered
|
|
116
|
+
* accounts; every other domain (e.g. "1sat.name") keeps resolving through
|
|
117
|
+
* on-chain OpNS binds. Unset = OpNS for all domains. Either way an alias
|
|
118
|
+
* only resolves when its identity holds an account on this host.
|
|
117
119
|
*/
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Wallet storage URL for entitlement listOutputs (and optional later
|
|
121
|
-
* subscribe). Defaults to local wallet serve URL like messagebox.
|
|
122
|
-
*/
|
|
123
|
-
walletStorageUrl?: string
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface ServerHostingConfig {
|
|
127
|
-
/** Master toggle. Defaults to false. */
|
|
128
|
-
enabled?: boolean
|
|
129
|
-
/** Sats per subscription period. */
|
|
130
|
-
priceSats?: number
|
|
131
|
-
/**
|
|
132
|
-
* USD price per subscription period. Returned as `priceUsd` on the
|
|
133
|
-
* pricing API for display, and maintained as the repricing target for
|
|
134
|
-
* `priceSats` when `server.repricer` is enabled.
|
|
135
|
-
*/
|
|
136
|
-
targetUsd?: number
|
|
137
|
-
/** Period length in seconds (e.g. 2592000 ≈ 30 days). */
|
|
138
|
-
periodSeconds?: number
|
|
120
|
+
userDomain?: string
|
|
139
121
|
}
|
|
140
122
|
|
|
141
123
|
export interface ServerSessionStoreConfig {
|
|
@@ -167,11 +149,9 @@ export interface ServerConfig {
|
|
|
167
149
|
accounts?: ServerAccountsConfig
|
|
168
150
|
/** Messagebox subcommand settings. */
|
|
169
151
|
messagebox?: ServerMessageboxConfig
|
|
170
|
-
/** Paymail
|
|
152
|
+
/** Paymail settings for the unified host. */
|
|
171
153
|
paymail?: ServerPaymailConfig
|
|
172
|
-
/**
|
|
173
|
-
hosting?: ServerHostingConfig
|
|
174
|
-
/** Shared BSV/USD repricer engine for accounts + hosting prices. */
|
|
154
|
+
/** Shared BSV/USD repricer engine for the accounts storage price. */
|
|
175
155
|
repricer?: RepricerConfig
|
|
176
156
|
/**
|
|
177
157
|
* Redis-shared BRC-104 sessions. Required when multiple serve instances
|
package/src/context.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
import { type OneSatContext, createContext } from '@1sat/actions'
|
|
11
11
|
import { type NodeWalletResult, createNodeWallet } from '@1sat/wallet-node'
|
|
12
12
|
import type { PrivateKey } from '@bsv/sdk'
|
|
13
|
-
import { ensureDataDir, loadConfig } from './config'
|
|
14
|
-
import { spawnDetachedMonitorOnce } from './monitor-once'
|
|
13
|
+
import { ensureDataDir, loadConfig } from './config.js'
|
|
14
|
+
import { spawnDetachedMonitorOnce } from './monitor-once.js'
|
|
15
15
|
|
|
16
16
|
/** Extended context that includes cleanup */
|
|
17
17
|
export interface CliContext {
|
package/src/help.ts
CHANGED
|
@@ -714,7 +714,7 @@ export const COMMANDS: CommandSpec[] = [
|
|
|
714
714
|
group: 'Server',
|
|
715
715
|
name: 'serve',
|
|
716
716
|
description:
|
|
717
|
-
'Run unified host server (storage +
|
|
717
|
+
'Run unified host server (storage + accounts + paymail + messagebox) and/or monitor (config under server.* in config.json)',
|
|
718
718
|
subcommands: [
|
|
719
719
|
{
|
|
720
720
|
name: '(no subcommand)',
|
|
@@ -778,7 +778,7 @@ export const COMMANDS: CommandSpec[] = [
|
|
|
778
778
|
},
|
|
779
779
|
],
|
|
780
780
|
notes:
|
|
781
|
-
|
|
781
|
+
'Examples:\n 1sat authfetch GET https://wallet.1sat.app/account/status\n 1sat authfetch POST https://wallet.1sat.app/account/register --body \'{"username":"alice"}\' --yes\n 1sat authfetch PUT https://wallet.1sat.app/account/profile --body \'{"displayName":"Alice"}\' --yes',
|
|
782
782
|
},
|
|
783
783
|
{
|
|
784
784
|
group: 'Advanced',
|
package/src/keys.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { join } from 'node:path'
|
|
|
17
17
|
import { PrivateKey } from '@bsv/sdk'
|
|
18
18
|
import { isCancel, password as promptPassword } from '@clack/prompts'
|
|
19
19
|
import { type WifBackup, decryptBackup, encryptBackup } from 'bitcoin-backup'
|
|
20
|
-
import { ensureConfigDir, getConfigDir } from './config'
|
|
20
|
+
import { ensureConfigDir, getConfigDir } from './config.js'
|
|
21
21
|
|
|
22
22
|
const KEYS_FILE = 'keys.bep'
|
|
23
23
|
|
package/src/main.ts
CHANGED
|
@@ -10,28 +10,33 @@
|
|
|
10
10
|
import { existsSync } from 'node:fs'
|
|
11
11
|
import { resolve } from 'node:path'
|
|
12
12
|
import { config as loadEnv } from 'dotenv'
|
|
13
|
-
import { parseGlobalFlags } from './args'
|
|
14
|
-
import { handleActionCommand } from './commands/action'
|
|
15
|
-
import { handleAuthfetchCommand } from './commands/authfetch'
|
|
16
|
-
import { handleConfigCommand } from './commands/config'
|
|
17
|
-
import { handleIdentityCommand } from './commands/identity'
|
|
18
|
-
import { handleInitCommand } from './commands/init'
|
|
19
|
-
import { handleLocksCommand } from './commands/locks'
|
|
20
|
-
import { handleMcpProxyCommand } from './commands/mcp-proxy'
|
|
21
|
-
import { handleMessageboxCommand } from './commands/messagebox'
|
|
22
|
-
import { handleOpnsCommand } from './commands/opns'
|
|
23
|
-
import { handleOrdinalsCommand } from './commands/ordinals'
|
|
24
|
-
import { handleRemoteCommand } from './commands/remote'
|
|
25
|
-
import { handleServeCommand } from './commands/serve'
|
|
26
|
-
import { handleSocialCommand } from './commands/social'
|
|
27
|
-
import { handleStorageCommand } from './commands/storage'
|
|
28
|
-
import { handleSweepCommand } from './commands/sweep'
|
|
29
|
-
import { handleTokensCommand } from './commands/tokens'
|
|
30
|
-
import { handleTxCommand } from './commands/tx'
|
|
31
|
-
import { handleWalletCommand } from './commands/wallet'
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
13
|
+
import { parseGlobalFlags } from './args.js'
|
|
14
|
+
import { handleActionCommand } from './commands/action.js'
|
|
15
|
+
import { handleAuthfetchCommand } from './commands/authfetch.js'
|
|
16
|
+
import { handleConfigCommand } from './commands/config.js'
|
|
17
|
+
import { handleIdentityCommand } from './commands/identity.js'
|
|
18
|
+
import { handleInitCommand } from './commands/init.js'
|
|
19
|
+
import { handleLocksCommand } from './commands/locks.js'
|
|
20
|
+
import { handleMcpProxyCommand } from './commands/mcp-proxy.js'
|
|
21
|
+
import { handleMessageboxCommand } from './commands/messagebox.js'
|
|
22
|
+
import { handleOpnsCommand } from './commands/opns.js'
|
|
23
|
+
import { handleOrdinalsCommand } from './commands/ordinals.js'
|
|
24
|
+
import { handleRemoteCommand } from './commands/remote.js'
|
|
25
|
+
import { handleServeCommand } from './commands/serve.js'
|
|
26
|
+
import { handleSocialCommand } from './commands/social.js'
|
|
27
|
+
import { handleStorageCommand } from './commands/storage.js'
|
|
28
|
+
import { handleSweepCommand } from './commands/sweep.js'
|
|
29
|
+
import { handleTokensCommand } from './commands/tokens.js'
|
|
30
|
+
import { handleTxCommand } from './commands/tx.js'
|
|
31
|
+
import { handleWalletCommand } from './commands/wallet.js'
|
|
32
|
+
import {
|
|
33
|
+
getCommand,
|
|
34
|
+
printCommandHelp,
|
|
35
|
+
printHelp,
|
|
36
|
+
printVersion,
|
|
37
|
+
} from './help.js'
|
|
38
|
+
import { runMonitorOnce } from './monitor-once.js'
|
|
39
|
+
import { formatError } from './output.js'
|
|
35
40
|
|
|
36
41
|
const rawArgs = process.argv.slice(2)
|
|
37
42
|
|
package/src/monitor-lock.ts
CHANGED
|
@@ -29,10 +29,7 @@ export function writeMonitorPid(
|
|
|
29
29
|
* contains that pid (avoids a short once-run clearing a serve owner that
|
|
30
30
|
* started while the once-run was shutting down).
|
|
31
31
|
*/
|
|
32
|
-
export function clearMonitorPid(
|
|
33
|
-
dataDir: string,
|
|
34
|
-
onlyPid?: number,
|
|
35
|
-
): void {
|
|
32
|
+
export function clearMonitorPid(dataDir: string, onlyPid?: number): void {
|
|
36
33
|
const path = monitorPidPath(dataDir)
|
|
37
34
|
try {
|
|
38
35
|
if (onlyPid !== undefined) {
|
package/src/monitor-once.ts
CHANGED
|
@@ -10,13 +10,13 @@ import { type SpawnOptions, spawn } from 'node:child_process'
|
|
|
10
10
|
import { appendFileSync, closeSync, openSync } from 'node:fs'
|
|
11
11
|
import { join } from 'node:path'
|
|
12
12
|
import { createNodeWallet } from '@1sat/wallet-node'
|
|
13
|
-
import { ensureDataDir, loadConfig } from './config'
|
|
14
|
-
import { loadKey } from './keys'
|
|
13
|
+
import { ensureDataDir, loadConfig } from './config.js'
|
|
14
|
+
import { loadKey } from './keys.js'
|
|
15
15
|
import {
|
|
16
16
|
clearMonitorPid,
|
|
17
17
|
readLiveMonitorPid,
|
|
18
18
|
writeMonitorPid,
|
|
19
|
-
} from './monitor-lock'
|
|
19
|
+
} from './monitor-lock.js'
|
|
20
20
|
|
|
21
21
|
export const MONITOR_LOG_FILENAME = 'monitor.log'
|
|
22
22
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { computeReprice } from './computeReprice'
|
|
2
|
-
import type { RateProvider, RepricerBounds } from './types'
|
|
1
|
+
import { computeReprice } from './computeReprice.js'
|
|
2
|
+
import type { RateProvider, RepricerBounds } from './types.js'
|
|
3
3
|
|
|
4
4
|
/** One price the repricer maintains from the shared BSV/USD quote. */
|
|
5
5
|
export interface RepriceTarget {
|
package/src/repricer/index.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export { buildPriceUpdateTask } from './buildPriceUpdateTask'
|
|
1
|
+
export { buildPriceUpdateTask } from './buildPriceUpdateTask.js'
|
|
2
2
|
export type {
|
|
3
3
|
PriceUpdateTaskOptions,
|
|
4
4
|
RepriceTarget,
|
|
5
|
-
} from './buildPriceUpdateTask'
|
|
6
|
-
export { computeReprice } from './computeReprice'
|
|
7
|
-
export { createAccountsConfigLoader } from './configLoader'
|
|
8
|
-
export type { AccountsConfigLoaderOptions } from './configLoader'
|
|
9
|
-
export { resolveRateProvider } from './providers'
|
|
10
|
-
export { createWhatsOnChainProvider } from './whatsOnChain'
|
|
5
|
+
} from './buildPriceUpdateTask.js'
|
|
6
|
+
export { computeReprice } from './computeReprice.js'
|
|
7
|
+
export { createAccountsConfigLoader } from './configLoader.js'
|
|
8
|
+
export type { AccountsConfigLoaderOptions } from './configLoader.js'
|
|
9
|
+
export { resolveRateProvider } from './providers.js'
|
|
10
|
+
export { createWhatsOnChainProvider } from './whatsOnChain.js'
|
|
11
11
|
export type {
|
|
12
12
|
BsvUsdQuote,
|
|
13
13
|
ComputeRepriceInput,
|
|
14
14
|
ComputeRepriceResult,
|
|
15
15
|
RateProvider,
|
|
16
16
|
RepricerBounds,
|
|
17
|
-
} from './types'
|
|
17
|
+
} from './types.js'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RateProvider } from './types'
|
|
2
|
-
import { createWhatsOnChainProvider } from './whatsOnChain'
|
|
1
|
+
import type { RateProvider } from './types.js'
|
|
2
|
+
import { createWhatsOnChainProvider } from './whatsOnChain.js'
|
|
3
3
|
|
|
4
4
|
export interface ResolveProviderOptions {
|
|
5
5
|
chain: 'main' | 'test'
|
package/scripts/check-bun.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const { spawnSync } = require('node:child_process')
|
|
3
|
-
|
|
4
|
-
const result = spawnSync('bun', ['--version'], { stdio: 'ignore' })
|
|
5
|
-
if (result.error || result.status !== 0) {
|
|
6
|
-
console.error('')
|
|
7
|
-
console.error('@1sat/cli requires the Bun runtime (https://bun.sh).')
|
|
8
|
-
console.error('')
|
|
9
|
-
console.error('Install Bun:')
|
|
10
|
-
console.error(' curl -fsSL https://bun.sh/install | bash')
|
|
11
|
-
console.error('')
|
|
12
|
-
console.error('Then retry:')
|
|
13
|
-
console.error(' bunx @1sat/cli # run without installing')
|
|
14
|
-
console.error(' bun add -g @1sat/cli # install globally')
|
|
15
|
-
console.error('')
|
|
16
|
-
process.exit(1)
|
|
17
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One-off recovery script: re-submit a BSV21 deploy tx to the discovery
|
|
3
|
-
* overlay topic (tm_bsv21).
|
|
4
|
-
*
|
|
5
|
-
* Use when a deploy was broadcast on-chain but didn't reach the overlay
|
|
6
|
-
* (e.g. previous URL bug, network blip, server downtime).
|
|
7
|
-
*
|
|
8
|
-
* Usage: bun run scripts/resubmit-bsv21-discovery.ts <txid>
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { OneSatServices } from '@1sat/client'
|
|
12
|
-
|
|
13
|
-
const txid = process.argv[2]
|
|
14
|
-
if (!txid || !/^[0-9a-f]{64}$/i.test(txid)) {
|
|
15
|
-
console.error(
|
|
16
|
-
'Usage: bun run scripts/resubmit-bsv21-discovery.ts <txid>\n' +
|
|
17
|
-
' txid must be a 64-char hex string',
|
|
18
|
-
)
|
|
19
|
-
process.exit(1)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const services = new OneSatServices('main')
|
|
23
|
-
|
|
24
|
-
console.log(`Fetching BEEF for ${txid}...`)
|
|
25
|
-
const beef = await services.getBeefForTxid(txid)
|
|
26
|
-
console.log(` beef has ${beef.txs.length} txs and ${beef.bumps.length} bumps`)
|
|
27
|
-
|
|
28
|
-
const atomicBeef = beef.toBinaryAtomic(txid)
|
|
29
|
-
console.log(` atomic BEEF size: ${atomicBeef.length} bytes`)
|
|
30
|
-
|
|
31
|
-
console.log('Submitting to tm_bsv21 discovery topic...')
|
|
32
|
-
const result = await services.overlay.submitBsv21Discovery(atomicBeef)
|
|
33
|
-
console.log('Result:', result)
|