alby-hub/db/models.go
Adithya Vardhan 0c421375e5
chore: update to use sat/msat suffixes everywhere (#2271)
* chore: align internal models and methods to use sat/msat suffixes

* chore: update request structs to use sat/msat suffixes

* fix: default max amount to 0 during app creation

* fix: simplify helper functions

* chore: remove unused lnclient probing methods

* chore: remove unused json tags on swap struct

* chore: update frontend to use sat/msat suffixes everywhere

* chore: use request types in frontend

* fix: linting

* fix: remove deprecated sat and msat fields in frontend

* chore: further changes

* fix: avoid sat/msat resolver variable shadowing

* fix: validate Support Alby amounts
2026-05-01 15:41:56 +05:30

135 lines
3.2 KiB
Go

package db
import (
"time"
"gorm.io/datatypes"
)
type UserConfig struct {
ID uint
Key string
Value string
Encrypted bool
CreatedAt time.Time
UpdatedAt time.Time
}
type App struct {
ID uint
Name string `validate:"required"`
Description string
AppPubkey string `validate:"required"`
WalletPubkey *string
CreatedAt time.Time
UpdatedAt time.Time
LastUsedAt *time.Time
LastSettledTransactionAt *time.Time
Isolated bool
Metadata datatypes.JSON
}
type AppPermission struct {
ID uint
AppId uint `validate:"required"`
App App
Scope string `validate:"required"`
MaxAmountSat int
BudgetRenewal string
ExpiresAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
type RequestEvent struct {
ID uint
AppId *uint
App App
NostrId string `validate:"required"`
ContentData string
Method string
State string
CreatedAt time.Time
UpdatedAt time.Time
}
type ResponseEvent struct {
ID uint
NostrId string `validate:"required"`
RequestId uint `validate:"required"`
State string
RepliedAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
type Transaction struct {
ID uint
AppId *uint
App *App
RequestEventId *uint
RequestEvent *RequestEvent
Type string
State string
AmountMsat uint64
FeeMsat uint64
FeeReserveMsat uint64
PaymentRequest string
PaymentHash string
Description string
DescriptionHash string
Preimage *string
CreatedAt time.Time
ExpiresAt *time.Time
UpdatedAt time.Time
SettledAt *time.Time
Metadata datatypes.JSON
SelfPayment bool
Boostagram datatypes.JSON
FailureReason string
Hold bool
SettleDeadline *uint32 // block number for accepted hold invoices
}
type Swap struct {
ID uint
SwapId string `validate:"required"`
Type string
State string
Invoice string
SendAmountSat uint64 `gorm:"column:send_amount"`
ReceiveAmountSat uint64 `gorm:"column:receive_amount"`
Preimage string
PaymentHash string
DestinationAddress string
RefundAddress string
LockupAddress string
LockupTxId string
ClaimTxId string
AutoSwap bool
UsedXpub bool
TimeoutBlockHeight uint32
BoltzPubkey string
SwapTree datatypes.JSON
CreatedAt time.Time
UpdatedAt time.Time
}
type Forward struct {
ID uint
OutboundAmountForwardedMsat uint64
TotalFeeEarnedMsat uint64
CreatedAt time.Time
UpdatedAt time.Time
}
const (
REQUEST_EVENT_STATE_HANDLER_EXECUTING = "executing"
REQUEST_EVENT_STATE_HANDLER_EXECUTED = "executed"
REQUEST_EVENT_STATE_HANDLER_ERROR = "error"
)
const (
RESPONSE_EVENT_STATE_PUBLISH_CONFIRMED = "confirmed"
RESPONSE_EVENT_STATE_PUBLISH_FAILED = "failed"
RESPONSE_EVENT_STATE_PUBLISH_UNCONFIRMED = "unconfirmed"
)