Skip to content
This repository was archived by the owner on Feb 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode/
.idea/
*.DS_Store
*.dat
Expand All @@ -14,4 +15,9 @@ localconfig*
worker/worker
vultisigner
cmd/payroll/server/server
cmd/dca/server/server
cmd/dca/server/server

tmp/
test/vaults/*
.air.*.toml
fee_config.json
2 changes: 1 addition & 1 deletion Dockerfile.postgres
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Use a specific version if you prefer, e.g. postgres:15
FROM postgres:latest
FROM postgres:17

COPY init-scripts/ /docker-entrypoint-initdb.d/
18 changes: 1 addition & 17 deletions api/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func (s *Server) GetPluginPolicyTransactionHistory(c echo.Context) error {
}

func (s *Server) verifyPolicySignature(policy vtypes.PluginPolicy) bool {
msgBytes, err := policyToMessageHex(policy)
msgBytes, err := common.PolicyToMessageHex(policy)
if err != nil {
s.logger.WithError(err).Error("Failed to convert policy to message hex")
return false
Expand Down Expand Up @@ -369,22 +369,6 @@ func (s *Server) getVault(publicKeyECDSA, pluginId string) (*v1.Vault, error) {
return v, nil
}

func policyToMessageHex(policy vtypes.PluginPolicy) ([]byte, error) {
delimiter := "*#*"
fields := []string{
policy.Recipe,
policy.PublicKey,
fmt.Sprintf("%d", policy.PolicyVersion),
policy.PluginVersion}
for _, item := range fields {
if strings.Contains(item, delimiter) {
return nil, fmt.Errorf("invalid policy signature")
}
}
result := strings.Join(fields, delimiter)
return []byte(result), nil
}

func calculateTransactionHash(txData string) (string, error) {
tx := &gtypes.Transaction{}
rawTx, err := hex.DecodeString(txData)
Expand Down
2 changes: 2 additions & 0 deletions api/server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ type ServerConfig struct {
Host string `mapstructure:"host" json:"host,omitempty"`
Port int64 `mapstructure:"port" json:"port,omitempty"`
EncryptionSecret string `mapstructure:"encryption_secret" json:"encryption_secret,omitempty"`
VerifierUrl string `mapstructure:"verifier_url" json:"verifier_url,omitempty"` //The url of the verifier (i.e. the counter party to sign transactions).
VaultsFilePath string `mapstructure:"vaults_file_path" json:"vaults_file_path,omitempty"` //This is just for testing locally

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create an issue to remove this once s3 testing buckets are available?

}
53 changes: 53 additions & 0 deletions cmd/fees/server/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package main

import (
"fmt"
"os"

"github.com/spf13/viper"
"github.com/vultisig/verifier/vault_config"

"github.com/vultisig/plugin/api"
"github.com/vultisig/plugin/storage"
)

type CoreConfig struct {
Server api.ServerConfig `mapstructure:"server" json:"server"`
Database struct {
DSN string `mapstructure:"dsn" json:"dsn,omitempty"`
} `mapstructure:"database" json:"database,omitempty"`
BaseConfigPath string `mapstructure:"base_config_path" json:"base_config_path,omitempty"`
Redis storage.RedisConfig `mapstructure:"redis" json:"redis,omitempty"`
BlockStorage vault_config.BlockStorageConfig `mapstructure:"block_storage" json:"block_storage,omitempty"`
Datadog struct {
Host string `mapstructure:"host" json:"host,omitempty"`
Port string `mapstructure:"port" json:"port,omitempty"`
} `mapstructure:"datadog" json:"datadog"`
}

func GetConfigure() (*CoreConfig, error) {
configName := os.Getenv("VS_CONFIG_NAME")
if configName == "" {
configName = "config"
}

return ReadConfig(configName)
}

func ReadConfig(configName string) (*CoreConfig, error) {
viper.SetConfigName(configName)
viper.AddConfigPath(".")
viper.AutomaticEnv()

viper.SetDefault("Server.VaultsFilePath", "vaults")

if err := viper.ReadInConfig(); err != nil {
return nil, fmt.Errorf("fail to reading config file, %w", err)
}
var cfg CoreConfig
err := viper.Unmarshal(&cfg)
if err != nil {
return nil, fmt.Errorf("unable to decode into struct, %w", err)
}
return &cfg, nil
}
102 changes: 102 additions & 0 deletions cmd/fees/server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package main

import (
"context"
"fmt"
"net"

"github.com/DataDog/datadog-go/statsd"
"github.com/hibiken/asynq"
"github.com/sirupsen/logrus"
"github.com/vultisig/verifier/tx_indexer"
tx_indexer_storage "github.com/vultisig/verifier/tx_indexer/pkg/storage"
"github.com/vultisig/verifier/vault"

"github.com/vultisig/plugin/api"
"github.com/vultisig/plugin/plugin/fees"
"github.com/vultisig/plugin/storage"
"github.com/vultisig/plugin/storage/postgres"
)

func main() {
ctx := context.Background()

cfg, err := GetConfigure()
if err != nil {
panic(err)
}

logger := logrus.New()
sdClient, err := statsd.New(net.JoinHostPort(cfg.Datadog.Host, cfg.Datadog.Port))
if err != nil {
panic(err)
}
redisStorage, err := storage.NewRedisStorage(cfg.Redis)
if err != nil {
panic(err)
}
redisOptions := asynq.RedisClientOpt{
Addr: net.JoinHostPort(cfg.Redis.Host, cfg.Redis.Port),
Username: cfg.Redis.User,
Password: cfg.Redis.Password,
DB: cfg.Redis.DB,
}

client := asynq.NewClient(redisOptions)
defer func() {
if err := client.Close(); err != nil {
fmt.Println("fail to close asynq client,", err)
}
}()

inspector := asynq.NewInspector(redisOptions)

vaultStorage, err := vault.NewBlockStorageImp(cfg.BlockStorage)
if err != nil {
panic(err)
}

txIndexerStore, err := tx_indexer_storage.NewPostgresTxIndexStore(ctx, cfg.Database.DSN)
if err != nil {
panic(fmt.Errorf("tx_indexer_storage.NewPostgresTxIndexStore: %w", err))
}

_ = tx_indexer.NewService(
logger,
txIndexerStore,
tx_indexer.Chains(),
)

db, err := postgres.NewPostgresBackend(cfg.Database.DSN, nil)
if err != nil {
logger.Fatalf("Failed to connect to database: %v", err)
}

//base config path
feesConfig, err := fees.NewFeeConfig(
fees.WithVerifierUrl(cfg.Server.VerifierUrl),
)

if err != nil {
logger.Fatalf("failed to create fees config,err: %s", err)
}

feePlugin, err := fees.NewFeePlugin(db, logger, cfg.BaseConfigPath, feesConfig)
if err != nil {
logger.Fatalf("failed to create DCA plugin,err: %s", err)
}
server := api.NewServer(
cfg.Server,
db,
redisStorage,
vaultStorage,
redisOptions,
client,
inspector,
sdClient,
feePlugin,
)
if err := server.StartServer(); err != nil {
panic(err)
}
}
52 changes: 52 additions & 0 deletions cmd/fees/worker/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package main

import (
"fmt"
"os"

"github.com/spf13/viper"
"github.com/vultisig/verifier/vault_config"

"github.com/vultisig/plugin/api"
"github.com/vultisig/plugin/storage"
)

type CoreConfig struct {
Server api.ServerConfig `mapstructure:"server" json:"server"`
Database struct {
DSN string `mapstructure:"dsn" json:"dsn,omitempty"`
} `mapstructure:"database" json:"database,omitempty"`
BaseConfigPath string `mapstructure:"base_config_path" json:"base_config_path,omitempty"`
Redis storage.RedisConfig `mapstructure:"redis" json:"redis,omitempty"`
BlockStorage vault_config.BlockStorageConfig `mapstructure:"block_storage" json:"block_storage,omitempty"`
VaultServiceConfig vault_config.Config `mapstructure:"vault_service" json:"vault_service,omitempty"`
Datadog struct {
Host string `mapstructure:"host" json:"host,omitempty"`
Port string `mapstructure:"port" json:"port,omitempty"`
} `mapstructure:"datadog" json:"datadog"`
}

func GetConfigure() (*CoreConfig, error) {
configName := os.Getenv("VS_CONFIG_NAME")
if configName == "" {
configName = "config"
}

return ReadConfig(configName)
}

func ReadConfig(configName string) (*CoreConfig, error) {
viper.SetConfigName(configName)
viper.AddConfigPath(".")
viper.AutomaticEnv()

if err := viper.ReadInConfig(); err != nil {
return nil, fmt.Errorf("fail to reading config file, %w", err)
}
var cfg CoreConfig
err := viper.Unmarshal(&cfg)
if err != nil {
return nil, fmt.Errorf("unable to decode into struct, %w", err)
}
return &cfg, nil
}
Loading