Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Script modulize #65

Open
u2 opened this issue Mar 7, 2019 · 0 comments
Open

Script modulize #65

u2 opened this issue Mar 7, 2019 · 0 comments

Comments

@u2
Copy link
Contributor

u2 commented Mar 7, 2019

In the scripts/bitcoin folder, there are 8 different sighash combination, but there are many duplicated codes in the script.

All the sighash without the anyonecanpay modifier, the sha3 of inputs are the same:

tx["inputs"].each_with_index do |input, i|
  sha3.update(input["hash"])
  sha3.update(input["index"].to_s)
  sha3.update(CKB.load_script_hash(i, CKB::Source::INPUT, CKB::Category::LOCK))
end

All the sighash with the anyonecanpay modifier:

out_point = CKB.load_input_out_point(0, CKB::Source::CURRENT)
sha3.update(out_point["hash"])
sha3.update(out_point["index"].to_s)
sha3.update(CKB::CellField.new(CKB::Source::CURRENT, 0, CKB::CellField::LOCK_HASH).readall)

Any good way to optimize it? If we want to develop some complicated scripts, like the contract for the layer2 protocol or implement EVM by ruby, it's better to modulize it. It's a universal problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant