utils

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LND_HOST             = "LND_GRPC_HOST"
	LND_TLS_CERT         = "LND_TLS_CERT"
	LND_MACAROON         = "LND_MACAROON"
	MINT_LNBITS_ENDPOINT = "MINT_LNBITS_ENDPOINT"
	MINT_LNBITS_KEY      = "MINT_LNBITS_KEY"

	CLN_HOST     = "CLN_GRPC_HOST"
	CLN_TLS_CERT = "CLN_TLS_CERT"
	CLN_MACAROON = "CLN_MACAROON"
)
View Source
const ConfigDirName string = "nutmix"
View Source
const ConfigFileName string = "config.toml"
View Source
const LogExtraInfo string = "extra-info"
View Source
const LogFileName string = "nutmix.log"

Variables

View Source
var (
	MODE_ENV             = "MODE"
	MINT_PRIVATE_KEY_ENV = "MINT_PRIVATE_KEY"
)
View Source
var (
	// AppVersion will be in 0.0.0 format
	AppVersion = "development"

	// BuildTime is the time it built, in RFC3339
	BuildTime = "unknown"

	// GitCommit is the Git commit hash
	GitCommit = "unknown"
)
View Source
var ErrAlreadyLNPaying = errors.New("already paying lightning invoice")

Functions

func CanUseLiquidityManager

func CanUseLiquidityManager(backend LightningBackend) bool

func CreateDirectoryAndPath

func CreateDirectoryAndPath(dirPath string, filename string) error

func ExtractInternalFile

func ExtractInternalFile(ctx context.Context, container testcontainers.Container, path string) (string, error)

func GetAndCalculateProofsValues

func GetAndCalculateProofsValues(proofs *cashu.Proofs) (uint64, []cashu.WrappedPublicKey, error)

Sets some values being used by the mint like seen, secretY, seen, and pending state

func GetLogsDirectory

func GetLogsDirectory() (string, error)

func GetMessagesForChange

func GetMessagesForChange(overpaidFees uint64, outputs []cashu.BlindedMessage) []cashu.BlindedMessage

func ParseErrorToCashuErrorCode

func ParseErrorToCashuErrorCode(proofError error) (cashu.ErrorCode, *string)

func RandomHash

func RandomHash() (string, error)

func ReadDataFromReader

func ReadDataFromReader(reader io.Reader) (string, error)

func SetUpLightingNetworkTestEnviroment

This is used for testing purpose returns alice, bob, btcNode, aliceLnBits, error

Types

type Config

type Config struct {
	PEG_OUT_LIMIT_SATS              *int             `db:"peg_out_limit_sats,omitempty"`
	IconUrl                         *string          `db:"icon_url,omitempty"`
	TosUrl                          *string          `db:"tos_url,omitempty"`
	PEG_IN_LIMIT_SATS               *int             `db:"peg_in_limit_sats,omitempty"`
	NETWORK                         string           `db:"network"`
	CLN_CLIENT_CERT                 string           `db:"cln_client_cert"`
	EMAIL                           string           `db:"email"`
	NOSTR                           string           `db:"nostr"`
	NAME                            string           `db:"name"`
	MINT_LIGHTNING_BACKEND          LightningBackend `db:"mint_lightning_backend"`
	LND_GRPC_HOST                   string           `db:"lnd_grpc_host"`
	LND_TLS_CERT                    string           `db:"lnd_tls_cert"`
	LND_MACAROON                    string           `db:"lnd_macaroon"`
	MINT_LNBITS_ENDPOINT            string           `db:"mint_lnbits_endpoint"`
	MINT_LNBITS_KEY                 string           `db:"mint_lnbits_key"`
	CLN_GRPC_HOST                   string           `db:"cln_grpc_host"`
	CLN_CA_CERT                     string           `db:"cln_ca_cert"`
	MOTD                            string           `db:"motd"`
	CLN_CLIENT_KEY                  string           `db:"cln_client_key"`
	CLN_MACAROON                    string           `db:"cln_macaroon"`
	STRIKE_KEY                      string           `db:"strike_key"`
	STRIKE_ENDPOINT                 string           `db:"strike_endpoint"`
	MINT_AUTH_OICD_CLIENT_ID        string           `db:"mint_auth_oicd_client_id,omitempty"`
	DESCRIPTION_LONG                string           `db:"description_long"`
	DESCRIPTION                     string           `db:"description"`
	MINT_AUTH_OICD_URL              string           `db:"mint_auth_oicd_url,omitempty"`
	MINT_AUTH_CLEAR_AUTH_URLS       []string         `db:"mint_auth_clear_auth_urls,omitempty"`
	MINT_AUTH_BLIND_AUTH_URLS       []string         `db:"mint_auth_blind_auth_urls,omitempty"`
	MINT_AUTH_RATE_LIMIT_PER_MINUTE int              `db:"mint_auth_rate_limit_per_minute,omitempty"`
	MINT_AUTH_MAX_BLIND_TOKENS      uint64           `db:"mint_auth_max_blind_tokens,omitempty"`
	MINT_REQUIRE_AUTH               bool             `db:"mint_require_auth,omitempty"`
	PEG_OUT_ONLY                    bool             `db:"peg_out_only"`
}

func (*Config) Default

func (c *Config) Default()

func (*Config) UseEnviromentVars

func (c *Config) UseEnviromentVars()

type LightningBackend

type LightningBackend string
const CLNGRPC LightningBackend = "ClnGrpcWallet"
const FAKE_WALLET LightningBackend = "FakeWallet"
const LNBITS LightningBackend = "LNbitsWallet"
const LNDGRPC LightningBackend = "LndGrpcWallet"
const Strike LightningBackend = "Strike"

func StringToLightningBackend

func StringToLightningBackend(text string) LightningBackend

type LiquiditySwap

type LiquiditySwap struct {
	Id               string    `json:"id"`
	LightningInvoice string    `db:"lightning_invoice"`
	CheckingId       string    `db:"checking_id"`
	State            SwapState `json:"state"`
	Type             SwapType  `json:"type"`
	Amount           uint64    `json:"amount"`
	Expiration       uint64    `json:"expiration"`
}

type SlogRecordJSON

type SlogRecordJSON struct {
	Time      time.Time
	Extras    map[string]any `json:"-"`
	Msg       string
	ExtraInfo string `json:"extra-info"`
	Level     slog.Level
}

func ParseLogFileByLevelAndTime

func ParseLogFileByLevelAndTime(file *os.File, wantedLevel []slog.Level, limitTime time.Time) []SlogRecordJSON

ParseLogFileByLevelAndTime parses the provided log file line-by-line assuming the file is in ascending time order (oldest logs first). It skips lines until it finds the first log with Time >= limitTime, then collects all subsequent records whose Level is in wantedLevel.

type SwapState

type SwapState string
const Expired SwapState = "Expired"
const Finished SwapState = "Finished"
const LightningPaymentExpired SwapState = "LightningPaymentExpired"
const LightningPaymentFail SwapState = "LightningPaymentFail"
const LightningPaymentPending SwapState = "LightningPaymentPending"
const MintWaitingPaymentRecv SwapState = "MintWaitingPaymentRecv"
const UnknownProblem SwapState = "UnknownProblem"
const WaitingUserConfirmation SwapState = "WaitingUserConfirmation"

func (SwapState) ToString

func (s SwapState) ToString() string

type SwapType

type SwapType string
const LiquidityIn SwapType = "LiquidityIn"
const LiquidityOut SwapType = "LiquidityOut"

func (SwapType) ToString

func (s SwapType) ToString() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL