graph/db: treat empty channel signatures as missing

This commit improves handling of missing channel signatures in the
database:

- Return nil from auth proof accessors instead of empty slices so that
  missing signatures are stored as NULL in SQL.
- Update public channel checks to require signature length > 0, which
  properly handles existing empty bytea values in the database.
- Add regression test covering empty v1 and v2 channel signatures to
  prevent future issues.
This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:23 +02:00
1 parent a39f94eb4a
commit 6328c4d897
5 files changed
+85 -27

No files matched your search

+12 -14
View File
@@ -89,31 +89,29 @@ func NewV2ChannelAuthProof(signature []byte) *ChannelAuthProof {
}
}
// NodeSig1 returns the first node signature bytes, or an empty slice if not
// present.
// NodeSig1 returns the first node signature bytes, or nil if not present.
func (c *ChannelAuthProof) NodeSig1() []byte {
return c.NodeSig1Bytes.UnwrapOr([]byte{})
return c.NodeSig1Bytes.UnwrapOr(nil)
}
// NodeSig2 returns the second node signature bytes, or an empty slice if not
// present.
// NodeSig2 returns the second node signature bytes, or nil if not present.
func (c *ChannelAuthProof) NodeSig2() []byte {
return c.NodeSig2Bytes.UnwrapOr([]byte{})
return c.NodeSig2Bytes.UnwrapOr(nil)
}
// BitcoinSig1 returns the first bitcoin signature bytes, or an empty slice if
// not present.
// BitcoinSig1 returns the first bitcoin signature bytes, or nil if not
// present.
func (c *ChannelAuthProof) BitcoinSig1() []byte {
return c.BitcoinSig1Bytes.UnwrapOr([]byte{})
return c.BitcoinSig1Bytes.UnwrapOr(nil)
}
// BitcoinSig2 returns the second bitcoin signature bytes, or an empty slice if
// not present.
// BitcoinSig2 returns the second bitcoin signature bytes, or nil if not
// present.
func (c *ChannelAuthProof) BitcoinSig2() []byte {
return c.BitcoinSig2Bytes.UnwrapOr([]byte{})
return c.BitcoinSig2Bytes.UnwrapOr(nil)
}
// Sig returns the v2 signature bytes, or an empty slice if not present.
// Sig returns the v2 signature bytes, or nil if not present.
func (c *ChannelAuthProof) Sig() []byte {
return c.Signature.UnwrapOr([]byte{})
return c.Signature.UnwrapOr(nil)
}