Categorygithub.com/lightninglabs/taproot-assets
modulepackage
0.4.1
Repository: https://github.com/lightninglabs/taproot-assets.git
Documentation: pkg.go.dev

# 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.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package taprpc is a reverse proxy.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AddSubLogger is a helper method to conveniently create and register the logger of one or more sub systems.
CheckFederationServer attempts to connect to the target server and ensure that it is a valid federation server that isn't the local daemon.
ConnectUniverse connects to a remote Universe server using the provided server address.
MarshalAssetFedSyncCfg returns an RPC ready asset specific federation sync config.
MarshalUniID marshals the universe ID into the RPC counterpart.
MarshalUniProofType marshals the universe proof type into the RPC counterpart.
NewLndInvoicesClient creates a new LND invoices client for a given LND service.
NewLndMsgTransportClient creates a new message transport RPC client for a given LND service.
NewLndPbstChannelFunder creates a new LndPbstChannelFunder instance.
NewLndRouterClient creates a new LND router client for a given LND service.
NewLndRpcChainBridge creates a new chain bridge from an active lnd services client.
NewLndRpcKeyRing creates a new instance of the LndRpcKeyRing based on the passed ln client.
NewLndRpcVirtualTxSigner returns a new tx signer instance backed by the passed connection to a remote lnd node.
NewLndRpcWalletAnchor returns a new wallet anchor instance using the passed lnd node.
NewProofChainLookup creates a new ProofChainLookup instance.
NewRpcUniverseDiff creates a new RpcUniverseDiff instance that dials out to the target remote universe server address.
NewRpcUniverseRegistrar creates a new RpcUniverseRegistrar instance that dials out to the target remote universe server address.
NewServer creates a new server given the passed config.
ParseUniversePublicAccessStatus parses a string into a universe public access status.
SetAgentName overwrites the default agent name which can be used to identify the software tapd is bundled in (for example LiT).
SetSubLogger is a helper method to conveniently register the logger of a sub system.
SetupLoggers initializes all package-global logger variables.
Tags returns the list of build tags that were compiled into the executable.
UnmarshalUniID parses the RPC universe ID into the native counterpart.
UnmarshalUniProofType parses the RPC universe proof type into the native counterpart.
UserAgent returns the full user agent string that identifies the software that is submitting swaps to the loop server.
Version returns the application version as a properly formed string per the semantic versioning 2.0.0 spec (http://semver.org/).

# Constants

AppMajor defines the major version of this binary.
AppMinor defines the minor version of this binary.
AppPatch defines the application patch for this binary.
AppPreRelease defines the pre-release version of this binary.
AppStatus defines the release status of this binary (e.g.
AssetBurnConfirmationText is the text that needs to be set on the RPC to confirm an asset burn.
CustomChannelRemoteReserve is the custom channel minimum remote reserve that we'll use for our channels.
GitTagIncludeStatus indicates whether the status should be included in the git tag name.
UniversePublicAccessStatusNone indicates that no public access is granted.
UniversePublicAccessStatusRead indicates that read access is granted.
UniversePublicAccessStatusReadWrite indicates that read and write access is granted.
UniversePublicAccessStatusWrite indicates that write access is granted.

# Variables

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.
CommitHash stores the current commit hash of this build.
GoVersion stores the go version that the executable was compiled with.
MaxMsgReceiveSize is the largest message our client will receive.
P2TRChangeType is the type of change address that should be used for funding PSBTs, as we'll always want to use P2TR change addresses.
RawTags contains the raw set of build tags, separated by commas.
ServerMaxMsgReceiveSize is the largest message our server will receive.

# Structs

Config is the main config of the Taproot Assets server.
DatabaseConfig is the config that holds all the persistence related structs and interfaces needed for tapd to function.
LndInvoicesClient is an LND invoices RPC client.
LndMsgTransportClient is an LND RPC message transport client.
LndPbstChannelFunder is an implementation of the tapchannel.ChannelFunder interface that uses lnd to carry out the PSBT funding process.
LndRouterClient is an LND router RPC client.
LndRpcChainBridge is an implementation of the tapgarden.ChainBridge interface backed by an active remote lnd node.
LndRpcKeyRing is an implementation of the keychain.KeyRing interface backed by an active remote lnd node.
LndRpcVirtualTxSigner is an implementation of the tapscript.Signer interface backed by an active lnd node.
LndRpcWalletAnchor is an implementation of the tapgarden.WalletAnchor interfaced backed by an active remote lnd node.
ProofChainLookup is an implementation of the asset.ChainLookup interface that uses a proof file to look up block height information of previous inputs while validating proofs.
RPCConfig is a sub-config of the main server that packages up everything needed to start the RPC server.
RpcUniverseDiff is an implementation of the universe.DiffEngine interface that uses an RPC connection to target Universe.
RpcUniverseRegistrar is an implementation of the universe.Registrar interface that uses an RPC connection to target Universe.
Server is the main daemon construct for the Taproot Asset server.
ValidatorV0 is an implementation of the tapscript.TxValidator interface that supports Taproot Asset script version 0.
WitnessValidatorV0 is an implementation of the tapscript.WitnessValidator interface that supports Taproot Asset script version 0.

# Interfaces

No description provided by the author

# Type aliases

UniversePublicAccessStatus is a type that indicates the status of public access to the universe server.