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

how can I get msg_hash? #251

Open
fishTsai20 opened this issue Sep 12, 2024 · 1 comment
Open

how can I get msg_hash? #251

fishTsai20 opened this issue Sep 12, 2024 · 1 comment

Comments

@fishTsai20
Copy link

method 1:
Below is how ton-index(https://github.com/toncenter/ton-index-worker) get msg-hash

trans.r1 struct:
struct Record {
    typedef Transaction_aux type_class;
    Ref<CellSlice> in_msg;  	// in_msg : Maybe ^(Message Any)
    Ref<CellSlice> out_msgs;  	// out_msgs : HashmapE 15 ^(Message Any)
    Record() = default;
    Record(Ref<CellSlice> _in_msg, Ref<CellSlice> _out_msgs) : in_msg(std::move(_in_msg)), out_msgs(std::move(_out_msgs)) {}
  };

Ref<Cell> CellSlice::prefetch_ref(unsigned offset) const {
  if (offset < size_refs()) {
    auto ref_id = refs_st + offset;
    auto res = cell->get_ref(ref_id)->virtualize(child_virt());
    if (!tree_node.empty()) {
      res = UsageCell::create(std::move(res), tree_node.create_child(ref_id));
    }
    return res;
  } else {
    return Ref<Cell>{};
  }
}

auto msg = trans.r1.in_msg->prefetch_ref();
tx_info.in_msg_hash = msg->get_hash().bits();

method 2:
Below is how I get msg-hash with your code

message tlb.Message
msgCell, err := tlb.ToCell(message)
msg.Hash = msgCell.Hash()
hash = base64.StdEncoding.EncodeToString(msg.Hash)

The msg-hash generated by these two methods is different, how can I use your code to get the same msg-hash as ton-index-worker?

@byte1023
Copy link

i wanna also know how this tx hash is figured out. plz tell me if u have solved this problem. thank u

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