ports

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 13 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 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, blocknumber int64, blocktime int64, err error)
	RescanUtxos(ctx context.Context, outpoints []wire.OutPoint) error
}

type BoardingInput

type BoardingInput struct {
	Input
	Amount uint64
}

type BoardingInputsStore

type BoardingInputsStore interface {
	Set(numOfInputs int)
	Get() int
}

type ConfirmationSessions

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

type ConfirmationSessionsStore

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

type CurrentRoundStore

type CurrentRoundStore interface {
	Upsert(fn func(m *domain.Round) *domain.Round) error
	Get() *domain.Round
	Fail(err error) []domain.Event
}

type ForfeitTxsStore

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

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() int64
	Push(intent domain.Intent, boardingInputs []BoardingInput, cosignersPublicKeys []string) error
	Pop(num int64) []TimedIntent
	GetSelectedIntents() []TimedIntent
	Update(intent domain.Intent, cosignersPublicKeys []string) error
	Delete(ids []string) error
	DeleteAll() error
	DeleteVtxos()
	ViewAll(ids []string) ([]TimedIntent, error)
	View(id string) (*domain.Intent, bool)
	IncludesAny(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(offchainTx domain.OffchainTx)
	Remove(arkTxid string)
	Get(arkTxid string) (domain.OffchainTx, bool)
	Includes(outpoint domain.Outpoint) bool
}

type RepoManager

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

type SchedulerService

type SchedulerService interface {
	Start()
	Stop()

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

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

type SweepableOutput struct {
	Amount int64
	Hash   chainhash.Hash
	Index  uint32
	// Script is the tapscript that should be used to sweep the output
	Script []byte
	// ControlBlock is the control block associated with leaf script
	ControlBlock []byte
	// InternalKey is the internal key used to compute the control block
	InternalKey *btcec.PublicKey
}

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 TreeSigningSessionsStore

type TreeSigningSessionsStore interface {
	New(roundId string, uniqueSignersPubKeys map[string]struct{}) *MusigSigningSession
	Get(roundId string) (*MusigSigningSession, bool)
	Delete(roundId string)
	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, connectorAddresses []string,
		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 []SweepableOutput) (txid string, signedSweepTx string, err error)
	GetSweepableBatchOutputs(vtxoTree *tree.TxTree) (
		vtxoTreeExpiry *arklib.RelativeLocktime, batchOutputs SweepableOutput, err error,
	)
	FinalizeAndExtract(tx string) (txhex string, err error)
	VerifyTapscriptPartialSigs(
		tx string, mustIncludeSignerSig bool,
	) (valid bool, ptx *psbt.Packet, err error)
	VerifyAndCombinePartialTx(dest string, src string) (string, error)
	CountSignedTaprootInputs(tx string) (int, 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 interface {
	GetTxid() string
	GetIndex() uint32
	GetScript() string
	GetValue() uint64
}

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 struct{}, 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