application

package
v0.0.0-...-241d3e1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

* This package contains intermediary events that are used only by the covenantless version * they let to sign the vtxo tree using musig2 algorithm * they are not included in domain because they don't mutate the Round state and should not be persisted

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminService

type AdminService interface {
	Wallet() ports.WalletService
	GetScheduledSweeps(ctx context.Context) ([]ScheduledSweep, error)
	GetRoundDetails(ctx context.Context, roundId string) (*RoundDetails, error)
	GetRounds(ctx context.Context, after int64, before int64) ([]string, error)
	GetWalletAddress(ctx context.Context) (string, error)
	GetWalletStatus(ctx context.Context) (*WalletStatus, error)
	CreateNotes(ctx context.Context, amount uint32, quantity int) ([]string, error)
}

func NewAdminService

func NewAdminService(walletSvc ports.WalletService, repoManager ports.RepoManager, txBuilder ports.TxBuilder, timeUnit ports.TimeUnit) AdminService

type ArkProviderBalance

type ArkProviderBalance struct {
	MainAccountBalance       Balance
	ConnectorsAccountBalance Balance
}

type Balance

type Balance struct {
	Locked    uint64
	Available uint64
}

type Batch

type Batch struct {
	TotalOutputAmount uint64
	TotalOutputVtxos  int32
	ExpiresAt         int64
	Swept             bool
}

type ChainTx

type ChainTx struct {
	Txid string
	Type string
}

type ChainWithExpiry

type ChainWithExpiry struct {
	Txid      string
	Txs       []ChainTx
	ExpiresAt int64
}

type CommitmentTxLeavesResp

type CommitmentTxLeavesResp struct {
	Leaves []domain.Vtxo
	Page   PageResp
}

type CommitmentTxResp

type CommitmentTxResp struct {
	StartedAt         int64
	EndAt             int64
	Batches           map[VOut]Batch
	TotalInputAmount  uint64
	TotalInputtVtxos  int32
	TotalOutputAmount uint64
	TotalOutputVtxos  int32
}

type ConnectorResp

type ConnectorResp struct {
	Connectors []Node
	Page       PageResp
}

type ForfeitTxsResp

type ForfeitTxsResp struct {
	Txs  []string
	Page PageResp
}

type GetVtxosResp

type GetVtxosResp struct {
	Vtxos []domain.Vtxo
	Page  PageResp
}

type IndexerService

type IndexerService interface {
	GetCommitmentTxInfo(ctx context.Context, txid string) (*CommitmentTxResp, error)
	GetCommitmentTxLeaves(ctx context.Context, txid string, page *Page) (*CommitmentTxLeavesResp, error)
	GetVtxoTree(ctx context.Context, batchOutpoint Outpoint, page *Page) (*VtxoTreeResp, error)
	GetVtxoTreeLeaves(ctx context.Context, batchOutpoint Outpoint, page *Page) (*VtxoTreeLeavesResp, error)
	GetForfeitTxs(ctx context.Context, txid string, page *Page) (*ForfeitTxsResp, error)
	GetConnectors(ctx context.Context, txid string, page *Page) (*ConnectorResp, error)
	GetVtxos(ctx context.Context, pubkeys []string, spendableOnly, spendOnly bool, page *Page) (*GetVtxosResp, error)
	GetVtxosByOutpoint(ctx context.Context, outpoints []Outpoint, page *Page) (*GetVtxosResp, error)
	GetTransactionHistory(ctx context.Context, pubkey string, start, end int64, page *Page) (*TxHistoryResp, error)
	GetVtxoChain(ctx context.Context, vtxoKey Outpoint, page *Page) (*VtxoChainResp, error)
	GetVirtualTxs(ctx context.Context, txids []string, page *Page) (*VirtualTxsResp, error)
	GetSweptCommitmentTx(ctx context.Context, txid string) (*SweptCommitmentTxResp, error)
}

func NewIndexerService

func NewIndexerService(
	pubkey *secp256k1.PublicKey,
	repoManager ports.RepoManager,
) IndexerService

type NextMarketHour

type NextMarketHour struct {
	StartTime     time.Time
	EndTime       time.Time
	Period        time.Duration
	RoundInterval time.Duration
}

type Node

type Node struct {
	Txid       string
	Tx         string
	ParentTxid string
	Level      int32
	LevelIndex int32
}

type Outpoint

type Outpoint struct {
	Txid string
	Vout uint32
}

type Page

type Page struct {
	PageSize int32
	PageNum  int32
}

type PageResp

type PageResp struct {
	Current int32
	Next    int32
	Total   int32
}

type RedeemTransactionEvent

type RedeemTransactionEvent struct {
	RedeemTxid     string
	SpentVtxos     []domain.Vtxo
	SpendableVtxos []domain.Vtxo
	TxHex          string
}

func (RedeemTransactionEvent) GetSpendableVtxos

func (r RedeemTransactionEvent) GetSpendableVtxos() []domain.Vtxo

func (RedeemTransactionEvent) GetSpentVtxos

func (r RedeemTransactionEvent) GetSpentVtxos() []domain.Vtxo

func (RedeemTransactionEvent) GetTxId

func (r RedeemTransactionEvent) GetTxId() string

func (RedeemTransactionEvent) Type

type RoundDetails

type RoundDetails struct {
	RoundId          string
	TxId             string
	ForfeitedAmount  uint64
	TotalVtxosAmount uint64
	TotalExitAmount  uint64
	FeesAmount       uint64
	InputsVtxos      []string
	OutputsVtxos     []string
	ExitAddresses    []string
}

type RoundSigningNoncesGenerated

type RoundSigningNoncesGenerated struct {
	Id     string
	Nonces tree.TreeNonces // aggregated nonces
}

signer should react to this event by partially signing the vtxo tree transactions then, delete its ephemeral key

func (RoundSigningNoncesGenerated) IsEvent

func (r RoundSigningNoncesGenerated) IsEvent()

func (RoundSigningNoncesGenerated) SerializeNonces

func (e RoundSigningNoncesGenerated) SerializeNonces() (string, error)

type RoundSigningStarted

type RoundSigningStarted struct {
	Id               string
	UnsignedVtxoTree tree.TxTree
	UnsignedRoundTx  string
	CosignersPubkeys []string
}

signer should react to this event by generating a musig2 nonce for each transaction in the tree

func (RoundSigningStarted) IsEvent

func (r RoundSigningStarted) IsEvent()

implement domain.RoundEvent interface

type RoundTransactionEvent

type RoundTransactionEvent struct {
	RoundTxid             string
	SpentVtxos            []domain.Vtxo
	SpendableVtxos        []domain.Vtxo
	ClaimedBoardingInputs []domain.VtxoKey
	TxHex                 string
}

func (RoundTransactionEvent) GetSpendableVtxos

func (r RoundTransactionEvent) GetSpendableVtxos() []domain.Vtxo

func (RoundTransactionEvent) GetSpentVtxos

func (r RoundTransactionEvent) GetSpentVtxos() []domain.Vtxo

func (RoundTransactionEvent) GetTxId

func (r RoundTransactionEvent) GetTxId() string

func (RoundTransactionEvent) Type

type ScheduledSweep

type ScheduledSweep struct {
	RoundId          string
	SweepableOutputs []SweepableOutput
}

type Service

type Service interface {
	Start() error
	Stop()
	SpendNotes(ctx context.Context, notes []note.Note) (string, error)
	RegisterIntent(ctx context.Context, bip322signature bip322.Signature, message tree.IntentMessage) (string, error)
	SpendVtxos(ctx context.Context, inputs []ports.Input) (string, error)
	ClaimVtxos(ctx context.Context, creds string, receivers []domain.Receiver, musig2Data *tree.Musig2) error
	SignVtxos(ctx context.Context, forfeitTxs []string) error
	SignRoundTx(ctx context.Context, roundTx string) error
	GetRoundByTxid(ctx context.Context, roundTxid string) (*domain.Round, error)
	GetRoundById(ctx context.Context, id string) (*domain.Round, error)
	GetCurrentRound(ctx context.Context) (*domain.Round, error)
	GetEventsChannel(ctx context.Context) <-chan domain.RoundEvent
	UpdateTxRequestStatus(ctx context.Context, requestID string) error
	ListVtxos(
		ctx context.Context, address string,
	) (spendableVtxos, spentVtxos []domain.Vtxo, err error)
	GetInfo(ctx context.Context) (*ServiceInfo, error)
	SubmitRedeemTx(ctx context.Context, redeemTx string) (signedRedeemTx, redeemTxid string, err error)
	GetBoardingAddress(
		ctx context.Context, userPubkey *secp256k1.PublicKey,
	) (address string, scripts []string, err error)
	// Tree signing methods
	RegisterCosignerNonces(
		ctx context.Context, roundID string,
		pubkey *secp256k1.PublicKey, nonces string,
	) error
	RegisterCosignerSignatures(
		ctx context.Context, roundID string,
		pubkey *secp256k1.PublicKey, signatures string,
	) error
	GetTransactionEventsChannel(ctx context.Context) <-chan TransactionEvent
	GetMarketHourConfig(ctx context.Context) (*domain.MarketHour, error)
	UpdateMarketHourConfig(ctx context.Context, marketHourStartTime, marketHourEndTime time.Time, period, roundInterval time.Duration) error
	GetTxRequestQueue(ctx context.Context, requestIds ...string) ([]TxRequestInfo, error)
	DeleteTxRequests(ctx context.Context, requestIds ...string) error

	// TODO remove this in v7
	GetIndexerTxChannel(ctx context.Context) <-chan TransactionEvent
}

func NewService

func NewService(
	network common.Network,
	roundInterval int64,
	vtxoTreeExpiry, unilateralExitDelay, boardingExitDelay common.RelativeLocktime,
	walletSvc ports.WalletService, repoManager ports.RepoManager,
	builder ports.TxBuilder, scanner ports.BlockchainScanner,
	scheduler ports.SchedulerService,
	noteUriPrefix string,
	marketHourStartTime, marketHourEndTime time.Time,
	marketHourPeriod, marketHourRoundInterval time.Duration,
	allowZeroFees bool,
	roundMaxParticipantsCount int64,
	utxoMaxAmount int64,
	utxoMinAmount int64,
	vtxoMaxAmount int64,
	vtxoMinAmount int64,
) (Service, error)

type ServiceInfo

type ServiceInfo struct {
	PubKey              string
	VtxoTreeExpiry      int64
	UnilateralExitDelay int64
	BoardingExitDelay   int64
	RoundInterval       int64
	Network             string
	Dust                uint64
	ForfeitAddress      string
	NextMarketHour      *NextMarketHour
	UtxoMinAmount       int64
	UtxoMaxAmount       int64
	VtxoMinAmount       int64
	VtxoMaxAmount       int64
}

type SweepableOutput

type SweepableOutput struct {
	TxId        string
	Vout        uint32
	Amount      uint64
	ScheduledAt int64
}

type SweptCommitmentTxResp

type SweptCommitmentTxResp struct {
	SweptBy []string
}

type TransactionEvent

type TransactionEvent interface {
	Type() TransactionEventType
	GetSpentVtxos() []domain.Vtxo
	GetSpendableVtxos() []domain.Vtxo
	GetTxId() string
}

type TransactionEventType

type TransactionEventType string
const (
	RoundTransaction  TransactionEventType = "round_tx"
	RedeemTransaction TransactionEventType = "redeem_tx"
)

type TxHistoryRecord

type TxHistoryRecord struct {
	CommitmentTxid string
	VirtualTxid    string
	Type           TxType
	Amount         uint64
	CreatedAt      time.Time
	Settled        bool
	SettledBy      string
}

type TxHistoryResp

type TxHistoryResp struct {
	Records []TxHistoryRecord
	Page    PageResp
}

type TxRequestInfo

type TxRequestInfo struct {
	Id        string
	CreatedAt time.Time
	Receivers []struct {
		Address string
		Amount  uint64
	}
	Inputs         []domain.Vtxo
	BoardingInputs []ports.BoardingInput
	Notes          []note.Note
	SigningType    string
	Cosigners      []string
	LastPing       time.Time
}

type TxType

type TxType int
const (
	TxUnspecified TxType = iota
	TxReceived
	TxSent
)

type VOut

type VOut int

type VirtualTxsResp

type VirtualTxsResp struct {
	Transactions []string
	Page         PageResp
}

type VtxoChainResp

type VtxoChainResp struct {
	Chain              []ChainWithExpiry
	Page               PageResp
	Depth              int32
	RootCommitmentTxid string
}

type VtxoTreeLeavesResp

type VtxoTreeLeavesResp struct {
	Leaves []domain.Vtxo
	Page   PageResp
}

type VtxoTreeResp

type VtxoTreeResp struct {
	Nodes []Node
	Page  PageResp
}

type WalletStatus

type WalletStatus struct {
	IsInitialized bool
	IsUnlocked    bool
	IsSynced      bool
}

Jump to

Keyboard shortcuts

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