models

package
v0.0.0-...-a0f7607 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntryTypeIncoming           = "incoming"
	EntryTypeOutgoing           = "outgoing"
	EntryTypeFee                = "fee"
	EntryTypeFeeReserve         = "fee_reserve"
	EntryTypeServiceFee         = "service_fee"
	EntryTypeServiceFeeReversal = "service_fee_reversal"
	EntryTypeFeeReserveReversal = "fee_reserve_reversal"
	EntryTypeOutgoingReversal   = "outgoing_reversal"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID     int64  `bun:",pk,autoincrement"`
	UserID int64  `bun:",notnull"`
	User   *User  `bun:"rel:belongs-to,join:user_id=id"`
	Type   string `bun:",notnull"`
}

Account : Account Model

type Invoice

type Invoice struct {
	ID                       int64             `json:"id" bun:",pk,autoincrement"`
	Type                     string            `json:"type" validate:"required"`
	UserID                   int64             `json:"user_id" validate:"required"`
	User                     *User             `json:"-" bun:"rel:belongs-to,join:user_id=id"`
	Amount                   int64             `json:"amount" validate:"gte=0"`
	Fee                      int64             `json:"fee"`
	ServiceFee               int64             `json:"service_fee"`
	RoutingFee               int64             `json:"routing_fee"`
	Memo                     string            `json:"memo" bun:",nullzero"`
	DescriptionHash          string            `json:"description_hash,omitempty" bun:",nullzero"`
	PaymentRequest           string            `json:"payment_request" bun:",nullzero"`
	DestinationPubkeyHex     string            `json:"destination_pubkey_hex" bun:",notnull"`
	DestinationCustomRecords map[uint64][]byte `json:"custom_records,omitempty"`
	RHash                    string            `json:"r_hash"`
	Preimage                 string            `json:"preimage" bun:",nullzero"`
	Internal                 bool              `json:"-" bun:",nullzero"`
	Keysend                  bool              `json:"keysend" bun:",nullzero"`
	State                    string            `json:"state" bun:",default:'initialized'"`
	ErrorMessage             string            `json:"error_message,omitempty" bun:",nullzero"`
	AddIndex                 uint64            `json:"-" bun:",nullzero"`
	CreatedAt                time.Time         `json:"created_at" bun:",nullzero,notnull,default:current_timestamp"`
	ExpiresAt                bun.NullTime      `json:"expires_at" bun:",nullzero"`
	UpdatedAt                bun.NullTime      `json:"updated_at"`
	SettledAt                bun.NullTime      `json:"settled_at"`
}

Invoice : Invoice Model

func (*Invoice) BeforeAppendModel

func (i *Invoice) BeforeAppendModel(ctx context.Context, query bun.Query) error

func (*Invoice) SetFee

func (i *Invoice) SetFee(txEntry TransactionEntry, routingFee int64)

type TransactionEntry

type TransactionEntry struct {
	ID              int64             `bun:",pk,autoincrement"`
	UserID          int64             `bun:",notnull"`
	User            *User             `bun:"rel:belongs-to,join:user_id=id"`
	InvoiceID       int64             `bun:",notnull"`
	Invoice         *Invoice          `bun:"rel:belongs-to,join:invoice_id=id"`
	ParentID        int64             `bun:",nullzero"`
	Parent          *TransactionEntry `bun:"rel:belongs-to"`
	CreditAccountID int64             `bun:",notnull"`
	FeeReserve      *TransactionEntry `bun:"rel:belongs-to"`
	ServiceFee      *TransactionEntry `bun:"rel:belongs-to"`
	CreditAccount   *Account          `bun:"rel:belongs-to,join:credit_account_id=id"`
	DebitAccountID  int64             `bun:",notnull"`
	DebitAccount    *Account          `bun:"rel:belongs-to,join:debit_account_id=id"`
	Amount          int64             `bun:",notnull"`
	CreatedAt       time.Time         `bun:",nullzero,notnull,default:current_timestamp"`
	EntryType       string
}

TransactionEntry : Transaction Entries Model

type User

type User struct {
	ID          int64          `bun:",pk,autoincrement"`
	Email       sql.NullString `bun:",unique"`
	Login       string         `bun:",unique,notnull"`
	Password    string         `bun:",notnull"`
	CreatedAt   time.Time      `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt   bun.NullTime
	Invoices    []*Invoice `bun:"rel:has-many,join:id=user_id"`
	Accounts    []*Account `bun:"rel:has-many,join:id=user_id"`
	Deactivated bool
	Deleted     bool
}

User : User Model

func (*User) BeforeAppendModel

func (u *User) BeforeAppendModel(ctx context.Context, query bun.Query) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址