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

/transfers endpoint returns wrong address when inscription moved again #16

Open
therunesdev opened this issue Feb 20, 2024 · 3 comments

Comments

@therunesdev
Copy link

The /transfers endpoint returns a list of inscription IDs moved in a given block, very useful. But also returns addresses where inscription moved to. Also very useful. But that address wrong when inscription has moved again later, because

 async fn inscriptionids_from_height_inner(
    chain: Chain,
    index: Arc<Index>,
    inscription_ids: Vec<InscriptionId>,
  ) -> ServerResult<String> {
    task::block_in_place(|| {
      let mut ret = String::from("");
      let mut tx_cache = HashMap::new();
      for inscription_id in inscription_ids {
        let satpoint = index
          .get_inscription_satpoint_by_id(inscription_id)?
          .ok_or_not_found(|| format!("inscription {inscription_id}"))?;
        let address = Self::outpoint_to_address(chain, &index, satpoint.outpoint, &mut tx_cache)?;
        ret += &format!("{} {}\n", inscription_id, address);
      }

      Ok(ret)
    })

always look at current satpoint of inscription id. So I think is misleading to return address.

@therunesdev
Copy link
Author

This is especially tricky because it means /transfers endpoint returns the correct endpoint when called right after block mined, but returns wrong result when called later after other transfer happened.

@jhinii
Copy link

jhinii commented Feb 20, 2024

add the block as a pair to the id.

@dooglus
Copy link

dooglus commented Feb 21, 2024

The /transfers endpoint lists the inscriptions that moved in each block, and the address that the inscription is currently at.

Sometimes an inscription moves twice in the same block. In that case (as in all cases) the /transfers endpoint will show the address that the inscription is currently at.

This is useful for sites that want to track the current location of inscriptions. They can use /transfers to get a list of the inscriptions that need updating in their db.

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

3 participants