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

[bug]: Minting a normal asset with --decimal_display does not yield expected results #972

Closed
Liongrass opened this issue Jun 25, 2024 · 11 comments · Fixed by #979
Closed
Assignees
Labels
bug Something isn't working needs triage
Milestone

Comments

@Liongrass
Copy link
Contributor

Background

I minted a new asset with the flag: --decimal-display 3 but the created asset shows "decimal_display": 0

Your environment

litd integrated mode
branch: 0-19-staging
commit: fa32097a4d0deee7e84872690194d18f108cf5a5

Steps to reproduce

Command used:

tapcli --tlscertpath ~/.lit/tls.cert --rpcserver=localhost:8443 --network=testnet assets mint --type normal --name beefbux --supply 1000000 --decimal_display 3 --new_grouped_asset --meta_type json

tapcli assets mint finalize

Expected behavior

When running tapcli assets list, I expect to see the asset with its defined decimal display.

Actual behavior

The minted asset appears to have its decimal display set to 0:

        {
            "version":  "ASSET_VERSION_V0",
            "asset_genesis":  {
                "genesis_point":  "1fd2b57bbbaaae90d9015f7ea4b75413629aeb591fc789ad42c900d5a999f56a:1",
                "name":  "beefbux",
                "meta_hash":  "0000000000000000000000000000000000000000000000000000000000000000",
                "asset_id":  "9052f8837a836ee5d48b8609f78cb475aec480d2e58fe798b0d5b8354245e121",
                "asset_type":  "NORMAL",
                "output_index":  0
            },
            "amount":  "1000000",
            "lock_time":  0,
            "relative_lock_time":  0,
            "script_version":  0,
            "script_key":  "02c71287f4763bc86e7144933d586e534ea799b6530dd49909d78e7eb1c00baaa7",
            "script_key_is_local":  true,
            "asset_group":  {
                "raw_group_key":  "029b811d7ef954704bf07c949f0464b680224a808468fd13d391c9141d9046459c",
                "tweaked_group_key":  "02e446b1ee2e362a75fa94f2ed02a2653df979225d8d68c79ae0643e7fcb317f64",
                "asset_witness":  "0140fd75b9eb5b1840b426eb1b3248f0038e8d38665c12bab4e7817322d517eef6ab86675433edf171e7e9bfb52315d20265b40e4ab28638cd2388212e68bc656032",
                "tapscript_root":  ""
            },
            "chain_anchor":  {
                "anchor_tx":  "020000000001016af599a9d500c942ad89c71f59eb9a621354b7a47e5f01d990aeaabb7bb5d21f01000000000000000002e80300000000000022512082bcb8523d1c7ecf7a156c452df083144ffd7d0691f0c5314f5c1586476343a4704b0a02000000002251209423066211c876f9ba1709678567091e9c750747747625b2c4725a68944a4d5301408391f5c0f3d4873c48d83d20bb9749b2f709f0dff5e6b37df995f81372e73d926d3d80c73bb25dd66d35c36922a5c180bc824730224ff369869f397c3110d98900000000",
                "anchor_block_hash":  "0000000000000000000000000000000000000000000000000000000000000000",
                "anchor_outpoint":  "f939a83cf71a7d8d743a989e81ad9c292f4e6c4f7c3bc5639313cd1739a15363:0",
                "internal_key":  "03b7484d5f0c6102cb58c016186fe28f8e7bc007c6d859eaa3b206534098e3c14d",
                "merkle_root":  "a376b5e1cd538fd5c4c1426bda4621d02c5c0924c5ff689dcc59712efc291255",
                "tapscript_sibling":  "",
                "block_height":  0
            },
            "prev_witnesses":  [],
            "is_spent":  false,
            "lease_owner":  "",
            "lease_expiry":  "0",
            "is_burn":  false,
            "script_key_declared_known":  false,
            "script_key_has_script_path":  false,
            "decimal_display":  {
                "decimal_display":  0
            }
        }

Maybe unrelated, but I also don't understand why the block height appears to be zero (and the block hash is empty). The minting transaction had over 2000 confirmations at the time when I pulled the above data: f939a83cf71a7d8d743a989e81ad9c292f4e6c4f7c3bc5639313cd1739a15363

@Liongrass Liongrass added bug Something isn't working needs triage labels Jun 25, 2024
@dstadulis dstadulis added this to the v0.4 milestone Jun 26, 2024
@jharveyb
Copy link
Collaborator

The bit with block height displayed as 0 has come up in the Slack as a surprise + issue that requires user workarounds.

@jharveyb
Copy link
Collaborator

Looks like this is from not having any metadata set for this mint call; I assumed that a caller setting a decimal display would also include some other metadata. If no metadata exsists we end up skipping the logic to add the decimal display.

IMO the correct behavior here is to have the decimal_display as the sole JSON object. Implemented in #979 .

@Liongrass
Copy link
Contributor Author

Classic user error!

I first tried adding metadata with the --meta_bytes flag but that wasn't allowed, so I removed that flag and set --meta_type json
Could you help me craft a sample json file for my guides?

@jharveyb
Copy link
Collaborator

Hmm, adding metadata should have been allowed? If it was JSON, then decimal display should get added to that.

@Liongrass
Copy link
Contributor Author

This is the error I run into for the command:

tapcli assets mint --type normal --name beefbux --supply 1000000 --decimal_display 3 --meta_bytes 66616e746173746963206d6f6e6579 --new_grouped_asset

[tapcli] unable to mint asset: rpc error: code = Unknown desc = cannot set decimal display if meta type is not JSON

@Roasbeef
Copy link
Member

@jharveyb so we should be assuming that if decimal display is set, then we use the json meta type.

@Roasbeef
Copy link
Member

@Liongrass do things work if you add --meta_type json back to the set of flags?

@Liongrass
Copy link
Contributor Author

I wasn't able to set --meta_bytes 66616e746173746963206d6f6e6579 and --meta_type json at the same time, and when I only set --meta_type json the decimal_display ended up set to zero

@jharveyb
Copy link
Collaborator

jharveyb commented Jun 28, 2024

@Liongrass

Quick tools to encode & decode JSON to hex.

Encode:

echo -n '{"hello":"world"}' | hexdump -v -e '/1 "%02X"'

7B2268656C6C6F223A22776F726C64227D

Decode:

echo 7B2268656C6C6F223A22776F726C64227D | xxd -r -p

{"hello":"world"}

@Liongrass
Copy link
Contributor Author

Hm I was using a tool similar to this, but my main question is whether I have to pass the hex encoded string to tapd or the raw string. I tried with the hex encoded string first and got an error, but roasbeef instructed me to use the raw string

@jharveyb
Copy link
Collaborator

jharveyb commented Jul 1, 2024

Ah true, I forgot that tapd will encode it to bytes internally. I guess with this you could decode JSON for an already minted asset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

4 participants