Documentation ¶
Index ¶
- Constants
- Variables
- type ActiveAssetsStore
- type AddrBook
- type AddrBookTxOptions
- type AddrByTaprootOutput
- type AddrEvent
- type AddrEventID
- type AddrEventQuery
- type AddrManaged
- type AddrQuery
- type Addresses
- type AnchorPoint
- type AnchorTxConf
- type AssetAnchor
- type AssetAnchorUpdate
- type AssetBalance
- type AssetDelta
- type AssetDeltaWithProof
- type AssetFamSig
- type AssetFamilyBalance
- type AssetFamilyKey
- type AssetMintingStore
- func (a *AssetMintingStore) AddSeedlingsToBatch(ctx context.Context, batchKey *btcec.PublicKey, ...) error
- func (a *AssetMintingStore) AddSproutsToBatch(ctx context.Context, batchKey *btcec.PublicKey, ...) error
- func (a *AssetMintingStore) CommitMintingBatch(ctx context.Context, newBatch *tarogarden.MintingBatch) error
- func (a *AssetMintingStore) CommitSignedGenesisTx(ctx context.Context, batchKey *btcec.PublicKey, ...) error
- func (a *AssetMintingStore) FetchNonFinalBatches(ctx context.Context) ([]*tarogarden.MintingBatch, error)
- func (a *AssetMintingStore) MarkBatchConfirmed(ctx context.Context, batchKey *btcec.PublicKey, blockHash *chainhash.Hash, ...) error
- func (a *AssetMintingStore) UpdateBatchState(ctx context.Context, batchKey *btcec.PublicKey, newState tarogarden.BatchState) error
- type AssetProof
- type AssetProofI
- type AssetQueryFilters
- type AssetSeedling
- type AssetSeedlingItem
- type AssetSeedlingShell
- type AssetSpendDelta
- type AssetSprout
- type AssetStore
- func (a *AssetStore) ConfirmParcelDelivery(ctx context.Context, conf *tarofreighter.AssetConfirmEvent) error
- func (a *AssetStore) FetchAllAssets(ctx context.Context, query *AssetQueryFilters) ([]*ChainAsset, error)
- func (a *AssetStore) FetchAssetProofs(ctx context.Context, targetAssets ...*btcec.PublicKey) (proof.AssetBlobs, error)
- func (a *AssetStore) FetchProof(ctx context.Context, locator proof.Locator) (proof.Blob, error)
- func (a *AssetStore) ImportProofs(ctx context.Context, proofs ...*proof.AnnotatedProof) error
- func (a *AssetStore) LogPendingParcel(ctx context.Context, spend *tarofreighter.OutboundParcelDelta) error
- func (a *AssetStore) PendingParcels(ctx context.Context) ([]*tarofreighter.OutboundParcelDelta, error)
- func (a *AssetStore) QueryAssetBalancesByFamily(ctx context.Context, famKey *btcec.PublicKey) (map[asset.SerializedKey]AssetFamilyBalance, error)
- func (a *AssetStore) QueryBalancesByAsset(ctx context.Context, assetID *asset.ID) (map[asset.ID]AssetBalance, error)
- func (a *AssetStore) QueryParcels(ctx context.Context, pending bool) ([]*tarofreighter.OutboundParcelDelta, error)
- func (a *AssetStore) SelectCommitment(ctx context.Context, constraints tarofreighter.CommitmentConstraints) ([]*tarofreighter.AnchoredCommitment, error)
- type AssetStoreTxOptions
- type AssetTransfer
- type AssetWitness
- type BatchChainUpdate
- type BatchStateUpdate
- type BatchedAddrBook
- type BatchedAssetStore
- type BatchedKeyStore
- type BatchedPendingAssetStore
- type BatchedQuerier
- type BatchedTreeStore
- type BatchedTx
- type ChainAsset
- type ChainTx
- type ChainTxConf
- type ChildQuery
- type ConfirmedAsset
- type DelNode
- type FetchGenesisStore
- type Genesis
- type GenesisAsset
- type GenesisPointAnchor
- type GenesisTxUpdate
- type InternalKey
- type KeyStore
- type KeyStoreTxOptions
- type MacaroonID
- type MacaroonRootKey
- type MintingBatch
- type MintingBatchI
- type MintingBatchInit
- type MintingBatchTuple
- type NewAddr
- type NewAssetDelta
- type NewAssetTransfer
- type NewBranch
- type NewCompactedLeaf
- type NewLeaf
- type NewScriptKey
- type NewSpendProof
- type PendingAssetStore
- type PrevInput
- type ProofUpdate
- type QueryAssetFilters
- type QueryCreator
- type RawAssetBalance
- type RawAssetFamilyBalance
- type RawManagedUTXO
- type RootKeyStore
- type SqliteConfig
- type SqliteStore
- type StoredNode
- type TaroAddressBook
- func (t *TaroAddressBook) AddrByTaprootOutput(ctx context.Context, key *btcec.PublicKey) (*address.AddrWithKeyInfo, error)
- func (t *TaroAddressBook) CompleteEvent(ctx context.Context, event *address.Event, status address.Status, ...) error
- func (t *TaroAddressBook) GetOrCreateEvent(ctx context.Context, status address.Status, addr *address.AddrWithKeyInfo, ...) (*address.Event, error)
- func (t *TaroAddressBook) InsertAddrs(ctx context.Context, addrs ...address.AddrWithKeyInfo) error
- func (t *TaroAddressBook) QueryAddrEvents(ctx context.Context, params address.EventQueryParams) ([]*address.Event, error)
- func (t *TaroAddressBook) QueryAddrs(ctx context.Context, params address.QueryParams) ([]address.AddrWithKeyInfo, error)
- func (t *TaroAddressBook) SetAddrManaged(ctx context.Context, addr *address.AddrWithKeyInfo, managedFrom time.Time) error
- type TaroTreeStore
- type TransactionExecutor
- type TransferQuery
- type TreeStore
- type TreeStoreTxOptions
- type Tx
- type TxOptions
- type UpdateRoot
- type UpsertAddrEvent
- type UpsertAssetStore
- type UtxoQuery
Constants ¶
const ( // SqliteMintingStoreName is the name of the minting store backed by // sqlite3. SqliteMintingStoreName = "sqlite3" )
const (
// SqliteTreeStoreName is the name of the tree store backed by sqlite3.
SqliteTreeStoreName = "sqlite3"
)
Variables ¶
var ( // DefaultStoreTimeout is the default timeout used for any interaction // with the storage/database. DefaultStoreTimeout = time.Second * 10 )
Functions ¶
This section is empty.
Types ¶
type ActiveAssetsStore ¶
type ActiveAssetsStore interface { // UpsertAssetStore houses the methods related to inserting/updating // assets. UpsertAssetStore // QueryAssets fetches the set of fully confirmed assets. QueryAssets(context.Context, QueryAssetFilters) ([]ConfirmedAsset, error) // QueryAssetBalancesByAsset queries the balances for assets or // alternatively for a selected one that matches the passed asset ID // filter. QueryAssetBalancesByAsset(context.Context, interface{}) ([]RawAssetBalance, error) // QueryAssetBalancesByFamily queries the asset balances for asset // families or alternatively for a selected one that matches the passed // filter. QueryAssetBalancesByFamily(context.Context, interface{}) ([]RawAssetFamilyBalance, error) // FetchAssetProofs fetches all the asset proofs we have stored on // disk. FetchAssetProofs(ctx context.Context) ([]AssetProof, error) // FetchAssetProof fetches the asset proof for a given asset identified // by its script key. FetchAssetProof(ctx context.Context, scriptKey []byte) (AssetProofI, error) // UpsertChainTx inserts a new or updates an existing chain tx into the // DB. UpsertChainTx(ctx context.Context, arg ChainTx) (int32, error) // UpsertManagedUTXO inserts a new or updates an existing managed UTXO // to disk and returns the primary key. UpsertManagedUTXO(ctx context.Context, arg RawManagedUTXO) (int32, error) // UpsertAssetProof inserts a new or updates an existing asset proof on // disk. UpsertAssetProof(ctx context.Context, arg sqlite.UpsertAssetProofParams) error // InsertAssetWitness inserts a new prev input for an asset into the // database. InsertAssetWitness(context.Context, PrevInput) error // FetchAssetWitnesses attempts to fetch either all the asset witnesses // on disk (NULL param), or the witness for a given asset ID. FetchAssetWitnesses(context.Context, sql.NullInt32) ([]AssetWitness, error) // FetchManagedUTXO fetches a managed UTXO based on either the outpoint // or the transaction that anchors it. FetchManagedUTXO(context.Context, UtxoQuery) (AnchorPoint, error) // ReanchorAssets takes an old anchor point, then updates all assets // that point to that old anchor point-to-point to the new one. ReanchorAssets(ctx context.Context, arg AssetAnchorUpdate) error // ApplySpendDelta applies a sped delta (new amount and script key) // based on the existing script key of an asset. ApplySpendDelta(ctx context.Context, arg AssetSpendDelta) (int32, error) // DeleteManagedUTXO deletes the managed utxo identified by the passed // serialized outpoint. DeleteManagedUTXO(ctx context.Context, outpoint []byte) error // ConfirmChainAnchorTx marks a new anchor transaction that was // previously unconfirmed as confirmed. ConfirmChainAnchorTx(ctx context.Context, arg AnchorTxConf) error // FetchAssetDeltas fetches the asset deltas associated with a given // transfer id. FetchAssetDeltas(ctx context.Context, transferID int32) ([]AssetDelta, error) // FetchAssetDeltasWithProofs fetches the asset deltas including the // proofs associated with a given transfer id. FetchAssetDeltasWithProofs(ctx context.Context, transferID int32) ([]AssetDeltaWithProof, error) // InsertAssetDelta inserts a new asset delta into the DB. InsertAssetDelta(ctx context.Context, arg NewAssetDelta) error // InsertAssetTransfer inserts a new asset transfer into the DB. InsertAssetTransfer(ctx context.Context, arg NewAssetTransfer) (int32, error) // QueryAssetTransfers queries for a set of asset transfers in the db. QueryAssetTransfers(ctx context.Context, tranferQuery TransferQuery) ([]AssetTransfer, error) // DeleteAssetWitnesses deletes the witnesses on disk associated with a // given asset ID. DeleteAssetWitnesses(ctx context.Context, assetID int32) error // InsertSpendProofs is used to insert the new spend proofs after a // transfer into DB. InsertSpendProofs(ctx context.Context, arg NewSpendProof) (int32, error) // DeleteSpendProofs is used to delete the set of proofs on disk after // we apply a transfer. DeleteSpendProofs(ctx context.Context, transferID int32) error // FetchSpendProofs looks up the spend proofs for the given transfer // ID. FetchSpendProofs(ctx context.Context, transferID int32) (sqlite.FetchSpendProofsRow, error) }
ActiveAssetsStore is a sub-set of the main sqlite.Querier interface that contains methods related to querying the set of confirmed assets.
type AddrBook ¶
type AddrBook interface { // UpsertAssetStore houses the methods related to inserting/updating // assets. UpsertAssetStore // FetchGenesisStore houses the methods related to fetching genesis // assets. FetchGenesisStore // FetchAddrs returns all the addresses based on the constraints of the // passed AddrQuery. FetchAddrs(ctx context.Context, arg AddrQuery) ([]Addresses, error) // FetchAddrByTaprootOutputKey returns a single address based on its // Taproot output key or a sql.ErrNoRows error if no such address // exists. FetchAddrByTaprootOutputKey(ctx context.Context, arg []byte) (AddrByTaprootOutput, error) // InsertAddr inserts a new address into the database. InsertAddr(ctx context.Context, arg NewAddr) (int32, error) // UpsertInternalKey inserts a new or updates an existing internal key // into the database and returns the primary key. UpsertInternalKey(ctx context.Context, arg InternalKey) (int32, error) // UpsertScriptKey inserts a new script key on disk into the DB. UpsertScriptKey(context.Context, NewScriptKey) (int32, error) // SetAddrManaged sets an address as being managed by the internal // wallet. SetAddrManaged(ctx context.Context, arg AddrManaged) error // UpsertManagedUTXO inserts a new or updates an existing managed UTXO // to disk and returns the primary key. UpsertManagedUTXO(ctx context.Context, arg RawManagedUTXO) (int32, error) // UpsertChainTx inserts a new or updates an existing chain tx into the // DB. UpsertChainTx(ctx context.Context, arg ChainTx) (int32, error) // UpsertAddrEvent inserts a new or updates an existing address event // and returns the primary key. UpsertAddrEvent(ctx context.Context, arg UpsertAddrEvent) (int32, error) // FetchAddrEvent returns a single address event based on its primary // key. FetchAddrEvent(ctx context.Context, id int32) (AddrEvent, error) // QueryEventIDs returns a list of event IDs and their corresponding // address IDs that match the given query parameters. QueryEventIDs(ctx context.Context, query AddrEventQuery) ([]AddrEventID, error) // FetchAssetProof fetches the asset proof for a given asset identified // by its script key. FetchAssetProof(ctx context.Context, scriptKey []byte) (AssetProofI, error) }
AddrBook is an interface that represents the storage backed needed to create the TaroAddressBook book. We need to be able to insert/fetch addresses, and also make internal keys since each address has an internal key and a script key (tho they can be the same).
type AddrBookTxOptions ¶
type AddrBookTxOptions struct {
// contains filtered or unexported fields
}
AddrBookTxOptions defines the set of db txn options the AddrBook understands.
func (*AddrBookTxOptions) ReadOnly ¶
func (a *AddrBookTxOptions) ReadOnly() bool
ReadOnly returns true if the transaction should be read only.
NOTE: This implements the TxOptions
type AddrByTaprootOutput ¶
type AddrByTaprootOutput = sqlite.FetchAddrByTaprootOutputKeyRow
AddrByTaprootOutput is a type alias for returning an address by its Taproot output key.
type AddrEvent ¶
type AddrEvent = sqlite.FetchAddrEventRow
AddrEvent is a type alias for fetching an address event row.
type AddrEventID ¶
type AddrEventID = sqlite.QueryEventIDsRow
AddrEventID is a type alias for fetching the ID of an address event and its corresponding address.
type AddrEventQuery ¶
type AddrEventQuery = sqlite.QueryEventIDsParams
AddrEventQuery is a type alias for a query into the set of known address events.
type AddrManaged ¶
type AddrManaged = sqlite.SetAddrManagedParams
AddrManaged is a type alias for setting an address as managed.
type AddrQuery ¶
type AddrQuery = sqlite.FetchAddrsParams
AddrQuery as a type alias for a query into the set of known addresses.
type Addresses ¶
type Addresses = sqlite.FetchAddrsRow
Addresses is a type alias for the full address row with key locator information.
type AnchorPoint ¶
type AnchorPoint = sqlite.FetchManagedUTXORow
AnchorPoint wraps a managed UTXO along with all the auxiliary information it references.
type AnchorTxConf ¶
type AnchorTxConf = sqlite.ConfirmChainAnchorTxParams
AnchorTxConf identifies an unconfirmed anchor tx to confirm.
type AssetAnchor ¶
type AssetAnchor = sqlite.AnchorPendingAssetsParams
AssetAnchor is used to bind assets on disk with the transaction that will create them on-chain.
type AssetAnchorUpdate ¶
type AssetAnchorUpdate = sqlite.ReanchorAssetsParams
AssetAnchorUpdate is used to update the managed UTXO pointer when spending assets on chain.
type AssetBalance ¶
type AssetBalance struct { ID asset.ID Version int32 Balance uint64 Tag string Meta []byte Type asset.Type GenesisPoint wire.OutPoint OutputIndex uint32 }
AssetBalance holds a balance query result for a particular asset or all assets tracked by this daemon.
type AssetDelta ¶
type AssetDelta = sqlite.FetchAssetDeltasRow
AssetDelta tracks the changes to an asset within the confines of a transfer.
type AssetDeltaWithProof ¶
type AssetDeltaWithProof = sqlite.FetchAssetDeltasWithProofsRow
AssetDeltaWithProof tracks the changes to an asset within the confines of a transfer, also containing the proofs for the change.
type AssetFamSig ¶
type AssetFamSig = sqlite.UpsertAssetFamilySigParams
AssetFamSig is used to insert the family key signature for a given asset on disk.
type AssetFamilyBalance ¶
type AssetFamilyBalance struct { FamKey *btcec.PublicKey Balance uint64 }
AssetFamilyBalance holds abalance query result for a particular asset family or all asset families tracked by this daemon.
type AssetFamilyKey ¶
type AssetFamilyKey = sqlite.UpsertAssetFamilyKeyParams
AssetFamilyKey is used to insert a new asset key family into the DB.
type AssetMintingStore ¶
type AssetMintingStore struct {
// contains filtered or unexported fields
}
AssetMintingStore is an implementation of the tarogarden.PlantingLog interface backed by a persistent database. The abstracted BatchedPendingAssetStore permits re-use of the main storage related business logic for any backend that can implement the specified interface.
func NewAssetMintingStore ¶
func NewAssetMintingStore(db BatchedPendingAssetStore) *AssetMintingStore
NewAssetMintingStore creates a new AssetMintingStore from the specified BatchedPendingAssetStore interface.
func (*AssetMintingStore) AddSeedlingsToBatch ¶
func (a *AssetMintingStore) AddSeedlingsToBatch(ctx context.Context, batchKey *btcec.PublicKey, seedlings ...*tarogarden.Seedling) error
AddSeedlingsToBatch adds a new set of seedlings to an existing batch.
func (*AssetMintingStore) AddSproutsToBatch ¶
func (a *AssetMintingStore) AddSproutsToBatch(ctx context.Context, batchKey *btcec.PublicKey, genesisPacket *tarogarden.FundedPsbt, assetRoot *commitment.TaroCommitment) error
AddSproutsToBatch updates a batch with the passed batch transaction and also binds the genesis transaction (which will create the set of assets in the batch) to the batch itself.
func (*AssetMintingStore) CommitMintingBatch ¶
func (a *AssetMintingStore) CommitMintingBatch(ctx context.Context, newBatch *tarogarden.MintingBatch) error
CommitMintingBatch commits a new minting batch to disk along with any seedlings specified as part of the batch. A new internal key is also created, with the batch referencing that internal key. This internal key will be used as the internal key which will mint all the assets in the batch.
func (*AssetMintingStore) CommitSignedGenesisTx ¶
func (a *AssetMintingStore) CommitSignedGenesisTx(ctx context.Context, batchKey *btcec.PublicKey, genesisPkt *tarogarden.FundedPsbt, anchorOutputIndex uint32, taroScriptRoot []byte) error
CommitSignedGenesisTx binds a fully signed genesis transaction to a pending batch on disk. The anchor output index and script root are also stored to ensure we can reconstruct the private key needed to sign for the batch. The genesis transaction itself is inserted as a new chain transaction, which all other components then reference.
TODO(roasbeef): or could just re-read assets from disk and set the script root manually?
func (*AssetMintingStore) FetchNonFinalBatches ¶
func (a *AssetMintingStore) FetchNonFinalBatches(ctx context.Context, ) ([]*tarogarden.MintingBatch, error)
FetchNonFinalBatches fetches all the batches that aren't fully finalized on disk.
func (*AssetMintingStore) MarkBatchConfirmed ¶
func (a *AssetMintingStore) MarkBatchConfirmed(ctx context.Context, batchKey *btcec.PublicKey, blockHash *chainhash.Hash, blockHeight uint32, txIndex uint32, mintingProofs proof.AssetBlobs) error
MarkBatchConfirmed stores final confirmation information for a batch on disk.
func (*AssetMintingStore) UpdateBatchState ¶
func (a *AssetMintingStore) UpdateBatchState(ctx context.Context, batchKey *btcec.PublicKey, newState tarogarden.BatchState) error
UpdateBatchState updates the state of a batch based on the batch key.
type AssetProof ¶
type AssetProof = sqlite.FetchAssetProofsRow
AssetProof is the asset proof for a given asset, identified by its script key.
type AssetProofI ¶
type AssetProofI = sqlite.FetchAssetProofRow
AssetProofI is identical to AssetProof but is used for the case where the proofs for a specific asset are fetched.
type AssetQueryFilters ¶
type AssetQueryFilters struct {
tarofreighter.CommitmentConstraints
}
AssetQueryFilters is a wrapper struct over the CommitmentConstraints struct which lets us filter the results of the set of assets returned.
type AssetSeedlingItem ¶
type AssetSeedlingItem = sqlite.InsertAssetSeedlingIntoBatchParams
AssetSeedlingItem is used to insert a seedling into an asset based on the batch key of the batch.
type AssetSeedlingShell ¶
type AssetSeedlingShell = sqlite.InsertAssetSeedlingParams
AssetSeedlingShell holds the components of a seedling asset.
type AssetSpendDelta ¶
type AssetSpendDelta = sqlite.ApplySpendDeltaParams
AssetSpendDelta is used to update the script key and amount of an existing asset.
type AssetSprout ¶
type AssetSprout = sqlite.FetchAssetsForBatchRow
AssetSprout is used to fetch the set of assets from disk.
type AssetStore ¶
type AssetStore struct {
// contains filtered or unexported fields
}
AssetStore is used to query for the set of pending and confirmed assets.
func NewAssetStore ¶
func NewAssetStore(db BatchedAssetStore) *AssetStore
NewAssetStore creates a new AssetStore from the specified BatchedAssetStore interface.
func (*AssetStore) ConfirmParcelDelivery ¶
func (a *AssetStore) ConfirmParcelDelivery(ctx context.Context, conf *tarofreighter.AssetConfirmEvent) error
ConfirmParcelDelivery marks a spend event on disk as confirmed. This updates the on-chain reference information on disk to point to this new spend.
func (*AssetStore) FetchAllAssets ¶
func (a *AssetStore) FetchAllAssets(ctx context.Context, query *AssetQueryFilters) ([]*ChainAsset, error)
FetchAllAssets fetches the set of confirmed assets stored on disk.
func (*AssetStore) FetchAssetProofs ¶
func (a *AssetStore) FetchAssetProofs(ctx context.Context, targetAssets ...*btcec.PublicKey) (proof.AssetBlobs, error)
FetchAssetProofs returns the latest proof file for either the set of target assets, or all assets if no script keys for an asset are passed in.
TODO(roasbeef): potentially have a version that writes thru a reader instead?
func (*AssetStore) FetchProof ¶
FetchProof fetches a proof for an asset uniquely idenfitied by the passed ProofIdentifier.
NOTE: This implements the proof.ArchiveBackend interface.
func (*AssetStore) ImportProofs ¶
func (a *AssetStore) ImportProofs(ctx context.Context, proofs ...*proof.AnnotatedProof) error
ImportProofs attempts to store fully populated proofs on disk. The previous outpoint of the first state transition will be used as the Genesis point. The final resting place of the asset will be used as the script key itself.
NOTE: This implements the proof.ArchiveBackend interface.
func (*AssetStore) LogPendingParcel ¶
func (a *AssetStore) LogPendingParcel(ctx context.Context, spend *tarofreighter.OutboundParcelDelta) error
TODO(jhb): Update for new table LogPendingParcel marks an outbound parcel as pending on disk. This commits the set of changes to disk (the asset deltas) but doesn't mark the batched spend as being finalized.
func (*AssetStore) PendingParcels ¶
func (a *AssetStore) PendingParcels( ctx context.Context) ([]*tarofreighter.OutboundParcelDelta, error)
PendingParcels returns the set of parcels that haven't yet been finalized. This can be used to query the set of unconfirmed transactions for re-broadcast.
func (*AssetStore) QueryAssetBalancesByFamily ¶
func (a *AssetStore) QueryAssetBalancesByFamily(ctx context.Context, famKey *btcec.PublicKey) (map[asset.SerializedKey]AssetFamilyBalance, error)
QueryAssetBalancesByFamily queries the asset balances for asset families or alternatively for a selected one that matches the passed filter.
func (*AssetStore) QueryBalancesByAsset ¶
func (a *AssetStore) QueryBalancesByAsset(ctx context.Context, assetID *asset.ID) (map[asset.ID]AssetBalance, error)
QueryBalancesByAsset queries the balances for assets or alternatively for a selected one that matches the passed asset ID filter.
func (*AssetStore) QueryParcels ¶
func (a *AssetStore) QueryParcels(ctx context.Context, pending bool) ([]*tarofreighter.OutboundParcelDelta, error)
QueryParcels returns the set of confirmed or unconformed parcels.
func (*AssetStore) SelectCommitment ¶
func (a *AssetStore) SelectCommitment( ctx context.Context, constraints tarofreighter.CommitmentConstraints, ) ([]*tarofreighter.AnchoredCommitment, error)
SelectCommitment takes the set of commitment contrarians and returns an AnchoredCommitment that returns all the information needed to use the commitment as an input to an on chain taro transaction.
NOTE: This implements the tarofreighter.CommitmentSelector interface.
type AssetStoreTxOptions ¶
type AssetStoreTxOptions struct {
// contains filtered or unexported fields
}
AssetStoreTxOptions defines the set of db txn options the PendingAssetStore understands.
func NewAddrBookReadTx ¶
func NewAddrBookReadTx() AssetStoreTxOptions
NewAddrBookReadTx creates a new read transaction option set.
func NewAssetStoreReadTx ¶
func NewAssetStoreReadTx() AssetStoreTxOptions
NewAssetStoreReadTx creates a new read transaction option set.
func (*AssetStoreTxOptions) ReadOnly ¶
func (r *AssetStoreTxOptions) ReadOnly() bool
ReadOnly returns true if the transaction should be read only.
NOTE: This implements the TxOptions
type AssetTransfer ¶
type AssetTransfer = sqlite.QueryAssetTransfersRow
AssetTransfer packages information related to an asset transfer.
type AssetWitness ¶
type AssetWitness = sqlite.FetchAssetWitnessesRow
AssetWitness is the full prev input for an asset that also couples along the asset ID that the witness belong to.
type BatchChainUpdate ¶
type BatchChainUpdate = sqlite.BindMintingBatchWithTxParams
BatchChainUpdate is used to update a batch with the minting transaction associated with it.
type BatchStateUpdate ¶
type BatchStateUpdate = sqlite.UpdateMintingBatchStateParams
BatchStateUpdate holds the arguments to updated the state of a batch.
type BatchedAddrBook ¶
BatchedAddrBook is a version of the AddrBook that's capable of batched database operations.
type BatchedAssetStore ¶
type BatchedAssetStore interface { ActiveAssetsStore BatchedTx[ActiveAssetsStore, TxOptions] }
BatchedAssetStore combines the AssetStore interface with the BatchedTx interface, allowing for multiple queries to be executed in a single SQL transaction.
type BatchedKeyStore ¶
type BatchedKeyStore interface { KeyStore // Parametrize the BatchedTx generic interface w/ KeyStore, which // allows us to perform operations to the key store in an atomic // transaction. Also add in the TxOptions interface which our defined // KeyStoreTxOptions satisfies. BatchedTx[KeyStore, TxOptions] }
BatchedKeyStore is the main storage interface for the RootKeyStore. It supports all the basic queries as well as running the set of queries in a single database transaction.
TODO(roasbeef) use type params here to use slimmer interface instead of sqlite.Querier?
type BatchedPendingAssetStore ¶
type BatchedPendingAssetStore interface { PendingAssetStore BatchedTx[PendingAssetStore, TxOptions] }
BatchedPendingAssetStore combines the PendingAssetStore interface with the BatchedTx interface, allowing for multiple queries to be executed in a single SQL transaction.
type BatchedQuerier ¶
type BatchedQuerier[O TxOptions] interface { // Querier is the underlying query source, this is in place so we can // pass a BatchedQuerier implementation directly into objects that // create a batched version of the normal methods they need. sqlite.Querier // BeginTx creates a new database transaction given the set of // transaction options. BeginTx(ctx context.Context, options O) (Tx, error) }
BatchedQuerier is a generic interface that allows callers to create a new database transaction based on an abstract type that implements the TxOptions interface.
TODO(roasbeef): just enough to pass in the interface here and drop the constraint? unclear if need additional flexibility given the sqlitestore.BeginTx method?
type BatchedTreeStore ¶
BatchedTreeStore is a version of the AddrBook that's capable of batched database operations.
type BatchedTx ¶
type BatchedTx[Q any, O TxOptions] interface { // ExecTx will execute the passed txBody, operating upon generic // parameter Q (usually a storage interface) in a single transaction. // The set of TxOptions are passed in in order to allow the caller to // specify if a transaction should be read-only and optionally what // type of concurrency control should be used. ExecTx(ctx context.Context, txOptions O, txBody func(Q) error) error }
BatchedTx is a generic interface that represents the ability to execute several operations to a given storage interface in a single atomic transaction. Typically Q here will be some subset of the main sqlite.Querier interface allowing it to only depend on the routines it needs to implement any additional business logic.
type ChainAsset ¶
type ChainAsset struct { *asset.Asset // AnchorTx is the transaction that anchors this chain asset. AnchorTx *wire.MsgTx // AnchorTxid is the TXID of the anchor tx. AnchorTxid chainhash.Hash // AnchorBlockHash is the blockhash that mined the anchor tx. AnchorBlockHash chainhash.Hash // AnchorOutpoint is the outpoint that commits to the asset. AnchorOutpoint wire.OutPoint // AnchorInternalKey is the raw internal key that was used to create the // anchor Taproot output key. AnchorInternalKey *btcec.PublicKey }
ChainAsset is a wrapper around the base asset struct that includes information detailing where in the chain the asset is currently anchored.
type ChainTx ¶
type ChainTx = sqlite.UpsertChainTxParams
ChainTx is used to insert a new chain tx on disk.
type ChainTxConf ¶
type ChainTxConf = sqlite.ConfirmChainTxParams
ChainTxConf is used to mark a chain tx as being confirmed.
type ChildQuery ¶
type ChildQuery = sqlite.FetchChildrenParams
ChildQuery wraps the args we need to fetch the children of a node.
type ConfirmedAsset ¶
type ConfirmedAsset = sqlite.QueryAssetsRow
ConfirmedAsset is an asset that has been fully confirmed on chain.
type DelNode ¶
type DelNode = sqlite.DeleteNodeParams
DelNode wraps the args we need to delete a node.
type FetchGenesisStore ¶
type FetchGenesisStore interface { // FetchGenesisByID returns a single genesis asset by its primary key // ID. FetchGenesisByID(ctx context.Context, assetID int32) (Genesis, error) }
FetchGenesisStore houses the methods related to fetching genesis assets.
type Genesis ¶
type Genesis = sqlite.FetchGenesisByIDRow
Genesis is a type alias for fetching the genesis asset information.
type GenesisAsset ¶
type GenesisAsset = sqlite.UpsertGenesisAssetParams
GenesisAsset is used to insert the base information of an asset into the DB.
type GenesisPointAnchor ¶
type GenesisPointAnchor = sqlite.AnchorGenesisPointParams
GenesisPointAnchor is used to update the genesis point with the final information w.r.t where its confirmed on chain.
type GenesisTxUpdate ¶
type GenesisTxUpdate = sqlite.UpdateBatchGenesisTxParams
GenesisTxUpdate is used to update the existing batch TX associated with a batch.
type InternalKey ¶
type InternalKey = sqlite.UpsertInternalKeyParams
InternalKey holds the arguments to update an internal key.
type KeyStore ¶
type KeyStore interface { // GetRootKey fetches the root key associated with the passed ID. GetRootKey(ctx context.Context, id []byte) (MacaroonRootKey, error) // InsertRootKeyParams inserts a new (id, rootKey) tuple into the // database. InsertRootKey(ctx context.Context, arg MacaroonID) error }
KeyStore represents access to a persistence key store for macaroon root key IDs.
type KeyStoreTxOptions ¶
type KeyStoreTxOptions struct {
// contains filtered or unexported fields
}
KeyStoreTxOptions defines the set of db txn options the KeyStore understands.
func (*KeyStoreTxOptions) ReadOnly ¶
func (r *KeyStoreTxOptions) ReadOnly() bool
ReadOnly returns true if the transaction should be read only.
NOTE: This implements the TxOptions
type MacaroonID ¶
type MacaroonID = sqlite.InsertRootKeyParams
MacaroonID is used to insert new (id, rootKey) into the database.
type MacaroonRootKey ¶
MacaroonRootKey is a tuple of (id, rootKey) that is used to validate + create macaroons.
type MintingBatch ¶
type MintingBatch = sqlite.FetchMintingBatchesByStateRow
MintingBatch is an alias for a minting batch including the internal key info.
type MintingBatchI ¶
type MintingBatchI = sqlite.FetchMintingBatchesByInverseStateRow
MintingBatchI is an alias for a minting batch including the internal key info. This is used to query for batches where the state doesn't match a certain value.
type MintingBatchInit ¶
type MintingBatchInit = sqlite.NewMintingBatchParams
MintingBatchInit is used to create a new minting batch.
type MintingBatchTuple ¶
type MintingBatchTuple = sqlite.UpdateMintingBatchStateParams
MintingBatchTuple is used to update a batch state based on the raw key.
type NewAddr ¶
type NewAddr = sqlite.InsertAddrParams
NewAddr is a type alias for the params to create a new address.
type NewAssetDelta ¶
type NewAssetDelta = sqlite.InsertAssetDeltaParams
NewAssetDelta wraps the params needed to insert a new asset delta.
type NewAssetTransfer ¶
type NewAssetTransfer = sqlite.InsertAssetTransferParams
NewAssetTransfer wraps the params needed to insert a new asset transfer.
type NewBranch ¶
type NewBranch = sqlite.InsertBranchParams
NewBranch is a type alias for the params to create a new mssmt branch node.
type NewCompactedLeaf ¶
type NewCompactedLeaf = sqlite.InsertCompactedLeafParams
NewCompactedLeaf is a type alias for the params to create a new mssmt compacted leaf node.
type NewLeaf ¶
type NewLeaf = sqlite.InsertLeafParams
NewLeaf is a type alias for the params to create a new mssmt leaf node.
type NewScriptKey ¶
type NewScriptKey = sqlite.UpsertScriptKeyParams
NewScriptKey wraps the params needed to insert a new script key on disk.
type NewSpendProof ¶
type NewSpendProof = sqlite.InsertSpendProofsParams
NewSpendProof is used to insert new spend proofs for the sender+receiver.
type PendingAssetStore ¶
type PendingAssetStore interface { // UpsertAssetStore houses the methods related to inserting/updating // assets. UpsertAssetStore // NewMintingBatch creates a new minting batch. NewMintingBatch(ctx context.Context, arg MintingBatchInit) error // UpdateMintingBatchState updates the state of an existing minting // batch. UpdateMintingBatchState(ctx context.Context, arg BatchStateUpdate) error // InsertAssetSeedling inserts a new asset seedling (base description) // into the database. InsertAssetSeedling(ctx context.Context, arg AssetSeedlingShell) error // InsertAssetSeedlingIntoBatch inserts a new asset seedling into a // batch based on the batch key its included in. InsertAssetSeedlingIntoBatch(ctx context.Context, arg AssetSeedlingItem) error // FetchMintingBatchesByState is used to fetch minting batches with a // particular state. FetchMintingBatchesByState(ctx context.Context, batchState int16) ([]MintingBatch, error) // FetchMintingBatchesByInverseState is used to fetch minting batches // that don't have a particular state. FetchMintingBatchesByInverseState(ctx context.Context, batchState int16) ([]MintingBatchI, error) // FetchSeedlingsForBatch is used to fetch all the seedlings by the key // of the batch they're included in. FetchSeedlingsForBatch(ctx context.Context, rawKey []byte) ([]AssetSeedling, error) // BindMintingBatchWithTx adds the minting transaction to an existing // batch. BindMintingBatchWithTx(ctx context.Context, arg BatchChainUpdate) error // UpdateBatchGenesisTx updates the batch tx attached to an existing // batch. UpdateBatchGenesisTx(ctx context.Context, arg GenesisTxUpdate) error // UpsertManagedUTXO inserts a new or updates an existing managed UTXO // to disk and returns the primary key. UpsertManagedUTXO(ctx context.Context, arg RawManagedUTXO) (int32, error) // AnchorPendingAssets associated an asset on disk with the transaction // that once confirmed will mint the asset. AnchorPendingAssets(ctx context.Context, arg AssetAnchor) error // AnchorGenesisPoint associates a genesis point with the transaction // that mints the associated assets on disk. AnchorGenesisPoint(ctx context.Context, arg GenesisPointAnchor) error // UpsertChainTx inserts a new or updates an existing chain tx into the // DB. UpsertChainTx(ctx context.Context, arg ChainTx) (int32, error) // ConfirmChainTx confirms an existing chain tx. ConfirmChainTx(ctx context.Context, arg ChainTxConf) error // FetchAssetsForBatch fetches all the assets created by a particular // batch. FetchAssetsForBatch(ctx context.Context, rawKey []byte) ([]AssetSprout, error) // UpsertAssetProof inserts a new or updates an existing asset proof on // disk. // // TODO(roasbeef): move somewhere else?? UpsertAssetProof(ctx context.Context, arg sqlite.UpsertAssetProofParams) error }
PendingAssetStore is a sub-set of the main sqlite.Querier interface that contains only the methods needed to drive the process of batching and creating a new set of assets.
type PrevInput ¶
type PrevInput = sqlite.InsertAssetWitnessParams
PrevInput stores the full input information including the prev out, and also the witness information itself.
type ProofUpdate ¶
type ProofUpdate = sqlite.UpsertAssetProofParams
ProofUpdate is used to update a proof file on disk.
type QueryAssetFilters ¶
type QueryAssetFilters = sqlite.QueryAssetsParams
QueryAssetFilters lets us query assets in the database based on some set filters. This is useful to get the balance of a set of assets, or for things like coin selection.
type QueryCreator ¶
QueryCreator is a generic function that's used to create a Querier, which is a type of interface that implements storage related methods from a database transaction. This will be used to instantiate an object callers can use to apply multiple modifications to an object interface in a single atomic transaction.
type RawAssetBalance ¶
type RawAssetBalance = sqlite.QueryAssetBalancesByAssetRow
RawAssetBalance holds a balance query result for a particular asset or all assets tracked by this daemon.
type RawAssetFamilyBalance ¶
type RawAssetFamilyBalance = sqlite.QueryAssetBalancesByFamilyRow
RawAssetFamilyBalance holds a balance query result for a particular asset family or all asset families tracked by this daemon.
type RawManagedUTXO ¶
type RawManagedUTXO = sqlite.UpsertManagedUTXOParams
RawManagedUTXO is used to insert a new managed UTXO into the database.
type RootKeyStore ¶
type RootKeyStore struct {
// contains filtered or unexported fields
}
RootKeyStore is an implementation of the bakery.RootKeyStore interface that'll be used to store macaroons for the project. This uses the sql.Querier interface to have access to the set of storage routines we need to implement the interface.
func NewRootKeyStore ¶
func NewRootKeyStore(db BatchedKeyStore) *RootKeyStore
NewRootKeyStore creates a new RKS from the passed querier interface.
type SqliteConfig ¶
type SqliteConfig struct { // CreateTables if true, then all the tables will be created on start // up if they don't already exist. CreateTables bool // DatabaseFileName is the full file path where the database file can be // found. DatabaseFileName string }
SqliteConfig holds all the config arguments needed to interact with our sqlite DB.
type SqliteStore ¶
SqliteStore is a sqlite3 based database for the taro daemon.
TODO(roasbeef): can type params out the main interface and db here to also support postgres?
func NewSqliteStore ¶
func NewSqliteStore(cfg *SqliteConfig) (*SqliteStore, error)
NewSqliteStore attempts to open a new sqlite database based on the passed config.
func NewTestSqliteDB ¶
func NewTestSqliteDB(t *testing.T) *SqliteStore
NewTestSqliteDB is a helper function that creates
type StoredNode ¶
type StoredNode = sqlite.FetchChildrenRow
StoredNode is a type alias for an arbitrary child of an mssmt branch.
type TaroAddressBook ¶
type TaroAddressBook struct {
// contains filtered or unexported fields
}
TaroAddressBook represents a storage backend for all the Taro addresses a daemon has created.
func NewTaroAddressBook ¶
func NewTaroAddressBook(db BatchedAddrBook, params *address.ChainParams) *TaroAddressBook
NewTaroAddressBook creates a new TaroAddressBook instance given a open BatchedAddrBook storage backend.
func (*TaroAddressBook) AddrByTaprootOutput ¶
func (t *TaroAddressBook) AddrByTaprootOutput(ctx context.Context, key *btcec.PublicKey) (*address.AddrWithKeyInfo, error)
AddrByTaprootOutput returns a single address based on its Taproot output key or a sql.ErrNoRows error if no such address exists.
func (*TaroAddressBook) CompleteEvent ¶
func (t *TaroAddressBook) CompleteEvent(ctx context.Context, event *address.Event, status address.Status, anchorPoint wire.OutPoint) error
CompleteEvent updates an address event as being complete and links it with the proof and asset that was imported/created for it.
func (*TaroAddressBook) GetOrCreateEvent ¶
func (t *TaroAddressBook) GetOrCreateEvent(ctx context.Context, status address.Status, addr *address.AddrWithKeyInfo, walletTx *lndclient.Transaction, outputIdx uint32, tapscriptSibling *chainhash.Hash) (*address.Event, error)
GetOrCreateEvent creates a new address event for the given status, address and transaction. If an event for that address and transaction already exists, then the status and transaction information is updated instead.
func (*TaroAddressBook) InsertAddrs ¶
func (t *TaroAddressBook) InsertAddrs(ctx context.Context, addrs ...address.AddrWithKeyInfo) error
InsertAddrs inserts a new address into the database.
func (*TaroAddressBook) QueryAddrEvents ¶
func (t *TaroAddressBook) QueryAddrEvents( ctx context.Context, params address.EventQueryParams) ([]*address.Event, error)
QueryAddrEvents returns a list of event that match the given query parameters.
func (*TaroAddressBook) QueryAddrs ¶
func (t *TaroAddressBook) QueryAddrs(ctx context.Context, params address.QueryParams) ([]address.AddrWithKeyInfo, error)
QueryAddrs attempts to query for the set of addresses on disk given the passed set of query params.
func (*TaroAddressBook) SetAddrManaged ¶
func (t *TaroAddressBook) SetAddrManaged(ctx context.Context, addr *address.AddrWithKeyInfo, managedFrom time.Time) error
SetAddrManaged sets an address as being managed by the internal wallet.
type TaroTreeStore ¶
type TaroTreeStore struct {
// contains filtered or unexported fields
}
TaroTreeStore is an persistent MS-SMT implementation backed by a live SQL database.
func NewTaroTreeStore ¶
func NewTaroTreeStore(db BatchedTreeStore, namespace string) *TaroTreeStore
NewTaroAddressBook creates a new TaroTreeStore instance given a open BatchedTreeStore storage backend. The namespace argument is required, as it allow us to store several distinct trees on disk in the same table.
func (*TaroTreeStore) Update ¶
func (t *TaroTreeStore) Update(ctx context.Context, update func(tx mssmt.TreeStoreUpdateTx) error) error
Update updates the persistent tree in the passed update closure using the update transaction.
func (*TaroTreeStore) View ¶
func (t *TaroTreeStore) View(ctx context.Context, update func(tx mssmt.TreeStoreViewTx) error) error
View gives a view of the persistent tree in the passed view closure using the view transaction.
type TransactionExecutor ¶
type TransactionExecutor[Query any, TxOpts TxOptions] struct { BatchedQuerier[TxOpts] // contains filtered or unexported fields }
TransactionExecutor is a generic struct that abstracts away from the type of query a type needs to run under a database transaction, and also the set of options for that transaction. The QueryCreator is used to create a query given a database transaction created by the BatchedQuerier.
func NewTransactionExecutor ¶
func NewTransactionExecutor[Querier any, TxOpts TxOptions]( db BatchedQuerier[TxOpts], createQuery QueryCreator[Querier]) *TransactionExecutor[Querier, TxOpts]
NewTransactionExecutor creates a new instance of a TransactionExecutor given a Querier query object and a concrete type for the type of transactions the Querier understands.
func (*TransactionExecutor[Q, O]) ExecTx ¶
func (t *TransactionExecutor[Q, O]) ExecTx(ctx context.Context, txOptions O, txBody func(Q) error) error
ExecTx is a wrapper for txBody to abstract the creation and commit of a db transaction. The db transaction is embedded in a `*Queries` that txBody needs to use when executing each one of the queries that need to be applied atomically. This can be used by other storage interfaces to parameterize the type of query and options run, in order to have access to batched operations related to a storage object.
type TransferQuery ¶
type TransferQuery = sqlite.QueryAssetTransfersParams
TransferQuery allows callers to filter out the set of transfers based on set information.
type TreeStore ¶
type TreeStore interface { // InsertBranch inserts a new branch to the store. InsertBranch(ctx context.Context, newNode NewBranch) error // InsertLeaf inserts a new leaf to the store. InsertLeaf(ctx context.Context, newNode NewLeaf) error // InsertCompactedLeaf inserts a new compacted leaf to the store. InsertCompactedLeaf(ctx context.Context, newNode NewCompactedLeaf) error // FetchChildren fetches the children (at most two currently) of the // passed branch hash key. FetchChildren(ctx context.Context, c ChildQuery) ([]StoredNode, error) // DeleteNode deletes a node (can be either branch, leaf of compacted // leaf) from the store. DeleteNode(ctx context.Context, n DelNode) (int64, error) // FetchRootNode fetches the root node for the specified namespace. FetchRootNode(ctx context.Context, namespace string) (sqlite.MssmtNode, error) // UpsertRootNode allows us to update the root node in place for a // given namespace. UpsertRootNode(ctx context.Context, arg UpdateRoot) error }
TreeStore is a sub-set of the main sqlite.Querier interface that contains only the methods needed to manipulate and query stored MSSMT trees.
type TreeStoreTxOptions ¶
type TreeStoreTxOptions struct {
// contains filtered or unexported fields
}
func NewTreeStoreReadTx ¶
func NewTreeStoreReadTx() TreeStoreTxOptions
NewTreeStoreReadTx creates a new read transaction option set.
func (*TreeStoreTxOptions) ReadOnly ¶
func (t *TreeStoreTxOptions) ReadOnly() bool
ReadOnly returns true if the transaction should be read only.
NOTE: This implements the TxOptions
type Tx ¶
type Tx interface { // Commits the database transaction, an error should be returned if the // commit isn't possible. Commit() error // Rollback rolls back an incomplete database transaction. // Transactions that were able to be committed can still call this as a // noop. Rollback() error }
Tx represents a database transaction that can be committed or rolled back.
type TxOptions ¶
type TxOptions interface { // ReadOnly returns true if the transaction should be read only. ReadOnly() bool }
TxOptions represents a set of options one can use to control what type of database transaction is created. Transaction can wither be read or write.
type UpdateRoot ¶
type UpdateRoot = sqlite.UpsertRootNodeParams
UpdateRoot wraps the args we need to update a root node.
type UpsertAddrEvent ¶
type UpsertAddrEvent = sqlite.UpsertAddrEventParams
UpsertAddrEvent is a type alias for creating a new address event or updating an existing one.
type UpsertAssetStore ¶
type UpsertAssetStore interface { // UpsertGenesisPoint inserts a new or updates an existing genesis point // on disk, and returns the primary key. UpsertGenesisPoint(ctx context.Context, prevOut []byte) (int32, error) // UpsertGenesisAsset inserts a new or updates an existing genesis asset // (the base asset info) in the DB, and returns the primary key. // // TODO(roasbeef): hybrid version of the main tx interface that an // accept two diff storage interfaces? // // * or use a sort of mix-in type? UpsertGenesisAsset(ctx context.Context, arg GenesisAsset) (int32, error) // UpsertInternalKey inserts a new or updates an existing internal key // into the database. UpsertInternalKey(ctx context.Context, arg InternalKey) (int32, error) // UpsertScriptKey inserts a new script key on disk into the DB. UpsertScriptKey(context.Context, NewScriptKey) (int32, error) // UpsertAssetFamilySig inserts a new asset family sig into the DB. UpsertAssetFamilySig(ctx context.Context, arg AssetFamSig) (int32, error) // UpsertAssetFamilyKey inserts a new or updates an existing family key // on disk, and returns the primary key. UpsertAssetFamilyKey(ctx context.Context, arg AssetFamilyKey) (int32, error) // InsertNewAsset inserts a new asset on disk. InsertNewAsset(ctx context.Context, arg sqlite.InsertNewAssetParams) (int32, error) }
UpsertAssetStore is a sub-set of the main sqlite.Querier interface that contains methods related to inserting/updating assets.
type UtxoQuery ¶
type UtxoQuery = sqlite.FetchManagedUTXOParams
UtxoQuery lets us query a managed UTXO by either the transaction it references, or the outpoint.