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

lightningnetwork / lnd / 12343072627

15 Dec 2024 11:09PM UTC coverage: 57.504% (-1.1%) from 58.636%
12343072627

Pull #9315

github

yyforyongyu
contractcourt: offer outgoing htlc one block earlier before its expiry

We need to offer the outgoing htlc one block earlier to make sure when
the expiry height hits, the sweeper will not miss sweeping it in the
same block. This also means the outgoing contest resolver now only does
one thing - watch for preimage spend till height expiry-1, which can
easily be moved into the timeout resolver instead in the future.
Pull Request #9315: Implement `blockbeat`

1445 of 2007 new or added lines in 26 files covered. (72.0%)

19246 existing lines in 249 files now uncovered.

102342 of 177975 relevant lines covered (57.5%)

24772.24 hits per line

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

63.33
/lnwire/update_fail_malformed_htlc.go
1
package lnwire
2

3
import (
4
        "bytes"
5
        "crypto/sha256"
6
        "io"
7
)
8

9
// UpdateFailMalformedHTLC is sent by either the payment forwarder or by
10
// payment receiver to the payment sender in order to notify it that the onion
11
// blob can't be parsed. For that reason we send this message instead of
12
// obfuscate the onion failure.
13
type UpdateFailMalformedHTLC struct {
14
        // ChanID is the particular active channel that this
15
        // UpdateFailMalformedHTLC is bound to.
16
        ChanID ChannelID
17

18
        // ID references which HTLC on the remote node's commitment transaction
19
        // has timed out.
20
        ID uint64
21

22
        // ShaOnionBlob hash of the onion blob on which can't be parsed by the
23
        // node in the payment path.
24
        ShaOnionBlob [sha256.Size]byte
25

26
        // FailureCode the exact reason why onion blob haven't been parsed.
27
        FailureCode FailCode
28

29
        // ExtraData is the set of data that was appended to this message to
30
        // fill out the full maximum transport message size. These fields can
31
        // be used to specify optional data such as custom TLV fields.
32
        ExtraData ExtraOpaqueData
33
}
34

35
// A compile time check to ensure UpdateFailMalformedHTLC implements the
36
// lnwire.Message interface.
37
var _ Message = (*UpdateFailMalformedHTLC)(nil)
38

39
// Decode deserializes a serialized UpdateFailMalformedHTLC message stored in the passed
40
// io.Reader observing the specified protocol version.
41
//
42
// This is part of the lnwire.Message interface.
43
func (c *UpdateFailMalformedHTLC) Decode(r io.Reader, pver uint32) error {
135✔
44
        return ReadElements(r,
135✔
45
                &c.ChanID,
135✔
46
                &c.ID,
135✔
47
                c.ShaOnionBlob[:],
135✔
48
                &c.FailureCode,
135✔
49
                &c.ExtraData,
135✔
50
        )
135✔
51
}
135✔
52

53
// Encode serializes the target UpdateFailMalformedHTLC into the passed
54
// io.Writer observing the protocol version specified.
55
//
56
// This is part of the lnwire.Message interface.
57
func (c *UpdateFailMalformedHTLC) Encode(w *bytes.Buffer,
58
        pver uint32) error {
118✔
59

118✔
60
        if err := WriteChannelID(w, c.ChanID); err != nil {
118✔
61
                return err
×
62
        }
×
63

64
        if err := WriteUint64(w, c.ID); err != nil {
118✔
65
                return err
×
66
        }
×
67

68
        if err := WriteBytes(w, c.ShaOnionBlob[:]); err != nil {
118✔
69
                return err
×
70
        }
×
71

72
        if err := WriteFailCode(w, c.FailureCode); err != nil {
118✔
73
                return err
×
74
        }
×
75

76
        return WriteBytes(w, c.ExtraData)
118✔
77
}
78

79
// MsgType returns the integer uniquely identifying this message type on the
80
// wire.
81
//
82
// This is part of the lnwire.Message interface.
83
func (c *UpdateFailMalformedHTLC) MsgType() MessageType {
121✔
84
        return MsgUpdateFailMalformedHTLC
121✔
85
}
121✔
86

87
// TargetChanID returns the channel id of the link for which this message is
88
// intended.
89
//
90
// NOTE: Part of peer.LinkUpdater interface.
UNCOV
91
func (c *UpdateFailMalformedHTLC) TargetChanID() ChannelID {
×
UNCOV
92
        return c.ChanID
×
UNCOV
93
}
×
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