Skip to content

Commit 27ff5f0

Browse files
committed
lnwallet: remove unused function PayDescsFromRemoteLogUpdates
This function is no longer used as of the last commit and it is the last remaining leak of the PaymentDescriptor type through the public API.
1 parent dc60f78 commit 27ff5f0

File tree

1 file changed

+0
-97
lines changed

1 file changed

+0
-97
lines changed

lnwallet/channel.go

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -168,103 +168,6 @@ func (e *ErrCommitSyncLocalDataLoss) Error() string {
168168
// payments requested by the wallet/daemon.
169169
type PaymentHash [32]byte
170170

171-
// PayDescsFromRemoteLogUpdates converts a slice of LogUpdates received from the
172-
// remote peer into PaymentDescriptors to inform a link's forwarding decisions.
173-
//
174-
// NOTE: The provided `logUpdates` MUST correspond exactly to either the Adds
175-
// or SettleFails in this channel's forwarding package at `height`.
176-
func PayDescsFromRemoteLogUpdates(chanID lnwire.ShortChannelID, height uint64,
177-
logUpdates []channeldb.LogUpdate) ([]*PaymentDescriptor, error) {
178-
179-
// Allocate enough space to hold all of the payment descriptors we will
180-
// reconstruct, and also the list of pointers that will be returned to
181-
// the caller.
182-
payDescs := make([]PaymentDescriptor, 0, len(logUpdates))
183-
payDescPtrs := make([]*PaymentDescriptor, 0, len(logUpdates))
184-
185-
// Iterate over the log updates we loaded from disk, and reconstruct the
186-
// payment descriptor corresponding to one of the four types of htlcs we
187-
// can receive from the remote peer. We only repopulate the information
188-
// necessary to process the packets and, if necessary, forward them to
189-
// the switch.
190-
//
191-
// For each log update, we include either an AddRef or a SettleFailRef
192-
// so that they can be ACK'd and garbage collected.
193-
for i, logUpdate := range logUpdates {
194-
var pd PaymentDescriptor
195-
switch wireMsg := logUpdate.UpdateMsg.(type) {
196-
197-
case *lnwire.UpdateAddHTLC:
198-
pd = PaymentDescriptor{
199-
ChanID: wireMsg.ChanID,
200-
RHash: wireMsg.PaymentHash,
201-
Timeout: wireMsg.Expiry,
202-
Amount: wireMsg.Amount,
203-
EntryType: Add,
204-
HtlcIndex: wireMsg.ID,
205-
LogIndex: logUpdate.LogIndex,
206-
SourceRef: &channeldb.AddRef{
207-
Height: height,
208-
Index: uint16(i),
209-
},
210-
BlindingPoint: wireMsg.BlindingPoint,
211-
CustomRecords: wireMsg.CustomRecords.Copy(),
212-
}
213-
pd.OnionBlob = wireMsg.OnionBlob
214-
215-
case *lnwire.UpdateFulfillHTLC:
216-
pd = PaymentDescriptor{
217-
ChanID: wireMsg.ChanID,
218-
RPreimage: wireMsg.PaymentPreimage,
219-
ParentIndex: wireMsg.ID,
220-
EntryType: Settle,
221-
DestRef: &channeldb.SettleFailRef{
222-
Source: chanID,
223-
Height: height,
224-
Index: uint16(i),
225-
},
226-
}
227-
228-
case *lnwire.UpdateFailHTLC:
229-
pd = PaymentDescriptor{
230-
ChanID: wireMsg.ChanID,
231-
ParentIndex: wireMsg.ID,
232-
EntryType: Fail,
233-
FailReason: wireMsg.Reason[:],
234-
DestRef: &channeldb.SettleFailRef{
235-
Source: chanID,
236-
Height: height,
237-
Index: uint16(i),
238-
},
239-
}
240-
241-
case *lnwire.UpdateFailMalformedHTLC:
242-
pd = PaymentDescriptor{
243-
ChanID: wireMsg.ChanID,
244-
ParentIndex: wireMsg.ID,
245-
EntryType: MalformedFail,
246-
FailCode: wireMsg.FailureCode,
247-
ShaOnionBlob: wireMsg.ShaOnionBlob,
248-
DestRef: &channeldb.SettleFailRef{
249-
Source: chanID,
250-
Height: height,
251-
Index: uint16(i),
252-
},
253-
}
254-
255-
// NOTE: UpdateFee is not expected since they are not forwarded.
256-
case *lnwire.UpdateFee:
257-
return nil, fmt.Errorf("unexpected update fee")
258-
259-
}
260-
261-
payDescs = append(payDescs, pd)
262-
payDescPtrs = append(payDescPtrs, &payDescs[i])
263-
}
264-
265-
return payDescPtrs, nil
266-
}
267-
268171
// commitment represents a commitment to a new state within an active channel.
269172
// New commitments can be initiated by either side. Commitments are ordered
270173
// into a commitment chain, with one existing for both parties. Each side can

0 commit comments

Comments
 (0)