Documentation ¶
Index ¶
- Constants
- Variables
- func AddrMatchesAsset(addr *address.AddrWithKeyInfo, a *asset.Asset) bool
- func DisableLog()
- func EventMatchesProof(event *address.Event, p *proof.Proof) bool
- func FundGenesisTx(packet *psbt.Packet, feeRate chainfee.SatPerKWeight)
- func GenGroupAnchorVerifier(ctx context.Context, mintingStore MintingStore) func(*asset.Genesis, *asset.GroupKey) error
- func GenGroupVerifier(ctx context.Context, mintingStore MintingStore) func(*btcec.PublicKey) error
- func GenHeaderVerifier(ctx context.Context, chainBridge ChainBridge) func(wire.BlockHeader, uint32) error
- func GenMockGroupVerifier() func(*btcec.PublicKey) error
- func GenRawGroupAnchorVerifier(ctx context.Context) func(*asset.Genesis, *asset.GroupKey) error
- func NewGenesisTx(t testing.TB, feeRate chainfee.SatPerKWeight) psbt.Packet
- func RandSeedlings(t testing.TB, numSeedlings int) map[string]*Seedling
- func SortAssets(fullAssets []*asset.Asset, anchorVerifier proof.GroupAnchorVerifier) ([]*asset.Asset, []*asset.Asset, error)
- func SortSeedlings(seedlings []*Seedling) []string
- func UseLogger(logger btclog.Logger)
- func VerifyOutputScript(batchKey *btcec.PublicKey, tapSibling *chainhash.Hash, genesisScript []byte, ...) (*commitment.TapCommitment, error)
- type AssetMetas
- type AssetMintEvent
- type AssetReceiveEvent
- type BatchCaretaker
- type BatchCaretakerConfig
- type BatchKey
- type BatchState
- type CancelResp
- type ChainBridge
- type ChainPlanter
- func (c *ChainPlanter) CancelBatch() (*btcec.PublicKey, error)
- func (c *ChainPlanter) CancelSeedling() error
- func (c *ChainPlanter) FinalizeBatch(params FinalizeParams) (*MintingBatch, error)
- func (c *ChainPlanter) FundBatch(params FundParams) (*MintingBatch, error)
- func (c *ChainPlanter) ListBatches(params ListBatchesParams) ([]*VerboseBatch, error)
- func (c *ChainPlanter) NumActiveBatches() (int, error)
- func (c *ChainPlanter) PendingBatch() (*MintingBatch, error)
- func (c *ChainPlanter) QueueNewSeedling(req *Seedling) (SeedlingUpdates, error)
- func (c *ChainPlanter) RegisterSubscriber(receiver *fn.EventReceiver[fn.Event], _, _ bool) error
- func (c *ChainPlanter) RemoveSubscriber(subscriber *fn.EventReceiver[fn.Event]) error
- func (c *ChainPlanter) SealBatch(params SealParams) (*MintingBatch, error)
- func (c *ChainPlanter) Start() error
- func (c *ChainPlanter) Stop() error
- type Custodian
- type CustodianConfig
- type FallibleTapscriptTreeMgr
- func (mgr FallibleTapscriptTreeMgr) DeleteTapscriptTree(ctx context.Context, rootHash chainhash.Hash) error
- func (mgr FallibleTapscriptTreeMgr) LoadTapscriptTree(ctx context.Context, rootHash chainhash.Hash) (*asset.TapscriptTreeNodes, error)
- func (mgr FallibleTapscriptTreeMgr) StoreTapscriptTree(ctx context.Context, treeNodes asset.TapscriptTreeNodes) (*chainhash.Hash, error)
- type FinalizeParams
- type FundParams
- type GardenKit
- type KeyRing
- type ListBatchesParams
- type MintingBatch
- func (m *MintingBatch) Copy() *MintingBatch
- func (m *MintingBatch) HasSeedlings() bool
- func (m *MintingBatch) IsFunded() bool
- func (m *MintingBatch) MintingOutputKey(sibling *commitment.TapscriptPreimage) (*btcec.PublicKey, []byte, error)
- func (m *MintingBatch) State() BatchState
- func (m *MintingBatch) TapSibling() []byte
- func (m *MintingBatch) UpdateState(state BatchState)
- func (m *MintingBatch) UpdateTapSibling(sibling *chainhash.Hash)
- type MintingState
- type MintingStore
- type MockAssetSyncer
- func (m *MockAssetSyncer) AddAsset(newAsset asset.Asset)
- func (m *MockAssetSyncer) EnableAssetSync(_ context.Context, groupInfo *asset.AssetGroup) error
- func (m *MockAssetSyncer) FetchAsset(id asset.ID) (*asset.AssetGroup, error)
- func (m *MockAssetSyncer) RemoveAsset(id asset.ID)
- func (m *MockAssetSyncer) SyncAssetInfo(_ context.Context, id *asset.ID) error
- type MockChainBridge
- func (m *MockChainBridge) CurrentHeight(_ context.Context) (uint32, error)
- func (m *MockChainBridge) EmptyConf(enable bool)
- func (m *MockChainBridge) EstimateFee(ctx context.Context, _ uint32) (chainfee.SatPerKWeight, error)
- func (m *MockChainBridge) FailConf(enable bool)
- func (m *MockChainBridge) FailFeeEstimatesOnce()
- func (m *MockChainBridge) GenFileChainLookup(*proof.File) asset.ChainLookup
- func (m *MockChainBridge) GenProofChainLookup(*proof.Proof) (asset.ChainLookup, error)
- func (m *MockChainBridge) GetBlock(ctx context.Context, hash chainhash.Hash) (*wire.MsgBlock, error)
- func (m *MockChainBridge) GetBlockHash(ctx context.Context, blockHeight int64) (chainhash.Hash, error)
- func (m *MockChainBridge) GetBlockTimestamp(_ context.Context, _ uint32) int64
- func (m *MockChainBridge) MeanBlockTimestamp(context.Context, uint32) (time.Time, error)
- func (m *MockChainBridge) PublishTransaction(_ context.Context, tx *wire.MsgTx) error
- func (m *MockChainBridge) RegisterBlockEpochNtfn(ctx context.Context) (chan int32, chan error, error)
- func (m *MockChainBridge) RegisterConfirmationsNtfn(ctx context.Context, _ *chainhash.Hash, _ []byte, _, _ uint32, _ bool, ...) (*chainntnfs.ConfirmationEvent, chan error, error)
- func (m *MockChainBridge) SendConfNtfn(reqNo int, blockHash *chainhash.Hash, blockHeight, blockIndex int, ...)
- func (m *MockChainBridge) TxBlockHeight(context.Context, chainhash.Hash) (uint32, error)
- func (m *MockChainBridge) VerifyBlock(_ context.Context, _ wire.BlockHeader, _ uint32) error
- type MockGenSigner
- type MockKeyRing
- func (m *MockKeyRing) DeriveKey(ctx context.Context, _ keychain.KeyLocator) (keychain.KeyDescriptor, error)
- func (m *MockKeyRing) DeriveNextKey(ctx context.Context, keyFam keychain.KeyFamily) (keychain.KeyDescriptor, error)
- func (m *MockKeyRing) DeriveNextTaprootAssetKey(ctx context.Context) (keychain.KeyDescriptor, error)
- func (m *MockKeyRing) IsLocalKey(context.Context, keychain.KeyDescriptor) bool
- type MockProofArchive
- func (m *MockProofArchive) FetchProof(ctx context.Context, id proof.Locator) (proof.Blob, error)
- func (m *MockProofArchive) FetchProofs(ctx context.Context, id asset.ID) ([]*proof.AnnotatedProof, error)
- func (m *MockProofArchive) HasProof(ctx context.Context, id proof.Locator) (bool, error)
- func (m *MockProofArchive) ImportProofs(context.Context, proof.HeaderVerifier, proof.MerkleVerifier, ...) error
- type MockProofWatcher
- type MockWalletAnchor
- func (m *MockWalletAnchor) FundPsbt(_ context.Context, packet *psbt.Packet, _ uint32, _ chainfee.SatPerKWeight, ...) (*tapsend.FundedPsbt, error)
- func (m *MockWalletAnchor) ImportTaprootOutput(ctx context.Context, pub *btcec.PublicKey) (btcutil.Address, error)
- func (m *MockWalletAnchor) ImportTapscript(_ context.Context, tapscript *waddrmgr.Tapscript) (btcutil.Address, error)
- func (m *MockWalletAnchor) ListTransactions(ctx context.Context, _, _ int32, _ string) ([]lndclient.Transaction, error)
- func (m *MockWalletAnchor) ListUnspentImportScripts(ctx context.Context) ([]*lnwallet.Utxo, error)
- func (m *MockWalletAnchor) SignAndFinalizePsbt(ctx context.Context, pkt *psbt.Packet) (*psbt.Packet, error)
- func (m *MockWalletAnchor) SubscribeTransactions(ctx context.Context) (<-chan lndclient.Transaction, <-chan error, error)
- func (m *MockWalletAnchor) UnlockInput(context.Context, wire.OutPoint) error
- type PendingAssetGroup
- type Planter
- type PlanterConfig
- type ReOrgWatcher
- func (w *ReOrgWatcher) DefaultUpdateCallback() proof.UpdateCallback
- func (w *ReOrgWatcher) MaybeWatch(file *proof.File, onProofUpdate proof.UpdateCallback) error
- func (w *ReOrgWatcher) ShouldWatch(p *proof.Proof) bool
- func (w *ReOrgWatcher) Start() error
- func (w *ReOrgWatcher) Stop() error
- func (w *ReOrgWatcher) WatchProofs(newProofs []*proof.Proof, onProofUpdate proof.UpdateCallback) error
- type ReOrgWatcherConfig
- type SealParams
- type Seedling
- type SeedlingUpdate
- type SeedlingUpdates
- type UnsealedSeedling
- type VerboseBatch
- type WalletAnchor
Constants ¶
const ( // GenesisAmtSats is the amount of sats we'll use to anchor created // assets within. This value just needs to be greater than dust, as for // now, we assume that the tapd client manages asset bearing UTXOs // distinctly from normal UTXOs. GenesisAmtSats = btcutil.Amount(1_000) // GenesisConfTarget is the confirmation target we'll use to query for // a fee estimate. GenesisConfTarget = 6 // DefaultTimeout is the default timeout we use for RPC and database // operations. DefaultTimeout = 30 * time.Second )
const Subsystem = "GRDN" // GRDN as in Garden.
Subsystem defines the logging code for this subsystem.
Variables ¶
var ( // ErrGroupKeyUnknown is an error returned if an asset has a group key // attached that has not been previously verified. ErrGroupKeyUnknown = errors.New("group key not known") // ErrGenesisNotGroupAnchor is an error returned if an asset has a group // key attached, and the asset is not the anchor asset for the group. // This is true for any asset created via reissuance. ErrGenesisNotGroupAnchor = errors.New("genesis not group anchor") )
var ( // ErrNoGenesis is returned when fetching an asset genesis fails. ErrNoGenesis = errors.New("unable to fetch genesis asset") // ErrBatchAlreadySealed is returned when a minting batch is already // sealed. ErrBatchAlreadySealed = errors.New("batch is already sealed") )
var ( // ErrInvalidAssetType is returned if an invalid asset type is passed // in. // // TODO(roasbeef): make proper error type struct? ErrInvalidAssetType = fmt.Errorf("invalid asset type") // ErrInvalidAssetAmt is returned in an asset request has an invalid // amount. ErrInvalidAssetAmt = fmt.Errorf("asset amt cannot be zero") )
Functions ¶
func AddrMatchesAsset ¶
func AddrMatchesAsset(addr *address.AddrWithKeyInfo, a *asset.Asset) bool
AddrMatchesAsset returns true if the given asset state (ID, group key, script key) matches the state represented in the address.
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
func EventMatchesProof ¶ added in v0.3.3
EventMatchesProof returns true if the given event matches the given proof.
func FundGenesisTx ¶ added in v0.4.0
func FundGenesisTx(packet *psbt.Packet, feeRate chainfee.SatPerKWeight)
FundGenesisTx add a genesis input and change output to a 1-output TX.
func GenGroupAnchorVerifier ¶ added in v0.3.0
func GenGroupAnchorVerifier(ctx context.Context, mintingStore MintingStore) func(*asset.Genesis, *asset.GroupKey) error
GenGroupAnchorVerifier generates a caching group anchor verification callback function given a DB handle.
func GenGroupVerifier ¶ added in v0.3.0
func GenGroupVerifier(ctx context.Context, mintingStore MintingStore) func(*btcec.PublicKey) error
GenGroupVerifier generates a group key verification callback function given a DB handle.
func GenHeaderVerifier ¶
func GenHeaderVerifier(ctx context.Context, chainBridge ChainBridge) func(wire.BlockHeader, uint32) error
GenHeaderVerifier generates a block header on-chain verification callback function given a chain bridge.
func GenMockGroupVerifier ¶ added in v0.3.0
func GenMockGroupVerifier() func(*btcec.PublicKey) error
func GenRawGroupAnchorVerifier ¶ added in v0.3.0
GenRawGroupAnchorVerifier generates a group anchor verification callback function. This anchor verifier recomputes the tweaked group key with the passed genesis and compares that key to the given group key. This verifier is only used in the caretaker, before any asset groups are stored in the DB.
func NewGenesisTx ¶ added in v0.4.0
NewGenesisTx creates a funded genesis PSBT with the given fee rate.
func RandSeedlings ¶
RandSeedlings creates a new set of random seedlings for testing.
func SortAssets ¶ added in v0.3.0
func SortAssets(fullAssets []*asset.Asset, anchorVerifier proof.GroupAnchorVerifier) ([]*asset.Asset, []*asset.Asset, error)
SortAssets sorts the batch assets such that assets that are group anchors are partitioned from all other assets.
func SortSeedlings ¶
SortSeedlings sorts the seedling names such that all seedlings that will be a group anchor are first.
func UseLogger ¶
UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.
func VerifyOutputScript ¶ added in v0.4.0
func VerifyOutputScript(batchKey *btcec.PublicKey, tapSibling *chainhash.Hash, genesisScript []byte, assets []*asset.Asset) (*commitment.TapCommitment, error)
VerifyOutputScript recomputes a batch genesis output script from a batch key, tapscript sibling, and set of assets. It checks multiple tap commitment versions to account for legacy batches.
Types ¶
type AssetMetas ¶
type AssetMetas map[asset.SerializedKey]*proof.MetaReveal
AssetMetas maps the serialized script key of an asset to the meta reveal for that asset, if it has one.
type AssetMintEvent ¶ added in v0.4.0
type AssetMintEvent struct { // BatchState is the last state that was executed before the event is // received. This field takes precedence over Batch.State() as that // might not always be updated when the event is created. In case Error // below is set, the BatchState is the state that was executed that lead // to the error. BatchState BatchState // Error is an optional error, indicating that something went wrong // during the execution of the BatchState above. Error error // Batch is the batch that is being minted. Batch *MintingBatch // contains filtered or unexported fields }
AssetMintEvent is an event which is sent to the BatchCaretaker's event subscribers after a state was executed successfully.
func (*AssetMintEvent) Timestamp ¶ added in v0.4.0
func (e *AssetMintEvent) Timestamp() time.Time
Timestamp returns the timestamp of the event.
type AssetReceiveEvent ¶ added in v0.4.0
type AssetReceiveEvent struct { // Address is the address associated with the asset that was received. Address address.Tap // OutPoint is the outpoint of the transaction that was used to receive // the asset. OutPoint wire.OutPoint // Status is the status of the asset receive event. If Error below is // set, this is the status that lead to the error. Status address.Status // ConfirmationHeight is the height of the block the asset receive // transaction was mined in. This is only set if the status is // StatusConfirmed or later. ConfirmationHeight uint32 // Error is an optional error, indicating that something went wrong // during the execution of the Status above. Error error // contains filtered or unexported fields }
AssetReceiveEvent is an event that is sent to a subscriber once the asset receive process has finished for a given address and outpoint.
func NewAssetReceiveErrorEvent ¶ added in v0.4.0
func NewAssetReceiveErrorEvent(err error, addr address.Tap, outpoint wire.OutPoint, confHeight uint32, status address.Status) *AssetReceiveEvent
NewAssetReceiveErrorEvent creates a new AssetReceiveEvent with an error.
func NewAssetReceiveEvent ¶ added in v0.4.0
func NewAssetReceiveEvent(addr address.Tap, outpoint wire.OutPoint, confHeight uint32, status address.Status) *AssetReceiveEvent
NewAssetReceiveEvent creates a new AssetReceiveEvent.
func (*AssetReceiveEvent) Timestamp ¶ added in v0.4.0
func (e *AssetReceiveEvent) Timestamp() time.Time
Timestamp returns the timestamp of the event.
type BatchCaretaker ¶
type BatchCaretaker struct { // ContextGuard provides a wait group and main quit channel that can be // used to create guarded contexts. *fn.ContextGuard // contains filtered or unexported fields }
BatchCaretaker is the caretaker for a MintingBatch. It'll handle validating the batch, creating a transaction that mints all items in the batch, and waiting for enough confirmations for the batch to be considered finalized.
func NewBatchCaretaker ¶
func NewBatchCaretaker(cfg *BatchCaretakerConfig) *BatchCaretaker
NewBatchCaretaker creates a new Taproot Asset caretaker based on the passed config.
TODO(roasbeef): rename to Cultivator?
func (*BatchCaretaker) Cancel ¶
func (b *BatchCaretaker) Cancel() error
Cancel signals for a batch caretaker to stop advancing a batch. A batch can only be cancelled if it has not reached BatchStateBroadcast yet. If cancellation succeeds, we forward the batch state after cancellation. If the batch could not be cancelled, the planter will handle caretaker shutdown and batch state.
func (*BatchCaretaker) Start ¶
func (b *BatchCaretaker) Start() error
Start attempts to start a new batch caretaker.
func (*BatchCaretaker) Stop ¶
func (b *BatchCaretaker) Stop() error
Stop signals for a batch caretaker to gracefully exit.
type BatchCaretakerConfig ¶
type BatchCaretakerConfig struct { // Batch is the minting batch that this caretaker is responsible for? Batch *MintingBatch // BatchFeeRate is an optional manually-set feerate specified when // finalizing a batch. BatchFeeRate *chainfee.SatPerKWeight GardenKit // BroadcastCompleteChan is used to signal back to the caller that the // batch has been broadcast and is now waiting for confirmation. Either // this channel _or_ BroadcastErrChan is sent on, never both. BroadcastCompleteChan chan struct{} // BroadcastErrChan is used to signal back to the caller that while // attempting to proceed the batch to the state of broadcasting the // batch transaction, an error occurred. Either this channel _or_ // BroadcastCompleteChan is sent on, never both. BroadcastErrChan chan error // SignalCompletion is used to signal back to the BatchPlanter that // their batch has been finalized. SignalCompletion func() // CancelChan is used by the BatchPlanter to signal that the caretaker // should stop advancing the batch. CancelReqChan chan struct{} // CancelRespChan is used by the BatchCaretaker to report the result of // attempted batch cancellation to the planter. CancelRespChan chan CancelResp // UpdateMintingProofs is used to update the minting proofs in the // database in case of a re-org. This cannot be done by the caretaker // itself, because its job is already done at the point that a re-org // can happen (the batch is finalized after a single confirmation). UpdateMintingProofs func([]*proof.Proof) error // PublishMintEvent is used to publish a mint event to all subscribers. PublishMintEvent func(event fn.Event) // ErrChan is the main error channel the caretaker will report back // critical errors to the main server. ErrChan chan<- error }
BatchCaretakerConfig houses all the items that the BatchCaretaker needs to carry out its duties.
type BatchKey ¶
type BatchKey = asset.SerializedKey
BatchKey is a type alias for a serialized public key.
type BatchState ¶
type BatchState uint8
BatchState an enum that represents the various stages of a minting batch.
const ( // BatchStatePending denotes that the batch is pending and may have // some assets allocated to it. BatchStatePending BatchState = 0 // BatchStateFrozen denotes that a batch is frozen, and no new // seedlings can be added to it. BatchStateFrozen BatchState = 1 // BatchStateCommitted denotes that a batch now has an unsigned genesis // PSBT packet and the set of seedlings have been made into sprouts // with all relevant fields populated. BatchStateCommitted BatchState = 2 // BatchStateBroadcast denotes a batch now has a fully signed genesis // transaction and can be broadcast to the network. BatchStateBroadcast BatchState = 3 // BatchStateConfirmed denotes that a batch has confirmed on chain, and // only needs a sufficient amount of confirmations before it can be // finalized. BatchStateConfirmed BatchState = 4 // BatchStateFinalized is the final state for a batch. In this terminal // state the batch has been confirmed on chain, with all assets // created. BatchStateFinalized BatchState = 5 // BatchStateSeedlingCancelled denotes that a batch has been cancelled, // and will not be passed to a caretaker. BatchStateSeedlingCancelled BatchState = 6 // BatchStateSproutCancelled denotes that a batch has been cancelled // after being passed to a caretaker and sprouting. BatchStateSproutCancelled BatchState = 7 )
func NewBatchState ¶ added in v0.2.1
func NewBatchState(state uint8) (BatchState, error)
NewBatchState creates a BatchState from a uint8, returning an error if the input value does not map to a valid BatchState.
func (BatchState) String ¶
func (b BatchState) String() string
String returns a human-readable string for the target batch state.
type CancelResp ¶
type CancelResp struct {
// contains filtered or unexported fields
}
CancelResp is the response from a caretaker attempting to cancel a batch.
type ChainBridge ¶
type ChainBridge interface { proof.ChainLookupGenerator // RegisterConfirmationsNtfn registers an intent to be notified once // txid reaches numConfs confirmations. RegisterConfirmationsNtfn(ctx context.Context, txid *chainhash.Hash, pkScript []byte, numConfs, heightHint uint32, includeBlock bool, reOrgChan chan struct{}) (*chainntnfs.ConfirmationEvent, chan error, error) // RegisterBlockEpochNtfn registers an intent to be notified of each // new block connected to the main chain. RegisterBlockEpochNtfn(ctx context.Context) (chan int32, chan error, error) // GetBlock returns a chain block given its hash. GetBlock(context.Context, chainhash.Hash) (*wire.MsgBlock, error) // GetBlockHash returns the hash of the block in the best blockchain at // the given height. GetBlockHash(context.Context, int64) (chainhash.Hash, 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. VerifyBlock(ctx context.Context, header wire.BlockHeader, height uint32) error // CurrentHeight return the current height of the main chain. CurrentHeight(context.Context) (uint32, error) // GetBlockTimestamp returns the timestamp of the block at the given // height. GetBlockTimestamp(context.Context, uint32) int64 // PublishTransaction attempts to publish a new transaction to the // network. PublishTransaction(context.Context, *wire.MsgTx) error // EstimateFee returns a fee estimate for the confirmation target. EstimateFee(ctx context.Context, confTarget uint32) (chainfee.SatPerKWeight, error) }
ChainBridge is our bridge to the target chain. It's used to get confirmation notifications, the current height, publish transactions, and also estimate fees.
type ChainPlanter ¶
type ChainPlanter struct { // ContextGuard provides a wait group and main quit channel that can be // used to create guarded contexts. *fn.ContextGuard // contains filtered or unexported fields }
ChainPlanter is responsible for accepting new incoming requests to create taproot assets. The planter will periodically batch those requests into a new minting batch, which is handed off to a caretaker. While batches are progressing through maturity the planter will be responsible for sending notifications back to the relevant caller.
func NewChainPlanter ¶
func NewChainPlanter(cfg PlanterConfig) *ChainPlanter
NewChainPlanter creates a new ChainPlanter instance given the passed config.
func (*ChainPlanter) CancelBatch ¶
func (c *ChainPlanter) CancelBatch() (*btcec.PublicKey, error)
CancelBatch sends a signal to the planter to cancel the current batch.
func (*ChainPlanter) CancelSeedling ¶
func (c *ChainPlanter) CancelSeedling() error
CancelSeedling attempts to cancel the creation of a new asset identified by its name. If the seedling has already progressed to a point where the genesis PSBT has been broadcasted, an error is returned.
NOTE: This is part of the Planter interface.
func (*ChainPlanter) FinalizeBatch ¶
func (c *ChainPlanter) FinalizeBatch(params FinalizeParams) (*MintingBatch, error)
FinalizeBatch sends a signal to the planter to finalize the current batch.
func (*ChainPlanter) FundBatch ¶ added in v0.4.0
func (c *ChainPlanter) FundBatch(params FundParams) (*MintingBatch, error)
FundBatch sends a signal to the planter to fund the current batch, or create a funded batch.
func (*ChainPlanter) ListBatches ¶
func (c *ChainPlanter) ListBatches(params ListBatchesParams) ([]*VerboseBatch, error)
ListBatches returns the single batch specified by the batch key, or the set of batches not yet finalized on disk.
func (*ChainPlanter) NumActiveBatches ¶
func (c *ChainPlanter) NumActiveBatches() (int, error)
NumActiveBatches returns the total number of active batches that have an outstanding caretaker assigned.
func (*ChainPlanter) PendingBatch ¶
func (c *ChainPlanter) PendingBatch() (*MintingBatch, error)
PendingBatch returns the current pending batch. If there's no pending batch, then an error is returned.
func (*ChainPlanter) QueueNewSeedling ¶
func (c *ChainPlanter) QueueNewSeedling(req *Seedling) (SeedlingUpdates, error)
QueueNewSeedling attempts to queue a new seedling request (the intent for New asset creation or ongoing issuance) to the ChainPlanter. A channel is returned where future updates will be sent over. If an error is returned no issuance operation was possible.
NOTE: This is part of the Planter interface.
func (*ChainPlanter) RegisterSubscriber ¶ added in v0.4.0
func (c *ChainPlanter) RegisterSubscriber( receiver *fn.EventReceiver[fn.Event], _, _ bool) error
RegisterSubscriber adds a new subscriber to the set of subscribers that will be notified of any new events that are broadcast.
func (*ChainPlanter) RemoveSubscriber ¶ added in v0.4.0
func (c *ChainPlanter) RemoveSubscriber( subscriber *fn.EventReceiver[fn.Event]) error
RemoveSubscriber removes a subscriber from the set of subscribers that will be notified of any new events that are broadcast.
func (*ChainPlanter) SealBatch ¶ added in v0.4.0
func (c *ChainPlanter) SealBatch(params SealParams) (*MintingBatch, error)
SealBatch attempts to seal the current batch, by providing or deriving all witnesses necessary to create the final genesis TX.
func (*ChainPlanter) Start ¶
func (c *ChainPlanter) Start() error
Start starts the ChainPlanter and any goroutines it needs to carry out its duty.
func (*ChainPlanter) Stop ¶
func (c *ChainPlanter) Stop() error
Stop signals the ChainPlanter to halt all operations gracefully.
type Custodian ¶
type Custodian struct { // ContextGuard provides a wait group and main quit channel that can be // used to create guarded contexts. *fn.ContextGuard // contains filtered or unexported fields }
Custodian is responsible for taking custody of an asset that is transferred to us on-chain. It watches the chain for incoming transfers defined by Taproot Asset addresses and then takes full custody of the transferred assets by collecting and validating their provenance proofs.
func NewCustodian ¶
func NewCustodian(cfg *CustodianConfig) *Custodian
NewCustodian creates a new Taproot Asset custodian based on the passed config.
func (*Custodian) RegisterSubscriber ¶ added in v0.3.1
func (c *Custodian) RegisterSubscriber(receiver *fn.EventReceiver[fn.Event], deliverExisting bool, deliverFrom time.Time) error
RegisterSubscriber adds a new subscriber to the set of subscribers that will be notified of any new status update events.
func (*Custodian) RemoveSubscriber ¶ added in v0.3.1
RemoveSubscriber removes a subscriber from the set of status event subscribers.
type CustodianConfig ¶
type CustodianConfig struct { // ChainParams are the Taproot Asset specific chain parameters. ChainParams *address.ChainParams // WalletAnchor is the main interface for interacting with the on-chain // wallet. WalletAnchor WalletAnchor // ChainBridge is the main interface for interacting with the chain // backend. ChainBridge ChainBridge // GroupVerifier is used to verify the validity of the group key for an // asset. GroupVerifier proof.GroupVerifier // AddrBook is the storage backend for addresses. AddrBook *address.Book // ProofArchive is the storage backend for proofs to which we store new // incoming proofs. ProofArchive proof.Archiver // ProofNotifier is the storage backend for proofs from which we are // notified about new proofs. This can be the same as the ProofArchive // above but can also be different (for example if we should _store_ the // proofs to a multi archiver but only be notified about new proofs // being available in the relational database). ProofNotifier proof.NotifyArchiver // ProofCourierDispatcher is the dispatcher that is used to create new // proof courier handles for receiving proofs based on the protocol of // a proof courier address. ProofCourierDispatcher proof.CourierDispatch // ProofRetrievalDelay is the time duration the custodian waits having // identified an asset transfer on-chain and before retrieving the // corresponding proof via the proof courier service. ProofRetrievalDelay time.Duration // ProofWatcher is used to watch new proofs for their anchor transaction // to be confirmed safely with a minimum number of confirmations. ProofWatcher proof.Watcher // ErrChan is the main error channel the custodian will report back // critical errors to the main server. ErrChan chan<- error }
CustodianConfig houses all the items that the Custodian needs to carry out its duties.
type FallibleTapscriptTreeMgr ¶ added in v0.4.0
type FallibleTapscriptTreeMgr struct {
FailLoad, FailStore bool
// contains filtered or unexported fields
}
func NewFallibleTapscriptTreeMgr ¶ added in v0.4.0
func NewFallibleTapscriptTreeMgr(store MintingStore) FallibleTapscriptTreeMgr
func (FallibleTapscriptTreeMgr) DeleteTapscriptTree ¶ added in v0.4.0
func (FallibleTapscriptTreeMgr) LoadTapscriptTree ¶ added in v0.4.0
func (mgr FallibleTapscriptTreeMgr) LoadTapscriptTree(ctx context.Context, rootHash chainhash.Hash) (*asset.TapscriptTreeNodes, error)
func (FallibleTapscriptTreeMgr) StoreTapscriptTree ¶ added in v0.4.0
func (mgr FallibleTapscriptTreeMgr) StoreTapscriptTree(ctx context.Context, treeNodes asset.TapscriptTreeNodes) (*chainhash.Hash, error)
type FinalizeParams ¶ added in v0.4.0
type FinalizeParams struct { FeeRate fn.Option[chainfee.SatPerKWeight] SiblingTapTree fn.Option[asset.TapscriptTreeNodes] }
FinalizeParams are the options available to change how a batch is finalized, and how the genesis TX is constructed.
type FundParams ¶ added in v0.4.0
type FundParams struct { FeeRate fn.Option[chainfee.SatPerKWeight] SiblingTapTree fn.Option[asset.TapscriptTreeNodes] }
FundParams are the options available to change how a batch is funded, and how the genesis TX is constructed.
type GardenKit ¶
type GardenKit struct { // Wallet is an active on chain wallet for the target chain. Wallet WalletAnchor // ChainBridge provides access to the chain for confirmation // notification, and other block related actions. ChainBridge ChainBridge // Log stores the current state of any active batch, throughout the // various states the planter will progress it through. Log MintingStore // TreeStore provides access to optional tapscript trees used with // script keys, minting output keys, and group keys. TreeStore asset.TapscriptTreeManager // KeyRing is used for obtaining internal keys for the anchor // transaction, as well as script keys for each asset and group keys // for assets created that permit ongoing emission. KeyRing KeyRing // GenSigner is used to generate signatures for the key group tweaked // by the genesis point when creating assets that permit on going // emission. GenSigner asset.GenesisSigner // GenTxBuilder is used to create virtual transactions for the group // witness generation process. GenTxBuilder asset.GenesisTxBuilder // TxValidator is used to validate group witnesses when creating assets // that support reissuance. TxValidator tapscript.TxValidator // ProofFiles stores the set of flat proof files. ProofFiles proof.Archiver // Universe is used to register new asset issuance with a local/remote // base universe instance. Universe universe.BatchRegistrar // ProofWatcher is used to watch new proofs for their anchor transaction // to be confirmed safely with a minimum number of confirmations. ProofWatcher proof.Watcher // UniversePushBatchSize is the number of minted items to push to the // local universe in a single batch. UniversePushBatchSize int }
GardenKit holds the set of shared fundamental interfaces all sub-systems of the tapgarden need to function.
type KeyRing ¶
type KeyRing interface { // 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. DeriveNextKey(context.Context, keychain.KeyFamily) (keychain.KeyDescriptor, error) // 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. DeriveKey(context.Context, keychain.KeyLocator) (keychain.KeyDescriptor, error) // IsLocalKey returns true if the key is under the control of the wallet // and can be derived by it. IsLocalKey(context.Context, keychain.KeyDescriptor) bool }
KeyRing is a mirror of the keychain.KeyRing interface, with the addition of a passed context which allows for cancellation of requests.
type ListBatchesParams ¶ added in v0.4.0
type ListBatchesParams struct { BatchKey *btcec.PublicKey Verbose bool }
ListBatchesParams are the options available to specify which minting batches are listed, and how verbose the listing should be.
type MintingBatch ¶
type MintingBatch struct { // CreationTime is the time that this batch was created. CreationTime time.Time // HeightHint is the recorded block height at time of creating this // batch. We use it to know where to start looking for the signed batch // transaction. HeightHint uint32 // BatchKey is the unique identifier for a batch. BatchKey keychain.KeyDescriptor // Seedlings is the set of seedlings for this batch. This maps an // asset's name to the seedling itself. // // NOTE: This field is only set if the state is BatchStateFrozen or // BatchStatePending. Seedlings map[string]*Seedling // GenesisPacket is the funded genesis packet that may or may not be // fully signed. When broadcast, this will create all assets stored // within this batch. GenesisPacket *tapsend.FundedPsbt // RootAssetCommitment is the root Taproot Asset commitment for all the // assets contained in this batch. // // NOTE: This field is only set if the state is beyond // BatchStateCommitted. RootAssetCommitment *commitment.TapCommitment // AssetMetas maps the serialized script key of an asset to the meta // reveal for that asset, if it has one. AssetMetas AssetMetas // contains filtered or unexported fields }
MintingBatch packages the pending state of a batch, this includes the batch key, the state of the batch and the assets to be created.
TODO(roasbeef): split this up after all? into two struts? Either[A, B]?
func RandSeedlingMintingBatch ¶
func RandSeedlingMintingBatch(t testing.TB, numSeedlings int) *MintingBatch
RandSeedlingMintingBatch creates a new minting batch with only random seedlings populated for testing.
func (*MintingBatch) Copy ¶ added in v0.4.0
func (m *MintingBatch) Copy() *MintingBatch
Copy creates a deep copy of the batch.
func (*MintingBatch) HasSeedlings ¶ added in v0.4.0
func (m *MintingBatch) HasSeedlings() bool
HasSeedlings checks if the batch has any seedlings. A batch with no seedlings cannot be sealed nor finalized.
func (*MintingBatch) IsFunded ¶ added in v0.4.0
func (m *MintingBatch) IsFunded() bool
IsFunded checks if the batch already has a funded genesis packet.
func (*MintingBatch) MintingOutputKey ¶
func (m *MintingBatch) MintingOutputKey(sibling *commitment.TapscriptPreimage) ( *btcec.PublicKey, []byte, error)
MintingOutputKey derives the output key that once mined, will commit to the Taproot asset root, thereby creating the set of included assets.
func (*MintingBatch) State ¶ added in v0.2.1
func (m *MintingBatch) State() BatchState
State returns the private state of the batch.
func (*MintingBatch) TapSibling ¶ added in v0.4.0
func (m *MintingBatch) TapSibling() []byte
TapSibling returns the optional tapscript sibling for the batch, which is a root hash of a tapscript tree.
func (*MintingBatch) UpdateState ¶ added in v0.2.1
func (m *MintingBatch) UpdateState(state BatchState)
UpdateState updates the state of a batch to a value that has been verified to be a valid batch state.
func (*MintingBatch) UpdateTapSibling ¶ added in v0.4.0
func (m *MintingBatch) UpdateTapSibling(sibling *chainhash.Hash)
UpdateTapSibling updates the optional tapscript sibling for the batch.
type MintingState ¶
type MintingState uint8
MintingState is an enum that tracks an asset through the various minting stages.
const ( // MintingStateNone is the default state, no actions have been taken. MintingStateNone MintingState = iota // MintingStateSeed denotes the seedling as been added to a batch. MintingStateSeed // MintingStateSeedling denotes that a seedling has been finalized in a // batch and now has a corresponding asset associated with it. MintingStateSeedling // MintingStateSprout denotes that a seedling has been paired with a // genesis transaction and broadcast for confirmation. MintingStateSprout // MintingStateAdult denotes that a seedling has been confirmed on // chain and reached full adulthood. MintingStateAdult )
type MintingStore ¶
type MintingStore interface { asset.TapscriptTreeManager // CommitMintingBatch commits a new minting batch to disk, identified // by its batch key. CommitMintingBatch(ctx context.Context, newBatch *MintingBatch) error // UpdateBatchState updates the batch state on disk identified by the // batch key. UpdateBatchState(ctx context.Context, batchKey *btcec.PublicKey, newState BatchState) error // AddSeedlingsToBatch adds a new seedling to an existing batch. Once // added this batch should remain in the BatchStatePending state. // // TODO(roasbeef): assumption that only one pending batch at a time? AddSeedlingsToBatch(ctx context.Context, batchKey *btcec.PublicKey, seedlings ...*Seedling) error // FetchAllBatches fetches all the batches on disk. FetchAllBatches(ctx context.Context) ([]*MintingBatch, error) // FetchNonFinalBatches fetches all non-finalized batches, meaning // batches that haven't yet fully confirmed on chain. FetchNonFinalBatches(ctx context.Context) ([]*MintingBatch, error) // FetchMintingBatch is used to fetch a single minting batch specified // by the batch key. FetchMintingBatch(ctx context.Context, batchKey *btcec.PublicKey) (*MintingBatch, error) // AddSeedlingGroups stores the asset groups for seedlings associated // with a batch. AddSeedlingGroups(ctx context.Context, genesisOutpoint wire.OutPoint, assetGroups []*asset.AssetGroup) error // FetchSeedlingGroups is used to fetch the asset groups for seedlings // associated with a funded batch. FetchSeedlingGroups(ctx context.Context, genesisOutpoint wire.OutPoint, anchorOutputIndex uint32, seedlings []*Seedling) ([]*asset.AssetGroup, error) // AddSproutsToBatch adds a new set of sprouts to the batch, along with // a GenesisPacket, that once signed and broadcast with create the // set of assets on chain. // // NOTE: The BatchState should transition to BatchStateCommitted upon a // successful call. AddSproutsToBatch(ctx context.Context, batchKey *btcec.PublicKey, genesisPacket *tapsend.FundedPsbt, assets *commitment.TapCommitment) error // CommitSignedGenesisTx adds a fully signed genesis transaction to the // batch, along with the Taproot Asset script root, which is the // left/right sibling for the Taproot Asset tapscript commitment in the // transaction. // // NOTE: The BatchState should transition to the BatchStateBroadcast // state upon a successful call. CommitSignedGenesisTx(ctx context.Context, batchKey *btcec.PublicKey, genesisTx *tapsend.FundedPsbt, anchorOutputIndex uint32, merkleRoot, tapTreeRoot, tapSibling []byte) error // MarkBatchConfirmed marks the batch as confirmed on chain. The passed // block location information determines where exactly in the chain the // batch was confirmed. // // NOTE: The BatchState should transition to the BatchStateConfirmed // state upon a successful call. MarkBatchConfirmed(ctx context.Context, batchKey *btcec.PublicKey, blockHash *chainhash.Hash, blockHeight uint32, txIndex uint32, mintingProofs proof.AssetBlobs) error // FetchGroupByGenesis fetches the asset group created by the genesis // referenced by the given ID. FetchGroupByGenesis(ctx context.Context, genesisID int64) (*asset.AssetGroup, error) // FetchGroupByGroupKey fetches the asset group with a matching tweaked // key, including the genesis information used to create the group. FetchGroupByGroupKey(ctx context.Context, groupKey *btcec.PublicKey) (*asset.AssetGroup, error) // FetchScriptKeyByTweakedKey fetches the populated script key given the // tweaked script key. FetchScriptKeyByTweakedKey(ctx context.Context, tweakedKey *btcec.PublicKey) (*asset.TweakedScriptKey, error) // FetchAssetMeta fetches the meta reveal for an asset genesis. FetchAssetMeta(ctx context.Context, ID asset.ID) (*proof.MetaReveal, error) // CommitBatchTapSibling adds a tapscript sibling to the batch, // specified by the sibling root hash. // // NOTE: The tapscript tree that defines the batch sibling must already // be committed to disk. CommitBatchTapSibling(ctx context.Context, batchKey *btcec.PublicKey, rootHash *chainhash.Hash) error // CommitBatchTx adds a funded transaction to the batch, which also sets // the genesis point for the batch. CommitBatchTx(ctx context.Context, batchKey *btcec.PublicKey, genesisTx *tapsend.FundedPsbt) error }
MintingStore is a log that stores information related to the set of pending minting batches. The ChainPlanter and ChainCaretaker use this log to record the process of seeding, planting, and finally maturing taproot assets that are a part of the batch.
type MockAssetSyncer ¶ added in v0.3.1
type MockAssetSyncer struct { Assets map[asset.ID]*asset.AssetGroup FetchedAssets chan *asset.AssetGroup FetchErrs bool }
func NewMockAssetSyncer ¶ added in v0.3.1
func NewMockAssetSyncer() *MockAssetSyncer
func (*MockAssetSyncer) AddAsset ¶ added in v0.3.1
func (m *MockAssetSyncer) AddAsset(newAsset asset.Asset)
func (*MockAssetSyncer) EnableAssetSync ¶ added in v0.3.1
func (m *MockAssetSyncer) EnableAssetSync(_ context.Context, groupInfo *asset.AssetGroup) error
func (*MockAssetSyncer) FetchAsset ¶ added in v0.3.1
func (m *MockAssetSyncer) FetchAsset(id asset.ID) (*asset.AssetGroup, error)
func (*MockAssetSyncer) RemoveAsset ¶ added in v0.3.1
func (m *MockAssetSyncer) RemoveAsset(id asset.ID)
func (*MockAssetSyncer) SyncAssetInfo ¶ added in v0.3.1
type MockChainBridge ¶
type MockChainBridge struct { FeeEstimateSignal chan struct{} PublishReq chan *wire.MsgTx ConfReqSignal chan int BlockEpochSignal chan struct{} NewBlocks chan int32 ReqCount int ConfReqs map[int]*chainntnfs.ConfirmationEvent // contains filtered or unexported fields }
func NewMockChainBridge ¶
func NewMockChainBridge() *MockChainBridge
func (*MockChainBridge) CurrentHeight ¶
func (m *MockChainBridge) CurrentHeight(_ context.Context) (uint32, error)
func (*MockChainBridge) EmptyConf ¶ added in v0.4.0
func (m *MockChainBridge) EmptyConf(enable bool)
func (*MockChainBridge) EstimateFee ¶
func (m *MockChainBridge) EstimateFee(ctx context.Context, _ uint32) (chainfee.SatPerKWeight, error)
func (*MockChainBridge) FailConf ¶ added in v0.4.0
func (m *MockChainBridge) FailConf(enable bool)
func (*MockChainBridge) FailFeeEstimatesOnce ¶ added in v0.4.0
func (m *MockChainBridge) FailFeeEstimatesOnce()
func (*MockChainBridge) GenFileChainLookup ¶ added in v0.4.0
func (m *MockChainBridge) GenFileChainLookup(*proof.File) asset.ChainLookup
GenFileChainLookup generates a chain lookup interface for the given proof file that can be used to validate proofs.
func (*MockChainBridge) GenProofChainLookup ¶ added in v0.4.0
func (m *MockChainBridge) GenProofChainLookup(*proof.Proof) (asset.ChainLookup, error)
GenProofChainLookup generates a chain lookup interface for the given single proof that can be used to validate proofs.
func (*MockChainBridge) GetBlock ¶
func (m *MockChainBridge) GetBlock(ctx context.Context, hash chainhash.Hash) (*wire.MsgBlock, error)
GetBlock returns a chain block given its hash.
func (*MockChainBridge) GetBlockHash ¶ added in v0.2.3
func (m *MockChainBridge) 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 (*MockChainBridge) GetBlockTimestamp ¶ added in v0.4.0
func (m *MockChainBridge) GetBlockTimestamp(_ context.Context, _ uint32) int64
func (*MockChainBridge) MeanBlockTimestamp ¶ added in v0.4.0
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 (*MockChainBridge) PublishTransaction ¶
func (*MockChainBridge) RegisterBlockEpochNtfn ¶ added in v0.3.0
func (*MockChainBridge) RegisterConfirmationsNtfn ¶
func (m *MockChainBridge) RegisterConfirmationsNtfn(ctx context.Context, _ *chainhash.Hash, _ []byte, _, _ uint32, _ bool, _ chan struct{}) (*chainntnfs.ConfirmationEvent, chan error, error)
func (*MockChainBridge) SendConfNtfn ¶
func (*MockChainBridge) TxBlockHeight ¶ added in v0.4.0
TxBlockHeight returns the block height that the given transaction was included in.
func (*MockChainBridge) VerifyBlock ¶ added in v0.2.3
func (m *MockChainBridge) VerifyBlock(_ context.Context, _ wire.BlockHeader, _ 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 MockGenSigner ¶
type MockGenSigner struct { KeyRing *MockKeyRing FailSigning bool }
func NewMockGenSigner ¶
func NewMockGenSigner(keyRing *MockKeyRing) *MockGenSigner
func (*MockGenSigner) SignVirtualTx ¶ added in v0.3.0
func (m *MockGenSigner) SignVirtualTx(signDesc *lndclient.SignDescriptor, virtualTx *wire.MsgTx, prevOut *wire.TxOut) (*schnorr.Signature, error)
type MockKeyRing ¶
type MockKeyRing struct { FamIndex keychain.KeyFamily KeyIndex uint32 Keys map[keychain.KeyLocator]*btcec.PrivateKey ReqKeys chan *keychain.KeyDescriptor }
func NewMockKeyRing ¶
func NewMockKeyRing() *MockKeyRing
func (*MockKeyRing) DeriveKey ¶
func (m *MockKeyRing) DeriveKey(ctx context.Context, _ keychain.KeyLocator) (keychain.KeyDescriptor, error)
func (*MockKeyRing) DeriveNextKey ¶
func (m *MockKeyRing) DeriveNextKey(ctx context.Context, keyFam keychain.KeyFamily) (keychain.KeyDescriptor, error)
func (*MockKeyRing) DeriveNextTaprootAssetKey ¶
func (m *MockKeyRing) DeriveNextTaprootAssetKey( ctx context.Context) (keychain.KeyDescriptor, error)
DeriveNextTaprootAssetKey attempts to derive the *next* key within the Taproot Asset key family.
func (*MockKeyRing) IsLocalKey ¶
func (m *MockKeyRing) IsLocalKey(context.Context, keychain.KeyDescriptor) bool
type MockProofArchive ¶
type MockProofArchive struct { }
func (*MockProofArchive) FetchProof ¶
func (*MockProofArchive) FetchProofs ¶ added in v0.3.0
func (m *MockProofArchive) FetchProofs(ctx context.Context, id asset.ID) ([]*proof.AnnotatedProof, error)
func (*MockProofArchive) ImportProofs ¶
func (m *MockProofArchive) ImportProofs(context.Context, proof.HeaderVerifier, proof.MerkleVerifier, proof.GroupVerifier, proof.ChainLookupGenerator, bool, ...*proof.AnnotatedProof) error
type MockProofWatcher ¶ added in v0.3.0
type MockProofWatcher struct { }
func (*MockProofWatcher) DefaultUpdateCallback ¶ added in v0.3.0
func (m *MockProofWatcher) DefaultUpdateCallback() proof.UpdateCallback
func (*MockProofWatcher) MaybeWatch ¶ added in v0.3.0
func (m *MockProofWatcher) MaybeWatch(*proof.File, proof.UpdateCallback) error
func (*MockProofWatcher) ShouldWatch ¶ added in v0.3.0
func (m *MockProofWatcher) ShouldWatch(*proof.Proof) bool
func (*MockProofWatcher) WatchProofs ¶ added in v0.3.0
func (m *MockProofWatcher) WatchProofs([]*proof.Proof, proof.UpdateCallback) error
type MockWalletAnchor ¶
type MockWalletAnchor struct { FundPsbtSignal chan *tapsend.FundedPsbt SignPsbtSignal chan struct{} ImportPubKeySignal chan *btcec.PublicKey ListUnspentSignal chan struct{} SubscribeTxSignal chan struct{} SubscribeTx chan lndclient.Transaction ListTxnsSignal chan struct{} Transactions []lndclient.Transaction ImportedUtxos []*lnwallet.Utxo }
func NewMockWalletAnchor ¶
func NewMockWalletAnchor() *MockWalletAnchor
func (*MockWalletAnchor) FundPsbt ¶
func (m *MockWalletAnchor) FundPsbt(_ context.Context, packet *psbt.Packet, _ uint32, _ chainfee.SatPerKWeight, changeIdx int32) (*tapsend.FundedPsbt, error)
FundPsbt funds a PSBT.
func (*MockWalletAnchor) ImportTaprootOutput ¶
func (*MockWalletAnchor) ImportTapscript ¶
func (m *MockWalletAnchor) ImportTapscript(_ context.Context, tapscript *waddrmgr.Tapscript) (btcutil.Address, error)
ImportTapscript imports a Taproot output script into the wallet to track it on-chain in a watch-only manner.
func (*MockWalletAnchor) ListTransactions ¶
func (m *MockWalletAnchor) ListTransactions(ctx context.Context, _, _ int32, _ 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 (*MockWalletAnchor) ListUnspentImportScripts ¶
ListUnspentImportScripts lists all UTXOs of the imported Taproot scripts.
func (*MockWalletAnchor) SignAndFinalizePsbt ¶
func (*MockWalletAnchor) SubscribeTransactions ¶
func (m *MockWalletAnchor) 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 (*MockWalletAnchor) UnlockInput ¶
UnlockInput unlocks the set of target inputs after a batch or send transaction is abandoned.
type PendingAssetGroup ¶ added in v0.4.0
type PendingAssetGroup struct { asset.GroupKeyRequest asset.GroupVirtualTx }
PendingAssetGroup is the group key request and virtual TX necessary to produce an asset group witness for a seedling.
type Planter ¶
type Planter interface { // QueueNewSeedling attempts to queue a new seedling request (the // intent for New asset creation or ongoing issuance) to the Planter. // A channel is returned where future updates will be sent over. If an // error is returned no issuance operation was possible. QueueNewSeedling(req *Seedling) (SeedlingUpdates, error) // ListBatches lists the set of batches submitted for minting, or the // details of a specific batch. ListBatches(params ListBatchesParams) ([]*VerboseBatch, error) // CancelSeedling attempts to cancel the creation of a new asset // identified by its name. If the seedling has already progressed to a // point where the genesis PSBT has been broadcasted, an error is // returned. CancelSeedling() error // FundBatch attempts to provide a genesis point for the current batch, // or create a new funded batch. FundBatch(params FundParams) (*MintingBatch, error) // SealBatch attempts to seal the current batch, by providing or // deriving all witnesses necessary to create the final genesis TX. SealBatch(params SealParams) (*MintingBatch, error) // FinalizeBatch signals that the asset minter should finalize // the current batch, if one exists. FinalizeBatch(params FinalizeParams) (*MintingBatch, error) // CancelBatch signals that the asset minter should cancel the // current batch, if one exists. CancelBatch() (*btcec.PublicKey, error) // Start signals that the asset minter should being operations. Start() error // Stop signals that the asset minter should attempt a graceful // shutdown. Stop() error // EventPublisher is a subscription interface that allows callers to // subscribe to events that are relevant to the Planter. fn.EventPublisher[fn.Event, bool] }
Planter is responsible for batching a set of seedlings into a minting batch that will eventually be confirmed on chain.
type PlanterConfig ¶
type PlanterConfig struct { GardenKit // ProofUpdates is the storage backend for updated proofs. ProofUpdates proof.Archiver // ErrChan is the main error channel the planter will report back // critical errors to the main server. ErrChan chan<- error }
PlanterConfig is the main config for the ChainPlanter.
type ReOrgWatcher ¶ added in v0.3.0
type ReOrgWatcher struct { // ContextGuard provides a wait group and main quit channel that can be // used to create guarded contexts. *fn.ContextGuard // contains filtered or unexported fields }
ReOrgWatcher is responsible for watching initially confirmed transactions until they reach a safe confirmation depth. If a re-org happens, it will update the proof and store it in the proof archive.
func NewReOrgWatcher ¶ added in v0.3.0
func NewReOrgWatcher(cfg *ReOrgWatcherConfig) *ReOrgWatcher
NewReOrgWatcher creates a new re-org watcher based on the passed config.
func (*ReOrgWatcher) DefaultUpdateCallback ¶ added in v0.3.0
func (w *ReOrgWatcher) DefaultUpdateCallback() proof.UpdateCallback
DefaultUpdateCallback is the default implementation for the update callback that is called when a proof is updated. This implementation will replace the old proof in the proof archiver (multi-archive) with the new one.
func (*ReOrgWatcher) MaybeWatch ¶ added in v0.3.0
func (w *ReOrgWatcher) MaybeWatch(file *proof.File, onProofUpdate proof.UpdateCallback) error
MaybeWatch inspects the given proof file for any proofs that are not yet buried sufficiently deep and adds them to the re-org watcher.
func (*ReOrgWatcher) ShouldWatch ¶ added in v0.3.0
func (w *ReOrgWatcher) ShouldWatch(p *proof.Proof) bool
ShouldWatch returns true if the proof is for a block that is not yet sufficiently deep to be considered safe.
func (*ReOrgWatcher) Start ¶ added in v0.3.0
func (w *ReOrgWatcher) Start() error
Start attempts to start a new re-org watcher.
func (*ReOrgWatcher) Stop ¶ added in v0.3.0
func (w *ReOrgWatcher) Stop() error
Stop signals for a re-org watcher to gracefully exit.
func (*ReOrgWatcher) WatchProofs ¶ added in v0.3.0
func (w *ReOrgWatcher) WatchProofs(newProofs []*proof.Proof, onProofUpdate proof.UpdateCallback) error
WatchProofs adds new proofs to the re-org watcher for their anchor transaction to be watched until it reaches a safe confirmation depth.
type ReOrgWatcherConfig ¶ added in v0.3.0
type ReOrgWatcherConfig struct { // ChainBridge is the main interface for interacting with the chain // backend. ChainBridge ChainBridge // GroupVerifier is used to verify the validity of the group key for an // asset. GroupVerifier proof.GroupVerifier // ProofArchive is the storage backend for proofs to which we store // updated proofs. ProofArchive proof.Archiver // NonBuriedAssetFetcher is a function that returns all assets that are // not yet sufficiently deep buried. NonBuriedAssetFetcher func(ctx context.Context, minHeight int32) ([]*asset.ChainAsset, error) // SafeDepth is the number of confirmations we require before we // consider a transaction to be safely buried in the chain. SafeDepth int32 // ErrChan is the main error channel the watcher will report back // critical errors to the main server. ErrChan chan<- error }
ReOrgWatcherConfig houses all the items that the re-org watcher needs to carry out its duties.
type SealParams ¶ added in v0.4.0
type SealParams struct {
GroupWitnesses []asset.PendingGroupWitness
}
SealParams change how asset groups in a minting batch are created.
type Seedling ¶
type Seedling struct { // AssetVersion is the version of the asset to be created. AssetVersion asset.Version // AssetType is the type of the asset. AssetType asset.Type // AssetName is the name of the asset. AssetName string // Meta is the set of metadata associated with the asset. Meta *proof.MetaReveal // Amount is the total amount of the asset. Amount uint64 // GroupInfo contains the information needed to link this asset to an // exiting group. GroupInfo *asset.AssetGroup // EnableEmission if true, then an asset group key will be specified // for this asset meaning future assets linked to it can be created. EnableEmission bool // GroupAnchor is the name of another seedling in the pending batch that // will anchor an asset group. This seedling will be minted with the // same group key as the anchor asset. GroupAnchor *string // ScriptKey is the tweaked Taproot key that will be used to spend the // asset after minting. By default, this key is constructed with a // BIP-0086 style tweak. ScriptKey asset.ScriptKey // GroupInternalKey is the raw group key before the tweak with the // genesis point or tapscript root has been applied. GroupInternalKey *keychain.KeyDescriptor // GroupTapscriptRoot is the root of the Tapscript tree that commits to // all script spend conditions for the group key. Instead of spending an // asset, these scripts are used to define witnesses more complex than // a Schnorr signature for reissuing assets. A group key with an empty // Tapscript root can only authorize reissuance with a signature. GroupTapscriptRoot []byte // contains filtered or unexported fields }
Seedling is an adolescent Taproot asset that will one day bloom into a fully grown plant.
func (Seedling) HasGroupKey ¶
HasGroupKey checks if a seedling specifies a particular group key.
type SeedlingUpdate ¶
type SeedlingUpdate struct { // NewState is the new state a seedling has transitioned to. NewState MintingState // PendingBatch is the current pending batch that the seedling has been // added to. PendingBatch *MintingBatch // Error if non-nil, denotes that an terminal error state has been // reached. Error error }
SeedlingUpdate is a struct used to send notifications w.r.t the state of a seedling back to the caller.
type SeedlingUpdates ¶
type SeedlingUpdates chan SeedlingUpdate
SeedlingUpdates is a channel that will be used to send updates for each seedling back to the caller.
type UnsealedSeedling ¶ added in v0.4.0
type UnsealedSeedling struct { *Seedling *PendingAssetGroup }
UnsealedSeedling is a previously submitted seedling and its associated PendingAssetGroup, which can be used to produce an asset group witness.
type VerboseBatch ¶ added in v0.4.0
type VerboseBatch struct { *MintingBatch UnsealedSeedlings map[string]*UnsealedSeedling }
VerboseBatch is a MintingBatch that includes seedlings with their pending asset group information. The Seedlings map is empty, and all seedlings are stored as UnsealedSeedlings.
func (*VerboseBatch) ToMintingBatch ¶ added in v0.4.0
func (v *VerboseBatch) ToMintingBatch() *MintingBatch
ToMintingBatch creates a new MintingBatch from a VerboseBatch.
type WalletAnchor ¶
type WalletAnchor interface { // FundPsbt attaches enough inputs to the target PSBT packet for it to // be valid. FundPsbt(ctx context.Context, packet *psbt.Packet, minConfs uint32, feeRate chainfee.SatPerKWeight, changeIdx int32) (*tapsend.FundedPsbt, error) // SignAndFinalizePsbt fully signs and finalizes the target PSBT // packet. SignAndFinalizePsbt(context.Context, *psbt.Packet) (*psbt.Packet, error) // ImportTaprootOutput imports a new public key into the wallet, as a // P2TR output. ImportTaprootOutput(context.Context, *btcec.PublicKey) (btcutil.Address, error) // UnlockInput unlocks the set of target inputs after a batch or send // transaction is abandoned. UnlockInput(context.Context, wire.OutPoint) error // ListUnspentImportScripts lists all UTXOs of the imported Taproot // scripts. ListUnspentImportScripts(ctx context.Context) ([]*lnwallet.Utxo, 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. ListTransactions(ctx context.Context, startHeight, endHeight int32, account string) ([]lndclient.Transaction, 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. SubscribeTransactions(context.Context) (<-chan lndclient.Transaction, <-chan error, error) }
WalletAnchor is the main wallet interface used to managed PSBT packets, and import public keys into the wallet.