application

package
v0.0.0-...-d8d4545 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 34 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

View Source
const (
	SelectIntentsStage              = "select_intents_stage"
	ConfirmationStage               = "confirmation_stage"
	BuildCommitmentTxStage          = "build_commitment_tx_stage"
	TreeSigningStage                = "tree_signing_stage"
	ForfeitTxsCollectionStage       = "forfeit_txs_collection_stage"
	SignAndPublishCommitmentTxStage = "sign_and_publish_commitment_tx_stage"

	SendConfirmationEventOp          = "send_confiration_event_op"
	WaitForConfirmationOp            = "wait_for_confiration_op"
	BuildCommitmentTxOp              = "build_commitment_tx_op"
	CreateTreeNoncesOp               = "create_tree_nonces_op"
	SendUnsignedTreeEventOp          = "send_unsigned_tree_event_op"
	WaitForTreeNoncesOp              = "wait_for_tree_nonces_op"
	AggregateNoncesOp                = "aggregate_nonces_op"
	SendAggregatedTreeNoncesEventOp  = "send_aggregated_tree_nonces_event_op"
	SignTreeOp                       = "sign_tree_op"
	WaitForTreeSignaturesOp          = "wait_for_tree_signatures_op"
	AggregateTreeSignaturesOp        = "aggregate_tree_signatures_op"
	SendSignedTreeEventOp            = "send_signed_tree_event_op"
	VerifyForfeitsSignaturesOp       = "verify_forfeits_signatures_op"
	WaitForForfeitTxsOp              = "wait_for_forfeit_txs_op"
	VerifyBoardingInputsSignaturesOp = "verify_boarding_inputs_signatures_op"
	SignCommitmentTxOp               = "sign_commitment_tx_op"
	PublishCommitmentTxOp            = "publish_commitment_tx_op"
)

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)
	GetMarketHourConfig(ctx context.Context) (*domain.MarketHour, error)
	UpdateMarketHourConfig(
		ctx context.Context,
		marketHourStartTime, marketHourEndTime time.Time, period, roundInterval time.Duration,
	) error
	ListIntents(ctx context.Context, intentIds ...string) ([]IntentInfo, error)
	DeleteIntents(ctx context.Context, intentIds ...string) error
}

func NewAdminService

func NewAdminService(
	walletSvc ports.WalletService, repoManager ports.RepoManager, txBuilder ports.TxBuilder,
	liveStoreSvc ports.LiveStore, 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 BatchStarted

type BatchStarted struct {
	domain.RoundEvent
	IntentIdsHashes [][32]byte
	BatchExpiry     uint32
}

the user should react to this event by confirming the registration using intent_id

type ChainTx

type ChainTx struct {
	Txid      string
	ExpiresAt int64
	Type      ChainTxType
	Spends    []string
}

type ChainTxType

type ChainTxType string
const (
	IndexerChainedTxTypeUnspecified ChainTxType = "unspecified"
	IndexerChainedTxTypeCommitment  ChainTxType = "commitment"
	IndexerChainedTxTypeArk         ChainTxType = "ark"
	IndexerChainedTxTypeTree        ChainTxType = "tree"
	IndexerChainedTxTypeCheckpoint  ChainTxType = "checkpoint"
)

type CommitmentTxInfo

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

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) (*CommitmentTxInfo, error)
	GetVtxoTree(ctx context.Context, batchOutpoint Outpoint, page *Page) (*TreeTxResp, 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) (*TreeTxResp, error)
	GetVtxos(
		ctx context.Context,
		pubkeys []string, spendableOnly, spendOnly, recoverableOnly bool, page *Page,
	) (*GetVtxosResp, error)
	GetVtxosByOutpoint(
		ctx context.Context, outpoints []Outpoint, page *Page,
	) (*GetVtxosResp, error)
	GetVtxoChain(ctx context.Context, vtxoKey Outpoint, page *Page) (*VtxoChainResp, error)
	GetVirtualTxs(ctx context.Context, txids []string, page *Page) (*VirtualTxsResp, error)
	GetBatchSweepTxs(ctx context.Context, batchOutpoint Outpoint) ([]string, error)
}

func NewIndexerService

func NewIndexerService(repoManager ports.RepoManager) IndexerService

type IntentInfo

type IntentInfo struct {
	Id             string
	CreatedAt      time.Time
	Receivers      []Receiver
	Inputs         []domain.Vtxo
	BoardingInputs []ports.BoardingInput
	Cosigners      []string
	Proof          string
	Message        string
}

type NextMarketHour

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

type OpMetric

type OpMetric struct {
	Latency            float64 // seconds
	CPU                float64 // seconds
	CoreEq             float64
	UtilizedPct        float64
	MemAllocDelta      float64 // MB
	MemSysDelta        float64 // MB
	MemTotalAllocDelta float64 // MB
	GCDelta            uint32
}

type Outpoint

type Outpoint = domain.Outpoint

type Page

type Page struct {
	PageSize int32
	PageNum  int32
}

type PageResp

type PageResp struct {
	Current int32
	Next    int32
	Total   int32
}

type Receiver

type Receiver struct {
	VtxoScript     string
	OnchainAddress string
	Amount         uint64
}

type RoundDetails

type RoundDetails struct {
	RoundId          string
	TxId             string
	ForfeitedAmount  uint64
	TotalVtxosAmount uint64
	TotalExitAmount  uint64
	FeesAmount       uint64
	InputVtxos       []string
	OutputVtxos      []string
	ExitAddresses    []string
	StartedAt        int64
	EndedAt          int64
}

type RoundFinalized

type RoundFinalized struct {
	domain.RoundFinalized
	Txid string
}

type RoundMetrics

type RoundMetrics struct {
	Latency            float64 // seconds
	CPU                float64 // seconds
	CoreEq             float64 // equivalent CPU cores used (CPU time / wall-clock time)
	UtilizedPct        float64 // CPU utilization percentage across all logical cores
	MemAllocDelta      float64 // MB
	MemSysDelta        float64 // MB
	MemTotalAllocDelta float64 // MB
	GCDelta            uint32
}

type RoundReport

type RoundReport struct {
	RoundID string                 `json:"round_id"`
	Stats   RoundStats             `json:"round_stats"`
	Metrics RoundMetrics           `json:"round_metrics"`
	Stages  map[string]StageMetric `json:"stages"`
	Ops     map[string]OpMetric    `json:"ops"`
}

type RoundReportService

type RoundReportService interface {
	RoundStarted(roundID string)
	SetIntentsNum(numIntents int)
	RoundEnded(commitmentTxID string, totalInputs int, totalOutputs int, numTreeNodes int)
	StageStarted(stage string)
	StageEnded(stage string)
	OpStarted(op string)
	OpEnded(op string)
	Report() <-chan *RoundReport
	Close()
}

func NewRoundReportService

func NewRoundReportService() RoundReportService

type RoundSigningStarted

type RoundSigningStarted struct {
	domain.RoundEvent
	UnsignedCommitmentTx string
	CosignersPubkeys     []string
}

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

func (RoundSigningStarted) GetTopic

func (r RoundSigningStarted) GetTopic() string

implement domain.RoundEvent interface

type RoundStats

type RoundStats struct {
	NumIntents       int    `json:"num_intents"`
	TotalInputVtxos  int    `json:"total_input_vtxos"`
	TotalOutputVtxos int    `json:"total_output_vtxos"`
	NumTreeNodes     int    `json:"num_tree_nodes"`
	CommitmentTxID   string `json:"commitment_txid"`
}

type ScheduledSweep

type ScheduledSweep struct {
	RoundId          string
	SweepableOutputs []SweepableOutput
}

type Service

type Service interface {
	Start() error
	Stop()
	RegisterIntent(
		ctx context.Context, proof bip322.Signature, message bip322.IntentMessage,
	) (string, error)
	ConfirmRegistration(ctx context.Context, intentId string) error
	SubmitForfeitTxs(ctx context.Context, forfeitTxs []string) error
	SignCommitmentTx(ctx context.Context, commitmentTx string) error
	GetEventsChannel(ctx context.Context) <-chan []domain.Event
	GetInfo(ctx context.Context) (*ServiceInfo, error)
	SubmitOffchainTx(
		ctx context.Context, checkpointTxs []string, signedArkTx string,
	) (signedCheckpoints []string, finalArkTx string, arkTxid string, err error)
	FinalizeOffchainTx(ctx context.Context, txid string, finalCheckpoints []string) error
	// Tree signing methods
	RegisterCosignerNonces(
		ctx context.Context, roundId, pubkey string, nonces tree.TreeNonces,
	) error
	RegisterCosignerSignatures(
		ctx context.Context, roundId, pubkey string, signatures tree.TreePartialSigs,
	) error
	GetTxEventsChannel(ctx context.Context) <-chan TransactionEvent
	DeleteIntentsByProof(
		ctx context.Context, bip322signature bip322.Signature, message bip322.DeleteIntentMessage,
	) error

	// TODO: remove when detaching the indexer svc.
	GetIndexerTxChannel(ctx context.Context) <-chan TransactionEvent
}

func NewService

func NewService(
	wallet ports.WalletService,
	signer ports.SignerService,
	repoManager ports.RepoManager,
	builder ports.TxBuilder,
	scanner ports.BlockchainScanner,
	scheduler ports.SchedulerService,
	cache ports.LiveStore,
	vtxoTreeExpiry, unilateralExitDelay, boardingExitDelay arklib.RelativeLocktime,
	roundInterval, roundMinParticipantsCount, roundMaxParticipantsCount,
	utxoMaxAmount, utxoMinAmount, vtxoMaxAmount, vtxoMinAmount int64,
	network arklib.Network, allowCSVBlockType bool, noteUriPrefix string,
	marketHourStartTime, marketHourEndTime time.Time,
	marketHourPeriod, marketHourRoundInterval time.Duration, reportSvc RoundReportService,
) (Service, error)

type ServiceInfo

type ServiceInfo struct {
	SignerPubKey        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 StageMetric

type StageMetric struct{ Latency float64 } // seconds

type SweepableOutput

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

type TransactionEvent

type TransactionEvent struct {
	TxData
	Type           TransactionEventType
	SpentVtxos     []domain.Vtxo
	SpendableVtxos []domain.Vtxo
	CheckpointTxs  map[string]TxData
}

type TransactionEventType

type TransactionEventType string
const (
	CommitmentTxType TransactionEventType = "commitment_tx"
	ArkTxType        TransactionEventType = "ark_tx"
)

type TreeNoncesAggregated

type TreeNoncesAggregated struct {
	domain.RoundEvent
	Nonces tree.TreeNonces // aggregated nonces
}

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

func (TreeNoncesAggregated) GetTopic

func (r TreeNoncesAggregated) GetTopic() string

type TreeSignatureMessage

type TreeSignatureMessage struct {
	domain.RoundEvent
	Topic      []string
	BatchIndex int32
	Txid       string
	Signature  string
}

func (TreeSignatureMessage) GetTopic

func (r TreeSignatureMessage) GetTopic() string

type TreeTx

type TreeTx = tree.TxTreeNode

type TreeTxMessage

type TreeTxMessage struct {
	domain.RoundEvent
	Topic      []string
	BatchIndex int32
	Node       tree.TxTreeNode
}

func (TreeTxMessage) GetTopic

func (r TreeTxMessage) GetTopic() string

type TreeTxResp

type TreeTxResp struct {
	Txs  []TreeTx
	Page PageResp
}

type TxData

type TxData struct {
	Tx   string
	Txid string
}

type TxType

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

type VOut

type VOut int

type VirtualTxsResp

type VirtualTxsResp struct {
	Txs  []string
	Page PageResp
}

type VtxoChainResp

type VtxoChainResp struct {
	Chain []ChainTx
	Page  PageResp
}

type VtxoTreeLeavesResp

type VtxoTreeLeavesResp struct {
	Leaves []domain.Vtxo
	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