diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 515bd21..da0f25f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: CI env: - go-version: "1.22" + go-version: "1.23" # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the main branch @@ -40,7 +40,7 @@ jobs: - name: lint run: | make install - make lint-github-action + make lint build: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 83689ed..b1516be 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ name: Build and Release env: - go-version: "1.22" + go-version: "1.23" on: release: diff --git a/.golangci.yml b/.golangci.yml index 4ba7091..fdb5ae6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,122 +4,6 @@ # This file is not a configuration example, # it contains the exhaustive configuration with explanations of the options. -# Options for analysis running. -run: - # Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously. - # If it is explicitly set to 0 (i.e. not the default) then golangci-lint will automatically set the value to match Linux container CPU quota. - # Default: the number of logical CPUs in the machine - # concurrency: 4 - - # Timeout for analysis, e.g. 30s, 5m. - # Default: 1m - timeout: 5m - - # Exit code when at least one issue was found. - # Default: 1 - # issues-exit-code: 1 - - # Include test files or not. - # Default: true - # tests: true - - # List of build tags, all linters use it. - # Default: [] - # build-tags: - # - mytag - - # If set, we pass it to "go list -mod={option}". From "go help modules": - # If invoked with -mod=readonly, the go command is disallowed from the implicit - # automatic updating of go.mod described above. Instead, it fails when any changes - # to go.mod are needed. This setting is most useful to check that go.mod does - # not need updates, such as in a continuous integration and testing system. - # If invoked with -mod=vendor, the go command assumes that the vendor - # directory holds the correct copies of dependencies and ignores - # the dependency descriptions in go.mod. - # - # Allowed values: readonly|vendor|mod - # Default: "" - modules-download-mode: readonly - - # Allow multiple parallel golangci-lint instances running. - # If false, golangci-lint acquires file lock on start. - # Default: false - # allow-parallel-runners: true - - # Allow multiple golangci-lint instances running, but serialize them around a lock. - # If false, golangci-lint exits with an error if it fails to acquire file lock on start. - # Default: false - # allow-serial-runners: true - - # Define the Go version limit. - # Mainly related to generics support since go1.18. - # Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17 - # go: '1.19' - -# output configuration options -output: - # The formats used to render issues. - # Format: `colored-line-number`, `line-number`, `json`, `colored-tab`, `tab`, `checkstyle`, `code-climate`, `junit-xml`, `github-actions`, `teamcity` - # Output path can be either `stdout`, `stderr` or path to the file to write to. - # - # For the CLI flag (`--out-format`), multiple formats can be specified by separating them by comma. - # The output can be specified for each of them by separating format name and path by colon symbol. - # Example: "--out-format=checkstyle:report.xml,json:stdout,colored-line-number" - # The CLI flag (`--out-format`) override the configuration file. - # - # Default: - # formats: - # - format: colored-line-number - # path: stdout - formats: - # - format: json - # path: stderr - # - format: checkstyle - # path: report.xml - - format: colored-line-number - - # Print lines of code with issue. - # Default: true - # print-issued-lines: false - - # Print linter name in the end of issue text. - # Default: true - # print-linter-name: false - - # Make issues output unique by line. - # Default: true - # uniq-by-line: false - - # Add a prefix to the output file references. - # Default: "" - # path-prefix: "" - - # Sort results by the order defined in `sort-order`. - # Default: false - sort-results: true - - # Order to use when sorting results. - # Require `sort-results` to `true`. - # Possible values: `file`, `linter`, and `severity`. - # - # If the severity values are inside the following list, they are ordered in this order: - # 1. error - # 2. warning - # 3. high - # 4. medium - # 5. low - # Either they are sorted alphabetically. - # - # Default: ["file"] - sort-order: - - linter - - severity - - file # filepath, line, and column. - - # Show statistics per linter. - # Default: false - # show-stats: true - linters: # Disable all linters. # Default: false @@ -131,6 +15,7 @@ linters: # - asciicheck # - bidichk # - bodyclose + - canonicalheader # - containedctx # - contextcheck - copyloopvar @@ -141,6 +26,7 @@ linters: # - dupl # - dupword # - durationcheck + # - err113 # - errcheck # - errchkjson # - errname @@ -149,6 +35,7 @@ linters: # - exhaustive # - exhaustruct # - exportloopref + - fatcontext # - forbidigo # - forcetypeassert # - funlen @@ -164,12 +51,10 @@ linters: # - gocyclo - godot # - godox - # - goerr113 - gofmt - gofumpt # - goheader # - goimports - # - gomnd # - gomoddirectives # - gomodguard # - goprintffuncname @@ -179,7 +64,7 @@ linters: - govet # - grouper - importas - - inamedparam + # - inamedparam - ineffassign # - interfacebloat # - intrange @@ -190,6 +75,7 @@ linters: # - makezero # - mirror - misspell + # - mnd # - musttag - nakedret - nestif @@ -222,11 +108,10 @@ linters: # - testpackage # - thelper # - tparallel - - typecheck # - unconvert # - unparam - unused - # - usestdlibvars + - usestdlibvars # - varnamelen # - wastedassign # - whitespace @@ -244,6 +129,7 @@ linters: # - asciicheck # - bidichk # - bodyclose + # - canonicalheader # - containedctx # - contextcheck # - copyloopvar @@ -254,6 +140,7 @@ linters: # - dupl # - dupword # - durationcheck + # - err113 # - errcheck # - errchkjson # - errname @@ -262,6 +149,7 @@ linters: # - exhaustive # - exhaustruct # - exportloopref + # - fatcontext # - forbidigo # - forcetypeassert # - funlen @@ -277,12 +165,10 @@ linters: # - gocyclo # - godot # - godox - # - goerr113 # - gofmt # - gofumpt # - goheader # - goimports - # - gomnd # - gomoddirectives # - gomodguard # - goprintffuncname @@ -303,6 +189,7 @@ linters: # - makezero # - mirror # - misspell + # - mnd # - musttag # - nakedret # - nestif @@ -335,7 +222,6 @@ linters: # - testpackage # - thelper # - tparallel - # - typecheck # - unconvert # - unparam # - unused @@ -346,6 +232,17 @@ linters: # - wrapcheck # - wsl # - zerologlint + # - deadcode # Deprecated + # - exhaustivestruct # Deprecated + # - golint # Deprecated + # - ifshort # Deprecated + # - interfacer # Deprecated + # - maligned # Deprecated + # - gomnd # Deprecated + # - nosnakecase # Deprecated + # - scopelint # Deprecated + # - structcheck # Deprecated + # - varcheck # Deprecated # Enable presets. # https://golangci-lint.run/usage/linters @@ -369,8 +266,14 @@ linters: # Default: false # fast: true + # All available settings of specific linters. linters-settings: + copyloopvar: + # Check all assigning the loop variable to another variable. + # Default: false + check-alias: true + depguard: # Rules to apply. # @@ -418,16 +321,17 @@ linters-settings: gci: # Section configuration to compare against. # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot > alias`, + # The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`, # If `custom-order` is `true`, it follows the order of `sections` option. # Default: ["standard", "default"] sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. + - standard # Standard section: captures all standard packages. + - default # Default section: contains all imports that could not be matched to another section type. - prefix(github.com/spacemeshos/smcli) # Custom section: groups all imports with the specified Prefix. - # - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. - # - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. - # - alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled. + # - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. + # - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. + # - alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled. + # - localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled. # Skip generated files. # Default: true @@ -438,6 +342,27 @@ linters-settings: # Default: false # custom-order: true + # Drops lexical ordering for custom sections. + # Default: false + # no-lex-order: true + + godot: + # Comments to be checked: `declarations`, `toplevel`, or `all`. + # Default: declarations + # scope: toplevel + # List of regexps for excluding particular comment lines from check. + # Default: [] + exclude: + # Exclude todo and fixme comments. + - "^fixme:" + - "^todo:" + # Check that each sentence ends with a period. + # Default: true + # period: false + # Check that each sentence starts with a capital letter. + # Default: false + # capital: true + gofmt: # Simplify code: gofmt with `-s` option. # Default: true @@ -446,10 +371,10 @@ linters-settings: # https://pkg.go.dev/cmd/gofmt # Default: [] rewrite-rules: - - pattern: "interface{}" - replacement: "any" - - pattern: "a[b:len(a)]" - replacement: "a[b:]" + - pattern: 'interface{}' + replacement: 'any' + - pattern: 'a[b:len(a)]' + replacement: 'a[b:]' gofumpt: # Module path which contains the source code being formatted. @@ -463,39 +388,12 @@ linters-settings: gosimple: # Sxxxx checks in https://staticcheck.io/docs/configuration/options/#checks # Default: ["*"] - checks: ["all"] - - govet: - # Disable all analyzers. - # Default: false - disable-all: false - # Enable analyzers by name. - # (in addition to default: - # appends, asmdecl, assign, atomic, bools, buildtag, cgocall, composites, copylocks, defers, directive, errorsas, - # framepointer, httpresponse, ifaceassert, loopclosure, lostcancel, nilfunc, printf, shift, sigchanyzer, slog, - # stdmethods, stringintconv, structtag, testinggoroutine, tests, timeformat, unmarshal, unreachable, unsafeptr, - # unusedresult - # ). - # Run `GL_DEBUG=govet golangci-lint run --enable=govet` to see default, all available analyzers, and enabled analyzers. - # Default: [] - # enable: - - # Enable all analyzers. - # Default: false - enable-all: false - # Disable analyzers by name. - # (in addition to default - # atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice, - # timeformat, unusedwrite - # ). - # Run `GL_DEBUG=govet golangci-lint run --enable=govet` to see default, all available analyzers, and enabled analyzers. - # Default: [] - # disable: + checks: [ "all" ] importas: # Do not allow unaliased imports of aliased packages. # Default: false - # no-unaliased: true + no-unaliased: true # Do not allow non-required aliases. # Default: false # no-extra-aliases: true @@ -549,11 +447,6 @@ linters-settings: - pkg: "k8s.io/client-go/applyconfigurations/meta/v1" alias: metav1 - inamedparam: - # Skips check for interface methods with only a single parameter. - # Default: false - skip-single-param: false - lll: # Max line length, lines longer will be reported. # '\t' is counted as 1 character by default, and can be changed with the tab-width option. @@ -588,15 +481,10 @@ linters-settings: # Default: "" mode: restricted - nakedret: - # Make an issue if func has more lines of code than this setting, and it has naked returns. - # Default: 30 - max-func-lines: 30 - nestif: # Minimal complexity of if statements to report. # Default: 5 - min-complexity: 5 + min-complexity: 15 perfsprint: # Optimizes even if it requires an int or uint type cast. @@ -638,7 +526,7 @@ linters-settings: # Sets the default failure confidence. # This means that linting errors with less than 0.8 confidence will be ignored. # Default: 0.8 - # confidence: 0.8 + # confidence: 0.1 spancheck: # Checks to enable. @@ -657,11 +545,17 @@ linters-settings: # Default: [] ignore-check-signatures: - "telemetry.RecordError" - + # A list of regexes for additional function signatures that create spans. + # This is useful if you have a utility method to create spans. + # Each entry should be of the form `:`, where `telemetry-type` can be `opentelemetry` or `opencensus`. + # https://github.com/jjti/go-spancheck#extra-start-span-signatures + # Default: [] + # extra-start-span-signatures: + # - "github.com/user/repo/telemetry/trace.Start:opentelemetry" staticcheck: # SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks # Default: ["*"] - checks: ["all"] + checks: [ "all" ] testifylint: # Enable all checkers (https://github.com/Antonboom/testifylint#checkers). @@ -679,13 +573,17 @@ linters-settings: # - error-is-as # - error-nil # - expected-actual - # - go-require # - float-compare + # - formatter + # - go-require # - len + # - negative-positive # - nil-compare # - require-error + # - suite-broken-parallel # - suite-dont-use-pkg # - suite-extra-assert-call + # - suite-subtest-run # - suite-thelper # - useless-assert @@ -695,7 +593,8 @@ linters-settings: # Enable checkers by name # (in addition to default # blank-import, bool-compare, compares, empty, error-is-as, error-nil, expected-actual, go-require, float-compare, - # len, nil-compare, require-error, suite-dont-use-pkg, suite-extra-assert-call, useless-assert + # formatter, len, negative-positive, nil-compare, require-error, suite-broken-parallel, suite-dont-use-pkg, + # suite-extra-assert-call, suite-subtest-run, useless-assert # ). # enable: # - blank-import @@ -705,16 +604,72 @@ linters-settings: # - error-is-as # - error-nil # - expected-actual - # - go-require # - float-compare + # - formatter + # - go-require # - len + # - negative-positive # - nil-compare # - require-error + # - suite-broken-parallel # - suite-dont-use-pkg # - suite-extra-assert-call + # - suite-subtest-run # - suite-thelper # - useless-assert + usestdlibvars: + # Suggest the use of http.MethodXX. + # Default: true + http-method: false + # Suggest the use of http.StatusXX. + # Default: true + http-status-code: false + # Suggest the use of time.Weekday.String(). + # Default: true + time-weekday: true + # Suggest the use of time.Month.String(). + # Default: false + time-month: true + # Suggest the use of time.Layout. + # Default: false + time-layout: true + # Suggest the use of crypto.Hash.String(). + # Default: false + crypto-hash: true + # Suggest the use of rpc.DefaultXXPath. + # Default: false + default-rpc-path: true + # Suggest the use of sql.LevelXX.String(). + # Default: false + sql-isolation-level: true + # Suggest the use of tls.SignatureScheme.String(). + # Default: false + tls-signature-scheme: true + # Suggest the use of constant.Kind.String(). + # Default: false + constant-kind: true + + unused: + # Mark all struct fields that have been written to as used. + # Default: true + field-writes-are-uses: false + # Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write. + # Default: false + # post-statements-are-reads: true + # Mark all exported fields as used. + # default: true + exported-fields-are-used: false + # Mark all function parameters as used. + # default: true + # parameters-are-used: false + # Mark all local variables as used. + # default: true + local-variables-are-used: false + # Mark all identifiers inside generated files as used. + # Default: true + # generated-is-used: false + issues: # List of regexps of issue texts to exclude. # @@ -728,6 +683,36 @@ issues: # Excluding configuration per-path, per-linter, per-text and per-source # exclude-rules: + # # Exclude some linters from running on tests files. + # - path: _test\.go + # linters: + # - gocyclo + # - errcheck + # - dupl + # - gosec + + # # Run some linter only for test files by excluding its issues for everything else. + # - path-except: _test\.go + # linters: + # - forbidigo + + # # Exclude known linters from partially hard-vendored code, + # # which is impossible to exclude via `nolint` comments. + # # `/` will be replaced by current OS file path separator to properly work on Windows. + # - path: internal/hmac/ + # text: "weak cryptographic primitive" + # linters: + # - gosec + + # # Exclude some `staticcheck` messages. + # - linters: + # - staticcheck + # text: "SA9003:" + + # # Exclude `lll` issues for long lines with `go:generate`. + # - linters: + # - lll + # source: "^//go:generate " # Independently of option `exclude` we use default exclude patterns, # it can be disabled by this option. @@ -760,20 +745,21 @@ issues: # If it's not, please let us know. # "/" will be replaced by current OS file path separator to properly work on Windows. # Default: [] - exclude-files: - - "^mock_*\\.go$" + # exclude-files: + # - ".*\\.my\\.go$" + # - lib/bad.go - # To follow strictly the Go generated file convention. + # Mode of the generated files analysis. # - # If set to true, source files that have lines matching only the following regular expression will be excluded: - # `^// Code generated .* DO NOT EDIT\.$` - # This line must appear before the first non-comment, non-blank text in the file. - # https://go.dev/s/generatedcode + # - `strict`: sources are excluded by following strictly the Go generated file convention. + # Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$` + # This line must appear before the first non-comment, non-blank text in the file. + # https://go.dev/s/generatedcode + # - `lax`: sources are excluded if they contain lines `autogenerated file`, `code generated`, `do not edit`, etc. + # - `disable`: disable the generated files exclusion. # - # By default, a lax pattern is applied: - # sources are excluded if they contain lines `autogenerated file`, `code generated`, `do not edit`, etc. - # Default: false - # exclude-generated-strict: true + # Default: lax + # exclude-generated: strict # The list of ids of default excludes to include or disable. # https://golangci-lint.run/usage/false-positives/#default-exclusions @@ -822,14 +808,14 @@ issues: # Default: "" # new-from-patch: path/to/patch/file - # Fix found issues (if it's supported by the linter). - # Default: false - # fix: true - # Show issues in any part of update files (requires new-from-rev or new-from-patch). # Default: false whole-files: true + # Fix found issues (if it's supported by the linter). + # Default: false + # fix: true + severity: # Set the default severity for issues. # @@ -863,3 +849,132 @@ severity: # - linters: # - dupl # severity: info + + # Options for analysis running. +run: + # Timeout for analysis, e.g. 30s, 5m. + # Default: 1m + timeout: 5m + + # Exit code when at least one issue was found. + # Default: 1 + # issues-exit-code: 2 + + # Include test files or not. + # Default: true + # tests: false + + # List of build tags, all linters use it. + # Default: [] + # build-tags: + # - mytag + + # If set, we pass it to "go list -mod={option}". From "go help modules": + # If invoked with -mod=readonly, the go command is disallowed from the implicit + # automatic updating of go.mod described above. Instead, it fails when any changes + # to go.mod are needed. This setting is most useful to check that go.mod does + # not need updates, such as in a continuous integration and testing system. + # If invoked with -mod=vendor, the go command assumes that the vendor + # directory holds the correct copies of dependencies and ignores + # the dependency descriptions in go.mod. + # + # Allowed values: readonly|vendor|mod + # Default: "" + modules-download-mode: readonly + + # Allow multiple parallel golangci-lint instances running. + # If false, golangci-lint acquires file lock on start. + # Default: false + # allow-parallel-runners: true + + # Allow multiple golangci-lint instances running, but serialize them around a lock. + # If false, golangci-lint exits with an error if it fails to acquire file lock on start. + # Default: false + # allow-serial-runners: true + + # Define the Go version limit. + # Mainly related to generics support since go1.18. + # Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17 + # go: '1.19' + + # Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously. + # If it is explicitly set to 0 (i.e. not the default) then golangci-lint will automatically set the value to match Linux container CPU quota. + # Default: the number of logical CPUs in the machine + concurrency: 4 + +# output configuration options +output: + # The formats used to render issues. + # Formats: + # - `colored-line-number` + # - `line-number` + # - `json` + # - `colored-tab` + # - `tab` + # - `html` + # - `checkstyle` + # - `code-climate` + # - `junit-xml` + # - `junit-xml-extended` + # - `github-actions` + # - `teamcity` + # - `sarif` + # Output path can be either `stdout`, `stderr` or path to the file to write to. + # + # For the CLI flag (`--out-format`), multiple formats can be specified by separating them by comma. + # The output can be specified for each of them by separating format name and path by colon symbol. + # Example: "--out-format=checkstyle:report.xml,json:stdout,colored-line-number" + # The CLI flag (`--out-format`) override the configuration file. + # + # Default: + # formats: + # - format: colored-line-number + # path: stdout + formats: + # - format: json + # path: stderr + # - format: checkstyle + # path: report.xml + - format: colored-line-number + + # Print lines of code with issue. + # Default: true + # print-issued-lines: false + + # Print linter name in the end of issue text. + # Default: true + # print-linter-name: false + + # Make issues output unique by line. + # Default: true + # uniq-by-line: false + + # Add a prefix to the output file references. + # Default: "" + # path-prefix: "" + + # Sort results by the order defined in `sort-order`. + # Default: false + sort-results: true + + # Order to use when sorting results. + # Require `sort-results` to `true`. + # Possible values: `file`, `linter`, and `severity`. + # + # If the severity values are inside the following list, they are ordered in this order: + # 1. error + # 2. warning + # 3. high + # 4. medium + # 5. low + # Either they are sorted alphabetically. + # + # Default: ["file"] + sort-order: + - linter + - severity + - file # filepath, line, and column. + + # Show statistics per linter. + # Default: false + # show-stats: true diff --git a/Makefile b/Makefile index 38676a5..923a75a 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ CGO_LDFLAGS := $(LINKLIBS) $(RPATH) STATICLDFLAGS := -L$(UNZIP_DEST) -led25519_bip32 -lspacemesh_remote_wallet EXTRACT = tar -xzf -GOLANGCI_LINT_VERSION := v1.59.0 +GOLANGCI_LINT_VERSION := v1.61.0 GOTESTSUM_VERSION := v1.12.0 # Detect operating system @@ -152,12 +152,5 @@ lint-fix: $(UNZIP_DEST) LD_LIBRARY_PATH=$(REAL_DEST) \ ./bin/golangci-lint run --config .golangci.yml --fix -.PHONY: lint-github-action -lint-github-action: $(UNZIP_DEST) - CGO_CFLAGS="-I$(REAL_DEST)" \ - CGO_LDFLAGS="$(CGO_LDFLAGS)" \ - LD_LIBRARY_PATH=$(REAL_DEST) \ - ./bin/golangci-lint run --config .golangci.yml --out-format=github-actions - clean: rm -rf $(UNZIP_DEST) diff --git a/README.md b/README.md index 0c88b9e..c1fb3cf 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,69 @@ # smcli: Spacemesh Command-line Interface Tool -smcli is a simple command line tool that you can use to manage wallet files (in the future it may be expanded with additional functionality). +smcli is a simple command line tool that you can use to manage wallet files (in the future it may be expanded with +additional functionality). -It currently supports the following features. Note that this documentation is not intended to be as complete as the built-in help documentation in the application itself, which fully documents all commands, flags, and features. Run `smcli -h` to see this documentation. +It currently supports the following features. Note that this documentation is not intended to be as complete as the +built-in help documentation in the application itself, which fully documents all commands, flags, and features. +Run `smcli -h` to see this documentation. ## Wallet -smcli allows you to read encrypted wallet files (including those created using Smapp and other compatible tools), and generate new wallet files. +smcli allows you to read encrypted wallet files (including those created using Smapp and other compatible tools), and +generate new wallet files. ### Reading To read an encrypted wallet file, run: -``` +```console smcli wallet read ``` -You'll be prompted to enter the (optional) password used to encrypt the wallet file. If you enter the correct password, you'll see the contents of the wallet printed, including the accounts it contains. Include the flags `--full` to see full keys, and `--private` to see private keys and mnemonic in addition to public keys. +You'll be prompted to enter the (optional) password used to encrypt the wallet file. If you enter the correct password, +you'll see the contents of the wallet printed, including the accounts it contains. Include the flags `--full` to see +full keys, and `--private` to see private keys and mnemonic in addition to public keys. -Note that you can read both wallet files created using `smcli` as well as those created using [Smapp](https://github.com/spacemeshos/smapp/) or any other tool that supports standard Spacemesh wallet format. +Note that you can read both wallet files created using `smcli` as well as those created using +[Smapp](https://github.com/spacemeshos/smapp/) or any other tool that supports standard Spacemesh wallet format. ### Generation To generate a new wallet, run: -``` +```console smcli wallet create ``` -The command will prompt you to enter a [BIP39-compatible mnemonic](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki), or alternatively generate a new, random mnemonic for you. It will then prompt you to enter a password to encrypt the wallet file (optional but highly recommended) and will then generate an encrypted wallet file with one or more new keypairs. +The command will prompt you to enter a +[BIP39-compatible mnemonic](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki), or alternatively generate +a new, random mnemonic for you. It will then prompt you to enter a password to encrypt the wallet file (optional but +highly recommended) and will then generate an encrypted wallet file with one or more new keypairs. -Note that these keypairs (public and private key) are _not_ the same as Spacemesh wallet addresses. The public key can be converted directly and deterministically into your wallet address; in other words, there is a one-to-one mapping between public keys and wallet addresses. Conversion and outputting of public keys as wallet addresses [will be available shortly](https://github.com/spacemeshos/smcli/issues/38). +Note that these keypairs (public and private key) are _not_ the same as Spacemesh wallet addresses. The public key can +be converted directly and deterministically into your wallet address; in other words, there is a one-to-one mapping +between public keys and wallet addresses. Conversion and outputting of public keys as wallet addresses +[will be available shortly](https://github.com/spacemeshos/smcli/issues/38). #### Hardware wallet support -`smcli` supports key generation using Ledger hardware devices including Nano S, Nano S+, and Nano X. To generate a wallet file using a hardware wallet, first sideload the [Spacemesh Ledger app](https://github.com/spacemeshos/app-spacemesh) onto your device (follow the instructions in that README). Make sure the device is connected and unlocked and the Spacemesh app is open, then run: +`smcli` supports key generation using Ledger hardware devices including Nano S, Nano S+, and Nano X. To generate a +wallet file using a hardware wallet, first sideload the +[Spacemesh Ledger app](https://github.com/spacemeshos/app-spacemesh) onto your device (follow the instructions in that +README). Make sure the device is connected and unlocked and the Spacemesh app is open, then run: -``` +```console smcli wallet create --ledger ``` -Note that the created wallet file will not contain any private keys or mnemonic (as these obviously remain on the Ledger device). If you subsequently use `smcli wallet read` to read the file, these will not be printed. We still recommend encrypting the wallet file with a secure password for privacy purposes. +Note that the created wallet file will not contain any private keys or mnemonic (as these obviously remain on the +Ledger device). If you subsequently use `smcli wallet read` to read the file, these will not be printed. We still +recommend encrypting the wallet file with a secure password for privacy purposes. -**NOTE: We strongly recommend only creating a new wallet on a hardware wallet or on a secure, airgapped computer. You are responsible for safely storing your mnemonic and wallet files. Your mnemonic is the ONLY way to restore access to your wallet and accounts if you misplace the wallet file, so it's essential that you back it up securely and reliably. There is absolutely nothing that we can do to help you recover your wallet if you misplace the file or mnemonic.** +**NOTE: We strongly recommend only creating a new wallet on a hardware wallet or on a secure, airgapped computer. You +are responsible for safely storing your mnemonic and wallet files. Your mnemonic is the ONLY way to restore access to +your wallet and accounts if you misplace the wallet file, so it's essential that you back it up securely and reliably. +There is absolutely nothing that we can do to help you recover your wallet if you misplace the file or mnemonic.** ## Genesis @@ -52,12 +73,18 @@ smcli includes commands to verify the information contained in the genesis ledge To verify the vesting (owner) address and vault address for a particular genesis vesting vault, run: -``` +```console smcli genesis verify ``` -This command will prompt you to enter one or more public keys, along with the multisig params (minimum required signers) and vaulted amount. It will subsequently output the vesting and vault addresses associated with the vault. +This command will prompt you to enter one or more public keys, along with the multisig params (minimum required signers) +and vaulted amount. It will subsequently output the vesting and vault addresses associated with the vault. ## Building -Building the app is fairly straightforward. The only prerequisites are Golang with CGO support, `libudev` on Linux (`sudo apt-get install libudev-dev` on Debian/Ubuntu) and two libraries that will be statically linked into the binary. All of the details are handled in `Makefile` and should work on Linux (AMD64 and ARM64), macOS (Intel and Apple Silicon), and Windows. Simply run `make build`, which should download the correct libraries for your OS and platform. See the [release CI workflow](https://github.com/spacemeshos/smcli/blob/develop/.github/workflows/release.yml) for more details, and feel free to open an issue if you encounter any trouble. +Building the app is fairly straightforward. The only prerequisites are Golang with CGO support, `libudev` on Linux +(`sudo apt-get install libudev-dev` on Debian/Ubuntu) and two libraries that will be statically linked into the binary. +All of the details are handled in `Makefile` and should work on Linux (AMD64 and ARM64), macOS (Intel and Apple +Silicon), and Windows. Simply run `make build`, which should download the correct libraries for your OS and platform. +See the [release CI workflow](https://github.com/spacemeshos/smcli/blob/develop/.github/workflows/release.yml) for more +details, and feel free to open an issue if you encounter any trouble. diff --git a/go.mod b/go.mod index 6c4c0cc..d00a5d7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/spacemeshos/smcli -go 1.22.4 +go 1.23.2 require ( github.com/btcsuite/btcutil v1.0.2 @@ -20,20 +20,31 @@ require ( github.com/c0mm4nd/go-ripemd v0.0.0-20200326052756-bd1759ad7d10 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-llsqlite/crawshaw v0.5.5 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.6.0 // indirect + github.com/hashicorp/go-secure-stdlib/password v0.1.3 github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/klauspost/compress v1.17.9 // indirect github.com/klauspost/cpuid/v2 v2.2.8 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect github.com/minio/sha256-simd v1.0.1 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.20.4 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.59.1 // indirect github.com/prometheus/procfs v0.15.1 // indirect + github.com/rivo/uniseg v0.4.4 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect @@ -42,26 +53,6 @@ require ( github.com/spacemeshos/poet v0.10.4 // indirect github.com/spacemeshos/post v0.12.8 // indirect github.com/spacemeshos/sha256-simd v0.1.0 // indirect - github.com/zeebo/blake3 v0.2.4 // indirect - go.uber.org/mock v0.4.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.27.0 // indirect - golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect - google.golang.org/protobuf v1.34.2 // indirect -) - -require ( - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/hashicorp/go-secure-stdlib/password v0.1.3 - github.com/hashicorp/hcl v1.0.0 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/magiconair/properties v1.8.7 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/rivo/uniseg v0.4.4 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/cobra v1.8.1 @@ -70,10 +61,16 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect github.com/tyler-smith/go-bip39 v1.1.0 github.com/xdg-go/pbkdf2 v1.0.0 + github.com/zeebo/blake3 v0.2.4 // indirect + go.uber.org/mock v0.4.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.27.0 // indirect + golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect golang.org/x/sys v0.25.0 // indirect golang.org/x/term v0.24.0 // indirect golang.org/x/text v0.18.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/wallet/store.go b/wallet/store.go index 9b18421..073d77c 100644 --- a/wallet/store.go +++ b/wallet/store.go @@ -2,6 +2,7 @@ package wallet import ( "bytes" + "crypto" "crypto/aes" "crypto/cipher" "crypto/hmac" @@ -234,7 +235,7 @@ func (k *WalletKey) Export(file io.Writer, w *Wallet) error { Iterations int `json:"iterations"` }{ DKLen: Pbkdf2Dklen, - Hash: "SHA-256", + Hash: crypto.SHA256.String(), Salt: k.salt, Iterations: Pbkdf2Iterations, },