• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 17027244024

17 Aug 2025 11:32PM UTC coverage: 57.287% (-9.5%) from 66.765%
17027244024

Pull #10167

github

web-flow
Merge fcb4f4303 into fb1adfc21
Pull Request #10167: multi: bump Go to 1.24.6

3 of 18 new or added lines in 6 files covered. (16.67%)

28537 existing lines in 457 files now uncovered.

99094 of 172978 relevant lines covered (57.29%)

1.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/lntypes/hash.go
1
package lntypes
2

3
import (
4
        "encoding/hex"
5
        "fmt"
6
)
7

8
// HashSize of array used to store hashes.
9
const HashSize = 32
10

11
// ZeroHash is a predefined hash containing all zeroes.
12
var ZeroHash Hash
13

14
// Hash is used in several of the lightning messages and common structures. It
15
// typically represents a payment hash.
16
type Hash [HashSize]byte
17

18
// String returns the Hash as a hexadecimal string.
19
func (hash Hash) String() string {
3✔
20
        return hex.EncodeToString(hash[:])
3✔
21
}
3✔
22

23
// MakeHash returns a new Hash from a byte slice.  An error is returned if
24
// the number of bytes passed in is not HashSize.
25
func MakeHash(newHash []byte) (Hash, error) {
3✔
26
        nhlen := len(newHash)
3✔
27
        if nhlen != HashSize {
3✔
UNCOV
28
                return Hash{}, fmt.Errorf("invalid hash length of %v, want %v",
×
UNCOV
29
                        nhlen, HashSize)
×
UNCOV
30
        }
×
31

32
        var hash Hash
3✔
33
        copy(hash[:], newHash)
3✔
34

3✔
35
        return hash, nil
3✔
36
}
37

38
// MakeHashFromStr creates a Hash from a hex hash string.
39
func MakeHashFromStr(newHash string) (Hash, error) {
3✔
40
        // Return error if hash string is of incorrect length.
3✔
41
        if len(newHash) != HashSize*2 {
6✔
42
                return Hash{}, fmt.Errorf("invalid hash string length of %v, "+
3✔
43
                        "want %v", len(newHash), HashSize*2)
3✔
44
        }
3✔
45

46
        hash, err := hex.DecodeString(newHash)
3✔
47
        if err != nil {
6✔
48
                return Hash{}, err
3✔
49
        }
3✔
50

51
        return MakeHash(hash)
3✔
52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc