application

package
v0.8.11 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 37 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 AcceptedOffchainTx added in v0.8.9

type AcceptedOffchainTx struct {
	TxId                string
	FinalArkTx          string
	SignedCheckpointTxs []string
}

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, before int64, withFailed, withCompleted bool,
	) ([]string, error)
	GetWalletAddress(ctx context.Context) (string, error)
	GetWalletStatus(ctx context.Context) (*WalletStatus, error)
	CreateNotes(ctx context.Context, amount uint32, quantity int) ([]string, error)
	GetScheduledSessionConfig(ctx context.Context) (*domain.ScheduledSession, error)
	UpdateScheduledSessionConfig(
		ctx context.Context, scheduledSessionStartTime, scheduledSessionEndTime time.Time,
		period, duration time.Duration, roundMinParticipantsCount, roundMaxParticipantsCount int64,
	) error
	ClearScheduledSessionConfig(ctx context.Context) error
	ListIntents(ctx context.Context, intentIds ...string) ([]IntentInfo, error)
	DeleteIntents(ctx context.Context, intentIds ...string) error
	GetIntentFees(ctx context.Context) (*domain.IntentFees, error)
	UpdateIntentFees(ctx context.Context, fees domain.IntentFees) error
	ClearIntentFees(ctx context.Context) error
	GetConvictionsByIds(ctx context.Context, ids []string) ([]domain.Conviction, error)
	GetConvictions(ctx context.Context, from, to time.Time) ([]domain.Conviction, error)
	GetConvictionsByRound(ctx context.Context, roundID string) ([]domain.Conviction, error)
	GetActiveScriptConvictions(
		ctx context.Context, script string,
	) ([]domain.ScriptConviction, error)
	PardonConviction(ctx context.Context, id string) error
	BanScript(ctx context.Context, script, reason string, banDuration *time.Duration) error
	Sweep(
		ctx context.Context, withConnectors bool, commitmentTxids []string,
	) (string, string, error)
	GetExpiringLiquidity(ctx context.Context, after, before int64) (uint64, error)
	GetRecoverableLiquidity(ctx context.Context) (uint64, error)
}

func NewAdminService

func NewAdminService(
	walletSvc ports.WalletService, repoManager ports.RepoManager, txBuilder ports.TxBuilder,
	liveStoreSvc ports.LiveStore, timeUnit ports.TimeUnit, feeManager ports.FeeManager,
	roundMinParticipantsCount, roundMaxParticipantsCount int64,
) AdminService

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
	TotalInputVtxos   int32
	TotalOutputAmount uint64
	TotalOutputVtxos  int32
}

type FeeInfo added in v0.8.0

type FeeInfo struct {
	IntentFees domain.IntentFees
	TxFeeRate  float64
}

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, pendingOnly 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 NextScheduledSession added in v0.8.0

type NextScheduledSession struct {
	StartTime time.Time
	EndTime   time.Time
	Period    time.Duration
	Duration  time.Duration
	Fees      FeeInfo
}

type OpMetric added in v0.8.0

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 RoundFailed added in v0.8.0

type RoundFailed struct {
	domain.RoundFailed
	Topic []string
}

type RoundFinalized

type RoundFinalized struct {
	domain.RoundFinalized
	Txid string
}

type RoundMetrics added in v0.8.0

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 added in v0.8.0

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 added in v0.8.0

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 added in v0.8.0

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 added in v0.8.0

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
	Confirmed        bool
	SweepableOutputs []SweepableOutput
}

type Service

type Service interface {
	Start() errors.Error
	Stop()
	RegisterIntent(
		ctx context.Context, proof intent.Proof, message intent.RegisterMessage,
	) (string, errors.Error)
	EstimateIntentFee(
		ctx context.Context, proof intent.Proof, message intent.EstimateIntentFeeMessage,
	) (int64, errors.Error)
	ConfirmRegistration(ctx context.Context, intentId string) errors.Error
	SubmitForfeitTxs(ctx context.Context, forfeitTxs []string) errors.Error
	SignCommitmentTx(ctx context.Context, commitmentTx string) errors.Error
	GetEventsChannel(ctx context.Context) <-chan []domain.Event
	GetInfo(ctx context.Context) (*ServiceInfo, errors.Error)
	SubmitOffchainTx(
		ctx context.Context, checkpointTxs []string, signedArkTx string,
	) (tx *AcceptedOffchainTx, err errors.Error)
	FinalizeOffchainTx(ctx context.Context, txid string, finalCheckpoints []string) errors.Error
	GetPendingOffchainTxs(
		ctx context.Context,
		proof intent.Proof,
		message intent.GetPendingTxMessage,
	) ([]AcceptedOffchainTx, errors.Error)
	// Tree signing methods
	RegisterCosignerNonces(
		ctx context.Context, roundId, pubkey string, nonces tree.TreeNonces,
	) errors.Error
	RegisterCosignerSignatures(
		ctx context.Context, roundId, pubkey string, signatures tree.TreePartialSigs,
	) errors.Error
	GetTxEventsChannel(ctx context.Context) <-chan TransactionEvent
	DeleteIntentsByProof(
		ctx context.Context,
		proof intent.Proof,
		message intent.DeleteMessage,
	) errors.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,
	reportSvc RoundReportService,
	alerts ports.Alerts,
	feeManager ports.FeeManager,
	vtxoTreeExpiry, unilateralExitDelay, publicUnilateralExitDelay,
	boardingExitDelay, checkpointExitDelay arklib.RelativeLocktime,
	sessionDuration, roundMinParticipantsCount, roundMaxParticipantsCount,
	utxoMaxAmount, utxoMinAmount, vtxoMaxAmount, vtxoMinAmount, banDuration, banThreshold int64,
	network arklib.Network,
	allowCSVBlockType bool,
	noteUriPrefix string,
	scheduledSessionStartTime, scheduledSessionEndTime time.Time,
	scheduledSessionPeriod, scheduledSessionDuration time.Duration,
	scheduledSessionRoundMinParticipantsCount, scheduledSessionRoundMaxParticipantsCount int64,
	settlementMinExpiryGap int64,
	vtxoNoCsvValidationCutoffTime time.Time,
) (Service, error)

type ServiceInfo

type ServiceInfo struct {
	SignerPubKey         string
	ForfeitPubKey        string
	UnilateralExitDelay  int64
	BoardingExitDelay    int64
	SessionDuration      int64
	Network              string
	Dust                 uint64
	ForfeitAddress       string
	NextScheduledSession *NextScheduledSession
	UtxoMinAmount        int64
	UtxoMaxAmount        int64
	VtxoMinAmount        int64
	VtxoMaxAmount        int64
	CheckpointTapscript  string
	Fees                 FeeInfo
}

type StageMetric added in v0.8.0

type StageMetric struct{ Latency float64 } // seconds

type SweepableOutput

type SweepableOutput struct {
	TxInput     ports.TxInput
	ScheduledAt int64
}

type TransactionEvent

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

type TransactionEventType

type TransactionEventType string
const (
	CommitmentTxType TransactionEventType = "commitment_tx"
	ArkTxType        TransactionEventType = "ark_tx"
	SweepTxType      TransactionEventType = "sweep_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 TreeTxNoncesEvent added in v0.8.0

type TreeTxNoncesEvent struct {
	domain.RoundEvent
	Txid   string
	Topic  []string
	Nonces map[string]*tree.Musig2Nonce // pubkey -> nonces
}

func (TreeTxNoncesEvent) GetTopic added in v0.8.0

func (r TreeTxNoncesEvent) 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