Help us shape the future of Go! Take the 2026 Go Developer Survey

clientlib

package module
v0.0.0-...-f863e48 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	GrpcClient = "grpc"
)
View Source
const (
	SingleKeyIdentity = "singlekey"
)

Variables

View Source
var (
	ErrConnectionClosedByServer = fmt.Errorf("connection closed by server")
)

Functions

func ApplyGetTxHistoryOptions

func ApplyGetTxHistoryOptions(opts ...GetTxHistoryOption) (*getTxHistoryOption, error)

func ApplyGetVtxosOptions

func ApplyGetVtxosOptions(opts ...GetVtxosOption) (*getVtxosOption, error)

func ApplyPageOptions

func ApplyPageOptions(opts ...PageOption) (*pageOption, error)

func CoinSelect

func CoinSelect(
	boardingUtxos []Utxo, vtxos []Vtxo,
	outputs []Receiver, dust uint64, feeEstimator *arkfee.Estimator,
) ([]Utxo, []Vtxo, uint64, error)

CoinSelect picks boarding utxos and vtxos to cover the BTC amount of the given outputs. When feeEstimator is non-nil it also accounts for the per-input and per-output fees, growing the target amount accordingly. If the computed change is below dust it is folded into the selection by adding one more input (preferring an offchain vtxo, then a boarding utxo) when one is available, otherwise the change is dropped to zero. Returns the selected boarding utxos, the selected vtxos, and the leftover change in sats.

func EcPubkeyFromHex

func EcPubkeyFromHex(pubkey string) (*btcec.PublicKey, error)

EcPubkeyFromHex decodes a hex-encoded secp256k1 public key and parses it into a *btcec.PublicKey. The input may be compressed or uncompressed, as accepted by btcec.ParsePubKey. It returns an error if the string is not valid hex or does not encode a valid public key.

func NetworkFromString

func NetworkFromString(net string) arklib.Network

NetworkFromString resolves the textual network name reported by the server (mainnet, testnet, testnet4, signet, mutinynet, regtest) into the matching arklib.Network value. Unknown values fall back to arklib.Bitcoin (mainnet).

func ParseBitcoinAddress

func ParseBitcoinAddress(addr string, net chaincfg.Params) (
	bool, []byte, error,
)

ParseBitcoinAddress attempts to decode addr as a Bitcoin address on the given network. Returns (true, output script, nil) on success, (false, nil, nil) when the address can't be decoded on that network (i.e. the caller can treat the input as "not an on-chain address"), and (false, nil, err) only when a successfully-decoded address fails to produce a PayToAddr script.

func ParseClosure

func ParseClosure(
	outpoint Outpoint, closure script.Closure, tapscripts []string,
) ([]byte, *arklib.TaprootMerkleProof, error)

ParseClosure derives the on-chain pkScript and the taproot merkle proof that authorizes the given closure (typically the forfeit script) under the vtxo's tapscript tree. Used by Vtxo/Utxo to expose the signing leaf needed when adding the input to an intent proof or ark transaction. Returns errors scoped to outpoint so failures are traceable to a specific input.

func ToBitcoinNetwork

func ToBitcoinNetwork(net arklib.Network) chaincfg.Params

ToBitcoinNetwork maps an arklib.Network to the corresponding btcd chaincfg.Params used to decode/encode Bitcoin addresses on that network. Unknown networks fall back to mainnet params.

Types

type AcceptedOffchainTx

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

type Address

type Address struct {
	// KeyID identifies which wallet key produced this address.
	// Single-key wallets populate it with their fixed key handle; HD wallets can
	// use the derivation path.
	KeyID      string
	Tapscripts []string
	Address    string
	// contains filtered or unexported fields
}

func (*Address) CollaborativeClosure

func (a *Address) CollaborativeClosure() (script.Closure, error)

func (*Address) ExitClosure

func (a *Address) ExitClosure() (script.Closure, error)

func (*Address) RawScript

func (a *Address) RawScript() (script.VtxoScript, error)

func (Address) Script

func (a Address) Script() (string, error)

type Asset

type Asset struct {
	AssetId string
	Amount  uint64
}

type AssetInfo

type AssetInfo struct {
	AssetId        string
	Supply         uint64
	ControlAssetId string
	Metadata       []asset.Metadata
}

type Batch

type Batch struct {
	TotalOutputAmount uint64
	TotalOutputVtxos  int32
	ExpiresAt         int64
	Swept             bool
}

type BatchEventChannel

type BatchEventChannel struct {
	Event      any
	Connection *StreamConnectionEvent
	Err        error
}

type BatchFailedEvent

type BatchFailedEvent struct {
	Id     string
	Reason string
}

type BatchFinalizationEvent

type BatchFinalizationEvent struct {
	Id string
	Tx string
}

type BatchFinalizedEvent

type BatchFinalizedEvent struct {
	Id   string
	Txid string
}

type BatchStartedEvent

type BatchStartedEvent struct {
	Id              string
	HashedIntentIds []string
	BatchExpiry     int64
}

type ChainWithExpiry

type ChainWithExpiry struct {
	Txid      string
	ExpiresAt int64
	Type      IndexerChainedTxType
	Spends    []string
}

type Client

type Client interface {
	GetInfo(ctx context.Context) (*Info, error)
	RegisterIntent(ctx context.Context, proof, message string) (string, error)
	DeleteIntent(ctx context.Context, proof, message string) error
	EstimateIntentFee(ctx context.Context, proof, message string) (int64, error)
	ConfirmRegistration(ctx context.Context, intentID string) error
	SubmitTreeNonces(
		ctx context.Context, batchId, cosignerPubkey string, nonces tree.TreeNonces,
	) error
	SubmitTreeSignatures(
		ctx context.Context, batchId, cosignerPubkey string, signatures tree.TreePartialSigs,
	) error
	SubmitSignedForfeitTxs(
		ctx context.Context, signedForfeitTxs []string, signedCommitmentTx string,
	) error
	GetEventStream(ctx context.Context, topics []string) (<-chan BatchEventChannel, func(), error)
	SubmitTx(ctx context.Context, signedArkTx string, checkpointTxs []string) (

		arkTxid, finalArkTx string, signedCheckpointTxs []string, err error,
	)
	FinalizeTx(ctx context.Context, arkTxid string, finalCheckpointTxs []string) error
	GetPendingTx(ctx context.Context, proof, message string) ([]AcceptedOffchainTx, error)
	GetTransactionsStream(ctx context.Context) (<-chan TransactionEvent, func(), error)
	ModifyStreamTopics(
		ctx context.Context, addTopics, removeTopics []string,
	) (addedTopics, removedTopics, allTopics []string, err error)
	OverwriteStreamTopics(
		ctx context.Context, topics []string,
	) (addedTopics, removedTopics, allTopics []string, err error)
	Close()
}

type CommitmentTx

type CommitmentTx struct {
	StartedAt         int64
	EndedAt           int64
	TotalInputAmount  uint64
	TotalInputVtxos   int32
	TotalOutputAmount uint64
	TotalOutputVtxos  int32
	Batches           map[uint32]*Batch
}

type ConfirmedStatus

type ConfirmedStatus struct {
	Confirmed bool
	BlockTime int64
}

type ConnectorsResponse

type ConnectorsResponse struct {
	Tree []TxNode
	Page *PageResponse
}

type ControlAsset

type ControlAsset interface {
	// contains filtered or unexported methods
}

ControlAsset represents the control asset configuration for issuing new assets. Use either NewControlAsset to create a new control asset, or ExistingControlAsset

type DeprecatedSigner

type DeprecatedSigner struct {
	PubKey     *btcec.PublicKey
	CutoffDate time.Time
}

type DeprecatedSignerInfo

type DeprecatedSignerInfo struct {
	PubKey     string
	CutoffDate int64
}

type ExistingControlAsset

type ExistingControlAsset struct {
	Id     string
	Amount uint64
}

ExistingControlAsset references an existing control asset by its ID.

type Explorer

type Explorer interface {
	// Start must be used when using the explorer with tracking enabled.
	Start()

	// GetTxHex retrieves the raw transaction hex for a given transaction ID.
	GetTxHex(txid string) (string, error)

	// Broadcast broadcasts one or more raw transactions to the network.
	// Returns the transaction ID of the first transaction on success.
	Broadcast(txs ...string) (string, error)

	// GetBlockHeight returns the current block height.
	GetBlockHeight() (int64, error)

	// GetTxs retrieves all transactions associated with a given address.
	GetTxs(addr string) ([]Tx, error)

	// GetTxOutspends returns the spent status of all outputs for a given transaction.
	GetTxOutspends(tx string) ([]SpentStatus, error)

	// GetUtxos retrieves all unspent transaction outputs (UTXOs) for the given addresses.
	GetUtxos(addresses []string) ([]ExplorerUtxo, error)

	// GetRedeemedVtxosBalance calculates the redeemed virtual UTXO balance for an address
	// considering the unilateral exit delay.
	GetRedeemedVtxosBalance(
		addr string, unilateralExitDelay arklib.RelativeLocktime,
	) (uint64, map[int64]uint64, error)

	// GetTxBlockTime returns whether a transaction is confirmed and its block time.
	GetTxBlockTime(txid string) (confirmed bool, blocktime int64, err error)

	// BaseUrl returns the base URL of the explorer service.
	BaseUrl() string

	// GetFeeRate retrieves the current recommended fee rate in sat/vB.
	GetFeeRate() (float64, error)

	// GetConnectionCount returns the number of active WebSocket connections.
	GetConnectionCount() int

	// GetSubscribedAddresses returns a list of all currently subscribed addresses.
	GetSubscribedAddresses() []string

	// IsAddressSubscribed checks if a specific address is currently subscribed.
	IsAddressSubscribed(address string) bool

	// GetAddressesEvents returns a channel that receives onchain address events
	// (new UTXOs, spent UTXOs, confirmed UTXOs) for all subscribed addresses.
	GetAddressesEvents() <-chan OnchainAddressEvent

	// SubscribeForAddresses subscribes to address updates via WebSocket connections.
	// Addresses are automatically distributed across multiple connections using hash-based routing.
	// Subscriptions are batched to prevent overwhelming individual connections.
	// Duplicate subscriptions are automatically prevented via instance-scoped deduplication.
	SubscribeForAddresses(addresses []string) error

	// UnsubscribeForAddresses removes address subscriptions and updates the WebSocket connections.
	UnsubscribeForAddresses(addresses []string) error

	// Stop gracefully shuts down the explorer, closing all WebSocket connections and channels.
	Stop()
}

Explorer provides methods to interact with blockchain explorers (e.g., mempool.space, esplora). It supports both HTTP REST API calls and WebSocket connections for real-time address tracking. The implementation uses a connection pool architecture with multiple concurrent WebSocket connections to handle high-volume address subscriptions without overwhelming individual connections.

type ExplorerUtxo

type ExplorerUtxo struct {
	Txid   string
	Vout   uint32
	Amount uint64
	Script string
	Status ConfirmedStatus
}

ExplorerUtxo represents an unspent transaction output from the blockchain explorer.

func (ExplorerUtxo) ToUtxo

func (u ExplorerUtxo) ToUtxo(
	delay arklib.RelativeLocktime, tapscripts []string, signingClosure script.Closure,
) Utxo

ToUtxo converts the explorer Utxo type to the client-lib Utxo one with the specified relative locktime delay (mandatory), tapscripts, and signing closure (optional).

type FeeInfo

type FeeInfo struct {
	IntentFees arkfee.Config
	TxFeeRate  float64
}

type ForfeitTxsResponse

type ForfeitTxsResponse struct {
	Txids []string
	Page  *PageResponse
}

type GetTxHistoryOption

type GetTxHistoryOption func(*getTxHistoryOption) error

GetTxHistoryOption is a functional option for GetTxHistory requests.

func WithEndTime

func WithEndTime(endTime time.Time) GetTxHistoryOption

func WithStartTime

func WithStartTime(startTime time.Time) GetTxHistoryOption

type GetVtxosOption

type GetVtxosOption func(*getVtxosOption) error

GetVtxosOption is a functional option for GetVtxos requests.

func WithOutpoints

func WithOutpoints(outpoints []Outpoint) GetVtxosOption

func WithPendingOnly

func WithPendingOnly() GetVtxosOption

func WithRecoverableOnly

func WithRecoverableOnly() GetVtxosOption

func WithScripts

func WithScripts(scripts []string) GetVtxosOption

func WithSpendableOnly

func WithSpendableOnly() GetVtxosOption

func WithSpentOnly

func WithSpentOnly() GetVtxosOption

func WithTimeRange

func WithTimeRange(before, after int64) GetVtxosOption

func WithVtxosPage

func WithVtxosPage(page *PageRequest) GetVtxosOption

type Identity

type Identity interface {
	GetType() string
	Create(
		ctx context.Context, network arklib.Network, password, seed string,
	) (autoGeneratedSeed string, err error)
	Lock(ctx context.Context) (err error)
	Unlock(ctx context.Context, password string) (alreadyUnlocked bool, err error)
	IsLocked() bool
	NextKeyId(ctx context.Context, id string) (string, error)
	GetKeyIndex(ctx context.Context, id string) (index uint32, err error)
	NewKey(ctx context.Context) (key *KeyRef, err error)
	GetXpub(ctx context.Context) (xpub string, err error)
	GetKey(ctx context.Context, id string) (key *KeyRef, err error)
	ListKeys(ctx context.Context) (keys []KeyRef, err error)
	SignTransaction(
		ctx context.Context, tx string, keys map[string]string,
	) (signedTx string, err error)
	SignMessage(ctx context.Context, message []byte) (signature string, err error)
	Dump(ctx context.Context) (seed string, err error)
}

type Indexer

type Indexer interface {
	GetCommitmentTx(ctx context.Context, txid string) (*CommitmentTx, error)
	GetVtxoTree(
		ctx context.Context, batchOutpoint Outpoint, opts ...PageOption,
	) (*VtxoTreeResponse, error)
	GetFullVtxoTree(
		ctx context.Context, batchOutpoint Outpoint, opts ...PageOption,
	) ([]tree.TxTreeNode, error)
	GetVtxoTreeLeaves(
		ctx context.Context, batchOutpoint Outpoint, opts ...PageOption,
	) (*VtxoTreeLeavesResponse, error)
	GetForfeitTxs(
		ctx context.Context, txid string, opts ...PageOption,
	) (*ForfeitTxsResponse, error)
	GetConnectors(
		ctx context.Context, txid string, opts ...PageOption,
	) (*ConnectorsResponse, error)
	GetVtxos(ctx context.Context, opts ...GetVtxosOption) (*VtxosResponse, error)
	GetVtxoChain(
		ctx context.Context, outpoint Outpoint, opts ...PageOption,
	) (*VtxoChainResponse, error)
	GetVirtualTxs(
		ctx context.Context, txids []string, opts ...PageOption,
	) (*VirtualTxsResponse, error)
	GetBatchSweepTxs(ctx context.Context, batchOutpoint Outpoint) ([]string, error)
	NewSubscription(
		ctx context.Context, scripts []string,
	) (string, <-chan ScriptEvent, func(), error)
	UpdateSubscription(
		ctx context.Context, subscriptionId string, scriptsToAdd, scriptsToRemove []string,
	) error
	GetAsset(ctx context.Context, assetID string) (*AssetInfo, error)

	Close()
}

type IndexerChainedTxType

type IndexerChainedTxType string
const (
	IndexerChainedTxTypeUnspecified IndexerChainedTxType = "unspecified"
	IndexerChainedTxTypeCommitment  IndexerChainedTxType = "commitment"
	IndexerChainedTxTypeArk         IndexerChainedTxType = "ark"
	IndexerChainedTxTypeTree        IndexerChainedTxType = "tree"
	IndexerChainedTxTypeCheckpoint  IndexerChainedTxType = "checkpoint"
)

type Info

type Info struct {
	Version                   string
	SignerPubKey              string
	ForfeitPubKey             string
	UnilateralExitDelay       int64
	BoardingExitDelay         int64
	SessionDuration           int64
	Network                   string
	Dust                      uint64
	ForfeitAddress            string
	ScheduledSessionStartTime int64
	ScheduledSessionEndTime   int64
	ScheduledSessionPeriod    int64
	ScheduledSessionDuration  int64
	ScheduledSessionFees      FeeInfo
	UtxoMinAmount             int64
	UtxoMaxAmount             int64
	VtxoMinAmount             int64
	VtxoMaxAmount             int64
	CheckpointTapscript       string
	MaxTxWeight               int64
	MaxOpReturnOutputs        int64
	Fees                      FeeInfo
	DeprecatedSignerPubKeys   []DeprecatedSignerInfo
	ServiceStatus             map[string]string
	Digest                    string
}

func (Info) ServerParams

func (i Info) ServerParams(serverUrl, explorerUrl string) (*ServerParams, error)

type Input

type Input struct {
	Output
	Txid string
	Vout uint32
}

type KeyRef

type KeyRef struct {
	// Id can be anything and it's up to implementation whether it is, for example, a derivation
	// path or just a derivation index
	Id     string
	PubKey *btcec.PublicKey
}

type NewControlAsset

type NewControlAsset struct {
	Amount uint64
}

NewControlAsset creates a new control asset with the specified amount.

type OnchainAddressEvent

type OnchainAddressEvent struct {
	Error          error
	SpentUtxos     []OnchainOutput
	NewUtxos       []OnchainOutput
	ConfirmedUtxos []OnchainOutput
	Replacements   map[string]string // replacedTxid -> replacementTxid
}

type OnchainOutput

type OnchainOutput struct {
	Outpoint
	Script    string
	Amount    uint64
	CreatedAt time.Time
	Spent     bool
	SpentBy   string
}

type Outpoint

type Outpoint struct {
	Txid string
	VOut uint32
}

func (Outpoint) String

func (v Outpoint) String() string

type Output

type Output struct {
	Script  string
	Address string
	Amount  uint64
}

type PageOption

type PageOption func(*pageOption) error

PageOption is a functional option for paginated requests.

func WithPage

func WithPage(page *PageRequest) PageOption

type PageRequest

type PageRequest struct {
	Size  int32
	Index int32
}

type PageResponse

type PageResponse struct {
	Current int32
	Next    int32
	Total   int32
}

type Receiver

type Receiver struct {
	To     string
	Amount uint64
	Assets []Asset
}

func (Receiver) IsOnchain

func (r Receiver) IsOnchain() bool

func (Receiver) ToArkFeeOutput

func (r Receiver) ToArkFeeOutput() arkfee.Output

func (Receiver) ToTxOut

func (o Receiver) ToTxOut() (*wire.TxOut, bool, error)

type ScriptEvent

type ScriptEvent struct {
	Data       *ScriptEventData
	Connection *StreamConnectionEvent
	Err        error
}

type ScriptEventData

type ScriptEventData struct {
	Txid          string
	Tx            string
	Scripts       []string
	NewVtxos      []Vtxo
	SpentVtxos    []Vtxo
	CheckpointTxs map[string]TxData
}

type ServerParams

type ServerParams struct {
	ServerUrl           string
	SignerPubKey        *btcec.PublicKey
	ForfeitPubKey       *btcec.PublicKey
	Network             arklib.Network
	SessionDuration     int64
	UnilateralExitDelay arklib.RelativeLocktime
	Dust                uint64
	BoardingExitDelay   arklib.RelativeLocktime
	ExplorerURL         string
	ForfeitAddress      string
	UtxoMinAmount       int64
	UtxoMaxAmount       int64
	VtxoMinAmount       int64
	VtxoMaxAmount       int64
	CheckpointTapscript string
	Fees                FeeInfo
	DeprecatedSigners   []DeprecatedSigner
}

func (ServerParams) AllSigners

func (p ServerParams) AllSigners() map[string]*btcec.PublicKey

func (ServerParams) CheckpointExitPath

func (p ServerParams) CheckpointExitPath() []byte

type SignFn

type SignFn func(ctx context.Context, tx string) (string, error)

SignFn signs the provided base64-encoded PSBT with the caller's identity and returns the signed PSBT base64.

type SpentStatus

type SpentStatus struct {
	Spent   bool
	SpentBy string
}

type StreamConnectionEvent

type StreamConnectionEvent struct {
	State          StreamConnectionState
	At             time.Time
	DisconnectedAt time.Time
	Err            error
}

type StreamConnectionState

type StreamConnectionState string
const (
	StreamConnectionStateDisconnected StreamConnectionState = "DISCONNECTED"
	StreamConnectionStateReconnected  StreamConnectionState = "RECONNECTED"
	StreamConnectionStateReady        StreamConnectionState = "READY"
)

type StreamStartedEvent

type StreamStartedEvent struct {
	Id string
}

type SyncEvent

type SyncEvent struct {
	Synced bool
	Err    error
}

type Transaction

type Transaction struct {
	TransactionKey
	Amount      uint64
	Type        TxType
	CreatedAt   time.Time
	Hex         string
	SettledBy   string
	AssetPacket asset.Packet
	// Assets is the per-asset breakdown for this transaction, expressed as
	// net amounts (gross inputs minus own change). Populated at construction
	// by any code path that has the source vtxos in hand — notably
	// funding.vtxosToTxs (for reconciled history) and the wallet-side
	// send/batch handlers (for just-signed sends). Nil for pure-BTC
	// transactions.
	Assets []Asset
}

func (Transaction) String

func (t Transaction) String() string

type TransactionEvent

type TransactionEvent struct {
	CommitmentTx *TxNotification
	ArkTx        *TxNotification
	SweepTx      *TxNotification
	Connection   *StreamConnectionEvent
	Err          error
}

type TransactionKey

type TransactionKey struct {
	BoardingTxid   string
	CommitmentTxid string
	ArkTxid        string
}

func (TransactionKey) String

func (t TransactionKey) String() string

type TreeNoncesAggregatedEvent

type TreeNoncesAggregatedEvent struct {
	Id     string
	Nonces tree.TreeNonces
}

type TreeNoncesEvent

type TreeNoncesEvent struct {
	Id     string
	Topic  []string
	Txid   string
	Nonces map[string]*tree.Musig2Nonce
}

type TreeSignatureEvent

type TreeSignatureEvent struct {
	Id         string
	Topic      []string
	BatchIndex int32
	Txid       string
	Signature  string
}

type TreeSigningStartedEvent

type TreeSigningStartedEvent struct {
	Id                   string
	UnsignedCommitmentTx string
	CosignersPubkeys     []string
}

type TreeTxEvent

type TreeTxEvent struct {
	Id         string
	Topic      []string
	BatchIndex int32
	Node       tree.TxTreeNode
}

type Tx

type Tx struct {
	Txid   string
	Vin    []Input
	Vout   []Output
	Status ConfirmedStatus
}

type TxData

type TxData struct {
	Txid string
	Tx   string
}

type TxHistoryResponse

type TxHistoryResponse struct {
	History []Transaction
	Page    *PageResponse
}

type TxNode

type TxNode struct {
	Txid     string
	Children map[uint32]string
}

type TxNodes

type TxNodes []TxNode

func (TxNodes) ToTree

func (t TxNodes) ToTree(txMap map[string]string) []tree.TxTreeNode

func (TxNodes) Txids

func (t TxNodes) Txids() []string

type TxNotification

type TxNotification struct {
	TxData
	SpentVtxos     []Vtxo
	SpendableVtxos []Vtxo
	CheckpointTxs  map[Outpoint]TxData
	SweptVtxos     []Outpoint
}

type TxType

type TxType string
const (
	TxSent     TxType = "SENT"
	TxReceived TxType = "RECEIVED"
)

type Utxo

type Utxo struct {
	Outpoint
	Amount         uint64
	Script         string
	Delay          arklib.RelativeLocktime
	RedeemableAt   time.Time
	CreatedAt      time.Time
	Spent          bool
	SpentBy        string
	Tx             string
	Assets         []Asset
	Tapscripts     []string
	SigningClosure script.Closure
}

func (Utxo) IsConfirmed

func (u Utxo) IsConfirmed() bool

func (Utxo) ParseClosure

func (u Utxo) ParseClosure() ([]byte, *arklib.TaprootMerkleProof, error)

func (Utxo) Sequence

func (u Utxo) Sequence() (uint32, error)

func (Utxo) ToArkFeeInput

func (u Utxo) ToArkFeeInput() arkfee.OnchainInput

type VirtualTxsResponse

type VirtualTxsResponse struct {
	Txs  []string
	Page *PageResponse
}

type Vtxo

type Vtxo struct {
	Outpoint
	Script          string
	Amount          uint64
	CommitmentTxids []string
	ExpiresAt       time.Time
	CreatedAt       time.Time
	Preconfirmed    bool
	Swept           bool
	Unrolled        bool
	Spent           bool
	SpentBy         string
	SettledBy       string
	ArkTxid         string
	Assets          []Asset
	Tapscripts      []string
	SigningClosure  script.Closure
}

func CoinSelectAsset

func CoinSelectAsset(
	vtxos []Vtxo, amount uint64,
	assetID string, withoutExpirySorting bool,
) ([]Vtxo, uint64, error)

CoinSelectAsset picks vtxos that, combined, hold at least `amount` units of the asset identified by assetID. Vtxos with no matching asset are filtered out up front. By default vtxos are sorted so that the ones nearest to expiry sit at the end of the slice, and the loop picks from the front — i.e. it preserves the soonest-to-expire balance for as long as possible. Pass withoutExpirySorting=true to consume the input order verbatim (useful when the caller has already ordered the vtxos). Returns the selected vtxos plus the leftover change in asset units.

func (Vtxo) Address

func (v Vtxo) Address(server *btcec.PublicKey, net arklib.Network) (string, error)

func (Vtxo) IsRecoverable

func (v Vtxo) IsRecoverable() bool

func (Vtxo) ParseClosure

func (v Vtxo) ParseClosure() ([]byte, *arklib.TaprootMerkleProof, error)

func (Vtxo) String

func (v Vtxo) String() string

func (Vtxo) ToArkFeeInput

func (v Vtxo) ToArkFeeInput() arkfee.OffchainInput

type VtxoChainResponse

type VtxoChainResponse struct {
	Chain []ChainWithExpiry
	Page  *PageResponse
}

type VtxoTreeLeavesResponse

type VtxoTreeLeavesResponse struct {
	Leaves []Outpoint
	Page   *PageResponse
}

type VtxoTreeResponse

type VtxoTreeResponse struct {
	Tree []TxNode
	Page *PageResponse
}

type VtxosResponse

type VtxosResponse struct {
	Vtxos []Vtxo
	Page  *PageResponse
}

Directories

Path Synopsis
Package explorer provides an explorer client with support for multiple concurrent WebSocket connections for addresses tracking.
Package explorer provides an explorer client with support for multiple concurrent WebSocket connections for addresses tracking.
internal

Jump to

Keyboard shortcuts

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