taprootassets

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 89 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 = 4

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

	// AppStatus defines the release status of this binary (e.g. beta).
	AppStatus = "alpha"

	// AppPreRelease defines the pre-release version of this binary.
	// It MUST only contain characters from the semantic versioning spec.
	AppPreRelease = ""

	// GitTagIncludeStatus indicates whether the status should be included
	// in the git tag name.
	//
	// Including the app version status in the git tag may be problematic
	// for golang projects when importing them as dependencies. We therefore
	// include this flag to allow toggling the status on and off in a
	// standardised way across our projects.
	GitTagIncludeStatus = false
)

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"
)
View Source
const (
	// CustomChannelRemoteReserve is the custom channel minimum remote
	// reserve that we'll use for our channels.
	CustomChannelRemoteReserve = 1062
)

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)

	// P2TRChangeType is the type of change address that should be used for
	// funding PSBTs, as we'll always want to use P2TR change addresses.
	P2TRChangeType = walletrpc.ChangeAddressType_CHANGE_ADDRESS_TYPE_P2TR
)
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 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

	// EnableChannelFeatures indicates that tapd is running inside the
	// Lightning Terminal daemon (litd) and can provide Taproot Asset
	// channel functionality.
	EnableChannelFeatures bool

	ChainParams address.ChainParams

	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

	// UniFedSyncAllAssets is a flag that indicates whether the
	// universe federation syncer should default to syncing all assets.
	UniFedSyncAllAssets bool

	RfqManager *rfq.Manager

	UniverseStats universe.Telemetry

	AuxLeafSigner *tapchannel.AuxLeafSigner

	AuxFundingController *tapchannel.FundingController

	AuxTrafficShaper *tapchannel.AuxTrafficShaper

	AuxInvoiceManager *tapchannel.AuxInvoiceManager

	AuxChanCloser *tapchannel.AuxChanCloser

	AuxSweeper *tapchannel.AuxSweeper

	// UniversePublicAccess is a field that indicates the status of public
	// access (i.e. read/write) to the universe server.
	//
	// NOTE: This field does not influence universe federation syncing
	// behaviour.
	UniversePublicAccess UniversePublicAccessStatus

	// 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 EventStream added in v0.4.0

type EventStream[T any] interface {
	// Send sends an event object to the notification stream.
	Send(T) error
	grpc.ServerStream
}

EventStream is a generic interface type for notification streams.

type LndInvoicesClient added in v0.4.0

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

LndInvoicesClient is an LND invoices RPC client.

func NewLndInvoicesClient added in v0.4.0

func NewLndInvoicesClient(lnd *lndclient.LndServices) *LndInvoicesClient

NewLndInvoicesClient creates a new LND invoices client for a given LND service.

func (*LndInvoicesClient) HtlcModifier added in v0.4.0

HtlcModifier is a bidirectional streaming RPC that allows a client to intercept and modify the HTLCs that attempt to settle the given invoice. The server will send HTLCs of invoices to the client and the client can modify some aspects of the HTLC in order to pass the invoice acceptance tests.

type LndMsgTransportClient added in v0.4.0

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

LndMsgTransportClient is an LND RPC message transport client.

func NewLndMsgTransportClient added in v0.4.0

func NewLndMsgTransportClient(
	lnd *lndclient.LndServices) *LndMsgTransportClient

NewLndMsgTransportClient creates a new message transport RPC client for a given LND service.

func (*LndMsgTransportClient) ReportError added in v0.4.0

func (l *LndMsgTransportClient) ReportError(ctx context.Context,
	peer btcec.PublicKey, pid funding.PendingChanID, err error)

ReportError sends a custom message with the error type to a peer.

NOTE: In order for this custom message to be sent over the lnd RPC interface, lnd needs to be configured with the `--custom-message=17` flag, which allows sending the non-custom error message type.

func (*LndMsgTransportClient) SendCustomMessage added in v0.4.0

func (l *LndMsgTransportClient) SendCustomMessage(ctx context.Context,
	msg lndclient.CustomMessage) error

SendCustomMessage sends a custom message to a peer.

func (*LndMsgTransportClient) SendMessage added in v0.4.0

func (l *LndMsgTransportClient) SendMessage(ctx context.Context,
	peer btcec.PublicKey, msg lnwire.Message) error

SendMessage sends a message to a remote peer.

func (*LndMsgTransportClient) SubscribeCustomMessages added in v0.4.0

func (l *LndMsgTransportClient) SubscribeCustomMessages(
	ctx context.Context) (<-chan lndclient.CustomMessage,
	<-chan error, error)

SubscribeCustomMessages creates a subscription to custom messages received from our peers.

type LndPbstChannelFunder added in v0.4.0

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

LndPbstChannelFunder is an implementation of the tapchannel.ChannelFunder interface that uses lnd to carry out the PSBT funding process.

func NewLndPbstChannelFunder added in v0.4.0

func NewLndPbstChannelFunder(lnd *lndclient.LndServices) *LndPbstChannelFunder

NewLndPbstChannelFunder creates a new LndPbstChannelFunder instance.

func (*LndPbstChannelFunder) OpenChannel added in v0.4.0

OpenChannel attempts to open a new asset holding private channel using the backing lnd node. The PSBT flow is by default. An AssetChanIntent is returned that includes the updated PSBT template that includes the funding output. Once all other inputs+outputs have been added, then BindPsbt should be called to progress the funding process. Afterward, the funding transaction should be signed+broadcast.

NOTE: This is part of the tapchannel.ChannelFunder interface.

type LndRouterClient added in v0.4.0

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

LndRouterClient is an LND router RPC client.

func NewLndRouterClient added in v0.4.0

func NewLndRouterClient(lnd *lndclient.LndServices) *LndRouterClient

NewLndRouterClient creates a new LND router client for a given LND service.

func (*LndRouterClient) AddLocalAlias added in v0.4.0

func (l *LndRouterClient) AddLocalAlias(ctx context.Context, alias,
	baseScid lnwire.ShortChannelID) error

AddLocalAlias adds a database mapping from the passed alias to the passed base SCID.

func (*LndRouterClient) DeleteLocalAlias added in v0.4.0

func (l *LndRouterClient) DeleteLocalAlias(ctx context.Context, alias,
	baseScid lnwire.ShortChannelID) error

DeleteLocalAlias removes a mapping from the database and the Manager's maps.

func (*LndRouterClient) InterceptHtlcs added in v0.4.0

func (l *LndRouterClient) InterceptHtlcs(
	ctx context.Context, handler lndclient.HtlcInterceptHandler) error

InterceptHtlcs intercepts all incoming HTLCs and calls the given handler function with the HTLC details. The handler function can then decide whether to accept or reject the HTLC.

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,
	assetStore *tapdb.AssetStore) *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) GenFileChainLookup added in v0.4.0

func (l *LndRpcChainBridge) GenFileChainLookup(
	f *proof.File) asset.ChainLookup

GenFileChainLookup generates a chain lookup interface for the given proof file that can be used to validate proofs.

func (*LndRpcChainBridge) GenProofChainLookup added in v0.4.0

func (l *LndRpcChainBridge) GenProofChainLookup(
	p *proof.Proof) (asset.ChainLookup, error)

GenProofChainLookup generates a chain lookup interface for the given single proof that can be used to validate proofs.

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) GetBlockTimestamp added in v0.4.0

func (l *LndRpcChainBridge) GetBlockTimestamp(ctx context.Context,
	height uint32) int64

GetBlockTimestamp returns the timestamp of the block at the given height.

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,
	changeIdx int32) (*tapsend.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) ListChannels added in v0.4.0

func (l *LndRpcWalletAnchor) ListChannels(
	ctx context.Context) ([]lndclient.ChannelInfo, error)

ListChannels returns the list of active channels of the backing lnd node.

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,
	op wire.OutPoint) error

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

type ProofChainLookup added in v0.4.0

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

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.

func NewProofChainLookup added in v0.4.0

func NewProofChainLookup(chainBridge tapgarden.ChainBridge,
	assetStore *tapdb.AssetStore, proofFile *proof.File) *ProofChainLookup

NewProofChainLookup creates a new ProofChainLookup instance.

func (*ProofChainLookup) CurrentHeight added in v0.4.0

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

CurrentHeight returns the current height of the main chain.

func (*ProofChainLookup) MeanBlockTimestamp added in v0.4.0

func (l *ProofChainLookup) MeanBlockTimestamp(ctx context.Context,
	blockHeight uint32) (time.Time, error)

MeanBlockTimestamp returns the timestamp of the block at the given height as a Unix timestamp in seconds, taking into account the mean time elapsed over the previous 11 blocks.

func (*ProofChainLookup) TxBlockHeight added in v0.4.0

func (l *ProofChainLookup) TxBlockHeight(ctx context.Context,
	txid chainhash.Hash) (uint32, error)

TxBlockHeight returns the block height that the given transaction was included in.

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(chainParams *address.ChainParams, cfg *Config) *Server

NewServer creates a new server given the passed config.

func (Server) AddAssetBuyOffer added in v0.4.0

func (r Server) AddAssetBuyOffer(_ context.Context,
	req *rfqrpc.AddAssetBuyOfferRequest) (*rfqrpc.AddAssetBuyOfferResponse,
	error)

AddAssetBuyOffer upserts a new buy offer for the given asset into the RFQ manager. If the offer already exists for the given asset, it will be updated.

A buy offer is used by the node to selectively accept or reject incoming asset sell quote requests before price is considered.

func (Server) AddAssetBuyOrder added in v0.4.0

func (r Server) AddAssetBuyOrder(_ context.Context,
	req *rfqrpc.AddAssetBuyOrderRequest) (*rfqrpc.AddAssetBuyOrderResponse,
	error)

AddAssetBuyOrder upserts a new buy order for the given asset into the RFQ manager. If the order already exists for the given asset, it will be updated.

func (Server) AddAssetSellOffer added in v0.4.0

func (r Server) AddAssetSellOffer(_ context.Context,
	req *rfqrpc.AddAssetSellOfferRequest) (*rfqrpc.AddAssetSellOfferResponse,
	error)

AddAssetSellOffer upserts a new sell offer for the given asset into the RFQ manager. If the offer already exists for the given asset, it will be updated.

func (Server) AddAssetSellOrder added in v0.4.0

func (r Server) AddAssetSellOrder(_ context.Context,
	req *rfqrpc.AddAssetSellOrderRequest) (*rfqrpc.AddAssetSellOrderResponse,
	error)

AddAssetSellOrder upserts a new sell order for the given asset into the RFQ manager. If the order already exists for the given asset, it will be updated.

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.

func (*Server) ApplyHtlcView added in v0.4.0

func (s *Server) ApplyHtlcView(chanState *channeldb.OpenChannel,
	prevBlob tlv.Blob, originalView *lnwallet.HtlcView, isOurCommit bool,
	ourBalance, theirBalance lnwire.MilliSatoshi,
	keys lnwallet.CommitmentKeyRing) (lfn.Option[tlv.Blob], error)

ApplyHtlcView serves as the state transition function for the custom channel's blob. Given the old blob, and an HTLC view, then a new blob should be returned that reflects the pending updates.

NOTE: This method is part of the lnwallet.AuxLeafStore interface.

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) AuxCloseOutputs added in v0.4.0

func (s *Server) AuxCloseOutputs(
	desc chancloser.AuxCloseDesc) (lfn.Option[chancloser.AuxCloseOutputs],
	error)

AuxCloseOutputs returns the set of close outputs to use for this co-op close attempt. We'll add some extra outputs to the co-op close transaction, and also give the caller a custom sorting routine.

NOTE: This method is part of the chancloser.AuxChanCloser interface.

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) CanHandle added in v0.4.0

func (s *Server) CanHandle(msg protofsm.PeerMsg) bool

CanHandle returns true if the target message can be routed to this endpoint.

NOTE: This method is part of the protofsm.MsgEndpoint interface.

func (Server) CancelBatch

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

CancelBatch attempts to cancel the current pending batch.

func (*Server) ChannelFinalized added in v0.4.0

func (s *Server) ChannelFinalized(pid funding.PendingChanID) error

ChannelFinalized is called once we receive the commit sig from a remote party and find it to be valid.

NOTE: This method is part of the funding.AuxFundingController interface.

func (*Server) ChannelReady added in v0.4.0

func (s *Server) ChannelReady(openChan *channeldb.OpenChannel) error

ChannelReady is called when a channel has been fully opened and is ready to be used. This can be used to perform any final setup or cleanup.

NOTE: This method is part of the funding.AuxFundingController interface.

func (Server) CommitVirtualPsbts added in v0.4.0

func (r Server) CommitVirtualPsbts(ctx context.Context,
	req *wrpc.CommitVirtualPsbtsRequest) (*wrpc.CommitVirtualPsbtsResponse,
	error)

CommitVirtualPsbts creates the output commitments and proofs for the given virtual transactions by committing them to the BTC level anchor transaction. In addition, the BTC level anchor transaction is funded and prepared up to the point where it is ready to be signed.

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) DecDisplayForAssetID added in v0.4.0

func (r Server) DecDisplayForAssetID(ctx context.Context,
	id asset.ID) (fn.Option[uint32], error)

DecDisplayForAssetID attempts to fetch the meta reveal for a specific asset ID and extract the decimal display value from it.

func (Server) DeclareScriptKey added in v0.4.0

func (r Server) DeclareScriptKey(ctx context.Context,
	in *wrpc.DeclareScriptKeyRequest) (*wrpc.DeclareScriptKeyResponse,
	error)

DeclareScriptKey declares a new script key to the wallet. This is useful when the script key contains scripts, which would mean it wouldn't be recognized by the wallet automatically. Declaring a script key will make any assets sent to the script key be recognized as being local assets.

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) DeriveSweepAddr added in v0.4.0

func (s *Server) DeriveSweepAddr(inputs []input.Input,
	change lnwallet.AddrWithKey) lfn.Result[sweep.SweepOutput]

DeriveSweepAddr takes a set of inputs, and the change address we'd use to sweep them, and maybe results in an extra sweep output that we should add to the sweeping transaction.

func (*Server) DeriveTapscriptRoot added in v0.4.0

func (s *Server) DeriveTapscriptRoot(
	pid funding.PendingChanID) (lfn.Option[chainhash.Hash], error)

DeriveTapscriptRoot takes a pending channel ID and maybe returns a tapscript root that should be used when creating any MuSig2 sessions for a channel.

NOTE: This method is part of the funding.AuxFundingController interface.

func (*Server) DescFromPendingChanID added in v0.4.0

func (s *Server) DescFromPendingChanID(pid funding.PendingChanID,
	chanState *channeldb.OpenChannel, localKeys,
	remoteKeys lnwallet.CommitmentKeyRing,
	initiator bool) (lfn.Option[lnwallet.AuxFundingDesc], error)

DescFromPendingChanID takes a pending channel ID, that may already be known due to prior custom channel messages, and maybe returns an aux funding desc which can be used to modify how a channel is funded.

NOTE: This method is part of the funding.AuxFundingController interface.

func (Server) EncodeCustomRecords added in v0.4.0

func (r Server) EncodeCustomRecords(_ context.Context,
	in *tchrpc.EncodeCustomRecordsRequest) (
	*tchrpc.EncodeCustomRecordsResponse, error)

EncodeCustomRecords allows RPC users to encode Taproot Asset channel related data into the TLV format that is used in the custom records of the lnd payment or other channel related RPCs. This RPC is completely stateless and does not perform any checks on the data provided, other than pure format validation.

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)

func (*Server) FetchLeavesFromCommit added in v0.4.0

FetchLeavesFromCommit attempts to fetch the auxiliary leaves that correspond to the passed aux blob, and an existing channel commitment.

NOTE: This method is part of the lnwallet.AuxLeafStore interface.

func (*Server) FetchLeavesFromRevocation added in v0.4.0

func (s *Server) FetchLeavesFromRevocation(
	rev *channeldb.RevocationLog) (lfn.Option[lnwallet.CommitAuxLeaves],
	error)

FetchLeavesFromRevocation attempts to fetch the auxiliary leaves from a channel revocation that stores balance + blob information.

NOTE: This method is part of the lnwallet.AuxLeafStore interface.

func (*Server) FetchLeavesFromView added in v0.4.0

func (s *Server) FetchLeavesFromView(chanState *channeldb.OpenChannel,
	prevBlob tlv.Blob, view *lnwallet.HtlcView, isOurCommit bool,
	ourBalance, theirBalance lnwire.MilliSatoshi,
	keys lnwallet.CommitmentKeyRing) (lfn.Option[lnwallet.CommitAuxLeaves],
	lnwallet.CommitSortFunc, error)

FetchLeavesFromView attempts to fetch the auxiliary leaves that correspond to the passed aux blob, and pending fully evaluated HTLC view.

NOTE: This method is part of the lnwallet.AuxLeafStore interface.

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) FinalizeClose added in v0.4.0

func (s *Server) FinalizeClose(desc chancloser.AuxCloseDesc,
	closeTx *wire.MsgTx) error

FinalizeClose is called once the co-op close transaction has been agreed upon. We'll finalize the exclusion proofs, then send things off to the custodian or porter to finish sending/receiving the proofs.

NOTE: This method is part of the chancloser.AuxChanCloser interface.

func (Server) FundBatch added in v0.4.0

func (r Server) FundBatch(_ context.Context,
	req *mintrpc.FundBatchRequest) (*mintrpc.FundBatchResponse, error)

FundBatch attempts to fund the current pending batch.

func (Server) FundChannel added in v0.4.0

func (r Server) FundChannel(ctx context.Context,
	req *tchrpc.FundChannelRequest) (*tchrpc.FundChannelResponse,
	error)

FundChannel initiates the channel funding negotiation with a peer for the creation of a channel that contains a specified amount of a given asset.

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) HandleTraffic added in v0.4.0

func (s *Server) HandleTraffic(cid lnwire.ShortChannelID,
	fundingBlob lfn.Option[tlv.Blob]) (bool, error)

HandleTraffic is called in order to check if the channel identified by the provided channel ID is handled by the traffic shaper implementation. If it is handled by the traffic shaper, then the normal bandwidth calculation can be skipped and the bandwidth returned by PaymentBandwidth should be used instead.

NOTE: This method is part of the routing.TlvTrafficShaper interface.

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) InlineParseCustomData added in v0.4.0

func (s *Server) InlineParseCustomData(msg proto.Message) error

InlineParseCustomData replaces any custom data binary blob in the given RPC message with its corresponding JSON formatted data. This transforms the binary (likely TLV encoded) data to a human-readable JSON representation (still as byte slice).

NOTE: This method is part of the lnd.AuxDataParser interface.

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

ListTransfers returns a list of all asset transfers managed by this daemon. This includes both confirmed and unconfirmed transfers.

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) MarshalChainAsset added in v0.4.0

func (r Server) MarshalChainAsset(ctx context.Context, a *asset.ChainAsset,
	meta *proof.MetaReveal, withWitness bool,
	keyRing taprpc.KeyLookup) (*taprpc.Asset, error)

MarshalChainAsset marshals the given chain asset into an RPC asset.

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) MultiverseRoot added in v0.4.0

func (r Server) MultiverseRoot(ctx context.Context,
	req *unirpc.MultiverseRootRequest) (*unirpc.MultiverseRootResponse,
	error)

MultiverseRoot returns the root of the multiverse tree. This is useful to determine the equality of two multiverse trees, since the root can directly be compared to another multiverse root to find out if a sync is required.

func (*Server) Name added in v0.4.0

func (s *Server) Name() protofsm.EndpointName

Name returns the name of this endpoint. This MUST be unique across all registered endpoints.

NOTE: This method is part of the protofsm.MsgEndpoint interface.

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) NotifyBroadcast added in v0.4.0

func (s *Server) NotifyBroadcast(req *sweep.BumpRequest,
	tx *wire.MsgTx, fee btcutil.Amount) error

NotifyBroadcast is used to notify external callers of the broadcast of a sweep transaction, generated by the passed BumpRequest.

func (*Server) PackSigs added in v0.4.0

func (s *Server) PackSigs(
	blob []lfn.Option[tlv.Blob]) (lfn.Option[tlv.Blob], error)

PackSigs takes a series of aux signatures and packs them into a single blob that can be sent alongside the CommitSig messages.

NOTE: This method is part of the lnwallet.AuxSigner interface.

func (*Server) PaymentBandwidth added in v0.4.0

func (s *Server) PaymentBandwidth(htlcBlob, commitmentBlob lfn.Option[tlv.Blob],
	linkBandwidth lnwire.MilliSatoshi) (lnwire.MilliSatoshi, error)

PaymentBandwidth returns the available bandwidth for a custom channel decided by the given channel aux blob and HTLC blob. A return value of 0 means there is no bandwidth available. To find out if a channel is a custom channel that should be handled by the traffic shaper, the HandleTraffic method should be called first.

NOTE: This method is part of the routing.TlvTrafficShaper interface.

func (*Server) ProduceHtlcExtraData added in v0.4.0

func (s *Server) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi,
	htlcCustomRecords lnwire.CustomRecords) (lnwire.MilliSatoshi, tlv.Blob,
	error)

ProduceHtlcExtraData is a function that, based on the previous custom record blob of an HTLC, may produce a different blob or modify the amount of bitcoin this HTLC should carry.

NOTE: This method is part of the routing.TlvTrafficShaper interface.

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) PublishAndLogTransfer added in v0.4.0

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

PublishAndLogTransfer accepts a fully committed and signed anchor transaction and publishes it to the Bitcoin network. It also logs the transfer of the given active and passive assets in the database and ships any outgoing proofs to the counterparties.

func (Server) PushProof added in v0.4.0

func (r Server) PushProof(ctx context.Context,
	req *unirpc.PushProofRequest) (*unirpc.PushProofResponse, error)

PushProof attempts to query the local universe for a proof specified by a UniverseKey. If found, a connection is made to a remote Universe server to attempt to upload the asset leaf.

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) QueryInternalKey added in v0.4.0

func (r Server) QueryInternalKey(ctx context.Context,
	req *wrpc.QueryInternalKeyRequest) (*wrpc.QueryInternalKeyResponse,
	error)

QueryInternalKey returns the key descriptor for the given internal key.

func (Server) QueryPeerAcceptedQuotes added in v0.4.0

QueryPeerAcceptedQuotes is used to query for quotes that were requested by our node and have been accepted our peers.

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) QueryScriptKey added in v0.4.0

func (r Server) QueryScriptKey(ctx context.Context,
	req *wrpc.QueryScriptKeyRequest) (*wrpc.QueryScriptKeyResponse, error)

QueryScriptKey returns the full script key descriptor for the given tweaked script key.

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) ResolveContract added in v0.4.0

func (s *Server) ResolveContract(
	req lnwallet.ResolutionReq) lfn.Result[tlv.Blob]

ResolveContract attempts to obtain a resolution blob for the specified contract.

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) SealBatch added in v0.4.0

func (r Server) SealBatch(ctx context.Context,
	req *mintrpc.SealBatchRequest) (*mintrpc.SealBatchResponse, error)

SealBatch attempts to seal the current pending batch, validating provided asset group witnesses and generating asset group witnesses as needed.

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) SendMessage added in v0.4.0

func (s *Server) SendMessage(msg protofsm.PeerMsg) bool

SendMessage handles the target message, and returns true if the message was able to be processed.

NOTE: This method is part of the protofsm.MsgEndpoint interface.

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) ShutdownBlob added in v0.4.0

func (s *Server) ShutdownBlob(
	req chancloser.AuxShutdownReq) (lfn.Option[lnwire.CustomRecords],
	error)

ShutdownBlob returns the set of custom records that should be included in the shutdown message.

NOTE: This method is part of the chancloser.AuxChanCloser interface.

func (Server) SignVirtualPsbt

func (r Server) SignVirtualPsbt(ctx 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) SubmitSecondLevelSigBatch added in v0.4.0

func (s *Server) SubmitSecondLevelSigBatch(chanState *channeldb.OpenChannel,
	commitTx *wire.MsgTx, sigJob []lnwallet.AuxSigJob) error

SubmitSecondLevelSigBatch takes a batch of aux sign jobs and processes them asynchronously.

NOTE: This method is part of the lnwallet.AuxSigner interface.

func (Server) SubscribeMintEvents added in v0.4.0

func (r Server) SubscribeMintEvents(req *mintrpc.SubscribeMintEventsRequest,
	ntfnStream mintEventStream) error

SubscribeMintEvents allows a caller to subscribe to mint events for asset creation batches.

func (Server) SubscribeReceiveAssetEventNtfns added in v0.3.1

func (r Server) SubscribeReceiveAssetEventNtfns(
	_ *tapdevrpc.SubscribeReceiveAssetEventNtfnsRequest,
	ntfnStream devReceiveEventStream) error

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

func (Server) SubscribeReceiveEvents added in v0.4.0

func (r Server) SubscribeReceiveEvents(
	req *taprpc.SubscribeReceiveEventsRequest,
	ntfnStream receiveEventStream) error

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

func (Server) SubscribeRfqEventNtfns added in v0.4.0

func (r Server) SubscribeRfqEventNtfns(
	_ *rfqrpc.SubscribeRfqEventNtfnsRequest,
	ntfnStream rfqrpc.Rfq_SubscribeRfqEventNtfnsServer) error

SubscribeRfqEventNtfns subscribes to RFQ event notifications.

func (Server) SubscribeSendAssetEventNtfns

func (r Server) SubscribeSendAssetEventNtfns(
	_ *tapdevrpc.SubscribeSendAssetEventNtfnsRequest,
	ntfnStream devSendEventStream) error

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

func (Server) SubscribeSendEvents added in v0.4.0

func (r Server) SubscribeSendEvents(req *taprpc.SubscribeSendEventsRequest,
	ntfnStream sendEventStream) error

SubscribeSendEvents 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) UnpackSigs added in v0.4.0

func (s *Server) UnpackSigs(blob lfn.Option[tlv.Blob]) ([]lfn.Option[tlv.Blob],
	error)

UnpackSigs takes a packed blob of signatures and returns the original signatures for each HTLC, keyed by HTLC index.

NOTE: This method is part of the lnwallet.AuxSigner interface.

func (*Server) UpdateConfig added in v0.4.0

func (s *Server) UpdateConfig(cfg *Config)

UpdateConfig updates the server's configuration. This MUST be called before the server is started.

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.

func (*Server) VerifySecondLevelSigs added in v0.4.0

func (s *Server) VerifySecondLevelSigs(chanState *channeldb.OpenChannel,
	commitTx *wire.MsgTx, verifyJob []lnwallet.AuxVerifyJob) error

VerifySecondLevelSigs attempts to synchronously verify a batch of aux sig jobs.

NOTE: This method is part of the lnwallet.AuxSigner interface.

type UniversePublicAccessStatus added in v0.4.0

type UniversePublicAccessStatus string

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

const (
	// UniversePublicAccessStatusNone indicates that no public access is
	// granted.
	UniversePublicAccessStatusNone UniversePublicAccessStatus = ""

	// UniversePublicAccessStatusRead indicates that read access is granted.
	UniversePublicAccessStatusRead UniversePublicAccessStatus = "r"

	// UniversePublicAccessStatusWrite indicates that write access is
	// granted.
	UniversePublicAccessStatusWrite UniversePublicAccessStatus = "w"

	// UniversePublicAccessStatusReadWrite indicates that read and write
	// access is granted.
	UniversePublicAccessStatusReadWrite UniversePublicAccessStatus = "rw"
)

func ParseUniversePublicAccessStatus added in v0.4.0

func ParseUniversePublicAccessStatus(
	s string) (UniversePublicAccessStatus, error)

ParseUniversePublicAccessStatus parses a string into a universe public access status.

func (UniversePublicAccessStatus) IsReadAccessGranted added in v0.4.0

func (s UniversePublicAccessStatus) IsReadAccessGranted() bool

IsReadAccessGranted returns true if the status indicates that read access is granted.

func (UniversePublicAccessStatus) IsWriteAccessGranted added in v0.4.0

func (s UniversePublicAccessStatus) IsWriteAccessGranted() bool

IsWriteAccessGranted returns true if the status indicates that write access is granted.

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,
	chainLookup asset.ChainLookup) error

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

type WitnessValidatorV0 added in v0.4.0

type WitnessValidatorV0 struct{}

WitnessValidatorV0 is an implementation of the tapscript.WitnessValidator interface that supports Taproot Asset script version 0.

func (*WitnessValidatorV0) ValidateWitnesses added in v0.4.0

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

ValidateWitnesses validates the created witnesses of an asset transfer.

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.
priceoraclerpc
Package priceoraclerpc is a reverse proxy.
Package priceoraclerpc is a reverse proxy.
rfqrpc
Package rfqrpc is a reverse proxy.
Package rfqrpc is a reverse proxy.
tapchannelrpc
Package tapchannelrpc is a reverse proxy.
Package tapchannelrpc 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