diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3f9e052..23db438 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,11 +21,11 @@ jobs: with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v2.1.4 + uses: actions/setup-go@v2.1.5 with: go-version: 1.17 - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2.8.0 + uses: goreleaser/goreleaser-action@v2.8.1 with: distribution: goreleaser version: latest diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8aef391..fd215ce 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -22,7 +22,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Install Go - uses: actions/setup-go@v2.1.4 + uses: actions/setup-go@v2.1.5 with: go-version: ${{ matrix.go-version }} - name: Checkout code diff --git a/.make/go.mk b/.make/go.mk index 8ee8004..d06a368 100644 --- a/.make/go.mk +++ b/.make/go.mk @@ -13,15 +13,21 @@ DARWIN=$(BINARY_NAME)-darwin LINUX=$(BINARY_NAME)-linux WINDOWS=$(BINARY_NAME)-windows.exe +## Define the binary name +TAGS= +ifdef GO_BUILD_TAGS + override TAGS=-tags $(GO_BUILD_TAGS) +endif + .PHONY: test lint vet install generate bench: ## Run all benchmarks in the Go application @echo "running benchmarks..." - @go test -bench=. -benchmem + @go test -bench=. -benchmem $(TAGS) build-go: ## Build the Go application (locally) @echo "building go app..." - @go build -o bin/$(BINARY_NAME) + @go build -o bin/$(BINARY_NAME) $(TAGS) clean-mods: ## Remove all the Go mod cache @echo "cleaning mods..." @@ -29,11 +35,11 @@ clean-mods: ## Remove all the Go mod cache coverage: ## Shows the test coverage @echo "creating coverage report..." - @go test -coverprofile=coverage.out ./... && go tool cover -func=coverage.out + @go test -coverprofile=coverage.out ./... $(TAGS) && go tool cover -func=coverage.out $(TAGS) generate: ## Runs the go generate command in the base of the repo @echo "generating files..." - @go generate -v + @go generate -v $(TAGS) godocs: ## Sync the latest tag with GoDocs @echo "syndicating to GoDocs..." @@ -45,59 +51,59 @@ godocs: ## Sync the latest tag with GoDocs install: ## Install the application @echo "installing binary..." - @go build -o $$GOPATH/bin/$(BINARY_NAME) + @go build -o $$GOPATH/bin/$(BINARY_NAME) $(TAGS) install-go: ## Install the application (Using Native Go) @echo "installing package..." - @go install $(GIT_DOMAIN)/$(REPO_OWNER)/$(REPO_NAME) + @go install $(GIT_DOMAIN)/$(REPO_OWNER)/$(REPO_NAME) $(TAGS) lint: ## Run the golangci-lint application (install if not found) @echo "installing golangci-lint..." @#Travis (has sudo) - @if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.43.0 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi; + @if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.44.0 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi; @#AWS CodePipeline - @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(CODEBUILD_BUILD_ID)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0; fi; + @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(CODEBUILD_BUILD_ID)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.44.0; fi; @#Github Actions - @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(GITHUB_WORKFLOW)" != "" ]; then curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b $(go env GOPATH)/bin v1.43.0; fi; + @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(GITHUB_WORKFLOW)" != "" ]; then curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b $(go env GOPATH)/bin v1.44.0; fi; @#Brew - MacOS @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then brew install golangci-lint; fi; @#MacOS Vanilla - @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- v1.43.0; fi; + @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- v1.44.0; fi; @echo "running golangci-lint..." @golangci-lint run --verbose test: ## Runs lint and ALL tests @$(MAKE) lint @echo "running tests..." - @go test ./... -v + @go test ./... -v $(TAGS) test-unit: ## Runs tests and outputs coverage @echo "running unit tests..." - @go test ./... -race -coverprofile=coverage.txt -covermode=atomic + @go test ./... -race -coverprofile=coverage.txt -covermode=atomic $(TAGS) test-short: ## Runs vet, lint and tests (excludes integration tests) @$(MAKE) lint @echo "running tests (short)..." - @go test ./... -v -test.short + @go test ./... -v -test.short $(TAGS) test-ci: ## Runs all tests via CI (exports coverage) @$(MAKE) lint @echo "running tests (CI)..." - @go test ./... -race -coverprofile=coverage.txt -covermode=atomic + @go test ./... -race -coverprofile=coverage.txt -covermode=atomic $(TAGS) test-ci-no-race: ## Runs all tests via CI (no race) (exports coverage) @$(MAKE) lint @echo "running tests (CI - no race)..." - @go test ./... -coverprofile=coverage.txt -covermode=atomic + @go test ./... -coverprofile=coverage.txt -covermode=atomic $(TAGS) test-ci-short: ## Runs unit tests via CI (exports coverage) @$(MAKE) lint @echo "running tests (CI - unit tests only)..." - @go test ./... -test.short -race -coverprofile=coverage.txt -covermode=atomic + @go test ./... -test.short -race -coverprofile=coverage.txt -covermode=atomic $(TAGS) test-no-lint: ## Runs just tests @echo "running tests..." - @go test ./... -v + @go test ./... -v $(TAGS) uninstall: ## Uninstall the application (and remove files) @echo "uninstalling go application..." @@ -119,4 +125,4 @@ update-linter: ## Update the golangci-lint package (macOS only) vet: ## Run the Go vet application @echo "running go vet..." - @go vet -v ./... + @go vet -v ./... $(TAGS) diff --git a/go.mod b/go.mod index 0a52f98..15d147c 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,7 @@ require ( require ( github.com/bitcoinsv/bsvlog v0.0.0-20181216181007-cb81b076bf2e // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/libsv/go-bk v0.1.5 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b // indirect + golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8 // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) diff --git a/go.sum b/go.sum index ad2cfa0..561041f 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,6 @@ github.com/bitcoinsv/bsvutil v0.0.0-20181216182056-1d77cf353ea9/go.mod h1:p44KuN github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/libsv/go-bk v0.1.5 h1:fqbWy8nwVM/ayM8Nxe+lM7fN0FaUMMD1w5MCpwit7XQ= -github.com/libsv/go-bk v0.1.5/go.mod h1:xbDkeFFpP0uyFaPLnP6TwaLpAsHaslZ0LftTdWlB6HI= github.com/libsv/go-bt v1.0.4 h1:2Css5lfomk/J97tM5Gk56Lp+tTK6xWYnmHNc/fGO6lE= github.com/libsv/go-bt v1.0.4/go.mod h1:AfXoLFYEbY/TvCq/84xTce2xGjPUuC5imokHmcykF2k= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -18,11 +16,9 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b h1:QAqMVf3pSa6eeTsuklijukjXBlj7Es2QQplab+/RbQ4= -golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8 h1:kACShD3qhmr/3rLmg1yXyt+N4HcwutKyPRB93s54TIU= +golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -32,7 +28,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/hd_key.go b/hd_key.go index 2de9c7a..0954d79 100644 --- a/hd_key.go +++ b/hd_key.go @@ -154,7 +154,7 @@ func GetAddressStringFromHDKey(hdKey *hdkeychain.ExtendedKey) (string, error) { } // GetPublicKeysForPath gets the PublicKeys for a given derivation path -// Uses the standard m/0/0 (internal) and m/0/1 (external) paths +// Uses the standard m/0/0 (external) and m/0/1 (internal) paths // Reference: https://en.bitcoin.it/wiki/BIP_0032#The_default_wallet_layout func GetPublicKeysForPath(hdKey *hdkeychain.ExtendedKey, num uint32) (pubKeys []*bsvec.PublicKey, err error) { @@ -164,7 +164,7 @@ func GetPublicKeysForPath(hdKey *hdkeychain.ExtendedKey, num uint32) (pubKeys [] return } - // Get the internal pubkey from m/0/x + // Get the external pubkey from m/0/x var pubKey *bsvec.PublicKey if pubKey, err = childM0x.ECPubKey(); err != nil { // Should never error since the previous method ensures a valid hdKey @@ -179,7 +179,7 @@ func GetPublicKeysForPath(hdKey *hdkeychain.ExtendedKey, num uint32) (pubKeys [] return } - // Get the external pubkey from m/1/x + // Get the internal pubkey from m/1/x if pubKey, err = childM1x.ECPubKey(); err != nil { // Should never error since the previous method ensures a valid hdKey return