Skip to content

Commit 28845ae

Browse files
authored
Merge pull request lightningdevkit#102 from benthecarman/help-text
Add help text for all cli commands and args
2 parents 9a6c8ec + 1084b5c commit 28845ae

1 file changed

Lines changed: 133 additions & 47 deletions

File tree

  • ldk-server/ldk-server-cli/src

ldk-server/ldk-server-cli/src/main.rs

Lines changed: 133 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ const DEFAULT_MAX_CHANNEL_SATURATION_POWER_OF_HALF: u32 = 2;
4848
const DEFAULT_EXPIRY_SECS: u32 = 86_400;
4949

5050
#[derive(Parser, Debug)]
51-
#[command(version, about, long_about = None)]
51+
#[command(
52+
name = "ldk-server-cli",
53+
version,
54+
about = "CLI for interacting with an LDK Server node",
55+
override_usage = "ldk-server-cli [OPTIONS] <COMMAND>"
56+
)]
5257
struct Cli {
5358
#[arg(short, long, help = "Base URL of the server. If not provided, reads from config file")]
5459
base_url: Option<String>,
@@ -76,95 +81,161 @@ struct Cli {
7681

7782
#[derive(Subcommand, Debug)]
7883
enum Commands {
84+
#[command(about = "Retrieve the latest node info like node_id, current_best_block, etc")]
7985
GetNodeInfo,
86+
#[command(about = "Retrieve an overview of all known balances")]
8087
GetBalances,
88+
#[command(about = "Retrieve a new on-chain funding address")]
8189
OnchainReceive,
90+
#[command(about = "Send an on-chain payment to the given address")]
8291
OnchainSend {
83-
#[arg(short, long)]
92+
#[arg(short, long, help = "The address to send coins to")]
8493
address: String,
85-
#[arg(long)]
94+
#[arg(
95+
long,
96+
help = "The amount in satoshis to send. Will respect any on-chain reserve needed for anchor channels"
97+
)]
8698
amount_sats: Option<u64>,
87-
#[arg(long)]
99+
#[arg(
100+
long,
101+
help = "Send full balance to the address. Warning: will not retain on-chain reserves for anchor channels"
102+
)]
88103
send_all: Option<bool>,
89-
#[arg(long)]
104+
#[arg(
105+
long,
106+
help = "Fee rate in satoshis per virtual byte. If not set, a reasonable estimate will be used"
107+
)]
90108
fee_rate_sat_per_vb: Option<u64>,
91109
},
110+
#[command(about = "Create a BOLT11 invoice to receive a payment")]
92111
Bolt11Receive {
93-
#[arg(short, long)]
112+
#[arg(short, long, help = "Description to attach along with the invoice")]
94113
description: Option<String>,
95-
#[arg(long)]
114+
#[arg(
115+
long,
116+
help = "SHA-256 hash of the description (hex). Use instead of description for longer text"
117+
)]
96118
description_hash: Option<String>,
97-
#[arg(short, long)]
119+
#[arg(short, long, help = "Invoice expiry time in seconds (default: 86400)")]
98120
expiry_secs: Option<u32>,
99-
#[arg(long)]
121+
#[arg(
122+
long,
123+
help = "Amount in millisatoshis to request. If unset, a variable-amount invoice is returned"
124+
)]
100125
amount_msat: Option<u64>,
101126
},
127+
#[command(about = "Pay a BOLT11 invoice")]
102128
Bolt11Send {
103-
#[arg(short, long)]
129+
#[arg(short, long, help = "A BOLT11 invoice for a payment within the Lightning Network")]
104130
invoice: String,
105-
#[arg(long)]
131+
#[arg(long, help = "Amount in millisatoshis. Required when paying a zero-amount invoice")]
106132
amount_msat: Option<u64>,
107-
#[arg(long)]
133+
#[arg(
134+
long,
135+
help = "Maximum total fees in millisatoshis that may accrue during route finding. Defaults to 1% of payment + 50 sats"
136+
)]
108137
max_total_routing_fee_msat: Option<u64>,
109-
#[arg(long)]
138+
#[arg(long, help = "Maximum total CLTV delta we accept for the route (default: 1008)")]
110139
max_total_cltv_expiry_delta: Option<u32>,
111-
#[arg(long)]
140+
#[arg(
141+
long,
142+
help = "Maximum number of paths that may be used by MPP payments (default: 10)"
143+
)]
112144
max_path_count: Option<u32>,
113-
#[arg(long)]
145+
#[arg(
146+
long,
147+
help = "Maximum share of a channel's total capacity to send over a channel, as a power of 1/2 (default: 2)"
148+
)]
114149
max_channel_saturation_power_of_half: Option<u32>,
115150
},
151+
#[command(about = "Return a BOLT12 offer for receiving payments")]
116152
Bolt12Receive {
117-
#[arg(short, long)]
153+
#[arg(short, long, help = "Description to attach along with the offer")]
118154
description: String,
119-
#[arg(long)]
155+
#[arg(
156+
long,
157+
help = "Amount in millisatoshis to request. If unset, a variable-amount offer is returned"
158+
)]
120159
amount_msat: Option<u64>,
121-
#[arg(long)]
160+
#[arg(long, help = "Offer expiry time in seconds")]
122161
expiry_secs: Option<u32>,
123-
#[arg(long)]
162+
#[arg(long, help = "Number of items requested. Can only be set for fixed-amount offers")]
124163
quantity: Option<u64>,
125164
},
165+
#[command(about = "Send a payment for a BOLT12 offer")]
126166
Bolt12Send {
127-
#[arg(short, long)]
167+
#[arg(short, long, help = "A BOLT12 offer for a payment within the Lightning Network")]
128168
offer: String,
129-
#[arg(long)]
169+
#[arg(long, help = "Amount in millisatoshis. Required when paying a zero-amount offer")]
130170
amount_msat: Option<u64>,
131-
#[arg(short, long)]
171+
#[arg(short, long, help = "Number of items requested")]
132172
quantity: Option<u64>,
133-
#[arg(short, long)]
173+
#[arg(
174+
short,
175+
long,
176+
help = "Note to include for the payee. Will be seen by recipient and reflected back in the invoice"
177+
)]
134178
payer_note: Option<String>,
135-
#[arg(long)]
179+
#[arg(
180+
long,
181+
help = "Maximum total fees, in millisatoshi, that may accrue during route finding, Defaults to 1% of the payment amount + 50 sats"
182+
)]
136183
max_total_routing_fee_msat: Option<u64>,
137-
#[arg(long)]
184+
#[arg(long, help = "Maximum total CLTV delta we accept for the route (default: 1008)")]
138185
max_total_cltv_expiry_delta: Option<u32>,
139-
#[arg(long)]
186+
#[arg(
187+
long,
188+
help = "Maximum number of paths that may be used by MPP payments (default: 10)"
189+
)]
140190
max_path_count: Option<u32>,
141-
#[arg(long)]
191+
#[arg(
192+
long,
193+
help = "Maximum share of a channel's total capacity to send over a channel, as a power of 1/2 (default: 2)"
194+
)]
142195
max_channel_saturation_power_of_half: Option<u32>,
143196
},
197+
#[command(about = "Cooperatively close the channel specified by the given channel ID")]
144198
CloseChannel {
145-
#[arg(short, long)]
199+
#[arg(short, long, help = "The local user_channel_id of this channel")]
146200
user_channel_id: String,
147-
#[arg(short, long)]
201+
#[arg(
202+
short,
203+
long,
204+
help = "The hex-encoded public key of the node to close a channel with"
205+
)]
148206
counterparty_node_id: String,
149207
},
208+
#[command(about = "Force close the channel specified by the given channel ID")]
150209
ForceCloseChannel {
151-
#[arg(short, long)]
210+
#[arg(short, long, help = "The local user_channel_id of this channel")]
152211
user_channel_id: String,
153-
#[arg(short, long)]
212+
#[arg(
213+
short,
214+
long,
215+
help = "The hex-encoded public key of the node to close a channel with"
216+
)]
154217
counterparty_node_id: String,
155-
#[arg(long)]
218+
#[arg(long, help = "The reason for force-closing, defaults to \"\"")]
156219
force_close_reason: Option<String>,
157220
},
221+
#[command(about = "Create a new outbound channel to the given remote node")]
158222
OpenChannel {
159-
#[arg(short, long)]
223+
#[arg(short, long, help = "The hex-encoded public key of the node to open a channel with")]
160224
node_pubkey: String,
161-
#[arg(short, long)]
225+
#[arg(
226+
short,
227+
long,
228+
help = "Address to connect to remote peer (IPv4:port, IPv6:port, OnionV3:port, or hostname:port)"
229+
)]
162230
address: String,
163-
#[arg(long)]
231+
#[arg(long, help = "The amount of satoshis to commit to the channel")]
164232
channel_amount_sats: u64,
165-
#[arg(long)]
233+
#[arg(
234+
long,
235+
help = "Amount of satoshis to push to the remote side as part of the initial commitment state"
236+
)]
166237
push_to_counterparty_msat: Option<u64>,
167-
#[arg(long)]
238+
#[arg(long, help = "Whether the channel should be public")]
168239
announce_channel: bool,
169240
// Channel config options
170241
#[arg(
@@ -183,25 +254,35 @@ enum Commands {
183254
)]
184255
cltv_expiry_delta: Option<u32>,
185256
},
257+
#[command(
258+
about = "Increase the channel balance by the given amount, funds will come from the node's on-chain wallet"
259+
)]
186260
SpliceIn {
187-
#[arg(short, long)]
261+
#[arg(short, long, help = "The local user_channel_id of the channel")]
188262
user_channel_id: String,
189-
#[arg(short, long)]
263+
#[arg(short, long, help = "The hex-encoded public key of the channel's counterparty node")]
190264
counterparty_node_id: String,
191-
#[arg(long)]
265+
#[arg(long, help = "The amount of sats to splice into the channel")]
192266
splice_amount_sats: u64,
193267
},
268+
#[command(about = "Decrease the channel balance by the given amount")]
194269
SpliceOut {
195-
#[arg(short, long)]
270+
#[arg(short, long, help = "The local user_channel_id of this channel")]
196271
user_channel_id: String,
197-
#[arg(short, long)]
272+
#[arg(short, long, help = "The hex-encoded public key of the channel's counterparty node")]
198273
counterparty_node_id: String,
199-
#[arg(short, long)]
200-
address: Option<String>,
201-
#[arg(long)]
274+
#[arg(long, help = "The amount of sats to splice out of the channel")]
202275
splice_amount_sats: u64,
276+
#[arg(
277+
short,
278+
long,
279+
help = "Bitcoin address to send the spliced-out funds. If not set, uses the node's on-chain wallet"
280+
)]
281+
address: Option<String>,
203282
},
283+
#[command(about = "Return a list of known channels")]
204284
ListChannels,
285+
#[command(about = "Retrieve list of all payments")]
205286
ListPayments {
206287
#[arg(short, long)]
207288
#[arg(
@@ -212,10 +293,15 @@ enum Commands {
212293
#[arg(help = "Page token to continue from a previous page (format: token:index)")]
213294
page_token: Option<String>,
214295
},
296+
#[command(about = "Update the config for a previously opened channel")]
215297
UpdateChannelConfig {
216-
#[arg(short, long)]
298+
#[arg(short, long, help = "The local user_channel_id of this channel")]
217299
user_channel_id: String,
218-
#[arg(short, long)]
300+
#[arg(
301+
short,
302+
long,
303+
help = "The hex-encoded public key of the counterparty node to update channel config with"
304+
)]
219305
counterparty_node_id: String,
220306
#[arg(
221307
long,

0 commit comments

Comments
 (0)