From 34fd35bc63776f6b1b2c1794066710d39e398dab Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 2 Jan 2024 18:44:44 -0800 Subject: [PATCH] lnwire: add Record() method to lnwire.Sig We'll use this later on to re-use the normal primitive record to create a series of new TLV types for the new co-op close protocol. --- lnwire/signature.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lnwire/signature.go b/lnwire/signature.go index db6d59052..35b039ed0 100644 --- a/lnwire/signature.go +++ b/lnwire/signature.go @@ -7,6 +7,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2/ecdsa" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/lightningnetwork/lnd/input" + "github.com/lightningnetwork/lnd/tlv" ) var ( @@ -64,6 +65,17 @@ func (s *Sig) Copy() Sig { return sCopy } +// Record returns a Record that can be used to encode or decode the backing +// object. +// +// This returns a record that serializes the sig as a 64-byte fixed size +// signature. +func (s *Sig) Record() tlv.Record { + // We set a type here as zero as it isn't needed when used as a + // RecordT. + return tlv.MakePrimitiveRecord(0, &s.bytes) +} + // NewSigFromWireECDSA returns a Sig instance based on an ECDSA signature // that's already in the 64-byte format we expect. func NewSigFromWireECDSA(sig []byte) (Sig, error) {