Documentation
¶
Index ¶
- Constants
- type AssetStore
- type Balance
- type Contract
- type ContractState
- type ContractStore
- type ContractType
- type Cursor
- type GetVtxoFilter
- type LockedOnchainBalance
- type OffchainBalance
- type OnchainAddressEvent
- type OnchainBalance
- type Store
- type SyncEvent
- type TransactionEvent
- type TransactionStore
- type TxEventType
- type UtxoEvent
- type UtxoEventType
- type UtxoStore
- type VtxoDetails
- type VtxoEvent
- type VtxoEventType
- type VtxoPageResult
- type VtxoStatusFilter
- type VtxoStore
Constants ¶
const ( InMemoryStore = "inmemory" FileStore = "file" SQLStore = "sql" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetStore ¶
type Balance ¶ added in v0.10.0
type Balance struct {
OnchainBalance OnchainBalance `json:"onchain_balance"`
OffchainBalance OffchainBalance `json:"offchain_balance"`
Total uint64 `json:"total"`
AssetBalances map[string]uint64 `json:"asset_balances,omitempty"`
}
Balance represents the full wallet balance including both on-chain and off-chain (Ark) funds.
type ContractState ¶ added in v0.10.0
type ContractState string
const ( ContractStateActive ContractState = "active" ContractStateInactive ContractState = "inactive" )
type ContractStore ¶ added in v0.10.0
type ContractStore interface {
AddContract(ctx context.Context, c Contract, keyIndex uint32) error
ListContracts(ctx context.Context) ([]Contract, error)
GetContractsByScripts(ctx context.Context, scripts []string) ([]Contract, error)
GetContractsByState(ctx context.Context, state ContractState) ([]Contract, error)
GetActiveContractsByType(ctx context.Context, contractType ContractType) ([]Contract, error)
GetLatestActiveContract(ctx context.Context, contractType ContractType) (*Contract, error)
UpdateContractState(ctx context.Context, script string, state ContractState) error
Clean(ctx context.Context) error
}
type ContractType ¶ added in v0.10.0
type ContractType string
const ( ContractTypeDefault ContractType = "default" ContractTypeBoarding ContractType = "boarding" )
type Cursor ¶ added in v0.10.0
Cursor is the cursor position in the (created_at DESC, txid DESC, vout DESC) sort order.
type GetVtxoFilter ¶ added in v0.10.0
type GetVtxoFilter struct {
Status VtxoStatusFilter
AssetID string // "" = no asset filter
Script string // "" = no script filter
After *Cursor // nil = first page
Limit int // number of VTXOs to return
}
GetVtxoFilter defines all filters that can be applied to a GetVtxos request.
type LockedOnchainBalance ¶ added in v0.10.0
type LockedOnchainBalance struct {
SpendableAt string `json:"spendable_at"`
Amount uint64 `json:"amount"`
}
LockedOnchainBalance represents on-chain funds that are locked until a specific time.
type OffchainBalance ¶ added in v0.10.0
type OffchainBalance struct {
Total uint64 `json:"total"`
NextExpiration string `json:"next_expiration,omitempty"`
Details []VtxoDetails `json:"details"`
Available uint64 `json:"available"`
Preconfirmed uint64 `json:"preconfirmed"`
Recoverable uint64 `json:"recoverable"`
Settled uint64 `json:"settled"`
}
OffchainBalance represents the off-chain (Ark) balance with state breakdowns.
type OnchainAddressEvent ¶
type OnchainAddressEvent struct {
Error error
SpentUtxos []clientTypes.OnchainOutput
NewUtxos []clientTypes.OnchainOutput
ConfirmedUtxos []clientTypes.OnchainOutput
Replacements map[string]string // replacedTxid -> replacementTxid
}
type OnchainBalance ¶ added in v0.10.0
type OnchainBalance struct {
Confirmed uint64 `json:"confirmed"`
Unconfirmed uint64 `json:"unconfirmed"`
Total uint64 `json:"total"`
SpendableAmount uint64 `json:"spendable_amount"`
LockedAmount []LockedOnchainBalance `json:"locked_amount,omitempty"`
}
OnchainBalance represents the on-chain (boarding) balance.
type Store ¶
type Store interface {
TransactionStore() TransactionStore
UtxoStore() UtxoStore
VtxoStore() VtxoStore
AssetStore() AssetStore
ContractStore() ContractStore
Clean(ctx context.Context)
Close()
}
type TransactionEvent ¶
type TransactionEvent struct {
Type TxEventType
Txs []clientTypes.Transaction
Replacements map[string]string
}
type TransactionStore ¶
type TransactionStore interface {
AddTransactions(ctx context.Context, txs []types.Transaction) (int, error)
SettleTransactions(ctx context.Context, txids []string, settledBy string) (int, error)
ConfirmTransactions(ctx context.Context, txids []string, timestamp time.Time) (int, error)
RbfTransactions(ctx context.Context, rbfTxs map[string]string) (int, error)
GetAllTransactions(ctx context.Context) ([]types.Transaction, error)
GetTransactions(ctx context.Context, txids []string) ([]types.Transaction, error)
UpdateTransactions(ctx context.Context, txs []types.Transaction) (int, error)
Clean(ctx context.Context) error
GetEventChannel() <-chan TransactionEvent
}
type TxEventType ¶
type TxEventType int
const ( TxsAdded TxEventType = iota TxsSettled TxsConfirmed TxsReplaced TxsUpdated )
func (TxEventType) String ¶
func (e TxEventType) String() string
type UtxoEvent ¶
type UtxoEvent struct {
Type UtxoEventType
Utxos []clientTypes.Utxo
}
type UtxoEventType ¶
type UtxoEventType int
const ( UtxosAdded UtxoEventType = iota UtxosConfirmed UtxosReplaced UtxosSpent )
func (UtxoEventType) String ¶
func (e UtxoEventType) String() string
type UtxoStore ¶
type UtxoStore interface {
AddUtxos(ctx context.Context, utxos []types.Utxo) (int, error)
ReplaceUtxo(ctx context.Context, from, to types.Outpoint) error
ConfirmUtxos(ctx context.Context, confirmedUtxos map[types.Outpoint]int64) (int, error)
SpendUtxos(ctx context.Context, spentUtxos map[types.Outpoint]string) (int, error)
DeleteUtxos(ctx context.Context, outpoints []types.Outpoint) (int, error)
GetAllUtxos(ctx context.Context) (spendable, spent []types.Utxo, err error)
GetUtxos(ctx context.Context, keys []types.Outpoint) ([]types.Utxo, error)
GetUtxosByTxid(ctx context.Context, txid string) ([]types.Utxo, error)
Clean(ctx context.Context) error
GetEventChannel() <-chan UtxoEvent
}
type VtxoDetails ¶ added in v0.10.0
VtxoDetails provides per-expiration balance breakdown.
type VtxoEvent ¶
type VtxoEvent struct {
Type VtxoEventType
Vtxos []clientTypes.Vtxo
}
type VtxoEventType ¶
type VtxoEventType int
const ( VtxosAdded VtxoEventType = iota VtxosSpent VtxoSettled VtxosSwept VtxosUnrolled )
func (VtxoEventType) String ¶
func (e VtxoEventType) String() string
type VtxoPageResult ¶ added in v0.10.0
VtxoPageResult is the typed page response from VtxoStore.GetVtxos. Next is nil when there is no further page.
type VtxoStatusFilter ¶ added in v0.10.0
type VtxoStatusFilter int
VtxoStatusFilter narrows GetVtxos results by spend/unroll state.
const ( VtxoStatusAll VtxoStatusFilter = iota // no status filter VtxoStatusSpendable // spent = false AND unrolled = false VtxoStatusSpent // spent = true OR unrolled = true )
type VtxoStore ¶
type VtxoStore interface {
AddVtxos(ctx context.Context, vtxos []types.Vtxo) (int, error)
SpendVtxos(
ctx context.Context, spentVtxos map[types.Outpoint]string, arkTxid string,
) (int, error)
SettleVtxos(
ctx context.Context, spentVtxos map[types.Outpoint]string, settledBy string,
) (int, error)
SweepVtxos(ctx context.Context, vtxosToSweep []types.Vtxo) (int, error)
UnrollVtxos(ctx context.Context, vtxosToUnroll []types.Vtxo) (int, error)
// GetSpendableOrRecoverableVtxos returns all VTXOs where spent = false AND
// unrolled = false. This is the union of strictly spendable VTXOs and
// recoverable VTXOs (swept or expired, but not spent). Callers needing to
// distinguish use IsRecoverable on each returned VTXO.
GetSpendableOrRecoverableVtxos(ctx context.Context) ([]types.Vtxo, error)
// GetVtxosByOutpoints returns VTXOs matching the given outpoints.
GetVtxosByOutpoints(ctx context.Context, keys []types.Outpoint) ([]types.Vtxo, error)
// GetVtxos returns one page of VTXOs according to q. When the returned
// cursor is nil, the page is the end of the result set. The cursor is an
// internal keyset position used by the public Wallet.ListVtxos API.
GetVtxos(ctx context.Context, q GetVtxoFilter) ([]types.Vtxo, *Cursor, error)
Clean(ctx context.Context) error
GetEventChannel() <-chan VtxoEvent
}