models

package
v0.0.0-...-de2af28 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const TableNameSwapIn = "swap_ins"
View Source
const TableNameSwapOut = "swap_outs"

Variables

This section is empty.

Functions

func CreateChainEnumSQL

func CreateChainEnumSQL() string

func CreateSwapOutcomeEnumSQL

func CreateSwapOutcomeEnumSQL() string

func CreateSwapStatusEnumSQL

func CreateSwapStatusEnumSQL() string

func DropChainEnumSQL

func DropChainEnumSQL() string

func DropSwapOutcomeEnumSQL

func DropSwapOutcomeEnumSQL() string

func DropSwapStatusEnumSQL

func DropSwapStatusEnumSQL() string

func RegisterPreimageSerializer

func RegisterPreimageSerializer()

Types

type Chain

type Chain string
const (
	Bitcoin Chain = "bitcoin"
	Liquid  Chain = "liquid"
)

func (Chain) IsValid

func (c Chain) IsValid() bool

func (*Chain) Scan

func (c *Chain) Scan(value interface{}) error

func (Chain) String

func (c Chain) String() string

func (Chain) Value

func (c Chain) Value() (driver.Value, error)

type PreimageSerializer

type PreimageSerializer struct{}

PreimageSerializer handles serialization/deserialization of *lntypes.Preimage

func (PreimageSerializer) Scan

func (PreimageSerializer) Scan(ctx context.Context, field *schema.Field, dst reflect.Value, dbValue interface{}) error

Scan implements serializer interface

func (PreimageSerializer) Value

func (PreimageSerializer) Value(ctx context.Context, field *schema.Field, dst reflect.Value, fieldValue interface{}) (interface{}, error)

Value implements serializer interface

type SwapIn

type SwapIn struct {
	ID                 int64             `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true;<-:create" json:"id"`
	SwapID             string            `gorm:"column:swap_id;type:text;not null" json:"swap_id"`
	AmountSats         int64             `gorm:"column:amount_sats;type:bigint;not null" json:"amount_sats"`
	Status             SwapStatus        `gorm:"column:status;type:swap_status;not null" json:"status"`
	Outcome            *SwapOutcome      `gorm:"column:outcome;type:swap_outcome" json:"outcome"`
	SourceChain        Chain             `gorm:"column:source_chain;type:chain_enum;not null" json:"source_chain"`
	ClaimAddress       string            `gorm:"column:claim_address;type:text" json:"claim_address"`
	TimeoutBlockHeight int64             `gorm:"column:timeout_block_height;type:bigint" json:"timeout_block_height"`
	RefundAddress      string            `gorm:"column:refund_address;type:text" json:"refund_address"`
	RefundTxID         string            `gorm:"column:refund_tx_id;type:text" json:"refund_tx_id"`
	RefundPrivatekey   string            `gorm:"column:refund_privatekey;type:text;not null" json:"refund_privatekey"`
	RedeemScript       string            `gorm:"column:redeem_script;type:text" json:"redeem_script"`
	PaymentRequest     string            `gorm:"column:payment_request;type:text;not null" json:"payment_request"`
	PreImage           *lntypes.Preimage `gorm:"column:pre_image;type:text;serializer:preimage" json:"pre_image"`
	OnChainFeeSats     int64             `gorm:"column:on_chain_fee_sats;type:bigint;not null" json:"on_chain_fee_sats"`
	ServiceFeeSats     int64             `gorm:"column:service_fee_sats;type:bigint;not null" json:"service_fee_sats"`
	CreatedAt          time.Time         `gorm:"column:created_at;type:timestamp with time zone;<-:create" json:"created_at"`
	UpdatedAt          time.Time         `gorm:"column:updated_at;type:timestamp with time zone;<-:update" json:"updated_at"`
	RefundRequestedAt  time.Time         `gorm:"column:refund_requested_at;type:timestamp with time zone" json:"refund_requested_at"`
	LockTxID           string            `gorm:"column:lock_tx_id;type:text" json:"lock_tx_id"`
	RefundAmount       int64             `gorm:"column:refund_amount;type:bigint" json:"refund_amount"`
}

SwapIn mapped from table <swap_ins>

func (*SwapIn) TableName

func (*SwapIn) TableName() string

TableName SwapIn's table name

type SwapOut

type SwapOut struct {
	ID                 int64             `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true;<-:create" json:"id"`
	SwapID             string            `gorm:"column:swap_id;type:text;not null" json:"swap_id"`
	Status             SwapStatus        `gorm:"column:status;type:swap_status;not null" json:"status"`
	AmountSats         int64             `gorm:"column:amount_sats;type:bigint;not null" json:"amount_sats"`
	DestinationAddress string            `gorm:"column:destination_address;type:text;not null" json:"destination_address"`
	ServiceFeeSats     int64             `gorm:"column:service_fee_sats;type:bigint;not null" json:"service_fee_sats"`
	OnchainFeeSats     int64             `gorm:"column:onchain_fee_sats;type:bigint" json:"onchain_fee_sats"`
	OffchainFeeSats    int64             `gorm:"column:offchain_fee_sats;type:bigint" json:"offchain_fee_sats"`
	DestinationChain   Chain             `gorm:"column:destination_chain;type:chain_enum;not null" json:"destination_chain"`
	ClaimPrivateKey    string            `gorm:"column:claim_private_key;type:text;not null" json:"claim_private_key"`
	PaymentRequest     string            `gorm:"column:payment_request;type:text;not null" json:"payment_request"`
	Description        string            `gorm:"column:description;type:text" json:"description"`
	MaxRoutingFeeRatio float64           `gorm:"column:max_routing_fee_ratio;type:numeric;not null" json:"max_routing_fee_ratio"`
	Outcome            *SwapOutcome      `gorm:"column:outcome;type:swap_outcome" json:"outcome"`
	PreImage           *lntypes.Preimage `gorm:"column:pre_image;type:text;serializer:preimage" json:"pre_image"`
	TimeoutBlockHeight int64             `gorm:"column:timeout_block_height;type:bigint" json:"timeout_block_height"`
	TxID               string            `gorm:"column:tx_id;type:text" json:"tx_id"`
}

SwapOut mapped from table <swap_outs>

func (*SwapOut) TableName

func (*SwapOut) TableName() string

TableName SwapOut's table name

type SwapOutcome

type SwapOutcome string
const (
	OutcomeFailed   SwapOutcome = "FAILED"
	OutcomeSuccess  SwapOutcome = "SUCCESS"
	OutcomeRefunded SwapOutcome = "REFUNDED"
	OutcomeExpired  SwapOutcome = "EXPIRED"
)

func (*SwapOutcome) Scan

func (o *SwapOutcome) Scan(value interface{}) error

func (SwapOutcome) String

func (o SwapOutcome) String() string

func (SwapOutcome) Value

func (o SwapOutcome) Value() (driver.Value, error)

type SwapStatus

type SwapStatus string
const (
	// happy path
	StatusCreated                      SwapStatus = "CREATED"
	StatusInvoicePaymentIntentReceived SwapStatus = "INVOICE_PAYMENT_INTENT_RECEIVED"
	StatusContractFundedUnconfirmed    SwapStatus = "CONTRACT_FUNDED_UNCONFIRMED"
	StatusContractFunded               SwapStatus = "CONTRACT_FUNDED"
	StatusInvoicePaid                  SwapStatus = "INVOICE_PAID"
	StatusContractClaimedUnconfirmed   SwapStatus = "CONTRACT_CLAIMED_UNCONFIRMED"
	StatusDone                         SwapStatus = "DONE"
	// if it expires after CONTRACT_FUNDED
	StatusContractRefundedUnconfirmed SwapStatus = "CONTRACT_REFUNDED_UNCONFIRMED"
	StatusContractExpired             SwapStatus = "CONTRACT_EXPIRED"
)

func (*SwapStatus) Scan

func (s *SwapStatus) Scan(value interface{}) error

func (SwapStatus) String

func (s SwapStatus) String() string

func (SwapStatus) Value

func (s SwapStatus) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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