Skip to content

Commit

Permalink
lnwallet: remove unused function PayDescsFromRemoteLogUpdates
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ProofOfKeags committed Sep 10, 2024
1 parent dc60f78 commit 27ff5f0
Showing 1 changed file with 0 additions and 97 deletions.
97 changes: 0 additions & 97 deletions lnwallet/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,103 +168,6 @@ func (e *ErrCommitSyncLocalDataLoss) Error() string {
// payments requested by the wallet/daemon.
type PaymentHash [32]byte

// PayDescsFromRemoteLogUpdates converts a slice of LogUpdates received from the
// remote peer into PaymentDescriptors to inform a link's forwarding decisions.
//
// NOTE: The provided `logUpdates` MUST correspond exactly to either the Adds
// or SettleFails in this channel's forwarding package at `height`.
func PayDescsFromRemoteLogUpdates(chanID lnwire.ShortChannelID, height uint64,
logUpdates []channeldb.LogUpdate) ([]*PaymentDescriptor, error) {

// Allocate enough space to hold all of the payment descriptors we will
// reconstruct, and also the list of pointers that will be returned to
// the caller.
payDescs := make([]PaymentDescriptor, 0, len(logUpdates))
payDescPtrs := make([]*PaymentDescriptor, 0, len(logUpdates))

// Iterate over the log updates we loaded from disk, and reconstruct the
// payment descriptor corresponding to one of the four types of htlcs we
// can receive from the remote peer. We only repopulate the information
// necessary to process the packets and, if necessary, forward them to
// the switch.
//
// For each log update, we include either an AddRef or a SettleFailRef
// so that they can be ACK'd and garbage collected.
for i, logUpdate := range logUpdates {
var pd PaymentDescriptor
switch wireMsg := logUpdate.UpdateMsg.(type) {

case *lnwire.UpdateAddHTLC:
pd = PaymentDescriptor{
ChanID: wireMsg.ChanID,
RHash: wireMsg.PaymentHash,
Timeout: wireMsg.Expiry,
Amount: wireMsg.Amount,
EntryType: Add,
HtlcIndex: wireMsg.ID,
LogIndex: logUpdate.LogIndex,
SourceRef: &channeldb.AddRef{
Height: height,
Index: uint16(i),
},
BlindingPoint: wireMsg.BlindingPoint,
CustomRecords: wireMsg.CustomRecords.Copy(),
}
pd.OnionBlob = wireMsg.OnionBlob

case *lnwire.UpdateFulfillHTLC:
pd = PaymentDescriptor{
ChanID: wireMsg.ChanID,
RPreimage: wireMsg.PaymentPreimage,
ParentIndex: wireMsg.ID,
EntryType: Settle,
DestRef: &channeldb.SettleFailRef{
Source: chanID,
Height: height,
Index: uint16(i),
},
}

case *lnwire.UpdateFailHTLC:
pd = PaymentDescriptor{
ChanID: wireMsg.ChanID,
ParentIndex: wireMsg.ID,
EntryType: Fail,
FailReason: wireMsg.Reason[:],
DestRef: &channeldb.SettleFailRef{
Source: chanID,
Height: height,
Index: uint16(i),
},
}

case *lnwire.UpdateFailMalformedHTLC:
pd = PaymentDescriptor{
ChanID: wireMsg.ChanID,
ParentIndex: wireMsg.ID,
EntryType: MalformedFail,
FailCode: wireMsg.FailureCode,
ShaOnionBlob: wireMsg.ShaOnionBlob,
DestRef: &channeldb.SettleFailRef{
Source: chanID,
Height: height,
Index: uint16(i),
},
}

// NOTE: UpdateFee is not expected since they are not forwarded.
case *lnwire.UpdateFee:
return nil, fmt.Errorf("unexpected update fee")

}

payDescs = append(payDescs, pd)
payDescPtrs = append(payDescPtrs, &payDescs[i])
}

return payDescPtrs, nil
}

// commitment represents a commitment to a new state within an active channel.
// New commitments can be initiated by either side. Commitments are ordered
// into a commitment chain, with one existing for both parties. Each side can
Expand Down

0 comments on commit 27ff5f0

Please sign in to comment.