taprootassets

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 63 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 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

The current codebase does not support the Bitcoin mainnet. Patching the code to run on mainnet will very likely lead to loss of funds (both the minted assets and the BTC UTXO) as things will break or change in the future.

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 = 2

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

	// 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/).

Variables

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) (unirpc.UniverseClient, error)

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

func MarshalAsset

func MarshalAsset(ctx context.Context, a *asset.Asset,
	isSpent, withWitness bool,
	keyRing KeyLookup) (*taprpc.Asset, error)

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 UnmarshalOutpoint added in v0.2.1

func UnmarshalOutpoint(outpoint string) (*wire.OutPoint, error)

unmarshalOutpoint unmarshals an outpoint from a string received via RPC.

func UnmarshalScriptKey

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

UnmarshalScriptKey parses the RPC script key 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

	AcceptRemoteUniverseProofs bool

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

	Lnd *lndclient.LndServices

	SignalInterceptor signal.Interceptor

	AssetMinter tapgarden.Planter

	AssetCustodian *tapgarden.Custodian

	ChainBridge tapgarden.ChainBridge

	AddrBook *address.Book

	ProofArchive proof.Archiver

	AssetWallet tapfreighter.Wallet

	ChainPorter tapfreighter.Porter

	BaseUniverse *universe.MintingArchive

	UniverseSyncer universe.Syncer

	UniverseFederation *universe.FederationEnvoy

	UniverseStats universe.Telemetry

	// 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

	UniverseForest *tapdb.BaseUniverseForest

	FederationDB *tapdb.UniverseFederationDB
}

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

type KeyLookup

type KeyLookup interface {
	// IsLocalKey returns true if the key is under the control of the
	// wallet and can be derived by it.
	IsLocalKey(ctx context.Context, desc keychain.KeyDescriptor) bool
}

KeyLookup is used to determine whether a key is under the control of the local wallet.

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) PublishTransaction

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

PublishTransaction attempts to publish a new transaction to the network.

func (*LndRpcChainBridge) RegisterConfirmationsNtfn

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

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

type LndRpcGenSigner

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

LndRpcGenSigner is an implementation of the asset.GenesisSigner interface backed by an active lnd node.

func NewLndRpcGenSigner

func NewLndRpcGenSigner(lnd *lndclient.LndServices) *LndRpcGenSigner

NewLndRpcGenSigner returns a new gen signer instance backed by the passed connection to a remote lnd node.

func (*LndRpcGenSigner) SignGenesis

func (l *LndRpcGenSigner) SignGenesis(keyDesc keychain.KeyDescriptor,
	initialGen asset.Genesis, currentGen *asset.Genesis) (*btcec.PublicKey,
	*schnorr.Signature, error)

SignGenesis tweaks the public key identified by the passed key descriptor with the the first passed Genesis description, and signs the second passed Genesis description with the tweaked public key. For minting the first asset in a group, only one Genesis object is needed, since we tweak with and sign over the same Genesis object. The final tweaked public key and the signature are returned.

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

	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) FetchIssuanceProof

func (r *RpcUniverseDiff) FetchIssuanceProof(ctx context.Context,
	id universe.Identifier,
	key universe.BaseKey) ([]*universe.IssuanceProof, error)

FetchIssuanceProof attempts to fetch an issuance proof for the target base leaf based on the 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) MintingKeys

func (r *RpcUniverseDiff) MintingKeys(ctx context.Context,
	id universe.Identifier) ([]universe.BaseKey, error)

MintingKeys returns all the keys inserted in the universe.

func (*RpcUniverseDiff) RootNode

RootNode returns the root node for a given base universe.

func (*RpcUniverseDiff) RootNodes

func (r *RpcUniverseDiff) RootNodes(
	ctx context.Context) ([]universe.BaseRoot, error)

RootNodes returns the complete set of known root nodes for the set of assets tracked in the base 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) RegisterIssuance added in v0.2.1

RegisterIssuance 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,
	in *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,
	in *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,
	in *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.ID) (*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) 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,
	in *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,
	in *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,
	in *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,
	in *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,
	in *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

FinalizeBatch attempts to finalize the current pending batch.

func (Server) FundVirtualPsbt

func (r Server) FundVirtualPsbt(ctx context.Context,
	in *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

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,
	in *taprpc.ImportProofRequest) (*taprpc.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,
	req *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 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,
	in *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,
	in *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,
	in *taprpc.ListTransfersRequest) (*taprpc.ListTransfersResponse,
	error)

ListTransfers lists all asset transfers managed by this deamon.

func (Server) ListUtxos

func (r Server) ListUtxos(ctx context.Context,
	_ *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,
	in *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,
	in *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,
	in *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) QueryProof

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

QueryProof attempts to query for an issuance 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, then the issuance proof is returned that includes an inclusion proof to the known Universe root, as well as a Taproot Asset state transition or issuance proof for the said 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) 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,
	in *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) SignVirtualPsbt

func (r Server) SignVirtualPsbt(_ context.Context,
	in *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) SubscribeSendAssetEventNtfns

func (r Server) SubscribeSendAssetEventNtfns(
	in *taprpc.SubscribeSendAssetEventNtfnsRequest,
	ntfnStream taprpc.TaprootAssets_SubscribeSendAssetEventNtfnsServer) 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,
	req *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,
	in *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,
	in *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.
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