@utexo/rgb-sdk 1.0.0-beta.8
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/LICENCE +201 -0
- package/Readme.md +480 -0
- package/cli/README.md +348 -0
- package/cli/commands/address.mjs +16 -0
- package/cli/commands/blindreceive.mjs +15 -0
- package/cli/commands/btcbalance.mjs +11 -0
- package/cli/commands/createlightninginvoice.mjs +14 -0
- package/cli/commands/createutxos.mjs +13 -0
- package/cli/commands/decodergbinvoice.mjs +9 -0
- package/cli/commands/generate_keys.mjs +35 -0
- package/cli/commands/getlightningreceiverequest.mjs +10 -0
- package/cli/commands/getlightningsendrequest.mjs +10 -0
- package/cli/commands/getonchainsendstatus.mjs +20 -0
- package/cli/commands/listassets.mjs +11 -0
- package/cli/commands/listtransfers.mjs +10 -0
- package/cli/commands/listunspents.mjs +10 -0
- package/cli/commands/onchainreceive.mjs +16 -0
- package/cli/commands/onchainsend.mjs +11 -0
- package/cli/commands/onchainsendbegin.mjs +9 -0
- package/cli/commands/onchainsendend.mjs +9 -0
- package/cli/commands/paylightninginvoice.mjs +11 -0
- package/cli/commands/paylightninginvoicebegin.mjs +10 -0
- package/cli/commands/paylightninginvoiceend.mjs +9 -0
- package/cli/commands/refresh.mjs +9 -0
- package/cli/commands/send.mjs +31 -0
- package/cli/commands/sign-psbt.mjs +12 -0
- package/cli/commands/signpsbt.mjs +10 -0
- package/cli/commands/witnessreceive.mjs +15 -0
- package/cli/data/stage2-receiver.example.json +11 -0
- package/cli/data/stage2-sender.example.json +11 -0
- package/cli/generate_keys.mjs +66 -0
- package/cli/run.mjs +308 -0
- package/cli/utils.mjs +220 -0
- package/dist/index.cjs +1282 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +163 -0
- package/dist/index.d.ts +163 -0
- package/dist/index.mjs +1018 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +124 -0
package/cli/README.md
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
# UTEXO CLI
|
|
2
|
+
|
|
3
|
+
CLI for UTEXOWallet. All commands run via the single entrypoint.
|
|
4
|
+
|
|
5
|
+
**Usage:** `utexo <command> <wallet_name> [options]` or `npm run utexo -- <command> <wallet_name> [options]` or `node cli/run.mjs <command> <wallet_name> [options]`
|
|
6
|
+
|
|
7
|
+
**Exception:** `sign-psbt` has no wallet: `utexo sign-psbt --psbt "<psbt>" --network <net> --mnemonic "<mn>"`
|
|
8
|
+
|
|
9
|
+
## Structure
|
|
10
|
+
|
|
11
|
+
- **`run.mjs`** — Single entrypoint for all commands
|
|
12
|
+
- **`commands/`** — Command modules (each exports `run(walletName, flagArgs[, options])`)
|
|
13
|
+
- **`utils.mjs`** — Shared helpers (parseFlags, runWithWallet, wallet config load/save)
|
|
14
|
+
- **`data/`** — Wallet configs (`data/<wallet_name>.json`)
|
|
15
|
+
- **`generate_keys.mjs`** — Setup script to create a new wallet config (also: `utexo generate_keys <wallet> [network]`)
|
|
16
|
+
|
|
17
|
+
## Scripts
|
|
18
|
+
|
|
19
|
+
### generate_keys
|
|
20
|
+
|
|
21
|
+
Generates new wallet keys and saves them to a JSON file.
|
|
22
|
+
|
|
23
|
+
**Usage:**
|
|
24
|
+
```bash
|
|
25
|
+
utexo generate_keys <wallet_name> [network]
|
|
26
|
+
# or: node cli/generate_keys.mjs <wallet_name> [network]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Examples:**
|
|
30
|
+
```bash
|
|
31
|
+
utexo generate_keys mywallet # default: regtest
|
|
32
|
+
utexo generate_keys mywallet testnet
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Parameters:**
|
|
36
|
+
- `wallet_name` (required) - Name for the wallet configuration file
|
|
37
|
+
- `network` (optional) - Bitcoin network, defaults to `regtest` if not provided
|
|
38
|
+
- Options: `mainnet`, `testnet`, `testnet4`, `regtest`, `utexo`
|
|
39
|
+
|
|
40
|
+
**Output:**
|
|
41
|
+
- Creates a JSON file in `cli/data/<wallet_name>.json` containing:
|
|
42
|
+
- Wallet name
|
|
43
|
+
- Network
|
|
44
|
+
- Mnemonic (⚠️ keep secure!)
|
|
45
|
+
- xpub, accountXpubVanilla, accountXpubColored
|
|
46
|
+
- masterFingerprint
|
|
47
|
+
- xpriv
|
|
48
|
+
- Created timestamp
|
|
49
|
+
|
|
50
|
+
### address
|
|
51
|
+
|
|
52
|
+
Get wallet address.
|
|
53
|
+
|
|
54
|
+
**Usage:** `utexo address <wallet_name>`
|
|
55
|
+
|
|
56
|
+
**Parameters:**
|
|
57
|
+
- `wallet_name` (required) - Name of the wallet (must match a file in `data/<wallet_name>.json`)
|
|
58
|
+
|
|
59
|
+
**Output:**
|
|
60
|
+
- Displays the wallet address and wallet information
|
|
61
|
+
|
|
62
|
+
### btcbalance
|
|
63
|
+
|
|
64
|
+
Get BTC balance.
|
|
65
|
+
|
|
66
|
+
**Usage:** `utexo btcbalance <wallet_name>`
|
|
67
|
+
|
|
68
|
+
**Parameters:**
|
|
69
|
+
- `wallet_name` (required) - Name of the wallet (must match a file in `data/<wallet_name>.json`)
|
|
70
|
+
|
|
71
|
+
**Output:**
|
|
72
|
+
- Displays BTC balance information including:
|
|
73
|
+
- Vanilla (Regular BTC) balance: settled, future, spendable
|
|
74
|
+
- Colored (RGB Assets) balance: settled, future, spendable
|
|
75
|
+
- Wallet information
|
|
76
|
+
|
|
77
|
+
### createutxos
|
|
78
|
+
|
|
79
|
+
Create UTXOs.
|
|
80
|
+
|
|
81
|
+
**Usage:** `utexo createutxos <wallet_name> [options]`
|
|
82
|
+
|
|
83
|
+
**Options:**
|
|
84
|
+
- `--num <number>` - Number of UTXOs to create (default: 5)
|
|
85
|
+
- `--size <number>` - Size of each UTXO in sats (default: 1000)
|
|
86
|
+
- `--feeRate <number>` - Fee rate in sat/vB (default: 1)
|
|
87
|
+
- `--upTo` - Create UTXOs up to the specified number (optional flag)
|
|
88
|
+
|
|
89
|
+
**Examples:**
|
|
90
|
+
```bash
|
|
91
|
+
utexo createutxos mywallet
|
|
92
|
+
utexo createutxos mywallet --num 10 --size 2000 --feeRate 2
|
|
93
|
+
utexo createutxos mywallet --num 20 --upTo
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Parameters:**
|
|
97
|
+
- `wallet_name` (required) - Name of the wallet (must match `data/<wallet_name>.json`)
|
|
98
|
+
- Options are optional and have sensible defaults
|
|
99
|
+
|
|
100
|
+
**Output:**
|
|
101
|
+
- Displays the number of UTXOs created
|
|
102
|
+
- Shows wallet information
|
|
103
|
+
|
|
104
|
+
**Note:** This command requires the wallet to have sufficient BTC balance to create UTXOs and pay fees.
|
|
105
|
+
|
|
106
|
+
### listassets
|
|
107
|
+
|
|
108
|
+
List RGB assets.
|
|
109
|
+
|
|
110
|
+
**Usage:** `utexo listassets <wallet_name> [--assetId <id>]`
|
|
111
|
+
|
|
112
|
+
**Parameters:**
|
|
113
|
+
- `wallet_name` (required) - Name of the wallet (must match `data/<wallet_name>.json`)
|
|
114
|
+
|
|
115
|
+
**Output:**
|
|
116
|
+
- Lists all assets by type: NIA (RGB20), UDA, CFA, IFA
|
|
117
|
+
- For each asset: ticker/name, asset ID, settled and spendable balance
|
|
118
|
+
- Total asset count
|
|
119
|
+
- Raw JSON response from `listAssets()`
|
|
120
|
+
|
|
121
|
+
### blindreceive
|
|
122
|
+
|
|
123
|
+
Create blind receive invoice.
|
|
124
|
+
|
|
125
|
+
**Usage:** `utexo blindreceive <wallet_name> --amount <number> [options]`
|
|
126
|
+
|
|
127
|
+
**Options:**
|
|
128
|
+
- `--amount <number>` (required) - Amount to receive
|
|
129
|
+
- `--assetId <string>` - Asset ID (optional)
|
|
130
|
+
- `--minConfirmations <n>` - Min confirmations (optional)
|
|
131
|
+
- `--durationSeconds <n>` - Invoice duration in seconds (optional)
|
|
132
|
+
|
|
133
|
+
**Examples:**
|
|
134
|
+
```bash
|
|
135
|
+
utexo blindreceive mywallet --amount 100
|
|
136
|
+
utexo blindreceive mywallet --amount 50 --assetId rgb:xxx... --durationSeconds 2000
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Output:**
|
|
140
|
+
- Raw JSON response from `blindReceive()`: invoice, recipientId, expirationTimestamp, batchTransferIdx
|
|
141
|
+
- Wallet info
|
|
142
|
+
|
|
143
|
+
### witnessreceive
|
|
144
|
+
|
|
145
|
+
Create witness receive invoice.
|
|
146
|
+
|
|
147
|
+
**Usage:** `utexo witnessreceive <wallet_name> --amount <number> [options]`
|
|
148
|
+
|
|
149
|
+
**Options:**
|
|
150
|
+
- `--amount <number>` (required) - Amount to receive
|
|
151
|
+
- `--assetId <string>` - Asset ID (optional)
|
|
152
|
+
- `--minConfirmations <n>` - Min confirmations (optional)
|
|
153
|
+
- `--durationSeconds <n>` - Invoice duration in seconds (optional)
|
|
154
|
+
|
|
155
|
+
**Examples:**
|
|
156
|
+
```bash
|
|
157
|
+
utexo witnessreceive mywallet --amount 100
|
|
158
|
+
utexo witnessreceive mywallet --amount 50 --assetId rgb:xxx... --durationSeconds 2000
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Output:**
|
|
162
|
+
- Raw JSON response from `witnessReceive()`: invoice, recipientId, expirationTimestamp, batchTransferIdx
|
|
163
|
+
- Wallet info
|
|
164
|
+
|
|
165
|
+
### decodergbinvoice
|
|
166
|
+
|
|
167
|
+
Decode an RGB invoice.
|
|
168
|
+
|
|
169
|
+
**Usage:** `utexo decodergbinvoice <wallet_name> --invoice "<invoice_string>"`
|
|
170
|
+
|
|
171
|
+
**Output:**
|
|
172
|
+
- Raw JSON response from `decodeRGBInvoice()`: invoice, recipientId, assetSchema, assetId, network, assignment, assignmentName, expirationTimestamp, transportEndpoints
|
|
173
|
+
- Wallet info
|
|
174
|
+
|
|
175
|
+
### refresh
|
|
176
|
+
|
|
177
|
+
Refresh wallet state.
|
|
178
|
+
|
|
179
|
+
**Usage:** `utexo refresh <wallet_name>`
|
|
180
|
+
|
|
181
|
+
**Parameters:**
|
|
182
|
+
- `wallet_name` (required) - Name of the wallet (must match `data/<wallet_name>.json`)
|
|
183
|
+
|
|
184
|
+
**Output:**
|
|
185
|
+
- Success message and wallet info
|
|
186
|
+
|
|
187
|
+
### listtransfers
|
|
188
|
+
|
|
189
|
+
List transfers.
|
|
190
|
+
|
|
191
|
+
**Usage:** `utexo listtransfers <wallet_name> [--assetId <asset_id>]`
|
|
192
|
+
- `--assetId <string>` (optional) - Filter transfers by asset ID
|
|
193
|
+
|
|
194
|
+
**Examples:**
|
|
195
|
+
```bash
|
|
196
|
+
utexo listtransfers mywallet
|
|
197
|
+
utexo listtransfers mywallet --assetId rgb:xxx...
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Output:**
|
|
201
|
+
- Raw JSON response from `listTransfers()` (array of transfers)
|
|
202
|
+
- Total transfer count
|
|
203
|
+
- Wallet info
|
|
204
|
+
|
|
205
|
+
### onchainreceive
|
|
206
|
+
|
|
207
|
+
Generate on-chain deposit invoice (mainnet → UTEXO).
|
|
208
|
+
|
|
209
|
+
**Usage:** `utexo onchainreceive <wallet_name> --amount <n> [--assetId <id>] [--minConfirmations <n>] [--durationSeconds <n>]`
|
|
210
|
+
|
|
211
|
+
**Output:** Mainnet invoice for depositing to UTEXO.
|
|
212
|
+
|
|
213
|
+
### onchainsendbegin
|
|
214
|
+
|
|
215
|
+
Begin on-chain send, returns unsigned PSBT.
|
|
216
|
+
|
|
217
|
+
**Usage:** `utexo onchainsendbegin <wallet_name> --invoice "<invoice_string>"`
|
|
218
|
+
|
|
219
|
+
### signpsbt
|
|
220
|
+
|
|
221
|
+
Sign PSBT (uses wallet; requires init/goOnline).
|
|
222
|
+
|
|
223
|
+
**Usage:** `utexo signpsbt <wallet_name> --psbt "<psbt_string>" [--mnemonic "<mnemonic>"]`
|
|
224
|
+
|
|
225
|
+
### sign-psbt
|
|
226
|
+
|
|
227
|
+
Sign PSBT standalone (no wallet). Use when signing without loading a wallet config.
|
|
228
|
+
|
|
229
|
+
**Usage:** `utexo sign-psbt --psbt "<psbt>" --network <regtest|testnet|mainnet> --mnemonic "<mnemonic>"`
|
|
230
|
+
|
|
231
|
+
### onchainsendend
|
|
232
|
+
|
|
233
|
+
Complete on-chain send with signed PSBT.
|
|
234
|
+
|
|
235
|
+
**Usage:** `utexo onchainsendend <wallet_name> --invoice "<invoice_string>" --signedPsbt "<signed_psbt>"`
|
|
236
|
+
|
|
237
|
+
### onchainsend
|
|
238
|
+
|
|
239
|
+
Complete on-chain send flow (begin + sign + end).
|
|
240
|
+
|
|
241
|
+
**Usage:** `utexo onchainsend <wallet_name> --invoice "<invoice_string>" [--mnemonic "<mnemonic>"]`
|
|
242
|
+
|
|
243
|
+
### send
|
|
244
|
+
|
|
245
|
+
Standard RGB send (blind/witness invoice).
|
|
246
|
+
|
|
247
|
+
**Usage:** `utexo send <wallet_name> --invoice "<inv>" [--assetId <id>] [--amount <n>] [--witnessData "<json>"] [--mnemonic "<mn>"] [--feeRate <n>] [--minConfirmations <n>]`
|
|
248
|
+
|
|
249
|
+
### listunspents
|
|
250
|
+
|
|
251
|
+
List unspent UTXOs.
|
|
252
|
+
|
|
253
|
+
**Usage:** `utexo listunspents <wallet_name>`
|
|
254
|
+
|
|
255
|
+
### getonchainsendstatus
|
|
256
|
+
|
|
257
|
+
Get on-chain send status.
|
|
258
|
+
|
|
259
|
+
**Usage:** `utexo getonchainsendstatus <wallet_name> --invoice "<invoice_string>"`
|
|
260
|
+
|
|
261
|
+
### createlightninginvoice
|
|
262
|
+
|
|
263
|
+
Create Lightning invoice.
|
|
264
|
+
|
|
265
|
+
**Usage:** `utexo createlightninginvoice <wallet_name> --assetId <id> --amount <n> [--amountSats <n>] [--expirySeconds <n>]`
|
|
266
|
+
|
|
267
|
+
### paylightninginvoicebegin
|
|
268
|
+
|
|
269
|
+
Begin Lightning payment, returns unsigned PSBT.
|
|
270
|
+
|
|
271
|
+
**Usage:** `utexo paylightninginvoicebegin <wallet_name> --lnInvoice "<ln_invoice>" [--maxFee <n>]`
|
|
272
|
+
|
|
273
|
+
### paylightninginvoice
|
|
274
|
+
|
|
275
|
+
Complete Lightning payment (begin + sign + end).
|
|
276
|
+
|
|
277
|
+
**Usage:** `utexo paylightninginvoice <wallet_name> --lnInvoice "<ln_invoice>" [--amount <n>] [--assetId <id>] [--maxFee <n>] [--mnemonic "<mn>"]`
|
|
278
|
+
|
|
279
|
+
### paylightninginvoiceend
|
|
280
|
+
|
|
281
|
+
Complete Lightning payment with signed PSBT.
|
|
282
|
+
|
|
283
|
+
**Usage:** `utexo paylightninginvoiceend <wallet_name> --lnInvoice "<ln_invoice>" --signedPsbt "<signed_psbt>"`
|
|
284
|
+
|
|
285
|
+
### getlightningsendrequest
|
|
286
|
+
|
|
287
|
+
Get Lightning send status.
|
|
288
|
+
|
|
289
|
+
**Usage:** `utexo getlightningsendrequest <wallet_name> --lnInvoice "<ln_invoice>"`
|
|
290
|
+
|
|
291
|
+
### getlightningreceiverequest
|
|
292
|
+
|
|
293
|
+
Get Lightning receive status.
|
|
294
|
+
|
|
295
|
+
**Usage:** `utexo getlightningreceiverequest <wallet_name> --lnInvoice "<ln_invoice>"`
|
|
296
|
+
|
|
297
|
+
## Example Workflow
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# 1. Generate keys (default: regtest)
|
|
301
|
+
utexo generate_keys testwallet
|
|
302
|
+
|
|
303
|
+
# 2. Get address, balance, create UTXOs
|
|
304
|
+
utexo address testwallet
|
|
305
|
+
utexo btcbalance testwallet
|
|
306
|
+
utexo createutxos testwallet --num 10 --size 1500
|
|
307
|
+
utexo listassets testwallet
|
|
308
|
+
|
|
309
|
+
# 3. Receive invoices
|
|
310
|
+
utexo blindreceive testwallet --amount 100
|
|
311
|
+
utexo witnessreceive testwallet --amount 100
|
|
312
|
+
|
|
313
|
+
# 4. On-chain (UTEXO)
|
|
314
|
+
utexo onchainreceive testwallet --amount 100
|
|
315
|
+
utexo onchainsend testwallet --invoice "<mainnet_invoice>"
|
|
316
|
+
utexo getonchainsendstatus testwallet --invoice "<invoice>"
|
|
317
|
+
|
|
318
|
+
# 5. Lightning
|
|
319
|
+
utexo createlightninginvoice testwallet --assetId rgb:xxx... --amount 100
|
|
320
|
+
utexo paylightninginvoice testwallet --lnInvoice "lnbc..."
|
|
321
|
+
|
|
322
|
+
# 6. Standard RGB send
|
|
323
|
+
utexo send testwallet --invoice "<inv>" --assetId <id> --amount <n>
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**WalletManager (standard RGB, same keys):** `utexo wm address|btcbalance|refresh|sync|createutxos|blindreceive|listassets|listtransfers|sendbatch|sendbtc <wallet> [options]`
|
|
327
|
+
|
|
328
|
+
## Security Warning
|
|
329
|
+
|
|
330
|
+
⚠️ **IMPORTANT**: The wallet configuration files contain sensitive information (mnemonic, private keys).
|
|
331
|
+
- Never commit these files to version control
|
|
332
|
+
- Keep them secure and encrypted
|
|
333
|
+
- This folder is automatically ignored by git (see `.gitignore`)
|
|
334
|
+
|
|
335
|
+
## Data folder
|
|
336
|
+
|
|
337
|
+
Wallet config files and other test data live in **`cli/data/`**:
|
|
338
|
+
- `data/<wallet_name>.json` — wallet configs created by `generate_keys.mjs`
|
|
339
|
+
- `data/bridge.txt` — optional bridge-related data
|
|
340
|
+
|
|
341
|
+
Scripts read and write wallet configs under `data/` automatically.
|
|
342
|
+
|
|
343
|
+
## Notes
|
|
344
|
+
|
|
345
|
+
- All scripts use ES modules (`.mjs` extension)
|
|
346
|
+
- Scripts require the project to be built (`npm run build`) before use
|
|
347
|
+
- Wallet files are stored in `cli/data/` as `<wallet_name>.json`
|
|
348
|
+
- Wallet `network` from config (e.g. `regtest`, `utexo`, `testnet`) is mapped to UTEXOWallet presets `mainnet` or `testnet` automatically
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* address command: get wallet address
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
8
|
+
|
|
9
|
+
export async function run(walletName, flagArgs) {
|
|
10
|
+
parseFlags(flagArgs, { required: [], optional: [] });
|
|
11
|
+
|
|
12
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
13
|
+
const address = await wallet.getAddress();
|
|
14
|
+
console.log(`✅ Address: ${address}`);
|
|
15
|
+
}, { quiet: true });
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['amount'], optional: ['assetId', 'minConfirmations', 'durationSeconds'] }, { usage: options.usage });
|
|
5
|
+
const request = {
|
|
6
|
+
amount: parseInt(opts.amount, 10),
|
|
7
|
+
...(opts.assetId && { assetId: opts.assetId }),
|
|
8
|
+
...(opts.minConfirmations && { minConfirmations: parseInt(opts.minConfirmations, 10) }),
|
|
9
|
+
...(opts.durationSeconds && { durationSeconds: parseInt(opts.durationSeconds, 10) }),
|
|
10
|
+
};
|
|
11
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
12
|
+
const result = await wallet.blindReceive(request);
|
|
13
|
+
console.log(JSON.stringify(result, null, 2));
|
|
14
|
+
}, { quiet: true });
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs) {
|
|
4
|
+
parseFlags(flagArgs, { required: [], optional: [] });
|
|
5
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
6
|
+
const balance = await wallet.getBtcBalance();
|
|
7
|
+
console.log('✅ BTC balance:');
|
|
8
|
+
console.log(` Vanilla: settled ${balance.vanilla.settled}, spendable ${balance.vanilla.spendable} sats`);
|
|
9
|
+
console.log(` Colored: settled ${balance.colored.settled}, spendable ${balance.colored.spendable} sats`);
|
|
10
|
+
}, { quiet: true });
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['assetId', 'amount'], optional: ['amountSats', 'expirySeconds'] }, { usage: options.usage });
|
|
5
|
+
const request = {
|
|
6
|
+
asset: { assetId: opts.assetId, amount: parseInt(opts.amount, 10) },
|
|
7
|
+
...(opts.amountSats && { amountSats: parseInt(opts.amountSats, 10) }),
|
|
8
|
+
...(opts.expirySeconds && { expirySeconds: parseInt(opts.expirySeconds, 10) }),
|
|
9
|
+
};
|
|
10
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
11
|
+
const result = await wallet.createLightningInvoice(request);
|
|
12
|
+
console.log(JSON.stringify(result, null, 2));
|
|
13
|
+
}, { quiet: true });
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: [], optional: ['num', 'size', 'feeRate'] });
|
|
5
|
+
const upTo = flagArgs.includes('--upTo');
|
|
6
|
+
const num = opts.num ? parseInt(opts.num, 10) : 5;
|
|
7
|
+
const size = opts.size ? parseInt(opts.size, 10) : 1000;
|
|
8
|
+
const feeRate = opts.feeRate ? parseInt(opts.feeRate, 10) : 1;
|
|
9
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
10
|
+
const count = await wallet.createUtxos({ num, size, feeRate, upTo: upTo || undefined });
|
|
11
|
+
console.log(`✅ Created ${count} UTXO(s)`);
|
|
12
|
+
}, { quiet: true });
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['invoice'], optional: [] }, { usage: options.usage });
|
|
5
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
6
|
+
const result = await wallet.decodeRGBInvoice({ invoice: opts.invoice });
|
|
7
|
+
console.log(JSON.stringify(result, null, 2));
|
|
8
|
+
}, { quiet: true });
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate new wallet keys and save to cli/data/<wallet_name>.json
|
|
3
|
+
* Usage: utexo generate_keys <wallet_name> [network]
|
|
4
|
+
* network: regtest (default), testnet, mainnet
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { generateKeys } from '../../dist/index.mjs';
|
|
8
|
+
import { saveWalletConfig } from '../utils.mjs';
|
|
9
|
+
|
|
10
|
+
export async function run(walletName, flagArgs, { usage } = {}) {
|
|
11
|
+
if (!walletName) {
|
|
12
|
+
console.error('Usage: utexo generate_keys <wallet_name> [network]');
|
|
13
|
+
if (usage) console.error(usage);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const network = flagArgs[0] || 'regtest';
|
|
18
|
+
const keys = await generateKeys(network);
|
|
19
|
+
|
|
20
|
+
const walletConfig = {
|
|
21
|
+
walletName,
|
|
22
|
+
network,
|
|
23
|
+
mnemonic: keys.mnemonic,
|
|
24
|
+
xpub: keys.xpub,
|
|
25
|
+
accountXpubVanilla: keys.accountXpubVanilla,
|
|
26
|
+
accountXpubColored: keys.accountXpubColored,
|
|
27
|
+
masterFingerprint: keys.masterFingerprint,
|
|
28
|
+
xpriv: keys.xpriv,
|
|
29
|
+
createdAt: new Date().toISOString(),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const filepath = saveWalletConfig(walletName, walletConfig);
|
|
33
|
+
console.log(`✅ Keys saved to ${filepath}`);
|
|
34
|
+
console.log(` Network: ${network}`);
|
|
35
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['lnInvoice'], optional: [] }, { usage: options.usage });
|
|
5
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
6
|
+
const status = await wallet.getLightningReceiveRequest(opts.lnInvoice);
|
|
7
|
+
console.log(status === null ? '✅ No transfer found' : `✅ Status: ${status}`);
|
|
8
|
+
if (status !== null) console.log(JSON.stringify(status, null, 2));
|
|
9
|
+
}, { quiet: true });
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['lnInvoice'], optional: [] }, { usage: options.usage });
|
|
5
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
6
|
+
const status = await wallet.getLightningSendRequest(opts.lnInvoice);
|
|
7
|
+
console.log(status === null ? '✅ No transfer found' : `✅ Status: ${status}`);
|
|
8
|
+
if (status !== null) console.log(JSON.stringify(status, null, 2));
|
|
9
|
+
}, { quiet: true });
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* getonchainsendstatus command: get onchain send status for an invoice
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
8
|
+
|
|
9
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
10
|
+
const { usage } = options;
|
|
11
|
+
const opts = parseFlags(flagArgs, { required: ['invoice'], optional: [] }, {
|
|
12
|
+
usage: usage ? `❌ --invoice "<invoice_string>" is required\n\n${usage}` : undefined,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
16
|
+
const status = await wallet.getOnchainSendStatus(opts.invoice);
|
|
17
|
+
console.log(status === null ? '✅ No transfer found for this invoice' : `✅ Status: ${status}`);
|
|
18
|
+
if (status !== null) console.log(JSON.stringify(status, null, 2));
|
|
19
|
+
}, { quiet: true });
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs) {
|
|
4
|
+
parseFlags(flagArgs, { required: [], optional: [] });
|
|
5
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
6
|
+
const assets = await wallet.listAssets();
|
|
7
|
+
console.log(JSON.stringify(assets, null, 2));
|
|
8
|
+
const n = (assets.nia?.length || 0) + (assets.uda?.length || 0) + (assets.cfa?.length || 0) + (assets.ifa?.length || 0);
|
|
9
|
+
console.log(`✅ Total: ${n} asset(s)`);
|
|
10
|
+
}, { quiet: true });
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: [], optional: ['assetId'] });
|
|
5
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
6
|
+
const transfers = await wallet.listTransfers(opts.assetId);
|
|
7
|
+
console.log(JSON.stringify(transfers, null, 2));
|
|
8
|
+
console.log(`✅ Total: ${Array.isArray(transfers) ? transfers.length : 0} transfer(s)`);
|
|
9
|
+
}, { quiet: true });
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs) {
|
|
4
|
+
parseFlags(flagArgs, { required: [], optional: [] });
|
|
5
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
6
|
+
const unspents = await wallet.listUnspents();
|
|
7
|
+
console.log(JSON.stringify(unspents, null, 2));
|
|
8
|
+
console.log(`✅ Total: ${Array.isArray(unspents) ? unspents.length : 0} unspent(s)`);
|
|
9
|
+
}, { quiet: true });
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['amount'], optional: ['assetId', 'minConfirmations', 'durationSeconds'] }, { usage: options.usage });
|
|
5
|
+
const request = {
|
|
6
|
+
amount: parseInt(opts.amount, 10),
|
|
7
|
+
...(opts.assetId && { assetId: opts.assetId }),
|
|
8
|
+
...(opts.minConfirmations && { minConfirmations: parseInt(opts.minConfirmations, 10) }),
|
|
9
|
+
...(opts.durationSeconds && { durationSeconds: parseInt(opts.durationSeconds, 10) }),
|
|
10
|
+
};
|
|
11
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
12
|
+
const result = await wallet.onchainReceive(request);
|
|
13
|
+
console.log(JSON.stringify(result, null, 2));
|
|
14
|
+
if (result?.invoice) console.log('\nMainnet invoice:', result.invoice);
|
|
15
|
+
}, { quiet: true });
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['invoice'], optional: ['assetId', 'amount', 'mnemonic'] }, { usage: options.usage });
|
|
5
|
+
await runWithWallet(walletName, async (wallet, walletConfig) => {
|
|
6
|
+
const mnemonic = opts.mnemonic || walletConfig.mnemonic;
|
|
7
|
+
const request = { invoice: opts.invoice, ...(opts.assetId && { assetId: opts.assetId }), ...(opts.amount && { amount: parseInt(opts.amount, 10) }) };
|
|
8
|
+
const result = await wallet.onchainSend(request, mnemonic);
|
|
9
|
+
console.log(JSON.stringify(result, null, 2));
|
|
10
|
+
}, { quiet: true });
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['invoice'], optional: [] }, { usage: options.usage });
|
|
5
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
6
|
+
const psbt = await wallet.onchainSendBegin({ invoice: opts.invoice });
|
|
7
|
+
console.log(psbt);
|
|
8
|
+
}, { quiet: true });
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['invoice', 'signedPsbt'], optional: [] }, { usage: options.usage });
|
|
5
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
6
|
+
const result = await wallet.onchainSendEnd({ invoice: opts.invoice, signedPsbt: opts.signedPsbt });
|
|
7
|
+
console.log(JSON.stringify(result, null, 2));
|
|
8
|
+
}, { quiet: true });
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['lnInvoice'], optional: ['amount', 'assetId', 'maxFee', 'mnemonic'] }, { usage: options.usage });
|
|
5
|
+
await runWithWallet(walletName, async (wallet, walletConfig) => {
|
|
6
|
+
const mnemonic = opts.mnemonic || walletConfig.mnemonic;
|
|
7
|
+
const request = { lnInvoice: opts.lnInvoice, ...(opts.amount && { amount: parseInt(opts.amount, 10) }), ...(opts.assetId && { assetId: opts.assetId }), ...(opts.maxFee && { maxFee: parseInt(opts.maxFee, 10) }) };
|
|
8
|
+
const result = await wallet.payLightningInvoice(request, mnemonic);
|
|
9
|
+
console.log(JSON.stringify(result, null, 2));
|
|
10
|
+
}, { quiet: true });
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['lnInvoice'], optional: ['maxFee'] }, { usage: options.usage });
|
|
5
|
+
const request = { lnInvoice: opts.lnInvoice, ...(opts.maxFee && { maxFee: parseInt(opts.maxFee, 10) }) };
|
|
6
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
7
|
+
const psbt = await wallet.payLightningInvoiceBegin(request);
|
|
8
|
+
console.log(psbt);
|
|
9
|
+
}, { quiet: true });
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs, options = {}) {
|
|
4
|
+
const opts = parseFlags(flagArgs, { required: ['lnInvoice', 'signedPsbt'], optional: [] }, { usage: options.usage });
|
|
5
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
6
|
+
const result = await wallet.payLightningInvoiceEnd({ lnInvoice: opts.lnInvoice, signedPsbt: opts.signedPsbt });
|
|
7
|
+
console.log(JSON.stringify(result, null, 2));
|
|
8
|
+
}, { quiet: true });
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { parseFlags, runWithWallet } from '../utils.mjs';
|
|
2
|
+
|
|
3
|
+
export async function run(walletName, flagArgs) {
|
|
4
|
+
parseFlags(flagArgs, { required: [], optional: [] });
|
|
5
|
+
await runWithWallet(walletName, async (wallet) => {
|
|
6
|
+
await wallet.refreshWallet();
|
|
7
|
+
console.log('✅ Wallet refreshed');
|
|
8
|
+
}, { quiet: true });
|
|
9
|
+
}
|