lnwallet: add TLV blob to PaymentDescriptor + htlc add

In this commit, we add a TLV blob to the PaymentDescriptor struct. We also now thread through this value from the UpdateAddHTLC message to the PaymentDescriptor mapping, and the other way around.
This commit is contained in:
Olaoluwa Osuntokun authored and Oliver Gugger committed 2024-08-28 13:21:12 +02:00
1 parent d95c1f93f3
commit c1e641e9d9
5 files changed
+78 -7

No files matched your search

+13 -1
View File
@@ -529,6 +529,7 @@ func (c *commitment) toDiskCommit(
LogIndex: htlc.LogIndex,
Incoming: false,
BlindingPoint: htlc.BlindingPoint,
CustomRecords: htlc.CustomRecords.Copy(),
}
copy(h.OnionBlob[:], htlc.OnionBlob)
@@ -554,8 +555,10 @@ func (c *commitment) toDiskCommit(
LogIndex: htlc.LogIndex,
Incoming: true,
BlindingPoint: htlc.BlindingPoint,
CustomRecords: htlc.CustomRecords.Copy(),
}
copy(h.OnionBlob[:], htlc.OnionBlob)
if whoseCommit.IsLocal() && htlc.sig != nil {
h.Signature = htlc.sig.Serialize()
}
@@ -653,6 +656,7 @@ func (lc *LightningChannel) diskHtlcToPayDesc(feeRate chainfee.SatPerKWeight,
theirPkScript: theirP2WSH,
theirWitnessScript: theirWitnessScript,
BlindingPoint: htlc.BlindingPoint,
CustomRecords: htlc.CustomRecords.Copy(),
}, nil
}
@@ -5727,6 +5731,9 @@ func (lc *LightningChannel) htlcAddDescriptor(htlc *lnwire.UpdateAddHTLC,
OnionBlob: htlc.OnionBlob[:],
OpenCircuitKey: openKey,
BlindingPoint: htlc.BlindingPoint,
// TODO(guggero): Add custom records from HTLC here once we have
// the custom records in the HTLC struct (later commits in this
// PR).
}
}
@@ -5767,7 +5774,9 @@ func (lc *LightningChannel) validateAddHtlc(pd *PaymentDescriptor,
// ReceiveHTLC adds an HTLC to the state machine's remote update log. This
// method should be called in response to receiving a new HTLC from the remote
// party.
func (lc *LightningChannel) ReceiveHTLC(htlc *lnwire.UpdateAddHTLC) (uint64, error) {
func (lc *LightningChannel) ReceiveHTLC(htlc *lnwire.UpdateAddHTLC) (uint64,
error) {
lc.Lock()
defer lc.Unlock()
@@ -5785,6 +5794,9 @@ func (lc *LightningChannel) ReceiveHTLC(htlc *lnwire.UpdateAddHTLC) (uint64, err
HtlcIndex: lc.remoteUpdateLog.htlcCounter,
OnionBlob: htlc.OnionBlob[:],
BlindingPoint: htlc.BlindingPoint,
// TODO(guggero): Add custom records from HTLC here once we have
// the custom records in the HTLC struct (later commits in this
// PR).
}
localACKedIndex := lc.remoteCommitChain.tail().ourMessageIndex