ussd/internal/utils/db.go

55 lines
933 B
Go
Raw Permalink Normal View History

2024-09-05 16:12:38 +02:00
package utils
import (
"encoding/binary"
)
type DataTyp uint16
const (
DATA_ACCOUNT DataTyp = iota
DATA_ACCOUNT_CREATED
DATA_TRACKING_ID
DATA_PUBLIC_KEY
DATA_CUSTODIAL_ID
2024-09-05 18:50:02 +02:00
DATA_ACCOUNT_PIN
2024-09-06 07:35:01 +02:00
DATA_ACCOUNT_STATUS
DATA_TEMPORARY_FIRST_NAME
2024-09-06 07:35:01 +02:00
DATA_FIRST_NAME
DATA_TEMPORARY_FAMILY_NAME
2024-09-06 07:35:01 +02:00
DATA_FAMILY_NAME
DATA_TEMPORARY_YOB
2024-09-06 07:35:01 +02:00
DATA_YOB
DATA_TEMPORARY_LOCATION
2024-09-06 07:35:01 +02:00
DATA_LOCATION
DATA_TEMPORARY_GENDER
2024-09-06 07:35:01 +02:00
DATA_GENDER
DATA_TEMPORARY_OFFERINGS
2024-09-06 07:35:01 +02:00
DATA_OFFERINGS
DATA_RECIPIENT
DATA_AMOUNT
2024-09-16 13:39:42 +02:00
DATA_TEMPORARY_PIN
DATA_VOUCHER_LIST
2024-10-09 14:38:19 +02:00
DATA_TEMPORARY_SYM
DATA_ACTIVE_SYM
2024-10-10 13:48:23 +02:00
DATA_TEMPORARY_BAL
DATA_ACTIVE_BAL
2024-10-30 01:59:59 +01:00
DATA_PUBLIC_KEY_REVERSE
DATA_TEMPORARY_DECIMAL
DATA_ACTIVE_DECIMAL
DATA_TEMPORARY_ADDRESS
DATA_ACTIVE_ADDRESS
2024-09-05 16:12:38 +02:00
)
func typToBytes(typ DataTyp) []byte {
var b [2]byte
binary.BigEndian.PutUint16(b[:], uint16(typ))
return b[:]
2024-09-05 16:12:38 +02:00
}
2024-09-07 15:25:29 +02:00
func PackKey(typ DataTyp, data []byte) []byte {
2024-09-05 16:12:38 +02:00
v := typToBytes(typ)
return append(v, data...)
}