Skip to content

Commit 265b342

Browse files
committed
update linter version, add lint exceptions for gosec, update change log
1 parent 86e755e commit 265b342

File tree

9 files changed

+35
-19
lines changed

9 files changed

+35
-19
lines changed

.github/workflows/golangci-lint.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ on:
99
- "master"
1010

1111
env:
12-
GO_VERSION: '1.22' # Use the version you need
13-
GOLANGCI_LINT_VERSION: v1.59 # Latest version as of my last update
12+
GO_VERSION: '1.22'
13+
GOLANGCI_LINT_VERSION: v1.60.1
1414

1515
jobs:
1616
detect-modules:

.golangci.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ linters-settings:
196196
checks:
197197
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
198198
argument,case,condition,operation,return,assign
199-
199+
200200
govet:
201201
# report about shadowed variables
202202
shadow: true
@@ -336,7 +336,7 @@ linters:
336336
- dogsled
337337
# - revive
338338
- prealloc
339-
- exportloopref
339+
- copyloopvar
340340
- exhaustive
341341
- sqlclosecheck
342342
- nolintlint
@@ -398,6 +398,11 @@ issues:
398398
- staticcheck
399399
text: "SA1019:"
400400

401+
# Exclude some gosec messages
402+
- linters:
403+
- gosec
404+
text: "G115:"
405+
401406
# Exclude lll issues for long lines with go:generate
402407
- linters:
403408
- lll

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. The format
55
## Table of Contents
66

77
- [Unreleased](#unreleased)
8+
- [1.1.8 - 2024-09-17](#118---2024-09-17)
89
- [1.1.7 - 2024-09-10](#117---2024-09-10)
910
- [1.1.6 - 2024-09-09](#116---2024-09-09)
1011
- [1.1.5 - 2024-09-06](#115---2024-09-06)
@@ -16,6 +17,17 @@ All notable changes to this project will be documented in this file. The format
1617
- [1.0.0 - 2024-06-06](#100---2024-06-06)
1718

1819

20+
## [1.1.8] - 2024-09-17
21+
### Changed
22+
- Restore Transaction `Clone` to its previous state, and add `ShallowClone` as a more efficient alternative
23+
- Fix the version number bytes in `message`
24+
- Rename `merkleproof.ToHex()` to `Hex()`
25+
- Update golangci-lint version and rules
26+
27+
### Added
28+
- `transaction.ShallowClone`
29+
- `transaction.Hex`
30+
1931
## [1.1.7] - 2024-09-10
2032
- Rework `tx.Clone()` to be more efficient
2133
- Introduce SignUnsigned to sign only inputs that have not already been signed

primitives/hash/hash.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"crypto/sha256"
66
"crypto/sha512"
77

8-
"golang.org/x/crypto/ripemd160"
8+
"golang.org/x/crypto/ripemd160" //nolint:gosec // required
99
)
1010

1111
// Sha256 calculates hash(b) and returns the resulting bytes.
@@ -42,7 +42,7 @@ func Sha512HMAC(b, key []byte) []byte {
4242

4343
// Ripemd160 hashes with RIPEMD160
4444
func Ripemd160(b []byte) []byte {
45-
ripe := ripemd160.New()
45+
ripe := ripemd160.New() //nolint:gosec // required
4646
_, _ = ripe.Write(b[:])
4747
return ripe.Sum(nil)
4848
}

script/interpreter/operations.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"hash"
88
"math/big"
99

10-
"golang.org/x/crypto/ripemd160"
10+
"golang.org/x/crypto/ripemd160" //nolint:gosec // required
1111

1212
ec "github.com/bitcoin-sv/go-sdk/primitives/ec"
1313
crypto "github.com/bitcoin-sv/go-sdk/primitives/hash"
@@ -1869,7 +1869,7 @@ func opcodeRipemd160(op *ParsedOpcode, t *thread) error {
18691869
return err
18701870
}
18711871

1872-
t.dstack.PushByteArray(calcHash(buf, ripemd160.New()))
1872+
t.dstack.PushByteArray(calcHash(buf, ripemd160.New())) //nolint:gosec // required
18731873
return nil
18741874
}
18751875

@@ -1914,7 +1914,7 @@ func opcodeHash160(op *ParsedOpcode, t *thread) error {
19141914
}
19151915

19161916
hash := sha256.Sum256(buf)
1917-
t.dstack.PushByteArray(calcHash(hash[:], ripemd160.New()))
1917+
t.dstack.PushByteArray(calcHash(hash[:], ripemd160.New())) //nolint:gosec // required
19181918
return nil
19191919
}
19201920

transaction/merklepath.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ func (mp *MerklePath) Bytes() []byte {
186186
return bytes
187187
}
188188

189-
// ToHex converts the MerklePath to a hexadecimal string representation
190-
func (mp *MerklePath) ToHex() string {
189+
// Hex converts the MerklePath to a hexadecimal string representation
190+
func (mp *MerklePath) Hex() string {
191191
return hex.EncodeToString(mp.Bytes())
192192
}
193193

transaction/merklepath_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,30 @@ var BRC74JSON = MerklePath{
5555

5656
var BRC74JSONTrimmed = `{"blockHeight":813706,"path":[[{"offset":3048,"hash":"304e737fdfcb017a1a322e78b067ecebb5e07b44f0a36ed1f01264d2014f7711"},{"offset":3049,"hash":"d888711d588021e588984e8278a2decf927298173a06737066e43f3e75534e00","txid":true},{"offset":3050,"hash":"98c9c5dd79a18f40837061d5e0395ffb52e700a2689e641d19f053fc9619445e","txid":true},{"offset":3051,"duplicate":true}],[],[{"offset":763,"duplicate":true}],[{"offset":380,"hash":"858e41febe934b4cbc1cb80a1dc8e254cb1e69acff8e4f91ecdd779bcaefb393"}],[{"offset":191,"duplicate":true}],[{"offset":94,"hash":"f80263e813c644cd71bcc88126d0463df070e28f11023a00543c97b66e828158"}],[{"offset":46,"hash":"f36f792fa2b42acfadfa043a946d4d7b6e5e1e2e0266f2cface575bbb82b7ae0"}],[{"offset":22,"hash":"7d5051f0d4ceb7d2e27a49e448aedca2b3865283ceffe0b00b9c3017faca2081"}],[{"offset":10,"hash":"43aeeb9b6a9e94a5a787fbf04380645e6fd955f8bf0630c24365f492ac592e50"}],[{"offset":4,"hash":"45be5d16ac41430e3589a579ad780e5e42cf515381cc309b48d0f4648f9fcd1c"}],[{"offset":3,"duplicate":true}],[{"offset":0,"hash":"d40cb31af3ef53dd910f5ce15e9a1c20875c009a22d25eab32c11c7ece6487af"}]]}`
5757

58-
func TestMerklePath_ParseHex(t *testing.T) {
58+
func TestMerklePathParseHex(t *testing.T) {
5959
t.Parallel()
6060

6161
t.Run("parses from hex", func(t *testing.T) {
6262
mp, err := NewMerklePathFromHex(BRC74Hex)
6363
require.NoError(t, err)
64-
require.Equal(t, BRC74Hex, mp.ToHex())
64+
require.Equal(t, BRC74Hex, mp.Hex())
6565
})
6666
}
6767

68-
func TestMerklePath_ToHex(t *testing.T) {
68+
func TestMerklePathToHex(t *testing.T) {
6969
// t.Parallel()
7070

7171
t.Run("serializes to hex", func(t *testing.T) {
7272
path := MerklePath{
7373
BlockHeight: BRC74JSON.BlockHeight,
7474
Path: BRC74JSON.Path,
7575
}
76-
hex := path.ToHex()
76+
hex := path.Hex()
7777
require.Equal(t, BRC74Hex, hex)
7878
})
7979
}
8080

81-
func TestMerklePath_ComputeRootHex(t *testing.T) {
81+
func TestMerklePathComputeRootHex(t *testing.T) {
8282
t.Parallel()
8383

8484
t.Run("computes a root", func(t *testing.T) {
@@ -120,7 +120,7 @@ func TestMerklePath_Verify(t *testing.T) {
120120

121121
}
122122

123-
func TestMerklePath_Combine(t *testing.T) {
123+
func TestMerklePathCombine(t *testing.T) {
124124
t.Parallel()
125125

126126
t.Run("combines two paths", func(t *testing.T) {

transaction/transaction_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,6 @@ func TestSignUnsignedNew(t *testing.T) {
185185
require.NoError(t, err)
186186

187187
for _, input := range tx.Inputs {
188-
require.Positive(t, len(input.UnlockingScript.Bytes()))
188+
require.NotEmpty(t, input.UnlockingScript.Bytes())
189189
}
190190
}

util/bytemanipulation_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func TestLittleEndianBytes(t *testing.T) {
5858
}
5959

6060
for _, tc := range testCases {
61-
tc := tc
6261
t.Run(tc.name, func(t *testing.T) {
6362
t.Parallel()
6463
result := util.LittleEndianBytes(tc.input, tc.length)

0 commit comments

Comments
 (0)