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

"asset_entropy" wrong or missing for issuances #99

Closed
valerio-vaccaro opened this issue Jun 19, 2019 · 3 comments
Closed

"asset_entropy" wrong or missing for issuances #99

valerio-vaccaro opened this issue Jun 19, 2019 · 3 comments

Comments

@valerio-vaccaro
Copy link
Contributor

In order to validate an issuance transaction, the liquid-core give you the asset_entropy value that you can use to calculate asset_id and reissuance_token_id. Esplora shows you this information via the API but the value is missing or wrong.

e.g.issuance tx a89e97e9eec81802d65a8f013133267705c2bd249d46ba85f77cdf52778a0ffb

issuance tx d535ded7ce07a0bb9c61d0fefff8127da3fc4833302b05e2b8a0cf9e04446af1

@shesek
Copy link
Collaborator

shesek commented Jun 21, 2019

The mismatch is due to a somewhat confusing terminology used in rust-elements and cpp-elements that spilled into esplora.

In rust-elements, for initial issuances, the asset_entropy field of the AssetIssuance struct contains the user-provided entropy from the issuance transaction as-is, which is typically referred to as the "contract hash" in cpp-elements. The default entropy, if none was provided by the issuer, is 32 0x00 bytes. The null value signifies that the default value was used (this might be a bit confusing, perhaps I should change that to return the raw zerod-out bytes instead?).

The user-provided entropy is then hashed (using the fast merkle root algo) with the outpoint being spent by the issuance input to arrive at the asset entropy. cpp-elements's rpc converts the assetEntropy field on issuances from the user-provided entropy to the asset entropy before returning it in rpc replies, while esplora doesn't do that. (edit: I think I linked to the wrong code snippet, but it does do that conversion somewhere)

For re-issuances, the input contains the derived asset entropy directly, so there's no difference between cpp-elements and rust-elements.

There's an unmerged PR to rust-elements which implements the fast merkle root algorithm, as well as the conversion from user-provided entropy and outpoint into the asset entropy, and from the asset entropy to the asset id. I'm already using it on a development branch that extends esplora's support for issued assets. Among other things, it computes the asset entropy/id and adds an asset_id field to the issuance json. To be more in-line with cpp-elements's terminology, I'll rename the asset_entropy field to contract_hash and add a new asset_entropy field with the derived asset entropy.

But note that this will probably only be deployed on blockstream.info once the PR to rust-elements is merged. In the meanwhile, if you have a fast merkle root implementation in your environment (or willing to write one), you could compute the asset entropy yourself using the data currently available from the esplora api.

shesek added a commit to shesek/electrs that referenced this issue Jun 21, 2019
The issuance input JSON format was changed as following:

- Added a `contract_hash` field with the user-provided entropy of initial issuances.
  This field is not available for reissuances.

- Changed `asset_entropy` to contain the asset entropy derived from the user-provided
  entropy and the prevout. This only effects initial issuances.

Refs Blockstream/esplora#99
@shesek
Copy link
Collaborator

shesek commented Jun 21, 2019

Implemented the changes in shesek/electrs@5942c83.

shesek added a commit to shesek/esplora that referenced this issue Jun 21, 2019
shesek added a commit to shesek/electrs that referenced this issue Jun 23, 2019
The issuance input JSON format was changed as following:

- Added a `contract_hash` field with the user-provided entropy of initial issuances.
  This field is not available for reissuances.

- Changed `asset_entropy` to contain the asset entropy derived from the user-provided
  entropy and the prevout. This only effects initial issuances.

Refs Blockstream/esplora#99
shesek added a commit to shesek/esplora that referenced this issue Jun 24, 2019
shesek added a commit to shesek/electrs that referenced this issue Jun 24, 2019
The issuance input JSON format was changed as following:

- Added a `contract_hash` field with the user-provided entropy of initial issuances.
  This field is not available for reissuances.

- Changed `asset_entropy` to contain the asset entropy derived from the user-provided
  entropy and the prevout. This only effects initial issuances.

Refs Blockstream/esplora#99
shesek added a commit to shesek/electrs that referenced this issue Jun 29, 2019
The issuance input JSON format was changed as following:

- Added a `contract_hash` field with the user-provided entropy of initial issuances.
  This field is not available for reissuances.

- Changed `asset_entropy` to contain the asset entropy derived from the user-provided
  entropy and the prevout. This only effects initial issuances.

Refs Blockstream/esplora#99
shesek added a commit to shesek/esplora that referenced this issue Jul 2, 2019
shesek added a commit to shesek/esplora that referenced this issue Jul 6, 2019
@shesek
Copy link
Collaborator

shesek commented Jul 13, 2019

@valerio-vaccaro I'm closing, please report back if you're still having trouble.

@shesek shesek closed this as completed Jul 13, 2019
SatoKentaNayoro pushed a commit to boolnetwork/mempool-electrs that referenced this issue Nov 29, 2024
The issuance input JSON format was changed as following:

- Added a `contract_hash` field with the user-provided entropy of initial issuances.
  This field is not available for reissuances.

- Changed `asset_entropy` to contain the asset entropy derived from the user-provided
  entropy and the prevout. This only effects initial issuances.

Refs Blockstream/esplora#99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants