Skip to content

Commit a7707d5

Browse files
committed
proof: update GroupKeyRevealRecord size calc for V0 and V1 handling
Refactored the GroupKeyRevealRecord size calculation to support both GroupKeyRevealV0 and GroupKeyRevealV1 formats.
1 parent fac93e6 commit a7707d5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

proof/records.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,25 @@ func GenesisRevealRecord(genesis **asset.Genesis) tlv.Record {
379379
}
380380

381381
func GroupKeyRevealRecord(reveal *asset.GroupKeyReveal) tlv.Record {
382+
// recordSize returns the size of the record in bytes. This is used to
383+
// determine the size of the record when encoding it.
382384
recordSize := func() uint64 {
383385
if reveal == nil || *reveal == nil {
384386
return 0
385387
}
386-
r := *reveal
387-
return uint64(
388-
btcec.PubKeyBytesLenCompressed + len(r.TapscriptRoot()),
388+
389+
var (
390+
b bytes.Buffer
391+
buf [8]byte
389392
)
393+
err := asset.GroupKeyRevealEncoder(&b, reveal, &buf)
394+
if err != nil {
395+
panic(err)
396+
}
397+
398+
return uint64(len(b.Bytes()))
390399
}
400+
391401
return tlv.MakeDynamicRecord(
392402
GroupKeyRevealType, reveal, recordSize,
393403
asset.GroupKeyRevealEncoder, asset.GroupKeyRevealDecoder,

0 commit comments

Comments
 (0)