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

liquid native asset id for regtest networks is static, must be retrieved from sidechain daemon #140

Open
philippem opened this issue Feb 7, 2025 · 0 comments

Comments

@philippem
Copy link
Collaborator

The native asset ids (L-BTC equivalent) for Liquid side chains is currently in a static lookup table https://github.com/Blockstream/electrs/blob/new-index/src/elements/asset.rs#L18

lazy_static! {
    pub static ref NATIVE_ASSET_ID: AssetId =
        "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d"
            .parse()
            .unwrap();
    pub static ref NATIVE_ASSET_ID_TESTNET: AssetId =
        "144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49"
            .parse()
            .unwrap();
    pub static ref NATIVE_ASSET_ID_REGTEST: AssetId =
        "5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225"
            .parse()
            .unwrap();
}

This asset id is used to identify the fees in Liquid transactions, which have explicit fee outputs spending the native asset.
See get_tx_fee at https://github.com/Blockstream/electrs/blob/new-index/src/util/fees.rs#L46


#[cfg(feature = "liquid")]
pub fn get_tx_fee(tx: &Transaction, _prevouts: &HashMap<u32, &TxOut>, network: Network) -> u64 {
    tx.fee_in(*network.native_asset())
}

A static asset id works for liquidv1, liquidtestnet, and elementsregtest (liquidregtest) networks, but doesn't work for any other network with non standard chain params, which are used to define the native asset id (see elements https://github.com/ElementsProject/elements/blob/master/src/chainparams.cpp#L928).

A result of this is that in custom test networks, the fee property for a transaction resource will be 0:

  "weight": 5229,
  "fee": 0,
  "status": {
    "confirmed": false
  },
  "discount_vsize": 191,
  "discount_weight": 762
}

For custom test networks, electrs should make a getsidechaininfo RPC call to the sidechain daemon and use the value of pegged_asset.

Example for liquid staging:

{
  "fedpegscript": "745c87635b21022944b3c8d83d743e83e12b8a5654a9a48d741bae19f0498dd390b038502666b021023927b2c7716358d4f46cc1f8ca753f35818f593bd62ab2e19137522c35d671b721024c726615f549b02ea1db0fd2ab1973bfe20c296aa4ef14f8979da609b88caa6121027d8facb30d8648cbcea166f6094d1631053800332469827f90c5338368e48e3d2102a5ffc6da600cf25ebc01c4dfbe8ba220a0d35615db1a2c306ba06a355c34902b2102ab5b0b8e18d0dd7933176bbe0d0883a360ade9f45403accf7bdfa9c5439514f62102b0ffa5f8a78dd356afecc371bd826acb3671d8627561289d89a627a121a9c2272102b3278e89c3d5c19cbe5956d4a70a93a3bb0da4e8598d13c034ec5d50cce06b542102b43e4bd6c19b984ef36db6a622eea478f955676fe26786c3141b001e8f91402c2102e5a7aedc7889cad6f14d4534b546cd55d1fde039b0dd1ccb4c58ceac246327f72102e5fe77826e39e69421a0b478419a984c45d94228702aeac2acd540839fd034742103595fa9737e2720b9f600926f2350b4b1315b2248b76ef27fa287022609caead82103f2bbf79daf114617f35e719c46790c301ade558c247ced15f745a40db256a1e62103f4f161336c18c9095aff80aa38ca0417c345f73c73937298d49859e5bf7066e02103fec9f90addc21da7fa30da1568c8a5432a2372e89e8616468d55196c6ea2a7a25f6702c00fb275522102aef2b8a39966d49183fdddaefdc75af6d81ea6d16f7aba745cc4855e88f830842102141d452c3deeb937efff9f3378cd50bbde0543b77bbc6df6fc0e0addbf5578c52103948d24a9622cb14b198aed0739783d7c03d74c32c05780a86b43429c65679def5368ae",
  "current_fedpeg_programs": [
    "0020051c5aaa9d09c4ff74778124a18647f347b759d513d6e029e87fc134aff90d86",
    "0020051c5aaa9d09c4ff74778124a18647f347b759d513d6e029e87fc134aff90d86"
  ],
  "current_fedpegscripts": [
    "5b21022944b3c8d83d743e83e12b8a5654a9a48d741bae19f0498dd390b038502666b021023927b2c7716358d4f46cc1f8ca753f35818f593bd62ab2e19137522c35d671b721024c726615f549b02ea1db0fd2ab1973bfe20c296aa4ef14f8979da609b88caa6121027d8facb30d8648cbcea166f6094d1631053800332469827f90c5338368e48e3d2102a5ffc6da600cf25ebc01c4dfbe8ba220a0d35615db1a2c306ba06a355c34902b2102ab5b0b8e18d0dd7933176bbe0d0883a360ade9f45403accf7bdfa9c5439514f62102b0ffa5f8a78dd356afecc371bd826acb3671d8627561289d89a627a121a9c2272102b3278e89c3d5c19cbe5956d4a70a93a3bb0da4e8598d13c034ec5d50cce06b542102b43e4bd6c19b984ef36db6a622eea478f955676fe26786c3141b001e8f91402c2102e5a7aedc7889cad6f14d4534b546cd55d1fde039b0dd1ccb4c58ceac246327f72102e5fe77826e39e69421a0b478419a984c45d94228702aeac2acd540839fd034742103595fa9737e2720b9f600926f2350b4b1315b2248b76ef27fa287022609caead82103f2bbf79daf114617f35e719c46790c301ade558c247ced15f745a40db256a1e6210226e364b607a78b600e46d376ac8848f0c3dd44a41602af46e210f5aac755f5812103fec9f90addc21da7fa30da1568c8a5432a2372e89e8616468d55196c6ea2a7a25fae736402c00fb269522102aef2b8a39966d49183fdddaefdc75af6d81ea6d16f7aba745cc4855e88f830842102141d452c3deeb937efff9f3378cd50bbde0543b77bbc6df6fc0e0addbf5578c52103948d24a9622cb14b198aed0739783d7c03d74c32c05780a86b43429c65679def53ae68",
    "5b21022944b3c8d83d743e83e12b8a5654a9a48d741bae19f0498dd390b038502666b021023927b2c7716358d4f46cc1f8ca753f35818f593bd62ab2e19137522c35d671b721024c726615f549b02ea1db0fd2ab1973bfe20c296aa4ef14f8979da609b88caa6121027d8facb30d8648cbcea166f6094d1631053800332469827f90c5338368e48e3d2102a5ffc6da600cf25ebc01c4dfbe8ba220a0d35615db1a2c306ba06a355c34902b2102ab5b0b8e18d0dd7933176bbe0d0883a360ade9f45403accf7bdfa9c5439514f62102b0ffa5f8a78dd356afecc371bd826acb3671d8627561289d89a627a121a9c2272102b3278e89c3d5c19cbe5956d4a70a93a3bb0da4e8598d13c034ec5d50cce06b542102b43e4bd6c19b984ef36db6a622eea478f955676fe26786c3141b001e8f91402c2102e5a7aedc7889cad6f14d4534b546cd55d1fde039b0dd1ccb4c58ceac246327f72102e5fe77826e39e69421a0b478419a984c45d94228702aeac2acd540839fd034742103595fa9737e2720b9f600926f2350b4b1315b2248b76ef27fa287022609caead82103f2bbf79daf114617f35e719c46790c301ade558c247ced15f745a40db256a1e6210226e364b607a78b600e46d376ac8848f0c3dd44a41602af46e210f5aac755f5812103fec9f90addc21da7fa30da1568c8a5432a2372e89e8616468d55196c6ea2a7a25fae736402c00fb269522102aef2b8a39966d49183fdddaefdc75af6d81ea6d16f7aba745cc4855e88f830842102141d452c3deeb937efff9f3378cd50bbde0543b77bbc6df6fc0e0addbf5578c52103948d24a9622cb14b198aed0739783d7c03d74c32c05780a86b43429c65679def53ae68"
  ],
  "pegged_asset": "2532cc1cff7278b0e3b7d09c8153d7386e61a858c07b8924ea519fd08c42c00d",
  "min_peg_diff": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
  "parent_blockhash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
  "parent_chain_has_pow": true,
  "enforce_pak": true,
  "pegin_confirmation_depth": 8
}
@philippem philippem changed the title liquid native asset id for regtest networks is static liquid native asset id for regtest networks is static, must be retrieved from sidechain daemon Feb 7, 2025
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

1 participant