lightninglabs / taproot-assets

A layer 1 daemon, for the Taproot Assets Protocol specification, written in Go (golang)
MIT License
470 stars 115 forks source link

[bug]: Minting New Batches of Grouped, Normal (Version 0) Assets when `--decimal_display` is Used #1228

Closed Nsandomeno closed 2 hours ago

Nsandomeno commented 2 hours ago

Background

I'm attempting to mint a subsequent batch of a normal, Version 0 asset where --decimal_display was used in the initial batches mint command. There was no meta_bytes associated with the original mint either.

Using the proper group key, it does not appear there is anyway for the next group of the asset, in a different batch, to inherit the --decimal_display setting of the initially minted group.

Your environment

Lightning Terminal integrated mode v0.13.993-exp

tapcli getinfo                       # version of `tapd`, `lnd`, and network

{
    "version":  "0.4.1-alpha commit=v0.4.2-0.20240815180811-2110839696cb",
    "lnd_version":  "0.18.0-beta",
    "network":  "regtest",
    "lnd_identity_pubkey":  "028d846445f80f8f53385b36f3d1217b3cc10d066221e7a95fc3a1823eb26ff0ac",
    "node_alias":  "alice",
    "block_height":  291,
    "block_hash":  "255f55c955c1392c4cfbfc94ad3bfcea7ad69d2e8d9763244eaa588fda6cb4cc",
    "sync_to_chain":  true
}

uname -mrsv                          # operating system 

Linux 5.15.49-linuxkit-pr #1 SMP Thu May 25 07:17:40 UTC 2023 x86_64

bitcoind --version || btcd --version # version of `btcd`, `bitcoind`, or other backend

Polar default.

Steps to reproduce

(1) Mint the first batch, with the initial group of the asset

tapcli assets mint --type normal --name regtestCoin --supply 100000000000 --new_grouped_asset true --decimal_display 4

(2) Finalize the batch and mine some blocks.

(3) Attempt to mint the second group of the asset in a new batch. The error output indicates that the decimal_display should be 0 (incorrectly)

litd@alice:/$ tapcli assets mint --type normal --name regtestCoin --supply 100000000 --decimal_display 4 --grouped_asset --group_key 036c5e19efc591dd1e63f209b7431499bc82e5ffa7ba3
bea2f32f79282acfc362c --meta_type json --meta_bytes '{"decimal_display": 4}'

[tapcli] unable to mint asset: rpc error: code = Unknown desc = unable to mint asset: seedling decimal display does not match group anchor: 4, 0

(4) A second attempt to mint the second group, using a decimal_display of 0 works

litd@alice:/$ tapcli assets mint --type normal --name depixTestnet1 --supply 100000000 --grouped_asset --group_key 036c5e19efc591dd1e63f209b7431499bc82e5ffa7ba3bea2f32f79282acfc362c --meta_type json --meta_bytes '{"decimal_display": 0}'

{
    "pending_batch":  {
        "batch_key":  "034432ecf70ecac7396ac0fb2d95a09f0722798c60d149afe29423577de050bb85",
        "batch_txid":  "",
        "state":  "BATCH_STATE_PENDING",

        ...

Expected behavior

Expect step (3) from above to work and step (4) from above to return the error message returned from step (3).

Actual behavior

The output indicates that the daemon expects the new group to have a decimal_display of 0, potentially looking down a path of group_anchor rather than group_key.

guggero commented 2 hours ago

Thanks for the report.

Just a hunch, but I think the group anchor isn't created correctly because there's a parameter too much. The command line library we use never takes true as an argument for a boolean flag. Just by specifying the flag itself you turn it on or set it to true (all boolean flag are by default false because of that). So --new_grouped_asset true probably causes the parser to think the flags are done and interprets true as the first non-flag parameter (then ignoring --decimal_display 4).

Could you please test if that's the case? So just replace --new_grouped_asset true with --new_grouped_asset.

Nsandomeno commented 2 hours ago

@guggero Thanks for the snappy response!

Your suggestion satisfied what I was trying to achieve.