Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tapdb - [feature]: add new associative table to track asset burns ListBurns #1095

Open
Roasbeef opened this issue Aug 20, 2024 · 0 comments · May be fixed by #1178
Open

tapdb - [feature]: add new associative table to track asset burns ListBurns #1095

Roasbeef opened this issue Aug 20, 2024 · 0 comments · May be fixed by #1178
Assignees
Labels

Comments

@Roasbeef
Copy link
Member

Is your feature request related to a problem? Please describe.

Today we have an easy way to burn assets, but no easy way to track all burns we've made for a given asset.

Describe the solution you'd like

With the way things work today, burns are just another transfer:

taproot-assets/rpcserver.go

Lines 3258 to 3282 in 420f246

fundResp, err := r.cfg.AssetWallet.FundBurn(
ctx, &tapsend.FundingDescriptor{
AssetSpecifier: assetSpecifier,
Amount: in.AmountToBurn,
},
)
if err != nil {
return nil, fmt.Errorf("error funding burn: %w", err)
}
// Now we can sign the packet and send it to the chain.
_, err = r.cfg.AssetWallet.SignVirtualPacket(fundResp.VPacket)
if err != nil {
return nil, fmt.Errorf("error signing packet: %w", err)
}
resp, err := r.cfg.ChainPorter.RequestShipment(
tapfreighter.NewPreSignedParcel(
[]*tappsbt.VPacket{fundResp.VPacket},
fundResp.InputCommitments,
),
)
if err != nil {
return nil, err
}

However, we don't have an easy/efficient way to scan the transfers table for all the burns we've done:

CREATE TABLE IF NOT EXISTS asset_transfers (
id INTEGER PRIMARY KEY,
height_hint INTEGER NOT NULL,
anchor_txn_id BIGINT NOT NULL REFERENCES chain_txns(txn_id),
transfer_time_unix TIMESTAMP NOT NULL
);

We should add a new associative table (that can store other meta data) that we add to each time we burn an asset. We should then create a set of queries to easily look up the set of burnt assets all time, for a given asset, etc, etc.

A draft table would look something like:

CREATE TABLE IF NOT EXISTS asset_burn_transfers (
     burn_id INTEGER PRIMARY KEY, 

     transfer_id BIGINT NOT NULL REFERENCES asset_transfers(id),
     
     note TEXT,

     asset_id BIGINT NOT NULL REFERENCES assets(asset_id),

     group_key_id BIGINT NOT NULL REFERENCES asset_groups(group_id) 
)

The note field can be used to store other metadata related to a burn.

Describe alternatives you've considered

A user can scan all the proof files on disk, to find those that end in a bug suffix, but this doesn't lend well to the creation of an automated system.

@Roasbeef Roasbeef added enhancement New feature or request transfers burning labels Aug 20, 2024
@dstadulis dstadulis added this to the v0.4.3 (temporary) milestone Sep 23, 2024
@Roasbeef Roasbeef changed the title tapdb - [feature]: add new associative table to track asset burns tapdb - [feature]: add new associative table to track asset burns ListBurns Oct 28, 2024
@GeorgeTsagk GeorgeTsagk linked a pull request Nov 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🏗 In progress
Development

Successfully merging a pull request may close this issue.

3 participants