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