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.
This commit is contained in:
Olaoluwa Osuntokun 2024-01-02 18:44:44 -08:00
parent 63e698ec49
commit 34fd35bc63
No known key found for this signature in database
GPG Key ID: 3BBD59E99B280306

View File

@ -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) {