ports

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNonFinalBIP68 is returned when a transaction spending a CSV-locked output is not final.
	ErrNonFinalBIP68 = errors.New("non-final BIP68 sequence")
)

Functions

This section is empty.

Types

type Alerts added in v0.8.8

type Alerts interface {
	Publish(ctx context.Context, topic Topic, message any) error
}

type BatchFinalizedAlert added in v0.8.8

type BatchFinalizedAlert struct {
	Id                                  string
	CommitmentTxid                      string
	Duration                            string
	LiquidityProviderInputAmount        uint64
	LiquidityProviderConfirmedBalance   uint64
	LiquidityProviderUnconfirmedBalance uint64
	LiquidityCost                       string
	LiquidityProvided                   uint64
	BoardingInputCount                  int
	BoardingInputAmount                 uint64
	IntentsCount                        int
	LeafCount                           int
	LeafAmount                          uint64
	ConnectorsCount                     int
	ConnectorsAmount                    uint64
	ExitCount                           int
	ExitAmount                          uint64
	ForfeitCount                        int
	ForfeitAmount                       uint64
	OnchainFees                         uint64
	CollectedFees                       uint64
}

type BlockTimestamp

type BlockTimestamp struct {
	Height uint32
	Time   int64
}

type BlockchainScanner

type BlockchainScanner interface {
	WatchScripts(ctx context.Context, scripts []string) error
	UnwatchScripts(ctx context.Context, scripts []string) error
	GetNotificationChannel(ctx context.Context) <-chan map[string][]VtxoWithValue
	IsTransactionConfirmed(
		ctx context.Context, txid string,
	) (isConfirmed bool, blockTimestamp *BlockTimestamp, err error)
	RescanUtxos(ctx context.Context, outpoints []wire.OutPoint) error
}

type BoardingInput

type BoardingInput struct {
	Input
	Amount uint64
}

type BoardingInputsStore

type BoardingInputsStore interface {
	Set(ctx context.Context, numOfInputs int) error
	Get(ctx context.Context) (int, error)
	AddSignatures(
		ctx context.Context, batchId string, inputSigs map[uint32]SignedBoardingInput,
	) error
	GetSignatures(ctx context.Context, batchId string) (map[uint32]SignedBoardingInput, error)
	DeleteSignatures(ctx context.Context, batchId string) error
}

type ConfirmationSessions

type ConfirmationSessions struct {
	IntentsHashes       map[[32]byte]bool // hash --> confirmed
	NumIntents          int
	NumConfirmedIntents int
}

type ConfirmationSessionsStore

type ConfirmationSessionsStore interface {
	Init(ctx context.Context, intentIDsHashes [][32]byte) error
	Confirm(ctx context.Context, intentId string) error
	Get(ctx context.Context) (*ConfirmationSessions, error)
	Reset(ctx context.Context) error
	Initialized(ctx context.Context) bool
	SessionCompleted() <-chan struct{}
}

type CurrentRoundStore

type CurrentRoundStore interface {
	Upsert(ctx context.Context, fn func(m *domain.Round) *domain.Round) error
	Get(ctx context.Context) (*domain.Round, error)
}

type FeeManager added in v0.8.11

type FeeManager interface {
	ComputeIntentFees(
		ctx context.Context,
		boardingInputs []wire.TxOut, vtxoInputs []domain.Vtxo,
		onchainOutputs, offchainOutputs []wire.TxOut,
	) (int64, error)
	Validate(fees domain.IntentFees) error
}

type ForfeitTxsStore

type ForfeitTxsStore interface {
	Init(ctx context.Context, connectors tree.FlatTxTree, intents []domain.Intent) error
	Sign(ctx context.Context, txs []string) error
	Reset(ctx context.Context) error
	Pop(ctx context.Context) ([]string, error)
	AllSigned(ctx context.Context) (bool, error)
	GetUnsignedInputs(ctx context.Context) ([]domain.Outpoint, error)
	Len(ctx context.Context) (int, error)
	GetConnectorsIndexes(ctx context.Context) (map[string]domain.Outpoint, error)
}

type Input

type Input struct {
	domain.Outpoint
	Tapscripts []string
}

func (Input) OutputScript added in v0.8.0

func (i Input) OutputScript() ([]byte, error)

type IntentStore

type IntentStore interface {
	Len(ctx context.Context) (int64, error)
	Push(
		ctx context.Context, intent domain.Intent, boardingInputs []BoardingInput, cosignersPublicKeys []string,
	) error
	Pop(ctx context.Context, num int64) ([]TimedIntent, error)
	GetSelectedIntents(ctx context.Context) ([]TimedIntent, error)
	// TODO uncomment when we have a way to register outputs outside of intent proof
	// Update(intent domain.Intent, cosignersPublicKeys []string) error
	Delete(ctx context.Context, ids []string) error
	DeleteAll(ctx context.Context) error
	DeleteVtxos(ctx context.Context) error
	ViewAll(ctx context.Context, ids []string) ([]TimedIntent, error)
	IncludesAny(ctx context.Context, outpoints []domain.Outpoint) (bool, string)
}

type LiveStore

type LiveStore interface {
	Intents() IntentStore
	ForfeitTxs() ForfeitTxsStore
	OffchainTxs() OffChainTxStore
	CurrentRound() CurrentRoundStore
	ConfirmationSessions() ConfirmationSessionsStore
	TreeSigingSessions() TreeSigningSessionsStore
	BoardingInputs() BoardingInputsStore
}

type MusigSigningSession

type MusigSigningSession struct {
	NbCosigners int
	Cosigners   map[string]struct{}
	Nonces      map[string]tree.TreeNonces

	Signatures map[string]tree.TreePartialSigs
}

MusigSigningSession holds the state of ephemeral nonces and signatures in order to coordinate the signing of the tree

type Notifier

type Notifier interface {
	Notify(ctx context.Context, to any, message string) error
}

Notifier defines the interface for sending notifications

type OffChainTxStore

type OffChainTxStore interface {
	Add(ctx context.Context, offchainTx domain.OffchainTx) error
	Remove(ctx context.Context, arkTxid string) error
	Get(ctx context.Context, arkTxid string) (*domain.OffchainTx, error)
	Includes(ctx context.Context, outpoint domain.Outpoint) (bool, error)
}

type RepoManager

type RepoManager interface {
	Events() domain.EventRepository
	Rounds() domain.RoundRepository
	Vtxos() domain.VtxoRepository
	ScheduledSession() domain.ScheduledSessionRepo
	OffchainTxs() domain.OffchainTxRepository
	Convictions() domain.ConvictionRepository
	Assets() domain.AssetRepository
	Fees() domain.FeeRepository
	Close()
}

type SchedulerService

type SchedulerService interface {
	Start()
	Stop()

	Unit() TimeUnit
	AfterNow(expiry int64) bool
	ScheduleTaskOnce(at int64, task func()) error
}

type SignedBoardingInput added in v0.8.7

type SignedBoardingInput struct {
	Signatures []*psbt.TaprootScriptSpendSig
	LeafScript *psbt.TaprootTapLeafScript
}

type SignerService added in v0.7.1

type SignerService interface {
	IsReady(ctx context.Context) (bool, error)
	GetPubkey(ctx context.Context) (*btcec.PublicKey, error)
	SignTransaction(ctx context.Context, partialTx string, extractRawTx bool) (string, error)
	SignTransactionTapscript(
		ctx context.Context, partialTx string, inputIndexes []int,
	) (string, error)
}

type Tapscript added in v0.8.11

type Tapscript struct {
	InternalKey  string // hex encoded
	ControlBlock string // hex encoded
	Tapscript    string // hex encoded
}

type TimeUnit

type TimeUnit int
const (
	UnixTime TimeUnit = iota
	BlockHeight
)

type TimedIntent

type TimedIntent struct {
	domain.Intent
	BoardingInputs      []BoardingInput
	Timestamp           time.Time
	CosignersPublicKeys []string
}

func (TimedIntent) HashID

func (t TimedIntent) HashID() [32]byte

type Topic added in v0.8.8

type Topic string
const (
	BatchFinalized Topic = "Batch Finalized"
	ArkTx          Topic = "Ark Tx"
)

type TreeSigningSessionsStore

type TreeSigningSessionsStore interface {
	New(ctx context.Context, roundId string, uniqueSignersPubKeys map[string]struct{}) error
	Get(ctx context.Context, roundId string) (*MusigSigningSession, error)
	Delete(ctx context.Context, roundId string) error
	AddNonces(ctx context.Context, roundId string, pubkey string, nonces tree.TreeNonces) error
	AddSignatures(
		ctx context.Context, roundId, pubkey string, nonces tree.TreePartialSigs,
	) error
	NoncesCollected(roundId string) <-chan struct{}
	SignaturesCollected(roundId string) <-chan struct{}
}

type TxBuilder

type TxBuilder interface {
	// BuildCommitmentTx builds a commitment tx for the given intents and boarding inputs
	// It expects an optional list of connector addresses of expired batches from which selecting
	// utxos as inputs of the transaction.
	// Returns the commitment tx, the vtxo tree, the connector tree and its root address.
	BuildCommitmentTx(
		signerPubkey *btcec.PublicKey, intents domain.Intents,
		boardingInputs []BoardingInput, cosigners [][]string,
	) (
		commitmentTx string, vtxoTree *tree.TxTree,
		connectorAddress string, connectors *tree.TxTree, err error,
	)
	// VerifyForfeitTxs verifies a list of forfeit txs against a set of VTXOs and
	// connectors.
	VerifyForfeitTxs(
		vtxos []domain.Vtxo, connectors tree.FlatTxTree, txs []string,
	) (valid map[domain.Outpoint]ValidForfeitTx, err error)
	BuildSweepTx(inputs []TxInput) (txid string, signedSweepTx string, err error)
	GetSweepableBatchOutputs(vtxoTree *tree.TxTree) (
		vtxoTreeExpiry *arklib.RelativeLocktime, batchOutputs *TxInput, err error,
	)
	FinalizeAndExtract(tx string) (txhex string, err error)
	VerifyVtxoTapscriptSigs(
		tx string, mustIncludeSignerSig bool,
	) (valid bool, ptx *psbt.Packet, err error)
	VerifyBoardingTapscriptSigs(
		signedTx string, commitmentTx string,
	) (map[uint32]SignedBoardingInput, error)
}

type TxDecoder

type TxDecoder interface {
	DecodeTx(tx string) (txid string, ins []TxIn, outs []TxOut, err error)
}

type TxIn

type TxIn = domain.Outpoint

type TxInput

type TxInput struct {
	Txid          string
	Index         uint32
	Script        string // hex encoded
	Value         uint64
	TapscriptLeaf *Tapscript // nil if not tapscript spend
}

type TxOut

type TxOut struct {
	Amount   uint64
	PkScript []byte
}

type Unlocker

type Unlocker interface {
	GetPassword(ctx context.Context) (string, error)
}

type ValidForfeitTx

type ValidForfeitTx struct {
	Tx        string
	Connector domain.Outpoint
}

type VtxoWithValue

type VtxoWithValue struct {
	domain.Outpoint
	Value uint64
}

type WalletService

type WalletService interface {
	BlockchainScanner
	GetReadyUpdate(ctx context.Context) (<-chan bool, error)
	GenSeed(ctx context.Context) (string, error)
	Create(ctx context.Context, seed, password string) error
	Restore(ctx context.Context, seed, password string) error
	Unlock(ctx context.Context, password string) error
	Lock(ctx context.Context) error
	Status(ctx context.Context) (WalletStatus, error)
	GetNetwork(ctx context.Context) (*arklib.Network, error)
	GetForfeitPubkey(ctx context.Context) (*btcec.PublicKey, error)
	DeriveConnectorAddress(ctx context.Context) (string, error)
	DeriveAddresses(ctx context.Context, num int) ([]string, error)
	SignTransaction(ctx context.Context, partialTx string, extractRawTx bool) (string, error)
	SignTransactionTapscript(
		ctx context.Context, partialTx string, inputIndexes []int,
	) (string, error)
	SelectUtxos(
		ctx context.Context, asset string, amount uint64, confirmedOnly bool,
	) ([]TxInput, uint64, error)
	BroadcastTransaction(ctx context.Context, txs ...string) (string, error)
	EstimateFees(ctx context.Context, psbt string) (uint64, error)
	FeeRate(ctx context.Context) (uint64, error)
	ListConnectorUtxos(ctx context.Context, connectorAddress string) ([]TxInput, error)
	MainAccountBalance(ctx context.Context) (uint64, uint64, error)
	ConnectorsAccountBalance(ctx context.Context) (uint64, uint64, error)
	LockConnectorUtxos(ctx context.Context, utxos []domain.Outpoint) error
	GetDustAmount(ctx context.Context) (uint64, error)
	GetTransaction(ctx context.Context, txid string) (string, error)
	GetOutpointStatus(ctx context.Context, outpoint domain.Outpoint) (spent bool, err error)
	GetCurrentBlockTime(ctx context.Context) (*BlockTimestamp, error)
	Withdraw(ctx context.Context, address string, amount uint64, all bool) (string, error)
	LoadSignerKey(ctx context.Context, prvkey string) error
	Close()
}

type WalletStatus

type WalletStatus interface {
	IsInitialized() bool
	IsUnlocked() bool
	IsSynced() bool
}

Jump to

Keyboard shortcuts

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