Skip to content

Commit bb75d7b

Browse files
committed
fix(dashboard_exporter): add scan support for Base64Bytes
1 parent f6bed1f commit bb75d7b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

backend/pkg/consapi/types/debug.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@ func (b *Base64Bytes) UnmarshalText(text []byte) error {
3030
return nil
3131
}
3232

33+
func (b *Base64Bytes) Scan(value interface{}) error {
34+
switch v := value.(type) {
35+
case []byte:
36+
decoded, err := base64.StdEncoding.DecodeString(string(v))
37+
if err != nil {
38+
return errors.Wrap(err, "failed to decode base64")
39+
}
40+
if len(decoded) == 0 {
41+
return fmt.Errorf("base64 decoded string is empty")
42+
}
43+
*b = Base64Bytes(decoded)
44+
case string:
45+
return b.UnmarshalText([]byte(v))
46+
default:
47+
return fmt.Errorf("unsupported type: %T", v)
48+
}
49+
return nil
50+
}
51+
3352
type ElectraDeposit struct {
3453
Pubkey Base64Bytes `json:"pubkey" db:"pubkey"`
3554
Amount int64 `json:"amount,string" db:"amount"`

0 commit comments

Comments
 (0)