grpc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEventClient

func NewEventClient(conn grpc.ClientConnInterface,
	timeout time.Duration,
	adminMac macaroon.SerializedMacaroon,
	mintMac macaroon.SerializedMacaroon) *eventClient

NewEventClient creates a new event subscription client.

func NewMintClient

func NewMintClient(conn grpc.ClientConnInterface, timeout time.Duration,
	mintMac macaroon.SerializedMacaroon) *mintClient

NewMintClient creates a new Mint client.

func NewProofClient

func NewProofClient(conn grpc.ClientConnInterface, timeout time.Duration,
	proofMac macaroon.SerializedMacaroon) *proofClient

NewProofClient creates a new Proof client.

func NewUniverseClient

func NewUniverseClient(conn grpc.ClientConnInterface, timeout time.Duration,
	universeMac macaroon.SerializedMacaroon) *universeClient

NewUniverseClient creates a new Universe client.

func NewWalletClient

func NewWalletClient(conn grpc.ClientConnInterface, timeout time.Duration,
	adminMac macaroon.SerializedMacaroon) *walletClient

NewWalletClient creates a new Wallet client.

func NewWalletKitClient

func NewWalletKitClient(conn grpc.ClientConnInterface, timeout time.Duration,
	walletKitMac macaroon.SerializedMacaroon) *walletKitClient

NewWalletKitClient creates a new WalletKit client.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client holds the connection to the tapd daemon and the sub-clients.

func NewClient

func NewClient(cfg *Config) (*Client, error)

NewClient creates a new Client instance.

func (Client) AddFederationServer

func (u Client) AddFederationServer(ctx context.Context,
	servers []tapsdk.FederationServer) error

AddFederationServer adds servers to the federation.

func (Client) AddrReceives

func (s Client) AddrReceives(ctx context.Context,
	query *tapsdk.AddressReceivesQuery) ([]*tapsdk.AddressEvent, error)

AddrReceives returns incoming transfer events for addresses created by this tapd instance.

func (Client) AnchorVirtualPsbts

func (m Client) AnchorVirtualPsbts(ctx context.Context,
	signedPsbts [][]byte) (*tapsdk.AssetTransfer, error)

AnchorVirtualPsbts anchors signed virtual PSBTs in a single call. This combines signing, committing, and publishing into one operation. It returns the completed transfer result with transaction details and proofs.

func (Client) AssetLeafKeys

func (u Client) AssetLeafKeys(ctx context.Context,
	req *tapsdk.AssetLeafKeysRequest) ([]tapsdk.AssetLeafKey,
	error)

AssetLeafKeys returns the set of leaf keys for a universe.

func (Client) AssetLeaves

func (u Client) AssetLeaves(ctx context.Context,
	id *tapsdk.UniverseID) ([]tapsdk.AssetLeaf, error)

AssetLeaves returns the set of asset leaves for a universe.

func (Client) AssetRoots

func (u Client) AssetRoots(ctx context.Context,
	req *tapsdk.AssetRootRequest) (
	map[string]*tapsdk.UniverseRoot, error)

AssetRoots returns the known universe roots for all assets.

func (Client) BurnAsset

func (s Client) BurnAsset(ctx context.Context,
	req *tapsdk.BurnAssetRequest) (*tapsdk.BurnAssetResponse,
	error)

BurnAsset burns asset units. The confirmation text must be set to "assets will be destroyed" for the burn to succeed.

func (Client) CancelBatch

func (m Client) CancelBatch(ctx context.Context) (
	*tapsdk.CancelBatchResponse, error)

CancelBatch cancels the current mint batch.

func (*Client) Close

func (c *Client) Close() error

Close tears down the underlying gRPC connection.

func (Client) CommitVirtualPsbts

func (m Client) CommitVirtualPsbts(ctx context.Context,
	virtualPsbts [][]byte, passivePsbts [][]byte,
	feeRate tapsdk.FeeRate) (
	*tapsdk.CommittedTransfer, error)

CommitVirtualPsbts commits virtual transactions.

func (Client) DeclareScriptKey

func (m Client) DeclareScriptKey(ctx context.Context,
	req *tapsdk.DeclareScriptKeyRequest) (*tapsdk.ScriptKey,
	error)

DeclareScriptKey informs the wallet about an externally derived script key.

func (Client) DecodeAddr

func (s Client) DecodeAddr(ctx context.Context,
	addr string) (*tapsdk.Address, error)

DecodeAddr decodes a bech32m Taproot Asset address string into its components.

func (Client) DecodeProof

func (p Client) DecodeProof(ctx context.Context,
	rawProof []byte) (*tapsdk.DecodedProof, error)

DecodeProof decodes a raw proof and returns details about it.

func (Client) DeleteAssetRoot

func (u Client) DeleteAssetRoot(ctx context.Context,
	id *tapsdk.UniverseID) error

DeleteAssetRoot deletes a universe root for a specific asset.

func (Client) DeleteFederationServer

func (u Client) DeleteFederationServer(ctx context.Context,
	servers []tapsdk.FederationServer) error

DeleteFederationServer removes servers from the federation.

func (Client) DeriveInternalKey

func (m Client) DeriveInternalKey(ctx context.Context) (
	*tapsdk.InternalKey, error)

DeriveInternalKey derives a new internal key for anchor outputs.

func (Client) DeriveScriptKey

func (m Client) DeriveScriptKey(ctx context.Context) (
	*tapsdk.ScriptKey, error)

DeriveScriptKey derives a new script key for receiving assets. The script key includes both the internal key and the tweaked Taproot output key.

func (Client) ExportBackup

func (m Client) ExportBackup(ctx context.Context,
	mode tapsdk.BackupMode) ([]byte, error)

ExportBackup exports an asset wallet backup blob.

func (Client) ExportProof

func (p Client) ExportProof(ctx context.Context,
	ref tapsdk.AssetRef, scriptKey tapsdk.PubKey,
	outpoint *tapsdk.Outpoint) (*tapsdk.ProofFile, error)

ExportProof exports a proof file for a specific asset output.

func (Client) FetchAssetMeta

func (s Client) FetchAssetMeta(ctx context.Context,
	req *tapsdk.FetchAssetMetaRequest) (*tapsdk.AssetMeta, error)

FetchAssetMeta fetches the metadata for an asset by ID or meta hash.

func (Client) FinalizeBatch

func (m Client) FinalizeBatch(ctx context.Context,
	req *tapsdk.FinalizeBatchRequest) (*tapsdk.MintingBatch, error)

FinalizeBatch finalizes the current pending mint batch.

func (Client) FundBatch

func (m Client) FundBatch(ctx context.Context,
	req *tapsdk.FundBatchRequest) (*tapsdk.VerboseMintingBatch, error)

FundBatch funds the current pending minting batch.

func (Client) FundInteractivePsbt

func (m Client) FundInteractivePsbt(ctx context.Context,
	psbt []byte) (*tapsdk.FundedTransfer, error)

FundInteractivePsbt funds a virtual PSBT for interactive sends. The psbt parameter should be a serialized vPacket created for the interactive transfer.

func (Client) FundTransfer

func (m Client) FundTransfer(ctx context.Context,
	recipients []tapsdk.Recipient, inputs []tapsdk.PrevID) (
	*tapsdk.FundedTransfer, error)

FundTransfer funds a virtual transaction.

func (Client) GetInfo

func (s Client) GetInfo(ctx context.Context) (*tapsdk.Info, error)

func (Client) ImportBackup

func (m Client) ImportBackup(ctx context.Context,
	backup []byte) (uint32, error)

ImportBackup imports assets from a previously exported wallet backup blob.

func (Client) Info

func (u Client) Info(
	ctx context.Context) (*tapsdk.UniverseInfo, error)

Info returns basic universe server information.

func (Client) InsertProof

func (u Client) InsertProof(ctx context.Context, rawProof []byte,
	decoded *tapsdk.DecodedProof) error

InsertProof inserts a proof into the local universe. The decoded proof information is used to construct the universe key.

func (Client) ListAssetGroups

func (s Client) ListAssetGroups(
	ctx context.Context) ([]tapsdk.AssetGroupRecord, error)

ListAssetGroups lists all known asset groups.

func (Client) ListAssetRecords

func (s Client) ListAssetRecords(ctx context.Context,
	req *tapsdk.ListAssetsRequest) ([]*tapsdk.AssetRecord, error)

func (Client) ListBalances

func (s Client) ListBalances(ctx context.Context,
	req *tapsdk.ListBalancesRequest) (
	*tapsdk.ListBalancesResponse, error)

func (Client) ListBatches

func (m Client) ListBatches(ctx context.Context,
	req *tapsdk.ListBatchesRequest) ([]*tapsdk.VerboseMintingBatch, error)

ListBatches lists mint batches known to the daemon.

func (Client) ListBurns

func (s Client) ListBurns(ctx context.Context,
	req *tapsdk.ListBurnsRequest) ([]*tapsdk.BurnRecord, error)

ListBurns lists asset burns with optional filtering.

func (Client) ListFederationServers

func (u Client) ListFederationServers(
	ctx context.Context) ([]tapsdk.FederationServer, error)

ListFederationServers lists the universe federation peers.

func (Client) ListTransfers

func (s Client) ListTransfers(ctx context.Context,
	req *tapsdk.ListTransfersRequest) ([]*tapsdk.AssetTransfer, error)

func (Client) ListUtxos

func (s Client) ListUtxos(ctx context.Context,
	req *tapsdk.ListUtxosRequest) (map[string]*tapsdk.ManagedUtxo,
	error)

ListUtxos lists managed UTXOs with optional filtering.

func (Client) MintAsset

func (m Client) MintAsset(ctx context.Context,
	req *tapsdk.MintAssetRequest) (*tapsdk.MintingBatch,
	error)

MintAsset adds a brand-new asset to the pending minting batch.

func (Client) MintIssuance

func (m Client) MintIssuance(ctx context.Context,
	req *tapsdk.MintIssuanceRequest) (*tapsdk.MintingBatch,
	error)

MintIssuance adds an additional issuance to the pending minting batch.

func (Client) NewAddr

func (s Client) NewAddr(ctx context.Context,
	req *tapsdk.NewAddressRequest) (*tapsdk.Address, error)

NewAddr creates a new Taproot Asset address for receiving assets.

func (Client) ProveAssetOwnership

func (m Client) ProveAssetOwnership(ctx context.Context,
	req *tapsdk.ProveOwnershipRequest) (*tapsdk.OwnershipProof,
	error)

ProveAssetOwnership generates a proof of ownership for an asset.

func (Client) PublishAndLogTransfer

func (m Client) PublishAndLogTransfer(ctx context.Context,
	anchorPsbt []byte, virtualPsbts [][]byte, passivePsbts [][]byte,
	skipAnchorTxBroadcast bool) (*tapsdk.AssetPacket, error)

PublishAndLogTransfer publishes the anchor transaction and logs the transfer.

func (Client) QueryAddrs

func (s Client) QueryAddrs(ctx context.Context,
	query *tapsdk.AddressQuery) ([]*tapsdk.Address, error)

QueryAddrs returns addresses that were previously created by this tapd instance.

func (Client) QueryAssetRoots

func (u Client) QueryAssetRoots(ctx context.Context,
	id *tapsdk.UniverseID) (*tapsdk.QueryRootResponse, error)

QueryAssetRoots queries the issuance and transfer roots for a specific asset.

func (Client) QueryAssetStats

func (u Client) QueryAssetStats(ctx context.Context,
	req *tapsdk.AssetStatsQuery) ([]tapsdk.AssetStatsSnapshot,
	error)

QueryAssetStats returns per-asset statistics.

func (Client) QueryEvents

func (u Client) QueryEvents(ctx context.Context,
	req *tapsdk.QueryEventsRequest) (
	[]tapsdk.GroupedUniverseEvents, error)

QueryEvents returns daily event counts for a time range.

func (Client) QueryFederationSyncConfig

func (u Client) QueryFederationSyncConfig(ctx context.Context,
	ids []tapsdk.UniverseID) (*tapsdk.FederationSyncConfig, error)

QueryFederationSyncConfig queries the federation sync configuration.

func (Client) QueryInternalKey

func (m Client) QueryInternalKey(ctx context.Context,
	internalKey []byte) (*tapsdk.KeyDescriptor, error)

QueryInternalKey looks up an internal key by its raw public key bytes. The input can be 32-byte x-only or 33-byte compressed.

func (Client) QueryProof

func (u Client) QueryProof(ctx context.Context,
	key *tapsdk.UniverseKey) (*tapsdk.AssetProofResponse, error)

QueryProof queries a specific proof from the universe.

func (Client) QueryScriptKey

func (m Client) QueryScriptKey(ctx context.Context,
	tweakedScriptKey []byte) (*tapsdk.ScriptKey, error)

QueryScriptKey looks up a script key by its tweaked public key bytes. The input can be 32-byte x-only or 33-byte compressed.

func (Client) RegisterTransfer

func (p Client) RegisterTransfer(ctx context.Context,
	assetRef tapsdk.AssetRef, scriptKey tapsdk.PubKey,
	outpoint tapsdk.Outpoint) (
	*tapsdk.RegisteredAsset, error)

RegisterTransfer registers an inbound transfer for an interactive send. The proof must already be in the local universe before calling this.

func (Client) RegisterTransferWithIssuance

func (p Client) RegisterTransferWithIssuance(ctx context.Context,
	assetRef tapsdk.AssetRef, issuanceID tapsdk.AssetID,
	scriptKey tapsdk.PubKey, outpoint tapsdk.Outpoint) (
	*tapsdk.RegisteredAsset, error)

RegisterTransferWithIssuance registers an inbound transfer when the user facing asset ref is a group key and tapd still needs the concrete issuance ID from the imported proof.

func (Client) RemoveUTXOLease

func (m Client) RemoveUTXOLease(ctx context.Context,
	outpoint tapsdk.Outpoint) error

RemoveUTXOLease removes a lease on a UTXO.

func (Client) SealBatch

func (m Client) SealBatch(ctx context.Context,
	req *tapsdk.SealBatchRequest) (*tapsdk.MintingBatch, error)

SealBatch seals the current funded mint batch.

func (Client) SendAsset

func (s Client) SendAsset(ctx context.Context,
	req *tapsdk.SendAssetRequest) (*tapsdk.AssetTransfer, error)

SendAsset performs a one-shot address-based send.

func (Client) SetFederationSyncConfig

func (u Client) SetFederationSyncConfig(ctx context.Context,
	global []tapsdk.GlobalFederationSyncConfig,
	asset []tapsdk.AssetFederationSyncConfig) error

SetFederationSyncConfig sets the federation sync configuration.

func (Client) SignVirtualPsbt

func (m Client) SignVirtualPsbt(ctx context.Context,
	fundedPsbt []byte) ([]byte, error)

SignVirtualPsbt signs a virtual transaction.

func (Client) SubscribeMintEvents

func (c Client) SubscribeMintEvents(ctx context.Context,
	req *tapsdk.SubscribeMintEventsRequest) (
	<-chan *tapsdk.MintEvent, <-chan error, error)

SubscribeMintEvents opens a server-streaming subscription for minting batch lifecycle events.

func (Client) SubscribeReceiveEvents

func (c Client) SubscribeReceiveEvents(ctx context.Context,
	req *tapsdk.SubscribeReceiveEventsRequest) (
	<-chan *tapsdk.ReceiveEventRecord, <-chan error, error)

SubscribeReceiveEvents opens a server-streaming subscription for incoming asset transfer events. It returns a channel of events and an error channel. The error channel receives exactly one value when the stream terminates.

func (Client) SubscribeSendEvents

func (c Client) SubscribeSendEvents(ctx context.Context,
	req *tapsdk.SubscribeSendEventsRequest) (
	<-chan *tapsdk.SendEventRecord, <-chan error, error)

SubscribeSendEvents opens a server-streaming subscription for outgoing asset transfer events.

func (Client) SyncUniverse

func (u Client) SyncUniverse(ctx context.Context,
	req *tapsdk.SyncRequest) ([]tapsdk.SyncedUniverse, error)

SyncUniverse synchronizes with a remote universe server.

func (Client) UniverseStats

func (u Client) UniverseStats(
	ctx context.Context) (*tapsdk.UniverseStats, error)

UniverseStats returns aggregate statistics for the universe.

func (Client) UnpackProofFile

func (p Client) UnpackProofFile(ctx context.Context,
	rawProofFile []byte) ([][]byte, error)

UnpackProofFile unpacks a proof file into individual proofs.

func (Client) VerifyAssetOwnership

func (m Client) VerifyAssetOwnership(ctx context.Context,
	req *tapsdk.VerifyOwnershipRequest) (
	*tapsdk.VerifyOwnershipResponse, error)

VerifyAssetOwnership verifies an asset ownership proof.

func (Client) VerifyProof

func (s Client) VerifyProof(ctx context.Context,
	rawProofFile []byte) (*tapsdk.VerifyProofResponse, error)

VerifyProof verifies a proof file and returns the decoded last proof if valid.

type Config

type Config struct {
	// Host is the network address (host:port) of the tapd instance to connect
	// to.
	Host string

	// Network is the bitcoin network we expect the tapd instance to operate on.
	Network tapsdk.Network

	// Macaroon chooses where the SDK reads authentication
	// macaroons from. Obtain values from macaroon.FromPath,
	// macaroon.FromDir, or macaroon.FromHex. When nil, the SDK
	// falls back to tapd's default per-network directory under
	// ~/.tapd.
	Macaroon macaroon.Source

	// TLS chooses how the SDK builds its TLS trust configuration.
	// Obtain values from TLSFromPath, TLSFromData, TLSSystemCert,
	// or TLSInsecure. When nil, the SDK falls back to tapd's
	// default tls.cert path under ~/.tapd.
	TLS TLSSource

	// TLSMinVersion sets the minimum TLS version the client will accept.
	// Defaults to TLS 1.2 when zero. Use crypto/tls constants
	// (tls.VersionTLS12, tls.VersionTLS13).
	TLSMinVersion uint16

	// TLSPinnedCertFingerprint is the hex-encoded SHA-256 fingerprint
	// of the expected server certificate. When set, the client rejects
	// connections to servers presenting a different leaf certificate.
	// The fingerprint is compared against the raw DER encoding of the
	// first certificate in the peer's chain.
	TLSPinnedCertFingerprint string

	// RPCTimeout is an optional custom timeout that will be used for rpc
	// calls to tapd. If this value is not set, it will default to 30
	// seconds.
	RPCTimeout time.Duration
}

Config holds all configuration settings that are needed to connect to a tapd instance.

type TLSSource

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

TLSSource describes how the gRPC client should build its TLS trust configuration. Exactly one source is held on Config.TLS — so mutually exclusive choices (pinned cert vs system pool vs insecure) cannot be expressed. Instances are obtained from TLSFromPath, TLSFromData, TLSSystemCert, or TLSInsecure.

func TLSFromData

func TLSFromData(pem string) TLSSource

TLSFromData returns a TLSSource that trusts a PEM certificate supplied directly as a string (useful when the cert travels through config management rather than the filesystem).

func TLSFromPath

func TLSFromPath(path string) TLSSource

TLSFromPath returns a TLSSource that loads a PEM-encoded certificate from disk and trusts exactly that cert.

func TLSInsecure

func TLSInsecure() TLSSource

TLSInsecure returns a TLSSource that disables TLS verification. Intended for local bufconn / regtest setups only — never for production.

func TLSSystemCert

func TLSSystemCert() TLSSource

TLSSystemCert returns a TLSSource that uses the host's system certificate pool, appropriate for reaching tapd through a publicly-issued certificate chain.

Jump to

Keyboard shortcuts

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