taprootassets

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 68 Imported by: 2

README

Taproot Assets

The Taproot Assets Daemon tapd implements the Taproot Assets Protocol for issuing assets on the Bitcoin blockchain. Taproot Assets leverage Taproot transactions to commit to newly created assets and their transfers in an efficient and scalable manner. Multiple assets can be created and transferred in a single bitcoin UTXO, while witness data is transacted and stored off-chain.

Features:

  • Mint and burn assets
  • Synchronize to universes
  • Send and receive assets
  • Export and import Taproot Asset proofs
  • Create and manage CLI profiles

How it works:

When minting a new asset, Taproot Assets will generate the relevant witness data, assign the asset to a key held by you and publish the corresponding bitcoin UTXO -- the minting transaction.

The outpoint this minting transaction consumes becomes the genesis_point of the newly minted asset, acting as its unique identifier. Assets can be spent to a new recipient, who provides the sender with the necessary information encoded in their Taproot Asset address.

To transact assets, the witnesses in the prior transaction are recommitted into one or multiple taproot outputs while the necessary witness data is passed to the recipient. Similar to bitcoin transactions, the remaining balance is spent back to the sender as a change output.

Learn more about the Taproot Assets Protocol.

Architecture:

Taproot Assets are implemented as the Taproot Assets Daemon tapd and the Taproot Assets Command Line Interface tapcli. Additionally, tapd exposes a GRPC interface to allow for a direct integration into applications.

Taproot Assets leverage several LND features including the Taproot wallet and signing capabilities. These facilities are accessed through LND’s GRPC.

The Taproot Assets stack:

Bitcoin blockchain backend <-> LND <-> Taproot Assets

Custody of Taproot Assets is segmented across LND and Tapd to maximize security. LND holds the private key, which has had a taproot tweak applied to it, controlling the bitcoin UTXO holding the Taproot Asset. The taproot tweak on the other hand is held by Tapd. This increases the requirements for asset recovery as both the internal key as well as the taproot tweak are necessary to spend the output. This prevents LND from accidentally burning Taproot assets.

Prerequisites:

Taproot Assets require LND version v0.16.2-beta or later to be synced and running on the same Bitcoin network as Taproot Assets (e.g. regtest, simnet, testnet3). RPC connections need to be accepted and a valid macaroon needs to be present.

git clone https://github.com/lightningnetwork/lnd.git
cd lnd 
make install tags="signrpc walletrpc chainrpc invoicesrpc"

Installation:

From source:

Compile Taproot Assets from source by cloning this repository. Go version 1.19 or higher is required.

git clone --recurse-submodules https://github.com/lightninglabs/taproot-assets.git
cd taproot-assets
make install

Initialization:

Run Taproot Assets with the command tapd. Specify how Taproot Assets can reach LND and what network to run Tapd with by passing it additional flags. The Bitcoin backend and LND need to be running and synced before the Taproot Assets daemon can be started.

tapd --network=testnet --debuglevel=debug --lnd.host=localhost:10009 --lnd.macaroonpath=~/.lnd/data/chain/bitcoin/testnet/admin.macaroon --lnd.tlspath=~/.lnd/tls.cert

Usage:

See a full list of options by executing:

tapd --help

Use tapcli to interact with tapd

tapcli assets mint --type normal --name fantasycoin --supply 100 --meta_bytes "fantastic money"
tapcli assets mint finalize
tapcli assets list

Synchronize yourself with a universe, for example the one running as part of the issuer's tapd.

tapcli universe sync --universe_host testnet.universe.lightning.finance

Add multiple universes to your local federation to always stay up to date. You can also use the universe to query existing assets and their metadata. You may also configure your tapd instance to listen to incoming requests with --rpclisten 0.0.0.0:10029 to run your own universe.

tapcli universe federation add --universe_host testnet.universe.lightning.finance
tapcli universe roots

Once you have obtained the necessary proofs and asset IDs, you can generate a Taproot Asset address for a specific asset and amount.

tapcli addrs new --asset_id bab08407[...]129bf6d0 --amt 21

The sender can now fulfill the request by initiating the transfer.

tapcli assets send --addr taptb1q[...]tywpre3a

Development

API

Taproot Assets exposes a GRPC (port 10029) and a REST (port 8089) API. Connections are encrypted with TLS and authenticated using macaroons. The API is documented here. Further guides can be found here.

Mainnet

Starting with the release of version v0.3.0 the daemon does support the Bitcoin mainnet.

IMPORTANT NOTE: To avoid loss of funds, it's imperative that you read the Operational Safety Guidelines before using tapd on mainnet!

The daemon is still in alpha state, which means there can still be bugs and not all desired data safety and backup mechanisms have been implemented yet. Releasing on mainnet mainly signals that there will be no breaking changes in the future and that assets minted with v0.3.0 will be compatible with later versions.

Important note for Umbrel/Lightning Terminal users

DO NOT UNDER ANY CIRCUMSTANCE uninstall (or re-install) the "Lightning Terminal" app without first making a manual backup of all local tapd data, if you are using Taproot Assets as part of the "Lightning Terminal" app with Umbrel -- or any comparable node-in-a-box solution. Uninstalling Umbrel apps deletes application data. This Taproot Assets application data encumbers Taproot Assets AND bitcoin funds. Receiving and sending tapd assets updates the daemon's funds-custody material. Merely having the lnd seed phrase is NOT enough to restore assets minted or received. WITHOUT BACKUP BEFORE DELETION, FUNDS ARE DESTROYED.

Submit feature requests

The GitHub issue tracker can be used to request specific improvements or report bugs.

Join us on Slack

Join us in the Lightning Labs Slack and join the #taproot-assets channel to ask questions and interact with the community.

Documentation

Index

Constants

View Source
const (
	// AppMajor defines the major version of this binary.
	AppMajor uint = 0

	// AppMinor defines the minor version of this binary.
	AppMinor uint = 3

	// AppPatch defines the application patch for this binary.
	AppPatch uint = 3

	// AppPreRelease MUST only contain characters from semanticAlphabet
	// per the semantic versioning spec.
	AppPreRelease = "alpha"
)

These constants define the application version and follow the semantic versioning 2.0.0 spec (http://semver.org/).

View Source
const (

	// AssetBurnConfirmationText is the text that needs to be set on the
	// RPC to confirm an asset burn.
	AssetBurnConfirmationText = "assets will be destroyed"
)

Variables

View Source
var (
	// MaxMsgReceiveSize is the largest message our client will receive. We
	// set this to 200MiB atm.
	MaxMsgReceiveSize = grpc.MaxCallRecvMsgSize(lnrpc.MaxGrpcMsgSize)

	// ServerMaxMsgReceiveSize is the largest message our server will
	// receive.
	ServerMaxMsgReceiveSize = grpc.MaxRecvMsgSize(lnrpc.MaxGrpcMsgSize)
)
View Source
var (
	// Commit stores the current commit of this build, which includes the
	// most recent tag, the number of commits since that tag (if non-zero),
	// the commit hash, and a dirty marker. This should be set using the
	// -ldflags during compilation.
	Commit string

	// CommitHash stores the current commit hash of this build.
	CommitHash string

	// RawTags contains the raw set of build tags, separated by commas.
	RawTags string

	// GoVersion stores the go version that the executable was compiled
	// with.
	GoVersion string
)

Functions

func AddSubLogger

func AddSubLogger(root *build.RotatingLogWriter, subsystem string,
	interceptor signal.Interceptor, useLoggers ...func(btclog.Logger))

AddSubLogger is a helper method to conveniently create and register the logger of one or more sub systems.

func CheckFederationServer added in v0.2.1

func CheckFederationServer(localRuntimeID int64, connectTimeout time.Duration,
	server universe.ServerAddr) error

CheckFederationServer attempts to connect to the target server and ensure that it is a valid federation server that isn't the local daemon.

func ConnectUniverse added in v0.2.1

func ConnectUniverse(
	serverAddr universe.ServerAddr) (*universeClientConn, error)

ConnectUniverse connects to a remote Universe server using the provided server address.

func MarshalAssetFedSyncCfg added in v0.3.0

func MarshalAssetFedSyncCfg(
	config universe.FedUniSyncConfig) (*unirpc.AssetFederationSyncConfig,
	error)

MarshalAssetFedSyncCfg returns an RPC ready asset specific federation sync config.

func MarshalUniID added in v0.3.0

func MarshalUniID(id universe.Identifier) (*unirpc.ID, error)

MarshalUniID marshals the universe ID into the RPC counterpart.

func MarshalUniProofType added in v0.3.0

func MarshalUniProofType(
	proofType universe.ProofType) (unirpc.ProofType, error)

MarshalUniProofType marshals the universe proof type into the RPC counterpart.

func NewRpcUniverseDiff

func NewRpcUniverseDiff(
	serverAddr universe.ServerAddr) (universe.DiffEngine, error)

NewRpcUniverseDiff creates a new RpcUniverseDiff instance that dials out to the target remote universe server address.

func NewRpcUniverseRegistrar added in v0.2.1

func NewRpcUniverseRegistrar(
	serverAddr universe.ServerAddr) (universe.Registrar, error)

NewRpcUniverseRegistrar creates a new RpcUniverseRegistrar instance that dials out to the target remote universe server address.

func SetAgentName

func SetAgentName(newAgentName string)

SetAgentName overwrites the default agent name which can be used to identify the software tapd is bundled in (for example LiT). This function panics if the agent name contains characters outside of the allowed semantic alphabet.

func SetSubLogger

func SetSubLogger(root *build.RotatingLogWriter, subsystem string,
	logger btclog.Logger, useLoggers ...func(btclog.Logger))

SetSubLogger is a helper method to conveniently register the logger of a sub system.

func SetupLoggers

func SetupLoggers(root *build.RotatingLogWriter, interceptor signal.Interceptor)

SetupLoggers initializes all package-global logger variables.

func Tags

func Tags() []string

Tags returns the list of build tags that were compiled into the executable.

func UnmarshalKeyDescriptor

func UnmarshalKeyDescriptor(
	rpcDesc *taprpc.KeyDescriptor) (keychain.KeyDescriptor, error)

UnmarshalKeyDescriptor parses the RPC key descriptor into the native counterpart.

func UnmarshalScriptKey

func UnmarshalScriptKey(rpcKey *taprpc.ScriptKey) (*asset.ScriptKey, error)

UnmarshalScriptKey parses the RPC script key into the native counterpart.

func UnmarshalUniID added in v0.3.0

func UnmarshalUniID(rpcID *unirpc.ID) (universe.Identifier, error)

UnmarshalUniID parses the RPC universe ID into the native counterpart.

func UnmarshalUniProofType added in v0.3.0

func UnmarshalUniProofType(rpcType unirpc.ProofType) (universe.ProofType,
	error)

UnmarshalUniProofType parses the RPC universe proof type into the native counterpart.

func UserAgent

func UserAgent(initiator string) string

UserAgent returns the full user agent string that identifies the software that is submitting swaps to the loop server.

func Version

func Version() string

Version returns the application version as a properly formed string per the semantic versioning 2.0.0 spec (http://semver.org/).

Types

type Config

type Config struct {
	DebugLevel string

	// RuntimeID is a pseudo-random ID that is generated when the server
	// starts. It is used to identify the server to itself, to avoid
	// connecting to itself as a federation member.
	RuntimeID int64

	// TODO(roasbeef): use the Taproot Asset chain param wrapper here?
	ChainParams chaincfg.Params

	Lnd *lndclient.LndServices

	SignalInterceptor signal.Interceptor

	ReOrgWatcher *tapgarden.ReOrgWatcher

	AssetMinter tapgarden.Planter

	AssetCustodian *tapgarden.Custodian

	ChainBridge tapgarden.ChainBridge

	AddrBook *address.Book

	// AddrBookDisableSyncer is a flag which, if true, will prevent the
	// daemon from trying to sync issuance proofs for unknown assets when
	// creating an address.
	AddrBookDisableSyncer bool

	DefaultProofCourierAddr *url.URL

	ProofArchive proof.Archiver

	AssetWallet tapfreighter.Wallet

	CoinSelect *tapfreighter.CoinSelect

	ChainPorter tapfreighter.Porter

	UniverseArchive *universe.Archive

	UniverseSyncer universe.Syncer

	UniverseFederation *universe.FederationEnvoy

	UniverseStats universe.Telemetry

	// UniversePublicAccess is flag which, If true, and the Universe server
	// is on a public interface, valid proof from remote parties will be
	// accepted, and proofs will be queryable by remote parties.
	// This applies to federation syncing as well as RPC insert and query.
	UniversePublicAccess bool

	// UniverseQueriesPerSecond is the maximum number of queries per
	// second across the set of active universe queries that is permitted.
	// Anything above this starts to get rate limited.
	UniverseQueriesPerSecond rate.Limit

	// UniverseQueriesBurst is the burst budget for the universe query rate
	// limiting.
	UniverseQueriesBurst int

	Prometheus monitoring.PrometheusConfig

	// LogWriter is the root logger that all of the daemon's subloggers are
	// hooked up to.
	LogWriter *build.RotatingLogWriter

	*RPCConfig

	*DatabaseConfig
}

Config is the main config of the Taproot Assets server.

type DatabaseConfig

type DatabaseConfig struct {
	RootKeyStore *tapdb.RootKeyStore

	MintingStore tapgarden.MintingStore

	AssetStore *tapdb.AssetStore

	TapAddrBook *tapdb.TapAddressBook

	Multiverse *tapdb.MultiverseStore

	FederationDB *tapdb.UniverseFederationDB
}

DatabaseConfig is the config that holds all the persistence related structs and interfaces needed for tapd to function.

type LndRpcChainBridge

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

LndRpcChainBridge is an implementation of the tapgarden.ChainBridge interface backed by an active remote lnd node.

func NewLndRpcChainBridge

func NewLndRpcChainBridge(lnd *lndclient.LndServices) *LndRpcChainBridge

NewLndRpcChainBridge creates a new chain bridge from an active lnd services client.

func (*LndRpcChainBridge) CurrentHeight

func (l *LndRpcChainBridge) CurrentHeight(ctx context.Context) (uint32, error)

CurrentHeight return the current height of the main chain.

func (*LndRpcChainBridge) EstimateFee

func (l *LndRpcChainBridge) EstimateFee(ctx context.Context,
	confTarget uint32) (chainfee.SatPerKWeight, error)

EstimateFee returns a fee estimate for the confirmation target.

func (*LndRpcChainBridge) GetBlock

func (l *LndRpcChainBridge) GetBlock(ctx context.Context,
	hash chainhash.Hash) (*wire.MsgBlock, error)

GetBlock returns a chain block given its hash.

func (*LndRpcChainBridge) GetBlockHash added in v0.2.3

func (l *LndRpcChainBridge) GetBlockHash(ctx context.Context,
	blockHeight int64) (chainhash.Hash, error)

GetBlockHash returns the hash of the block in the best blockchain at the given height.

func (*LndRpcChainBridge) GetBlockHeader added in v0.3.2

func (l *LndRpcChainBridge) GetBlockHeader(ctx context.Context,
	hash chainhash.Hash) (*wire.BlockHeader, error)

GetBlockHeader returns a block header given its hash.

func (*LndRpcChainBridge) GetBlockHeaderSupported added in v0.3.2

func (l *LndRpcChainBridge) GetBlockHeaderSupported(ctx context.Context) bool

GetBlockHeaderSupported returns true if the chain backend supports the `GetBlockHeader` RPC call.

func (*LndRpcChainBridge) PublishTransaction

func (l *LndRpcChainBridge) PublishTransaction(ctx context.Context,
	tx *wire.MsgTx) error

PublishTransaction attempts to publish a new transaction to the network.

func (*LndRpcChainBridge) RegisterBlockEpochNtfn added in v0.3.0

func (l *LndRpcChainBridge) RegisterBlockEpochNtfn(
	ctx context.Context) (chan int32, chan error, error)

RegisterBlockEpochNtfn registers an intent to be notified of each new block connected to the main chain.

func (*LndRpcChainBridge) RegisterConfirmationsNtfn

func (l *LndRpcChainBridge) RegisterConfirmationsNtfn(ctx context.Context,
	txid *chainhash.Hash, pkScript []byte, numConfs, heightHint uint32,
	includeBlock bool,
	reOrgChan chan struct{}) (*chainntnfs.ConfirmationEvent, chan error,
	error)

RegisterConfirmationsNtfn registers an intent to be notified once txid reaches numConfs confirmations.

func (*LndRpcChainBridge) VerifyBlock added in v0.2.3

func (l *LndRpcChainBridge) VerifyBlock(ctx context.Context,
	header wire.BlockHeader, height uint32) error

VerifyBlock returns an error if a block (with given header and height) is not present on-chain. It also checks to ensure that block height corresponds to the given block header.

type LndRpcKeyRing

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

LndRpcKeyRing is an implementation of the keychain.KeyRing interface backed by an active remote lnd node.

func NewLndRpcKeyRing

func NewLndRpcKeyRing(lnd *lndclient.LndServices) *LndRpcKeyRing

NewLndRpcKeyRing creates a new instance of the LndRpcKeyRing based on the passed ln client.

func (*LndRpcKeyRing) DeriveKey

DeriveKey attempts to derive an arbitrary key specified by the passed KeyLocator. This may be used in several recovery scenarios, or when manually rotating something like our current default node key.

func (*LndRpcKeyRing) DeriveNextKey

func (l *LndRpcKeyRing) DeriveNextKey(ctx context.Context,
	keyFam keychain.KeyFamily) (keychain.KeyDescriptor, error)

DeriveNextKey attempts to derive the *next* key within the key family (account in BIP-0043) specified. This method should return the next external child within this branch.

func (*LndRpcKeyRing) DeriveNextTaprootAssetKey

func (l *LndRpcKeyRing) DeriveNextTaprootAssetKey(
	ctx context.Context) (keychain.KeyDescriptor, error)

DeriveNextTaprootAssetKey attempts to derive the *next* key within the Taproot Asset key family.

func (*LndRpcKeyRing) IsLocalKey

func (l *LndRpcKeyRing) IsLocalKey(ctx context.Context,
	desc keychain.KeyDescriptor) bool

IsLocalKey returns true if the key is under the control of the wallet and can be derived by it.

type LndRpcVirtualTxSigner

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

LndRpcVirtualTxSigner is an implementation of the tapscript.Signer interface backed by an active lnd node.

func NewLndRpcVirtualTxSigner

func NewLndRpcVirtualTxSigner(lnd *lndclient.LndServices) *LndRpcVirtualTxSigner

NewLndRpcVirtualTxSigner returns a new tx signer instance backed by the passed connection to a remote lnd node.

func (*LndRpcVirtualTxSigner) SignVirtualTx

func (l *LndRpcVirtualTxSigner) SignVirtualTx(signDesc *lndclient.SignDescriptor,
	tx *wire.MsgTx, prevOut *wire.TxOut) (*schnorr.Signature, error)

SignVirtualTx generates a signature according to the passed signing descriptor and virtual TX.

type LndRpcWalletAnchor

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

LndRpcWalletAnchor is an implementation of the tapgarden.WalletAnchor interfaced backed by an active remote lnd node.

func NewLndRpcWalletAnchor

func NewLndRpcWalletAnchor(lnd *lndclient.LndServices) *LndRpcWalletAnchor

NewLndRpcWalletAnchor returns a new wallet anchor instance using the passed lnd node.

func (*LndRpcWalletAnchor) FundPsbt

func (l *LndRpcWalletAnchor) FundPsbt(ctx context.Context, packet *psbt.Packet,
	minConfs uint32, feeRate chainfee.SatPerKWeight) (tapgarden.FundedPsbt,
	error)

FundPsbt attaches enough inputs to the target PSBT packet for it to be valid.

func (*LndRpcWalletAnchor) ImportTaprootOutput

func (l *LndRpcWalletAnchor) ImportTaprootOutput(ctx context.Context,
	pub *btcec.PublicKey) (btcutil.Address, error)

ImportTaprootOutput imports a new public key into the wallet, as a P2TR output.

func (*LndRpcWalletAnchor) ListTransactions

func (l *LndRpcWalletAnchor) ListTransactions(ctx context.Context, startHeight,
	endHeight int32, account string) ([]lndclient.Transaction, error)

ListTransactions returns all known transactions of the backing lnd node. It takes a start and end block height which can be used to limit the block range that we query over. These values can be left as zero to include all blocks. To include unconfirmed transactions in the query, endHeight must be set to -1.

func (*LndRpcWalletAnchor) ListUnspentImportScripts

func (l *LndRpcWalletAnchor) ListUnspentImportScripts(
	ctx context.Context) ([]*lnwallet.Utxo, error)

ListUnspentImportScripts lists all UTXOs of the imported Taproot scripts.

func (*LndRpcWalletAnchor) SignAndFinalizePsbt

func (l *LndRpcWalletAnchor) SignAndFinalizePsbt(ctx context.Context,
	pkt *psbt.Packet) (*psbt.Packet, error)

SignAndFinalizePsbt fully signs and finalizes the target PSBT packet.

func (*LndRpcWalletAnchor) SignPsbt

func (l *LndRpcWalletAnchor) SignPsbt(ctx context.Context,
	packet *psbt.Packet) (*psbt.Packet, error)

SignPsbt...

func (*LndRpcWalletAnchor) SubscribeTransactions

func (l *LndRpcWalletAnchor) SubscribeTransactions(
	ctx context.Context) (<-chan lndclient.Transaction, <-chan error,
	error)

SubscribeTransactions creates a uni-directional stream from the server to the client in which any newly discovered transactions relevant to the wallet are sent over.

func (*LndRpcWalletAnchor) UnlockInput

func (l *LndRpcWalletAnchor) UnlockInput(ctx context.Context) error

UnlockInput unlocks the set of target inputs after a batch is abandoned.

type RPCConfig

type RPCConfig struct {
	LisCfg *lnd.ListenerCfg

	RPCListeners []net.Addr

	RESTListeners []net.Addr

	GrpcServerOpts []grpc.ServerOption

	RestDialOpts []grpc.DialOption

	RestListenFunc func(net.Addr) (net.Listener, error)

	WSPingInterval time.Duration

	WSPongWait time.Duration

	RestCORS []string

	NoMacaroons bool

	MacaroonPath string

	AllowPublicUniProofCourier bool

	AllowPublicStats bool

	LetsEncryptDir string

	LetsEncryptListen string

	LetsEncryptDomain string

	LetsEncryptEmail string
}

RPCConfig is a sub-config of the main server that packages up everything needed to start the RPC server.

type RpcUniverseDiff

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

RpcUniverseDiff is an implementation of the universe.DiffEngine interface that uses an RPC connection to target Universe.

func (*RpcUniverseDiff) Close added in v0.3.3

func (r *RpcUniverseDiff) Close() error

Close closes the underlying RPC connection to the remote universe server.

func (*RpcUniverseDiff) FetchProofLeaf added in v0.3.1

func (r *RpcUniverseDiff) FetchProofLeaf(ctx context.Context,
	id universe.Identifier,
	key universe.LeafKey) ([]*universe.Proof, error)

FetchProofLeaf attempts to fetch a proof leaf for the target leaf key and given a universe identifier (assetID/groupKey).

TODO(roasbeef): actually add this somewhere else? * rn kinda asymmetric, as just need this to complete final portion of diff

func (*RpcUniverseDiff) RootNode

RootNode returns the root node for a given universe.

func (*RpcUniverseDiff) RootNodes

RootNodes returns the complete set of known root nodes for the set of assets tracked in the universe.

func (*RpcUniverseDiff) UniverseLeafKeys added in v0.3.0

UniverseLeafKeys returns all the keys inserted in the universe.

type RpcUniverseRegistrar added in v0.2.1

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

RpcUniverseRegistrar is an implementation of the universe.Registrar interface that uses an RPC connection to target Universe.

func (*RpcUniverseRegistrar) Close added in v0.3.3

func (r *RpcUniverseRegistrar) Close() error

Close closes the underlying RPC connection to the remote Universe server.

func (*RpcUniverseRegistrar) UpsertProofLeaf added in v0.3.1

UpsertProofLeaf is an implementation of the universe.Registrar interface that uses a remote Universe server as the Registry instance.

type Server

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

Server is the main daemon construct for the Taproot Asset server. It handles spinning up the RPC sever, the database, and any other components that the Taproot Asset server needs to function.

func NewServer

func NewServer(cfg *Config) *Server

NewServer creates a new server given the passed config.

func (Server) AddFederationServer

func (r Server) AddFederationServer(ctx context.Context,
	req *unirpc.AddFederationServerRequest,
) (*unirpc.AddFederationServerResponse, error)

AddFederationServer adds a new server to the federation of the local Universe server. Once a server is added, this call can also optionally be used to trigger a sync of the remote server.

func (Server) AddrReceives

func (r Server) AddrReceives(ctx context.Context,
	req *taprpc.AddrReceivesRequest) (*taprpc.AddrReceivesResponse,
	error)

AddrReceives lists all receives for incoming asset transfers for addresses that were created previously.

func (Server) AnchorVirtualPsbts

func (r Server) AnchorVirtualPsbts(ctx context.Context,
	req *wrpc.AnchorVirtualPsbtsRequest) (*taprpc.SendAssetResponse,
	error)

AnchorVirtualPsbts merges and then commits multiple virtual transactions in a single BTC level anchor transaction.

TODO(guggero): Actually implement accepting and merging multiple transactions.

func (Server) AssetLeafKeys

func (r Server) AssetLeafKeys(ctx context.Context,
	req *unirpc.AssetLeafKeysRequest) (*unirpc.AssetLeafKeyResponse, error)

AssetLeafKeys queries for the set of Universe keys associated with a given asset_id or group_key. Each key takes the form: (outpoint, script_key), where outpoint is an outpoint in the Bitcoin blockchain that anchors a valid Taproot Asset commitment, and script_key is the script_key of the asset within the Taproot Asset commitment for the given asset_id or group_key.

func (Server) AssetLeaves

func (r Server) AssetLeaves(ctx context.Context,
	req *unirpc.ID) (*unirpc.AssetLeafResponse, error)

AssetLeaves queries for the set of asset leaves (the values in the Universe MS-SMT tree) for a given asset_id or group_key. These represents either asset issuance events (they have a genesis witness) or asset transfers that took place on chain. The leaves contain a normal Taproot asset proof, as well as details for the asset.

func (Server) AssetRoots

func (r Server) AssetRoots(ctx context.Context,
	req *unirpc.AssetRootRequest) (*unirpc.AssetRootResponse, error)

AssetRoots queries for the known Universe roots associated with each known asset. These roots represent the supply/audit state for each known asset.

func (Server) BurnAsset added in v0.3.0

func (r Server) BurnAsset(ctx context.Context,
	in *taprpc.BurnAssetRequest) (*taprpc.BurnAssetResponse, error)

BurnAsset burns the given number of units of a given asset by sending them to a provably un-spendable script key. Burning means irrevocably destroying a certain number of assets, reducing the total supply of the asset. Because burning is such a destructive and non-reversible operation, some specific values need to be set in the request to avoid accidental burns.

func (Server) CancelBatch

func (r Server) CancelBatch(_ context.Context,
	_ *mintrpc.CancelBatchRequest) (*mintrpc.CancelBatchResponse,
	error)

CancelBatch attempts to cancel the current pending batch.

func (Server) DebugLevel

func (r Server) DebugLevel(ctx context.Context,
	req *taprpc.DebugLevelRequest) (*taprpc.DebugLevelResponse, error)

DebugLevel allows a caller to programmatically set the logging verbosity of tapd. The logging can be targeted according to a coarse daemon-wide logging level, or in a granular fashion to specify the logging for a target sub-system.

func (Server) DecodeAddr

func (r Server) DecodeAddr(_ context.Context,
	req *taprpc.DecodeAddrRequest) (*taprpc.Addr, error)

DecodeAddr decode a Taproot Asset address into a partial asset message that represents the asset it wants to receive.

func (Server) DecodeProof added in v0.2.1

func (r Server) DecodeProof(ctx context.Context,
	req *taprpc.DecodeProofRequest) (*taprpc.DecodeProofResponse, error)

DecodeProof attempts to decode a given proof file that claims to be anchored at the specified genesis point.

func (Server) DeleteAssetRoot added in v0.2.1

func (r Server) DeleteAssetRoot(ctx context.Context,
	req *unirpc.DeleteRootQuery) (*unirpc.DeleteRootResponse, error)

DeleteAssetRoot attempts to locate the current Universe root for a specific asset, and deletes the associated Universe tree if found.

func (Server) DeleteFederationServer

func (r Server) DeleteFederationServer(ctx context.Context,
	req *unirpc.DeleteFederationServerRequest,
) (*unirpc.DeleteFederationServerResponse, error)

DeleteFederationServer removes a server from the federation of the local Universe server.

func (Server) ExportProof

func (r Server) ExportProof(ctx context.Context,
	req *taprpc.ExportProofRequest) (*taprpc.ProofFile, error)

ExportProof exports the latest raw proof file anchored at the specified script_key.

func (Server) FetchAssetMeta

func (r Server) FetchAssetMeta(ctx context.Context,
	req *taprpc.FetchAssetMetaRequest) (*taprpc.AssetMeta, error)

FetchAssetMeta allows a caller to fetch the reveal meta data for an asset either by the asset ID for that asset, or a meta hash.

func (Server) FinalizeBatch

func (r Server) FinalizeBatch(_ context.Context,
	req *mintrpc.FinalizeBatchRequest) (*mintrpc.FinalizeBatchResponse,
	error)

FinalizeBatch attempts to finalize the current pending batch.

func (Server) FundVirtualPsbt

func (r Server) FundVirtualPsbt(ctx context.Context,
	req *wrpc.FundVirtualPsbtRequest) (*wrpc.FundVirtualPsbtResponse,
	error)

FundVirtualPsbt selects inputs from the available asset commitments to fund a virtual transaction matching the template.

func (Server) GetInfo added in v0.2.1

func (r Server) GetInfo(ctx context.Context,
	_ *taprpc.GetInfoRequest) (*taprpc.GetInfoResponse, error)

GetInfo returns general information relating to the active daemon. For example: its version, network, and lnd version.

func (Server) ImportProof

func (r Server) ImportProof(ctx context.Context,
	req *tapdevrpc.ImportProofRequest) (*tapdevrpc.ImportProofResponse,
	error)

ImportProof attempts to import a proof file into the daemon. If successful, a new asset will be inserted on disk, spendable using the specified target script key, and internal key.

func (Server) Info added in v0.2.1

func (r Server) Info(ctx context.Context,
	_ *unirpc.InfoRequest) (*unirpc.InfoResponse, error)

Info returns a set of information about the current state of the Universe.

func (Server) InsertProof

func (r Server) InsertProof(ctx context.Context,
	req *unirpc.AssetProof) (*unirpc.AssetProofResponse, error)

InsertProof attempts to insert a new issuance or transfer proof into the Universe tree specified by the UniverseKey. If valid, then the proof is inserted into the database, with a new Universe root returned for the updated asset_id/group_key.

func (Server) ListAssets

func (r Server) ListAssets(ctx context.Context,
	req *taprpc.ListAssetRequest) (*taprpc.ListAssetResponse, error)

ListAssets lists the set of assets owned by the target daemon.

func (Server) ListBalances

func (r Server) ListBalances(ctx context.Context,
	req *taprpc.ListBalancesRequest) (*taprpc.ListBalancesResponse, error)

ListBalances lists the asset balances owned by the daemon.

func (Server) ListBatches

func (r Server) ListBatches(_ context.Context,
	req *mintrpc.ListBatchRequest) (*mintrpc.ListBatchResponse, error)

ListBatches lists the set of batches submitted for minting, including pending and cancelled batches.

func (Server) ListFederationServers

func (r Server) ListFederationServers(ctx context.Context,
	_ *unirpc.ListFederationServersRequest,
) (*unirpc.ListFederationServersResponse, error)

ListFederationServers lists the set of servers that make up the federation of the local Universe server. This servers are used to push out new proofs, and also periodically call sync new proofs from the remote server.

func (Server) ListGroups

func (r Server) ListGroups(ctx context.Context,
	_ *taprpc.ListGroupsRequest) (*taprpc.ListGroupsResponse, error)

ListGroups lists known groups and the assets held in each group.

func (Server) ListTransfers

func (r Server) ListTransfers(ctx context.Context,
	_ *taprpc.ListTransfersRequest) (*taprpc.ListTransfersResponse,
	error)

ListTransfers lists all asset transfers managed by this deamon.

func (Server) ListUtxos

func (r Server) ListUtxos(ctx context.Context,
	req *taprpc.ListUtxosRequest) (*taprpc.ListUtxosResponse, error)

ListUtxos lists the UTXOs managed by the target daemon, and the assets they hold.

func (Server) MintAsset

func (r Server) MintAsset(ctx context.Context,
	req *mintrpc.MintAssetRequest) (*mintrpc.MintAssetResponse, error)

MintAsset attempts to mint the set of assets (async by default to ensure proper batching) specified in the request.

func (Server) NewAddr

func (r Server) NewAddr(ctx context.Context,
	req *taprpc.NewAddrRequest) (*taprpc.Addr, error)

NewAddr makes a new address from the set of request params.

func (Server) NextInternalKey

func (r Server) NextInternalKey(ctx context.Context,
	req *wrpc.NextInternalKeyRequest) (*wrpc.NextInternalKeyResponse,
	error)

NextInternalKey derives the next internal key for the given key family and stores it as an internal key in the database to make sure it is identified as a local key later on when importing proofs. While an internal key can also be used as the internal key of a script key, it is recommended to use the NextScriptKey RPC instead, to make sure the tweaked Taproot output key is also recognized as a local key.

func (Server) NextScriptKey

func (r Server) NextScriptKey(ctx context.Context,
	req *wrpc.NextScriptKeyRequest) (*wrpc.NextScriptKeyResponse,
	error)

NextScriptKey derives the next script key (and its corresponding internal key) and stores them both in the database to make sure they are identified as local keys later on when importing proofs.

func (Server) ProveAssetOwnership

func (r Server) ProveAssetOwnership(ctx context.Context,
	req *wrpc.ProveAssetOwnershipRequest) (*wrpc.ProveAssetOwnershipResponse,
	error)

ProveAssetOwnership creates an ownership proof embedded in an asset transition proof. That ownership proof is a signed virtual transaction spending the asset with a valid witness to prove the prover owns the keys that can spend the asset.

func (Server) QueryAddrs

func (r Server) QueryAddrs(ctx context.Context,
	req *taprpc.QueryAddrRequest) (*taprpc.QueryAddrResponse, error)

QueryAddrs queries the set of Taproot Asset addresses stored in the database.

func (Server) QueryAssetRoots

func (r Server) QueryAssetRoots(ctx context.Context,
	req *unirpc.AssetRootQuery) (*unirpc.QueryRootResponse, error)

QueryAssetRoots attempts to locate the current Universe root for a specific asset. This asset can be identified by its asset ID or group key.

func (Server) QueryAssetStats

func (r Server) QueryAssetStats(ctx context.Context,
	req *unirpc.AssetStatsQuery) (*unirpc.UniverseAssetStats, error)

QueryAssetStats returns a set of statistics for a given set of assets. Stats can be queried for all assets, or based on the: asset ID, name, or asset type. Pagination is supported via the offset and limit params. Results can also be sorted based on any of the main query params.

func (Server) QueryEvents added in v0.2.3

func (r Server) QueryEvents(ctx context.Context,
	req *unirpc.QueryEventsRequest) (*unirpc.QueryEventsResponse, error)

QueryEvents returns the number of sync and proof events for a given time period, grouped by day.

func (Server) QueryFederationSyncConfig added in v0.3.0

func (r Server) QueryFederationSyncConfig(ctx context.Context,
	_ *unirpc.QueryFederationSyncConfigRequest,
) (*unirpc.QueryFederationSyncConfigResponse, error)

QueryFederationSyncConfig queries the universe federation sync configuration settings.

func (Server) QueryProof

func (r Server) QueryProof(ctx context.Context,
	req *unirpc.UniverseKey) (*unirpc.AssetProofResponse, error)

QueryProof attempts to query for an issuance or transfer proof for a given asset based on its UniverseKey. A UniverseKey is composed of the Universe ID (asset_id/group_key) and also a leaf key (outpoint || script_key). If found, the target universe proof leaf is returned in addition to inclusion proofs for the Universe and Multiverse MS-SMTs. This allows a caller to verify the known Universe root, Multiverse root, and transition or issuance proof for the target asset.

func (Server) RegisterWithGrpcServer

func (r Server) RegisterWithGrpcServer(grpcServer *grpc.Server) error

RegisterWithGrpcServer registers the rpcServer with the passed root gRPC server.

func (Server) RegisterWithRestProxy

func (r Server) RegisterWithRestProxy(restCtx context.Context,
	restMux *proxy.ServeMux, restDialOpts []grpc.DialOption,
	restProxyDest string) error

RegisterWithRestProxy registers the RPC server with the given rest proxy.

func (Server) RemoveUTXOLease added in v0.3.0

func (r Server) RemoveUTXOLease(ctx context.Context,
	req *wrpc.RemoveUTXOLeaseRequest) (*wrpc.RemoveUTXOLeaseResponse,
	error)

RemoveUTXOLease removes the lease/lock/reservation of the given managed UTXO.

func (*Server) RunUntilShutdown

func (s *Server) RunUntilShutdown(mainErrChan <-chan error) error

RunUntilShutdown runs the main Taproot Asset server loop until a signal is received to shut down the process.

func (Server) SendAsset

func (r Server) SendAsset(_ context.Context,
	req *taprpc.SendAssetRequest) (*taprpc.SendAssetResponse, error)

SendAsset uses one or multiple passed Taproot Asset address(es) to attempt to complete an asset send. The method returns information w.r.t the on chain send, as well as the proof file information the receiver needs to fully receive the asset.

func (Server) SetFederationSyncConfig added in v0.3.0

func (r Server) SetFederationSyncConfig(ctx context.Context,
	req *unirpc.SetFederationSyncConfigRequest) (
	*unirpc.SetFederationSyncConfigResponse, error)

SetFederationSyncConfig sets the configuration of the universe federation sync.

func (Server) SignVirtualPsbt

func (r Server) SignVirtualPsbt(_ context.Context,
	req *wrpc.SignVirtualPsbtRequest) (*wrpc.SignVirtualPsbtResponse,
	error)

SignVirtualPsbt signs the inputs of a virtual transaction and prepares the commitments of the inputs and outputs.

func (Server) Start

func (r Server) Start() error

Start signals that the RPC server starts accepting requests.

func (*Server) StartAsSubserver

func (s *Server) StartAsSubserver(lndGrpc *lndclient.GrpcLndServices) error

StartAsSubserver is an alternative to Start where the RPC server does not create its own gRPC server but registers to an existing one. The same goes for REST (if enabled), instead of creating an own mux and HTTP server, we register to an existing one.

func (*Server) Stop

func (s *Server) Stop() error

Stop signals that the main tapd server should attempt a graceful shutdown.

func (Server) StopDaemon

func (r Server) StopDaemon(_ context.Context,
	_ *taprpc.StopRequest) (*taprpc.StopResponse, error)

StopDaemon will send a shutdown request to the interrupt handler, triggering a graceful shutdown of the daemon.

func (Server) SubscribeReceiveAssetEventNtfns added in v0.3.1

func (r Server) SubscribeReceiveAssetEventNtfns(
	_ *taprpc.SubscribeReceiveAssetEventNtfnsRequest,
	ntfnStream subReceiveEventNtfnsStream) error

SubscribeReceiveAssetEventNtfns registers a subscription to the event notification stream which relates to the asset receiving process.

func (Server) SubscribeSendAssetEventNtfns

func (r Server) SubscribeSendAssetEventNtfns(
	_ *taprpc.SubscribeSendAssetEventNtfnsRequest,
	ntfnStream subSendEventNtfnsStream) error

SubscribeSendAssetEventNtfns registers a subscription to the event notification stream which relates to the asset sending process.

func (Server) SyncUniverse

func (r Server) SyncUniverse(ctx context.Context,
	req *unirpc.SyncRequest) (*unirpc.SyncResponse, error)

SyncUniverse takes host information for a remote Universe server, then attempts to synchronize either only the set of specified asset_ids, or all assets if none are specified. The sync process will attempt to query for the latest known root for each asset, performing tree based reconciliation to arrive at a new shared root.

func (Server) UniverseStats

func (r Server) UniverseStats(ctx context.Context,
	_ *unirpc.StatsRequest) (*unirpc.StatsResponse, error)

UniverseStats returns a set of aggregate statistics for the current state of the Universe.

func (*Server) ValidateMacaroon

func (s *Server) ValidateMacaroon(ctx context.Context,
	requiredPermissions []bakery.Op, fullMethod string) error

ValidateMacaroon extracts the macaroon from the context's gRPC metadata, checks its signature, makes sure all specified permissions for the called method are contained within and finally ensures all caveat conditions are met. A non-nil error is returned if any of the checks fail. This method is needed to enable tapd running as an external subserver in the same process as lnd but still validate its own macaroons.

func (Server) VerifyAssetOwnership

func (r Server) VerifyAssetOwnership(ctx context.Context,
	req *wrpc.VerifyAssetOwnershipRequest) (*wrpc.VerifyAssetOwnershipResponse,
	error)

VerifyAssetOwnership verifies the asset ownership proof embedded in the given transition proof of an asset and returns true if the proof is valid.

func (Server) VerifyProof

func (r Server) VerifyProof(ctx context.Context,
	req *taprpc.ProofFile) (*taprpc.VerifyProofResponse, error)

VerifyProof attempts to verify a given proof file that claims to be anchored at the specified genesis point.

type ValidatorV0

type ValidatorV0 struct{}

ValidatorV0 is an implementation of the tapscript.TxValidator interface that supports Taproot Asset script version 0.

func (*ValidatorV0) Execute

func (v *ValidatorV0) Execute(newAsset *asset.Asset,
	splitAssets []*commitment.SplitAsset,
	prevAssets commitment.InputSet) error

Execute creates and runs an instance of the Taproot Asset script V0 VM.

Directories

Path Synopsis
cmd
internal
Package taprpc is a reverse proxy.
Package taprpc is a reverse proxy.
assetwalletrpc
Package assetwalletrpc is a reverse proxy.
Package assetwalletrpc is a reverse proxy.
mintrpc
Package mintrpc is a reverse proxy.
Package mintrpc is a reverse proxy.
tapdevrpc
Package tapdevrpc is a reverse proxy.
Package tapdevrpc is a reverse proxy.
universerpc
Package universerpc is a reverse proxy.
Package universerpc is a reverse proxy.

Jump to

Keyboard shortcuts

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