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

lightningnetwork / lnd / 17132206455

21 Aug 2025 03:56PM UTC coverage: 54.685% (-2.6%) from 57.321%
17132206455

Pull #10167

github

web-flow
Merge 5dd2ed093 into 0c2f045f5
Pull Request #10167: multi: bump Go to 1.24.6

4 of 31 new or added lines in 10 files covered. (12.9%)

23854 existing lines in 284 files now uncovered.

108937 of 199210 relevant lines covered (54.68%)

22026.48 hits per line

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

79.17
/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 {
350✔
20
        return hex.EncodeToString(hash[:])
350✔
21
}
350✔
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) {
22,870✔
26
        nhlen := len(newHash)
22,870✔
27
        if nhlen != HashSize {
22,872✔
28
                return Hash{}, fmt.Errorf("invalid hash length of %v, want %v",
2✔
29
                        nhlen, HashSize)
2✔
30
        }
2✔
31

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

22,868✔
35
        return hash, nil
22,868✔
36
}
37

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

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

51
        return MakeHash(hash)
37✔
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