models

package
v0.0.0-...-73df3ec Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 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"

	BroadcastStatePending   = "pending"
	BroadcastStateBroadcast = "broadcast"
	LnhubInternalOutpoint   = "lnhub_internal_outpoint"
	LnhubInternalComplete   = "lnhub_internal_complete"
)

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"`
	AssetID string `bun:",notnull"`
	Asset   *Asset `bun:"rel:has-one,join:asset_id=asset_id"`
	Type    string `bun:",notnull"`
}

Account : Account Model

type Address

type Address struct {
	ID        uint64 `bun:",pk,autoincrement"`
	Addr      string `bun:",notnull,unique"`
	UserId    uint64 `bun:",notnull"`
	AssetID   string `bun:",notnull"`
	Amount    uint64
	CreatedAt time.Time    `bun:",notnull,default:current_timestamp"`
	UpdatedAt bun.NullTime `bun:",nullzero"`
	// relationship
	Asset *Asset `bun:"rel:has-one,join:asset_id=asset_id"`
	User  *User  `bun:"rel:belongs-to,join:user_id=id"`
}

Address : Address Model

func (*Address) BeforeAppendModel

func (a *Address) BeforeAppendModel(ctx context.Context, query bun.Query) error

type Asset

type Asset struct {
	ID        int64     `bun:",pk,autoincrement"`
	AssetID   string    `bun:",notnull,unique"`
	AssetName string    `bun:",notnull,unique"`
	AssetType int64     `bun:",notnull"` // https://lightning.engineering/api-docs/api/taproot-assets/universe/query-asset-stats#taprpcassettype
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt bun.NullTime
}

`AssetID` is not unique ! This is because `Group`s of the same Taproot Asset have different asset_id's.

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"`
	AssetID                  string            `json:"asset_id" validate:"required"`
	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"`
	AssetID         string            `bun:",nullzero"`
	Asset           *Asset            `bun:"rel:belongs-to,join:asset_id=asset_id"`
	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
	Outpoint        string
	BroadcastState  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"`
	Addresses   []*Address `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
⌂ 换网址