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

lightningnetwork / lnd / 15205630088

23 May 2025 08:14AM UTC coverage: 57.45% (-11.5%) from 68.996%
15205630088

Pull #9784

github

web-flow
Merge f8b9f36a3 into c52a6ddeb
Pull Request #9784: [wip] lnwallet+walletrpc: add SubmitPackage and related RPC call

47 of 96 new or added lines in 5 files covered. (48.96%)

30087 existing lines in 459 files now uncovered.

95586 of 166380 relevant lines covered (57.45%)

0.61 hits per line

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

58.18
/lnwire/update_fulfill_htlc.go
1
package lnwire
2

3
import (
4
        "bytes"
5
        "io"
6
)
7

8
// UpdateFulfillHTLC is sent by Alice to Bob when she wishes to settle a
9
// particular HTLC referenced by its HTLCKey within a specific active channel
10
// referenced by ChannelPoint.  A subsequent CommitSig message will be sent by
11
// Alice to "lock-in" the removal of the specified HTLC, possible containing a
12
// batch signature covering several settled HTLC's.
13
type UpdateFulfillHTLC struct {
14
        // ChanID references an active channel which holds the HTLC to be
15
        // settled.
16
        ChanID ChannelID
17

18
        // ID denotes the exact HTLC stage within the receiving node's
19
        // commitment transaction to be removed.
20
        ID uint64
21

22
        // PaymentPreimage is the R-value preimage required to fully settle an
23
        // HTLC.
24
        PaymentPreimage [32]byte
25

26
        // CustomRecords maps TLV types to byte slices, storing arbitrary data
27
        // intended for inclusion in the ExtraData field.
28
        CustomRecords CustomRecords
29

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

36
// NewUpdateFulfillHTLC returns a new empty UpdateFulfillHTLC.
37
func NewUpdateFulfillHTLC(chanID ChannelID, id uint64,
38
        preimage [32]byte) *UpdateFulfillHTLC {
×
39

×
40
        return &UpdateFulfillHTLC{
×
41
                ChanID:          chanID,
×
42
                ID:              id,
×
43
                PaymentPreimage: preimage,
×
44
        }
×
45
}
×
46

47
// A compile time check to ensure UpdateFulfillHTLC implements the
48
// lnwire.Message interface.
49
var _ Message = (*UpdateFulfillHTLC)(nil)
50

51
// A compile time check to ensure UpdateFulfillHTLC implements the
52
// lnwire.SizeableMessage interface.
53
var _ SizeableMessage = (*UpdateFulfillHTLC)(nil)
54

55
// Decode deserializes a serialized UpdateFulfillHTLC message stored in the
56
// passed io.Reader observing the specified protocol version.
57
//
58
// This is part of the lnwire.Message interface.
59
func (c *UpdateFulfillHTLC) Decode(r io.Reader, pver uint32) error {
1✔
60
        // msgExtraData is a temporary variable used to read the message extra
1✔
61
        // data field from the reader.
1✔
62
        var msgExtraData ExtraOpaqueData
1✔
63

1✔
64
        if err := ReadElements(r,
1✔
65
                &c.ChanID,
1✔
66
                &c.ID,
1✔
67
                c.PaymentPreimage[:],
1✔
68
                &msgExtraData,
1✔
69
        ); err != nil {
1✔
UNCOV
70
                return err
×
UNCOV
71
        }
×
72

73
        // Extract custom records from the extra data field.
74
        customRecords, _, extraData, err := ParseAndExtractCustomRecords(
1✔
75
                msgExtraData,
1✔
76
        )
1✔
77
        if err != nil {
1✔
UNCOV
78
                return err
×
UNCOV
79
        }
×
80

81
        c.CustomRecords = customRecords
1✔
82
        c.ExtraData = extraData
1✔
83

1✔
84
        return nil
1✔
85
}
86

87
// Encode serializes the target UpdateFulfillHTLC into the passed io.Writer
88
// observing the protocol version specified.
89
//
90
// This is part of the lnwire.Message interface.
91
func (c *UpdateFulfillHTLC) Encode(w *bytes.Buffer, pver uint32) error {
1✔
92
        if err := WriteChannelID(w, c.ChanID); err != nil {
1✔
93
                return err
×
94
        }
×
95

96
        if err := WriteUint64(w, c.ID); err != nil {
1✔
97
                return err
×
98
        }
×
99

100
        if err := WriteBytes(w, c.PaymentPreimage[:]); err != nil {
1✔
101
                return err
×
102
        }
×
103

104
        // Combine the custom records and the extra data, then encode the
105
        // result as a byte slice.
106
        extraData, err := MergeAndEncode(nil, c.ExtraData, c.CustomRecords)
1✔
107
        if err != nil {
1✔
108
                return err
×
109
        }
×
110

111
        return WriteBytes(w, extraData)
1✔
112
}
113

114
// MsgType returns the integer uniquely identifying this message type on the
115
// wire.
116
//
117
// This is part of the lnwire.Message interface.
118
func (c *UpdateFulfillHTLC) MsgType() MessageType {
1✔
119
        return MsgUpdateFulfillHTLC
1✔
120
}
1✔
121

122
// SerializedSize returns the serialized size of the message in bytes.
123
//
124
// This is part of the lnwire.SizeableMessage interface.
125
func (c *UpdateFulfillHTLC) SerializedSize() (uint32, error) {
×
126
        return MessageSerializedSize(c)
×
127
}
×
128

129
// TargetChanID returns the channel id of the link for which this message is
130
// intended.
131
//
132
// NOTE: Part of peer.LinkUpdater interface.
133
func (c *UpdateFulfillHTLC) TargetChanID() ChannelID {
1✔
134
        return c.ChanID
1✔
135
}
1✔
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