model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MIT Imports: 6 Imported by: 11

Documentation

Index

Constants

View Source
const (
	SsmAddressStatusUnused      = SsmAddressStatus("unused")
	SsmAddressStatusUsed        = SsmAddressStatus("used")
	SsmAddressStatusBlacklisted = SsmAddressStatus("blacklisted")
)
View Source
const DefaultFeeRate = Float(0.001) // 0.1%
View Source
const MemPoolBlockID = BlockID(1)

Variables

View Source
var (
	ErrAccountStatusInvalid = errors.New("Invalid AccountStatus")
)
View Source
var (
	ErrInvalidDataType = errors.New("Invalid DataType")
)
View Source
var (
	ErrOperationTypeInvalid = errors.New("Invalid OperationType")
)
View Source
var (
	ErrSynchroneousTypeInvalid = errors.New("Invalid SynchroneousType")
)

Functions

This section is empty.

Types

type Account added in v0.0.2

type Account struct {
	ID           AccountID    `gorm:"primary_key"`                     // [PK] Account
	UserID       UserID       `gorm:"index;not null"`                  // [FK] Reference to User table
	CurrencyName CurrencyName `gorm:"index;not null;type:varchar(16)"` // [FK] Reference to Currency table
	Name         AccountName  `gorm:"index;not null"`                  // [U] Unique Account name for User and Currency
}

type AccountID added in v0.0.2

type AccountID ID

type AccountName added in v0.0.2

type AccountName String

type AccountOperation added in v0.0.2

type AccountOperation struct {
	ID        AccountOperationID `gorm:"primary_key;unique_index:idx_id_previd;"` // [PK] AccountOperation
	AccountID AccountID          `gorm:"index;not null"`                          // [FK] Reference to Account table

	SynchroneousType SynchroneousType `gorm:"index;not null;type:varchar(16)"` // [enum] Operation synchroneous type (sync, async-start, async-end)
	OperationType    OperationType    `gorm:"index;not null;type:varchar(16)"` // [enum] Determine table for ReferenceID (deposit, withdraw, transfer, adjustment, none, other)
	ReferenceID      RefID            `gorm:"index;not null"`                  // [optional - FK] Reference to related table with OperationType

	Timestamp time.Time `gorm:"index;not null;type:timestamp"` // Operation timestamp
	Amount    ZeroFloat `gorm:"default:0;not null"`            // Operation amount (can be negative)
	Balance   ZeroFloat `gorm:"default:0;not null"`            // Account balance (strictly positive or zero)

	LockAmount  ZeroFloat `gorm:"default:0;not null"` // Operation amount (can be negative)
	TotalLocked ZeroFloat `gorm:"default:0;not null"` // Total locked (strictly positive or zero and less or equal than Balance)
}

AccountOperation model

func NewAccountOperation added in v0.0.2

func NewAccountOperation(ID AccountOperationID, accountID AccountID, synchroneousType SynchroneousType, operationType OperationType, referenceID RefID, timestamp time.Time, amount, balance, lockAmount, totalLocked Float) AccountOperation

func NewInitOperation added in v0.0.3

func NewInitOperation(accountID AccountID, referenceID RefID) AccountOperation

func (*AccountOperation) IsValid added in v0.0.2

func (p *AccountOperation) IsValid() bool

func (*AccountOperation) PreCheck added in v0.0.2

func (p *AccountOperation) PreCheck() bool

type AccountOperationID added in v0.0.2

type AccountOperationID ID

type AccountState added in v0.0.2

type AccountState struct {
	AccountID AccountID     `gorm:"unique_index;not null"`           // [FK] Reference to Account table
	State     AccountStatus `gorm:"index;not null;type:varchar(16)"` // AccountStatus [normal, locked, disabled]
}

type AccountStatus added in v0.0.2

type AccountStatus String
const (
	AccountStatusInvalid AccountStatus = ""

	AccountStatusCreated  AccountStatus = "created"
	AccountStatusNormal   AccountStatus = "normal"
	AccountStatusLocked   AccountStatus = "locked"
	AccountStatusDisabled AccountStatus = "disabled"
)

func ParseAccountStatus added in v0.0.2

func ParseAccountStatus(str string) AccountStatus

func (AccountStatus) String added in v0.0.2

func (p AccountStatus) String() string

func (AccountStatus) Valid added in v0.0.2

func (p AccountStatus) Valid() bool

type Asset added in v0.0.3

type Asset struct {
	ID           AssetID      `gorm:"primary_key;"`                                          // [PK] Asset
	CurrencyName CurrencyName `gorm:"index;unique_index:idx_currency_hash;not null;size:16"` // [FK] Currency, non mutable`
	Hash         AssetHash    `gorm:"index;unique_index:idx_currency_hash;not null;size:64"` //  Asset Hash
}

type AssetHash added in v0.0.3

type AssetHash String

type AssetID added in v0.0.3

type AssetID ID

type AssetIcon added in v0.0.3

type AssetIcon struct {
	AssetID    AssetID   `gorm:"unique_index;not null"`         // [FK] Reference to Asset table
	LastUpdate time.Time `gorm:"index;not null;type:timestamp"` // Last update timestamp
	Data       []byte    `gorm:"type:MEDIUMBLOB;default:null"`  // Decoded data byte
}

AssetIcon from https://assets.blockstream.info/icons.json

type AssetInfo added in v0.0.3

type AssetInfo struct {
	AssetID    AssetID   `gorm:"unique_index;not null"`         // [FK] Reference to Asset table
	LastUpdate time.Time `gorm:"index;not null;type:timestamp"` // Last update timestamp
	Domain     string    `gorm:"index;not null;size:253"`       // AssetDomaine name (RFC 1053)
	Name       string    `gorm:"index;not null;size:255"`       // Asset unique asset name
	Ticker     string    `gorm:"index;not null;size:5"`         // Asset unique ticker name
	Precision  uint8     `gorm:"default:0;not null"`            // Asset precision [0, 8]
}

AssetInfo from https://assets.blockstream.info/

func (*AssetInfo) Valid added in v0.0.3

func (p *AssetInfo) Valid() bool

type Base58 added in v0.0.2

type Base58 String

type Batch added in v0.0.5

type Batch struct {
	ID           BatchID      `gorm:"primary_key"`
	Timestamp    time.Time    `gorm:"index;not null;type:timestamp"`   // Creation timestamp
	ExecuteAfter time.Time    `gorm:"index;not null;type:timestamp"`   // Execute after timestamp
	Capacity     Int          `gorm:"index;not null"`                  // Batch capacity
	Network      BatchNetwork `gorm:"index;not null;size:24"`          // Network [sepa, swift, card, bitcoin, bitcoin-testnet, liquid, lightning]
	Data         BatchData    `gorm:"type:blob;not null;default:'{}'"` // Batch data
}

func (*Batch) IsComplete added in v0.0.5

func (p *Batch) IsComplete() bool

type BatchData added in v0.0.5

type BatchData String

type BatchID added in v0.0.5

type BatchID ID

type BatchInfo added in v0.0.5

type BatchInfo struct {
	ID        BatchInfoID       `gorm:"primary_key"`
	Timestamp time.Time         `gorm:"index;not null;type:timestamp"`   // Creation timestamp
	BatchID   BatchID           `gorm:"index;not null"`                  // [FK] Reference to Batch table
	Status    BatchStatus       `gorm:"index;not null;size:16"`          // BatchStatus [created, processing, completed, canceled]
	Type      encoding.DataType `gorm:"index;not null;size:16"`          // DataType [crypto]
	Data      BatchInfoData     `gorm:"type:blob;not null;default:'{}'"` // BatchInfo data
}

func (*BatchInfo) CryptoData added in v0.0.5

func (p *BatchInfo) CryptoData() (BatchInfoCryptoData, error)

type BatchInfoCryptoData added in v0.0.5

type BatchInfoCryptoData struct {
	TxID   String `json:"txid,omitempty"`
	Height Int    `json:"height,omitempty"`
}

BatchInfoCryptoData data type for BatchInfo crypto

type BatchInfoData added in v0.0.5

type BatchInfoData encoding.Data

type BatchInfoID added in v0.0.5

type BatchInfoID ID

type BatchMode added in v0.0.5

type BatchMode String
const (
	BatchModeInstant BatchMode = "instant"
	BatchModeFast    BatchMode = "fast"
	BatchModeNormal  BatchMode = "normal"
	BatchModeSlow    BatchMode = "slow"
)

type BatchNetwork added in v0.0.5

type BatchNetwork String
const (
	BatchNetworkSepa  BatchNetwork = "sepa"
	BatchNetworkSwift BatchNetwork = "swift"
	BatchNetworkCard  BatchNetwork = "card"

	BatchNetworkBitcoin          BatchNetwork = "bitcoin"
	BatchNetworkBitcoinTestnet   BatchNetwork = "bitcoin-testnet"
	BatchNetworkBitcoinLiquid    BatchNetwork = "liquid"
	BatchNetworkBitcoinLightning BatchNetwork = "lightning"
)

type BatchStatus added in v0.0.5

type BatchStatus String
const (
	BatchStatusCreated    BatchStatus = "created"
	BatchStatusReady      BatchStatus = "ready"
	BatchStatusProcessing BatchStatus = "processing"
	BatchStatusConfirmed  BatchStatus = "confirmed"
	BatchStatusSettled    BatchStatus = "settled"
	BatchStatusCanceled   BatchStatus = "canceled"

	BatchInfoCrypto encoding.DataType = "crypto"
)

type BatchWithdraw added in v0.0.5

type BatchWithdraw struct {
	BatchID    BatchID    `gorm:"unique_index:idx_batch_withdraw;index;not null"`                     // [FK] Reference to Batch table
	WithdrawID WithdrawID `gorm:"unique_index:idx_withdraw;unique_index:idx_batch_withdraw;not null"` // [FK] Reference to Withdraw table
}

type BlockID added in v0.0.3

type BlockID ID

type Credential

type Credential struct {
	UserID       UserID `gorm:"unique_index"`
	LoginHash    Base58 `gorm:"size:64;not null;index"`
	PasswordHash Base58 `gorm:"size:64;not null;index"`
	TOTPSecret   String `gorm:"size:64;not null"`
}

type CryptoAddress added in v0.0.3

type CryptoAddress struct {
	ID               CryptoAddressID `gorm:"primary_key"`                    // [PK] CryptoAddress
	AccountID        AccountID       `gorm:"index;not null"`                 // [FK] Reference to Account table
	PublicAddress    String          `gorm:"unique_index;not null;size:128"` // CryptoAddress public key, non mutable
	Unconfidential   String          `gorm:"index;size:64"`                  // CryptoAddress unconfidential address, non mutable`
	Chain            String          `gorm:"index;not null;size:16"`         // CryptoAddress chain, non mutable
	CreationDate     *time.Time      `gorm:"index;not null"`                 // CryptoAddress creation date, non mutable
	FirstBlockId     BlockID         `gorm:"index;not null"`                 // Block height of the first transaction
	IgnoreAccounting bool            `gorm:"not null"`                       // This address is not for Accounting (change address)
}

func (*CryptoAddress) Confirmations added in v0.0.3

func (p *CryptoAddress) Confirmations(height BlockID) int

func (*CryptoAddress) IsUsed added in v0.0.3

func (p *CryptoAddress) IsUsed() bool

type CryptoAddressID added in v0.0.3

type CryptoAddressID ID

type Currency added in v0.0.2

type Currency struct {
	Name        CurrencyName `gorm:"primary_key;type:varchar(16)"` // [PK] Currency
	DisplayName CurrencyName `gorm:"type:varchar(32)"`
	Type        ZeroInt      `gorm:"default:0;not null"` // currencyType [Fiat=0, CryptoNative=1, CryptoAsset=2]
	Available   ZeroInt      `gorm:"default:0;not null"`
	Crypto      ZeroInt      `gorm:"default:0;not null"`
	Precision   ZeroInt      `gorm:"default:0;not null"`
	AutoCreate  bool         `gorm:"default:false"` // Automatic creation for accounts
}

func NewCurrency added in v0.0.2

func NewCurrency(name, displayName CurrencyName, currencyType, available, crypto, precision Int) Currency

func (*Currency) DisplayPrecision added in v0.0.2

func (p *Currency) DisplayPrecision() Int

func (*Currency) GetType added in v0.0.3

func (p *Currency) GetType() Int

func (*Currency) IsAvailable added in v0.0.2

func (p *Currency) IsAvailable() bool

func (*Currency) IsCrypto added in v0.0.2

func (p *Currency) IsCrypto() bool

type CurrencyAvailable added in v0.0.2

type CurrencyAvailable ZeroInt

type CurrencyName added in v0.0.2

type CurrencyName String

type CurrencyRate added in v0.0.2

type CurrencyRate struct {
	ID        CurrencyRateID     `gorm:"primary_key"`
	Timestamp time.Time          `gorm:"index;not null;type:timestamp"`
	Source    CurrencyRateSource `gorm:"index;not null;type:varchar(16)"`
	Base      CurrencyName       `gorm:"index;not null;type:varchar(16)"`
	Name      CurrencyName       `gorm:"index;not null;type:varchar(16)"`
	Rate      CurrencyRateValue  `gorm:"not null"`
}

type CurrencyRateID added in v0.0.2

type CurrencyRateID ID

type CurrencyRateSource added in v0.0.2

type CurrencyRateSource String

type CurrencyRateValue added in v0.0.2

type CurrencyRateValue Float

type Fee added in v0.0.5

type Fee struct {
	ID         FeeID      `gorm:"primary_key"`
	WithdrawID WithdrawID `gorm:"unique_index;not null"`           // [FK] Reference to Withdraw table
	Amount     ZeroFloat  `gorm:"default:0;not null"`              // Operation amount (can be negative)
	Data       FeeData    `gorm:"type:blob;not null;default:'{}'"` // Fee data
}

type FeeData added in v0.0.5

type FeeData String

type FeeID added in v0.0.5

type FeeID ID

type FeeInfo added in v0.0.5

type FeeInfo struct {
	Currency CurrencyName `gorm:"primary_key"`            // [PK] Related currency
	Minimum  Float        `gorm:"default:0.0;not null"`   // Minimum Fee
	Rate     Float        `gorm:"default:0.001;not null"` // Percent Fee Rate (default 0.1%)
}

func (*FeeInfo) Compute added in v0.0.5

func (p *FeeInfo) Compute(amount Float) Float

func (*FeeInfo) IsValid added in v0.0.5

func (p *FeeInfo) IsValid() bool

type Float added in v0.0.2

type Float float64

func ToFixedFloat added in v0.0.2

func ToFixedFloat(value Float) Float

type ID added in v0.0.2

type ID uint64

type Int added in v0.0.2

type Int int

type OAuth added in v0.0.2

type OAuth struct {
	ID         ID     `gorm:"primary_key"`                                            // [PK] OAuth
	Provider   string `gorm:"unique_index:idx_prov_provid;not null;type:varchar(16)"` // [U] Provider name
	ProviderID string `gorm:"unique_index:idx_prov_provid;not null;type:varchar(64)"` // [U] Provider unique ID (from goth User.UserID)
	UserID     UserID `gorm:"index;not null"`                                         // [FK] Reference to User table. Same user can have multiple providers
}

type OAuthData added in v0.0.2

type OAuthData struct {
	OAuthID ID     `gorm:"unique_index;not null"`           // [FK] Reference to OAuth table
	Data    string `gorm:"type:json;not null;default:'{}'"` // goth User json data
}

type OperationInfo added in v0.0.3

type OperationInfo struct {
	ID              OperationInfoID `gorm:"primary_key;"`                  // [PK] OperationInfo
	CryptoAddressID CryptoAddressID `gorm:"index;not null"`                // [FK] Reference to CryptoAddress table
	AssetID         AssetID         `gorm:"default:0;not null"`            // [FK] Reference to Asset table, optional
	Timestamp       time.Time       `gorm:"index;not null;type:timestamp"` // Creation timestamp
	TxID            TxID            `gorm:"unique_index;not null;size:64"` // Transaction ID
	Vout            Vout            `gorm:"default:0"`                     // Transaction output ID
	Amount          Float           `gorm:"default:0.0;not null"`          // Operation amount (GTE 0.0)
	Data            String          `gorm:"type:json;not null"`            // Specific operation json data
}

type OperationInfoID added in v0.0.3

type OperationInfoID ID

type OperationStatus added in v0.0.3

type OperationStatus struct {
	OperationInfoID OperationInfoID `gorm:"unique_index;not null"`           // [FK] Reference to OperationInfo table
	LastUpdate      time.Time       `gorm:"index;not null;type:timestamp"`   // Last update timestamp
	State           string          `gorm:"index;not null;type:varchar(16)"` // [enum] Operation synchroneous state (received, confirmed, settled)
	Accounted       string          `gorm:"index;not null;type:varchar(16)"` // Accounted state (see State)
}

type OperationType added in v0.0.2

type OperationType String
const (
	OperationTypeInvalid OperationType = ""

	OperationTypeInit        OperationType = "init"
	OperationTypeDeposit     OperationType = "deposit"
	OperationTypeWithdraw    OperationType = "withdraw"
	OperationTypeTransfer    OperationType = "transfer"
	OperationTypeTransferFee OperationType = "transfer_fee"
	OperationTypeRefund      OperationType = "refund"
	OperationTypeAdjustment  OperationType = "adjustment"

	OperationTypeNone  OperationType = "none"
	OperationTypeOther OperationType = "other"
)

func ParseOperationType added in v0.0.2

func ParseOperationType(str string) OperationType

func (OperationType) String added in v0.0.2

func (p OperationType) String() string

func (OperationType) Valid added in v0.0.2

func (p OperationType) Valid() bool

type Payload added in v0.0.4

type Payload String

type RefID added in v0.0.2

type RefID ID

type RoleName added in v0.1.0

type RoleName String
const (
	RoleNameDefault RoleName = "default"
	RoleNameAdmin   RoleName = "admin"
)

type SsmAddress added in v0.0.5

type SsmAddress struct {
	ID            SsmAddressID     `gorm:"primary_key;"`                   // [PK] SsmAddress ID
	PublicAddress SsmPublicAddress `gorm:"unique_index;not null;size:126"` // Ssm Address, non mutable
	ScriptPubkey  SsmPubkey        `gorm:"not null;size:66"`               // Ssm Script, non mutable
	BlindingKey   SsmBlindingKey   `gorm:"not null;size:64"`               // Ssm BlindingKey, non mutable (optional)
}

func (*SsmAddress) IsValid added in v0.0.5

func (p *SsmAddress) IsValid() bool

type SsmAddressID added in v0.0.5

type SsmAddressID ID

type SsmAddressInfo added in v0.0.5

type SsmAddressInfo struct {
	SsmAddressID SsmAddressID   `gorm:"unique_index;not null"`  // [FK] Reference to SsmAddress table
	Chain        SsmChain       `gorm:"index;not null;size:16"` // Ssm chain, non mutable
	Fingerprint  SsmFingerprint `gorm:"index;not null;size:8"`  // Ssm fingerprint, non mutable
	HDPath       SsmHDPath      `gorm:"index;not null;size:24"` // Ssm HDPath, non mutable
}

func (*SsmAddressInfo) IsValid added in v0.0.5

func (p *SsmAddressInfo) IsValid() bool

type SsmAddressState added in v0.0.5

type SsmAddressState struct {
	ID           SsmAddressStateID `gorm:"primary_key;"`                  // [PK] SsmAddressState ID
	SsmAddressID SsmAddressID      `gorm:"index;not null"`                // [FK] Reference to SsmAddress table
	Timestamp    time.Time         `gorm:"index;not null;type:timestamp"` // Creation timestamp
	State        SsmAddressStatus  `gorm:"not null;size:64"`              // Ssm State [unused, used, blacklisted]
}

type SsmAddressStateID added in v0.0.5

type SsmAddressStateID ID

type SsmAddressStatus added in v0.0.5

type SsmAddressStatus String

type SsmBlindingKey added in v0.0.5

type SsmBlindingKey String

type SsmChain added in v0.0.5

type SsmChain String

type SsmFingerprint added in v0.0.5

type SsmFingerprint String

type SsmHDPath added in v0.0.5

type SsmHDPath String

type SsmPubkey added in v0.0.5

type SsmPubkey String

type SsmPublicAddress added in v0.0.5

type SsmPublicAddress String

type String added in v0.0.2

type String string

type Swap added in v0.0.4

type Swap struct {
	ID              SwapID          `gorm:"primary_key"`
	Timestamp       time.Time       `gorm:"index;not null;type:timestamp"` // Creation timestamp
	ValidUntil      time.Time       `gorm:"index;not null;type:timestamp"` // Valid Until
	Type            SwapType        `gorm:"index;not null;size:16"`        // SwapType [bid, ask]
	CryptoAddressID CryptoAddressID `gorm:"index;not null"`                // [FK] Reference to CryptoAddress table
	DebitAsset      AssetID         `gorm:"index;not null"`                // [FK] Reference to Asset table for Debit
	DebitAmount     Float           `gorm:"default:0;not null"`            // DebitAmount (strictly positive)
	CreditAsset     AssetID         `gorm:"index;not null"`                // [FK] Reference to Asset table for Credit
	CreditAmount    Float           `gorm:"default:0;not null"`            // CreditAmount (strictly positive)
}

type SwapID added in v0.0.4

type SwapID ID

type SwapInfo added in v0.0.4

type SwapInfo struct {
	ID        SwapInfoID `gorm:"primary_key"`
	Timestamp time.Time  `gorm:"index;not null;type:timestamp"` // Creation timestamp
	SwapID    SwapID     `gorm:"index;not null"`                // [FK] Reference to Swap table
	Status    SwapStatus `gorm:"index;not null;size:16"`        // SwapStatus [proposed, accepted, finalized, completed, canceled]
	Payload   Payload    `gorm:"type:blob;not null"`            // Payload swap data
}

type SwapInfoID added in v0.0.4

type SwapInfoID ID

type SwapStatus added in v0.0.4

type SwapStatus String
const (
	SwapStatusProposed  SwapStatus = "proposed"
	SwapStatusAccepted  SwapStatus = "accepted"
	SwapStatusFinalized SwapStatus = "finalized"
	SwapStatusCompleted SwapStatus = "completed"
	SwapStatusCanceled  SwapStatus = "canceled"
)

type SwapType added in v0.0.4

type SwapType String
const (
	SwapTypeBid SwapType = "bid"
	SwapTypeAsk SwapType = "ask"

	SwapTypeInternalBid SwapType = "internal_bid"
	SwapTypeInternalAsk SwapType = "internal_ask"
)

type SynchroneousType added in v0.0.2

type SynchroneousType String
const (
	SynchroneousTypeInvalid SynchroneousType = ""

	SynchroneousTypeSync       SynchroneousType = "sync"
	SynchroneousTypeAsyncStart SynchroneousType = "async-start"
	SynchroneousTypeAsyncEnd   SynchroneousType = "async-end"
)

func ParseSynchroneousType added in v0.0.2

func ParseSynchroneousType(str string) SynchroneousType

func (SynchroneousType) String added in v0.0.2

func (p SynchroneousType) String() string

func (SynchroneousType) Valid added in v0.0.2

func (p SynchroneousType) Valid() bool

type TxID added in v0.0.3

type TxID String

type User

type User struct {
	ID    UserID    `gorm:"primary_key"`
	Name  UserName  `gorm:"size:64;unique;not null"`
	Email UserEmail `gorm:"size:256;unique;not null"`
}

type UserEmail added in v0.0.2

type UserEmail String

type UserID added in v0.0.2

type UserID ID

type UserName added in v0.0.2

type UserName String

type UserRole added in v0.1.0

type UserRole struct {
	UserID UserID   `gorm:"unique_index:idx_user_role;index;not null"` // [FK] Reference to User table
	Role   RoleName `gorm:"unique_index:idx_user_role;not null"`       // RoleName
}

type Vout added in v0.0.3

type Vout ID

type Withdraw added in v0.0.5

type Withdraw struct {
	ID        WithdrawID   `gorm:"primary_key"`
	Timestamp time.Time    `gorm:"index;not null;type:timestamp"`   // Creation timestamp
	From      AccountID    `gorm:"index;not null"`                  // [FK] Reference to Account table
	To        AccountID    `gorm:"index;not null"`                  // [FK] Reference to Account table
	Amount    ZeroFloat    `gorm:"default:0;not null"`              // Operation amount (can not be negative)
	Batch     BatchMode    `gorm:"index;not null;size:16"`          // BatchMode [instant, fast, normal, slow]
	Data      WithdrawData `gorm:"type:blob;not null;default:'{}'"` // Withdraw data
}

type WithdrawData added in v0.0.5

type WithdrawData String

type WithdrawID added in v0.0.5

type WithdrawID ID

type WithdrawInfo added in v0.0.5

type WithdrawInfo struct {
	ID         WithdrawInfoID   `gorm:"primary_key"`
	Timestamp  time.Time        `gorm:"index;not null;type:timestamp"`   // Creation timestamp
	WithdrawID WithdrawID       `gorm:"index;not null"`                  // [FK] Reference to Withdraw table
	Status     WithdrawStatus   `gorm:"index;not null;size:16"`          // WithdrawStatus [created, processing, completed, canceled]
	Data       WithdrawInfoData `gorm:"type:blob;not null;default:'{}'"` // WithdrawInfo data
}

type WithdrawInfoData added in v0.0.5

type WithdrawInfoData String

type WithdrawInfoID added in v0.0.5

type WithdrawInfoID ID

type WithdrawStatus added in v0.0.5

type WithdrawStatus String
const (
	WithdrawStatusCreated    WithdrawStatus = "created"
	WithdrawStatusProcessing WithdrawStatus = "processing"
	WithdrawStatusSettled    WithdrawStatus = "settled"
	WithdrawStatusCanceling  WithdrawStatus = "canceling"
	WithdrawStatusCanceled   WithdrawStatus = "canceled"
)

type WithdrawTarget added in v0.0.5

type WithdrawTarget struct {
	ID         WithdrawTargetID   `gorm:"primary_key"`
	WithdrawID WithdrawID         `gorm:"index;not null"`                  // [FK] Reference to Withdraw table
	Type       WithdrawTargetType `gorm:"index;not null;size:16"`          // DataType [onchain, liquid, lightning, sepa, swift, card]
	Data       WithdrawTargetData `gorm:"type:blob;not null;default:'{}'"` // WithdrawTarget data
}

func FromCardData added in v0.0.5

func FromCardData(withdrawID WithdrawID, card WithdrawTargetCardData) WithdrawTarget

func FromLightningData added in v0.0.5

func FromLightningData(withdrawID WithdrawID, lightning WithdrawTargetLightningData) WithdrawTarget

func FromLiquidData added in v0.0.5

func FromLiquidData(withdrawID WithdrawID, liquid WithdrawTargetLiquidData) WithdrawTarget

func FromOnChainData added in v0.0.5

func FromOnChainData(withdrawID WithdrawID, chain string, onChain WithdrawTargetOnChainData) WithdrawTarget

func FromSepaData added in v0.0.5

func FromSepaData(withdrawID WithdrawID, sepa WithdrawTargetSepaData) WithdrawTarget

func FromSwiftData added in v0.0.5

func FromSwiftData(withdrawID WithdrawID, swift WithdrawTargetSwiftData) WithdrawTarget

func (*WithdrawTarget) CardData added in v0.0.5

func (p *WithdrawTarget) CardData() (WithdrawTargetCardData, error)

func (*WithdrawTarget) LightningData added in v0.0.5

func (p *WithdrawTarget) LightningData() (WithdrawTargetLightningData, error)

func (*WithdrawTarget) LiquidData added in v0.0.5

func (p *WithdrawTarget) LiquidData() (WithdrawTargetLiquidData, error)

func (*WithdrawTarget) OnChainData added in v0.0.5

func (p *WithdrawTarget) OnChainData() (WithdrawTargetOnChainData, error)

func (*WithdrawTarget) SepaData added in v0.0.5

func (p *WithdrawTarget) SepaData() (WithdrawTargetSepaData, error)

func (*WithdrawTarget) SwiftData added in v0.0.5

func (p *WithdrawTarget) SwiftData() (WithdrawTargetSwiftData, error)

type WithdrawTargetCardData added in v0.0.5

type WithdrawTargetCardData struct {
	WithdrawTargetFiatData
	PAN string `json:"pan,omitempty"`
}

WithdrawTargetCardData data type for WithdrawTargetType card

type WithdrawTargetCryptoData added in v0.0.5

type WithdrawTargetCryptoData struct {
	Chain     string `json:"chain,omitempty"`
	PublicKey string `json:"publickey,omitempty"`
}

WithdrawTargetCryptoData data type for WithdrawTargetType crypto, liquid & lightning

type WithdrawTargetData added in v0.0.5

type WithdrawTargetData encoding.Data

type WithdrawTargetFiatData added in v0.0.5

type WithdrawTargetFiatData struct {
	Network string `json:"network,omitempty"`
}

WithdrawTargetFiatData data type for WithdrawTargetType sepa, swift & cb

type WithdrawTargetID added in v0.0.5

type WithdrawTargetID ID

type WithdrawTargetLightningData added in v0.0.5

type WithdrawTargetLightningData struct {
	WithdrawTargetCryptoData
	Invoice string `json:"invoice,omitempty"`
}

WithdrawTargetLightningData data type for WithdrawTargetType Lightning

type WithdrawTargetLiquidData added in v0.0.5

type WithdrawTargetLiquidData struct {
	WithdrawTargetCryptoData
}

WithdrawTargetLiquidData data type for WithdrawTargetType liquid

type WithdrawTargetOnChainData added in v0.0.5

type WithdrawTargetOnChainData struct {
	WithdrawTargetCryptoData
}

WithdrawTargetOnChainData data type for WithdrawTargetType crypto

type WithdrawTargetSepaData added in v0.0.5

type WithdrawTargetSepaData struct {
	WithdrawTargetFiatData
	BIC  string `json:"bic,omitempty"`
	IBAN string `json:"iban,omitempty"`
}

WithdrawTargetSepaData data type for WithdrawTargetType sepa

type WithdrawTargetSwiftData added in v0.0.5

type WithdrawTargetSwiftData struct {
	WithdrawTargetFiatData
	CountryCode string `json:"country_code,omitempty"`
	Bank        string `json:"bank,omitempty"`
	Account     string `json:"account,omitempty"`
}

WithdrawTargetSwiftData data type for WithdrawTargetType sepa

type WithdrawTargetType added in v0.0.5

type WithdrawTargetType encoding.DataType
const (
	// Fiat
	WithdrawTargetSepa  WithdrawTargetType = "sepa"
	WithdrawTargetSwift WithdrawTargetType = "swift"
	WithdrawTargetCard  WithdrawTargetType = "card"

	// Crypto
	WithdrawTargetOnChain   WithdrawTargetType = "onchain"
	WithdrawTargetLiquid    WithdrawTargetType = "liquid"
	WithdrawTargetLightning WithdrawTargetType = "lightning"
)

type ZeroFloat added in v0.0.2

type ZeroFloat *Float

type ZeroInt added in v0.0.2

type ZeroInt *Int

Jump to

Keyboard shortcuts

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