ports

package
v0.0.0-...-02d61d7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 9 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)
}

type BoardingInput

type BoardingInput struct {
	Input
	Amount uint64
}

type Input

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

type Notifier

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

Notifier defines the interface for sending notifications

type RepoManager

type RepoManager interface {
	Events() domain.RoundEventRepository
	Rounds() domain.RoundRepository
	Vtxos() domain.VtxoRepository
	Notes() domain.NoteRepository
	Entities() domain.EntityRepository
	MarketHourRepo() domain.MarketHourRepo
	RegisterEventsHandler(func(*domain.Round))
	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 SweepInput

type SweepInput interface {
	GetAmount() uint64
	GetHash() chainhash.Hash
	GetIndex() uint32
	GetLeafScript() []byte
	GetControlBlock() []byte
	GetInternalKey() *secp256k1.PublicKey
}

type TimeUnit

type TimeUnit int
const (
	UnixTime TimeUnit = iota
	BlockHeight
)

type TxBuilder

type TxBuilder interface {
	// BuildRoundTx builds a round tx for the given offchain and boarding tx
	// requests. It expects an optional list of connector addresses of expired
	// rounds from which selecting UTXOs as inputs of the transaction.
	// Returns the round tx, the VTXO tree, the connector chain and its root
	// address.
	BuildRoundTx(
		serverPubkey *secp256k1.PublicKey, txRequests []domain.TxRequest,
		boardingInputs []BoardingInput, connectorAddresses []string,
		musig2Data []*tree.Musig2,
	) (
		roundTx 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.TxTree, txs []string,
		connectorIndex map[string]domain.Outpoint,
	) (valid map[domain.VtxoKey]string, err error)
	BuildSweepTx(inputs []SweepInput) (txid string, signedSweepTx string, err error)
	GetSweepInput(node tree.Node) (vtxoTreeExpiry *common.RelativeLocktime, sweepInput SweepInput, err error)
	FinalizeAndExtract(tx string) (txhex string, err error)
	VerifyTapscriptPartialSigs(tx string) (valid bool, txid string, err error)
	// FindLeaves returns all the leaves txs that are reachable from the given outpoint
	FindLeaves(vtxoTree tree.TxTree, fromtxid string, vout uint32) (leaves []tree.Node, err error)
	VerifyAndCombinePartialTx(dest string, src string) (string, error)
	GetTxID(tx string) (string, error)
}

type TxInput

type TxInput interface {
	GetTxid() string
	GetIndex() uint32
	GetScript() string
	GetAsset() string
	GetValue() uint64
}

type TxOutpoint

type TxOutpoint interface {
	GetTxid() string
	GetIndex() uint32
}

type Unlocker

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

type VtxoWithValue

type VtxoWithValue struct {
	domain.VtxoKey
	Value uint64
}

type WalletService

type WalletService interface {
	BlockchainScanner
	GetSyncedUpdate(ctx context.Context) <-chan struct{}
	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, password string) error
	Status(ctx context.Context) (WalletStatus, error)
	GetPubkey(ctx context.Context) (*secp256k1.PublicKey, error)
	GetForfeitAddress(ctx context.Context) (string, 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) // inputIndexes == nil means sign all inputs
	SelectUtxos(ctx context.Context, asset string, amount uint64) ([]TxInput, uint64, error)
	BroadcastTransaction(ctx context.Context, txHex string) (string, error)
	WaitForSync(ctx context.Context, txid string) error
	EstimateFees(ctx context.Context, psbt string) (uint64, error)
	MinRelayFee(ctx context.Context, vbytes uint64) (uint64, error)
	MinRelayFeeRate(ctx context.Context) chainfee.SatPerKVByte
	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 []TxOutpoint) error
	GetDustAmount(ctx context.Context) (uint64, error)
	GetTransaction(ctx context.Context, txid string) (string, error)
	SignMessage(ctx context.Context, message []byte) ([]byte, error)
	VerifyMessageSignature(ctx context.Context, message, signature []byte) (bool, error)
	GetCurrentBlockTime(ctx context.Context) (*BlockTimestamp, error)
	Withdraw(ctx context.Context, address string, amount uint64) (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