Skip to content

Commit e6fcb58

Browse files
committed
doc+cmd: generate description from commands
1 parent caf4da5 commit e6fcb58

40 files changed

+498
-24
lines changed

cmd/chantools/chanbackup.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ func newChanBackupCommand() *cobra.Command {
2121
cc.cmd = &cobra.Command{
2222
Use: "chanbackup",
2323
Short: "Create a channel.backup file from a channel database",
24-
RunE: cc.Execute,
24+
Long: `This command creates a new channel.backup from a
25+
channel.db file.`,
26+
Example: `chantools chanbackup --rootkey xprvxxxxxxx \
27+
--channeldb ~/.lnd/data/graph/mainnet/channel.db \
28+
--multi_file new_channel_backup.backup`,
29+
RunE: cc.Execute,
2530
}
2631
cc.cmd.Flags().StringVar(
2732
&cc.ChannelDB, "channeldb", "", "lnd channel.db file to "+

cmd/chantools/compactdb.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ func newCompactDBCommand() *cobra.Command {
2626
Use: "compactdb",
2727
Short: "Create a copy of a channel.db file in safe/read-only " +
2828
"mode",
29+
Long: `This command opens a database in read-only mode and tries
30+
to create a copy of it to a destination file, compacting it in the process.`,
31+
Example: `chantools compactdb \
32+
--sourcedb ~/.lnd/data/graph/mainnet/channel.db \
33+
--destdb ./results/compacted.db`,
2934
RunE: cc.Execute,
3035
}
3136
cc.cmd.Flags().Int64Var(

cmd/chantools/derivekey.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,23 @@ import (
1010
)
1111

1212
type deriveKeyCommand struct {
13-
BIP39 bool
14-
Path string
15-
Neuter bool
13+
BIP39 bool
14+
Path string
15+
Neuter bool
1616

1717
rootKey *rootKey
18-
cmd *cobra.Command
18+
cmd *cobra.Command
1919
}
2020

2121
func newDeriveKeyCommand() *cobra.Command {
2222
cc := &deriveKeyCommand{}
2323
cc.cmd = &cobra.Command{
24-
Use: "derivekey",
24+
Use: "derivekey",
2525
Short: "Derive a key with a specific derivation path",
26+
Long: `This command derives a single key with the given BIP32
27+
derivation path from the root key and prints it to the console.`,
28+
Example: `chantools derivekey --rootkey xprvxxxxxxxxxx \
29+
--path "m/1017'/0'/5'/0/0'" --neuter`,
2630
RunE: cc.Execute,
2731
}
2832
cc.cmd.Flags().BoolVar(
@@ -40,7 +44,7 @@ func newDeriveKeyCommand() *cobra.Command {
4044
)
4145

4246
cc.rootKey = newRootKey(cc.cmd, "decrypting the backup")
43-
47+
4448
return cc.cmd
4549
}
4650

cmd/chantools/dumpbackup.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,27 @@ type dumpBackupCommand struct {
1515
MultiFile string
1616

1717
rootKey *rootKey
18-
cmd *cobra.Command
18+
cmd *cobra.Command
1919
}
2020

2121
func newDumpBackupCommand() *cobra.Command {
2222
cc := &dumpBackupCommand{}
2323
cc.cmd = &cobra.Command{
2424
Use: "dumpbackup",
2525
Short: "Dump the content of a channel.backup file",
26-
RunE: cc.Execute,
26+
Long: `This command dumps all information that is inside a
27+
channel.backup file in a human readable format.`,
28+
Example: `chantools dumpbackup --rootkey xprvxxxxxxxxxx \
29+
--multi_file ~/.lnd/data/chain/bitcoin/mainnet/channel.backup`,
30+
RunE: cc.Execute,
2731
}
2832
cc.cmd.Flags().StringVar(
2933
&cc.MultiFile, "multi_file", "", "lnd channel.backup file to "+
3034
"dump",
3135
)
3236

3337
cc.rootKey = newRootKey(cc.cmd, "decrypting the backup")
34-
38+
3539
return cc.cmd
3640
}
3741

cmd/chantools/dumpchannels.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ func newDumpChannelsCommand() *cobra.Command {
2323
Use: "dumpchannels",
2424
Short: "Dump all channel information from an lnd channel " +
2525
"database",
26+
Long: `This command dumps all open and pending channels from the
27+
given lnd channel.db gile in a human readable format.`,
28+
Example: `chantools dumpchannels \
29+
--channeldb ~/.lnd/data/graph/mainnet/channel.db`,
2630
RunE: cc.Execute,
2731
}
2832
cc.cmd.Flags().StringVar(

cmd/chantools/filterbackup.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ func newFilterBackupCommand() *cobra.Command {
2626
Use: "filterbackup",
2727
Short: "Filter an lnd channel.backup file and remove certain " +
2828
"channels",
29+
Long: `Filter an lnd channel.backup file by removing certain
30+
channels (identified by their funding transaction outpoints).`,
31+
Example: `chantools filterbackup --rootkey xprvxxxxxxxxxx \
32+
--multi_file ~/.lnd/data/chain/bitcoin/mainnet/channel.backup \
33+
--discard 2abcdef2b2bffaaa...db0abadd:1,4abcdef2b2bffaaa...db8abadd:0`,
2934
RunE: cc.Execute,
3035
}
3136
cc.cmd.Flags().StringVar(

cmd/chantools/fixoldbackup.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ func newFixOldBackupCommand() *cobra.Command {
2525
Short: "Fixes an old channel.backup file that is affected by " +
2626
"the lnd issue #3881 (unable to derive shachain root " +
2727
"key)",
28+
Long: `Fixes an old channel.backup file that is affected by the
29+
lnd issue [#3881](https://github.com/lightningnetwork/lnd/issues/3881)
30+
(<code>[lncli] unable to restore chan backups: rpc error: code = Unknown desc =
31+
unable to unpack chan backup: unable to derive shachain root key: unable to
32+
derive private key</code>).`,
33+
Example: `chantools fixoldbackup --rootkey xprvxxxxxxxxxx \
34+
--multi_file ~/.lnd/data/chain/bitcoin/mainnet/channel.backup`,
2835
RunE: cc.Execute,
2936
}
3037
cc.cmd.Flags().StringVar(

cmd/chantools/forceclose.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ func newForceCloseCommand() *cobra.Command {
3535
Use: "forceclose",
3636
Short: "Force-close the last state that is in the channel.db " +
3737
"provided",
38+
Long: `If you are certain that a node is offline for good (AFTER
39+
you've tried SCB!) and a channel is still open, you can use this method to
40+
force-close your latest state that you have in your channel.db.
41+
42+
**!!! WARNING !!! DANGER !!! WARNING !!!**
43+
44+
If you do this and the state that you publish is *not* the latest state, then
45+
the remote node *could* punish you by taking the whole channel amount *if* they
46+
come online before you can sweep the funds from the time locked (144 - 2000
47+
blocks) transaction *or* they have a watch tower looking out for them.
48+
49+
**This should absolutely be the last resort and you have been warned!**`,
50+
Example: `chantools forceclose --rootkey xprvxxxxxxxxxx \
51+
--fromsummary results/summary-xxxx-yyyy.json
52+
--channeldb ~/.lnd/data/graph/mainnet/channel.db \
53+
--publish`,
3854
RunE: cc.Execute,
3955
}
4056
cc.cmd.Flags().StringVar(

cmd/chantools/genimportscript.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ func newGenImportScriptCommand() *cobra.Command {
3333
Short: "Generate a script containing the on-chain " +
3434
"keys of an lnd wallet that can be imported into " +
3535
"other software like bitcoind",
36+
Long: `Generates a script that contains all on-chain private (or
37+
public) keys derived from an lnd 24 word aezeed wallet. That script can then be
38+
imported into other software like bitcoind.
39+
40+
The following script formats are currently supported:
41+
* bitcoin-cli: Creates a list of bitcoin-cli importprivkey commands that can
42+
be used in combination with a bitcoind full node to recover the funds locked
43+
in those private keys.
44+
* bitcoin-cli-watchonly: Does the same as bitcoin-cli but with the
45+
bitcoin-cli importpubkey command. That means, only the public keys are
46+
imported into bitcoind to watch the UTXOs of those keys. The funds cannot be
47+
spent that way as they are watch-only.
48+
* bitcoin-importwallet: Creates a text output that is compatible with
49+
bitcoind's importwallet command.`,
50+
Example: `chantools genimportscript --format bitcoin-cli \
51+
--recoverywindow 5000`,
3652
RunE: cc.Execute,
3753
}
3854
cc.cmd.Flags().StringVar(

cmd/chantools/removechannel.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func newRemoveChannelCommand() *cobra.Command {
2424
cc.cmd = &cobra.Command{
2525
Use: "removechannel",
2626
Short: "Remove a single channel from the given channel DB",
27+
Example: `chantools --channeldb ~/.lnd/data/graph/mainnet/channel.db \
28+
--channel 3149764effbe82718b280de425277e5e7b245a4573aa4a0203ac12cee1c37816:0`,
2729
RunE: cc.Execute,
2830
}
2931
cc.cmd.Flags().StringVar(

0 commit comments

Comments
 (0)