lnwire: export SerializeSigToWire and DeserializeSigFromWire
This commit is contained in:
parent
74322a99be
commit
ff4ca664e3
@ -152,7 +152,7 @@ func writeElement(w io.Writer, element interface{}) error {
|
||||
}
|
||||
|
||||
var b [64]byte
|
||||
err := serializeSigToWire(&b, e)
|
||||
err := SerializeSigToWire(&b, e)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -467,7 +467,7 @@ func readElement(r io.Reader, element interface{}) error {
|
||||
if _, err := io.ReadFull(r, b[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
err = deserializeSigFromWire(e, b)
|
||||
err = DeserializeSigFromWire(e, b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
"github.com/roasbeef/btcd/btcec"
|
||||
)
|
||||
|
||||
// serializeSigToWire serializes a *Signature to [64]byte in the format
|
||||
// SerializeSigToWire serializes a *Signature to [64]byte in the format
|
||||
// specified by the Lightning RFC.
|
||||
func serializeSigToWire(b *[64]byte, e *btcec.Signature) error {
|
||||
func SerializeSigToWire(b *[64]byte, e *btcec.Signature) error {
|
||||
|
||||
// Serialize the signature with all the checks that entails.
|
||||
sig := e.Serialize()
|
||||
@ -53,9 +53,9 @@ func serializeSigToWire(b *[64]byte, e *btcec.Signature) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// deserializeSigFromWire deserializes a *Signature from [64]byte in the format
|
||||
// DeserializeSigFromWire deserializes a *Signature from [64]byte in the format
|
||||
// specified by the Lightning RFC.
|
||||
func deserializeSigFromWire(e **btcec.Signature, b [64]byte) error {
|
||||
func DeserializeSigFromWire(e **btcec.Signature, b [64]byte) error {
|
||||
|
||||
// Extract canonically-padded bigint representations from buffer
|
||||
r := extractCanonicalPadding(b[0:32])
|
||||
|
@ -15,12 +15,12 @@ func TestSignatureSerializeDeserialize(t *testing.T) {
|
||||
// check for errors as well as check if the results are correct.
|
||||
signatureSerializeDeserialize := func(e btcec.Signature) error {
|
||||
var b [64]byte
|
||||
err := serializeSigToWire(&b, &e)
|
||||
err := SerializeSigToWire(&b, &e)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var e2 *btcec.Signature
|
||||
err = deserializeSigFromWire(&e2, b)
|
||||
err = DeserializeSigFromWire(&e2, b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user