mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-05 20:49:48 +02:00
htlcswitch+lnwallet: fix OnionBlob to 1366 bytes
This commit is contained in:
parent
df3c6b72ab
commit
5deb4c253a
@ -3419,7 +3419,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
|
|||||||
// parse the onion object in order to obtain the
|
// parse the onion object in order to obtain the
|
||||||
// routing information with DecodeHopIterator function
|
// routing information with DecodeHopIterator function
|
||||||
// which process the Sphinx packet.
|
// which process the Sphinx packet.
|
||||||
onionReader := bytes.NewReader(pd.OnionBlob)
|
onionReader := bytes.NewReader(pd.OnionBlob[:])
|
||||||
|
|
||||||
req := hop.DecodeHopIteratorRequest{
|
req := hop.DecodeHopIteratorRequest{
|
||||||
OnionReader: onionReader,
|
OnionReader: onionReader,
|
||||||
@ -3471,7 +3471,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
|
|||||||
// Fetch the onion blob that was included within this processed
|
// Fetch the onion blob that was included within this processed
|
||||||
// payment descriptor.
|
// payment descriptor.
|
||||||
var onionBlob [lnwire.OnionPacketSize]byte
|
var onionBlob [lnwire.OnionPacketSize]byte
|
||||||
copy(onionBlob[:], pd.OnionBlob)
|
copy(onionBlob[:], pd.OnionBlob[:])
|
||||||
|
|
||||||
// Before adding the new htlc to the state machine, parse the
|
// Before adding the new htlc to the state machine, parse the
|
||||||
// onion object in order to obtain the routing information with
|
// onion object in order to obtain the routing information with
|
||||||
|
@ -210,8 +210,7 @@ func PayDescsFromRemoteLogUpdates(chanID lnwire.ShortChannelID, height uint64,
|
|||||||
BlindingPoint: wireMsg.BlindingPoint,
|
BlindingPoint: wireMsg.BlindingPoint,
|
||||||
CustomRecords: wireMsg.CustomRecords.Copy(),
|
CustomRecords: wireMsg.CustomRecords.Copy(),
|
||||||
}
|
}
|
||||||
pd.OnionBlob = make([]byte, len(wireMsg.OnionBlob))
|
pd.OnionBlob = wireMsg.OnionBlob
|
||||||
copy(pd.OnionBlob[:], wireMsg.OnionBlob[:])
|
|
||||||
|
|
||||||
case *lnwire.UpdateFulfillHTLC:
|
case *lnwire.UpdateFulfillHTLC:
|
||||||
pd = PaymentDescriptor{
|
pd = PaymentDescriptor{
|
||||||
@ -532,10 +531,10 @@ func (c *commitment) toDiskCommit(
|
|||||||
HtlcIndex: htlc.HtlcIndex,
|
HtlcIndex: htlc.HtlcIndex,
|
||||||
LogIndex: htlc.LogIndex,
|
LogIndex: htlc.LogIndex,
|
||||||
Incoming: false,
|
Incoming: false,
|
||||||
|
OnionBlob: htlc.OnionBlob,
|
||||||
BlindingPoint: htlc.BlindingPoint,
|
BlindingPoint: htlc.BlindingPoint,
|
||||||
CustomRecords: htlc.CustomRecords.Copy(),
|
CustomRecords: htlc.CustomRecords.Copy(),
|
||||||
}
|
}
|
||||||
copy(h.OnionBlob[:], htlc.OnionBlob)
|
|
||||||
|
|
||||||
if whoseCommit.IsLocal() && htlc.sig != nil {
|
if whoseCommit.IsLocal() && htlc.sig != nil {
|
||||||
h.Signature = htlc.sig.Serialize()
|
h.Signature = htlc.sig.Serialize()
|
||||||
@ -558,11 +557,10 @@ func (c *commitment) toDiskCommit(
|
|||||||
HtlcIndex: htlc.HtlcIndex,
|
HtlcIndex: htlc.HtlcIndex,
|
||||||
LogIndex: htlc.LogIndex,
|
LogIndex: htlc.LogIndex,
|
||||||
Incoming: true,
|
Incoming: true,
|
||||||
|
OnionBlob: htlc.OnionBlob,
|
||||||
BlindingPoint: htlc.BlindingPoint,
|
BlindingPoint: htlc.BlindingPoint,
|
||||||
CustomRecords: htlc.CustomRecords.Copy(),
|
CustomRecords: htlc.CustomRecords.Copy(),
|
||||||
}
|
}
|
||||||
copy(h.OnionBlob[:], htlc.OnionBlob)
|
|
||||||
|
|
||||||
if whoseCommit.IsLocal() && htlc.sig != nil {
|
if whoseCommit.IsLocal() && htlc.sig != nil {
|
||||||
h.Signature = htlc.sig.Serialize()
|
h.Signature = htlc.sig.Serialize()
|
||||||
}
|
}
|
||||||
@ -657,7 +655,7 @@ func (lc *LightningChannel) diskHtlcToPayDesc(feeRate chainfee.SatPerKWeight,
|
|||||||
EntryType: Add,
|
EntryType: Add,
|
||||||
HtlcIndex: htlc.HtlcIndex,
|
HtlcIndex: htlc.HtlcIndex,
|
||||||
LogIndex: htlc.LogIndex,
|
LogIndex: htlc.LogIndex,
|
||||||
OnionBlob: htlc.OnionBlob[:],
|
OnionBlob: htlc.OnionBlob,
|
||||||
localOutputIndex: localOutputIndex,
|
localOutputIndex: localOutputIndex,
|
||||||
remoteOutputIndex: remoteOutputIndex,
|
remoteOutputIndex: remoteOutputIndex,
|
||||||
ourPkScript: ourP2WSH,
|
ourPkScript: ourP2WSH,
|
||||||
@ -1160,11 +1158,10 @@ func (lc *LightningChannel) logUpdateToPayDesc(logUpdate *channeldb.LogUpdate,
|
|||||||
HtlcIndex: wireMsg.ID,
|
HtlcIndex: wireMsg.ID,
|
||||||
LogIndex: logUpdate.LogIndex,
|
LogIndex: logUpdate.LogIndex,
|
||||||
addCommitHeightRemote: commitHeight,
|
addCommitHeightRemote: commitHeight,
|
||||||
|
OnionBlob: wireMsg.OnionBlob,
|
||||||
BlindingPoint: wireMsg.BlindingPoint,
|
BlindingPoint: wireMsg.BlindingPoint,
|
||||||
CustomRecords: wireMsg.CustomRecords.Copy(),
|
CustomRecords: wireMsg.CustomRecords.Copy(),
|
||||||
}
|
}
|
||||||
pd.OnionBlob = make([]byte, len(wireMsg.OnionBlob))
|
|
||||||
copy(pd.OnionBlob[:], wireMsg.OnionBlob[:])
|
|
||||||
|
|
||||||
isDustRemote := HtlcIsDust(
|
isDustRemote := HtlcIsDust(
|
||||||
lc.channelState.ChanType, false, lntypes.Remote,
|
lc.channelState.ChanType, false, lntypes.Remote,
|
||||||
@ -1375,11 +1372,10 @@ func (lc *LightningChannel) remoteLogUpdateToPayDesc(logUpdate *channeldb.LogUpd
|
|||||||
HtlcIndex: wireMsg.ID,
|
HtlcIndex: wireMsg.ID,
|
||||||
LogIndex: logUpdate.LogIndex,
|
LogIndex: logUpdate.LogIndex,
|
||||||
addCommitHeightLocal: commitHeight,
|
addCommitHeightLocal: commitHeight,
|
||||||
|
OnionBlob: wireMsg.OnionBlob,
|
||||||
BlindingPoint: wireMsg.BlindingPoint,
|
BlindingPoint: wireMsg.BlindingPoint,
|
||||||
CustomRecords: wireMsg.CustomRecords.Copy(),
|
CustomRecords: wireMsg.CustomRecords.Copy(),
|
||||||
}
|
}
|
||||||
pd.OnionBlob = make([]byte, len(wireMsg.OnionBlob))
|
|
||||||
copy(pd.OnionBlob, wireMsg.OnionBlob[:])
|
|
||||||
|
|
||||||
// We don't need to generate an htlc script yet. This will be
|
// We don't need to generate an htlc script yet. This will be
|
||||||
// done once we sign our remote commitment.
|
// done once we sign our remote commitment.
|
||||||
@ -3424,10 +3420,10 @@ func (lc *LightningChannel) createCommitDiff(newCommit *commitment,
|
|||||||
Amount: pd.Amount,
|
Amount: pd.Amount,
|
||||||
Expiry: pd.Timeout,
|
Expiry: pd.Timeout,
|
||||||
PaymentHash: pd.RHash,
|
PaymentHash: pd.RHash,
|
||||||
|
OnionBlob: pd.OnionBlob,
|
||||||
BlindingPoint: pd.BlindingPoint,
|
BlindingPoint: pd.BlindingPoint,
|
||||||
CustomRecords: pd.CustomRecords.Copy(),
|
CustomRecords: pd.CustomRecords.Copy(),
|
||||||
}
|
}
|
||||||
copy(htlc.OnionBlob[:], pd.OnionBlob)
|
|
||||||
logUpdate.UpdateMsg = htlc
|
logUpdate.UpdateMsg = htlc
|
||||||
|
|
||||||
// Gather any references for circuits opened by this Add
|
// Gather any references for circuits opened by this Add
|
||||||
@ -3565,10 +3561,10 @@ func (lc *LightningChannel) getUnsignedAckedUpdates() []channeldb.LogUpdate {
|
|||||||
Amount: pd.Amount,
|
Amount: pd.Amount,
|
||||||
Expiry: pd.Timeout,
|
Expiry: pd.Timeout,
|
||||||
PaymentHash: pd.RHash,
|
PaymentHash: pd.RHash,
|
||||||
|
OnionBlob: pd.OnionBlob,
|
||||||
BlindingPoint: pd.BlindingPoint,
|
BlindingPoint: pd.BlindingPoint,
|
||||||
CustomRecords: pd.CustomRecords.Copy(),
|
CustomRecords: pd.CustomRecords.Copy(),
|
||||||
}
|
}
|
||||||
copy(htlc.OnionBlob[:], pd.OnionBlob)
|
|
||||||
logUpdate.UpdateMsg = htlc
|
logUpdate.UpdateMsg = htlc
|
||||||
|
|
||||||
case Settle:
|
case Settle:
|
||||||
@ -5643,10 +5639,10 @@ func (lc *LightningChannel) ReceiveRevocation(revMsg *lnwire.RevokeAndAck) (
|
|||||||
Amount: pd.Amount,
|
Amount: pd.Amount,
|
||||||
Expiry: pd.Timeout,
|
Expiry: pd.Timeout,
|
||||||
PaymentHash: pd.RHash,
|
PaymentHash: pd.RHash,
|
||||||
|
OnionBlob: pd.OnionBlob,
|
||||||
BlindingPoint: pd.BlindingPoint,
|
BlindingPoint: pd.BlindingPoint,
|
||||||
CustomRecords: pd.CustomRecords.Copy(),
|
CustomRecords: pd.CustomRecords.Copy(),
|
||||||
}
|
}
|
||||||
copy(htlc.OnionBlob[:], pd.OnionBlob)
|
|
||||||
logUpdate.UpdateMsg = htlc
|
logUpdate.UpdateMsg = htlc
|
||||||
addUpdates = append(addUpdates, logUpdate)
|
addUpdates = append(addUpdates, logUpdate)
|
||||||
|
|
||||||
@ -5988,7 +5984,7 @@ func (lc *LightningChannel) htlcAddDescriptor(htlc *lnwire.UpdateAddHTLC,
|
|||||||
Amount: htlc.Amount,
|
Amount: htlc.Amount,
|
||||||
LogIndex: lc.updateLogs.Local.logIndex,
|
LogIndex: lc.updateLogs.Local.logIndex,
|
||||||
HtlcIndex: lc.updateLogs.Local.htlcCounter,
|
HtlcIndex: lc.updateLogs.Local.htlcCounter,
|
||||||
OnionBlob: htlc.OnionBlob[:],
|
OnionBlob: htlc.OnionBlob,
|
||||||
OpenCircuitKey: openKey,
|
OpenCircuitKey: openKey,
|
||||||
BlindingPoint: htlc.BlindingPoint,
|
BlindingPoint: htlc.BlindingPoint,
|
||||||
CustomRecords: htlc.CustomRecords.Copy(),
|
CustomRecords: htlc.CustomRecords.Copy(),
|
||||||
@ -6051,7 +6047,7 @@ func (lc *LightningChannel) ReceiveHTLC(htlc *lnwire.UpdateAddHTLC) (uint64,
|
|||||||
Amount: htlc.Amount,
|
Amount: htlc.Amount,
|
||||||
LogIndex: lc.updateLogs.Remote.logIndex,
|
LogIndex: lc.updateLogs.Remote.logIndex,
|
||||||
HtlcIndex: lc.updateLogs.Remote.htlcCounter,
|
HtlcIndex: lc.updateLogs.Remote.htlcCounter,
|
||||||
OnionBlob: htlc.OnionBlob[:],
|
OnionBlob: htlc.OnionBlob,
|
||||||
BlindingPoint: htlc.BlindingPoint,
|
BlindingPoint: htlc.BlindingPoint,
|
||||||
CustomRecords: htlc.CustomRecords.Copy(),
|
CustomRecords: htlc.CustomRecords.Copy(),
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ type PaymentDescriptor struct {
|
|||||||
// routing.
|
// routing.
|
||||||
//
|
//
|
||||||
// NOTE: Populated only on add payment descriptor entry types.
|
// NOTE: Populated only on add payment descriptor entry types.
|
||||||
OnionBlob []byte
|
OnionBlob [lnwire.OnionPacketSize]byte
|
||||||
|
|
||||||
// ShaOnionBlob is a sha of the onion blob.
|
// ShaOnionBlob is a sha of the onion blob.
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user