mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
multi: reformat long lines for readability
- Replace occurrences of `// nolint:lll` with `// nolint:ll` across files for consistency. - Reformat multiline strings, comments, and function parameters to improve clarity and adhere to style guidelines. - Add `// nolint:ll` comments where necessary to prevent linter warnings.
This commit is contained in:
parent
e96424cc4a
commit
a0e63124c0
55 changed files with 383 additions and 216 deletions
|
|
@ -110,6 +110,7 @@ func NewAccountChecker(service Service,
|
|||
)
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
checkers := CheckerMap{
|
||||
// Invoices:
|
||||
"/lnrpc.Lightning/AddInvoice": mid.NewResponseRewriter(
|
||||
|
|
|
|||
|
|
@ -379,6 +379,7 @@ func TestAccountCheckers(t *testing.T) {
|
|||
originalRequest: &lnrpc.PendingChannelsRequest{},
|
||||
originalResponse: &lnrpc.PendingChannelsResponse{
|
||||
TotalLimboBalance: 123456,
|
||||
// nolint:ll
|
||||
PendingOpenChannels: []*lnrpc.PendingChannelsResponse_PendingOpenChannel{
|
||||
{},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const (
|
|||
// SQLQueries is a subset of the sqlc.Queries interface that can be used
|
||||
// to interact with accounts related tables.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
type SQLQueries interface {
|
||||
AddAccountInvoice(ctx context.Context, arg sqlc.AddAccountInvoiceParams) error
|
||||
DeleteAccount(ctx context.Context, id int64) error
|
||||
|
|
|
|||
|
|
@ -227,7 +227,9 @@ func PaymentEntryMapEncoder(w io.Writer, val any, buf *[8]byte) error {
|
|||
}
|
||||
|
||||
// PaymentEntryMapDecoder decodes a map of payment entries.
|
||||
func PaymentEntryMapDecoder(r io.Reader, val any, buf *[8]byte, _ uint64) error {
|
||||
func PaymentEntryMapDecoder(r io.Reader, val any, buf *[8]byte,
|
||||
_ uint64) error {
|
||||
|
||||
if typ, ok := val.(*AccountPayments); ok {
|
||||
numItems, err := tlv.ReadVarInt(r, buf)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ var ErrVersionIncompatible = fmt.Errorf("litd version is not compatible " +
|
|||
|
||||
// Config holds the configuration options for the autopilot server client.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
type Config struct {
|
||||
// Disable will disable the autopilot client.
|
||||
Disable bool `long:"disable" description:"disable the autopilot client"`
|
||||
|
|
|
|||
|
|
@ -310,7 +310,8 @@ func (m *Server) GetPrivacyFlags(remoteKey *btcec.PublicKey) (
|
|||
key := hex.EncodeToString(remoteKey.SerializeCompressed())
|
||||
sess, ok := m.sessions[key]
|
||||
if !ok {
|
||||
return session.PrivacyFlags{}, fmt.Errorf("no such client found")
|
||||
return session.PrivacyFlags{},
|
||||
fmt.Errorf("no such client found")
|
||||
}
|
||||
|
||||
privacyFlags, err := session.Deserialize(sess.privacyFlags)
|
||||
|
|
@ -436,7 +437,9 @@ func rulesToRPC(rulesMap map[string]*RuleRanges) (
|
|||
return res, nil
|
||||
}
|
||||
|
||||
func permissionsToRPC(ps map[string][]bakery.Op) []*autopilotserverrpc.Permissions {
|
||||
func permissionsToRPC(
|
||||
ps map[string][]bakery.Op) []*autopilotserverrpc.Permissions {
|
||||
|
||||
res := make([]*autopilotserverrpc.Permissions, len(ps))
|
||||
|
||||
for method, ops := range ps {
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@ var updateAccountCommand = cli.Command{
|
|||
Name: "update",
|
||||
ShortName: "u",
|
||||
Usage: "Update an existing off-chain account.",
|
||||
ArgsUsage: "[id | label] new_balance [new_expiration_date] [--save_to=]",
|
||||
ArgsUsage: "[id | label] new_balance [new_expiration_date] " +
|
||||
"[--save_to=]",
|
||||
Description: "Updates an existing off-chain account and sets " +
|
||||
"either a new balance or new expiration date or both.",
|
||||
Flags: []cli.Flag{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ var listActionsCommand = cli.Command{
|
|||
Name: "state",
|
||||
Usage: "The action state to filter on. If not set, " +
|
||||
"then actions of any state will be returned. " +
|
||||
"Options include: 'pending', 'done' and 'error'.",
|
||||
"Options include: 'pending', 'done' and " +
|
||||
"'error'.",
|
||||
},
|
||||
cli.Uint64Flag{
|
||||
Name: "index_offset",
|
||||
|
|
|
|||
|
|
@ -131,11 +131,11 @@ var addAutopilotSessionCmd = cli.Command{
|
|||
},
|
||||
cli.StringFlag{
|
||||
Name: "privacy-flags",
|
||||
Usage: "String representation of privacy flags to set " +
|
||||
"for the session. Each individual flag will " +
|
||||
"remove privacy from certain aspects of " +
|
||||
"messages transmitted to autopilot. " +
|
||||
"The strongest privacy is on by " +
|
||||
Usage: "String representation of privacy flags " +
|
||||
"to set for the session. Each individual " +
|
||||
"flag will remove privacy from certain " +
|
||||
"aspects of messages transmitted to " +
|
||||
"autopilot. The strongest privacy is on by " +
|
||||
"default and an empty string means full " +
|
||||
"privacy. Some features may not be able to " +
|
||||
"run correctly with full privacy, see the " +
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ var litCommands = []cli.Command{
|
|||
Name: "bakesupermacaroon",
|
||||
Usage: "Bake a new super macaroon with all of LiT's active " +
|
||||
"permissions",
|
||||
Description: "Bake a new super macaroon with all of LiT's active " +
|
||||
"permissions.",
|
||||
Description: "Bake a new super macaroon with all of LiT's " +
|
||||
"active permissions.",
|
||||
Category: "LiT",
|
||||
Action: bakeSuperMacaroon,
|
||||
Flags: []cli.Flag{
|
||||
|
|
@ -47,8 +47,8 @@ var litCommands = []cli.Command{
|
|||
Name: "getinfo",
|
||||
Usage: "Returns basic information related to the active " +
|
||||
"daemon",
|
||||
Description: "Returns basic information related to the active " +
|
||||
"daemon.",
|
||||
Description: "Returns basic information related to the " +
|
||||
"active daemon.",
|
||||
Category: "LiT",
|
||||
Action: getInfo,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -121,8 +121,7 @@ func addSession(cli *cli.Context) error {
|
|||
sessionExpiry := time.Now().Add(sessionLength).Unix()
|
||||
|
||||
ctx := getContext()
|
||||
resp, err := client.AddSession(
|
||||
ctx, &litrpc.AddSessionRequest{
|
||||
req := litrpc.AddSessionRequest{
|
||||
Label: cli.String("label"),
|
||||
SessionType: sessType,
|
||||
ExpiryTimestampSeconds: uint64(sessionExpiry),
|
||||
|
|
@ -130,8 +129,8 @@ func addSession(cli *cli.Context) error {
|
|||
DevServer: cli.Bool("devserver"),
|
||||
MacaroonCustomPermissions: macPerms,
|
||||
AccountId: cli.String("account_id"),
|
||||
},
|
||||
)
|
||||
}
|
||||
resp, err := client.AddSession(ctx, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
27
config.go
27
config.go
|
|
@ -146,7 +146,7 @@ var (
|
|||
// all config items of its enveloping subservers, each prefixed with their
|
||||
// daemon's short name.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
type Config struct {
|
||||
ShowVersion bool `long:"version" description:"Display version information and exit."`
|
||||
|
||||
|
|
@ -284,6 +284,8 @@ func (c *Config) lndConnectParams() (string, lndclient.Network, string,
|
|||
// defaultConfig returns a configuration struct with all default values set.
|
||||
func defaultConfig() *Config {
|
||||
defaultLogCfg := build.DefaultLogConfig()
|
||||
|
||||
// nolint:ll
|
||||
return &Config{
|
||||
HTTPSListen: defaultHTTPSListen,
|
||||
TLSCertPath: DefaultTLSCertPath,
|
||||
|
|
@ -539,10 +541,15 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
|
|||
// the remote connection as well.
|
||||
defaultFaradayCfg := faraday.DefaultConfig()
|
||||
if cfg.faradayRemote && cfg.Network != DefaultNetwork {
|
||||
if cfg.Remote.Faraday.MacaroonPath == defaultFaradayCfg.MacaroonPath {
|
||||
cfg.Remote.Faraday.MacaroonPath = cfg.Faraday.MacaroonPath
|
||||
if cfg.Remote.Faraday.MacaroonPath ==
|
||||
defaultFaradayCfg.MacaroonPath {
|
||||
|
||||
cfg.Remote.Faraday.MacaroonPath =
|
||||
cfg.Faraday.MacaroonPath
|
||||
}
|
||||
if cfg.Remote.Faraday.TLSCertPath == defaultFaradayCfg.TLSCertPath {
|
||||
if cfg.Remote.Faraday.TLSCertPath ==
|
||||
defaultFaradayCfg.TLSCertPath {
|
||||
|
||||
cfg.Remote.Faraday.TLSCertPath = cfg.Faraday.TLSCertPath
|
||||
}
|
||||
}
|
||||
|
|
@ -553,7 +560,8 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
|
|||
cfg.faradayRpcConfig.MacaroonPath = cfg.Faraday.MacaroonPath
|
||||
|
||||
if cfg.Faraday.ChainConn {
|
||||
cfg.faradayRpcConfig.BitcoinClient, err = chain.NewBitcoinClient(
|
||||
cfg.faradayRpcConfig.BitcoinClient, err =
|
||||
chain.NewBitcoinClient(
|
||||
cfg.Faraday.Bitcoin,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -583,13 +591,16 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
|
|||
|
||||
defaultTapCfg := tapcfg.DefaultConfig()
|
||||
if cfg.tapRemote && cfg.Network != DefaultNetwork {
|
||||
if cfg.Remote.TaprootAssets.MacaroonPath == defaultTapCfg.RpcConf.MacaroonPath {
|
||||
if cfg.Remote.TaprootAssets.MacaroonPath ==
|
||||
defaultTapCfg.RpcConf.MacaroonPath {
|
||||
|
||||
macaroonPath := cfg.TaprootAssets.RpcConf.MacaroonPath
|
||||
cfg.Remote.TaprootAssets.MacaroonPath = macaroonPath
|
||||
}
|
||||
if cfg.Remote.TaprootAssets.TLSCertPath == defaultTapCfg.RpcConf.TLSCertPath {
|
||||
tlsCertPath := cfg.TaprootAssets.RpcConf.TLSCertPath
|
||||
if cfg.Remote.TaprootAssets.TLSCertPath ==
|
||||
defaultTapCfg.RpcConf.TLSCertPath {
|
||||
|
||||
tlsCertPath := cfg.TaprootAssets.RpcConf.TLSCertPath
|
||||
cfg.Remote.TaprootAssets.TLSCertPath = tlsCertPath
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ var defaultSqliteDatabasePath = filepath.Join(
|
|||
// features not yet available in production. Since our itests are built with
|
||||
// the dev tag, we can test these features in our itests.
|
||||
//
|
||||
// nolint:lll
|
||||
// nolint:ll
|
||||
type DevConfig struct {
|
||||
// DatabaseBackend is the database backend we will use for storing all
|
||||
// account related data. While this feature is still in development, we
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ var (
|
|||
|
||||
// PostgresConfig holds the postgres database configuration.
|
||||
//
|
||||
// nolint:lll
|
||||
// nolint:ll
|
||||
type PostgresConfig struct {
|
||||
SkipMigrations bool `long:"skipmigrations" description:"Skip applying migrations on startup."`
|
||||
Host string `long:"host" description:"Database server hostname."`
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ var (
|
|||
// SqliteConfig holds all the config arguments needed to interact with our
|
||||
// sqlite DB.
|
||||
//
|
||||
// nolint: lll
|
||||
// nolint:ll
|
||||
type SqliteConfig struct {
|
||||
// SkipMigrations if true, then all the tables will be created on start
|
||||
// up if they don't already exist.
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ func TestInterceptMetaInfo(t *testing.T) {
|
|||
ActorName: "autopilot",
|
||||
Feature: "re-balance",
|
||||
Trigger: "channel 7413345453234435345 depleted",
|
||||
Intent: "increase outbound liquidity by 2000000 sats",
|
||||
Intent: "increase outbound liquidity by 2000000 " +
|
||||
"sats",
|
||||
StructuredJsonData: "{}",
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +94,7 @@ func TestParseMetaInfoCaveat(t *testing.T) {
|
|||
// caveat and then parsed again successfully.
|
||||
func TestInterceptRule(t *testing.T) {
|
||||
rules := &InterceptRules{
|
||||
// nolint:ll
|
||||
FeatureRules: map[string]map[string]string{
|
||||
"AutoFees": {
|
||||
"first-hop-ignore-list": "03abcd...,02badb01...",
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ package firewall
|
|||
|
||||
// Config holds all config options for the firewall.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
type Config struct {
|
||||
RequestLogger *RequestLoggerConfig `group:"request-logger" namespace:"request-logger" description:"request logger settings"`
|
||||
}
|
||||
|
||||
// RequestLoggerConfig holds all the config options for the request logger.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
type RequestLoggerConfig struct {
|
||||
RequestLoggerLevel RequestLoggerLevel `long:"level" description:"Set the request logger level. Options include 'all', 'full' and 'interceptor''"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -338,7 +338,8 @@ func handleGetInfoResponse(db firewalldb.PrivacyMapDB,
|
|||
tx firewalldb.PrivacyMapTx) error {
|
||||
|
||||
var err error
|
||||
pseudoPubKey, err = firewalldb.HideString( //nolint:lll
|
||||
// nolint:ll
|
||||
pseudoPubKey, err = firewalldb.HideString(
|
||||
ctx, tx, r.IdentityPubkey,
|
||||
)
|
||||
|
||||
|
|
@ -444,7 +445,8 @@ func handleFwdHistoryResponse(db firewalldb.PrivacyMapDB,
|
|||
|
||||
timestamp := time.Unix(0, int64(fe.TimestampNs))
|
||||
if !flags.Contains(session.ClearTimeStamps) {
|
||||
// We randomize the forwarding timestamp.
|
||||
// We randomize the forwarding
|
||||
// timestamp.
|
||||
timestamp, err = hideTimestamp(
|
||||
randIntn, timeVariation,
|
||||
timestamp,
|
||||
|
|
@ -511,7 +513,8 @@ func handleFeeReportResponse(db firewalldb.PrivacyMapDB,
|
|||
|
||||
chanPoint := c.ChannelPoint
|
||||
if !flags.Contains(session.ClearChanIDs) {
|
||||
chanPoint, err = firewalldb.HideChanPointStr(
|
||||
chanPoint, err =
|
||||
firewalldb.HideChanPointStr(
|
||||
ctx, tx, chanPoint,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -611,7 +614,8 @@ func handleListChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
chanPoint := c.ChannelPoint
|
||||
chanID := c.ChanId
|
||||
if hideChanIds {
|
||||
chanPoint, err = firewalldb.HideChanPointStr(
|
||||
chanPoint, err =
|
||||
firewalldb.HideChanPointStr(
|
||||
ctx, tx, c.ChannelPoint,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -660,7 +664,8 @@ func handleListChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
if !flags.Contains(session.ClearAmounts) {
|
||||
// We adapt the remote balance
|
||||
// accordingly.
|
||||
remoteBalance = c.Capacity - localBalance
|
||||
remoteBalance =
|
||||
c.Capacity - localBalance
|
||||
}
|
||||
|
||||
// We hide the total sats sent and received.
|
||||
|
|
@ -698,7 +703,7 @@ func handleListChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
return err
|
||||
}
|
||||
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
channels[i] = &lnrpc.Channel{
|
||||
// Items we adjust.
|
||||
RemotePubkey: remotePub,
|
||||
|
|
@ -780,7 +785,8 @@ func handleUpdatePolicyRequest(db firewalldb.PrivacyMapDB,
|
|||
tx firewalldb.PrivacyMapTx) error {
|
||||
|
||||
var err error
|
||||
newTxid, newIndex, err = firewalldb.RevealChanPoint( //nolint:lll
|
||||
// nolint:ll
|
||||
newTxid, newIndex, err = firewalldb.RevealChanPoint(
|
||||
ctx, tx, newTxid, newIndex,
|
||||
)
|
||||
return err
|
||||
|
|
@ -986,7 +992,8 @@ func handleClosedChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
|
||||
channelPoint := c.ChannelPoint
|
||||
if !flags.Contains(session.ClearChanIDs) {
|
||||
channelPoint, err = firewalldb.HideChanPointStr(
|
||||
channelPoint, err =
|
||||
firewalldb.HideChanPointStr(
|
||||
ctx, tx, c.ChannelPoint,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -1006,8 +1013,10 @@ func handleClosedChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
|
||||
closingTxid := c.ClosingTxHash
|
||||
if !flags.Contains(session.ClearClosingTxIds) {
|
||||
closingTxid, err = firewalldb.HideString(
|
||||
ctx, tx, c.ClosingTxHash,
|
||||
closingTxid, err =
|
||||
firewalldb.HideString(
|
||||
ctx, tx,
|
||||
c.ClosingTxHash,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -1172,6 +1181,7 @@ func handlePendingChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
return err
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
pendingOpen := lnrpc.PendingChannelsResponse_PendingOpenChannel{
|
||||
// Non-obfuscated fields.
|
||||
CommitFee: c.CommitFee,
|
||||
|
|
@ -1198,7 +1208,8 @@ func handlePendingChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
|
||||
closingTxid := c.ClosingTxid
|
||||
if !flags.Contains(session.ClearClosingTxIds) {
|
||||
closingTxid, err = firewalldb.HideString( //nolint:lll
|
||||
// nolint:ll
|
||||
closingTxid, err = firewalldb.HideString(
|
||||
ctx, tx, c.ClosingTxid,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -1206,6 +1217,7 @@ func handlePendingChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
}
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
pendingClose := lnrpc.PendingChannelsResponse_ClosedChannel{
|
||||
// Obfuscated fields.
|
||||
ClosingTxid: closingTxid,
|
||||
|
|
@ -1227,7 +1239,8 @@ func handlePendingChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
|
||||
closingTxid := c.ClosingTxid
|
||||
if !flags.Contains(session.ClearClosingTxIds) {
|
||||
closingTxid, err = firewalldb.HideString(
|
||||
closingTxid, err =
|
||||
firewalldb.HideString(
|
||||
ctx, tx, c.ClosingTxid,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -1257,6 +1270,7 @@ func handlePendingChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
limboBalance = pendingChannel.Capacity
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
pendingForceClose := lnrpc.PendingChannelsResponse_ForceClosedChannel{
|
||||
// Obfuscated fields.
|
||||
ClosingTxid: closingTxid,
|
||||
|
|
@ -1299,7 +1313,8 @@ func handlePendingChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
|
||||
closingTxid := c.ClosingTxid
|
||||
if !flags.Contains(session.ClearClosingTxIds) {
|
||||
closingTxid, err = firewalldb.HideString(
|
||||
closingTxid, err =
|
||||
firewalldb.HideString(
|
||||
ctx, tx, closingTxid,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -1316,7 +1331,8 @@ func handlePendingChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
session.ClearClosingTxIds,
|
||||
) {
|
||||
|
||||
closingTxHex, err = firewalldb.HideString(
|
||||
closingTxHex, err =
|
||||
firewalldb.HideString(
|
||||
ctx, tx, closingTxHex,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -1324,6 +1340,7 @@ func handlePendingChannelsResponse(db firewalldb.PrivacyMapDB,
|
|||
}
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
waitingCloseChannel := lnrpc.PendingChannelsResponse_WaitingCloseChannel{
|
||||
Channel: pendingChannel,
|
||||
LimboBalance: limboBalance,
|
||||
|
|
@ -1381,7 +1398,8 @@ func handleBatchOpenChannelRequest(db firewalldb.PrivacyMapDB,
|
|||
// GetInfo or the like.
|
||||
nodePubkey := c.NodePubkey
|
||||
if !flags.Contains(session.ClearPubkeys) {
|
||||
nodePubkey, err = firewalldb.RevealBytes(
|
||||
nodePubkey, err =
|
||||
firewalldb.RevealBytes(
|
||||
ctx, tx, c.NodePubkey,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -1389,6 +1407,7 @@ func handleBatchOpenChannelRequest(db firewalldb.PrivacyMapDB,
|
|||
}
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
reqs[i] = &lnrpc.BatchOpenChannel{
|
||||
// Obfuscated fields.
|
||||
NodePubkey: nodePubkey,
|
||||
|
|
@ -1457,7 +1476,8 @@ func handleBatchOpenChannelResponse(db firewalldb.PrivacyMapDB,
|
|||
return err
|
||||
}
|
||||
|
||||
txID, outIdx, err := firewalldb.HideChanPoint( //nolint:lll
|
||||
// nolint:ll
|
||||
txID, outIdx, err := firewalldb.HideChanPoint(
|
||||
ctx, tx, txId.String(),
|
||||
p.OutputIndex,
|
||||
)
|
||||
|
|
@ -1533,6 +1553,7 @@ func handleChannelOpenRequest(db firewalldb.PrivacyMapDB,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
return &lnrpc.OpenChannelRequest{
|
||||
// Obfuscated fields.
|
||||
NodePubkey: nodePubkey,
|
||||
|
|
@ -1625,6 +1646,7 @@ func handleChannelOpenResponse(db firewalldb.PrivacyMapDB,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
return &lnrpc.ChannelPoint{
|
||||
FundingTxid: &lnrpc.ChannelPoint_FundingTxidBytes{
|
||||
FundingTxidBytes: hash[:],
|
||||
|
|
|
|||
|
|
@ -27,16 +27,20 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
}
|
||||
|
||||
// Define some transaction outpoints used for mapping.
|
||||
//
|
||||
// nolint:ll
|
||||
clearTxID := "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd"
|
||||
clearTxIDReveresed, err := chainhash.NewHashFromStr(clearTxID)
|
||||
require.NoError(t, err)
|
||||
|
||||
// nolint:ll
|
||||
obfusTxID0 := "097ef666a61919ff3413b3b701eae3a5cbac08f70c0ca567806e1fa6acbfe384"
|
||||
require.NoError(t, err)
|
||||
obfusOut0 := uint32(2161781494)
|
||||
obfusTxID0Reversed, err := chainhash.NewHashFromStr(obfusTxID0)
|
||||
require.NoError(t, err)
|
||||
|
||||
// nolint:ll
|
||||
obfusTxID1 := "45ec471bfccb0b7b9a8bc4008248931c59ad994903e07b54f54821ea3ef5cc5c"
|
||||
obfusOut1 := uint32(1642614131)
|
||||
|
||||
|
|
@ -135,6 +139,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
}
|
||||
)
|
||||
|
||||
// nolint:ll
|
||||
tests := []struct {
|
||||
name string
|
||||
privacyFlags session.PrivacyFlags
|
||||
|
|
@ -376,6 +381,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
},
|
||||
},
|
||||
expectedReplacement: &lnrpc.PolicyUpdateResponse{
|
||||
// nolint:ll
|
||||
FailedUpdates: []*lnrpc.FailedUpdate{
|
||||
{
|
||||
Outpoint: &lnrpc.OutPoint{
|
||||
|
|
@ -396,6 +402,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
UnconfirmedBalance: 1_000_000,
|
||||
LockedBalance: 1_000_000,
|
||||
ReservedBalanceAnchorChan: 1_000_000,
|
||||
// nolint:ll
|
||||
AccountBalance: map[string]*lnrpc.WalletAccountBalance{
|
||||
"first": {
|
||||
ConfirmedBalance: 1_000_000,
|
||||
|
|
@ -410,6 +417,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
UnconfirmedBalance: 950_100,
|
||||
LockedBalance: 950_100,
|
||||
ReservedBalanceAnchorChan: 950_100,
|
||||
// nolint:ll
|
||||
AccountBalance: map[string]*lnrpc.WalletAccountBalance{
|
||||
"first": {
|
||||
ConfirmedBalance: 950_100,
|
||||
|
|
@ -457,6 +465,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
uri: "/lnrpc.Lightning/ClosedChannels",
|
||||
msgType: rpcperms.TypeResponse,
|
||||
msg: &lnrpc.ClosedChannelsResponse{
|
||||
// nolint:ll
|
||||
Channels: []*lnrpc.ChannelCloseSummary{
|
||||
{
|
||||
ChannelPoint: outPoint(
|
||||
|
|
@ -481,6 +490,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
},
|
||||
},
|
||||
expectedReplacement: &lnrpc.ClosedChannelsResponse{
|
||||
// nolint:ll
|
||||
Channels: []*lnrpc.ChannelCloseSummary{
|
||||
{
|
||||
ChannelPoint: outPoint(
|
||||
|
|
@ -502,6 +512,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
name: "ClosedChannels Response clear",
|
||||
uri: "/lnrpc.Lightning/ClosedChannels",
|
||||
msgType: rpcperms.TypeResponse,
|
||||
// nolint:ll
|
||||
msg: &lnrpc.ClosedChannelsResponse{
|
||||
Channels: []*lnrpc.ChannelCloseSummary{
|
||||
{
|
||||
|
|
@ -533,6 +544,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
session.ClearAmounts,
|
||||
},
|
||||
expectedReplacement: &lnrpc.ClosedChannelsResponse{
|
||||
// nolint:ll
|
||||
Channels: []*lnrpc.ChannelCloseSummary{
|
||||
{
|
||||
ChannelPoint: outPoint(
|
||||
|
|
@ -554,6 +566,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
name: "PendingChannels Response",
|
||||
uri: "/lnrpc.Lightning/PendingChannels",
|
||||
msgType: rpcperms.TypeResponse,
|
||||
// nolint:ll
|
||||
msg: &lnrpc.PendingChannelsResponse{
|
||||
PendingOpenChannels: []*lnrpc.PendingChannelsResponse_PendingOpenChannel{
|
||||
{
|
||||
|
|
@ -595,6 +608,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
// nolint:ll
|
||||
expectedReplacement: &lnrpc.PendingChannelsResponse{
|
||||
PendingOpenChannels: []*lnrpc.PendingChannelsResponse_PendingOpenChannel{
|
||||
{
|
||||
|
|
@ -636,6 +650,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
uri: "/lnrpc.Lightning/PendingChannels",
|
||||
msgType: rpcperms.TypeResponse,
|
||||
msg: &lnrpc.PendingChannelsResponse{
|
||||
// nolint:ll
|
||||
PendingOpenChannels: []*lnrpc.PendingChannelsResponse_PendingOpenChannel{
|
||||
{
|
||||
CommitFee: 123,
|
||||
|
|
@ -658,6 +673,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
session.ClearAmounts,
|
||||
session.ClearChanIDs,
|
||||
},
|
||||
// nolint:ll
|
||||
expectedReplacement: &lnrpc.PendingChannelsResponse{
|
||||
PendingOpenChannels: []*lnrpc.PendingChannelsResponse_PendingOpenChannel{
|
||||
{
|
||||
|
|
@ -712,15 +728,16 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
name: "BatchOpenChannel Response",
|
||||
uri: "/lnrpc.Lightning/BatchOpenChannel",
|
||||
msgType: rpcperms.TypeResponse,
|
||||
// nolint:ll
|
||||
msg: &lnrpc.BatchOpenChannelResponse{
|
||||
PendingChannels: []*lnrpc.PendingUpdate{
|
||||
{
|
||||
|
||||
Txid: clearTxIDReveresed[:],
|
||||
OutputIndex: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
// nolint:ll
|
||||
expectedReplacement: &lnrpc.BatchOpenChannelResponse{
|
||||
PendingChannels: []*lnrpc.PendingUpdate{
|
||||
{
|
||||
|
|
@ -1015,6 +1032,7 @@ func TestPrivacyMapper(t *testing.T) {
|
|||
session.AddToGRPCMetadata(md, sessionID)
|
||||
|
||||
for i := 0; i < numSamples; i++ {
|
||||
// nolint:ll
|
||||
interceptReq := &rpcperms.InterceptionRequest{
|
||||
Type: rpcperms.TypeResponse,
|
||||
Macaroon: mac,
|
||||
|
|
@ -1326,7 +1344,7 @@ func TestHideBool(t *testing.T) {
|
|||
// TestObfuscateConfig tests that we substitute substrings in the config
|
||||
// correctly.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
func TestObfuscateConfig(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ func (p *actionPaginator) queryCountAll() ([]*Action, uint64, uint64, error) {
|
|||
|
||||
totalCount++
|
||||
|
||||
// nolint:ll
|
||||
if p.cfg.IndexOffset != 0 &&
|
||||
binary.BigEndian.Uint64(indexKey) == p.cfg.IndexOffset+1 {
|
||||
|
||||
|
|
|
|||
|
|
@ -318,9 +318,9 @@ func (s *groupActionsReadDB) ListActions(ctx context.Context) ([]*RuleAction,
|
|||
return actions, nil
|
||||
}
|
||||
|
||||
// groupFeatureActionsReadDB is an implementation of the rules.ActionsListDB that
|
||||
// will provide read access to all the Actions of a feature within a particular
|
||||
// group.
|
||||
// groupFeatureActionsReadDB is an implementation of the rules.ActionsListDB
|
||||
// that will provide read access to all the Actions of a feature within a
|
||||
// particular group.
|
||||
type groupFeatureActionsReadDB struct {
|
||||
*allActionsReadDB
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ const (
|
|||
typeLocatorActionID tlv.Type = 2
|
||||
)
|
||||
|
||||
// nolint:ll
|
||||
/*
|
||||
The Actions are stored in the following structure in the KV db:
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ type SQLAccountQueries interface {
|
|||
// SQLActionQueries is a subset of the sqlc.Queries interface that can be used
|
||||
// to interact with action related tables.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
type SQLActionQueries interface {
|
||||
SQLSessionQueries
|
||||
SQLAccountQueries
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
// nolint:ll
|
||||
/*
|
||||
The KVStores are stored in the following structure in the KV db. Note that
|
||||
the `perm` and `temp` buckets are identical in structure. The only difference
|
||||
|
|
@ -347,7 +348,8 @@ func (s *kvStoreTx) getSessionFeatureRuleBucket(perm bool) getBucketFunc {
|
|||
}
|
||||
|
||||
if create {
|
||||
featureBucket, err := sessBucket.CreateBucketIfNotExists(
|
||||
featureBucket, err :=
|
||||
sessBucket.CreateBucketIfNotExists(
|
||||
featureKVStoreBucketKey,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import (
|
|||
// SQLKVStoreQueries is a subset of the sqlc.Queries interface that can be
|
||||
// used to interact with the kvstore tables.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
type SQLKVStoreQueries interface {
|
||||
SQLSessionQueries
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
// SQLPrivacyPairQueries is a subset of the sqlc.Queries interface that can be
|
||||
// used to interact with the privacy map table.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
type SQLPrivacyPairQueries interface {
|
||||
SQLSessionQueries
|
||||
|
||||
|
|
|
|||
|
|
@ -894,6 +894,8 @@ func migrateActionsToSQL(ctx context.Context, kvStore *bbolt.DB,
|
|||
|
||||
// Iterate over session ID buckets (i.e. what we should name
|
||||
// macaroon IDs).
|
||||
//
|
||||
// nolint:ll
|
||||
return sessionsBucket.ForEach(func(macID []byte, v []byte) error {
|
||||
if v != nil {
|
||||
return fmt.Errorf("expected only sub-buckets " +
|
||||
|
|
@ -984,7 +986,8 @@ func migrateActionsToSQL(ctx context.Context, kvStore *bbolt.DB,
|
|||
return fmt.Errorf("iterating over actions failed: %w", err)
|
||||
}
|
||||
|
||||
log.Infof("Finished iterating actions in KV store (no persistence yet).")
|
||||
log.Infof("Finished iterating actions in KV store " +
|
||||
"(no persistence yet).")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1097,8 +1100,8 @@ func validateMigratedAction(ctx context.Context, sqlTx SQLQueries,
|
|||
ctx, insertParams.SessionID.Int64,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get session with id %d: %w",
|
||||
insertParams.SessionID.Int64, err)
|
||||
return fmt.Errorf("unable to get session with id %d: "+
|
||||
"%w", insertParams.SessionID.Int64, err)
|
||||
}
|
||||
|
||||
overriddenSessID = fn.Some(session.ID(sess.Alias))
|
||||
|
|
@ -1109,8 +1112,8 @@ func validateMigratedAction(ctx context.Context, sqlTx SQLQueries,
|
|||
ctx, insertParams.AccountID.Int64,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get account with id %d: %w",
|
||||
insertParams.AccountID.Int64, err)
|
||||
return fmt.Errorf("unable to get account with id %d: "+
|
||||
"%w", insertParams.AccountID.Int64, err)
|
||||
}
|
||||
|
||||
acctAlias, err := accounts.AccountIDFromInt64(acct.Alias)
|
||||
|
|
|
|||
|
|
@ -387,6 +387,8 @@ func TestFirewallDBMigration(t *testing.T) {
|
|||
|
||||
// The tests slice contains all the tests that we will run for the
|
||||
// migration of the firewalldb from a BoltDB to a SQLDB.
|
||||
//
|
||||
// nolint:ll
|
||||
tests := []struct {
|
||||
name string
|
||||
populateDB func(t *testing.T, ctx context.Context,
|
||||
|
|
@ -1863,6 +1865,7 @@ func randomActions(t *testing.T, ctx context.Context, boltDB *BoltDB,
|
|||
acctAlias, err := newAcctID.ToInt64()
|
||||
require.NoError(t, err)
|
||||
|
||||
// nolint:ll
|
||||
_, err = acctSqlStore.UpdateAccountAliasForTests(
|
||||
ctx, sqlc.UpdateAccountAliasForTestsParams{
|
||||
Alias: acctAlias,
|
||||
|
|
@ -2185,7 +2188,8 @@ func randomString(n int) string {
|
|||
func randomBytes(n int) []byte {
|
||||
b := make([]byte, n)
|
||||
for i := range b {
|
||||
b[i] = byte(rand.Intn(256)) // Random int between 0-255, then cast to byte
|
||||
// Random int between 0-255, then cast to byte.
|
||||
b[i] = byte(rand.Intn(256))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
|
|
|||
10
gzip.go
10
gzip.go
|
|
@ -21,7 +21,10 @@ func (w gzipResponseWriter) Write(b []byte) (int, error) {
|
|||
func makeGzipHandler(handler http.HandlerFunc) http.HandlerFunc {
|
||||
return func(resp http.ResponseWriter, req *http.Request) {
|
||||
// Check if the client can accept the gzip encoding.
|
||||
if !strings.Contains(req.Header.Get("Accept-Encoding"), "gzip") {
|
||||
isGzipEncoding := strings.Contains(
|
||||
req.Header.Get("Accept-Encoding"), "gzip",
|
||||
)
|
||||
if !isGzipEncoding {
|
||||
// The client cannot accept it, so return the output
|
||||
// uncompressed.
|
||||
handler(resp, req)
|
||||
|
|
@ -31,6 +34,9 @@ func makeGzipHandler(handler http.HandlerFunc) http.HandlerFunc {
|
|||
resp.Header().Set("Content-Encoding", "gzip")
|
||||
gzipWriter := gzip.NewWriter(resp)
|
||||
defer gzipWriter.Close()
|
||||
handler(gzipResponseWriter{Writer: gzipWriter, ResponseWriter: resp}, req)
|
||||
gzipRespWriter := gzipResponseWriter{
|
||||
Writer: gzipWriter, ResponseWriter: resp,
|
||||
}
|
||||
handler(gzipRespWriter, req)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ const (
|
|||
DefaultPushSat int64 = 1062
|
||||
)
|
||||
|
||||
// nolint: lll
|
||||
// nolint:ll
|
||||
var (
|
||||
failureNoBalance = lnrpc.PaymentFailureReason_FAILURE_REASON_INSUFFICIENT_BALANCE
|
||||
failureNoRoute = lnrpc.PaymentFailureReason_FAILURE_REASON_NO_ROUTE
|
||||
|
|
@ -554,7 +554,8 @@ func createTestAssetNetwork(t *harnessTest, net *NetworkHarness, charlieTap,
|
|||
// After opening the channels, the asset balance of the funding nodes
|
||||
// should have been decreased with the funding amount.
|
||||
assertBalance(
|
||||
t.t, charlieTap, charlieAssetBalance, itest.WithAssetID(assetID),
|
||||
t.t, charlieTap, charlieAssetBalance,
|
||||
itest.WithAssetID(assetID),
|
||||
)
|
||||
assertBalance(
|
||||
t.t, daveTap, daveAssetBalance, itest.WithAssetID(assetID),
|
||||
|
|
@ -3194,8 +3195,8 @@ func assertPendingForceCloseChannelAssetData(t *testing.T, node *HarnessNode,
|
|||
error) {
|
||||
|
||||
if len(resp.PendingForceClosingChannels) == 0 {
|
||||
return nil, fmt.Errorf("no pending force close " +
|
||||
"channels found")
|
||||
return nil, fmt.Errorf("no pending force " +
|
||||
"close channels found")
|
||||
}
|
||||
|
||||
for _, ch := range resp.PendingForceClosingChannels {
|
||||
|
|
@ -3528,9 +3529,10 @@ func assertForceCloseSweeps(ctx context.Context, net *NetworkHarness,
|
|||
|
||||
// We'll pause here and wait until the sweeper recognizes that we've
|
||||
// offered the second level sweep transaction.
|
||||
//
|
||||
// nolint:ll
|
||||
assertSweepExists(
|
||||
t.t, alice,
|
||||
//nolint: lll
|
||||
walletrpc.WitnessType_TAPROOT_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL,
|
||||
)
|
||||
|
||||
|
|
@ -3642,9 +3644,9 @@ func assertForceCloseSweeps(ctx context.Context, net *NetworkHarness,
|
|||
// If we didn't yet sweep all HTLCs, then we need to wait for another
|
||||
// sweep.
|
||||
if numSweptHTLCs < numTimeoutHTLCs {
|
||||
// nolint:ll
|
||||
assertSweepExists(
|
||||
t.t, bob,
|
||||
// nolint: lll
|
||||
walletrpc.WitnessType_TAPROOT_HTLC_OFFERED_REMOTE_TIMEOUT,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ var (
|
|||
"--taproot-assets.universerpccourier.maxbackoff=600ms",
|
||||
"--taproot-assets.custodianproofretrievaldelay=500ms",
|
||||
}
|
||||
// nolint:ll
|
||||
litdArgsTemplate = append(litdArgsTemplateNoOracle, []string{
|
||||
"--taproot-assets.experimental.rfq.priceoracleaddress=" +
|
||||
"use_mock_price_oracle_service_promise_to_" +
|
||||
|
|
@ -98,6 +99,7 @@ var (
|
|||
"--taproot-assets.experimental.rfq.acceptpricedeviationppm=50000",
|
||||
}...)
|
||||
|
||||
// nolint:ll
|
||||
litdArgsTemplateDiffOracle = append(litdArgsTemplateNoOracle, []string{
|
||||
"--taproot-assets.experimental.rfq.priceoracleaddress=" +
|
||||
"use_mock_price_oracle_service_promise_to_" +
|
||||
|
|
@ -2338,7 +2340,9 @@ func testCustomChannelsV1Upgrade(ctx context.Context, net *NetworkHarness,
|
|||
)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
charlie, err := net.NewNode(t.t, "Charlie", lndArgs, false, true, litdArgs...)
|
||||
charlie, err := net.NewNode(
|
||||
t.t, "Charlie", lndArgs, false, true, litdArgs...,
|
||||
)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
// Next we'll connect all the nodes and also fund them with some coins.
|
||||
|
|
|
|||
|
|
@ -976,6 +976,7 @@ func testChannelOpening(net *NetworkHarness, ht *harnessTest, t *testing.T) {
|
|||
net.autopilotServer.SetFeatures(map[string]*mock.Feature{
|
||||
"OpenChannels": {
|
||||
Description: "open channels while you sleep!",
|
||||
// nolint:ll
|
||||
Rules: map[string]*mock.RuleRanges{
|
||||
rules.OnChainBudgetName: onChainBudgetRule,
|
||||
rules.ChanConstraintName: chanConstraintsRule,
|
||||
|
|
@ -1028,6 +1029,7 @@ func testChannelOpening(net *NetworkHarness, ht *harnessTest, t *testing.T) {
|
|||
MailboxServerAddr: mailboxServerAddr,
|
||||
Features: map[string]*litrpc.FeatureConfig{
|
||||
"OpenChannels": {
|
||||
// nolint:ll
|
||||
Rules: &litrpc.RulesMap{
|
||||
Rules: map[string]*litrpc.RuleValue{
|
||||
rules.ChanConstraintName: {
|
||||
|
|
@ -1292,6 +1294,7 @@ func testChannelOpening(net *NetworkHarness, ht *harnessTest, t *testing.T) {
|
|||
MailboxServerAddr: mailboxServerAddr,
|
||||
Features: map[string]*litrpc.FeatureConfig{
|
||||
"OpenChannels": {
|
||||
// nolint:ll
|
||||
Rules: &litrpc.RulesMap{
|
||||
Rules: map[string]*litrpc.RuleValue{
|
||||
rules.OnChainBudgetName: {
|
||||
|
|
@ -1474,6 +1477,7 @@ func testRateLimitAndPrivacyMapper(net *NetworkHarness, t *harnessTest) {
|
|||
time.Now().Add(5 * time.Minute).Unix(),
|
||||
),
|
||||
MailboxServerAddr: mailboxServerAddr,
|
||||
// nolint:ll
|
||||
Features: map[string]*litrpc.FeatureConfig{
|
||||
"HealthCheck": {
|
||||
Rules: &litrpc.RulesMap{
|
||||
|
|
@ -1700,6 +1704,7 @@ func testHistoryLimitRule(net *NetworkHarness, t *harnessTest) {
|
|||
time.Now().Add(5 * time.Minute).Unix(),
|
||||
),
|
||||
MailboxServerAddr: mailboxServerAddr,
|
||||
// nolint:ll
|
||||
Features: map[string]*litrpc.FeatureConfig{
|
||||
"AutoFees": {
|
||||
Rules: &litrpc.RulesMap{
|
||||
|
|
@ -1820,6 +1825,7 @@ func testChanPolicyBoundsRule(net *NetworkHarness, t *harnessTest) {
|
|||
net.autopilotServer.SetFeatures(map[string]*mock.Feature{
|
||||
"AutoFees": {
|
||||
Description: "manages your channel fees",
|
||||
// nolint:ll
|
||||
Rules: map[string]*mock.RuleRanges{
|
||||
rules.ChanPolicyBoundsName: chanPolicyBoundsRule,
|
||||
},
|
||||
|
|
@ -1857,6 +1863,7 @@ func testChanPolicyBoundsRule(net *NetworkHarness, t *harnessTest) {
|
|||
Features: map[string]*litrpc.FeatureConfig{
|
||||
"AutoFees": {
|
||||
Rules: &litrpc.RulesMap{
|
||||
// nolint:ll
|
||||
Rules: map[string]*litrpc.RuleValue{
|
||||
rules.ChanPolicyBoundsName: {
|
||||
Value: policyBounds,
|
||||
|
|
@ -2117,6 +2124,7 @@ func testPeerAndChannelRestrictRules(net *NetworkHarness, t *harnessTest) {
|
|||
MailboxServerAddr: mailboxServerAddr,
|
||||
Features: map[string]*litrpc.FeatureConfig{
|
||||
"AutoFees": {
|
||||
// nolint:ll
|
||||
Rules: &litrpc.RulesMap{
|
||||
Rules: map[string]*litrpc.RuleValue{
|
||||
rules.PeersRestrictName: {
|
||||
|
|
@ -2385,8 +2393,7 @@ func testLargeHttpHeader(ctx context.Context, net *NetworkHarness,
|
|||
// Add a new Autopilot session that subscribes to a "Test", feature.
|
||||
// This call is expected to also result in Litd registering this session
|
||||
// with the mock autopilot server.
|
||||
sessResp, err := litClient.AddAutopilotSession(
|
||||
ctxm, &litrpc.AddAutopilotSessionRequest{
|
||||
req := litrpc.AddAutopilotSessionRequest{
|
||||
Label: "integration-test",
|
||||
ExpiryTimestampSeconds: uint64(
|
||||
time.Now().Add(5 * time.Minute).Unix(),
|
||||
|
|
@ -2401,8 +2408,8 @@ func testLargeHttpHeader(ctx context.Context, net *NetworkHarness,
|
|||
},
|
||||
// Switch the privacy mapper off for simplicity’s sake.
|
||||
NoPrivacyMapper: true,
|
||||
},
|
||||
)
|
||||
}
|
||||
sessResp, err := litClient.AddAutopilotSession(ctxm, &req)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
// We now connect to the mailbox from the PoV of the autopilot server.
|
||||
|
|
@ -2525,7 +2532,9 @@ func connectMailboxWithRemoteKey(ctx context.Context,
|
|||
|
||||
transportConn, err := mailbox.NewGrpcClient(
|
||||
ctx, mailboxServerAddr, connData,
|
||||
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
|
||||
grpc.WithTransportCredentials(
|
||||
credentials.NewTLS(&tls.Config{}),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
|
|
|||
|
|
@ -817,7 +817,8 @@ func runCertificateCheck(t *testing.T, node *HarnessNode) {
|
|||
require.NoError(t, err)
|
||||
require.Len(t, litCerts, 1)
|
||||
require.Equal(
|
||||
t, "litd autogenerated cert", litCerts[0].Issuer.Organization[0],
|
||||
t, "litd autogenerated cert",
|
||||
litCerts[0].Issuer.Organization[0],
|
||||
)
|
||||
|
||||
lndCerts, err := getServerCertificates(node.Cfg.RPCAddr())
|
||||
|
|
@ -1357,7 +1358,9 @@ func connectMailboxWithPairingPhrase(ctx context.Context,
|
|||
|
||||
transportConn, err := mailbox.NewGrpcClient(
|
||||
ctx, mailboxServerAddr, connData,
|
||||
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
|
||||
grpc.WithTransportCredentials(
|
||||
credentials.NewTLS(&tls.Config{}),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -637,7 +637,8 @@ func (hn *HarnessNode) InvoiceMacPath() string {
|
|||
return hn.Cfg.InvoiceMacPath
|
||||
}
|
||||
|
||||
// renameFile is a helper to rename (log) files created during integration tests.
|
||||
// renameFile is a helper to rename (log) files created during integration
|
||||
// tests.
|
||||
func renameFile(fromFileName, toFileName string) {
|
||||
err := os.Rename(fromFileName, toFileName)
|
||||
if err != nil {
|
||||
|
|
@ -807,8 +808,8 @@ func (hn *HarnessNode) Start(litdBinary string,
|
|||
return nil
|
||||
}
|
||||
|
||||
// Since Stop uses the LightningClient to stop the node, if we fail to get a
|
||||
// connected client, we have to kill the process.
|
||||
// Since Stop uses the LightningClient to stop the node, if we fail to
|
||||
// get a connected client, we have to kill the process.
|
||||
useMacaroons := !hn.Cfg.HasSeed
|
||||
conn, err := hn.ConnectRPC(useMacaroons)
|
||||
if err != nil {
|
||||
|
|
@ -1273,7 +1274,10 @@ func (hn *HarnessNode) initLightningClient(conn *grpc.ClientConn) error {
|
|||
// Set the harness node's pubkey to what the node claims in GetInfo.
|
||||
// Since the RPC might not be immediately active, we wrap the call in a
|
||||
// wait.NoError.
|
||||
if err := wait.NoError(hn.FetchNodeInfo, lntest.DefaultTimeout); err != nil {
|
||||
err := wait.NoError(
|
||||
hn.FetchNodeInfo, lntest.DefaultTimeout,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -1331,7 +1335,8 @@ func (hn *HarnessNode) ReadMacaroon(macPath string, timeout time.Duration) (
|
|||
err := wait.NoError(func() error {
|
||||
macBytes, err := ioutil.ReadFile(macPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error reading macaroon file: %v", err)
|
||||
return fmt.Errorf("error reading macaroon file: %v",
|
||||
err)
|
||||
}
|
||||
|
||||
newMac := &macaroon.Macaroon{}
|
||||
|
|
@ -1432,7 +1437,8 @@ func (hn *HarnessNode) cleanup() error {
|
|||
if hn.backupDbDir != "" {
|
||||
err := os.RemoveAll(hn.backupDbDir)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to remove backup dir: %v", err)
|
||||
return fmt.Errorf("unable to remove backup dir: %v",
|
||||
err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1461,7 +1467,9 @@ func (hn *HarnessNode) Stop() error {
|
|||
return nil
|
||||
|
||||
// Try again if a recovery/rescan is in progress.
|
||||
case strings.Contains(err.Error(), "recovery in progress"):
|
||||
case strings.Contains(
|
||||
err.Error(), "recovery in progress",
|
||||
):
|
||||
return err
|
||||
|
||||
default:
|
||||
|
|
@ -1506,9 +1514,10 @@ func (hn *HarnessNode) Stop() error {
|
|||
// Close any attempts at further grpc connections.
|
||||
if hn.conn != nil {
|
||||
err := hn.conn.Close()
|
||||
if err != nil &&
|
||||
!strings.Contains(err.Error(), "connection is closing") {
|
||||
|
||||
isConnClosingErr := strings.Contains(
|
||||
err.Error(), "connection is closing",
|
||||
)
|
||||
if err != nil && !isConnClosingErr {
|
||||
return fmt.Errorf("error attempting to stop grpc "+
|
||||
"client: %v", err)
|
||||
}
|
||||
|
|
@ -1803,7 +1812,9 @@ func (hn *HarnessNode) WaitForBlockchainSync(ctx context.Context) error {
|
|||
|
||||
// WaitForBalance waits until the node sees the expected confirmed/unconfirmed
|
||||
// balance within their wallet.
|
||||
func (hn *HarnessNode) WaitForBalance(expectedBalance btcutil.Amount, confirmed bool) error {
|
||||
func (hn *HarnessNode) WaitForBalance(expectedBalance btcutil.Amount,
|
||||
confirmed bool) error {
|
||||
|
||||
ctx := context.Background()
|
||||
req := &lnrpc.WalletBalanceRequest{}
|
||||
|
||||
|
|
@ -1815,18 +1826,23 @@ func (hn *HarnessNode) WaitForBalance(expectedBalance btcutil.Amount, confirmed
|
|||
}
|
||||
|
||||
if confirmed {
|
||||
lastBalance = btcutil.Amount(balance.ConfirmedBalance)
|
||||
return btcutil.Amount(balance.ConfirmedBalance) == expectedBalance
|
||||
balanceAmt := btcutil.Amount(
|
||||
balance.ConfirmedBalance,
|
||||
)
|
||||
lastBalance = balanceAmt
|
||||
return balanceAmt == expectedBalance
|
||||
}
|
||||
|
||||
lastBalance = btcutil.Amount(balance.UnconfirmedBalance)
|
||||
return btcutil.Amount(balance.UnconfirmedBalance) == expectedBalance
|
||||
balanceAmt := btcutil.Amount(balance.UnconfirmedBalance)
|
||||
lastBalance = balanceAmt
|
||||
return balanceAmt == expectedBalance
|
||||
}
|
||||
|
||||
err := wait.Predicate(doesBalanceMatch, lntest.DefaultTimeout)
|
||||
if err != nil {
|
||||
return fmt.Errorf("balances not synced after deadline: "+
|
||||
"expected %v, only have %v", expectedBalance, lastBalance)
|
||||
"expected %v, only have %v", expectedBalance,
|
||||
lastBalance)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ type NetworkHarness struct {
|
|||
// compiled with all required itest flags.
|
||||
litdBinary string
|
||||
|
||||
// Miner is a reference to a running full node that can be used to create
|
||||
// new blocks on the network.
|
||||
// Miner is a reference to a running full node that can be used to
|
||||
// create new blocks on the network.
|
||||
Miner *miner.HarnessMiner
|
||||
|
||||
LNDHarness *lntest.HarnessTest
|
||||
|
|
@ -467,9 +467,11 @@ func (n *NetworkHarness) connect(ctx context.Context,
|
|||
tryconnect:
|
||||
if _, err := a.ConnectPeer(ctx, req); err != nil {
|
||||
// If the chain backend is still syncing, retry.
|
||||
if strings.Contains(err.Error(), lnd.ErrServerNotActive.Error()) ||
|
||||
strings.Contains(err.Error(), "i/o timeout") {
|
||||
|
||||
isNotActiveErr := strings.Contains(
|
||||
err.Error(), lnd.ErrServerNotActive.Error(),
|
||||
)
|
||||
isTimeoutErr := strings.Contains(err.Error(), "i/o timeout")
|
||||
if isNotActiveErr || isTimeoutErr {
|
||||
select {
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
goto tryconnect
|
||||
|
|
@ -520,7 +522,9 @@ func (n *NetworkHarness) EnsureConnected(t *testing.T, a, b *HarnessNode) {
|
|||
|
||||
var predErr error
|
||||
err = wait.Predicate(func() bool {
|
||||
ctx, cancel := context.WithTimeout(ctx, lntest.DefaultTimeout)
|
||||
ctx, cancel := context.WithTimeout(
|
||||
ctx, lntest.DefaultTimeout,
|
||||
)
|
||||
defer cancel()
|
||||
|
||||
err := n.connect(ctx, req, a)
|
||||
|
|
@ -748,7 +752,9 @@ func (n *NetworkHarness) RestartNode(node *HarnessNode, callback func() error,
|
|||
|
||||
// Give the node some time to catch up with the chain before we continue
|
||||
// with the tests.
|
||||
ctxc, done := context.WithTimeout(context.Background(), lntest.DefaultTimeout)
|
||||
ctxc, done := context.WithTimeout(
|
||||
context.Background(), lntest.DefaultTimeout,
|
||||
)
|
||||
defer done()
|
||||
return node.WaitForBlockchainSync(ctxc)
|
||||
}
|
||||
|
|
@ -941,7 +947,9 @@ func (n *NetworkHarness) OpenChannel(srcNode, destNode *HarnessNode,
|
|||
// The cancel is intentionally left out here because the returned
|
||||
// item(open channel client) relies on the context being active. This
|
||||
// will be fixed once we finish refactoring the NetworkHarness.
|
||||
ctx, _ := context.WithTimeout(ctxb, wait.ChannelOpenTimeout) // nolint: govet
|
||||
//
|
||||
// nolint:govet
|
||||
ctx, _ := context.WithTimeout(ctxb, wait.ChannelOpenTimeout)
|
||||
|
||||
// Wait until srcNode and destNode have the latest chain synced.
|
||||
// Otherwise, we may run into a check within the funding manager that
|
||||
|
|
@ -982,17 +990,18 @@ func (n *NetworkHarness) OpenChannel(srcNode, destNode *HarnessNode,
|
|||
chanOpen := make(chan struct{})
|
||||
errChan := make(chan error)
|
||||
go func() {
|
||||
// Consume the "channel pending" update. This waits until the node
|
||||
// notifies us that the final message in the channel funding workflow
|
||||
// has been sent to the remote node.
|
||||
// Consume the "channel pending" update. This waits until the
|
||||
// node notifies us that the final message in the channel
|
||||
// funding workflow has been sent to the remote node.
|
||||
resp, err := respStream.Recv()
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
if _, ok := resp.Update.(*lnrpc.OpenStatusUpdate_ChanPending); !ok {
|
||||
errChan <- fmt.Errorf("expected channel pending update, "+
|
||||
"instead got %v", resp)
|
||||
_, ok := resp.Update.(*lnrpc.OpenStatusUpdate_ChanPending)
|
||||
if !ok {
|
||||
errChan <- fmt.Errorf("expected channel pending "+
|
||||
"update, instead got %v", resp)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1010,10 +1019,10 @@ func (n *NetworkHarness) OpenChannel(srcNode, destNode *HarnessNode,
|
|||
}
|
||||
}
|
||||
|
||||
// OpenPendingChannel attempts to open a channel between srcNode and destNode with the
|
||||
// passed channel funding parameters. If the passed context has a timeout, then
|
||||
// if the timeout is reached before the channel pending notification is
|
||||
// received, an error is returned.
|
||||
// OpenPendingChannel attempts to open a channel between srcNode and destNode
|
||||
// with the passed channel funding parameters. If the passed context has a
|
||||
// timeout, then if the timeout is reached before the channel pending
|
||||
// notification is received, an error is returned.
|
||||
func (n *NetworkHarness) OpenPendingChannel(srcNode, destNode *HarnessNode,
|
||||
amt btcutil.Amount,
|
||||
pushAmt btcutil.Amount) (*lnrpc.PendingUpdate, error) {
|
||||
|
|
@ -1046,18 +1055,19 @@ func (n *NetworkHarness) OpenPendingChannel(srcNode, destNode *HarnessNode,
|
|||
chanPending := make(chan *lnrpc.PendingUpdate)
|
||||
errChan := make(chan error)
|
||||
go func() {
|
||||
// Consume the "channel pending" update. This waits until the node
|
||||
// notifies us that the final message in the channel funding workflow
|
||||
// has been sent to the remote node.
|
||||
// Consume the "channel pending" update. This waits until the
|
||||
// node notifies us that the final message in the channel
|
||||
// funding workflow has been sent to the remote node.
|
||||
resp, err := respStream.Recv()
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
pendingResp, ok := resp.Update.(*lnrpc.OpenStatusUpdate_ChanPending)
|
||||
pendingResp, ok :=
|
||||
resp.Update.(*lnrpc.OpenStatusUpdate_ChanPending)
|
||||
if !ok {
|
||||
errChan <- fmt.Errorf("expected channel pending update, "+
|
||||
"instead got %v", resp)
|
||||
errChan <- fmt.Errorf("expected channel pending "+
|
||||
"update, instead got %v", resp)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1080,7 +1090,8 @@ func (n *NetworkHarness) OpenPendingChannel(srcNode, destNode *HarnessNode,
|
|||
// has a timeout, then if the timeout is reached before the channel has been
|
||||
// opened, then an error is returned.
|
||||
func (n *NetworkHarness) WaitForChannelOpen(
|
||||
openChanStream lnrpc.Lightning_OpenChannelClient) (*lnrpc.ChannelPoint, error) {
|
||||
openChanStream lnrpc.Lightning_OpenChannelClient) (*lnrpc.ChannelPoint,
|
||||
error) {
|
||||
|
||||
ctxb := context.Background()
|
||||
ctx, cancel := context.WithTimeout(ctxb, wait.ChannelOpenTimeout)
|
||||
|
|
@ -1091,10 +1102,12 @@ func (n *NetworkHarness) WaitForChannelOpen(
|
|||
go func() {
|
||||
resp, err := openChanStream.Recv()
|
||||
if err != nil {
|
||||
errChan <- fmt.Errorf("unable to read rpc resp: %v", err)
|
||||
errChan <- fmt.Errorf("unable to read rpc resp: %w",
|
||||
err)
|
||||
return
|
||||
}
|
||||
fundingResp, ok := resp.Update.(*lnrpc.OpenStatusUpdate_ChanOpen)
|
||||
fundingResp, ok :=
|
||||
resp.Update.(*lnrpc.OpenStatusUpdate_ChanOpen)
|
||||
if !ok {
|
||||
errChan <- fmt.Errorf("expected channel open update, "+
|
||||
"instead got %v", resp)
|
||||
|
|
@ -1120,14 +1133,16 @@ func (n *NetworkHarness) WaitForChannelOpen(
|
|||
// has a timeout, an error is returned if that timeout is reached before the
|
||||
// channel close is pending.
|
||||
func (n *NetworkHarness) CloseChannel(lnNode *HarnessNode,
|
||||
cp *lnrpc.ChannelPoint,
|
||||
force bool) (lnrpc.Lightning_CloseChannelClient, *chainhash.Hash, error) {
|
||||
cp *lnrpc.ChannelPoint, force bool) (lnrpc.Lightning_CloseChannelClient,
|
||||
*chainhash.Hash, error) {
|
||||
|
||||
ctxb := context.Background()
|
||||
// The cancel is intentionally left out here because the returned
|
||||
// item(close channel client) relies on the context being active. This
|
||||
// will be fixed once we finish refactoring the NetworkHarness.
|
||||
ctx, _ := context.WithTimeout(ctxb, wait.ChannelCloseTimeout) // nolint: govet
|
||||
//
|
||||
// nolint: govet
|
||||
ctx, _ := context.WithTimeout(ctxb, wait.ChannelCloseTimeout)
|
||||
|
||||
// Create a channel outpoint that we can use to compare to channels
|
||||
// from the ListChannelsResponse.
|
||||
|
|
@ -1181,7 +1196,8 @@ func (n *NetworkHarness) CloseChannel(lnNode *HarnessNode,
|
|||
}
|
||||
|
||||
// Next, we'll fetch the target channel in order to get the
|
||||
// harness node that will be receiving the channel close request.
|
||||
// harness node that will be receiving the channel close
|
||||
// request.
|
||||
targetChan, err := filterChannel(lnNode, chanPoint)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
|
@ -1198,7 +1214,9 @@ func (n *NetworkHarness) CloseChannel(lnNode *HarnessNode,
|
|||
return nil, nil, fmt.Errorf("channel of closing " +
|
||||
"node not active in time")
|
||||
}
|
||||
err = wait.Predicate(activeChanPredicate(receivingNode), timeout)
|
||||
err = wait.Predicate(
|
||||
activeChanPredicate(receivingNode), timeout,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("channel of receiving " +
|
||||
"node not active in time")
|
||||
|
|
@ -1232,7 +1250,8 @@ func (n *NetworkHarness) CloseChannel(lnNode *HarnessNode,
|
|||
return fmt.Errorf("unable to recv() from close "+
|
||||
"stream: %v", err)
|
||||
}
|
||||
pendingClose, ok := closeResp.Update.(*lnrpc.CloseStatusUpdate_ClosePending)
|
||||
pendingClose, ok :=
|
||||
closeResp.Update.(*lnrpc.CloseStatusUpdate_ClosePending)
|
||||
if !ok {
|
||||
return fmt.Errorf("expected channel close update, "+
|
||||
"instead got %v", pendingClose)
|
||||
|
|
@ -1317,7 +1336,8 @@ func (n *NetworkHarness) AssertChannelExists(node *HarnessNode,
|
|||
return wait.NoError(func() error {
|
||||
resp, err := node.ListChannels(ctx, req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable fetch node's channels: %v", err)
|
||||
return fmt.Errorf("unable fetch node's channels: %w",
|
||||
err)
|
||||
}
|
||||
|
||||
for _, channel := range resp.Channels {
|
||||
|
|
@ -1498,7 +1518,8 @@ func (n *NetworkHarness) sendCoins(amt btcutil.Amount, target *HarnessNode,
|
|||
// the target node's unconfirmed balance reflects the expected balance
|
||||
// and exit.
|
||||
if !confirmed {
|
||||
expectedBalance := btcutil.Amount(initialBalance.UnconfirmedBalance) + amt
|
||||
expectedBalance :=
|
||||
btcutil.Amount(initialBalance.UnconfirmedBalance) + amt
|
||||
return target.WaitForBalance(expectedBalance, false)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -228,7 +228,9 @@ func mineBlocksSlow(t *harnessTest, net *NetworkHarness,
|
|||
return blocks
|
||||
}
|
||||
|
||||
func assertTxInBlock(t *harnessTest, block *wire.MsgBlock, txid *chainhash.Hash) {
|
||||
func assertTxInBlock(t *harnessTest, block *wire.MsgBlock,
|
||||
txid *chainhash.Hash) {
|
||||
|
||||
for _, tx := range block.Transactions {
|
||||
sha := tx.TxHash()
|
||||
if bytes.Equal(txid[:], sha[:]) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ const (
|
|||
|
||||
// Config is the configuration struct for the RPC middleware.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
type Config struct {
|
||||
Disabled bool `long:"disabled" description:"Disable the RPC middleware"`
|
||||
InterceptTimeout time.Duration `long:"intercept-timeout" description:"The maximum time the RPC middleware is allowed to take for intercepting each RPC request"`
|
||||
|
|
|
|||
|
|
@ -431,8 +431,8 @@ func validateRequestCheckHandler(typedHandlerType reflect.Type,
|
|||
"with a sub type of context.Context")
|
||||
}
|
||||
if !typedHandlerType.In(1).ConvertibleTo(requestType) {
|
||||
return fmt.Errorf("request handler must have second parameter " +
|
||||
"with a sub type of proto.Message")
|
||||
return fmt.Errorf("request handler must have second " +
|
||||
"parameter with a sub type of proto.Message")
|
||||
}
|
||||
if typedHandlerType.Out(0) != errorType {
|
||||
return fmt.Errorf("request handler must return exactly one " +
|
||||
|
|
@ -459,8 +459,8 @@ func validateMessageHandler(typedHandlerType reflect.Type,
|
|||
"with a sub type of context.Context")
|
||||
}
|
||||
if !typedHandlerType.In(1).ConvertibleTo(messageType) {
|
||||
return fmt.Errorf("message handler must have second parameter " +
|
||||
"with a sub type of proto.Message")
|
||||
return fmt.Errorf("message handler must have second " +
|
||||
"parameter with a sub type of proto.Message")
|
||||
}
|
||||
outType0 := typedHandlerType.Out(0)
|
||||
pmt := protoMessageType
|
||||
|
|
|
|||
|
|
@ -212,8 +212,8 @@ func (c *ChannelRestrictEnforcer) HandleRequest(ctx context.Context, uri string,
|
|||
// rpcmiddleware.RoundTripCheckers.
|
||||
//
|
||||
// NOTE: this is part of the Enforcer interface.
|
||||
func (c *ChannelRestrictEnforcer) HandleResponse(ctx context.Context, uri string,
|
||||
msg proto.Message) (proto.Message, error) {
|
||||
func (c *ChannelRestrictEnforcer) HandleResponse(ctx context.Context,
|
||||
uri string, msg proto.Message) (proto.Message, error) {
|
||||
|
||||
checkers := c.checkers()
|
||||
if checkers == nil {
|
||||
|
|
|
|||
|
|
@ -240,8 +240,8 @@ func (h *HistoryLimit) ToProto() *litrpc.RuleValue {
|
|||
}
|
||||
}
|
||||
|
||||
// GetStartDate is a helper function that determines the start date of the values
|
||||
// given if a start date is set or a max duration is given.
|
||||
// GetStartDate is a helper function that determines the start date of the
|
||||
// values given if a start date is set or a max duration is given.
|
||||
func (h *HistoryLimit) GetStartDate() time.Time {
|
||||
startDate := h.StartDate
|
||||
if h.StartDate.IsZero() {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ func TestHistoryLimitCheckers(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
// The ForwardingHistory request has a StartTime parameter. The request
|
||||
// should be allowed if the parameter is ok given the HistoryLimit values.
|
||||
// should be allowed if the parameter is ok given the HistoryLimit
|
||||
// values.
|
||||
_, err = values.HandleRequest(
|
||||
ctx, "/lnrpc.Lightning/ForwardingHistory",
|
||||
&lnrpc.ForwardingHistoryRequest{
|
||||
|
|
@ -87,7 +88,8 @@ func TestHistoryLimitCheckers(t *testing.T) {
|
|||
|
||||
// And it should be denied if it violates the values.
|
||||
// The ForwardingHistory request has a StartTime parameter. The request
|
||||
// should be allowed if the parameter is ok given the HistoryLimit values.
|
||||
// should be allowed if the parameter is ok given the HistoryLimit
|
||||
// values.
|
||||
_, err = values.HandleRequest(
|
||||
ctx, "/lnrpc.Lightning/ForwardingHistory",
|
||||
&lnrpc.ForwardingHistoryRequest{
|
||||
|
|
@ -99,9 +101,9 @@ func TestHistoryLimitCheckers(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
|
||||
// The ListInvoices function does not have a StartTime parameter and
|
||||
// so the HistoryLimit values needs to alter the _response_ of this query
|
||||
// instead to only include the invoices created after the HistoryLimit
|
||||
// start date.
|
||||
// so the HistoryLimit values needs to alter the _response_ of this
|
||||
// query instead to only include the invoices created after the
|
||||
// HistoryLimit start date.
|
||||
invoices := []*lnrpc.Invoice{
|
||||
{CreationDate: time.Now().Unix()},
|
||||
{CreationDate: time.Now().Add(-time.Hour * 5).Unix()},
|
||||
|
|
|
|||
|
|
@ -255,7 +255,8 @@ func (o *OnChainBudgetEnforcer) checkers() map[string]mid.RoundTripChecker {
|
|||
"/lnrpc.Lightning/ListChannels": mid.NewResponseRewriter(
|
||||
&lnrpc.ListChannelsRequest{},
|
||||
&lnrpc.ListChannelsResponse{},
|
||||
func(ctx context.Context, r *lnrpc.ListChannelsResponse) (
|
||||
func(ctx context.Context,
|
||||
r *lnrpc.ListChannelsResponse) (
|
||||
proto.Message, error) {
|
||||
|
||||
// We remove any potentially added memos for
|
||||
|
|
@ -271,7 +272,8 @@ func (o *OnChainBudgetEnforcer) checkers() map[string]mid.RoundTripChecker {
|
|||
"/lnrpc.Lightning/PendingChannels": mid.NewResponseRewriter(
|
||||
&lnrpc.PendingChannelsRequest{},
|
||||
&lnrpc.PendingChannelsResponse{},
|
||||
func(ctx context.Context, r *lnrpc.PendingChannelsResponse) (
|
||||
func(ctx context.Context,
|
||||
r *lnrpc.PendingChannelsResponse) (
|
||||
proto.Message, error) {
|
||||
|
||||
// We remove any potentially added memos for
|
||||
|
|
@ -288,6 +290,7 @@ func (o *OnChainBudgetEnforcer) checkers() map[string]mid.RoundTripChecker {
|
|||
)
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
for _, c := range r.PendingForceClosingChannels {
|
||||
c.Channel.Memo = removeReqId(
|
||||
c.Channel.Memo,
|
||||
|
|
|
|||
|
|
@ -380,10 +380,12 @@ func TestHandleMemoResponse(t *testing.T) {
|
|||
},
|
||||
)
|
||||
require.NoError(t, err)
|
||||
// nolint:ll
|
||||
for _, channel := range response.(*lnrpc.ListChannelsResponse).Channels {
|
||||
assertMemoInvariant(channel.Memo)
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
response, err = enf.HandleResponse(
|
||||
ctx, "/lnrpc.Lightning/PendingChannels",
|
||||
&lnrpc.PendingChannelsResponse{
|
||||
|
|
|
|||
|
|
@ -180,8 +180,8 @@ func TestRateLimitCheckRequest(t *testing.T) {
|
|||
// Now we add a more recent write action to the DB.
|
||||
db.addAction("write-uri", time.Now())
|
||||
|
||||
// Since the rate limit values only allows one write action per 24 hours,
|
||||
// a request for another write action should not be allowed.
|
||||
// Since the rate limit values only allows one write action per 24
|
||||
// hours, a request for another write action should not be allowed.
|
||||
_, err = enf.HandleRequest(ctx, "write-uri", nil)
|
||||
require.Error(t, err)
|
||||
|
||||
|
|
@ -227,8 +227,8 @@ func (m *mockRateLimitCfg) GetMethodPerms() func(string) ([]bakery.Op, bool) {
|
|||
}
|
||||
}
|
||||
|
||||
// mockActionsDB is used to mock the action's db backend used by the RateLimitMgr
|
||||
// values.
|
||||
// mockActionsDB is used to mock the action's db backend used by the
|
||||
// RateLimitMgr values.
|
||||
type mockActionsDB struct {
|
||||
actions []*firewalldb.RuleAction
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ var (
|
|||
// information about sessions. These sessions are indexed by their
|
||||
// public key.
|
||||
//
|
||||
// nolint:ll
|
||||
//
|
||||
// The session bucket has the following structure:
|
||||
// session -> <key> -> <serialised session>
|
||||
// -> id-index -> <session-id> -> key -> <session key>
|
||||
|
|
|
|||
|
|
@ -219,9 +219,8 @@ func DeserializeSession(r io.Reader) (*Session, error) {
|
|||
}
|
||||
|
||||
if t, ok := parsedTypes[typeLocalPrivateKey]; ok && t == nil {
|
||||
session.LocalPrivateKey, session.LocalPublicKey = btcec.PrivKeyFromBytes(
|
||||
privateKey,
|
||||
)
|
||||
session.LocalPrivateKey, session.LocalPublicKey =
|
||||
btcec.PrivKeyFromBytes(privateKey)
|
||||
}
|
||||
|
||||
if t, ok := parsedTypes[typeFeaturesConfig]; ok && t == nil {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ var (
|
|||
// information about sessions. These sessions are indexed by their
|
||||
// public key.
|
||||
//
|
||||
// nolint:ll
|
||||
//
|
||||
// The session bucket has the following structure:
|
||||
// session -> <key> -> <serialised session>
|
||||
// -> id-index -> <session-id> -> key -> <session key>
|
||||
|
|
@ -54,7 +56,8 @@ var (
|
|||
)
|
||||
|
||||
// MigrateSessionIDToGroupIndex back-fills the session ID to group index so that
|
||||
// it has an entry for all sessions that the session store is currently aware of.
|
||||
// it has an entry for all sessions that the session store is currently aware
|
||||
// of.
|
||||
func MigrateSessionIDToGroupIndex(tx *bbolt.Tx) error {
|
||||
sessionBucket := tx.Bucket(sessionBucketKey)
|
||||
if sessionBucket == nil {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,9 @@ func dumpBucket(bucket *bbolt.Bucket) error {
|
|||
}
|
||||
|
||||
// RestoreDB primes the database with the given data set.
|
||||
func RestoreDB(tx *bbolt.Tx, rootKey []byte, data map[string]interface{}) error {
|
||||
func RestoreDB(tx *bbolt.Tx, rootKey []byte,
|
||||
data map[string]interface{}) error {
|
||||
|
||||
bucket, err := tx.CreateBucket(rootKey)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -968,7 +968,8 @@ func randomAccountOptions(ctx context.Context, t *testing.T,
|
|||
func randomBytes(n int) []byte {
|
||||
b := make([]byte, n)
|
||||
for i := range b {
|
||||
b[i] = byte(rand.Intn(256)) // Random int between 0-255, then cast to byte
|
||||
// Random int between 0-255, then cast to byte.
|
||||
b[i] = byte(rand.Intn(256))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import (
|
|||
|
||||
// SQLQueries is a subset of the sqlc.Queries interface that can be used to
|
||||
// interact with session related tables.
|
||||
//
|
||||
// nolint:ll
|
||||
type SQLQueries interface {
|
||||
GetAliasBySessionID(ctx context.Context, id int64) ([]byte, error)
|
||||
GetSessionByID(ctx context.Context, id int64) (sqlc.Session, error)
|
||||
|
|
@ -140,7 +142,8 @@ func (s *SQLStore) NewSession(ctx context.Context, label string, typ Type,
|
|||
}
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to convert account ID: %w", err)
|
||||
return fmt.Errorf("unable to convert account ID: %w",
|
||||
err)
|
||||
}
|
||||
|
||||
localKey := sess.LocalPublicKey.SerializeCompressed()
|
||||
|
|
@ -216,6 +219,7 @@ func (s *SQLStore) NewSession(ctx context.Context, label string, typ Type,
|
|||
// Write mac perms and caveats.
|
||||
if sess.MacaroonRecipe != nil {
|
||||
for _, perm := range sess.MacaroonRecipe.Permissions {
|
||||
// nolint:ll
|
||||
err := db.InsertSessionMacaroonPermission(
|
||||
ctx, sqlc.InsertSessionMacaroonPermissionParams{
|
||||
SessionID: dbID,
|
||||
|
|
@ -230,6 +234,7 @@ func (s *SQLStore) NewSession(ctx context.Context, label string, typ Type,
|
|||
}
|
||||
|
||||
for _, caveat := range sess.MacaroonRecipe.Caveats {
|
||||
// nolint:ll
|
||||
err := db.InsertSessionMacaroonCaveat(
|
||||
ctx, sqlc.InsertSessionMacaroonCaveatParams{
|
||||
SessionID: dbID,
|
||||
|
|
@ -253,6 +258,7 @@ func (s *SQLStore) NewSession(ctx context.Context, label string, typ Type,
|
|||
// Write feature configs.
|
||||
if sess.FeatureConfig != nil {
|
||||
for featureName, config := range *sess.FeatureConfig {
|
||||
// nolint:ll
|
||||
err := db.InsertSessionFeatureConfig(
|
||||
ctx, sqlc.InsertSessionFeatureConfigParams{
|
||||
SessionID: dbID,
|
||||
|
|
@ -606,7 +612,8 @@ func (s *SQLStore) GetSession(ctx context.Context, alias ID) (*Session, error) {
|
|||
return sess, err
|
||||
}
|
||||
|
||||
// GetGroupID will return the legacy group Alias for the given legacy session Alias.
|
||||
// GetGroupID will return the legacy group Alias for the given legacy session
|
||||
// Alias.
|
||||
//
|
||||
// NOTE: This is part of the AliasToGroupIndex interface.
|
||||
func (s *SQLStore) GetGroupID(ctx context.Context, sessionID ID) (ID, error) {
|
||||
|
|
@ -728,7 +735,8 @@ func unmarshalSession(ctx context.Context, db SQLQueries,
|
|||
|
||||
accountAlias, err := accounts.AccountIDFromInt64(account.Alias)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to get account ID: %v", err)
|
||||
return nil, fmt.Errorf("unable to get account ID: %v",
|
||||
err)
|
||||
}
|
||||
acctAlias = fn.Some(accountAlias)
|
||||
}
|
||||
|
|
@ -837,7 +845,9 @@ func unmarshalMacPerms(dbPerms []sqlc.SessionMacaroonPermission) []bakery.Op {
|
|||
return ops
|
||||
}
|
||||
|
||||
func unmarshalMacCaveats(dbCaveats []sqlc.SessionMacaroonCaveat) []macaroon.Caveat {
|
||||
func unmarshalMacCaveats(
|
||||
dbCaveats []sqlc.SessionMacaroonCaveat) []macaroon.Caveat {
|
||||
|
||||
caveats := make([]macaroon.Caveat, len(dbCaveats))
|
||||
for i, dbCaveat := range dbCaveats {
|
||||
caveats[i] = macaroon.Caveat{
|
||||
|
|
@ -850,7 +860,9 @@ func unmarshalMacCaveats(dbCaveats []sqlc.SessionMacaroonCaveat) []macaroon.Cave
|
|||
return caveats
|
||||
}
|
||||
|
||||
func unmarshalFeatureConfigs(dbConfigs []sqlc.SessionFeatureConfig) *FeaturesConfig {
|
||||
func unmarshalFeatureConfigs(
|
||||
dbConfigs []sqlc.SessionFeatureConfig) *FeaturesConfig {
|
||||
|
||||
configs := make(FeaturesConfig, len(dbConfigs))
|
||||
for _, dbConfig := range dbConfigs {
|
||||
configs[dbConfig.FeatureName] = dbConfig.Config
|
||||
|
|
|
|||
|
|
@ -261,9 +261,8 @@ func DeserializeSession(r io.Reader) (*Session, error) {
|
|||
}
|
||||
|
||||
if t, ok := parsedTypes[typeLocalPrivateKey]; ok && t == nil {
|
||||
session.LocalPrivateKey, session.LocalPublicKey = btcec.PrivKeyFromBytes(
|
||||
privateKey,
|
||||
)
|
||||
session.LocalPrivateKey, session.LocalPublicKey =
|
||||
btcec.PrivKeyFromBytes(privateKey)
|
||||
}
|
||||
|
||||
if t, ok := parsedTypes[typeFeaturesConfig]; ok && t == nil {
|
||||
|
|
|
|||
|
|
@ -240,7 +240,8 @@ func (s *sessionRpcServer) start(ctx context.Context,
|
|||
|
||||
if perm {
|
||||
err := s.cfg.db.ShiftState(
|
||||
ctx, sess.ID, session.StateRevoked,
|
||||
ctx, sess.ID,
|
||||
session.StateRevoked,
|
||||
)
|
||||
if err != nil {
|
||||
log.Errorf("error revoking "+
|
||||
|
|
@ -383,9 +384,9 @@ func (s *sessionRpcServer) AddSession(ctx context.Context,
|
|||
// No other types are currently supported.
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid session type, only admin, " +
|
||||
"readonly, custom and account macaroon types supported in " +
|
||||
"LiT. Autopilot sessions must be added using " +
|
||||
"AddAutoPilotSession method")
|
||||
"readonly, custom and account macaroon types " +
|
||||
"supported in LiT. Autopilot sessions must be added " +
|
||||
"using AddAutoPilotSession method")
|
||||
}
|
||||
|
||||
// Collect the de-duped permissions.
|
||||
|
|
@ -651,7 +652,8 @@ func (s *sessionRpcServer) ListSessions(ctx context.Context,
|
|||
// RevokeSession revokes a single session and also stops it if it is currently
|
||||
// active.
|
||||
func (s *sessionRpcServer) RevokeSession(ctx context.Context,
|
||||
req *litrpc.RevokeSessionRequest) (*litrpc.RevokeSessionResponse, error) {
|
||||
req *litrpc.RevokeSessionRequest) (*litrpc.RevokeSessionResponse,
|
||||
error) {
|
||||
|
||||
pubKey, err := btcec.ParsePubKey(req.LocalPublicKey)
|
||||
if err != nil {
|
||||
|
|
@ -1576,6 +1578,7 @@ func (s *sessionRpcServer) marshalRPCSession(ctx context.Context,
|
|||
accountID = hex.EncodeToString(id[:])
|
||||
})
|
||||
|
||||
// nolint:ll
|
||||
return &litrpc.Session{
|
||||
Id: sess.ID[:],
|
||||
Label: sess.Label,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import "github.com/lightningnetwork/lnd/build"
|
|||
// RemoteConfig holds the configuration parameters that are needed when running
|
||||
// LiT in the "remote" lnd mode.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
type RemoteConfig struct {
|
||||
LitLogDir string `long:"lit-logdir" description:"For lnd remote mode only: Directory to log output."`
|
||||
LitMaxLogFiles int `long:"lit-maxlogfiles" description:"For lnd remote mode only: Maximum logfiles to keep (0 for no rotation). DEPRECATED: use --logging.file.max-files instead" hidden:"true"`
|
||||
|
|
@ -25,7 +25,7 @@ type RemoteConfig struct {
|
|||
// RemoteDaemonConfig holds the configuration parameters that are needed to
|
||||
// connect to a remote daemon like lnd for example.
|
||||
//
|
||||
//nolint:lll
|
||||
//nolint:ll
|
||||
type RemoteDaemonConfig struct {
|
||||
// RPCServer is host:port that the remote daemon's RPC server is
|
||||
// listening on.
|
||||
|
|
|
|||
|
|
@ -534,6 +534,7 @@ func (g *LightningTerminal) start(ctx context.Context) error {
|
|||
auxComponents = *components
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
implCfg := &lnd.ImplementationCfg{
|
||||
GrpcRegistrar: g,
|
||||
RestRegistrar: g,
|
||||
|
|
@ -1074,7 +1075,8 @@ func (g *LightningTerminal) startInternalSubServers(ctx context.Context,
|
|||
db: g.stores.sessions,
|
||||
basicAuth: g.rpcProxy.basicAuth,
|
||||
grpcOptions: []grpc.ServerOption{
|
||||
grpc.CustomCodec(grpcProxy.Codec()), // nolint: staticcheck,
|
||||
// nolint:staticcheck,
|
||||
grpc.CustomCodec(grpcProxy.Codec()),
|
||||
grpc.ChainStreamInterceptor(
|
||||
g.rpcProxy.StreamServerInterceptor,
|
||||
),
|
||||
|
|
@ -2060,6 +2062,7 @@ func (g *LightningTerminal) showStartupInfo(ctx context.Context) error {
|
|||
webInterfaceString = "disabled"
|
||||
}
|
||||
|
||||
// nolint:ll
|
||||
str := "" +
|
||||
"----------------------------------------------------------\n" +
|
||||
" Lightning Terminal (LiT) by Lightning Labs \n" +
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ var CommitHash string
|
|||
var Dirty string
|
||||
|
||||
// semanticAlphabet
|
||||
const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-."
|
||||
const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn" +
|
||||
"opqrstuvwxyz-."
|
||||
|
||||
// These constants define the application version and follow the semantic
|
||||
// versioning 2.0.0 spec (http://semver.org/).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue