From 115bad5c5ca7f61cda96532f89e11737ec33c8d6 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 22 Jul 2024 19:30:53 -0700 Subject: [PATCH 1/2] build: update to latest TLV version --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 62c5b14a6d0..88741ad8d75 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,7 @@ require ( github.com/lightningnetwork/lnd/queue v1.1.1 github.com/lightningnetwork/lnd/sqldb v1.0.2 github.com/lightningnetwork/lnd/ticker v1.1.1 - github.com/lightningnetwork/lnd/tlv v1.2.5 + github.com/lightningnetwork/lnd/tlv v1.2.6 github.com/lightningnetwork/lnd/tor v1.1.2 github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 github.com/miekg/dns v1.1.43 diff --git a/go.sum b/go.sum index d792bcc911e..09e515c0689 100644 --- a/go.sum +++ b/go.sum @@ -460,8 +460,8 @@ github.com/lightningnetwork/lnd/sqldb v1.0.2 h1:PfuYzScYMD9/QonKo/QvgsbXfTnH5Dfl github.com/lightningnetwork/lnd/sqldb v1.0.2/go.mod h1:V2Xl6JNWLTKE97WJnwfs0d0TYJdIQTqK8/3aAwkd3qI= github.com/lightningnetwork/lnd/ticker v1.1.1 h1:J/b6N2hibFtC7JLV77ULQp++QLtCwT6ijJlbdiZFbSM= github.com/lightningnetwork/lnd/ticker v1.1.1/go.mod h1:waPTRAAcwtu7Ji3+3k+u/xH5GHovTsCoSVpho0KDvdA= -github.com/lightningnetwork/lnd/tlv v1.2.5 h1:/VsoWw628t78OiDN90pHDbqwOcuZ9JMicxXZVQjBwX0= -github.com/lightningnetwork/lnd/tlv v1.2.5/go.mod h1:/CmY4VbItpOldksocmGT4lxiJqRP9oLxwSZOda2kzNQ= +github.com/lightningnetwork/lnd/tlv v1.2.6 h1:icvQG2yDr6k3ZuZzfRdG3EJp6pHurcuh3R6dg0gv/Mw= +github.com/lightningnetwork/lnd/tlv v1.2.6/go.mod h1:/CmY4VbItpOldksocmGT4lxiJqRP9oLxwSZOda2kzNQ= github.com/lightningnetwork/lnd/tor v1.1.2 h1:3zv9z/EivNFaMF89v3ciBjCS7kvCj4ZFG7XvD2Qq0/k= github.com/lightningnetwork/lnd/tor v1.1.2/go.mod h1:j7T9uJ2NLMaHwE7GiBGnpYLn4f7NRoTM6qj+ul6/ycA= github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 h1:sjOGyegMIhvgfq5oaue6Td+hxZuf3tDC8lAPrFldqFw= From 6a8da1cd80b7aeaa22c3ca1e6f47f201a8ca3557 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 22 Jul 2024 19:14:57 -0700 Subject: [PATCH 2/2] lnwallet: store aux sig in custom data within the HTLC We can use this space as we'll properly encode the blinded paths data along with our custom fields before we go to write the HTLCs to the wire. --- lnwallet/aux_signer.go | 4 ++++ lnwallet/channel.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/lnwallet/aux_signer.go b/lnwallet/aux_signer.go index ef7133bd437..a2a4aa2e7cf 100644 --- a/lnwallet/aux_signer.go +++ b/lnwallet/aux_signer.go @@ -125,6 +125,10 @@ func NewAuxVerifyJob(sig fn.Option[tlv.Blob], keyRing CommitmentKeyRing, } } +// htlcCustomSigType is the TLV type that is used to encode the custom HTLC +// signatures within the custom data for an existing HTLC. +var htlcCustomSigType tlv.TlvType65543 + // AuxSigner is an interface that is used to sign and verify HTLCs for custom // channels. It is similar to the existing SigPool, but uses opaque blobs to // shuffle around signature information and other metadata. diff --git a/lnwallet/channel.go b/lnwallet/channel.go index a1ed2dc3682..fc279c264a9 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -5496,6 +5496,14 @@ func genHtlcSigValidationJobs(chanState *channeldb.OpenChannel, localCommitmentView.customBlob, auxLeaf, ) + // As this HTLC has a custom sign associated with it, + // store in the custom records map so we can write to + // disk later. + sigType := htlcCustomSigType.TypeVal() + htlc.CustomRecords[uint64(sigType)] = auxSig.UnwrapOr( + nil, + ) + auxVerifyJobs = append(auxVerifyJobs, auxVerifyJob) }