@getalby/cli 0.0.0 → 0.0.1
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 +63 -3
- package/build/commands/{request-invoice.js → request-invoice-from-lightning-address.js} +5 -5
- package/build/index.js +2 -2
- package/build/test/lightning-tools.test.js +2 -2
- package/build/tools/lightning/{request_invoice.js → request_invoice_from_lightning_address.js} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,14 +48,41 @@ npx @getalby/cli -c "nostr+walletconnect://..." make-invoice --amount 1000 --des
|
|
|
48
48
|
# Pay an invoice
|
|
49
49
|
npx @getalby/cli -c "nostr+walletconnect://..." pay-invoice --invoice "lnbc..."
|
|
50
50
|
|
|
51
|
+
# Send a keysend payment
|
|
52
|
+
npx @getalby/cli -c "nostr+walletconnect://..." pay-keysend --pubkey "02abc..." --amount 100
|
|
53
|
+
|
|
51
54
|
# Look up an invoice by payment hash
|
|
52
55
|
npx @getalby/cli -c "nostr+walletconnect://..." lookup-invoice --payment-hash "abc123..."
|
|
53
56
|
|
|
54
57
|
# List transactions
|
|
55
58
|
npx @getalby/cli -c "nostr+walletconnect://..." list-transactions --limit 10
|
|
56
59
|
|
|
60
|
+
# Get wallet budget
|
|
61
|
+
npx @getalby/cli -c "nostr+walletconnect://..." get-budget
|
|
62
|
+
|
|
63
|
+
# Sign a message
|
|
64
|
+
npx @getalby/cli -c "nostr+walletconnect://..." sign-message --message "Hello, World!"
|
|
65
|
+
|
|
57
66
|
# Fetch L402-protected resource
|
|
58
67
|
npx @getalby/cli -c "nostr+walletconnect://..." fetch-l402 --url "https://example.com/api"
|
|
68
|
+
|
|
69
|
+
# Wait for a payment notification
|
|
70
|
+
npx @getalby/cli -c "nostr+walletconnect://..." wait-for-payment --payment-hash "abc123..."
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### HOLD Invoices
|
|
74
|
+
|
|
75
|
+
HOLD invoices allow you to accept payments conditionally - the payment is held until you settle or cancel it.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Create a HOLD invoice (you provide the payment hash)
|
|
79
|
+
npx @getalby/cli -c "nostr+walletconnect://..." make-hold-invoice --amount 1000 --payment-hash "abc123..."
|
|
80
|
+
|
|
81
|
+
# Settle a HOLD invoice (claim the payment)
|
|
82
|
+
npx @getalby/cli -c "nostr+walletconnect://..." settle-hold-invoice --preimage "def456..."
|
|
83
|
+
|
|
84
|
+
# Cancel a HOLD invoice (reject the payment)
|
|
85
|
+
npx @getalby/cli -c "nostr+walletconnect://..." cancel-hold-invoice --payment-hash "abc123..."
|
|
59
86
|
```
|
|
60
87
|
|
|
61
88
|
### Lightning Tools
|
|
@@ -66,28 +93,61 @@ These commands don't require a wallet connection:
|
|
|
66
93
|
# Convert USD to sats
|
|
67
94
|
npx @getalby/cli fiat-to-sats --currency USD --amount 10
|
|
68
95
|
|
|
96
|
+
# Convert sats to USD
|
|
97
|
+
npx @getalby/cli sats-to-fiat --amount 1000 --currency USD
|
|
98
|
+
|
|
69
99
|
# Parse a BOLT-11 invoice
|
|
70
100
|
npx @getalby/cli parse-invoice --invoice "lnbc..."
|
|
71
101
|
|
|
102
|
+
# Verify a preimage against an invoice
|
|
103
|
+
npx @getalby/cli verify-preimage --invoice "lnbc..." --preimage "abc123..."
|
|
104
|
+
|
|
72
105
|
# Request invoice from lightning address
|
|
73
|
-
npx @getalby/cli request-invoice --address "hello@getalby.com" --amount 1000
|
|
106
|
+
npx @getalby/cli request-invoice-from-lightning-address --address "hello@getalby.com" --amount 1000
|
|
74
107
|
```
|
|
75
108
|
|
|
76
109
|
## Command Reference
|
|
77
110
|
|
|
111
|
+
### Wallet Commands
|
|
112
|
+
|
|
113
|
+
These require `--connection-secret`:
|
|
114
|
+
|
|
78
115
|
| Command | Description | Required Options |
|
|
79
116
|
|---------|-------------|------------------|
|
|
80
117
|
| `get-balance` | Get wallet balance | - |
|
|
81
118
|
| `get-info` | Get wallet info | - |
|
|
82
119
|
| `get-wallet-service-info` | Get wallet capabilities | - |
|
|
120
|
+
| `get-budget` | Get wallet budget | - |
|
|
83
121
|
| `make-invoice` | Create a lightning invoice | `--amount` |
|
|
84
122
|
| `pay-invoice` | Pay a lightning invoice | `--invoice` |
|
|
123
|
+
| `pay-keysend` | Send a keysend payment | `--pubkey`, `--amount` |
|
|
85
124
|
| `lookup-invoice` | Look up an invoice | `--payment-hash` or `--invoice` |
|
|
86
125
|
| `list-transactions` | List transactions | - |
|
|
126
|
+
| `sign-message` | Sign a message with wallet key | `--message` |
|
|
127
|
+
| `wait-for-payment` | Wait for payment notification | `--payment-hash` |
|
|
128
|
+
| `fetch-l402` | Fetch L402-protected resource | `--url` |
|
|
129
|
+
|
|
130
|
+
### HOLD Invoice Commands
|
|
131
|
+
|
|
132
|
+
These require `--connection-secret`:
|
|
133
|
+
|
|
134
|
+
| Command | Description | Required Options |
|
|
135
|
+
|---------|-------------|------------------|
|
|
136
|
+
| `make-hold-invoice` | Create a HOLD invoice | `--amount`, `--payment-hash` |
|
|
137
|
+
| `settle-hold-invoice` | Settle a HOLD invoice | `--preimage` |
|
|
138
|
+
| `cancel-hold-invoice` | Cancel a HOLD invoice | `--payment-hash` |
|
|
139
|
+
|
|
140
|
+
### Lightning Tools
|
|
141
|
+
|
|
142
|
+
These don't require a wallet connection:
|
|
143
|
+
|
|
144
|
+
| Command | Description | Required Options |
|
|
145
|
+
|---------|-------------|------------------|
|
|
87
146
|
| `fiat-to-sats` | Convert fiat to sats | `--currency`, `--amount` |
|
|
147
|
+
| `sats-to-fiat` | Convert sats to fiat | `--amount`, `--currency` |
|
|
88
148
|
| `parse-invoice` | Parse a BOLT-11 invoice | `--invoice` |
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
149
|
+
| `verify-preimage` | Verify preimage against invoice | `--invoice`, `--preimage` |
|
|
150
|
+
| `request-invoice-from-lightning-address` | Request invoice from lightning address | `--address`, `--amount` |
|
|
91
151
|
|
|
92
152
|
## Output
|
|
93
153
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { requestInvoiceFromLightningAddress } from "../tools/lightning/request_invoice_from_lightning_address.js";
|
|
2
2
|
import { handleError, output } from "../utils.js";
|
|
3
|
-
export function
|
|
3
|
+
export function registerRequestInvoiceFromLightningAddressCommand(program) {
|
|
4
4
|
program
|
|
5
|
-
.command("request-invoice")
|
|
6
|
-
.description("Request invoice from lightning address")
|
|
5
|
+
.command("request-invoice-from-lightning-address")
|
|
6
|
+
.description("Request an invoice from a lightning address")
|
|
7
7
|
.requiredOption("-a, --address <ln-address>", "Lightning address")
|
|
8
8
|
.requiredOption("-s, --amount <sats>", "Amount in sats", parseInt)
|
|
9
9
|
.option("--comment <text>", "Optional comment")
|
|
10
10
|
.action(async (options) => {
|
|
11
11
|
await handleError(async () => {
|
|
12
|
-
const result = await
|
|
12
|
+
const result = await requestInvoiceFromLightningAddress({
|
|
13
13
|
lightning_address: options.address,
|
|
14
14
|
amount_in_sats: options.amount,
|
|
15
15
|
comment: options.comment,
|
package/build/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { registerFiatToSatsCommand } from "./commands/fiat-to-sats.js";
|
|
|
18
18
|
import { registerSatsToFiatCommand } from "./commands/sats-to-fiat.js";
|
|
19
19
|
import { registerParseInvoiceCommand } from "./commands/parse-invoice.js";
|
|
20
20
|
import { registerVerifyPreimageCommand } from "./commands/verify-preimage.js";
|
|
21
|
-
import {
|
|
21
|
+
import { registerRequestInvoiceFromLightningAddressCommand } from "./commands/request-invoice-from-lightning-address.js";
|
|
22
22
|
import { registerFetchL402Command } from "./commands/fetch-l402.js";
|
|
23
23
|
const program = new Command();
|
|
24
24
|
program
|
|
@@ -45,6 +45,6 @@ registerFiatToSatsCommand(program);
|
|
|
45
45
|
registerSatsToFiatCommand(program);
|
|
46
46
|
registerParseInvoiceCommand(program);
|
|
47
47
|
registerVerifyPreimageCommand(program);
|
|
48
|
-
|
|
48
|
+
registerRequestInvoiceFromLightningAddressCommand(program);
|
|
49
49
|
registerFetchL402Command(program);
|
|
50
50
|
program.parse();
|
|
@@ -28,8 +28,8 @@ describe("Lightning Tools (no wallet required)", () => {
|
|
|
28
28
|
expect(result.success).toBe(true);
|
|
29
29
|
expect(result.output.valid).toBe(false);
|
|
30
30
|
});
|
|
31
|
-
test("request-invoice requests invoice from lightning address", async () => {
|
|
32
|
-
const result = runCli(`request-invoice -a "${exampleLightningAddress}" -s 100`);
|
|
31
|
+
test("request-invoice-from-lightning-address requests invoice from lightning address", async () => {
|
|
32
|
+
const result = runCli(`request-invoice-from-lightning-address -a "${exampleLightningAddress}" -s 100`);
|
|
33
33
|
expect(result.success).toBe(true);
|
|
34
34
|
expect(result.output.paymentRequest.toLowerCase()).toMatch(/^lnbc/);
|
|
35
35
|
});
|
package/build/tools/lightning/{request_invoice.js → request_invoice_from_lightning_address.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LightningAddress } from "@getalby/lightning-tools";
|
|
2
|
-
export async function
|
|
2
|
+
export async function requestInvoiceFromLightningAddress(params) {
|
|
3
3
|
const ln = new LightningAddress(params.lightning_address);
|
|
4
4
|
await ln.fetch();
|
|
5
5
|
const { satoshi, ...invoice } = await ln.requestInvoice({
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@getalby/cli",
|
|
3
3
|
"description": "CLI for Nostr Wallet Connect (NIP-47) with a few additional useful lightning tools",
|
|
4
4
|
"repository": "https://github.com/getAlby/cli.git",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"bin": {
|