mirror of
https://github.com/asmogo/nws.git
synced 2025-01-18 18:11:33 +00:00
initialized mint
This commit is contained in:
parent
ba1e856763
commit
f88e30bad4
34
cmd/nws/.env
34
cmd/nws/.env
@ -2,4 +2,36 @@ NOSTR_RELAYS = 'ws://0.0.0.0:7777'#NOSTR_RELAYS = 'ws://localhost:6666'
|
||||
NOSTR_PRIVATE_KEY = ""
|
||||
BACKEND_HOST = 'localhost:3338'
|
||||
PUBLIC = true
|
||||
PUBLIC_ADDRESS = 'localhost:4443'
|
||||
PUBLIC_ADDRESS = 'localhost:4443'
|
||||
|
||||
|
||||
# Bump this number to generate new active keyset and deactivate previous one
|
||||
DERIVATION_PATH_IDX=0
|
||||
# fee to charge per input (in parts per thousand)
|
||||
INPUT_FEE_PPK=100
|
||||
|
||||
# mint info
|
||||
MINT_NAME="a cashu mint"
|
||||
MINT_DESCRIPTION="short mint description"
|
||||
MINT_DESCRIPTION_LONG="a long description of the mint"
|
||||
MINT_CONTACT_INFO=[["email", "contact@me.com"], ["nostr", "npub..."]]
|
||||
MINT_MOTD="message to the users of the mint"
|
||||
MINT_ICON_URL="https://<mint>/icon.jpeg"
|
||||
MINT_URLS=["https://<mint>", "https://<mint2>"]
|
||||
|
||||
# mint limits (these are optional but recommended to use)
|
||||
# max balance (in sats). Minting new ecash will be disabled if this balance is reached
|
||||
MAX_BALANCE=1000000
|
||||
# max mint amount (in sats)
|
||||
MINTING_MAX_AMOUNT=50000
|
||||
# max melt amount (in sats)
|
||||
MELTING_MAX_AMOUNT=50000
|
||||
|
||||
# Lightning Backend - Lnd, FakeBackend (FOR TESTING ONLY)
|
||||
LIGHTNING_BACKEND="Lnd"
|
||||
|
||||
# LND
|
||||
LND_GRPC_HOST="127.0.0.1:10004"
|
||||
LND_CERT_PATH="/Users/xxx/.polar/networks/3/volumes/lnd/dave/tls.cert"
|
||||
LND_MACAROON_PATH="/Users/xxx/.polar/networks/3/volumes/lnd/dave/data/chain/bitcoin/regtest/admin.macaroon"
|
||||
DB_MIGRATIONS="/Users/xxx/go/src/github.com/asmogo/gonuts/mint/storage/sqlite/migrations"
|
23
exit/exit.go
23
exit/exit.go
@ -8,11 +8,12 @@ import (
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/asmogo/gonuts/mint"
|
||||
"github.com/asmogo/nws/config"
|
||||
"github.com/asmogo/nws/netstr"
|
||||
"github.com/asmogo/nws/protocol"
|
||||
"github.com/asmogo/nws/socks5"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
btcec2 "github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/ekzyis/nip44"
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
@ -44,6 +45,7 @@ type Exit struct {
|
||||
incomingChannel chan nostr.IncomingEvent
|
||||
nprofile string
|
||||
publicKey string
|
||||
mint *mint.Mint
|
||||
}
|
||||
|
||||
func New(ctx context.Context, exitNodeConfig *config.ExitConfig) *Exit {
|
||||
@ -69,12 +71,29 @@ func New(ctx context.Context, exitNodeConfig *config.ExitConfig) *Exit {
|
||||
if err := exit.announceExitNode(ctx); err != nil {
|
||||
slog.Error("failed to announce exit node", "error", err)
|
||||
}
|
||||
if err := exit.initializeMint(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
printExitNodeInfo(exit, exitNodeConfig)
|
||||
|
||||
return exit
|
||||
}
|
||||
|
||||
// initializeMint initializes the mint client
|
||||
func (e *Exit) initializeMint() error {
|
||||
mintConfig, err := mint.ConfigFromEnv()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to initialize mint config: %w", err)
|
||||
}
|
||||
cashuMint, err := mint.LoadMint(*mintConfig)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to initialize mint: %w", err)
|
||||
}
|
||||
e.mint = cashuMint
|
||||
return nil
|
||||
}
|
||||
|
||||
func printExitNodeInfo(exit *Exit, exitNodeConfig *config.ExitConfig) {
|
||||
// Set up remaining steps for the exit node
|
||||
domain, err := exit.getDomain()
|
||||
@ -180,7 +199,7 @@ func GetPublicKeyBase32(sk string) (string, error) {
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to decode private key: %w", err)
|
||||
}
|
||||
_, pk := btcec.PrivKeyFromBytes(b)
|
||||
_, pk := btcec2.PrivKeyFromBytes(b)
|
||||
return base32.HexEncoding.WithPadding(base32.NoPadding).EncodeToString(schnorr.SerializePubKey(pk)), nil
|
||||
}
|
||||
|
||||
|
183
go.mod
183
go.mod
@ -1,9 +1,10 @@
|
||||
module github.com/asmogo/nws
|
||||
|
||||
go 1.21.0
|
||||
go 1.23.1
|
||||
|
||||
require (
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2
|
||||
github.com/asmogo/gonuts v0.0.0-20241212202957-c17f5e7e59b2
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.3
|
||||
github.com/caarlos0/env/v11 v11.0.0
|
||||
github.com/ekzyis/nip44 v0.0.0-20240425094820-6a3d864c8f08
|
||||
github.com/google/uuid v1.6.0
|
||||
@ -17,28 +18,192 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
|
||||
dario.cat/mergo v1.0.0 // indirect
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
|
||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
|
||||
github.com/aead/siphash v1.0.1 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/btcsuite/btcd v0.24.2 // indirect
|
||||
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
|
||||
github.com/btcsuite/btcd/btcutil/psbt v1.1.9 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
|
||||
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c // indirect
|
||||
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 // indirect
|
||||
github.com/btcsuite/btcwallet v0.16.10-0.20240718224643-db3a4a2543bd // indirect
|
||||
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.4 // indirect
|
||||
github.com/btcsuite/btcwallet/wallet/txrules v1.2.1 // indirect
|
||||
github.com/btcsuite/btcwallet/wallet/txsizes v1.2.4 // indirect
|
||||
github.com/btcsuite/btcwallet/walletdb v1.4.2 // indirect
|
||||
github.com/btcsuite/btcwallet/wtxmgr v1.5.3 // indirect
|
||||
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
|
||||
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
|
||||
github.com/btcsuite/winsvc v1.0.0 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/containerd/continuity v0.4.2 // indirect
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
|
||||
github.com/decred/dcrd/lru v1.1.2 // indirect
|
||||
github.com/docker/cli v27.3.1+incompatible // indirect
|
||||
github.com/docker/docker v27.3.1+incompatible // indirect
|
||||
github.com/docker/go-connections v0.5.0 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/fergusstrange/embedded-postgres v1.25.0 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||
github.com/go-errors/errors v1.5.1 // indirect
|
||||
github.com/go-logr/logr v1.4.1 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
||||
github.com/gobwas/httphead v0.1.0 // indirect
|
||||
github.com/gobwas/pool v0.2.1 // indirect
|
||||
github.com/gobwas/ws v1.2.0 // indirect
|
||||
github.com/gofrs/uuid v4.2.0+incompatible // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
|
||||
github.com/golang-migrate/migrate/v4 v4.17.1 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/btree v1.0.1 // indirect
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
||||
github.com/gorilla/mux v1.8.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgconn v1.14.3 // indirect
|
||||
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||
github.com/jackc/pgtype v1.14.0 // indirect
|
||||
github.com/jackc/pgx/v4 v4.18.2 // indirect
|
||||
github.com/jackc/pgx/v5 v5.5.4 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||
github.com/jessevdk/go-flags v1.4.0 // indirect
|
||||
github.com/jonboulle/clockwork v0.2.2 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/jrick/logrotate v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/juju/clock v1.1.1 // indirect
|
||||
github.com/juju/errors v1.0.0 // indirect
|
||||
github.com/juju/loggo v1.0.0 // indirect
|
||||
github.com/juju/testing v1.0.2 // indirect
|
||||
github.com/juju/utils/v3 v3.2.0 // indirect
|
||||
github.com/kkdai/bstream v1.0.0 // indirect
|
||||
github.com/lib/pq v1.10.9 // indirect
|
||||
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf // indirect
|
||||
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd // indirect
|
||||
github.com/lightninglabs/neutrino/cache v1.1.2 // indirect
|
||||
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb // indirect
|
||||
github.com/lightningnetwork/lnd v0.18.3-beta.rc3 // indirect
|
||||
github.com/lightningnetwork/lnd/clock v1.1.1 // indirect
|
||||
github.com/lightningnetwork/lnd/fn v1.2.0 // indirect
|
||||
github.com/lightningnetwork/lnd/healthcheck v1.2.5 // indirect
|
||||
github.com/lightningnetwork/lnd/kvdb v1.4.10 // indirect
|
||||
github.com/lightningnetwork/lnd/queue v1.1.1 // indirect
|
||||
github.com/lightningnetwork/lnd/sqldb v1.0.5 // indirect
|
||||
github.com/lightningnetwork/lnd/ticker v1.1.1 // indirect
|
||||
github.com/lightningnetwork/lnd/tlv v1.2.3 // indirect
|
||||
github.com/lightningnetwork/lnd/tor v1.1.3 // indirect
|
||||
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/miekg/dns v1.1.58 // indirect
|
||||
github.com/moby/docker-image-spec v1.3.1 // indirect
|
||||
github.com/moby/term v0.5.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/nbd-wtf/ln-decodepay v1.12.1 // indirect
|
||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.1.0 // indirect
|
||||
github.com/opencontainers/runc v1.1.14 // indirect
|
||||
github.com/ory/dockertest/v3 v3.10.0 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_golang v1.14.0 // indirect
|
||||
github.com/prometheus/client_model v0.3.0 // indirect
|
||||
github.com/prometheus/common v0.37.0 // indirect
|
||||
github.com/prometheus/procfs v0.8.0 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/rogpeppe/fastuuid v1.2.0 // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/soheilhy/cmux v0.1.5 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/stretchr/objx v0.5.2 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
|
||||
github.com/tidwall/gjson v1.14.4 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
|
||||
go.etcd.io/bbolt v1.3.7 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.7 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect
|
||||
go.etcd.io/etcd/client/v2 v2.305.7 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.7 // indirect
|
||||
go.etcd.io/etcd/pkg/v3 v3.5.7 // indirect
|
||||
go.etcd.io/etcd/raft/v3 v3.5.7 // indirect
|
||||
go.etcd.io/etcd/server/v3 v3.5.7 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.0 // indirect
|
||||
go.opentelemetry.io/otel v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
go.uber.org/zap v1.17.0 // indirect
|
||||
golang.org/x/crypto v0.25.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 // indirect
|
||||
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
|
||||
golang.org/x/mod v0.17.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/term v0.22.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
|
||||
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
|
||||
google.golang.org/grpc v1.64.1 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
gopkg.in/errgo.v1 v1.0.1 // indirect
|
||||
gopkg.in/macaroon-bakery.v2 v2.0.1 // indirect
|
||||
gopkg.in/macaroon.v2 v2.1.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
|
||||
modernc.org/libc v1.49.3 // indirect
|
||||
modernc.org/mathutil v1.6.0 // indirect
|
||||
modernc.org/memory v1.8.0 // indirect
|
||||
modernc.org/sqlite v1.29.10 // indirect
|
||||
modernc.org/strutil v1.2.0 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||
)
|
||||
|
||||
replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display
|
||||
|
Loading…
Reference in New Issue
Block a user