application

package
v0.0.0-...-a9b2b18 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: MIT Imports: 35 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

View Source
var (
	ErrTreeSigningNotRequired = fmt.Errorf("tree signing is not required on this ark (covenant)")
)

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 NextMarketHour

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

type OwnershipProof

type OwnershipProof struct {
	ControlBlock *txscript.ControlBlock
	Script       []byte
	Signature    *schnorr.Signature
}

OwnershipProof is a proof that the owner of a vtxo has the secret key able to sign the forfeit leaf.

type RedeemTransactionEvent

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

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 bitcointree.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.VtxoTree
	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.VtxoKey
	SpendableVtxos        []domain.Vtxo
	ClaimedBoardingInputs []domain.VtxoKey
}

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)
	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
	SetNostrRecipient(ctx context.Context, nostrRecipient string, signedVtxoOutpoints []SignedVtxoOutpoint) error
	DeleteNostrRecipient(ctx context.Context, signedVtxoOutpoints []SignedVtxoOutpoint) error
	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
}

func NewCovenantService

func NewCovenantService(
	network common.Network,
	roundInterval int64,
	vtxoTreeExpiry, unilateralExitDelay, boardingExitDelay common.RelativeLocktime,
	nostrDefaultRelays []string,
	walletSvc ports.WalletService, repoManager ports.RepoManager,
	builder ports.TxBuilder, scanner ports.BlockchainScanner,
	scheduler ports.SchedulerService,
	notificationPrefix string,
	marketHourStartTime, marketHourEndTime time.Time, marketHourPeriod, marketHourRoundInterval time.Duration,
) (Service, error)

func NewCovenantlessService

func NewCovenantlessService(
	network common.Network,
	roundInterval int64,
	vtxoTreeExpiry, unilateralExitDelay, boardingExitDelay common.RelativeLocktime,
	nostrDefaultRelays []string,
	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,
) (Service, error)

type ServiceInfo

type ServiceInfo struct {
	PubKey              string
	VtxoTreeExpiry      int64
	UnilateralExitDelay int64
	RoundInterval       int64
	Network             string
	Dust                uint64
	ForfeitAddress      string
	NextMarketHour      *NextMarketHour
}

type SignedVtxoOutpoint

type SignedVtxoOutpoint struct {
	Outpoint domain.VtxoKey
	Proof    OwnershipProof
}

type SweepableOutput

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

type TransactionEvent

type TransactionEvent interface {
	Type() TransactionEventType
}

type TransactionEventType

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

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 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