lnd: fix golint warning which requires to add additional comments

This commit is contained in:
Andrey Samokhvalov 2017-02-24 16:32:33 +03:00 committed by Olaoluwa Osuntokun
parent 0074643c10
commit ee2379775c
9 changed files with 135 additions and 70 deletions

@ -37,6 +37,8 @@ const (
)
var (
// ErrMaxMessageLengthExceeded is returned a message to be written to
// the cipher session exceeds the maximum allowed message payload.
ErrMaxMessageLengthExceeded = errors.New("the generated payload exceeds " +
"the max allowed message length of (2^16)-1")
)

@ -23,6 +23,8 @@ const (
)
var (
// ErrChainNotifierShuttingDown is used when we are trying to
// measure a spend notification when notifier is already stopped.
ErrChainNotifierShuttingDown = errors.New("chainntnfs: system interrupt " +
"while attempting to register for spend notification.")
)

@ -3,31 +3,74 @@ package channeldb
import "fmt"
var (
ErrNoChanDBExists = fmt.Errorf("channel db has not yet been created")
// ErrNoChanDBExists is returned when a channel bucket hasn't been
// created.
ErrNoChanDBExists = fmt.Errorf("channel db has not yet been created")
// ErrLinkNodesNotFound is returned when node info bucket hasn't been
// created.
ErrLinkNodesNotFound = fmt.Errorf("no link nodes exist")
// ErrNoActiveChannels is returned when there is no active (open)
// channels within the database.
ErrNoActiveChannels = fmt.Errorf("no active channels exist")
ErrChannelNoExist = fmt.Errorf("this channel does not exist")
ErrNoPastDeltas = fmt.Errorf("channel has no recorded deltas")
ErrInvoiceNotFound = fmt.Errorf("unable to locate invoice")
// ErrNoPastDeltas is returned when the channel delta bucket hasn't been
// created.
ErrNoPastDeltas = fmt.Errorf("channel has no recorded deltas")
// ErrInvoiceNotFound is returned when a targeted invoice can't be
// found.
ErrInvoiceNotFound = fmt.Errorf("unable to locate invoice")
// ErrNoInvoicesCreated is returned when we don't have invoices in
// our database to return.
ErrNoInvoicesCreated = fmt.Errorf("there are no existing invoices")
ErrDuplicateInvoice = fmt.Errorf("invoice with payment hash already exists")
// ErrDuplicateInvoice is returned when an invoice with the target
// payment hash already exists.
ErrDuplicateInvoice = fmt.Errorf("invoice with payment hash already exists")
// ErrNoPaymentsCreated is returned when bucket of payments hasn't been
// created.
ErrNoPaymentsCreated = fmt.Errorf("there are no existing payments")
// ErrNodeNotFound is returned when node bucket exists, but node with
// specific identity can't be found.
ErrNodeNotFound = fmt.Errorf("link node with target identity not found")
// ErrMetaNotFound is returned when meta bucket hasn't been
// created.
ErrMetaNotFound = fmt.Errorf("unable to locate meta information")
ErrGraphNotFound = fmt.Errorf("graph bucket not initialized")
ErrGraphNodesNotFound = fmt.Errorf("no graph nodes exist")
ErrGraphNoEdgesFound = fmt.Errorf("no graph edges exist")
ErrGraphNodeNotFound = fmt.Errorf("unable to find node")
ErrGraphNeverPruned = fmt.Errorf("graph never pruned")
// ErrGraphNotFound is returned when at least one of the components of
// graph doesn't exist.
ErrGraphNotFound = fmt.Errorf("graph bucket not initialized")
// ErrGraphNeverPruned is returned when graph was never pruned.
ErrGraphNeverPruned = fmt.Errorf("graph never pruned")
// ErrSourceNodeNotSet is returned if the the source node of the graph
// hasn't been added The source node is the center node within a
// star-graph.
ErrSourceNodeNotSet = fmt.Errorf("source node does not exist")
// ErrGraphNodesNotFound is returned in case none of the nodes has
// been added in graph node bucket.
ErrGraphNodesNotFound = fmt.Errorf("no graph nodes exist")
// ErrGraphNoEdgesFound is returned in case of none of the channel/edges
// has been added in graph edge bucket.
ErrGraphNoEdgesFound = fmt.Errorf("no graph edges exist")
// ErrGraphNodeNotFound is returned when we're unable to find the target
// node.
ErrGraphNodeNotFound = fmt.Errorf("unable to find node")
// ErrEdgeNotFound is returned when an edge for the target chanID
// can't be found.
ErrEdgeNotFound = fmt.Errorf("edge for chanID not found")
// ErrNodeAliasNotFound is returned when alias for node can't be found.
ErrNodeAliasNotFound = fmt.Errorf("alias for node not found")
ErrSourceNodeNotSet = fmt.Errorf("source node does not exist")
)

@ -166,11 +166,11 @@ func (d *DB) LookupInvoice(paymentHash [32]byte) (*Invoice, error) {
err := d.View(func(tx *bolt.Tx) error {
invoices := tx.Bucket(invoiceBucket)
if invoices == nil {
return ErrInvoiceNotFound
return ErrNoInvoicesCreated
}
invoiceIndex := invoices.Bucket(invoiceIndexBucket)
if invoiceIndex == nil {
return ErrInvoiceNotFound
return ErrNoInvoicesCreated
}
// Check the invoice index to see if an invoice paying to this

@ -52,7 +52,7 @@ func printRespJSON(resp proto.Message) {
fmt.Println(jsonStr)
}
var NewAddressCommand = cli.Command{
var newAddressCommand = cli.Command{
Name: "newaddress",
Usage: "generates a new address.",
ArgsUsage: "address-type",
@ -96,7 +96,7 @@ func newAddress(ctx *cli.Context) error {
return nil
}
var SendCoinsCommand = cli.Command{
var sendCoinsCommand = cli.Command{
Name: "sendcoins",
Usage: "send bitcoin on-chain to an address",
ArgsUsage: "addr amt",
@ -169,7 +169,7 @@ func sendCoins(ctx *cli.Context) error {
return nil
}
var SendManyCommand = cli.Command{
var sendManyCommand = cli.Command{
Name: "sendmany",
Usage: "send bitcoin on-chain to multiple addresses.",
ArgsUsage: "send-json-string",
@ -204,7 +204,7 @@ func sendMany(ctx *cli.Context) error {
return nil
}
var ConnectCommand = cli.Command{
var connectCommand = cli.Command{
Name: "connect",
Usage: "connect to a remote lnd peer",
ArgsUsage: "<pubkey>@host",
@ -250,7 +250,7 @@ func connectPeer(ctx *cli.Context) error {
}
// TODO(roasbeef): change default number of confirmations
var OpenChannelCommand = cli.Command{
var openChannelCommand = cli.Command{
Name: "openchannel",
Usage: "Open a channel to an existing peer.",
Description: "Attempt to open a new channel to an existing peer with the key node-key, " +
@ -411,7 +411,7 @@ func openChannel(ctx *cli.Context) error {
// TODO(roasbeef): also allow short relative channel ID.
var CloseChannelCommand = cli.Command{
var closeChannelCommand = cli.Command{
Name: "closechannel",
Usage: "Close an existing channel.",
Description: "Close an existing channel. The channel can be closed either " +
@ -544,7 +544,7 @@ func closeChannel(ctx *cli.Context) error {
}
}
var ListPeersCommand = cli.Command{
var listPeersCommand = cli.Command{
Name: "listpeers",
Usage: "List all active, currently connected peers.",
Action: listPeers,
@ -565,7 +565,7 @@ func listPeers(ctx *cli.Context) error {
return nil
}
var WalletBalanceCommand = cli.Command{
var walletBalanceCommand = cli.Command{
Name: "walletbalance",
Usage: "compute and display the wallet's current balance",
Flags: []cli.Flag{
@ -595,7 +595,7 @@ func walletBalance(ctx *cli.Context) error {
return nil
}
var ChannelBalanceCommand = cli.Command{
var channelBalanceCommand = cli.Command{
Name: "channelbalance",
Usage: "returns the sum of the total available channel balance across all open channels",
Action: channelBalance,
@ -616,7 +616,7 @@ func channelBalance(ctx *cli.Context) error {
return nil
}
var GetInfoCommand = cli.Command{
var getInfoCommand = cli.Command{
Name: "getinfo",
Usage: "returns basic information related to the active daemon",
Action: getInfo,
@ -637,7 +637,7 @@ func getInfo(ctx *cli.Context) error {
return nil
}
var PendingChannelsCommand = cli.Command{
var pendingChannelsCommand = cli.Command{
Name: "pendingchannels",
Usage: "display information pertaining to pending channels",
Flags: []cli.Flag{
@ -686,7 +686,7 @@ func pendingChannels(ctx *cli.Context) error {
return nil
}
var ListChannelsCommand = cli.Command{
var listChannelsCommand = cli.Command{
Name: "listchannels",
Usage: "list all open channels",
Flags: []cli.Flag{
@ -716,7 +716,7 @@ func listChannels(ctx *cli.Context) error {
return nil
}
var SendPaymentCommand = cli.Command{
var sendPaymentCommand = cli.Command{
Name: "sendpayment",
Usage: "send a payment over lightning",
ArgsUsage: "(destination amount payment_hash " +
@ -744,10 +744,10 @@ var SendPaymentCommand = cli.Command{
Usage: "a zbase32-check encoded payment request to fulfill",
},
},
Action: sendPaymentCommand,
Action: sendPayment,
}
func sendPaymentCommand(ctx *cli.Context) error {
func sendPayment(ctx *cli.Context) error {
client, cleanUp := getClient(ctx)
defer cleanUp()
@ -856,7 +856,7 @@ func sendPaymentCommand(ctx *cli.Context) error {
return nil
}
var AddInvoiceCommand = cli.Command{
var addInvoiceCommand = cli.Command{
Name: "addinvoice",
Usage: "add a new invoice.",
Description: "Add a new invoice, expressing intent for a future payment. " +
@ -948,7 +948,7 @@ func addInvoice(ctx *cli.Context) error {
return nil
}
var LookupInvoiceCommand = cli.Command{
var lookupInvoiceCommand = cli.Command{
Name: "lookupinvoice",
Usage: "Lookup an existing invoice by its payment hash.",
ArgsUsage: "rhash",
@ -998,7 +998,7 @@ func lookupInvoice(ctx *cli.Context) error {
return nil
}
var ListInvoicesCommand = cli.Command{
var listInvoicesCommand = cli.Command{
Name: "listinvoices",
Usage: "List all invoices currently stored.",
Flags: []cli.Flag{
@ -1034,7 +1034,7 @@ func listInvoices(ctx *cli.Context) error {
return nil
}
var DescribeGraphCommand = cli.Command{
var describeGraphCommand = cli.Command{
Name: "describegraph",
Description: "prints a human readable version of the known channel " +
"graph from the PoV of the node",
@ -1217,7 +1217,7 @@ func drawChannelGraph(graph *lnrpc.ChannelGraph) error {
return nil
}
var ListPaymentsCommand = cli.Command{
var listPaymentsCommand = cli.Command{
Name: "listpayments",
Usage: "list all outgoing payments",
Action: listPayments,
@ -1238,7 +1238,7 @@ func listPayments(ctx *cli.Context) error {
return nil
}
var GetChanInfoCommand = cli.Command{
var getChanInfoCommand = cli.Command{
Name: "getchaninfo",
Usage: "get the state of a channel",
Description: "prints out the latest authenticated state for a " +
@ -1285,7 +1285,7 @@ func getChanInfo(ctx *cli.Context) error {
return nil
}
var GetNodeInfoCommand = cli.Command{
var getNodeInfoCommand = cli.Command{
Name: "getnodeinfo",
Usage: "Get information on a specific node.",
Description: "prints out the latest authenticated node state for an " +
@ -1322,7 +1322,7 @@ func getNodeInfo(ctx *cli.Context) error {
return nil
}
var QueryRouteCommand = cli.Command{
var queryRouteCommand = cli.Command{
Name: "queryroute",
Usage: "Query a route to a destination.",
Description: "Queries the channel router for a potential path to the destination that has sufficient flow for the amount including fees",
@ -1390,7 +1390,7 @@ func queryRoute(ctx *cli.Context) error {
return nil
}
var GetNetworkInfoCommand = cli.Command{
var getNetworkInfoCommand = cli.Command{
Name: "getnetworkinfo",
Usage: "getnetworkinfo",
Description: "returns a set of statistics pertaining to the known channel " +
@ -1414,7 +1414,7 @@ func getNetworkInfo(ctx *cli.Context) error {
return nil
}
var DebugLevel = cli.Command{
var debugLevelCommand = cli.Command{
Name: "debuglevel",
Usage: "Set the debug level.",
Description: "Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems",
@ -1450,7 +1450,7 @@ func debugLevel(ctx *cli.Context) error {
return nil
}
var DecodePayReq = cli.Command{
var decodePayReqComamnd = cli.Command{
Name: "decodepayreq",
Usage: "Decode a payment request.",
Description: "Decode the passed payment request revealing the destination, payment hash and value of the payment request",

@ -53,30 +53,30 @@ func main() {
},
}
app.Commands = []cli.Command{
NewAddressCommand,
SendManyCommand,
SendCoinsCommand,
ConnectCommand,
OpenChannelCommand,
CloseChannelCommand,
ListPeersCommand,
WalletBalanceCommand,
ChannelBalanceCommand,
GetInfoCommand,
PendingChannelsCommand,
SendPaymentCommand,
AddInvoiceCommand,
LookupInvoiceCommand,
ListInvoicesCommand,
ListChannelsCommand,
ListPaymentsCommand,
DescribeGraphCommand,
GetChanInfoCommand,
GetNodeInfoCommand,
QueryRouteCommand,
GetNetworkInfoCommand,
DebugLevel,
DecodePayReq,
newAddressCommand,
sendManyCommand,
sendCoinsCommand,
connectCommand,
openChannelCommand,
closeChannelCommand,
listPeersCommand,
walletBalanceCommand,
channelBalanceCommand,
getInfoCommand,
pendingChannelsCommand,
sendPaymentCommand,
addInvoiceCommand,
lookupInvoiceCommand,
listInvoicesCommand,
listChannelsCommand,
listPaymentsCommand,
describeGraphCommand,
getChanInfoCommand,
getNodeInfoCommand,
queryRouteCommand,
getNetworkInfoCommand,
debugLevelCommand,
decodePayReqComamnd,
ListChainTxns,
}

@ -7,7 +7,10 @@ import (
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
// TODO(roasbeef) add comment which justifying this import.
// This is required to register bdb as a valid walletdb driver. In the
// init function of the package, it registers itself. The import is used
// to activate the side effects w/o actually binding the package name to
// a file-level variable.
_ "github.com/roasbeef/btcwallet/walletdb/bdb"
)

@ -25,11 +25,23 @@ import (
var zeroHash chainhash.Hash
var (
// ErrChanClosing is returned when a caller attempts to close a channel
// that has already been closed or is in the process of being closed.
ErrChanClosing = fmt.Errorf("channel is being closed, operation disallowed")
ErrNoWindow = fmt.Errorf("unable to sign new commitment, the current" +
// ErrNoWindow is returned when revocation window is exausted.
ErrNoWindow = fmt.Errorf("unable to sign new commitment, the current" +
" revocation window is exhausted")
// ErrMaxWeightCost is returned when the cost/weight (see segwit)
// exceeds the widely used maximum allowed policy weight limit. In this
// case the commitment transaction can't be propagated through the
// network.
ErrMaxWeightCost = fmt.Errorf("commitment transaction exceed max " +
"available weight")
"available cost")
// ErrMaxHTLCNumber is returned when a proposed HTLC would exceed the
// maximum number of allowed HTLC's if committed in a state transition
ErrMaxHTLCNumber = fmt.Errorf("commitment transaction exceed max " +
"htlc number")
)
@ -1793,7 +1805,7 @@ func (lc *LightningChannel) ExtendRevocationWindow() (*lnwire.RevokeAndAck, erro
return revMsg, nil
}
// NextRevocationKey returns the revocation key for the _next_ commitment
// NextRevocationkey returns the revocation key for the _next_ commitment
// height. The pubkey returned by this function is required by the remote party
// to extend our commitment chain with a new commitment.
//

@ -21,8 +21,11 @@ var (
// TODO(roasbeef): remove these and use the one's defined in txscript
// within testnet-L.
SequenceLockTimeSeconds = uint32(1 << 22)
OP_CHECKSEQUENCEVERIFY byte = txscript.OP_NOP3
// SequenceLockTimeSeconds is the 22nd bit which indicates the lock
// time is in seconds.
SequenceLockTimeSeconds = uint32(1 << 22)
OP_CHECKSEQUENCEVERIFY byte = txscript.OP_NOP3
// TimelockShift is used to make sure the commitment transaction is
// spendable by setting the locktime with it so that it is larger than